@power-plant/core 0.0.12 → 0.0.16

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.
Files changed (42) hide show
  1. package/README.md +1 -1
  2. package/dist/{config-DMItzxbk.d.cts → config-B_E87BPl.d.cts} +62 -238
  3. package/dist/config-B_E87BPl.d.cts.map +1 -0
  4. package/dist/{config-DMItzxbk.d.mts → config-B_E87BPl.d.mts} +62 -238
  5. package/dist/config-B_E87BPl.d.mts.map +1 -0
  6. package/dist/config.d.cts +1 -1
  7. package/dist/config.d.mts +1 -1
  8. package/dist/context-BCW5TgL-.d.mts +183 -0
  9. package/dist/context-BCW5TgL-.d.mts.map +1 -0
  10. package/dist/context-C0n9Tore.d.cts +183 -0
  11. package/dist/context-C0n9Tore.d.cts.map +1 -0
  12. package/dist/context.cjs +1 -1
  13. package/dist/context.d.cts +34 -2
  14. package/dist/context.d.cts.map +1 -1
  15. package/dist/context.d.mts +34 -2
  16. package/dist/context.mjs +1 -1
  17. package/dist/define.d.cts +2 -2
  18. package/dist/define.d.cts.map +1 -1
  19. package/dist/define.d.mts +2 -2
  20. package/dist/index.cjs +1 -1
  21. package/dist/index.d.cts +5 -26
  22. package/dist/index.d.mts +5 -26
  23. package/dist/index.mjs +1 -1
  24. package/dist/{type-checks-E_UZ_-fD.d.cts → type-checks-BYCnzjxr.d.cts} +4 -4
  25. package/dist/{type-checks-E_UZ_-fD.d.cts.map → type-checks-BYCnzjxr.d.cts.map} +1 -1
  26. package/dist/{type-checks-SBt7tgFq.d.mts → type-checks-C-wRp-HW.d.mts} +4 -4
  27. package/dist/type-checks-C-wRp-HW.d.mts.map +1 -0
  28. package/dist/type-checks.d.cts +1 -1
  29. package/dist/type-checks.d.mts +1 -1
  30. package/dist/types/__internal.d.cts +4 -4
  31. package/dist/types/__internal.d.cts.map +1 -1
  32. package/dist/types/__internal.d.mts +4 -4
  33. package/package.json +5 -5
  34. package/dist/config-DMItzxbk.d.cts.map +0 -1
  35. package/dist/config-DMItzxbk.d.mts.map +0 -1
  36. package/dist/context-BxqCoy9z.d.cts +0 -128
  37. package/dist/context-BxqCoy9z.d.cts.map +0 -1
  38. package/dist/context-COQtFcI5.d.mts +0 -128
  39. package/dist/context-COQtFcI5.d.mts.map +0 -1
  40. package/dist/index.d.cts.map +0 -1
  41. package/dist/index.d.mts.map +0 -1
  42. package/dist/type-checks-SBt7tgFq.d.mts.map +0 -1
@@ -4,7 +4,6 @@ import { InferExtractOptions, SchemaConfig, SchemaEnvelopeOf, SchemaSourceConfig
4
4
  import { InferLoadOptions, LoadReference } from "@stryke/resolve/types";
5
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?: MetaData<TSpec, TOptions>;
20
+ data?: Record<string, any>;
34
21
  }
35
- interface MetaConfig<TSpec, TOptions extends object> extends BaseMeta<TSpec, TOptions> {
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?: MetaValue<TSpec, TOptions, string>;
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?: MetaValue<TSpec, TOptions, string>;
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?: MetaValue<TSpec, TOptions, MetaDeprecated>;
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?: MetaValue<TSpec, TOptions, string[]>;
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?: MetaValue<TSpec, TOptions, MetaLink[]>;
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, TOptions extends object = any> extends MetaConfig<TSpec, TOptions> {
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> | MetaValue<TSpec, TOptions, 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?: MetaValue<TSpec, TOptions, string>;
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, TOptions extends object = any> {
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, TOptions>;
101
+ meta?: SchemaMetaConfig<TSpec>;
174
102
  }
175
- type InferCreateSchemaOptions<T extends SchemaSourceConfig<any> | SchemaEnvelopeOf<any> | SchemaConfigObject<any, any>> = T extends SchemaSourceConfig<any> | SchemaEnvelopeOf<any> ? InferExtractOptions<T> : {};
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, TOptions extends object = any> extends SchemaEnvelopeOf<TSpec> {
107
+ interface Schema<TSpec> extends SchemaEnvelopeOf<TSpec> {
180
108
  /**
181
109
  * Optional contextual metadata associated with the schema.
182
110
  */
183
- meta: SchemaMeta<TSpec, TOptions>;
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, TOptions extends object = any> = Schema<TSpec, TOptions>;
120
+ type SchemaOf<TSpec> = Schema<TSpec>;
193
121
  //#endregion
194
122
  //#region src/types/input.d.ts
195
- type InputFunction<TSpec, TOptions extends object> = (options: TOptions) => MaybePromise<TSpec>;
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. 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.
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, TOptions>;
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<TSpec, TOptions>;
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, TOptions>;
150
+ schema: SchemaOf<TSpec>;
229
151
  /**
230
152
  * Optional metadata that provides contextual information for the input.
231
153
  */
232
- meta?: InputMeta<TSpec, TOptions>;
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,132 +164,33 @@ interface Input<TSpec, TOptions extends object> {
242
164
  input: TSpec | InputFunction<TSpec, TOptions>;
243
165
  }
244
166
  //#endregion
245
- //#region src/types/execution.d.ts
246
- interface ExecutionSource<TSpec, TOptions extends object> {
247
- /**
248
- * The language of the document.
249
- */
250
- language?: string;
251
- /**
252
- * The content of the source code.
253
- */
254
- content: string;
167
+ //#region src/types/generator.d.ts
168
+ type GeneratorMeta<TSpec, TOptions extends object> = MetaConfig & {
255
169
  /**
256
- * The metadata of the source code.
170
+ * A string description outlining the purpose or behavior of the generator.
257
171
  */
258
- meta: Meta<TSpec, TOptions>;
172
+ description?: string;
173
+ };
174
+ interface GeneratedDocumentChunk {
175
+ content?: string;
176
+ meta?: MetaConfig;
259
177
  }
260
- interface ExecutionDocument<TSpec, TOptions extends object> {
261
- /**
262
- * The path of the document.
263
- */
178
+ interface GeneratedDocument<TSpec, TOptions extends object> {
264
179
  path: string;
265
- /**
266
- * The source of the document.
267
- */
268
- source: ExecutionSource<TSpec, TOptions>[];
269
- /**
270
- * The metadata of the document.
271
- */
272
- meta: Meta<TSpec, TOptions>;
180
+ language?: string;
181
+ chunks?: DeepPartial<GeneratedDocumentChunk>[];
182
+ meta?: MetaConfig;
273
183
  }
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;
184
+ type GeneratorFunction<TSpec, TOptions extends object> = (spec: TSpec, options: TOptions) => MaybePromise<Record<string, GeneratedDocument<TSpec, TOptions>>>;
185
+ type GeneratorFunctionResult<TSpec, TOptions extends object> = Awaited<ReturnType<GeneratorFunction<TSpec, TOptions>>>;
186
+ interface GeneratorResult<TSpec, TOptions extends object, TReturns = void> {
290
187
  /**
291
- * The specification used to generate the source code during the execution.
188
+ * The specification used to generate the documents.
292
189
  */
293
190
  spec: TSpec;
294
191
  /**
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>;
320
- }
321
- type ExecutionResult<TSpec, TOptions extends object, TReturns = void> = GeneratedDocument<TSpec, TOptions> & {
322
- /**
323
- * The returned value of the generator function.
324
- */
325
- returns?: TReturns;
326
- };
327
- type ExtractedExecutionSource<TSpec, TOptions extends object> = Omit<ExecutionSource<TSpec, TOptions>, "meta"> & {
328
- /**
329
- * The extracted metadata of the execution.
330
- */
331
- meta: InferExtractedMeta<ExecutionSource<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.
192
+ * The options used to generate the documents.
358
193
  */
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
- source?: DeepPartial<ExecutionSource<TSpec, TOptions>>[];
366
- };
367
- type GeneratorFunction<TSpec, TOptions extends object> = (spec: TSpec, options: TOptions) => MaybePromise<Record<string, GeneratedDocument<TSpec, TOptions>>>;
368
- type GeneratorFunctionResult<TSpec, TOptions extends object> = Awaited<ReturnType<GeneratorFunction<TSpec, TOptions>>>;
369
- interface GeneratorResult<TSpec, TOptions extends object, TReturns = void> {
370
- spec: TSpec;
371
194
  options: TOptions;
372
195
  /**
373
196
  * The documents generated by the generator.
@@ -386,7 +209,7 @@ interface GeneratorConfigObject<TSpec, TOptions extends object, TReturns = void>
386
209
  /**
387
210
  * The schema config that defines the structure of the specification object for this generator.
388
211
  */
389
- schema?: SchemaConfig<TSpec> | SchemaConfigObject<TSpec, TOptions>;
212
+ schema?: SchemaConfig<TSpec> | SchemaConfigObject<TSpec>;
390
213
  /**
391
214
  * The input config for the generator specification.
392
215
  */
@@ -410,7 +233,7 @@ interface Generator<TSpec, TOptions extends object, TReturns = void> {
410
233
  /**
411
234
  * The schema config that defines the structure of the specification object for this generator.
412
235
  */
413
- schema: SchemaOf<TSpec, TOptions>;
236
+ schema: SchemaOf<TSpec>;
414
237
  /**
415
238
  * 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.
416
239
  */
@@ -430,30 +253,31 @@ interface Generator<TSpec, TOptions extends object, TReturns = void> {
430
253
  */
431
254
  generator: (options: TOptions & UserConfig) => Promise<GeneratorResult<TSpec, TOptions, TReturns>>;
432
255
  }
256
+ type InferSchemaConfig<T extends GeneratorConfig<any, any, any>> = T extends LoadReference ? InferLoadOptions<T> : T extends GeneratorConfigObject<any, any, any> ? T["schema"] : never;
257
+ type InferGeneratorMeta<T extends GeneratorConfig<any, any, any>> = T extends LoadReference ? InferLoadOptions<T> : T extends GeneratorConfigObject<any, any, any> ? T["meta"] : never;
258
+ type InferInputConfig<T extends GeneratorConfig<any, any, any>> = T extends LoadReference ? InferLoadOptions<T> : T extends GeneratorConfigObject<any, any, any> ? T["input"] : never;
259
+ type InferOutputConfig<T extends GeneratorConfig<any, any, any>> = T extends LoadReference ? InferLoadOptions<T> : T extends GeneratorConfigObject<any, any, any> ? T["output"] : never;
260
+ type InferGeneratorFunction<T extends GeneratorConfig<any, any, any>> = T extends LoadReference ? InferLoadOptions<T> : T extends GeneratorConfigObject<any, any, any> ? T["generator"] : never;
261
+ type InferGeneratorResult<T extends GeneratorConfig<any, any, any>> = InferGeneratorFunction<T> extends GeneratorFunction<any, any> ? Awaited<ReturnType<InferGeneratorFunction<T>>> : never;
262
+ interface InferGenerator<T extends GeneratorConfig<any, any, any>> {
263
+ meta?: InferGeneratorMeta<T>;
264
+ schema: InferSchemaConfig<T>;
265
+ input: InferInputConfig<T>;
266
+ output: InferOutputConfig<T>;
267
+ generator: InferGeneratorFunction<T>;
268
+ }
433
269
  //#endregion
434
270
  //#region src/types/output.d.ts
435
271
  type OutputFunction<TSpec, TOptions extends object, TReturns = void> = (spec: TSpec, options: TOptions, documents: Record<string, GeneratedDocument<TSpec, TOptions>>) => MaybePromise<TReturns>;
436
- interface OutputMetaConfig<TSpec, TOptions extends object> extends MetaConfig<TSpec, TOptions> {
437
- /**
438
- * 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.
439
- */
440
- produces?: string;
441
- }
442
- interface OutputMeta<TSpec, TOptions extends object> extends Meta<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
272
  interface OutputConfigObject<TSpec, TOptions extends object, TReturns = void> {
449
273
  /**
450
274
  * 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.
451
275
  */
452
- schema?: SchemaConfig<TSpec> | SchemaConfigObject<TSpec, TOptions>;
276
+ schema?: SchemaConfig<TSpec> | SchemaConfigObject<TSpec>;
453
277
  /**
454
278
  * Optional metadata that provides contextual information for the output.
455
279
  */
456
- meta?: OutputMetaConfig<TSpec, TOptions>;
280
+ meta?: MetaConfig;
457
281
  /**
458
282
  * The output implementation, either as a callable function or a file reference.
459
283
  */
@@ -465,11 +289,11 @@ interface Output<TSpec, TOptions extends object, TReturns = void> {
465
289
  /**
466
290
  * 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.
467
291
  */
468
- schema: SchemaOf<TSpec, TOptions>;
292
+ schema: SchemaOf<TSpec>;
469
293
  /**
470
294
  * Optional metadata that provides contextual information for the output.
471
295
  */
472
- meta?: OutputMeta<TSpec, TOptions>;
296
+ meta?: MetaConfig;
473
297
  /**
474
298
  * 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.
475
299
  *
@@ -561,5 +385,5 @@ type UserConfigFnPromise<TSpec = any, TOptions extends object = any, TReturns =
561
385
  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>[]>;
562
386
  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>;
563
387
  //#endregion
564
- export { MetaDataPrimitive as $, ExtractedExecution as A, InferCreateSchemaOptions as B, GeneratorResult as C, ExecutionMeta as D, ExecutionDocument as E, InputConfig as F, SchemaMetaExample as G, SchemaConfigObject as H, InputConfigObject as I, InferExtractedMeta as J, SchemaOf as K, InputFunction as L, ExtractedExecutionSource as M, InferCreateInputOptions as N, ExecutionResult as O, Input as P, MetaData as Q, InputMeta as R, GeneratorMeta as S, Execution as T, SchemaMeta as U, Schema as V, SchemaMetaConfig as W, Meta as X, InferExtractedMetaDataRecord as Y, MetaConfig as Z, Generator as _, UserConfigFnPromise as a, GeneratorFunction as b, Settings as c, OutputConfig as d, MetaDataRecord as et, OutputConfigObject as f, GeneratedDocument as g, OutputMetaConfig as h, UserConfigFnObject as i, ExtractedExecutionDocument as j, ExecutionSource as k, InferCreateOutputOptions as l, OutputMeta as m, UserConfigExport as n, MetaLink as nt, UserConfigParams as o, OutputFunction as p, BaseMeta as q, UserConfigFn as r, MetaValue as rt, Logger as s, UserConfig as t, MetaDeprecated as tt, Output as u, GeneratorConfig as v, InferCreateGeneratorOptions as w, GeneratorFunctionResult as x, GeneratorConfigObject as y, InputMetaConfig as z };
565
- //# sourceMappingURL=config-DMItzxbk.d.mts.map
388
+ export { InferSchemaConfig as A, SchemaMetaConfig as B, InferCreateGeneratorOptions as C, InferGeneratorResult as D, InferGeneratorMeta as E, InputFunction as F, MetaDeprecated as G, SchemaOf as H, InputMetaConfig as I, MetaLink as K, InferCreateSchemaOptions as L, Input as M, InputConfig as N, InferInputConfig as O, InputConfigObject as P, Schema as R, GeneratorResult as S, InferGeneratorFunction as T, BaseMetaConfig as U, SchemaMetaExample as V, MetaConfig 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, InferCreateInputOptions as j, InferOutputConfig 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, InferGenerator as w, GeneratorMeta as x, GeneratorFunction as y, SchemaConfigObject as z };
389
+ //# sourceMappingURL=config-B_E87BPl.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-B_E87BPl.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-DMItzxbk.cjs";
1
+ import { a as UserConfigFnPromise, i as UserConfigFnObject, n as UserConfigExport, o as UserConfigParams, r as UserConfigFn, t as UserConfig } from "./config-B_E87BPl.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-DMItzxbk.mjs";
1
+ import { a as UserConfigFnPromise, i as UserConfigFnObject, n as UserConfigExport, o as UserConfigParams, r as UserConfigFn, t as UserConfig } from "./config-B_E87BPl.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.