@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.
@@ -1 +1 @@
1
- export { InMemoryBucketProvider } from "./mock";
1
+ export { InMemoryBucketProvider, InMemoryFileProvider } from "./mock";
package/dist/esm/index.js CHANGED
@@ -22070,26 +22070,6 @@ MediaLibraryService = __decorate([
22070
22070
  __metadata("design:paramtypes", [EntityManagerRegistry])
22071
22071
  ], MediaLibraryService);
22072
22072
 
22073
- function toInteger(dirtyNumber) {
22074
- if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
22075
- return NaN;
22076
- }
22077
-
22078
- var number = Number(dirtyNumber);
22079
-
22080
- if (isNaN(number)) {
22081
- return number;
22082
- }
22083
-
22084
- return number < 0 ? Math.ceil(number) : Math.floor(number);
22085
- }
22086
-
22087
- function requiredArgs(required, args) {
22088
- if (args.length < required) {
22089
- throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
22090
- }
22091
- }
22092
-
22093
22073
  /**
22094
22074
  * @name toDate
22095
22075
  * @category Common Helpers
@@ -22106,9 +22086,11 @@ function requiredArgs(required, args) {
22106
22086
  *
22107
22087
  * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
22108
22088
  *
22109
- * @param {Date|Number} argument - the value to convert
22110
- * @returns {Date} the parsed date in the local time zone
22111
- * @throws {TypeError} 1 argument required
22089
+ * @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).
22090
+ *
22091
+ * @param argument - The value to convert
22092
+ *
22093
+ * @returns The parsed date in the local time zone
22112
22094
  *
22113
22095
  * @example
22114
22096
  * // Clone the date:
@@ -22120,28 +22102,68 @@ function requiredArgs(required, args) {
22120
22102
  * const result = toDate(1392098430000)
22121
22103
  * //=> Tue Feb 11 2014 11:30:30
22122
22104
  */
22123
-
22124
22105
  function toDate(argument) {
22125
- requiredArgs(1, arguments);
22126
- var argStr = Object.prototype.toString.call(argument); // Clone the date
22106
+ const argStr = Object.prototype.toString.call(argument);
22127
22107
 
22128
- if (argument instanceof Date || typeof argument === 'object' && argStr === '[object Date]') {
22108
+ // Clone the date
22109
+ if (
22110
+ argument instanceof Date ||
22111
+ (typeof argument === "object" && argStr === "[object Date]")
22112
+ ) {
22129
22113
  // Prevent the date to lose the milliseconds when passed to new Date() in IE10
22130
- return new Date(argument.getTime());
22131
- } else if (typeof argument === 'number' || argStr === '[object Number]') {
22114
+ return new argument.constructor(+argument);
22115
+ } else if (
22116
+ typeof argument === "number" ||
22117
+ argStr === "[object Number]" ||
22118
+ typeof argument === "string" ||
22119
+ argStr === "[object String]"
22120
+ ) {
22121
+ // TODO: Can we get rid of as?
22132
22122
  return new Date(argument);
22133
22123
  } else {
22134
- if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
22135
- // eslint-disable-next-line no-console
22136
- 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
22137
-
22138
- console.warn(new Error().stack);
22139
- }
22140
-
22124
+ // TODO: Can we get rid of as?
22141
22125
  return new Date(NaN);
22142
22126
  }
22143
22127
  }
22144
22128
 
22129
+ /**
22130
+ * @name constructFrom
22131
+ * @category Generic Helpers
22132
+ * @summary Constructs a date using the reference date and the value
22133
+ *
22134
+ * @description
22135
+ * The function constructs a new date using the constructor from the reference
22136
+ * date and the given value. It helps to build generic functions that accept
22137
+ * date extensions.
22138
+ *
22139
+ * It defaults to `Date` if the passed reference date is a number or a string.
22140
+ *
22141
+ * @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).
22142
+ *
22143
+ * @param date - The reference date to take constructor from
22144
+ * @param value - The value to create the date
22145
+ *
22146
+ * @returns Date initialized using the given date and value
22147
+ *
22148
+ * @example
22149
+ * import { constructFrom } from 'date-fns'
22150
+ *
22151
+ * // A function that clones a date preserving the original type
22152
+ * function cloneDate<DateType extends Date(date: DateType): DateType {
22153
+ * return constructFrom(
22154
+ * date, // Use contrustor from the given date
22155
+ * date.getTime() // Use the date value to create a new date
22156
+ * )
22157
+ * }
22158
+ */
22159
+ function constructFrom(date, value) {
22160
+ if (date instanceof Date) {
22161
+ return new date.constructor(value);
22162
+ } else {
22163
+ return new Date(value);
22164
+ }
22165
+ }
22166
+
22145
22167
  /**
22146
22168
  * @name addDays
22147
22169
  * @category Day Helpers
@@ -22150,37 +22172,60 @@ function toDate(argument) {
22150
22172
  * @description
22151
22173
  * Add the specified number of days to the given date.
22152
22174
  *
22153
- * ### v2.0.0 breaking changes:
22175
+ * @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).
22154
22176
  *
22155
- * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
22177
+ * @param date - The date to be changed
22178
+ * @param amount - The amount of days to be added.
22156
22179
  *
22157
- * @param {Date|Number} date - the date to be changed
22158
- * @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`.
22159
- * @returns {Date} the new date with the days added
22160
- * @throws {TypeError} 2 arguments required
22180
+ * @returns The new date with the days added
22161
22181
  *
22162
22182
  * @example
22163
22183
  * // Add 10 days to 1 September 2014:
22164
- * var result = addDays(new Date(2014, 8, 1), 10)
22184
+ * const result = addDays(new Date(2014, 8, 1), 10)
22165
22185
  * //=> Thu Sep 11 2014 00:00:00
22166
22186
  */
22167
-
22168
- function addDays(dirtyDate, dirtyAmount) {
22169
- requiredArgs(2, arguments);
22170
- var date = toDate(dirtyDate);
22171
- var amount = toInteger(dirtyAmount);
22172
-
22173
- if (isNaN(amount)) {
22174
- return new Date(NaN);
22175
- }
22176
-
22187
+ function addDays(date, amount) {
22188
+ const _date = toDate(date);
22189
+ if (isNaN(amount)) return constructFrom(date, NaN);
22177
22190
  if (!amount) {
22178
22191
  // If 0 days, no-op to avoid changing times in the hour before end of DST
22179
- return date;
22192
+ return _date;
22180
22193
  }
22194
+ _date.setDate(_date.getDate() + amount);
22195
+ return _date;
22196
+ }
22197
+
22198
+ /**
22199
+ * @module constants
22200
+ * @summary Useful constants
22201
+ * @description
22202
+ * Collection of useful date constants.
22203
+ *
22204
+ * The constants could be imported from `date-fns/constants`:
22205
+ *
22206
+ * ```ts
22207
+ * import { maxTime, minTime } from "./constants/date-fns/constants";
22208
+ *
22209
+ * function isAllowedTime(time) {
22210
+ * return time <= maxTime && time >= minTime;
22211
+ * }
22212
+ * ```
22213
+ */
22181
22214
 
22182
- date.setDate(date.getDate() + amount);
22183
- return date;
22215
+ /**
22216
+ * @constant
22217
+ * @name millisecondsInMinute
22218
+ * @summary Milliseconds in 1 minute
22219
+ */
22220
+ const millisecondsInMinute = 60000;
22221
+
22222
+ function getRoundingMethod(method) {
22223
+ return (number) => {
22224
+ const round = method ? Math[method] : Math.trunc;
22225
+ const result = round(number);
22226
+ // Prevent negative zero
22227
+ return result === 0 ? 0 : result;
22228
+ };
22184
22229
  }
22185
22230
 
22186
22231
  /**
@@ -22191,33 +22236,30 @@ function addDays(dirtyDate, dirtyAmount) {
22191
22236
  * @description
22192
22237
  * Get the number of milliseconds between the given dates.
22193
22238
  *
22194
- * ### v2.0.0 breaking changes:
22239
+ * @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).
22195
22240
  *
22196
- * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
22241
+ * @param dateLeft - The later date
22242
+ * @param dateRight - The earlier date
22197
22243
  *
22198
- * @param {Date|Number} dateLeft - the later date
22199
- * @param {Date|Number} dateRight - the earlier date
22200
- * @returns {Number} the number of milliseconds
22201
- * @throws {TypeError} 2 arguments required
22244
+ * @returns The number of milliseconds
22202
22245
  *
22203
22246
  * @example
22204
22247
  * // How many milliseconds are between
22205
22248
  * // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700?
22206
- * var result = differenceInMilliseconds(
22249
+ * const result = differenceInMilliseconds(
22207
22250
  * new Date(2014, 6, 2, 12, 30, 21, 700),
22208
22251
  * new Date(2014, 6, 2, 12, 30, 20, 600)
22209
22252
  * )
22210
22253
  * //=> 1100
22211
22254
  */
22212
-
22213
- function differenceInMilliseconds(dirtyDateLeft, dirtyDateRight) {
22214
- requiredArgs(2, arguments);
22215
- var dateLeft = toDate(dirtyDateLeft);
22216
- var dateRight = toDate(dirtyDateRight);
22217
- return dateLeft.getTime() - dateRight.getTime();
22255
+ function differenceInMilliseconds(dateLeft, dateRight) {
22256
+ return +toDate(dateLeft) - +toDate(dateRight);
22218
22257
  }
22219
22258
 
22220
- var MILLISECONDS_IN_MINUTE = 60000;
22259
+ /**
22260
+ * The {@link differenceInMinutes} function options.
22261
+ */
22262
+
22221
22263
  /**
22222
22264
  * @name differenceInMinutes
22223
22265
  * @category Minute Helpers
@@ -22226,36 +22268,34 @@ var MILLISECONDS_IN_MINUTE = 60000;
22226
22268
  * @description
22227
22269
  * Get the signed number of full (rounded towards 0) minutes between the given dates.
22228
22270
  *
22229
- * ### v2.0.0 breaking changes:
22271
+ * @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).
22230
22272
  *
22231
- * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
22273
+ * @param dateLeft - The later date
22274
+ * @param dateRight - The earlier date
22275
+ * @param options - An object with options.
22232
22276
  *
22233
- * @param {Date|Number} dateLeft - the later date
22234
- * @param {Date|Number} dateRight - the earlier date
22235
- * @returns {Number} the number of minutes
22236
- * @throws {TypeError} 2 arguments required
22277
+ * @returns The number of minutes
22237
22278
  *
22238
22279
  * @example
22239
22280
  * // How many minutes are between 2 July 2014 12:07:59 and 2 July 2014 12:20:00?
22240
- * var result = differenceInMinutes(
22281
+ * const result = differenceInMinutes(
22241
22282
  * new Date(2014, 6, 2, 12, 20, 0),
22242
22283
  * new Date(2014, 6, 2, 12, 7, 59)
22243
22284
  * )
22244
22285
  * //=> 12
22245
22286
  *
22246
22287
  * @example
22247
- * // How many minutes are from 10:01:59 to 10:00:00
22248
- * var result = differenceInMinutes(
22288
+ * // How many minutes are between 10:01:59 and 10:00:00
22289
+ * const result = differenceInMinutes(
22249
22290
  * new Date(2000, 0, 1, 10, 0, 0),
22250
22291
  * new Date(2000, 0, 1, 10, 1, 59)
22251
22292
  * )
22252
22293
  * //=> -1
22253
22294
  */
22254
-
22255
- function differenceInMinutes(dirtyDateLeft, dirtyDateRight) {
22256
- requiredArgs(2, arguments);
22257
- var diff = differenceInMilliseconds(dirtyDateLeft, dirtyDateRight) / MILLISECONDS_IN_MINUTE;
22258
- return diff > 0 ? Math.floor(diff) : Math.ceil(diff);
22295
+ function differenceInMinutes(dateLeft, dateRight, options) {
22296
+ const diff =
22297
+ differenceInMilliseconds(dateLeft, dateRight) / millisecondsInMinute;
22298
+ return getRoundingMethod(options?.roundingMethod)(diff);
22259
22299
  }
22260
22300
 
22261
22301
  /**
@@ -22266,25 +22306,20 @@ function differenceInMinutes(dirtyDateLeft, dirtyDateRight) {
22266
22306
  * @description
22267
22307
  * Subtract the specified number of days from the given date.
22268
22308
  *
22269
- * ### v2.0.0 breaking changes:
22309
+ * @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).
22270
22310
  *
22271
- * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
22311
+ * @param date - The date to be changed
22312
+ * @param amount - The amount of days to be subtracted.
22272
22313
  *
22273
- * @param {Date|Number} date - the date to be changed
22274
- * @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`.
22275
- * @returns {Date} the new date with the days subtracted
22276
- * @throws {TypeError} 2 arguments required
22314
+ * @returns The new date with the days subtracted
22277
22315
  *
22278
22316
  * @example
22279
22317
  * // Subtract 10 days from 1 September 2014:
22280
- * var result = subDays(new Date(2014, 8, 1), 10)
22318
+ * const result = subDays(new Date(2014, 8, 1), 10)
22281
22319
  * //=> Fri Aug 22 2014 00:00:00
22282
22320
  */
22283
-
22284
- function subDays(dirtyDate, dirtyAmount) {
22285
- requiredArgs(2, arguments);
22286
- var amount = toInteger(dirtyAmount);
22287
- return addDays(dirtyDate, -amount);
22321
+ function subDays(date, amount) {
22322
+ return addDays(date, -amount);
22288
22323
  }
22289
22324
 
22290
22325
  const WpOperationLockService = (props = {}) => applyDecorators(Injectable(), SetMetadata(EntityManagerSymbols.OperationLockService, {
@@ -44143,5 +44178,5 @@ InMemorySecretsProvider = __decorate([
44143
44178
  WpSecretsProvider("inMemorySecretsManager")
44144
44179
  ], InMemorySecretsProvider);
44145
44180
 
44146
- export { AUTHENTICATION_EVENTS_NAMESPACE, ApiKeyAccess, AppExceptionsFilterBase, AppHashingService, AppInMemorySettings, AppSession, AppSessionMiddleware, AppSessionService, AuthGuard, Authenticated, AuthenticationEmailTemplates, AuthenticationError, AuthenticationEvents, AuthenticationExtensionSymbols, AuthenticationModule, AuthenticationService, AwsBucketModule, AwsDynamoDbModule, AwsEmailModule, AwsJobsModule, AwsS3BucketError, AwsS3BucketProvider, AwsS3MediaError, AwsS3MediaModule, AwsS3MediaProvider, AwsSecretsModule, AwsSecretsProvider, AwsSesEmailTemplate, BucketItemType, CacheService, ConnectorMode, CurrentUser, CustomDiscoveryModule, CustomDiscoveryService, DynamoDbCacheInstance, DynamoDbCollection, EmailService, EntityManagerConfigurationError, EntityManagerException, EntityManagerInitializer, EntityManagerModule, EntityManagerRegistry, EntityManagerService, EntityManagerSymbols, EntityManagerUnauthorizedException, EntityNotFoundException, EntityOperationType, EntityOperationUnauthorizedException, EntitySeeder, EntitySerializationFormat, EntitySerializer, EntitySnapshotService, EntityVersionOperation, EventsService, ExclusiveOperationResult, FilesManager, IEntityVersionsCursor, InMemoryBucketProvider, InMemoryEmailProvider, InMemoryMediaProvider, InMemorySecretsProvider, InvalidCredentialsError, JobConcurrency, JobInstance, JobProviderState, JobRunType, JobSchedule, JobStatus, JobsModule, JobsService, LockNotFoundError, MediaLibraryService, MemberOf, MissingEntityIdError, ModulesContainerProvider, MultiTenancyModule, MultipleEntitiesFoundException, NestEntityActions, NestEntityAuthorizationMiddleware, NestEntityManager, NestEntitySerializer, NestEntitySnapshotService, NestPipelineTemplate, NestTypeOrmEntitySeeder, NestTypeOrmQueryBuilder, NestTypeOrmRepository, OperationLockService, OperationTokenMismatchError, PLATFORM_EVENT_NAMESPACE, Permissions, PipelineController, PipelineErrorType, PipelineInvocationError, PipelineStatus, PipelineStepErrorType, PipelinesBuilder, PipelinesRunner, PlatformEvents, Public, QueryBuilderBase, QueryBuilderOperation, ReplicationMode, Roles, SanityMediaError, SanityMediaModule, SanityMediaProvider, SecretsService, SendgridEmailModule, SendgridEmailTemplate, SortDirection, TrackingService, TypeOrmQueryBuilder, TypeOrmRepository, TypeormCacheInstance, TypeormOperationLockRepository, UserCreationError, UserRegistrationError, WpApiKeysService, WpAppInitializer, WpAwsSesEmailTemplate, WpBucketProvider, WpCacheInstance, WpEmailLogger, WpEmailProvider, WpEmailTemplate, WpEmailTemplateMiddleware, WpEntity, WpEntityActions, WpEntityAdapter, WpEntityAuthMiddleware, WpEntityConnector, WpEntityConnectorMapper, WpEntityConverter, WpEntityManager, WpEntityQueryBuilder, WpEntityRepository, WpEntitySeeder, WpEntitySerializer, WpEntitySnapshotService, WpEntityVersioningProvider, WpEventsTracker, WpFileProvider, WpFileReferenceRepository, WpGlobalAuthenticationMiddleware, WpMediaFolderRepository, WpMediaProvider, WpMediaReferenceRepository, WpPermissionsService, WpPipeline, WpRolesService, WpSendgridEmailTemplate, WpUserRolesService, WpUserService, awsBatchSettings, buildPermissionsGuard, buildProviderToken, buildRolesGuard, createContainer, createExpressFileResponse, getEntityManagerProviderToken, getLocalizedText, newUuid, renderHandlebarsTemplate, sessionStorage, toEntitiesImportInput };
44181
+ export { AUTHENTICATION_EVENTS_NAMESPACE, ApiKeyAccess, AppExceptionsFilterBase, AppHashingService, AppInMemorySettings, AppSession, AppSessionMiddleware, AppSessionService, AuthGuard, Authenticated, AuthenticationEmailTemplates, AuthenticationError, AuthenticationEvents, AuthenticationExtensionSymbols, AuthenticationModule, AuthenticationService, AwsBucketModule, AwsDynamoDbModule, AwsEmailModule, AwsJobsModule, AwsS3BucketError, AwsS3BucketProvider, AwsS3MediaError, AwsS3MediaModule, AwsS3MediaProvider, AwsSecretsModule, AwsSecretsProvider, AwsSesEmailTemplate, BucketItemType, CacheService, ConnectorMode, CurrentUser, CustomDiscoveryModule, CustomDiscoveryService, DynamoDbCacheInstance, DynamoDbCollection, EmailService, EntityManagerConfigurationError, EntityManagerException, EntityManagerInitializer, EntityManagerModule, EntityManagerRegistry, EntityManagerService, EntityManagerSymbols, EntityManagerUnauthorizedException, EntityNotFoundException, EntityOperationType, EntityOperationUnauthorizedException, EntitySeeder, EntitySerializationFormat, EntitySerializer, EntitySnapshotService, EntityVersionOperation, EventsService, ExclusiveOperationResult, FilesManager, IEntityVersionsCursor, InMemoryBucketProvider, InMemoryEmailProvider, InMemoryFileProvider, InMemoryMediaProvider, InMemorySecretsProvider, InvalidCredentialsError, JobConcurrency, JobInstance, JobProviderState, JobRunType, JobSchedule, JobStatus, JobsModule, JobsService, LockNotFoundError, MediaLibraryService, MemberOf, MissingEntityIdError, ModulesContainerProvider, MultiTenancyModule, MultipleEntitiesFoundException, NestEntityActions, NestEntityAuthorizationMiddleware, NestEntityManager, NestEntitySerializer, NestEntitySnapshotService, NestPipelineTemplate, NestTypeOrmEntitySeeder, NestTypeOrmQueryBuilder, NestTypeOrmRepository, OperationLockService, OperationTokenMismatchError, PLATFORM_EVENT_NAMESPACE, Permissions, PipelineController, PipelineErrorType, PipelineInvocationError, PipelineStatus, PipelineStepErrorType, PipelinesBuilder, PipelinesRunner, PlatformEvents, Public, QueryBuilderBase, QueryBuilderOperation, ReplicationMode, Roles, SanityMediaError, SanityMediaModule, SanityMediaProvider, SecretsService, SendgridEmailModule, SendgridEmailTemplate, SortDirection, TrackingService, TypeOrmQueryBuilder, TypeOrmRepository, TypeormCacheInstance, TypeormOperationLockRepository, UserCreationError, UserRegistrationError, WpApiKeysService, WpAppInitializer, WpAwsSesEmailTemplate, WpBucketProvider, WpCacheInstance, WpEmailLogger, WpEmailProvider, WpEmailTemplate, WpEmailTemplateMiddleware, WpEntity, WpEntityActions, WpEntityAdapter, WpEntityAuthMiddleware, WpEntityConnector, WpEntityConnectorMapper, WpEntityConverter, WpEntityManager, WpEntityQueryBuilder, WpEntityRepository, WpEntitySeeder, WpEntitySerializer, WpEntitySnapshotService, WpEntityVersioningProvider, WpEventsTracker, WpFileProvider, WpFileReferenceRepository, WpGlobalAuthenticationMiddleware, WpMediaFolderRepository, WpMediaProvider, WpMediaReferenceRepository, WpPermissionsService, WpPipeline, WpRolesService, WpSendgridEmailTemplate, WpUserRolesService, WpUserService, awsBatchSettings, buildPermissionsGuard, buildProviderToken, buildRolesGuard, createContainer, createExpressFileResponse, getEntityManagerProviderToken, getLocalizedText, newUuid, renderHandlebarsTemplate, sessionStorage, toEntitiesImportInput };
44147
44182
  //# sourceMappingURL=index.js.map