@buka/nestjs-kit 4.1.9 → 4.2.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.2.0](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.1.9...v4.2.0) (2026-05-24)
4
+
5
+
6
+ ### Features
7
+
8
+ * urn支持通配符 ([31bc4e1](https://github.com/buka-ltd/npm.nestjs-kit/commit/31bc4e13045255eb99b8b719589af697046005d0))
9
+
3
10
  ## [4.1.9](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.1.8...v4.1.9) (2026-05-24)
4
11
 
5
12
 
package/dist/index.d.mts CHANGED
@@ -227,9 +227,9 @@ declare function IsScalarDictionary(ctor: ScalarClass, validationOptions?: Valid
227
227
  //#endregion
228
228
  //#region src/modules/core/decorators/class-validator/is-urn.d.ts
229
229
  declare const IS_URN = "isUrn";
230
- declare const IS_NAMESPACE_URN = "isNamespaceUrn";
231
- declare const IS_RESOURCE_URN = "isResourceUrn";
232
- declare const IS_IDENTIFIER_URN = "isIdentifierUrn";
230
+ declare const IS_DOMAIN_URN = "isDomainUrn";
231
+ declare const IS_RESOURCE_TYPE_URN = "isResourceTypeUrn";
232
+ declare const IS_RESOURCE_ID_URN = "isResourceIdUrn";
233
233
  /**
234
234
  * 验证字符串是否为合法的 URN(任意层级)。
235
235
  *
@@ -243,41 +243,41 @@ declare const IS_IDENTIFIER_URN = "isIdentifierUrn";
243
243
  */
244
244
  declare function IsUrn(validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
245
245
  /**
246
- * 验证字符串是否为 namespace 级 URN(仅含 namespace,无 resource 和 identifier)。
246
+ * 验证字符串是否为概念域级 URN(仅含 domain,无 resourceType 和 resourceId)。
247
247
  *
248
248
  * @example
249
249
  * ```typescript
250
250
  * class TokenPayloadDTO {
251
- * @IsNamespaceUrn()
251
+ * @IsDomainUrn()
252
252
  * aud: string
253
253
  * }
254
254
  * ```
255
255
  */
256
- declare function IsNamespaceUrn(validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
256
+ declare function IsDomainUrn(validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
257
257
  /**
258
- * 验证字符串是否为资源类型级 URN(含 namespace 和 resource,无 identifier)。
258
+ * 验证字符串是否为资源类型级 URN(含 domain 和 resourceType,无 resourceId)。
259
259
  *
260
260
  * @example
261
261
  * ```typescript
262
262
  * class ResourceDTO {
263
- * @IsResourceUrn()
263
+ * @IsResourceTypeUrn()
264
264
  * resourceType: string
265
265
  * }
266
266
  * ```
267
267
  */
268
- declare function IsResourceUrn(validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
268
+ declare function IsResourceTypeUrn(validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
269
269
  /**
270
- * 验证字符串是否为实例级 URN(含完整三段:namespace、resource 和 identifier)。
270
+ * 验证字符串是否为实例级 URN(含完整三段:domain、resourceType 和 resourceId)。
271
271
  *
272
272
  * @example
273
273
  * ```typescript
274
274
  * class TokenPayloadDTO {
275
- * @IsIdentifierUrn()
275
+ * @IsResourceIdUrn()
276
276
  * sub: string
277
277
  * }
278
278
  * ```
279
279
  */
280
- declare function IsIdentifierUrn(validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
280
+ declare function IsResourceIdUrn(validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
281
281
  //#endregion
282
282
  //#region src/modules/core/decorators/class-validator/match-json-schema.d.ts
283
283
  declare const MATCH_JSON_SCHEMA = "matchJsonSchema";
@@ -969,123 +969,142 @@ declare class Slice<T extends object> {
969
969
  /**
970
970
  * 统一资源名称(URN)
971
971
  *
972
- * 格式: urn:buka:<namespace>[:<resource>[:<identifier>]]
972
+ * 格式: urn:buka:<domain>:<resource-type>[:<resource-id>]
973
973
  *
974
974
  * 支持三种粒度:
975
- * - namespace 级: urn:buka:galaxy
975
+ * - 概念域级: urn:buka:galaxy
976
976
  * - 资源类型级: urn:buka:galaxy:principal
977
977
  * - 实例级: urn:buka:galaxy:principal:550e8400-e29b-41d4-a716-446655440000
978
978
  *
979
- * namespace 划分原则:按资源类型的定义权归属划分,非按部署单元。
979
+ * domain 划分原则:按资源类型的定义权归属划分,非按部署单元。
980
+ * resource-type 第一级推荐用于 env(环境),这是一个语义约定,不强制。
980
981
  *
981
982
  * 推荐通过静态工厂方法或派生方法构建层级 URN:
982
983
  * ```ts
983
- * Urn.of('galaxy') // → NamespaceUrn
984
- * Urn.of('galaxy', 'principal') // → ResourceUrn
985
- * Urn.of('galaxy', 'principal', '550e8400-...') // → IdentifierUrn
984
+ * Urn.of('galaxy') // → DomainUrn
985
+ * Urn.of('galaxy', 'principal') // → ResourceTypeUrn
986
+ * Urn.of('galaxy', 'principal', '550e8400-...') // → ResourceIdUrn
986
987
  *
987
988
  * // 或通过派生方法逐层构建
988
989
  * Urn.of('galaxy')
989
- * .withResource('principal') // → ResourceUrn
990
- * .withIdentifier('550e8400-...') // → IdentifierUrn
990
+ * .withResourceType('principal') // → ResourceTypeUrn
991
+ * .withResourceId('550e8400-...') // → ResourceIdUrn
991
992
  * ```
992
993
  */
993
994
  declare class Urn {
994
- /** 资源类型所有者(概念域/平台),如 galaxy、infra */
995
- readonly namespace: string;
996
- /** 资源类型,如 principal、oauth2-client */
997
- readonly resource?: string | undefined;
998
- /** 资源唯一标识 */
999
- readonly identifier?: string | undefined;
995
+ /** 概念域 — 资源类型定义权归属,通常为系统名 */
996
+ readonly domain: string;
997
+ /** 资源类型,可多级。第一级推荐用于 env */
998
+ readonly resourceType?: string | undefined;
999
+ /** 资源实例唯一标识 */
1000
+ readonly resourceId?: string | undefined;
1000
1001
  private constructor();
1001
1002
  /**
1002
1003
  * 序列化为 URN 字符串
1003
1004
  */
1004
1005
  toString(): string;
1006
+ /**
1007
+ * 返回 resourceType 按 `:` 拆分后的层级数组
1008
+ */
1009
+ get resourceTypeSegments(): string[];
1010
+ private toSegments;
1005
1011
  /**
1006
1012
  * 衍生出资源类型级 URN
1007
1013
  *
1008
- * @throws Error 当前 URN 已有 resource 时抛出
1014
+ * @throws Error 当前 URN 已有 resourceType 时抛出
1009
1015
  */
1010
- withResource(resource: string): ResourceUrn;
1016
+ withResourceType(resourceType: string): ResourceTypeUrn;
1011
1017
  /**
1012
1018
  * 衍生出实例级 URN
1013
1019
  *
1014
- * @throws Error 当前 URN 无 resource 或已有 identifier 时抛出
1020
+ * @throws Error 当前 URN 无 resourceType 或已有 resourceId 时抛出
1015
1021
  */
1016
- withIdentifier(identifier: string): IdentifierUrn;
1022
+ withResourceId(resourceId: string): ResourceIdUrn;
1017
1023
  /**
1018
- * 类型守卫:判断是否为 namespace 级 URN
1024
+ * 类型守卫:判断是否为概念域级 URN
1019
1025
  */
1020
- isNamespaceUrn(): this is NamespaceUrn;
1026
+ isDomainUrn(): this is DomainUrn;
1021
1027
  /**
1022
1028
  * 类型守卫:判断是否为资源类型级 URN
1023
1029
  */
1024
- isResourceUrn(): this is ResourceUrn;
1030
+ isResourceTypeUrn(): this is ResourceTypeUrn;
1025
1031
  /**
1026
1032
  * 类型守卫:判断是否为实例级 URN
1027
1033
  */
1028
- isIdentifierUrn(): this is IdentifierUrn;
1034
+ isResourceIdUrn(): this is ResourceIdUrn;
1029
1035
  /**
1030
1036
  * 根据参数创建对应层级的 URN
1031
1037
  *
1032
1038
  * 重载签名使返回类型随参数数量自动窄化:
1033
- * - 仅 namespace → NamespaceUrn
1034
- * - namespace + resource → ResourceUrn
1035
- * - namespace + resource + identifier → IdentifierUrn
1039
+ * - 仅 domain → DomainUrn
1040
+ * - domain + resourceType → ResourceTypeUrn
1041
+ * - domain + resourceType + resourceId → ResourceIdUrn
1036
1042
  */
1037
- static of(namespace: string): NamespaceUrn;
1038
- static of(namespace: string, resource: string): ResourceUrn;
1039
- static of(namespace: string, resource: string, identifier: string): IdentifierUrn;
1043
+ static of(domain: string): DomainUrn;
1044
+ static of(domain: string, resourceType: string): ResourceTypeUrn;
1045
+ static of(domain: string, resourceType: string, resourceId: string): ResourceIdUrn;
1040
1046
  /**
1041
- * 从 URN 字符串解析
1047
+ * 从 URN 字符串解析,支持通配符 `*` 和 `**`
1048
+ *
1049
+ * - `*` 匹配恰好一个段
1050
+ * - `**` 匹配零个或多个尾部段(仅允许出现在末尾)
1042
1051
  *
1043
1052
  * @throws Error URN 格式不合法时抛出
1044
1053
  */
1045
1054
  static parse(urn: string): Urn;
1046
1055
  /**
1047
- * 判断是否匹配指定的 namespace、resource 和 identifier
1056
+ * 判断是否匹配指定的 domain、resourceType 和 resourceId
1048
1057
  *
1049
1058
  * 仅比较传入的参数,未传入的参数不参与比较。
1050
1059
  */
1051
- is(namespace: string, resource?: string, identifier?: string): boolean;
1060
+ is(domain: string, resourceType?: string, resourceId?: string): boolean;
1061
+ /**
1062
+ * 判断当前 URN 是否包含另一个 URN
1063
+ *
1064
+ * 当前 URN 含通配符(`*` 或 `**`)时,作为集合模式判断:
1065
+ * - `*` 匹配恰好一个段
1066
+ * - `**` 匹配零个或多个尾部段(仅末尾有效)
1067
+ *
1068
+ * 当前 URN 为具体 URN(无通配符)时,仅包含自身(严格相等)。
1069
+ */
1070
+ contains(other: Urn): boolean;
1052
1071
  }
1053
1072
  /**
1054
- * namespace 级 URN — 仅含 namespace,无 resource 和 identifier
1073
+ * 概念域级 URN — 仅含 domain,无 resourceType 和 resourceId
1055
1074
  *
1056
- * 可通过 `withResource()` 衍生出 `ResourceUrn`。
1057
- * 禁止直接调用 `withIdentifier()`(跳层派生)。
1075
+ * 可通过 `withResourceType()` 衍生出 `ResourceTypeUrn`。
1076
+ * 禁止直接调用 `withResourceId()`(跳层派生)。
1058
1077
  */
1059
- interface NamespaceUrn extends Urn {
1060
- readonly resource: undefined;
1061
- readonly identifier: undefined;
1062
- /** @deprecated 禁止跳层派生,请先调用 withResource() */
1063
- withIdentifier: never;
1078
+ interface DomainUrn extends Urn {
1079
+ readonly resourceType: undefined;
1080
+ readonly resourceId: undefined;
1081
+ /** @deprecated 禁止跳层派生,请先调用 withResourceType() */
1082
+ withResourceId: never;
1064
1083
  }
1065
1084
  /**
1066
- * 资源类型级 URN — 含 namespace 和 resource,无 identifier
1085
+ * 资源类型级 URN — 含 domain 和 resourceType,无 resourceId
1067
1086
  *
1068
- * 可通过 `withIdentifier()` 衍生出 `IdentifierUrn`。
1069
- * 禁止调用 `withResource()`(横向衍生另一个资源类型)。
1087
+ * 可通过 `withResourceId()` 衍生出 `ResourceIdUrn`。
1088
+ * 禁止调用 `withResourceType()`(横向衍生另一个资源类型)。
1070
1089
  */
1071
- interface ResourceUrn extends Urn {
1072
- readonly resource: string;
1073
- readonly identifier: undefined;
1074
- /** @deprecated 禁止横向衍生,ResourceUrn 不能再衍生另一个资源类型 */
1075
- withResource: never;
1090
+ interface ResourceTypeUrn extends Urn {
1091
+ readonly resourceType: string;
1092
+ readonly resourceId: undefined;
1093
+ /** @deprecated 禁止横向衍生,ResourceTypeUrn 不能再衍生另一个资源类型 */
1094
+ withResourceType: never;
1076
1095
  }
1077
1096
  /**
1078
- * 实例级 URN — 含完整三段:namespace、resource 和 identifier
1097
+ * 实例级 URN — 含完整三段:domain、resourceType 和 resourceId
1079
1098
  *
1080
1099
  * 终态 URN,不可继续衍生。
1081
1100
  */
1082
- interface IdentifierUrn extends Urn {
1083
- readonly resource: string;
1084
- readonly identifier: string;
1101
+ interface ResourceIdUrn extends Urn {
1102
+ readonly resourceType: string;
1103
+ readonly resourceId: string;
1085
1104
  /** @deprecated 终态 URN,不可继续衍生 */
1086
- withResource: never;
1105
+ withResourceType: never;
1087
1106
  /** @deprecated 终态 URN,不可继续衍生 */
1088
- withIdentifier: never;
1107
+ withResourceId: never;
1089
1108
  }
1090
1109
  //#endregion
1091
1110
  //#region src/modules/core/converters/eager-type/eager-type.d.ts
@@ -18660,5 +18679,5 @@ declare class ObjectStorageService implements OnModuleInit {
18660
18679
  */
18661
18680
  declare function stableStringify(value: unknown): string;
18662
18681
  //#endregion
18663
- export { AssociationMetadata, AuthException, BUKA_MODULE_OPTIONS_TOKEN, Base32, BlindIndex, BlindIndexHasher, BlindIndexModule, BlindIndexService, BlindIndexV1Hasher, BukaConfigurableModuleClass, BukaExceptions, BukaModule, BukaModuleOptions, BukaPageQueryValidationPipe, BukaValidationPipe, BusinessException, Cardinality, type CipherMetadata, CollectionAssociationMetadata, Column, Composite, CompositePropertyMetadata, ConfigurableModuleClass, ConflictException, CursorPagination, DatabaseConfig, type DecryptCommand, DegradeException, Dictionary, DictionaryPropertyMetadata, DiscreteEntity, EagerType, type EncryptCommand, EncryptedPayload, EntityRef, Enum, EnumPropertyMetadata, EnvelopeEncryptionModule, type EnvelopeEncryptionModuleOptions, EnvelopeEncryptionService, ErrorCategory, ErrorCode, ErrorCodeController, ErrorCodeExceptionFilter, ErrorCodeDefinitionDto as ErrorCodeItemDto, ErrorCodeMetadataDto, type ErrorCodeOptions, ErrorCodePartsDto, ErrorCodeRegistry, ErrorResponseSchema, type ExceptionConstructor, type ExceptionConstructorWithArgs, type ExceptionDetail, ExceptionDetailSchema, ExceptionModule, type ExceptionModuleOptions as ExceptionNestModuleOptions, type ExceptionOptions, type ExceptionOptionsWithFactory, type ExceptionOptionsWithMessage, ExcludeDefinedOpt, ExcludeHidden, ExcludeOpt, ExcludeRef, ExcludeScalarClass, FeatureException, FilterQuery, FilterQueryOperator, FilterQueryOperators, FilterQueryOperatorsMetadataKey, FilterQueryTransformPipe, HAS_ANY_KEY, HasAnyKey, HttpException, type HttpExceptionOptions, IEntityPrimaryKey, IFilter, IFilterQuery, IFilterQueryCollectionCondition, IFilterQueryCondition, IFilterQueryNestedProperty, IFilterQueryObject, IFilterQueryProperty, IListResponseBody, IListResponseBodyMeta, INextCursorPageParameters, IOffsetPageParameters, IOrderQuery, IPageQuery, IPreviousCursorPageParameters, IResponseBody, IS_CROCKFORD_BASE32, IS_IDENTIFIER_URN, IS_NAMESPACE_URN, IS_RESOURCE_URN, IS_SCALAR_DICTIONARY, IS_URN, IdentifierUrn, InjectLogger, IsBrowserRequest, IsCrockfordBase32, IsHidden, IsIdentifierUrn, IsNamespaceUrn, IsOpt, IsResourceUrn, IsScalar, IsScalarDictionary, IsUrn, KeyEnvelope, LinearEntity, List, ListErrorCodesResponseDto, ListPropertyMetadata, ListResponseBodyType, Logger, LoggerConfig, LoggerErrorInterceptor, LoggerModule, type LoggerModuleOptions, MATCH_JSON_SCHEMA, MODULE_OPTIONS_TOKEN, MatchJsonSchema, Model, ModelMetadata, ModelOptions, ModelRegister, ModelSchemaOptions, ModuleExceptions, type ExceptionModuleOptions$1 as ModuleExceptionsOptions, NamespaceUrn, NextCursorPageSchema, ObjectStorageModule, ObjectStorageModuleConfig, ObjectStorageModuleOptions, ObjectStorageOptions, ObjectStorageService, OffsetPageSchema, OffsetPagination, OmitType, OpenBaoAppRoleAuth, OpenBaoAppRoleAuthConfig, OpenBaoAuthMethod, OpenBaoAuthResponse, OpenBaoHttpClient, OpenBaoKubernetesAuth, OpenBaoKubernetesAuthConfig, OpenBaoModule, OpenBaoModuleConfig, OpenBaoModuleOptions, OpenBaoTokenAuth, OpenBaoTokenAuthConfig, OpenBaoTokenLookupSelfResponse, OpenBaoTokenManager, OpenBaoUserpassAuth, OpenBaoUserpassAuthConfig, OptionalPageQuery, OrderQueryType, PageQuery, ParseUUIDv7Pipe, PartialType, PendingException, PickType, PreviousCursorPageSchema, PrimaryKeyType, PrimaryKeyTypeClassMetadataPropertyKey, Property, PropertyKind, PropertyMetadata, RateLimitException, type ReencryptCommand, RefAssociationMetadata, type ResolveExceptions, ResourceUrn, ResponseBodyType, SaltedHash, SaltedHashHasher, SaltedHashModule, SaltedHashService, SaltedHashV1Hasher, ScalarClass, ScalarPropertyMetadata, type SchemaObject, Slice, SwaggerPatcher, SystemException, ThirdPartyException, TimestampedEntity, type UnifyExceptionResponsesOptions, Urn, VALIDATE_NESTED_DICTIONARY, ValidateNestedDictionary, ValidationException, getExceptionModuleId, getFilterQueryOperators, isScalarClass, serializeModel, setOpenBaoToken, stableStringify };
18682
+ export { AssociationMetadata, AuthException, BUKA_MODULE_OPTIONS_TOKEN, Base32, BlindIndex, BlindIndexHasher, BlindIndexModule, BlindIndexService, BlindIndexV1Hasher, BukaConfigurableModuleClass, BukaExceptions, BukaModule, BukaModuleOptions, BukaPageQueryValidationPipe, BukaValidationPipe, BusinessException, Cardinality, type CipherMetadata, CollectionAssociationMetadata, Column, Composite, CompositePropertyMetadata, ConfigurableModuleClass, ConflictException, CursorPagination, DatabaseConfig, type DecryptCommand, DegradeException, Dictionary, DictionaryPropertyMetadata, DiscreteEntity, DomainUrn, EagerType, type EncryptCommand, EncryptedPayload, EntityRef, Enum, EnumPropertyMetadata, EnvelopeEncryptionModule, type EnvelopeEncryptionModuleOptions, EnvelopeEncryptionService, ErrorCategory, ErrorCode, ErrorCodeController, ErrorCodeExceptionFilter, ErrorCodeDefinitionDto as ErrorCodeItemDto, ErrorCodeMetadataDto, type ErrorCodeOptions, ErrorCodePartsDto, ErrorCodeRegistry, ErrorResponseSchema, type ExceptionConstructor, type ExceptionConstructorWithArgs, type ExceptionDetail, ExceptionDetailSchema, ExceptionModule, type ExceptionModuleOptions as ExceptionNestModuleOptions, type ExceptionOptions, type ExceptionOptionsWithFactory, type ExceptionOptionsWithMessage, ExcludeDefinedOpt, ExcludeHidden, ExcludeOpt, ExcludeRef, ExcludeScalarClass, FeatureException, FilterQuery, FilterQueryOperator, FilterQueryOperators, FilterQueryOperatorsMetadataKey, FilterQueryTransformPipe, HAS_ANY_KEY, HasAnyKey, HttpException, type HttpExceptionOptions, IEntityPrimaryKey, IFilter, IFilterQuery, IFilterQueryCollectionCondition, IFilterQueryCondition, IFilterQueryNestedProperty, IFilterQueryObject, IFilterQueryProperty, IListResponseBody, IListResponseBodyMeta, INextCursorPageParameters, IOffsetPageParameters, IOrderQuery, IPageQuery, IPreviousCursorPageParameters, IResponseBody, IS_CROCKFORD_BASE32, IS_DOMAIN_URN, IS_RESOURCE_ID_URN, IS_RESOURCE_TYPE_URN, IS_SCALAR_DICTIONARY, IS_URN, InjectLogger, IsBrowserRequest, IsCrockfordBase32, IsDomainUrn, IsHidden, IsOpt, IsResourceIdUrn, IsResourceTypeUrn, IsScalar, IsScalarDictionary, IsUrn, KeyEnvelope, LinearEntity, List, ListErrorCodesResponseDto, ListPropertyMetadata, ListResponseBodyType, Logger, LoggerConfig, LoggerErrorInterceptor, LoggerModule, type LoggerModuleOptions, MATCH_JSON_SCHEMA, MODULE_OPTIONS_TOKEN, MatchJsonSchema, Model, ModelMetadata, ModelOptions, ModelRegister, ModelSchemaOptions, ModuleExceptions, type ExceptionModuleOptions$1 as ModuleExceptionsOptions, NextCursorPageSchema, ObjectStorageModule, ObjectStorageModuleConfig, ObjectStorageModuleOptions, ObjectStorageOptions, ObjectStorageService, OffsetPageSchema, OffsetPagination, OmitType, OpenBaoAppRoleAuth, OpenBaoAppRoleAuthConfig, OpenBaoAuthMethod, OpenBaoAuthResponse, OpenBaoHttpClient, OpenBaoKubernetesAuth, OpenBaoKubernetesAuthConfig, OpenBaoModule, OpenBaoModuleConfig, OpenBaoModuleOptions, OpenBaoTokenAuth, OpenBaoTokenAuthConfig, OpenBaoTokenLookupSelfResponse, OpenBaoTokenManager, OpenBaoUserpassAuth, OpenBaoUserpassAuthConfig, OptionalPageQuery, OrderQueryType, PageQuery, ParseUUIDv7Pipe, PartialType, PendingException, PickType, PreviousCursorPageSchema, PrimaryKeyType, PrimaryKeyTypeClassMetadataPropertyKey, Property, PropertyKind, PropertyMetadata, RateLimitException, type ReencryptCommand, RefAssociationMetadata, type ResolveExceptions, ResourceIdUrn, ResourceTypeUrn, ResponseBodyType, SaltedHash, SaltedHashHasher, SaltedHashModule, SaltedHashService, SaltedHashV1Hasher, ScalarClass, ScalarPropertyMetadata, type SchemaObject, Slice, SwaggerPatcher, SystemException, ThirdPartyException, TimestampedEntity, type UnifyExceptionResponsesOptions, Urn, VALIDATE_NESTED_DICTIONARY, ValidateNestedDictionary, ValidationException, getExceptionModuleId, getFilterQueryOperators, isScalarClass, serializeModel, setOpenBaoToken, stableStringify };
18664
18683
  //# sourceMappingURL=index.d.mts.map
package/dist/index.d.ts CHANGED
@@ -227,9 +227,9 @@ declare function IsScalarDictionary(ctor: ScalarClass, validationOptions?: Valid
227
227
  //#endregion
228
228
  //#region src/modules/core/decorators/class-validator/is-urn.d.ts
229
229
  declare const IS_URN = "isUrn";
230
- declare const IS_NAMESPACE_URN = "isNamespaceUrn";
231
- declare const IS_RESOURCE_URN = "isResourceUrn";
232
- declare const IS_IDENTIFIER_URN = "isIdentifierUrn";
230
+ declare const IS_DOMAIN_URN = "isDomainUrn";
231
+ declare const IS_RESOURCE_TYPE_URN = "isResourceTypeUrn";
232
+ declare const IS_RESOURCE_ID_URN = "isResourceIdUrn";
233
233
  /**
234
234
  * 验证字符串是否为合法的 URN(任意层级)。
235
235
  *
@@ -243,41 +243,41 @@ declare const IS_IDENTIFIER_URN = "isIdentifierUrn";
243
243
  */
244
244
  declare function IsUrn(validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
245
245
  /**
246
- * 验证字符串是否为 namespace 级 URN(仅含 namespace,无 resource 和 identifier)。
246
+ * 验证字符串是否为概念域级 URN(仅含 domain,无 resourceType 和 resourceId)。
247
247
  *
248
248
  * @example
249
249
  * ```typescript
250
250
  * class TokenPayloadDTO {
251
- * @IsNamespaceUrn()
251
+ * @IsDomainUrn()
252
252
  * aud: string
253
253
  * }
254
254
  * ```
255
255
  */
256
- declare function IsNamespaceUrn(validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
256
+ declare function IsDomainUrn(validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
257
257
  /**
258
- * 验证字符串是否为资源类型级 URN(含 namespace 和 resource,无 identifier)。
258
+ * 验证字符串是否为资源类型级 URN(含 domain 和 resourceType,无 resourceId)。
259
259
  *
260
260
  * @example
261
261
  * ```typescript
262
262
  * class ResourceDTO {
263
- * @IsResourceUrn()
263
+ * @IsResourceTypeUrn()
264
264
  * resourceType: string
265
265
  * }
266
266
  * ```
267
267
  */
268
- declare function IsResourceUrn(validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
268
+ declare function IsResourceTypeUrn(validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
269
269
  /**
270
- * 验证字符串是否为实例级 URN(含完整三段:namespace、resource 和 identifier)。
270
+ * 验证字符串是否为实例级 URN(含完整三段:domain、resourceType 和 resourceId)。
271
271
  *
272
272
  * @example
273
273
  * ```typescript
274
274
  * class TokenPayloadDTO {
275
- * @IsIdentifierUrn()
275
+ * @IsResourceIdUrn()
276
276
  * sub: string
277
277
  * }
278
278
  * ```
279
279
  */
280
- declare function IsIdentifierUrn(validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
280
+ declare function IsResourceIdUrn(validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
281
281
  //#endregion
282
282
  //#region src/modules/core/decorators/class-validator/match-json-schema.d.ts
283
283
  declare const MATCH_JSON_SCHEMA = "matchJsonSchema";
@@ -969,123 +969,142 @@ declare class Slice<T extends object> {
969
969
  /**
970
970
  * 统一资源名称(URN)
971
971
  *
972
- * 格式: urn:buka:<namespace>[:<resource>[:<identifier>]]
972
+ * 格式: urn:buka:<domain>:<resource-type>[:<resource-id>]
973
973
  *
974
974
  * 支持三种粒度:
975
- * - namespace 级: urn:buka:galaxy
975
+ * - 概念域级: urn:buka:galaxy
976
976
  * - 资源类型级: urn:buka:galaxy:principal
977
977
  * - 实例级: urn:buka:galaxy:principal:550e8400-e29b-41d4-a716-446655440000
978
978
  *
979
- * namespace 划分原则:按资源类型的定义权归属划分,非按部署单元。
979
+ * domain 划分原则:按资源类型的定义权归属划分,非按部署单元。
980
+ * resource-type 第一级推荐用于 env(环境),这是一个语义约定,不强制。
980
981
  *
981
982
  * 推荐通过静态工厂方法或派生方法构建层级 URN:
982
983
  * ```ts
983
- * Urn.of('galaxy') // → NamespaceUrn
984
- * Urn.of('galaxy', 'principal') // → ResourceUrn
985
- * Urn.of('galaxy', 'principal', '550e8400-...') // → IdentifierUrn
984
+ * Urn.of('galaxy') // → DomainUrn
985
+ * Urn.of('galaxy', 'principal') // → ResourceTypeUrn
986
+ * Urn.of('galaxy', 'principal', '550e8400-...') // → ResourceIdUrn
986
987
  *
987
988
  * // 或通过派生方法逐层构建
988
989
  * Urn.of('galaxy')
989
- * .withResource('principal') // → ResourceUrn
990
- * .withIdentifier('550e8400-...') // → IdentifierUrn
990
+ * .withResourceType('principal') // → ResourceTypeUrn
991
+ * .withResourceId('550e8400-...') // → ResourceIdUrn
991
992
  * ```
992
993
  */
993
994
  declare class Urn {
994
- /** 资源类型所有者(概念域/平台),如 galaxy、infra */
995
- readonly namespace: string;
996
- /** 资源类型,如 principal、oauth2-client */
997
- readonly resource?: string | undefined;
998
- /** 资源唯一标识 */
999
- readonly identifier?: string | undefined;
995
+ /** 概念域 — 资源类型定义权归属,通常为系统名 */
996
+ readonly domain: string;
997
+ /** 资源类型,可多级。第一级推荐用于 env */
998
+ readonly resourceType?: string | undefined;
999
+ /** 资源实例唯一标识 */
1000
+ readonly resourceId?: string | undefined;
1000
1001
  private constructor();
1001
1002
  /**
1002
1003
  * 序列化为 URN 字符串
1003
1004
  */
1004
1005
  toString(): string;
1006
+ /**
1007
+ * 返回 resourceType 按 `:` 拆分后的层级数组
1008
+ */
1009
+ get resourceTypeSegments(): string[];
1010
+ private toSegments;
1005
1011
  /**
1006
1012
  * 衍生出资源类型级 URN
1007
1013
  *
1008
- * @throws Error 当前 URN 已有 resource 时抛出
1014
+ * @throws Error 当前 URN 已有 resourceType 时抛出
1009
1015
  */
1010
- withResource(resource: string): ResourceUrn;
1016
+ withResourceType(resourceType: string): ResourceTypeUrn;
1011
1017
  /**
1012
1018
  * 衍生出实例级 URN
1013
1019
  *
1014
- * @throws Error 当前 URN 无 resource 或已有 identifier 时抛出
1020
+ * @throws Error 当前 URN 无 resourceType 或已有 resourceId 时抛出
1015
1021
  */
1016
- withIdentifier(identifier: string): IdentifierUrn;
1022
+ withResourceId(resourceId: string): ResourceIdUrn;
1017
1023
  /**
1018
- * 类型守卫:判断是否为 namespace 级 URN
1024
+ * 类型守卫:判断是否为概念域级 URN
1019
1025
  */
1020
- isNamespaceUrn(): this is NamespaceUrn;
1026
+ isDomainUrn(): this is DomainUrn;
1021
1027
  /**
1022
1028
  * 类型守卫:判断是否为资源类型级 URN
1023
1029
  */
1024
- isResourceUrn(): this is ResourceUrn;
1030
+ isResourceTypeUrn(): this is ResourceTypeUrn;
1025
1031
  /**
1026
1032
  * 类型守卫:判断是否为实例级 URN
1027
1033
  */
1028
- isIdentifierUrn(): this is IdentifierUrn;
1034
+ isResourceIdUrn(): this is ResourceIdUrn;
1029
1035
  /**
1030
1036
  * 根据参数创建对应层级的 URN
1031
1037
  *
1032
1038
  * 重载签名使返回类型随参数数量自动窄化:
1033
- * - 仅 namespace → NamespaceUrn
1034
- * - namespace + resource → ResourceUrn
1035
- * - namespace + resource + identifier → IdentifierUrn
1039
+ * - 仅 domain → DomainUrn
1040
+ * - domain + resourceType → ResourceTypeUrn
1041
+ * - domain + resourceType + resourceId → ResourceIdUrn
1036
1042
  */
1037
- static of(namespace: string): NamespaceUrn;
1038
- static of(namespace: string, resource: string): ResourceUrn;
1039
- static of(namespace: string, resource: string, identifier: string): IdentifierUrn;
1043
+ static of(domain: string): DomainUrn;
1044
+ static of(domain: string, resourceType: string): ResourceTypeUrn;
1045
+ static of(domain: string, resourceType: string, resourceId: string): ResourceIdUrn;
1040
1046
  /**
1041
- * 从 URN 字符串解析
1047
+ * 从 URN 字符串解析,支持通配符 `*` 和 `**`
1048
+ *
1049
+ * - `*` 匹配恰好一个段
1050
+ * - `**` 匹配零个或多个尾部段(仅允许出现在末尾)
1042
1051
  *
1043
1052
  * @throws Error URN 格式不合法时抛出
1044
1053
  */
1045
1054
  static parse(urn: string): Urn;
1046
1055
  /**
1047
- * 判断是否匹配指定的 namespace、resource 和 identifier
1056
+ * 判断是否匹配指定的 domain、resourceType 和 resourceId
1048
1057
  *
1049
1058
  * 仅比较传入的参数,未传入的参数不参与比较。
1050
1059
  */
1051
- is(namespace: string, resource?: string, identifier?: string): boolean;
1060
+ is(domain: string, resourceType?: string, resourceId?: string): boolean;
1061
+ /**
1062
+ * 判断当前 URN 是否包含另一个 URN
1063
+ *
1064
+ * 当前 URN 含通配符(`*` 或 `**`)时,作为集合模式判断:
1065
+ * - `*` 匹配恰好一个段
1066
+ * - `**` 匹配零个或多个尾部段(仅末尾有效)
1067
+ *
1068
+ * 当前 URN 为具体 URN(无通配符)时,仅包含自身(严格相等)。
1069
+ */
1070
+ contains(other: Urn): boolean;
1052
1071
  }
1053
1072
  /**
1054
- * namespace 级 URN — 仅含 namespace,无 resource 和 identifier
1073
+ * 概念域级 URN — 仅含 domain,无 resourceType 和 resourceId
1055
1074
  *
1056
- * 可通过 `withResource()` 衍生出 `ResourceUrn`。
1057
- * 禁止直接调用 `withIdentifier()`(跳层派生)。
1075
+ * 可通过 `withResourceType()` 衍生出 `ResourceTypeUrn`。
1076
+ * 禁止直接调用 `withResourceId()`(跳层派生)。
1058
1077
  */
1059
- interface NamespaceUrn extends Urn {
1060
- readonly resource: undefined;
1061
- readonly identifier: undefined;
1062
- /** @deprecated 禁止跳层派生,请先调用 withResource() */
1063
- withIdentifier: never;
1078
+ interface DomainUrn extends Urn {
1079
+ readonly resourceType: undefined;
1080
+ readonly resourceId: undefined;
1081
+ /** @deprecated 禁止跳层派生,请先调用 withResourceType() */
1082
+ withResourceId: never;
1064
1083
  }
1065
1084
  /**
1066
- * 资源类型级 URN — 含 namespace 和 resource,无 identifier
1085
+ * 资源类型级 URN — 含 domain 和 resourceType,无 resourceId
1067
1086
  *
1068
- * 可通过 `withIdentifier()` 衍生出 `IdentifierUrn`。
1069
- * 禁止调用 `withResource()`(横向衍生另一个资源类型)。
1087
+ * 可通过 `withResourceId()` 衍生出 `ResourceIdUrn`。
1088
+ * 禁止调用 `withResourceType()`(横向衍生另一个资源类型)。
1070
1089
  */
1071
- interface ResourceUrn extends Urn {
1072
- readonly resource: string;
1073
- readonly identifier: undefined;
1074
- /** @deprecated 禁止横向衍生,ResourceUrn 不能再衍生另一个资源类型 */
1075
- withResource: never;
1090
+ interface ResourceTypeUrn extends Urn {
1091
+ readonly resourceType: string;
1092
+ readonly resourceId: undefined;
1093
+ /** @deprecated 禁止横向衍生,ResourceTypeUrn 不能再衍生另一个资源类型 */
1094
+ withResourceType: never;
1076
1095
  }
1077
1096
  /**
1078
- * 实例级 URN — 含完整三段:namespace、resource 和 identifier
1097
+ * 实例级 URN — 含完整三段:domain、resourceType 和 resourceId
1079
1098
  *
1080
1099
  * 终态 URN,不可继续衍生。
1081
1100
  */
1082
- interface IdentifierUrn extends Urn {
1083
- readonly resource: string;
1084
- readonly identifier: string;
1101
+ interface ResourceIdUrn extends Urn {
1102
+ readonly resourceType: string;
1103
+ readonly resourceId: string;
1085
1104
  /** @deprecated 终态 URN,不可继续衍生 */
1086
- withResource: never;
1105
+ withResourceType: never;
1087
1106
  /** @deprecated 终态 URN,不可继续衍生 */
1088
- withIdentifier: never;
1107
+ withResourceId: never;
1089
1108
  }
1090
1109
  //#endregion
1091
1110
  //#region src/modules/core/converters/eager-type/eager-type.d.ts
@@ -18660,5 +18679,5 @@ declare class ObjectStorageService implements OnModuleInit {
18660
18679
  */
18661
18680
  declare function stableStringify(value: unknown): string;
18662
18681
  //#endregion
18663
- export { AssociationMetadata, AuthException, BUKA_MODULE_OPTIONS_TOKEN, Base32, BlindIndex, BlindIndexHasher, BlindIndexModule, BlindIndexService, BlindIndexV1Hasher, BukaConfigurableModuleClass, BukaExceptions, BukaModule, BukaModuleOptions, BukaPageQueryValidationPipe, BukaValidationPipe, BusinessException, Cardinality, type CipherMetadata, CollectionAssociationMetadata, Column, Composite, CompositePropertyMetadata, ConfigurableModuleClass, ConflictException, CursorPagination, DatabaseConfig, type DecryptCommand, DegradeException, Dictionary, DictionaryPropertyMetadata, DiscreteEntity, EagerType, type EncryptCommand, EncryptedPayload, EntityRef, Enum, EnumPropertyMetadata, EnvelopeEncryptionModule, type EnvelopeEncryptionModuleOptions, EnvelopeEncryptionService, ErrorCategory, ErrorCode, ErrorCodeController, ErrorCodeExceptionFilter, ErrorCodeDefinitionDto as ErrorCodeItemDto, ErrorCodeMetadataDto, type ErrorCodeOptions, ErrorCodePartsDto, ErrorCodeRegistry, ErrorResponseSchema, type ExceptionConstructor, type ExceptionConstructorWithArgs, type ExceptionDetail, ExceptionDetailSchema, ExceptionModule, type ExceptionModuleOptions as ExceptionNestModuleOptions, type ExceptionOptions, type ExceptionOptionsWithFactory, type ExceptionOptionsWithMessage, ExcludeDefinedOpt, ExcludeHidden, ExcludeOpt, ExcludeRef, ExcludeScalarClass, FeatureException, FilterQuery, FilterQueryOperator, FilterQueryOperators, FilterQueryOperatorsMetadataKey, FilterQueryTransformPipe, HAS_ANY_KEY, HasAnyKey, HttpException, type HttpExceptionOptions, IEntityPrimaryKey, IFilter, IFilterQuery, IFilterQueryCollectionCondition, IFilterQueryCondition, IFilterQueryNestedProperty, IFilterQueryObject, IFilterQueryProperty, IListResponseBody, IListResponseBodyMeta, INextCursorPageParameters, IOffsetPageParameters, IOrderQuery, IPageQuery, IPreviousCursorPageParameters, IResponseBody, IS_CROCKFORD_BASE32, IS_IDENTIFIER_URN, IS_NAMESPACE_URN, IS_RESOURCE_URN, IS_SCALAR_DICTIONARY, IS_URN, IdentifierUrn, InjectLogger, IsBrowserRequest, IsCrockfordBase32, IsHidden, IsIdentifierUrn, IsNamespaceUrn, IsOpt, IsResourceUrn, IsScalar, IsScalarDictionary, IsUrn, KeyEnvelope, LinearEntity, List, ListErrorCodesResponseDto, ListPropertyMetadata, ListResponseBodyType, Logger, LoggerConfig, LoggerErrorInterceptor, LoggerModule, type LoggerModuleOptions, MATCH_JSON_SCHEMA, MODULE_OPTIONS_TOKEN, MatchJsonSchema, Model, ModelMetadata, ModelOptions, ModelRegister, ModelSchemaOptions, ModuleExceptions, type ExceptionModuleOptions$1 as ModuleExceptionsOptions, NamespaceUrn, NextCursorPageSchema, ObjectStorageModule, ObjectStorageModuleConfig, ObjectStorageModuleOptions, ObjectStorageOptions, ObjectStorageService, OffsetPageSchema, OffsetPagination, OmitType, OpenBaoAppRoleAuth, OpenBaoAppRoleAuthConfig, OpenBaoAuthMethod, OpenBaoAuthResponse, OpenBaoHttpClient, OpenBaoKubernetesAuth, OpenBaoKubernetesAuthConfig, OpenBaoModule, OpenBaoModuleConfig, OpenBaoModuleOptions, OpenBaoTokenAuth, OpenBaoTokenAuthConfig, OpenBaoTokenLookupSelfResponse, OpenBaoTokenManager, OpenBaoUserpassAuth, OpenBaoUserpassAuthConfig, OptionalPageQuery, OrderQueryType, PageQuery, ParseUUIDv7Pipe, PartialType, PendingException, PickType, PreviousCursorPageSchema, PrimaryKeyType, PrimaryKeyTypeClassMetadataPropertyKey, Property, PropertyKind, PropertyMetadata, RateLimitException, type ReencryptCommand, RefAssociationMetadata, type ResolveExceptions, ResourceUrn, ResponseBodyType, SaltedHash, SaltedHashHasher, SaltedHashModule, SaltedHashService, SaltedHashV1Hasher, ScalarClass, ScalarPropertyMetadata, type SchemaObject, Slice, SwaggerPatcher, SystemException, ThirdPartyException, TimestampedEntity, type UnifyExceptionResponsesOptions, Urn, VALIDATE_NESTED_DICTIONARY, ValidateNestedDictionary, ValidationException, getExceptionModuleId, getFilterQueryOperators, isScalarClass, serializeModel, setOpenBaoToken, stableStringify };
18682
+ export { AssociationMetadata, AuthException, BUKA_MODULE_OPTIONS_TOKEN, Base32, BlindIndex, BlindIndexHasher, BlindIndexModule, BlindIndexService, BlindIndexV1Hasher, BukaConfigurableModuleClass, BukaExceptions, BukaModule, BukaModuleOptions, BukaPageQueryValidationPipe, BukaValidationPipe, BusinessException, Cardinality, type CipherMetadata, CollectionAssociationMetadata, Column, Composite, CompositePropertyMetadata, ConfigurableModuleClass, ConflictException, CursorPagination, DatabaseConfig, type DecryptCommand, DegradeException, Dictionary, DictionaryPropertyMetadata, DiscreteEntity, DomainUrn, EagerType, type EncryptCommand, EncryptedPayload, EntityRef, Enum, EnumPropertyMetadata, EnvelopeEncryptionModule, type EnvelopeEncryptionModuleOptions, EnvelopeEncryptionService, ErrorCategory, ErrorCode, ErrorCodeController, ErrorCodeExceptionFilter, ErrorCodeDefinitionDto as ErrorCodeItemDto, ErrorCodeMetadataDto, type ErrorCodeOptions, ErrorCodePartsDto, ErrorCodeRegistry, ErrorResponseSchema, type ExceptionConstructor, type ExceptionConstructorWithArgs, type ExceptionDetail, ExceptionDetailSchema, ExceptionModule, type ExceptionModuleOptions as ExceptionNestModuleOptions, type ExceptionOptions, type ExceptionOptionsWithFactory, type ExceptionOptionsWithMessage, ExcludeDefinedOpt, ExcludeHidden, ExcludeOpt, ExcludeRef, ExcludeScalarClass, FeatureException, FilterQuery, FilterQueryOperator, FilterQueryOperators, FilterQueryOperatorsMetadataKey, FilterQueryTransformPipe, HAS_ANY_KEY, HasAnyKey, HttpException, type HttpExceptionOptions, IEntityPrimaryKey, IFilter, IFilterQuery, IFilterQueryCollectionCondition, IFilterQueryCondition, IFilterQueryNestedProperty, IFilterQueryObject, IFilterQueryProperty, IListResponseBody, IListResponseBodyMeta, INextCursorPageParameters, IOffsetPageParameters, IOrderQuery, IPageQuery, IPreviousCursorPageParameters, IResponseBody, IS_CROCKFORD_BASE32, IS_DOMAIN_URN, IS_RESOURCE_ID_URN, IS_RESOURCE_TYPE_URN, IS_SCALAR_DICTIONARY, IS_URN, InjectLogger, IsBrowserRequest, IsCrockfordBase32, IsDomainUrn, IsHidden, IsOpt, IsResourceIdUrn, IsResourceTypeUrn, IsScalar, IsScalarDictionary, IsUrn, KeyEnvelope, LinearEntity, List, ListErrorCodesResponseDto, ListPropertyMetadata, ListResponseBodyType, Logger, LoggerConfig, LoggerErrorInterceptor, LoggerModule, type LoggerModuleOptions, MATCH_JSON_SCHEMA, MODULE_OPTIONS_TOKEN, MatchJsonSchema, Model, ModelMetadata, ModelOptions, ModelRegister, ModelSchemaOptions, ModuleExceptions, type ExceptionModuleOptions$1 as ModuleExceptionsOptions, NextCursorPageSchema, ObjectStorageModule, ObjectStorageModuleConfig, ObjectStorageModuleOptions, ObjectStorageOptions, ObjectStorageService, OffsetPageSchema, OffsetPagination, OmitType, OpenBaoAppRoleAuth, OpenBaoAppRoleAuthConfig, OpenBaoAuthMethod, OpenBaoAuthResponse, OpenBaoHttpClient, OpenBaoKubernetesAuth, OpenBaoKubernetesAuthConfig, OpenBaoModule, OpenBaoModuleConfig, OpenBaoModuleOptions, OpenBaoTokenAuth, OpenBaoTokenAuthConfig, OpenBaoTokenLookupSelfResponse, OpenBaoTokenManager, OpenBaoUserpassAuth, OpenBaoUserpassAuthConfig, OptionalPageQuery, OrderQueryType, PageQuery, ParseUUIDv7Pipe, PartialType, PendingException, PickType, PreviousCursorPageSchema, PrimaryKeyType, PrimaryKeyTypeClassMetadataPropertyKey, Property, PropertyKind, PropertyMetadata, RateLimitException, type ReencryptCommand, RefAssociationMetadata, type ResolveExceptions, ResourceIdUrn, ResourceTypeUrn, ResponseBodyType, SaltedHash, SaltedHashHasher, SaltedHashModule, SaltedHashService, SaltedHashV1Hasher, ScalarClass, ScalarPropertyMetadata, type SchemaObject, Slice, SwaggerPatcher, SystemException, ThirdPartyException, TimestampedEntity, type UnifyExceptionResponsesOptions, Urn, VALIDATE_NESTED_DICTIONARY, ValidateNestedDictionary, ValidationException, getExceptionModuleId, getFilterQueryOperators, isScalarClass, serializeModel, setOpenBaoToken, stableStringify };
18664
18683
  //# sourceMappingURL=index.d.ts.map