@power-plant/core 0.0.93 → 0.0.95
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-DS1cj7j6.d.cts → config-CvXMgTtG.d.mts} +42 -4
- package/dist/config-CvXMgTtG.d.mts.map +1 -0
- package/dist/{config-ZvnnxGt9.d.mts → config-D9w8UWb1.d.cts} +42 -4
- package/dist/config-D9w8UWb1.d.cts.map +1 -0
- package/dist/config.d.cts +1 -1
- package/dist/config.d.mts +1 -1
- package/dist/{context-C3M0YsM_.d.cts → context-Dky8WN7n.d.mts} +3 -3
- package/dist/context-Dky8WN7n.d.mts.map +1 -0
- package/dist/{context-FIedZFci.d.mts → context-TUsikpbp.d.cts} +3 -3
- package/dist/{context-C3M0YsM_.d.cts.map → context-TUsikpbp.d.cts.map} +1 -1
- package/dist/context.d.cts +1 -1
- package/dist/context.d.mts +1 -1
- package/dist/define.cjs +36 -1
- package/dist/define.d.cts +33 -2
- package/dist/define.d.cts.map +1 -1
- package/dist/define.d.mts +33 -2
- package/dist/define.mjs +36 -2
- package/dist/{execute-C7wgqV2z.cjs → execute-Dg9Z7kc_.cjs} +57 -15
- package/dist/{execute-CMeb6o0g.mjs → execute-gLfQXb4N.mjs} +54 -12
- package/dist/execute-gLfQXb4N.mjs.map +1 -0
- package/dist/execute.cjs +2 -2
- package/dist/execute.d.cts +2 -2
- package/dist/execute.d.mts +2 -2
- package/dist/execute.mjs +1 -1
- package/dist/{execution-BaOcMIgV.d.mts → execution-54smWTBe.d.mts} +2 -2
- package/dist/execution-54smWTBe.d.mts.map +1 -0
- package/dist/{execution-vXX_IEkO.d.cts → execution-C8ndihYL.d.cts} +2 -2
- package/dist/{execution-vXX_IEkO.d.cts.map → execution-C8ndihYL.d.cts.map} +1 -1
- package/dist/helpers/index.cjs +3 -2
- package/dist/helpers/index.d.cts +2 -2
- package/dist/helpers/index.d.mts +2 -2
- package/dist/helpers/index.mjs +2 -2
- package/dist/helpers/meta.cjs +1 -1
- package/dist/helpers/meta.mjs +1 -1
- package/dist/helpers/type-checks.cjs +10 -0
- package/dist/helpers/type-checks.d.cts +10 -3
- package/dist/helpers/type-checks.d.cts.map +1 -1
- package/dist/helpers/type-checks.d.mts +10 -3
- package/dist/helpers/type-checks.mjs +10 -1
- package/dist/index-D1tOhzie.d.cts +3 -0
- package/dist/index-WL6lus3e.d.mts +3 -0
- package/dist/index.cjs +5 -4
- package/dist/index.d.cts +6 -6
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +3 -3
- package/package.json +18 -18
- package/dist/config-DS1cj7j6.d.cts.map +0 -1
- package/dist/config-ZvnnxGt9.d.mts.map +0 -1
- package/dist/context-FIedZFci.d.mts.map +0 -1
- package/dist/execute-CMeb6o0g.mjs.map +0 -1
- package/dist/execution-BaOcMIgV.d.mts.map +0 -1
- package/dist/index-BbAnTHxk.d.mts +0 -3
- package/dist/index-CXUTyD9L.d.cts +0 -3
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ The Power Plant monorepo is a collection of packages that are designed to work t
|
|
|
33
33
|
|
|
34
34
|
<h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
|
|
35
35
|
|
|
36
|
-
[](https://docs.stormsoftware.com/projects/power-plant) [](http://commitizen.github.io/cz-cli/)  
|
|
37
37
|
|
|
38
38
|
<!-- prettier-ignore-start -->
|
|
39
39
|
<!-- markdownlint-disable -->
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EnvPaths } from "@stryke/env/get-env-paths";
|
|
2
2
|
import { Storage } from "unstorage";
|
|
3
3
|
import { BaseExtractOptions, 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
7
|
type MetaDeprecated = true | string | {
|
|
8
8
|
message?: string;
|
|
@@ -164,6 +164,36 @@ interface Input<TSpec, TOptions extends object> {
|
|
|
164
164
|
input: TSpec | InputFunction<TSpec, TOptions>;
|
|
165
165
|
}
|
|
166
166
|
//#endregion
|
|
167
|
+
//#region src/types/formatter.d.ts
|
|
168
|
+
type FormatterFunction<TSpec, TOptions extends object> = (spec: TSpec, options: TOptions, documents: Record<string, GeneratedDocument>) => MaybePromise<Record<string, GeneratedDocument>>;
|
|
169
|
+
interface FormatterConfigObject<TSpec, TOptions extends object> {
|
|
170
|
+
/**
|
|
171
|
+
* Optional metadata that provides contextual information for the formatter.
|
|
172
|
+
*/
|
|
173
|
+
meta?: MetaConfig;
|
|
174
|
+
/**
|
|
175
|
+
* The formatter implementation, either as a callable function or a file reference.
|
|
176
|
+
*/
|
|
177
|
+
format: FormatterFunction<TSpec, TOptions> | LoadReference;
|
|
178
|
+
}
|
|
179
|
+
type FormatterConfig<TSpec, TOptions extends object> = LoadReference | FormatterFunction<TSpec, TOptions> | FormatterConfigObject<TSpec, TOptions>;
|
|
180
|
+
type InferCreateFormatterOptions<T extends FormatterConfig<any, any>> = (T extends LoadReference ? InferLoadOptions<T> : {}) & BaseExtractOptions;
|
|
181
|
+
interface Formatter<TSpec, TOptions extends object> {
|
|
182
|
+
/**
|
|
183
|
+
* Optional metadata that provides contextual information for the formatter.
|
|
184
|
+
*/
|
|
185
|
+
meta?: MetaConfig;
|
|
186
|
+
/**
|
|
187
|
+
* The formatter function, which receives the documents produced by the generator and returns the formatted documents that will be passed to the output.
|
|
188
|
+
*
|
|
189
|
+
* @param spec - The specification object used to generate the documents.
|
|
190
|
+
* @param options - The options used to generate the documents.
|
|
191
|
+
* @param documents - The generated documents to format.
|
|
192
|
+
* @returns The formatted documents.
|
|
193
|
+
*/
|
|
194
|
+
format: FormatterFunction<TSpec, TOptions>;
|
|
195
|
+
}
|
|
196
|
+
//#endregion
|
|
167
197
|
//#region src/types/generator.d.ts
|
|
168
198
|
interface GeneratedDocumentChunk {
|
|
169
199
|
content?: string;
|
|
@@ -212,6 +242,10 @@ interface GeneratorConfigObject<TSpec, TOptions extends object, TReturns = void>
|
|
|
212
242
|
* The output config that consumes generated output.
|
|
213
243
|
*/
|
|
214
244
|
output?: OutputConfig<TSpec, TOptions, TReturns>;
|
|
245
|
+
/**
|
|
246
|
+
* The formatter config(s) applied, in order, to the generated documents before they are passed to the output.
|
|
247
|
+
*/
|
|
248
|
+
format?: FormatterConfig<TSpec, TOptions> | FormatterConfig<TSpec, TOptions>[];
|
|
215
249
|
/**
|
|
216
250
|
* The generate implementation, either as a callable function or a file reference.
|
|
217
251
|
*/
|
|
@@ -236,6 +270,10 @@ interface Generator<TSpec, TOptions extends object, TReturns = void> {
|
|
|
236
270
|
* 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.
|
|
237
271
|
*/
|
|
238
272
|
output: Output<TSpec, TOptions, TReturns>;
|
|
273
|
+
/**
|
|
274
|
+
* The formatters applied, in order, to the generated documents before they are passed to the output.
|
|
275
|
+
*/
|
|
276
|
+
formatters: Formatter<TSpec, TOptions>[];
|
|
239
277
|
/**
|
|
240
278
|
* The generator function that executes the generator logic, taking in options and producing output based on the input and output definitions.
|
|
241
279
|
*
|
|
@@ -386,5 +424,5 @@ type UserConfigFnPromise<TSpec = any, TOptions extends object = any, TReturns =
|
|
|
386
424
|
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>[]>;
|
|
387
425
|
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>;
|
|
388
426
|
//#endregion
|
|
389
|
-
export {
|
|
390
|
-
//# sourceMappingURL=config-
|
|
427
|
+
export { Formatter as A, InputMetaConfig as B, InferGenerator as C, InferMeta as D, InferInputConfig as E, InferCreateInputOptions as F, SchemaMetaExample as G, Schema as H, Input as I, MetaConfig as J, SchemaOf as K, InputConfig as L, FormatterConfigObject as M, FormatterFunction as N, InferOutputConfig as O, InferCreateFormatterOptions as P, InputConfigObject as R, InferCreateGeneratorOptions as S, InferGeneratorResult as T, SchemaConfigObject as U, InferCreateSchemaOptions as V, SchemaMetaConfig as W, MetaLink as X, MetaDeprecated as Y, 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, FormatterConfig as j, InferSchemaConfig as k, InferCreateOutputOptions as l, GeneratedDocument as m, UserConfigExport as n, UserConfigParams as o, OutputFunction as p, BaseMetaConfig as q, UserConfigFn as r, Logger as s, UserConfig as t, Output as u, GeneratorConfigObject as v, InferGeneratorFunction as w, GeneratorResult as x, GeneratorFunction as y, InputFunction as z };
|
|
428
|
+
//# sourceMappingURL=config-CvXMgTtG.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-CvXMgTtG.d.mts","names":[],"sources":["../src/types/meta.ts","../src/types/schema.ts","../src/types/input.ts","../src/types/formatter.ts","../src/types/generator.ts","../src/types/output.ts","../src/types/settings.ts","../src/types/config.ts"],"mappings":""}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DeepPartial, MaybePromise } from "@stryke/types/base";
|
|
2
2
|
import { Storage } from "unstorage";
|
|
3
3
|
import { BaseExtractOptions, InferExtractOptions, SchemaConfig, SchemaEnvelopeOf, SchemaSourceConfig } from "@power-plant/schema";
|
|
4
|
-
import { DeepPartial, MaybePromise } from "@stryke/types/base";
|
|
5
4
|
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
7
|
type MetaDeprecated = true | string | {
|
|
8
8
|
message?: string;
|
|
@@ -164,6 +164,36 @@ interface Input<TSpec, TOptions extends object> {
|
|
|
164
164
|
input: TSpec | InputFunction<TSpec, TOptions>;
|
|
165
165
|
}
|
|
166
166
|
//#endregion
|
|
167
|
+
//#region src/types/formatter.d.ts
|
|
168
|
+
type FormatterFunction<TSpec, TOptions extends object> = (spec: TSpec, options: TOptions, documents: Record<string, GeneratedDocument>) => MaybePromise<Record<string, GeneratedDocument>>;
|
|
169
|
+
interface FormatterConfigObject<TSpec, TOptions extends object> {
|
|
170
|
+
/**
|
|
171
|
+
* Optional metadata that provides contextual information for the formatter.
|
|
172
|
+
*/
|
|
173
|
+
meta?: MetaConfig;
|
|
174
|
+
/**
|
|
175
|
+
* The formatter implementation, either as a callable function or a file reference.
|
|
176
|
+
*/
|
|
177
|
+
format: FormatterFunction<TSpec, TOptions> | LoadReference;
|
|
178
|
+
}
|
|
179
|
+
type FormatterConfig<TSpec, TOptions extends object> = LoadReference | FormatterFunction<TSpec, TOptions> | FormatterConfigObject<TSpec, TOptions>;
|
|
180
|
+
type InferCreateFormatterOptions<T extends FormatterConfig<any, any>> = (T extends LoadReference ? InferLoadOptions<T> : {}) & BaseExtractOptions;
|
|
181
|
+
interface Formatter<TSpec, TOptions extends object> {
|
|
182
|
+
/**
|
|
183
|
+
* Optional metadata that provides contextual information for the formatter.
|
|
184
|
+
*/
|
|
185
|
+
meta?: MetaConfig;
|
|
186
|
+
/**
|
|
187
|
+
* The formatter function, which receives the documents produced by the generator and returns the formatted documents that will be passed to the output.
|
|
188
|
+
*
|
|
189
|
+
* @param spec - The specification object used to generate the documents.
|
|
190
|
+
* @param options - The options used to generate the documents.
|
|
191
|
+
* @param documents - The generated documents to format.
|
|
192
|
+
* @returns The formatted documents.
|
|
193
|
+
*/
|
|
194
|
+
format: FormatterFunction<TSpec, TOptions>;
|
|
195
|
+
}
|
|
196
|
+
//#endregion
|
|
167
197
|
//#region src/types/generator.d.ts
|
|
168
198
|
interface GeneratedDocumentChunk {
|
|
169
199
|
content?: string;
|
|
@@ -212,6 +242,10 @@ interface GeneratorConfigObject<TSpec, TOptions extends object, TReturns = void>
|
|
|
212
242
|
* The output config that consumes generated output.
|
|
213
243
|
*/
|
|
214
244
|
output?: OutputConfig<TSpec, TOptions, TReturns>;
|
|
245
|
+
/**
|
|
246
|
+
* The formatter config(s) applied, in order, to the generated documents before they are passed to the output.
|
|
247
|
+
*/
|
|
248
|
+
format?: FormatterConfig<TSpec, TOptions> | FormatterConfig<TSpec, TOptions>[];
|
|
215
249
|
/**
|
|
216
250
|
* The generate implementation, either as a callable function or a file reference.
|
|
217
251
|
*/
|
|
@@ -236,6 +270,10 @@ interface Generator<TSpec, TOptions extends object, TReturns = void> {
|
|
|
236
270
|
* 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.
|
|
237
271
|
*/
|
|
238
272
|
output: Output<TSpec, TOptions, TReturns>;
|
|
273
|
+
/**
|
|
274
|
+
* The formatters applied, in order, to the generated documents before they are passed to the output.
|
|
275
|
+
*/
|
|
276
|
+
formatters: Formatter<TSpec, TOptions>[];
|
|
239
277
|
/**
|
|
240
278
|
* The generator function that executes the generator logic, taking in options and producing output based on the input and output definitions.
|
|
241
279
|
*
|
|
@@ -386,5 +424,5 @@ type UserConfigFnPromise<TSpec = any, TOptions extends object = any, TReturns =
|
|
|
386
424
|
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>[]>;
|
|
387
425
|
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>;
|
|
388
426
|
//#endregion
|
|
389
|
-
export {
|
|
390
|
-
//# sourceMappingURL=config-
|
|
427
|
+
export { Formatter as A, InputMetaConfig as B, InferGenerator as C, InferMeta as D, InferInputConfig as E, InferCreateInputOptions as F, SchemaMetaExample as G, Schema as H, Input as I, MetaConfig as J, SchemaOf as K, InputConfig as L, FormatterConfigObject as M, FormatterFunction as N, InferOutputConfig as O, InferCreateFormatterOptions as P, InputConfigObject as R, InferCreateGeneratorOptions as S, InferGeneratorResult as T, SchemaConfigObject as U, InferCreateSchemaOptions as V, SchemaMetaConfig as W, MetaLink as X, MetaDeprecated as Y, 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, FormatterConfig as j, InferSchemaConfig as k, InferCreateOutputOptions as l, GeneratedDocument as m, UserConfigExport as n, UserConfigParams as o, OutputFunction as p, BaseMetaConfig as q, UserConfigFn as r, Logger as s, UserConfig as t, Output as u, GeneratorConfigObject as v, InferGeneratorFunction as w, GeneratorResult as x, GeneratorFunction as y, InputFunction as z };
|
|
428
|
+
//# sourceMappingURL=config-D9w8UWb1.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-D9w8UWb1.d.cts","names":[],"sources":["../src/types/meta.ts","../src/types/schema.ts","../src/types/input.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,OAAO,UAAU;KACrB,oBACV,aACA,+BACA,mBAEA,QAAQ,qBACL,QACD,WAAW,OAAO,UAAU,YAC5B,WAAW,OAAO,UAAU;KAEpB,aACV,aACA,+BACA,mBAEA,QAAQ,qBAEN,WAAW,OAAO,UAAU,YAC5B,WAAW,OAAO,UAAU,cAC5B,QACI,WAAW,OAAO,UAAU,YAC5B,WAAW,OAAO,UAAU;KAExB,iBACV,aACA,+BACA,kBAEE,WAAW,OAAO,UAAU,YAC5B,WAAW,OAAO,UAAU,cAC5B,QACI,WAAW,OAAO,UAAU,YAC5B,WAAW,OAAO,UAAU,eAEhC,mBAAmB,OAAO,UAAU,YACpC,oBAAoB,OAAO,UAAU,YACrC,aAAa,OAAO,UAAU"}
|
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-D9w8UWb1.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-CvXMgTtG.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.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as Execution } from "./execution-
|
|
1
|
+
import { I as Input, K as SchemaOf, c as Settings, m as GeneratedDocument, s as Logger, u as Output } from "./config-CvXMgTtG.mjs";
|
|
2
|
+
import { n as Execution } from "./execution-54smWTBe.mjs";
|
|
3
3
|
import { Storage } from "unstorage";
|
|
4
4
|
//#region src/types/base.d.ts
|
|
5
5
|
interface Base {
|
|
@@ -104,4 +104,4 @@ interface LocalStore {
|
|
|
104
104
|
}
|
|
105
105
|
//#endregion
|
|
106
106
|
export { Session as a, SessionContext as i, ExecutionContext as n, Base as o, LocalStore as r, Context as t };
|
|
107
|
-
//# sourceMappingURL=context-
|
|
107
|
+
//# sourceMappingURL=context-Dky8WN7n.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-Dky8WN7n.d.mts","names":[],"sources":["../src/types/base.ts","../src/types/session.ts","../src/types/context.ts"],"mappings":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as Execution } from "./execution-
|
|
1
|
+
import { I as Input, K as SchemaOf, c as Settings, m as GeneratedDocument, s as Logger, u as Output } from "./config-D9w8UWb1.cjs";
|
|
2
|
+
import { n as Execution } from "./execution-C8ndihYL.cjs";
|
|
3
3
|
import { Storage } from "unstorage";
|
|
4
4
|
//#region src/types/base.d.ts
|
|
5
5
|
interface Base {
|
|
@@ -104,4 +104,4 @@ interface LocalStore {
|
|
|
104
104
|
}
|
|
105
105
|
//#endregion
|
|
106
106
|
export { Session as a, SessionContext as i, ExecutionContext as n, Base as o, LocalStore as r, Context as t };
|
|
107
|
-
//# sourceMappingURL=context-
|
|
107
|
+
//# sourceMappingURL=context-TUsikpbp.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-
|
|
1
|
+
{"version":3,"file":"context-TUsikpbp.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;;UAGe,uBAAuB;;;;EAItC,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"}
|
package/dist/context.d.cts
CHANGED
package/dist/context.d.mts
CHANGED
package/dist/define.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_helpers_type_checks = require(
|
|
2
|
+
const require_helpers_type_checks = require("./helpers/type-checks.cjs");
|
|
3
3
|
|
|
4
4
|
//#region src/define.ts
|
|
5
5
|
/**
|
|
@@ -70,6 +70,40 @@ function defineOutput(output) {
|
|
|
70
70
|
return { output };
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
|
+
* Defines a formatter configuration object. If the provided format is already a formatter configuration object, it will be returned as-is. Otherwise, it will be wrapped in an object with a `format` property.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* import { defineFormatter } from "@power-plant/core";
|
|
78
|
+
*
|
|
79
|
+
* // Define a formatter from a formatter function
|
|
80
|
+
* export default defineFormatter((spec, options, documents) => {
|
|
81
|
+
* // Your formatting logic here
|
|
82
|
+
* return documents;
|
|
83
|
+
* });
|
|
84
|
+
*
|
|
85
|
+
* // Define a formatter from an existing formatter configuration object
|
|
86
|
+
* export default defineFormatter({
|
|
87
|
+
* meta: {
|
|
88
|
+
* name: "My Formatter",
|
|
89
|
+
* version: "1.0.0",
|
|
90
|
+
* description: "A formatter that does something.",
|
|
91
|
+
* },
|
|
92
|
+
* format: (spec, options, documents) => {
|
|
93
|
+
* // Your formatting logic here
|
|
94
|
+
* return documents;
|
|
95
|
+
* },
|
|
96
|
+
* });
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* @param format - The formatter configuration to define. This can be either a formatter configuration object or a formatter function.
|
|
100
|
+
* @returns A formatter configuration object that contains the provided formatter. If the input was already a formatter configuration object, it will be returned unchanged.
|
|
101
|
+
*/
|
|
102
|
+
function defineFormatter(format) {
|
|
103
|
+
if (require_helpers_type_checks.isFormatterConfigObject(format)) return format;
|
|
104
|
+
return { format };
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
73
107
|
* Defines a schema configuration object. If the provided schema is already a schema configuration object, it will be returned as-is. Otherwise, it will be wrapped in an object with a `schema` property.
|
|
74
108
|
*
|
|
75
109
|
* @param schema - The schema configuration to define. This can be either a schema source configuration, a schema envelope, or a schema configuration object.
|
|
@@ -91,6 +125,7 @@ function defineGenerator(generator) {
|
|
|
91
125
|
}
|
|
92
126
|
|
|
93
127
|
//#endregion
|
|
128
|
+
exports.defineFormatter = defineFormatter;
|
|
94
129
|
exports.defineGenerator = defineGenerator;
|
|
95
130
|
exports.defineInput = defineInput;
|
|
96
131
|
exports.defineOutput = defineOutput;
|
package/dist/define.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { L as InputConfig, M as FormatterConfigObject, R as InputConfigObject, U as SchemaConfigObject, d as OutputConfig, f as OutputConfigObject, j as FormatterConfig, v as GeneratorConfigObject } from "./config-D9w8UWb1.cjs";
|
|
2
2
|
import { SchemaEnvelopeOf, SchemaSourceConfig } from "@power-plant/schema";
|
|
3
3
|
//#region src/define.d.ts
|
|
4
4
|
/**
|
|
@@ -62,6 +62,37 @@ declare function defineInput<TSpec, TOptions extends object>(input: InputConfig<
|
|
|
62
62
|
* @returns A output configuration object that contains the provided output. If the input was already a output configuration object, it will be returned unchanged.
|
|
63
63
|
*/
|
|
64
64
|
declare function defineOutput<TSpec, TOptions extends object, TReturns = void>(output: OutputConfig<TSpec, TOptions, TReturns>): OutputConfigObject<TSpec, TOptions, TReturns>;
|
|
65
|
+
/**
|
|
66
|
+
* Defines a formatter configuration object. If the provided format is already a formatter configuration object, it will be returned as-is. Otherwise, it will be wrapped in an object with a `format` property.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* import { defineFormatter } from "@power-plant/core";
|
|
71
|
+
*
|
|
72
|
+
* // Define a formatter from a formatter function
|
|
73
|
+
* export default defineFormatter((spec, options, documents) => {
|
|
74
|
+
* // Your formatting logic here
|
|
75
|
+
* return documents;
|
|
76
|
+
* });
|
|
77
|
+
*
|
|
78
|
+
* // Define a formatter from an existing formatter configuration object
|
|
79
|
+
* export default defineFormatter({
|
|
80
|
+
* meta: {
|
|
81
|
+
* name: "My Formatter",
|
|
82
|
+
* version: "1.0.0",
|
|
83
|
+
* description: "A formatter that does something.",
|
|
84
|
+
* },
|
|
85
|
+
* format: (spec, options, documents) => {
|
|
86
|
+
* // Your formatting logic here
|
|
87
|
+
* return documents;
|
|
88
|
+
* },
|
|
89
|
+
* });
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* @param format - The formatter configuration to define. This can be either a formatter configuration object or a formatter function.
|
|
93
|
+
* @returns A formatter configuration object that contains the provided formatter. If the input was already a formatter configuration object, it will be returned unchanged.
|
|
94
|
+
*/
|
|
95
|
+
declare function defineFormatter<TSpec, TOptions extends object>(format: FormatterConfig<TSpec, TOptions>): FormatterConfigObject<TSpec, TOptions>;
|
|
65
96
|
/**
|
|
66
97
|
* Defines a schema configuration object. If the provided schema is already a schema configuration object, it will be returned as-is. Otherwise, it will be wrapped in an object with a `schema` property.
|
|
67
98
|
*
|
|
@@ -77,5 +108,5 @@ declare function defineSchema<TSpec>(schema: SchemaSourceConfig<TSpec> | SchemaE
|
|
|
77
108
|
*/
|
|
78
109
|
declare function defineGenerator<TSpec, TOptions extends object, TReturns = void>(generator: GeneratorConfigObject<TSpec, TOptions, TReturns>): GeneratorConfigObject<TSpec, TOptions, TReturns>;
|
|
79
110
|
//#endregion
|
|
80
|
-
export { defineGenerator, defineInput, defineOutput, defineSchema };
|
|
111
|
+
export { defineFormatter, defineGenerator, defineInput, defineOutput, defineSchema };
|
|
81
112
|
//# sourceMappingURL=define.d.cts.map
|
package/dist/define.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define.d.cts","names":[],"sources":["../src/define.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"define.d.cts","names":[],"sources":["../src/define.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+DgB,YAAY,OAAO,yBACjC,OAAO,YAAY,OAAO,YACzB,kBAAkB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoCZ,aAAa,OAAO,yBAAyB,iBAC3D,QAAQ,aAAa,OAAO,UAAU,YACrC,mBAAmB,OAAO,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsCvB,gBAAgB,OAAO,yBACrC,QAAQ,gBAAgB,OAAO,YAC9B,sBAAsB,OAAO;;;;;;;iBAchB,aAAa,OAC3B,QACI,mBAAmB,SACnB,iBAAiB,SACjB,mBAAmB,SACtB,mBAAmB;;;;;;;iBAcN,gBACd,OACA,yBACA,iBAEA,WAAW,sBAAsB,OAAO,UAAU,YACjD,sBAAsB,OAAO,UAAU"}
|
package/dist/define.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { L as InputConfig, M as FormatterConfigObject, R as InputConfigObject, U as SchemaConfigObject, d as OutputConfig, f as OutputConfigObject, j as FormatterConfig, v as GeneratorConfigObject } from "./config-CvXMgTtG.mjs";
|
|
2
2
|
import { SchemaEnvelopeOf, SchemaSourceConfig } from "@power-plant/schema";
|
|
3
3
|
//#region src/define.d.ts
|
|
4
4
|
/**
|
|
@@ -62,6 +62,37 @@ declare function defineInput<TSpec, TOptions extends object>(input: InputConfig<
|
|
|
62
62
|
* @returns A output configuration object that contains the provided output. If the input was already a output configuration object, it will be returned unchanged.
|
|
63
63
|
*/
|
|
64
64
|
declare function defineOutput<TSpec, TOptions extends object, TReturns = void>(output: OutputConfig<TSpec, TOptions, TReturns>): OutputConfigObject<TSpec, TOptions, TReturns>;
|
|
65
|
+
/**
|
|
66
|
+
* Defines a formatter configuration object. If the provided format is already a formatter configuration object, it will be returned as-is. Otherwise, it will be wrapped in an object with a `format` property.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* import { defineFormatter } from "@power-plant/core";
|
|
71
|
+
*
|
|
72
|
+
* // Define a formatter from a formatter function
|
|
73
|
+
* export default defineFormatter((spec, options, documents) => {
|
|
74
|
+
* // Your formatting logic here
|
|
75
|
+
* return documents;
|
|
76
|
+
* });
|
|
77
|
+
*
|
|
78
|
+
* // Define a formatter from an existing formatter configuration object
|
|
79
|
+
* export default defineFormatter({
|
|
80
|
+
* meta: {
|
|
81
|
+
* name: "My Formatter",
|
|
82
|
+
* version: "1.0.0",
|
|
83
|
+
* description: "A formatter that does something.",
|
|
84
|
+
* },
|
|
85
|
+
* format: (spec, options, documents) => {
|
|
86
|
+
* // Your formatting logic here
|
|
87
|
+
* return documents;
|
|
88
|
+
* },
|
|
89
|
+
* });
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* @param format - The formatter configuration to define. This can be either a formatter configuration object or a formatter function.
|
|
93
|
+
* @returns A formatter configuration object that contains the provided formatter. If the input was already a formatter configuration object, it will be returned unchanged.
|
|
94
|
+
*/
|
|
95
|
+
declare function defineFormatter<TSpec, TOptions extends object>(format: FormatterConfig<TSpec, TOptions>): FormatterConfigObject<TSpec, TOptions>;
|
|
65
96
|
/**
|
|
66
97
|
* Defines a schema configuration object. If the provided schema is already a schema configuration object, it will be returned as-is. Otherwise, it will be wrapped in an object with a `schema` property.
|
|
67
98
|
*
|
|
@@ -77,5 +108,5 @@ declare function defineSchema<TSpec>(schema: SchemaSourceConfig<TSpec> | SchemaE
|
|
|
77
108
|
*/
|
|
78
109
|
declare function defineGenerator<TSpec, TOptions extends object, TReturns = void>(generator: GeneratorConfigObject<TSpec, TOptions, TReturns>): GeneratorConfigObject<TSpec, TOptions, TReturns>;
|
|
79
110
|
//#endregion
|
|
80
|
-
export { defineGenerator, defineInput, defineOutput, defineSchema };
|
|
111
|
+
export { defineFormatter, defineGenerator, defineInput, defineOutput, defineSchema };
|
|
81
112
|
//# sourceMappingURL=define.d.mts.map
|
package/dist/define.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isGeneratorConfigObject, isInputConfigObject, isOutputConfigObject, isSchemaConfigObject } from "./helpers/type-checks.mjs";
|
|
1
|
+
import { isFormatterConfigObject, isGeneratorConfigObject, isInputConfigObject, isOutputConfigObject, isSchemaConfigObject } from "./helpers/type-checks.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/define.ts
|
|
4
4
|
/**
|
|
@@ -69,6 +69,40 @@ function defineOutput(output) {
|
|
|
69
69
|
return { output };
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
|
+
* Defines a formatter configuration object. If the provided format is already a formatter configuration object, it will be returned as-is. Otherwise, it will be wrapped in an object with a `format` property.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* import { defineFormatter } from "@power-plant/core";
|
|
77
|
+
*
|
|
78
|
+
* // Define a formatter from a formatter function
|
|
79
|
+
* export default defineFormatter((spec, options, documents) => {
|
|
80
|
+
* // Your formatting logic here
|
|
81
|
+
* return documents;
|
|
82
|
+
* });
|
|
83
|
+
*
|
|
84
|
+
* // Define a formatter from an existing formatter configuration object
|
|
85
|
+
* export default defineFormatter({
|
|
86
|
+
* meta: {
|
|
87
|
+
* name: "My Formatter",
|
|
88
|
+
* version: "1.0.0",
|
|
89
|
+
* description: "A formatter that does something.",
|
|
90
|
+
* },
|
|
91
|
+
* format: (spec, options, documents) => {
|
|
92
|
+
* // Your formatting logic here
|
|
93
|
+
* return documents;
|
|
94
|
+
* },
|
|
95
|
+
* });
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @param format - The formatter configuration to define. This can be either a formatter configuration object or a formatter function.
|
|
99
|
+
* @returns A formatter configuration object that contains the provided formatter. If the input was already a formatter configuration object, it will be returned unchanged.
|
|
100
|
+
*/
|
|
101
|
+
function defineFormatter(format) {
|
|
102
|
+
if (isFormatterConfigObject(format)) return format;
|
|
103
|
+
return { format };
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
72
106
|
* Defines a schema configuration object. If the provided schema is already a schema configuration object, it will be returned as-is. Otherwise, it will be wrapped in an object with a `schema` property.
|
|
73
107
|
*
|
|
74
108
|
* @param schema - The schema configuration to define. This can be either a schema source configuration, a schema envelope, or a schema configuration object.
|
|
@@ -90,5 +124,5 @@ function defineGenerator(generator) {
|
|
|
90
124
|
}
|
|
91
125
|
|
|
92
126
|
//#endregion
|
|
93
|
-
export { defineGenerator, defineInput, defineOutput, defineSchema };
|
|
127
|
+
export { defineFormatter, defineGenerator, defineInput, defineOutput, defineSchema };
|
|
94
128
|
//# sourceMappingURL=define.mjs.map
|
|
@@ -25,9 +25,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
}) : target, mod));
|
|
26
26
|
|
|
27
27
|
//#endregion
|
|
28
|
-
const require_context = require(
|
|
29
|
-
const require_helpers_type_checks = require(
|
|
30
|
-
const require_helpers_meta = require(
|
|
28
|
+
const require_context = require("./context.cjs");
|
|
29
|
+
const require_helpers_type_checks = require("./helpers/type-checks.cjs");
|
|
30
|
+
const require_helpers_meta = require("./helpers/meta.cjs");
|
|
31
31
|
let _stryke_unique_id_uuid = require("@stryke/unique-id/uuid");
|
|
32
32
|
let _stryke_env_get_env_paths = require("@stryke/env/get-env-paths");
|
|
33
33
|
let _stryke_fs_read_file = require("@stryke/fs/read-file");
|
|
@@ -44,10 +44,11 @@ unstorage_drivers_fs_lite = __toESM(unstorage_drivers_fs_lite, 1);
|
|
|
44
44
|
let unstorage_drivers_memory = require("unstorage/drivers/memory");
|
|
45
45
|
unstorage_drivers_memory = __toESM(unstorage_drivers_memory, 1);
|
|
46
46
|
let _power_plant_schema_storage = require("@power-plant/schema/storage");
|
|
47
|
+
let _stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
47
48
|
let _stryke_resolve_load = require("@stryke/resolve/load");
|
|
48
49
|
let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
49
|
-
let _power_plant_schema = require("@power-plant/schema");
|
|
50
50
|
let _stryke_resolve_type_checks = require("@stryke/resolve/type-checks");
|
|
51
|
+
let _power_plant_schema = require("@power-plant/schema");
|
|
51
52
|
|
|
52
53
|
//#region src/lib/context.ts
|
|
53
54
|
const logger = {
|
|
@@ -163,6 +164,37 @@ async function extractExecution(execution, _spec, _options) {
|
|
|
163
164
|
return execution;
|
|
164
165
|
}
|
|
165
166
|
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/lib/formatter.ts
|
|
169
|
+
/**
|
|
170
|
+
* Normalizes any accepted formatter config into a concrete formatter descriptor.
|
|
171
|
+
*
|
|
172
|
+
* @param config - The formatter config to normalize.
|
|
173
|
+
* @param options - Optional options for resolving the formatter config.
|
|
174
|
+
* @returns A promise that resolves to a normalized formatter descriptor.
|
|
175
|
+
*/
|
|
176
|
+
async function createFormatter(config, options = {}) {
|
|
177
|
+
const { format, meta } = require_helpers_type_checks.isFormatterConfigObject(config) ? config : {
|
|
178
|
+
format: config,
|
|
179
|
+
meta: void 0
|
|
180
|
+
};
|
|
181
|
+
let resolvedFormatter;
|
|
182
|
+
let resolvedMeta = meta;
|
|
183
|
+
if ((0, _stryke_resolve_type_checks.isLoadReference)(format)) try {
|
|
184
|
+
const loaded = await (0, _stryke_resolve_load.load)(format, options);
|
|
185
|
+
if (require_helpers_type_checks.isFormatterConfigObject(loaded)) {
|
|
186
|
+
const created = await createFormatter(loaded, options);
|
|
187
|
+
resolvedFormatter = created.format;
|
|
188
|
+
resolvedMeta ??= created.meta;
|
|
189
|
+
} else resolvedFormatter = loaded;
|
|
190
|
+
} catch {}
|
|
191
|
+
if (!resolvedFormatter) resolvedFormatter = format;
|
|
192
|
+
return {
|
|
193
|
+
format: resolvedFormatter,
|
|
194
|
+
meta: resolvedMeta
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
166
198
|
//#endregion
|
|
167
199
|
//#region src/lib/schema.ts
|
|
168
200
|
/**
|
|
@@ -353,13 +385,20 @@ async function createGenerator(executionId, sessionContext, config, options = {}
|
|
|
353
385
|
}
|
|
354
386
|
let outputConfig = configObject.output;
|
|
355
387
|
if (!outputConfig) outputConfig = "@power-plant/unstorage-output";
|
|
356
|
-
const [input, output] = await Promise.all([
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
388
|
+
const [input, output, ...formatters] = await Promise.all([
|
|
389
|
+
createInput(schema, inputConfig, {
|
|
390
|
+
storage: sessionContext.storage,
|
|
391
|
+
...options
|
|
392
|
+
}),
|
|
393
|
+
createOutput(schema, outputConfig, {
|
|
394
|
+
storage: sessionContext.storage,
|
|
395
|
+
...options
|
|
396
|
+
}),
|
|
397
|
+
...(0, _stryke_convert_to_array.toArray)(configObject.format ?? []).map(async (formatterConfig) => createFormatter(formatterConfig, {
|
|
398
|
+
storage: sessionContext.storage,
|
|
399
|
+
...options
|
|
400
|
+
}))
|
|
401
|
+
]);
|
|
363
402
|
assertGeneratorConfigSchemasDoNotContradict(schema, input, output);
|
|
364
403
|
const generator = async (options) => {
|
|
365
404
|
const context = await createExecutionContext(executionId, sessionContext, options, schema, input, output);
|
|
@@ -375,12 +414,14 @@ async function createGenerator(executionId, sessionContext, config, options = {}
|
|
|
375
414
|
storage: context.storage,
|
|
376
415
|
...options
|
|
377
416
|
});
|
|
378
|
-
|
|
417
|
+
let documents = await generatorFn(spec, options);
|
|
418
|
+
for (const formatter of formatters) documents = await formatter.format(spec, options, documents);
|
|
419
|
+
const returns = await output.output(spec, options, documents);
|
|
379
420
|
return {
|
|
380
421
|
spec,
|
|
381
422
|
options,
|
|
382
423
|
documents,
|
|
383
|
-
returns
|
|
424
|
+
returns
|
|
384
425
|
};
|
|
385
426
|
});
|
|
386
427
|
};
|
|
@@ -389,6 +430,7 @@ async function createGenerator(executionId, sessionContext, config, options = {}
|
|
|
389
430
|
schema,
|
|
390
431
|
input,
|
|
391
432
|
output,
|
|
433
|
+
formatters,
|
|
392
434
|
generator
|
|
393
435
|
};
|
|
394
436
|
}
|
|
@@ -502,13 +544,13 @@ async function execute(config, options = {}) {
|
|
|
502
544
|
}
|
|
503
545
|
|
|
504
546
|
//#endregion
|
|
505
|
-
Object.defineProperty(exports,
|
|
547
|
+
Object.defineProperty(exports, "createExecute", {
|
|
506
548
|
enumerable: true,
|
|
507
549
|
get: function () {
|
|
508
550
|
return createExecute;
|
|
509
551
|
}
|
|
510
552
|
});
|
|
511
|
-
Object.defineProperty(exports,
|
|
553
|
+
Object.defineProperty(exports, "execute", {
|
|
512
554
|
enumerable: true,
|
|
513
555
|
get: function () {
|
|
514
556
|
return execute;
|