@punks/backend-entity-manager 0.0.510 → 0.0.512
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 +79 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/integrations/cache/in-memory/index.d.ts +2 -0
- package/dist/cjs/types/integrations/cache/in-memory/instance.d.ts +23 -0
- package/dist/cjs/types/integrations/cache/in-memory/types.d.ts +7 -0
- package/dist/cjs/types/integrations/cache/index.d.ts +1 -0
- package/dist/esm/index.js +79 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/integrations/cache/in-memory/index.d.ts +2 -0
- package/dist/esm/types/integrations/cache/in-memory/instance.d.ts +23 -0
- package/dist/esm/types/integrations/cache/in-memory/types.d.ts +7 -0
- package/dist/esm/types/integrations/cache/index.d.ts +1 -0
- package/dist/index.d.ts +32 -1
- package/package.json +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CacheEntryDetail, CacheEntryInfo, CacheTtl, ICacheInstance } from "../../../abstractions/cache";
|
|
2
|
+
export declare abstract class InMemoryCacheInstance implements ICacheInstance {
|
|
3
|
+
protected readonly instanceName: string;
|
|
4
|
+
private readonly store;
|
|
5
|
+
constructor(instanceName: string);
|
|
6
|
+
getEntries(): Promise<CacheEntryInfo[]>;
|
|
7
|
+
getEntry(key: string): Promise<CacheEntryDetail | undefined>;
|
|
8
|
+
get<T>(key: string): Promise<T | undefined>;
|
|
9
|
+
set<T>(key: string, input: {
|
|
10
|
+
value: T;
|
|
11
|
+
ttl: CacheTtl;
|
|
12
|
+
}): Promise<void>;
|
|
13
|
+
retrieve<T>(key: string, input: {
|
|
14
|
+
ttl: CacheTtl;
|
|
15
|
+
valueFactory: () => Promise<T>;
|
|
16
|
+
}): Promise<T>;
|
|
17
|
+
delete(key: string): Promise<void>;
|
|
18
|
+
clear(): Promise<void>;
|
|
19
|
+
getInstanceName(): string;
|
|
20
|
+
private isExpired;
|
|
21
|
+
private toCacheEntryInfo;
|
|
22
|
+
private toCacheEntryDetail;
|
|
23
|
+
}
|
package/dist/esm/index.js
CHANGED
|
@@ -3177,6 +3177,83 @@ class DynamoDbCacheInstance {
|
|
|
3177
3177
|
}
|
|
3178
3178
|
}
|
|
3179
3179
|
|
|
3180
|
+
class InMemoryCacheInstance {
|
|
3181
|
+
constructor(instanceName) {
|
|
3182
|
+
this.instanceName = instanceName;
|
|
3183
|
+
this.store = new Map();
|
|
3184
|
+
}
|
|
3185
|
+
async getEntries() {
|
|
3186
|
+
const now = new Date();
|
|
3187
|
+
const entries = [];
|
|
3188
|
+
for (const entry of this.store.values()) {
|
|
3189
|
+
if (!this.isExpired(entry, now)) {
|
|
3190
|
+
entries.push(this.toCacheEntryInfo(entry));
|
|
3191
|
+
}
|
|
3192
|
+
}
|
|
3193
|
+
return entries;
|
|
3194
|
+
}
|
|
3195
|
+
async getEntry(key) {
|
|
3196
|
+
const entry = this.store.get(key);
|
|
3197
|
+
if (!entry || this.isExpired(entry, new Date())) {
|
|
3198
|
+
if (entry) {
|
|
3199
|
+
this.store.delete(key);
|
|
3200
|
+
}
|
|
3201
|
+
return undefined;
|
|
3202
|
+
}
|
|
3203
|
+
return this.toCacheEntryDetail(entry);
|
|
3204
|
+
}
|
|
3205
|
+
async get(key) {
|
|
3206
|
+
const item = await this.getEntry(key);
|
|
3207
|
+
return item?.data;
|
|
3208
|
+
}
|
|
3209
|
+
async set(key, input) {
|
|
3210
|
+
const now = Date.now();
|
|
3211
|
+
this.store.set(key, {
|
|
3212
|
+
key,
|
|
3213
|
+
data: input.value,
|
|
3214
|
+
createdOn: now,
|
|
3215
|
+
updatedOn: now,
|
|
3216
|
+
expiration: addTime(new Date(), input.ttl).getTime(),
|
|
3217
|
+
});
|
|
3218
|
+
}
|
|
3219
|
+
async retrieve(key, input) {
|
|
3220
|
+
const item = await this.get(key);
|
|
3221
|
+
if (item !== undefined) {
|
|
3222
|
+
return item;
|
|
3223
|
+
}
|
|
3224
|
+
const value = await input.valueFactory();
|
|
3225
|
+
await this.set(key, { value, ttl: input.ttl });
|
|
3226
|
+
return value;
|
|
3227
|
+
}
|
|
3228
|
+
async delete(key) {
|
|
3229
|
+
this.store.delete(key);
|
|
3230
|
+
}
|
|
3231
|
+
async clear() {
|
|
3232
|
+
this.store.clear();
|
|
3233
|
+
}
|
|
3234
|
+
getInstanceName() {
|
|
3235
|
+
return this.instanceName;
|
|
3236
|
+
}
|
|
3237
|
+
isExpired(entry, when) {
|
|
3238
|
+
return entry.expiration < when.getTime();
|
|
3239
|
+
}
|
|
3240
|
+
toCacheEntryInfo(entry) {
|
|
3241
|
+
return {
|
|
3242
|
+
instanceName: this.instanceName,
|
|
3243
|
+
key: entry.key,
|
|
3244
|
+
expiration: new Date(entry.expiration),
|
|
3245
|
+
createdOn: new Date(entry.createdOn),
|
|
3246
|
+
updatedOn: new Date(entry.updatedOn),
|
|
3247
|
+
};
|
|
3248
|
+
}
|
|
3249
|
+
toCacheEntryDetail(entry) {
|
|
3250
|
+
return {
|
|
3251
|
+
...this.toCacheEntryInfo(entry),
|
|
3252
|
+
data: entry.data,
|
|
3253
|
+
};
|
|
3254
|
+
}
|
|
3255
|
+
}
|
|
3256
|
+
|
|
3180
3257
|
class TypeormCacheInstance {
|
|
3181
3258
|
constructor(instanceName) {
|
|
3182
3259
|
this.instanceName = instanceName;
|
|
@@ -35252,7 +35329,7 @@ let TaskShell = TaskShell_1 = class TaskShell {
|
|
|
35252
35329
|
this.logger.info(`Task ${settings.name} -> completed`);
|
|
35253
35330
|
}
|
|
35254
35331
|
catch (error) {
|
|
35255
|
-
this.logger.exception(`Task ${settings.name} -> failed`, error);
|
|
35332
|
+
this.logger.exception(`Task ${settings.name} -> failed ${error?.message}`, error);
|
|
35256
35333
|
}
|
|
35257
35334
|
}
|
|
35258
35335
|
get operationsLockService() {
|
|
@@ -45524,5 +45601,5 @@ class TestingAppSessionService {
|
|
|
45524
45601
|
}
|
|
45525
45602
|
}
|
|
45526
45603
|
|
|
45527
|
-
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, DataExportService, DataSerializationFormat, DataSheetsBuilder, DataSheetsExporterService, 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, InvalidEntityHandling, 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, fieldEmailValidator, fieldNumericValidator, fieldOptionValidator, fieldOptionsValidator, fieldRequiredValidator, fieldTextValidator, getEntityManagerProviderToken, getLocalizedText, newUuid, renderHandlebarsTemplate, sessionStorage, toEntitiesImportInput };
|
|
45604
|
+
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, DataExportService, DataSerializationFormat, DataSheetsBuilder, DataSheetsExporterService, 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, InMemoryCacheInstance, InMemoryEmailProvider, InMemoryFileProvider, InMemoryMediaProvider, InMemorySecretsProvider, InvalidCredentialsError, InvalidEntityHandling, 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, fieldEmailValidator, fieldNumericValidator, fieldOptionValidator, fieldOptionsValidator, fieldRequiredValidator, fieldTextValidator, getEntityManagerProviderToken, getLocalizedText, newUuid, renderHandlebarsTemplate, sessionStorage, toEntitiesImportInput };
|
|
45528
45605
|
//# sourceMappingURL=index.js.map
|