ngx-lift 1.10.3 → 19.0.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/README.md +5 -1
- package/fesm2022/ngx-lift.mjs +729 -194
- package/fesm2022/ngx-lift.mjs.map +1 -1
- package/index.d.ts +1638 -3
- package/package.json +6 -6
- package/esm2022/lib/const.mjs +0 -10
- package/esm2022/lib/models/async-state.model.mjs +0 -2
- package/esm2022/lib/models/index.mjs +0 -6
- package/esm2022/lib/models/kubernetes-list.model.mjs +0 -2
- package/esm2022/lib/models/kubernetes-object-condition.model.mjs +0 -2
- package/esm2022/lib/models/kubernetes-object-meta.model.mjs +0 -2
- package/esm2022/lib/models/kubernetes-object.model.mjs +0 -2
- package/esm2022/lib/operators/combine-latest-eager.operator.mjs +0 -48
- package/esm2022/lib/operators/create-async-state.operator.mjs +0 -61
- package/esm2022/lib/operators/distinct-on-change.operator.mjs +0 -80
- package/esm2022/lib/operators/index.mjs +0 -9
- package/esm2022/lib/operators/kubernetes-pagination.operator.mjs +0 -71
- package/esm2022/lib/operators/logger.operator.mjs +0 -21
- package/esm2022/lib/operators/poll.operator.mjs +0 -39
- package/esm2022/lib/operators/start-with-tap.operator.mjs +0 -15
- package/esm2022/lib/operators/switch-map-with-async-state.operator.mjs +0 -33
- package/esm2022/lib/pipes/array-join.pipe.mjs +0 -21
- package/esm2022/lib/pipes/byte-converter.pipe.mjs +0 -150
- package/esm2022/lib/pipes/index.mjs +0 -6
- package/esm2022/lib/pipes/is-https.pipe.mjs +0 -18
- package/esm2022/lib/pipes/mask.pipe.mjs +0 -36
- package/esm2022/lib/pipes/range.pipe.mjs +0 -19
- package/esm2022/lib/signals/combine-from.mjs +0 -90
- package/esm2022/lib/signals/computed-async.mjs +0 -63
- package/esm2022/lib/signals/create-trigger.mjs +0 -11
- package/esm2022/lib/signals/index.mjs +0 -7
- package/esm2022/lib/signals/inject-params.mjs +0 -35
- package/esm2022/lib/signals/inject-query-params.mjs +0 -53
- package/esm2022/lib/signals/merge-from.mjs +0 -71
- package/esm2022/lib/utils/difference-in-days.util.mjs +0 -25
- package/esm2022/lib/utils/form.util.mjs +0 -56
- package/esm2022/lib/utils/idle-detection/idle-detection.config.mjs +0 -7
- package/esm2022/lib/utils/idle-detection/idle-detection.module.mjs +0 -25
- package/esm2022/lib/utils/idle-detection/idle-detection.service.mjs +0 -190
- package/esm2022/lib/utils/idle-detection/index.mjs +0 -4
- package/esm2022/lib/utils/index.mjs +0 -10
- package/esm2022/lib/utils/internal.util.mjs +0 -13
- package/esm2022/lib/utils/is-empty.util.mjs +0 -49
- package/esm2022/lib/utils/is-equal.util.mjs +0 -24
- package/esm2022/lib/utils/is-promise.util.mjs +0 -5
- package/esm2022/lib/utils/omit-by.util.mjs +0 -12
- package/esm2022/lib/utils/pick-by.util.mjs +0 -16
- package/esm2022/lib/utils/range.util.mjs +0 -28
- package/esm2022/lib/utils/url.util.mjs +0 -34
- package/esm2022/lib/validators/date-range.validator.mjs +0 -58
- package/esm2022/lib/validators/index.mjs +0 -5
- package/esm2022/lib/validators/intersection.validator.mjs +0 -34
- package/esm2022/lib/validators/unique.validator.mjs +0 -64
- package/esm2022/lib/validators/url.validator.mjs +0 -14
- package/esm2022/ngx-lift.mjs +0 -5
- package/esm2022/public-api.mjs +0 -10
- package/lib/const.d.ts +0 -5
- package/lib/models/async-state.model.d.ts +0 -22
- package/lib/models/index.d.ts +0 -5
- package/lib/models/kubernetes-list.model.d.ts +0 -10
- package/lib/models/kubernetes-object-condition.model.d.ts +0 -28
- package/lib/models/kubernetes-object-meta.model.d.ts +0 -38
- package/lib/models/kubernetes-object.model.d.ts +0 -8
- package/lib/operators/combine-latest-eager.operator.d.ts +0 -7
- package/lib/operators/create-async-state.operator.d.ts +0 -64
- package/lib/operators/distinct-on-change.operator.d.ts +0 -55
- package/lib/operators/index.d.ts +0 -8
- package/lib/operators/kubernetes-pagination.operator.d.ts +0 -30
- package/lib/operators/logger.operator.d.ts +0 -11
- package/lib/operators/poll.operator.d.ts +0 -39
- package/lib/operators/start-with-tap.operator.d.ts +0 -10
- package/lib/operators/switch-map-with-async-state.operator.d.ts +0 -31
- package/lib/pipes/array-join.pipe.d.ts +0 -7
- package/lib/pipes/byte-converter.pipe.d.ts +0 -40
- package/lib/pipes/index.d.ts +0 -5
- package/lib/pipes/is-https.pipe.d.ts +0 -7
- package/lib/pipes/mask.pipe.d.ts +0 -19
- package/lib/pipes/range.pipe.d.ts +0 -10
- package/lib/signals/combine-from.d.ts +0 -25
- package/lib/signals/computed-async.d.ts +0 -29
- package/lib/signals/create-trigger.d.ts +0 -4
- package/lib/signals/index.d.ts +0 -6
- package/lib/signals/inject-params.d.ts +0 -63
- package/lib/signals/inject-query-params.d.ts +0 -71
- package/lib/signals/merge-from.d.ts +0 -13
- package/lib/utils/difference-in-days.util.d.ts +0 -19
- package/lib/utils/form.util.d.ts +0 -18
- package/lib/utils/idle-detection/idle-detection.config.d.ts +0 -5
- package/lib/utils/idle-detection/idle-detection.module.d.ts +0 -13
- package/lib/utils/idle-detection/idle-detection.service.d.ts +0 -119
- package/lib/utils/idle-detection/index.d.ts +0 -3
- package/lib/utils/index.d.ts +0 -9
- package/lib/utils/internal.util.d.ts +0 -4
- package/lib/utils/is-empty.util.d.ts +0 -10
- package/lib/utils/is-equal.util.d.ts +0 -7
- package/lib/utils/is-promise.util.d.ts +0 -1
- package/lib/utils/omit-by.util.d.ts +0 -7
- package/lib/utils/pick-by.util.d.ts +0 -7
- package/lib/utils/range.util.d.ts +0 -12
- package/lib/utils/url.util.d.ts +0 -24
- package/lib/validators/date-range.validator.d.ts +0 -19
- package/lib/validators/index.d.ts +0 -4
- package/lib/validators/intersection.validator.d.ts +0 -9
- package/lib/validators/unique.validator.d.ts +0 -18
- package/lib/validators/url.validator.d.ts +0 -3
- package/public-api.d.ts +0 -6
package/index.d.ts
CHANGED
|
@@ -1,5 +1,1640 @@
|
|
|
1
|
+
import { HttpErrorResponse, HttpClient } from '@angular/common/http';
|
|
2
|
+
import * as rxjs from 'rxjs';
|
|
3
|
+
import { Observable, TapObserver, UnaryFunction, OperatorFunction, ObservableInput } from 'rxjs';
|
|
4
|
+
import * as i0 from '@angular/core';
|
|
5
|
+
import { Signal, PipeTransform, Injector, CreateComputedOptions, ModuleWithProviders } from '@angular/core';
|
|
6
|
+
import { Params } from '@angular/router';
|
|
7
|
+
import { AbstractControl, ValidatorFn, AsyncValidatorFn, ValidationErrors } from '@angular/forms';
|
|
8
|
+
|
|
1
9
|
/**
|
|
2
|
-
*
|
|
10
|
+
* Represents the state of an asynchronous operation, including loading, error, and data.
|
|
11
|
+
* @template T - The type of the data in the response.
|
|
12
|
+
* @template E - The type of the error response, defaulting to `HttpErrorResponse`.
|
|
3
13
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
14
|
+
interface AsyncState<T, E = HttpErrorResponse> {
|
|
15
|
+
/**
|
|
16
|
+
* Indicates whether the asynchronous operation is in progress.
|
|
17
|
+
*/
|
|
18
|
+
loading: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Represents any error that occurred during the asynchronous operation.
|
|
21
|
+
* Null if no error occurred.
|
|
22
|
+
*/
|
|
23
|
+
error: E | null;
|
|
24
|
+
/**
|
|
25
|
+
* The data resulting from the asynchronous operation.
|
|
26
|
+
* Null if the operation has not completed successfully.
|
|
27
|
+
*/
|
|
28
|
+
data: T | null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Represents the metadata of a Kubernetes object.
|
|
33
|
+
* Based on the Kubernetes API v1.23 ObjectMeta specification.
|
|
34
|
+
*
|
|
35
|
+
* @see {@link https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/#objectmeta-v1-meta | Kubernetes ObjectMeta API Reference}
|
|
36
|
+
*/
|
|
37
|
+
interface KubernetesObjectMetaV1 {
|
|
38
|
+
/**
|
|
39
|
+
* The name of the object. Must be unique within a namespace.
|
|
40
|
+
*/
|
|
41
|
+
name: string;
|
|
42
|
+
/**
|
|
43
|
+
* The namespace in which the object exists.
|
|
44
|
+
* Can be undefined for cluster-scoped resources.
|
|
45
|
+
*/
|
|
46
|
+
namespace?: string;
|
|
47
|
+
/**
|
|
48
|
+
* A URL representing this object. Populated by the system.
|
|
49
|
+
*/
|
|
50
|
+
selfLink?: string;
|
|
51
|
+
/**
|
|
52
|
+
* A unique identifier for the object. Generated by the system.
|
|
53
|
+
*/
|
|
54
|
+
uid?: string;
|
|
55
|
+
/**
|
|
56
|
+
* An opaque value that represents the internal version of this object.
|
|
57
|
+
* Used for optimistic concurrency control and watch operations.
|
|
58
|
+
*/
|
|
59
|
+
resourceVersion?: string;
|
|
60
|
+
/**
|
|
61
|
+
* A sequence number representing a specific generation of the desired state.
|
|
62
|
+
* Populated by the system. Read-only.
|
|
63
|
+
*/
|
|
64
|
+
generation?: number;
|
|
65
|
+
/**
|
|
66
|
+
* The timestamp when the object was created.
|
|
67
|
+
* Format: RFC3339 date-time string.
|
|
68
|
+
*/
|
|
69
|
+
creationTimestamp?: string;
|
|
70
|
+
/**
|
|
71
|
+
* The timestamp when the object was marked for deletion.
|
|
72
|
+
* Only present if the object is being deleted.
|
|
73
|
+
* Format: RFC3339 date-time string.
|
|
74
|
+
*/
|
|
75
|
+
deletionTimestamp?: string;
|
|
76
|
+
/**
|
|
77
|
+
* The grace period in seconds before the object will be permanently deleted.
|
|
78
|
+
* Only present if the object is being deleted.
|
|
79
|
+
*/
|
|
80
|
+
deletionGracePeriodSeconds?: number;
|
|
81
|
+
/**
|
|
82
|
+
* Map of string keys and values that can be used to organize and categorize objects.
|
|
83
|
+
*/
|
|
84
|
+
labels?: Record<string, string>;
|
|
85
|
+
/**
|
|
86
|
+
* Map of string keys and values that can be used to store arbitrary metadata.
|
|
87
|
+
*/
|
|
88
|
+
annotations?: Record<string, string>;
|
|
89
|
+
/**
|
|
90
|
+
* List of objects that own this object.
|
|
91
|
+
* Used for garbage collection and cascading deletions.
|
|
92
|
+
*/
|
|
93
|
+
ownerReferences?: OwnerReference[];
|
|
94
|
+
/**
|
|
95
|
+
* List of finalizers that must be executed before the object can be deleted.
|
|
96
|
+
*/
|
|
97
|
+
finalizers?: string[];
|
|
98
|
+
/**
|
|
99
|
+
* The name of the cluster where the object exists.
|
|
100
|
+
* Only present for objects in a cluster.
|
|
101
|
+
*/
|
|
102
|
+
clusterName?: string;
|
|
103
|
+
/**
|
|
104
|
+
* ManagedFields maps workflow-id and version to the set of fields
|
|
105
|
+
* that are managed by that workflow.
|
|
106
|
+
*/
|
|
107
|
+
managedFields?: ManagedField[];
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Represents a reference to another Kubernetes object that owns this object.
|
|
111
|
+
*/
|
|
112
|
+
interface OwnerReference {
|
|
113
|
+
/**
|
|
114
|
+
* The API version of the owner object.
|
|
115
|
+
*/
|
|
116
|
+
apiVersion: string;
|
|
117
|
+
/**
|
|
118
|
+
* The kind of the owner object.
|
|
119
|
+
*/
|
|
120
|
+
kind: string;
|
|
121
|
+
/**
|
|
122
|
+
* The name of the owner object.
|
|
123
|
+
*/
|
|
124
|
+
name: string;
|
|
125
|
+
/**
|
|
126
|
+
* The UID of the owner object.
|
|
127
|
+
*/
|
|
128
|
+
uid: string;
|
|
129
|
+
/**
|
|
130
|
+
* If true, this reference points to the managing controller.
|
|
131
|
+
*/
|
|
132
|
+
controller: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* If true, and the owner has the "foregroundDeletion" finalizer,
|
|
135
|
+
* then the owner cannot be deleted from the key-value store until
|
|
136
|
+
* this reference is removed.
|
|
137
|
+
*/
|
|
138
|
+
blockOwnerDeletion?: boolean;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Represents a managed field entry in the object metadata.
|
|
142
|
+
*/
|
|
143
|
+
interface ManagedField {
|
|
144
|
+
/**
|
|
145
|
+
* The API version of the field manager.
|
|
146
|
+
*/
|
|
147
|
+
apiVersion: string;
|
|
148
|
+
/**
|
|
149
|
+
* The type of fields being managed.
|
|
150
|
+
*/
|
|
151
|
+
fieldsType: string;
|
|
152
|
+
/**
|
|
153
|
+
* The fields in JSON format.
|
|
154
|
+
*/
|
|
155
|
+
fieldsV1: Record<string, unknown>;
|
|
156
|
+
/**
|
|
157
|
+
* The name of the manager that manages these fields.
|
|
158
|
+
*/
|
|
159
|
+
manager: string;
|
|
160
|
+
/**
|
|
161
|
+
* The operation type (e.g., "Apply", "Update").
|
|
162
|
+
*/
|
|
163
|
+
operation: string;
|
|
164
|
+
/**
|
|
165
|
+
* The subresource name, if applicable.
|
|
166
|
+
*/
|
|
167
|
+
subresource?: string;
|
|
168
|
+
/**
|
|
169
|
+
* The timestamp when the field was last modified.
|
|
170
|
+
* Format: RFC3339 date-time string.
|
|
171
|
+
*/
|
|
172
|
+
time: string;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Represents a Kubernetes object with standard API structure.
|
|
177
|
+
* This interface defines the common structure for all Kubernetes resources.
|
|
178
|
+
*
|
|
179
|
+
* @template T - The type of the spec object (optional).
|
|
180
|
+
* @template S - The type of the status object (optional).
|
|
181
|
+
*/
|
|
182
|
+
interface KubernetesObject {
|
|
183
|
+
/**
|
|
184
|
+
* The API version of the Kubernetes object.
|
|
185
|
+
* Example: "v1", "apps/v1", "networking.k8s.io/v1"
|
|
186
|
+
*/
|
|
187
|
+
apiVersion: string;
|
|
188
|
+
/**
|
|
189
|
+
* The kind of the Kubernetes object.
|
|
190
|
+
* Example: "Pod", "Deployment", "Service"
|
|
191
|
+
*/
|
|
192
|
+
kind: string;
|
|
193
|
+
/**
|
|
194
|
+
* Metadata about the Kubernetes object, including name, namespace, labels, etc.
|
|
195
|
+
*/
|
|
196
|
+
metadata: KubernetesObjectMetaV1;
|
|
197
|
+
/**
|
|
198
|
+
* The desired state of the object.
|
|
199
|
+
* The structure depends on the specific Kubernetes resource type.
|
|
200
|
+
*/
|
|
201
|
+
spec?: any;
|
|
202
|
+
/**
|
|
203
|
+
* The current state of the object.
|
|
204
|
+
* The structure depends on the specific Kubernetes resource type.
|
|
205
|
+
*/
|
|
206
|
+
status?: any;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Represents a list of Kubernetes objects, typically returned from list/watch API endpoints.
|
|
211
|
+
*
|
|
212
|
+
* @template T - The type of Kubernetes objects in the list. Must extend `KubernetesObject`.
|
|
213
|
+
*/
|
|
214
|
+
interface KubernetesList<T extends KubernetesObject> {
|
|
215
|
+
/**
|
|
216
|
+
* The API version of the Kubernetes list object.
|
|
217
|
+
* Example: "v1", "apps/v1"
|
|
218
|
+
*/
|
|
219
|
+
apiVersion: string;
|
|
220
|
+
/**
|
|
221
|
+
* Metadata about the list, including pagination information.
|
|
222
|
+
*/
|
|
223
|
+
metadata: {
|
|
224
|
+
/**
|
|
225
|
+
* A token that can be used to retrieve the next page of results.
|
|
226
|
+
* Empty string if there are no more results.
|
|
227
|
+
*/
|
|
228
|
+
continue: string;
|
|
229
|
+
/**
|
|
230
|
+
* The resource version of the list.
|
|
231
|
+
* Used for optimistic concurrency control and watch operations.
|
|
232
|
+
*/
|
|
233
|
+
resourceVersion: string;
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* The kind of the list object.
|
|
237
|
+
* Typically the plural form of the object kind, e.g., "PodList", "DeploymentList"
|
|
238
|
+
*/
|
|
239
|
+
kind: string;
|
|
240
|
+
/**
|
|
241
|
+
* The array of Kubernetes objects in the list.
|
|
242
|
+
*/
|
|
243
|
+
items: T[];
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Represents a condition of a Kubernetes object.
|
|
248
|
+
* Conditions provide a standard way to represent the status of an object and its components.
|
|
249
|
+
*
|
|
250
|
+
* @template T - The type of the condition type (e.g., 'Ready', 'Available', 'Progressing').
|
|
251
|
+
* @template R - The type of the reason string (e.g., 'PodScheduled', 'ContainersReady').
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* ```typescript
|
|
255
|
+
* const condition: KubernetesObjectCondition = {
|
|
256
|
+
* type: 'Ready',
|
|
257
|
+
* status: 'True',
|
|
258
|
+
* reason: 'PodReady',
|
|
259
|
+
* message: 'Pod is ready',
|
|
260
|
+
* lastTransitionTime: '2024-01-01T00:00:00Z'
|
|
261
|
+
* };
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
interface KubernetesObjectCondition<T = string, R = string> {
|
|
265
|
+
/**
|
|
266
|
+
* lastTransitionTime is a string representing the last time the condition transitioned from one status to another.
|
|
267
|
+
* If the underlying condition change is unknown, the time when the API field changed is used.
|
|
268
|
+
*/
|
|
269
|
+
lastTransitionTime: string;
|
|
270
|
+
/**
|
|
271
|
+
* message is a string providing a human - readable message about the transition. It can be an empty string.
|
|
272
|
+
*/
|
|
273
|
+
message: string;
|
|
274
|
+
/**
|
|
275
|
+
* reason is a string containing a programmatic identifier indicating the reason for the condition's last transition.
|
|
276
|
+
* Producers of specific condition types may define expected values and meanings for this field.
|
|
277
|
+
*/
|
|
278
|
+
reason: R;
|
|
279
|
+
/**
|
|
280
|
+
* status is an enum with possible values 'True', 'False', or 'Unknown' representing the current status of the condition.
|
|
281
|
+
*/
|
|
282
|
+
status: 'True' | 'False' | 'Unknown';
|
|
283
|
+
/**
|
|
284
|
+
* type is a string representing the type of condition in CamelCase or in foo.example.com/CamelCase format.
|
|
285
|
+
*/
|
|
286
|
+
type: T;
|
|
287
|
+
/**
|
|
288
|
+
* observedGeneration is an integer representing the.metadata.generation that the condition was set based upon.
|
|
289
|
+
*/
|
|
290
|
+
observedGeneration?: number;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
declare function combineLatestEager<T extends Observable<unknown>[]>(sources: T, startWithNullForAll?: boolean): Observable<{
|
|
294
|
+
[K in keyof T]: T[K] extends Observable<infer U> ? U | null : never;
|
|
295
|
+
}>;
|
|
296
|
+
declare function combineLatestEager<T extends Record<string, Observable<unknown>>>(sources: T, startWithNullForAll?: boolean): Observable<{
|
|
297
|
+
[K in keyof T]: T[K] extends Observable<infer U> ? U | null : never;
|
|
298
|
+
}>;
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* createAsyncState transforms an Observable of type T into an Observable of AsyncState<T>.
|
|
302
|
+
* AsyncState<T> represents the loading, error, and data states for asynchronous operations.
|
|
303
|
+
*
|
|
304
|
+
* @template T - The type of the data in the observable.
|
|
305
|
+
* @template E - The type of the error that can occur.
|
|
306
|
+
*
|
|
307
|
+
* @param {Partial<Observer<T>> | ((value: T) => void)} [observerOrNextForOrigin] -
|
|
308
|
+
* An optional parameter that can be a partial TapObserver<T> or a function to handle the next value or error in the original Observable.
|
|
309
|
+
*
|
|
310
|
+
* @returns {UnaryFunction<Observable<T>, Observable<AsyncState<T, E>>>} -
|
|
311
|
+
* A function that transforms an observable stream into an asynchronous state.
|
|
312
|
+
*
|
|
313
|
+
* @example
|
|
314
|
+
* Usage 1: Simple request
|
|
315
|
+
* data$ = this.shopService.products$.pipe(
|
|
316
|
+
* createAsyncState({
|
|
317
|
+
* next: res => console.log('Side effect if success: ' + res),
|
|
318
|
+
* error: error => console.error('Side effect if error: ' + error.message)
|
|
319
|
+
* })
|
|
320
|
+
* );
|
|
321
|
+
*
|
|
322
|
+
* Usage 2: Dependent requests
|
|
323
|
+
* data$ = firstCall$.pipe(
|
|
324
|
+
* switchMap(() => this.shopService.products$),
|
|
325
|
+
* createAsyncState()
|
|
326
|
+
* );
|
|
327
|
+
*
|
|
328
|
+
* Another implementation thought when refreshing the data: instead of startWith, `merge of` emit as the trigger
|
|
329
|
+
*
|
|
330
|
+
* subject.pipe(
|
|
331
|
+
* switchMap(() => merge(
|
|
332
|
+
* of({ loading: true, error: null, data: null }),
|
|
333
|
+
* this.service.apiCall().pipe(
|
|
334
|
+
* map(data => ({ loading: false, error: null, data })),
|
|
335
|
+
* tap({
|
|
336
|
+
* next: res => callback?.(res.data),
|
|
337
|
+
* error: err => errorCallback?.(err),
|
|
338
|
+
* }),
|
|
339
|
+
* catchError(error => of({ loading: false, error, data: null })),
|
|
340
|
+
* ),
|
|
341
|
+
* ))
|
|
342
|
+
* )
|
|
343
|
+
*
|
|
344
|
+
* Usage 3: provide initialValue
|
|
345
|
+
*
|
|
346
|
+
* import {createAsyncState} from 'ngx-lift';
|
|
347
|
+
* import {noop} from 'rxjs';
|
|
348
|
+
*
|
|
349
|
+
* private userService = inject(UserService);
|
|
350
|
+
* private location = inject(Location);
|
|
351
|
+
*
|
|
352
|
+
* userState$ = this.userService
|
|
353
|
+
* .getUserById(1)
|
|
354
|
+
* .pipe(createAsyncState<User>(noop, {loading: false, error: null, data: this.location.getState()}));
|
|
355
|
+
*/
|
|
356
|
+
declare function createAsyncState<T, E = HttpErrorResponse>(observerOrNextForOrigin?: Partial<TapObserver<T>> | ((value: T) => void), initialValue?: {
|
|
357
|
+
loading: boolean;
|
|
358
|
+
error: E | null;
|
|
359
|
+
data: T | null;
|
|
360
|
+
}): UnaryFunction<Observable<T>, Observable<AsyncState<T, E>>>;
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Creates an operator function for RxJS Observables that filters out consecutive
|
|
364
|
+
* values that are considered equal according to a provided comparator function,
|
|
365
|
+
* and invokes a callback when a distinct value is encountered.
|
|
366
|
+
*
|
|
367
|
+
* @template T - The type of elements emitted by the observable.
|
|
368
|
+
* @param {(previousValue: T, currentValue: T) => void} onChangeCallback
|
|
369
|
+
* A callback function that will be invoked when a distinct value is encountered.
|
|
370
|
+
* It receives the previous distinct value and the current value.
|
|
371
|
+
* @param {(previousValue: T, currentValue: T) => boolean} [comparator]
|
|
372
|
+
* A function that determines if two values are considered equal.
|
|
373
|
+
* Defaults to a function that performs strict equality (===) comparison.
|
|
374
|
+
* @returns {OperatorFunction<T, T>} - The RxJS operator function.
|
|
375
|
+
*
|
|
376
|
+
* @example
|
|
377
|
+
* Example 1:
|
|
378
|
+
* const source$ = new Observable<number>((observer) => {
|
|
379
|
+
* observer.next(1);
|
|
380
|
+
* observer.next(2);
|
|
381
|
+
* observer.next(2);
|
|
382
|
+
* observer.next(3);
|
|
383
|
+
* observer.next(3);
|
|
384
|
+
* observer.next(4);
|
|
385
|
+
* observer.next(5);
|
|
386
|
+
* observer.complete();
|
|
387
|
+
* });
|
|
388
|
+
*
|
|
389
|
+
* const distinctOnChange$ = source$.pipe(
|
|
390
|
+
* distinctOnChange(
|
|
391
|
+
* (prev, curr) => console.log(`Value changed from ${prev} to: ${curr}`),
|
|
392
|
+
* (prev, curr) => prev === curr,
|
|
393
|
+
* ),
|
|
394
|
+
* );
|
|
395
|
+
* distinctOnChange$.subscribe((res) => console.log(res));
|
|
396
|
+
*
|
|
397
|
+
*
|
|
398
|
+
* Example 2:
|
|
399
|
+
* distinctOnChange<RDEValue<OseInstance>[]>(
|
|
400
|
+
* () => {
|
|
401
|
+
* this.store.dispatch(
|
|
402
|
+
* addToast({
|
|
403
|
+
* toast: {
|
|
404
|
+
* type: ToastType.SUCCESS,
|
|
405
|
+
* title: this.l10nService.getMessage('STATUS_CHANGE'),
|
|
406
|
+
* description: this.l10nService.getMessage('STATUS_CHANGE_DESC'),
|
|
407
|
+
* },
|
|
408
|
+
* }),
|
|
409
|
+
* );
|
|
410
|
+
* },
|
|
411
|
+
* (prev, current) =>
|
|
412
|
+
* prev.every((prevInstance, index) => instanceComparator(prevInstance.entity, current[index].entity)),
|
|
413
|
+
* );
|
|
414
|
+
*/
|
|
415
|
+
declare function distinctOnChange<T>(onChangeCallback: (previousValue: T, currentValue: T) => void, comparator?: (previousValue: T, currentValue: T) => boolean): OperatorFunction<T, T>;
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Creates an RxJS operator that fetches paginated Kubernetes resources by continually making requests
|
|
419
|
+
* until all pages have been retrieved, and aggregates the items from all pages into a single KubernetesList.
|
|
420
|
+
*
|
|
421
|
+
* This operator uses Kubernetes' pagination mechanism with the `continue` token. It:
|
|
422
|
+
* - Starts with the initial request
|
|
423
|
+
* - Checks for a `continue` token in the response metadata
|
|
424
|
+
* - Makes subsequent requests with the `continue` token until no more pages exist
|
|
425
|
+
* - Aggregates all items from all pages into a single KubernetesList
|
|
426
|
+
*
|
|
427
|
+
* @template T - The type of Kubernetes objects in the list. Must extend `KubernetesObject`.
|
|
428
|
+
* @param http - The HttpClient instance used to make the HTTP requests.
|
|
429
|
+
* @param endpoint - The API endpoint to fetch the resources from.
|
|
430
|
+
* @param initialParams - Optional initial parameters to include in the request.
|
|
431
|
+
* Can include query parameters like filters and pagination settings.
|
|
432
|
+
* Note: `limit` and `continue` are Kubernetes-specific pagination parameters.
|
|
433
|
+
* @returns An RxJS operator function that transforms a source Observable into an Observable
|
|
434
|
+
* that emits a single KubernetesList containing all aggregated items from all pages.
|
|
435
|
+
*
|
|
436
|
+
* @example
|
|
437
|
+
* ```typescript
|
|
438
|
+
* // Use as an operator
|
|
439
|
+
* this.http.get<KubernetesList<Pod>>('/api/v1/pods')
|
|
440
|
+
* .pipe(
|
|
441
|
+
* aggregatePaginatedKubernetesResources(this.http, '/api/v1/pods', { limit: 100 })
|
|
442
|
+
* )
|
|
443
|
+
* .subscribe(list => {
|
|
444
|
+
* console.log(`Total pods: ${list.items.length}`);
|
|
445
|
+
* });
|
|
446
|
+
* ```
|
|
447
|
+
*/
|
|
448
|
+
declare function aggregatePaginatedKubernetesResources<T extends KubernetesObject>(http: HttpClient, endpoint: string, initialParams?: Record<string, string | number | boolean | (string | number | boolean)[]>): OperatorFunction<KubernetesList<T>, KubernetesList<T>>;
|
|
449
|
+
/**
|
|
450
|
+
* Fetches paginated Kubernetes resources by continually making requests until all pages have been retrieved.
|
|
451
|
+
*
|
|
452
|
+
* This function is a convenience wrapper that combines the initial HTTP request with pagination handling.
|
|
453
|
+
* It automatically handles Kubernetes pagination using the `continue` token mechanism.
|
|
454
|
+
*
|
|
455
|
+
* Unlike `aggregatePaginatedKubernetesResources`, this function makes the initial request itself
|
|
456
|
+
* rather than being used as an operator on an existing Observable.
|
|
457
|
+
*
|
|
458
|
+
* @template T - The type of Kubernetes objects in the list. Must extend `KubernetesObject`.
|
|
459
|
+
* @param http - The HttpClient instance used to make the HTTP requests.
|
|
460
|
+
* @param endpoint - The API endpoint to fetch the resources from.
|
|
461
|
+
* @param initialParams - Optional initial parameters to include in the request.
|
|
462
|
+
* Can include query parameters like filters and pagination settings.
|
|
463
|
+
* Note: `limit` and `continue` are Kubernetes-specific pagination parameters.
|
|
464
|
+
* @returns An Observable that emits a single KubernetesList containing all aggregated items from all pages.
|
|
465
|
+
*
|
|
466
|
+
* @example
|
|
467
|
+
* ```typescript
|
|
468
|
+
* // Fetch all pods across all pages
|
|
469
|
+
* fetchPaginatedKubernetesResources<Pod>(
|
|
470
|
+
* this.http,
|
|
471
|
+
* '/api/v1/pods',
|
|
472
|
+
* { limit: 100 }
|
|
473
|
+
* ).subscribe(list => {
|
|
474
|
+
* console.log(`Total pods: ${list.items.length}`);
|
|
475
|
+
* });
|
|
476
|
+
* ```
|
|
477
|
+
*/
|
|
478
|
+
declare function fetchPaginatedKubernetesResources<T extends KubernetesObject>(http: HttpClient, endpoint: string, initialParams?: Record<string, string | number | boolean | (string | number | boolean)[]>): Observable<KubernetesList<T>>;
|
|
479
|
+
|
|
480
|
+
type LoggerType = 'count' | 'debug' | 'dir' | 'log' | 'table';
|
|
481
|
+
/**
|
|
482
|
+
* RxJS operator that logs values emitted by an observable using various console methods.
|
|
483
|
+
* Useful for debugging and monitoring observable streams during development.
|
|
484
|
+
*
|
|
485
|
+
* @template T - The type of values emitted by the observable.
|
|
486
|
+
* @param loggerType - The type of logger to be used. Options:
|
|
487
|
+
* - `'log'`: Standard console.log (default)
|
|
488
|
+
* - `'debug'`: Console.debug for debug messages
|
|
489
|
+
* - `'dir'`: Console.dir for object inspection
|
|
490
|
+
* - `'count'`: Console.count for counting emissions
|
|
491
|
+
* - `'table'`: Console.table for tabular data display
|
|
492
|
+
* @returns An RxJS operator function that logs values using the specified console function.
|
|
493
|
+
*
|
|
494
|
+
* @example
|
|
495
|
+
* ```typescript
|
|
496
|
+
* // Log all values
|
|
497
|
+
* source$.pipe(logger()).subscribe();
|
|
498
|
+
*
|
|
499
|
+
* // Use debug logger
|
|
500
|
+
* source$.pipe(logger('debug')).subscribe();
|
|
501
|
+
*
|
|
502
|
+
* // Display objects in table format
|
|
503
|
+
* users$.pipe(logger('table')).subscribe();
|
|
504
|
+
* ```
|
|
505
|
+
*/
|
|
506
|
+
declare const logger: <T>(loggerType?: LoggerType) => OperatorFunction<T, T>;
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Polls data at a specified interval and can be triggered manually, returning an observable that
|
|
510
|
+
* emits the result of each poll as an `AsyncState` object.
|
|
511
|
+
*
|
|
512
|
+
* This operator is useful for periodically fetching data from an API or checking for updates.
|
|
513
|
+
* It supports:
|
|
514
|
+
* - Automatic polling at a specified interval
|
|
515
|
+
* - Manual refresh triggers via Observable or Signal
|
|
516
|
+
* - Parameter building for dynamic polling requests
|
|
517
|
+
* - Initial values and delayed start
|
|
518
|
+
*
|
|
519
|
+
* The polling function can return an Observable, Promise, or synchronous value.
|
|
520
|
+
* The operator uses `exhaustMap` internally, which means if a poll is in progress when a new
|
|
521
|
+
* trigger arrives, the new trigger will be ignored until the current poll completes.
|
|
522
|
+
*
|
|
523
|
+
* @template Data - The type of the data emitted by the polling function.
|
|
524
|
+
* @template Input - The type of the input parameter used to build polling parameters (when using `forceRefresh`).
|
|
525
|
+
*
|
|
526
|
+
* @param options - Configuration options for polling:
|
|
527
|
+
* - `interval`: The interval in milliseconds between each automatic poll.
|
|
528
|
+
* - `pollingFn`: A function that returns an Observable, Promise, or primitive value to poll.
|
|
529
|
+
* When `forceRefresh` is provided, this function receives the parameter value.
|
|
530
|
+
* - `forceRefresh`: Optional Observable or Signal that triggers a manual refresh.
|
|
531
|
+
* The emitted value can be used as a parameter for `pollingFn` or transformed via `paramsBuilder`.
|
|
532
|
+
* - `paramsBuilder`: Optional function that transforms the `forceRefresh` value into parameters for `pollingFn`.
|
|
533
|
+
* - `initialValue`: Optional initial `AsyncState` value to emit before the first poll completes.
|
|
534
|
+
* - `delay`: Optional delay in milliseconds to wait before starting the first poll.
|
|
535
|
+
*
|
|
536
|
+
* @returns An observable that emits `AsyncState<Data>` objects representing the polling results.
|
|
537
|
+
* Each emission includes `loading`, `error`, and `data` properties.
|
|
538
|
+
*
|
|
539
|
+
* @example
|
|
540
|
+
* ```typescript
|
|
541
|
+
* // Simple polling
|
|
542
|
+
* const dataState$ = poll({
|
|
543
|
+
* interval: 5000, // Poll every 5 seconds
|
|
544
|
+
* pollingFn: () => this.http.get('/api/data'),
|
|
545
|
+
* initialValue: { loading: true, error: null, data: null }
|
|
546
|
+
* });
|
|
547
|
+
*
|
|
548
|
+
* // Polling with manual refresh
|
|
549
|
+
* const refresh$ = new Subject<void>();
|
|
550
|
+
* const dataState$ = poll({
|
|
551
|
+
* interval: 5000,
|
|
552
|
+
* pollingFn: () => this.http.get('/api/data'),
|
|
553
|
+
* forceRefresh: refresh$
|
|
554
|
+
* });
|
|
555
|
+
*
|
|
556
|
+
* // Polling with parameters
|
|
557
|
+
* const userId$ = new BehaviorSubject(1);
|
|
558
|
+
* const userState$ = poll({
|
|
559
|
+
* interval: 10000,
|
|
560
|
+
* pollingFn: (id: number) => this.http.get(`/api/users/${id}`),
|
|
561
|
+
* forceRefresh: userId$,
|
|
562
|
+
* paramsBuilder: (id) => id
|
|
563
|
+
* });
|
|
564
|
+
* ```
|
|
565
|
+
*/
|
|
566
|
+
declare function poll<Data>(options: {
|
|
567
|
+
interval: number;
|
|
568
|
+
pollingFn: (params: any) => Observable<Data> | Promise<Data> | Data;
|
|
569
|
+
initialValue?: AsyncState<Data>;
|
|
570
|
+
delay?: number;
|
|
571
|
+
}): Observable<AsyncState<Data>>;
|
|
572
|
+
declare function poll<Data, Input>(options: {
|
|
573
|
+
interval: number;
|
|
574
|
+
pollingFn: (params: Input) => Observable<Data> | Promise<Data> | Data;
|
|
575
|
+
forceRefresh: Observable<Input> | Signal<Input>;
|
|
576
|
+
initialValue?: AsyncState<Data>;
|
|
577
|
+
delay?: number;
|
|
578
|
+
}): Observable<AsyncState<Data>>;
|
|
579
|
+
declare function poll<Data, Input>(options: {
|
|
580
|
+
interval: number;
|
|
581
|
+
pollingFn: (params: any) => Observable<Data> | Promise<Data> | Data;
|
|
582
|
+
forceRefresh: Observable<Input> | Signal<Input>;
|
|
583
|
+
paramsBuilder: (input: Input) => any;
|
|
584
|
+
initialValue?: AsyncState<Data>;
|
|
585
|
+
delay?: number;
|
|
586
|
+
}): Observable<AsyncState<Data>>;
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* RxJS operator that executes a callback function before the source Observable starts emitting values.
|
|
590
|
+
* This operator is useful for triggering side effects (like logging, state updates, or initialization)
|
|
591
|
+
* before the main Observable begins emitting.
|
|
592
|
+
*
|
|
593
|
+
* @template T - The type of values emitted by the observable.
|
|
594
|
+
* @param callback - A function to be executed synchronously before the source Observable emits its first value.
|
|
595
|
+
* @returns An RxJS operator function that executes the callback and then returns the source Observable unchanged.
|
|
596
|
+
*
|
|
597
|
+
* @example
|
|
598
|
+
* ```typescript
|
|
599
|
+
* // Log before starting
|
|
600
|
+
* data$.pipe(
|
|
601
|
+
* startWithTap(() => console.log('Starting data fetch...')),
|
|
602
|
+
* switchMap(() => this.http.get('/api/data'))
|
|
603
|
+
* ).subscribe();
|
|
604
|
+
*
|
|
605
|
+
* // Update loading state
|
|
606
|
+
* data$.pipe(
|
|
607
|
+
* startWithTap(() => this.loading.set(true)),
|
|
608
|
+
* finalize(() => this.loading.set(false))
|
|
609
|
+
* ).subscribe();
|
|
610
|
+
* ```
|
|
611
|
+
*/
|
|
612
|
+
declare function startWithTap<T>(callback: () => void): (source: Observable<T>) => Observable<T>;
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Custom RxJS operator that uses switchMap to handle asynchronous operations and
|
|
616
|
+
* transforms the emitted values into an AsyncState object.
|
|
617
|
+
*
|
|
618
|
+
* @template T - The type of data emitted by the observable returned by the project.
|
|
619
|
+
* @template K - The type of value emitted by the source observable.
|
|
620
|
+
* @template E - The type of error that can be encountered during the asynchronous operation.
|
|
621
|
+
*
|
|
622
|
+
* @param {function(K): Observable<T>} project - A function that takes a value emitted by the source
|
|
623
|
+
* observable and returns an observable representing an asynchronous operation.
|
|
624
|
+
*
|
|
625
|
+
* @returns {OperatorFunction<K, AsyncState<T, E>>} - An RxJS operator that transforms the source observable into
|
|
626
|
+
* an observable of AsyncState objects.
|
|
627
|
+
*
|
|
628
|
+
* @example
|
|
629
|
+
* // Usage of the switchMapWithAsyncState operator
|
|
630
|
+
* const source$ = new BehaviorSubject<number>(1);
|
|
631
|
+
*
|
|
632
|
+
* const asyncOperation = (value: number) => {
|
|
633
|
+
* return of(value * 2).pipe(delay(1000));
|
|
634
|
+
* };
|
|
635
|
+
*
|
|
636
|
+
* const result$ = source$.pipe(switchMapWithAsyncState(asyncOperation));
|
|
637
|
+
* result$.subscribe((state) => {
|
|
638
|
+
* console.log(state); // Outputs AsyncState objects with loading, data, and error properties.
|
|
639
|
+
* });
|
|
640
|
+
*/
|
|
641
|
+
declare function switchMapWithAsyncState<T, K, E = HttpErrorResponse>(project: (value: K, index: number) => Observable<T>): OperatorFunction<K, AsyncState<T, E>>;
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Angular pipe that joins array elements into a string using a specified separator.
|
|
645
|
+
*
|
|
646
|
+
* @example
|
|
647
|
+
* ```html
|
|
648
|
+
* <!-- Join array with default comma separator -->
|
|
649
|
+
* <div>{{ ['apple', 'banana', 'cherry'] | arrayJoin }}</div>
|
|
650
|
+
* <!-- Output: "apple,banana,cherry" -->
|
|
651
|
+
*
|
|
652
|
+
* <!-- Join array with custom separator -->
|
|
653
|
+
* <div>{{ ['apple', 'banana', 'cherry'] | arrayJoin: ' - ' }}</div>
|
|
654
|
+
* <!-- Output: "apple - banana - cherry" -->
|
|
655
|
+
* ```
|
|
656
|
+
*/
|
|
657
|
+
declare class ArrayJoinPipe implements PipeTransform {
|
|
658
|
+
/**
|
|
659
|
+
* Transforms an array into a string by joining its elements with a separator.
|
|
660
|
+
*
|
|
661
|
+
* @param value - The array to join. If not an array, returns the value as-is.
|
|
662
|
+
* @param separator - The separator string to use between array elements. Defaults to ','.
|
|
663
|
+
* @returns A string containing the joined array elements, or the original value if not an array
|
|
664
|
+
*/
|
|
665
|
+
transform(value: unknown, separator?: string): string | unknown;
|
|
666
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ArrayJoinPipe, never>;
|
|
667
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<ArrayJoinPipe, "arrayJoin", true>;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* Angular pipe that converts a number of bytes into a human-readable string format
|
|
672
|
+
* (e.g., "1.5 MB", "2.3 GB") with locale-aware formatting.
|
|
673
|
+
*
|
|
674
|
+
* Supports multiple locales including English, French, Chinese, Japanese, and more.
|
|
675
|
+
* The pipe uses the application's LOCALE_ID to determine the appropriate unit translations.
|
|
676
|
+
*
|
|
677
|
+
* @example
|
|
678
|
+
* ```html
|
|
679
|
+
* <!-- Convert bytes to human-readable format -->
|
|
680
|
+
* <div>{{ 1024 | byteConverter }}</div>
|
|
681
|
+
* <!-- Output: "1 KB" (English) or "1 Ko" (French) -->
|
|
682
|
+
*
|
|
683
|
+
* <div>{{ 1048576 | byteConverter }}</div>
|
|
684
|
+
* <!-- Output: "1 MB" (English) or "1 Mo" (French) -->
|
|
685
|
+
* ```
|
|
686
|
+
*
|
|
687
|
+
* @example
|
|
688
|
+
* To use locale-specific formatting, configure LOCALE_ID in your app:
|
|
689
|
+
* ```typescript
|
|
690
|
+
* import { LOCALE_ID, NgModule } from '@angular/core';
|
|
691
|
+
* import { registerLocaleData } from '@angular/common';
|
|
692
|
+
* import localeEn from '@angular/common/locales/en';
|
|
693
|
+
* import localeFr from '@angular/common/locales/fr';
|
|
694
|
+
*
|
|
695
|
+
* registerLocaleData(localeEn);
|
|
696
|
+
* registerLocaleData(localeFr);
|
|
697
|
+
*
|
|
698
|
+
* @NgModule({
|
|
699
|
+
* providers: [
|
|
700
|
+
* {
|
|
701
|
+
* provide: LOCALE_ID,
|
|
702
|
+
* useFactory: () => navigator.language || 'en',
|
|
703
|
+
* },
|
|
704
|
+
* ],
|
|
705
|
+
* })
|
|
706
|
+
* export class AppModule {}
|
|
707
|
+
* ```
|
|
708
|
+
*/
|
|
709
|
+
declare class ByteConverterPipe implements PipeTransform {
|
|
710
|
+
private locale;
|
|
711
|
+
transform(value: number): string;
|
|
712
|
+
transform(value?: number): string | null;
|
|
713
|
+
transform(value?: number | null): string | null;
|
|
714
|
+
private formatNumber;
|
|
715
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ByteConverterPipe, never>;
|
|
716
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<ByteConverterPipe, "byteConverter", true>;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* Angular pipe that checks if a URL string uses the HTTPS protocol.
|
|
721
|
+
*
|
|
722
|
+
* @example
|
|
723
|
+
* ```html
|
|
724
|
+
* <!-- Check if URL is HTTPS -->
|
|
725
|
+
* <div>{{ 'https://example.com' | isHttps }}</div>
|
|
726
|
+
* <!-- Output: true -->
|
|
727
|
+
*
|
|
728
|
+
* <div>{{ 'http://example.com' | isHttps }}</div>
|
|
729
|
+
* <!-- Output: false -->
|
|
730
|
+
* ```
|
|
731
|
+
*/
|
|
732
|
+
declare class IsHttpsPipe implements PipeTransform {
|
|
733
|
+
/**
|
|
734
|
+
* Transforms a URL string into a boolean indicating whether it uses HTTPS.
|
|
735
|
+
*
|
|
736
|
+
* @param value - The URL string to check
|
|
737
|
+
* @returns `true` if the URL uses HTTPS protocol, `false` otherwise
|
|
738
|
+
*/
|
|
739
|
+
transform(value: string): boolean;
|
|
740
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<IsHttpsPipe, never>;
|
|
741
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<IsHttpsPipe, "isHttps", true>;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
/**
|
|
745
|
+
* Options for configuring the mask pipe behavior.
|
|
746
|
+
*/
|
|
747
|
+
interface MaskOptions {
|
|
748
|
+
/**
|
|
749
|
+
* The number of characters to leave unmasked at the beginning of the string.
|
|
750
|
+
* Defaults to 6.
|
|
751
|
+
*/
|
|
752
|
+
unmaskedPrefixLength?: number;
|
|
753
|
+
/**
|
|
754
|
+
* The number of characters to leave unmasked at the end of the string.
|
|
755
|
+
* Defaults to 6.
|
|
756
|
+
*/
|
|
757
|
+
unmaskedSuffixLength?: number;
|
|
758
|
+
/**
|
|
759
|
+
* Whether to apply masking. If `false`, the original string is returned unchanged.
|
|
760
|
+
* Defaults to `true`.
|
|
761
|
+
*/
|
|
762
|
+
masked?: boolean;
|
|
763
|
+
}
|
|
764
|
+
/**
|
|
765
|
+
* Angular pipe that masks sensitive string data by replacing characters with asterisks,
|
|
766
|
+
* while preserving a configurable number of characters at the beginning and end.
|
|
767
|
+
*
|
|
768
|
+
* @example
|
|
769
|
+
* ```html
|
|
770
|
+
* <!-- Mask a credit card number -->
|
|
771
|
+
* <div>{{ '1234567890123456' | mask }}</div>
|
|
772
|
+
* <!-- Output: "123456******3456" -->
|
|
773
|
+
*
|
|
774
|
+
* <!-- Custom masking options -->
|
|
775
|
+
* <div>{{ '1234567890123456' | mask: { unmaskedPrefixLength: 4, unmaskedSuffixLength: 4 } }}</div>
|
|
776
|
+
* <!-- Output: "1234********3456" -->
|
|
777
|
+
* ```
|
|
778
|
+
*/
|
|
779
|
+
declare class MaskPipe implements PipeTransform {
|
|
780
|
+
/**
|
|
781
|
+
* Transforms the input string by masking characters based on the provided options.
|
|
782
|
+
*
|
|
783
|
+
* @param value - The input string to be masked
|
|
784
|
+
* @param options - Options for customizing the masking behavior
|
|
785
|
+
* @returns The masked string, or the original string if masking is disabled or the string is too short
|
|
786
|
+
*/
|
|
787
|
+
transform(value: string, options?: MaskOptions): string;
|
|
788
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MaskPipe, never>;
|
|
789
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<MaskPipe, "mask", true>;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* Angular pipe that generates an array of numbers within a specified range.
|
|
794
|
+
*
|
|
795
|
+
* @example
|
|
796
|
+
* ```html
|
|
797
|
+
* <!-- Generate array from 0 to 4 -->
|
|
798
|
+
* <div *ngFor="let i of [5] | range">{{ i }}</div>
|
|
799
|
+
*
|
|
800
|
+
* <!-- Generate array from 1 to 5 -->
|
|
801
|
+
* <div *ngFor="let i of [1, 5] | range">{{ i }}</div>
|
|
802
|
+
*
|
|
803
|
+
* <!-- Generate array from 0 to 10 with step 2 -->
|
|
804
|
+
* <div *ngFor="let i of [0, 10, 2] | range">{{ i }}</div>
|
|
805
|
+
* ```
|
|
806
|
+
*/
|
|
807
|
+
declare class RangePipe implements PipeTransform {
|
|
808
|
+
/**
|
|
809
|
+
* Transforms the input value into an array of numbers.
|
|
810
|
+
*
|
|
811
|
+
* @param value - An array containing:
|
|
812
|
+
* - `[number]`: The end value (starts from 0)
|
|
813
|
+
* - `[number, number]`: The start and end values
|
|
814
|
+
* - `[number, number, number]`: The start, end, and step values
|
|
815
|
+
* - `[number, number, number, boolean]`: The start, end, step, and inclusive flag
|
|
816
|
+
* @returns An array of numbers within the specified range
|
|
817
|
+
*/
|
|
818
|
+
transform(value: [number]): number[];
|
|
819
|
+
transform(value: [number, number]): number[];
|
|
820
|
+
transform(value: [number, number, number]): number[];
|
|
821
|
+
transform(value: [number, number, number, boolean]): number[];
|
|
822
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<RangePipe, never>;
|
|
823
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<RangePipe, "range", true>;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
type ObservableSignalInput$1<T> = ObservableInput<T> | Signal<T>;
|
|
827
|
+
type ObservableSignalInputTuple$1<T> = {
|
|
828
|
+
[K in keyof T]: ObservableSignalInput$1<T[K]> | (() => T[K]);
|
|
829
|
+
};
|
|
830
|
+
type CombineFromOptions<IValue> = {
|
|
831
|
+
readonly injector?: Injector;
|
|
832
|
+
readonly initialValue?: IValue;
|
|
833
|
+
};
|
|
834
|
+
declare function combineFrom<Input extends readonly unknown[], Output = Input>(sources: readonly [...ObservableSignalInputTuple$1<Input>]): Signal<Output>;
|
|
835
|
+
declare function combineFrom<Input extends readonly unknown[], Output = Input>(sources: readonly [...ObservableSignalInputTuple$1<Input>], operator?: OperatorFunction<Input, Output>, options?: CombineFromOptions<undefined>): Signal<Output | undefined>;
|
|
836
|
+
declare function combineFrom<Input extends readonly unknown[], Output = Input>(sources: readonly [...ObservableSignalInputTuple$1<Input>], operator?: OperatorFunction<Input, Output>, options?: CombineFromOptions<null>): Signal<Output | null>;
|
|
837
|
+
declare function combineFrom<Input extends readonly unknown[], Output = Input>(sources: readonly [...ObservableSignalInputTuple$1<Input>], operator?: OperatorFunction<Input, Output>, options?: CombineFromOptions<Output>): Signal<Output>;
|
|
838
|
+
declare function combineFrom<Input extends readonly unknown[], Output = Input>(sources: readonly [...ObservableSignalInputTuple$1<Input>], options?: CombineFromOptions<undefined>): Signal<Output | undefined>;
|
|
839
|
+
declare function combineFrom<Input extends readonly unknown[], Output = Input>(sources: readonly [...ObservableSignalInputTuple$1<Input>], options?: CombineFromOptions<null>): Signal<Output | null>;
|
|
840
|
+
declare function combineFrom<Input extends readonly unknown[], Output = Input>(sources: readonly [...ObservableSignalInputTuple$1<Input>], options?: CombineFromOptions<Output>): Signal<Output>;
|
|
841
|
+
declare function combineFrom<Input extends object, Output = Input>(sources: ObservableSignalInputTuple$1<Input>): Signal<Output>;
|
|
842
|
+
declare function combineFrom<Input extends object, Output = Input>(sources: ObservableSignalInputTuple$1<Input>, operator?: OperatorFunction<Input, Output>, options?: CombineFromOptions<undefined>): Signal<Output | undefined>;
|
|
843
|
+
declare function combineFrom<Input extends object, Output = Input>(sources: ObservableSignalInputTuple$1<Input>, operator?: OperatorFunction<Input, Output>, options?: CombineFromOptions<null>): Signal<Output | null>;
|
|
844
|
+
declare function combineFrom<Input extends object, Output = Input>(sources: ObservableSignalInputTuple$1<Input>, operator?: OperatorFunction<Input, Output>, options?: CombineFromOptions<Output>): Signal<Output>;
|
|
845
|
+
declare function combineFrom<Input extends object, Output = Input>(sources: ObservableSignalInputTuple$1<Input>, options?: CombineFromOptions<undefined>): Signal<Output | undefined>;
|
|
846
|
+
declare function combineFrom<Input extends object, Output = Input>(sources: ObservableSignalInputTuple$1<Input>, options?: CombineFromOptions<null>): Signal<Output | null>;
|
|
847
|
+
declare function combineFrom<Input extends object, Output = Input>(sources: ObservableSignalInputTuple$1<Input>, options?: CombineFromOptions<Output>): Signal<Output>;
|
|
848
|
+
|
|
849
|
+
/**
|
|
850
|
+
* Behavior mode for handling multiple async sources in computedAsync.
|
|
851
|
+
* - `switch`: Cancel previous async operations when a new one starts (default)
|
|
852
|
+
* - `merge`: Process all async operations concurrently
|
|
853
|
+
* - `concat`: Process async operations sequentially
|
|
854
|
+
* - `exhaust`: Ignore new async operations while one is in progress
|
|
855
|
+
*/
|
|
856
|
+
type ComputedAsyncBehavior = 'switch' | 'merge' | 'concat' | 'exhaust';
|
|
857
|
+
type BaseOptions<T> = CreateComputedOptions<T> & {
|
|
858
|
+
behavior?: ComputedAsyncBehavior;
|
|
859
|
+
};
|
|
860
|
+
type OptionsWithInitialValue<T> = {
|
|
861
|
+
initialValue: T;
|
|
862
|
+
} & BaseOptions<T>;
|
|
863
|
+
type OptionsWithOptionalInitialValue<T> = {
|
|
864
|
+
initialValue?: undefined;
|
|
865
|
+
} & BaseOptions<T>;
|
|
866
|
+
type OptionsWithRequireSync<T> = {
|
|
867
|
+
requireSync: true;
|
|
868
|
+
} & BaseOptions<T>;
|
|
869
|
+
/**
|
|
870
|
+
* Creates a computed signal that can derive its value from asynchronous sources
|
|
871
|
+
* (Observables, Promises) or synchronous values. The signal automatically updates
|
|
872
|
+
* when dependencies change.
|
|
873
|
+
*
|
|
874
|
+
* This function extends Angular's `computed()` to support async operations. It handles:
|
|
875
|
+
* - Observables: Automatically subscribes and unsubscribes
|
|
876
|
+
* - Promises: Converts to Observable and handles resolution
|
|
877
|
+
* - Synchronous values: Returns immediately
|
|
878
|
+
*
|
|
879
|
+
* The function supports different behaviors for handling multiple async operations:
|
|
880
|
+
* - `switch`: Cancel previous operations when a new one starts (default)
|
|
881
|
+
* - `merge`: Process all operations concurrently
|
|
882
|
+
* - `concat`: Process operations sequentially
|
|
883
|
+
* - `exhaust`: Ignore new operations while one is in progress
|
|
884
|
+
*
|
|
885
|
+
* @template T - The type of the computed value.
|
|
886
|
+
* @param computeFn - A function that computes the value. Can return an Observable, Promise, or synchronous value.
|
|
887
|
+
* The function receives the previous value as a parameter (if available).
|
|
888
|
+
* @param options - Optional configuration:
|
|
889
|
+
* - `initialValue`: Initial value for the Signal
|
|
890
|
+
* - `requireSync`: If `true`, requires the first computation to be synchronous (throws error for Promises)
|
|
891
|
+
* - `behavior`: How to handle multiple async operations ('switch' | 'merge' | 'concat' | 'exhaust')
|
|
892
|
+
* - `equal`: Custom equality function for signal comparison
|
|
893
|
+
* @returns A signal that emits the computed value. May be `T | undefined` if no initial value is provided.
|
|
894
|
+
*
|
|
895
|
+
* @example
|
|
896
|
+
* ```typescript
|
|
897
|
+
* // Basic usage with Observable
|
|
898
|
+
* const userId = signal(1);
|
|
899
|
+
* const user = computedAsync(() => this.userService.getUser(userId()));
|
|
900
|
+
*
|
|
901
|
+
* // With initial value
|
|
902
|
+
* const user = computedAsync(
|
|
903
|
+
* () => this.userService.getUser(userId()),
|
|
904
|
+
* { initialValue: null }
|
|
905
|
+
* );
|
|
906
|
+
*
|
|
907
|
+
* // With requireSync (ensures synchronous initial value)
|
|
908
|
+
* const user = computedAsync(
|
|
909
|
+
* () => this.userService.getUserSync(userId()),
|
|
910
|
+
* { requireSync: true }
|
|
911
|
+
* );
|
|
912
|
+
*
|
|
913
|
+
* // With behavior option
|
|
914
|
+
* const data = computedAsync(
|
|
915
|
+
* () => this.dataService.getData(),
|
|
916
|
+
* { behavior: 'merge' }
|
|
917
|
+
* );
|
|
918
|
+
* ```
|
|
919
|
+
*/
|
|
920
|
+
declare function computedAsync<T>(computeFn: (previousValue?: T) => Observable<T> | Promise<T> | T | undefined): Signal<T | undefined>;
|
|
921
|
+
declare function computedAsync<T>(computeFn: (previousValue?: T) => Observable<T> | Promise<T> | T | undefined, options: OptionsWithOptionalInitialValue<T>): Signal<T | undefined>;
|
|
922
|
+
declare function computedAsync<T>(computeFn: (previousValue?: T) => Observable<T> | Promise<T> | T | undefined, options: OptionsWithInitialValue<T>): Signal<T>;
|
|
923
|
+
declare function computedAsync<T>(computeFn: (previousValue?: T) => Promise<T>, options: OptionsWithOptionalInitialValue<T> & {
|
|
924
|
+
requireSync: true;
|
|
925
|
+
}): never;
|
|
926
|
+
declare function computedAsync<T>(computeFn: (previousValue?: T) => Observable<T> | T | undefined, options: {
|
|
927
|
+
initialValue?: undefined;
|
|
928
|
+
requireSync?: false;
|
|
929
|
+
} & BaseOptions<T>): Signal<T | undefined>;
|
|
930
|
+
declare function computedAsync<T>(computeFn: (previousValue?: T) => Observable<T> | T, options: OptionsWithRequireSync<T> & {
|
|
931
|
+
initialValue?: undefined | T;
|
|
932
|
+
}): Signal<T>;
|
|
933
|
+
|
|
934
|
+
/**
|
|
935
|
+
* Creates a trigger signal that can be used to manually trigger updates or side effects.
|
|
936
|
+
* The trigger maintains an internal counter that increments each time `next()` is called.
|
|
937
|
+
*
|
|
938
|
+
* @returns An object containing:
|
|
939
|
+
* - `next()`: A function to trigger an update (increments the internal counter)
|
|
940
|
+
* - `value`: A readonly signal that emits the current counter value
|
|
941
|
+
*
|
|
942
|
+
* @example
|
|
943
|
+
* ```typescript
|
|
944
|
+
* export class MyComponent {
|
|
945
|
+
* private refreshTrigger = createTrigger();
|
|
946
|
+
*
|
|
947
|
+
* // Use the trigger to refresh data
|
|
948
|
+
* refreshData() {
|
|
949
|
+
* this.refreshTrigger.next();
|
|
950
|
+
* }
|
|
951
|
+
*
|
|
952
|
+
* // React to trigger changes
|
|
953
|
+
* data$ = toObservable(this.refreshTrigger.value).pipe(
|
|
954
|
+
* switchMap(() => this.dataService.getData())
|
|
955
|
+
* );
|
|
956
|
+
* }
|
|
957
|
+
* ```
|
|
958
|
+
*/
|
|
959
|
+
declare function createTrigger(): {
|
|
960
|
+
/**
|
|
961
|
+
* Triggers an update by incrementing the internal counter.
|
|
962
|
+
*/
|
|
963
|
+
next: () => void;
|
|
964
|
+
/**
|
|
965
|
+
* A readonly signal that emits the current counter value.
|
|
966
|
+
*/
|
|
967
|
+
value: i0.Signal<number>;
|
|
968
|
+
};
|
|
969
|
+
|
|
970
|
+
type ParamsTransformFn<Output> = (params: Params) => Output;
|
|
971
|
+
/**
|
|
972
|
+
* The `InputOptions` interface defines options for configuring the behavior of the `injectParams` function.
|
|
973
|
+
*
|
|
974
|
+
* @template Output - The expected type of the read value.
|
|
975
|
+
*/
|
|
976
|
+
interface ParamsOptions<Output> {
|
|
977
|
+
/**
|
|
978
|
+
* A transformation function to convert the written value to the expected read value.
|
|
979
|
+
*
|
|
980
|
+
* @param v - The value to transform.
|
|
981
|
+
* @returns The transformed value.
|
|
982
|
+
*/
|
|
983
|
+
transform?: (v: string) => Output;
|
|
984
|
+
/**
|
|
985
|
+
* The initial value to use if the parameter is not present or undefined.
|
|
986
|
+
*/
|
|
987
|
+
initialValue?: Output;
|
|
988
|
+
}
|
|
989
|
+
/**
|
|
990
|
+
* Injects the params from the current route.
|
|
991
|
+
* If a key is provided, returns the value of that key.
|
|
992
|
+
* If a transform function is provided, returns the result of the function.
|
|
993
|
+
* Otherwise, returns the entire params object.
|
|
994
|
+
*
|
|
995
|
+
* @example
|
|
996
|
+
* const params = injectParams(); // Returns the entire params object
|
|
997
|
+
* const userId = injectParams('id'); // Returns the value of the 'id' param
|
|
998
|
+
* const userId = injectParams(p => p['id'] as string); // Returns the 'id' param using a custom transform function
|
|
999
|
+
* const userId = injectParams('id', { transform: numberAttribute, initialValue: 1 });
|
|
1000
|
+
*
|
|
1001
|
+
* @param keyOrParamsTransform OPTIONAL The key of the param to return, or a transform function to apply to the params object
|
|
1002
|
+
*/
|
|
1003
|
+
declare function injectParams(): Signal<Params>;
|
|
1004
|
+
declare function injectParams<Output>(fn: ParamsTransformFn<Output>): Signal<Output>;
|
|
1005
|
+
declare function injectParams(key: string): Signal<string | null>;
|
|
1006
|
+
declare function injectParams(key: string, options: {
|
|
1007
|
+
transform: (v: string) => boolean;
|
|
1008
|
+
initialValue: boolean;
|
|
1009
|
+
}): Signal<boolean>;
|
|
1010
|
+
declare function injectParams(key: string, options: {
|
|
1011
|
+
transform: (v: string) => number;
|
|
1012
|
+
initialValue: number;
|
|
1013
|
+
}): Signal<number>;
|
|
1014
|
+
declare function injectParams(key: string, options: {
|
|
1015
|
+
transform?: (v: string) => string;
|
|
1016
|
+
initialValue: string;
|
|
1017
|
+
}): Signal<string>;
|
|
1018
|
+
declare function injectParams(key: string, options: {
|
|
1019
|
+
transform: (v: string) => boolean;
|
|
1020
|
+
initialValue?: undefined;
|
|
1021
|
+
}): Signal<boolean | null>;
|
|
1022
|
+
declare function injectParams(key: string, options: {
|
|
1023
|
+
transform: (v: string) => number;
|
|
1024
|
+
initialValue?: undefined;
|
|
1025
|
+
}): Signal<number | null>;
|
|
1026
|
+
declare function injectParams(key: string, options: {
|
|
1027
|
+
transform: (v: string) => string;
|
|
1028
|
+
initialValue?: undefined;
|
|
1029
|
+
}): Signal<string | null>;
|
|
1030
|
+
|
|
1031
|
+
type QueryParamsTransformFn<Output> = (params: Params) => Output;
|
|
1032
|
+
/**
|
|
1033
|
+
* The `InputOptions` interface defines options for configuring the behavior of the `injectQueryParams` function.
|
|
1034
|
+
*
|
|
1035
|
+
* @template Output - The expected type of the read value.
|
|
1036
|
+
*/
|
|
1037
|
+
interface QueryParamsOptions<Output> {
|
|
1038
|
+
/**
|
|
1039
|
+
* A transformation function to convert the written value to the expected read value.
|
|
1040
|
+
*
|
|
1041
|
+
* @param v - The value to transform.
|
|
1042
|
+
* @returns The transformed value.
|
|
1043
|
+
*/
|
|
1044
|
+
transform?: (v: string) => Output;
|
|
1045
|
+
/**
|
|
1046
|
+
* The initial value to use if the query parameter is not present or undefined.
|
|
1047
|
+
*/
|
|
1048
|
+
initialValue?: Output;
|
|
1049
|
+
}
|
|
1050
|
+
/**
|
|
1051
|
+
* The `injectQueryParams` function allows you to access and manipulate query parameters from the current route.
|
|
1052
|
+
*
|
|
1053
|
+
* @returns A `Signal` that emits the entire query parameters object.
|
|
1054
|
+
*/
|
|
1055
|
+
declare function injectQueryParams(): Signal<Params>;
|
|
1056
|
+
/**
|
|
1057
|
+
* The `injectQueryParams` function allows you to access and manipulate query parameters from the current route.
|
|
1058
|
+
* It retrieves the value of a query parameter based on a custom transform function applied to the query parameters object.
|
|
1059
|
+
*
|
|
1060
|
+
* @template Output - The expected type of the read value.
|
|
1061
|
+
* @param {QueryParamsTransformFn<Output>} fn - A transform function that takes the query parameters object (`params: Params`) and returns the desired value.
|
|
1062
|
+
* @returns {Signal} A `Signal` that emits the transformed value based on the provided custom transform function.
|
|
1063
|
+
*
|
|
1064
|
+
* @example
|
|
1065
|
+
* const searchValue = injectQueryParams((params) => params['search'] as string);
|
|
1066
|
+
*/
|
|
1067
|
+
declare function injectQueryParams<Output>(fn: QueryParamsTransformFn<Output>): Signal<Output>;
|
|
1068
|
+
/**
|
|
1069
|
+
* The `injectQueryParams` function allows you to access and manipulate query parameters from the current route.
|
|
1070
|
+
*
|
|
1071
|
+
* @param {string} key - The name of the query parameter to retrieve.
|
|
1072
|
+
* @returns {Signal} A `Signal` that emits the value of the specified query parameter, or `null` if it's not present.
|
|
1073
|
+
*/
|
|
1074
|
+
declare function injectQueryParams(key: string): Signal<string | null>;
|
|
1075
|
+
declare function injectQueryParams(key: string, options: {
|
|
1076
|
+
transform: (v: string) => boolean;
|
|
1077
|
+
initialValue: boolean;
|
|
1078
|
+
}): Signal<boolean>;
|
|
1079
|
+
declare function injectQueryParams(key: string, options: {
|
|
1080
|
+
transform: (v: string) => number;
|
|
1081
|
+
initialValue: number;
|
|
1082
|
+
}): Signal<number>;
|
|
1083
|
+
declare function injectQueryParams(key: string, options: {
|
|
1084
|
+
transform?: (v: string) => string;
|
|
1085
|
+
initialValue: string;
|
|
1086
|
+
}): Signal<string>;
|
|
1087
|
+
declare function injectQueryParams(key: string, options: {
|
|
1088
|
+
transform: (v: string) => boolean;
|
|
1089
|
+
initialValue?: undefined;
|
|
1090
|
+
}): Signal<boolean | null>;
|
|
1091
|
+
declare function injectQueryParams(key: string, options: {
|
|
1092
|
+
transform: (v: string) => number;
|
|
1093
|
+
initialValue?: undefined;
|
|
1094
|
+
}): Signal<number | null>;
|
|
1095
|
+
declare function injectQueryParams(key: string, options: {
|
|
1096
|
+
transform: (v: string) => string;
|
|
1097
|
+
initialValue?: undefined;
|
|
1098
|
+
}): Signal<string | null>;
|
|
1099
|
+
|
|
1100
|
+
type ObservableSignalInput<T> = ObservableInput<T> | Signal<T>;
|
|
1101
|
+
type ObservableSignalInputTuple<T> = {
|
|
1102
|
+
[K in keyof T]: ObservableSignalInput<T[K]>;
|
|
1103
|
+
};
|
|
1104
|
+
type MergeFromOptions<T> = {
|
|
1105
|
+
readonly injector?: Injector;
|
|
1106
|
+
readonly initialValue?: T | null;
|
|
1107
|
+
};
|
|
1108
|
+
declare function mergeFrom<Input extends readonly unknown[], Output = Input[number]>(sources: readonly [...ObservableSignalInputTuple<Input>], operator?: OperatorFunction<Input[number], Output>, options?: MergeFromOptions<Output>): Signal<Output>;
|
|
1109
|
+
declare function mergeFrom<Input extends readonly unknown[], Output = Input[number]>(sources: readonly [...ObservableSignalInputTuple<Input>], options?: MergeFromOptions<Output>): Signal<Output>;
|
|
1110
|
+
|
|
1111
|
+
/**
|
|
1112
|
+
* Calculates the difference in whole days between two dates.
|
|
1113
|
+
*
|
|
1114
|
+
* @param {Date | number | string} dateLeft - The date from which the difference is measured (the reference date).
|
|
1115
|
+
* Can be a Date object, a number representing milliseconds since the Unix epoch,
|
|
1116
|
+
* or a string in a format parseable by the Date constructor.
|
|
1117
|
+
* @param {Date | number | string} dateRight - The date to be compared against the reference date.
|
|
1118
|
+
* Can be a Date object, a number representing milliseconds since the Unix epoch,
|
|
1119
|
+
* or a string in a format parseable by the Date constructor.
|
|
1120
|
+
* @returns {number} The number of whole days between the reference date (dateLeft) and the compared date (dateRight).
|
|
1121
|
+
*
|
|
1122
|
+
* @example
|
|
1123
|
+
* // How many whole days are between '2022-09-08' and '2023-09-18'?
|
|
1124
|
+
* const result = differenceInDays('2022-09-08', new Date('2023-09-18'));
|
|
1125
|
+
*
|
|
1126
|
+
* The result is 0 if the diff is within a full day
|
|
1127
|
+
* const result = differenceInDays('2022-09-08T00:00:00', new Date('2023-09-08T14:00:00'));
|
|
1128
|
+
*/
|
|
1129
|
+
declare function differenceInDays(dateLeft: Date | number | string, dateRight: Date | number | string): number;
|
|
1130
|
+
|
|
1131
|
+
/**
|
|
1132
|
+
* Provides a conditional validator that applies the specified validator functions only if the condition is met.
|
|
1133
|
+
*
|
|
1134
|
+
* @param condition A function that determines whether the validators should be applied.
|
|
1135
|
+
* @param trueValidatorFn The validator function or an array of validator functions to be applied when the condition is true.
|
|
1136
|
+
* @param falseValidatorFn Optional. The validator function or an array of validator functions to be applied when the condition is false.
|
|
1137
|
+
* @returns A validator function that can be used with Angular Reactive Forms.
|
|
1138
|
+
*/
|
|
1139
|
+
declare function ifValidator(condition: (control: AbstractControl) => boolean, trueValidatorFn: ValidatorFn | ValidatorFn[], falseValidatorFn?: ValidatorFn | ValidatorFn[]): ValidatorFn;
|
|
1140
|
+
/**
|
|
1141
|
+
* Provides a conditional async validator that applies the specified async validator function only if the condition is met.
|
|
1142
|
+
*
|
|
1143
|
+
* @param condition A function that determines whether the async validator should be applied.
|
|
1144
|
+
* @param validatorFn The async validator function to be applied conditionally.
|
|
1145
|
+
* @returns An async validator function that can be used with Angular Reactive Forms.
|
|
1146
|
+
*/
|
|
1147
|
+
declare function ifAsyncValidator(condition: (control: AbstractControl) => boolean, validatorFn: AsyncValidatorFn): AsyncValidatorFn;
|
|
1148
|
+
|
|
1149
|
+
/**
|
|
1150
|
+
* Configuration options for the idle detection service.
|
|
1151
|
+
* Used to customize the idle duration and timeout duration for user inactivity detection.
|
|
1152
|
+
*/
|
|
1153
|
+
declare class IdleDetectionConfig {
|
|
1154
|
+
/**
|
|
1155
|
+
* The duration in seconds before the user is considered idle.
|
|
1156
|
+
* After this duration, the idle detection phase ends and countdown begins.
|
|
1157
|
+
* Defaults to 19 minutes (1140 seconds) if not provided.
|
|
1158
|
+
*/
|
|
1159
|
+
idleDurationInSeconds?: number;
|
|
1160
|
+
/**
|
|
1161
|
+
* The duration in seconds for the countdown phase after idle detection.
|
|
1162
|
+
* During this phase, the user can still interact to reset the timer.
|
|
1163
|
+
* After this duration, the timeout event is emitted.
|
|
1164
|
+
* Defaults to 1 minute (60 seconds) if not provided.
|
|
1165
|
+
*/
|
|
1166
|
+
timeoutDurationInSeconds?: number;
|
|
1167
|
+
}
|
|
1168
|
+
/**
|
|
1169
|
+
* Provides configuration for the idle detection service.
|
|
1170
|
+
* This function should be used in the application's providers array to configure idle detection.
|
|
1171
|
+
*
|
|
1172
|
+
* @param config - The idle detection configuration object.
|
|
1173
|
+
* @returns Environment providers for the idle detection configuration.
|
|
1174
|
+
*
|
|
1175
|
+
* @example
|
|
1176
|
+
* ```typescript
|
|
1177
|
+
* export const appConfig: ApplicationConfig = {
|
|
1178
|
+
* providers: [
|
|
1179
|
+
* provideIdleDetectionConfig({
|
|
1180
|
+
* idleDurationInSeconds: 15 * 60, // 15 minutes
|
|
1181
|
+
* timeoutDurationInSeconds: 60 // 1 minute
|
|
1182
|
+
* })
|
|
1183
|
+
* ]
|
|
1184
|
+
* };
|
|
1185
|
+
* ```
|
|
1186
|
+
*/
|
|
1187
|
+
declare function provideIdleDetectionConfig(config: IdleDetectionConfig): i0.EnvironmentProviders;
|
|
1188
|
+
|
|
1189
|
+
/**
|
|
1190
|
+
* Idle detection module.
|
|
1191
|
+
* @deprecated use provideIdleDetectionConfig(config: IdleDetectionConfig) instead
|
|
1192
|
+
*/
|
|
1193
|
+
declare class IdleDetectionModule {
|
|
1194
|
+
static forRoot(config: IdleDetectionConfig): ModuleWithProviders<IdleDetectionModule>;
|
|
1195
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<IdleDetectionModule, never>;
|
|
1196
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<IdleDetectionModule, never, never, never>;
|
|
1197
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<IdleDetectionModule>;
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
/**
|
|
1201
|
+
* Service for detecting user idle time and implementing a countdown.
|
|
1202
|
+
*/
|
|
1203
|
+
declare class IdleDetectionService {
|
|
1204
|
+
/**
|
|
1205
|
+
* The list of interruption events that will end the idle detection.
|
|
1206
|
+
*/
|
|
1207
|
+
private interruptionEvents;
|
|
1208
|
+
private interruptionSubscription?;
|
|
1209
|
+
/**
|
|
1210
|
+
* The default idle duration in seconds (19 minutes).
|
|
1211
|
+
*/
|
|
1212
|
+
private idleDuration;
|
|
1213
|
+
/**
|
|
1214
|
+
* The default timeout duration in seconds (1 minute).
|
|
1215
|
+
*/
|
|
1216
|
+
private timeoutDuration;
|
|
1217
|
+
/**
|
|
1218
|
+
* Timer for idle detection.
|
|
1219
|
+
*/
|
|
1220
|
+
private idleTimer?;
|
|
1221
|
+
/**
|
|
1222
|
+
* Timer for countdown.
|
|
1223
|
+
*/
|
|
1224
|
+
private countdownTimer?;
|
|
1225
|
+
/**
|
|
1226
|
+
* Flag to indicate if countdown is in progress.
|
|
1227
|
+
*/
|
|
1228
|
+
private isCountingDown;
|
|
1229
|
+
/**
|
|
1230
|
+
* The current countdown value.
|
|
1231
|
+
*/
|
|
1232
|
+
private countdown;
|
|
1233
|
+
/**
|
|
1234
|
+
* Subject to emit when idle period ends.
|
|
1235
|
+
*/
|
|
1236
|
+
private idleEndSubject;
|
|
1237
|
+
/**
|
|
1238
|
+
* Subject to emit the countdown value.
|
|
1239
|
+
*/
|
|
1240
|
+
private countdownSubject;
|
|
1241
|
+
/**
|
|
1242
|
+
* Subject to emit when countdown ends.
|
|
1243
|
+
*/
|
|
1244
|
+
private countdownEndSubject;
|
|
1245
|
+
/**
|
|
1246
|
+
* Constructs the IdleDetectionService.
|
|
1247
|
+
* @param config - Optional configuration for idle and timeout durations.
|
|
1248
|
+
*/
|
|
1249
|
+
constructor();
|
|
1250
|
+
/**
|
|
1251
|
+
* Starts to watch for user inactivity.
|
|
1252
|
+
*/
|
|
1253
|
+
startWatching(): void;
|
|
1254
|
+
/**
|
|
1255
|
+
* Resets the idle timer when user activity is detected.
|
|
1256
|
+
* @param withCountdownReset - Flag to indicate if countdown should be reset.
|
|
1257
|
+
* By default, it only reset the idle-detection timer. If you enter the countdown phase, it won't stop the countdown.
|
|
1258
|
+
* Pass true when you want to reset the countdown as well. This is useful when you click "Keep Me Signed In" button in cll-idle-detection component
|
|
1259
|
+
*/
|
|
1260
|
+
resetTimer(withCountdownReset?: boolean): void;
|
|
1261
|
+
/**
|
|
1262
|
+
* Sets up the interruption events that will end the idle detection.
|
|
1263
|
+
* Listens to a set of events on the document (e.g. click, keydown, mousemove, etc.).
|
|
1264
|
+
* When any of these events is triggered, the idle timer is reset.
|
|
1265
|
+
* Uses `throttleTime` operator to only trigger the reset when the events are spaced
|
|
1266
|
+
* out by at least 1000ms (1 second).
|
|
1267
|
+
* @private
|
|
1268
|
+
*/
|
|
1269
|
+
private setupInterruptionEvents;
|
|
1270
|
+
/**
|
|
1271
|
+
* Starts the idle timer.
|
|
1272
|
+
* When the timer expires, it emits an event through onIdleEnd() and starts the countdown.
|
|
1273
|
+
*/
|
|
1274
|
+
private startIdleTimer;
|
|
1275
|
+
/**
|
|
1276
|
+
* Starts the countdown.
|
|
1277
|
+
*/
|
|
1278
|
+
private startCountdown;
|
|
1279
|
+
/**
|
|
1280
|
+
* Stops the countdown.
|
|
1281
|
+
*/
|
|
1282
|
+
private stopCountdown;
|
|
1283
|
+
/**
|
|
1284
|
+
* Returns an observable that emits when the user has been idle for a long period.
|
|
1285
|
+
* Developers can use this to perform actions like opening a dialog.
|
|
1286
|
+
*
|
|
1287
|
+
* user has been inactive for a long period (idleDuration), at this moment, idle detection phase ends, onIdleEnd event is emitted, and then enter countdown/timeout phase.
|
|
1288
|
+
* During the countdown phase:
|
|
1289
|
+
* - if user has any activity, countdown phase immediately ends and restart the idle detection phase.
|
|
1290
|
+
* - else, countdownEnd event will be emitted when timeoutDuration is over.
|
|
1291
|
+
* @returns {Observable<void>} - Observable for idle end event.
|
|
1292
|
+
*/
|
|
1293
|
+
onIdleEnd(): rxjs.Observable<void>;
|
|
1294
|
+
/**
|
|
1295
|
+
* Returns an observable that emits when the countdown ends.
|
|
1296
|
+
* Usually means the user has been inactive for a very long time and should be logged out.
|
|
1297
|
+
* @returns {Observable<void>} - Observable for countdown end event.
|
|
1298
|
+
*/
|
|
1299
|
+
onTimeoutEnd(): rxjs.Observable<void>;
|
|
1300
|
+
/**
|
|
1301
|
+
* Returns an observable that emits the countdown value every second.
|
|
1302
|
+
* @returns {Observable<number>} - Observable for countdown value.
|
|
1303
|
+
*/
|
|
1304
|
+
onCountDown(): rxjs.Observable<number>;
|
|
1305
|
+
/**
|
|
1306
|
+
* Clears all timers when the component is destroyed.
|
|
1307
|
+
*/
|
|
1308
|
+
clearTimers(): void;
|
|
1309
|
+
/**
|
|
1310
|
+
* Sets the idle and timeout durations based on the provided configuration.
|
|
1311
|
+
* @param config - Configuration object with idle and timeout durations.
|
|
1312
|
+
*/
|
|
1313
|
+
setConfig(config: IdleDetectionConfig): void;
|
|
1314
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<IdleDetectionService, never>;
|
|
1315
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<IdleDetectionService>;
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
/**
|
|
1319
|
+
* Type guard that checks if a string value is empty.
|
|
1320
|
+
*
|
|
1321
|
+
* @param value - The string value to check.
|
|
1322
|
+
* @returns `true` if the value is an empty string, `false` otherwise.
|
|
1323
|
+
*
|
|
1324
|
+
* @example
|
|
1325
|
+
* ```typescript
|
|
1326
|
+
* isEmpty(''); // true
|
|
1327
|
+
* isEmpty('text'); // false
|
|
1328
|
+
* ```
|
|
1329
|
+
*/
|
|
1330
|
+
declare function isEmpty(value: string): value is '';
|
|
1331
|
+
/**
|
|
1332
|
+
* Check if a value is null, undefined, empty ArrayLike, Map, Set or empty object.
|
|
1333
|
+
* @param value The value to check.
|
|
1334
|
+
* @returns Whether the value is null, undefined, empty ArrayLike, Map, Set or empty object.
|
|
1335
|
+
*/
|
|
1336
|
+
declare function isEmpty<T extends object | ArrayLike<any> | Map<any, any> | Set<any>>(value: T | null | undefined): value is null | undefined;
|
|
1337
|
+
/**
|
|
1338
|
+
* Type guard that checks if a string value is not empty.
|
|
1339
|
+
*
|
|
1340
|
+
* @param value - The string value to check.
|
|
1341
|
+
* @returns `false` if the value is an empty string, `true` otherwise.
|
|
1342
|
+
*/
|
|
1343
|
+
declare function isNotEmpty(value: ''): false;
|
|
1344
|
+
/**
|
|
1345
|
+
* Type guard that checks if a string value is not empty.
|
|
1346
|
+
*
|
|
1347
|
+
* @param value - The string value to check.
|
|
1348
|
+
* @returns `true` if the value is a non-empty string, `false` otherwise.
|
|
1349
|
+
*/
|
|
1350
|
+
declare function isNotEmpty(value: string): value is Exclude<string, ''>;
|
|
1351
|
+
/**
|
|
1352
|
+
* Type guard that checks if a value is not empty (not null, undefined, or empty collection).
|
|
1353
|
+
*
|
|
1354
|
+
* @param value - The value to check.
|
|
1355
|
+
* @returns `true` if the value is not null, undefined, or empty, `false` otherwise.
|
|
1356
|
+
*/
|
|
1357
|
+
declare function isNotEmpty<T extends object | ArrayLike<any> | Map<any, any> | Set<any>>(value: T | null | undefined): value is T;
|
|
1358
|
+
|
|
1359
|
+
/**
|
|
1360
|
+
* Check if two values are deeply equal.
|
|
1361
|
+
* @param {T} value1 - The first value to compare.
|
|
1362
|
+
* @param {T} value2 - The second value to compare.
|
|
1363
|
+
* @returns {boolean} - Returns true if the values are deeply equal, otherwise false.
|
|
1364
|
+
*/
|
|
1365
|
+
declare function isEqual<T>(value1: T, value2: T): boolean;
|
|
1366
|
+
|
|
1367
|
+
/**
|
|
1368
|
+
* Create an object composed of object properties that do not satisfy a given condition.
|
|
1369
|
+
* @param {T} source - The object to omit properties from.
|
|
1370
|
+
* @param {(value: T[keyof T], key: string) => boolean} predicate - The function invoked per property.
|
|
1371
|
+
* @returns {Partial<T>} - Returns the new object.
|
|
1372
|
+
*/
|
|
1373
|
+
declare function omitBy<T>(source: T, predicate: (value: T[keyof T], key: string) => boolean): Partial<T>;
|
|
1374
|
+
|
|
1375
|
+
/**
|
|
1376
|
+
* Create an object composed of object properties that satisfy a given condition.
|
|
1377
|
+
* @param {T} source - The object to pick properties from.
|
|
1378
|
+
* @param {(value: T[keyof T], key: string) => boolean} predicate - The function invoked per property.
|
|
1379
|
+
* @returns {Partial<T>} - Returns the new object.
|
|
1380
|
+
*/
|
|
1381
|
+
declare function pickBy<T>(source: T, predicate: (value: T[keyof T], key: string) => boolean): Partial<T>;
|
|
1382
|
+
|
|
1383
|
+
/**
|
|
1384
|
+
* Creates an array of numbers (positive and/or negative) progressing from start up to, but not including, end.
|
|
1385
|
+
* A step of -1 is used if a negative start is specified without an end or step.
|
|
1386
|
+
* If end is not specified, it's set to start with start then set to 0.
|
|
1387
|
+
*
|
|
1388
|
+
* @param {number} start The start of the range.
|
|
1389
|
+
* @param {number} end The end of the range.
|
|
1390
|
+
* @param {number} step The value to increment or decrement by.
|
|
1391
|
+
* @param {boolean} [fromRight] Specify iterating from right to left.
|
|
1392
|
+
* @returns {Array} Returns the range of numbers.
|
|
1393
|
+
*/
|
|
1394
|
+
declare function range(start: number, end?: number | undefined, step?: number | undefined, fromRight?: boolean): any[];
|
|
1395
|
+
|
|
1396
|
+
/**
|
|
1397
|
+
* Checks if a hostname is a valid IP address (IPv4 or IPv6).
|
|
1398
|
+
*
|
|
1399
|
+
* @param hostname - The hostname to check. Should be extracted from `new URL(url).hostname`
|
|
1400
|
+
* @returns `true` if the hostname is a valid IP address, `false` otherwise
|
|
1401
|
+
*
|
|
1402
|
+
* @example
|
|
1403
|
+
* ```typescript
|
|
1404
|
+
* const url = new URL('http://192.168.1.1');
|
|
1405
|
+
* isIP(url.hostname); // true
|
|
1406
|
+
*
|
|
1407
|
+
* const url2 = new URL('http://example.com');
|
|
1408
|
+
* isIP(url2.hostname); // false
|
|
1409
|
+
* ```
|
|
1410
|
+
*/
|
|
1411
|
+
declare function isIP(hostname: string): boolean;
|
|
1412
|
+
/**
|
|
1413
|
+
* Checks if a hostname is a valid Fully Qualified Domain Name (FQDN).
|
|
1414
|
+
*
|
|
1415
|
+
* @param hostname - The hostname to check. Should be extracted from `new URL(url).hostname`
|
|
1416
|
+
* @returns `true` if the hostname is a valid FQDN, `false` otherwise
|
|
1417
|
+
*
|
|
1418
|
+
* @example
|
|
1419
|
+
* ```typescript
|
|
1420
|
+
* const url = new URL('http://example.com');
|
|
1421
|
+
* isFQDN(url.hostname); // true
|
|
1422
|
+
*
|
|
1423
|
+
* const url2 = new URL('http://192.168.1.1');
|
|
1424
|
+
* isFQDN(url2.hostname); // false
|
|
1425
|
+
* ```
|
|
1426
|
+
*/
|
|
1427
|
+
declare function isFQDN(hostname: string): boolean;
|
|
1428
|
+
/**
|
|
1429
|
+
* Checks if a string is a valid URL.
|
|
1430
|
+
*
|
|
1431
|
+
* @param url - The URL string to validate
|
|
1432
|
+
* @returns `true` if the string is a valid URL, `false` otherwise
|
|
1433
|
+
*
|
|
1434
|
+
* @example
|
|
1435
|
+
* ```typescript
|
|
1436
|
+
* isURL('https://example.com'); // true
|
|
1437
|
+
* isURL('not-a-url'); // false
|
|
1438
|
+
* ```
|
|
1439
|
+
*/
|
|
1440
|
+
declare function isURL(url: string): boolean;
|
|
1441
|
+
/**
|
|
1442
|
+
* Checks if a URL string uses the HTTPS protocol.
|
|
1443
|
+
* The URL must be a valid URL format.
|
|
1444
|
+
*
|
|
1445
|
+
* @param url - The URL string to check
|
|
1446
|
+
* @returns `true` if the URL is valid and uses HTTPS protocol, `false` otherwise
|
|
1447
|
+
*
|
|
1448
|
+
* @example
|
|
1449
|
+
* ```typescript
|
|
1450
|
+
* isHttps('https://example.com'); // true
|
|
1451
|
+
* isHttps('http://example.com'); // false
|
|
1452
|
+
* ```
|
|
1453
|
+
*/
|
|
1454
|
+
declare function isHttps(url: string): boolean;
|
|
1455
|
+
|
|
1456
|
+
/**
|
|
1457
|
+
* Interface defining the options for the date range validator.
|
|
1458
|
+
*/
|
|
1459
|
+
interface DateRangeOptions {
|
|
1460
|
+
/**
|
|
1461
|
+
* The minimum allowed date. The control value must be greater than (or equal to, if `minInclusive` is true) this date.
|
|
1462
|
+
* Can be a Date object or a string that can be parsed by the Date constructor.
|
|
1463
|
+
*/
|
|
1464
|
+
minDate?: Date | string;
|
|
1465
|
+
/**
|
|
1466
|
+
* The maximum allowed date. The control value must be less than (or equal to, if `maxInclusive` is true) this date.
|
|
1467
|
+
* Can be a Date object or a string that can be parsed by the Date constructor.
|
|
1468
|
+
*/
|
|
1469
|
+
maxDate?: Date | string;
|
|
1470
|
+
/**
|
|
1471
|
+
* Whether the comparison for the minimum date can include the exact date.
|
|
1472
|
+
* If `true`, the control value can be equal to `minDate`.
|
|
1473
|
+
* If `false` (default), the control value must be strictly greater than `minDate`.
|
|
1474
|
+
*/
|
|
1475
|
+
minInclusive?: boolean;
|
|
1476
|
+
/**
|
|
1477
|
+
* Whether the comparison for the maximum date can include the exact date.
|
|
1478
|
+
* If `true`, the control value can be equal to `maxDate`.
|
|
1479
|
+
* If `false` (default), the control value must be strictly less than `maxDate`.
|
|
1480
|
+
*/
|
|
1481
|
+
maxInclusive?: boolean;
|
|
1482
|
+
/**
|
|
1483
|
+
* Whether to compare the time components as well.
|
|
1484
|
+
* If `true`, comparisons will include Date time components (hours, minutes, seconds, milliseconds).
|
|
1485
|
+
* If `false` (default), time parts will be ignored and only the date portion will be compared.
|
|
1486
|
+
*/
|
|
1487
|
+
compareTime?: boolean;
|
|
1488
|
+
}
|
|
1489
|
+
/**
|
|
1490
|
+
* Creates a validator function that validates a date against a specified date range.
|
|
1491
|
+
*
|
|
1492
|
+
* The validator checks if the form control's date value falls within the specified range.
|
|
1493
|
+
* It supports:
|
|
1494
|
+
* - Minimum and maximum date constraints
|
|
1495
|
+
* - Inclusive or exclusive boundary comparisons
|
|
1496
|
+
* - Time-aware or date-only comparisons
|
|
1497
|
+
*
|
|
1498
|
+
* @param options - The options for the date range validation.
|
|
1499
|
+
* @returns A validator function that validates a FormControl and returns an error object if the date is out of range,
|
|
1500
|
+
* or `null` if the date is valid. Error objects contain:
|
|
1501
|
+
* - `minDate`: ISO string of the minimum date (if value is too early)
|
|
1502
|
+
* - `maxDate`: ISO string of the maximum date (if value is too late)
|
|
1503
|
+
* - `invalidDate`: `true` (if the value cannot be parsed as a date)
|
|
1504
|
+
*
|
|
1505
|
+
* @example
|
|
1506
|
+
* ```typescript
|
|
1507
|
+
* // Date range with inclusive boundaries
|
|
1508
|
+
* const form = new FormGroup({
|
|
1509
|
+
* startDate: new FormControl('', [
|
|
1510
|
+
* dateRangeValidator({
|
|
1511
|
+
* minDate: new Date('2024-01-01'),
|
|
1512
|
+
* maxDate: new Date('2024-12-31'),
|
|
1513
|
+
* minInclusive: true,
|
|
1514
|
+
* maxInclusive: true
|
|
1515
|
+
* })
|
|
1516
|
+
* ])
|
|
1517
|
+
* });
|
|
1518
|
+
*
|
|
1519
|
+
* // Date-only comparison (ignores time)
|
|
1520
|
+
* const form = new FormGroup({
|
|
1521
|
+
* appointment: new FormControl('', [
|
|
1522
|
+
* dateRangeValidator({
|
|
1523
|
+
* minDate: '2024-01-01',
|
|
1524
|
+
* compareTime: false
|
|
1525
|
+
* })
|
|
1526
|
+
* ])
|
|
1527
|
+
* });
|
|
1528
|
+
* ```
|
|
1529
|
+
*/
|
|
1530
|
+
declare function dateRangeValidator(options: DateRangeOptions): ValidatorFn;
|
|
1531
|
+
|
|
1532
|
+
/**
|
|
1533
|
+
* Creates a validator function that checks for intersection between two form controls within a FormGroup.
|
|
1534
|
+
* Both controls' values must be arrays. The validator sets an error on both controls if they have any common values.
|
|
1535
|
+
*
|
|
1536
|
+
* This is useful for scenarios where you need to ensure two arrays don't share any elements,
|
|
1537
|
+
* such as preventing duplicate selections in multi-select scenarios.
|
|
1538
|
+
*
|
|
1539
|
+
* @template T - The type of elements in the arrays (defaults to `string`).
|
|
1540
|
+
* @param controlName1 - The name of the first form control in the FormGroup.
|
|
1541
|
+
* @param controlName2 - The name of the second form control in the FormGroup.
|
|
1542
|
+
* @returns A validator function that validates the FormGroup and returns an error object with `intersection: true`
|
|
1543
|
+
* if there is an intersection between the two arrays, or `null` if there is no intersection.
|
|
1544
|
+
*
|
|
1545
|
+
* @example
|
|
1546
|
+
* ```typescript
|
|
1547
|
+
* const form = new FormGroup({
|
|
1548
|
+
* selectedUsers: new FormControl(['user1', 'user2']),
|
|
1549
|
+
* excludedUsers: new FormControl(['user3', 'user4']),
|
|
1550
|
+
* }, {
|
|
1551
|
+
* validators: [intersectionValidator('selectedUsers', 'excludedUsers')]
|
|
1552
|
+
* });
|
|
1553
|
+
*
|
|
1554
|
+
* // If selectedUsers contains 'user1' and excludedUsers also contains 'user1',
|
|
1555
|
+
* // both controls will have an error: { intersection: true }
|
|
1556
|
+
* ```
|
|
1557
|
+
*/
|
|
1558
|
+
declare function intersectionValidator<T = string>(controlName1: string, controlName2: string): ValidatorFn;
|
|
1559
|
+
|
|
1560
|
+
/**
|
|
1561
|
+
* Validator for checking uniqueness across multiple fields in a FormArray or FormGroup.
|
|
1562
|
+
*
|
|
1563
|
+
* This validator can be applied to a FormArray or FormGroup containing the controls to be validated.
|
|
1564
|
+
* It ensures that each control's value is unique among all other controls within the array or group.
|
|
1565
|
+
*
|
|
1566
|
+
* When duplicate values are found, the validator sets a `notUnique` error on all affected controls.
|
|
1567
|
+
* The error is automatically removed when the value becomes unique again.
|
|
1568
|
+
*
|
|
1569
|
+
* @example
|
|
1570
|
+
* ```typescript
|
|
1571
|
+
* // FormArray with unique values
|
|
1572
|
+
* const formArray = new FormArray([
|
|
1573
|
+
* new FormControl('value1'),
|
|
1574
|
+
* new FormControl('value2'),
|
|
1575
|
+
* new FormControl('value1') // This will have notUnique error
|
|
1576
|
+
* ], [UniqueValidator.unique()]);
|
|
1577
|
+
*
|
|
1578
|
+
* // FormArray with custom key selector
|
|
1579
|
+
* const formArray = new FormArray([
|
|
1580
|
+
* new FormGroup({
|
|
1581
|
+
* id: new FormControl(1),
|
|
1582
|
+
* name: new FormControl('Item 1')
|
|
1583
|
+
* }),
|
|
1584
|
+
* new FormGroup({
|
|
1585
|
+
* id: new FormControl(2),
|
|
1586
|
+
* name: new FormControl('Item 2')
|
|
1587
|
+
* })
|
|
1588
|
+
* ], [UniqueValidator.unique(control => control.get('id'))]);
|
|
1589
|
+
* ```
|
|
1590
|
+
*/
|
|
1591
|
+
declare class UniqueValidator {
|
|
1592
|
+
/**
|
|
1593
|
+
* Creates a validator function that checks for uniqueness of values across controls in a FormArray or FormGroup.
|
|
1594
|
+
*
|
|
1595
|
+
* The validator:
|
|
1596
|
+
* - Compares values using the provided key selector function
|
|
1597
|
+
* - Sets `notUnique` error on controls with duplicate values
|
|
1598
|
+
* - Automatically removes errors when values become unique
|
|
1599
|
+
* - Ignores null, undefined, empty strings, and 'NaN' values
|
|
1600
|
+
*
|
|
1601
|
+
* @template T - The type of the control value.
|
|
1602
|
+
* @param keySelector - A function to select the key control for comparison.
|
|
1603
|
+
* Defaults to the control itself if not provided.
|
|
1604
|
+
* This is useful when validating FormGroups where you want to check uniqueness of a specific field.
|
|
1605
|
+
* @returns A validator function that can be attached to a FormArray or FormGroup.
|
|
1606
|
+
*/
|
|
1607
|
+
static unique<T>(keySelector?: (control: AbstractControl) => AbstractControl<T>): ValidatorFn;
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
/**
|
|
1611
|
+
* Validator function that checks if a form control value is a valid URL.
|
|
1612
|
+
*
|
|
1613
|
+
* @param control - The form control to validate
|
|
1614
|
+
* @returns `null` if the value is a valid URL, or an error object with `invalidUrl: true` if invalid
|
|
1615
|
+
*
|
|
1616
|
+
* @example
|
|
1617
|
+
* ```typescript
|
|
1618
|
+
* const form = new FormGroup({
|
|
1619
|
+
* website: new FormControl('', urlValidator)
|
|
1620
|
+
* });
|
|
1621
|
+
* ```
|
|
1622
|
+
*/
|
|
1623
|
+
declare function urlValidator(control: AbstractControl): ValidationErrors | null;
|
|
1624
|
+
/**
|
|
1625
|
+
* Validator function that checks if a form control value is a valid HTTPS URL.
|
|
1626
|
+
*
|
|
1627
|
+
* @param control - The form control to validate
|
|
1628
|
+
* @returns `null` if the value is a valid HTTPS URL, or an error object with `invalidUrl: true` if invalid
|
|
1629
|
+
*
|
|
1630
|
+
* @example
|
|
1631
|
+
* ```typescript
|
|
1632
|
+
* const form = new FormGroup({
|
|
1633
|
+
* secureUrl: new FormControl('', httpsValidator)
|
|
1634
|
+
* });
|
|
1635
|
+
* ```
|
|
1636
|
+
*/
|
|
1637
|
+
declare function httpsValidator(control: AbstractControl): ValidationErrors | null;
|
|
1638
|
+
|
|
1639
|
+
export { ArrayJoinPipe, ByteConverterPipe, IdleDetectionConfig, IdleDetectionModule, IdleDetectionService, IsHttpsPipe, MaskPipe, RangePipe, UniqueValidator, aggregatePaginatedKubernetesResources, combineFrom, combineLatestEager, computedAsync, createAsyncState, createTrigger, dateRangeValidator, differenceInDays, distinctOnChange, fetchPaginatedKubernetesResources, httpsValidator, ifAsyncValidator, ifValidator, injectParams, injectQueryParams, intersectionValidator, isEmpty, isEqual, isFQDN, isHttps, isIP, isNotEmpty, isURL, logger, mergeFrom, omitBy, pickBy, poll, provideIdleDetectionConfig, range, startWithTap, switchMapWithAsyncState, urlValidator };
|
|
1640
|
+
export type { AsyncState, CombineFromOptions, KubernetesList, KubernetesObject, KubernetesObjectCondition, KubernetesObjectMetaV1, MaskOptions, MergeFromOptions, ParamsOptions, QueryParamsOptions };
|