@power-plant/core 0.0.3 → 0.0.5
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/dist/context-BGSa-2fY.mjs +2 -0
- package/dist/context-BGSa-2fY.mjs.map +1 -0
- package/dist/context-Bcrz4kGb.cjs +1 -0
- package/dist/create-0IEoomGw.cjs +1 -0
- package/dist/create-CYRTmdJO.mjs +2 -0
- package/dist/create-CYRTmdJO.mjs.map +1 -0
- package/dist/create-D_u2Zj81.cjs +1 -0
- package/dist/create-DcfhZUHw.mjs +2 -0
- package/dist/create-DcfhZUHw.mjs.map +1 -0
- package/dist/create-MFKW4s0V.cjs +1 -0
- package/dist/create-cqJljXdZ.mjs +2 -0
- package/dist/create-cqJljXdZ.mjs.map +1 -0
- package/dist/define-B5baoppv.d.cts +14 -0
- package/dist/define-B5baoppv.d.cts.map +1 -0
- package/dist/define-BNsSORkE.d.cts +13 -0
- package/dist/define-BNsSORkE.d.cts.map +1 -0
- package/dist/define-B__DotaM.cjs +1 -0
- package/dist/define-BpCv3wD0.d.mts +38 -0
- package/dist/define-BpCv3wD0.d.mts.map +1 -0
- package/dist/define-Bviec8Ry.d.cts +38 -0
- package/dist/define-Bviec8Ry.d.cts.map +1 -0
- package/dist/define-C5_Sx-Eg.mjs +2 -0
- package/dist/define-C5_Sx-Eg.mjs.map +1 -0
- package/dist/define-C_GLY1-q.cjs +1 -0
- package/dist/define-Cjl-0yK0.d.mts +13 -0
- package/dist/define-Cjl-0yK0.d.mts.map +1 -0
- package/dist/define-DE0RBdIR.mjs +2 -0
- package/dist/define-DE0RBdIR.mjs.map +1 -0
- package/dist/define-DQQxZK9L.d.mts +14 -0
- package/dist/define-DQQxZK9L.d.mts.map +1 -0
- package/dist/define-DVggP_03.cjs +1 -0
- package/dist/define-DY1s6sGY.mjs +2 -0
- package/dist/define-DY1s6sGY.mjs.map +1 -0
- package/dist/define-OeGEPyv1.d.cts +45 -0
- package/dist/define-OeGEPyv1.d.cts.map +1 -0
- package/dist/define-hhs2D0Hq.d.mts +45 -0
- package/dist/define-hhs2D0Hq.d.mts.map +1 -0
- package/dist/generator/index.cjs +1 -1
- package/dist/generator/index.d.cts +29 -2
- package/dist/generator/index.d.cts.map +1 -0
- package/dist/generator/index.d.mts +29 -2
- package/dist/generator/index.d.mts.map +1 -0
- package/dist/generator/index.mjs +2 -1
- package/dist/generator/index.mjs.map +1 -0
- package/dist/generator-9GSAWmOj.d.mts +126 -0
- package/dist/generator-9GSAWmOj.d.mts.map +1 -0
- package/dist/generator-D9KikId4.d.cts +126 -0
- package/dist/generator-D9KikId4.d.cts.map +1 -0
- package/dist/helpers-8tc33xyp.mjs +2 -0
- package/dist/helpers-8tc33xyp.mjs.map +1 -0
- package/dist/helpers-BWqqSR02.cjs +1 -0
- package/dist/helpers-BcTg0l_X.cjs +1 -0
- package/dist/helpers-Botqc1jf.cjs +1 -0
- package/dist/helpers-Cfl4NsE5.mjs +2 -0
- package/dist/helpers-Cfl4NsE5.mjs.map +1 -0
- package/dist/helpers-DwNCh4F3.mjs +2 -0
- package/dist/helpers-DwNCh4F3.mjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +101 -8
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +101 -8
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +1 -1
- package/dist/input/index.cjs +1 -0
- package/dist/input/index.d.cts +35 -0
- package/dist/input/index.d.cts.map +1 -0
- package/dist/input/index.d.mts +35 -0
- package/dist/input/index.d.mts.map +1 -0
- package/dist/input/index.mjs +1 -0
- package/dist/input-C3yGEfI-.d.mts +58 -0
- package/dist/input-C3yGEfI-.d.mts.map +1 -0
- package/dist/input-Osyk3YIo.d.cts +58 -0
- package/dist/input-Osyk3YIo.d.cts.map +1 -0
- package/dist/output/index.cjs +1 -0
- package/dist/output/index.d.cts +35 -0
- package/dist/output/index.d.cts.map +1 -0
- package/dist/output/index.d.mts +35 -0
- package/dist/output/index.d.mts.map +1 -0
- package/dist/output/index.mjs +1 -0
- package/dist/schema/index.cjs +1 -0
- package/dist/schema/index.d.cts +33 -0
- package/dist/schema/index.d.cts.map +1 -0
- package/dist/schema/index.d.mts +33 -0
- package/dist/schema/index.d.mts.map +1 -0
- package/dist/schema/index.mjs +1 -0
- package/dist/schema-DvnNqFd4.d.cts +180 -0
- package/dist/schema-DvnNqFd4.d.cts.map +1 -0
- package/dist/schema-DvnNqFd4.d.mts +180 -0
- package/dist/schema-DvnNqFd4.d.mts.map +1 -0
- package/package.json +35 -135
- package/dist/base-BKbfgxno.d.cts +0 -28
- package/dist/base-BKbfgxno.d.cts.map +0 -1
- package/dist/base-BKbfgxno.d.mts +0 -28
- package/dist/base-BKbfgxno.d.mts.map +0 -1
- package/dist/create-B14Jt6Iu.d.mts +0 -17
- package/dist/create-B14Jt6Iu.d.mts.map +0 -1
- package/dist/create-Cfgth9sz.d.cts +0 -19
- package/dist/create-Cfgth9sz.d.cts.map +0 -1
- package/dist/create-D32Jusq_.d.cts +0 -17
- package/dist/create-D32Jusq_.d.cts.map +0 -1
- package/dist/create-DVpg-3po.d.mts +0 -19
- package/dist/create-DVpg-3po.d.mts.map +0 -1
- package/dist/create-DoyLue8r.d.cts +0 -17
- package/dist/create-DoyLue8r.d.cts.map +0 -1
- package/dist/create-vgEDsShD.d.mts +0 -17
- package/dist/create-vgEDsShD.d.mts.map +0 -1
- package/dist/define-DEe-HPar.d.cts +0 -38
- package/dist/define-DEe-HPar.d.cts.map +0 -1
- package/dist/define-RneysDu1.d.mts +0 -38
- package/dist/define-RneysDu1.d.mts.map +0 -1
- package/dist/generator/create.cjs +0 -1
- package/dist/generator/create.d.cts +0 -2
- package/dist/generator/create.d.mts +0 -2
- package/dist/generator/create.mjs +0 -2
- package/dist/generator/create.mjs.map +0 -1
- package/dist/generator/helpers.cjs +0 -1
- package/dist/generator/helpers.d.cts +0 -6
- package/dist/generator/helpers.d.cts.map +0 -1
- package/dist/generator/helpers.d.mts +0 -6
- package/dist/generator/helpers.d.mts.map +0 -1
- package/dist/generator/helpers.mjs +0 -2
- package/dist/generator/helpers.mjs.map +0 -1
- package/dist/generator-C1_Q-QAb.d.cts +0 -60
- package/dist/generator-C1_Q-QAb.d.cts.map +0 -1
- package/dist/generator-MC25UERM.d.mts +0 -60
- package/dist/generator-MC25UERM.d.mts.map +0 -1
- package/dist/index-BVVgDSdq.d.cts +0 -1
- package/dist/index-BVVgDSdq.d.mts +0 -1
- package/dist/metadata-Cb6iMZqW.cjs +0 -1
- package/dist/metadata-Dmhrb3Kv.mjs +0 -2
- package/dist/metadata-Dmhrb3Kv.mjs.map +0 -1
- package/dist/sink/create.cjs +0 -1
- package/dist/sink/create.d.cts +0 -2
- package/dist/sink/create.d.mts +0 -2
- package/dist/sink/create.mjs +0 -2
- package/dist/sink/create.mjs.map +0 -1
- package/dist/sink/define.cjs +0 -1
- package/dist/sink/define.d.cts +0 -37
- package/dist/sink/define.d.cts.map +0 -1
- package/dist/sink/define.d.mts +0 -37
- package/dist/sink/define.d.mts.map +0 -1
- package/dist/sink/define.mjs +0 -2
- package/dist/sink/define.mjs.map +0 -1
- package/dist/sink/helpers.cjs +0 -1
- package/dist/sink/helpers.d.cts +0 -13
- package/dist/sink/helpers.d.cts.map +0 -1
- package/dist/sink/helpers.d.mts +0 -13
- package/dist/sink/helpers.d.mts.map +0 -1
- package/dist/sink/helpers.mjs +0 -2
- package/dist/sink/helpers.mjs.map +0 -1
- package/dist/sink/index.cjs +0 -1
- package/dist/sink/index.d.cts +0 -2
- package/dist/sink/index.d.mts +0 -2
- package/dist/sink/index.mjs +0 -1
- package/dist/sink-CAWlC7am.d.mts +0 -58
- package/dist/sink-CAWlC7am.d.mts.map +0 -1
- package/dist/sink-CTx7UtqU.d.cts +0 -58
- package/dist/sink-CTx7UtqU.d.cts.map +0 -1
- package/dist/source/create.cjs +0 -1
- package/dist/source/create.d.cts +0 -2
- package/dist/source/create.d.mts +0 -2
- package/dist/source/create.mjs +0 -2
- package/dist/source/create.mjs.map +0 -1
- package/dist/source/define.cjs +0 -1
- package/dist/source/define.d.cts +0 -2
- package/dist/source/define.d.mts +0 -2
- package/dist/source/define.mjs +0 -2
- package/dist/source/define.mjs.map +0 -1
- package/dist/source/helpers.cjs +0 -1
- package/dist/source/helpers.d.cts +0 -13
- package/dist/source/helpers.d.cts.map +0 -1
- package/dist/source/helpers.d.mts +0 -13
- package/dist/source/helpers.d.mts.map +0 -1
- package/dist/source/helpers.mjs +0 -2
- package/dist/source/helpers.mjs.map +0 -1
- package/dist/source/index.cjs +0 -1
- package/dist/source/index.d.cts +0 -3
- package/dist/source/index.d.mts +0 -3
- package/dist/source/index.mjs +0 -1
- package/dist/source-B3tctCZE.d.cts +0 -57
- package/dist/source-B3tctCZE.d.cts.map +0 -1
- package/dist/source-DjKhYXZ6.d.mts +0 -57
- package/dist/source-DjKhYXZ6.d.mts.map +0 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { c as Meta, l as MetaConfig, r as SchemaConfigObject, s as SchemaOf } from "./schema-DvnNqFd4.cjs";
|
|
2
|
+
import { SchemaEnvelopeOf, SchemaSourceConfig } from "@power-plant/schema";
|
|
3
|
+
import { InferLoadOptions, LoadReference } from "@stryke/resolve/types";
|
|
4
|
+
import { MaybePromise } from "@stryke/types/base";
|
|
5
|
+
|
|
6
|
+
//#region src/types/input.d.ts
|
|
7
|
+
type InputFunction<TSpec, TOptions extends object> = (options: TOptions) => MaybePromise<TSpec>;
|
|
8
|
+
interface InputMetaConfig<TSpec, TOptions extends object> extends MetaConfig<TSpec, TOptions> {
|
|
9
|
+
/**
|
|
10
|
+
* A string that describes how the specification will be extracted/generated. This property can provide context about the input of the specification, such as whether it is derived from a file, a database, an API, or any other input. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
11
|
+
*/
|
|
12
|
+
input?: string;
|
|
13
|
+
}
|
|
14
|
+
interface InputMeta<TSpec, TOptions extends object> extends Meta<TSpec, TOptions> {
|
|
15
|
+
/**
|
|
16
|
+
* A string that describes how the specification will be extracted/generated. This property can provide context about the input of the specification, such as whether it is derived from a file, a database, an API, or any other input. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
17
|
+
*/
|
|
18
|
+
input?: string;
|
|
19
|
+
}
|
|
20
|
+
interface InputConfigObject<TSpec, TOptions extends object> {
|
|
21
|
+
/**
|
|
22
|
+
* 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.
|
|
23
|
+
*/
|
|
24
|
+
schema?: SchemaSourceConfig<TSpec> | SchemaEnvelopeOf<TSpec> | SchemaConfigObject<TSpec, TOptions>;
|
|
25
|
+
/**
|
|
26
|
+
* The input implementation, either as a callable function, a static value, or a file reference.
|
|
27
|
+
*/
|
|
28
|
+
input: TSpec | InputFunction<TSpec, TOptions> | LoadReference;
|
|
29
|
+
/**
|
|
30
|
+
* Optional metadata that provides contextual information for the input.
|
|
31
|
+
*/
|
|
32
|
+
meta?: InputMetaConfig<TSpec, TOptions>;
|
|
33
|
+
}
|
|
34
|
+
type InputConfig<TSpec, TOptions extends object> = LoadReference | TSpec | InputFunction<TSpec, TOptions> | InputConfigObject<TSpec, TOptions>;
|
|
35
|
+
type InferCreateInputOptions<T extends InputConfig<any, any>> = T extends LoadReference ? InferLoadOptions<T> : {};
|
|
36
|
+
interface Input<TSpec, TOptions extends object> {
|
|
37
|
+
/**
|
|
38
|
+
* 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.
|
|
39
|
+
*/
|
|
40
|
+
schema: SchemaOf<TSpec, TOptions>;
|
|
41
|
+
/**
|
|
42
|
+
* Optional metadata that provides contextual information for the input.
|
|
43
|
+
*/
|
|
44
|
+
meta?: InputMeta<TSpec, TOptions>;
|
|
45
|
+
/**
|
|
46
|
+
* The input of the generator, which can be used to specify where the generator retrieves its input data from. This can be defined as a function that takes the specification and returns a value, or it can be a static value.
|
|
47
|
+
*
|
|
48
|
+
* @remarks
|
|
49
|
+
* The `input` 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.
|
|
50
|
+
*
|
|
51
|
+
* @param options - The options object that can be used to influence the generation process.
|
|
52
|
+
* @returns A value or a promise that resolves to a value, which will be used as the input data for the generator.
|
|
53
|
+
*/
|
|
54
|
+
input: TSpec | InputFunction<TSpec, TOptions>;
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { InputFunction as a, InputConfigObject as i, Input as n, InputMeta as o, InputConfig as r, InputMetaConfig as s, InferCreateInputOptions as t };
|
|
58
|
+
//# sourceMappingURL=input-Osyk3YIo.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-Osyk3YIo.d.cts","names":[],"sources":["../src/types/input.ts"],"mappings":";;;;;;KAwBY,aAAA,oCACV,OAAA,EAAS,QAAA,KACN,YAAA,CAAa,KAAA;AAAA,UAED,eAAA,yCAGP,UAAA,CAAW,KAAA,EAAO,QAAA;EAPH;;;EAWvB,KAAA;AAAA;AAAA,UAGe,SAAA,yCAAkD,IAAA,CACjE,KAAA,EACA,QAAA;EAde;;;EAmBf,KAAA;AAAA;AAAA,UAGe,iBAAA;EAtBC;;AAAK;EA0BrB,MAAA,GACI,kBAAA,CAAmB,KAAA,IACnB,gBAAA,CAAiB,KAAA,IACjB,kBAAA,CAAmB,KAAA,EAAO,QAAA;EA3BA;;;EAgC9B,KAAA,EAAO,KAAA,GAAQ,aAAA,CAAc,KAAA,EAAO,QAAA,IAAY,aAAA;EA7BxC;;;EAkCR,IAAA,GAAO,eAAA,CAAgB,KAAA,EAAO,QAAA;AAAA;AAAA,KAGpB,WAAA,mCACR,aAAA,GACA,KAAA,GACA,aAAA,CAAc,KAAA,EAAO,QAAA,IACrB,iBAAA,CAAkB,KAAA,EAAO,QAAA;AAAA,KAEjB,uBAAA,WAAkC,WAAA,cAC5C,CAAA,SAAU,aAAA,GACN,gBAAA,CAAiB,CAAA;AAAA,UAIN,KAAA;EA7Cf;;AAAK;EAiDL,MAAA,EAAQ,QAAA,CAAS,KAAA,EAAO,QAAA;EA9CA;;;EAmDxB,IAAA,GAAO,SAAA,CAAU,KAAA,EAAO,QAAA;EAnDyC;;;;;;;;;EA8DjE,KAAA,EAAO,KAAA,GAAQ,aAAA,CAAc,KAAA,EAAO,QAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../helpers-BWqqSR02.cjs"),t=require("../define-C_GLY1-q.cjs"),n=require("../create-MFKW4s0V.cjs");exports.createOutput=n.t,exports.defineOutput=t.t,exports.extractOutputMeta=n.n,exports.isOutputConfigObject=e.t;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { c as OutputConfig, d as OutputMeta, f as OutputMetaConfig, l as OutputConfigObject, o as InferCreateOutputOptions, s as Output } from "../generator-D9KikId4.cjs";
|
|
2
|
+
import { s as SchemaOf } from "../schema-DvnNqFd4.cjs";
|
|
3
|
+
import { t as defineOutput } from "../define-OeGEPyv1.cjs";
|
|
4
|
+
import { ExtractedSchemaEnvelope } from "@power-plant/schema";
|
|
5
|
+
|
|
6
|
+
//#region src/output/create.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Extracts and normalizes {@link OutputMeta | output metadata} from a given {@link OutputMetaConfig}. This function ensures that the metadata is in a consistent format, converting version numbers to strings and filtering out any invalid or empty tags.
|
|
9
|
+
*
|
|
10
|
+
* @param schema - The schema that the specification is expected to conform to.
|
|
11
|
+
* @param config - The output metadata config to extract and normalize.
|
|
12
|
+
* @returns The normalized output metadata.
|
|
13
|
+
*/
|
|
14
|
+
declare function extractOutputMeta<TSpec, TOptions extends object>(schema: ExtractedSchemaEnvelope<TSpec> | SchemaOf<TSpec, TOptions>, config?: OutputMetaConfig<TSpec, TOptions>): OutputMeta<TSpec, TOptions>;
|
|
15
|
+
/**
|
|
16
|
+
* Normalizes any accepted output config into a concrete output descriptor.
|
|
17
|
+
*
|
|
18
|
+
* @param schema - The schema that the output config is expected to conform to.
|
|
19
|
+
* @param config - The output config to normalize.
|
|
20
|
+
* @param options - Optional options for resolving the output config.
|
|
21
|
+
* @returns A promise that resolves to a normalized output descriptor.
|
|
22
|
+
*/
|
|
23
|
+
declare function createOutput<TSpec, TOptions extends object, TReturns = void>(schema: SchemaOf<TSpec, TOptions>, config: OutputConfig<TSpec, TOptions, TReturns>, options?: InferCreateOutputOptions<typeof config>): Promise<Output<TSpec, TOptions, TReturns>>;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/output/helpers.d.ts
|
|
26
|
+
/**
|
|
27
|
+
* Checks if the provided input is a {@link OutputConfigObject}.
|
|
28
|
+
*
|
|
29
|
+
* @param config - The input to check.
|
|
30
|
+
* @returns True if the input is a {@link OutputConfigObject}, false otherwise.
|
|
31
|
+
*/
|
|
32
|
+
declare function isOutputConfigObject<TSpec, TOptions extends object, TReturns = void>(config: unknown): config is OutputConfigObject<TSpec, TOptions, TReturns>;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { createOutput, defineOutput, extractOutputMeta, isOutputConfigObject };
|
|
35
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/output/create.ts","../../src/output/helpers.ts"],"mappings":";;;;;;;;;AA2CA;;;;iBAAgB,iBAAA,iCACd,MAAA,EAAQ,uBAAA,CAAwB,KAAA,IAAS,QAAA,CAAS,KAAA,EAAO,QAAA,GACzD,MAAA,GAAS,gBAAA,CAAiB,KAAA,EAAO,QAAA,IAChC,UAAA,CAAW,KAAA,EAAO,QAAA;;;;;;;;;iBAoCC,YAAA,kDAKpB,MAAA,EAAQ,QAAA,CAAS,KAAA,EAAO,QAAA,GACxB,MAAA,EAAQ,YAAA,CAAa,KAAA,EAAO,QAAA,EAAU,QAAA,GACtC,OAAA,GAAS,wBAAA,QAAgC,MAAA,IACxC,OAAA,CAAQ,MAAA,CAAO,KAAA,EAAO,QAAA,EAAU,QAAA;;;;;;;;AA/CnC;iBChBgB,oBAAA,kDAId,MAAA,YAAkB,MAAA,IAAU,kBAAA,CAAmB,KAAA,EAAO,QAAA,EAAU,QAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { c as OutputConfig, d as OutputMeta, f as OutputMetaConfig, l as OutputConfigObject, o as InferCreateOutputOptions, s as Output } from "../generator-9GSAWmOj.mjs";
|
|
2
|
+
import { s as SchemaOf } from "../schema-DvnNqFd4.mjs";
|
|
3
|
+
import { t as defineOutput } from "../define-hhs2D0Hq.mjs";
|
|
4
|
+
import { ExtractedSchemaEnvelope } from "@power-plant/schema";
|
|
5
|
+
|
|
6
|
+
//#region src/output/create.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Extracts and normalizes {@link OutputMeta | output metadata} from a given {@link OutputMetaConfig}. This function ensures that the metadata is in a consistent format, converting version numbers to strings and filtering out any invalid or empty tags.
|
|
9
|
+
*
|
|
10
|
+
* @param schema - The schema that the specification is expected to conform to.
|
|
11
|
+
* @param config - The output metadata config to extract and normalize.
|
|
12
|
+
* @returns The normalized output metadata.
|
|
13
|
+
*/
|
|
14
|
+
declare function extractOutputMeta<TSpec, TOptions extends object>(schema: ExtractedSchemaEnvelope<TSpec> | SchemaOf<TSpec, TOptions>, config?: OutputMetaConfig<TSpec, TOptions>): OutputMeta<TSpec, TOptions>;
|
|
15
|
+
/**
|
|
16
|
+
* Normalizes any accepted output config into a concrete output descriptor.
|
|
17
|
+
*
|
|
18
|
+
* @param schema - The schema that the output config is expected to conform to.
|
|
19
|
+
* @param config - The output config to normalize.
|
|
20
|
+
* @param options - Optional options for resolving the output config.
|
|
21
|
+
* @returns A promise that resolves to a normalized output descriptor.
|
|
22
|
+
*/
|
|
23
|
+
declare function createOutput<TSpec, TOptions extends object, TReturns = void>(schema: SchemaOf<TSpec, TOptions>, config: OutputConfig<TSpec, TOptions, TReturns>, options?: InferCreateOutputOptions<typeof config>): Promise<Output<TSpec, TOptions, TReturns>>;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/output/helpers.d.ts
|
|
26
|
+
/**
|
|
27
|
+
* Checks if the provided input is a {@link OutputConfigObject}.
|
|
28
|
+
*
|
|
29
|
+
* @param config - The input to check.
|
|
30
|
+
* @returns True if the input is a {@link OutputConfigObject}, false otherwise.
|
|
31
|
+
*/
|
|
32
|
+
declare function isOutputConfigObject<TSpec, TOptions extends object, TReturns = void>(config: unknown): config is OutputConfigObject<TSpec, TOptions, TReturns>;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { createOutput, defineOutput, extractOutputMeta, isOutputConfigObject };
|
|
35
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/output/create.ts","../../src/output/helpers.ts"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"../helpers-8tc33xyp.mjs";import{t}from"../define-C5_Sx-Eg.mjs";import{n,t as r}from"../create-cqJljXdZ.mjs";export{r as createOutput,t as defineOutput,n as extractOutputMeta,e as isOutputConfigObject};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../helpers-Botqc1jf.cjs"),t=require("../define-B__DotaM.cjs"),n=require("../create-D_u2Zj81.cjs");exports.createSchema=n.t,exports.defineSchema=t.t,exports.extractSchemaMeta=n.n,exports.isSchemaConfigObject=e.t;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { a as SchemaMetaConfig, i as SchemaMeta, r as SchemaConfigObject, s as SchemaOf, t as InferCreateSchemaOptions } from "../schema-DvnNqFd4.cjs";
|
|
2
|
+
import { t as defineSchema } from "../define-B5baoppv.cjs";
|
|
3
|
+
import { ExtractedSchemaEnvelope, SchemaEnvelopeOf, SchemaSourceConfig } from "@power-plant/schema";
|
|
4
|
+
|
|
5
|
+
//#region src/schema/create.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Extracts and normalizes {@link SchemaMeta | schema metadata} from a given {@link SchemaMetaConfig}. This function ensures that the metadata is in a consistent format, converting version numbers to strings and filtering out any invalid or empty tags.
|
|
8
|
+
*
|
|
9
|
+
* @param schema - The schema from which to extract metadata.
|
|
10
|
+
* @param input - The schema metadata input to extract and normalize.
|
|
11
|
+
* @returns The normalized schema metadata.
|
|
12
|
+
*/
|
|
13
|
+
declare function extractSchemaMeta<TSpec, TOptions extends object>(schema: ExtractedSchemaEnvelope<TSpec>, input?: SchemaMetaConfig<TSpec, TOptions>): SchemaMeta<TSpec, TOptions>;
|
|
14
|
+
/**
|
|
15
|
+
* Normalizes any accepted schema input into a concrete schema descriptor.
|
|
16
|
+
*
|
|
17
|
+
* @param input - The schema input to normalize.
|
|
18
|
+
* @param options - Optional options for resolving the schema input.
|
|
19
|
+
* @returns A promise that resolves to a normalized schema descriptor.
|
|
20
|
+
*/
|
|
21
|
+
declare function createSchema<TSpec, TOptions extends object>(input: SchemaSourceConfig<TSpec> | SchemaEnvelopeOf<TSpec> | SchemaConfigObject<TSpec, TOptions>, options?: InferCreateSchemaOptions<typeof input>): Promise<SchemaOf<TSpec, TOptions>>;
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/schema/helpers.d.ts
|
|
24
|
+
/**
|
|
25
|
+
* Checks if the provided configuration is a {@link SchemaConfigObject}.
|
|
26
|
+
*
|
|
27
|
+
* @param config - The configuration to check.
|
|
28
|
+
* @returns True if the configuration is a {@link SchemaConfigObject}, false otherwise.
|
|
29
|
+
*/
|
|
30
|
+
declare function isSchemaConfigObject<TSpec, TOptions extends object>(config: unknown): config is SchemaConfigObject<TSpec, TOptions>;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { createSchema, defineSchema, extractSchemaMeta, isSchemaConfigObject };
|
|
33
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/schema/create.ts","../../src/schema/helpers.ts"],"mappings":";;;;;;;;AA8CA;;;;iBAAgB,iBAAA,iCACd,MAAA,EAAQ,uBAAA,CAAwB,KAAA,GAChC,KAAA,GAAQ,gBAAA,CAAiB,KAAA,EAAO,QAAA,IAC/B,UAAA,CAAW,KAAA,EAAO,QAAA;;;;;;;;iBAoCC,YAAA,iCACpB,KAAA,EACI,kBAAA,CAAmB,KAAA,IACnB,gBAAA,CAAiB,KAAA,IACjB,kBAAA,CAAmB,KAAA,EAAO,QAAA,GAC9B,OAAA,GAAS,wBAAA,QAAgC,KAAA,IACxC,OAAA,CAAQ,QAAA,CAAS,KAAA,EAAO,QAAA;;;;;;;AA7C3B;;iBCnBgB,oBAAA,iCACd,MAAA,YACC,MAAA,IAAU,kBAAA,CAAmB,KAAA,EAAO,QAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { a as SchemaMetaConfig, i as SchemaMeta, r as SchemaConfigObject, s as SchemaOf, t as InferCreateSchemaOptions } from "../schema-DvnNqFd4.mjs";
|
|
2
|
+
import { t as defineSchema } from "../define-DQQxZK9L.mjs";
|
|
3
|
+
import { ExtractedSchemaEnvelope, SchemaEnvelopeOf, SchemaSourceConfig } from "@power-plant/schema";
|
|
4
|
+
|
|
5
|
+
//#region src/schema/create.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Extracts and normalizes {@link SchemaMeta | schema metadata} from a given {@link SchemaMetaConfig}. This function ensures that the metadata is in a consistent format, converting version numbers to strings and filtering out any invalid or empty tags.
|
|
8
|
+
*
|
|
9
|
+
* @param schema - The schema from which to extract metadata.
|
|
10
|
+
* @param input - The schema metadata input to extract and normalize.
|
|
11
|
+
* @returns The normalized schema metadata.
|
|
12
|
+
*/
|
|
13
|
+
declare function extractSchemaMeta<TSpec, TOptions extends object>(schema: ExtractedSchemaEnvelope<TSpec>, input?: SchemaMetaConfig<TSpec, TOptions>): SchemaMeta<TSpec, TOptions>;
|
|
14
|
+
/**
|
|
15
|
+
* Normalizes any accepted schema input into a concrete schema descriptor.
|
|
16
|
+
*
|
|
17
|
+
* @param input - The schema input to normalize.
|
|
18
|
+
* @param options - Optional options for resolving the schema input.
|
|
19
|
+
* @returns A promise that resolves to a normalized schema descriptor.
|
|
20
|
+
*/
|
|
21
|
+
declare function createSchema<TSpec, TOptions extends object>(input: SchemaSourceConfig<TSpec> | SchemaEnvelopeOf<TSpec> | SchemaConfigObject<TSpec, TOptions>, options?: InferCreateSchemaOptions<typeof input>): Promise<SchemaOf<TSpec, TOptions>>;
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/schema/helpers.d.ts
|
|
24
|
+
/**
|
|
25
|
+
* Checks if the provided configuration is a {@link SchemaConfigObject}.
|
|
26
|
+
*
|
|
27
|
+
* @param config - The configuration to check.
|
|
28
|
+
* @returns True if the configuration is a {@link SchemaConfigObject}, false otherwise.
|
|
29
|
+
*/
|
|
30
|
+
declare function isSchemaConfigObject<TSpec, TOptions extends object>(config: unknown): config is SchemaConfigObject<TSpec, TOptions>;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { createSchema, defineSchema, extractSchemaMeta, isSchemaConfigObject };
|
|
33
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/schema/create.ts","../../src/schema/helpers.ts"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"../helpers-DwNCh4F3.mjs";import{t}from"../define-DE0RBdIR.mjs";import{n,t as r}from"../create-DcfhZUHw.mjs";export{r as createSchema,t as defineSchema,n as extractSchemaMeta,e as isSchemaConfigObject};
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { InferExtractOptions, SchemaEnvelopeOf, SchemaSourceConfig } from "@power-plant/schema";
|
|
2
|
+
import { MaybePromise } from "@stryke/types/base";
|
|
3
|
+
|
|
4
|
+
//#region src/types/meta.d.ts
|
|
5
|
+
type MetaValue<TSpec, TOptions extends object, TValue = any> = TValue | ((spec: TSpec, options: TOptions) => MaybePromise<TValue>);
|
|
6
|
+
type MetaDeprecated = true | string | {
|
|
7
|
+
message?: string;
|
|
8
|
+
since?: string;
|
|
9
|
+
alternative?: string;
|
|
10
|
+
};
|
|
11
|
+
type MetaLink = string | {
|
|
12
|
+
href: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
};
|
|
15
|
+
interface MetaConfig<TSpec, TOptions extends object> {
|
|
16
|
+
/**
|
|
17
|
+
* A name for the schema, which can be used to identify or reference the schema in documentation, tooling, or other contexts. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* The `name` property is a string that can be used to give the schema a human-readable identifier. It can be used in documentation, error messages, or other contexts where it is helpful to have a name associated with the schema. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
21
|
+
*/
|
|
22
|
+
name?: MetaValue<TSpec, TOptions, string>;
|
|
23
|
+
/**
|
|
24
|
+
* A version string that indicates the version of the schema. This property can be used to track changes or updates to the schema over time, allowing consumers of the schema to determine which version they are working with. 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.
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* The `version` property is a string that can follow any versioning scheme, such as semantic versioning (e.g., "1.0.0", "2.1.3"), date-based versioning (e.g., "2023-06-15"), or any other format that conveys the version of the schema. It is recommended to use a consistent versioning scheme across all schemas to facilitate easier tracking and management of schema versions.
|
|
28
|
+
*
|
|
29
|
+
* @defaultValue "1.0"
|
|
30
|
+
*/
|
|
31
|
+
version?: MetaValue<TSpec, TOptions, string | Date | number>;
|
|
32
|
+
/**
|
|
33
|
+
* A string that describes the schema in some way.
|
|
34
|
+
*/
|
|
35
|
+
description?: MetaValue<TSpec, TOptions, string>;
|
|
36
|
+
/**
|
|
37
|
+
* A string that provides a human-readable name for the schema, which can be used in documentation, tooling, or other contexts to identify or reference the schema. 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.
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* The `title` property is a string that can be used to give the schema a more user-friendly or descriptive name. It can be used in documentation, error messages, or other contexts where it is helpful to have a display name associated with the schema. 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.
|
|
41
|
+
*/
|
|
42
|
+
title?: MetaValue<TSpec, TOptions, string>;
|
|
43
|
+
/**
|
|
44
|
+
* A string that describes when the schema is used.
|
|
45
|
+
*/
|
|
46
|
+
usage?: MetaValue<TSpec, TOptions, string>;
|
|
47
|
+
/**
|
|
48
|
+
* Indicates whether the schema is deprecated, and optionally provides additional information about the deprecation, such as a message, the version since which it is deprecated, and an alternative schema to use instead.
|
|
49
|
+
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* The `deprecated` property can be a boolean value, where `true` indicates that the schema is deprecated and `false` indicates that it is not. It can also be a string that provides a message explaining the deprecation, or an object that includes additional details such as a message, the version since which it is deprecated, and an alternative schema to use instead. 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.
|
|
52
|
+
*/
|
|
53
|
+
deprecated?: MetaValue<TSpec, TOptions, MetaDeprecated>;
|
|
54
|
+
/**
|
|
55
|
+
* An array of tags associated with the schema. Tags can be used to categorize or label schemas for organizational purposes, making it easier to search, filter, or group related schemas together. 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.
|
|
56
|
+
*
|
|
57
|
+
* @remarks
|
|
58
|
+
* Each tag in the array should be a string that represents a meaningful label or category for the schema. It is recommended to use consistent and descriptive tags across schemas to facilitate easier management and discovery of related schemas.
|
|
59
|
+
*/
|
|
60
|
+
tags?: MetaValue<TSpec, TOptions, string[]>;
|
|
61
|
+
/**
|
|
62
|
+
* An array of links associated with the schema. Each link can be a string representing a URL or an object containing a `href` property and an optional `description` property.
|
|
63
|
+
*/
|
|
64
|
+
links?: MetaValue<TSpec, TOptions, MetaLink[]>;
|
|
65
|
+
}
|
|
66
|
+
interface Meta<TSpec, TOptions extends object> {
|
|
67
|
+
/**
|
|
68
|
+
* A unique identifier for the schema, which can be used to reference or identify the schema in documentation, tooling, or other contexts. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
69
|
+
*
|
|
70
|
+
* @remarks
|
|
71
|
+
* The `id` property is a string that can be used to give the schema a unique identifier. It can be used in documentation, error messages, or other contexts where it is helpful to have an identifier associated with the schema. 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.
|
|
72
|
+
*/
|
|
73
|
+
id: MetaValue<TSpec, TOptions, string>;
|
|
74
|
+
/**
|
|
75
|
+
* A name for the schema, which can be used to identify or reference the schema in documentation, tooling, or other contexts. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
76
|
+
*
|
|
77
|
+
* @remarks
|
|
78
|
+
* The `name` property is a string that can be used to give the schema a human-readable identifier. It can be used in documentation, error messages, or other contexts where it is helpful to have a name associated with the schema. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
79
|
+
*/
|
|
80
|
+
name: MetaValue<TSpec, TOptions, string>;
|
|
81
|
+
/**
|
|
82
|
+
* A version string that indicates the version of the schema. This property can be used to track changes or updates to the schema over time, allowing consumers of the schema to determine which version they are working with. 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.
|
|
83
|
+
*
|
|
84
|
+
* @remarks
|
|
85
|
+
* The `version` property is a string that can follow any versioning scheme, such as semantic versioning (e.g., "1.0.0", "2.1.3"), date-based versioning (e.g., "2023-06-15"), or any other format that conveys the version of the schema. It is recommended to use a consistent versioning scheme across all schemas to facilitate easier tracking and management of schema versions.
|
|
86
|
+
*
|
|
87
|
+
* @defaultValue "1.0"
|
|
88
|
+
*/
|
|
89
|
+
version: MetaValue<TSpec, TOptions, string | Date | number>;
|
|
90
|
+
/**
|
|
91
|
+
* A string that describes the schema in some way.
|
|
92
|
+
*/
|
|
93
|
+
description: MetaValue<TSpec, TOptions, string>;
|
|
94
|
+
/**
|
|
95
|
+
* A string that provides a human-readable name for the schema, which can be used in documentation, tooling, or other contexts to identify or reference the schema. 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.
|
|
96
|
+
*
|
|
97
|
+
* @remarks
|
|
98
|
+
* The `title` property is a string that can be used to give the schema a more user-friendly or descriptive name. It can be used in documentation, error messages, or other contexts where it is helpful to have a display name associated with the schema. 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.
|
|
99
|
+
*/
|
|
100
|
+
title: MetaValue<TSpec, TOptions, string>;
|
|
101
|
+
/**
|
|
102
|
+
* A string that describes when the schema is used.
|
|
103
|
+
*/
|
|
104
|
+
usage?: MetaValue<TSpec, TOptions, string>;
|
|
105
|
+
/**
|
|
106
|
+
* Indicates whether the schema is deprecated, and optionally provides additional information about the deprecation, such as a message, the version since which it is deprecated, and an alternative schema to use instead.
|
|
107
|
+
*
|
|
108
|
+
* @remarks
|
|
109
|
+
* The `deprecated` property can be a boolean value, where `true` indicates that the schema is deprecated and `false` indicates that it is not. It can also be a string that provides a message explaining the deprecation, or an object that includes additional details such as a message, the version since which it is deprecated, and an alternative schema to use instead. 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.
|
|
110
|
+
*/
|
|
111
|
+
deprecated?: MetaValue<TSpec, TOptions, MetaDeprecated>;
|
|
112
|
+
/**
|
|
113
|
+
* An array of tags associated with the schema. Tags can be used to categorize or label schemas for organizational purposes, making it easier to search, filter, or group related schemas together. 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.
|
|
114
|
+
*
|
|
115
|
+
* @remarks
|
|
116
|
+
* Each tag in the array should be a string that represents a meaningful label or category for the schema. It is recommended to use consistent and descriptive tags across schemas to facilitate easier management and discovery of related schemas.
|
|
117
|
+
*/
|
|
118
|
+
tags?: MetaValue<TSpec, TOptions, string[]>;
|
|
119
|
+
/**
|
|
120
|
+
* An array of links associated with the schema. Each link can be a string representing a URL or an object containing a `href` property and an optional `description` property.
|
|
121
|
+
*/
|
|
122
|
+
links: MetaValue<TSpec, TOptions, MetaLink[]>;
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/types/schema.d.ts
|
|
126
|
+
type SchemaMetaExample<TSpec> = TSpec | {
|
|
127
|
+
name?: string;
|
|
128
|
+
description?: string;
|
|
129
|
+
value: TSpec;
|
|
130
|
+
};
|
|
131
|
+
interface SchemaMetaConfig<TSpec, TOptions extends object = any> extends MetaConfig<TSpec, TOptions> {
|
|
132
|
+
/**
|
|
133
|
+
* Examples of valid data for the schema. This can be a single example or an array of examples.
|
|
134
|
+
*/
|
|
135
|
+
examples?: SchemaMetaExample<TSpec> | MetaValue<TSpec, TOptions, SchemaMetaExample<TSpec>[]>;
|
|
136
|
+
/**
|
|
137
|
+
* A description of the specification that is described by this schema.
|
|
138
|
+
*/
|
|
139
|
+
spec?: MetaValue<TSpec, TOptions, string>;
|
|
140
|
+
}
|
|
141
|
+
interface SchemaMeta<TSpec, TOptions extends object = any> extends Meta<TSpec, TOptions> {
|
|
142
|
+
/**
|
|
143
|
+
* Examples of valid data for the schema.
|
|
144
|
+
*/
|
|
145
|
+
examples: MetaValue<TSpec, TOptions, SchemaMetaExample<TSpec>[]>;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Schema input wrapper that attaches optional contextual metadata.
|
|
149
|
+
*/
|
|
150
|
+
interface SchemaConfigObject<TSpec, TOptions extends object = any> {
|
|
151
|
+
/**
|
|
152
|
+
* 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.
|
|
153
|
+
*/
|
|
154
|
+
schema: SchemaSourceConfig<TSpec> | SchemaEnvelopeOf<TSpec>;
|
|
155
|
+
/**
|
|
156
|
+
* Optional metadata that provides contextual information for the schema.
|
|
157
|
+
*/
|
|
158
|
+
meta?: SchemaMetaConfig<TSpec, TOptions>;
|
|
159
|
+
}
|
|
160
|
+
type InferCreateSchemaOptions<T extends SchemaSourceConfig<any> | SchemaEnvelopeOf<any> | SchemaConfigObject<any, any>> = T extends SchemaSourceConfig<any> | SchemaEnvelopeOf<any> ? InferExtractOptions<T> : {};
|
|
161
|
+
/**
|
|
162
|
+
* A schema extracted from a source input, normalized to JSON Schema.
|
|
163
|
+
*/
|
|
164
|
+
interface Schema<TSpec, TOptions extends object = any> extends SchemaEnvelopeOf<TSpec> {
|
|
165
|
+
/**
|
|
166
|
+
* Optional contextual metadata associated with the schema.
|
|
167
|
+
*/
|
|
168
|
+
meta: SchemaMeta<TSpec, TOptions>;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* A normalized JSON Schema extracted from a source input of type `T`. This type represents the result of the schema extraction process, where a raw schema input (which could be in various formats such as Zod, Untyped, Valibot, or as a type definition in TypeScript source code) is transformed into a standardized JSON Schema format. The `SchemaOf<T>` type captures the normalized JSON Schema along with metadata about the source variant and a content hash for caching or identification purposes.
|
|
172
|
+
*
|
|
173
|
+
* @template TSpec - The original TypeScript type for which the schema is being extracted. This type parameter is used to derive the appropriate JSON Schema representation based on the structure and constraints of `T`.
|
|
174
|
+
*
|
|
175
|
+
* @see {@link Schema}
|
|
176
|
+
*/
|
|
177
|
+
type SchemaOf<TSpec, TOptions extends object = any> = Schema<TSpec, TOptions>;
|
|
178
|
+
//#endregion
|
|
179
|
+
export { SchemaMetaConfig as a, Meta as c, MetaLink as d, MetaValue as f, SchemaMeta as i, MetaConfig as l, Schema as n, SchemaMetaExample as o, SchemaConfigObject as r, SchemaOf as s, InferCreateSchemaOptions as t, MetaDeprecated as u };
|
|
180
|
+
//# sourceMappingURL=schema-DvnNqFd4.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-DvnNqFd4.d.cts","names":[],"sources":["../src/types/meta.ts","../src/types/schema.ts"],"mappings":";;;;KAoBY,SAAA,iDACV,MAAA,KAAW,IAAA,EAAM,KAAA,EAAO,OAAA,EAAS,QAAA,KAAa,YAAA,CAAa,MAAA;AAAA,KAEjD,cAAA;EACQ,OAAA;EAAkB,KAAA;EAAgB,WAAA;AAAA;AAAA,KAE1C,QAAA;EAAsB,IAAA;EAAc,WAAW;AAAA;AAAA,UAE1C,UAAA;EAP2C;;;;;;EAc1D,IAAA,GAAO,SAAA,CAAU,KAAA,EAAO,QAAA;EAdb;;;;;;AAAsD;AAEnE;EAsBE,OAAA,GAAU,SAAA,CAAU,KAAA,EAAO,QAAA,WAAmB,IAAA;;;;EAK9C,WAAA,GAAc,SAAA,CAAU,KAAA,EAAO,QAAA;EA1BqB;;AAAW;AAEjE;;;EAgCE,KAAA,GAAQ,SAAA,CAAU,KAAA,EAAO,QAAA;EAhCgC;AAE3D;;EAmCE,KAAA,GAAQ,SAAA,CAAU,KAAA,EAAO,QAAA;EA5BR;;;;;;EAoCjB,UAAA,GAAa,SAAA,CAAU,KAAA,EAAO,QAAA,EAAU,cAAA;EArBhB;;;;;;EA6BxB,IAAA,GAAO,SAAA,CAAU,KAAA,EAAO,QAAA;EAhBC;;;EAqBzB,KAAA,GAAQ,SAAA,CAAU,KAAA,EAAO,QAAA,EAAU,QAAA;AAAA;AAAA,UAGpB,IAAA;EARE;;;;;;EAejB,EAAA,EAAI,SAAA,CAAU,KAAA,EAAO,QAAA;EAVJ;;;;;;EAkBjB,IAAA,EAAM,SAAA,CAAU,KAAA,EAAO,QAAA;EAnEC;;;;;;;;EA6ExB,OAAA,EAAS,SAAA,CAAU,KAAA,EAAO,QAAA,WAAmB,IAAA;EA9Dd;;;EAmE/B,WAAA,EAAa,SAAA,CAAU,KAAA,EAAO,QAAA;EA3DL;;;;;;EAmEzB,KAAA,EAAO,SAAA,CAAU,KAAA,EAAO,QAAA;EAtDD;;;EA2DvB,KAAA,GAAQ,SAAA,CAAU,KAAA,EAAO,QAAA;EAnDlB;;;;;;EA2DP,UAAA,GAAa,SAAA,CAAU,KAAA,EAAO,QAAA,EAAU,cAAA;EAtDL;;AAAQ;AAG7C;;;EA2DE,IAAA,GAAO,SAAA,CAAU,KAAA,EAAO,QAAA;EApDH;;;EAyDrB,KAAA,EAAO,SAAA,CAAU,KAAA,EAAO,QAAA,EAAU,QAAA;AAAA;;;KC9HxB,iBAAA,UACV,KAAA;EAAU,IAAA;EAAe,WAAA;EAAsB,KAAA,EAAO,KAAK;AAAA;AAAA,UAE5C,gBAAA,+CAGP,UAAA,CAAW,KAAA,EAAO,QAAA;EDVT;;;ECcjB,QAAA,GACI,iBAAA,CAAkB,KAAA,IAClB,SAAA,CAAU,KAAA,EAAO,QAAA,EAAU,iBAAA,CAAkB,KAAA;EDhBS;;;ECqB1D,IAAA,GAAO,SAAA,CAAU,KAAA,EAAO,QAAA;AAAA;AAAA,UAGT,UAAA,+CAAyD,IAAA,CACxE,KAAA,EACA,QAAA;ED1BiB;;;EC+BjB,QAAA,EAAU,SAAA,CAAU,KAAA,EAAO,QAAA,EAAU,iBAAA,CAAkB,KAAA;AAAA;;;AD/BU;UCqClD,kBAAA;EDnCS;;;ECuCxB,MAAA,EAAQ,kBAAA,CAAmB,KAAA,IAAS,gBAAA,CAAiB,KAAA;EDtCjB;;;EC2CpC,IAAA,GAAO,gBAAA,CAAiB,KAAA,EAAO,QAAA;AAAA;AAAA,KAGrB,wBAAA,WAEN,kBAAA,QACA,gBAAA,QACA,kBAAA,cACF,CAAA,SAAU,kBAAA,QAA0B,gBAAA,QACpC,mBAAA,CAAoB,CAAA;;;ADlDmC;UCyD1C,MAAA,+CAGP,gBAAA,CAAiB,KAAA;ED1DA;;;EC8DzB,IAAA,EAAM,UAAA,CAAW,KAAA,EAAO,QAAA;AAAA;;;;;;;;KAUd,QAAA,yCAAiD,MAAA,CAC3D,KAAA,EACA,QAAA"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { InferExtractOptions, SchemaEnvelopeOf, SchemaSourceConfig } from "@power-plant/schema";
|
|
2
|
+
import { MaybePromise } from "@stryke/types/base";
|
|
3
|
+
|
|
4
|
+
//#region src/types/meta.d.ts
|
|
5
|
+
type MetaValue<TSpec, TOptions extends object, TValue = any> = TValue | ((spec: TSpec, options: TOptions) => MaybePromise<TValue>);
|
|
6
|
+
type MetaDeprecated = true | string | {
|
|
7
|
+
message?: string;
|
|
8
|
+
since?: string;
|
|
9
|
+
alternative?: string;
|
|
10
|
+
};
|
|
11
|
+
type MetaLink = string | {
|
|
12
|
+
href: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
};
|
|
15
|
+
interface MetaConfig<TSpec, TOptions extends object> {
|
|
16
|
+
/**
|
|
17
|
+
* A name for the schema, which can be used to identify or reference the schema in documentation, tooling, or other contexts. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* The `name` property is a string that can be used to give the schema a human-readable identifier. It can be used in documentation, error messages, or other contexts where it is helpful to have a name associated with the schema. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
21
|
+
*/
|
|
22
|
+
name?: MetaValue<TSpec, TOptions, string>;
|
|
23
|
+
/**
|
|
24
|
+
* A version string that indicates the version of the schema. This property can be used to track changes or updates to the schema over time, allowing consumers of the schema to determine which version they are working with. 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.
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* The `version` property is a string that can follow any versioning scheme, such as semantic versioning (e.g., "1.0.0", "2.1.3"), date-based versioning (e.g., "2023-06-15"), or any other format that conveys the version of the schema. It is recommended to use a consistent versioning scheme across all schemas to facilitate easier tracking and management of schema versions.
|
|
28
|
+
*
|
|
29
|
+
* @defaultValue "1.0"
|
|
30
|
+
*/
|
|
31
|
+
version?: MetaValue<TSpec, TOptions, string | Date | number>;
|
|
32
|
+
/**
|
|
33
|
+
* A string that describes the schema in some way.
|
|
34
|
+
*/
|
|
35
|
+
description?: MetaValue<TSpec, TOptions, string>;
|
|
36
|
+
/**
|
|
37
|
+
* A string that provides a human-readable name for the schema, which can be used in documentation, tooling, or other contexts to identify or reference the schema. 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.
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* The `title` property is a string that can be used to give the schema a more user-friendly or descriptive name. It can be used in documentation, error messages, or other contexts where it is helpful to have a display name associated with the schema. 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.
|
|
41
|
+
*/
|
|
42
|
+
title?: MetaValue<TSpec, TOptions, string>;
|
|
43
|
+
/**
|
|
44
|
+
* A string that describes when the schema is used.
|
|
45
|
+
*/
|
|
46
|
+
usage?: MetaValue<TSpec, TOptions, string>;
|
|
47
|
+
/**
|
|
48
|
+
* Indicates whether the schema is deprecated, and optionally provides additional information about the deprecation, such as a message, the version since which it is deprecated, and an alternative schema to use instead.
|
|
49
|
+
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* The `deprecated` property can be a boolean value, where `true` indicates that the schema is deprecated and `false` indicates that it is not. It can also be a string that provides a message explaining the deprecation, or an object that includes additional details such as a message, the version since which it is deprecated, and an alternative schema to use instead. 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.
|
|
52
|
+
*/
|
|
53
|
+
deprecated?: MetaValue<TSpec, TOptions, MetaDeprecated>;
|
|
54
|
+
/**
|
|
55
|
+
* An array of tags associated with the schema. Tags can be used to categorize or label schemas for organizational purposes, making it easier to search, filter, or group related schemas together. 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.
|
|
56
|
+
*
|
|
57
|
+
* @remarks
|
|
58
|
+
* Each tag in the array should be a string that represents a meaningful label or category for the schema. It is recommended to use consistent and descriptive tags across schemas to facilitate easier management and discovery of related schemas.
|
|
59
|
+
*/
|
|
60
|
+
tags?: MetaValue<TSpec, TOptions, string[]>;
|
|
61
|
+
/**
|
|
62
|
+
* An array of links associated with the schema. Each link can be a string representing a URL or an object containing a `href` property and an optional `description` property.
|
|
63
|
+
*/
|
|
64
|
+
links?: MetaValue<TSpec, TOptions, MetaLink[]>;
|
|
65
|
+
}
|
|
66
|
+
interface Meta<TSpec, TOptions extends object> {
|
|
67
|
+
/**
|
|
68
|
+
* A unique identifier for the schema, which can be used to reference or identify the schema in documentation, tooling, or other contexts. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
69
|
+
*
|
|
70
|
+
* @remarks
|
|
71
|
+
* The `id` property is a string that can be used to give the schema a unique identifier. It can be used in documentation, error messages, or other contexts where it is helpful to have an identifier associated with the schema. 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.
|
|
72
|
+
*/
|
|
73
|
+
id: MetaValue<TSpec, TOptions, string>;
|
|
74
|
+
/**
|
|
75
|
+
* A name for the schema, which can be used to identify or reference the schema in documentation, tooling, or other contexts. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
76
|
+
*
|
|
77
|
+
* @remarks
|
|
78
|
+
* The `name` property is a string that can be used to give the schema a human-readable identifier. It can be used in documentation, error messages, or other contexts where it is helpful to have a name associated with the schema. The presence of this property does not affect the validation behavior of the schema itself, but it can provide additional context or information about the expected data when used in conjunction with compatible tools.
|
|
79
|
+
*/
|
|
80
|
+
name: MetaValue<TSpec, TOptions, string>;
|
|
81
|
+
/**
|
|
82
|
+
* A version string that indicates the version of the schema. This property can be used to track changes or updates to the schema over time, allowing consumers of the schema to determine which version they are working with. 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.
|
|
83
|
+
*
|
|
84
|
+
* @remarks
|
|
85
|
+
* The `version` property is a string that can follow any versioning scheme, such as semantic versioning (e.g., "1.0.0", "2.1.3"), date-based versioning (e.g., "2023-06-15"), or any other format that conveys the version of the schema. It is recommended to use a consistent versioning scheme across all schemas to facilitate easier tracking and management of schema versions.
|
|
86
|
+
*
|
|
87
|
+
* @defaultValue "1.0"
|
|
88
|
+
*/
|
|
89
|
+
version: MetaValue<TSpec, TOptions, string | Date | number>;
|
|
90
|
+
/**
|
|
91
|
+
* A string that describes the schema in some way.
|
|
92
|
+
*/
|
|
93
|
+
description: MetaValue<TSpec, TOptions, string>;
|
|
94
|
+
/**
|
|
95
|
+
* A string that provides a human-readable name for the schema, which can be used in documentation, tooling, or other contexts to identify or reference the schema. 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.
|
|
96
|
+
*
|
|
97
|
+
* @remarks
|
|
98
|
+
* The `title` property is a string that can be used to give the schema a more user-friendly or descriptive name. It can be used in documentation, error messages, or other contexts where it is helpful to have a display name associated with the schema. 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.
|
|
99
|
+
*/
|
|
100
|
+
title: MetaValue<TSpec, TOptions, string>;
|
|
101
|
+
/**
|
|
102
|
+
* A string that describes when the schema is used.
|
|
103
|
+
*/
|
|
104
|
+
usage?: MetaValue<TSpec, TOptions, string>;
|
|
105
|
+
/**
|
|
106
|
+
* Indicates whether the schema is deprecated, and optionally provides additional information about the deprecation, such as a message, the version since which it is deprecated, and an alternative schema to use instead.
|
|
107
|
+
*
|
|
108
|
+
* @remarks
|
|
109
|
+
* The `deprecated` property can be a boolean value, where `true` indicates that the schema is deprecated and `false` indicates that it is not. It can also be a string that provides a message explaining the deprecation, or an object that includes additional details such as a message, the version since which it is deprecated, and an alternative schema to use instead. 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.
|
|
110
|
+
*/
|
|
111
|
+
deprecated?: MetaValue<TSpec, TOptions, MetaDeprecated>;
|
|
112
|
+
/**
|
|
113
|
+
* An array of tags associated with the schema. Tags can be used to categorize or label schemas for organizational purposes, making it easier to search, filter, or group related schemas together. 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.
|
|
114
|
+
*
|
|
115
|
+
* @remarks
|
|
116
|
+
* Each tag in the array should be a string that represents a meaningful label or category for the schema. It is recommended to use consistent and descriptive tags across schemas to facilitate easier management and discovery of related schemas.
|
|
117
|
+
*/
|
|
118
|
+
tags?: MetaValue<TSpec, TOptions, string[]>;
|
|
119
|
+
/**
|
|
120
|
+
* An array of links associated with the schema. Each link can be a string representing a URL or an object containing a `href` property and an optional `description` property.
|
|
121
|
+
*/
|
|
122
|
+
links: MetaValue<TSpec, TOptions, MetaLink[]>;
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/types/schema.d.ts
|
|
126
|
+
type SchemaMetaExample<TSpec> = TSpec | {
|
|
127
|
+
name?: string;
|
|
128
|
+
description?: string;
|
|
129
|
+
value: TSpec;
|
|
130
|
+
};
|
|
131
|
+
interface SchemaMetaConfig<TSpec, TOptions extends object = any> extends MetaConfig<TSpec, TOptions> {
|
|
132
|
+
/**
|
|
133
|
+
* Examples of valid data for the schema. This can be a single example or an array of examples.
|
|
134
|
+
*/
|
|
135
|
+
examples?: SchemaMetaExample<TSpec> | MetaValue<TSpec, TOptions, SchemaMetaExample<TSpec>[]>;
|
|
136
|
+
/**
|
|
137
|
+
* A description of the specification that is described by this schema.
|
|
138
|
+
*/
|
|
139
|
+
spec?: MetaValue<TSpec, TOptions, string>;
|
|
140
|
+
}
|
|
141
|
+
interface SchemaMeta<TSpec, TOptions extends object = any> extends Meta<TSpec, TOptions> {
|
|
142
|
+
/**
|
|
143
|
+
* Examples of valid data for the schema.
|
|
144
|
+
*/
|
|
145
|
+
examples: MetaValue<TSpec, TOptions, SchemaMetaExample<TSpec>[]>;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Schema input wrapper that attaches optional contextual metadata.
|
|
149
|
+
*/
|
|
150
|
+
interface SchemaConfigObject<TSpec, TOptions extends object = any> {
|
|
151
|
+
/**
|
|
152
|
+
* 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.
|
|
153
|
+
*/
|
|
154
|
+
schema: SchemaSourceConfig<TSpec> | SchemaEnvelopeOf<TSpec>;
|
|
155
|
+
/**
|
|
156
|
+
* Optional metadata that provides contextual information for the schema.
|
|
157
|
+
*/
|
|
158
|
+
meta?: SchemaMetaConfig<TSpec, TOptions>;
|
|
159
|
+
}
|
|
160
|
+
type InferCreateSchemaOptions<T extends SchemaSourceConfig<any> | SchemaEnvelopeOf<any> | SchemaConfigObject<any, any>> = T extends SchemaSourceConfig<any> | SchemaEnvelopeOf<any> ? InferExtractOptions<T> : {};
|
|
161
|
+
/**
|
|
162
|
+
* A schema extracted from a source input, normalized to JSON Schema.
|
|
163
|
+
*/
|
|
164
|
+
interface Schema<TSpec, TOptions extends object = any> extends SchemaEnvelopeOf<TSpec> {
|
|
165
|
+
/**
|
|
166
|
+
* Optional contextual metadata associated with the schema.
|
|
167
|
+
*/
|
|
168
|
+
meta: SchemaMeta<TSpec, TOptions>;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* A normalized JSON Schema extracted from a source input of type `T`. This type represents the result of the schema extraction process, where a raw schema input (which could be in various formats such as Zod, Untyped, Valibot, or as a type definition in TypeScript source code) is transformed into a standardized JSON Schema format. The `SchemaOf<T>` type captures the normalized JSON Schema along with metadata about the source variant and a content hash for caching or identification purposes.
|
|
172
|
+
*
|
|
173
|
+
* @template TSpec - The original TypeScript type for which the schema is being extracted. This type parameter is used to derive the appropriate JSON Schema representation based on the structure and constraints of `T`.
|
|
174
|
+
*
|
|
175
|
+
* @see {@link Schema}
|
|
176
|
+
*/
|
|
177
|
+
type SchemaOf<TSpec, TOptions extends object = any> = Schema<TSpec, TOptions>;
|
|
178
|
+
//#endregion
|
|
179
|
+
export { SchemaMetaConfig as a, Meta as c, MetaLink as d, MetaValue as f, SchemaMeta as i, MetaConfig as l, Schema as n, SchemaMetaExample as o, SchemaConfigObject as r, SchemaOf as s, InferCreateSchemaOptions as t, MetaDeprecated as u };
|
|
180
|
+
//# sourceMappingURL=schema-DvnNqFd4.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-DvnNqFd4.d.mts","names":[],"sources":["../src/types/meta.ts","../src/types/schema.ts"],"mappings":""}
|