@punks/backend-entity-manager 0.0.347 → 0.0.348

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/dist/cjs/index.js CHANGED
@@ -22085,26 +22085,6 @@ exports.MediaLibraryService = __decorate([
22085
22085
  __metadata("design:paramtypes", [exports.EntityManagerRegistry])
22086
22086
  ], exports.MediaLibraryService);
22087
22087
 
22088
- function toInteger(dirtyNumber) {
22089
- if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
22090
- return NaN;
22091
- }
22092
-
22093
- var number = Number(dirtyNumber);
22094
-
22095
- if (isNaN(number)) {
22096
- return number;
22097
- }
22098
-
22099
- return number < 0 ? Math.ceil(number) : Math.floor(number);
22100
- }
22101
-
22102
- function requiredArgs(required, args) {
22103
- if (args.length < required) {
22104
- throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
22105
- }
22106
- }
22107
-
22108
22088
  /**
22109
22089
  * @name toDate
22110
22090
  * @category Common Helpers
@@ -22121,9 +22101,11 @@ function requiredArgs(required, args) {
22121
22101
  *
22122
22102
  * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
22123
22103
  *
22124
- * @param {Date|Number} argument - the value to convert
22125
- * @returns {Date} the parsed date in the local time zone
22126
- * @throws {TypeError} 1 argument required
22104
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
22105
+ *
22106
+ * @param argument - The value to convert
22107
+ *
22108
+ * @returns The parsed date in the local time zone
22127
22109
  *
22128
22110
  * @example
22129
22111
  * // Clone the date:
@@ -22135,28 +22117,68 @@ function requiredArgs(required, args) {
22135
22117
  * const result = toDate(1392098430000)
22136
22118
  * //=> Tue Feb 11 2014 11:30:30
22137
22119
  */
22138
-
22139
22120
  function toDate(argument) {
22140
- requiredArgs(1, arguments);
22141
- var argStr = Object.prototype.toString.call(argument); // Clone the date
22121
+ const argStr = Object.prototype.toString.call(argument);
22142
22122
 
22143
- if (argument instanceof Date || typeof argument === 'object' && argStr === '[object Date]') {
22123
+ // Clone the date
22124
+ if (
22125
+ argument instanceof Date ||
22126
+ (typeof argument === "object" && argStr === "[object Date]")
22127
+ ) {
22144
22128
  // Prevent the date to lose the milliseconds when passed to new Date() in IE10
22145
- return new Date(argument.getTime());
22146
- } else if (typeof argument === 'number' || argStr === '[object Number]') {
22129
+ return new argument.constructor(+argument);
22130
+ } else if (
22131
+ typeof argument === "number" ||
22132
+ argStr === "[object Number]" ||
22133
+ typeof argument === "string" ||
22134
+ argStr === "[object String]"
22135
+ ) {
22136
+ // TODO: Can we get rid of as?
22147
22137
  return new Date(argument);
22148
22138
  } else {
22149
- if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
22150
- // eslint-disable-next-line no-console
22151
- console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule"); // eslint-disable-next-line no-console
22152
-
22153
- console.warn(new Error().stack);
22154
- }
22155
-
22139
+ // TODO: Can we get rid of as?
22156
22140
  return new Date(NaN);
22157
22141
  }
22158
22142
  }
22159
22143
 
22144
+ /**
22145
+ * @name constructFrom
22146
+ * @category Generic Helpers
22147
+ * @summary Constructs a date using the reference date and the value
22148
+ *
22149
+ * @description
22150
+ * The function constructs a new date using the constructor from the reference
22151
+ * date and the given value. It helps to build generic functions that accept
22152
+ * date extensions.
22153
+ *
22154
+ * It defaults to `Date` if the passed reference date is a number or a string.
22155
+ *
22156
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
22157
+ *
22158
+ * @param date - The reference date to take constructor from
22159
+ * @param value - The value to create the date
22160
+ *
22161
+ * @returns Date initialized using the given date and value
22162
+ *
22163
+ * @example
22164
+ * import { constructFrom } from 'date-fns'
22165
+ *
22166
+ * // A function that clones a date preserving the original type
22167
+ * function cloneDate<DateType extends Date(date: DateType): DateType {
22168
+ * return constructFrom(
22169
+ * date, // Use contrustor from the given date
22170
+ * date.getTime() // Use the date value to create a new date
22171
+ * )
22172
+ * }
22173
+ */
22174
+ function constructFrom(date, value) {
22175
+ if (date instanceof Date) {
22176
+ return new date.constructor(value);
22177
+ } else {
22178
+ return new Date(value);
22179
+ }
22180
+ }
22181
+
22160
22182
  /**
22161
22183
  * @name addDays
22162
22184
  * @category Day Helpers
@@ -22165,37 +22187,60 @@ function toDate(argument) {
22165
22187
  * @description
22166
22188
  * Add the specified number of days to the given date.
22167
22189
  *
22168
- * ### v2.0.0 breaking changes:
22190
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
22169
22191
  *
22170
- * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
22192
+ * @param date - The date to be changed
22193
+ * @param amount - The amount of days to be added.
22171
22194
  *
22172
- * @param {Date|Number} date - the date to be changed
22173
- * @param {Number} amount - the amount of days to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
22174
- * @returns {Date} the new date with the days added
22175
- * @throws {TypeError} 2 arguments required
22195
+ * @returns The new date with the days added
22176
22196
  *
22177
22197
  * @example
22178
22198
  * // Add 10 days to 1 September 2014:
22179
- * var result = addDays(new Date(2014, 8, 1), 10)
22199
+ * const result = addDays(new Date(2014, 8, 1), 10)
22180
22200
  * //=> Thu Sep 11 2014 00:00:00
22181
22201
  */
22182
-
22183
- function addDays(dirtyDate, dirtyAmount) {
22184
- requiredArgs(2, arguments);
22185
- var date = toDate(dirtyDate);
22186
- var amount = toInteger(dirtyAmount);
22187
-
22188
- if (isNaN(amount)) {
22189
- return new Date(NaN);
22190
- }
22191
-
22202
+ function addDays(date, amount) {
22203
+ const _date = toDate(date);
22204
+ if (isNaN(amount)) return constructFrom(date, NaN);
22192
22205
  if (!amount) {
22193
22206
  // If 0 days, no-op to avoid changing times in the hour before end of DST
22194
- return date;
22207
+ return _date;
22195
22208
  }
22209
+ _date.setDate(_date.getDate() + amount);
22210
+ return _date;
22211
+ }
22212
+
22213
+ /**
22214
+ * @module constants
22215
+ * @summary Useful constants
22216
+ * @description
22217
+ * Collection of useful date constants.
22218
+ *
22219
+ * The constants could be imported from `date-fns/constants`:
22220
+ *
22221
+ * ```ts
22222
+ * import { maxTime, minTime } from "./constants/date-fns/constants";
22223
+ *
22224
+ * function isAllowedTime(time) {
22225
+ * return time <= maxTime && time >= minTime;
22226
+ * }
22227
+ * ```
22228
+ */
22196
22229
 
22197
- date.setDate(date.getDate() + amount);
22198
- return date;
22230
+ /**
22231
+ * @constant
22232
+ * @name millisecondsInMinute
22233
+ * @summary Milliseconds in 1 minute
22234
+ */
22235
+ const millisecondsInMinute = 60000;
22236
+
22237
+ function getRoundingMethod(method) {
22238
+ return (number) => {
22239
+ const round = method ? Math[method] : Math.trunc;
22240
+ const result = round(number);
22241
+ // Prevent negative zero
22242
+ return result === 0 ? 0 : result;
22243
+ };
22199
22244
  }
22200
22245
 
22201
22246
  /**
@@ -22206,33 +22251,30 @@ function addDays(dirtyDate, dirtyAmount) {
22206
22251
  * @description
22207
22252
  * Get the number of milliseconds between the given dates.
22208
22253
  *
22209
- * ### v2.0.0 breaking changes:
22254
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
22210
22255
  *
22211
- * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
22256
+ * @param dateLeft - The later date
22257
+ * @param dateRight - The earlier date
22212
22258
  *
22213
- * @param {Date|Number} dateLeft - the later date
22214
- * @param {Date|Number} dateRight - the earlier date
22215
- * @returns {Number} the number of milliseconds
22216
- * @throws {TypeError} 2 arguments required
22259
+ * @returns The number of milliseconds
22217
22260
  *
22218
22261
  * @example
22219
22262
  * // How many milliseconds are between
22220
22263
  * // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700?
22221
- * var result = differenceInMilliseconds(
22264
+ * const result = differenceInMilliseconds(
22222
22265
  * new Date(2014, 6, 2, 12, 30, 21, 700),
22223
22266
  * new Date(2014, 6, 2, 12, 30, 20, 600)
22224
22267
  * )
22225
22268
  * //=> 1100
22226
22269
  */
22227
-
22228
- function differenceInMilliseconds(dirtyDateLeft, dirtyDateRight) {
22229
- requiredArgs(2, arguments);
22230
- var dateLeft = toDate(dirtyDateLeft);
22231
- var dateRight = toDate(dirtyDateRight);
22232
- return dateLeft.getTime() - dateRight.getTime();
22270
+ function differenceInMilliseconds(dateLeft, dateRight) {
22271
+ return +toDate(dateLeft) - +toDate(dateRight);
22233
22272
  }
22234
22273
 
22235
- var MILLISECONDS_IN_MINUTE = 60000;
22274
+ /**
22275
+ * The {@link differenceInMinutes} function options.
22276
+ */
22277
+
22236
22278
  /**
22237
22279
  * @name differenceInMinutes
22238
22280
  * @category Minute Helpers
@@ -22241,36 +22283,34 @@ var MILLISECONDS_IN_MINUTE = 60000;
22241
22283
  * @description
22242
22284
  * Get the signed number of full (rounded towards 0) minutes between the given dates.
22243
22285
  *
22244
- * ### v2.0.0 breaking changes:
22286
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
22245
22287
  *
22246
- * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
22288
+ * @param dateLeft - The later date
22289
+ * @param dateRight - The earlier date
22290
+ * @param options - An object with options.
22247
22291
  *
22248
- * @param {Date|Number} dateLeft - the later date
22249
- * @param {Date|Number} dateRight - the earlier date
22250
- * @returns {Number} the number of minutes
22251
- * @throws {TypeError} 2 arguments required
22292
+ * @returns The number of minutes
22252
22293
  *
22253
22294
  * @example
22254
22295
  * // How many minutes are between 2 July 2014 12:07:59 and 2 July 2014 12:20:00?
22255
- * var result = differenceInMinutes(
22296
+ * const result = differenceInMinutes(
22256
22297
  * new Date(2014, 6, 2, 12, 20, 0),
22257
22298
  * new Date(2014, 6, 2, 12, 7, 59)
22258
22299
  * )
22259
22300
  * //=> 12
22260
22301
  *
22261
22302
  * @example
22262
- * // How many minutes are from 10:01:59 to 10:00:00
22263
- * var result = differenceInMinutes(
22303
+ * // How many minutes are between 10:01:59 and 10:00:00
22304
+ * const result = differenceInMinutes(
22264
22305
  * new Date(2000, 0, 1, 10, 0, 0),
22265
22306
  * new Date(2000, 0, 1, 10, 1, 59)
22266
22307
  * )
22267
22308
  * //=> -1
22268
22309
  */
22269
-
22270
- function differenceInMinutes(dirtyDateLeft, dirtyDateRight) {
22271
- requiredArgs(2, arguments);
22272
- var diff = differenceInMilliseconds(dirtyDateLeft, dirtyDateRight) / MILLISECONDS_IN_MINUTE;
22273
- return diff > 0 ? Math.floor(diff) : Math.ceil(diff);
22310
+ function differenceInMinutes(dateLeft, dateRight, options) {
22311
+ const diff =
22312
+ differenceInMilliseconds(dateLeft, dateRight) / millisecondsInMinute;
22313
+ return getRoundingMethod(options?.roundingMethod)(diff);
22274
22314
  }
22275
22315
 
22276
22316
  /**
@@ -22281,25 +22321,20 @@ function differenceInMinutes(dirtyDateLeft, dirtyDateRight) {
22281
22321
  * @description
22282
22322
  * Subtract the specified number of days from the given date.
22283
22323
  *
22284
- * ### v2.0.0 breaking changes:
22324
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
22285
22325
  *
22286
- * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
22326
+ * @param date - The date to be changed
22327
+ * @param amount - The amount of days to be subtracted.
22287
22328
  *
22288
- * @param {Date|Number} date - the date to be changed
22289
- * @param {Number} amount - the amount of days to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
22290
- * @returns {Date} the new date with the days subtracted
22291
- * @throws {TypeError} 2 arguments required
22329
+ * @returns The new date with the days subtracted
22292
22330
  *
22293
22331
  * @example
22294
22332
  * // Subtract 10 days from 1 September 2014:
22295
- * var result = subDays(new Date(2014, 8, 1), 10)
22333
+ * const result = subDays(new Date(2014, 8, 1), 10)
22296
22334
  * //=> Fri Aug 22 2014 00:00:00
22297
22335
  */
22298
-
22299
- function subDays(dirtyDate, dirtyAmount) {
22300
- requiredArgs(2, arguments);
22301
- var amount = toInteger(dirtyAmount);
22302
- return addDays(dirtyDate, -amount);
22336
+ function subDays(date, amount) {
22337
+ return addDays(date, -amount);
22303
22338
  }
22304
22339
 
22305
22340
  const WpOperationLockService = (props = {}) => common.applyDecorators(common.Injectable(), common.SetMetadata(EntityManagerSymbols.OperationLockService, {
@@ -35106,7 +35141,7 @@ exports.AwsBucketModule = AwsBucketModule_1 = __decorate([
35106
35141
  })
35107
35142
  ], exports.AwsBucketModule);
35108
35143
 
35109
- let InMemoryFileProvider = class InMemoryFileProvider {
35144
+ exports.InMemoryFileProvider = class InMemoryFileProvider {
35110
35145
  constructor() {
35111
35146
  this.provider = new exports.InMemoryBucketProvider();
35112
35147
  }
@@ -35150,10 +35185,10 @@ let InMemoryFileProvider = class InMemoryFileProvider {
35150
35185
  };
35151
35186
  }
35152
35187
  };
35153
- InMemoryFileProvider = __decorate([
35188
+ exports.InMemoryFileProvider = __decorate([
35154
35189
  WpFileProvider("inMemory"),
35155
35190
  __metadata("design:paramtypes", [])
35156
- ], InMemoryFileProvider);
35191
+ ], exports.InMemoryFileProvider);
35157
35192
  exports.InMemoryBucketProvider = class InMemoryBucketProvider {
35158
35193
  constructor() {
35159
35194
  this.inMemoryStorage = {};