@power-plant/core 0.0.16 → 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-B_E87BPl.d.cts → config-BpNybJZY.d.cts} +9 -15
- package/dist/config-BpNybJZY.d.cts.map +1 -0
- package/dist/{config-B_E87BPl.d.mts → config-C9Hp8wTC.d.mts} +11 -17
- package/dist/{config-B_E87BPl.d.mts.map → config-C9Hp8wTC.d.mts.map} +1 -1
- 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.d.cts +1 -1
- package/dist/context.d.mts +1 -1
- package/dist/define.cjs +1 -1
- package/dist/define.d.cts +1 -1
- package/dist/define.d.mts +1 -1
- 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-BYCnzjxr.d.cts → helpers/type-checks.d.cts} +5 -5
- package/dist/helpers/type-checks.d.cts.map +1 -0
- package/dist/{type-checks-C-wRp-HW.d.mts → helpers/type-checks.d.mts} +5 -5
- 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 +6 -4
- package/dist/index.d.mts +6 -4
- 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 +58 -19
- package/dist/config-B_E87BPl.d.cts.map +0 -1
- package/dist/context-BCW5TgL-.d.mts +0 -183
- package/dist/context-BCW5TgL-.d.mts.map +0 -1
- package/dist/context-C0n9Tore.d.cts +0 -183
- package/dist/context-C0n9Tore.d.cts.map +0 -1
- package/dist/type-checks-BYCnzjxr.d.cts.map +0 -1
- package/dist/type-checks-C-wRp-HW.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
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 -->
|
|
@@ -165,23 +165,17 @@ interface Input<TSpec, TOptions extends object> {
|
|
|
165
165
|
}
|
|
166
166
|
//#endregion
|
|
167
167
|
//#region src/types/generator.d.ts
|
|
168
|
-
type GeneratorMeta<TSpec, TOptions extends object> = MetaConfig & {
|
|
169
|
-
/**
|
|
170
|
-
* A string description outlining the purpose or behavior of the generator.
|
|
171
|
-
*/
|
|
172
|
-
description?: string;
|
|
173
|
-
};
|
|
174
168
|
interface GeneratedDocumentChunk {
|
|
175
169
|
content?: string;
|
|
176
170
|
meta?: MetaConfig;
|
|
177
171
|
}
|
|
178
|
-
interface GeneratedDocument
|
|
172
|
+
interface GeneratedDocument {
|
|
179
173
|
path: string;
|
|
180
174
|
language?: string;
|
|
181
175
|
chunks?: DeepPartial<GeneratedDocumentChunk>[];
|
|
182
176
|
meta?: MetaConfig;
|
|
183
177
|
}
|
|
184
|
-
type GeneratorFunction<TSpec, TOptions extends object> = (spec: TSpec, options: TOptions) => MaybePromise<Record<string, GeneratedDocument
|
|
178
|
+
type GeneratorFunction<TSpec, TOptions extends object> = (spec: TSpec, options: TOptions) => MaybePromise<Record<string, GeneratedDocument>>;
|
|
185
179
|
type GeneratorFunctionResult<TSpec, TOptions extends object> = Awaited<ReturnType<GeneratorFunction<TSpec, TOptions>>>;
|
|
186
180
|
interface GeneratorResult<TSpec, TOptions extends object, TReturns = void> {
|
|
187
181
|
/**
|
|
@@ -205,7 +199,7 @@ interface GeneratorConfigObject<TSpec, TOptions extends object, TReturns = void>
|
|
|
205
199
|
/**
|
|
206
200
|
* Optional metadata about the generator, such as a description of the output it produces.
|
|
207
201
|
*/
|
|
208
|
-
meta?:
|
|
202
|
+
meta?: MetaConfig;
|
|
209
203
|
/**
|
|
210
204
|
* The schema config that defines the structure of the specification object for this generator.
|
|
211
205
|
*/
|
|
@@ -229,7 +223,7 @@ interface Generator<TSpec, TOptions extends object, TReturns = void> {
|
|
|
229
223
|
/**
|
|
230
224
|
* Optional metadata about the generator, such as a description of the output it produces.
|
|
231
225
|
*/
|
|
232
|
-
meta?:
|
|
226
|
+
meta?: MetaConfig;
|
|
233
227
|
/**
|
|
234
228
|
* The schema config that defines the structure of the specification object for this generator.
|
|
235
229
|
*/
|
|
@@ -254,13 +248,13 @@ interface Generator<TSpec, TOptions extends object, TReturns = void> {
|
|
|
254
248
|
generator: (options: TOptions & UserConfig) => Promise<GeneratorResult<TSpec, TOptions, TReturns>>;
|
|
255
249
|
}
|
|
256
250
|
type InferSchemaConfig<T extends GeneratorConfig<any, any, any>> = T extends LoadReference ? InferLoadOptions<T> : T extends GeneratorConfigObject<any, any, any> ? T["schema"] : never;
|
|
257
|
-
type
|
|
251
|
+
type InferMeta<T extends GeneratorConfig<any, any, any>> = T extends LoadReference ? InferLoadOptions<T> : T extends GeneratorConfigObject<any, any, any> ? T["meta"] : never;
|
|
258
252
|
type InferInputConfig<T extends GeneratorConfig<any, any, any>> = T extends LoadReference ? InferLoadOptions<T> : T extends GeneratorConfigObject<any, any, any> ? T["input"] : never;
|
|
259
253
|
type InferOutputConfig<T extends GeneratorConfig<any, any, any>> = T extends LoadReference ? InferLoadOptions<T> : T extends GeneratorConfigObject<any, any, any> ? T["output"] : never;
|
|
260
254
|
type InferGeneratorFunction<T extends GeneratorConfig<any, any, any>> = T extends LoadReference ? InferLoadOptions<T> : T extends GeneratorConfigObject<any, any, any> ? T["generator"] : never;
|
|
261
255
|
type InferGeneratorResult<T extends GeneratorConfig<any, any, any>> = InferGeneratorFunction<T> extends GeneratorFunction<any, any> ? Awaited<ReturnType<InferGeneratorFunction<T>>> : never;
|
|
262
256
|
interface InferGenerator<T extends GeneratorConfig<any, any, any>> {
|
|
263
|
-
meta?:
|
|
257
|
+
meta?: InferMeta<T>;
|
|
264
258
|
schema: InferSchemaConfig<T>;
|
|
265
259
|
input: InferInputConfig<T>;
|
|
266
260
|
output: InferOutputConfig<T>;
|
|
@@ -268,7 +262,7 @@ interface InferGenerator<T extends GeneratorConfig<any, any, any>> {
|
|
|
268
262
|
}
|
|
269
263
|
//#endregion
|
|
270
264
|
//#region src/types/output.d.ts
|
|
271
|
-
type OutputFunction<TSpec, TOptions extends object, TReturns = void> = (spec: TSpec, options: TOptions, documents: Record<string, GeneratedDocument
|
|
265
|
+
type OutputFunction<TSpec, TOptions extends object, TReturns = void> = (spec: TSpec, options: TOptions, documents: Record<string, GeneratedDocument>) => MaybePromise<TReturns>;
|
|
272
266
|
interface OutputConfigObject<TSpec, TOptions extends object, TReturns = void> {
|
|
273
267
|
/**
|
|
274
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.
|
|
@@ -385,5 +379,5 @@ type UserConfigFnPromise<TSpec = any, TOptions extends object = any, TReturns =
|
|
|
385
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>[]>;
|
|
386
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>;
|
|
387
381
|
//#endregion
|
|
388
|
-
export {
|
|
389
|
-
//# 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-BpNybJZY.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-BpNybJZY.d.cts","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":"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"}
|
|
@@ -1,8 +1,8 @@
|
|
|
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
7
|
type MetaDeprecated = true | string | {
|
|
8
8
|
message?: string;
|
|
@@ -165,23 +165,17 @@ interface Input<TSpec, TOptions extends object> {
|
|
|
165
165
|
}
|
|
166
166
|
//#endregion
|
|
167
167
|
//#region src/types/generator.d.ts
|
|
168
|
-
type GeneratorMeta<TSpec, TOptions extends object> = MetaConfig & {
|
|
169
|
-
/**
|
|
170
|
-
* A string description outlining the purpose or behavior of the generator.
|
|
171
|
-
*/
|
|
172
|
-
description?: string;
|
|
173
|
-
};
|
|
174
168
|
interface GeneratedDocumentChunk {
|
|
175
169
|
content?: string;
|
|
176
170
|
meta?: MetaConfig;
|
|
177
171
|
}
|
|
178
|
-
interface GeneratedDocument
|
|
172
|
+
interface GeneratedDocument {
|
|
179
173
|
path: string;
|
|
180
174
|
language?: string;
|
|
181
175
|
chunks?: DeepPartial<GeneratedDocumentChunk>[];
|
|
182
176
|
meta?: MetaConfig;
|
|
183
177
|
}
|
|
184
|
-
type GeneratorFunction<TSpec, TOptions extends object> = (spec: TSpec, options: TOptions) => MaybePromise<Record<string, GeneratedDocument
|
|
178
|
+
type GeneratorFunction<TSpec, TOptions extends object> = (spec: TSpec, options: TOptions) => MaybePromise<Record<string, GeneratedDocument>>;
|
|
185
179
|
type GeneratorFunctionResult<TSpec, TOptions extends object> = Awaited<ReturnType<GeneratorFunction<TSpec, TOptions>>>;
|
|
186
180
|
interface GeneratorResult<TSpec, TOptions extends object, TReturns = void> {
|
|
187
181
|
/**
|
|
@@ -205,7 +199,7 @@ interface GeneratorConfigObject<TSpec, TOptions extends object, TReturns = void>
|
|
|
205
199
|
/**
|
|
206
200
|
* Optional metadata about the generator, such as a description of the output it produces.
|
|
207
201
|
*/
|
|
208
|
-
meta?:
|
|
202
|
+
meta?: MetaConfig;
|
|
209
203
|
/**
|
|
210
204
|
* The schema config that defines the structure of the specification object for this generator.
|
|
211
205
|
*/
|
|
@@ -229,7 +223,7 @@ interface Generator<TSpec, TOptions extends object, TReturns = void> {
|
|
|
229
223
|
/**
|
|
230
224
|
* Optional metadata about the generator, such as a description of the output it produces.
|
|
231
225
|
*/
|
|
232
|
-
meta?:
|
|
226
|
+
meta?: MetaConfig;
|
|
233
227
|
/**
|
|
234
228
|
* The schema config that defines the structure of the specification object for this generator.
|
|
235
229
|
*/
|
|
@@ -254,13 +248,13 @@ interface Generator<TSpec, TOptions extends object, TReturns = void> {
|
|
|
254
248
|
generator: (options: TOptions & UserConfig) => Promise<GeneratorResult<TSpec, TOptions, TReturns>>;
|
|
255
249
|
}
|
|
256
250
|
type InferSchemaConfig<T extends GeneratorConfig<any, any, any>> = T extends LoadReference ? InferLoadOptions<T> : T extends GeneratorConfigObject<any, any, any> ? T["schema"] : never;
|
|
257
|
-
type
|
|
251
|
+
type InferMeta<T extends GeneratorConfig<any, any, any>> = T extends LoadReference ? InferLoadOptions<T> : T extends GeneratorConfigObject<any, any, any> ? T["meta"] : never;
|
|
258
252
|
type InferInputConfig<T extends GeneratorConfig<any, any, any>> = T extends LoadReference ? InferLoadOptions<T> : T extends GeneratorConfigObject<any, any, any> ? T["input"] : never;
|
|
259
253
|
type InferOutputConfig<T extends GeneratorConfig<any, any, any>> = T extends LoadReference ? InferLoadOptions<T> : T extends GeneratorConfigObject<any, any, any> ? T["output"] : never;
|
|
260
254
|
type InferGeneratorFunction<T extends GeneratorConfig<any, any, any>> = T extends LoadReference ? InferLoadOptions<T> : T extends GeneratorConfigObject<any, any, any> ? T["generator"] : never;
|
|
261
255
|
type InferGeneratorResult<T extends GeneratorConfig<any, any, any>> = InferGeneratorFunction<T> extends GeneratorFunction<any, any> ? Awaited<ReturnType<InferGeneratorFunction<T>>> : never;
|
|
262
256
|
interface InferGenerator<T extends GeneratorConfig<any, any, any>> {
|
|
263
|
-
meta?:
|
|
257
|
+
meta?: InferMeta<T>;
|
|
264
258
|
schema: InferSchemaConfig<T>;
|
|
265
259
|
input: InferInputConfig<T>;
|
|
266
260
|
output: InferOutputConfig<T>;
|
|
@@ -268,7 +262,7 @@ interface InferGenerator<T extends GeneratorConfig<any, any, any>> {
|
|
|
268
262
|
}
|
|
269
263
|
//#endregion
|
|
270
264
|
//#region src/types/output.d.ts
|
|
271
|
-
type OutputFunction<TSpec, TOptions extends object, TReturns = void> = (spec: TSpec, options: TOptions, documents: Record<string, GeneratedDocument
|
|
265
|
+
type OutputFunction<TSpec, TOptions extends object, TReturns = void> = (spec: TSpec, options: TOptions, documents: Record<string, GeneratedDocument>) => MaybePromise<TReturns>;
|
|
272
266
|
interface OutputConfigObject<TSpec, TOptions extends object, TReturns = void> {
|
|
273
267
|
/**
|
|
274
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.
|
|
@@ -385,5 +379,5 @@ type UserConfigFnPromise<TSpec = any, TOptions extends object = any, TReturns =
|
|
|
385
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>[]>;
|
|
386
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>;
|
|
387
381
|
//#endregion
|
|
388
|
-
export {
|
|
389
|
-
//# 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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-
|
|
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"}
|
|
@@ -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-C9Hp8wTC.mjs";
|
|
2
|
+
import { n as Execution } from "./execution-d10Z7Dih.mjs";
|
|
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-BUNCX0E-.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-BUNCX0E-.d.mts","names":[],"sources":["../src/types/base.ts","../src/types/session.ts","../src/types/context.ts"],"mappings":""}
|
package/dist/context.d.cts
CHANGED
package/dist/context.d.mts
CHANGED
package/dist/define.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./type-checks.cjs");function t(t){return e.isInputConfigObject(t)?t:{input:t}}function n(t){return e.isOutputConfigObject(t)?t:{output:t}}function r(t){return e.isSchemaConfigObject(t)?t:{schema:t}}function i(t){if(!e.isGeneratorConfigObject(t))throw TypeError(`An invalid generator configuration was provided - at minimum, a generator function is required.`);return t}exports.defineGenerator=i,exports.defineInput=t,exports.defineOutput=n,exports.defineSchema=r;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./helpers/type-checks.cjs");function t(t){return e.isInputConfigObject(t)?t:{input:t}}function n(t){return e.isOutputConfigObject(t)?t:{output:t}}function r(t){return e.isSchemaConfigObject(t)?t:{schema:t}}function i(t){if(!e.isGeneratorConfigObject(t))throw TypeError(`An invalid generator configuration was provided - at minimum, a generator function is required.`);return t}exports.defineGenerator=i,exports.defineInput=t,exports.defineOutput=n,exports.defineSchema=r;
|
package/dist/define.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { M as InputConfig, N as InputConfigObject, R as SchemaConfigObject, d as OutputConfig, f as OutputConfigObject, v as GeneratorConfigObject } from "./config-BpNybJZY.cjs";
|
|
2
2
|
import { SchemaEnvelopeOf, SchemaSourceConfig } from "@power-plant/schema";
|
|
3
3
|
//#region src/define.d.ts
|
|
4
4
|
/**
|
package/dist/define.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { M as InputConfig, N as InputConfigObject, R as SchemaConfigObject, d as OutputConfig, f as OutputConfigObject, v as GeneratorConfigObject } from "./config-C9Hp8wTC.mjs";
|
|
2
2
|
import { SchemaEnvelopeOf, SchemaSourceConfig } from "@power-plant/schema";
|
|
3
3
|
//#region src/define.d.ts
|
|
4
4
|
/**
|
package/dist/define.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{isGeneratorConfigObject as e,isInputConfigObject as t,isOutputConfigObject as n,isSchemaConfigObject as r}from"./type-checks.mjs";function i(e){return t(e)?e:{input:e}}function a(e){return n(e)?e:{output:e}}function o(e){return r(e)?e:{schema:e}}function s(t){if(!e(t))throw TypeError(`An invalid generator configuration was provided - at minimum, a generator function is required.`);return t}export{s as defineGenerator,i as defineInput,a as defineOutput,o as defineSchema};
|
|
1
|
+
import{isGeneratorConfigObject as e,isInputConfigObject as t,isOutputConfigObject as n,isSchemaConfigObject as r}from"./helpers/type-checks.mjs";function i(e){return t(e)?e:{input:e}}function a(e){return n(e)?e:{output:e}}function o(e){return r(e)?e:{schema:e}}function s(t){if(!e(t))throw TypeError(`An invalid generator configuration was provided - at minimum, a generator function is required.`);return t}export{s as defineGenerator,i as defineInput,a as defineOutput,o as defineSchema};
|
|
2
2
|
//# sourceMappingURL=define.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{callAsyncSessionContext as e}from"./context.mjs";import{isGeneratorConfigObject as t,isInputConfigObject as n,isOutputConfigObject as r,isSchemaConfigObject as i}from"./helpers/type-checks.mjs";import{resolveMeta as a,resolveMetaDescription as o,resolveMetaExample as s}from"./helpers/meta.mjs";import{uuid as c}from"@stryke/unique-id/uuid";import{getEnvPaths as l}from"@stryke/env/get-env-paths";import{readFileIfExisting as u}from"@stryke/fs/read-file";import{writeFile as d}from"@stryke/fs/write-file";import{joinPaths as f}from"@stryke/path/join-paths";import{isSetString as p}from"@stryke/type-checks/is-set-string";import m from"defu";import h from"node:os";import{createStorage as g}from"unstorage";import _ from"unstorage/drivers/fs-lite";import{callAsyncExecutionContext as v}from"@power-plant/core";import{mapStorageToFileSystem as y}from"@power-plant/schema/storage";import{load as b}from"@stryke/resolve/load";import{isFunction as x}from"@stryke/type-checks/is-function";import{extractSchemaWithSource as S,mergeMetadata as C}from"@power-plant/schema";import{isLoadReference as w}from"@stryke/resolve/type-checks";const T={debug:console.debug,info:console.info,warn:console.warn,error:console.error},E=l({appId:`power-plant`,orgId:`storm-software`});async function D(e={}){let t=e.cwd||process.cwd(),n=new Date,r=g({driver:_({base:t})}),i=JSON.parse(await u(f(E.data,`.local-store.json`))||`{}`),a=i.device||h.hostname()||c(),o=i.user||h.userInfo().username||c();return(!p(i.device)||!p(i.user))&&await d(f(E.data,`.local-store.json`),JSON.stringify({device:a,user:o},null,2)),m({cwd:t,session:{id:c(),createdAt:n,updatedAt:n,device:a,user:o,executions:[]}},e,{storage:r,settings:{},logger:T})}async function O(e,t,n,r,i,a){let o={},s=(e,t)=>{p(e)?o[e]=m({path:e},t,{chunks:[],meta:{}}):o[e.path]=m(e,t)},c,l={...t,id:e,createdAt:new Date,updatedAt:new Date,options:n,schema:r,input:i,output:a,documents:o,spec(){if(!c)throw Error(`The specification was accessed prior to the input processing.`);return c},addDocument:s,meta:{id:e,executedAt:new Date,executedBy:``}};return Object.defineProperty(l,"~spec",{get(){return c},set(e){c=e},enumerable:!1}),l}async function k(e,t,n){return e}function A(e,t){let n=e?.schema??{},r=a(e,t);return r.description=o(`Accepts a ${r.title??``} specification and processes it with a {title} sink.`,n,r,t?.description),r.examples=s(n,r,t?.examples),r}async function j(e,t={}){let{meta:n,schema:r}=i(e)?e:{schema:e,meta:{}},a=await S(r,t);return{...a,meta:A(a,n)}}function M(e,t){let n=e?.schema??{},r=a(e,t);return r.description=o(`Determines the ${r.title??``} specification from a {title} input.`,n,r,t?.description),r}async function N(e,t,r={}){let{input:i,meta:a,schema:o}=n(t)?t:{input:t,meta:{}},s=e;if(o){let t;if(w(o))try{t=await b(o,r)}catch{}else t=o;t&&(s=await j(t,r),s.schema=C(s.schema,e.schema))}let c;if(w(i))try{let e=await b(i,r);c=n(e)?await N(s,e.input,r).then(e=>e.input):e}catch{}return c||=i,{schema:s,input:c,meta:M(s,a)}}function P(e,t){let n=e?.schema??{},r=a(e,t);return r.description=o(`Accepts a ${r.title??``} specification and processes it with a {title} output.`,n,r,t?.description),r}async function F(e,t,n={}){let{output:i,meta:a,schema:o}=r(t)?t:{output:t,meta:{}},s=e;if(o){let t;if(w(o))try{t=await b(o,n)}catch{}else t=o;t&&(s=await j(t,n),s.schema=C(s.schema,e.schema))}let c;if(w(i))try{let e=await b(i,n);c=r(e)?await F(s,e.output,n).then(e=>e.output):e}catch{}return c||=i,{schema:s,output:c,meta:P(s,a)}}async function I(e,n,r,i={}){let a;a=t(r)?r:await b(r,{fs:y(n.storage),...i}),a.schema||={type:`any`};let o=await j(a.schema,{storage:n.storage,...i}),s=a.input;if(!s)if(i.inputPath)s=`@power-plant/unstorage-input`;else throw Error("No input configuration provided. Please provide an input configuration, a valid specification, or a `inputPath` option that points to a valid input file.");let c=a.output;c||=`@power-plant/unstorage-output`;let[l,u]=await Promise.all([N(o,s,{storage:n.storage,...i}),F(o,c,{storage:n.storage,...i})]);return{meta:a.meta,schema:o,input:l,output:u,generator:async t=>{let r=await O(e,n,t,o,l,u);return v(r,async()=>{let e=x(l.input)?await l.input({storage:r.storage,...t}):l.input;r[`~spec`]=e;let n;n=x(a.generator)?a.generator:await b(a.generator,{storage:r.storage,...t});let i=await n(e,t);return{spec:e,options:t,documents:i,returns:await u.output(e,t,i)}})}}}async function L(t={}){let n=await D(t);return async(t,r={})=>e(n,async()=>{let e=c(),{generator:i}=await I(e,n,t,r),{documents:a,returns:o,spec:s,options:l}=await i(r),u=await k({documents:Object.fromEntries(Object.entries(a).map(([t,n])=>[t,{...n,path:t,meta:{executionId:e}}])),meta:{executionId:e,executedAt:new Date,executedBy:n.session.user}},s,l);return n.session.executions.push(u),o})}async function R(e,t={}){return(await L(t))(e,t)}export{R as n,L as t};
|
|
2
|
+
//# sourceMappingURL=execute-8tWWCCpu.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-8tWWCCpu.mjs","names":[],"sources":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=require("./context.cjs"),l=require("./helpers/type-checks.cjs"),u=require("./helpers/meta.cjs");let d=require("@stryke/unique-id/uuid"),f=require("@stryke/env/get-env-paths"),p=require("@stryke/fs/read-file"),m=require("@stryke/fs/write-file"),h=require("@stryke/path/join-paths"),g=require("@stryke/type-checks/is-set-string"),_=require("defu");_=s(_,1);let v=require("node:os");v=s(v,1);let y=require("unstorage"),b=require("unstorage/drivers/fs-lite");b=s(b,1);let x=require("@power-plant/core"),S=require("@power-plant/schema/storage"),C=require("@stryke/resolve/load"),w=require("@stryke/type-checks/is-function"),T=require("@power-plant/schema"),E=require("@stryke/resolve/type-checks");const D={debug:console.debug,info:console.info,warn:console.warn,error:console.error},O=(0,f.getEnvPaths)({appId:`power-plant`,orgId:`storm-software`});async function k(e={}){let t=e.cwd||process.cwd(),n=new Date,r=(0,y.createStorage)({driver:(0,b.default)({base:t})}),i=JSON.parse(await(0,p.readFileIfExisting)((0,h.joinPaths)(O.data,`.local-store.json`))||`{}`),a=i.device||v.default.hostname()||(0,d.uuid)(),o=i.user||v.default.userInfo().username||(0,d.uuid)();return(!(0,g.isSetString)(i.device)||!(0,g.isSetString)(i.user))&&await(0,m.writeFile)((0,h.joinPaths)(O.data,`.local-store.json`),JSON.stringify({device:a,user:o},null,2)),(0,_.default)({cwd:t,session:{id:(0,d.uuid)(),createdAt:n,updatedAt:n,device:a,user:o,executions:[]}},e,{storage:r,settings:{},logger:D})}async function A(e,t,n,r,i,a){let o={},s=(e,t)=>{(0,g.isSetString)(e)?o[e]=(0,_.default)({path:e},t,{chunks:[],meta:{}}):o[e.path]=(0,_.default)(e,t)},c,l={...t,id:e,createdAt:new Date,updatedAt:new Date,options:n,schema:r,input:i,output:a,documents:o,spec(){if(!c)throw Error(`The specification was accessed prior to the input processing.`);return c},addDocument:s,meta:{id:e,executedAt:new Date,executedBy:``}};return Object.defineProperty(l,"~spec",{get(){return c},set(e){c=e},enumerable:!1}),l}async function j(e,t,n){return e}function M(e,t){let n=e?.schema??{},r=u.resolveMeta(e,t);return r.description=u.resolveMetaDescription(`Accepts a ${r.title??``} specification and processes it with a {title} sink.`,n,r,t?.description),r.examples=u.resolveMetaExample(n,r,t?.examples),r}async function N(e,t={}){let{meta:n,schema:r}=l.isSchemaConfigObject(e)?e:{schema:e,meta:{}},i=await(0,T.extractSchemaWithSource)(r,t);return{...i,meta:M(i,n)}}function P(e,t){let n=e?.schema??{},r=u.resolveMeta(e,t);return r.description=u.resolveMetaDescription(`Determines the ${r.title??``} specification from a {title} input.`,n,r,t?.description),r}async function F(e,t,n={}){let{input:r,meta:i,schema:a}=l.isInputConfigObject(t)?t:{input:t,meta:{}},o=e;if(a){let t;if((0,E.isLoadReference)(a))try{t=await(0,C.load)(a,n)}catch{}else t=a;t&&(o=await N(t,n),o.schema=(0,T.mergeMetadata)(o.schema,e.schema))}let s;if((0,E.isLoadReference)(r))try{let e=await(0,C.load)(r,n);s=l.isInputConfigObject(e)?await F(o,e.input,n).then(e=>e.input):e}catch{}return s||=r,{schema:o,input:s,meta:P(o,i)}}function I(e,t){let n=e?.schema??{},r=u.resolveMeta(e,t);return r.description=u.resolveMetaDescription(`Accepts a ${r.title??``} specification and processes it with a {title} output.`,n,r,t?.description),r}async function L(e,t,n={}){let{output:r,meta:i,schema:a}=l.isOutputConfigObject(t)?t:{output:t,meta:{}},o=e;if(a){let t;if((0,E.isLoadReference)(a))try{t=await(0,C.load)(a,n)}catch{}else t=a;t&&(o=await N(t,n),o.schema=(0,T.mergeMetadata)(o.schema,e.schema))}let s;if((0,E.isLoadReference)(r))try{let e=await(0,C.load)(r,n);s=l.isOutputConfigObject(e)?await L(o,e.output,n).then(e=>e.output):e}catch{}return s||=r,{schema:o,output:s,meta:I(o,i)}}async function R(e,t,n,r={}){let i;i=l.isGeneratorConfigObject(n)?n:await(0,C.load)(n,{fs:(0,S.mapStorageToFileSystem)(t.storage),...r}),i.schema||={type:`any`};let a=await N(i.schema,{storage:t.storage,...r}),o=i.input;if(!o)if(r.inputPath)o=`@power-plant/unstorage-input`;else throw Error("No input configuration provided. Please provide an input configuration, a valid specification, or a `inputPath` option that points to a valid input file.");let s=i.output;s||=`@power-plant/unstorage-output`;let[c,u]=await Promise.all([F(a,o,{storage:t.storage,...r}),L(a,s,{storage:t.storage,...r})]);return{meta:i.meta,schema:a,input:c,output:u,generator:async n=>{let r=await A(e,t,n,a,c,u);return(0,x.callAsyncExecutionContext)(r,async()=>{let e=(0,w.isFunction)(c.input)?await c.input({storage:r.storage,...n}):c.input;r[`~spec`]=e;let t;t=(0,w.isFunction)(i.generator)?i.generator:await(0,C.load)(i.generator,{storage:r.storage,...n});let a=await t(e,n);return{spec:e,options:n,documents:a,returns:await u.output(e,n,a)}})}}}async function z(e={}){let t=await k(e);return async(e,n={})=>c.callAsyncSessionContext(t,async()=>{let r=(0,d.uuid)(),{generator:i}=await R(r,t,e,n),{documents:a,returns:o,spec:s,options:c}=await i(n),l=await j({documents:Object.fromEntries(Object.entries(a).map(([e,t])=>[e,{...t,path:e,meta:{executionId:r}}])),meta:{executionId:r,executedAt:new Date,executedBy:t.session.user}},s,c);return t.session.executions.push(l),o})}async function B(e,t={}){return(await z(t))(e,t)}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return z}});
|
package/dist/execute.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./execute-D7rill1C.cjs");require("./context.cjs"),exports.createExecute=e.t,exports.execute=e.n;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { _ as GeneratorConfig, t as UserConfig } from "./config-BpNybJZY.cjs";
|
|
2
|
+
import { a as InferEngineOptions, t as ExecuteFunction } from "./execution-BAm3omij.cjs";
|
|
3
|
+
//#region src/execute.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Creates an execution function that can be used to execute a generator.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* This function is used to create an execution function that can be used to execute a generator. It creates a new execution context and returns an execution function that can be used to execute the generator with the given configuration and options.
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { createExecute } from "@power-plant/core";
|
|
14
|
+
*
|
|
15
|
+
* // First, create an execution function with a custom configuration
|
|
16
|
+
* const execute = await createExecute({
|
|
17
|
+
* ...
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* // Then, execute the generator
|
|
21
|
+
* const result = await execute("my-generator", {
|
|
22
|
+
* ...
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* import { createExecute } from "@power-plant/core";
|
|
29
|
+
*
|
|
30
|
+
* // First, create an execution function with a custom configuration
|
|
31
|
+
* const execute = await createExecute({
|
|
32
|
+
* ...
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* // Then, execute the generator
|
|
36
|
+
* const result = await execute({
|
|
37
|
+
* generator: (spec, options) => { ... },
|
|
38
|
+
* ...
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @template TSpec - The type of the specification that the generator will produce.
|
|
43
|
+
* @template TOptions - The type of the options that will be passed to the generator during generation.
|
|
44
|
+
* @template TReturns - The type of the returns that the generator will produce.
|
|
45
|
+
* @param userConfig - The user configuration for the engine.
|
|
46
|
+
* @returns A promise that resolves to an execution function.
|
|
47
|
+
*/
|
|
48
|
+
declare function createExecute(userConfig?: UserConfig): Promise<ExecuteFunction>;
|
|
49
|
+
/**
|
|
50
|
+
* Executes a generator with a given configuration and options.
|
|
51
|
+
*
|
|
52
|
+
* @remarks
|
|
53
|
+
* This function is used to execute a generator with a given configuration and options. It creates a new execution context and returns an execution function that can be used to execute the generator with the given configuration and options.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* import { execute } from "@power-plant/core";
|
|
58
|
+
*
|
|
59
|
+
* // Create and execute the generator
|
|
60
|
+
* const result = await execute("my-generator", {
|
|
61
|
+
* ...
|
|
62
|
+
* });
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* import { execute } from "@power-plant/core";
|
|
68
|
+
*
|
|
69
|
+
* // Create and execute the generator
|
|
70
|
+
* const result = await execute({
|
|
71
|
+
* generator: (spec, options) => { ... },
|
|
72
|
+
* }, {
|
|
73
|
+
* ...
|
|
74
|
+
* });
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @template TSpec - The type of the specification that the generator will produce.
|
|
78
|
+
* @template TOptions - The type of the options that will be passed to the generator during generation.
|
|
79
|
+
* @template TReturns - The type of the returns that the generator will produce.
|
|
80
|
+
* @param config - The configuration for the generator.
|
|
81
|
+
* @param options - The options for the generator.
|
|
82
|
+
* @returns A promise that resolves to the returns of the generator.
|
|
83
|
+
*/
|
|
84
|
+
declare function execute<TSpec, TOptions extends object, TReturns = void>(config: GeneratorConfig<TSpec, TOptions, TReturns>, options?: InferEngineOptions<typeof config> & TOptions): Promise<TReturns>;
|
|
85
|
+
//#endregion
|
|
86
|
+
export { createExecute, execute };
|
|
87
|
+
//# sourceMappingURL=execute.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.d.cts","names":[],"sources":["../src/execute.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2EsB,cACpB,aAAY,aACX,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2FW,QAAQ,OAAO,yBAAyB,iBAC5D,QAAQ,gBAAgB,OAAO,UAAU,WACzC,UAAS,0BAA0B,UACjC,WACD,QAAQ"}
|