@unchainedshop/core 4.6.1 → 4.7.2
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/lib/core-index.d.ts +3 -0
- package/lib/core-index.js +6 -2
- package/lib/directors/BaseDiscountDirector.js +6 -6
- package/lib/directors/BasePricingDirector.js +1 -1
- package/lib/directors/DeliveryAdapter.js +1 -0
- package/lib/directors/DeliveryDirector.js +11 -2
- package/lib/directors/DeliveryPricingAdapter.d.ts +2 -1
- package/lib/directors/DeliveryPricingAdapter.js +2 -1
- package/lib/directors/DeliveryPricingDirector.d.ts +1 -1
- package/lib/directors/DeliveryPricingDirector.js +12 -2
- package/lib/directors/DeliveryPricingSheet.d.ts +1 -1
- package/lib/directors/DeliveryPricingSheet.js +1 -1
- package/lib/directors/EnrollmentAdapter.js +1 -0
- package/lib/directors/EnrollmentDirector.js +11 -1
- package/lib/directors/FileDirector.d.ts +10 -0
- package/lib/directors/FileDirector.js +25 -0
- package/lib/directors/FilterAdapter.js +1 -0
- package/lib/directors/FilterDirector.js +11 -1
- package/lib/directors/OrderDiscountAdapter.d.ts +3 -2
- package/lib/directors/OrderDiscountAdapter.js +5 -2
- package/lib/directors/OrderDiscountDirector.d.ts +15 -1
- package/lib/directors/OrderDiscountDirector.js +14 -1
- package/lib/directors/OrderPricingAdapter.d.ts +2 -1
- package/lib/directors/OrderPricingAdapter.js +3 -1
- package/lib/directors/OrderPricingDirector.d.ts +4 -1
- package/lib/directors/OrderPricingDirector.js +12 -1
- package/lib/directors/OrderPricingSheet.d.ts +1 -1
- package/lib/directors/OrderPricingSheet.js +1 -1
- package/lib/directors/PaymentAdapter.js +1 -0
- package/lib/directors/PaymentDirector.js +11 -2
- package/lib/directors/PaymentPricingAdapter.d.ts +2 -1
- package/lib/directors/PaymentPricingAdapter.js +2 -1
- package/lib/directors/PaymentPricingDirector.d.ts +2 -1
- package/lib/directors/PaymentPricingDirector.js +11 -1
- package/lib/directors/PaymentPricingSheet.d.ts +2 -1
- package/lib/directors/PaymentPricingSheet.js +2 -1
- package/lib/directors/ProductDiscountAdapter.d.ts +3 -2
- package/lib/directors/ProductDiscountAdapter.js +5 -2
- package/lib/directors/ProductDiscountDirector.d.ts +16 -2
- package/lib/directors/ProductDiscountDirector.js +15 -2
- package/lib/directors/ProductPricingAdapter.d.ts +2 -1
- package/lib/directors/ProductPricingAdapter.js +3 -1
- package/lib/directors/ProductPricingDirector.d.ts +3 -1
- package/lib/directors/ProductPricingDirector.js +12 -1
- package/lib/directors/ProductPricingSheet.d.ts +1 -1
- package/lib/directors/ProductPricingSheet.js +1 -1
- package/lib/directors/QuotationAdapter.js +1 -0
- package/lib/directors/QuotationDirector.js +11 -2
- package/lib/directors/WarehousingAdapter.js +1 -0
- package/lib/directors/WarehousingDirector.d.ts +1 -1
- package/lib/directors/WarehousingDirector.js +12 -2
- package/lib/directors/WorkerAdapter.js +1 -0
- package/lib/directors/WorkerDirector.d.ts +1 -1
- package/lib/directors/WorkerDirector.js +10 -17
- package/lib/directors/index.d.ts +2 -0
- package/lib/directors/index.js +2 -0
- package/lib/errors/common.d.ts +568 -0
- package/lib/errors/common.js +789 -0
- package/lib/errors/index.d.ts +1 -0
- package/lib/errors/index.js +1 -0
- package/lib/factory/registerAssortmentSearchFilter.d.ts +2 -1
- package/lib/factory/registerAssortmentSearchFilter.js +12 -3
- package/lib/factory/registerInvoicePayment.d.ts +2 -2
- package/lib/factory/registerInvoicePayment.js +12 -3
- package/lib/factory/registerPhysicalWarehousing.d.ts +2 -2
- package/lib/factory/registerPhysicalWarehousing.js +12 -3
- package/lib/factory/registerPickUpDelivery.d.ts +2 -2
- package/lib/factory/registerPickUpDelivery.js +12 -3
- package/lib/factory/registerProductDiscoverabilityFilter.d.ts +2 -1
- package/lib/factory/registerProductDiscoverabilityFilter.js +12 -3
- package/lib/factory/registerProductSearchFilter.d.ts +2 -1
- package/lib/factory/registerProductSearchFilter.js +12 -3
- package/lib/factory/registerShippingDelivery.d.ts +2 -2
- package/lib/factory/registerShippingDelivery.js +12 -3
- package/lib/factory/registerVirtualWarehousing.d.ts +2 -2
- package/lib/factory/registerVirtualWarehousing.js +12 -3
- package/lib/factory/registerWorker.d.ts +2 -1
- package/lib/factory/registerWorker.js +12 -3
- package/lib/plugins/PluginRegistry.d.ts +42 -0
- package/lib/plugins/PluginRegistry.js +113 -0
- package/lib/services/addCartDiscount.d.ts +10 -0
- package/lib/services/addCartDiscount.js +27 -0
- package/lib/services/addCartItem.d.ts +15 -0
- package/lib/services/addCartItem.js +41 -0
- package/lib/services/addCartQuotation.d.ts +16 -0
- package/lib/services/addCartQuotation.js +52 -0
- package/lib/services/addEmail.d.ts +7 -0
- package/lib/services/addEmail.js +17 -0
- package/lib/services/addProductAssignment.d.ts +3 -0
- package/lib/services/addProductAssignment.js +63 -0
- package/lib/services/authenticateWithPassword.d.ts +15 -0
- package/lib/services/authenticateWithPassword.js +34 -0
- package/lib/services/changePassword.d.ts +10 -0
- package/lib/services/changePassword.js +19 -0
- package/lib/services/countOrdersWithFilters.d.ts +3 -0
- package/lib/services/countOrdersWithFilters.js +25 -0
- package/lib/services/createAssortment.d.ts +7 -0
- package/lib/services/createAssortment.js +10 -0
- package/lib/services/createBookmark.d.ts +8 -0
- package/lib/services/createBookmark.js +21 -0
- package/lib/services/createDeliveryProvider.d.ts +6 -0
- package/lib/services/createDeliveryProvider.js +19 -0
- package/lib/services/createDownloadStream.js +1 -1
- package/lib/services/createEnrollment.d.ts +17 -0
- package/lib/services/createEnrollment.js +33 -0
- package/lib/services/createFileDownloadURL.js +2 -1
- package/lib/services/createProduct.d.ts +7 -0
- package/lib/services/createProduct.js +8 -0
- package/lib/services/createProductBundleItem.d.ts +5 -0
- package/lib/services/createProductBundleItem.js +25 -0
- package/lib/services/createProductReview.d.ts +8 -0
- package/lib/services/createProductReview.js +12 -0
- package/lib/services/createSignedURL.js +2 -1
- package/lib/services/deliverOrder.d.ts +5 -0
- package/lib/services/deliverOrder.js +26 -0
- package/lib/services/findActiveWorkTypes.d.ts +2 -0
- package/lib/services/findActiveWorkTypes.js +6 -0
- package/lib/services/findDeliveryInterfaces.d.ts +7 -0
- package/lib/services/findDeliveryInterfaces.js +13 -0
- package/lib/services/findOrdersWithFilters.d.ts +9 -0
- package/lib/services/findOrdersWithFilters.js +25 -0
- package/lib/services/findPaymentInterfaces.d.ts +7 -0
- package/lib/services/findPaymentInterfaces.js +13 -0
- package/lib/services/findWarehousingInterfaces.d.ts +7 -0
- package/lib/services/findWarehousingInterfaces.js +13 -0
- package/lib/services/getDeliveryDiscounts.d.ts +8 -0
- package/lib/services/getDeliveryDiscounts.js +14 -0
- package/lib/services/getPaymentDiscounts.d.ts +8 -0
- package/lib/services/getPaymentDiscounts.js +14 -0
- package/lib/services/getShopInfo.d.ts +25 -0
- package/lib/services/getShopInfo.js +47 -0
- package/lib/services/impersonateUser.d.ts +8 -0
- package/lib/services/impersonateUser.js +20 -0
- package/lib/services/linkFileService.js +1 -1
- package/lib/services/loginAsGuest.d.ts +10 -0
- package/lib/services/loginAsGuest.js +19 -0
- package/lib/services/obfuscateWorkerData.d.ts +4 -0
- package/lib/services/obfuscateWorkerData.js +4 -0
- package/lib/services/orderPricingAccessors.d.ts +18 -0
- package/lib/services/orderPricingAccessors.js +29 -0
- package/lib/services/payOrder.d.ts +5 -0
- package/lib/services/payOrder.js +25 -0
- package/lib/services/registerUser.d.ts +14 -0
- package/lib/services/registerUser.js +44 -0
- package/lib/services/removeBookmark.d.ts +6 -0
- package/lib/services/removeBookmark.js +10 -0
- package/lib/services/removeCartItem.d.ts +6 -0
- package/lib/services/removeCartItem.js +19 -0
- package/lib/services/removeFiles.js +1 -1
- package/lib/services/resetPasswordWithMigration.d.ts +14 -0
- package/lib/services/resetPasswordWithMigration.js +31 -0
- package/lib/services/resolveWorkType.d.ts +1 -0
- package/lib/services/resolveWorkType.js +7 -0
- package/lib/services/searchProductsWithAssortment.d.ts +19 -0
- package/lib/services/searchProductsWithAssortment.js +17 -0
- package/lib/services/toggleBookmark.d.ts +8 -0
- package/lib/services/toggleBookmark.js +33 -0
- package/lib/services/updateCart.d.ts +15 -0
- package/lib/services/updateCart.js +27 -0
- package/lib/services/updateCartItem.d.ts +11 -0
- package/lib/services/updateCartItem.js +37 -0
- package/lib/services/updateEnrollment.d.ts +13 -0
- package/lib/services/updateEnrollment.js +36 -0
- package/lib/services/uploadFileFromStream.js +2 -1
- package/lib/services/uploadFileFromURL.js +2 -1
- package/lib/services/verifyEmailWithMigration.d.ts +15 -0
- package/lib/services/verifyEmailWithMigration.js +23 -0
- package/lib/utils/getFileAdapter.d.ts +1 -0
- package/lib/utils/getFileAdapter.js +7 -0
- package/lib/utils/schedule.js +164 -28
- package/package.json +1 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ordersSettings } from '@unchainedshop/core-orders';
|
|
2
|
+
import { updateCalculationService } from "./updateCalculation.js";
|
|
3
|
+
import { OrderItemNotFoundError, OrderNotFoundError, OrderWrongStatusError, OrderQuantityTooLowError, ProductNotFoundError, } from "../errors/index.js";
|
|
4
|
+
export async function updateCartItemService(params, context) {
|
|
5
|
+
const { itemId, configuration, quantity = 1 } = params;
|
|
6
|
+
const item = await this.orders.positions.findOrderPosition({ itemId });
|
|
7
|
+
if (!item) {
|
|
8
|
+
throw new OrderItemNotFoundError({ orderItemId: itemId });
|
|
9
|
+
}
|
|
10
|
+
const order = await this.orders.findOrder({ orderId: item.orderId });
|
|
11
|
+
if (!order) {
|
|
12
|
+
throw new OrderNotFoundError({ orderId: item.orderId });
|
|
13
|
+
}
|
|
14
|
+
if (!this.orders.isCart(order)) {
|
|
15
|
+
throw new OrderWrongStatusError({ status: order.status });
|
|
16
|
+
}
|
|
17
|
+
const product = await this.products.findProduct({ productId: item.productId });
|
|
18
|
+
if (!product) {
|
|
19
|
+
throw new ProductNotFoundError({ productId: item.productId });
|
|
20
|
+
}
|
|
21
|
+
if (quantity !== null && quantity < 1) {
|
|
22
|
+
throw new OrderQuantityTooLowError({ quantity });
|
|
23
|
+
}
|
|
24
|
+
await ordersSettings.validateOrderPosition({
|
|
25
|
+
order,
|
|
26
|
+
product,
|
|
27
|
+
configuration,
|
|
28
|
+
quantityDiff: quantity - item.quantity,
|
|
29
|
+
}, context);
|
|
30
|
+
await this.orders.positions.updateProductItem({
|
|
31
|
+
orderPositionId: item._id,
|
|
32
|
+
quantity: quantity || null,
|
|
33
|
+
configuration: configuration || null,
|
|
34
|
+
});
|
|
35
|
+
await updateCalculationService.bind(this)(order._id);
|
|
36
|
+
return (await this.orders.positions.findOrderPosition({ itemId: item._id }));
|
|
37
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Enrollment, type EnrollmentPlan } from '@unchainedshop/core-enrollments';
|
|
2
|
+
import type { Address, Contact } from '@unchainedshop/core-users';
|
|
3
|
+
import type { Modules } from '../modules.ts';
|
|
4
|
+
export interface UpdateEnrollmentParams {
|
|
5
|
+
enrollmentId: string;
|
|
6
|
+
contact?: Contact;
|
|
7
|
+
plan?: EnrollmentPlan;
|
|
8
|
+
billingAddress?: Address;
|
|
9
|
+
payment?: Enrollment['payment'];
|
|
10
|
+
delivery?: Enrollment['delivery'];
|
|
11
|
+
meta?: any;
|
|
12
|
+
}
|
|
13
|
+
export declare function updateEnrollmentService(this: Modules, params: UpdateEnrollmentParams): Promise<Enrollment>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { EnrollmentStatus } from '@unchainedshop/core-enrollments';
|
|
2
|
+
import { initializeEnrollmentService } from "./initializeEnrollment.js";
|
|
3
|
+
import { EnrollmentNotFoundError, EnrollmentWrongStatusError, EnrollmentPlanUpdateNotAllowedError, } from "../errors/index.js";
|
|
4
|
+
export async function updateEnrollmentService(params) {
|
|
5
|
+
const { enrollmentId, billingAddress, contact, delivery, meta, payment, plan } = params;
|
|
6
|
+
let enrollment = await this.enrollments.findEnrollment({ enrollmentId });
|
|
7
|
+
if (!enrollment) {
|
|
8
|
+
throw new EnrollmentNotFoundError({ enrollmentId });
|
|
9
|
+
}
|
|
10
|
+
if (enrollment.status === EnrollmentStatus.TERMINATED) {
|
|
11
|
+
throw new EnrollmentWrongStatusError({ status: enrollment.status, enrollmentId: enrollment._id });
|
|
12
|
+
}
|
|
13
|
+
if (meta) {
|
|
14
|
+
enrollment = (await this.enrollments.updateContext(enrollmentId, meta));
|
|
15
|
+
}
|
|
16
|
+
if (billingAddress) {
|
|
17
|
+
enrollment = (await this.enrollments.updateBillingAddress(enrollmentId, billingAddress));
|
|
18
|
+
}
|
|
19
|
+
if (contact) {
|
|
20
|
+
enrollment = (await this.enrollments.updateContact(enrollmentId, contact));
|
|
21
|
+
}
|
|
22
|
+
if (payment) {
|
|
23
|
+
enrollment = (await this.enrollments.updatePayment(enrollmentId, payment));
|
|
24
|
+
}
|
|
25
|
+
if (delivery) {
|
|
26
|
+
enrollment = (await this.enrollments.updateDelivery(enrollmentId, delivery));
|
|
27
|
+
}
|
|
28
|
+
if (plan) {
|
|
29
|
+
if (enrollment.status !== EnrollmentStatus.INITIAL) {
|
|
30
|
+
throw new EnrollmentPlanUpdateNotAllowedError({ status: enrollment.status, enrollmentId });
|
|
31
|
+
}
|
|
32
|
+
enrollment = (await this.enrollments.updatePlan(enrollmentId, plan));
|
|
33
|
+
enrollment = await initializeEnrollmentService.bind(this)(enrollment, { reason: 'updated_plan' });
|
|
34
|
+
}
|
|
35
|
+
return enrollment;
|
|
36
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { getFileFromFileData
|
|
1
|
+
import { getFileFromFileData } from '@unchainedshop/core-files';
|
|
2
|
+
import { getFileAdapter } from "../utils/getFileAdapter.js";
|
|
2
3
|
export async function uploadFileFromStreamService({ directoryName, rawFile, meta, ...options }) {
|
|
3
4
|
const fileUploadAdapter = getFileAdapter();
|
|
4
5
|
const uploadFileData = await fileUploadAdapter.uploadFileFromStream(directoryName, rawFile, {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { getFileFromFileData
|
|
1
|
+
import { getFileFromFileData } from '@unchainedshop/core-files';
|
|
2
|
+
import { getFileAdapter } from "../utils/getFileAdapter.js";
|
|
2
3
|
export async function uploadFileFromURLService({ directoryName, fileInput, meta, }) {
|
|
3
4
|
const fileUploadAdapter = getFileAdapter();
|
|
4
5
|
const uploadFileData = await fileUploadAdapter.uploadFileFromURL(directoryName, fileInput, {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { User } from '@unchainedshop/core-users';
|
|
2
|
+
import type { Modules } from '../modules.ts';
|
|
3
|
+
export interface VerifyEmailHttpContext {
|
|
4
|
+
remoteAddress?: string;
|
|
5
|
+
remotePort?: number;
|
|
6
|
+
userAgent?: string;
|
|
7
|
+
locale?: string;
|
|
8
|
+
countryCode: string;
|
|
9
|
+
}
|
|
10
|
+
export interface VerifyEmailParams {
|
|
11
|
+
token: string;
|
|
12
|
+
currentUserId?: string;
|
|
13
|
+
httpContext: VerifyEmailHttpContext;
|
|
14
|
+
}
|
|
15
|
+
export declare function verifyEmailWithMigrationService(this: Modules, params: VerifyEmailParams): Promise<User>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { nextUserCartService } from "./nextUserCart.js";
|
|
2
|
+
import { migrateUserDataService } from "./migrateUserData.js";
|
|
3
|
+
import { InvalidEmailVerificationTokenError } from "../errors/index.js";
|
|
4
|
+
export async function verifyEmailWithMigrationService(params) {
|
|
5
|
+
const { token, currentUserId, httpContext } = params;
|
|
6
|
+
const unverifiedToken = await this.users.findUnverifiedEmailToken(token);
|
|
7
|
+
if (!unverifiedToken) {
|
|
8
|
+
throw new InvalidEmailVerificationTokenError({ token });
|
|
9
|
+
}
|
|
10
|
+
await this.users.verifyEmail(unverifiedToken.userId, unverifiedToken.address);
|
|
11
|
+
const user = (await this.users.updateHeartbeat(unverifiedToken.userId, {
|
|
12
|
+
remoteAddress: httpContext.remoteAddress,
|
|
13
|
+
remotePort: httpContext.remotePort,
|
|
14
|
+
userAgent: httpContext.userAgent,
|
|
15
|
+
locale: httpContext.locale,
|
|
16
|
+
countryCode: httpContext.countryCode,
|
|
17
|
+
}));
|
|
18
|
+
if (currentUserId) {
|
|
19
|
+
await migrateUserDataService.bind(this)(currentUserId, user._id);
|
|
20
|
+
}
|
|
21
|
+
await nextUserCartService.bind(this)({ user, countryCode: httpContext.countryCode });
|
|
22
|
+
return user;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getFileAdapter: () => import("@unchainedshop/core-files").IFileAdapter<unknown>;
|
package/lib/utils/schedule.js
CHANGED
|
@@ -99,37 +99,173 @@ function parseText(text) {
|
|
|
99
99
|
throw new Error(`Unsupported time unit: ${unit}`);
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
+
function findNextInSorted(sorted, minVal) {
|
|
103
|
+
for (const v of sorted) {
|
|
104
|
+
if (v >= minVal)
|
|
105
|
+
return v;
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
function daysInMonth(year, month) {
|
|
110
|
+
return new Date(year, month, 0).getDate();
|
|
111
|
+
}
|
|
102
112
|
function getNextOccurrences(scheduleData, count, referenceDate) {
|
|
103
113
|
const results = [];
|
|
104
|
-
const
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
let
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
114
|
+
const sched = scheduleData.schedules[0];
|
|
115
|
+
const start = new Date(referenceDate.getTime());
|
|
116
|
+
start.setMilliseconds(0);
|
|
117
|
+
start.setSeconds(start.getSeconds() + 1);
|
|
118
|
+
let year = start.getFullYear();
|
|
119
|
+
let month = start.getMonth() + 1;
|
|
120
|
+
let day = start.getDate();
|
|
121
|
+
let hour = start.getHours();
|
|
122
|
+
let minute = start.getMinutes();
|
|
123
|
+
let second = start.getSeconds();
|
|
124
|
+
const maxYear = year + 5;
|
|
125
|
+
search: while (results.length < count && year <= maxYear) {
|
|
126
|
+
if (sched.M) {
|
|
127
|
+
const nextMonth = findNextInSorted(sched.M, month);
|
|
128
|
+
if (nextMonth === null) {
|
|
129
|
+
year++;
|
|
130
|
+
month = sched.M[0];
|
|
131
|
+
day = sched.D ? sched.D[0] : 1;
|
|
132
|
+
hour = sched.h ? sched.h[0] : 0;
|
|
133
|
+
minute = sched.m ? sched.m[0] : 0;
|
|
134
|
+
second = sched.s ? sched.s[0] : 0;
|
|
135
|
+
continue search;
|
|
136
|
+
}
|
|
137
|
+
if (nextMonth > month) {
|
|
138
|
+
month = nextMonth;
|
|
139
|
+
day = sched.D ? sched.D[0] : 1;
|
|
140
|
+
hour = sched.h ? sched.h[0] : 0;
|
|
141
|
+
minute = sched.m ? sched.m[0] : 0;
|
|
142
|
+
second = sched.s ? sched.s[0] : 0;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const maxDay = daysInMonth(year, month);
|
|
146
|
+
if (sched.D || sched.d) {
|
|
147
|
+
let found = false;
|
|
148
|
+
let candidateDay = day;
|
|
149
|
+
while (candidateDay <= maxDay) {
|
|
150
|
+
const matchesD = !sched.D || sched.D.includes(candidateDay);
|
|
151
|
+
if (matchesD) {
|
|
152
|
+
const dow = new Date(year, month - 1, candidateDay).getDay();
|
|
153
|
+
const matchesDow = !sched.d || sched.d.includes(dow);
|
|
154
|
+
if (matchesDow) {
|
|
155
|
+
if (candidateDay > day) {
|
|
156
|
+
hour = sched.h ? sched.h[0] : 0;
|
|
157
|
+
minute = sched.m ? sched.m[0] : 0;
|
|
158
|
+
second = sched.s ? sched.s[0] : 0;
|
|
159
|
+
}
|
|
160
|
+
day = candidateDay;
|
|
161
|
+
found = true;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
candidateDay++;
|
|
166
|
+
}
|
|
167
|
+
if (!found) {
|
|
168
|
+
month++;
|
|
169
|
+
if (month > 12) {
|
|
170
|
+
year++;
|
|
171
|
+
month = sched.M ? sched.M[0] : 1;
|
|
172
|
+
}
|
|
173
|
+
else if (sched.M) {
|
|
174
|
+
const nextM = findNextInSorted(sched.M, month);
|
|
175
|
+
if (nextM === null) {
|
|
176
|
+
year++;
|
|
177
|
+
month = sched.M[0];
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
month = nextM;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
day = sched.D ? sched.D[0] : 1;
|
|
184
|
+
hour = sched.h ? sched.h[0] : 0;
|
|
185
|
+
minute = sched.m ? sched.m[0] : 0;
|
|
186
|
+
second = sched.s ? sched.s[0] : 0;
|
|
187
|
+
continue search;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
else if (day > maxDay) {
|
|
191
|
+
month++;
|
|
192
|
+
if (month > 12) {
|
|
193
|
+
year++;
|
|
194
|
+
month = sched.M ? sched.M[0] : 1;
|
|
195
|
+
}
|
|
196
|
+
else if (sched.M) {
|
|
197
|
+
const nextM = findNextInSorted(sched.M, month);
|
|
198
|
+
if (nextM === null) {
|
|
199
|
+
year++;
|
|
200
|
+
month = sched.M[0];
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
month = nextM;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
day = 1;
|
|
207
|
+
hour = sched.h ? sched.h[0] : 0;
|
|
208
|
+
minute = sched.m ? sched.m[0] : 0;
|
|
209
|
+
second = sched.s ? sched.s[0] : 0;
|
|
210
|
+
continue search;
|
|
211
|
+
}
|
|
212
|
+
if (hour > 23) {
|
|
213
|
+
day++;
|
|
214
|
+
hour = sched.h ? sched.h[0] : 0;
|
|
215
|
+
minute = sched.m ? sched.m[0] : 0;
|
|
216
|
+
second = sched.s ? sched.s[0] : 0;
|
|
217
|
+
continue search;
|
|
218
|
+
}
|
|
219
|
+
if (sched.h) {
|
|
220
|
+
const nextHour = findNextInSorted(sched.h, hour);
|
|
221
|
+
if (nextHour === null) {
|
|
222
|
+
day++;
|
|
223
|
+
hour = sched.h[0];
|
|
224
|
+
minute = sched.m ? sched.m[0] : 0;
|
|
225
|
+
second = sched.s ? sched.s[0] : 0;
|
|
226
|
+
continue search;
|
|
227
|
+
}
|
|
228
|
+
if (nextHour > hour) {
|
|
229
|
+
hour = nextHour;
|
|
230
|
+
minute = sched.m ? sched.m[0] : 0;
|
|
231
|
+
second = sched.s ? sched.s[0] : 0;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (minute > 59) {
|
|
235
|
+
hour++;
|
|
236
|
+
minute = sched.m ? sched.m[0] : 0;
|
|
237
|
+
second = sched.s ? sched.s[0] : 0;
|
|
238
|
+
continue search;
|
|
239
|
+
}
|
|
240
|
+
if (sched.m) {
|
|
241
|
+
const nextMinute = findNextInSorted(sched.m, minute);
|
|
242
|
+
if (nextMinute === null) {
|
|
243
|
+
hour++;
|
|
244
|
+
minute = sched.m[0];
|
|
245
|
+
second = sched.s ? sched.s[0] : 0;
|
|
246
|
+
continue search;
|
|
247
|
+
}
|
|
248
|
+
if (nextMinute > minute) {
|
|
249
|
+
minute = nextMinute;
|
|
250
|
+
second = sched.s ? sched.s[0] : 0;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (second > 59) {
|
|
254
|
+
minute++;
|
|
255
|
+
second = sched.s ? sched.s[0] : 0;
|
|
256
|
+
continue search;
|
|
257
|
+
}
|
|
258
|
+
if (sched.s) {
|
|
259
|
+
const nextSecond = findNextInSorted(sched.s, second);
|
|
260
|
+
if (nextSecond === null) {
|
|
261
|
+
minute++;
|
|
262
|
+
second = sched.s[0];
|
|
263
|
+
continue search;
|
|
264
|
+
}
|
|
265
|
+
second = nextSecond;
|
|
131
266
|
}
|
|
132
|
-
|
|
267
|
+
results.push(new Date(year, month - 1, day, hour, minute, second));
|
|
268
|
+
second++;
|
|
133
269
|
}
|
|
134
270
|
return results;
|
|
135
271
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/core",
|
|
3
3
|
"description": "Core orchestration package for the Unchained Engine with business services and directors",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.7.2",
|
|
5
5
|
"main": "lib/core-index.js",
|
|
6
6
|
"types": "lib/core-index.d.ts",
|
|
7
7
|
"type": "module",
|