@clementine-solutions/jane-io 1.0.0 → 1.0.2
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 +132 -1
- package/dist/core/analysis/diff.d.ts +35 -0
- package/dist/core/analysis/diff.js +88 -0
- package/dist/core/analysis/explain.d.ts +35 -0
- package/dist/core/analysis/explain.js +117 -0
- package/dist/core/analysis/index.d.ts +14 -0
- package/dist/core/analysis/index.js +26 -0
- package/dist/core/analysis/replay.d.ts +34 -0
- package/dist/core/analysis/replay.js +68 -0
- package/dist/core/analysis/telemetry.d.ts +28 -0
- package/dist/core/analysis/telemetry.js +123 -0
- package/dist/core/boundary-rules/at-most-one.d.ts +17 -0
- package/dist/core/boundary-rules/at-most-one.js +38 -0
- package/dist/core/boundary-rules/conditionally-required.d.ts +18 -0
- package/dist/core/boundary-rules/conditionally-required.js +44 -0
- package/dist/core/boundary-rules/date-range.d.ts +17 -0
- package/dist/core/boundary-rules/date-range.js +39 -0
- package/dist/core/boundary-rules/index.d.ts +18 -0
- package/dist/core/boundary-rules/index.js +21 -0
- package/dist/core/boundary-rules/mutually-exclusive.d.ts +16 -0
- package/dist/core/boundary-rules/mutually-exclusive.js +38 -0
- package/dist/core/boundary-rules/no-unknown-fields.d.ts +17 -0
- package/dist/core/boundary-rules/no-unknown-fields.js +39 -0
- package/dist/core/boundary-rules/require-all.d.ts +16 -0
- package/dist/core/boundary-rules/require-all.js +39 -0
- package/dist/core/boundary-rules/require-one.d.ts +17 -0
- package/dist/core/boundary-rules/require-one.js +41 -0
- package/dist/core/common/events.d.ts +37 -0
- package/dist/core/common/events.js +82 -0
- package/dist/core/common/fluent.d.ts +151 -0
- package/dist/core/common/fluent.js +429 -0
- package/dist/core/common/index.d.ts +16 -0
- package/dist/core/common/index.js +31 -0
- package/dist/core/common/policy.d.ts +170 -0
- package/dist/core/common/policy.js +550 -0
- package/dist/core/common/utilities.d.ts +59 -0
- package/dist/core/common/utilities.js +177 -0
- package/dist/core/common/wildcard.d.ts +27 -0
- package/dist/core/common/wildcard.js +63 -0
- package/dist/core/field-path/construct.d.ts +77 -0
- package/dist/core/field-path/construct.js +189 -0
- package/dist/core/field-path/format.d.ts +41 -0
- package/dist/core/field-path/format.js +154 -0
- package/dist/core/field-path/index.d.ts +14 -0
- package/dist/core/field-path/index.js +26 -0
- package/dist/core/field-path/utilities.d.ts +85 -0
- package/dist/core/field-path/utilities.js +138 -0
- package/dist/core/field-path/walk.d.ts +36 -0
- package/dist/core/field-path/walk.js +80 -0
- package/dist/core/fluent-registry.d.ts +138 -0
- package/dist/core/fluent-registry.js +151 -0
- package/dist/core/normalizers/array/compact-sparse-array.d.ts +22 -0
- package/dist/core/normalizers/array/compact-sparse-array.js +40 -0
- package/dist/core/normalizers/array/flatten-one-level.d.ts +17 -0
- package/dist/core/normalizers/array/flatten-one-level.js +45 -0
- package/dist/core/normalizers/array/remove-empty-string-items.d.ts +6 -0
- package/dist/core/normalizers/array/remove-empty-string-items.js +34 -0
- package/dist/core/normalizers/array/remove-null-items.d.ts +16 -0
- package/dist/core/normalizers/array/remove-null-items.js +34 -0
- package/dist/core/normalizers/array/remove-undefined-items.d.ts +16 -0
- package/dist/core/normalizers/array/remove-undefined-items.js +34 -0
- package/dist/core/normalizers/date/invalid-date-to-undefined.d.ts +17 -0
- package/dist/core/normalizers/date/invalid-date-to-undefined.js +35 -0
- package/dist/core/normalizers/index.d.ts +28 -0
- package/dist/core/normalizers/index.js +46 -0
- package/dist/core/normalizers/normalizer-register.d.ts +17 -0
- package/dist/core/normalizers/normalizer-register.js +41 -0
- package/dist/core/normalizers/number/infinity-to-undefined.d.ts +18 -0
- package/dist/core/normalizers/number/infinity-to-undefined.js +35 -0
- package/dist/core/normalizers/number/nan-to-undefined.d.ts +17 -0
- package/dist/core/normalizers/number/nan-to-undefined.js +34 -0
- package/dist/core/normalizers/number/normalize-negative-zero.d.ts +16 -0
- package/dist/core/normalizers/number/normalize-negative-zero.js +33 -0
- package/dist/core/normalizers/object/remove-empty-array-keys.d.ts +17 -0
- package/dist/core/normalizers/object/remove-empty-array-keys.js +38 -0
- package/dist/core/normalizers/object/remove-empty-object-keys.d.ts +16 -0
- package/dist/core/normalizers/object/remove-empty-object-keys.js +42 -0
- package/dist/core/normalizers/object/remove-empty-string-keys.d.ts +16 -0
- package/dist/core/normalizers/object/remove-empty-string-keys.js +37 -0
- package/dist/core/normalizers/object/remove-null-keys.d.ts +16 -0
- package/dist/core/normalizers/object/remove-null-keys.js +37 -0
- package/dist/core/normalizers/object/remove-undefined-keys.d.ts +16 -0
- package/dist/core/normalizers/object/remove-undefined-keys.js +37 -0
- package/dist/core/normalizers/string/collapse-whitespace.d.ts +17 -0
- package/dist/core/normalizers/string/collapse-whitespace.js +35 -0
- package/dist/core/normalizers/string/empty-to-undefined.d.ts +16 -0
- package/dist/core/normalizers/string/empty-to-undefined.js +33 -0
- package/dist/core/normalizers/string/trim.d.ts +16 -0
- package/dist/core/normalizers/string/trim.js +34 -0
- package/dist/core/parsers/index.d.ts +22 -0
- package/dist/core/parsers/index.js +43 -0
- package/dist/core/parsers/parse-array-string.d.ts +16 -0
- package/dist/core/parsers/parse-array-string.js +36 -0
- package/dist/core/parsers/parse-bigint-string.d.ts +16 -0
- package/dist/core/parsers/parse-bigint-string.js +33 -0
- package/dist/core/parsers/parse-binary-string.d.ts +16 -0
- package/dist/core/parsers/parse-binary-string.js +33 -0
- package/dist/core/parsers/parse-boolean-string.d.ts +16 -0
- package/dist/core/parsers/parse-boolean-string.js +27 -0
- package/dist/core/parsers/parse-date-string.d.ts +16 -0
- package/dist/core/parsers/parse-date-string.js +30 -0
- package/dist/core/parsers/parse-duration-string.d.ts +16 -0
- package/dist/core/parsers/parse-duration-string.js +37 -0
- package/dist/core/parsers/parse-hex-string.d.ts +16 -0
- package/dist/core/parsers/parse-hex-string.js +29 -0
- package/dist/core/parsers/parse-integer-string.d.ts +16 -0
- package/dist/core/parsers/parse-integer-string.js +30 -0
- package/dist/core/parsers/parse-json-string.d.ts +17 -0
- package/dist/core/parsers/parse-json-string.js +35 -0
- package/dist/core/parsers/parse-numeric-string.d.ts +16 -0
- package/dist/core/parsers/parse-numeric-string.js +29 -0
- package/dist/core/parsers/parse-object-string.d.ts +16 -0
- package/dist/core/parsers/parse-object-string.js +36 -0
- package/dist/core/parsers/parse-octal-string.d.ts +16 -0
- package/dist/core/parsers/parse-octal-string.js +33 -0
- package/dist/core/parsers/parse-scientific-notation-string.d.ts +16 -0
- package/dist/core/parsers/parse-scientific-notation-string.js +30 -0
- package/dist/core/parsers/parse-url-string.d.ts +16 -0
- package/dist/core/parsers/parse-url-string.js +36 -0
- package/dist/core/pipeline/boundary.d.ts +36 -0
- package/dist/core/pipeline/boundary.js +256 -0
- package/dist/core/pipeline/contain.d.ts +122 -0
- package/dist/core/pipeline/contain.js +339 -0
- package/dist/core/pipeline/index.d.ts +16 -0
- package/dist/core/pipeline/index.js +37 -0
- package/dist/core/pipeline/normalize.d.ts +34 -0
- package/dist/core/pipeline/normalize.js +76 -0
- package/dist/core/pipeline/parse.d.ts +40 -0
- package/dist/core/pipeline/parse.js +91 -0
- package/dist/core/pipeline/pipeline.d.ts +23 -0
- package/dist/core/pipeline/pipeline.js +418 -0
- package/dist/core/pipeline/scan.d.ts +46 -0
- package/dist/core/pipeline/scan.js +115 -0
- package/dist/core/pipeline/validate.d.ts +40 -0
- package/dist/core/pipeline/validate.js +74 -0
- package/dist/core/scanners/any/scan-for-sentinels.d.ts +19 -0
- package/dist/core/scanners/any/scan-for-sentinels.js +35 -0
- package/dist/core/scanners/array/array-is-deep.d.ts +19 -0
- package/dist/core/scanners/array/array-is-deep.js +38 -0
- package/dist/core/scanners/array/array-is-heterogenous.d.ts +18 -0
- package/dist/core/scanners/array/array-is-heterogenous.js +39 -0
- package/dist/core/scanners/array/array-is-large.d.ts +19 -0
- package/dist/core/scanners/array/array-is-large.js +32 -0
- package/dist/core/scanners/bigint/bigint-is-large.d.ts +20 -0
- package/dist/core/scanners/bigint/bigint-is-large.js +34 -0
- package/dist/core/scanners/bigint/bigint-not-safe.d.ts +20 -0
- package/dist/core/scanners/bigint/bigint-not-safe.js +34 -0
- package/dist/core/scanners/date/date-is-before-epoch.d.ts +19 -0
- package/dist/core/scanners/date/date-is-before-epoch.js +32 -0
- package/dist/core/scanners/date/date-is-far-future.d.ts +19 -0
- package/dist/core/scanners/date/date-is-far-future.js +32 -0
- package/dist/core/scanners/date/date-is-invalid.d.ts +19 -0
- package/dist/core/scanners/date/date-is-invalid.js +31 -0
- package/dist/core/scanners/index.d.ts +31 -0
- package/dist/core/scanners/index.js +58 -0
- package/dist/core/scanners/number/number-is-infinite.d.ts +19 -0
- package/dist/core/scanners/number/number-is-infinite.js +31 -0
- package/dist/core/scanners/number/number-is-nan.d.ts +19 -0
- package/dist/core/scanners/number/number-is-nan.js +31 -0
- package/dist/core/scanners/number/number-is-too-large.d.ts +20 -0
- package/dist/core/scanners/number/number-is-too-large.js +33 -0
- package/dist/core/scanners/number/number-is-unsafe-integer.d.ts +19 -0
- package/dist/core/scanners/number/number-is-unsafe-integer.js +31 -0
- package/dist/core/scanners/object/object-has-circular-references.d.ts +20 -0
- package/dist/core/scanners/object/object-has-circular-references.js +43 -0
- package/dist/core/scanners/object/object-has-many-keys.d.ts +19 -0
- package/dist/core/scanners/object/object-has-many-keys.js +33 -0
- package/dist/core/scanners/object/object-is-deep.d.ts +20 -0
- package/dist/core/scanners/object/object-is-deep.js +38 -0
- package/dist/core/scanners/scanner-registry.d.ts +19 -0
- package/dist/core/scanners/scanner-registry.js +36 -0
- package/dist/core/scanners/string/string-has-unsafe-unicode.d.ts +19 -0
- package/dist/core/scanners/string/string-has-unsafe-unicode.js +32 -0
- package/dist/core/scanners/string/string-has-whitespace-edges.d.ts +19 -0
- package/dist/core/scanners/string/string-has-whitespace-edges.js +31 -0
- package/dist/core/scanners/string/string-is-long.d.ts +19 -0
- package/dist/core/scanners/string/string-is-long.js +32 -0
- package/dist/core/scanners/unknown/unknown-not-scannable.d.ts +21 -0
- package/dist/core/scanners/unknown/unknown-not-scannable.js +34 -0
- package/dist/core/shapes/analysis.d.ts +239 -0
- package/dist/core/shapes/analysis.js +11 -0
- package/dist/core/shapes/boundary.d.ts +126 -0
- package/dist/core/shapes/boundary.js +11 -0
- package/dist/core/shapes/events.d.ts +83 -0
- package/dist/core/shapes/events.js +10 -0
- package/dist/core/shapes/field-path.d.ts +51 -0
- package/dist/core/shapes/field-path.js +10 -0
- package/dist/core/shapes/index.d.ts +21 -0
- package/dist/core/shapes/index.js +11 -0
- package/dist/core/shapes/normalize.d.ts +59 -0
- package/dist/core/shapes/normalize.js +11 -0
- package/dist/core/shapes/parse.d.ts +75 -0
- package/dist/core/shapes/parse.js +11 -0
- package/dist/core/shapes/pipeline.d.ts +149 -0
- package/dist/core/shapes/pipeline.js +11 -0
- package/dist/core/shapes/policy.d.ts +158 -0
- package/dist/core/shapes/policy.js +11 -0
- package/dist/core/shapes/public.d.ts +92 -0
- package/dist/core/shapes/public.js +10 -0
- package/dist/core/shapes/scan.d.ts +126 -0
- package/dist/core/shapes/scan.js +11 -0
- package/dist/core/shapes/validate.d.ts +65 -0
- package/dist/core/shapes/validate.js +11 -0
- package/dist/core/validators/array/array-max-items.d.ts +25 -0
- package/dist/core/validators/array/array-max-items.js +42 -0
- package/dist/core/validators/array/array-min-items.d.ts +25 -0
- package/dist/core/validators/array/array-min-items.js +42 -0
- package/dist/core/validators/array/array.d.ts +22 -0
- package/dist/core/validators/array/array.js +34 -0
- package/dist/core/validators/array/excludes.d.ts +25 -0
- package/dist/core/validators/array/excludes.js +47 -0
- package/dist/core/validators/array/has-unique-items.d.ts +24 -0
- package/dist/core/validators/array/has-unique-items.js +46 -0
- package/dist/core/validators/array/includes.d.ts +24 -0
- package/dist/core/validators/array/includes.js +46 -0
- package/dist/core/validators/array/items-equal.d.ts +25 -0
- package/dist/core/validators/array/items-equal.js +42 -0
- package/dist/core/validators/array/no-empty-string-items.d.ts +24 -0
- package/dist/core/validators/array/no-empty-string-items.js +46 -0
- package/dist/core/validators/array/no-null-items.d.ts +24 -0
- package/dist/core/validators/array/no-null-items.js +46 -0
- package/dist/core/validators/array/no-undefined-items.d.ts +24 -0
- package/dist/core/validators/array/no-undefined-items.js +45 -0
- package/dist/core/validators/array/non-empty-array.d.ts +24 -0
- package/dist/core/validators/array/non-empty-array.js +45 -0
- package/dist/core/validators/array/not-sparse.d.ts +25 -0
- package/dist/core/validators/array/not-sparse.js +44 -0
- package/dist/core/validators/bigint/bigint-equals.d.ts +24 -0
- package/dist/core/validators/bigint/bigint-equals.js +57 -0
- package/dist/core/validators/bigint/bigint-max.d.ts +25 -0
- package/dist/core/validators/bigint/bigint-max.js +63 -0
- package/dist/core/validators/bigint/bigint-min.d.ts +25 -0
- package/dist/core/validators/bigint/bigint-min.js +87 -0
- package/dist/core/validators/bigint/bigint-negative.d.ts +23 -0
- package/dist/core/validators/bigint/bigint-negative.js +73 -0
- package/dist/core/validators/bigint/bigint-non-negative.d.ts +24 -0
- package/dist/core/validators/bigint/bigint-non-negative.js +72 -0
- package/dist/core/validators/bigint/bigint-non-positive.d.ts +24 -0
- package/dist/core/validators/bigint/bigint-non-positive.js +72 -0
- package/dist/core/validators/bigint/bigint-positive.d.ts +24 -0
- package/dist/core/validators/bigint/bigint-positive.js +72 -0
- package/dist/core/validators/bigint/bigint-safe.d.ts +25 -0
- package/dist/core/validators/bigint/bigint-safe.js +75 -0
- package/dist/core/validators/bigint/bigint.d.ts +20 -0
- package/dist/core/validators/bigint/bigint.js +38 -0
- package/dist/core/validators/boolean/boolean.d.ts +21 -0
- package/dist/core/validators/boolean/boolean.js +39 -0
- package/dist/core/validators/boolean/is-false.d.ts +22 -0
- package/dist/core/validators/boolean/is-false.js +48 -0
- package/dist/core/validators/boolean/is-true.d.ts +22 -0
- package/dist/core/validators/boolean/is-true.js +48 -0
- package/dist/core/validators/common/is-country-code.d.ts +17 -0
- package/dist/core/validators/common/is-country-code.js +36 -0
- package/dist/core/validators/common/is-currency-code.d.ts +17 -0
- package/dist/core/validators/common/is-currency-code.js +36 -0
- package/dist/core/validators/common/is-email-strict.d.ts +17 -0
- package/dist/core/validators/common/is-email-strict.js +36 -0
- package/dist/core/validators/common/is-email.d.ts +17 -0
- package/dist/core/validators/common/is-email.js +36 -0
- package/dist/core/validators/common/is-ip.d.ts +17 -0
- package/dist/core/validators/common/is-ip.js +37 -0
- package/dist/core/validators/common/is-phone-strict.d.ts +17 -0
- package/dist/core/validators/common/is-phone-strict.js +36 -0
- package/dist/core/validators/common/is-phone.d.ts +17 -0
- package/dist/core/validators/common/is-phone.js +36 -0
- package/dist/core/validators/common/is-port.d.ts +17 -0
- package/dist/core/validators/common/is-port.js +35 -0
- package/dist/core/validators/common/is-postal-code.d.ts +17 -0
- package/dist/core/validators/common/is-postal-code.js +36 -0
- package/dist/core/validators/common/is-url.d.ts +17 -0
- package/dist/core/validators/common/is-url.js +38 -0
- package/dist/core/validators/common/is-uuid.d.ts +17 -0
- package/dist/core/validators/common/is-uuid.js +36 -0
- package/dist/core/validators/date/before-epoch.d.ts +28 -0
- package/dist/core/validators/date/before-epoch.js +56 -0
- package/dist/core/validators/date/date-now-required.d.ts +22 -0
- package/dist/core/validators/date/date-now-required.js +48 -0
- package/dist/core/validators/date/is-date.d.ts +21 -0
- package/dist/core/validators/date/is-date.js +47 -0
- package/dist/core/validators/date/is-far-future.d.ts +23 -0
- package/dist/core/validators/date/is-far-future.js +46 -0
- package/dist/core/validators/date/is-future.d.ts +24 -0
- package/dist/core/validators/date/is-future.js +59 -0
- package/dist/core/validators/date/is-past.d.ts +24 -0
- package/dist/core/validators/date/is-past.js +59 -0
- package/dist/core/validators/date/not-after.d.ts +25 -0
- package/dist/core/validators/date/not-after.js +66 -0
- package/dist/core/validators/date/not-before.d.ts +25 -0
- package/dist/core/validators/date/not-before.js +66 -0
- package/dist/core/validators/date/same-day.d.ts +25 -0
- package/dist/core/validators/date/same-day.js +60 -0
- package/dist/core/validators/date/same-month.d.ts +25 -0
- package/dist/core/validators/date/same-month.js +59 -0
- package/dist/core/validators/date/same-year.d.ts +24 -0
- package/dist/core/validators/date/same-year.js +56 -0
- package/dist/core/validators/date/too-early.d.ts +25 -0
- package/dist/core/validators/date/too-early.js +57 -0
- package/dist/core/validators/date/too-late.d.ts +25 -0
- package/dist/core/validators/date/too-late.js +57 -0
- package/dist/core/validators/date/weekday.d.ts +32 -0
- package/dist/core/validators/date/weekday.js +65 -0
- package/dist/core/validators/date/weekend.d.ts +27 -0
- package/dist/core/validators/date/weekend.js +56 -0
- package/dist/core/validators/index.d.ts +112 -0
- package/dist/core/validators/index.js +139 -0
- package/dist/core/validators/nullish/is-null-or-undefined.d.ts +22 -0
- package/dist/core/validators/nullish/is-null-or-undefined.js +40 -0
- package/dist/core/validators/nullish/is-null.d.ts +21 -0
- package/dist/core/validators/nullish/is-null.js +39 -0
- package/dist/core/validators/nullish/is-undefined.d.ts +21 -0
- package/dist/core/validators/nullish/is-undefined.js +39 -0
- package/dist/core/validators/number/finite.d.ts +22 -0
- package/dist/core/validators/number/finite.js +40 -0
- package/dist/core/validators/number/integer.d.ts +22 -0
- package/dist/core/validators/number/integer.js +40 -0
- package/dist/core/validators/number/less-than.d.ts +21 -0
- package/dist/core/validators/number/less-than.js +39 -0
- package/dist/core/validators/number/max.d.ts +21 -0
- package/dist/core/validators/number/max.js +39 -0
- package/dist/core/validators/number/min.d.ts +21 -0
- package/dist/core/validators/number/min.js +39 -0
- package/dist/core/validators/number/more-than.d.ts +21 -0
- package/dist/core/validators/number/more-than.js +39 -0
- package/dist/core/validators/number/negative.d.ts +20 -0
- package/dist/core/validators/number/negative.js +38 -0
- package/dist/core/validators/number/non-negative.d.ts +19 -0
- package/dist/core/validators/number/non-negative.js +37 -0
- package/dist/core/validators/number/non-positive.d.ts +19 -0
- package/dist/core/validators/number/non-positive.js +37 -0
- package/dist/core/validators/number/number.d.ts +19 -0
- package/dist/core/validators/number/number.js +31 -0
- package/dist/core/validators/number/positive.d.ts +20 -0
- package/dist/core/validators/number/positive.js +38 -0
- package/dist/core/validators/number/safe-integer.d.ts +19 -0
- package/dist/core/validators/number/safe-integer.js +42 -0
- package/dist/core/validators/object/deep-equals.d.ts +24 -0
- package/dist/core/validators/object/deep-equals.js +47 -0
- package/dist/core/validators/object/has-key.d.ts +23 -0
- package/dist/core/validators/object/has-key.js +42 -0
- package/dist/core/validators/object/has-value.d.ts +27 -0
- package/dist/core/validators/object/has-value.js +59 -0
- package/dist/core/validators/object/keys-equal.d.ts +26 -0
- package/dist/core/validators/object/keys-equal.js +47 -0
- package/dist/core/validators/object/max-keys.d.ts +24 -0
- package/dist/core/validators/object/max-keys.js +43 -0
- package/dist/core/validators/object/min-keys.d.ts +24 -0
- package/dist/core/validators/object/min-keys.js +43 -0
- package/dist/core/validators/object/missing-key.d.ts +23 -0
- package/dist/core/validators/object/missing-key.js +42 -0
- package/dist/core/validators/object/no-empty-array-values.d.ts +23 -0
- package/dist/core/validators/object/no-empty-array-values.js +44 -0
- package/dist/core/validators/object/no-empty-object-values.d.ts +23 -0
- package/dist/core/validators/object/no-empty-object-values.js +44 -0
- package/dist/core/validators/object/no-null-values.d.ts +23 -0
- package/dist/core/validators/object/no-null-values.js +44 -0
- package/dist/core/validators/object/no-undefined-values.d.ts +23 -0
- package/dist/core/validators/object/no-undefined-values.js +44 -0
- package/dist/core/validators/object/non-empty-object.d.ts +21 -0
- package/dist/core/validators/object/non-empty-object.js +40 -0
- package/dist/core/validators/object/only-keys.d.ts +23 -0
- package/dist/core/validators/object/only-keys.js +43 -0
- package/dist/core/validators/object/plain-object.d.ts +22 -0
- package/dist/core/validators/object/plain-object.js +35 -0
- package/dist/core/validators/string/alpha-num.d.ts +23 -0
- package/dist/core/validators/string/alpha-num.js +50 -0
- package/dist/core/validators/string/alpha.d.ts +24 -0
- package/dist/core/validators/string/alpha.js +51 -0
- package/dist/core/validators/string/chars-equal.d.ts +23 -0
- package/dist/core/validators/string/chars-equal.js +49 -0
- package/dist/core/validators/string/ends-with.d.ts +23 -0
- package/dist/core/validators/string/ends-with.js +50 -0
- package/dist/core/validators/string/is-ascii.d.ts +24 -0
- package/dist/core/validators/string/is-ascii.js +53 -0
- package/dist/core/validators/string/is-printable.d.ts +25 -0
- package/dist/core/validators/string/is-printable.js +53 -0
- package/dist/core/validators/string/matches.d.ts +23 -0
- package/dist/core/validators/string/matches.js +50 -0
- package/dist/core/validators/string/max-length.d.ts +24 -0
- package/dist/core/validators/string/max-length.js +50 -0
- package/dist/core/validators/string/min-length.d.ts +24 -0
- package/dist/core/validators/string/min-length.js +50 -0
- package/dist/core/validators/string/no-lead-space.d.ts +23 -0
- package/dist/core/validators/string/no-lead-space.js +50 -0
- package/dist/core/validators/string/no-repeat-space.d.ts +25 -0
- package/dist/core/validators/string/no-repeat-space.js +52 -0
- package/dist/core/validators/string/no-space.d.ts +24 -0
- package/dist/core/validators/string/no-space.js +51 -0
- package/dist/core/validators/string/no-trail-space.d.ts +23 -0
- package/dist/core/validators/string/no-trail-space.js +50 -0
- package/dist/core/validators/string/non-empty.d.ts +22 -0
- package/dist/core/validators/string/non-empty.js +48 -0
- package/dist/core/validators/string/not-one-of.d.ts +24 -0
- package/dist/core/validators/string/not-one-of.js +51 -0
- package/dist/core/validators/string/num-string.d.ts +23 -0
- package/dist/core/validators/string/num-string.js +50 -0
- package/dist/core/validators/string/one-of.d.ts +23 -0
- package/dist/core/validators/string/one-of.js +50 -0
- package/dist/core/validators/string/starts-with.d.ts +23 -0
- package/dist/core/validators/string/starts-with.js +50 -0
- package/dist/core/validators/string/string.d.ts +21 -0
- package/dist/core/validators/string/string.js +39 -0
- package/dist/core/validators/string/trimmed.d.ts +24 -0
- package/dist/core/validators/string/trimmed.js +51 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.js +26 -0
- package/dist/test.d.ts +1 -0
- package/dist/test.js +12 -0
- package/package.json +2 -2
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ----------------------------------------------------------------------------
|
|
3
|
+
* Common | Utilities
|
|
4
|
+
* ----------------------------------------------------------------------------
|
|
5
|
+
* @package @clementine-solutions/jane
|
|
6
|
+
* @description Shared low‑level helpers used across Jane’s core subsystems.
|
|
7
|
+
* @see https://jane-io.com
|
|
8
|
+
* ----------------------------------------------------------------------------
|
|
9
|
+
*/
|
|
10
|
+
/* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
|
|
11
|
+
|* Deep Equal *|
|
|
12
|
+
\* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
|
|
13
|
+
/**
|
|
14
|
+
* Performs structural deep equality on contained values.
|
|
15
|
+
*
|
|
16
|
+
* Primitives are compared by value, arrays and plain objects by shape and
|
|
17
|
+
* recursively by content, and Date objects by timestamp. Non‑plain objects
|
|
18
|
+
* are rejected. Cycle detection ensures safe comparison of recursive
|
|
19
|
+
* structures. This function defines the structural equality model used
|
|
20
|
+
* throughout Jane’s containment and diff logic.
|
|
21
|
+
*/
|
|
22
|
+
export function deepEqual(a, b, seen = new WeakMap()) {
|
|
23
|
+
if (a === b)
|
|
24
|
+
return true;
|
|
25
|
+
if (typeof a === 'number' && typeof b === 'number') {
|
|
26
|
+
return Number.isNaN(a) && Number.isNaN(b);
|
|
27
|
+
}
|
|
28
|
+
if (typeof a !== typeof b)
|
|
29
|
+
return false;
|
|
30
|
+
if (a === null || b === null)
|
|
31
|
+
return a === b;
|
|
32
|
+
if (typeof a !== 'object' || typeof b !== 'object')
|
|
33
|
+
return false;
|
|
34
|
+
if (seen.has(a))
|
|
35
|
+
return seen.get(a) === b;
|
|
36
|
+
seen.set(a, b);
|
|
37
|
+
if (a instanceof Date && b instanceof Date) {
|
|
38
|
+
return a.getTime() === b.getTime();
|
|
39
|
+
}
|
|
40
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
41
|
+
if (a.length !== b.length)
|
|
42
|
+
return false;
|
|
43
|
+
for (let i = 0; i < a.length; i++) {
|
|
44
|
+
if (!deepEqual(a[i], b[i], seen))
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
if (!isPlainObject(a) || !isPlainObject(b))
|
|
50
|
+
return false;
|
|
51
|
+
const aKeys = Object.keys(a);
|
|
52
|
+
const bKeys = Object.keys(b);
|
|
53
|
+
if (aKeys.length !== bKeys.length)
|
|
54
|
+
return false;
|
|
55
|
+
for (const key of aKeys) {
|
|
56
|
+
if (!Object.prototype.hasOwnProperty.call(b, key))
|
|
57
|
+
return false;
|
|
58
|
+
if (!deepEqual(a[key], b[key], seen)) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
/* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
|
|
65
|
+
|* Generate Run Id *|
|
|
66
|
+
\* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
|
|
67
|
+
/**
|
|
68
|
+
* Generates a unique run identifier.
|
|
69
|
+
*
|
|
70
|
+
* Uses `crypto.randomUUID` when available for strong, collision‑resistant IDs.
|
|
71
|
+
* Falls back to a timestamp + entropy string in environments without UUID
|
|
72
|
+
* support. Always returns a stable string suitable for pipeline metadata.
|
|
73
|
+
*/
|
|
74
|
+
export function generateRunId() {
|
|
75
|
+
if (typeof crypto?.randomUUID === 'function') {
|
|
76
|
+
return crypto.randomUUID();
|
|
77
|
+
}
|
|
78
|
+
// Fallback: time + entropy
|
|
79
|
+
return `run-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
|
|
80
|
+
}
|
|
81
|
+
/* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
|
|
82
|
+
|* Is Object *|
|
|
83
|
+
\* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
|
|
84
|
+
/**
|
|
85
|
+
* Checks for non‑null object values.
|
|
86
|
+
*
|
|
87
|
+
* Used as a minimal guard before structural checks. Functions, arrays, and
|
|
88
|
+
* plain objects all satisfy this test; it only excludes `null` and primitives.
|
|
89
|
+
*/
|
|
90
|
+
export function isObject(v) {
|
|
91
|
+
return v !== null && typeof v === 'object';
|
|
92
|
+
}
|
|
93
|
+
/* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
|
|
94
|
+
|* Is Plain Object *|
|
|
95
|
+
\* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
|
|
96
|
+
/**
|
|
97
|
+
* Checks whether a value is a strict plain object.
|
|
98
|
+
*
|
|
99
|
+
* Excludes arrays, null, and objects with custom or null prototypes. Only
|
|
100
|
+
* `{}`‑shaped values created by `Object` with `Object.prototype` qualify.
|
|
101
|
+
* Used wherever structural rules require predictable, JSON‑compatible objects.
|
|
102
|
+
*/
|
|
103
|
+
export function isPlainObject(value) {
|
|
104
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
const proto = Object.getPrototypeOf(value);
|
|
108
|
+
return proto === Object.prototype && value.constructor === Object;
|
|
109
|
+
}
|
|
110
|
+
/* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
|
|
111
|
+
|* Is Primitive *|
|
|
112
|
+
\* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
|
|
113
|
+
/**
|
|
114
|
+
* Checks whether a value is a JavaScript primitive.
|
|
115
|
+
*
|
|
116
|
+
* Includes all scalar literals plus `null` and `undefined`. Anything that is
|
|
117
|
+
* not an object and not a function qualifies. Used as a fast‑path guard before
|
|
118
|
+
* structural or container‑level checks.
|
|
119
|
+
*/
|
|
120
|
+
export function isPrimitive(value) {
|
|
121
|
+
return value === null || (typeof value !== 'object' && typeof value !== 'function');
|
|
122
|
+
}
|
|
123
|
+
/* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
|
|
124
|
+
|* Safe Stringify *|
|
|
125
|
+
\* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
|
|
126
|
+
/**
|
|
127
|
+
* Safely stringifies arbitrary values for use in messages and telemetry.
|
|
128
|
+
*
|
|
129
|
+
* Primitives are returned directly, strings are truncated with JSON quoting,
|
|
130
|
+
* functions and symbols are rendered as descriptive sentinels, and objects are
|
|
131
|
+
* JSON‑encoded with circular‑reference protection. Output is always bounded by
|
|
132
|
+
* `maxLength` to prevent runaway logs or unreadable diagnostics.
|
|
133
|
+
*/
|
|
134
|
+
export function safeStringify(value, maxLength = 80) {
|
|
135
|
+
try {
|
|
136
|
+
if (value === null)
|
|
137
|
+
return 'null';
|
|
138
|
+
if (value === undefined)
|
|
139
|
+
return 'undefined';
|
|
140
|
+
const t = typeof value;
|
|
141
|
+
if (t === 'string') {
|
|
142
|
+
const s = value;
|
|
143
|
+
return s.length > maxLength
|
|
144
|
+
? JSON.stringify(s.slice(0, maxLength)) + '…"'
|
|
145
|
+
: JSON.stringify(s);
|
|
146
|
+
}
|
|
147
|
+
if (t === 'number' || t === 'boolean' || t === 'bigint') {
|
|
148
|
+
return String(value);
|
|
149
|
+
}
|
|
150
|
+
if (t === 'symbol') {
|
|
151
|
+
return value.toString();
|
|
152
|
+
}
|
|
153
|
+
if (t === 'function') {
|
|
154
|
+
const _fn = value;
|
|
155
|
+
const name = value.name || 'anonymous';
|
|
156
|
+
return `[Function ${name}]`;
|
|
157
|
+
}
|
|
158
|
+
if (t === 'object') {
|
|
159
|
+
const seen = new WeakSet();
|
|
160
|
+
const json = JSON.stringify(value, (key, val) => {
|
|
161
|
+
if (typeof val === 'object' && val !== null) {
|
|
162
|
+
if (seen.has(val))
|
|
163
|
+
return '[Circular]';
|
|
164
|
+
seen.add(val);
|
|
165
|
+
}
|
|
166
|
+
return val;
|
|
167
|
+
}, 2);
|
|
168
|
+
if (!json)
|
|
169
|
+
return String(value);
|
|
170
|
+
return json.length > maxLength ? json.slice(0, maxLength) + '…' : json;
|
|
171
|
+
}
|
|
172
|
+
return String(value);
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
return String(value);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ----------------------------------------------------------------------------
|
|
3
|
+
* Common | Wildcard
|
|
4
|
+
* ----------------------------------------------------------------------------
|
|
5
|
+
* @package @clementine-solutions/jane
|
|
6
|
+
* @description Wildcard pattern helpers used for event‑code matching in policy rules.
|
|
7
|
+
* @see https://jane-io.com
|
|
8
|
+
* ----------------------------------------------------------------------------
|
|
9
|
+
*/
|
|
10
|
+
import type { EventCode } from '../shapes';
|
|
11
|
+
/**
|
|
12
|
+
* Compiles a wildcard pattern into a safe, anchored regular expression.
|
|
13
|
+
*
|
|
14
|
+
* Escapes all regex metacharacters except `*`, which expands to `.*`. The
|
|
15
|
+
* result matches the entire string, ensuring predictable event‑code pattern
|
|
16
|
+
* checks in policy rules.
|
|
17
|
+
*/
|
|
18
|
+
export declare function compileWildcard(pattern: string): RegExp;
|
|
19
|
+
export declare function getCompiledWildcard(pattern: string): RegExp;
|
|
20
|
+
/**
|
|
21
|
+
* Checks whether an event code matches any literal or wildcard pattern.
|
|
22
|
+
*
|
|
23
|
+
* Exact string matches take priority. Wildcard patterns are resolved through
|
|
24
|
+
* cached compiled expressions and tested in order. Returns `true` on the first
|
|
25
|
+
* match, otherwise `false`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function matchesWildcard(code: EventCode, patterns: readonly string[]): boolean;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ----------------------------------------------------------------------------
|
|
3
|
+
* Common | Wildcard
|
|
4
|
+
* ----------------------------------------------------------------------------
|
|
5
|
+
* @package @clementine-solutions/jane
|
|
6
|
+
* @description Wildcard pattern helpers used for event‑code matching in policy rules.
|
|
7
|
+
* @see https://jane-io.com
|
|
8
|
+
* ----------------------------------------------------------------------------
|
|
9
|
+
*/
|
|
10
|
+
/* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
|
|
11
|
+
|* Compile Wildcard *|
|
|
12
|
+
\* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
|
|
13
|
+
/**
|
|
14
|
+
* Compiles a wildcard pattern into a safe, anchored regular expression.
|
|
15
|
+
*
|
|
16
|
+
* Escapes all regex metacharacters except `*`, which expands to `.*`. The
|
|
17
|
+
* result matches the entire string, ensuring predictable event‑code pattern
|
|
18
|
+
* checks in policy rules.
|
|
19
|
+
*/
|
|
20
|
+
export function compileWildcard(pattern) {
|
|
21
|
+
const escaped = pattern.replace(/[-/\\^$+?.()|[\]{}]/g, '\\$&');
|
|
22
|
+
return new RegExp('^' + escaped.replace(/\*/g, '.*') + '$');
|
|
23
|
+
}
|
|
24
|
+
/* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
|
|
25
|
+
|* Get Compiled Wildcard *|
|
|
26
|
+
\* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
|
|
27
|
+
/**
|
|
28
|
+
* Returns a cached compiled wildcard, compiling on first use.
|
|
29
|
+
*
|
|
30
|
+
* Ensures each pattern is compiled once for consistent, fast matching across
|
|
31
|
+
* policy lookups. Cache entries are stable for the lifetime of the process.
|
|
32
|
+
*/
|
|
33
|
+
const wildcardCache = new Map();
|
|
34
|
+
export function getCompiledWildcard(pattern) {
|
|
35
|
+
const cached = wildcardCache.get(pattern);
|
|
36
|
+
if (cached)
|
|
37
|
+
return cached;
|
|
38
|
+
const compiled = compileWildcard(pattern);
|
|
39
|
+
wildcardCache.set(pattern, compiled);
|
|
40
|
+
return compiled;
|
|
41
|
+
}
|
|
42
|
+
/* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
|
|
43
|
+
|* Matches Wildcard *|
|
|
44
|
+
\* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
|
|
45
|
+
/**
|
|
46
|
+
* Checks whether an event code matches any literal or wildcard pattern.
|
|
47
|
+
*
|
|
48
|
+
* Exact string matches take priority. Wildcard patterns are resolved through
|
|
49
|
+
* cached compiled expressions and tested in order. Returns `true` on the first
|
|
50
|
+
* match, otherwise `false`.
|
|
51
|
+
*/
|
|
52
|
+
export function matchesWildcard(code, patterns) {
|
|
53
|
+
for (const p of patterns) {
|
|
54
|
+
if (p === code)
|
|
55
|
+
return true;
|
|
56
|
+
if (p.includes('*')) {
|
|
57
|
+
const re = getCompiledWildcard(p);
|
|
58
|
+
if (re.test(code))
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ----------------------------------------------------------------------------
|
|
3
|
+
* Field Path | Construct
|
|
4
|
+
* ----------------------------------------------------------------------------
|
|
5
|
+
* @package @clementine-solutions/jane
|
|
6
|
+
* @description Constructors for creating canonical, immutable FieldPath
|
|
7
|
+
* objects.
|
|
8
|
+
* @see https://jane-io.com
|
|
9
|
+
* ----------------------------------------------------------------------------
|
|
10
|
+
*/
|
|
11
|
+
import type { FieldPath, FieldPathSegment, InternalJsonValue, SegmentIndex, SegmentKey } from '../shapes';
|
|
12
|
+
/**
|
|
13
|
+
* Appends a segment to an existing FieldPath.
|
|
14
|
+
*
|
|
15
|
+
* Produces a new canonical FieldPath by extending the current path’s segment
|
|
16
|
+
* list. Never mutates the original path.
|
|
17
|
+
*/
|
|
18
|
+
export declare function appendSegment(path: FieldPath, segment: FieldPathSegment): FieldPath;
|
|
19
|
+
/**
|
|
20
|
+
* Produces a deep clone of an InternalJsonValue.
|
|
21
|
+
*
|
|
22
|
+
* Recursively copies arrays and plain objects while returning primitives,
|
|
23
|
+
* null, and undefined unchanged. Never mutates the input and never preserves
|
|
24
|
+
* references, ensuring safe use in diff, replay, and boundary evaluation.
|
|
25
|
+
*/
|
|
26
|
+
export declare function cloneContainer(value: InternalJsonValue): InternalJsonValue;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a shallow clone of a FieldPath.
|
|
29
|
+
*
|
|
30
|
+
* Copies the segment list into a new canonical FieldPath, ensuring callers
|
|
31
|
+
* never share mutable path state.
|
|
32
|
+
*/
|
|
33
|
+
export declare function clonePath(path: FieldPath): FieldPath;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a canonical FieldPath from a list of segments.
|
|
36
|
+
*
|
|
37
|
+
* Wraps the segment array with a stable toString() implementation and optional
|
|
38
|
+
* inputName. Produces a new immutable path object without modifying callers’
|
|
39
|
+
* data.
|
|
40
|
+
*/
|
|
41
|
+
export declare function makeFieldPath(segments: FieldPathSegment[], inputName?: string): FieldPath;
|
|
42
|
+
/**
|
|
43
|
+
* Creates the root FieldPath.
|
|
44
|
+
*
|
|
45
|
+
* Produces an empty canonical path with an optional inputName. Used as the
|
|
46
|
+
* starting point for all path construction and never carries any segments.
|
|
47
|
+
*/
|
|
48
|
+
export declare const rootPath: (inputName?: string) => FieldPath;
|
|
49
|
+
/**
|
|
50
|
+
* Sets a value at the given FieldPath.
|
|
51
|
+
*
|
|
52
|
+
* If the path is empty, returns the value directly. Otherwise delegates to the
|
|
53
|
+
* recursive setter, producing a new InternalJsonValue without mutating the
|
|
54
|
+
* original root.
|
|
55
|
+
*/
|
|
56
|
+
export declare function setAtPath(root: InternalJsonValue, path: FieldPath, value: InternalJsonValue): InternalJsonValue;
|
|
57
|
+
/**
|
|
58
|
+
* Builds a FieldPath from the provided segments.
|
|
59
|
+
*
|
|
60
|
+
* Wraps the segment list in a canonical FieldPath object, ensuring callers
|
|
61
|
+
* always work with an immutable, well‑formed path representation.
|
|
62
|
+
*/
|
|
63
|
+
export declare const setFieldPath: (...segments: FieldPathSegment[]) => FieldPath;
|
|
64
|
+
/**
|
|
65
|
+
* Creates an index segment.
|
|
66
|
+
*
|
|
67
|
+
* Wraps the numeric index in a canonical SegmentIndex object for use in
|
|
68
|
+
* FieldPath construction.
|
|
69
|
+
*/
|
|
70
|
+
export declare const setIndex: (index: number) => SegmentIndex;
|
|
71
|
+
/**
|
|
72
|
+
* Creates a key segment.
|
|
73
|
+
*
|
|
74
|
+
* Wraps the string key in a canonical SegmentKey object for use in
|
|
75
|
+
* FieldPath construction.
|
|
76
|
+
*/
|
|
77
|
+
export declare const setKey: (key: string) => SegmentKey;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ----------------------------------------------------------------------------
|
|
3
|
+
* Field Path | Construct
|
|
4
|
+
* ----------------------------------------------------------------------------
|
|
5
|
+
* @package @clementine-solutions/jane
|
|
6
|
+
* @description Constructors for creating canonical, immutable FieldPath
|
|
7
|
+
* objects.
|
|
8
|
+
* @see https://jane-io.com
|
|
9
|
+
* ----------------------------------------------------------------------------
|
|
10
|
+
*/
|
|
11
|
+
/* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
|
|
12
|
+
|* Internal Modules *|
|
|
13
|
+
\* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
|
|
14
|
+
import { deepClone } from '../pipeline';
|
|
15
|
+
/* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
|
|
16
|
+
|* Append Segment *|
|
|
17
|
+
\* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
|
|
18
|
+
/**
|
|
19
|
+
* Appends a segment to an existing FieldPath.
|
|
20
|
+
*
|
|
21
|
+
* Produces a new canonical FieldPath by extending the current path’s segment
|
|
22
|
+
* list. Never mutates the original path.
|
|
23
|
+
*/
|
|
24
|
+
export function appendSegment(path, segment) {
|
|
25
|
+
return makeFieldPath([...path.segments, segment]);
|
|
26
|
+
}
|
|
27
|
+
/* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
|
|
28
|
+
|* Clone Container *|
|
|
29
|
+
\* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
|
|
30
|
+
/**
|
|
31
|
+
* Produces a deep clone of an InternalJsonValue.
|
|
32
|
+
*
|
|
33
|
+
* Recursively copies arrays and plain objects while returning primitives,
|
|
34
|
+
* null, and undefined unchanged. Never mutates the input and never preserves
|
|
35
|
+
* references, ensuring safe use in diff, replay, and boundary evaluation.
|
|
36
|
+
*/
|
|
37
|
+
export function cloneContainer(value) {
|
|
38
|
+
if (Array.isArray(value)) {
|
|
39
|
+
const array = value;
|
|
40
|
+
return array.map((v) => cloneContainer(v));
|
|
41
|
+
}
|
|
42
|
+
if (value !== null && typeof value === 'object') {
|
|
43
|
+
const obj = value;
|
|
44
|
+
const clone = {};
|
|
45
|
+
for (const key of Object.keys(obj)) {
|
|
46
|
+
clone[key] = cloneContainer(obj[key]);
|
|
47
|
+
}
|
|
48
|
+
return clone;
|
|
49
|
+
}
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
/* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
|
|
53
|
+
|* Clone Path *|
|
|
54
|
+
\* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
|
|
55
|
+
/**
|
|
56
|
+
* Creates a shallow clone of a FieldPath.
|
|
57
|
+
*
|
|
58
|
+
* Copies the segment list into a new canonical FieldPath, ensuring callers
|
|
59
|
+
* never share mutable path state.
|
|
60
|
+
*/
|
|
61
|
+
export function clonePath(path) {
|
|
62
|
+
return makeFieldPath([...path.segments]);
|
|
63
|
+
}
|
|
64
|
+
/* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
|
|
65
|
+
|* Make Field Path *|
|
|
66
|
+
\* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
|
|
67
|
+
/**
|
|
68
|
+
* Creates a canonical FieldPath from a list of segments.
|
|
69
|
+
*
|
|
70
|
+
* Wraps the segment array with a stable toString() implementation and optional
|
|
71
|
+
* inputName. Produces a new immutable path object without modifying callers’
|
|
72
|
+
* data.
|
|
73
|
+
*/
|
|
74
|
+
export function makeFieldPath(segments, inputName) {
|
|
75
|
+
return {
|
|
76
|
+
segments,
|
|
77
|
+
inputName,
|
|
78
|
+
toString() {
|
|
79
|
+
if (segments.length === 0)
|
|
80
|
+
return inputName ? inputName : '/';
|
|
81
|
+
return ('/' + segments.map((s) => (s.kind === 'key' ? s.key : String(s.index))).join('/'));
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
|
|
86
|
+
|* Root Path *|
|
|
87
|
+
\* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
|
|
88
|
+
/**
|
|
89
|
+
* Creates the root FieldPath.
|
|
90
|
+
*
|
|
91
|
+
* Produces an empty canonical path with an optional inputName. Used as the
|
|
92
|
+
* starting point for all path construction and never carries any segments.
|
|
93
|
+
*/
|
|
94
|
+
export const rootPath = (inputName) => makeFieldPath([], inputName);
|
|
95
|
+
/* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
|
|
96
|
+
|* Set At Path *|
|
|
97
|
+
\* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
|
|
98
|
+
/**
|
|
99
|
+
* Sets a value at the given FieldPath.
|
|
100
|
+
*
|
|
101
|
+
* If the path is empty, returns the value directly. Otherwise delegates to the
|
|
102
|
+
* recursive setter, producing a new InternalJsonValue without mutating the
|
|
103
|
+
* original root.
|
|
104
|
+
*/
|
|
105
|
+
export function setAtPath(root, path, value) {
|
|
106
|
+
const { segments } = path;
|
|
107
|
+
if (segments.length === 0) {
|
|
108
|
+
return value;
|
|
109
|
+
}
|
|
110
|
+
return setAtPathRecursive(root, segments, 0, value);
|
|
111
|
+
}
|
|
112
|
+
/* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
|
|
113
|
+
|* Set At Path Recursive *|
|
|
114
|
+
\* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
|
|
115
|
+
/**
|
|
116
|
+
* Recursively sets a value at a nested FieldPath segment.
|
|
117
|
+
*
|
|
118
|
+
* Clones arrays and objects as it descends, ensuring each level is rebuilt
|
|
119
|
+
* without mutating the original structure. When the final segment is reached,
|
|
120
|
+
* assigns the value and returns the newly constructed container.
|
|
121
|
+
*/
|
|
122
|
+
function setAtPathRecursive(current, segments, index, value) {
|
|
123
|
+
const seg = segments[index];
|
|
124
|
+
const isLast = index === segments.length - 1;
|
|
125
|
+
if (seg.kind === 'index') {
|
|
126
|
+
const idx = seg.index;
|
|
127
|
+
const baseArray = Array.isArray(current)
|
|
128
|
+
? current
|
|
129
|
+
: [];
|
|
130
|
+
const nextArray = baseArray.slice();
|
|
131
|
+
if (isLast) {
|
|
132
|
+
nextArray[idx] = value;
|
|
133
|
+
return nextArray;
|
|
134
|
+
}
|
|
135
|
+
const child = baseArray[idx] === undefined ? undefined : deepClone(baseArray[idx]);
|
|
136
|
+
const updatedChild = setAtPathRecursive(child, segments, index + 1, value);
|
|
137
|
+
nextArray[idx] = updatedChild;
|
|
138
|
+
return nextArray;
|
|
139
|
+
}
|
|
140
|
+
const key = seg.key;
|
|
141
|
+
const baseObject = current !== null && typeof current === 'object' && !Array.isArray(current)
|
|
142
|
+
? current
|
|
143
|
+
: {};
|
|
144
|
+
const nextObject = { ...baseObject };
|
|
145
|
+
if (isLast) {
|
|
146
|
+
nextObject[key] = value;
|
|
147
|
+
return nextObject;
|
|
148
|
+
}
|
|
149
|
+
const child = baseObject[key] === undefined ? undefined : deepClone(baseObject[key]);
|
|
150
|
+
const updatedChild = setAtPathRecursive(child, segments, index + 1, value);
|
|
151
|
+
nextObject[key] = updatedChild;
|
|
152
|
+
return nextObject;
|
|
153
|
+
}
|
|
154
|
+
/* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
|
|
155
|
+
|* Set Field Path *|
|
|
156
|
+
\* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
|
|
157
|
+
/**
|
|
158
|
+
* Builds a FieldPath from the provided segments.
|
|
159
|
+
*
|
|
160
|
+
* Wraps the segment list in a canonical FieldPath object, ensuring callers
|
|
161
|
+
* always work with an immutable, well‑formed path representation.
|
|
162
|
+
*/
|
|
163
|
+
export const setFieldPath = (...segments) => makeFieldPath([...segments]);
|
|
164
|
+
/* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
|
|
165
|
+
|* Set Index *|
|
|
166
|
+
\* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
|
|
167
|
+
/**
|
|
168
|
+
* Creates an index segment.
|
|
169
|
+
*
|
|
170
|
+
* Wraps the numeric index in a canonical SegmentIndex object for use in
|
|
171
|
+
* FieldPath construction.
|
|
172
|
+
*/
|
|
173
|
+
export const setIndex = (index) => ({
|
|
174
|
+
kind: 'index',
|
|
175
|
+
index,
|
|
176
|
+
});
|
|
177
|
+
/* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
|
|
178
|
+
|* Set Key *|
|
|
179
|
+
\* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
|
|
180
|
+
/**
|
|
181
|
+
* Creates a key segment.
|
|
182
|
+
*
|
|
183
|
+
* Wraps the string key in a canonical SegmentKey object for use in
|
|
184
|
+
* FieldPath construction.
|
|
185
|
+
*/
|
|
186
|
+
export const setKey = (key) => ({
|
|
187
|
+
kind: 'key',
|
|
188
|
+
key,
|
|
189
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ----------------------------------------------------------------------------
|
|
3
|
+
* Field Path | Format
|
|
4
|
+
* ----------------------------------------------------------------------------
|
|
5
|
+
* @package @clementine-solutions/jane
|
|
6
|
+
* @description Converts FieldPath structures into stable, user‑facing
|
|
7
|
+
* string forms.
|
|
8
|
+
* @see https://jane-io.com
|
|
9
|
+
* ----------------------------------------------------------------------------
|
|
10
|
+
*/
|
|
11
|
+
import type { FieldPath } from '../shapes';
|
|
12
|
+
/**
|
|
13
|
+
* Converts a list of raw parts into a FieldPath.
|
|
14
|
+
*
|
|
15
|
+
* Maps numbers to index segments and strings to key segments, producing a
|
|
16
|
+
* canonical FieldPath suitable for formatting, traversal, or boundary work.
|
|
17
|
+
*/
|
|
18
|
+
export declare function arrayToFieldPath(parts: (string | number)[]): FieldPath;
|
|
19
|
+
/**
|
|
20
|
+
* Converts a FieldPath into its raw parts.
|
|
21
|
+
*
|
|
22
|
+
* Extracts each segment’s key or index in order, producing a simple array
|
|
23
|
+
* representation suitable for serialization or comparison.
|
|
24
|
+
*/
|
|
25
|
+
export declare function fieldPathToArray(path: FieldPath): (string | number)[];
|
|
26
|
+
/**
|
|
27
|
+
* Converts a FieldPath into a user‑facing string.
|
|
28
|
+
*
|
|
29
|
+
* Uses dotted notation for safe keys and bracket notation for indexes or
|
|
30
|
+
* keys requiring escaping. Produces a stable, readable form for logs,
|
|
31
|
+
* errors, and policy messages.
|
|
32
|
+
*/
|
|
33
|
+
export declare function fieldPathToUser(path: FieldPath): string;
|
|
34
|
+
/**
|
|
35
|
+
* Parses a user‑facing path string into a FieldPath.
|
|
36
|
+
*
|
|
37
|
+
* Supports dotted keys, bracketed indexes, and quoted/escaped keys. Normalizes
|
|
38
|
+
* the "$" root form and walks the string character‑by‑character to build a
|
|
39
|
+
* canonical segment list suitable for traversal and boundary evaluation.
|
|
40
|
+
*/
|
|
41
|
+
export declare function userToFieldPath(user?: string): FieldPath;
|