@typedly/data 5.0.0-beta → 5.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 CHANGED
@@ -10,39 +10,53 @@
10
10
  ## @typedly/data
11
11
 
12
12
  <!-- npm badge -->
13
- [![npm version][typedly-npm-badge-svg]][typedly-npm-badge]
14
- [![GitHub issues][typedly-badge-issues]][typedly-issues]
15
- [![GitHub license][typedly-badge-license]][typedly-license]
13
+ [![npm version][package-npm-badge-svg]][package-npm-badge]
14
+ [![GitHub issues][package-badge-issues]][package-issues]
15
+ [![GitHub license][package-badge-license]][package-license]
16
+
17
+ <!-- GitHub badges -->
18
+ [![GitHub issues][package-badge-issues]][package-issues]
19
+ [![GitHub forks][package-badge-forks]][package-forks]
20
+ [![GitHub stars][package-badge-stars]][package-stars]
21
+ [![GitHub license][package-badge-license]][package-license]
22
+
23
+ <!-- Sponsors -->
24
+ [![GitHub Sponsors][github-badge-sponsor]][github-sponsor-link]
25
+ [![Patreon Sponsors][patreon-badge]][patreon-link]
16
26
 
17
27
  A **TypeScript** type definitions package for [**@typescript-package/data**](https://github.com/typescript-package/data).
18
28
 
19
29
  ## Features
20
30
 
21
- - **Adapter**: Optional data adapter to customize managing underlying data.
31
+ - **Adapter**: Optional data adapter to customize managing underlying data available under the [`@typedly/adaptable-data`](https://github.com/typedly/data-adapter).
32
+ - **Configurable**: Configurable data shape available under the [`@typedly/configurable-data`](https://github.com/typedly/configurable-data).
33
+ - **Traits**: Extended customization via traits, such as `Configurable`, `Adaptable`, `Serializable`, and `Transformable` under the [`@typedly/data-traits`](https://github.com/typedly/data-traits) package.
22
34
  - **Shape**: The default shape for data of any `T` type with conditional async.
23
35
 
24
36
  ## Table of contents
25
37
 
38
+ - [Related packages](#related-packages)
26
39
  - [Installation](#installation)
27
40
  - [Api](#api)
28
- - [Constructor](#constructor)
29
- - [`AdaptableDataConstructor`](#adaptabledataconstructor)
30
- - [`DataAdapterConstructor`](#dataadapterconstructor)
31
- - [`DataConstructor`](#dataconstructor)
32
- - [`ValueConstructor`](#valueconstructor)
33
- - [Interface](#interface)
34
- - [`AdaptableDataShape`](#adaptabledatashape)
35
- - [`DataAdapterShape`](#dataadaptershape)
36
- - [`DataShape`](#datashape)
37
- - [`ValueShape`](#valueshape)
38
- - [Type](#type)
39
- - [`AdaptableDataConstructorInput`](#adaptabledataconstructorinput)
40
- - [`AdaptableDataConstructorTuple`](#adaptabledataconstructortuple)
41
+ - [Configuration](#configuration)
42
+ - [`DataConfig`](#dataconfig)
43
+ - [`DataSettings`](#datasettings)
44
+ - [Data](#data)
41
45
  - [`AsyncReturn`](#asyncreturn)
42
46
  - [`DataConstructorInput`](#dataconstructorinput)
43
47
  - [`DataConstructorTuple`](#dataconstructortuple)
48
+ - [`DataConstructor`](#dataconstructor)
49
+ - [`DataShape`](#datashape)
50
+ - [Inference](#inference)
51
+ - [`InferAsyncOf`](#inferasyncof)
52
+ - [`InferAsync`](#inferasync)
53
+ - [`InferValue`](#infervalue)
54
+ - [Iterable](#iterable)
44
55
  - [`IterValue`](#itervalue)
45
- - [Full example usage](#full-example-usage)
56
+ - [`IterableElement`](#itervalue)
57
+ - [Value](#value)
58
+ - [`ValueConstructor`](#valueconstructor)
59
+ - [`ValueShape`](#valueshape)
46
60
  - [Contributing](#contributing)
47
61
  - [Support](#support)
48
62
  - [Code of Conduct](#code-of-conduct)
@@ -50,7 +64,17 @@ A **TypeScript** type definitions package for [**@typescript-package/data**](htt
50
64
  - [Commit](#commit)
51
65
  - [Versioning](#versioning)
52
66
  - [License](#license)
53
- - [Related packages](#related-packages)
67
+ - [Packages](#packages)
68
+
69
+ ## Related packages
70
+
71
+ - **[@typedly/adaptable-data](https://github.com/typedly/adaptable-data)**: A **TypeScript** type definitions for data adapter.
72
+ - **[@typedly/collection](https://github.com/typedly/collection)**: A **TypeScript** type definitions package for data collections with customizable storage.
73
+ - **[@typedly/configurable-data](https://github.com/typedly/configurable-data)**: A **TypeScript** type definitions for configurable data.
74
+ - **[@typedly/data-adapter](https://github.com/typedly/data-adapter)**: A **TypeScript** type definitions for data adapter.
75
+ - **[@typedly/data-traits](https://github.com/typedly/data-traits)**: A **TypeScript** type definitions for data traits.
76
+ - **[@typescript-package/data](https://github.com/typescript-package/data)**: A lightweight **TypeScript** library for basic data management.
77
+ - **[@typescript-package/collection](https://github.com/typescript-package/collection)**: A lightweight **TypeScript** library for data collection.
54
78
 
55
79
  ## Installation
56
80
 
@@ -70,179 +94,182 @@ npm install @typedly/data --save-peer
70
94
 
71
95
  ```typescript
72
96
  import {
73
- // Data adapter constructor.
74
- DataAdapterConstructor,
97
+ // Configuration
98
+ DataConfig,
99
+ DataSettings,
75
100
 
76
- // Data Constructor.
77
- AdaptableDataConstructor,
78
- DataConstructor,
79
-
80
- // Value Constructor.
81
- ValueConstructor,
101
+ // Inference.
102
+ InferAsync,
103
+ InferAsyncOf,
104
+ InferValue,
82
105
 
83
- // Data adapter Interface.
84
- DataAdapterShape,
106
+ // Iterable.
107
+ IterValue,
108
+ IterableElement,
85
109
 
86
- // Data Interface.
87
- AdaptableDataShape,
110
+ // Data.
111
+ DataConstructor,
88
112
  DataShape,
89
113
 
90
- // Value Interface.
91
- ValueShape,
92
-
93
- // Adaptable data constructor input and tuple.
94
- AdaptableDataConstructorInput,
95
- AdaptableDataConstructorTuple,
96
-
97
- // Data constructor input and tuple.
114
+ // Return types
115
+ AsyncReturn,
116
+ // Input types
98
117
  DataConstructorInput,
99
118
  DataConstructorTuple,
100
119
 
101
- // Type.
102
- AsyncReturn,
103
- IterValue
120
+ // Value.
121
+ ValueConstructor,
122
+ ValueShape,
104
123
  } from '@typedly/data';
105
124
  ```
106
125
 
107
- ### Constructor
126
+ ### Configuration
108
127
 
109
- #### `AdaptableDataConstructor`
128
+ #### `DataConfig`
110
129
 
111
- The constructor interface for data types with adapter.
130
+ The type for the data configuration, which can be either a full configuration object of `C` or just an async flag.
112
131
 
113
132
  ```typescript
114
- import { AdaptableDataConstructor } from '@typedly/data';
133
+ import { DataConfig } from '@typedly/data';
115
134
  ```
116
135
 
117
- [Source](https://github.com/typedly/data/blob/main/src/lib/constructor/lib/adaptable-data.constructor.ts)
136
+ [Source](https://github.com/typedly/data/blob/main/src/lib/type/data.config.ts)
118
137
 
119
- #### `DataAdapterConstructor`
138
+ #### `DataSettings`
120
139
 
121
- The constructor interface for data adapters.
140
+ The settings for a data type.
122
141
 
123
142
  ```typescript
124
- import { DataAdapterConstructor } from '@typedly/data';
143
+ import { DataSettings } from '@typedly/data';
125
144
  ```
126
145
 
127
- [Source](https://github.com/typedly/data/blob/main/src/lib/constructor/lib/data-adapter.constructor.ts)
146
+ [Source](https://github.com/typedly/data/blob/main/src/lib/interface/lib/data.settings.ts)
128
147
 
129
- #### `DataConstructor`
148
+ ### Inference
130
149
 
131
- The constructor interface for data types.
150
+ #### `InferAsyncOf`
151
+
152
+ Infers the async flag from a tuple of arguments, returning true if any of the arguments has an async flag set to true.
132
153
 
133
154
  ```typescript
134
- import { DataConstructor } from '@typedly/data';
155
+ import { InferAsync } from '@typedly/data';
135
156
  ```
136
157
 
137
- [Source](https://github.com/typedly/data/blob/main/src/lib/constructor/lib/data.constructor.ts)
158
+ [Source](https://github.com/typedly/data/blob/main/src/inference/infer-async-of.type.ts)
138
159
 
139
- #### `ValueConstructor`
160
+ #### `InferAsync`
161
+
162
+ Infers the async flag from the settings `DataSettings` or shape `DataShape`.
140
163
 
141
164
  ```typescript
142
- import { ValueConstructor } from '@typedly/data';
165
+ import { InferAsync } from '@typedly/data';
143
166
  ```
144
167
 
145
- [Source](https://github.com/typedly/data/blob/main/src/lib/constructor/lib/value.constructor.ts)
168
+ [Source](https://github.com/typedly/data/blob/main/src/inference/infer-async.type.ts)
146
169
 
147
- ### Interface
170
+ #### `InferValue`
148
171
 
149
- #### `AdaptableDataShape`
150
-
151
- The shape of a data type with optional adapter.
172
+ Infers the value type from a data shape interface.
152
173
 
153
174
  ```typescript
154
- import { AdaptableDataShape } from '@typedly/data';
175
+ import { InferAsync } from '@typedly/data';
155
176
  ```
156
177
 
157
- [Source](https://github.com/typedly/data/blob/main/src/lib/interface/adaptable-data.shape.ts)
178
+ [Source](https://github.com/typedly/data/blob/main/src/inference/infer-value.type.ts)
179
+
180
+ ### Iterable
158
181
 
159
- #### `DataAdapterShape`
182
+ #### `IterElement`
160
183
 
161
- The adapter interface for data types.
184
+ The iterate element type.
162
185
 
163
186
  ```typescript
164
- import { DataAdapterShape } from '@typedly/data';
187
+ import { IterElement } from '@typedly/data';
165
188
  ```
166
189
 
167
- [Source](https://github.com/typedly/data/blob/main/src/lib/interface/data-adapter.shape.ts)
190
+ [Source](https://github.com/typedly/data/blob/main/src/iterable/iter-element.type.ts)
168
191
 
169
- #### `DataShape`
192
+ #### `IterValue`
170
193
 
171
- The shape of a `Data` type.
194
+ The iterated value type.
172
195
 
173
196
  ```typescript
174
- import { DataShape } from '@typedly/data';
197
+ import { IterValue } from '@typedly/data';
175
198
  ```
176
199
 
177
- [Source](https://github.com/typedly/data/blob/main/src/lib/interface/data.shape.ts)
200
+ [Source](https://github.com/typedly/data/blob/main/src/iterable/iter-value.type.ts)
178
201
 
179
- #### `ValueShape`
202
+ ### Data
180
203
 
181
- The shape of a `Value` type.
204
+ #### `AsyncReturn`
205
+
206
+ The conditional return type for async methods.
182
207
 
183
208
  ```typescript
184
- import { ValueShape } from '@typedly/data';
209
+ import { AsyncReturn } from '@typedly/data';
185
210
  ```
186
211
 
187
- [Source](https://github.com/typedly/data/blob/main/src/lib/interface/value-shape.interface.ts)
212
+ [Source](https://github.com/typedly/data/blob/main/src/lib/type/async-return.type.ts)
188
213
 
189
- ### Type
214
+ #### `DataConstructorInput`
190
215
 
191
- #### `AdaptableDataConstructorInput`
216
+ The input type for data constructors, with arguments support.
192
217
 
193
218
  ```typescript
194
- import { AdaptableDataConstructorInput } from '@typedly/data';
219
+ import { DataConstructorInput } from '@typedly/data';
195
220
  ```
196
221
 
197
- [Source](https://github.com/typedly/data/blob/main/src/lib/type/adaptable-data-constructor-input.type.ts)
222
+ [Source](https://github.com/typedly/data/blob/main/src/lib/type/data-constructor-input.type.ts)
223
+
224
+ #### `DataConstructorTuple`
198
225
 
199
- #### `AdaptableDataConstructorTuple`
226
+ The input type for data constructors, with arguments support.
200
227
 
201
228
  ```typescript
202
- import { AdaptableDataConstructorTuple } from '@typedly/data';
229
+ import { DataConstructorTuple } from '@typedly/data';
203
230
  ```
204
231
 
205
- [Source](https://github.com/typedly/data/blob/main/src/lib/type/adaptable-data-constructor-tuple.type.ts)
232
+ [Source](https://github.com/typedly/data/blob/main/src/lib/type/data-constructor-tuple.type.ts)
206
233
 
207
- #### `AsyncReturn`
234
+ #### `DataConstructor`
208
235
 
209
- The conditional return type for async methods.
236
+ The constructor interface for data types.
210
237
 
211
238
  ```typescript
212
- import { AsyncReturn } from '@typedly/data';
239
+ import { DataConstructor } from '@typedly/data';
213
240
  ```
214
241
 
215
- [Source](https://github.com/typedly/data/blob/main/src/lib/type/async-return.type.ts)
242
+ [Source](https://github.com/typedly/data/blob/main/src/lib/interface/lib/data.constructor.ts)
216
243
 
217
- #### `DataConstructorInput`
244
+ #### `DataShape`
218
245
 
219
- The input type for data constructors, with arguments support.
246
+ The shape of a `Data` type.
220
247
 
221
248
  ```typescript
222
- import { DataConstructorInput } from '@typedly/data';
249
+ import { DataShape } from '@typedly/data';
223
250
  ```
224
251
 
225
- [Source](https://github.com/typedly/data/blob/main/src/lib/type/data-constructor-input.type.ts)
252
+ [Source](https://github.com/typedly/data/blob/main/src/lib/interface/data.shape.ts)
226
253
 
227
- #### `DataConstructorTuple`
254
+ ### Value
228
255
 
229
- The input type for data constructors, with arguments support.
256
+ #### `ValueConstructor`
230
257
 
231
258
  ```typescript
232
- import { DataConstructorTuple } from '@typedly/data';
259
+ import { ValueConstructor } from '@typedly/data';
233
260
  ```
234
261
 
235
- [Source](https://github.com/typedly/data/blob/main/src/lib/type/data-constructor-tuple.type.ts)
262
+ [Source](https://github.com/typedly/data/blob/main/src/value/lib/value.constructor.ts)
236
263
 
237
- #### `IterValue`
264
+ #### `ValueShape`
238
265
 
239
- The iterated value type.
266
+ The shape of a `Value` type.
240
267
 
241
268
  ```typescript
242
- import { IterValue } from '@typedly/data';
269
+ import { ValueShape } from '@typedly/data';
243
270
  ```
244
271
 
245
- [Source](https://github.com/typedly/data/blob/main/src/lib/type/iter-value.type.ts)
272
+ [Source](https://github.com/typedly/data/blob/main/src/value/lib/value-shape.interface.ts)
246
273
 
247
274
  ## Contributing
248
275
 
@@ -309,11 +336,7 @@ How do I know when to release 1.0.0?
309
336
 
310
337
  ## License
311
338
 
312
- MIT © typedly ([license][typedly-license])
313
-
314
- ## Related packages
315
-
316
- - **[@typescript-package/collection](https://github.com/typescript-package/collection)**: A lightweight TypeScript library for data collection.
339
+ MIT © typedly ([license][package-license])
317
340
 
318
341
  ## Packages
319
342
 
@@ -329,23 +352,41 @@ MIT © typedly ([license][typedly-license])
329
352
  - **[@typescript-package/wrapped-descriptor](https://github.com/typescript-package/wrapped-descriptor)**: A lightweight **TypeScript** library for wrapped property descriptor.
330
353
  - **[@xtypescript/property](https://github.com/xtypescript/property)** - A comprehensive, reactive **TypeScript** library for precise and extensible object property control.
331
354
 
355
+ <!-- Funding -->
356
+ [github-badge-sponsor]: https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&link=https://github.com/sponsors/angular-package
357
+ [github-sponsor-link]: https://github.com/sponsors/angular-package
358
+ [patreon-badge]: https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fshieldsio-patreon.vercel.app%2Fapi%3Fusername%3Dangularpackage%26type%3Dpatrons&style=flat
359
+ [patreon-link]: https://www.patreon.com/join/angularpackage/checkout?fan_landing=true&rid=0
360
+
361
+ <!-- Discord -->
362
+ [discord-badge]: https://img.shields.io/discord/925168966098386944?style=social&logo=discord&label=Discord
363
+ [discord-channel]: https://discord.com/invite/rUCR2CW75G
364
+
365
+ <!-- Gitter -->
366
+ [gitter-badge]: https://img.shields.io/gitter/room/angular-package/ap-sass?style=social&logo=gitter
367
+ [gitter-chat]: https://app.gitter.im/#/room/#ap-sass:gitter.im
368
+
369
+ <!-- Twitter -->
370
+ [twitter-badge]: https://img.shields.io/twitter/follow/angularpackage?label=%40angularpackage&style=social
371
+ [twitter-follow]: https://twitter.com/angularpackage
372
+
332
373
  <!-- This package: typedly -->
333
374
  <!-- GitHub: badges -->
334
- [typedly-badge-issues]: https://img.shields.io/github/issues/typedly/data
335
- [typedly-badge-forks]: https://img.shields.io/github/forks/typedly/data
336
- [typedly-badge-stars]: https://img.shields.io/github/stars/typedly/data
337
- [typedly-badge-license]: https://img.shields.io/github/license/typedly/data
375
+ [package-badge-issues]: https://img.shields.io/github/issues/typedly/data
376
+ [package-badge-forks]: https://img.shields.io/github/forks/typedly/data
377
+ [package-badge-stars]: https://img.shields.io/github/stars/typedly/data
378
+ [package-badge-license]: https://img.shields.io/github/license/typedly/data
338
379
  <!-- GitHub: badges links -->
339
- [typedly-issues]: https://github.com/typedly/data/issues
340
- [typedly-forks]: https://github.com/typedly/data/network
341
- [typedly-license]: https://github.com/typedly/data/blob/master/LICENSE
342
- [typedly-stars]: https://github.com/typedly/data/stargazers
380
+ [package-issues]: https://github.com/typedly/data/issues
381
+ [package-forks]: https://github.com/typedly/data/network
382
+ [package-license]: https://github.com/typedly/data/blob/master/LICENSE
383
+ [package-stars]: https://github.com/typedly/data/stargazers
343
384
  <!-- This package -->
344
385
 
345
386
  <!-- Package: typedly -->
346
387
  <!-- npm -->
347
- [typedly-npm-badge-svg]: https://badge.fury.io/gh/typedly%2Fdata.svg
348
- [typedly-npm-badge]: https://badge.fury.io/js/@typedly%2Fdata
388
+ [package-npm-badge-svg]: https://badge.fury.io/gh/typedly%2Fdata.svg
389
+ [package-npm-badge]: https://badge.fury.io/js/@typedly%2Fdata
349
390
 
350
391
  <!-- GIT -->
351
392
  [git-semver]: http://semver.org/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typedly/data",
3
- "version": "5.0.0-beta",
3
+ "version": "5.0.0",
4
4
  "author": "wwwdev.io <dev@wwwdev.io>",
5
5
  "description": "A TypeScript type definitions package for @typescript-package/data.",
6
6
  "license": "MIT",
@@ -20,7 +20,9 @@
20
20
  },
21
21
  "keywords": [
22
22
  "@typedly",
23
- "@typedly/data"
23
+ "@typedly/data",
24
+ "configuration",
25
+ "settings"
24
26
  ],
25
27
  "funding": [
26
28
  {
@@ -1,25 +1,29 @@
1
1
  import { DataConstructor as DataConstructor$1 } from '@typedly/constructor';
2
2
 
3
- type AdaptableDataConstructorTuple<A extends DataAdapterShape<T, C, R>, I extends AdaptableDataShape<A, T, C, R>, C extends {
4
- async?: boolean;
5
- } = A extends DataAdapterShape<any, infer V, any> ? V : any, T = A extends DataAdapterShape<infer U, any, any> ? U : any, R extends boolean = A extends DataAdapterShape<T, C, infer U> ? U extends boolean ? U : false : false, G extends readonly any[] = any[]> = readonly [AdaptableDataConstructor<A, I, C, T, R, G>, ...G];
6
-
7
- type AdaptableDataConstructorInput<A extends DataAdapterShape<T, C, R>, I extends AdaptableDataShape<A, T, C, R>, C extends {
8
- async?: boolean;
9
- } = A extends DataAdapterShape<any, infer V, any> ? V : any, T = A extends DataAdapterShape<infer U, any, any> ? U : any, R extends boolean = A extends DataAdapterShape<T, C, infer U> ? U extends boolean ? U : false : false, G extends readonly any[] = any[]> = AdaptableDataConstructor<A, I, C, T, R, G> | AdaptableDataConstructorTuple<A, I, C, T, R, G>;
3
+ /**
4
+ * @description The settings for a data type.
5
+ * @export
6
+ * @interface DataSettings
7
+ * @template {boolean} [R=false] The async flag.
8
+ */
9
+ interface DataSettings<R extends boolean = false> {
10
+ /**
11
+ * @description Optional async flag to indicate whether the data type is asynchronous.
12
+ * @default false
13
+ * @type {?R}
14
+ */
15
+ async?: R;
16
+ }
10
17
 
11
18
  /**
12
19
  * @description The type to provide data constructor with arguments.
13
20
  * @export
14
- * @template {DataShape<T, C, R>} I The type of the data instance.
15
- * @template {{ async?: boolean }} [C=I extends DataShape<any, infer V, any> ? V : any] The type of the configuration, inferred from I if possible.
16
- * @template [T=I extends DataShape<infer U, any, any> ? U : any] The type of value instance, inferred from I if possible.
17
- * @template {boolean} [R=I extends DataShape<T, C, infer U> ? U extends boolean ? U : false : false] The type of the readonly flag, inferred from I if possible.
18
- * @template {readonly any[]} [G=any[]] The type of the arguments tuple.
21
+ * @template {DataShape<T, R>} I The type of the data instance.
22
+ * @template [T=InferValue<I>] The type of value instance, inferred from I if possible.
23
+ * @template {boolean} [R=InferAsync<I>] The type of the readonly flag, inferred from I if possible.
24
+ * @template {readonly any[]} [G=[]] The type of the arguments tuple.
19
25
  */
20
- type DataConstructorTuple<I extends DataShape<T, C, R>, C extends {
21
- async?: boolean;
22
- } = I extends DataShape<any, infer V, any> ? V : any, T = I extends DataShape<infer U, any, any> ? U : any, R extends boolean = I extends DataShape<T, C, infer U> ? U extends boolean ? U : false : false, G extends readonly any[] = any[]> = [DataConstructor<I, C, T, R, G>, ...G];
26
+ type DataConstructorTuple<I extends DataShape<T, R>, T = InferValue<I>, R extends boolean = InferAsync<I>, G extends readonly any[] = []> = [DataConstructor<I, T, R, G>, ...G];
23
27
 
24
28
  /**
25
29
  * @description The input type for data constructors, with arguments support.
@@ -28,53 +32,38 @@ type DataConstructorTuple<I extends DataShape<T, C, R>, C extends {
28
32
  * @template {{ async?: boolean }} [C=I extends DataShape<any, infer V, any> ? V : any] The type of the configuration, inferred from I if possible.
29
33
  * @template [T=I extends DataShape<infer U, any, any> ? U : any] The type of value instance, inferred from I if possible.
30
34
  * @template {boolean} [R=I extends DataShape<T, C, infer U> ? U extends boolean ? U : false : false] The type of the readonly flag, inferred from I if possible.
31
- * @template {readonly any[]} [G=any[]] The type of the arguments tuple.
35
+ * @template {readonly any[]} [G=[]] The type of the arguments tuple.
32
36
  */
33
- type DataConstructorInput<I extends DataShape<T, C, R>, C extends {
34
- async?: boolean;
35
- } = I extends DataShape<any, infer V, any> ? V : any, T = I extends DataShape<infer U, any, any> ? U : any, R extends boolean = I extends DataShape<T, C, infer U> ? U extends boolean ? U : false : false, G extends readonly any[] = any[]> = DataConstructor<I, C, T, R, G> | DataConstructorTuple<I, C, T, R, G>;
37
+ type DataConstructorInput<I extends DataShape<T, R>, T = I extends DataShape<infer U, any> ? U : any, R extends boolean = InferAsync<I>, G extends readonly any[] = []> = DataConstructor<I, T, R, G> | DataConstructorTuple<I, T, R, G>;
36
38
 
37
39
  /**
38
40
  * @description The conditional return type for async methods.
39
41
  * @export
40
- * @template Async The boolean flag indicating if the return type should be a Promise.
42
+ * @template {boolean} R The boolean flag indicating if the return type should be a `Promise`.
41
43
  * @template T The type of the value to be returned.
42
44
  */
43
- type AsyncReturn<Async, T> = Async extends true ? Promise<T> : T;
44
-
45
- /**
46
- * @description The iterated value type.
47
- * @export
48
- * @template T The type of iterated value constrained by the `Iterable` type.
49
- */
50
- type IterValue<T> = T extends Iterable<infer U> ? U : T;
45
+ type AsyncReturn<R extends boolean, T> = R extends true ? Promise<T> : T;
51
46
 
52
47
  /**
53
48
  * @description The shape of a data type.
54
49
  * @export
55
50
  * @interface DataShape
56
51
  * @template T The value type.
57
- * @template C The configuration type.
58
- * @template {boolean} [R=C extends { async?: boolean } ? C['async'] extends boolean ? C['async'] : false : false] The `Promise` return type for methods.
52
+ * @template {boolean} [R=false] The async flag.
59
53
  */
60
- interface DataShape<T, C, R extends boolean = C extends {
61
- async?: boolean;
62
- } ? C['async'] extends boolean ? C['async'] : false : false> {
54
+ interface DataShape<T, R extends boolean = false> {
63
55
  /**
64
56
  * @description Indicates whether the methods return a `Promise`.
57
+ * @readonly
65
58
  * @type {R}
66
59
  */
67
- async: R;
68
- /**
69
- * @description The configuration of the `Data` instance.
70
- * @type {?C}
71
- */
72
- configuration?: C;
60
+ readonly async: R;
73
61
  /**
74
62
  * @description The value of the `Data` instance.
63
+ * @readonly
75
64
  * @type {T}
76
65
  */
77
- value: T;
66
+ readonly value: T;
78
67
  /**
79
68
  * @description Clears the value of the `Data` instance.
80
69
  * @returns {AsyncReturn<R, this>}
@@ -92,7 +81,7 @@ interface DataShape<T, C, R extends boolean = C extends {
92
81
  getValue(): AsyncReturn<R, T>;
93
82
  /**
94
83
  * @description Locks the `Data` instance, preventing any further modifications to its value.
95
- * @returns {this}
84
+ * @returns {this} The `Data` instance at the time of locking.
96
85
  */
97
86
  lock(): this;
98
87
  /**
@@ -101,110 +90,86 @@ interface DataShape<T, C, R extends boolean = C extends {
101
90
  * @returns {AsyncReturn<R, this>}
102
91
  */
103
92
  setValue(value: T): AsyncReturn<R, this>;
104
- /**
105
- * @description The string tag of the `Data` instance.
106
- * @type {?string}
107
- */
108
- [Symbol.toStringTag]?: string;
109
- /**
110
- * @description The iterator method for the `Data` instance, allowing it to be iterable.
111
- * @returns {IterableIterator<IterValue<T>>}
112
- */
113
- [Symbol.iterator]?(): IterableIterator<IterValue<T>>;
114
- /**
115
- * @description The asynchronous iterator method for the `Data` instance, allowing it to be asynchronously iterable.
116
- * @returns {AsyncIterableIterator<IterValue<T>>}
117
- */
118
- [Symbol.asyncIterator]?(): AsyncIterableIterator<IterValue<T>>;
119
93
  }
120
94
 
121
95
  /**
122
- * @description The adapter interface for data types.
96
+ * @description The constructor interface for data types.
123
97
  * @export
124
- * @interface DataAdapterShape
125
- * @template T The type of the data value.
126
- * @template C The type of the configuration object.
127
- * @template {boolean} [R=false] The type of the return values for methods.
128
- * @extends {DataShape<T, C, R>}
98
+ * @interface DataConstructor
99
+ * @template {DataShape<T, R>} I The data instance type.
100
+ * @template [T=InferValue<I>] The data type inferred from `I`.
101
+ * @template {boolean} [R=InferAsync<I>] The async flag, inferred from `I` if possible.
102
+ * @template {readonly any[]} [G=[]] Additional arguments.
129
103
  */
130
- interface DataAdapterShape<T, C, R extends boolean = C extends {
131
- async?: boolean;
132
- } ? C['async'] extends boolean ? C['async'] : false : false> extends DataShape<T, C, R> {
133
- version?: string;
104
+ interface DataConstructor<I extends DataShape<T, R>, T = InferValue<I>, R extends boolean = InferAsync<I>, G extends readonly any[] = []> {
105
+ new (
106
+ /** The optional initial value for the data instance. */
107
+ value: T,
108
+ /** Additional arguments for the constructor. */
109
+ ...args: G): I;
134
110
  }
135
111
 
136
112
  /**
137
- * @description The shape of a data type with optional adapter.
113
+ * @description Infers the async flag from the settings `DataSettings` or shape `DataShape`.
138
114
  * @export
139
- * @interface AdaptableDataShape
140
- * @template {DataAdapterShape<T, C, any>} A The adapter type.
141
- * @template [T=A extends DataAdapterShape<infer U, any, any> ? U : any] The value type.
142
- * @template [C=A extends DataAdapterShape<any, infer V, any> ? V : any] The configuration type.
143
- * @template {boolean} [R=A extends DataAdapterShape<T, C, infer U> ? U extends boolean ? U : false : false] The async flag.
144
- * @extends {DataShape<T, C, R>}
115
+ * @template T The type of the configuration object.
116
+ * @template F The default async flag if it cannot be inferred from T.
145
117
  */
146
- interface AdaptableDataShape<A extends DataAdapterShape<T, C, any> | undefined = undefined, T = A extends DataAdapterShape<infer U, any, any> ? U : any, C = A extends DataAdapterShape<any, infer V, any> ? V : any, R extends boolean = A extends DataAdapterShape<T, C, infer U> ? U extends boolean ? U : false : false> extends DataShape<T, C, R> {
147
- adapter?: A;
148
- }
118
+ type InferAsync<T = undefined, F = false> = T extends DataSettings<infer R extends boolean> ? R : T extends DataShape<any, infer R extends boolean> ? R : F;
149
119
 
150
120
  /**
151
- * @description The value shape.
121
+ * @description Infers the async flag from a tuple of arguments, returning true if any of the arguments has an async flag set to true.
152
122
  * @export
153
- * @interface ValueShape
154
- * @template Type The type of value.
123
+ * @template {readonly any[]} A The tuple of arguments to infer the async flag from.
124
+ * @template [F=false] The default async flag value if the tuple is empty.
155
125
  */
156
- interface ValueShape<Type> {
157
- get value(): Type;
158
- set(value: Type): this;
159
- }
126
+ type InferAsyncOf<A extends readonly any[], F = false> = A extends [infer Head, ...infer Tail] ? InferAsync<Head> extends true ? true : InferAsyncOf<Tail> : F;
160
127
 
161
128
  /**
162
- * @description The constructor interface for data adapters.
129
+ * @description Infers the value type from a data shape interface.
130
+ * It checks if the input type `I` extends `DataShape` and extracts the value type accordingly.
131
+ * If none of the conditions match, it returns the fallback type `F`.
163
132
  * @export
164
- * @interface DataAdapterConstructor
165
- * @template {DataAdapterShape<T, C, R>} I The data adapter instance type.
166
- * @template {{ async?: boolean }} [C=I extends DataAdapterShape<any, infer V, any> ? V : any] The configuration type, inferred from I if possible.
167
- * @template [T=I extends DataAdapterShape<infer U, any, any> ? U : any] The underlying value type, inferred from I if possible.
168
- * @template {boolean} [R=I extends DataAdapterShape<T, C, infer U> ? U extends boolean ? U : false : false] The async flag, inferred from I if possible.
169
- * @template {readonly any[]} [G=any[]] Additional arguments.
133
+ * @template I The data shape type.
134
+ * @template [F=any] The fallback type if inference fails.
170
135
  */
171
- interface DataAdapterConstructor<I extends DataAdapterShape<T, C, R>, C extends {
172
- async?: boolean;
173
- } = I extends DataAdapterShape<any, infer V, any> ? V : any, T = I extends DataAdapterShape<infer U, any, any> ? U : any, R extends boolean = I extends DataAdapterShape<T, C, infer U> ? U extends boolean ? U : false : false, G extends readonly any[] = any[]> {
174
- new (settings: C, value: T, ...args: G): I;
175
- }
136
+ type InferValue<I, F = any> = I extends DataShape<infer T> ? T : I extends {
137
+ value?: infer V;
138
+ } ? V : F;
176
139
 
177
140
  /**
178
- * @description The constructor interface for data types with adapter.
141
+ * @description The type for the data configuration, which can be either a full configuration object of `C` or just an async flag.
179
142
  * @export
180
- * @interface AdaptableDataConstructor
181
- * @template {DataAdapterShape<T, C, R>} A The data adapter instance type.
182
- * @template {AdaptableDataShape<A, T, C, R>} I The data instance type.
183
- * @template {{ async?: boolean }} [C=A extends DataAdapterShape<any, infer V, any> ? V : any] The configuration type, inferred from A if possible.
184
- * @template [T=A extends DataAdapterShape<infer U, any, any> ? U : any] The underlying value type, inferred from A if possible.
185
- * @template {boolean} [R=A extends DataAdapterShape<T, C, infer U> ? U extends boolean ? U : false : false] The async flag, inferred from A if possible.
186
- * @template {readonly any[]} [G=any[]] The additional arguments type.
143
+ * @template {DataSettings<R> | undefined} C The type of the settings for configuration.
144
+ * @template {boolean} [R=InferAsync<C>] The type of the async flag.
187
145
  */
188
- interface AdaptableDataConstructor<A extends DataAdapterShape<T, C, R>, I extends AdaptableDataShape<A, T, C, R>, C extends {
189
- async?: boolean;
190
- } = A extends DataAdapterShape<any, infer V, any> ? V : any, T = A extends DataAdapterShape<infer U, any, any> ? U : any, R extends boolean = A extends DataAdapterShape<T, C, infer U> ? U extends boolean ? U : false : false, G extends readonly any[] = any[]> {
191
- new (settings: C, value: T, adapter: DataAdapterConstructor<A, C, T, R, G>, ...args: G): I;
192
- }
146
+ type DataConfig<C extends DataSettings<R> | undefined, R extends boolean = InferAsync<C>> = C extends DataSettings<R> ? Required<C> : {
147
+ async: R;
148
+ };
193
149
 
194
150
  /**
195
- * @description The constructor interface for data types.
151
+ * @description The iterate element type.
196
152
  * @export
197
- * @interface DataConstructor
198
- * @template {DataShape<T, C, R>} I The data instance type.
199
- * @template {{ async?: boolean }} C The configuration type, inferred from `I` if possible.
200
- * @template T The underlying value type, inferred from `I` if possible.
201
- * @template {boolean} [R=C['async'] extends boolean ? C['async'] : false] The async flag, inferred from `I` if possible.
202
- * @template {readonly any[]} [G=any[]] Additional arguments.
153
+ * @template T The type of the iterable.
154
+ */
155
+ type IterableElement<T> = T extends Iterable<infer U> ? U : T;
156
+
157
+ /**
158
+ * @description The iterated value type.
159
+ * @export
160
+ * @template T The type of iterated value constrained by the `Iterable` type.
161
+ */
162
+ type IterValue<T> = IterableElement<T>;
163
+
164
+ /**
165
+ * @description The value shape.
166
+ * @export
167
+ * @interface ValueShape
168
+ * @template T The type of value.
203
169
  */
204
- interface DataConstructor<I extends DataShape<T, C, R>, C extends {
205
- async?: boolean;
206
- } = I extends DataShape<any, infer V, any> ? V : any, T = I extends DataShape<infer U, any, any> ? U : any, R extends boolean = I extends DataShape<T, C, infer U> ? U extends boolean ? U : false : false, G extends readonly any[] = any[]> {
207
- new (settings: C, value: T, ...args: G): I;
170
+ interface ValueShape<T> {
171
+ get value(): T;
172
+ set(value: T): this;
208
173
  }
209
174
 
210
175
  /**
@@ -219,4 +184,4 @@ interface DataConstructor<I extends DataShape<T, C, R>, C extends {
219
184
  interface ValueConstructor<T, I extends ValueShape<T>, G extends readonly any[] = any[]> extends DataConstructor$1<T, ValueShape<T>, I, [...G]> {
220
185
  }
221
186
 
222
- export type { AdaptableDataConstructor, AdaptableDataConstructorInput, AdaptableDataConstructorTuple, AdaptableDataShape, AsyncReturn, DataAdapterConstructor, DataAdapterShape, DataConstructor, DataConstructorInput, DataConstructorTuple, DataShape, IterValue, ValueConstructor, ValueShape };
187
+ export type { AsyncReturn, DataConfig, DataConstructor, DataConstructorInput, DataConstructorTuple, DataSettings, DataShape, InferAsync, InferAsyncOf, InferValue, IterValue, IterableElement, ValueConstructor, ValueShape };