@power-plant/core 0.0.2 → 0.0.4
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/create-23iLtMb_.cjs +1 -0
- package/dist/create-BR4IeVl4.mjs +2 -0
- package/dist/create-BR4IeVl4.mjs.map +1 -0
- package/dist/create-BqRl9d7m.d.cts +19 -0
- package/dist/create-BqRl9d7m.d.cts.map +1 -0
- package/dist/create-C-rR8nuY.d.mts +23 -0
- package/dist/create-C-rR8nuY.d.mts.map +1 -0
- package/dist/create-Cz9qVT4m.d.cts +23 -0
- package/dist/create-Cz9qVT4m.d.cts.map +1 -0
- package/dist/create-DAGPeYVI.d.cts +25 -0
- package/dist/create-DAGPeYVI.d.cts.map +1 -0
- package/dist/create-DEe398aQ.d.mts +25 -0
- package/dist/create-DEe398aQ.d.mts.map +1 -0
- package/dist/create-DUt-efk7.d.cts +25 -0
- package/dist/create-DUt-efk7.d.cts.map +1 -0
- package/dist/create-DcCu_zM3.d.mts +19 -0
- package/dist/create-DcCu_zM3.d.mts.map +1 -0
- package/dist/create-Qxy2mq7r.d.mts +25 -0
- package/dist/create-Qxy2mq7r.d.mts.map +1 -0
- package/dist/define-BPfeEA9Z.d.cts +14 -0
- package/dist/define-BPfeEA9Z.d.cts.map +1 -0
- package/dist/define-CQZ042K5.d.mts +14 -0
- package/dist/define-CQZ042K5.d.mts.map +1 -0
- package/dist/define-Dw8JgVQ1.d.mts +38 -0
- package/dist/define-Dw8JgVQ1.d.mts.map +1 -0
- package/dist/define-aWeW6VVo.d.cts +38 -0
- package/dist/define-aWeW6VVo.d.cts.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-BGkKE8HQ.d.mts} +18 -14
- package/dist/generator-BGkKE8HQ.d.mts.map +1 -0
- package/dist/{generator-DZI01B4_.d.mts → generator-Dq0PL5w6.d.cts} +18 -14
- package/dist/generator-Dq0PL5w6.d.cts.map +1 -0
- package/dist/helpers-BqnQPaP5.d.cts +13 -0
- package/dist/helpers-BqnQPaP5.d.cts.map +1 -0
- package/dist/helpers-CgXgqnVu.d.mts +13 -0
- package/dist/helpers-CgXgqnVu.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 +12 -8
- package/dist/index.d.mts +12 -8
- package/dist/index.mjs +1 -1
- package/dist/schema/create.cjs +1 -0
- package/dist/schema/create.d.cts +2 -0
- package/dist/schema/create.d.mts +2 -0
- package/dist/schema/create.mjs +1 -0
- package/dist/schema/define.cjs +1 -0
- package/dist/schema/define.d.cts +2 -0
- package/dist/schema/define.d.mts +2 -0
- package/dist/schema/define.mjs +2 -0
- package/dist/schema/define.mjs.map +1 -0
- package/dist/schema/helpers.cjs +1 -0
- package/dist/schema/helpers.d.cts +2 -0
- package/dist/schema/helpers.d.mts +2 -0
- package/dist/schema/helpers.mjs +2 -0
- package/dist/schema/helpers.mjs.map +1 -0
- package/dist/schema/index.cjs +1 -0
- package/dist/schema/index.d.cts +4 -0
- package/dist/schema/index.d.mts +4 -0
- package/dist/schema/index.mjs +1 -0
- package/dist/schema-xFkmOyE6.d.cts +205 -0
- package/dist/schema-xFkmOyE6.d.cts.map +1 -0
- package/dist/schema-xFkmOyE6.d.mts +205 -0
- package/dist/schema-xFkmOyE6.d.mts.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-CHQncb8H.d.mts +58 -0
- package/dist/sink-CHQncb8H.d.mts.map +1 -0
- package/dist/sink-DHpx94GM.d.cts +58 -0
- package/dist/sink-DHpx94GM.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-BiOs3_-8.d.mts +57 -0
- package/dist/source-BiOs3_-8.d.mts.map +1 -0
- package/dist/source-txi0ZuzR.d.cts +57 -0
- package/dist/source-txi0ZuzR.d.cts.map +1 -0
- package/package.json +187 -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
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-DEe398aQ.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 { c as Meta, p as MaybePromise, r as SchemaInputObject, s as SchemaOf, u as MetaInput } from "./schema-xFkmOyE6.mjs";
|
|
2
|
+
import { InferLoadOptions, LoadInput } from "@stryke/resolve/types";
|
|
3
|
+
import { SchemaEnvelopeOf, SchemaSourceInput } 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, TOptions> {
|
|
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, TOptions> {
|
|
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?: SchemaSourceInput<TSpec> | SchemaEnvelopeOf<TSpec> | SchemaInputObject<TSpec, TOptions>;
|
|
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, TOptions>;
|
|
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-CHQncb8H.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sink-CHQncb8H.d.mts","names":[],"sources":["../src/types/sink.ts"],"mappings":""}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { c as Meta, p as MaybePromise, r as SchemaInputObject, s as SchemaOf, u as MetaInput } from "./schema-xFkmOyE6.cjs";
|
|
2
|
+
import { InferLoadOptions, LoadInput } from "@stryke/resolve/types";
|
|
3
|
+
import { SchemaEnvelopeOf, SchemaSourceInput } 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, TOptions> {
|
|
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, TOptions> {
|
|
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?: SchemaSourceInput<TSpec> | SchemaEnvelopeOf<TSpec> | SchemaInputObject<TSpec, TOptions>;
|
|
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, TOptions>;
|
|
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-DHpx94GM.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sink-DHpx94GM.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,yCAGP,SAAA,CAAU,KAAA,EAAO,QAAA;EARH;;;EAYtB,QAAA;AAAA;AAAA,UAGe,QAAA,yCAAiD,IAAA,CAChE,KAAA,EACA,QAAA;EAde;;;EAmBf,QAAA;AAAA;AAAA,UAGe,eAAA;EAvBN;;;EA+BT,MAAA,GACI,iBAAA,CAAkB,KAAA,IAClB,gBAAA,CAAiB,KAAA,IACjB,iBAAA,CAAkB,KAAA,EAAO,QAAA;EAjCL;AAAA;AAE1B;EAoCE,IAAA,GAAO,QAAA,CAAS,KAAA,EAAO,QAAA;EApCK;;;EAyC5B,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;EApDP;;;EAwDR,MAAA,EAAQ,QAAA,CAAS,KAAA,EAAO,QAAA;EApDhB;AAAA;AAGV;EAsDE,IAAA,GAAO,QAAA,CAAS,KAAA,EAAO,QAAA;EAtDA;;;;;;;;;;EAkEvB,IAAA,EAAM,YAAA,CAAa,KAAA,EAAO,QAAA,EAAU,QAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../create-23iLtMb_.cjs"),t=require("./helpers.cjs");let n=require("@stryke/resolve/load"),r=require("@stryke/type-checks/is-function"),i=require("@power-plant/schema/helpers"),a=require("@stryke/resolve/type-checks");function o(t,n){let i=t?.schema??{},a=e.r(t,n);return a.description=e.i((0,r.isFunction)(a.title)?async(e,t)=>`Determines the ${await Promise.resolve(a.title(e,t))??``} specification from a {title} source.`:`Determines the ${a.title??``} specification from a {title} source.`,i,a,n?.description),a}async function s(r,c,l={}){let{source:u,meta:d,schema:f}=t.isSourceInputObject(c)?c:{source:c,meta:{}},p=r;f&&(p=await e.t(f,l),p.schema=(0,i.mergeMetadata)(p.schema,r.schema));let m;if((0,a.isLoadInput)(u))try{let e=await(0,n.load)(u,l);m=t.isSourceInputObject(e)?await s(p,e.source,l).then(e=>e.source):e}catch{}return m||=u,{schema:p,source:m,meta:o(p,d)}}exports.createSource=s,exports.extractSourceMeta=o;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as e,r as t,t as n}from"../create-BR4IeVl4.mjs";import{isSourceInputObject as r}from"./helpers.mjs";import{load as i}from"@stryke/resolve/load";import{isFunction as a}from"@stryke/type-checks/is-function";import{mergeMetadata as o}from"@power-plant/schema/helpers";import{isLoadInput as s}from"@stryke/resolve/type-checks";function c(n,r){let i=n?.schema??{},o=t(n,r);return o.description=e(a(o.title)?async(e,t)=>`Determines the ${await Promise.resolve(o.title(e,t))??``} specification from a {title} source.`:`Determines the ${o.title??``} specification from a {title} source.`,i,o,r?.description),o}async function l(e,t,a={}){let{source:u,meta:d,schema:f}=r(t)?t:{source:t,meta:{}},p=e;f&&(p=await n(f,a),p.schema=o(p.schema,e.schema));let m;if(s(u))try{let e=await i(u,a);m=r(e)?await l(p,e.source,a).then(e=>e.source):e}catch{}return m||=u,{schema:p,source:m,meta:c(p,d)}}export{l as createSource,c as extractSourceMeta};
|
|
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.isSourceInputObject(t)?t:{source:t}}exports.defineSource=t;
|
|
@@ -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)&&`source`in t&&t.source!==void 0}exports.isSourceInputObject=t;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { a as SourceInputObject } from "../source-txi0ZuzR.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/source/helpers.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Checks if the provided input is a {@link SourceInputObject}.
|
|
6
|
+
*
|
|
7
|
+
* @param input - The input to check.
|
|
8
|
+
* @returns True if the input is a {@link SourceInputObject}, false otherwise.
|
|
9
|
+
*/
|
|
10
|
+
declare function isSourceInputObject<TSpec, TOptions extends object>(input: unknown): input is SourceInputObject<TSpec, TOptions>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { isSourceInputObject };
|
|
13
|
+
//# sourceMappingURL=helpers.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.cts","names":[],"sources":["../../src/source/helpers.ts"],"mappings":";;;;;AA2BA;;;;iBAAgB,mBAAA,iCACd,KAAA,YACC,KAAA,IAAS,iBAAA,CAAkB,KAAA,EAAO,QAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { a as SourceInputObject } from "../source-BiOs3_-8.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/source/helpers.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Checks if the provided input is a {@link SourceInputObject}.
|
|
6
|
+
*
|
|
7
|
+
* @param input - The input to check.
|
|
8
|
+
* @returns True if the input is a {@link SourceInputObject}, false otherwise.
|
|
9
|
+
*/
|
|
10
|
+
declare function isSourceInputObject<TSpec, TOptions extends object>(input: unknown): input is SourceInputObject<TSpec, TOptions>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { isSourceInputObject };
|
|
13
|
+
//# sourceMappingURL=helpers.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.mts","names":[],"sources":["../../src/source/helpers.ts"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.mjs","names":[],"sources":[],"mappings":""}
|
package/dist/source/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"),t=require("./define.cjs");exports.createSource=e.createSource,exports.defineSource=t.defineSource,exports.extractSourceMeta=e.extractSourceMeta;
|
package/dist/source/index.d.cts
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
//#region src/source/constants.d.ts
|
|
6
|
-
declare const VALID_SOURCE_FILE_EXTENSIONS: string[];
|
|
7
|
-
//#endregion
|
|
8
|
-
//#region src/source/extract.d.ts
|
|
9
|
-
type SourceResolvedInput<TSpec, TOptions = never> = TSpec | Promise<TSpec> | SourceFunction<TSpec, TOptions>;
|
|
10
|
-
/**
|
|
11
|
-
* Normalizes any accepted source input into a concrete source descriptor.
|
|
12
|
-
*/
|
|
13
|
-
declare function extractSource<TSpec, TOptions = never>(schema: SchemaOf<TSpec>, input: SourceInput<TSpec, TOptions>, options?: ResolveOptions): Promise<Source<TSpec, TOptions>>;
|
|
14
|
-
//#endregion
|
|
15
|
-
export { type Source, type SourceFunction, type SourceInput, type SourceInputWithMeta, type SourceMeta, SourceResolvedInput, type SourceValue, VALID_SOURCE_FILE_EXTENSIONS, extractSource };
|
|
16
|
-
//# sourceMappingURL=index.d.cts.map
|
|
1
|
+
import { n as extractSourceMeta, t as createSource } from "../create-DUt-efk7.cjs";
|
|
2
|
+
import { t as defineSource } from "../define-aWeW6VVo.cjs";
|
|
3
|
+
export { createSource, defineSource, extractSourceMeta };
|
package/dist/source/index.d.mts
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
//#region src/source/constants.d.ts
|
|
6
|
-
declare const VALID_SOURCE_FILE_EXTENSIONS: string[];
|
|
7
|
-
//#endregion
|
|
8
|
-
//#region src/source/extract.d.ts
|
|
9
|
-
type SourceResolvedInput<TSpec, TOptions = never> = TSpec | Promise<TSpec> | SourceFunction<TSpec, TOptions>;
|
|
10
|
-
/**
|
|
11
|
-
* Normalizes any accepted source input into a concrete source descriptor.
|
|
12
|
-
*/
|
|
13
|
-
declare function extractSource<TSpec, TOptions = never>(schema: SchemaOf<TSpec>, input: SourceInput<TSpec, TOptions>, options?: ResolveOptions): Promise<Source<TSpec, TOptions>>;
|
|
14
|
-
//#endregion
|
|
15
|
-
export { type Source, type SourceFunction, type SourceInput, type SourceInputWithMeta, type SourceMeta, SourceResolvedInput, type SourceValue, VALID_SOURCE_FILE_EXTENSIONS, extractSource };
|
|
16
|
-
//# sourceMappingURL=index.d.mts.map
|
|
1
|
+
import { n as extractSourceMeta, t as createSource } from "../create-Qxy2mq7r.mjs";
|
|
2
|
+
import { t as defineSource } from "../define-Dw8JgVQ1.mjs";
|
|
3
|
+
export { createSource, defineSource, extractSourceMeta };
|
package/dist/source/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{createSource as e,extractSourceMeta as t}from"./create.mjs";import{defineSource as n}from"./define.mjs";export{e as createSource,n as defineSource,t as extractSourceMeta};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { c as Meta, p as MaybePromise, r as SchemaInputObject, s as SchemaOf, u as MetaInput } from "./schema-xFkmOyE6.mjs";
|
|
2
|
+
import { InferLoadOptions, LoadInput } from "@stryke/resolve/types";
|
|
3
|
+
import { SchemaEnvelopeOf, SchemaSourceInput } from "@power-plant/schema/types";
|
|
4
|
+
|
|
5
|
+
//#region src/types/source.d.ts
|
|
6
|
+
type SourceFunction<TSpec, TOptions extends object> = (options: TOptions) => MaybePromise<TSpec>;
|
|
7
|
+
interface SourceMetaInput<TSpec, TOptions extends object> extends MetaInput<TSpec, TOptions> {
|
|
8
|
+
/**
|
|
9
|
+
* A string that describes how the specification will be extracted/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
|
+
input?: string;
|
|
12
|
+
}
|
|
13
|
+
interface SourceMeta<TSpec, TOptions extends object> extends Meta<TSpec, TOptions> {
|
|
14
|
+
/**
|
|
15
|
+
* A string that describes how the specification will be extracted/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
|
+
input?: string;
|
|
18
|
+
}
|
|
19
|
+
interface SourceInputObject<TSpec, TOptions extends object> {
|
|
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?: SchemaSourceInput<TSpec> | SchemaEnvelopeOf<TSpec> | SchemaInputObject<TSpec, TOptions>;
|
|
24
|
+
/**
|
|
25
|
+
* The source implementation, either as a callable function, a static value, or a file reference.
|
|
26
|
+
*/
|
|
27
|
+
source: TSpec | SourceFunction<TSpec, TOptions> | LoadInput;
|
|
28
|
+
/**
|
|
29
|
+
* Optional metadata that provides contextual information for the source.
|
|
30
|
+
*/
|
|
31
|
+
meta?: SourceMetaInput<TSpec, TOptions>;
|
|
32
|
+
}
|
|
33
|
+
type SourceInput<TSpec, TOptions extends object> = LoadInput | TSpec | SourceFunction<TSpec, TOptions> | SourceInputObject<TSpec, TOptions>;
|
|
34
|
+
type InferCreateSourceOptions<T extends SourceInput<any, any>> = T extends LoadInput ? InferLoadOptions<T> : {};
|
|
35
|
+
interface Source<TSpec, TOptions extends object> {
|
|
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, TOptions>;
|
|
40
|
+
/**
|
|
41
|
+
* Optional metadata that provides contextual information for the source.
|
|
42
|
+
*/
|
|
43
|
+
meta?: SourceMeta<TSpec, TOptions>;
|
|
44
|
+
/**
|
|
45
|
+
* The source of the generator, which can be used to specify where the generator retrieves its input data from. This can be defined as a function that takes the specification and returns a value, or it can be a static value.
|
|
46
|
+
*
|
|
47
|
+
* @remarks
|
|
48
|
+
* The `source` property can be either a static value of type `TSpec` or a function that takes the specification object and returns a value of type `TSpec` or a promise that resolves to `TSpec`. This allows for flexibility in how the generator retrieves its input data, enabling both synchronous and asynchronous data retrieval based on the specification.
|
|
49
|
+
*
|
|
50
|
+
* @param options - The options object that can be used to influence the generation process.
|
|
51
|
+
* @returns A value or a promise that resolves to a value, which will be used as the input data for the generator.
|
|
52
|
+
*/
|
|
53
|
+
source: TSpec | SourceFunction<TSpec, TOptions>;
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { SourceInputObject as a, SourceInput as i, Source as n, SourceMeta as o, SourceFunction as r, SourceMetaInput as s, InferCreateSourceOptions as t };
|
|
57
|
+
//# sourceMappingURL=source-BiOs3_-8.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-BiOs3_-8.d.mts","names":[],"sources":["../src/types/source.ts"],"mappings":""}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { c as Meta, p as MaybePromise, r as SchemaInputObject, s as SchemaOf, u as MetaInput } from "./schema-xFkmOyE6.cjs";
|
|
2
|
+
import { InferLoadOptions, LoadInput } from "@stryke/resolve/types";
|
|
3
|
+
import { SchemaEnvelopeOf, SchemaSourceInput } from "@power-plant/schema/types";
|
|
4
|
+
|
|
5
|
+
//#region src/types/source.d.ts
|
|
6
|
+
type SourceFunction<TSpec, TOptions extends object> = (options: TOptions) => MaybePromise<TSpec>;
|
|
7
|
+
interface SourceMetaInput<TSpec, TOptions extends object> extends MetaInput<TSpec, TOptions> {
|
|
8
|
+
/**
|
|
9
|
+
* A string that describes how the specification will be extracted/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
|
+
input?: string;
|
|
12
|
+
}
|
|
13
|
+
interface SourceMeta<TSpec, TOptions extends object> extends Meta<TSpec, TOptions> {
|
|
14
|
+
/**
|
|
15
|
+
* A string that describes how the specification will be extracted/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
|
+
input?: string;
|
|
18
|
+
}
|
|
19
|
+
interface SourceInputObject<TSpec, TOptions extends object> {
|
|
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?: SchemaSourceInput<TSpec> | SchemaEnvelopeOf<TSpec> | SchemaInputObject<TSpec, TOptions>;
|
|
24
|
+
/**
|
|
25
|
+
* The source implementation, either as a callable function, a static value, or a file reference.
|
|
26
|
+
*/
|
|
27
|
+
source: TSpec | SourceFunction<TSpec, TOptions> | LoadInput;
|
|
28
|
+
/**
|
|
29
|
+
* Optional metadata that provides contextual information for the source.
|
|
30
|
+
*/
|
|
31
|
+
meta?: SourceMetaInput<TSpec, TOptions>;
|
|
32
|
+
}
|
|
33
|
+
type SourceInput<TSpec, TOptions extends object> = LoadInput | TSpec | SourceFunction<TSpec, TOptions> | SourceInputObject<TSpec, TOptions>;
|
|
34
|
+
type InferCreateSourceOptions<T extends SourceInput<any, any>> = T extends LoadInput ? InferLoadOptions<T> : {};
|
|
35
|
+
interface Source<TSpec, TOptions extends object> {
|
|
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, TOptions>;
|
|
40
|
+
/**
|
|
41
|
+
* Optional metadata that provides contextual information for the source.
|
|
42
|
+
*/
|
|
43
|
+
meta?: SourceMeta<TSpec, TOptions>;
|
|
44
|
+
/**
|
|
45
|
+
* The source of the generator, which can be used to specify where the generator retrieves its input data from. This can be defined as a function that takes the specification and returns a value, or it can be a static value.
|
|
46
|
+
*
|
|
47
|
+
* @remarks
|
|
48
|
+
* The `source` property can be either a static value of type `TSpec` or a function that takes the specification object and returns a value of type `TSpec` or a promise that resolves to `TSpec`. This allows for flexibility in how the generator retrieves its input data, enabling both synchronous and asynchronous data retrieval based on the specification.
|
|
49
|
+
*
|
|
50
|
+
* @param options - The options object that can be used to influence the generation process.
|
|
51
|
+
* @returns A value or a promise that resolves to a value, which will be used as the input data for the generator.
|
|
52
|
+
*/
|
|
53
|
+
source: TSpec | SourceFunction<TSpec, TOptions>;
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { SourceInputObject as a, SourceInput as i, Source as n, SourceMeta as o, SourceFunction as r, SourceMetaInput as s, InferCreateSourceOptions as t };
|
|
57
|
+
//# sourceMappingURL=source-txi0ZuzR.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-txi0ZuzR.d.cts","names":[],"sources":["../src/types/source.ts"],"mappings":";;;;;KA2BY,cAAA,oCACV,OAAA,EAAS,QAAA,KACN,YAAA,CAAa,KAAA;AAAA,UAED,eAAA,yCAGP,SAAA,CAAU,KAAA,EAAO,QAAA;EAPD;;;EAWxB,KAAA;AAAA;AAAA,UAGe,UAAA,yCAAmD,IAAA,CAClE,KAAA,EACA,QAAA;EAhByB;;;EAqBzB,KAAA;AAAA;AAAA,UAGe,iBAAA;EAtBM;AAAA;AAEvB;EAwBE,MAAA,GACI,iBAAA,CAAkB,KAAA,IAClB,gBAAA,CAAiB,KAAA,IACjB,iBAAA,CAAkB,KAAA,EAAO,QAAA;EA3BC;;;EAgC9B,MAAA,EAAQ,KAAA,GAAQ,cAAA,CAAe,KAAA,EAAO,QAAA,IAAY,SAAA;EA7BjC;;;EAkCjB,IAAA,GAAO,eAAA,CAAgB,KAAA,EAAO,QAAA;AAAA;AAAA,KAGpB,WAAA,mCACR,SAAA,GACA,KAAA,GACA,cAAA,CAAe,KAAA,EAAO,QAAA,IACtB,iBAAA,CAAkB,KAAA,EAAO,QAAA;AAAA,KAEjB,wBAAA,WAAmC,WAAA,cAC7C,CAAA,SAAU,SAAA,GACN,gBAAA,CAAiB,CAAA;AAAA,UAIN,MAAA;EA7CV;AAAA;AAGP;EA8CE,MAAA,EAAQ,QAAA,CAAS,KAAA,EAAO,QAAA;EA9CC;;;EAmDzB,IAAA,GAAO,UAAA,CAAW,KAAA,EAAO,QAAA;EAnD6C;;;;;;;;;EA8DtE,MAAA,EAAQ,KAAA,GAAQ,cAAA,CAAe,KAAA,EAAO,QAAA;AAAA"}
|