@chevre/domain 26.0.0-alpha.0 → 26.0.0-alpha.1
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,20 @@
|
|
|
1
|
+
import type { Connection, FilterQuery } from 'mongoose';
|
|
2
|
+
import { factory } from '../factory';
|
|
3
|
+
import { IDocType } from './mongoose/schemas/scheduledTasks';
|
|
4
|
+
type IKeyOfProjection = keyof factory.task.ITask<factory.taskName> | 'expires';
|
|
5
|
+
type IFindParams = Pick<factory.task.ISearchConditions, 'id' | 'name' | 'project' | 'runsFrom' | 'runsThrough' | 'status' | 'limit' | 'page' | 'sort'>;
|
|
6
|
+
/**
|
|
7
|
+
* 予定タスク管理リポジトリ
|
|
8
|
+
*/
|
|
9
|
+
export declare class AdminScheduledTaskRepo {
|
|
10
|
+
private readonly scheduledTaskModel;
|
|
11
|
+
constructor(connection: Connection);
|
|
12
|
+
static CREATE_MONGO_CONDITIONS(params: Pick<IFindParams, 'id' | 'name' | 'project' | 'runsFrom' | 'runsThrough' | 'status'>): FilterQuery<import("@chevre/factory/lib/chevre/task").ITask | import("@chevre/factory/lib/chevre/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/chevre/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/chevre/task/createAccountingReport").ITask | import("@chevre/factory/lib/chevre/task/onAssetTransactionStatusChanged").ITask | import("@chevre/factory/lib/chevre/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/chevre/task/onEventChanged").ITask | import("@chevre/factory/lib/chevre/task/onResourceDeleted").ITask | import("@chevre/factory/lib/chevre/task/onResourceUpdated").ITask | import("@chevre/factory/lib/chevre/task/onOrderPaymentCompleted").ITask | import("@chevre/factory/lib/chevre/task/placeOrder").ITask | import("@chevre/factory/lib/chevre/task/returnOrder").ITask | import("@chevre/factory/lib/chevre/task/returnPayTransaction").ITask | import("@chevre/factory/lib/chevre/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/chevre/task/sendEmailMessage").ITask | import("@chevre/factory/lib/chevre/task/sendOrder").ITask | import("@chevre/factory/lib/chevre/task/triggerWebhook").ITask | import("@chevre/factory/lib/chevre/task/useReservation").ITask | import("@chevre/factory/lib/chevre/task/voidPayTransaction").ITask>[];
|
|
13
|
+
/**
|
|
14
|
+
* 検索する
|
|
15
|
+
*/
|
|
16
|
+
findScheduledTasks(params: IFindParams, inclusion: IKeyOfProjection[]): Promise<(IDocType & {
|
|
17
|
+
id: string;
|
|
18
|
+
})[]>;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AdminScheduledTaskRepo = void 0;
|
|
4
|
+
const settings_1 = require("../settings");
|
|
5
|
+
const scheduledTasks_1 = require("./mongoose/schemas/scheduledTasks");
|
|
6
|
+
const AVAILABLE_PROJECT_FIELDS = [
|
|
7
|
+
'description',
|
|
8
|
+
'project',
|
|
9
|
+
'name',
|
|
10
|
+
'status',
|
|
11
|
+
'runsAt',
|
|
12
|
+
'remainingNumberOfTries',
|
|
13
|
+
'lastTriedAt',
|
|
14
|
+
'numberOfTried',
|
|
15
|
+
'executionResults',
|
|
16
|
+
'executor',
|
|
17
|
+
'data',
|
|
18
|
+
'dateAborted',
|
|
19
|
+
'expires'
|
|
20
|
+
];
|
|
21
|
+
/**
|
|
22
|
+
* 予定タスク管理リポジトリ
|
|
23
|
+
*/
|
|
24
|
+
class AdminScheduledTaskRepo {
|
|
25
|
+
scheduledTaskModel;
|
|
26
|
+
constructor(connection) {
|
|
27
|
+
this.scheduledTaskModel = connection.model(scheduledTasks_1.modelName, (0, scheduledTasks_1.createSchema)());
|
|
28
|
+
}
|
|
29
|
+
static CREATE_MONGO_CONDITIONS(params) {
|
|
30
|
+
const andConditions = [];
|
|
31
|
+
const idEq = params.id?.$eq;
|
|
32
|
+
if (typeof idEq === 'string') {
|
|
33
|
+
andConditions.push({ _id: { $eq: idEq } });
|
|
34
|
+
}
|
|
35
|
+
const projectIdEq = params.project?.id?.$eq;
|
|
36
|
+
if (typeof projectIdEq === 'string') {
|
|
37
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
38
|
+
}
|
|
39
|
+
if (typeof params.name === 'string') {
|
|
40
|
+
andConditions.push({ name: { $eq: params.name } });
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
const nameIn = params.name?.$in;
|
|
44
|
+
if (Array.isArray(nameIn)) {
|
|
45
|
+
andConditions.push({ name: { $in: nameIn } });
|
|
46
|
+
}
|
|
47
|
+
const nameNin = params.name?.$nin;
|
|
48
|
+
if (Array.isArray(nameNin)) {
|
|
49
|
+
andConditions.push({ name: { $nin: nameNin } });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const statusEq = params.status?.$eq;
|
|
53
|
+
if (typeof statusEq === 'string') {
|
|
54
|
+
andConditions.push({ status: { $eq: statusEq } });
|
|
55
|
+
}
|
|
56
|
+
if (params.runsFrom instanceof Date) {
|
|
57
|
+
andConditions.push({ runsAt: { $gte: params.runsFrom } });
|
|
58
|
+
}
|
|
59
|
+
if (params.runsThrough instanceof Date) {
|
|
60
|
+
andConditions.push({ runsAt: { $lte: params.runsThrough } });
|
|
61
|
+
}
|
|
62
|
+
return andConditions;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* 検索する
|
|
66
|
+
*/
|
|
67
|
+
async findScheduledTasks(params, inclusion) {
|
|
68
|
+
const conditions = AdminScheduledTaskRepo.CREATE_MONGO_CONDITIONS(params);
|
|
69
|
+
let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
|
|
70
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
71
|
+
positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
// no op
|
|
75
|
+
}
|
|
76
|
+
const projection = {
|
|
77
|
+
_id: 0,
|
|
78
|
+
id: { $toString: '$_id' },
|
|
79
|
+
...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
|
|
80
|
+
};
|
|
81
|
+
const query = this.scheduledTaskModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
|
|
82
|
+
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
83
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
84
|
+
query.limit(params.limit)
|
|
85
|
+
.skip(params.limit * (page - 1));
|
|
86
|
+
}
|
|
87
|
+
if (params.sort?.runsAt !== undefined) {
|
|
88
|
+
query.sort({ runsAt: params.sort.runsAt });
|
|
89
|
+
}
|
|
90
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
91
|
+
.lean()
|
|
92
|
+
.exec();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.AdminScheduledTaskRepo = AdminScheduledTaskRepo;
|
|
@@ -17,6 +17,7 @@ import type { PayActionRepo } from './repo/action/pay';
|
|
|
17
17
|
import type { RefundActionRepo } from './repo/action/refund';
|
|
18
18
|
import type { AsyncActionRepo } from './repo/asyncAction';
|
|
19
19
|
import type { AdditionalPropertyRepo } from './repo/additionalProperty';
|
|
20
|
+
import type { AdminScheduledTaskRepo } from './repo/adminScheduledTask';
|
|
20
21
|
import type { AdminTaskRepo } from './repo/adminTask';
|
|
21
22
|
import type { AggregateActionRepo } from './repo/aggregateAction';
|
|
22
23
|
import type { AggregateOfferRepo } from './repo/aggregateOffer';
|
|
@@ -162,6 +163,10 @@ export type AdditionalProperty = AdditionalPropertyRepo;
|
|
|
162
163
|
export declare namespace AdditionalProperty {
|
|
163
164
|
function createInstance(...params: ConstructorParameters<typeof AdditionalPropertyRepo>): Promise<AdditionalPropertyRepo>;
|
|
164
165
|
}
|
|
166
|
+
export type AdminScheduledTask = AdminScheduledTaskRepo;
|
|
167
|
+
export declare namespace AdminScheduledTask {
|
|
168
|
+
function createInstance(...params: ConstructorParameters<typeof AdminScheduledTaskRepo>): Promise<AdminScheduledTaskRepo>;
|
|
169
|
+
}
|
|
165
170
|
export type AdminTask = AdminTaskRepo;
|
|
166
171
|
export declare namespace AdminTask {
|
|
167
172
|
function createInstance(...params: ConstructorParameters<typeof AdminTaskRepo>): Promise<AdminTaskRepo>;
|
package/lib/chevre/repository.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.WebSite = exports.rateLimit = exports.TransactionProcess = exports.TransactionNumber = exports.transaction = exports.Transaction = exports.Ticket = exports.AsyncAction = exports.Task = exports.ScheduledTask = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = exports.Person = void 0;
|
|
3
|
+
exports.PaymentServiceProvider = exports.PaymentServiceChannel = exports.PaymentService = exports.Passport = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.NoteAboutOrder = exports.Note = exports.MovieTicketType = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.IdentityProvider = exports.Identity = exports.EventSeries = exports.EventSellerMakesOffer = exports.EventOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Authorization = exports.CategoryCode = exports.assetTransaction = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOrder = exports.AggregateOffer = exports.AggregateTask = exports.AggregateAction = exports.AdminTask = exports.AdminScheduledTask = exports.AdditionalProperty = exports.action = exports.Action = exports.AccountTitle = exports.AccountingReport = exports.AcceptedOffer = void 0;
|
|
4
|
+
exports.WebSite = exports.rateLimit = exports.TransactionProcess = exports.TransactionNumber = exports.transaction = exports.Transaction = exports.Ticket = exports.AsyncAction = exports.Task = exports.ScheduledTask = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = exports.Person = exports.PendingReservation = void 0;
|
|
5
5
|
var AcceptedOffer;
|
|
6
6
|
(function (AcceptedOffer) {
|
|
7
7
|
let repo;
|
|
@@ -170,6 +170,17 @@ var AdditionalProperty;
|
|
|
170
170
|
}
|
|
171
171
|
AdditionalProperty.createInstance = createInstance;
|
|
172
172
|
})(AdditionalProperty || (exports.AdditionalProperty = AdditionalProperty = {}));
|
|
173
|
+
var AdminScheduledTask;
|
|
174
|
+
(function (AdminScheduledTask) {
|
|
175
|
+
let repo;
|
|
176
|
+
async function createInstance(...params) {
|
|
177
|
+
if (repo === undefined) {
|
|
178
|
+
repo = (await import('./repo/adminScheduledTask.js')).AdminScheduledTaskRepo;
|
|
179
|
+
}
|
|
180
|
+
return new repo(...params);
|
|
181
|
+
}
|
|
182
|
+
AdminScheduledTask.createInstance = createInstance;
|
|
183
|
+
})(AdminScheduledTask || (exports.AdminScheduledTask = AdminScheduledTask = {}));
|
|
173
184
|
var AdminTask;
|
|
174
185
|
(function (AdminTask) {
|
|
175
186
|
let repo;
|
package/package.json
CHANGED