@punks/backend-entity-manager 0.0.348 → 0.0.349

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,6 +22085,26 @@ 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
+
22088
22108
  /**
22089
22109
  * @name toDate
22090
22110
  * @category Common Helpers
@@ -22101,11 +22121,9 @@ exports.MediaLibraryService = __decorate([
22101
22121
  *
22102
22122
  * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
22103
22123
  *
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
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
22109
22127
  *
22110
22128
  * @example
22111
22129
  * // Clone the date:
@@ -22117,65 +22135,25 @@ exports.MediaLibraryService = __decorate([
22117
22135
  * const result = toDate(1392098430000)
22118
22136
  * //=> Tue Feb 11 2014 11:30:30
22119
22137
  */
22138
+
22120
22139
  function toDate(argument) {
22121
- const argStr = Object.prototype.toString.call(argument);
22140
+ requiredArgs(1, arguments);
22141
+ var argStr = Object.prototype.toString.call(argument); // Clone the date
22122
22142
 
22123
- // Clone the date
22124
- if (
22125
- argument instanceof Date ||
22126
- (typeof argument === "object" && argStr === "[object Date]")
22127
- ) {
22143
+ if (argument instanceof Date || typeof argument === 'object' && argStr === '[object Date]') {
22128
22144
  // Prevent the date to lose the milliseconds when passed to new Date() in IE10
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?
22145
+ return new Date(argument.getTime());
22146
+ } else if (typeof argument === 'number' || argStr === '[object Number]') {
22137
22147
  return new Date(argument);
22138
22148
  } else {
22139
- // TODO: Can we get rid of as?
22140
- return new Date(NaN);
22141
- }
22142
- }
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
22143
22152
 
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);
22153
+ console.warn(new Error().stack);
22154
+ }
22155
+
22156
+ return new Date(NaN);
22179
22157
  }
22180
22158
  }
22181
22159
 
@@ -22187,60 +22165,37 @@ function constructFrom(date, value) {
22187
22165
  * @description
22188
22166
  * Add the specified number of days to the given date.
22189
22167
  *
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).
22168
+ * ### v2.0.0 breaking changes:
22191
22169
  *
22192
- * @param date - The date to be changed
22193
- * @param amount - The amount of days to be added.
22170
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
22194
22171
  *
22195
- * @returns The new date with the days added
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
22196
22176
  *
22197
22177
  * @example
22198
22178
  * // Add 10 days to 1 September 2014:
22199
- * const result = addDays(new Date(2014, 8, 1), 10)
22179
+ * var result = addDays(new Date(2014, 8, 1), 10)
22200
22180
  * //=> Thu Sep 11 2014 00:00:00
22201
22181
  */
22202
- function addDays(date, amount) {
22203
- const _date = toDate(date);
22204
- if (isNaN(amount)) return constructFrom(date, NaN);
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
+
22205
22192
  if (!amount) {
22206
22193
  // If 0 days, no-op to avoid changing times in the hour before end of DST
22207
- return _date;
22194
+ return date;
22208
22195
  }
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
- */
22229
22196
 
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
- };
22197
+ date.setDate(date.getDate() + amount);
22198
+ return date;
22244
22199
  }
22245
22200
 
22246
22201
  /**
@@ -22251,30 +22206,33 @@ function getRoundingMethod(method) {
22251
22206
  * @description
22252
22207
  * Get the number of milliseconds between the given dates.
22253
22208
  *
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).
22209
+ * ### v2.0.0 breaking changes:
22255
22210
  *
22256
- * @param dateLeft - The later date
22257
- * @param dateRight - The earlier date
22211
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
22258
22212
  *
22259
- * @returns The number of milliseconds
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
22260
22217
  *
22261
22218
  * @example
22262
22219
  * // How many milliseconds are between
22263
22220
  * // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700?
22264
- * const result = differenceInMilliseconds(
22221
+ * var result = differenceInMilliseconds(
22265
22222
  * new Date(2014, 6, 2, 12, 30, 21, 700),
22266
22223
  * new Date(2014, 6, 2, 12, 30, 20, 600)
22267
22224
  * )
22268
22225
  * //=> 1100
22269
22226
  */
22270
- function differenceInMilliseconds(dateLeft, dateRight) {
22271
- return +toDate(dateLeft) - +toDate(dateRight);
22272
- }
22273
22227
 
22274
- /**
22275
- * The {@link differenceInMinutes} function options.
22276
- */
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();
22233
+ }
22277
22234
 
22235
+ var MILLISECONDS_IN_MINUTE = 60000;
22278
22236
  /**
22279
22237
  * @name differenceInMinutes
22280
22238
  * @category Minute Helpers
@@ -22283,34 +22241,36 @@ function differenceInMilliseconds(dateLeft, dateRight) {
22283
22241
  * @description
22284
22242
  * Get the signed number of full (rounded towards 0) minutes between the given dates.
22285
22243
  *
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).
22244
+ * ### v2.0.0 breaking changes:
22287
22245
  *
22288
- * @param dateLeft - The later date
22289
- * @param dateRight - The earlier date
22290
- * @param options - An object with options.
22246
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
22291
22247
  *
22292
- * @returns The number of minutes
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
22293
22252
  *
22294
22253
  * @example
22295
22254
  * // How many minutes are between 2 July 2014 12:07:59 and 2 July 2014 12:20:00?
22296
- * const result = differenceInMinutes(
22255
+ * var result = differenceInMinutes(
22297
22256
  * new Date(2014, 6, 2, 12, 20, 0),
22298
22257
  * new Date(2014, 6, 2, 12, 7, 59)
22299
22258
  * )
22300
22259
  * //=> 12
22301
22260
  *
22302
22261
  * @example
22303
- * // How many minutes are between 10:01:59 and 10:00:00
22304
- * const result = differenceInMinutes(
22262
+ * // How many minutes are from 10:01:59 to 10:00:00
22263
+ * var result = differenceInMinutes(
22305
22264
  * new Date(2000, 0, 1, 10, 0, 0),
22306
22265
  * new Date(2000, 0, 1, 10, 1, 59)
22307
22266
  * )
22308
22267
  * //=> -1
22309
22268
  */
22310
- function differenceInMinutes(dateLeft, dateRight, options) {
22311
- const diff =
22312
- differenceInMilliseconds(dateLeft, dateRight) / millisecondsInMinute;
22313
- return getRoundingMethod(options?.roundingMethod)(diff);
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);
22314
22274
  }
22315
22275
 
22316
22276
  /**
@@ -22321,20 +22281,25 @@ function differenceInMinutes(dateLeft, dateRight, options) {
22321
22281
  * @description
22322
22282
  * Subtract the specified number of days from the given date.
22323
22283
  *
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).
22284
+ * ### v2.0.0 breaking changes:
22325
22285
  *
22326
- * @param date - The date to be changed
22327
- * @param amount - The amount of days to be subtracted.
22286
+ * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
22328
22287
  *
22329
- * @returns The new date with the days subtracted
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
22330
22292
  *
22331
22293
  * @example
22332
22294
  * // Subtract 10 days from 1 September 2014:
22333
- * const result = subDays(new Date(2014, 8, 1), 10)
22295
+ * var result = subDays(new Date(2014, 8, 1), 10)
22334
22296
  * //=> Fri Aug 22 2014 00:00:00
22335
22297
  */
22336
- function subDays(date, amount) {
22337
- return addDays(date, -amount);
22298
+
22299
+ function subDays(dirtyDate, dirtyAmount) {
22300
+ requiredArgs(2, arguments);
22301
+ var amount = toInteger(dirtyAmount);
22302
+ return addDays(dirtyDate, -amount);
22338
22303
  }
22339
22304
 
22340
22305
  const WpOperationLockService = (props = {}) => common.applyDecorators(common.Injectable(), common.SetMetadata(EntityManagerSymbols.OperationLockService, {
@@ -44193,6 +44158,30 @@ exports.InMemorySecretsProvider = __decorate([
44193
44158
  WpSecretsProvider("inMemorySecretsManager")
44194
44159
  ], exports.InMemorySecretsProvider);
44195
44160
 
44161
+ class TestingAppSessionService {
44162
+ constructor() {
44163
+ this.values = new Map();
44164
+ }
44165
+ getValue(key) {
44166
+ return this.values.get(key);
44167
+ }
44168
+ setValue(key, value) {
44169
+ this.values.set(key, value);
44170
+ }
44171
+ clearValue(key) {
44172
+ this.values.set(key, undefined);
44173
+ }
44174
+ getRequest() {
44175
+ return this.values.get("request");
44176
+ }
44177
+ mockRequest(request) {
44178
+ this.values.set("request", request);
44179
+ }
44180
+ retrieveRequest() {
44181
+ return this.getRequest();
44182
+ }
44183
+ }
44184
+
44196
44185
  exports.AUTHENTICATION_EVENTS_NAMESPACE = AUTHENTICATION_EVENTS_NAMESPACE;
44197
44186
  exports.ApiKeyAccess = ApiKeyAccess;
44198
44187
  exports.AppExceptionsFilterBase = AppExceptionsFilterBase;
@@ -44247,6 +44236,7 @@ exports.QueryBuilderBase = QueryBuilderBase;
44247
44236
  exports.Roles = Roles;
44248
44237
  exports.SanityMediaError = SanityMediaError;
44249
44238
  exports.SendgridEmailTemplate = SendgridEmailTemplate;
44239
+ exports.TestingAppSessionService = TestingAppSessionService;
44250
44240
  exports.TypeOrmQueryBuilder = TypeOrmQueryBuilder;
44251
44241
  exports.TypeOrmRepository = TypeOrmRepository;
44252
44242
  exports.TypeormCacheInstance = TypeormCacheInstance;