@typedly/data 5.0.0-beta → 5.0.0-beta.1

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
@@ -18,31 +18,34 @@ A **TypeScript** type definitions package for [**@typescript-package/data**](htt
18
18
 
19
19
  ## Features
20
20
 
21
- - **Adapter**: Optional data adapter to customize managing underlying data.
21
+ - **Adapter**: Optional data adapter to customize managing underlying data available under the [`@typedly/adaptable-data`](https://github.com/typedly/data-adapter).
22
+ - **Configurable**: Configurable data shape available under the [`@typedly/configurable-data`](https://github.com/typedly/configurable-data).
23
+ - **Traits**: Extended customization by traits, such as `Configurable`, `Adaptable`, `Serializable`, and `Transformable` under the [`@typedly/data-traits`](https://github.com/typedly/data-traits) package.
22
24
  - **Shape**: The default shape for data of any `T` type with conditional async.
23
25
 
24
26
  ## Table of contents
25
27
 
28
+ - [Related packages](#related-packages)
26
29
  - [Installation](#installation)
27
30
  - [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)
31
+ - [Data](#data)
41
32
  - [`AsyncReturn`](#asyncreturn)
33
+ - [`DataConfig`](#dataconfig)
42
34
  - [`DataConstructorInput`](#dataconstructorinput)
43
35
  - [`DataConstructorTuple`](#dataconstructortuple)
36
+ - [`DataConstructor`](#dataconstructor)
37
+ - [`DataSettings`](#datasettings)
38
+ - [`DataShape`](#datashape)
39
+ - [Inference](#inference)
40
+ - [`InferAsyncOf`](#inferasyncof)
41
+ - [`InferAsync`](#inferasync)
42
+ - [`InferValue`](#infervalue)
43
+ - [Iterable](#iterable)
44
44
  - [`IterValue`](#itervalue)
45
- - [Full example usage](#full-example-usage)
45
+ - [`IterableElement`](#itervalue)
46
+ - [Value](#value)
47
+ - [`ValueConstructor`](#valueconstructor)
48
+ - [`ValueShape`](#valueshape)
46
49
  - [Contributing](#contributing)
47
50
  - [Support](#support)
48
51
  - [Code of Conduct](#code-of-conduct)
@@ -50,7 +53,17 @@ A **TypeScript** type definitions package for [**@typescript-package/data**](htt
50
53
  - [Commit](#commit)
51
54
  - [Versioning](#versioning)
52
55
  - [License](#license)
53
- - [Related packages](#related-packages)
56
+ - [Packages](#packages)
57
+
58
+ ## Related packages
59
+
60
+ - **[@typedly/adaptable-data](https://github.com/typedly/adaptable-data)**: A **TypeScript** type definitions for data adapter.
61
+ - **[@typedly/collection](https://github.com/typedly/collection)**: A **TypeScript** type definitions package for data collections with customizable storage.
62
+ - **[@typedly/configurable-data](https://github.com/typedly/configurable-data)**: A **TypeScript** type definitions for configurable data.
63
+ - **[@typedly/data-adapter](https://github.com/typedly/data-adapter)**: A **TypeScript** type definitions for data adapter.
64
+ - **[@typedly/data-traits](https://github.com/typedly/data-traits)**: A **TypeScript** type definitions for data traits.
65
+ - **[@typescript-package/data](https://github.com/typescript-package/data)**: A lightweight **TypeScript** library for basic data management.
66
+ - **[@typescript-package/collection](https://github.com/typescript-package/collection)**: A lightweight **TypeScript** library for data collection.
54
67
 
55
68
  ## Installation
56
69
 
@@ -70,179 +83,178 @@ npm install @typedly/data --save-peer
70
83
 
71
84
  ```typescript
72
85
  import {
73
- // Data adapter constructor.
74
- DataAdapterConstructor,
75
-
76
- // Data Constructor.
77
- AdaptableDataConstructor,
78
- DataConstructor,
79
-
80
- // Value Constructor.
81
- ValueConstructor,
82
-
83
- // Data adapter Interface.
84
- DataAdapterShape,
86
+ // Inference.
87
+ InferAsync,
88
+ InferAsyncOf,
89
+ InferValue,
85
90
 
86
- // Data Interface.
87
- AdaptableDataShape,
88
- DataShape,
91
+ // Iterable.
92
+ IterValue,
93
+ IterableElement,
89
94
 
90
- // Value Interface.
91
- ValueShape,
92
-
93
- // Adaptable data constructor input and tuple.
94
- AdaptableDataConstructorInput,
95
- AdaptableDataConstructorTuple,
96
-
97
- // Data constructor input and tuple.
95
+ // Return types
96
+ AsyncReturn,
97
+ // Config
98
+ DataConfig,
99
+ // Input types
98
100
  DataConstructorInput,
99
101
  DataConstructorTuple,
100
102
 
101
- // Type.
102
- AsyncReturn,
103
- IterValue
103
+ // Iterable
104
+ IterValue,
105
+ IterableElement,
106
+
107
+ // Value.
108
+ ValueConstructor,
109
+ ValueShape,
104
110
  } from '@typedly/data';
105
111
  ```
106
112
 
107
- ### Constructor
113
+ ### Inference
108
114
 
109
- #### `AdaptableDataConstructor`
115
+ #### `InferAsyncOf`
110
116
 
111
- The constructor interface for data types with adapter.
117
+ Infers the async flag from a tuple of arguments, returning true if any of the arguments has an async flag set to true.
112
118
 
113
119
  ```typescript
114
- import { AdaptableDataConstructor } from '@typedly/data';
120
+ import { InferAsync } from '@typedly/data';
115
121
  ```
116
122
 
117
- [Source](https://github.com/typedly/data/blob/main/src/lib/constructor/lib/adaptable-data.constructor.ts)
123
+ [Source](https://github.com/typedly/data/blob/main/src/inference/infer-async-of.type.ts)
118
124
 
119
- #### `DataAdapterConstructor`
125
+ #### `InferAsync`
120
126
 
121
- The constructor interface for data adapters.
127
+ Infers the async flag from the settings `DataSettings` or shape `DataShape`.
122
128
 
123
129
  ```typescript
124
- import { DataAdapterConstructor } from '@typedly/data';
130
+ import { InferAsync } from '@typedly/data';
125
131
  ```
126
132
 
127
- [Source](https://github.com/typedly/data/blob/main/src/lib/constructor/lib/data-adapter.constructor.ts)
133
+ [Source](https://github.com/typedly/data/blob/main/src/inference/infer-async.type.ts)
128
134
 
129
- #### `DataConstructor`
135
+ #### `InferValue`
130
136
 
131
- The constructor interface for data types.
137
+ Infers the value type from a data shape interface.
132
138
 
133
139
  ```typescript
134
- import { DataConstructor } from '@typedly/data';
140
+ import { InferAsync } from '@typedly/data';
135
141
  ```
136
142
 
137
- [Source](https://github.com/typedly/data/blob/main/src/lib/constructor/lib/data.constructor.ts)
143
+ [Source](https://github.com/typedly/data/blob/main/src/inference/infer-value.type.ts)
138
144
 
139
- #### `ValueConstructor`
145
+ ### Iterable
146
+
147
+ #### `IterElement`
148
+
149
+ The iterate element type.
140
150
 
141
151
  ```typescript
142
- import { ValueConstructor } from '@typedly/data';
152
+ import { IterElement } from '@typedly/data';
143
153
  ```
144
154
 
145
- [Source](https://github.com/typedly/data/blob/main/src/lib/constructor/lib/value.constructor.ts)
146
-
147
- ### Interface
155
+ [Source](https://github.com/typedly/data/blob/main/src/iterable/iter-element.type.ts)
148
156
 
149
- #### `AdaptableDataShape`
157
+ #### `IterValue`
150
158
 
151
- The shape of a data type with optional adapter.
159
+ The iterated value type.
152
160
 
153
161
  ```typescript
154
- import { AdaptableDataShape } from '@typedly/data';
162
+ import { IterValue } from '@typedly/data';
155
163
  ```
156
164
 
157
- [Source](https://github.com/typedly/data/blob/main/src/lib/interface/adaptable-data.shape.ts)
165
+ [Source](https://github.com/typedly/data/blob/main/src/iterable/iter-value.type.ts)
158
166
 
159
- #### `DataAdapterShape`
167
+ ### Data
160
168
 
161
- The adapter interface for data types.
169
+ #### `AsyncReturn`
170
+
171
+ The conditional return type for async methods.
162
172
 
163
173
  ```typescript
164
- import { DataAdapterShape } from '@typedly/data';
174
+ import { AsyncReturn } from '@typedly/data';
165
175
  ```
166
176
 
167
- [Source](https://github.com/typedly/data/blob/main/src/lib/interface/data-adapter.shape.ts)
177
+ [Source](https://github.com/typedly/data/blob/main/src/lib/type/async-return.type.ts)
168
178
 
169
- #### `DataShape`
179
+ #### `DataConfig`
170
180
 
171
- The shape of a `Data` type.
181
+ The type for the data configuration, which can be either a full configuration object of `C` or just an async flag.
172
182
 
173
183
  ```typescript
174
- import { DataShape } from '@typedly/data';
184
+ import { DataConfig } from '@typedly/data';
175
185
  ```
176
186
 
177
- [Source](https://github.com/typedly/data/blob/main/src/lib/interface/data.shape.ts)
187
+ [Source](https://github.com/typedly/data/blob/main/src/lib/type/data.config.ts)
178
188
 
179
- #### `ValueShape`
189
+ #### `DataConstructorInput`
180
190
 
181
- The shape of a `Value` type.
191
+ The input type for data constructors, with arguments support.
182
192
 
183
193
  ```typescript
184
- import { ValueShape } from '@typedly/data';
194
+ import { DataConstructorInput } from '@typedly/data';
185
195
  ```
186
196
 
187
- [Source](https://github.com/typedly/data/blob/main/src/lib/interface/value-shape.interface.ts)
197
+ [Source](https://github.com/typedly/data/blob/main/src/lib/type/data-constructor-input.type.ts)
188
198
 
189
- ### Type
199
+ #### `DataConstructorTuple`
190
200
 
191
- #### `AdaptableDataConstructorInput`
201
+ The input type for data constructors, with arguments support.
192
202
 
193
203
  ```typescript
194
- import { AdaptableDataConstructorInput } from '@typedly/data';
204
+ import { DataConstructorTuple } from '@typedly/data';
195
205
  ```
196
206
 
197
- [Source](https://github.com/typedly/data/blob/main/src/lib/type/adaptable-data-constructor-input.type.ts)
207
+ [Source](https://github.com/typedly/data/blob/main/src/lib/type/data-constructor-tuple.type.ts)
208
+
209
+ #### `DataConstructor`
198
210
 
199
- #### `AdaptableDataConstructorTuple`
211
+ The constructor interface for data types.
200
212
 
201
213
  ```typescript
202
- import { AdaptableDataConstructorTuple } from '@typedly/data';
214
+ import { DataConstructor } from '@typedly/data';
203
215
  ```
204
216
 
205
- [Source](https://github.com/typedly/data/blob/main/src/lib/type/adaptable-data-constructor-tuple.type.ts)
217
+ [Source](https://github.com/typedly/data/blob/main/src/lib/interface/lib/data.constructor.ts)
206
218
 
207
- #### `AsyncReturn`
219
+ #### `DataSettings`
208
220
 
209
- The conditional return type for async methods.
221
+ The settings for a data type.
210
222
 
211
223
  ```typescript
212
- import { AsyncReturn } from '@typedly/data';
224
+ import { DataSettings } from '@typedly/data';
213
225
  ```
214
226
 
215
- [Source](https://github.com/typedly/data/blob/main/src/lib/type/async-return.type.ts)
227
+ [Source](https://github.com/typedly/data/blob/main/src/lib/interface/lib/data.settings.ts)
216
228
 
217
- #### `DataConstructorInput`
229
+ #### `DataShape`
218
230
 
219
- The input type for data constructors, with arguments support.
231
+ The shape of a `Data` type.
220
232
 
221
233
  ```typescript
222
- import { DataConstructorInput } from '@typedly/data';
234
+ import { DataShape } from '@typedly/data';
223
235
  ```
224
236
 
225
- [Source](https://github.com/typedly/data/blob/main/src/lib/type/data-constructor-input.type.ts)
237
+ [Source](https://github.com/typedly/data/blob/main/src/lib/interface/data.shape.ts)
226
238
 
227
- #### `DataConstructorTuple`
239
+ ### Value
228
240
 
229
- The input type for data constructors, with arguments support.
241
+ #### `ValueConstructor`
230
242
 
231
243
  ```typescript
232
- import { DataConstructorTuple } from '@typedly/data';
244
+ import { ValueConstructor } from '@typedly/data';
233
245
  ```
234
246
 
235
- [Source](https://github.com/typedly/data/blob/main/src/lib/type/data-constructor-tuple.type.ts)
247
+ [Source](https://github.com/typedly/data/blob/main/src/value/lib/value.constructor.ts)
236
248
 
237
- #### `IterValue`
249
+ #### `ValueShape`
238
250
 
239
- The iterated value type.
251
+ The shape of a `Value` type.
240
252
 
241
253
  ```typescript
242
- import { IterValue } from '@typedly/data';
254
+ import { ValueShape } from '@typedly/data';
243
255
  ```
244
256
 
245
- [Source](https://github.com/typedly/data/blob/main/src/lib/type/iter-value.type.ts)
257
+ [Source](https://github.com/typedly/data/blob/main/src/value/lib/value-shape.interface.ts)
246
258
 
247
259
  ## Contributing
248
260
 
@@ -311,10 +323,6 @@ How do I know when to release 1.0.0?
311
323
 
312
324
  MIT © typedly ([license][typedly-license])
313
325
 
314
- ## Related packages
315
-
316
- - **[@typescript-package/collection](https://github.com/typescript-package/collection)**: A lightweight TypeScript library for data collection.
317
-
318
326
  ## Packages
319
327
 
320
328
  - **[@typescript-package/chain-descriptor](https://github.com/typescript-package/chain-descriptor)**: A **TypeScript** library for chain property descriptor.
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-beta.1",
4
4
  "author": "wwwdev.io <dev@wwwdev.io>",
5
5
  "description": "A TypeScript type definitions package for @typescript-package/data.",
6
6
  "license": "MIT",
@@ -1,25 +1,39 @@
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];
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
+ }
6
17
 
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>;
18
+ /**
19
+ * @description The type for the data configuration, which can be either a full configuration object of `C` or just an async flag.
20
+ * @export
21
+ * @template {DataSettings<R> | undefined} C The type of the settings for configuration.
22
+ * @template {boolean} [R=InferAsync<C>] The type of the async flag.
23
+ */
24
+ type DataConfig<C extends DataSettings<R> | undefined, R extends boolean = InferAsync<C>> = C extends DataSettings<R> ? Required<C> : {
25
+ async: R;
26
+ };
10
27
 
11
28
  /**
12
29
  * @description The type to provide data constructor with arguments.
13
30
  * @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.
31
+ * @template {DataShape<T, R>} I The type of the data instance.
32
+ * @template [T=InferValue<I>] The type of value instance, inferred from I if possible.
33
+ * @template {boolean} [R=InferAsync<I>] The type of the readonly flag, inferred from I if possible.
34
+ * @template {readonly any[]} [G=[]] The type of the arguments tuple.
19
35
  */
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];
36
+ 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
37
 
24
38
  /**
25
39
  * @description The input type for data constructors, with arguments support.
@@ -28,53 +42,52 @@ type DataConstructorTuple<I extends DataShape<T, C, R>, C extends {
28
42
  * @template {{ async?: boolean }} [C=I extends DataShape<any, infer V, any> ? V : any] The type of the configuration, inferred from I if possible.
29
43
  * @template [T=I extends DataShape<infer U, any, any> ? U : any] The type of value instance, inferred from I if possible.
30
44
  * @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.
45
+ * @template {readonly any[]} [G=[]] The type of the arguments tuple.
32
46
  */
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>;
47
+ 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
48
 
37
49
  /**
38
50
  * @description The conditional return type for async methods.
39
51
  * @export
40
- * @template Async The boolean flag indicating if the return type should be a Promise.
52
+ * @template {boolean} R The boolean flag indicating if the return type should be a `Promise`.
41
53
  * @template T The type of the value to be returned.
42
54
  */
43
- type AsyncReturn<Async, T> = Async extends true ? Promise<T> : T;
55
+ type AsyncReturn<R extends boolean, T> = R extends true ? Promise<T> : T;
56
+
57
+ /**
58
+ * @description The iterate element type.
59
+ * @export
60
+ * @template T The type of the iterable.
61
+ */
62
+ type IterableElement<T> = T extends Iterable<infer U> ? U : T;
44
63
 
45
64
  /**
46
65
  * @description The iterated value type.
47
66
  * @export
48
67
  * @template T The type of iterated value constrained by the `Iterable` type.
49
68
  */
50
- type IterValue<T> = T extends Iterable<infer U> ? U : T;
69
+ type IterValue<T> = IterableElement<T>;
51
70
 
52
71
  /**
53
72
  * @description The shape of a data type.
54
73
  * @export
55
74
  * @interface DataShape
56
75
  * @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.
76
+ * @template {boolean} [R=false] The async flag.
59
77
  */
60
- interface DataShape<T, C, R extends boolean = C extends {
61
- async?: boolean;
62
- } ? C['async'] extends boolean ? C['async'] : false : false> {
78
+ interface DataShape<T, R extends boolean = false> {
63
79
  /**
64
80
  * @description Indicates whether the methods return a `Promise`.
81
+ * @readonly
65
82
  * @type {R}
66
83
  */
67
- async: R;
68
- /**
69
- * @description The configuration of the `Data` instance.
70
- * @type {?C}
71
- */
72
- configuration?: C;
84
+ readonly async: R;
73
85
  /**
74
86
  * @description The value of the `Data` instance.
87
+ * @readonly
75
88
  * @type {T}
76
89
  */
77
- value: T;
90
+ readonly value: T;
78
91
  /**
79
92
  * @description Clears the value of the `Data` instance.
80
93
  * @returns {AsyncReturn<R, this>}
@@ -92,9 +105,9 @@ interface DataShape<T, C, R extends boolean = C extends {
92
105
  getValue(): AsyncReturn<R, T>;
93
106
  /**
94
107
  * @description Locks the `Data` instance, preventing any further modifications to its value.
95
- * @returns {this}
108
+ * @returns {AsyncReturn<R, this>} The `Data` instance at the time of locking.
96
109
  */
97
- lock(): this;
110
+ lock(): AsyncReturn<R, this>;
98
111
  /**
99
112
  * @description Sets the value of the `Data` instance.
100
113
  * @param {T} value
@@ -103,9 +116,10 @@ interface DataShape<T, C, R extends boolean = C extends {
103
116
  setValue(value: T): AsyncReturn<R, this>;
104
117
  /**
105
118
  * @description The string tag of the `Data` instance.
119
+ * @readonly
106
120
  * @type {?string}
107
121
  */
108
- [Symbol.toStringTag]?: string;
122
+ readonly [Symbol.toStringTag]?: string;
109
123
  /**
110
124
  * @description The iterator method for the `Data` instance, allowing it to be iterable.
111
125
  * @returns {IterableIterator<IterValue<T>>}
@@ -119,92 +133,59 @@ interface DataShape<T, C, R extends boolean = C extends {
119
133
  }
120
134
 
121
135
  /**
122
- * @description The adapter interface for data types.
123
- * @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>}
129
- */
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;
134
- }
135
-
136
- /**
137
- * @description The shape of a data type with optional adapter.
136
+ * @description The constructor interface for data types.
138
137
  * @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>}
138
+ * @interface DataConstructor
139
+ * @template {DataShape<T, R>} I The data instance type.
140
+ * @template [T=InferValue<I>] The data type inferred from `I`.
141
+ * @template {boolean} [R=InferAsync<I>] The async flag, inferred from `I` if possible.
142
+ * @template {readonly any[]} [G=[]] Additional arguments.
145
143
  */
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;
144
+ interface DataConstructor<I extends DataShape<T, R>, T = InferValue<I>, R extends boolean = InferAsync<I>, G extends readonly any[] = []> {
145
+ new (
146
+ /** The optional initial value for the data instance. */
147
+ value: T,
148
+ /** Additional arguments for the constructor. */
149
+ ...args: G): I;
148
150
  }
149
151
 
150
152
  /**
151
- * @description The value shape.
153
+ * @description Infers the async flag from the settings `DataSettings` or shape `DataShape`.
152
154
  * @export
153
- * @interface ValueShape
154
- * @template Type The type of value.
155
+ * @template T The type of the configuration object.
156
+ * @template F The default async flag if it cannot be inferred from T.
155
157
  */
156
- interface ValueShape<Type> {
157
- get value(): Type;
158
- set(value: Type): this;
159
- }
158
+ type InferAsync<T = undefined, F = false> = T extends DataSettings<infer R extends boolean> ? R : T extends DataShape<any, infer R extends boolean> ? R : F;
160
159
 
161
160
  /**
162
- * @description The constructor interface for data adapters.
161
+ * @description Infers the async flag from a tuple of arguments, returning true if any of the arguments has an async flag set to true.
163
162
  * @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.
163
+ * @template {readonly any[]} A The tuple of arguments to infer the async flag from.
164
+ * @template [F=false] The default async flag value if the tuple is empty.
170
165
  */
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
- }
166
+ type InferAsyncOf<A extends readonly any[], F = false> = A extends [infer Head, ...infer Tail] ? InferAsync<Head> extends true ? true : InferAsyncOf<Tail> : F;
176
167
 
177
168
  /**
178
- * @description The constructor interface for data types with adapter.
169
+ * @description Infers the value type from a data shape interface.
170
+ * It checks if the input type `I` extends `DataShape` and extracts the value type accordingly.
171
+ * If none of the conditions match, it returns the fallback type `F`.
179
172
  * @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.
173
+ * @template I The data shape type.
174
+ * @template [F=any] The fallback type if inference fails.
187
175
  */
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
- }
176
+ type InferValue<I, F = any> = I extends DataShape<infer T> ? T : I extends {
177
+ value?: infer V;
178
+ } ? V : F;
193
179
 
194
180
  /**
195
- * @description The constructor interface for data types.
181
+ * @description The value shape.
196
182
  * @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.
183
+ * @interface ValueShape
184
+ * @template T The type of value.
203
185
  */
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;
186
+ interface ValueShape<T> {
187
+ get value(): T;
188
+ set(value: T): this;
208
189
  }
209
190
 
210
191
  /**
@@ -219,4 +200,4 @@ interface DataConstructor<I extends DataShape<T, C, R>, C extends {
219
200
  interface ValueConstructor<T, I extends ValueShape<T>, G extends readonly any[] = any[]> extends DataConstructor$1<T, ValueShape<T>, I, [...G]> {
220
201
  }
221
202
 
222
- export type { AdaptableDataConstructor, AdaptableDataConstructorInput, AdaptableDataConstructorTuple, AdaptableDataShape, AsyncReturn, DataAdapterConstructor, DataAdapterShape, DataConstructor, DataConstructorInput, DataConstructorTuple, DataShape, IterValue, ValueConstructor, ValueShape };
203
+ export type { AsyncReturn, DataConfig, DataConstructor, DataConstructorInput, DataConstructorTuple, DataSettings, DataShape, InferAsync, InferAsyncOf, InferValue, IterValue, IterableElement, ValueConstructor, ValueShape };