@power-plant/core 0.0.15 → 0.0.17
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 +1 -1
- package/dist/{config-D3-0eTEI.d.cts → config-BpNybJZY.d.cts} +56 -244
- package/dist/config-BpNybJZY.d.cts.map +1 -0
- package/dist/{config-D3-0eTEI.d.mts → config-C9Hp8wTC.d.mts} +58 -246
- package/dist/config-C9Hp8wTC.d.mts.map +1 -0
- package/dist/config.d.cts +1 -1
- package/dist/config.d.mts +1 -1
- package/dist/context-BU2q1sN5.d.cts +105 -0
- package/dist/context-BU2q1sN5.d.cts.map +1 -0
- package/dist/context-BUNCX0E-.d.mts +105 -0
- package/dist/context-BUNCX0E-.d.mts.map +1 -0
- package/dist/context.cjs +1 -1
- package/dist/context.d.cts +34 -2
- package/dist/context.d.cts.map +1 -1
- package/dist/context.d.mts +34 -2
- package/dist/context.mjs +1 -1
- package/dist/define.cjs +1 -1
- package/dist/define.d.cts +2 -2
- package/dist/define.d.cts.map +1 -1
- package/dist/define.d.mts +2 -2
- package/dist/define.mjs +1 -1
- package/dist/execute-8tWWCCpu.mjs +2 -0
- package/dist/execute-8tWWCCpu.mjs.map +1 -0
- package/dist/execute-D7rill1C.cjs +1 -0
- package/dist/execute.cjs +1 -0
- package/dist/execute.d.cts +87 -0
- package/dist/execute.d.cts.map +1 -0
- package/dist/execute.d.mts +87 -0
- package/dist/execute.d.mts.map +1 -0
- package/dist/execute.mjs +1 -0
- package/dist/execution-BAm3omij.d.cts +61 -0
- package/dist/execution-BAm3omij.d.cts.map +1 -0
- package/dist/execution-d10Z7Dih.d.mts +61 -0
- package/dist/execution-d10Z7Dih.d.mts.map +1 -0
- package/dist/helpers/index.cjs +1 -0
- package/dist/helpers/index.d.cts +3 -0
- package/dist/helpers/index.d.mts +3 -0
- package/dist/helpers/index.mjs +1 -0
- package/dist/helpers/meta.cjs +1 -0
- package/dist/helpers/meta.d.cts +2 -0
- package/dist/helpers/meta.d.cts.map +1 -0
- package/dist/helpers/meta.d.mts +77 -0
- package/dist/helpers/meta.d.mts.map +1 -0
- package/dist/helpers/meta.mjs +2 -0
- package/dist/helpers/meta.mjs.map +1 -0
- package/dist/{type-checks-DBObymgE.d.cts → helpers/type-checks.d.cts} +6 -6
- package/dist/helpers/type-checks.d.cts.map +1 -0
- package/dist/{type-checks-DX_sqZhk.d.mts → helpers/type-checks.d.mts} +6 -6
- package/dist/helpers/type-checks.d.mts.map +1 -0
- package/dist/index-DY4xQ_iJ.d.mts +3 -0
- package/dist/index-it9jCi4L.d.cts +3 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +7 -5
- package/dist/index.d.mts +7 -5
- package/dist/index.mjs +1 -1
- package/dist/meta-CiPl-8rq.d.cts +82 -0
- package/dist/meta-CiPl-8rq.d.cts.map +1 -0
- package/package.json +60 -21
- package/dist/config-D3-0eTEI.d.cts.map +0 -1
- package/dist/config-D3-0eTEI.d.mts.map +0 -1
- package/dist/context-B4h787Dd.d.mts +0 -185
- package/dist/context-B4h787Dd.d.mts.map +0 -1
- package/dist/context-DYvyeLgC.d.cts +0 -185
- package/dist/context-DYvyeLgC.d.cts.map +0 -1
- package/dist/type-checks-DBObymgE.d.cts.map +0 -1
- package/dist/type-checks-DX_sqZhk.d.mts.map +0 -1
- package/dist/type-checks.d.cts +0 -2
- package/dist/type-checks.d.mts +0 -2
- package/dist/types/__internal.cjs +0 -0
- package/dist/types/__internal.d.cts +0 -13
- package/dist/types/__internal.d.cts.map +0 -1
- package/dist/types/__internal.d.mts +0 -13
- package/dist/types/__internal.d.mts.map +0 -1
- package/dist/types/__internal.mjs +0 -1
- /package/dist/{type-checks.cjs → helpers/type-checks.cjs} +0 -0
- /package/dist/{type-checks.mjs → helpers/type-checks.mjs} +0 -0
- /package/dist/{type-checks.mjs.map → helpers/type-checks.mjs.map} +0 -0
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EnvPaths } from "@stryke/env/get-env-paths";
|
|
2
2
|
import { Storage } from "unstorage";
|
|
3
3
|
import { InferExtractOptions, SchemaConfig, SchemaEnvelopeOf, SchemaSourceConfig } from "@power-plant/schema";
|
|
4
|
+
import { DeepPartial, MaybePromise } from "@stryke/types/base";
|
|
4
5
|
import { InferLoadOptions, LoadReference } from "@stryke/resolve/types";
|
|
5
|
-
import { EnvPaths } from "@stryke/env/get-env-paths";
|
|
6
6
|
//#region src/types/meta.d.ts
|
|
7
|
-
type MetaValue<TSpec, TOptions extends object, TValue = any> = TValue | ((spec: TSpec, options: TOptions) => MaybePromise<TValue>);
|
|
8
7
|
type MetaDeprecated = true | string | {
|
|
9
8
|
message?: string;
|
|
10
9
|
since?: string;
|
|
@@ -14,25 +13,13 @@ type MetaLink = string | {
|
|
|
14
13
|
href: string;
|
|
15
14
|
description?: string;
|
|
16
15
|
};
|
|
17
|
-
|
|
18
|
-
* A metadata primitive value.
|
|
19
|
-
*/
|
|
20
|
-
type MetaDataPrimitive = string | number | boolean | null | undefined;
|
|
21
|
-
/**
|
|
22
|
-
* A record of metadata primitive values.
|
|
23
|
-
*/
|
|
24
|
-
type MetaDataRecord<TSpec, TOptions extends object> = Record<string, MetaValue<TSpec, TOptions, MetaDataPrimitive | MetaDataPrimitive[]>>;
|
|
25
|
-
/**
|
|
26
|
-
* A record of metadata values.
|
|
27
|
-
*/
|
|
28
|
-
type MetaData<TSpec, TOptions extends object> = Record<string, MetaValue<TSpec, TOptions, MetaDataPrimitive | MetaDataPrimitive[] | MetaDataRecord<TSpec, TOptions>>>;
|
|
29
|
-
interface BaseMeta<TSpec, TOptions extends object> {
|
|
16
|
+
interface BaseMetaConfig {
|
|
30
17
|
/**
|
|
31
18
|
* Additional data associated with the object.
|
|
32
19
|
*/
|
|
33
|
-
data?:
|
|
20
|
+
data?: Record<string, any>;
|
|
34
21
|
}
|
|
35
|
-
interface MetaConfig
|
|
22
|
+
interface MetaConfig extends BaseMetaConfig {
|
|
36
23
|
/**
|
|
37
24
|
* A name for the object, which can be used to identify or reference the object in documentation, tooling, or other contexts. The presence of this property does not affect the validation behavior of the object itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
38
25
|
*
|
|
@@ -59,83 +46,30 @@ interface MetaConfig<TSpec, TOptions extends object> extends BaseMeta<TSpec, TOp
|
|
|
59
46
|
* @remarks
|
|
60
47
|
* The `title` property is a string that can be used to give the object a more user-friendly or descriptive name. It can be used in documentation, error messages, or other contexts where it is helpful to have a display name associated with the object. The presence of this property does not affect the validation behavior of the object itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
61
48
|
*/
|
|
62
|
-
title?:
|
|
63
|
-
/**
|
|
64
|
-
* A string that describes when the object is used.
|
|
65
|
-
*/
|
|
66
|
-
usage?: MetaValue<TSpec, TOptions, string>;
|
|
67
|
-
/**
|
|
68
|
-
* Indicates whether the object is deprecated, and optionally provides additional information about the deprecation, such as a message, the version since which it is deprecated, and an alternative object to use instead.
|
|
69
|
-
*
|
|
70
|
-
* @remarks
|
|
71
|
-
* The `deprecated` property can be a boolean value, where `true` indicates that the object is deprecated and `false` indicates that it is not. It can also be a string that provides a message explaining the deprecation, or an object that includes additional details such as a message, the version since which it is deprecated, and an alternative object to use instead. The presence of this property does not affect the validation behavior of the object itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
72
|
-
*/
|
|
73
|
-
deprecated?: MetaValue<TSpec, TOptions, MetaDeprecated>;
|
|
74
|
-
/**
|
|
75
|
-
* An array of tags associated with the object. Tags can be used to categorize or label objects for organizational purposes, making it easier to search, filter, or group related objects together. The presence of this property does not affect the validation behavior of the object itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
76
|
-
*
|
|
77
|
-
* @remarks
|
|
78
|
-
* Each tag in the array should be a string that represents a meaningful label or category for the object. It is recommended to use consistent and descriptive tags across objects to facilitate easier management and discovery of related objects.
|
|
79
|
-
*/
|
|
80
|
-
tags?: MetaValue<TSpec, TOptions, string[]>;
|
|
81
|
-
/**
|
|
82
|
-
* An array of links associated with the object. Each link can be a string representing a URL or an object containing a `href` property and an optional `description` property.
|
|
83
|
-
*/
|
|
84
|
-
links?: MetaValue<TSpec, TOptions, MetaLink[]>;
|
|
85
|
-
}
|
|
86
|
-
interface Meta<TSpec, TOptions extends object> extends BaseMeta<TSpec, TOptions> {
|
|
87
|
-
/**
|
|
88
|
-
* A name for the object, which can be used to identify or reference the object in documentation, tooling, or other contexts. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
89
|
-
*
|
|
90
|
-
* @remarks
|
|
91
|
-
* The `name` property is a string that can be used to give the object a human-readable identifier. It can be used in documentation, error messages, or other contexts where it is helpful to have a name associated with the schema. The presence of this property does not affect the validation behavior of the object itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
92
|
-
*/
|
|
93
|
-
name?: MetaValue<TSpec, TOptions, string>;
|
|
94
|
-
/**
|
|
95
|
-
* A version string that indicates the version of the object. This property can be used to track changes or updates to the object over time, allowing consumers of the object to determine which version they are working with. The presence of this property does not affect the validation behavior of the object itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
96
|
-
*
|
|
97
|
-
* @remarks
|
|
98
|
-
* The `version` property is a string that can follow any versioning scheme, such as semantic versioning (e.g., "1.0.0", "2.1.3"), date-based versioning (e.g., "2023-06-15"), or any other format that conveys the version of the object. It is recommended to use a consistent versioning scheme across all objects to facilitate easier tracking and management of object versions.
|
|
99
|
-
*
|
|
100
|
-
* @defaultValue "1.0"
|
|
101
|
-
*/
|
|
102
|
-
version?: MetaValue<TSpec, TOptions, string | Date | number>;
|
|
103
|
-
/**
|
|
104
|
-
* A string that describes the object in some way.
|
|
105
|
-
*/
|
|
106
|
-
description?: MetaValue<TSpec, TOptions, string>;
|
|
107
|
-
/**
|
|
108
|
-
* A string that provides a human-readable name for the object, which can be used in documentation, tooling, or other contexts to identify or reference the object. The presence of this property does not affect the validation behavior of the object itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
109
|
-
*
|
|
110
|
-
* @remarks
|
|
111
|
-
* The `title` property is a string that can be used to give the object a more user-friendly or descriptive name. It can be used in documentation, error messages, or other contexts where it is helpful to have a display name associated with the object. The presence of this property does not affect the validation behavior of the object itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
112
|
-
*/
|
|
113
|
-
title?: MetaValue<TSpec, TOptions, string>;
|
|
49
|
+
title?: string;
|
|
114
50
|
/**
|
|
115
51
|
* A string that describes when the object is used.
|
|
116
52
|
*/
|
|
117
|
-
usage?:
|
|
53
|
+
usage?: string;
|
|
118
54
|
/**
|
|
119
55
|
* Indicates whether the object is deprecated, and optionally provides additional information about the deprecation, such as a message, the version since which it is deprecated, and an alternative object to use instead.
|
|
120
56
|
*
|
|
121
57
|
* @remarks
|
|
122
58
|
* The `deprecated` property can be a boolean value, where `true` indicates that the object is deprecated and `false` indicates that it is not. It can also be a string that provides a message explaining the deprecation, or an object that includes additional details such as a message, the version since which it is deprecated, and an alternative object to use instead. The presence of this property does not affect the validation behavior of the object itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
123
59
|
*/
|
|
124
|
-
deprecated?:
|
|
60
|
+
deprecated?: MetaDeprecated;
|
|
125
61
|
/**
|
|
126
62
|
* An array of tags associated with the object. Tags can be used to categorize or label objects for organizational purposes, making it easier to search, filter, or group related objects together. The presence of this property does not affect the validation behavior of the object itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
127
63
|
*
|
|
128
64
|
* @remarks
|
|
129
65
|
* Each tag in the array should be a string that represents a meaningful label or category for the object. It is recommended to use consistent and descriptive tags across objects to facilitate easier management and discovery of related objects.
|
|
130
66
|
*/
|
|
131
|
-
tags?:
|
|
67
|
+
tags?: string[];
|
|
132
68
|
/**
|
|
133
69
|
* An array of links associated with the object. Each link can be a string representing a URL or an object containing a `href` property and an optional `description` property.
|
|
134
70
|
*/
|
|
135
|
-
links?:
|
|
71
|
+
links?: MetaLink[];
|
|
136
72
|
}
|
|
137
|
-
type InferExtractedMetaDataRecord<TMetaValue extends MetaDataRecord<any, any>> = { [K in keyof TMetaValue]: TMetaValue[K] extends MetaValue<any, any, infer U> ? U extends MetaDataRecord<any, any> ? InferExtractedMetaDataRecord<U> : U : TMetaValue[K]; };
|
|
138
|
-
type InferExtractedMeta<TMeta extends Meta<any, any>> = { [K in keyof TMeta]: TMeta[K] extends MetaValue<any, any, infer U> ? U extends MetaDataRecord<any, any> ? InferExtractedMetaDataRecord<U> : U : TMeta[K]; };
|
|
139
73
|
//#endregion
|
|
140
74
|
//#region src/types/schema.d.ts
|
|
141
75
|
type SchemaMetaExample<TSpec> = TSpec | {
|
|
@@ -143,26 +77,20 @@ type SchemaMetaExample<TSpec> = TSpec | {
|
|
|
143
77
|
description?: string;
|
|
144
78
|
value: TSpec;
|
|
145
79
|
};
|
|
146
|
-
interface SchemaMetaConfig<TSpec
|
|
80
|
+
interface SchemaMetaConfig<TSpec> extends MetaConfig {
|
|
147
81
|
/**
|
|
148
82
|
* Examples of valid data for the schema. This can be a single example or an array of examples.
|
|
149
83
|
*/
|
|
150
|
-
examples?: SchemaMetaExample<TSpec> |
|
|
84
|
+
examples?: SchemaMetaExample<TSpec> | SchemaMetaExample<TSpec>[];
|
|
151
85
|
/**
|
|
152
86
|
* A description of the specification that is described by this schema.
|
|
153
87
|
*/
|
|
154
|
-
spec?:
|
|
155
|
-
}
|
|
156
|
-
interface SchemaMeta<TSpec, TOptions extends object = any> extends Meta<TSpec, TOptions> {
|
|
157
|
-
/**
|
|
158
|
-
* Examples of valid data for the schema.
|
|
159
|
-
*/
|
|
160
|
-
examples: MetaValue<TSpec, TOptions, SchemaMetaExample<TSpec>[]>;
|
|
88
|
+
spec?: string;
|
|
161
89
|
}
|
|
162
90
|
/**
|
|
163
91
|
* Schema input wrapper that attaches optional contextual metadata.
|
|
164
92
|
*/
|
|
165
|
-
interface SchemaConfigObject<TSpec
|
|
93
|
+
interface SchemaConfigObject<TSpec> {
|
|
166
94
|
/**
|
|
167
95
|
* The schema that defines the structure of the specification input for the generator. This schema is used to validate the input specification and ensure that it conforms to the expected format before being processed by the generator.
|
|
168
96
|
*/
|
|
@@ -170,17 +98,17 @@ interface SchemaConfigObject<TSpec, TOptions extends object = any> {
|
|
|
170
98
|
/**
|
|
171
99
|
* Optional metadata that provides contextual information for the schema.
|
|
172
100
|
*/
|
|
173
|
-
meta?: SchemaMetaConfig<TSpec
|
|
101
|
+
meta?: SchemaMetaConfig<TSpec>;
|
|
174
102
|
}
|
|
175
|
-
type InferCreateSchemaOptions<T extends SchemaSourceConfig<any> | SchemaEnvelopeOf<any> | SchemaConfigObject<any
|
|
103
|
+
type InferCreateSchemaOptions<T extends SchemaSourceConfig<any> | SchemaEnvelopeOf<any> | SchemaConfigObject<any>> = T extends SchemaSourceConfig<any> | SchemaEnvelopeOf<any> ? InferExtractOptions<T> : {};
|
|
176
104
|
/**
|
|
177
105
|
* A schema extracted from a source input, normalized to JSON Schema.
|
|
178
106
|
*/
|
|
179
|
-
interface Schema<TSpec
|
|
107
|
+
interface Schema<TSpec> extends SchemaEnvelopeOf<TSpec> {
|
|
180
108
|
/**
|
|
181
109
|
* Optional contextual metadata associated with the schema.
|
|
182
110
|
*/
|
|
183
|
-
meta:
|
|
111
|
+
meta: SchemaMetaConfig<TSpec>;
|
|
184
112
|
}
|
|
185
113
|
/**
|
|
186
114
|
* A normalized JSON Schema extracted from a source input of type `T`. This type represents the result of the schema extraction process, where a raw schema input (which could be in various formats such as Zod, Untyped, Valibot, or as a type definition in TypeScript source code) is transformed into a standardized JSON Schema format. The `SchemaOf<T>` type captures the normalized JSON Schema along with metadata about the source variant and a content hash for caching or identification purposes.
|
|
@@ -189,27 +117,21 @@ interface Schema<TSpec, TOptions extends object = any> extends SchemaEnvelopeOf<
|
|
|
189
117
|
*
|
|
190
118
|
* @see {@link Schema}
|
|
191
119
|
*/
|
|
192
|
-
type SchemaOf<TSpec
|
|
120
|
+
type SchemaOf<TSpec> = Schema<TSpec>;
|
|
193
121
|
//#endregion
|
|
194
122
|
//#region src/types/input.d.ts
|
|
195
|
-
|
|
196
|
-
interface InputMetaConfig<TSpec, TOptions extends object> extends MetaConfig<TSpec, TOptions> {
|
|
197
|
-
/**
|
|
198
|
-
* A string that describes how the specification will be read/extracted. This property can provide context about the input of the specification, such as whether it is derived from a file, a database, an API, or any other input. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
199
|
-
*/
|
|
200
|
-
readFrom?: MetaValue<TSpec, TOptions, string>;
|
|
201
|
-
}
|
|
202
|
-
interface InputMeta<TSpec, TOptions extends object> extends Meta<TSpec, TOptions> {
|
|
123
|
+
interface InputMetaConfig extends MetaConfig {
|
|
203
124
|
/**
|
|
204
|
-
* A string that describes how the specification will be read/extracted.
|
|
125
|
+
* A string that describes how the specification will be read/extracted.
|
|
205
126
|
*/
|
|
206
127
|
readFrom?: string;
|
|
207
128
|
}
|
|
129
|
+
type InputFunction<TSpec, TOptions extends object> = (options: TOptions) => MaybePromise<TSpec>;
|
|
208
130
|
interface InputConfigObject<TSpec, TOptions extends object> {
|
|
209
131
|
/**
|
|
210
132
|
* The schema that defines the structure of the specification input for the generator. This schema is used to validate the input specification and ensure that it conforms to the expected format before being processed by the generator.
|
|
211
133
|
*/
|
|
212
|
-
schema?: SchemaConfig<TSpec> | SchemaConfigObject<TSpec
|
|
134
|
+
schema?: SchemaConfig<TSpec> | SchemaConfigObject<TSpec>;
|
|
213
135
|
/**
|
|
214
136
|
* The input implementation, either as a callable function, a static value, or a file reference.
|
|
215
137
|
*/
|
|
@@ -217,7 +139,7 @@ interface InputConfigObject<TSpec, TOptions extends object> {
|
|
|
217
139
|
/**
|
|
218
140
|
* Optional metadata that provides contextual information for the input.
|
|
219
141
|
*/
|
|
220
|
-
meta?: InputMetaConfig
|
|
142
|
+
meta?: InputMetaConfig;
|
|
221
143
|
}
|
|
222
144
|
type InputConfig<TSpec, TOptions extends object> = LoadReference | TSpec | InputFunction<TSpec, TOptions> | InputConfigObject<TSpec, TOptions>;
|
|
223
145
|
type InferCreateInputOptions<T extends InputConfig<any, any>> = T extends LoadReference ? InferLoadOptions<T> : {};
|
|
@@ -225,11 +147,11 @@ interface Input<TSpec, TOptions extends object> {
|
|
|
225
147
|
/**
|
|
226
148
|
* The schema that defines the structure of the specification input for the generator. This schema is used to validate the input specification and ensure that it conforms to the expected format before being processed by the generator.
|
|
227
149
|
*/
|
|
228
|
-
schema: SchemaOf<TSpec
|
|
150
|
+
schema: SchemaOf<TSpec>;
|
|
229
151
|
/**
|
|
230
152
|
* Optional metadata that provides contextual information for the input.
|
|
231
153
|
*/
|
|
232
|
-
meta?:
|
|
154
|
+
meta?: InputMetaConfig;
|
|
233
155
|
/**
|
|
234
156
|
* The input of the generator, which can be used to specify where the generator retrieves its input data from. This can be defined as a function that takes the specification and returns a value, or it can be a static value.
|
|
235
157
|
*
|
|
@@ -242,129 +164,18 @@ interface Input<TSpec, TOptions extends object> {
|
|
|
242
164
|
input: TSpec | InputFunction<TSpec, TOptions>;
|
|
243
165
|
}
|
|
244
166
|
//#endregion
|
|
245
|
-
//#region src/types/
|
|
246
|
-
interface
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
*/
|
|
250
|
-
content: string;
|
|
251
|
-
/**
|
|
252
|
-
* The metadata of the chunk.
|
|
253
|
-
*/
|
|
254
|
-
meta: Meta<TSpec, TOptions>;
|
|
167
|
+
//#region src/types/generator.d.ts
|
|
168
|
+
interface GeneratedDocumentChunk {
|
|
169
|
+
content?: string;
|
|
170
|
+
meta?: MetaConfig;
|
|
255
171
|
}
|
|
256
|
-
interface
|
|
257
|
-
/**
|
|
258
|
-
* The path of the document.
|
|
259
|
-
*/
|
|
172
|
+
interface GeneratedDocument {
|
|
260
173
|
path: string;
|
|
261
|
-
/**
|
|
262
|
-
* The language of the document.
|
|
263
|
-
*/
|
|
264
174
|
language?: string;
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
*/
|
|
268
|
-
chunks: ExecutionDocumentChunk<TSpec, TOptions>[];
|
|
269
|
-
/**
|
|
270
|
-
* The metadata of the document.
|
|
271
|
-
*/
|
|
272
|
-
meta: Meta<TSpec, TOptions>;
|
|
273
|
-
}
|
|
274
|
-
interface ExecutionMeta<TSpec, TOptions extends object> extends Meta<TSpec, TOptions> {
|
|
275
|
-
/**
|
|
276
|
-
* A unique identifier for the execution, typically used by the backend systems.
|
|
277
|
-
*
|
|
278
|
-
* @remarks
|
|
279
|
-
* This value will be in the UUID format, which is a 128-bit number represented as a string of hexadecimal digits. It is used to uniquely identify the execution in the backend systems and can be used for tracking and auditing purposes.
|
|
280
|
-
*/
|
|
281
|
-
executionId: string;
|
|
282
|
-
/**
|
|
283
|
-
* The date and time when the execution was performed.
|
|
284
|
-
*/
|
|
285
|
-
executedAt: Date;
|
|
286
|
-
/**
|
|
287
|
-
* The user who performed the execution.
|
|
288
|
-
*/
|
|
289
|
-
executedBy: string;
|
|
290
|
-
/**
|
|
291
|
-
* The specification used to generate the source code during the execution.
|
|
292
|
-
*/
|
|
293
|
-
spec: TSpec;
|
|
294
|
-
/**
|
|
295
|
-
* The metadata of the generator used to execute the source code during the execution.
|
|
296
|
-
*/
|
|
297
|
-
generator: GeneratorMeta<TSpec, TOptions>;
|
|
298
|
-
/**
|
|
299
|
-
* The metadata of the schema used to generate the source code during the execution.
|
|
300
|
-
*/
|
|
301
|
-
schema: SchemaMeta<TSpec, TOptions>;
|
|
302
|
-
/**
|
|
303
|
-
* The metadata of the input used to generate the source code during the execution.
|
|
304
|
-
*/
|
|
305
|
-
input: InputMeta<TSpec, TOptions>;
|
|
306
|
-
/**
|
|
307
|
-
* The metadata of the output used to generate the source code during the execution.
|
|
308
|
-
*/
|
|
309
|
-
output: OutputMeta<TSpec, TOptions>;
|
|
310
|
-
}
|
|
311
|
-
interface Execution<TSpec, TOptions extends object> {
|
|
312
|
-
/**
|
|
313
|
-
* The documents of the execution, indexed by the document path.
|
|
314
|
-
*/
|
|
315
|
-
documents: Record<string, ExecutionDocument<TSpec, TOptions>>;
|
|
316
|
-
/**
|
|
317
|
-
* The metadata of the execution.
|
|
318
|
-
*/
|
|
319
|
-
meta: ExecutionMeta<TSpec, TOptions>;
|
|
175
|
+
chunks?: DeepPartial<GeneratedDocumentChunk>[];
|
|
176
|
+
meta?: MetaConfig;
|
|
320
177
|
}
|
|
321
|
-
type
|
|
322
|
-
/**
|
|
323
|
-
* The returned value of the generator function.
|
|
324
|
-
*/
|
|
325
|
-
returns?: TReturns;
|
|
326
|
-
};
|
|
327
|
-
type ExtractedExecutionSource<TSpec, TOptions extends object> = Omit<ExecutionDocumentChunk<TSpec, TOptions>, "meta"> & {
|
|
328
|
-
/**
|
|
329
|
-
* The extracted metadata of the execution.
|
|
330
|
-
*/
|
|
331
|
-
meta: InferExtractedMeta<ExecutionDocumentChunk<TSpec, TOptions>["meta"]>;
|
|
332
|
-
};
|
|
333
|
-
type ExtractedExecutionDocument<TSpec, TOptions extends object> = Omit<ExecutionDocument<TSpec, TOptions>, "source" | "meta"> & {
|
|
334
|
-
/**
|
|
335
|
-
* The source of the document.
|
|
336
|
-
*/
|
|
337
|
-
source: ExtractedExecutionSource<TSpec, TOptions>[];
|
|
338
|
-
/**
|
|
339
|
-
* The extracted metadata of the execution.
|
|
340
|
-
*/
|
|
341
|
-
meta: InferExtractedMeta<ExecutionDocument<TSpec, TOptions>["meta"]>;
|
|
342
|
-
};
|
|
343
|
-
type ExtractedExecution<TSpec, TOptions extends object> = Omit<Execution<TSpec, TOptions>, "documents" | "meta"> & {
|
|
344
|
-
/**
|
|
345
|
-
* The documents of the execution, indexed by the document path.
|
|
346
|
-
*/
|
|
347
|
-
documents: Record<string, ExtractedExecutionDocument<TSpec, TOptions>>;
|
|
348
|
-
/**
|
|
349
|
-
* The extracted metadata of the execution.
|
|
350
|
-
*/
|
|
351
|
-
meta: InferExtractedMeta<ExecutionMeta<TSpec, TOptions>>;
|
|
352
|
-
};
|
|
353
|
-
//#endregion
|
|
354
|
-
//#region src/types/generator.d.ts
|
|
355
|
-
interface GeneratorMeta<TSpec, TOptions extends object> extends MetaConfig<TSpec, TOptions> {
|
|
356
|
-
/**
|
|
357
|
-
* A string description (or a function that returns a string) outlining the purpose or behavior of the generator.
|
|
358
|
-
*/
|
|
359
|
-
description?: string;
|
|
360
|
-
}
|
|
361
|
-
type GeneratedDocument<TSpec, TOptions extends object> = Partial<Omit<ExecutionDocument<TSpec, TOptions>, "source">> & Pick<ExecutionDocument<TSpec, TOptions>, "path"> & {
|
|
362
|
-
/**
|
|
363
|
-
* The sources of the document.
|
|
364
|
-
*/
|
|
365
|
-
chunks?: DeepPartial<ExecutionDocumentChunk<TSpec, TOptions>>[];
|
|
366
|
-
};
|
|
367
|
-
type GeneratorFunction<TSpec, TOptions extends object> = (spec: TSpec, options: TOptions) => MaybePromise<Record<string, GeneratedDocument<TSpec, TOptions>>>;
|
|
178
|
+
type GeneratorFunction<TSpec, TOptions extends object> = (spec: TSpec, options: TOptions) => MaybePromise<Record<string, GeneratedDocument>>;
|
|
368
179
|
type GeneratorFunctionResult<TSpec, TOptions extends object> = Awaited<ReturnType<GeneratorFunction<TSpec, TOptions>>>;
|
|
369
180
|
interface GeneratorResult<TSpec, TOptions extends object, TReturns = void> {
|
|
370
181
|
/**
|
|
@@ -388,11 +199,11 @@ interface GeneratorConfigObject<TSpec, TOptions extends object, TReturns = void>
|
|
|
388
199
|
/**
|
|
389
200
|
* Optional metadata about the generator, such as a description of the output it produces.
|
|
390
201
|
*/
|
|
391
|
-
meta?:
|
|
202
|
+
meta?: MetaConfig;
|
|
392
203
|
/**
|
|
393
204
|
* The schema config that defines the structure of the specification object for this generator.
|
|
394
205
|
*/
|
|
395
|
-
schema?: SchemaConfig<TSpec> | SchemaConfigObject<TSpec
|
|
206
|
+
schema?: SchemaConfig<TSpec> | SchemaConfigObject<TSpec>;
|
|
396
207
|
/**
|
|
397
208
|
* The input config for the generator specification.
|
|
398
209
|
*/
|
|
@@ -412,11 +223,11 @@ interface Generator<TSpec, TOptions extends object, TReturns = void> {
|
|
|
412
223
|
/**
|
|
413
224
|
* Optional metadata about the generator, such as a description of the output it produces.
|
|
414
225
|
*/
|
|
415
|
-
meta?:
|
|
226
|
+
meta?: MetaConfig;
|
|
416
227
|
/**
|
|
417
228
|
* The schema config that defines the structure of the specification object for this generator.
|
|
418
229
|
*/
|
|
419
|
-
schema: SchemaOf<TSpec
|
|
230
|
+
schema: SchemaOf<TSpec>;
|
|
420
231
|
/**
|
|
421
232
|
* The input of the generator, which can be used to specify where the generator retrieves its input data from. This can be defined as a function that takes the specification and returns a value, or it can be a static value.
|
|
422
233
|
*/
|
|
@@ -436,30 +247,31 @@ interface Generator<TSpec, TOptions extends object, TReturns = void> {
|
|
|
436
247
|
*/
|
|
437
248
|
generator: (options: TOptions & UserConfig) => Promise<GeneratorResult<TSpec, TOptions, TReturns>>;
|
|
438
249
|
}
|
|
250
|
+
type InferSchemaConfig<T extends GeneratorConfig<any, any, any>> = T extends LoadReference ? InferLoadOptions<T> : T extends GeneratorConfigObject<any, any, any> ? T["schema"] : never;
|
|
251
|
+
type InferMeta<T extends GeneratorConfig<any, any, any>> = T extends LoadReference ? InferLoadOptions<T> : T extends GeneratorConfigObject<any, any, any> ? T["meta"] : never;
|
|
252
|
+
type InferInputConfig<T extends GeneratorConfig<any, any, any>> = T extends LoadReference ? InferLoadOptions<T> : T extends GeneratorConfigObject<any, any, any> ? T["input"] : never;
|
|
253
|
+
type InferOutputConfig<T extends GeneratorConfig<any, any, any>> = T extends LoadReference ? InferLoadOptions<T> : T extends GeneratorConfigObject<any, any, any> ? T["output"] : never;
|
|
254
|
+
type InferGeneratorFunction<T extends GeneratorConfig<any, any, any>> = T extends LoadReference ? InferLoadOptions<T> : T extends GeneratorConfigObject<any, any, any> ? T["generator"] : never;
|
|
255
|
+
type InferGeneratorResult<T extends GeneratorConfig<any, any, any>> = InferGeneratorFunction<T> extends GeneratorFunction<any, any> ? Awaited<ReturnType<InferGeneratorFunction<T>>> : never;
|
|
256
|
+
interface InferGenerator<T extends GeneratorConfig<any, any, any>> {
|
|
257
|
+
meta?: InferMeta<T>;
|
|
258
|
+
schema: InferSchemaConfig<T>;
|
|
259
|
+
input: InferInputConfig<T>;
|
|
260
|
+
output: InferOutputConfig<T>;
|
|
261
|
+
generator: InferGeneratorFunction<T>;
|
|
262
|
+
}
|
|
439
263
|
//#endregion
|
|
440
264
|
//#region src/types/output.d.ts
|
|
441
|
-
type OutputFunction<TSpec, TOptions extends object, TReturns = void> = (spec: TSpec, options: TOptions, documents: Record<string, GeneratedDocument
|
|
442
|
-
interface OutputMetaConfig<TSpec, TOptions extends object> extends MetaConfig<TSpec, TOptions> {
|
|
443
|
-
/**
|
|
444
|
-
* A string that describes how the specification will be extracted or generated. This property can provide context about the source of the specification, such as whether it is derived from a file, a database, an API, or any other source. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
445
|
-
*/
|
|
446
|
-
produces?: string;
|
|
447
|
-
}
|
|
448
|
-
interface OutputMeta<TSpec, TOptions extends object> extends Meta<TSpec, TOptions> {
|
|
449
|
-
/**
|
|
450
|
-
* A string that describes how the specification will be extracted or generated. This property can provide context about the source of the specification, such as whether it is derived from a file, a database, an API, or any other source. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
451
|
-
*/
|
|
452
|
-
produces?: string;
|
|
453
|
-
}
|
|
265
|
+
type OutputFunction<TSpec, TOptions extends object, TReturns = void> = (spec: TSpec, options: TOptions, documents: Record<string, GeneratedDocument>) => MaybePromise<TReturns>;
|
|
454
266
|
interface OutputConfigObject<TSpec, TOptions extends object, TReturns = void> {
|
|
455
267
|
/**
|
|
456
268
|
* The schema that defines the structure of the specification output for the generator. This schema is used to validate the output specification and ensure that it conforms to the expected format before being processed by the generator.
|
|
457
269
|
*/
|
|
458
|
-
schema?: SchemaConfig<TSpec> | SchemaConfigObject<TSpec
|
|
270
|
+
schema?: SchemaConfig<TSpec> | SchemaConfigObject<TSpec>;
|
|
459
271
|
/**
|
|
460
272
|
* Optional metadata that provides contextual information for the output.
|
|
461
273
|
*/
|
|
462
|
-
meta?:
|
|
274
|
+
meta?: MetaConfig;
|
|
463
275
|
/**
|
|
464
276
|
* The output implementation, either as a callable function or a file reference.
|
|
465
277
|
*/
|
|
@@ -471,11 +283,11 @@ interface Output<TSpec, TOptions extends object, TReturns = void> {
|
|
|
471
283
|
/**
|
|
472
284
|
* The schema that defines the structure of the specification output for the generator. This schema is used to validate the output specification and ensure that it conforms to the expected format before being processed by the generator.
|
|
473
285
|
*/
|
|
474
|
-
schema: SchemaOf<TSpec
|
|
286
|
+
schema: SchemaOf<TSpec>;
|
|
475
287
|
/**
|
|
476
288
|
* Optional metadata that provides contextual information for the output.
|
|
477
289
|
*/
|
|
478
|
-
meta?:
|
|
290
|
+
meta?: MetaConfig;
|
|
479
291
|
/**
|
|
480
292
|
* The output of the generator, which can be used to specify where the generator sends its output data. This can be defined as a function that takes the specification and returns a value, or it can be a static value.
|
|
481
293
|
*
|
|
@@ -567,5 +379,5 @@ type UserConfigFnPromise<TSpec = any, TOptions extends object = any, TReturns =
|
|
|
567
379
|
type UserConfigFn<TSpec = any, TOptions extends object = any, TReturns = any> = (params: UserConfigParams) => UserConfig<TSpec, TOptions, TReturns> | UserConfig<TSpec, TOptions, TReturns>[] | Promise<UserConfig<TSpec, TOptions, TReturns> | UserConfig<TSpec, TOptions, TReturns>[]>;
|
|
568
380
|
type UserConfigExport<TSpec = any, TOptions extends object = any, TReturns = any> = UserConfig<TSpec, TOptions, TReturns> | UserConfig<TSpec, TOptions, TReturns>[] | Promise<UserConfig<TSpec, TOptions, TReturns> | UserConfig<TSpec, TOptions, TReturns>[]> | UserConfigFnObject<TSpec, TOptions, TReturns> | UserConfigFnPromise<TSpec, TOptions, TReturns> | UserConfigFn<TSpec, TOptions, TReturns>;
|
|
569
381
|
//#endregion
|
|
570
|
-
export {
|
|
571
|
-
//# sourceMappingURL=config-
|
|
382
|
+
export { InferCreateInputOptions as A, SchemaMetaExample as B, InferGenerator as C, InferMeta as D, InferInputConfig as E, InputMetaConfig as F, MetaLink as G, BaseMetaConfig as H, InferCreateSchemaOptions as I, Schema as L, InputConfig as M, InputConfigObject as N, InferOutputConfig as O, InputFunction as P, SchemaConfigObject as R, InferCreateGeneratorOptions as S, InferGeneratorResult as T, MetaConfig as U, SchemaOf as V, MetaDeprecated as W, GeneratorConfig as _, UserConfigFnPromise as a, GeneratorFunctionResult as b, Settings as c, OutputConfig as d, OutputConfigObject as f, Generator as g, GeneratedDocumentChunk as h, UserConfigFnObject as i, Input as j, InferSchemaConfig as k, InferCreateOutputOptions as l, GeneratedDocument as m, UserConfigExport as n, UserConfigParams as o, OutputFunction as p, UserConfigFn as r, Logger as s, UserConfig as t, Output as u, GeneratorConfigObject as v, InferGeneratorFunction as w, GeneratorResult as x, GeneratorFunction as y, SchemaMetaConfig as z };
|
|
383
|
+
//# sourceMappingURL=config-C9Hp8wTC.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-C9Hp8wTC.d.mts","names":[],"sources":["../src/types/meta.ts","../src/types/schema.ts","../src/types/input.ts","../src/types/generator.ts","../src/types/output.ts","../src/types/settings.ts","../src/types/config.ts"],"mappings":""}
|
package/dist/config.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as UserConfigFnPromise, i as UserConfigFnObject, n as UserConfigExport, o as UserConfigParams, r as UserConfigFn, t as UserConfig } from "./config-
|
|
1
|
+
import { a as UserConfigFnPromise, i as UserConfigFnObject, n as UserConfigExport, o as UserConfigParams, r as UserConfigFn, t as UserConfig } from "./config-BpNybJZY.cjs";
|
|
2
2
|
//#region src/config.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Type helper to make it easier to use `power-plant.config.ts` files. Accepts a direct {@link UserConfig} object, or a function that returns it. The function receives a {@link ConfigParams} object.
|
package/dist/config.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as UserConfigFnPromise, i as UserConfigFnObject, n as UserConfigExport, o as UserConfigParams, r as UserConfigFn, t as UserConfig } from "./config-
|
|
1
|
+
import { a as UserConfigFnPromise, i as UserConfigFnObject, n as UserConfigExport, o as UserConfigParams, r as UserConfigFn, t as UserConfig } from "./config-C9Hp8wTC.mjs";
|
|
2
2
|
//#region src/config.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Type helper to make it easier to use `power-plant.config.ts` files. Accepts a direct {@link UserConfig} object, or a function that returns it. The function receives a {@link ConfigParams} object.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { V as SchemaOf, c as Settings, j as Input, m as GeneratedDocument, s as Logger, u as Output } from "./config-BpNybJZY.cjs";
|
|
2
|
+
import { n as Execution } from "./execution-BAm3omij.cjs";
|
|
3
|
+
import { Storage } from "unstorage";
|
|
4
|
+
//#region src/types/base.d.ts
|
|
5
|
+
interface Base {
|
|
6
|
+
/**
|
|
7
|
+
* A unique identifier for the model.
|
|
8
|
+
*/
|
|
9
|
+
id: string;
|
|
10
|
+
/**
|
|
11
|
+
* The timestamp when the model was created.
|
|
12
|
+
*/
|
|
13
|
+
createdAt: Date;
|
|
14
|
+
/**
|
|
15
|
+
* The timestamp when the model was last updated.
|
|
16
|
+
*/
|
|
17
|
+
updatedAt: Date;
|
|
18
|
+
/**
|
|
19
|
+
* The description of the model.
|
|
20
|
+
*/
|
|
21
|
+
description?: string;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/types/session.d.ts
|
|
25
|
+
interface Session extends Base {
|
|
26
|
+
/**
|
|
27
|
+
* The device that started the session.
|
|
28
|
+
*/
|
|
29
|
+
device: string;
|
|
30
|
+
/**
|
|
31
|
+
* The user who started the session.
|
|
32
|
+
*/
|
|
33
|
+
user: string;
|
|
34
|
+
/**
|
|
35
|
+
* The executions of the session.
|
|
36
|
+
*/
|
|
37
|
+
executions: Execution<any>[];
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/types/context.d.ts
|
|
41
|
+
interface SessionContext {
|
|
42
|
+
/**
|
|
43
|
+
* The current working directory.
|
|
44
|
+
*/
|
|
45
|
+
cwd: string;
|
|
46
|
+
/**
|
|
47
|
+
* The settings for the context.
|
|
48
|
+
*/
|
|
49
|
+
settings: Settings;
|
|
50
|
+
/**
|
|
51
|
+
* The Unstorage storage for the context.
|
|
52
|
+
*
|
|
53
|
+
* @remarks
|
|
54
|
+
* This storage can be used to store the input and output of the execution.
|
|
55
|
+
*/
|
|
56
|
+
storage: Storage;
|
|
57
|
+
/**
|
|
58
|
+
* The logger for the context.
|
|
59
|
+
*/
|
|
60
|
+
logger: Logger;
|
|
61
|
+
/**
|
|
62
|
+
* The session for the context.
|
|
63
|
+
*/
|
|
64
|
+
session: Session;
|
|
65
|
+
}
|
|
66
|
+
interface ExecutionContext<TSpec, TOptions extends object, TReturns = void> extends SessionContext, Execution<TSpec> {
|
|
67
|
+
/**
|
|
68
|
+
* The options for the execution.
|
|
69
|
+
*/
|
|
70
|
+
options: TOptions;
|
|
71
|
+
/**
|
|
72
|
+
* The specification for the execution.
|
|
73
|
+
*/
|
|
74
|
+
get spec(): TSpec;
|
|
75
|
+
/**
|
|
76
|
+
* The schema for the execution.
|
|
77
|
+
*/
|
|
78
|
+
get schema(): SchemaOf<TSpec>;
|
|
79
|
+
/**
|
|
80
|
+
* The input for the execution.
|
|
81
|
+
*/
|
|
82
|
+
get input(): Input<TSpec, TOptions>;
|
|
83
|
+
/**
|
|
84
|
+
* The output for the execution.
|
|
85
|
+
*/
|
|
86
|
+
get output(): Output<TSpec, TOptions, TReturns>;
|
|
87
|
+
/**
|
|
88
|
+
* The documents that are currently being processed, indexed by the document path.
|
|
89
|
+
*/
|
|
90
|
+
get documents(): Record<string, GeneratedDocument>;
|
|
91
|
+
/**
|
|
92
|
+
* Adds a document to the currently processing documents.
|
|
93
|
+
*
|
|
94
|
+
* @param pathOrDocument - A string representing the path of the document to add, or the document to add.
|
|
95
|
+
* @param document - The document to add (without the path), if {@link pathOrDocument} is a string representing the document path.
|
|
96
|
+
*/
|
|
97
|
+
addDocument: (pathOrDocument: string | GeneratedDocument, document?: Omit<GeneratedDocument, "path">) => void;
|
|
98
|
+
}
|
|
99
|
+
interface LocalStore {
|
|
100
|
+
device?: string;
|
|
101
|
+
user?: string;
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
export { Base as a, Session as i, LocalStore as n, SessionContext as r, ExecutionContext as t };
|
|
105
|
+
//# sourceMappingURL=context-BU2q1sN5.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-BU2q1sN5.d.cts","names":[],"sources":["../src/types/base.ts","../src/types/session.ts","../src/types/context.ts"],"mappings":";;;;UAkBiB;;;;EAIf;;;;EAKA,WAAW;;;;EAKX,WAAW;;;;EAKX;;;;UChBe,gBAAgB;;;;EAI/B;;;;EAKA;;;;EAKA,YAAY;;;;UCRG;;;;EAIf;;;;EAKA,UAAU;;;;;;;EAQV,SAAS;;;;EAKT,QAAQ;;;;EAKR,SAAS;;UAGM,iBACf,OACA,yBACA,yBAEQ,gBAAgB,UAAU;;;;EAIlC,SAAS;;;;MAKL,QAAQ;;;;MAKR,UAAU,SAAS;;;;MAKnB,SAAS,MAAM,OAAO;;;;MAKtB,UAAU,OAAO,OAAO,UAAU;;;;MAKlC,aAAa,eAAe;;;;;;;EAQhC,cACE,yBAAyB,mBACzB,WAAW,KAAK;;UAIH;EACf;EACA"}
|