@buka/nestjs-kit 4.2.0 → 4.3.1

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/index.mjs CHANGED
@@ -648,6 +648,44 @@ function IsResourceIdUrn(validationOptions) {
648
648
  });
649
649
  };
650
650
  }
651
+ /**
652
+ * 验证字符串是否匹配指定的 URN 模式(支持通配符 `*` 和 `**`)。
653
+ *
654
+ * - `*` 匹配恰好一个段
655
+ * - `**` 匹配零个或多个尾部段
656
+ *
657
+ * @example
658
+ * ```typescript
659
+ * class CreateClientDTO {
660
+ * @MatchesUrn('urn:buka:galaxy:client:*')
661
+ * clientUrn: string
662
+ * }
663
+ * ```
664
+ */
665
+ function MatchesUrn(pattern, validationOptions) {
666
+ return function(object, propertyName) {
667
+ registerDecorator({
668
+ name: "matchesUrn",
669
+ target: object.constructor,
670
+ propertyName,
671
+ options: validationOptions,
672
+ validator: {
673
+ validate(value) {
674
+ if (typeof value !== "string") return false;
675
+ try {
676
+ const urn = Urn.parse(value);
677
+ return Urn.parse(pattern).contains(urn);
678
+ } catch {
679
+ return false;
680
+ }
681
+ },
682
+ defaultMessage() {
683
+ return `$property must match URN pattern ${pattern}`;
684
+ }
685
+ }
686
+ });
687
+ };
688
+ }
651
689
  //#endregion
652
690
  //#region src/modules/core/decorators/class-validator/match-json-schema.ts
653
691
  const MATCH_JSON_SCHEMA = "matchJsonSchema";
@@ -2570,6 +2608,7 @@ function Jsonb(options) {
2570
2608
  * 瞬态属性装饰器,标记属性不持久化到数据库。
2571
2609
  *
2572
2610
  * 等效于 MikroORM `@Property({ persist: false })`,适用于仅在运行时使用的计算属性。
2611
+ * 同时向 ModelRegister 注册,以便类型系统正确识别该属性。
2573
2612
  *
2574
2613
  * @param options - 必须通过 `type` 指定属性类型(MikroORM v7 要求)
2575
2614
  *
@@ -2583,10 +2622,17 @@ function Jsonb(options) {
2583
2622
  * ```
2584
2623
  */
2585
2624
  function Transient(options) {
2586
- return Property$1({
2587
- persist: false,
2588
- type: options.type
2589
- });
2625
+ return (target, propertyName) => {
2626
+ ModelRegister.addProperty(target.constructor, propertyName, {
2627
+ kind: "scalar",
2628
+ optional: false,
2629
+ lazy: false
2630
+ });
2631
+ return Property$1({
2632
+ persist: false,
2633
+ type: options.type
2634
+ })(target, propertyName);
2635
+ };
2590
2636
  }
2591
2637
  //#endregion
2592
2638
  //#region src/modules/mikro-orm/decorators/columns/embedded.column.ts
@@ -9976,6 +10022,6 @@ ObjectStorageModule = __decorate([Global(), Module({
9976
10022
  exports: [ObjectStorageService]
9977
10023
  })], ObjectStorageModule);
9978
10024
  //#endregion
9979
- export { AuthException, BUKA_MODULE_OPTIONS_TOKEN, Base32, BlindIndex, BlindIndexModule, BlindIndexService, BlindIndexV1Hasher, BukaConfigurableModuleClass, BukaExceptions, BukaModule, BukaPageQueryValidationPipe, BukaValidationPipe, BusinessException, Cardinality, Column, Composite, ConfigurableModuleClass, ConflictException, CursorPagination, DatabaseConfig, DegradeException, Dictionary, DiscreteEntity, EagerType, EncryptedPayload, EntityRef, Enum, EnvelopeEncryptionModule, EnvelopeEncryptionService, ErrorCategory, ErrorCode, ErrorCodeController, ErrorCodeExceptionFilter, ErrorCodeDefinitionDto as ErrorCodeItemDto, ErrorCodeMetadataDto, ErrorCodePartsDto, ErrorCodeRegistry, ErrorResponseSchema, ExceptionDetailSchema, ExceptionModule, FeatureException, FilterQuery, FilterQueryOperators, FilterQueryOperatorsMetadataKey, FilterQueryTransformPipe, HAS_ANY_KEY, HasAnyKey, HttpException, IS_CROCKFORD_BASE32, IS_DOMAIN_URN, IS_RESOURCE_ID_URN, IS_RESOURCE_TYPE_URN, IS_SCALAR_DICTIONARY, IS_URN, InjectLogger, IsBrowserRequest, IsCrockfordBase32, IsDomainUrn, IsResourceIdUrn, IsResourceTypeUrn, IsScalar, IsScalarDictionary, IsUrn, KeyEnvelope, LinearEntity, List, ListErrorCodesResponseDto, ListResponseBodyType, Logger, LoggerConfig, LoggerErrorInterceptor, LoggerModule, MATCH_JSON_SCHEMA, MODULE_OPTIONS_TOKEN, MatchJsonSchema, Model, ModelRegister, ModuleExceptions, NextCursorPageSchema, ObjectStorageModule, ObjectStorageModuleConfig, ObjectStorageService, OffsetPageSchema, OffsetPagination, OmitType, OpenBaoAppRoleAuthConfig, OpenBaoHttpClient, OpenBaoKubernetesAuthConfig, OpenBaoModule, OpenBaoModuleConfig, OpenBaoTokenAuthConfig, OpenBaoTokenManager, OpenBaoUserpassAuthConfig, OptionalPageQuery, OrderQueryType, PageQuery, ParseUUIDv7Pipe, PartialType, PendingException, PickType, PreviousCursorPageSchema, PrimaryKeyType, PrimaryKeyTypeClassMetadataPropertyKey, Property, RateLimitException, ResponseBodyType, SaltedHash, SaltedHashModule, SaltedHashService, SaltedHashV1Hasher, Slice, SwaggerPatcher, SystemException, ThirdPartyException, TimestampedEntity, Urn, VALIDATE_NESTED_DICTIONARY, ValidateNestedDictionary, ValidationException, getExceptionModuleId, getFilterQueryOperators, isScalarClass, serializeModel, setOpenBaoToken, stableStringify };
10025
+ export { AuthException, BUKA_MODULE_OPTIONS_TOKEN, Base32, BlindIndex, BlindIndexModule, BlindIndexService, BlindIndexV1Hasher, BukaConfigurableModuleClass, BukaExceptions, BukaModule, BukaPageQueryValidationPipe, BukaValidationPipe, BusinessException, Cardinality, Column, Composite, ConfigurableModuleClass, ConflictException, CursorPagination, DatabaseConfig, DegradeException, Dictionary, DiscreteEntity, EagerType, EncryptedPayload, EntityRef, Enum, EnvelopeEncryptionModule, EnvelopeEncryptionService, ErrorCategory, ErrorCode, ErrorCodeController, ErrorCodeExceptionFilter, ErrorCodeDefinitionDto as ErrorCodeItemDto, ErrorCodeMetadataDto, ErrorCodePartsDto, ErrorCodeRegistry, ErrorResponseSchema, ExceptionDetailSchema, ExceptionModule, FeatureException, FilterQuery, FilterQueryOperators, FilterQueryOperatorsMetadataKey, FilterQueryTransformPipe, HAS_ANY_KEY, HasAnyKey, HttpException, IS_CROCKFORD_BASE32, IS_DOMAIN_URN, IS_RESOURCE_ID_URN, IS_RESOURCE_TYPE_URN, IS_SCALAR_DICTIONARY, IS_URN, InjectLogger, IsBrowserRequest, IsCrockfordBase32, IsDomainUrn, IsResourceIdUrn, IsResourceTypeUrn, IsScalar, IsScalarDictionary, IsUrn, KeyEnvelope, LinearEntity, List, ListErrorCodesResponseDto, ListResponseBodyType, Logger, LoggerConfig, LoggerErrorInterceptor, LoggerModule, MATCH_JSON_SCHEMA, MODULE_OPTIONS_TOKEN, MatchJsonSchema, MatchesUrn, Model, ModelRegister, ModuleExceptions, NextCursorPageSchema, ObjectStorageModule, ObjectStorageModuleConfig, ObjectStorageService, OffsetPageSchema, OffsetPagination, OmitType, OpenBaoAppRoleAuthConfig, OpenBaoHttpClient, OpenBaoKubernetesAuthConfig, OpenBaoModule, OpenBaoModuleConfig, OpenBaoTokenAuthConfig, OpenBaoTokenManager, OpenBaoUserpassAuthConfig, OptionalPageQuery, OrderQueryType, PageQuery, ParseUUIDv7Pipe, PartialType, PendingException, PickType, PreviousCursorPageSchema, PrimaryKeyType, PrimaryKeyTypeClassMetadataPropertyKey, Property, RateLimitException, ResponseBodyType, SaltedHash, SaltedHashModule, SaltedHashService, SaltedHashV1Hasher, Slice, SwaggerPatcher, SystemException, ThirdPartyException, TimestampedEntity, Urn, VALIDATE_NESTED_DICTIONARY, ValidateNestedDictionary, ValidationException, getExceptionModuleId, getFilterQueryOperators, isScalarClass, serializeModel, setOpenBaoToken, stableStringify };
9980
10026
 
9981
10027
  //# sourceMappingURL=index.mjs.map