@angular/common 19.2.0-next.2 → 19.2.0-rc.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/fesm2022/common.mjs +131 -134
- package/fesm2022/common.mjs.map +1 -1
- package/fesm2022/http/testing.mjs +8 -8
- package/fesm2022/http.mjs +194 -40
- package/fesm2022/http.mjs.map +1 -1
- package/fesm2022/testing.mjs +16 -16
- package/fesm2022/upgrade.mjs +16 -6
- package/fesm2022/upgrade.mjs.map +1 -1
- package/http/index.d.ts +259 -1
- package/http/testing/index.d.ts +1 -1
- package/index.d.ts +1 -2
- package/package.json +2 -2
- package/testing/index.d.ts +1 -1
- package/upgrade/index.d.ts +1 -1
package/http/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v19.2.0-
|
|
2
|
+
* @license Angular v19.2.0-rc.0
|
|
3
3
|
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -9,9 +9,14 @@ import { EnvironmentInjector } from '@angular/core';
|
|
|
9
9
|
import { EnvironmentProviders } from '@angular/core';
|
|
10
10
|
import * as i0 from '@angular/core';
|
|
11
11
|
import { InjectionToken } from '@angular/core';
|
|
12
|
+
import type { Injector } from '@angular/core';
|
|
12
13
|
import { ModuleWithProviders } from '@angular/core';
|
|
13
14
|
import { Observable } from 'rxjs';
|
|
14
15
|
import { Provider } from '@angular/core';
|
|
16
|
+
import type { ResourceRef } from '@angular/core';
|
|
17
|
+
import type { Signal } from '@angular/core';
|
|
18
|
+
import type { ValueEqualityFn } from '@angular/core';
|
|
19
|
+
import type { WritableResource } from '@angular/core';
|
|
15
20
|
import { XhrFactory } from '@angular/common';
|
|
16
21
|
|
|
17
22
|
/**
|
|
@@ -4049,6 +4054,259 @@ export declare class HttpRequest<T> {
|
|
|
4049
4054
|
}): HttpRequest<V>;
|
|
4050
4055
|
}
|
|
4051
4056
|
|
|
4057
|
+
/**
|
|
4058
|
+
* `httpResource` makes a reactive HTTP request and exposes the request status and response value as
|
|
4059
|
+
* a `WritableResource`. By default, it assumes that the backend will return JSON data. To make a
|
|
4060
|
+
* request that expects a different kind of data, you can use a sub-constructor of `httpResource`,
|
|
4061
|
+
* such as `httpResource.text`.
|
|
4062
|
+
*
|
|
4063
|
+
* @experimental
|
|
4064
|
+
* @initializerApiFunction
|
|
4065
|
+
*/
|
|
4066
|
+
export declare const httpResource: HttpResourceFn;
|
|
4067
|
+
|
|
4068
|
+
/**
|
|
4069
|
+
* Type for the `httpRequest` top-level function, which includes the call signatures for the JSON-
|
|
4070
|
+
* based `httpRequest` as well as sub-functions for `ArrayBuffer`, `Blob`, and `string` type
|
|
4071
|
+
* requests.
|
|
4072
|
+
*
|
|
4073
|
+
* @experimental
|
|
4074
|
+
*/
|
|
4075
|
+
export declare interface HttpResourceFn {
|
|
4076
|
+
/**
|
|
4077
|
+
* Create a `Resource` that fetches data with an HTTP GET request to the given URL.
|
|
4078
|
+
*
|
|
4079
|
+
* If a reactive function is passed for the URL, the resource will update when the URL changes via
|
|
4080
|
+
* signals.
|
|
4081
|
+
*
|
|
4082
|
+
* Uses `HttpClient` to make requests and supports interceptors, testing, and the other features
|
|
4083
|
+
* of the `HttpClient` API. Data is parsed as JSON by default - use a sub-function of
|
|
4084
|
+
* `httpResource`, such as `httpResource.text()`, to parse the response differently.
|
|
4085
|
+
*
|
|
4086
|
+
* @experimental
|
|
4087
|
+
*/
|
|
4088
|
+
<TResult = unknown>(url: string | (() => string | undefined), options: HttpResourceOptions<TResult, unknown> & {
|
|
4089
|
+
defaultValue: NoInfer<TResult>;
|
|
4090
|
+
}): HttpResourceRef<TResult>;
|
|
4091
|
+
/**
|
|
4092
|
+
* Create a `Resource` that fetches data with an HTTP GET request to the given URL.
|
|
4093
|
+
*
|
|
4094
|
+
* If a reactive function is passed for the URL, the resource will update when the URL changes via
|
|
4095
|
+
* signals.
|
|
4096
|
+
*
|
|
4097
|
+
* Uses `HttpClient` to make requests and supports interceptors, testing, and the other features
|
|
4098
|
+
* of the `HttpClient` API. Data is parsed as JSON by default - use a sub-function of
|
|
4099
|
+
* `httpResource`, such as `httpResource.text()`, to parse the response differently.
|
|
4100
|
+
*
|
|
4101
|
+
* @experimental
|
|
4102
|
+
*/
|
|
4103
|
+
<TResult = unknown>(url: string | (() => string | undefined), options?: HttpResourceOptions<TResult, unknown>): HttpResourceRef<TResult | undefined>;
|
|
4104
|
+
/**
|
|
4105
|
+
* Create a `Resource` that fetches data with the configured HTTP request.
|
|
4106
|
+
*
|
|
4107
|
+
* If a reactive function is passed for the request, the resource will update when the request
|
|
4108
|
+
* changes via signals.
|
|
4109
|
+
*
|
|
4110
|
+
* Uses `HttpClient` to make requests and supports interceptors, testing, and the other features
|
|
4111
|
+
* of the `HttpClient` API. Data is parsed as JSON by default - use a sub-function of
|
|
4112
|
+
* `httpResource`, such as `httpResource.text()`, to parse the response differently.
|
|
4113
|
+
*
|
|
4114
|
+
* @experimental
|
|
4115
|
+
*/
|
|
4116
|
+
<TResult = unknown>(request: HttpResourceRequest | (() => HttpResourceRequest | undefined), options: HttpResourceOptions<TResult, unknown> & {
|
|
4117
|
+
defaultValue: NoInfer<TResult>;
|
|
4118
|
+
}): HttpResourceRef<TResult>;
|
|
4119
|
+
/**
|
|
4120
|
+
* Create a `Resource` that fetches data with the configured HTTP request.
|
|
4121
|
+
*
|
|
4122
|
+
* If a reactive function is passed for the request, the resource will update when the request
|
|
4123
|
+
* changes via signals.
|
|
4124
|
+
*
|
|
4125
|
+
* Uses `HttpClient` to make requests and supports interceptors, testing, and the other features
|
|
4126
|
+
* of the `HttpClient` API. Data is parsed as JSON by default - use a sub-function of
|
|
4127
|
+
* `httpResource`, such as `httpResource.text()`, to parse the response differently.
|
|
4128
|
+
*
|
|
4129
|
+
* @experimental
|
|
4130
|
+
*/
|
|
4131
|
+
<TResult = unknown>(request: HttpResourceRequest | (() => HttpResourceRequest | undefined), options?: HttpResourceOptions<TResult, unknown>): HttpResourceRef<TResult | undefined>;
|
|
4132
|
+
/**
|
|
4133
|
+
* Create a `Resource` that fetches data with the configured HTTP request.
|
|
4134
|
+
*
|
|
4135
|
+
* If a reactive function is passed for the URL or request, the resource will update when the
|
|
4136
|
+
* URL or request changes via signals.
|
|
4137
|
+
*
|
|
4138
|
+
* Uses `HttpClient` to make requests and supports interceptors, testing, and the other features
|
|
4139
|
+
* of the `HttpClient` API. Data is parsed into an `ArrayBuffer`.
|
|
4140
|
+
*
|
|
4141
|
+
* @experimental
|
|
4142
|
+
*/
|
|
4143
|
+
arrayBuffer: {
|
|
4144
|
+
<TResult = ArrayBuffer>(url: string | (() => string | undefined), options: HttpResourceOptions<TResult, ArrayBuffer> & {
|
|
4145
|
+
defaultValue: NoInfer<TResult>;
|
|
4146
|
+
}): HttpResourceRef<TResult>;
|
|
4147
|
+
<TResult = ArrayBuffer>(url: string | (() => string | undefined), options?: HttpResourceOptions<TResult, ArrayBuffer>): HttpResourceRef<TResult | undefined>;
|
|
4148
|
+
<TResult = ArrayBuffer>(request: HttpResourceRequest | (() => HttpResourceRequest | undefined), options: HttpResourceOptions<TResult, ArrayBuffer> & {
|
|
4149
|
+
defaultValue: NoInfer<TResult>;
|
|
4150
|
+
}): HttpResourceRef<TResult>;
|
|
4151
|
+
<TResult = ArrayBuffer>(request: HttpResourceRequest | (() => HttpResourceRequest | undefined), options?: HttpResourceOptions<TResult, ArrayBuffer>): HttpResourceRef<TResult | undefined>;
|
|
4152
|
+
};
|
|
4153
|
+
/**
|
|
4154
|
+
* Create a `Resource` that fetches data with the configured HTTP request.
|
|
4155
|
+
*
|
|
4156
|
+
* If a reactive function is passed for the URL or request, the resource will update when the
|
|
4157
|
+
* URL or request changes via signals.
|
|
4158
|
+
*
|
|
4159
|
+
* Uses `HttpClient` to make requests and supports interceptors, testing, and the other features
|
|
4160
|
+
* of the `HttpClient` API. Data is parsed into a `Blob`.
|
|
4161
|
+
*
|
|
4162
|
+
* @experimental
|
|
4163
|
+
*/
|
|
4164
|
+
blob: {
|
|
4165
|
+
<TResult = Blob>(url: string | (() => string | undefined), options: HttpResourceOptions<TResult, Blob> & {
|
|
4166
|
+
defaultValue: NoInfer<TResult>;
|
|
4167
|
+
}): HttpResourceRef<TResult>;
|
|
4168
|
+
<TResult = Blob>(url: string | (() => string | undefined), options?: HttpResourceOptions<TResult, Blob>): HttpResourceRef<TResult | undefined>;
|
|
4169
|
+
<TResult = Blob>(request: HttpResourceRequest | (() => HttpResourceRequest | undefined), options: HttpResourceOptions<TResult, Blob> & {
|
|
4170
|
+
defaultValue: NoInfer<TResult>;
|
|
4171
|
+
}): HttpResourceRef<TResult>;
|
|
4172
|
+
<TResult = Blob>(request: HttpResourceRequest | (() => HttpResourceRequest | undefined), options?: HttpResourceOptions<TResult, Blob>): HttpResourceRef<TResult | undefined>;
|
|
4173
|
+
};
|
|
4174
|
+
/**
|
|
4175
|
+
* Create a `Resource` that fetches data with the configured HTTP request.
|
|
4176
|
+
*
|
|
4177
|
+
* If a reactive function is passed for the URL or request, the resource will update when the
|
|
4178
|
+
* URL or request changes via signals.
|
|
4179
|
+
*
|
|
4180
|
+
* Uses `HttpClient` to make requests and supports interceptors, testing, and the other features
|
|
4181
|
+
* of the `HttpClient` API. Data is parsed as a `string`.
|
|
4182
|
+
*
|
|
4183
|
+
* @experimental
|
|
4184
|
+
*/
|
|
4185
|
+
text: {
|
|
4186
|
+
<TResult = string>(url: string | (() => string | undefined), options: HttpResourceOptions<TResult, string> & {
|
|
4187
|
+
defaultValue: NoInfer<TResult>;
|
|
4188
|
+
}): HttpResourceRef<TResult>;
|
|
4189
|
+
<TResult = string>(url: string | (() => string | undefined), options?: HttpResourceOptions<TResult, string>): HttpResourceRef<TResult | undefined>;
|
|
4190
|
+
<TResult = string>(request: HttpResourceRequest | (() => HttpResourceRequest | undefined), options: HttpResourceOptions<TResult, string> & {
|
|
4191
|
+
defaultValue: NoInfer<TResult>;
|
|
4192
|
+
}): HttpResourceRef<TResult>;
|
|
4193
|
+
<TResult = string>(request: HttpResourceRequest | (() => HttpResourceRequest | undefined), options?: HttpResourceOptions<TResult, string>): HttpResourceRef<TResult | undefined>;
|
|
4194
|
+
};
|
|
4195
|
+
}
|
|
4196
|
+
|
|
4197
|
+
/**
|
|
4198
|
+
* Options for creating an `httpResource`.
|
|
4199
|
+
*
|
|
4200
|
+
* @experimental
|
|
4201
|
+
*/
|
|
4202
|
+
export declare interface HttpResourceOptions<TResult, TRaw> {
|
|
4203
|
+
/**
|
|
4204
|
+
* Transform the result of the HTTP request before it's delivered to the resource.
|
|
4205
|
+
*
|
|
4206
|
+
* `map` receives the value from the HTTP layer as its raw type (e.g. as `unknown` for JSON data).
|
|
4207
|
+
* It can be used to validate or transform the type of the resource, and return a more specific
|
|
4208
|
+
* type. This is also useful for validating backend responses using a runtime schema validation
|
|
4209
|
+
* library such as Zod.
|
|
4210
|
+
*/
|
|
4211
|
+
map?: (value: TRaw) => TResult;
|
|
4212
|
+
/**
|
|
4213
|
+
* Value that the resource will take when in Idle, Loading, or Error states.
|
|
4214
|
+
*
|
|
4215
|
+
* If not set, the resource will use `undefined` as its default value.
|
|
4216
|
+
*/
|
|
4217
|
+
defaultValue?: NoInfer<TResult>;
|
|
4218
|
+
/**
|
|
4219
|
+
* The `Injector` in which to create the `httpResource`.
|
|
4220
|
+
*
|
|
4221
|
+
* If this is not provided, the current [injection context](guide/di/dependency-injection-context)
|
|
4222
|
+
* will be used instead (via `inject`).
|
|
4223
|
+
*/
|
|
4224
|
+
injector?: Injector;
|
|
4225
|
+
/**
|
|
4226
|
+
* A comparison function which defines equality for the response value.
|
|
4227
|
+
*/
|
|
4228
|
+
equal?: ValueEqualityFn<NoInfer<TResult>>;
|
|
4229
|
+
}
|
|
4230
|
+
|
|
4231
|
+
/**
|
|
4232
|
+
* A `WritableResource` that represents the results of a reactive HTTP request.
|
|
4233
|
+
*
|
|
4234
|
+
* `HttpResource`s are backed by `HttpClient`, including support for interceptors, testing, and the
|
|
4235
|
+
* other features of the `HttpClient` API.
|
|
4236
|
+
*
|
|
4237
|
+
* @experimental
|
|
4238
|
+
*/
|
|
4239
|
+
export declare interface HttpResourceRef<T> extends WritableResource<T>, ResourceRef<T> {
|
|
4240
|
+
/**
|
|
4241
|
+
* Signal of the response headers, when available.
|
|
4242
|
+
*/
|
|
4243
|
+
readonly headers: Signal<HttpHeaders | undefined>;
|
|
4244
|
+
/**
|
|
4245
|
+
* Signal of the response status code, when available.
|
|
4246
|
+
*/
|
|
4247
|
+
readonly statusCode: Signal<number | undefined>;
|
|
4248
|
+
/**
|
|
4249
|
+
* Signal of the latest progress update, if the request was made with `reportProgress: true`.
|
|
4250
|
+
*/
|
|
4251
|
+
readonly progress: Signal<HttpProgressEvent | undefined>;
|
|
4252
|
+
hasValue(): this is HttpResourceRef<Exclude<T, undefined>>;
|
|
4253
|
+
destroy(): void;
|
|
4254
|
+
}
|
|
4255
|
+
|
|
4256
|
+
/**
|
|
4257
|
+
* The structure of an `httpResource` request which will be sent to the backend.
|
|
4258
|
+
*
|
|
4259
|
+
* @experimental
|
|
4260
|
+
*/
|
|
4261
|
+
export declare interface HttpResourceRequest {
|
|
4262
|
+
/**
|
|
4263
|
+
* URL of the request.
|
|
4264
|
+
*
|
|
4265
|
+
* This URL should not include query parameters. Instead, specify query parameters through the
|
|
4266
|
+
* `params` field.
|
|
4267
|
+
*/
|
|
4268
|
+
url: string;
|
|
4269
|
+
/**
|
|
4270
|
+
* HTTP method of the request, which defaults to GET if not specified.
|
|
4271
|
+
*/
|
|
4272
|
+
method?: string;
|
|
4273
|
+
/**
|
|
4274
|
+
* Body to send with the request, if there is one.
|
|
4275
|
+
*
|
|
4276
|
+
* If no Content-Type header is specified by the user, Angular will attempt to set one based on
|
|
4277
|
+
* the type of `body`.
|
|
4278
|
+
*/
|
|
4279
|
+
body?: unknown;
|
|
4280
|
+
/**
|
|
4281
|
+
* Dictionary of query parameters which will be appeneded to the request URL.
|
|
4282
|
+
*/
|
|
4283
|
+
params?: HttpParams | Record<string, string | number | boolean | ReadonlyArray<string | number | boolean>>;
|
|
4284
|
+
/**
|
|
4285
|
+
* Dictionary of headers to include with the outgoing request.
|
|
4286
|
+
*/
|
|
4287
|
+
headers?: HttpHeaders | Record<string, string | ReadonlyArray<string>>;
|
|
4288
|
+
/**
|
|
4289
|
+
* If `true`, progress events will be enabled for the request and delivered through the
|
|
4290
|
+
* `HttpResource.progress` signal.
|
|
4291
|
+
*/
|
|
4292
|
+
reportProgress?: boolean;
|
|
4293
|
+
/**
|
|
4294
|
+
* Specifies whether the `withCredentials` flag should be set on the outgoing request.
|
|
4295
|
+
*
|
|
4296
|
+
* This flag causes the browser to send cookies and other authentication information along with
|
|
4297
|
+
* the request.
|
|
4298
|
+
*/
|
|
4299
|
+
withCredentials?: boolean;
|
|
4300
|
+
/**
|
|
4301
|
+
* Configures the server-side rendering transfer cache for this request.
|
|
4302
|
+
*
|
|
4303
|
+
* See the documentation on the transfer cache for more information.
|
|
4304
|
+
*/
|
|
4305
|
+
transferCache?: {
|
|
4306
|
+
includeHeaders?: string[];
|
|
4307
|
+
} | boolean;
|
|
4308
|
+
}
|
|
4309
|
+
|
|
4052
4310
|
/**
|
|
4053
4311
|
* A full HTTP response, including a typed response body (which may be `null`
|
|
4054
4312
|
* if one was not returned).
|
package/http/testing/index.d.ts
CHANGED
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v19.2.0-
|
|
2
|
+
* @license Angular v19.2.0-rc.0
|
|
3
3
|
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -3348,7 +3348,6 @@ export declare class SlicePipe implements PipeTransform {
|
|
|
3348
3348
|
transform<T>(value: ReadonlyArray<T> | null | undefined, start: number, end?: number): Array<T> | null;
|
|
3349
3349
|
transform(value: string, start: number, end?: number): string;
|
|
3350
3350
|
transform(value: string | null | undefined, start: number, end?: number): string | null;
|
|
3351
|
-
private supports;
|
|
3352
3351
|
static ɵfac: i0.ɵɵFactoryDeclaration<SlicePipe, never>;
|
|
3353
3352
|
static ɵpipe: i0.ɵɵPipeDeclaration<SlicePipe, "slice", true>;
|
|
3354
3353
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/common",
|
|
3
|
-
"version": "19.2.0-
|
|
3
|
+
"version": "19.2.0-rc.0",
|
|
4
4
|
"description": "Angular - commonly needed directives and services",
|
|
5
5
|
"author": "angular",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@angular/core": "19.2.0-
|
|
47
|
+
"@angular/core": "19.2.0-rc.0",
|
|
48
48
|
"rxjs": "^6.5.3 || ^7.4.0"
|
|
49
49
|
},
|
|
50
50
|
"repository": {
|
package/testing/index.d.ts
CHANGED
package/upgrade/index.d.ts
CHANGED