@elaraai/east 0.0.1-beta.8 → 1.0.0
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/LICENSE.md +15 -666
- package/README.md +113 -88
- package/dist/src/analyze.d.ts +3 -0
- package/dist/src/analyze.d.ts.map +1 -1
- package/dist/src/analyze.js +223 -111
- package/dist/src/analyze.js.map +1 -1
- package/dist/src/analyze.spec.d.ts +2 -0
- package/dist/src/analyze.spec.d.ts.map +1 -0
- package/dist/src/analyze.spec.js +445 -0
- package/dist/src/analyze.spec.js.map +1 -0
- package/dist/src/ast.d.ts +54 -35
- package/dist/src/ast.d.ts.map +1 -1
- package/dist/src/ast_to_ir.coerce_to.spec.d.ts +15 -0
- package/dist/src/ast_to_ir.coerce_to.spec.d.ts.map +1 -0
- package/dist/src/ast_to_ir.coerce_to.spec.js +420 -0
- package/dist/src/ast_to_ir.coerce_to.spec.js.map +1 -0
- package/dist/src/ast_to_ir.d.ts +18 -4
- package/dist/src/ast_to_ir.d.ts.map +1 -1
- package/dist/src/ast_to_ir.js +233 -178
- package/dist/src/ast_to_ir.js.map +1 -1
- package/dist/src/builtins.d.ts +1 -1
- package/dist/src/builtins.d.ts.map +1 -1
- package/dist/src/builtins.js +194 -2
- package/dist/src/builtins.js.map +1 -1
- package/dist/src/comparison.d.ts +2 -2
- package/dist/src/comparison.d.ts.map +1 -1
- package/dist/src/comparison.js +115 -40
- package/dist/src/comparison.js.map +1 -1
- package/dist/src/comparison.spec.d.ts +2 -0
- package/dist/src/comparison.spec.d.ts.map +1 -0
- package/dist/src/comparison.spec.js +1200 -0
- package/dist/src/comparison.spec.js.map +1 -0
- package/dist/src/compile.d.ts +31 -9
- package/dist/src/compile.d.ts.map +1 -1
- package/dist/src/compile.js +1048 -548
- package/dist/src/compile.js.map +1 -1
- package/dist/src/containers/matrix.d.ts +15 -0
- package/dist/src/containers/matrix.d.ts.map +1 -0
- package/dist/src/containers/matrix.js +15 -0
- package/dist/src/containers/matrix.js.map +1 -0
- package/dist/src/containers/ref.d.ts.map +1 -1
- package/dist/src/containers/ref.js +1 -1
- package/dist/src/containers/ref.js.map +1 -1
- package/dist/src/containers/sortedmap.spec.d.ts +2 -0
- package/dist/src/containers/sortedmap.spec.d.ts.map +1 -0
- package/dist/src/containers/sortedmap.spec.js +180 -0
- package/dist/src/containers/sortedmap.spec.js.map +1 -0
- package/dist/src/containers/sortedset.spec.d.ts +2 -0
- package/dist/src/containers/sortedset.spec.d.ts.map +1 -0
- package/dist/src/containers/sortedset.spec.js +228 -0
- package/dist/src/containers/sortedset.spec.js.map +1 -0
- package/dist/src/containers/variant.d.ts.map +1 -1
- package/dist/src/containers/variant.js +1 -1
- package/dist/src/containers/variant.js.map +1 -1
- package/dist/src/containers/variant.spec.d.ts +2 -0
- package/dist/src/containers/variant.spec.d.ts.map +1 -0
- package/dist/src/containers/variant.spec.js +217 -0
- package/dist/src/containers/variant.spec.js.map +1 -0
- package/dist/src/datetime_format/parse.spec.d.ts +6 -0
- package/dist/src/datetime_format/parse.spec.d.ts.map +1 -0
- package/dist/src/datetime_format/parse.spec.js +379 -0
- package/dist/src/datetime_format/parse.spec.js.map +1 -0
- package/dist/src/datetime_format/print.spec.d.ts +6 -0
- package/dist/src/datetime_format/print.spec.d.ts.map +1 -0
- package/dist/src/datetime_format/print.spec.js +257 -0
- package/dist/src/datetime_format/print.spec.js.map +1 -0
- package/dist/src/datetime_format/tokenize.spec.d.ts +2 -0
- package/dist/src/datetime_format/tokenize.spec.d.ts.map +1 -0
- package/dist/src/datetime_format/tokenize.spec.js +508 -0
- package/dist/src/datetime_format/tokenize.spec.js.map +1 -0
- package/dist/src/datetime_format/types.d.ts +23 -23
- package/dist/src/default.d.ts.map +1 -1
- package/dist/src/default.js +33 -0
- package/dist/src/default.js.map +1 -1
- package/dist/src/default.spec.d.ts +2 -0
- package/dist/src/default.spec.d.ts.map +1 -0
- package/dist/src/default.spec.js +178 -0
- package/dist/src/default.spec.js.map +1 -0
- package/dist/src/eastir.d.ts +7 -0
- package/dist/src/eastir.d.ts.map +1 -1
- package/dist/src/eastir.js +55 -7
- package/dist/src/eastir.js.map +1 -1
- package/dist/src/error.d.ts +14 -4
- package/dist/src/error.d.ts.map +1 -1
- package/dist/src/error.js +28 -3
- package/dist/src/error.js.map +1 -1
- package/dist/src/example.d.ts +87 -0
- package/dist/src/example.d.ts.map +1 -0
- package/dist/src/example.js +18 -0
- package/dist/src/example.js.map +1 -0
- package/dist/src/expr/array.d.ts +43 -1
- package/dist/src/expr/array.d.ts.map +1 -1
- package/dist/src/expr/array.js +103 -53
- package/dist/src/expr/array.js.map +1 -1
- package/dist/src/expr/ast.d.ts +1 -1
- package/dist/src/expr/ast.d.ts.map +1 -1
- package/dist/src/expr/ast.js +112 -54
- package/dist/src/expr/ast.js.map +1 -1
- package/dist/src/expr/asyncfunction.d.ts.map +1 -1
- package/dist/src/expr/asyncfunction.js +6 -4
- package/dist/src/expr/asyncfunction.js.map +1 -1
- package/dist/src/expr/blob.d.ts +48 -0
- package/dist/src/expr/blob.d.ts.map +1 -1
- package/dist/src/expr/blob.js +63 -8
- package/dist/src/expr/blob.js.map +1 -1
- package/dist/src/expr/block.d.ts +213 -12
- package/dist/src/expr/block.d.ts.map +1 -1
- package/dist/src/expr/block.js +796 -293
- package/dist/src/expr/block.js.map +1 -1
- package/dist/src/expr/boolean.d.ts +44 -0
- package/dist/src/expr/boolean.d.ts.map +1 -1
- package/dist/src/expr/boolean.js +58 -6
- package/dist/src/expr/boolean.js.map +1 -1
- package/dist/src/expr/datetime.d.ts +135 -0
- package/dist/src/expr/datetime.d.ts.map +1 -1
- package/dist/src/expr/datetime.js +184 -34
- package/dist/src/expr/datetime.js.map +1 -1
- package/dist/src/expr/dict.d.ts +47 -2
- package/dist/src/expr/dict.d.ts.map +1 -1
- package/dist/src/expr/dict.js +122 -61
- package/dist/src/expr/dict.js.map +1 -1
- package/dist/src/expr/expr.d.ts +3 -1
- package/dist/src/expr/expr.d.ts.map +1 -1
- package/dist/src/expr/expr.js +4 -3
- package/dist/src/expr/expr.js.map +1 -1
- package/dist/src/expr/float.d.ts +153 -0
- package/dist/src/expr/float.d.ts.map +1 -1
- package/dist/src/expr/float.js +191 -17
- package/dist/src/expr/float.js.map +1 -1
- package/dist/src/expr/function.d.ts +7 -2
- package/dist/src/expr/function.d.ts.map +1 -1
- package/dist/src/expr/function.js +6 -4
- package/dist/src/expr/function.js.map +1 -1
- package/dist/src/expr/index.d.ts +186 -2
- package/dist/src/expr/index.d.ts.map +1 -1
- package/dist/src/expr/index.js +183 -2
- package/dist/src/expr/index.js.map +1 -1
- package/dist/src/expr/integer.d.ts +180 -0
- package/dist/src/expr/integer.d.ts.map +1 -1
- package/dist/src/expr/integer.js +189 -18
- package/dist/src/expr/integer.js.map +1 -1
- package/dist/src/expr/libs/array.js +3 -3
- package/dist/src/expr/libs/array.js.map +1 -1
- package/dist/src/expr/libs/blob.js +3 -3
- package/dist/src/expr/libs/blob.js.map +1 -1
- package/dist/src/expr/libs/dict.js +1 -1
- package/dist/src/expr/libs/dict.js.map +1 -1
- package/dist/src/expr/libs/matrix.d.ts +17 -0
- package/dist/src/expr/libs/matrix.d.ts.map +1 -0
- package/dist/src/expr/libs/matrix.js +60 -0
- package/dist/src/expr/libs/matrix.js.map +1 -0
- package/dist/src/expr/libs/set.js +1 -1
- package/dist/src/expr/libs/set.js.map +1 -1
- package/dist/src/expr/libs/string.d.ts.map +1 -1
- package/dist/src/expr/libs/string.js +2 -1
- package/dist/src/expr/libs/string.js.map +1 -1
- package/dist/src/expr/libs/vector.d.ts +16 -0
- package/dist/src/expr/libs/vector.d.ts.map +1 -0
- package/dist/src/expr/libs/vector.js +44 -0
- package/dist/src/expr/libs/vector.js.map +1 -0
- package/dist/src/expr/matrix.d.ts +109 -0
- package/dist/src/expr/matrix.d.ts.map +1 -0
- package/dist/src/expr/matrix.js +224 -0
- package/dist/src/expr/matrix.js.map +1 -0
- package/dist/src/expr/recursive.d.ts +83 -0
- package/dist/src/expr/recursive.d.ts.map +1 -0
- package/dist/src/expr/recursive.js +99 -0
- package/dist/src/expr/recursive.js.map +1 -0
- package/dist/src/expr/ref.js +5 -5
- package/dist/src/expr/ref.js.map +1 -1
- package/dist/src/expr/set.d.ts +44 -2
- package/dist/src/expr/set.d.ts.map +1 -1
- package/dist/src/expr/set.js +102 -52
- package/dist/src/expr/set.js.map +1 -1
- package/dist/src/expr/string.d.ts +134 -0
- package/dist/src/expr/string.d.ts.map +1 -1
- package/dist/src/expr/string.js +173 -23
- package/dist/src/expr/string.js.map +1 -1
- package/dist/src/expr/struct.d.ts +1 -1
- package/dist/src/expr/struct.d.ts.map +1 -1
- package/dist/src/expr/struct.js +2 -2
- package/dist/src/expr/struct.js.map +1 -1
- package/dist/src/expr/types.d.ts +12 -9
- package/dist/src/expr/types.d.ts.map +1 -1
- package/dist/src/expr/variant.d.ts +108 -11
- package/dist/src/expr/variant.d.ts.map +1 -1
- package/dist/src/expr/variant.js +76 -38
- package/dist/src/expr/variant.js.map +1 -1
- package/dist/src/expr/vector.d.ts +102 -0
- package/dist/src/expr/vector.d.ts.map +1 -0
- package/dist/src/expr/vector.js +202 -0
- package/dist/src/expr/vector.js.map +1 -0
- package/dist/src/fuzz.d.ts +36 -2
- package/dist/src/fuzz.d.ts.map +1 -1
- package/dist/src/fuzz.js +409 -77
- package/dist/src/fuzz.js.map +1 -1
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/internal.d.ts +12 -2
- package/dist/src/internal.d.ts.map +1 -1
- package/dist/src/internal.js +13 -2
- package/dist/src/internal.js.map +1 -1
- package/dist/src/ir.d.ts +1754 -1484
- package/dist/src/ir.d.ts.map +1 -1
- package/dist/src/ir.js +51 -34
- package/dist/src/ir.js.map +1 -1
- package/dist/src/ir.spec.d.ts +2 -0
- package/dist/src/ir.spec.d.ts.map +1 -0
- package/dist/src/ir.spec.js +35 -0
- package/dist/src/ir.spec.js.map +1 -0
- package/dist/src/location.d.ts +56 -17
- package/dist/src/location.d.ts.map +1 -1
- package/dist/src/location.js +226 -29
- package/dist/src/location.js.map +1 -1
- package/dist/src/location.spec.d.ts +2 -0
- package/dist/src/location.spec.d.ts.map +1 -0
- package/dist/src/location.spec.js +102 -0
- package/dist/src/location.spec.js.map +1 -0
- package/dist/src/patch/apply.d.ts +15 -0
- package/dist/src/patch/apply.d.ts.map +1 -0
- package/dist/src/patch/apply.js +352 -0
- package/dist/src/patch/apply.js.map +1 -0
- package/dist/src/patch/compose.d.ts +15 -0
- package/dist/src/patch/compose.d.ts.map +1 -0
- package/dist/src/patch/compose.js +448 -0
- package/dist/src/patch/compose.js.map +1 -0
- package/dist/src/patch/diff.d.ts +15 -0
- package/dist/src/patch/diff.d.ts.map +1 -0
- package/dist/src/patch/diff.js +347 -0
- package/dist/src/patch/diff.js.map +1 -0
- package/dist/src/patch/fuzz.d.ts +73 -0
- package/dist/src/patch/fuzz.d.ts.map +1 -0
- package/dist/src/patch/fuzz.js +159 -0
- package/dist/src/patch/fuzz.js.map +1 -0
- package/dist/src/patch/index.d.ts +32 -0
- package/dist/src/patch/index.d.ts.map +1 -0
- package/dist/src/patch/index.js +48 -0
- package/dist/src/patch/index.js.map +1 -0
- package/dist/src/patch/invert.d.ts +15 -0
- package/dist/src/patch/invert.d.ts.map +1 -0
- package/dist/src/patch/invert.js +284 -0
- package/dist/src/patch/invert.js.map +1 -0
- package/dist/src/patch/merge.d.ts +56 -0
- package/dist/src/patch/merge.d.ts.map +1 -0
- package/dist/src/patch/merge.js +586 -0
- package/dist/src/patch/merge.js.map +1 -0
- package/dist/src/patch/merge.spec.d.ts +2 -0
- package/dist/src/patch/merge.spec.d.ts.map +1 -0
- package/dist/src/patch/merge.spec.js +1139 -0
- package/dist/src/patch/merge.spec.js.map +1 -0
- package/dist/src/patch/patch.spec.d.ts +2 -0
- package/dist/src/patch/patch.spec.d.ts.map +1 -0
- package/dist/src/patch/patch.spec.js +452 -0
- package/dist/src/patch/patch.spec.js.map +1 -0
- package/dist/src/patch/path.d.ts +115 -0
- package/dist/src/patch/path.d.ts.map +1 -0
- package/dist/src/patch/path.js +192 -0
- package/dist/src/patch/path.js.map +1 -0
- package/dist/src/patch/path.spec.d.ts +6 -0
- package/dist/src/patch/path.spec.d.ts.map +1 -0
- package/dist/src/patch/path.spec.js +322 -0
- package/dist/src/patch/path.spec.js.map +1 -0
- package/dist/src/patch/prune.d.ts +77 -0
- package/dist/src/patch/prune.d.ts.map +1 -0
- package/dist/src/patch/prune.js +115 -0
- package/dist/src/patch/prune.js.map +1 -0
- package/dist/src/patch/prune.spec.d.ts +6 -0
- package/dist/src/patch/prune.spec.d.ts.map +1 -0
- package/dist/src/patch/prune.spec.js +473 -0
- package/dist/src/patch/prune.spec.js.map +1 -0
- package/dist/src/patch/type_of_patch.d.ts +25 -0
- package/dist/src/patch/type_of_patch.d.ts.map +1 -0
- package/dist/src/patch/type_of_patch.js +144 -0
- package/dist/src/patch/type_of_patch.js.map +1 -0
- package/dist/src/patch/types.d.ts +220 -0
- package/dist/src/patch/types.d.ts.map +1 -0
- package/dist/src/patch/types.js +62 -0
- package/dist/src/patch/types.js.map +1 -0
- package/dist/src/patch/validate.d.ts +44 -0
- package/dist/src/patch/validate.d.ts.map +1 -0
- package/dist/src/patch/validate.js +190 -0
- package/dist/src/patch/validate.js.map +1 -0
- package/dist/src/patch/validate.spec.d.ts +6 -0
- package/dist/src/patch/validate.spec.d.ts.map +1 -0
- package/dist/src/patch/validate.spec.js +225 -0
- package/dist/src/patch/validate.spec.js.map +1 -0
- package/dist/src/patch/walk.d.ts +121 -0
- package/dist/src/patch/walk.d.ts.map +1 -0
- package/dist/src/patch/walk.js +385 -0
- package/dist/src/patch/walk.js.map +1 -0
- package/dist/src/patch/walk.spec.d.ts +6 -0
- package/dist/src/patch/walk.spec.d.ts.map +1 -0
- package/dist/src/patch/walk.spec.js +621 -0
- package/dist/src/patch/walk.spec.js.map +1 -0
- package/dist/src/platform.d.ts +6 -0
- package/dist/src/platform.d.ts.map +1 -1
- package/dist/src/platform.spec.d.ts +2 -0
- package/dist/src/platform.spec.d.ts.map +1 -0
- package/dist/src/platform.spec.js +330 -0
- package/dist/src/platform.spec.js.map +1 -0
- package/dist/src/serialization/beast.d.ts.map +1 -1
- package/dist/src/serialization/beast.js +12 -0
- package/dist/src/serialization/beast.js.map +1 -1
- package/dist/src/serialization/beast.spec.d.ts +6 -0
- package/dist/src/serialization/beast.spec.d.ts.map +1 -0
- package/dist/src/serialization/beast.spec.js +406 -0
- package/dist/src/serialization/beast.spec.js.map +1 -0
- package/dist/src/serialization/beast2/index.d.ts +50 -0
- package/dist/src/serialization/beast2/index.d.ts.map +1 -0
- package/dist/src/serialization/beast2/index.js +756 -0
- package/dist/src/serialization/beast2/index.js.map +1 -0
- package/dist/src/serialization/beast2/index.spec.d.ts +6 -0
- package/dist/src/serialization/beast2/index.spec.d.ts.map +1 -0
- package/dist/src/serialization/beast2/index.spec.js +528 -0
- package/dist/src/serialization/beast2/index.spec.js.map +1 -0
- package/dist/src/serialization/beast2/sourcemap-table.d.ts +29 -0
- package/dist/src/serialization/beast2/sourcemap-table.d.ts.map +1 -0
- package/dist/src/serialization/beast2/sourcemap-table.js +82 -0
- package/dist/src/serialization/beast2/sourcemap-table.js.map +1 -0
- package/dist/src/serialization/beast2/string-table.d.ts +16 -0
- package/dist/src/serialization/beast2/string-table.d.ts.map +1 -0
- package/dist/src/serialization/beast2/string-table.js +38 -0
- package/dist/src/serialization/beast2/string-table.js.map +1 -0
- package/dist/src/serialization/beast2/type-table.d.ts +86 -0
- package/dist/src/serialization/beast2/type-table.d.ts.map +1 -0
- package/dist/src/serialization/beast2/type-table.js +618 -0
- package/dist/src/serialization/beast2/type-table.js.map +1 -0
- package/dist/src/serialization/beast2/value-table.d.ts +40 -0
- package/dist/src/serialization/beast2/value-table.d.ts.map +1 -0
- package/dist/src/serialization/beast2/value-table.js +157 -0
- package/dist/src/serialization/beast2/value-table.js.map +1 -0
- package/dist/src/serialization/binary-utils.d.ts +33 -0
- package/dist/src/serialization/binary-utils.d.ts.map +1 -1
- package/dist/src/serialization/binary-utils.js +157 -0
- package/dist/src/serialization/binary-utils.js.map +1 -1
- package/dist/src/serialization/csv.d.ts +17 -17
- package/dist/src/serialization/csv.d.ts.map +1 -1
- package/dist/src/serialization/csv.js +10 -8
- package/dist/src/serialization/csv.js.map +1 -1
- package/dist/src/serialization/csv.spec.d.ts +2 -0
- package/dist/src/serialization/csv.spec.d.ts.map +1 -0
- package/dist/src/serialization/csv.spec.js +556 -0
- package/dist/src/serialization/csv.spec.js.map +1 -0
- package/dist/src/serialization/east-inferred.spec.d.ts +2 -0
- package/dist/src/serialization/east-inferred.spec.d.ts.map +1 -0
- package/dist/src/serialization/east-inferred.spec.js +322 -0
- package/dist/src/serialization/east-inferred.spec.js.map +1 -0
- package/dist/src/serialization/east.d.ts +1 -1
- package/dist/src/serialization/east.d.ts.map +1 -1
- package/dist/src/serialization/east.js +178 -26
- package/dist/src/serialization/east.js.map +1 -1
- package/dist/src/serialization/east.spec.d.ts +2 -0
- package/dist/src/serialization/east.spec.d.ts.map +1 -0
- package/dist/src/serialization/east.spec.js +1548 -0
- package/dist/src/serialization/east.spec.js.map +1 -0
- package/dist/src/serialization/index.d.ts +1 -2
- package/dist/src/serialization/index.d.ts.map +1 -1
- package/dist/src/serialization/index.js +1 -2
- package/dist/src/serialization/index.js.map +1 -1
- package/dist/src/serialization/json.d.ts +1 -1
- package/dist/src/serialization/json.d.ts.map +1 -1
- package/dist/src/serialization/json.js +123 -24
- package/dist/src/serialization/json.js.map +1 -1
- package/dist/src/serialization/json.spec.d.ts +2 -0
- package/dist/src/serialization/json.spec.d.ts.map +1 -0
- package/dist/src/serialization/json.spec.js +1297 -0
- package/dist/src/serialization/json.spec.js.map +1 -0
- package/dist/src/type_of_type.d.ts +72 -35
- package/dist/src/type_of_type.d.ts.map +1 -1
- package/dist/src/type_of_type.is_data.spec.d.ts +6 -0
- package/dist/src/type_of_type.is_data.spec.d.ts.map +1 -0
- package/dist/src/type_of_type.is_data.spec.js +221 -0
- package/dist/src/type_of_type.is_data.spec.js.map +1 -0
- package/dist/src/type_of_type.js +355 -80
- package/dist/src/type_of_type.js.map +1 -1
- package/dist/src/type_of_type.to_etv.spec.d.ts +6 -0
- package/dist/src/type_of_type.to_etv.spec.d.ts.map +1 -0
- package/dist/src/type_of_type.to_etv.spec.js +263 -0
- package/dist/src/type_of_type.to_etv.spec.js.map +1 -0
- package/dist/src/types.d.ts +82 -12
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.error.spec.d.ts +2 -0
- package/dist/src/types.error.spec.d.ts.map +1 -0
- package/dist/src/types.error.spec.js +665 -0
- package/dist/src/types.error.spec.js.map +1 -0
- package/dist/src/types.js +663 -156
- package/dist/src/types.js.map +1 -1
- package/dist/src/types.spec.d.ts +2 -0
- package/dist/src/types.spec.d.ts.map +1 -0
- package/dist/src/types.spec.js +946 -0
- package/dist/src/types.spec.js.map +1 -0
- package/dist/src/walker.d.ts +65 -0
- package/dist/src/walker.d.ts.map +1 -0
- package/dist/src/walker.js +165 -0
- package/dist/src/walker.js.map +1 -0
- package/dist/src/walker.spec.d.ts +6 -0
- package/dist/src/walker.spec.d.ts.map +1 -0
- package/dist/src/walker.spec.js +109 -0
- package/dist/src/walker.spec.js.map +1 -0
- package/package.json +16 -38
- package/dist/src/serialization/beast2-stream.d.ts +0 -38
- package/dist/src/serialization/beast2-stream.d.ts.map +0 -1
- package/dist/src/serialization/beast2-stream.js +0 -670
- package/dist/src/serialization/beast2-stream.js.map +0 -1
- package/dist/src/serialization/beast2.d.ts +0 -41
- package/dist/src/serialization/beast2.d.ts.map +0 -1
- package/dist/src/serialization/beast2.js +0 -495
- package/dist/src/serialization/beast2.js.map +0 -1
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* PatchType constructor for computing patch types from East types.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { NullType, StructType, VariantType, ArrayType, DictType, IntegerType, } from "../types.js";
|
|
11
|
+
import { fromEastTypeValue } from "../type_of_type.js";
|
|
12
|
+
import { isVariant } from "../containers/variant.js";
|
|
13
|
+
export function PatchType(type, ctx) {
|
|
14
|
+
if (isVariant(type))
|
|
15
|
+
type = fromEastTypeValue(type);
|
|
16
|
+
// Initialize context for tracking recursive types
|
|
17
|
+
const context = ctx ?? new Map();
|
|
18
|
+
// Check if we've already computed the patch type for this type (handles recursion)
|
|
19
|
+
const cached = context.get(type);
|
|
20
|
+
if (cached !== undefined) {
|
|
21
|
+
return cached;
|
|
22
|
+
}
|
|
23
|
+
const t = type;
|
|
24
|
+
if (t.type === "Never" ||
|
|
25
|
+
t.type === "Null" ||
|
|
26
|
+
t.type === "Boolean" ||
|
|
27
|
+
t.type === "Integer" ||
|
|
28
|
+
t.type === "Float" ||
|
|
29
|
+
t.type === "String" ||
|
|
30
|
+
t.type === "DateTime" ||
|
|
31
|
+
t.type === "Blob" ||
|
|
32
|
+
t.type === "Vector" ||
|
|
33
|
+
t.type === "Matrix") {
|
|
34
|
+
return VariantType({
|
|
35
|
+
unchanged: NullType,
|
|
36
|
+
replace: StructType({ before: type, after: type }),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else if (t.type === "Array") {
|
|
40
|
+
const elementType = t.value;
|
|
41
|
+
const elementPatchType = PatchType(elementType, context);
|
|
42
|
+
const operationType = VariantType({
|
|
43
|
+
delete: elementType,
|
|
44
|
+
insert: elementType,
|
|
45
|
+
update: elementPatchType,
|
|
46
|
+
});
|
|
47
|
+
const entryType = StructType({
|
|
48
|
+
key: IntegerType,
|
|
49
|
+
offset: IntegerType,
|
|
50
|
+
operation: operationType,
|
|
51
|
+
});
|
|
52
|
+
return VariantType({
|
|
53
|
+
unchanged: NullType,
|
|
54
|
+
replace: StructType({ before: type, after: type }),
|
|
55
|
+
patch: ArrayType(entryType),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
else if (t.type === "Set") {
|
|
59
|
+
const keyType = t.key;
|
|
60
|
+
const operationType = VariantType({
|
|
61
|
+
delete: NullType,
|
|
62
|
+
insert: NullType,
|
|
63
|
+
});
|
|
64
|
+
return VariantType({
|
|
65
|
+
unchanged: NullType,
|
|
66
|
+
replace: StructType({ before: type, after: type }),
|
|
67
|
+
patch: DictType(keyType, operationType),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
else if (t.type === "Dict") {
|
|
71
|
+
const keyType = t.key;
|
|
72
|
+
const valueType = t.value;
|
|
73
|
+
const valuePatchType = PatchType(valueType, context);
|
|
74
|
+
const operationType = VariantType({
|
|
75
|
+
delete: valueType,
|
|
76
|
+
insert: valueType,
|
|
77
|
+
update: valuePatchType,
|
|
78
|
+
});
|
|
79
|
+
return VariantType({
|
|
80
|
+
unchanged: NullType,
|
|
81
|
+
replace: StructType({ before: type, after: type }),
|
|
82
|
+
patch: DictType(keyType, operationType),
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
else if (t.type === "Struct") {
|
|
86
|
+
const fieldTypes = t.fields;
|
|
87
|
+
const patchFields = {};
|
|
88
|
+
for (const [name, fieldType] of Object.entries(fieldTypes)) {
|
|
89
|
+
patchFields[name] = PatchType(fieldType, context);
|
|
90
|
+
}
|
|
91
|
+
return VariantType({
|
|
92
|
+
unchanged: NullType,
|
|
93
|
+
replace: StructType({ before: type, after: type }),
|
|
94
|
+
patch: StructType(patchFields),
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
else if (t.type === "Variant") {
|
|
98
|
+
const caseTypes = t.cases;
|
|
99
|
+
const patchCases = {};
|
|
100
|
+
for (const [name, caseType] of Object.entries(caseTypes)) {
|
|
101
|
+
patchCases[name] = PatchType(caseType, context);
|
|
102
|
+
}
|
|
103
|
+
return VariantType({
|
|
104
|
+
unchanged: NullType,
|
|
105
|
+
replace: StructType({ before: type, after: type }),
|
|
106
|
+
patch: VariantType(patchCases),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
else if (t.type === "Ref") {
|
|
110
|
+
const innerType = t.value;
|
|
111
|
+
const innerPatchType = PatchType(innerType, context);
|
|
112
|
+
return VariantType({
|
|
113
|
+
unchanged: NullType,
|
|
114
|
+
replace: StructType({ before: type, after: type }),
|
|
115
|
+
patch: innerPatchType,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
else if (t.type === "Recursive") {
|
|
119
|
+
// Check if we've already seen this type (handles circular back-references)
|
|
120
|
+
const cached = context.get(type);
|
|
121
|
+
if (cached !== undefined) {
|
|
122
|
+
return cached;
|
|
123
|
+
}
|
|
124
|
+
// For back-references within the recursive structure, use replace-only semantics
|
|
125
|
+
// Register this BEFORE recursing so circular refs are caught
|
|
126
|
+
const replaceOnlyType = VariantType({
|
|
127
|
+
unchanged: NullType,
|
|
128
|
+
replace: StructType({ before: type, after: type }),
|
|
129
|
+
});
|
|
130
|
+
context.set(type, replaceOnlyType);
|
|
131
|
+
// Recurse into the node - the outer structure gets structural patching
|
|
132
|
+
return PatchType(t.node, context);
|
|
133
|
+
}
|
|
134
|
+
else if (t.type === "Function" || t.type === "AsyncFunction") {
|
|
135
|
+
return VariantType({
|
|
136
|
+
unchanged: NullType,
|
|
137
|
+
replace: StructType({ before: type, after: type }),
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
throw new Error(`Unhandled type in PatchType: ${t.type}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=type_of_patch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type_of_patch.js","sourceRoot":"","sources":["../../../src/patch/type_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AI,CAAC,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;QAC/D,OAAO,WAAW,CAAC;YACjB,SAAS,EAAE,QAAQ;YACnB,OAAO,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;SACnD,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,gCAAiC,CAAc,CAAC,IAAI,EAAE,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Shared types and context interfaces for the patch system.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import type { EastTypeValue } from "../type_of_type.js";
|
|
11
|
+
import type { EastType, NullType, NeverType, BooleanType, IntegerType, FloatType, StringType, DateTimeType, BlobType, RefType, ArrayType, SetType, DictType, StructType, VariantType, RecursiveType } from "../types.js";
|
|
12
|
+
import type { variant as VariantValue } from "../containers/variant.js";
|
|
13
|
+
/**
|
|
14
|
+
* Context for building diff handlers with proper recursive type support.
|
|
15
|
+
* Handlers are built in parallel so that when we encounter a `.Recursive n`
|
|
16
|
+
* back-reference, we can look up the appropriate handler from any array.
|
|
17
|
+
*/
|
|
18
|
+
export interface DiffContext {
|
|
19
|
+
/** Diff handlers: (before, after) => Patch */
|
|
20
|
+
diff: Array<(before: any, after: any) => any>;
|
|
21
|
+
/** Types at each level - used to call equalFor/compareFor on Recursive back-references */
|
|
22
|
+
types: Array<EastTypeValue>;
|
|
23
|
+
/** Equality handlers for recursive types, keyed by type id */
|
|
24
|
+
equal: Map<bigint, (a: any, b: any) => boolean>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Context for building apply handlers with proper recursive type support.
|
|
28
|
+
*/
|
|
29
|
+
export interface ApplyContext {
|
|
30
|
+
/** Apply handlers: (base, patch) => value */
|
|
31
|
+
apply: Array<(base: any, patch: any) => any>;
|
|
32
|
+
/** Types at each level */
|
|
33
|
+
types: Array<EastTypeValue>;
|
|
34
|
+
/** Equality handlers for recursive types, keyed by type id */
|
|
35
|
+
equal: Map<bigint, (a: any, b: any) => boolean>;
|
|
36
|
+
/** Print handlers built in parallel - used for error messages */
|
|
37
|
+
print: Map<bigint, (value: any) => string>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Context for building compose handlers with proper recursive type support.
|
|
41
|
+
*/
|
|
42
|
+
export interface ComposeContext {
|
|
43
|
+
/** Compose handlers: (first, second) => combined patch */
|
|
44
|
+
compose: Array<(first: any, second: any) => any>;
|
|
45
|
+
/** Apply handlers built in parallel - used instead of calling applyFor with fresh context */
|
|
46
|
+
apply: Array<(base: any, patch: any) => any>;
|
|
47
|
+
/** Invert handlers built in parallel - used instead of calling invertFor with fresh context */
|
|
48
|
+
invert: Array<(patch: any) => any>;
|
|
49
|
+
/** Types at each level */
|
|
50
|
+
types: Array<EastTypeValue>;
|
|
51
|
+
/** Equality handlers for recursive types, keyed by type id */
|
|
52
|
+
equal: Map<bigint, (a: any, b: any) => boolean>;
|
|
53
|
+
/** Print handlers built in parallel - used for error messages */
|
|
54
|
+
print: Map<bigint, (value: any) => string>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Context for building invert handlers with proper recursive type support.
|
|
58
|
+
*/
|
|
59
|
+
export interface InvertContext {
|
|
60
|
+
/** Invert handlers: (patch) => inverted patch */
|
|
61
|
+
invert: Array<(patch: any) => any>;
|
|
62
|
+
/** Types at each level */
|
|
63
|
+
types: Array<EastTypeValue>;
|
|
64
|
+
/** Equality handlers for recursive types, keyed by type id */
|
|
65
|
+
equal: Map<bigint, (a: any, b: any) => boolean>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A single conflict — two patches against the same base touch the same
|
|
69
|
+
* leaf with different intentions.
|
|
70
|
+
*/
|
|
71
|
+
export interface Conflict {
|
|
72
|
+
/**
|
|
73
|
+
* Dot/bracket-encoded path from the root of T down to the conflicting
|
|
74
|
+
* leaf. Format:
|
|
75
|
+
* - struct field: dot-joined name (e.g. `policy.maxWeeklyHours`)
|
|
76
|
+
* - array element: bracket-suffixed (e.g. `roster[2]`)
|
|
77
|
+
* - dict entry: brace-suffixed (e.g. `prices{Cabernet}`)
|
|
78
|
+
* - variant case: at-prefixed (e.g. `status@active`)
|
|
79
|
+
* - root: empty string
|
|
80
|
+
*/
|
|
81
|
+
path: string;
|
|
82
|
+
/** patchA's intended value at this path (whole patch operation, e.g. `{type:"replace",value:{before,after}}`). */
|
|
83
|
+
valueA: any;
|
|
84
|
+
/** patchB's intended value at this path. */
|
|
85
|
+
valueB: any;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Per-conflict resolution that the caller supplies to
|
|
89
|
+
* `mergeWithResolutionsFor`. Keys are paths (matching `Conflict.path`).
|
|
90
|
+
*/
|
|
91
|
+
export type Resolution = {
|
|
92
|
+
type: "keepA";
|
|
93
|
+
} | {
|
|
94
|
+
type: "keepB";
|
|
95
|
+
} | {
|
|
96
|
+
type: "manual";
|
|
97
|
+
value: any;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Context for building merge handlers with proper recursive type support.
|
|
101
|
+
*
|
|
102
|
+
* Carries only the merge-handler stack + types + equality cache. Unlike
|
|
103
|
+
* `ComposeContext`, merge does NOT need apply/invert handlers — every merge
|
|
104
|
+
* case is either a clean recursive walk over patch shapes, or a conflict that
|
|
105
|
+
* the caller resolves; we never need to apply or invert a sub-patch as part of
|
|
106
|
+
* merging.
|
|
107
|
+
*/
|
|
108
|
+
export interface MergeContext {
|
|
109
|
+
/** Merge handlers, indexed by type-stack depth. Used for recursive-type
|
|
110
|
+
* back-references. The signature is the internal walker's; not exposed in
|
|
111
|
+
* the public API. */
|
|
112
|
+
merge: Array<(a: VariantValue<string, any>, b: VariantValue<string, any>, path: string, accConflict: (path: string, vA: any, vB: any) => void, lookup: ((path: string) => Resolution | undefined) | null) => VariantValue<string, any>>;
|
|
113
|
+
/** Types at each level — used to resolve `Recursive n` back-references. */
|
|
114
|
+
types: Array<EastTypeValue>;
|
|
115
|
+
/** Equality handlers for recursive types, keyed by type id. Threaded
|
|
116
|
+
* into every nested `equalFor(...)` call. */
|
|
117
|
+
equal: Map<bigint, (a: any, b: any) => boolean>;
|
|
118
|
+
}
|
|
119
|
+
/** Type-level computation of the patch type for a given East type. */
|
|
120
|
+
export type PatchTypeOf<T extends EastType> = T extends NeverType | NullType | BooleanType | IntegerType | FloatType | StringType | DateTimeType | BlobType | import("../types.js").VectorType<any> | import("../types.js").MatrixType<any> ? VariantType<{
|
|
121
|
+
unchanged: NullType;
|
|
122
|
+
replace: StructType<{
|
|
123
|
+
before: T;
|
|
124
|
+
after: T;
|
|
125
|
+
}>;
|
|
126
|
+
}> : T extends RefType<infer V extends EastType> ? VariantType<{
|
|
127
|
+
unchanged: NullType;
|
|
128
|
+
replace: StructType<{
|
|
129
|
+
before: T;
|
|
130
|
+
after: T;
|
|
131
|
+
}>;
|
|
132
|
+
patch: PatchTypeOf<V>;
|
|
133
|
+
}> : T extends ArrayType<infer E extends EastType> ? VariantType<{
|
|
134
|
+
unchanged: NullType;
|
|
135
|
+
replace: StructType<{
|
|
136
|
+
before: T;
|
|
137
|
+
after: T;
|
|
138
|
+
}>;
|
|
139
|
+
patch: ArrayType<StructType<{
|
|
140
|
+
key: IntegerType;
|
|
141
|
+
offset: IntegerType;
|
|
142
|
+
operation: VariantType<{
|
|
143
|
+
delete: E;
|
|
144
|
+
insert: E;
|
|
145
|
+
update: PatchTypeOf<E>;
|
|
146
|
+
}>;
|
|
147
|
+
}>>;
|
|
148
|
+
}> : T extends SetType<infer K> ? VariantType<{
|
|
149
|
+
unchanged: NullType;
|
|
150
|
+
replace: StructType<{
|
|
151
|
+
before: T;
|
|
152
|
+
after: T;
|
|
153
|
+
}>;
|
|
154
|
+
patch: DictType<K, VariantType<{
|
|
155
|
+
delete: NullType;
|
|
156
|
+
insert: NullType;
|
|
157
|
+
}>>;
|
|
158
|
+
}> : T extends DictType<infer K, infer V extends EastType> ? VariantType<{
|
|
159
|
+
unchanged: NullType;
|
|
160
|
+
replace: StructType<{
|
|
161
|
+
before: T;
|
|
162
|
+
after: T;
|
|
163
|
+
}>;
|
|
164
|
+
patch: DictType<K, VariantType<{
|
|
165
|
+
delete: V;
|
|
166
|
+
insert: V;
|
|
167
|
+
update: PatchTypeOf<V>;
|
|
168
|
+
}>>;
|
|
169
|
+
}> : T extends StructType<infer Fields> ? VariantType<{
|
|
170
|
+
unchanged: NullType;
|
|
171
|
+
replace: StructType<{
|
|
172
|
+
before: T;
|
|
173
|
+
after: T;
|
|
174
|
+
}>;
|
|
175
|
+
patch: StructType<{
|
|
176
|
+
[K in keyof Fields]: Fields[K] extends EastType ? PatchTypeOf<Fields[K]> : never;
|
|
177
|
+
}>;
|
|
178
|
+
}> : T extends VariantType<infer Cases> ? VariantType<{
|
|
179
|
+
unchanged: NullType;
|
|
180
|
+
replace: StructType<{
|
|
181
|
+
before: T;
|
|
182
|
+
after: T;
|
|
183
|
+
}>;
|
|
184
|
+
patch: VariantType<{
|
|
185
|
+
[K in keyof Cases]: Cases[K] extends EastType ? PatchTypeOf<Cases[K]> : never;
|
|
186
|
+
}>;
|
|
187
|
+
}> : T extends RecursiveType<infer _Node extends EastType> ? VariantType<{
|
|
188
|
+
unchanged: NullType;
|
|
189
|
+
replace: StructType<{
|
|
190
|
+
before: T;
|
|
191
|
+
after: T;
|
|
192
|
+
}>;
|
|
193
|
+
}> : VariantType<{
|
|
194
|
+
unchanged: NullType;
|
|
195
|
+
replace: StructType<{
|
|
196
|
+
before: T;
|
|
197
|
+
after: T;
|
|
198
|
+
}>;
|
|
199
|
+
}>;
|
|
200
|
+
/**
|
|
201
|
+
* Error thrown when patch operations encounter conflicts.
|
|
202
|
+
*
|
|
203
|
+
* For merge operations, the `conflicts` field lists every detected conflict
|
|
204
|
+
* with its path and the two divergent patch arms. The caller decides how to
|
|
205
|
+
* format / render this information.
|
|
206
|
+
*/
|
|
207
|
+
export declare class ConflictError extends Error {
|
|
208
|
+
/** Detailed conflict list (only populated by merge / merge-with-resolutions). */
|
|
209
|
+
readonly conflicts: ReadonlyArray<Conflict>;
|
|
210
|
+
constructor(message: string, conflicts?: ReadonlyArray<Conflict>);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Compute the Longest Common Subsequence of two arrays.
|
|
214
|
+
* @internal
|
|
215
|
+
*/
|
|
216
|
+
export declare function computeLCS<T>(before: T[], after: T[], equal: (a: T, b: T) => boolean): {
|
|
217
|
+
beforeIndices: number[];
|
|
218
|
+
afterIndices: number[];
|
|
219
|
+
};
|
|
220
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/patch/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EACV,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,WAAW,EACX,WAAW,EACX,SAAS,EACT,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,SAAS,EACT,OAAO,EACP,QAAQ,EACR,UAAU,EACV,WAAW,EACX,aAAa,EACd,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAMxE;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,8CAA8C;IAC9C,IAAI,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,KAAK,GAAG,C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,CAAM;CAKrE;AAOD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAC1B,MAAM,EAAE,CAAC,EAAE,EACX,KAAK,EAAE,CAAC,EAAE,EACV,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,GAC7B;IAAE,aAAa,EAAE,MAAM,EAAE,CAAC;IAAC,YAAY,EAAE,MAAM,EAAE,CAAA;CAAE,CAmCrD"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Error thrown when patch operations encounter conflicts.
|
|
7
|
+
*
|
|
8
|
+
* For merge operations, the `conflicts` field lists every detected conflict
|
|
9
|
+
* with its path and the two divergent patch arms. The caller decides how to
|
|
10
|
+
* format / render this information.
|
|
11
|
+
*/
|
|
12
|
+
export class ConflictError extends Error {
|
|
13
|
+
/** Detailed conflict list (only populated by merge / merge-with-resolutions). */
|
|
14
|
+
conflicts;
|
|
15
|
+
constructor(message, conflicts = []) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.name = "ConflictError";
|
|
18
|
+
this.conflicts = conflicts;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
// ============================================================================
|
|
22
|
+
// Helper functions
|
|
23
|
+
// ============================================================================
|
|
24
|
+
/**
|
|
25
|
+
* Compute the Longest Common Subsequence of two arrays.
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export function computeLCS(before, after, equal) {
|
|
29
|
+
const m = before.length;
|
|
30
|
+
const n = after.length;
|
|
31
|
+
const dp = Array.from({ length: m + 1 }, () => Array(n + 1).fill(0));
|
|
32
|
+
for (let i = 1; i <= m; i++) {
|
|
33
|
+
for (let j = 1; j <= n; j++) {
|
|
34
|
+
if (equal(before[i - 1], after[j - 1])) {
|
|
35
|
+
dp[i][j] = dp[i - 1][j - 1] + 1;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const beforeIndices = [];
|
|
43
|
+
const afterIndices = [];
|
|
44
|
+
let i = m;
|
|
45
|
+
let j = n;
|
|
46
|
+
while (i > 0 && j > 0) {
|
|
47
|
+
if (equal(before[i - 1], after[j - 1])) {
|
|
48
|
+
beforeIndices.unshift(i - 1);
|
|
49
|
+
afterIndices.unshift(j - 1);
|
|
50
|
+
i--;
|
|
51
|
+
j--;
|
|
52
|
+
}
|
|
53
|
+
else if (dp[i - 1][j] > dp[i][j - 1]) {
|
|
54
|
+
i--;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
j--;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return { beforeIndices, afterIndices };
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/patch/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAwMH;;;;;;GAMG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,iFAAiF;IACxE,SAAS,CAA0B;IAE5C,YAAY,OAAe,EAAE,YAAqC,EAAE;QAClE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF;AAED,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAG/E;;;GAGG;AACH,MAAM,UAAU,UAAU,CACxB,MAAW,EACX,KAAU,EACV,KAA8B;IAE9B,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;IACxB,MAAM,CAAC,G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C,CAAE,CAAC,EAAE,CAAC;YACzC,aAAa,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAC7B,YAAY,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAC5B,CAAC,EAAE,CAAC;YACJ,CAAC,EAAE,CAAC;QACN,CAAC;aAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAE,CAAC,CAAC,CAAE,GAAG,EAAE,CAAC,CAAC,CAAE,CAAC,CAAC,GAAG,CAAC,CAAE,EAAE,CAAC;YAC3C,CAAC,EAAE,CAAC;QACN,CAAC;aAAM,CAAC;YACN,CAAC,EAAE,CAAC;QACN,CAAC;IACH,CAAC;IAED,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* `validatePatchFor` — non-throwing per-leaf validation of a patch against a
|
|
7
|
+
* base value. Returns the list of paths where the patch's expected `before`
|
|
8
|
+
* (or expected key presence/absence) disagrees with `base`'s actual value.
|
|
9
|
+
*
|
|
10
|
+
* This fills the gap between `applyFor` (which throws on the first stale op,
|
|
11
|
+
* losing per-leaf granularity) and `mergeFor` (which compares two patches
|
|
12
|
+
* against a common ancestor — different problem).
|
|
13
|
+
*
|
|
14
|
+
* Empty result list ⇒ `applyFor(type)(base, patch)` would succeed cleanly.
|
|
15
|
+
*
|
|
16
|
+
* @module
|
|
17
|
+
*/
|
|
18
|
+
import { type EastTypeValue } from "../type_of_type.js";
|
|
19
|
+
import type { EastType } from "../types.js";
|
|
20
|
+
import { type PatchPath } from "./path.js";
|
|
21
|
+
/**
|
|
22
|
+
* One per-leaf disagreement between a patch and a base value.
|
|
23
|
+
*
|
|
24
|
+
* @property path - structured path from the root of the base/patch.
|
|
25
|
+
* @property op - which patch operation didn't apply cleanly.
|
|
26
|
+
* @property expected - what the patch expected at this path.
|
|
27
|
+
* For `replace`/`delete`/`update`: the patch's `before`.
|
|
28
|
+
* For `insert`: `undefined` (insert expects absence).
|
|
29
|
+
* @property actual - what the base actually has at this path.
|
|
30
|
+
* `undefined` when the key/index is missing.
|
|
31
|
+
*/
|
|
32
|
+
export interface PatchConflict {
|
|
33
|
+
readonly path: PatchPath;
|
|
34
|
+
readonly op: "replace" | "delete" | "insert" | "update";
|
|
35
|
+
readonly expected: unknown;
|
|
36
|
+
readonly actual: unknown;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Build a validator for patches over `type`. The returned closure walks
|
|
40
|
+
* `base` and `patch` in parallel and accumulates per-leaf conflicts; never
|
|
41
|
+
* throws. Empty result ⇒ patch applies cleanly.
|
|
42
|
+
*/
|
|
43
|
+
export declare function validatePatchFor(type: EastTypeValue | EastType): (base: any, patch: any) => PatchConflict[];
|
|
44
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/patch/validate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI5C,OAAO,EACL,KAAK,SAAS,EAKf,MAAM,WAAW,CAAC;AAEnB;;;;;;;;;;GAUG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,EAAE,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACxD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,aAAa,GAAG,QAAQ,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,KAAK,aAAa,EAAE,CAO3G"}
|