@power-plant/core 0.0.2 → 0.0.3
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 +220 -0
- package/dist/base-BKbfgxno.d.cts +28 -0
- package/dist/base-BKbfgxno.d.cts.map +1 -0
- package/dist/base-BKbfgxno.d.mts +28 -0
- package/dist/base-BKbfgxno.d.mts.map +1 -0
- package/dist/create-B14Jt6Iu.d.mts +17 -0
- package/dist/create-B14Jt6Iu.d.mts.map +1 -0
- package/dist/create-Cfgth9sz.d.cts +19 -0
- package/dist/create-Cfgth9sz.d.cts.map +1 -0
- package/dist/create-D32Jusq_.d.cts +17 -0
- package/dist/create-D32Jusq_.d.cts.map +1 -0
- package/dist/create-DVpg-3po.d.mts +19 -0
- package/dist/create-DVpg-3po.d.mts.map +1 -0
- package/dist/create-DoyLue8r.d.cts +17 -0
- package/dist/create-DoyLue8r.d.cts.map +1 -0
- package/dist/create-vgEDsShD.d.mts +17 -0
- package/dist/create-vgEDsShD.d.mts.map +1 -0
- package/dist/define-DEe-HPar.d.cts +38 -0
- package/dist/define-DEe-HPar.d.cts.map +1 -0
- package/dist/define-RneysDu1.d.mts +38 -0
- package/dist/define-RneysDu1.d.mts.map +1 -0
- package/dist/generator/create.cjs +1 -0
- package/dist/generator/create.d.cts +2 -0
- package/dist/generator/create.d.mts +2 -0
- package/dist/generator/create.mjs +2 -0
- package/dist/generator/create.mjs.map +1 -0
- package/dist/generator/helpers.cjs +1 -0
- package/dist/generator/helpers.d.cts +6 -0
- package/dist/generator/helpers.d.cts.map +1 -0
- package/dist/generator/helpers.d.mts +6 -0
- package/dist/generator/helpers.d.mts.map +1 -0
- package/dist/generator/helpers.mjs +2 -0
- package/dist/generator/helpers.mjs.map +1 -0
- package/dist/generator/index.cjs +1 -1
- package/dist/generator/index.d.cts +2 -20
- package/dist/generator/index.d.mts +2 -20
- package/dist/generator/index.mjs +1 -2
- package/dist/{generator-C5O_C4RV.d.cts → generator-C1_Q-QAb.d.cts} +15 -12
- package/dist/generator-C1_Q-QAb.d.cts.map +1 -0
- package/dist/{generator-DZI01B4_.d.mts → generator-MC25UERM.d.mts} +15 -12
- package/dist/generator-MC25UERM.d.mts.map +1 -0
- package/dist/index-BVVgDSdq.d.cts +1 -0
- package/dist/index-BVVgDSdq.d.mts +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +8 -8
- package/dist/index.d.mts +8 -8
- package/dist/index.mjs +1 -1
- package/dist/metadata-Cb6iMZqW.cjs +1 -0
- package/dist/metadata-Dmhrb3Kv.mjs +2 -0
- package/dist/metadata-Dmhrb3Kv.mjs.map +1 -0
- package/dist/sink/create.cjs +1 -0
- package/dist/sink/create.d.cts +2 -0
- package/dist/sink/create.d.mts +2 -0
- package/dist/sink/create.mjs +2 -0
- package/dist/sink/create.mjs.map +1 -0
- package/dist/sink/define.cjs +1 -0
- package/dist/sink/define.d.cts +37 -0
- package/dist/sink/define.d.cts.map +1 -0
- package/dist/sink/define.d.mts +37 -0
- package/dist/sink/define.d.mts.map +1 -0
- package/dist/sink/define.mjs +2 -0
- package/dist/sink/define.mjs.map +1 -0
- package/dist/sink/helpers.cjs +1 -0
- package/dist/sink/helpers.d.cts +13 -0
- package/dist/sink/helpers.d.cts.map +1 -0
- package/dist/sink/helpers.d.mts +13 -0
- package/dist/sink/helpers.d.mts.map +1 -0
- package/dist/sink/helpers.mjs +2 -0
- package/dist/sink/helpers.mjs.map +1 -0
- package/dist/sink/index.cjs +1 -1
- package/dist/sink/index.d.cts +2 -15
- package/dist/sink/index.d.mts +2 -15
- package/dist/sink/index.mjs +1 -1
- package/dist/sink-CAWlC7am.d.mts +58 -0
- package/dist/sink-CAWlC7am.d.mts.map +1 -0
- package/dist/sink-CTx7UtqU.d.cts +58 -0
- package/dist/sink-CTx7UtqU.d.cts.map +1 -0
- package/dist/source/create.cjs +1 -0
- package/dist/source/create.d.cts +2 -0
- package/dist/source/create.d.mts +2 -0
- package/dist/source/create.mjs +2 -0
- package/dist/source/create.mjs.map +1 -0
- package/dist/source/define.cjs +1 -0
- package/dist/source/define.d.cts +2 -0
- package/dist/source/define.d.mts +2 -0
- package/dist/source/define.mjs +2 -0
- package/dist/source/define.mjs.map +1 -0
- package/dist/source/helpers.cjs +1 -0
- package/dist/source/helpers.d.cts +13 -0
- package/dist/source/helpers.d.cts.map +1 -0
- package/dist/source/helpers.d.mts +13 -0
- package/dist/source/helpers.d.mts.map +1 -0
- package/dist/source/helpers.mjs +2 -0
- package/dist/source/helpers.mjs.map +1 -0
- package/dist/source/index.cjs +1 -1
- package/dist/source/index.d.cts +3 -16
- package/dist/source/index.d.mts +3 -16
- package/dist/source/index.mjs +1 -1
- package/dist/source-B3tctCZE.d.cts +57 -0
- package/dist/source-B3tctCZE.d.cts.map +1 -0
- package/dist/source-DjKhYXZ6.d.mts +57 -0
- package/dist/source-DjKhYXZ6.d.mts.map +1 -0
- package/package.json +127 -27
- package/dist/config.cjs +0 -0
- package/dist/config.d.cts +0 -10
- package/dist/config.d.cts.map +0 -1
- package/dist/config.d.mts +0 -10
- package/dist/config.d.mts.map +0 -1
- package/dist/config.mjs +0 -2
- package/dist/config.mjs.map +0 -1
- package/dist/extract-BzZLelb2.mjs +0 -2
- package/dist/extract-BzZLelb2.mjs.map +0 -1
- package/dist/extract-DUwG1ZUO.cjs +0 -1
- package/dist/extract-FkKA9g1K.cjs +0 -1
- package/dist/extract-ZIpZAKsq.mjs +0 -2
- package/dist/extract-ZIpZAKsq.mjs.map +0 -1
- package/dist/generator/index.d.cts.map +0 -1
- package/dist/generator/index.d.mts.map +0 -1
- package/dist/generator/index.mjs.map +0 -1
- package/dist/generator-C5O_C4RV.d.cts.map +0 -1
- package/dist/generator-DZI01B4_.d.mts.map +0 -1
- package/dist/sink/index.d.cts.map +0 -1
- package/dist/sink/index.d.mts.map +0 -1
- package/dist/source/index.d.cts.map +0 -1
- package/dist/source/index.d.mts.map +0 -1
- package/dist/types-B2MtSxCp.d.cts +0 -47
- package/dist/types-B2MtSxCp.d.cts.map +0 -1
- package/dist/types-B2MtSxCp.d.mts +0 -47
- package/dist/types-B2MtSxCp.d.mts.map +0 -1
- package/dist/types-DJo-IRmS.d.cts +0 -47
- package/dist/types-DJo-IRmS.d.cts.map +0 -1
- package/dist/types-DJo-IRmS.d.mts +0 -47
- package/dist/types-DJo-IRmS.d.mts.map +0 -1
|
@@ -1,20 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
//#region src/generator/generator.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Creates a generator from raw schema/source/sink inputs and resolves all descriptors.
|
|
7
|
-
*
|
|
8
|
-
* @remarks
|
|
9
|
-
* This function is used to create a generator from raw schema, source, and sink inputs. It resolves all descriptors and returns a fully constructed generator that can be used to generate output based on the provided schema and options.
|
|
10
|
-
*
|
|
11
|
-
* @template TSpec - The type of the specification that the generator will produce.
|
|
12
|
-
* @template TOptions - The type of the options that will be passed to the generator during generation.
|
|
13
|
-
* @param input - The generator input containing schema, source, sink, and optional meta information.
|
|
14
|
-
* @param options - Optional extraction options for schema, source, and sink.
|
|
15
|
-
* @returns A promise that resolves to a fully constructed generator.
|
|
16
|
-
*/
|
|
17
|
-
declare function createGenerator<TSpec, TOptions = any>(input: GeneratorInput<TSpec, TOptions>, options?: ExtractOptions): Promise<Generator<TSpec, TOptions>>;
|
|
18
|
-
//#endregion
|
|
19
|
-
export { createGenerator };
|
|
20
|
-
//# sourceMappingURL=index.d.mts.map
|
|
1
|
+
import { t as createGenerator } from "../create-DVpg-3po.mjs";
|
|
2
|
+
export { createGenerator };
|
package/dist/generator/index.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
import{createGenerator as e}from"./create.mjs";export{e as createGenerator};
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { i as SinkInput, n as Sink } from "./sink-CTx7UtqU.cjs";
|
|
2
|
+
import { i as SourceInput, n as Source } from "./source-B3tctCZE.cjs";
|
|
3
3
|
import { SchemaInput, SchemaOf } from "@power-plant/schema";
|
|
4
|
+
import { InferLoadOptions, LoadInput } from "@stryke/resolve/types";
|
|
4
5
|
|
|
5
6
|
//#region src/types/generator.d.ts
|
|
6
|
-
interface GeneratorMeta<TSpec> {
|
|
7
|
+
interface GeneratorMeta<TSpec, TOptions extends object> {
|
|
7
8
|
/**
|
|
8
9
|
* A string description (or a function that returns a string) outlining the purpose or behavior of the generator.
|
|
9
10
|
*/
|
|
10
11
|
description?: string | ((spec: TSpec) => string);
|
|
11
12
|
}
|
|
12
|
-
interface
|
|
13
|
+
interface GeneratorInputObject<TSpec, TOptions extends object, TReturns = void> {
|
|
13
14
|
/**
|
|
14
15
|
* Optional metadata about the generator, such as a description of the output it produces.
|
|
15
16
|
*/
|
|
16
|
-
meta?: GeneratorMeta<TSpec>;
|
|
17
|
+
meta?: GeneratorMeta<TSpec, TOptions>;
|
|
17
18
|
/**
|
|
18
19
|
* The schema input that defines the structure of the specification object for this generator.
|
|
19
20
|
*/
|
|
@@ -25,13 +26,15 @@ interface GeneratorInput<TSpec, TOptions = never> {
|
|
|
25
26
|
/**
|
|
26
27
|
* The sink input that consumes generated output.
|
|
27
28
|
*/
|
|
28
|
-
sink: SinkInput<TSpec, TOptions>;
|
|
29
|
+
sink: SinkInput<TSpec, TOptions, TReturns>;
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
+
type GeneratorInput<TSpec, TOptions extends object, TReturns = void> = LoadInput | GeneratorInputObject<TSpec, TOptions, TReturns>;
|
|
32
|
+
type InferCreateGeneratorOptions<T extends GeneratorInput<any, any, any>> = T extends LoadInput ? InferLoadOptions<T> : {};
|
|
33
|
+
interface Generator<TSpec, TOptions extends object, TReturns = void> {
|
|
31
34
|
/**
|
|
32
35
|
* Optional metadata about the generator, such as a description of the output it produces.
|
|
33
36
|
*/
|
|
34
|
-
meta?: GeneratorMeta<TSpec>;
|
|
37
|
+
meta?: GeneratorMeta<TSpec, TOptions>;
|
|
35
38
|
/**
|
|
36
39
|
* The schema input that defines the structure of the specification object for this generator.
|
|
37
40
|
*/
|
|
@@ -43,15 +46,15 @@ interface Generator<TSpec, TOptions = never> {
|
|
|
43
46
|
/**
|
|
44
47
|
* The sink 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.
|
|
45
48
|
*/
|
|
46
|
-
sink: Sink<TSpec, TOptions>;
|
|
49
|
+
sink: Sink<TSpec, TOptions, TReturns>;
|
|
47
50
|
/**
|
|
48
51
|
* The generate function that executes the generator logic, taking in options and producing output based on the source and sink definitions.
|
|
49
52
|
*
|
|
50
53
|
* @param options - The options to be passed to the generator, which can be used to influence the generation process.
|
|
51
54
|
* @returns A promise that resolves when the generation process is complete.
|
|
52
55
|
*/
|
|
53
|
-
generate: (options: TOptions) => Promise<
|
|
56
|
+
generate: (options: TOptions) => Promise<TReturns>;
|
|
54
57
|
}
|
|
55
58
|
//#endregion
|
|
56
|
-
export { GeneratorInput as n,
|
|
57
|
-
//# sourceMappingURL=generator-
|
|
59
|
+
export { InferCreateGeneratorOptions as a, GeneratorMeta as i, GeneratorInput as n, GeneratorInputObject as r, Generator as t };
|
|
60
|
+
//# sourceMappingURL=generator-C1_Q-QAb.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator-C1_Q-QAb.d.cts","names":[],"sources":["../src/types/generator.ts"],"mappings":";;;;;;UAwBiB,aAAA;;AAAjB;;EAIE,WAAA,cAAyB,IAAA,EAAM,KAAK;AAAA;AAAA,UAGrB,oBAAA;EAPqB;;;EAepC,IAAA,GAAO,aAAA,CAAc,KAAA,EAAO,QAAA;EAXQ;AAAA;AAGtC;EAaE,MAAA,EAAQ,WAAA,CAAY,KAAA;EAbe;;;EAkBnC,MAAA,EAAQ,WAAA,CAAY,KAAA,EAAO,QAAA;EALP;;;EAUpB,IAAA,EAAM,SAAA,CAAU,KAAA,EAAO,QAAA,EAAU,QAAA;AAAA;AAAA,KAGvB,cAAA,oDACR,SAAA,GACA,oBAAA,CAAqB,KAAA,EAAO,QAAA,EAAU,QAAA;AAAA,KAE9B,2BAAA,WACA,cAAA,mBACR,CAAA,SAAU,SAAA,GACV,gBAAA,CAAiB,CAAA;AAAA,UAIJ,SAAA;EAdT;;;EAkBN,IAAA,GAAO,aAAA,CAAc,KAAA,EAAO,QAAA;EAvC5B;;;EA4CA,MAAA,EAAQ,QAAA,CAAS,KAAA;EAtCI;;;EA2CrB,MAAA,EAAQ,MAAA,CAAO,KAAA,EAAO,QAAA;EAtCF;;;EA2CpB,IAAA,EAAM,IAAA,CAAK,KAAA,EAAO,QAAA,EAAU,QAAA;EAtCD;;;;;;EA8C3B,QAAA,GAAW,OAAA,EAAS,QAAA,KAAa,OAAA,CAAQ,QAAA;AAAA"}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { i as SinkInput, n as Sink } from "./sink-CAWlC7am.mjs";
|
|
2
|
+
import { i as SourceInput, n as Source } from "./source-DjKhYXZ6.mjs";
|
|
3
3
|
import { SchemaInput, SchemaOf } from "@power-plant/schema";
|
|
4
|
+
import { InferLoadOptions, LoadInput } from "@stryke/resolve/types";
|
|
4
5
|
|
|
5
6
|
//#region src/types/generator.d.ts
|
|
6
|
-
interface GeneratorMeta<TSpec> {
|
|
7
|
+
interface GeneratorMeta<TSpec, TOptions extends object> {
|
|
7
8
|
/**
|
|
8
9
|
* A string description (or a function that returns a string) outlining the purpose or behavior of the generator.
|
|
9
10
|
*/
|
|
10
11
|
description?: string | ((spec: TSpec) => string);
|
|
11
12
|
}
|
|
12
|
-
interface
|
|
13
|
+
interface GeneratorInputObject<TSpec, TOptions extends object, TReturns = void> {
|
|
13
14
|
/**
|
|
14
15
|
* Optional metadata about the generator, such as a description of the output it produces.
|
|
15
16
|
*/
|
|
16
|
-
meta?: GeneratorMeta<TSpec>;
|
|
17
|
+
meta?: GeneratorMeta<TSpec, TOptions>;
|
|
17
18
|
/**
|
|
18
19
|
* The schema input that defines the structure of the specification object for this generator.
|
|
19
20
|
*/
|
|
@@ -25,13 +26,15 @@ interface GeneratorInput<TSpec, TOptions = never> {
|
|
|
25
26
|
/**
|
|
26
27
|
* The sink input that consumes generated output.
|
|
27
28
|
*/
|
|
28
|
-
sink: SinkInput<TSpec, TOptions>;
|
|
29
|
+
sink: SinkInput<TSpec, TOptions, TReturns>;
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
+
type GeneratorInput<TSpec, TOptions extends object, TReturns = void> = LoadInput | GeneratorInputObject<TSpec, TOptions, TReturns>;
|
|
32
|
+
type InferCreateGeneratorOptions<T extends GeneratorInput<any, any, any>> = T extends LoadInput ? InferLoadOptions<T> : {};
|
|
33
|
+
interface Generator<TSpec, TOptions extends object, TReturns = void> {
|
|
31
34
|
/**
|
|
32
35
|
* Optional metadata about the generator, such as a description of the output it produces.
|
|
33
36
|
*/
|
|
34
|
-
meta?: GeneratorMeta<TSpec>;
|
|
37
|
+
meta?: GeneratorMeta<TSpec, TOptions>;
|
|
35
38
|
/**
|
|
36
39
|
* The schema input that defines the structure of the specification object for this generator.
|
|
37
40
|
*/
|
|
@@ -43,15 +46,15 @@ interface Generator<TSpec, TOptions = never> {
|
|
|
43
46
|
/**
|
|
44
47
|
* The sink 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.
|
|
45
48
|
*/
|
|
46
|
-
sink: Sink<TSpec, TOptions>;
|
|
49
|
+
sink: Sink<TSpec, TOptions, TReturns>;
|
|
47
50
|
/**
|
|
48
51
|
* The generate function that executes the generator logic, taking in options and producing output based on the source and sink definitions.
|
|
49
52
|
*
|
|
50
53
|
* @param options - The options to be passed to the generator, which can be used to influence the generation process.
|
|
51
54
|
* @returns A promise that resolves when the generation process is complete.
|
|
52
55
|
*/
|
|
53
|
-
generate: (options: TOptions) => Promise<
|
|
56
|
+
generate: (options: TOptions) => Promise<TReturns>;
|
|
54
57
|
}
|
|
55
58
|
//#endregion
|
|
56
|
-
export { GeneratorInput as n,
|
|
57
|
-
//# sourceMappingURL=generator-
|
|
59
|
+
export { InferCreateGeneratorOptions as a, GeneratorMeta as i, GeneratorInput as n, GeneratorInputObject as r, Generator as t };
|
|
60
|
+
//# sourceMappingURL=generator-MC25UERM.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator-MC25UERM.d.mts","names":[],"sources":["../src/types/generator.ts"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`})
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./sink/create.cjs"),t=require("./source/create.cjs"),n=require("./generator/create.cjs");require("./generator/index.cjs"),require("./sink/index.cjs");const r=require("./source/define.cjs");require("./source/index.cjs"),exports.createGenerator=n.createGenerator,exports.createSink=e.createSink,exports.createSource=t.createSource,exports.defineSource=r.defineSource,exports.extractSinkMeta=e.extractSinkMeta,exports.extractSourceMeta=t.extractSourceMeta;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { a as
|
|
3
|
-
import { n as GeneratorInput, r as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
export { type Generator, type GeneratorInput, type GeneratorMeta, type Sink, type SinkFunction, type SinkInput, type
|
|
1
|
+
import { a as SinkInputObject, i as SinkInput, n as Sink, o as SinkMeta, r as SinkFunction, s as SinkMetaInput, t as InferCreateSinkOptions } from "./sink-CTx7UtqU.cjs";
|
|
2
|
+
import { a as SourceInputObject, i as SourceInput, n as Source, o as SourceMeta, r as SourceFunction, s as SourceMetaInput, t as InferCreateSourceOptions } from "./source-B3tctCZE.cjs";
|
|
3
|
+
import { a as InferCreateGeneratorOptions, i as GeneratorMeta, n as GeneratorInput, r as GeneratorInputObject, t as Generator } from "./generator-C1_Q-QAb.cjs";
|
|
4
|
+
import { t as createGenerator } from "./create-Cfgth9sz.cjs";
|
|
5
|
+
import { n as extractSinkMeta, t as createSink } from "./create-D32Jusq_.cjs";
|
|
6
|
+
import { n as extractSourceMeta, t as createSource } from "./create-DoyLue8r.cjs";
|
|
7
|
+
import { t as defineSource } from "./define-DEe-HPar.cjs";
|
|
8
|
+
export { type Generator, type GeneratorInput, type GeneratorInputObject, type GeneratorMeta, type InferCreateGeneratorOptions, type InferCreateSinkOptions, type InferCreateSourceOptions, type Sink, type SinkFunction, type SinkInput, type SinkInputObject, type SinkMeta, type SinkMetaInput, type Source, type SourceFunction, type SourceInput, type SourceInputObject, type SourceMeta, type SourceMetaInput, createGenerator, createSink, createSource, defineSource, extractSinkMeta, extractSourceMeta };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { a as
|
|
3
|
-
import { n as GeneratorInput, r as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
export { type Generator, type GeneratorInput, type GeneratorMeta, type Sink, type SinkFunction, type SinkInput, type
|
|
1
|
+
import { a as SinkInputObject, i as SinkInput, n as Sink, o as SinkMeta, r as SinkFunction, s as SinkMetaInput, t as InferCreateSinkOptions } from "./sink-CAWlC7am.mjs";
|
|
2
|
+
import { a as SourceInputObject, i as SourceInput, n as Source, o as SourceMeta, r as SourceFunction, s as SourceMetaInput, t as InferCreateSourceOptions } from "./source-DjKhYXZ6.mjs";
|
|
3
|
+
import { a as InferCreateGeneratorOptions, i as GeneratorMeta, n as GeneratorInput, r as GeneratorInputObject, t as Generator } from "./generator-MC25UERM.mjs";
|
|
4
|
+
import { t as createGenerator } from "./create-DVpg-3po.mjs";
|
|
5
|
+
import { n as extractSinkMeta, t as createSink } from "./create-B14Jt6Iu.mjs";
|
|
6
|
+
import { n as extractSourceMeta, t as createSource } from "./create-vgEDsShD.mjs";
|
|
7
|
+
import { t as defineSource } from "./define-RneysDu1.mjs";
|
|
8
|
+
export { type Generator, type GeneratorInput, type GeneratorInputObject, type GeneratorMeta, type InferCreateGeneratorOptions, type InferCreateSinkOptions, type InferCreateSourceOptions, type Sink, type SinkFunction, type SinkInput, type SinkInputObject, type SinkMeta, type SinkMetaInput, type Source, type SourceFunction, type SourceInput, type SourceInputObject, type SourceMeta, type SourceMetaInput, createGenerator, createSink, createSource, defineSource, extractSinkMeta, extractSourceMeta };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{createSink as e,extractSinkMeta as t}from"./sink/create.mjs";import{createSource as n,extractSourceMeta as r}from"./source/create.mjs";import{createGenerator as i}from"./generator/create.mjs";import"./generator/index.mjs";import"./sink/index.mjs";import{defineSource as a}from"./source/define.mjs";import"./source/index.mjs";export{i as createGenerator,e as createSink,n as createSource,a as defineSource,t as extractSinkMeta,r as extractSourceMeta};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let e=require("@power-plant/schema/metadata");function t(t,n){let r=t??{schema:{}},i=r?.meta??{};return i.name=(0,e.resolveMetaName)(r?.schema,i,n?.name),i.version=(0,e.resolveMetaVersion)(r?.schema,i,n?.version),i.id=(0,e.resolveMetaId)(r?.schema,i),i.displayName=(0,e.resolveMetaDisplayName)(r?.schema,i,n?.displayName),i.links=(0,e.resolveMetaLinks)(r?.schema,i,n?.links),n?.deprecated&&(i.deprecated=n?.deprecated),n?.usage&&(i.usage=n?.usage),n?.tags&&(i.tags=n?.tags),i}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return t}});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{resolveMetaDisplayName as e,resolveMetaId as t,resolveMetaLinks as n,resolveMetaName as r,resolveMetaVersion as i}from"@power-plant/schema/metadata";function a(a,o){let s=a??{schema:{}},c=s?.meta??{};return c.name=r(s?.schema,c,o?.name),c.version=i(s?.schema,c,o?.version),c.id=t(s?.schema,c),c.displayName=e(s?.schema,c,o?.displayName),c.links=n(s?.schema,c,o?.links),o?.deprecated&&(c.deprecated=o?.deprecated),o?.usage&&(c.usage=o?.usage),o?.tags&&(c.tags=o?.tags),c}export{a as t};
|
|
2
|
+
//# sourceMappingURL=metadata-Dmhrb3Kv.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata-Dmhrb3Kv.mjs","names":[],"sources":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../metadata-Cb6iMZqW.cjs"),t=require("./helpers.cjs");let n=require("@power-plant/schema/extract"),r=require("@stryke/resolve/load"),i=require("@power-plant/schema/helpers"),a=require("@power-plant/schema/metadata"),o=require("@stryke/resolve/type-checks");function s(t,n){let r=e.t(t,n);return r.description=(0,a.resolveMetaDescription)(`Accepts a ${t?.meta?.displayName?`${t?.meta?.displayName} `:``}specification and processes it with a {displayName} sink.`,t?.schema??{},r,n?.description),r}async function c(e,a,l={}){let{sink:u,meta:d,schema:f}=t.isSinkInputObject(a)?a:{sink:a,meta:{}},p=e;f&&(p=await(0,n.extract)(f,l),p.schema=(0,i.mergeMetadata)(p.schema,e.schema));let m;if((0,o.isLoadInput)(u))try{let e=await(0,r.load)(u,l);m=t.isSinkInputObject(e)?await c(p,e.sink,l).then(e=>e.sink):e}catch{}return m||=u,{schema:p,sink:m,meta:s(p,d)}}exports.createSink=c,exports.extractSinkMeta=s;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"../metadata-Dmhrb3Kv.mjs";import{isSinkInputObject as t}from"./helpers.mjs";import{extract as n}from"@power-plant/schema/extract";import{load as r}from"@stryke/resolve/load";import{mergeMetadata as i}from"@power-plant/schema/helpers";import{resolveMetaDescription as a}from"@power-plant/schema/metadata";import{isLoadInput as o}from"@stryke/resolve/type-checks";function s(t,n){let r=e(t,n);return r.description=a(`Accepts a ${t?.meta?.displayName?`${t?.meta?.displayName} `:``}specification and processes it with a {displayName} sink.`,t?.schema??{},r,n?.description),r}async function c(e,a,l={}){let{sink:u,meta:d,schema:f}=t(a)?a:{sink:a,meta:{}},p=e;f&&(p=await n(f,l),p.schema=i(p.schema,e.schema));let m;if(o(u))try{let e=await r(u,l);m=t(e)?await c(p,e.sink,l).then(e=>e.sink):e}catch{}return m||=u,{schema:p,sink:m,meta:s(p,d)}}export{c as createSink,s as extractSinkMeta};
|
|
2
|
+
//# sourceMappingURL=create.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.mjs","names":[],"sources":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./helpers.cjs");function t(t){return e.isSinkInputObject(t)?t:{sink:t}}exports.defineSink=t;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { a as SinkInputObject, i as SinkInput } from "../sink-CTx7UtqU.cjs";
|
|
2
|
+
//#region src/sink/define.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Defines a sink input object. If the provided sink is already a sink input object, it will be returned as-is. Otherwise, it will be wrapped in an object with a `sink` property.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { defineSink } from "@power-plant/core";
|
|
9
|
+
*
|
|
10
|
+
* // Define a sink from a sink function
|
|
11
|
+
* export default defineSink((spec, options) => {
|
|
12
|
+
* // Your sink logic here
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* // Define a sink from an existing sink input object
|
|
16
|
+
* export default defineSink({
|
|
17
|
+
* meta: {
|
|
18
|
+
* name: "My Sink",
|
|
19
|
+
* version: "1.0.0",
|
|
20
|
+
* description: "A sink that does something.",
|
|
21
|
+
* },
|
|
22
|
+
* schema: z.object({
|
|
23
|
+
* // Your schema definition here
|
|
24
|
+
* }),
|
|
25
|
+
* sink: (spec, options) => {
|
|
26
|
+
* // Your sink logic here
|
|
27
|
+
* },
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param sink - The sink input to define. This can be either a sink input object or a sink function.
|
|
32
|
+
* @returns A sink input object that contains the provided sink. If the input was already a sink input object, it will be returned unchanged.
|
|
33
|
+
*/
|
|
34
|
+
declare function defineSink<TSpec, TOptions extends object, TReturns = void>(sink: SinkInput<TSpec, TOptions, TReturns>): SinkInputObject<TSpec, TOptions, TReturns>;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { defineSink };
|
|
37
|
+
//# sourceMappingURL=define.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.d.cts","names":[],"sources":["../../src/sink/define.ts"],"mappings":";;;;;AAoDA;;;;;;;;;;;;;;;;;;;;;;;;;;AAE4C;;iBAF5B,UAAA,kDACd,IAAA,EAAM,SAAA,CAAU,KAAA,EAAO,QAAA,EAAU,QAAA,IAChC,eAAA,CAAgB,KAAA,EAAO,QAAA,EAAU,QAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { a as SinkInputObject, i as SinkInput } from "../sink-CAWlC7am.mjs";
|
|
2
|
+
//#region src/sink/define.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Defines a sink input object. If the provided sink is already a sink input object, it will be returned as-is. Otherwise, it will be wrapped in an object with a `sink` property.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { defineSink } from "@power-plant/core";
|
|
9
|
+
*
|
|
10
|
+
* // Define a sink from a sink function
|
|
11
|
+
* export default defineSink((spec, options) => {
|
|
12
|
+
* // Your sink logic here
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* // Define a sink from an existing sink input object
|
|
16
|
+
* export default defineSink({
|
|
17
|
+
* meta: {
|
|
18
|
+
* name: "My Sink",
|
|
19
|
+
* version: "1.0.0",
|
|
20
|
+
* description: "A sink that does something.",
|
|
21
|
+
* },
|
|
22
|
+
* schema: z.object({
|
|
23
|
+
* // Your schema definition here
|
|
24
|
+
* }),
|
|
25
|
+
* sink: (spec, options) => {
|
|
26
|
+
* // Your sink logic here
|
|
27
|
+
* },
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param sink - The sink input to define. This can be either a sink input object or a sink function.
|
|
32
|
+
* @returns A sink input object that contains the provided sink. If the input was already a sink input object, it will be returned unchanged.
|
|
33
|
+
*/
|
|
34
|
+
declare function defineSink<TSpec, TOptions extends object, TReturns = void>(sink: SinkInput<TSpec, TOptions, TReturns>): SinkInputObject<TSpec, TOptions, TReturns>;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { defineSink };
|
|
37
|
+
//# sourceMappingURL=define.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.d.mts","names":[],"sources":["../../src/sink/define.ts"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.mjs","names":[],"sources":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@stryke/type-checks/is-set-object");function t(t){return(0,e.isSetObject)(t)&&`sink`in t&&t.sink!==void 0}exports.isSinkInputObject=t;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { a as SinkInputObject } from "../sink-CTx7UtqU.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/sink/helpers.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Checks if the provided input is a {@link SinkInputObject}.
|
|
6
|
+
*
|
|
7
|
+
* @param input - The input to check.
|
|
8
|
+
* @returns True if the input is a {@link SinkInputObject}, false otherwise.
|
|
9
|
+
*/
|
|
10
|
+
declare function isSinkInputObject<TSpec, TOptions extends object, TReturns = void>(input: unknown): input is SinkInputObject<TSpec, TOptions, TReturns>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { isSinkInputObject };
|
|
13
|
+
//# sourceMappingURL=helpers.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.cts","names":[],"sources":["../../src/sink/helpers.ts"],"mappings":";;;;;AA2BA;;;;iBAAgB,iBAAA,kDAId,KAAA,YAAiB,KAAA,IAAS,eAAA,CAAgB,KAAA,EAAO,QAAA,EAAU,QAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { a as SinkInputObject } from "../sink-CAWlC7am.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/sink/helpers.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Checks if the provided input is a {@link SinkInputObject}.
|
|
6
|
+
*
|
|
7
|
+
* @param input - The input to check.
|
|
8
|
+
* @returns True if the input is a {@link SinkInputObject}, false otherwise.
|
|
9
|
+
*/
|
|
10
|
+
declare function isSinkInputObject<TSpec, TOptions extends object, TReturns = void>(input: unknown): input is SinkInputObject<TSpec, TOptions, TReturns>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { isSinkInputObject };
|
|
13
|
+
//# sourceMappingURL=helpers.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.mts","names":[],"sources":["../../src/sink/helpers.ts"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.mjs","names":[],"sources":[],"mappings":""}
|
package/dist/sink/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./create.cjs");exports.createSink=e.createSink,exports.extractSinkMeta=e.extractSinkMeta;
|
package/dist/sink/index.d.cts
CHANGED
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { ResolveOptions } from "@power-plant/schema/resolve";
|
|
4
|
-
|
|
5
|
-
//#region src/sink/constants.d.ts
|
|
6
|
-
declare const VALID_SINK_FILE_EXTENSIONS: string[];
|
|
7
|
-
//#endregion
|
|
8
|
-
//#region src/sink/extract.d.ts
|
|
9
|
-
/**
|
|
10
|
-
* Normalizes any accepted sink input into a concrete sink descriptor.
|
|
11
|
-
*/
|
|
12
|
-
declare function extractSink<TSpec, TOptions = never>(schema: SchemaOf<TSpec>, input: SinkInput<TSpec, TOptions>, options?: ResolveOptions): Promise<Sink<TSpec, TOptions>>;
|
|
13
|
-
//#endregion
|
|
14
|
-
export { type Sink, type SinkFunction, type SinkInput, type SinkInputWithMeta, type SinkMeta, VALID_SINK_FILE_EXTENSIONS, extractSink };
|
|
15
|
-
//# sourceMappingURL=index.d.cts.map
|
|
1
|
+
import { n as extractSinkMeta, t as createSink } from "../create-D32Jusq_.cjs";
|
|
2
|
+
export { createSink, extractSinkMeta };
|
package/dist/sink/index.d.mts
CHANGED
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { SchemaOf } from "@power-plant/schema/types";
|
|
4
|
-
|
|
5
|
-
//#region src/sink/constants.d.ts
|
|
6
|
-
declare const VALID_SINK_FILE_EXTENSIONS: string[];
|
|
7
|
-
//#endregion
|
|
8
|
-
//#region src/sink/extract.d.ts
|
|
9
|
-
/**
|
|
10
|
-
* Normalizes any accepted sink input into a concrete sink descriptor.
|
|
11
|
-
*/
|
|
12
|
-
declare function extractSink<TSpec, TOptions = never>(schema: SchemaOf<TSpec>, input: SinkInput<TSpec, TOptions>, options?: ResolveOptions): Promise<Sink<TSpec, TOptions>>;
|
|
13
|
-
//#endregion
|
|
14
|
-
export { type Sink, type SinkFunction, type SinkInput, type SinkInputWithMeta, type SinkMeta, VALID_SINK_FILE_EXTENSIONS, extractSink };
|
|
15
|
-
//# sourceMappingURL=index.d.mts.map
|
|
1
|
+
import { n as extractSinkMeta, t as createSink } from "../create-B14Jt6Iu.mjs";
|
|
2
|
+
export { createSink, extractSinkMeta };
|
package/dist/sink/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{createSink as e,extractSinkMeta as t}from"./create.mjs";export{e as createSink,t as extractSinkMeta};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { t as MaybePromise } from "./base-BKbfgxno.mjs";
|
|
2
|
+
import { InferLoadOptions, LoadInput } from "@stryke/resolve/types";
|
|
3
|
+
import { Meta, MetaInput, SchemaInput, SchemaOf } from "@power-plant/schema/types";
|
|
4
|
+
|
|
5
|
+
//#region src/types/sink.d.ts
|
|
6
|
+
type SinkFunction<TSpec, TOptions extends object, TReturns = void> = (spec: TSpec, context: TOptions) => MaybePromise<TReturns>;
|
|
7
|
+
interface SinkMetaInput<TSpec, TOptions extends object> extends MetaInput<TSpec> {
|
|
8
|
+
/**
|
|
9
|
+
* 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.
|
|
10
|
+
*/
|
|
11
|
+
produces?: string;
|
|
12
|
+
}
|
|
13
|
+
interface SinkMeta<TSpec, TOptions extends object> extends Meta<TSpec> {
|
|
14
|
+
/**
|
|
15
|
+
* 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.
|
|
16
|
+
*/
|
|
17
|
+
produces?: string;
|
|
18
|
+
}
|
|
19
|
+
interface SinkInputObject<TSpec, TOptions extends object, TReturns = void> {
|
|
20
|
+
/**
|
|
21
|
+
* 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.
|
|
22
|
+
*/
|
|
23
|
+
schema?: SchemaInput<TSpec>;
|
|
24
|
+
/**
|
|
25
|
+
* Optional metadata that provides contextual information for the sink.
|
|
26
|
+
*/
|
|
27
|
+
meta?: SinkMeta<TSpec, TOptions>;
|
|
28
|
+
/**
|
|
29
|
+
* The sink implementation, either as a callable function or a file reference.
|
|
30
|
+
*/
|
|
31
|
+
sink: SinkFunction<TSpec, TOptions, TReturns> | LoadInput;
|
|
32
|
+
}
|
|
33
|
+
type SinkInput<TSpec, TOptions extends object, TReturns = void> = LoadInput | SinkFunction<TSpec, TOptions, TReturns> | SinkInputObject<TSpec, TOptions, TReturns>;
|
|
34
|
+
type InferCreateSinkOptions<T extends SinkInput<any, any, any>> = T extends LoadInput ? InferLoadOptions<T> : {};
|
|
35
|
+
interface Sink<TSpec, TOptions extends object, TReturns = void> {
|
|
36
|
+
/**
|
|
37
|
+
* 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.
|
|
38
|
+
*/
|
|
39
|
+
schema: SchemaOf<TSpec>;
|
|
40
|
+
/**
|
|
41
|
+
* Optional metadata that provides contextual information for the sink.
|
|
42
|
+
*/
|
|
43
|
+
meta?: SinkMeta<TSpec, TOptions>;
|
|
44
|
+
/**
|
|
45
|
+
* The sink 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.
|
|
46
|
+
*
|
|
47
|
+
* @remarks
|
|
48
|
+
* The `sink` property is defined as a function that takes the specification object and any additional parameters, and returns a value or a promise that resolves to a value. This allows for flexibility in how the generator sends its output data, enabling both synchronous and asynchronous data handling based on the specification.
|
|
49
|
+
*
|
|
50
|
+
* @param spec - The specification object that conforms to the defined schema input.
|
|
51
|
+
* @param params - Additional parameters that may be needed for the sink function to process the output data.
|
|
52
|
+
* @returns A value or a promise that resolves to a value, which will be used as the output data for the generator.
|
|
53
|
+
*/
|
|
54
|
+
sink: SinkFunction<TSpec, TOptions, TReturns>;
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { SinkInputObject as a, SinkInput as i, Sink as n, SinkMeta as o, SinkFunction as r, SinkMetaInput as s, InferCreateSinkOptions as t };
|
|
58
|
+
//# sourceMappingURL=sink-CAWlC7am.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sink-CAWlC7am.d.mts","names":[],"sources":["../src/types/sink.ts"],"mappings":""}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { t as MaybePromise } from "./base-BKbfgxno.cjs";
|
|
2
|
+
import { InferLoadOptions, LoadInput } from "@stryke/resolve/types";
|
|
3
|
+
import { Meta, MetaInput, SchemaInput, SchemaOf } from "@power-plant/schema/types";
|
|
4
|
+
|
|
5
|
+
//#region src/types/sink.d.ts
|
|
6
|
+
type SinkFunction<TSpec, TOptions extends object, TReturns = void> = (spec: TSpec, context: TOptions) => MaybePromise<TReturns>;
|
|
7
|
+
interface SinkMetaInput<TSpec, TOptions extends object> extends MetaInput<TSpec> {
|
|
8
|
+
/**
|
|
9
|
+
* 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.
|
|
10
|
+
*/
|
|
11
|
+
produces?: string;
|
|
12
|
+
}
|
|
13
|
+
interface SinkMeta<TSpec, TOptions extends object> extends Meta<TSpec> {
|
|
14
|
+
/**
|
|
15
|
+
* 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.
|
|
16
|
+
*/
|
|
17
|
+
produces?: string;
|
|
18
|
+
}
|
|
19
|
+
interface SinkInputObject<TSpec, TOptions extends object, TReturns = void> {
|
|
20
|
+
/**
|
|
21
|
+
* 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.
|
|
22
|
+
*/
|
|
23
|
+
schema?: SchemaInput<TSpec>;
|
|
24
|
+
/**
|
|
25
|
+
* Optional metadata that provides contextual information for the sink.
|
|
26
|
+
*/
|
|
27
|
+
meta?: SinkMeta<TSpec, TOptions>;
|
|
28
|
+
/**
|
|
29
|
+
* The sink implementation, either as a callable function or a file reference.
|
|
30
|
+
*/
|
|
31
|
+
sink: SinkFunction<TSpec, TOptions, TReturns> | LoadInput;
|
|
32
|
+
}
|
|
33
|
+
type SinkInput<TSpec, TOptions extends object, TReturns = void> = LoadInput | SinkFunction<TSpec, TOptions, TReturns> | SinkInputObject<TSpec, TOptions, TReturns>;
|
|
34
|
+
type InferCreateSinkOptions<T extends SinkInput<any, any, any>> = T extends LoadInput ? InferLoadOptions<T> : {};
|
|
35
|
+
interface Sink<TSpec, TOptions extends object, TReturns = void> {
|
|
36
|
+
/**
|
|
37
|
+
* 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.
|
|
38
|
+
*/
|
|
39
|
+
schema: SchemaOf<TSpec>;
|
|
40
|
+
/**
|
|
41
|
+
* Optional metadata that provides contextual information for the sink.
|
|
42
|
+
*/
|
|
43
|
+
meta?: SinkMeta<TSpec, TOptions>;
|
|
44
|
+
/**
|
|
45
|
+
* The sink 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.
|
|
46
|
+
*
|
|
47
|
+
* @remarks
|
|
48
|
+
* The `sink` property is defined as a function that takes the specification object and any additional parameters, and returns a value or a promise that resolves to a value. This allows for flexibility in how the generator sends its output data, enabling both synchronous and asynchronous data handling based on the specification.
|
|
49
|
+
*
|
|
50
|
+
* @param spec - The specification object that conforms to the defined schema input.
|
|
51
|
+
* @param params - Additional parameters that may be needed for the sink function to process the output data.
|
|
52
|
+
* @returns A value or a promise that resolves to a value, which will be used as the output data for the generator.
|
|
53
|
+
*/
|
|
54
|
+
sink: SinkFunction<TSpec, TOptions, TReturns>;
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { SinkInputObject as a, SinkInput as i, Sink as n, SinkMeta as o, SinkFunction as r, SinkMetaInput as s, InferCreateSinkOptions as t };
|
|
58
|
+
//# sourceMappingURL=sink-CTx7UtqU.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sink-CTx7UtqU.d.cts","names":[],"sources":["../src/types/sink.ts"],"mappings":";;;;;KA2BY,YAAA,qDACV,IAAA,EAAM,KAAA,EACN,OAAA,EAAS,QAAA,KACN,YAAA,CAAa,QAAA;AAAA,UAED,aAAA,yCAIP,SAAS,CAAC,KAAA;EATR;;;EAaV,QAAA;AAAA;AAAA,UAIe,QAAA,yCAAiD,IAAI,CAAC,KAAA;EAdlE;;;EAkBH,QAAA;AAAA;AAAA,UAGe,eAAA;EAvBT;;;EA+BN,MAAA,GAAS,WAAA,CAAY,KAAA;EA7BlB;;;EAkCH,IAAA,GAAO,QAAA,CAAS,KAAA,EAAO,QAAA;EAhCR;;;EAqCf,IAAA,EAAM,YAAA,CAAa,KAAA,EAAO,QAAA,EAAU,QAAA,IAAY,SAAA;AAAA;AAAA,KAGtC,SAAA,oDACR,SAAA,GACA,YAAA,CAAa,KAAA,EAAO,QAAA,EAAU,QAAA,IAC9B,eAAA,CAAgB,KAAA,EAAO,QAAA,EAAU,QAAA;AAAA,KAEzB,sBAAA,WAAiC,SAAA,mBAC3C,CAAA,SAAU,SAAA,GACN,gBAAA,CAAiB,CAAA;AAAA,UAIN,IAAA;EA3Cf;;AAAQ;EA+CR,MAAA,EAAQ,QAAA,CAAS,KAAA;EA3CM;;;EAgDvB,IAAA,GAAO,QAAA,CAAS,KAAA,EAAO,QAAA;EAhDQ;;;;;AAIvB;AAGV;;;;EAqDE,IAAA,EAAM,YAAA,CAAa,KAAA,EAAO,QAAA,EAAU,QAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../metadata-Cb6iMZqW.cjs"),t=require("./helpers.cjs");let n=require("@power-plant/schema/extract"),r=require("@stryke/resolve/load"),i=require("@power-plant/schema/helpers"),a=require("@power-plant/schema/metadata"),o=require("@stryke/resolve/type-checks");function s(t,n){let r=e.t(t,n);return r.description=(0,a.resolveMetaDescription)(`Determines the ${t?.meta?.displayName?`${t?.meta?.displayName} `:``}specification from a {displayName} source.`,t?.schema??{},r,n?.description),r}async function c(e,a,l={}){let{source:u,meta:d,schema:f}=t.isSourceInputObject(a)?a:{source:a,meta:{}},p=e;f&&(p=await(0,n.extract)(f,l),p.schema=(0,i.mergeMetadata)(p.schema,e.schema));let m;if((0,o.isLoadInput)(u))try{let e=await(0,r.load)(u,l);m=t.isSourceInputObject(e)?await c(p,e.source,l).then(e=>e.source):e}catch{}return m||=u,{schema:p,source:m,meta:s(p,d)}}exports.createSource=c,exports.extractSourceMeta=s;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"../metadata-Dmhrb3Kv.mjs";import{isSourceInputObject as t}from"./helpers.mjs";import{extract as n}from"@power-plant/schema/extract";import{load as r}from"@stryke/resolve/load";import{mergeMetadata as i}from"@power-plant/schema/helpers";import{resolveMetaDescription as a}from"@power-plant/schema/metadata";import{isLoadInput as o}from"@stryke/resolve/type-checks";function s(t,n){let r=e(t,n);return r.description=a(`Determines the ${t?.meta?.displayName?`${t?.meta?.displayName} `:``}specification from a {displayName} source.`,t?.schema??{},r,n?.description),r}async function c(e,a,l={}){let{source:u,meta:d,schema:f}=t(a)?a:{source:a,meta:{}},p=e;f&&(p=await n(f,l),p.schema=i(p.schema,e.schema));let m;if(o(u))try{let e=await r(u,l);m=t(e)?await c(p,e.source,l).then(e=>e.source):e}catch{}return m||=u,{schema:p,source:m,meta:s(p,d)}}export{c as createSource,s as extractSourceMeta};
|
|
2
|
+
//# sourceMappingURL=create.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.mjs","names":[],"sources":[],"mappings":""}
|