@punks/backend-entity-manager 0.0.390 → 0.0.392
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 +34 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/abstractions/serializer.d.ts +1 -0
- package/dist/cjs/types/utils/index.d.ts +1 -1
- package/dist/cjs/types/utils/validators.d.ts +6 -0
- package/dist/esm/index.js +34 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/abstractions/serializer.d.ts +1 -0
- package/dist/esm/types/utils/index.d.ts +1 -1
- package/dist/esm/types/utils/validators.d.ts +6 -0
- package/dist/index.d.ts +8 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { getLocalizedText } from "./localization";
|
|
2
2
|
export { renderHandlebarsTemplate } from "./rendering";
|
|
3
3
|
export { newUuid } from "./uid";
|
|
4
|
-
export { fieldRequiredValidator, fieldOptionValidator, fieldOptionsValidator, } from "./validators";
|
|
4
|
+
export { fieldRequiredValidator, fieldOptionValidator, fieldOptionsValidator, fieldTextValidator, } from "./validators";
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { EntryValidationResult } from "../abstractions/serializer";
|
|
2
2
|
export declare const fieldRequiredValidator: <TSheetItem>(item: TSheetItem, selector: (item: TSheetItem) => any) => EntryValidationResult;
|
|
3
|
+
export declare const fieldTextValidator: <TSheetItem>(item: TSheetItem, selector: (item: TSheetItem) => any, params: {
|
|
4
|
+
required?: boolean;
|
|
5
|
+
minLength?: number;
|
|
6
|
+
maxLength?: number;
|
|
7
|
+
regex?: RegExp;
|
|
8
|
+
}) => EntryValidationResult;
|
|
3
9
|
export declare const fieldOptionValidator: <TSheetItem>(item: TSheetItem, selector: (item: TSheetItem) => string, { availableOptions, required, }: {
|
|
4
10
|
availableOptions: string[];
|
|
5
11
|
required?: boolean | undefined;
|
package/dist/esm/index.js
CHANGED
|
@@ -40742,6 +40742,39 @@ const fieldRequiredValidator = (item, selector) => {
|
|
|
40742
40742
|
validationErrors: value ? [] : [{ errorCode: "required" }],
|
|
40743
40743
|
};
|
|
40744
40744
|
};
|
|
40745
|
+
const fieldTextValidator = (item, selector, params) => {
|
|
40746
|
+
const value = selector(item);
|
|
40747
|
+
const isRequiredValid = params.required
|
|
40748
|
+
? typeof value === "string" && value.length >= 0
|
|
40749
|
+
: true;
|
|
40750
|
+
const length = typeof value === "string" ? value.length : 0;
|
|
40751
|
+
const isMinLengthValid = length >= (params.minLength ?? 0);
|
|
40752
|
+
const isMaxLengthValid = length <= (params.maxLength ?? Infinity);
|
|
40753
|
+
const isRegexValid = (typeof value === "string" && params.regex?.test(value)) ?? true;
|
|
40754
|
+
return {
|
|
40755
|
+
isValid: isMinLengthValid && isMaxLengthValid,
|
|
40756
|
+
validationErrors: [
|
|
40757
|
+
...(isRequiredValid ? [] : [{ errorCode: "required" }]),
|
|
40758
|
+
...(isMinLengthValid
|
|
40759
|
+
? []
|
|
40760
|
+
: [
|
|
40761
|
+
{
|
|
40762
|
+
errorCode: "minLength",
|
|
40763
|
+
payload: { current: length, expected: params.minLength },
|
|
40764
|
+
},
|
|
40765
|
+
]),
|
|
40766
|
+
...(isMaxLengthValid
|
|
40767
|
+
? []
|
|
40768
|
+
: [
|
|
40769
|
+
{
|
|
40770
|
+
errorCode: "maxLength",
|
|
40771
|
+
payload: { current: length, expected: params.maxLength },
|
|
40772
|
+
},
|
|
40773
|
+
]),
|
|
40774
|
+
...(isRegexValid ? [] : [{ errorCode: "regex" }]),
|
|
40775
|
+
],
|
|
40776
|
+
};
|
|
40777
|
+
};
|
|
40745
40778
|
const fieldOptionValidator = (item, selector, { availableOptions, required, }) => {
|
|
40746
40779
|
const value = selector(item);
|
|
40747
40780
|
if (!value) {
|
|
@@ -44789,5 +44822,5 @@ class TestingAppSessionService {
|
|
|
44789
44822
|
}
|
|
44790
44823
|
}
|
|
44791
44824
|
|
|
44792
|
-
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, EntityParseResult, EntityParseValidationError, 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, TaskConcurrency, TaskRunType, TasksModule, TasksService, TestingAppSessionService, 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, WpTask, WpUserRolesService, WpUserService, awsBatchSettings, buildPermissionsGuard, buildProviderToken, buildRolesGuard, createContainer, createExpressFileResponse, fieldOptionValidator, fieldOptionsValidator, fieldRequiredValidator, getEntityManagerProviderToken, getLocalizedText, newUuid, renderHandlebarsTemplate, sessionStorage, toEntitiesImportInput };
|
|
44825
|
+
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, EntityParseResult, EntityParseValidationError, 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, TaskConcurrency, TaskRunType, TasksModule, TasksService, TestingAppSessionService, 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, WpTask, WpUserRolesService, WpUserService, awsBatchSettings, buildPermissionsGuard, buildProviderToken, buildRolesGuard, createContainer, createExpressFileResponse, fieldOptionValidator, fieldOptionsValidator, fieldRequiredValidator, fieldTextValidator, getEntityManagerProviderToken, getLocalizedText, newUuid, renderHandlebarsTemplate, sessionStorage, toEntitiesImportInput };
|
|
44793
44826
|
//# sourceMappingURL=index.js.map
|