@chevre/domain 26.0.0-alpha.36 → 26.0.0-alpha.38

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.
@@ -1,7 +1,7 @@
1
1
  import { Connection } from 'mongoose';
2
2
  import { factory } from '../../factory';
3
3
  import { IModel as IActionModel } from '../mongoose/schemas/action';
4
- import { IModel as IActionRecipeModel } from '../mongoose/schemas/actionRecipe';
4
+ import { ActionRecipeRepo, IActionRecipe, IRecipeAsActionAttributes } from './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
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 {
@@ -14,40 +14,29 @@ export interface ICancelActionAction {
14
14
  typeOf: 'Task';
15
15
  };
16
16
  }
17
- export type IActionRecipe<T extends factory.recipe.RecipeCategory> = T extends factory.recipe.RecipeCategory.checkMovieTicket ? factory.action.check.paymentMethod.movieTicket.IRecipe : T extends factory.recipe.RecipeCategory.payCreditCard ? factory.action.trade.pay.IPayCreditCardRecipe : T extends factory.recipe.RecipeCategory.payMovieTicket ? factory.action.trade.pay.IPayMovieTicketRecipe : T extends factory.recipe.RecipeCategory.publishPaymentUrl ? factory.action.accept.pay.IRecipe : T extends factory.recipe.RecipeCategory.refundCreditCard ? factory.action.trade.refund.IRefundCreditCardRecipe : T extends factory.recipe.RecipeCategory.refundMovieTicket ? factory.action.trade.refund.IRefundMovieTicketRecipe : T extends factory.recipe.RecipeCategory.authorizeInvoice ? factory.action.authorize.invoice.IAuthorizeInvoiceRecipe : T extends factory.recipe.RecipeCategory.authorizeInvoice3ds ? factory.action.authorize.invoice.IAuthorizeInvoice3dsRecipe : T extends factory.recipe.RecipeCategory.acceptCOAOffer ? factory.action.accept.coaOffer.IRecipe : T extends factory.recipe.RecipeCategory.confirmCOAReserve ? factory.action.interact.confirm.reservation.IConfirmCOAReserveRecipe : T extends factory.recipe.RecipeCategory.cancelPendingCOAReserve ? factory.action.cancel.coaReserve.ICancelPendingCOAReserveRecipe : T extends factory.recipe.RecipeCategory.returnCOAReserve ? factory.action.transfer.returnAction.reserveTransaction.IReturnCOAReserveRecipe : T extends factory.recipe.RecipeCategory.sendEmailMessage ? factory.action.transfer.send.message.email.IRecipe : never;
18
- export type IRecipeAsDocument = factory.recipe.IRecipe & {
19
- recipeFor: {
20
- id: string;
21
- typeOf: factory.actionType;
22
- };
23
- dateCreated: Date;
24
- dateModified?: Date;
25
- };
26
- export type IRecipeAsActionAttributes<T extends factory.recipe.RecipeCategory> = Pick<IActionRecipe<T>, 'project' | 'recipeCategory' | 'step' | 'typeOf'>;
27
- export type IMinimizedPurchaseNumberAuthResult = Pick<factory.action.check.paymentMethod.movieTicket.IPurchaseNumberAuthResult, 'mkknmiNumSum' | 'resultInfo' | 'ykknmiNumSum'> & {
28
- knyknrNoInfoOut: Omit<factory.action.check.paymentMethod.movieTicket.IPurchaseNumberInfo, 'ykknInfo' | 'mkknInfo'>[] | null;
29
- };
17
+ export { IActionRecipe };
30
18
  export type IKeyOfProjection = keyof IAction<factory.actionType> | keyof IAction<factory.actionType.AuthorizeAction> | keyof IAction<factory.actionType.ReplaceAction> | 'identifier';
31
19
  export declare const AVAILABLE_PROJECT_FIELDS: IKeyOfProjection[];
32
20
  /**
33
21
  * アクション状態管理リポジトリ
34
22
  */
35
- export declare class ActionProcessRepo<TAction extends IAction<factory.actionType>, TActionRecipe extends IActionRecipe<factory.recipe.RecipeCategory>> {
23
+ export declare class ActionProcessRepo<TAction extends IAction<factory.actionType>, TActionRecipe extends IActionRecipe<factory.recipe.RecipeCategory>> extends ActionRecipeRepo<TActionRecipe> {
36
24
  protected readonly actionModel: IActionModel;
37
- protected readonly actionRecipeModel: IActionRecipeModel;
38
25
  constructor(connection: Connection);
39
26
  static CREATE_MONGO_CONDITIONS(params: factory.action.ISearchConditions): any[];
40
27
  /**
41
28
  * アクション開始
42
29
  */
43
- start<T extends TAction['typeOf']>(attributes: factory.action.IAttributes<T, any, any>, // eslint-disable-line @typescript-eslint/no-explicit-any
44
- options?: {
30
+ start<T extends TAction['typeOf']>(attributes: factory.action.IAttributes<T, any, any> & {
31
+ expires?: Date;
32
+ }, options?: {
45
33
  recipe?: IRecipeAsActionAttributes<TActionRecipe['recipeCategory']>;
46
34
  }): Promise<Pick<IAction<T>, 'id' | 'typeOf' | 'startDate'>>;
47
35
  completeWithVoid(params: {
48
36
  typeOf: TAction['typeOf'];
49
37
  id: string;
50
38
  result: any;
39
+ expires?: Date;
51
40
  recipe?: IRecipeAsActionAttributes<TActionRecipe['recipeCategory']>;
52
41
  }): Promise<void>;
53
42
  /**
@@ -65,28 +54,9 @@ export declare class ActionProcessRepo<TAction extends IAction<factory.actionTyp
65
54
  typeOf: TAction['typeOf'];
66
55
  id: string;
67
56
  error: Error | Error[] | unknown;
57
+ expires?: Date;
68
58
  recipe?: IRecipeAsActionAttributes<TActionRecipe['recipeCategory']>;
69
59
  }): Promise<void>;
70
- /**
71
- * 一定期間ActiveActionStatusのアクションをFailedActionStatusにする
72
- */
73
- giveUpStartDatePassedCertainPeriod(params: {
74
- id?: {
75
- $eq?: string;
76
- };
77
- error: any;
78
- startDate: {
79
- $lt: Date;
80
- };
81
- }): Promise<import("mongoose").UpdateWriteOpResult>;
82
- findRecipeByAction<T extends TActionRecipe['recipeCategory']>(params: {
83
- project: {
84
- id: string;
85
- };
86
- recipeFor: {
87
- id: string;
88
- };
89
- }): Promise<Pick<IActionRecipe<T>, 'step' | 'recipeCategory'> | null>;
90
60
  findById(params: {
91
61
  typeOf: TAction['typeOf'];
92
62
  id: string;
@@ -140,5 +110,4 @@ export declare class ActionProcessRepo<TAction extends IAction<factory.actionTyp
140
110
  };
141
111
  sort?: factory.action.ISortOrder;
142
112
  }): Promise<TAction[]>;
143
- protected upsertRecipe(savingRecipe: Pick<IRecipeAsDocument, 'project' | 'recipeCategory' | 'recipeFor' | 'step' | 'typeOf'>): Promise<void>;
144
113
  }
@@ -4,8 +4,8 @@ exports.ActionProcessRepo = exports.AVAILABLE_PROJECT_FIELDS = void 0;
4
4
  const factory_1 = require("../../factory");
5
5
  const settings_1 = require("../../settings");
6
6
  const action_1 = require("../mongoose/schemas/action");
7
- const actionRecipe_1 = require("../mongoose/schemas/actionRecipe");
8
7
  const unknown2actionError_1 = require("./unknown2actionError");
8
+ const actionRecipe_1 = require("./actionRecipe");
9
9
  exports.AVAILABLE_PROJECT_FIELDS = [
10
10
  'project',
11
11
  'actionStatus',
@@ -26,16 +26,18 @@ exports.AVAILABLE_PROJECT_FIELDS = [
26
26
  'cancelAction',
27
27
  'about',
28
28
  'identifier',
29
+ 'expires'
29
30
  ];
31
+ const DEFAULT_EXPIRE_AFTER_SECONDS = 17280000; // 200 days
32
+ const RECIPE_DEFAULT_EXPIRE_AFTER_SECONDS = 17280000; // 200 days
30
33
  /**
31
34
  * アクション状態管理リポジトリ
32
35
  */
33
- class ActionProcessRepo {
36
+ class ActionProcessRepo extends actionRecipe_1.ActionRecipeRepo {
34
37
  actionModel;
35
- actionRecipeModel;
36
38
  constructor(connection) {
39
+ super(connection);
37
40
  this.actionModel = connection.model(action_1.modelName, (0, action_1.createSchema)());
38
- this.actionRecipeModel = connection.model(actionRecipe_1.modelName, (0, actionRecipe_1.createSchema)());
39
41
  }
40
42
  static CREATE_MONGO_CONDITIONS(params) {
41
43
  const andConditions = []; // eslint-disable-line @typescript-eslint/no-explicit-any
@@ -436,15 +438,16 @@ class ActionProcessRepo {
436
438
  /**
437
439
  * アクション開始
438
440
  */
439
- async start(
440
- // public async start<T extends Exclude<TAction['typeOf'], factory.actionType.AcceptAction>>(
441
- attributes, // eslint-disable-line @typescript-eslint/no-explicit-any
442
- options) {
441
+ async start(attributes, options) {
443
442
  const startDate = new Date();
443
+ const expires = (attributes.expires instanceof Date)
444
+ ? attributes.expires
445
+ : new Date(startDate.getTime() + DEFAULT_EXPIRE_AFTER_SECONDS * 1000);
444
446
  const creatingAction = {
445
447
  ...attributes,
446
448
  actionStatus: factory_1.factory.actionStatusType.ActiveActionStatus,
447
- startDate
449
+ startDate,
450
+ expires
448
451
  };
449
452
  // reimplemnt with insertMany(2024-08-29~)
450
453
  const result = await this.actionModel.insertMany(creatingAction, { rawResult: true });
@@ -455,13 +458,17 @@ class ActionProcessRepo {
455
458
  // add recipe(2024-06-09~)
456
459
  const savingRecipe = options?.recipe;
457
460
  if (savingRecipe?.typeOf === 'Recipe') {
458
- await this.upsertRecipe({ ...savingRecipe, recipeFor: { id, typeOf: creatingAction.typeOf } });
461
+ await this.upsertRecipe({ ...savingRecipe, recipeFor: { id, typeOf: creatingAction.typeOf }, expires });
459
462
  }
460
463
  return { id, startDate, typeOf: creatingAction.typeOf };
461
464
  }
462
465
  async completeWithVoid(params) {
466
+ const endDate = new Date();
467
+ const recipeExpires = (params.expires instanceof Date)
468
+ ? params.expires
469
+ : new Date(endDate.getTime() + RECIPE_DEFAULT_EXPIRE_AFTER_SECONDS * 1000);
463
470
  if (params.recipe?.typeOf === 'Recipe') {
464
- await this.upsertRecipe({ ...params.recipe, recipeFor: { id: params.id, typeOf: params.typeOf } });
471
+ await this.upsertRecipe({ ...params.recipe, recipeFor: { id: params.id, typeOf: params.typeOf }, expires: recipeExpires });
465
472
  }
466
473
  const doc = await this.actionModel.findOneAndUpdate({
467
474
  _id: { $eq: params.id },
@@ -470,7 +477,7 @@ class ActionProcessRepo {
470
477
  $set: {
471
478
  actionStatus: factory_1.factory.actionStatusType.CompletedActionStatus,
472
479
  result: params.result,
473
- endDate: new Date()
480
+ endDate
474
481
  }
475
482
  }, { new: false, projection: { _id: 1 } })
476
483
  .lean()
@@ -521,14 +528,15 @@ class ActionProcessRepo {
521
528
  * アクション失敗
522
529
  */
523
530
  async giveUp(params) {
524
- // const actionError: IActionError | IActionError[] = (Array.isArray(params.error))
525
- // ? params.error.map((e) => ({ ...e, message: e.message, name: e.name }))
526
- // : { ...params.error, message: params.error.message, name: params.error.name };
531
+ const endDate = new Date();
532
+ const recipeExpires = (params.expires instanceof Date)
533
+ ? params.expires
534
+ : new Date(endDate.getTime() + RECIPE_DEFAULT_EXPIRE_AFTER_SECONDS * 1000);
527
535
  const actionError = Array.isArray(params.error)
528
536
  ? params.error.map(unknown2actionError_1.unknown2actionError)
529
537
  : (0, unknown2actionError_1.unknown2actionError)(params.error);
530
538
  if (params.recipe?.typeOf === 'Recipe') {
531
- await this.upsertRecipe({ ...params.recipe, recipeFor: { id: params.id, typeOf: params.typeOf } });
539
+ await this.upsertRecipe({ ...params.recipe, recipeFor: { id: params.id, typeOf: params.typeOf }, expires: recipeExpires });
532
540
  }
533
541
  const doc = await this.actionModel.findOneAndUpdate({
534
542
  typeOf: { $eq: params.typeOf },
@@ -537,7 +545,7 @@ class ActionProcessRepo {
537
545
  $set: {
538
546
  actionStatus: factory_1.factory.actionStatusType.FailedActionStatus,
539
547
  error: actionError,
540
- endDate: new Date()
548
+ endDate
541
549
  }
542
550
  }, { new: true, projection: { _id: 1 } })
543
551
  .lean()
@@ -546,36 +554,6 @@ class ActionProcessRepo {
546
554
  throw new factory_1.factory.errors.NotFound(this.actionModel.modelName);
547
555
  }
548
556
  }
549
- /**
550
- * 一定期間ActiveActionStatusのアクションをFailedActionStatusにする
551
- */
552
- async giveUpStartDatePassedCertainPeriod(params) {
553
- return this.actionModel.updateMany({
554
- actionStatus: { $eq: factory_1.factory.actionStatusType.ActiveActionStatus },
555
- // 一定期間過ぎたもの
556
- startDate: { $lt: params.startDate.$lt },
557
- ...(typeof params.id?.$eq === 'string') ? { _id: { $eq: params.id.$eq } } : undefined
558
- }, {
559
- actionStatus: factory_1.factory.actionStatusType.FailedActionStatus,
560
- error: params.error,
561
- endDate: new Date()
562
- })
563
- .exec();
564
- }
565
- async findRecipeByAction(params) {
566
- return this.actionRecipeModel.findOne({
567
- 'project.id': { $eq: params.project.id },
568
- 'recipeFor.id': { $eq: params.recipeFor.id }
569
- }, { step: 1, recipeCategory: 1 }
570
- // { lean: true }
571
- )
572
- .lean()
573
- .exec();
574
- // if (result === null) {
575
- // throw new factory.errors.NotFound(this.actionRecipeModel.modelName);
576
- // }
577
- // return result;
578
- }
579
557
  async findById(params, inclusion, exclusion) {
580
558
  let positiveProjectionFields = exports.AVAILABLE_PROJECT_FIELDS;
581
559
  if (Array.isArray(inclusion) && inclusion.length > 0) {
@@ -733,26 +711,5 @@ class ActionProcessRepo {
733
711
  .lean()
734
712
  .exec();
735
713
  }
736
- async upsertRecipe(savingRecipe) {
737
- const dateModified = new Date();
738
- const { typeOf, project, recipeCategory, recipeFor, step } = savingRecipe;
739
- const filter = {
740
- 'recipeFor.id': { $eq: recipeFor.id }
741
- };
742
- const setOnInsert = {
743
- project, typeOf, recipeCategory, recipeFor,
744
- dateCreated: dateModified
745
- };
746
- const setKeys = { step, dateModified };
747
- const update = {
748
- $setOnInsert: setOnInsert,
749
- $set: setKeys
750
- };
751
- await this.actionRecipeModel.updateOne(filter, update, {
752
- upsert: true
753
- // includeResultMetadata: true
754
- })
755
- .exec();
756
- }
757
714
  }
758
715
  exports.ActionProcessRepo = ActionProcessRepo;
@@ -0,0 +1,32 @@
1
+ import { Connection } from 'mongoose';
2
+ import { factory } from '../../factory';
3
+ import { IModel as IActionRecipeModel } from '../mongoose/schemas/actionRecipe';
4
+ export type IActionRecipe<T extends factory.recipe.RecipeCategory> = T extends factory.recipe.RecipeCategory.checkMovieTicket ? factory.action.check.paymentMethod.movieTicket.IRecipe : T extends factory.recipe.RecipeCategory.payCreditCard ? factory.action.trade.pay.IPayCreditCardRecipe : T extends factory.recipe.RecipeCategory.payMovieTicket ? factory.action.trade.pay.IPayMovieTicketRecipe : T extends factory.recipe.RecipeCategory.publishPaymentUrl ? factory.action.accept.pay.IRecipe : T extends factory.recipe.RecipeCategory.refundCreditCard ? factory.action.trade.refund.IRefundCreditCardRecipe : T extends factory.recipe.RecipeCategory.refundMovieTicket ? factory.action.trade.refund.IRefundMovieTicketRecipe : T extends factory.recipe.RecipeCategory.authorizeInvoice ? factory.action.authorize.invoice.IAuthorizeInvoiceRecipe : T extends factory.recipe.RecipeCategory.authorizeInvoice3ds ? factory.action.authorize.invoice.IAuthorizeInvoice3dsRecipe : T extends factory.recipe.RecipeCategory.acceptCOAOffer ? factory.action.accept.coaOffer.IRecipe : T extends factory.recipe.RecipeCategory.confirmCOAReserve ? factory.action.interact.confirm.reservation.IConfirmCOAReserveRecipe : T extends factory.recipe.RecipeCategory.cancelPendingCOAReserve ? factory.action.cancel.coaReserve.ICancelPendingCOAReserveRecipe : T extends factory.recipe.RecipeCategory.returnCOAReserve ? factory.action.transfer.returnAction.reserveTransaction.IReturnCOAReserveRecipe : T extends factory.recipe.RecipeCategory.sendEmailMessage ? factory.action.transfer.send.message.email.IRecipe : never;
5
+ export type IRecipeAsDocument = factory.recipe.IRecipe & {
6
+ recipeFor: {
7
+ id: string;
8
+ typeOf: factory.actionType;
9
+ };
10
+ dateCreated: Date;
11
+ dateModified?: Date;
12
+ expires: Date;
13
+ };
14
+ export type IRecipeAsActionAttributes<T extends factory.recipe.RecipeCategory> = Pick<IActionRecipe<T>, 'project' | 'recipeCategory' | 'step' | 'typeOf'>;
15
+ /**
16
+ * アクションレシピリポジトリ
17
+ */
18
+ export declare class ActionRecipeRepo<TActionRecipe extends IActionRecipe<factory.recipe.RecipeCategory>> {
19
+ protected readonly actionRecipeModel: IActionRecipeModel;
20
+ protected constructor(connection: Connection);
21
+ findRecipeByAction<T extends TActionRecipe['recipeCategory']>(params: {
22
+ project: {
23
+ id: string;
24
+ };
25
+ recipeFor: {
26
+ id: string;
27
+ };
28
+ }): Promise<Pick<IActionRecipe<T>, 'step' | 'recipeCategory'> | null>;
29
+ upsertRecipe(savingRecipe: Pick<IRecipeAsDocument, 'project' | 'recipeCategory' | 'recipeFor' | 'step' | 'typeOf'> & {
30
+ expires: Date;
31
+ }): Promise<void>;
32
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ActionRecipeRepo = void 0;
4
+ const actionRecipe_1 = require("../mongoose/schemas/actionRecipe");
5
+ /**
6
+ * アクションレシピリポジトリ
7
+ */
8
+ class ActionRecipeRepo {
9
+ actionRecipeModel;
10
+ constructor(connection) {
11
+ this.actionRecipeModel = connection.model(actionRecipe_1.modelName, (0, actionRecipe_1.createSchema)());
12
+ }
13
+ async findRecipeByAction(params) {
14
+ return this.actionRecipeModel.findOne({
15
+ 'project.id': { $eq: params.project.id },
16
+ 'recipeFor.id': { $eq: params.recipeFor.id }
17
+ }, { step: 1, recipeCategory: 1 }
18
+ // { lean: true }
19
+ )
20
+ .lean()
21
+ .exec();
22
+ // if (result === null) {
23
+ // throw new factory.errors.NotFound(this.actionRecipeModel.modelName);
24
+ // }
25
+ // return result;
26
+ }
27
+ async upsertRecipe(savingRecipe) {
28
+ const dateModified = new Date();
29
+ const { typeOf, project, recipeCategory, recipeFor, step, expires } = savingRecipe;
30
+ const filter = {
31
+ 'recipeFor.id': { $eq: recipeFor.id }
32
+ };
33
+ const setOnInsert = {
34
+ project, typeOf, recipeCategory, recipeFor,
35
+ dateCreated: dateModified,
36
+ expires // 必須化(2026-08-16~)
37
+ };
38
+ const setKeys = { step, dateModified };
39
+ const update = {
40
+ $setOnInsert: setOnInsert,
41
+ $set: setKeys
42
+ };
43
+ await this.actionRecipeModel.updateOne(filter, update, {
44
+ upsert: true
45
+ // includeResultMetadata: true
46
+ })
47
+ .exec();
48
+ }
49
+ }
50
+ exports.ActionRecipeRepo = ActionRecipeRepo;
@@ -27,6 +27,7 @@ const schemaDefinition = {
27
27
  cancelAction: mongoose_1.SchemaTypes.Mixed, // add(2024-05-26~)
28
28
  about: mongoose_1.SchemaTypes.Mixed, // add(2025-01-22~)
29
29
  identifier: mongoose_1.SchemaTypes.Mixed, // add(2025-02-06~)
30
+ expires: Date // support(2026-08-16~)
30
31
  // replacer: SchemaTypes.Mixed, // discontinue(2026-08-15~)
31
32
  // targetCollection: SchemaTypes.Mixed, // discontinue(2026-08-15~)
32
33
  // target: SchemaTypes.Mixed, // discontinue(2026-08-15~)
@@ -56,6 +57,16 @@ const schemaOptions = {
56
57
  }
57
58
  };
58
59
  const indexes = [
60
+ [
61
+ { expires: 1 },
62
+ {
63
+ name: 'expires',
64
+ expireAfterSeconds: 0,
65
+ partialFilterExpression: {
66
+ expires: { $exists: true }
67
+ }
68
+ }
69
+ ],
59
70
  [
60
71
  { startDate: 1 },
61
72
  {
@@ -7,6 +7,7 @@ type IDocType = factory.recipe.IRecipe & {
7
7
  };
8
8
  dateCreated?: Date;
9
9
  dateModified?: Date;
10
+ expires?: Date;
10
11
  };
11
12
  type IModel = Model<IDocType, Record<string, never>, Record<string, never>, IVirtuals>;
12
13
  type ISchemaDefinition = SchemaDefinition<IDocType>;
@@ -29,7 +29,8 @@ const schemaDefinition = {
29
29
  type: Date,
30
30
  required: true
31
31
  },
32
- dateModified: Date
32
+ dateModified: Date,
33
+ expires: Date // support(2026-08-16~)
33
34
  };
34
35
  const schemaOptions = {
35
36
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -56,6 +57,16 @@ const schemaOptions = {
56
57
  }
57
58
  };
58
59
  const indexes = [
60
+ [
61
+ { expires: 1 },
62
+ {
63
+ name: 'expires',
64
+ expireAfterSeconds: 0,
65
+ partialFilterExpression: {
66
+ expires: { $exists: true }
67
+ }
68
+ }
69
+ ],
59
70
  [
60
71
  { dateCreated: 1 },
61
72
  {
@@ -1,13 +1,8 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.createSendEmailMessageTaskIfNotExist = createSendEmailMessageTaskIfNotExist;
7
- const debug_1 = __importDefault(require("debug"));
8
4
  const util_1 = require("util");
9
5
  const factory_1 = require("../../../../factory");
10
- const debug = (0, debug_1.default)('chevre-domain:service:order');
11
6
  function createSendEmailMessageTaskIfNotExist(params) {
12
7
  return async (repos) => {
13
8
  const sendEmailMessageActions = params.sendEmailMessage;
@@ -19,12 +14,10 @@ function createSendEmailMessageTaskIfNotExist(params) {
19
14
  about: { identifier: { $eq: factory_1.factory.creativeWork.message.email.AboutIdentifier.OnOrderSent } },
20
15
  mainEntity: { orderNumber: { $eq: params.order.orderNumber } }
21
16
  }, ['identifier'])).shift();
22
- debug('createSendEmailMessageTaskIfNotExist: message4order:', JSON.stringify(message4order));
23
17
  if (typeof message4order?.identifier === 'string') {
24
18
  // 取引のpotentialActionsが存在する間は、メッセージ識別子が想定通りか確認する
25
19
  const messageIdentifierByTransaction = sendEmailMessageActions?.at(0)?.object.identifier;
26
20
  if (typeof messageIdentifierByTransaction === 'string') {
27
- debug('createSendEmailMessageTaskIfNotExist: identifier matched?', message4order.identifier, messageIdentifierByTransaction);
28
21
  if (message4order.identifier !== messageIdentifierByTransaction) {
29
22
  throw new factory_1.factory.errors.Internal(`message identifier not matched. ${message4order.identifier} ${messageIdentifierByTransaction}`);
30
23
  }
@@ -44,7 +37,6 @@ function createSendEmailMessageTaskIfNotExist(params) {
44
37
  typeOf: factory_1.factory.creativeWorkType.EmailMessage
45
38
  },
46
39
  agent: params.order.project,
47
- recipient: { typeOf: params.order.customer.typeOf, id: params.order.customer.id },
48
40
  purpose: simpleOrder
49
41
  };
50
42
  const sendEmailMessageTask = {
@@ -123,8 +123,6 @@ function createOnOrderReturnedTasksByTransaction(params) {
123
123
  const simpleOrder = {
124
124
  typeOf: params.order.typeOf,
125
125
  orderNumber: params.order.orderNumber,
126
- // price: params.order.price,
127
- // priceCurrency: params.order.priceCurrency,
128
126
  orderDate: params.order.orderDate
129
127
  };
130
128
  sendEmailMessageAttributes.forEach((s) => {
@@ -133,8 +131,6 @@ function createOnOrderReturnedTasksByTransaction(params) {
133
131
  typeOf: factory_1.factory.actionType.SendAction,
134
132
  object: s.object,
135
133
  agent: params.order.project,
136
- recipient: { typeOf: params.order.customer.typeOf, id: params.order.customer.id },
137
- // potentialActions: {}, // discontinue(2024-06-25~)
138
134
  purpose: simpleOrder
139
135
  };
140
136
  const sendEmailMessageTask = {
@@ -3,7 +3,6 @@ import type { ActionRepo } from '../../repo/action';
3
3
  import type { OrderRepo } from '../../repo/order';
4
4
  import type { SettingRepo } from '../../repo/setting';
5
5
  import type { TaskRepo } from '../../repo/task';
6
- import type { PlaceOrderRepo } from '../../repo/transaction/placeOrder';
7
6
  import { factory } from '../../factory';
8
7
  interface ISendOrderRepos {
9
8
  acceptedOffer: AcceptedOfferRepo;
@@ -11,7 +10,6 @@ interface ISendOrderRepos {
11
10
  order: OrderRepo;
12
11
  setting: SettingRepo;
13
12
  task: TaskRepo;
14
- placeOrder: PlaceOrderRepo;
15
13
  }
16
14
  type ISendOperation<T> = (repos: ISendOrderRepos) => Promise<T>;
17
15
  /**
@@ -1,14 +1,9 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.sendOrder = sendOrder;
7
- const debug_1 = __importDefault(require("debug"));
8
4
  // import { createOwnershipInfosFromOrder } from '../delivery/factory';
9
5
  const onOrderStatusChanged_1 = require("./onOrderStatusChanged");
10
6
  const factory_1 = require("../../factory");
11
- const debug = (0, debug_1.default)('chevre-domain:service:order');
12
7
  /**
13
8
  * 注文を配送する
14
9
  */
@@ -32,11 +27,6 @@ function sendOrder(params) {
32
27
  try {
33
28
  const orderNumber = params.object.orderNumber;
34
29
  const confirmationNumber = params.object.confirmationNumber;
35
- // const placeOrderTransaction = await findPlaceOrderTransaction({
36
- // project: { id: params.project.id },
37
- // confirmationNumber,
38
- // orderNumber
39
- // })(repos);
40
30
  // 注文取得
41
31
  let order = await repos.order.projectFieldsByOrderNumber({
42
32
  orderNumber,
@@ -66,12 +56,9 @@ function sendOrder(params) {
66
56
  agent: (typeof params.agent?.typeOf === 'string') ? params.agent : order.project,
67
57
  object: sendOrderObject,
68
58
  project: order.project,
69
- recipient: { id: order.customer.id, typeOf: order.customer.typeOf },
70
59
  typeOf: factory_1.factory.actionType.SendAction
71
60
  };
72
61
  const action = await repos.action.start(sendOrderActionAttributes);
73
- // let creatingOwnershipInfos: IOwnershipInfo[] = [];
74
- const createdOwnershipInfos = [];
75
62
  let allOffersDelivered = false;
76
63
  let acceptedOffers;
77
64
  // 所有権管理はひとまず廃止(2026-08-10~)
@@ -91,22 +78,8 @@ function sendOrder(params) {
91
78
  project: { id: { $eq: order.project.id } }
92
79
  });
93
80
  acceptedOffers = searchSlicedAcceptedOffersResult.acceptedOffers;
94
- debug('delivering...', order.orderNumber, params.object.acceptedOffers, 'offerIndexBase:', offerIndexBase);
95
81
  // 所有権管理はひとまず廃止(2026-08-10~)
96
82
  // if (createOwnerships) {
97
- // creatingOwnershipInfos = createOwnershipInfosFromOrder({
98
- // order: { ...order, acceptedOffers },
99
- // offerIndexBase
100
- // });
101
- // createdOwnershipInfos = await Promise.all(creatingOwnershipInfos.map(async (creatingOwnershipInfo) => {
102
- // const { id } = await repos.ownershipInfo.createIfNotExistByIdentifier(creatingOwnershipInfo);
103
- // return {
104
- // id,
105
- // ...(typeof creatingOwnershipInfo.identifier === 'string')
106
- // ? { identifier: creatingOwnershipInfo.identifier }
107
- // : undefined
108
- // };
109
- // }));
110
83
  // }
111
84
  if (acceptedOffers.length === 0) {
112
85
  order = await repos.order.changeStatus({
@@ -127,9 +100,8 @@ function sendOrder(params) {
127
100
  }
128
101
  throw error;
129
102
  }
130
- const result = createdOwnershipInfos;
103
+ const result = [];
131
104
  await repos.action.completeWithVoid({ typeOf: sendOrderActionAttributes.typeOf, id: action.id, result: result });
132
- debug('allOffersDelivered?:', allOffersDelivered, order.orderNumber);
133
105
  if (params.useOnOrderStatusChanged) {
134
106
  if (allOffersDelivered) {
135
107
  await (0, onOrderStatusChanged_1.onOrderDelivered)({
@@ -293,8 +293,6 @@ function onRefund(params) {
293
293
  const simpleOrder = {
294
294
  typeOf: order.typeOf,
295
295
  orderNumber: order.orderNumber,
296
- // price: order.price,
297
- // priceCurrency: order.priceCurrency,
298
296
  orderDate: order.orderDate
299
297
  };
300
298
  sendEmailMessageByPotentialActions.forEach((s) => {
@@ -303,7 +301,6 @@ function onRefund(params) {
303
301
  typeOf: factory_1.factory.actionType.SendAction,
304
302
  object: s.object,
305
303
  agent: refundActionAttributes.project,
306
- recipient: { typeOf: order.customer.typeOf, id: order.customer.id },
307
304
  purpose: simpleOrder
308
305
  };
309
306
  const sendEmailMessageTask = {
@@ -5,10 +5,8 @@ const factory_1 = require("../../factory");
5
5
  const acceptedOffer_1 = require("../../repo/acceptedOffer");
6
6
  const action_1 = require("../../repo/action");
7
7
  const order_1 = require("../../repo/order");
8
- // import { OwnershipInfoRepo } from '../../repo/ownershipInfo';
9
8
  const setting_1 = require("../../repo/setting");
10
9
  const task_1 = require("../../repo/task");
11
- const placeOrder_1 = require("../../repo/transaction/placeOrder");
12
10
  const sendOrder_1 = require("../order/sendOrder");
13
11
  /**
14
12
  * タスク実行関数
@@ -32,10 +30,8 @@ function call(params) {
32
30
  acceptedOffer: new acceptedOffer_1.AcceptedOfferRepo(connection),
33
31
  action: new action_1.ActionRepo(connection),
34
32
  order: new order_1.OrderRepo(connection),
35
- // ownershipInfo: new OwnershipInfoRepo(connection),
36
33
  setting: new setting_1.SettingRepo(connection),
37
34
  task: new task_1.TaskRepo(connection),
38
- placeOrder: new placeOrder_1.PlaceOrderRepo(connection)
39
35
  });
40
36
  };
41
37
  }
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.10",
14
+ "@chevre/factory": "10.3.0-alpha.11",
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.36"
91
+ "version": "26.0.0-alpha.38"
92
92
  }