@power-plant/schema 0.0.35 → 0.0.37

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/codegen.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_helpers = require('./helpers-BQD6GZyX.cjs');
2
+ const require_helpers = require('./helpers-DbFdMcOB.cjs');
3
3
  let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
4
4
  let _stryke_type_checks = require("@stryke/type-checks");
5
5
  let _stryke_string_format_list = require("@stryke/string-format/list");
@@ -1,4 +1,4 @@
1
- import { U as JsonSchemaType, a as JsonSchema } from "./types-hfHmxKG0.cjs";
1
+ import { G as JsonSchemaType, a as JsonSchema } from "./types-BH-Q7QrB.cjs";
2
2
  //#region src/codegen.d.ts
3
3
  /**
4
4
  * Stringifies a value for generated TypeScript code.
@@ -1,4 +1,4 @@
1
- import { U as JsonSchemaType, a as JsonSchema } from "./types-CyvYSCHO.mjs";
1
+ import { G as JsonSchemaType, a as JsonSchema } from "./types-BrSNvUQg.mjs";
2
2
  //#region src/codegen.d.ts
3
3
  /**
4
4
  * Stringifies a value for generated TypeScript code.
package/dist/codegen.mjs CHANGED
@@ -1,20 +1,20 @@
1
- import { B as isJsonSchemaString, D as isJsonSchemaLiteral, P as isJsonSchemaObject, a as getPropertiesList, c as isSchemaNullable, d as merge, h as isJsonSchema, ot as getPrimarySchemaType } from "./helpers-dvxktFml.mjs";
1
+ import { F as isJsonSchemaObject, O as isJsonSchemaLiteral, V as isJsonSchemaString, a as getPropertiesList, c as isSchemaNullable, d as merge, g as isJsonSchema, st as getPrimarySchemaType } from "./helpers-_8ADIMSN.mjs";
2
2
  import { isSetString } from "@stryke/type-checks/is-set-string";
3
3
  import { isInteger, isObject, isSetArray, isString } from "@stryke/type-checks";
4
4
  import { list } from "@stryke/string-format/list";
5
5
  import { toBool } from "@stryke/convert/to-bool";
6
6
  import { camelCase } from "@stryke/string-format/camel-case";
7
7
  import { isBoolean as isBoolean$1 } from "@stryke/type-checks/is-boolean";
8
- import { isNull } from "@stryke/type-checks/is-null";
9
- import { isNumber } from "@stryke/type-checks/is-number";
10
- import { isUndefined } from "@stryke/type-checks/is-undefined";
8
+ import { isNull as isNull$1 } from "@stryke/type-checks/is-null";
9
+ import { isNumber as isNumber$1 } from "@stryke/type-checks/is-number";
10
+ import { isUndefined as isUndefined$1 } from "@stryke/type-checks/is-undefined";
11
11
 
12
12
  //#region src/codegen.ts
13
13
  /**
14
14
  * Stringifies a value for generated TypeScript code.
15
15
  */
16
16
  function stringifyValue(value, type) {
17
- return isUndefined(value) ? "undefined" : isNull(value) ? "null" : type === "boolean" || isBoolean$1(value) ? String(toBool(value)) : type === "number" || isNumber(value) ? Number.parseFloat(String(value)).toLocaleString(void 0, { maximumFractionDigits: 20 }) : type === "integer" ? Number.parseInt(String(value)).toLocaleString() : type === "string" || type === "object" || type === "array" ? JSON.stringify(value) : String(value);
17
+ return isUndefined$1(value) ? "undefined" : isNull$1(value) ? "null" : type === "boolean" || isBoolean$1(value) ? String(toBool(value)) : type === "number" || isNumber$1(value) ? Number.parseFloat(String(value)).toLocaleString(void 0, { maximumFractionDigits: 20 }) : type === "integer" ? Number.parseInt(String(value)).toLocaleString() : type === "string" || type === "object" || type === "array" ? JSON.stringify(value) : String(value);
18
18
  }
19
19
  /**
20
20
  * Stringifies a JSON Schema fragment into a TypeScript-like type string.
@@ -25,7 +25,7 @@ function stringifyType(schema) {
25
25
  if (isJsonSchemaObject(schema) && isSetString(schema.name)) return schema.name;
26
26
  const objectSchema = schema;
27
27
  if (isSetString(objectSchema.$ref)) return /^#\/(?:definitions|\$defs)\/(.+)$/.exec(objectSchema.$ref)?.[1] ?? objectSchema.$ref;
28
- if (isJsonSchemaLiteral(schema) && !isUndefined(schema.const)) return JSON.stringify(isSetString(schema.const) ? schema.const.replaceAll(/^['"`]|['"`]$/g, "") : schema.const);
28
+ if (isJsonSchemaLiteral(schema) && !isUndefined$1(schema.const)) return JSON.stringify(isSetString(schema.const) ? schema.const.replaceAll(/^['"`]|['"`]$/g, "") : schema.const);
29
29
  const primaryType = getPrimarySchemaType(schema);
30
30
  if (primaryType) {
31
31
  if (primaryType === "integer" || primaryType === "number") return "number";
@@ -55,7 +55,7 @@ function stringifyType(schema) {
55
55
  * @returns A string representation of the value's type, which may be influenced by the provided JSON Schema primitive type hint. The function handles various JavaScript types and formats them accordingly, including special handling for `undefined`, `null`, booleans, numbers (with formatting), strings, objects, and arrays. If a specific type hint is provided, it will take precedence in determining the string representation of the value.
56
56
  */
57
57
  function getJsonSchemaType(value) {
58
- return isNull(value) ? "null" : isBoolean$1(value) ? "boolean" : isInteger(value) ? "integer" : isNumber(value) ? "number" : isString(value) ? "string" : isObject(value) ? "object" : Array.isArray(value) ? "array" : void 0;
58
+ return isNull$1(value) ? "null" : isBoolean$1(value) ? "boolean" : isInteger(value) ? "integer" : isNumber$1(value) ? "number" : isString(value) ? "string" : isObject(value) ? "object" : Array.isArray(value) ? "array" : void 0;
59
59
  }
60
60
  /**
61
61
  * Resolves a local JSON Schema `$ref` (e.g. `#/$defs/Name`) to the referenced definition name.
@@ -46,6 +46,15 @@ const JSON_SCHEMA_METADATA_KEYS = [
46
46
  "writeOnly"
47
47
  ];
48
48
  /**
49
+ * Own-property key set to `true` on constructor function schemas.
50
+ *
51
+ * @remarks
52
+ * Must be read with `Object.hasOwn(schema, JSON_SCHEMA_CONSTRUCTOR_KEY)` (or
53
+ * `hasJsonSchemaConstructorFlag`) — never via `schema.constructor`, which
54
+ * resolves `Object.prototype.constructor`.
55
+ */
56
+ const JSON_SCHEMA_CONSTRUCTOR_KEY = "constructor";
57
+ /**
49
58
  * Keywords whose values are a flat record of named JSON Schema fragments.
50
59
  * Each child schema is merged recursively with its counterpart.
51
60
  */
@@ -83,5 +92,5 @@ const SCHEMA_ARRAY_CONCAT_KEYWORDS = /* @__PURE__ */ new Set([
83
92
  ]);
84
93
 
85
94
  //#endregion
86
- export { SCHEMA_ARRAY_CONCAT_KEYWORDS as a, JsonSchemaTypeNames as i, JSON_SCHEMA_PRIMITIVE_TYPES as n, SCHEMA_RECORD_KEYWORDS as o, JSON_SCHEMA_TYPES as r, SCHEMA_SINGLE_KEYWORDS as s, JSON_SCHEMA_METADATA_KEYS as t };
87
- //# sourceMappingURL=constants-COGt3eeW.mjs.map
95
+ export { JsonSchemaTypeNames as a, SCHEMA_SINGLE_KEYWORDS as c, JSON_SCHEMA_TYPES as i, JSON_SCHEMA_METADATA_KEYS as n, SCHEMA_ARRAY_CONCAT_KEYWORDS as o, JSON_SCHEMA_PRIMITIVE_TYPES as r, SCHEMA_RECORD_KEYWORDS as s, JSON_SCHEMA_CONSTRUCTOR_KEY as t };
96
+ //# sourceMappingURL=constants-BlppSDwG.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants-BlppSDwG.mjs","names":[],"sources":[],"mappings":""}
@@ -47,6 +47,15 @@ const JSON_SCHEMA_METADATA_KEYS = [
47
47
  "writeOnly"
48
48
  ];
49
49
  /**
50
+ * Own-property key set to `true` on constructor function schemas.
51
+ *
52
+ * @remarks
53
+ * Must be read with `Object.hasOwn(schema, JSON_SCHEMA_CONSTRUCTOR_KEY)` (or
54
+ * `hasJsonSchemaConstructorFlag`) — never via `schema.constructor`, which
55
+ * resolves `Object.prototype.constructor`.
56
+ */
57
+ const JSON_SCHEMA_CONSTRUCTOR_KEY = "constructor";
58
+ /**
50
59
  * Keywords whose values are a flat record of named JSON Schema fragments.
51
60
  * Each child schema is merged recursively with its counterpart.
52
61
  */
@@ -84,6 +93,12 @@ const SCHEMA_ARRAY_CONCAT_KEYWORDS = /* @__PURE__ */ new Set([
84
93
  ]);
85
94
 
86
95
  //#endregion
96
+ Object.defineProperty(exports, 'JSON_SCHEMA_CONSTRUCTOR_KEY', {
97
+ enumerable: true,
98
+ get: function () {
99
+ return JSON_SCHEMA_CONSTRUCTOR_KEY;
100
+ }
101
+ });
87
102
  Object.defineProperty(exports, 'JSON_SCHEMA_METADATA_KEYS', {
88
103
  enumerable: true,
89
104
  get: function () {
@@ -1,13 +1,13 @@
1
1
  const require_rolldown_runtime = require('./rolldown-runtime-C_NdSu1c.cjs');
2
- const require_constants = require('./constants-B7xonHLD.cjs');
2
+ const require_constants = require('./constants-CEmLvTDd.cjs');
3
3
  let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
4
4
  let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
5
5
  let _stryke_type_checks = require("@stryke/type-checks");
6
6
  let _stryke_path_find = require("@stryke/path/find");
7
7
  let _stryke_resolve_constants = require("@stryke/resolve/constants");
8
- let _stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
9
8
  let defu = require("defu");
10
9
  defu = require_rolldown_runtime.__toESM(defu, 1);
10
+ let _stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
11
11
 
12
12
  //#region src/metadata.ts
13
13
  /**
@@ -531,6 +531,20 @@ function isValibotSchema(input) {
531
531
  return schema.kind === "schema" && (0, _stryke_type_checks.isSetString)(schema.type) && (0, _stryke_type_checks.isBoolean)(schema.async) && (0, _stryke_type_checks.isFunction)(schema.reference) && (0, _stryke_type_checks.isSetString)(schema.expects) && (0, _stryke_type_checks.isFunction)(schema["~run"]);
532
532
  }
533
533
  /**
534
+ * Returns true when `input` is a function schema that represents a constructor.
535
+ *
536
+ * @remarks
537
+ * Uses `Object.hasOwn` on {@link JSON_SCHEMA_CONSTRUCTOR_KEY}. Do not read
538
+ * `schema.constructor` — that returns `Object.prototype.constructor`.
539
+ *
540
+ * @param input - A JSON Schema (or unknown value) to inspect.
541
+ * @returns True when the schema has an own `"constructor": true` flag.
542
+ */
543
+ function hasJsonSchemaConstructorFlag(input) {
544
+ if (!(0, _stryke_type_checks.isSetObject)(input)) return false;
545
+ return Object.hasOwn(input, "constructor") && input["constructor"] === true;
546
+ }
547
+ /**
534
548
  * Type guard for JSON Schema types.
535
549
  *
536
550
  * @remarks
@@ -974,6 +988,12 @@ Object.defineProperty(exports, 'getProperty', {
974
988
  return getProperty;
975
989
  }
976
990
  });
991
+ Object.defineProperty(exports, 'hasJsonSchemaConstructorFlag', {
992
+ enumerable: true,
993
+ get: function () {
994
+ return hasJsonSchemaConstructorFlag;
995
+ }
996
+ });
977
997
  Object.defineProperty(exports, 'isFileReference', {
978
998
  enumerable: true,
979
999
  get: function () {
@@ -1,11 +1,11 @@
1
- import { a as SCHEMA_ARRAY_CONCAT_KEYWORDS, n as JSON_SCHEMA_PRIMITIVE_TYPES, o as SCHEMA_RECORD_KEYWORDS, r as JSON_SCHEMA_TYPES, s as SCHEMA_SINGLE_KEYWORDS, t as JSON_SCHEMA_METADATA_KEYS } from "./constants-COGt3eeW.mjs";
1
+ import { c as SCHEMA_SINGLE_KEYWORDS, i as JSON_SCHEMA_TYPES, n as JSON_SCHEMA_METADATA_KEYS, o as SCHEMA_ARRAY_CONCAT_KEYWORDS, r as JSON_SCHEMA_PRIMITIVE_TYPES, s as SCHEMA_RECORD_KEYWORDS, t as JSON_SCHEMA_CONSTRUCTOR_KEY } from "./constants-BlppSDwG.mjs";
2
2
  import { isSetObject } from "@stryke/type-checks/is-set-object";
3
3
  import { isSetString } from "@stryke/type-checks/is-set-string";
4
4
  import { isBoolean, isFunction, isSetObject as isSetObject$1, isSetString as isSetString$1, isString } from "@stryke/type-checks";
5
5
  import { findFileExtensionSafe } from "@stryke/path/find";
6
6
  import { VALID_OBJECT_SOURCE_EXTENSIONS } from "@stryke/resolve/constants";
7
- import { getUnique } from "@stryke/helpers/get-unique";
8
7
  import defu from "defu";
8
+ import { getUnique } from "@stryke/helpers/get-unique";
9
9
 
10
10
  //#region src/metadata.ts
11
11
  /**
@@ -529,6 +529,20 @@ function isValibotSchema(input) {
529
529
  return schema.kind === "schema" && isSetString$1(schema.type) && isBoolean(schema.async) && isFunction(schema.reference) && isSetString$1(schema.expects) && isFunction(schema["~run"]);
530
530
  }
531
531
  /**
532
+ * Returns true when `input` is a function schema that represents a constructor.
533
+ *
534
+ * @remarks
535
+ * Uses `Object.hasOwn` on {@link JSON_SCHEMA_CONSTRUCTOR_KEY}. Do not read
536
+ * `schema.constructor` — that returns `Object.prototype.constructor`.
537
+ *
538
+ * @param input - A JSON Schema (or unknown value) to inspect.
539
+ * @returns True when the schema has an own `"constructor": true` flag.
540
+ */
541
+ function hasJsonSchemaConstructorFlag(input) {
542
+ if (!isSetObject$1(input)) return false;
543
+ return Object.hasOwn(input, "constructor") && input["constructor"] === true;
544
+ }
545
+ /**
532
546
  * Type guard for JSON Schema types.
533
547
  *
534
548
  * @remarks
@@ -924,5 +938,5 @@ function traverseSchema(schema, callback) {
924
938
  }
925
939
 
926
940
  //#endregion
927
- export { isUntypedConfigStrict as $, isJsonSchemaNever as A, isJsonSchemaString as B, isJsonSchemaDecimal as C, isJsonSchemaLiteral as D, isJsonSchemaKeywords as E, isJsonSchemaPrimitiveType as F, isJsonSchemaUnknown as G, isJsonSchemaType as H, isJsonSchemaPrimitiveUnion as I, isSchemaObject as J, isNullOnlyJsonSchema as K, isJsonSchemaRecord as L, isJsonSchemaNullable as M, isJsonSchemaNumber as N, isJsonSchemaMap as O, isJsonSchemaObject as P, isUntypedConfig as Q, isJsonSchemaRef as R, isJsonSchemaDate as S, isJsonSchemaInteger as T, isJsonSchemaUndefined as U, isJsonSchemaTuple as V, isJsonSchemaUnion as W, isSchemaWithSource as X, isSchemaOf as Y, isStandardSchema as Z, isJsonSchemaAny as _, getPropertiesList as a, applyJsonSchemaMetadata as at, isJsonSchemaBigint as b, isSchemaNullable as c, merge as d, isUntypedInput as et, mergeMetadata as f, isJsonSchemaAllOf as g, isJsonSchema as h, getProperties as i, isValibotSchema as it, isJsonSchemaNull as j, isJsonSchemaNativeEnum as k, isValidSchemaConfigFile as l, isFileReference as m, getJsonSchema as n, isUntypedSchema as nt, getProperty as o, getPrimarySchemaType as ot, traverseSchema as p, isSchema as q, getJsonSchemaObject as r, isUntypedSchemaStrict as rt, isPropertyOptional as s, readSchemaTypes as st, addProperty as t, isUntypedInputStrict as tt, isValidSchemaInputFile as u, isJsonSchemaAnyOf as v, isJsonSchemaEnum as w, isJsonSchemaBoolean as x, isJsonSchemaArray as y, isJsonSchemaSet as z };
928
- //# sourceMappingURL=helpers-dvxktFml.mjs.map
941
+ export { isUntypedConfig as $, isJsonSchemaNativeEnum as A, isJsonSchemaSet as B, isJsonSchemaDate as C, isJsonSchemaKeywords as D, isJsonSchemaInteger as E, isJsonSchemaObject as F, isJsonSchemaUnion as G, isJsonSchemaTuple as H, isJsonSchemaPrimitiveType as I, isSchema as J, isJsonSchemaUnknown as K, isJsonSchemaPrimitiveUnion as L, isJsonSchemaNull as M, isJsonSchemaNullable as N, isJsonSchemaLiteral as O, isJsonSchemaNumber as P, isStandardSchema as Q, isJsonSchemaRecord as R, isJsonSchemaBoolean as S, isJsonSchemaEnum as T, isJsonSchemaType as U, isJsonSchemaString as V, isJsonSchemaUndefined as W, isSchemaOf as X, isSchemaObject as Y, isSchemaWithSource as Z, isJsonSchemaAllOf as _, getPropertiesList as a, isValibotSchema as at, isJsonSchemaArray as b, isSchemaNullable as c, readSchemaTypes as ct, merge as d, isUntypedConfigStrict as et, mergeMetadata as f, isJsonSchema as g, isFileReference as h, getProperties as i, isUntypedSchemaStrict as it, isJsonSchemaNever as j, isJsonSchemaMap as k, isValidSchemaConfigFile as l, hasJsonSchemaConstructorFlag as m, getJsonSchema as n, isUntypedInputStrict as nt, getProperty as o, applyJsonSchemaMetadata as ot, traverseSchema as p, isNullOnlyJsonSchema as q, getJsonSchemaObject as r, isUntypedSchema as rt, isPropertyOptional as s, getPrimarySchemaType as st, addProperty as t, isUntypedInput as tt, isValidSchemaInputFile as u, isJsonSchemaAny as v, isJsonSchemaDecimal as w, isJsonSchemaBigint as x, isJsonSchemaAnyOf as y, isJsonSchemaRef as z };
942
+ //# sourceMappingURL=helpers-_8ADIMSN.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers-_8ADIMSN.mjs","names":[],"sources":[],"mappings":""}