@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.
Files changed (171) hide show
  1. package/lib/core-index.d.ts +3 -0
  2. package/lib/core-index.js +6 -2
  3. package/lib/directors/BaseDiscountDirector.js +6 -6
  4. package/lib/directors/BasePricingDirector.js +1 -1
  5. package/lib/directors/DeliveryAdapter.js +1 -0
  6. package/lib/directors/DeliveryDirector.js +11 -2
  7. package/lib/directors/DeliveryPricingAdapter.d.ts +2 -1
  8. package/lib/directors/DeliveryPricingAdapter.js +2 -1
  9. package/lib/directors/DeliveryPricingDirector.d.ts +1 -1
  10. package/lib/directors/DeliveryPricingDirector.js +12 -2
  11. package/lib/directors/DeliveryPricingSheet.d.ts +1 -1
  12. package/lib/directors/DeliveryPricingSheet.js +1 -1
  13. package/lib/directors/EnrollmentAdapter.js +1 -0
  14. package/lib/directors/EnrollmentDirector.js +11 -1
  15. package/lib/directors/FileDirector.d.ts +10 -0
  16. package/lib/directors/FileDirector.js +25 -0
  17. package/lib/directors/FilterAdapter.js +1 -0
  18. package/lib/directors/FilterDirector.js +11 -1
  19. package/lib/directors/OrderDiscountAdapter.d.ts +3 -2
  20. package/lib/directors/OrderDiscountAdapter.js +5 -2
  21. package/lib/directors/OrderDiscountDirector.d.ts +15 -1
  22. package/lib/directors/OrderDiscountDirector.js +14 -1
  23. package/lib/directors/OrderPricingAdapter.d.ts +2 -1
  24. package/lib/directors/OrderPricingAdapter.js +3 -1
  25. package/lib/directors/OrderPricingDirector.d.ts +4 -1
  26. package/lib/directors/OrderPricingDirector.js +12 -1
  27. package/lib/directors/OrderPricingSheet.d.ts +1 -1
  28. package/lib/directors/OrderPricingSheet.js +1 -1
  29. package/lib/directors/PaymentAdapter.js +1 -0
  30. package/lib/directors/PaymentDirector.js +11 -2
  31. package/lib/directors/PaymentPricingAdapter.d.ts +2 -1
  32. package/lib/directors/PaymentPricingAdapter.js +2 -1
  33. package/lib/directors/PaymentPricingDirector.d.ts +2 -1
  34. package/lib/directors/PaymentPricingDirector.js +11 -1
  35. package/lib/directors/PaymentPricingSheet.d.ts +2 -1
  36. package/lib/directors/PaymentPricingSheet.js +2 -1
  37. package/lib/directors/ProductDiscountAdapter.d.ts +3 -2
  38. package/lib/directors/ProductDiscountAdapter.js +5 -2
  39. package/lib/directors/ProductDiscountDirector.d.ts +16 -2
  40. package/lib/directors/ProductDiscountDirector.js +15 -2
  41. package/lib/directors/ProductPricingAdapter.d.ts +2 -1
  42. package/lib/directors/ProductPricingAdapter.js +3 -1
  43. package/lib/directors/ProductPricingDirector.d.ts +3 -1
  44. package/lib/directors/ProductPricingDirector.js +12 -1
  45. package/lib/directors/ProductPricingSheet.d.ts +1 -1
  46. package/lib/directors/ProductPricingSheet.js +1 -1
  47. package/lib/directors/QuotationAdapter.js +1 -0
  48. package/lib/directors/QuotationDirector.js +11 -2
  49. package/lib/directors/WarehousingAdapter.js +1 -0
  50. package/lib/directors/WarehousingDirector.d.ts +1 -1
  51. package/lib/directors/WarehousingDirector.js +12 -2
  52. package/lib/directors/WorkerAdapter.js +1 -0
  53. package/lib/directors/WorkerDirector.d.ts +1 -1
  54. package/lib/directors/WorkerDirector.js +10 -17
  55. package/lib/directors/index.d.ts +2 -0
  56. package/lib/directors/index.js +2 -0
  57. package/lib/errors/common.d.ts +568 -0
  58. package/lib/errors/common.js +789 -0
  59. package/lib/errors/index.d.ts +1 -0
  60. package/lib/errors/index.js +1 -0
  61. package/lib/factory/registerAssortmentSearchFilter.d.ts +2 -1
  62. package/lib/factory/registerAssortmentSearchFilter.js +12 -3
  63. package/lib/factory/registerInvoicePayment.d.ts +2 -2
  64. package/lib/factory/registerInvoicePayment.js +12 -3
  65. package/lib/factory/registerPhysicalWarehousing.d.ts +2 -2
  66. package/lib/factory/registerPhysicalWarehousing.js +12 -3
  67. package/lib/factory/registerPickUpDelivery.d.ts +2 -2
  68. package/lib/factory/registerPickUpDelivery.js +12 -3
  69. package/lib/factory/registerProductDiscoverabilityFilter.d.ts +2 -1
  70. package/lib/factory/registerProductDiscoverabilityFilter.js +12 -3
  71. package/lib/factory/registerProductSearchFilter.d.ts +2 -1
  72. package/lib/factory/registerProductSearchFilter.js +12 -3
  73. package/lib/factory/registerShippingDelivery.d.ts +2 -2
  74. package/lib/factory/registerShippingDelivery.js +12 -3
  75. package/lib/factory/registerVirtualWarehousing.d.ts +2 -2
  76. package/lib/factory/registerVirtualWarehousing.js +12 -3
  77. package/lib/factory/registerWorker.d.ts +2 -1
  78. package/lib/factory/registerWorker.js +12 -3
  79. package/lib/plugins/PluginRegistry.d.ts +42 -0
  80. package/lib/plugins/PluginRegistry.js +113 -0
  81. package/lib/services/addCartDiscount.d.ts +10 -0
  82. package/lib/services/addCartDiscount.js +27 -0
  83. package/lib/services/addCartItem.d.ts +15 -0
  84. package/lib/services/addCartItem.js +41 -0
  85. package/lib/services/addCartQuotation.d.ts +16 -0
  86. package/lib/services/addCartQuotation.js +52 -0
  87. package/lib/services/addEmail.d.ts +7 -0
  88. package/lib/services/addEmail.js +17 -0
  89. package/lib/services/addProductAssignment.d.ts +3 -0
  90. package/lib/services/addProductAssignment.js +63 -0
  91. package/lib/services/authenticateWithPassword.d.ts +15 -0
  92. package/lib/services/authenticateWithPassword.js +34 -0
  93. package/lib/services/changePassword.d.ts +10 -0
  94. package/lib/services/changePassword.js +19 -0
  95. package/lib/services/countOrdersWithFilters.d.ts +3 -0
  96. package/lib/services/countOrdersWithFilters.js +25 -0
  97. package/lib/services/createAssortment.d.ts +7 -0
  98. package/lib/services/createAssortment.js +10 -0
  99. package/lib/services/createBookmark.d.ts +8 -0
  100. package/lib/services/createBookmark.js +21 -0
  101. package/lib/services/createDeliveryProvider.d.ts +6 -0
  102. package/lib/services/createDeliveryProvider.js +19 -0
  103. package/lib/services/createDownloadStream.js +1 -1
  104. package/lib/services/createEnrollment.d.ts +17 -0
  105. package/lib/services/createEnrollment.js +33 -0
  106. package/lib/services/createFileDownloadURL.js +2 -1
  107. package/lib/services/createProduct.d.ts +7 -0
  108. package/lib/services/createProduct.js +8 -0
  109. package/lib/services/createProductBundleItem.d.ts +5 -0
  110. package/lib/services/createProductBundleItem.js +25 -0
  111. package/lib/services/createProductReview.d.ts +8 -0
  112. package/lib/services/createProductReview.js +12 -0
  113. package/lib/services/createSignedURL.js +2 -1
  114. package/lib/services/deliverOrder.d.ts +5 -0
  115. package/lib/services/deliverOrder.js +26 -0
  116. package/lib/services/findActiveWorkTypes.d.ts +2 -0
  117. package/lib/services/findActiveWorkTypes.js +6 -0
  118. package/lib/services/findDeliveryInterfaces.d.ts +7 -0
  119. package/lib/services/findDeliveryInterfaces.js +13 -0
  120. package/lib/services/findOrdersWithFilters.d.ts +9 -0
  121. package/lib/services/findOrdersWithFilters.js +25 -0
  122. package/lib/services/findPaymentInterfaces.d.ts +7 -0
  123. package/lib/services/findPaymentInterfaces.js +13 -0
  124. package/lib/services/findWarehousingInterfaces.d.ts +7 -0
  125. package/lib/services/findWarehousingInterfaces.js +13 -0
  126. package/lib/services/getDeliveryDiscounts.d.ts +8 -0
  127. package/lib/services/getDeliveryDiscounts.js +14 -0
  128. package/lib/services/getPaymentDiscounts.d.ts +8 -0
  129. package/lib/services/getPaymentDiscounts.js +14 -0
  130. package/lib/services/getShopInfo.d.ts +25 -0
  131. package/lib/services/getShopInfo.js +47 -0
  132. package/lib/services/impersonateUser.d.ts +8 -0
  133. package/lib/services/impersonateUser.js +20 -0
  134. package/lib/services/linkFileService.js +1 -1
  135. package/lib/services/loginAsGuest.d.ts +10 -0
  136. package/lib/services/loginAsGuest.js +19 -0
  137. package/lib/services/obfuscateWorkerData.d.ts +4 -0
  138. package/lib/services/obfuscateWorkerData.js +4 -0
  139. package/lib/services/orderPricingAccessors.d.ts +18 -0
  140. package/lib/services/orderPricingAccessors.js +29 -0
  141. package/lib/services/payOrder.d.ts +5 -0
  142. package/lib/services/payOrder.js +25 -0
  143. package/lib/services/registerUser.d.ts +14 -0
  144. package/lib/services/registerUser.js +44 -0
  145. package/lib/services/removeBookmark.d.ts +6 -0
  146. package/lib/services/removeBookmark.js +10 -0
  147. package/lib/services/removeCartItem.d.ts +6 -0
  148. package/lib/services/removeCartItem.js +19 -0
  149. package/lib/services/removeFiles.js +1 -1
  150. package/lib/services/resetPasswordWithMigration.d.ts +14 -0
  151. package/lib/services/resetPasswordWithMigration.js +31 -0
  152. package/lib/services/resolveWorkType.d.ts +1 -0
  153. package/lib/services/resolveWorkType.js +7 -0
  154. package/lib/services/searchProductsWithAssortment.d.ts +19 -0
  155. package/lib/services/searchProductsWithAssortment.js +17 -0
  156. package/lib/services/toggleBookmark.d.ts +8 -0
  157. package/lib/services/toggleBookmark.js +33 -0
  158. package/lib/services/updateCart.d.ts +15 -0
  159. package/lib/services/updateCart.js +27 -0
  160. package/lib/services/updateCartItem.d.ts +11 -0
  161. package/lib/services/updateCartItem.js +37 -0
  162. package/lib/services/updateEnrollment.d.ts +13 -0
  163. package/lib/services/updateEnrollment.js +36 -0
  164. package/lib/services/uploadFileFromStream.js +2 -1
  165. package/lib/services/uploadFileFromURL.js +2 -1
  166. package/lib/services/verifyEmailWithMigration.d.ts +15 -0
  167. package/lib/services/verifyEmailWithMigration.js +23 -0
  168. package/lib/utils/getFileAdapter.d.ts +1 -0
  169. package/lib/utils/getFileAdapter.js +7 -0
  170. package/lib/utils/schedule.js +164 -28
  171. 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, getFileAdapter } from '@unchainedshop/core-files';
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, getFileAdapter } from '@unchainedshop/core-files';
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>;
@@ -0,0 +1,7 @@
1
+ import { FileDirector } from "../directors/FileDirector.js";
2
+ export const getFileAdapter = () => {
3
+ const adapters = FileDirector.getAdapters();
4
+ if (adapters.length === 0)
5
+ throw Error('No file adapter found.');
6
+ return adapters[0];
7
+ };
@@ -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 schedule = scheduleData.schedules[0];
105
- const current = new Date(referenceDate.getTime());
106
- current.setMilliseconds(0);
107
- current.setSeconds(current.getSeconds() + 1);
108
- const maxIterations = 366 * 24 * 60 * 60;
109
- let iterations = 0;
110
- while (results.length < count && iterations < maxIterations) {
111
- iterations++;
112
- const month = current.getMonth() + 1;
113
- const dayOfMonth = current.getDate();
114
- const dayOfWeek = current.getDay();
115
- const hour = current.getHours();
116
- const minute = current.getMinutes();
117
- const second = current.getSeconds();
118
- const matchesMonth = !schedule.M || schedule.M.includes(month);
119
- const matchesDay = !schedule.D || schedule.D.includes(dayOfMonth);
120
- const matchesDayOfWeek = !schedule.d || schedule.d.includes(dayOfWeek);
121
- const matchesHour = !schedule.h || schedule.h.includes(hour);
122
- const matchesMinute = !schedule.m || schedule.m.includes(minute);
123
- const matchesSecond = !schedule.s || schedule.s.includes(second);
124
- if (matchesMonth &&
125
- matchesDay &&
126
- matchesDayOfWeek &&
127
- matchesHour &&
128
- matchesMinute &&
129
- matchesSecond) {
130
- results.push(new Date(current));
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
- current.setSeconds(current.getSeconds() + 1);
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.6.1",
4
+ "version": "4.7.2",
5
5
  "main": "lib/core-index.js",
6
6
  "types": "lib/core-index.d.ts",
7
7
  "type": "module",