@sevtech/kit 21.6.2 → 21.8.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/http/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import * as _angular_common_http from '@angular/common/http';
1
2
  import { HttpParams, HttpHeaders, HttpContext, HttpEvent, HttpResponse, HttpContextToken, HttpInterceptorFn, HttpRequest, HttpErrorResponse } from '@angular/common/http';
2
3
  import { MaybeArray, SafeAny, MaybeFunction } from '@sevtech/kit/misc';
3
4
  import { Observable } from 'rxjs';
@@ -292,6 +293,7 @@ declare class ApiBase {
292
293
  private readonly serialize;
293
294
  private readonly prefix;
294
295
  private readonly options;
296
+ private readonly defaultContext;
295
297
  protected request(method: RequestMethod, url: string, options?: RequestOptions): Observable<unknown>;
296
298
  private resolveRequestOptions;
297
299
  private resolveSerializeConfig;
@@ -382,7 +384,8 @@ declare class HttpApiService extends ApiBase {
382
384
  declare const enum FeatureKind$3 {
383
385
  Prefix = 0,
384
386
  BodyTransform = 1,
385
- Serialize = 2
387
+ Serialize = 2,
388
+ DefaultContext = 3
386
389
  }
387
390
  /**
388
391
  * Добавляет базовый префикс к относительным URL запросов.
@@ -416,6 +419,14 @@ declare const withBodyTransform: (transform: (body: SafeAny) => SafeAny) => KitF
416
419
  * );
417
420
  */
418
421
  declare const withSerializeConfig: (config: MaybeFunction<Partial<SerializeConfig>>) => KitFeature<FeatureKind$3.Serialize>;
422
+ /**
423
+ * Задаёт токены контекста по умолчанию для запросов через `HttpApiService`.
424
+ * @description Callback получает новый контекст для каждого запроса.
425
+ * `options.context` применяется после него и может переопределить значения токенов.
426
+ * @example
427
+ * provideHttpApi(withDefaultContext((ctx) => ctx.set(USE_HEADERS, true)));
428
+ */
429
+ declare const withDefaultContext: (context: (context: _angular_common_http.HttpContext) => _angular_common_http.HttpContext) => KitFeature<FeatureKind$3.DefaultContext>;
419
430
  /**
420
431
  * Настраивает `HttpApiService`: опции запросов по умолчанию и фичи.
421
432
  * @description Опции применяются ко всем вызовам сервиса и переопределяются
@@ -1221,5 +1232,5 @@ declare const USE_TIMEOUT: HttpContextToken<number | false | null>;
1221
1232
  */
1222
1233
  declare function provideTimeoutConfig(config: MaybeFunction<Partial<TimeoutConfig>>): EnvironmentProviders;
1223
1234
 
1224
- export { ApiError, ErrorKind as ApiErrorKind, HttpApiService, ProgressHttpService, USE_ERROR_MESSAGE, USE_HEADERS, USE_LEGACY_ERRORS, USE_LOGGER, USE_MOCK, USE_PROGRESS, USE_RETRY, USE_TIMEOUT, defineMock, headersInterceptor, httpLogger, isApiError, loggerInterceptor, mockInterceptor, openApiInterceptor, progressInterceptor, provideHeadersConfig, provideHttpApi, provideLoggerConfig, provideMockConfig, provideOpenApiConfig, provideProgressConfig, provideRetryConfig, provideTimeoutConfig, retryInterceptor, timeoutInterceptor, withErrorMessages as withApiErrorMessages, withKindResolver as withApiKindResolver, withApiResponseFilter, withBodyTransform, withCustomHandler as withCustomLogger, withHeaders, withHeadersResolver, withPrefix, withSerializeConfig };
1235
+ export { ApiError, ErrorKind as ApiErrorKind, HttpApiService, ProgressHttpService, USE_ERROR_MESSAGE, USE_HEADERS, USE_LEGACY_ERRORS, USE_LOGGER, USE_MOCK, USE_PROGRESS, USE_RETRY, USE_TIMEOUT, defineMock, headersInterceptor, httpLogger, isApiError, loggerInterceptor, mockInterceptor, openApiInterceptor, progressInterceptor, provideHeadersConfig, provideHttpApi, provideLoggerConfig, provideMockConfig, provideOpenApiConfig, provideProgressConfig, provideRetryConfig, provideTimeoutConfig, retryInterceptor, timeoutInterceptor, withErrorMessages as withApiErrorMessages, withKindResolver as withApiKindResolver, withApiResponseFilter, withBodyTransform, withCustomHandler as withCustomLogger, withDefaultContext, withHeaders, withHeadersResolver, withPrefix, withSerializeConfig };
1225
1236
  export type { ErrorDetailsItem as ApiErrorDetailsItem, KindResolver as ApiErrorKindResolver, ErrorLocation as ApiErrorLocation, ErrorMessageResolver as ApiErrorMessageResolver, ErrorMessages as ApiErrorMessages, ErrorSource as ApiErrorSource, ApiOptions, RequestOptions as ApiRequestOptions, ApiResponse, ApiResponseFilter, SerializeConfig as ApiSerializeConfig, HeadersConfig, HeadersResolver, LoggerConfig, LoggerFn, MockConfig, MockOptions, OpenApiConfig, ProgressConfig, RetryConfig, TimeoutConfig };
@@ -1,6 +1,6 @@
1
1
  import { WritableSignal, ComponentRef, OutputRef, QueryList, InputSignalWithTransform, InjectionToken, TemplateRef, ViewContainerRef, Provider, DestroyRef } from '@angular/core';
2
2
  import { Observable, Subscriber, MonoTypeOperatorFunction, OperatorFunction } from 'rxjs';
3
- import { Route } from '@angular/router';
3
+ import { Route, UrlTree, Event } from '@angular/router';
4
4
  import { FormArray, FormControl, FormGroup, FormRecord, AbstractControl, AsyncValidatorFn, ValidatorFn } from '@angular/forms';
5
5
  import { NgComponentOutlet } from '@angular/common';
6
6
  import { MaybeArray } from '@sevtech/kit/misc';
@@ -212,5 +212,30 @@ declare function fromMaybeAsync<T>(value: MaybeAsync<T>): Observable<T>;
212
212
  declare function safeCatchError<T>(): MonoTypeOperatorFunction<T>;
213
213
  declare function safeCatchError<T, R>(fallback: R): OperatorFunction<T, T | R>;
214
214
 
215
- export { collectFeatureProviders, dateAttribute, defineKitFeature, fromMaybeAsync, htmlBooleanAttribute, ifAsyncValidator, ifValidator, isComponentOutlet, isComponentRef, isFormArray, isFormControl, isFormGroup, isFormRecord, isTemplateRef, isViewContainer, linkedQueryParam, resizeObservable, resolveConfigProviders, revalidateOn, safeCatchError };
215
+ /**
216
+ * Оставляет ровно один `/` в начале пути.
217
+ *
218
+ * @example
219
+ * withLeadingSlash('//login'); // '/login'
220
+ */
221
+ declare function withLeadingSlash(path: string): string;
222
+ /** Проверяет, что значение — `UrlTree` или непустая строка. */
223
+ declare function isRouterUrlInput(url: unknown): url is UrlTree | string;
224
+ /**
225
+ * Возвращает локальный URL для Angular Router или null.
226
+ * Принимает относительные ссылки и пути от корня приложения.
227
+ * Сравнивает запрещённые маршруты по основному outlet через {@link DefaultUrlSerializer}.
228
+ * При сравнении игнорирует matrix-параметры, query и фрагмент.
229
+ * Параметры, фрагмент и дополнительные outlets разрешённого URL сохраняются.
230
+ */
231
+ declare function toSafeRelativeUrl(url: unknown, blocked?: string | readonly string[]): string | null;
232
+
233
+ type RouterEventClass = abstract new (...args: never[]) => Event;
234
+ /**
235
+ * Возвращает поток указанных событий Router с общей фильтрацией для его подписчиков.
236
+ * Вызывать в контексте инъекции.
237
+ */
238
+ declare function injectRouterEvents<T extends [RouterEventClass, ...RouterEventClass[]]>(...eventClasses: T): Observable<InstanceType<T[number]>>;
239
+
240
+ export { collectFeatureProviders, dateAttribute, defineKitFeature, fromMaybeAsync, htmlBooleanAttribute, ifAsyncValidator, ifValidator, injectRouterEvents, isComponentOutlet, isComponentRef, isFormArray, isFormControl, isFormGroup, isFormRecord, isRouterUrlInput, isTemplateRef, isViewContainer, linkedQueryParam, resizeObservable, resolveConfigProviders, revalidateOn, safeCatchError, toSafeRelativeUrl, withLeadingSlash };
216
241
  export type { DataRoute, DataRoutes, ExtractAsync, ExtractComponentRef, ExtractFormArray, ExtractFormControl, ExtractFormGroup, ExtractFormRecord, ExtractOutputs, ExtractQueryList, ExtractSignalInputs, ExtractTokenType, KitFeature, LinkedQueryParamOptions, MaybeAsync, RevalidateOnOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sevtech/kit",
3
- "version": "21.6.2",
3
+ "version": "21.8.0",
4
4
  "sideEffects": false,
5
5
  "dependencies": {
6
6
  "tslib": "^2.3.0"