@punks/backend-entity-manager 0.0.143 → 0.0.145
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 +75 -104
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/abstractions/index.d.ts +1 -1
- package/dist/cjs/types/abstractions/searchResults.d.ts +3 -4
- package/dist/cjs/types/integrations/repository/typeorm/facets.d.ts +10 -6
- package/dist/cjs/types/integrations/repository/typeorm/queryBuilder.d.ts +7 -4
- package/dist/cjs/types/platforms/nest/__test__/server/entities/appEmailLogs/appEmailLog.models.d.ts +1 -1
- package/dist/cjs/types/platforms/nest/__test__/server/entities/crmContacts/crmContact.models.d.ts +2 -0
- package/dist/cjs/types/platforms/nest/__test__/server/entities/foos/foo.models.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/__test__/server/shared/api/facets.d.ts +18 -8
- package/dist/cjs/types/platforms/nest/index.d.ts +0 -1
- package/dist/esm/index.js +76 -99
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/abstractions/index.d.ts +1 -1
- package/dist/esm/types/abstractions/searchResults.d.ts +3 -4
- package/dist/esm/types/integrations/repository/typeorm/facets.d.ts +10 -6
- package/dist/esm/types/integrations/repository/typeorm/queryBuilder.d.ts +7 -4
- package/dist/esm/types/platforms/nest/__test__/server/entities/appEmailLogs/appEmailLog.models.d.ts +1 -1
- package/dist/esm/types/platforms/nest/__test__/server/entities/crmContacts/crmContact.models.d.ts +2 -0
- package/dist/esm/types/platforms/nest/__test__/server/entities/foos/foo.models.d.ts +2 -2
- package/dist/esm/types/platforms/nest/__test__/server/shared/api/facets.d.ts +18 -8
- package/dist/esm/types/platforms/nest/index.d.ts +0 -1
- package/dist/index.d.ts +19 -35
- package/package.json +1 -1
- package/dist/cjs/types/platforms/nest/dto/facets.d.ts +0 -25
- package/dist/cjs/types/platforms/nest/dto/index.d.ts +0 -1
- package/dist/esm/types/platforms/nest/dto/facets.d.ts +0 -25
- package/dist/esm/types/platforms/nest/dto/index.d.ts +0 -1
package/dist/cjs/index.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var backendCore = require('@punks/backend-core');
|
|
6
6
|
var common = require('@nestjs/common');
|
|
7
|
-
var swagger = require('@nestjs/swagger');
|
|
8
7
|
var core = require('@nestjs/core');
|
|
9
8
|
var async_hooks = require('async_hooks');
|
|
10
9
|
var bcrypt = require('bcrypt');
|
|
@@ -2453,98 +2452,6 @@ const WpEntityVersioningProvider = (props = {}) => common.applyDecorators(common
|
|
|
2453
2452
|
...props,
|
|
2454
2453
|
}));
|
|
2455
2454
|
|
|
2456
|
-
/******************************************************************************
|
|
2457
|
-
Copyright (c) Microsoft Corporation.
|
|
2458
|
-
|
|
2459
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
2460
|
-
purpose with or without fee is hereby granted.
|
|
2461
|
-
|
|
2462
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
2463
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
2464
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
2465
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
2466
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
2467
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
2468
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
2469
|
-
***************************************************************************** */
|
|
2470
|
-
|
|
2471
|
-
function __decorate(decorators, target, key, desc) {
|
|
2472
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2473
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2474
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2475
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2476
|
-
}
|
|
2477
|
-
|
|
2478
|
-
function __metadata(metadataKey, metadataValue) {
|
|
2479
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
2480
|
-
}
|
|
2481
|
-
|
|
2482
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
2483
|
-
var e = new Error(message);
|
|
2484
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
2485
|
-
};
|
|
2486
|
-
|
|
2487
|
-
class NumericFacetItem {
|
|
2488
|
-
}
|
|
2489
|
-
__decorate([
|
|
2490
|
-
swagger.ApiProperty(),
|
|
2491
|
-
__metadata("design:type", Number)
|
|
2492
|
-
], NumericFacetItem.prototype, "value", void 0);
|
|
2493
|
-
__decorate([
|
|
2494
|
-
swagger.ApiProperty({ required: false }),
|
|
2495
|
-
__metadata("design:type", String)
|
|
2496
|
-
], NumericFacetItem.prototype, "name", void 0);
|
|
2497
|
-
__decorate([
|
|
2498
|
-
swagger.ApiProperty({ required: false }),
|
|
2499
|
-
__metadata("design:type", Number)
|
|
2500
|
-
], NumericFacetItem.prototype, "count", void 0);
|
|
2501
|
-
class NumericFacet {
|
|
2502
|
-
}
|
|
2503
|
-
__decorate([
|
|
2504
|
-
swagger.ApiProperty({ type: [NumericFacetItem] }),
|
|
2505
|
-
__metadata("design:type", Array)
|
|
2506
|
-
], NumericFacet.prototype, "items", void 0);
|
|
2507
|
-
class BooleanFacetItem {
|
|
2508
|
-
}
|
|
2509
|
-
__decorate([
|
|
2510
|
-
swagger.ApiProperty(),
|
|
2511
|
-
__metadata("design:type", Boolean)
|
|
2512
|
-
], BooleanFacetItem.prototype, "value", void 0);
|
|
2513
|
-
__decorate([
|
|
2514
|
-
swagger.ApiProperty({ required: false }),
|
|
2515
|
-
__metadata("design:type", String)
|
|
2516
|
-
], BooleanFacetItem.prototype, "name", void 0);
|
|
2517
|
-
__decorate([
|
|
2518
|
-
swagger.ApiProperty({ required: false }),
|
|
2519
|
-
__metadata("design:type", Number)
|
|
2520
|
-
], BooleanFacetItem.prototype, "count", void 0);
|
|
2521
|
-
class BooleanFacet {
|
|
2522
|
-
}
|
|
2523
|
-
__decorate([
|
|
2524
|
-
swagger.ApiProperty({ type: [BooleanFacetItem] }),
|
|
2525
|
-
__metadata("design:type", Array)
|
|
2526
|
-
], BooleanFacet.prototype, "items", void 0);
|
|
2527
|
-
class StringFacetItem {
|
|
2528
|
-
}
|
|
2529
|
-
__decorate([
|
|
2530
|
-
swagger.ApiProperty(),
|
|
2531
|
-
__metadata("design:type", String)
|
|
2532
|
-
], StringFacetItem.prototype, "value", void 0);
|
|
2533
|
-
__decorate([
|
|
2534
|
-
swagger.ApiProperty({ required: false }),
|
|
2535
|
-
__metadata("design:type", String)
|
|
2536
|
-
], StringFacetItem.prototype, "name", void 0);
|
|
2537
|
-
__decorate([
|
|
2538
|
-
swagger.ApiProperty({ required: false }),
|
|
2539
|
-
__metadata("design:type", Number)
|
|
2540
|
-
], StringFacetItem.prototype, "count", void 0);
|
|
2541
|
-
class StringFacet {
|
|
2542
|
-
}
|
|
2543
|
-
__decorate([
|
|
2544
|
-
swagger.ApiProperty({ type: [StringFacetItem] }),
|
|
2545
|
-
__metadata("design:type", Array)
|
|
2546
|
-
], StringFacet.prototype, "items", void 0);
|
|
2547
|
-
|
|
2548
2455
|
const CurrentUser = common.createParamDecorator((data, context) => {
|
|
2549
2456
|
const request = context.switchToHttp().getRequest();
|
|
2550
2457
|
if (!request.auth) {
|
|
@@ -2618,6 +2525,37 @@ const AuthenticationEvents = {
|
|
|
2618
2525
|
UserPasswordResetCompleted: `${AUTHENTICATION_EVENTS_NAMESPACE}:user.passwordResetCompleted`,
|
|
2619
2526
|
};
|
|
2620
2527
|
|
|
2528
|
+
/******************************************************************************
|
|
2529
|
+
Copyright (c) Microsoft Corporation.
|
|
2530
|
+
|
|
2531
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
2532
|
+
purpose with or without fee is hereby granted.
|
|
2533
|
+
|
|
2534
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
2535
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
2536
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
2537
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
2538
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
2539
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
2540
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
2541
|
+
***************************************************************************** */
|
|
2542
|
+
|
|
2543
|
+
function __decorate(decorators, target, key, desc) {
|
|
2544
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2545
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2546
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2547
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2548
|
+
}
|
|
2549
|
+
|
|
2550
|
+
function __metadata(metadataKey, metadataValue) {
|
|
2551
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
2552
|
+
}
|
|
2553
|
+
|
|
2554
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
2555
|
+
var e = new Error(message);
|
|
2556
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
2557
|
+
};
|
|
2558
|
+
|
|
2621
2559
|
var AuthGuard_1;
|
|
2622
2560
|
exports.AuthGuard = AuthGuard_1 = class AuthGuard {
|
|
2623
2561
|
constructor(reflector) {
|
|
@@ -22256,8 +22194,13 @@ class TypeOrmQueryBuilder extends QueryBuilderBase {
|
|
|
22256
22194
|
facets,
|
|
22257
22195
|
};
|
|
22258
22196
|
}
|
|
22259
|
-
async
|
|
22260
|
-
this.getRepository().
|
|
22197
|
+
async getFieldDistinctValues(field, request, context) {
|
|
22198
|
+
return await this.getRepository().distinct(field, {
|
|
22199
|
+
where: {
|
|
22200
|
+
...(context ? this.buildContextFilter(context) : {}),
|
|
22201
|
+
...this.buildWhereClause(request),
|
|
22202
|
+
},
|
|
22203
|
+
});
|
|
22261
22204
|
}
|
|
22262
22205
|
async findPagedQueryResults(request, context) {
|
|
22263
22206
|
return await this.getRepository().find({
|
|
@@ -22290,14 +22233,48 @@ class TypeOrmQueryBuilder extends QueryBuilderBase {
|
|
|
22290
22233
|
});
|
|
22291
22234
|
}
|
|
22292
22235
|
async calculateFacet(field, request, context) {
|
|
22293
|
-
const
|
|
22236
|
+
const where = {
|
|
22294
22237
|
...(context ? this.buildContextFilter(context) : {}),
|
|
22295
22238
|
...this.buildWhereClause(request),
|
|
22296
|
-
}
|
|
22239
|
+
};
|
|
22240
|
+
const results = await this.getRepository()
|
|
22241
|
+
.getInnerRepository()
|
|
22242
|
+
.createQueryBuilder()
|
|
22243
|
+
.select(field, "value")
|
|
22244
|
+
.addSelect(`COUNT(${field})`, "count")
|
|
22245
|
+
.where(where)
|
|
22246
|
+
.addGroupBy(field)
|
|
22247
|
+
.orderBy(field)
|
|
22248
|
+
.getRawMany();
|
|
22297
22249
|
return {
|
|
22298
|
-
values
|
|
22250
|
+
values: results.map((x) => ({
|
|
22251
|
+
value: x.value,
|
|
22252
|
+
count: Number(x.count),
|
|
22253
|
+
})),
|
|
22299
22254
|
};
|
|
22300
22255
|
}
|
|
22256
|
+
async calculateStringFieldFacets(field, request, context) {
|
|
22257
|
+
return await this.calculateFacet(field, request, context);
|
|
22258
|
+
}
|
|
22259
|
+
async calculateNumericFieldFacets(field, request, context) {
|
|
22260
|
+
return await this.calculateFacet(field, request, context);
|
|
22261
|
+
}
|
|
22262
|
+
async calculateBooleanFieldFacets(field, request, context) {
|
|
22263
|
+
return await this.calculateFacet(field, request, context);
|
|
22264
|
+
}
|
|
22265
|
+
// protected async calculateFacet<TField extends keyof TEntity, TValue>(
|
|
22266
|
+
// field: TField,
|
|
22267
|
+
// request: TEntitySearchParameters,
|
|
22268
|
+
// context: IAuthenticationContext<TUserContext> | undefined
|
|
22269
|
+
// ): Promise<Facet<TValue>> {
|
|
22270
|
+
// const values = await this.getRepository().distinct<TField, TValue>(field, {
|
|
22271
|
+
// ...(context ? this.buildContextFilter(context) : {}),
|
|
22272
|
+
// ...this.buildWhereClause(request),
|
|
22273
|
+
// } as any)
|
|
22274
|
+
// return {
|
|
22275
|
+
// values,
|
|
22276
|
+
// }
|
|
22277
|
+
// }
|
|
22301
22278
|
getRepository() {
|
|
22302
22279
|
if (!this.repository) {
|
|
22303
22280
|
this.repository = this.services.resolveRepository();
|
|
@@ -28211,8 +28188,6 @@ exports.AuthenticationEvents = AuthenticationEvents;
|
|
|
28211
28188
|
exports.AuthenticationExtensionSymbols = AuthenticationExtensionSymbols;
|
|
28212
28189
|
exports.AwsS2BucketError = AwsS3BucketError;
|
|
28213
28190
|
exports.AwsSesEmailTemplate = AwsSesEmailTemplate;
|
|
28214
|
-
exports.BooleanFacet = BooleanFacet;
|
|
28215
|
-
exports.BooleanFacetItem = BooleanFacetItem;
|
|
28216
28191
|
exports.CurrentUser = CurrentUser;
|
|
28217
28192
|
exports.EntityManagerConfigurationError = EntityManagerConfigurationError;
|
|
28218
28193
|
exports.EntityManagerException = EntityManagerException;
|
|
@@ -28237,8 +28212,6 @@ exports.NestPipelineTemplate = NestPipelineTemplate;
|
|
|
28237
28212
|
exports.NestTypeOrmEntitySeeder = NestTypeOrmEntitySeeder;
|
|
28238
28213
|
exports.NestTypeOrmQueryBuilder = NestTypeOrmQueryBuilder;
|
|
28239
28214
|
exports.NestTypeOrmRepository = NestTypeOrmRepository;
|
|
28240
|
-
exports.NumericFacet = NumericFacet;
|
|
28241
|
-
exports.NumericFacetItem = NumericFacetItem;
|
|
28242
28215
|
exports.OperationTokenMismatchError = OperationTokenMismatchError;
|
|
28243
28216
|
exports.PLATFORM_EVENT_NAMESPACE = PLATFORM_EVENT_NAMESPACE;
|
|
28244
28217
|
exports.PipelineController = PipelineController;
|
|
@@ -28247,8 +28220,6 @@ exports.Public = Public;
|
|
|
28247
28220
|
exports.QueryBuilderBase = QueryBuilderBase;
|
|
28248
28221
|
exports.Roles = Roles;
|
|
28249
28222
|
exports.SendgridEmailTemplate = SendgridEmailTemplate;
|
|
28250
|
-
exports.StringFacet = StringFacet;
|
|
28251
|
-
exports.StringFacetItem = StringFacetItem;
|
|
28252
28223
|
exports.WpAppInitializer = WpAppInitializer;
|
|
28253
28224
|
exports.WpAwsSesEmailTemplate = WpAwsSesEmailTemplate;
|
|
28254
28225
|
exports.WpBucketProvider = WpBucketProvider;
|