@synnaxlabs/x 0.16.0 → 0.23.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/.turbo/turbo-build.log +99 -7
- package/.vscode/settings.json +5 -1
- package/dist/base-Cz4DfmJf.js +37 -0
- package/dist/base-D3FrPu8C.cjs +1 -0
- package/dist/binary.cjs +1 -0
- package/dist/binary.js +37 -0
- package/dist/bounds-1ouRnRJS.cjs +1 -0
- package/dist/bounds-BYz3mV9U.js +129 -0
- package/dist/bounds.cjs +1 -0
- package/dist/bounds.js +4 -0
- package/dist/box-CHDDKvN3.cjs +1 -0
- package/dist/box-Q7p9JFnX.js +204 -0
- package/dist/box.cjs +1 -0
- package/dist/box.js +4 -0
- package/dist/caseconv.cjs +1 -0
- package/dist/caseconv.js +4 -0
- package/dist/change-C-YELKx6.cjs +1 -0
- package/dist/change-DLl6DccR.js +12 -0
- package/dist/change.cjs +1 -0
- package/dist/change.js +4 -0
- package/dist/compare.cjs +1 -0
- package/dist/compare.js +4 -0
- package/dist/debounce.cjs +1 -0
- package/dist/debounce.js +17 -0
- package/dist/deep.cjs +1 -0
- package/dist/deep.js +119 -0
- package/dist/destructor.cjs +1 -0
- package/dist/destructor.js +1 -0
- package/dist/dimensions-9gLSFjFx.js +44 -0
- package/dist/dimensions-Fe8DhhXU.cjs +1 -0
- package/dist/dimensions.cjs +1 -0
- package/dist/dimensions.js +4 -0
- package/dist/direction-dXjlmg4_.cjs +1 -0
- package/dist/direction-wsPTe9a1.js +15 -0
- package/dist/direction.cjs +1 -0
- package/dist/direction.js +4 -0
- package/dist/external-B-DoBvh7.cjs +1 -0
- package/dist/external-DI9122wF.js +27 -0
- package/dist/identity.cjs +1 -0
- package/dist/identity.js +4 -0
- package/dist/index-Bcm6lEr8.js +73 -0
- package/dist/index-CnZb0cyW.cjs +1 -0
- package/dist/index-POWYBOZm.js +356 -0
- package/dist/index-xjptNL6Z.cjs +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.js +136 -0
- package/dist/kv.cjs +1 -0
- package/dist/kv.js +6 -0
- package/dist/location-C4YaXxjI.js +94 -0
- package/dist/location-CZOgJmu5.cjs +1 -0
- package/dist/location.cjs +1 -0
- package/dist/location.js +4 -0
- package/dist/observe.cjs +1 -0
- package/dist/observe.js +43 -0
- package/dist/path-BfHj5x9k.js +62 -0
- package/dist/path-By98WcWm.cjs +1 -0
- package/dist/position-BjhXUSEO.cjs +1 -0
- package/dist/position-PSYLZzqw.js +87 -0
- package/dist/position.cjs +1 -0
- package/dist/position.js +4 -0
- package/dist/record.cjs +1 -0
- package/dist/record.js +9 -0
- package/dist/runtime.cjs +1 -0
- package/dist/runtime.js +4 -0
- package/dist/scale-DCbi48di.js +205 -0
- package/dist/scale-DUBO0Q4s.cjs +1 -0
- package/dist/scale.cjs +1 -0
- package/dist/scale.js +4 -0
- package/dist/search.cjs +1 -0
- package/dist/search.js +15 -0
- package/dist/series-CSutMOtt.cjs +11 -0
- package/dist/series-DCv8f29w.js +1629 -0
- package/dist/spatial-6OGCmDve.js +11 -0
- package/dist/spatial-R5OeJgR6.cjs +1 -0
- package/dist/spatial.cjs +1 -0
- package/dist/spatial.js +20 -0
- package/dist/{binary → src/binary}/encoder.d.ts +7 -2
- package/dist/src/binary/encoder.d.ts.map +1 -0
- package/dist/src/binary/encoder.spec.d.ts.map +1 -0
- package/dist/src/binary/index.d.ts.map +1 -0
- package/dist/src/caseconv/caseconv.d.ts +4 -0
- package/dist/src/caseconv/caseconv.d.ts.map +1 -0
- package/dist/src/caseconv/index.d.ts +2 -0
- package/dist/src/caseconv/index.d.ts.map +1 -0
- package/dist/{change → src/change}/change.d.ts +10 -9
- package/dist/src/change/change.d.ts.map +1 -0
- package/dist/src/change/index.d.ts.map +1 -0
- package/dist/src/clamp/clamp.d.ts.map +1 -0
- package/dist/src/clamp/index.d.ts +2 -0
- package/dist/src/clamp/index.d.ts.map +1 -0
- package/dist/{compare → src/compare}/compare.d.ts +5 -4
- package/dist/src/compare/compare.d.ts.map +1 -0
- package/dist/src/compare/index.d.ts.map +1 -0
- package/dist/src/control/control.d.ts +107 -0
- package/dist/src/control/control.d.ts.map +1 -0
- package/dist/src/control/index.d.ts +2 -0
- package/dist/src/control/index.d.ts.map +1 -0
- package/dist/src/debounce/debounce.d.ts.map +1 -0
- package/dist/src/debounce/debounce.spec.d.ts +2 -0
- package/dist/src/debounce/debounce.spec.d.ts.map +1 -0
- package/dist/src/debounce/index.d.ts +2 -0
- package/dist/src/debounce/index.d.ts.map +1 -0
- package/dist/src/deep/copy.d.ts.map +1 -0
- package/dist/{deep → src/deep}/delete.d.ts +2 -1
- package/dist/src/deep/delete.d.ts.map +1 -0
- package/dist/{deep → src/deep}/delete.spec.d.ts.map +1 -1
- package/dist/src/deep/difference.d.ts.map +1 -0
- package/dist/src/deep/difference.spec.d.ts.map +1 -0
- package/dist/src/deep/equal.d.ts.map +1 -0
- package/dist/{deep → src/deep}/equal.spec.d.ts.map +1 -1
- package/dist/{deep → src/deep}/external.d.ts +3 -4
- package/dist/src/deep/external.d.ts.map +1 -0
- package/dist/src/deep/index.d.ts.map +1 -0
- package/dist/src/deep/merge.d.ts +12 -0
- package/dist/src/deep/merge.d.ts.map +1 -0
- package/dist/{deep → src/deep}/merge.spec.d.ts.map +1 -1
- package/dist/src/deep/partial.d.ts.map +1 -0
- package/dist/src/deep/path.d.ts +45 -0
- package/dist/src/deep/path.d.ts.map +1 -0
- package/dist/{deep → src/deep}/path.spec.d.ts.map +1 -1
- package/dist/src/destructor.d.ts.map +1 -0
- package/dist/{identity.d.ts → src/identity.d.ts} +2 -1
- package/dist/src/identity.d.ts.map +1 -0
- package/dist/{index.d.ts → src/index.d.ts} +22 -20
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/invert.d.ts.map +1 -0
- package/dist/src/join.d.ts.map +1 -0
- package/dist/src/kv/index.d.ts.map +1 -0
- package/dist/src/kv/types.d.ts.map +1 -0
- package/dist/src/math/index.d.ts +2 -0
- package/dist/src/math/index.d.ts.map +1 -0
- package/dist/src/math/math.d.ts +11 -0
- package/dist/src/math/math.d.ts.map +1 -0
- package/dist/src/migrate/index.d.ts.map +1 -0
- package/dist/{migrate → src/migrate}/migrate.d.ts +2 -1
- package/dist/src/migrate/migrate.d.ts.map +1 -0
- package/dist/src/migrate/migrate.spec.d.ts.map +1 -0
- package/dist/{mock → src/mock}/MockGLBufferController.d.ts +2 -1
- package/dist/src/mock/MockGLBufferController.d.ts.map +1 -0
- package/dist/src/mock/index.d.ts.map +1 -0
- package/dist/src/observe/index.d.ts.map +1 -0
- package/dist/src/observe/observe.d.ts +24 -0
- package/dist/src/observe/observe.d.ts.map +1 -0
- package/dist/src/observe/obsever.spec.d.ts +2 -0
- package/dist/src/observe/obsever.spec.d.ts.map +1 -0
- package/dist/src/optional.d.ts.map +1 -0
- package/dist/{primitive.d.ts → src/primitive.d.ts} +2 -1
- package/dist/src/primitive.d.ts.map +1 -0
- package/dist/{record.d.ts → src/record.d.ts} +7 -8
- package/dist/src/record.d.ts.map +1 -0
- package/dist/{renderable.d.ts → src/renderable.d.ts} +2 -1
- package/dist/src/renderable.d.ts.map +1 -0
- package/dist/src/runtime/detect.d.ts.map +1 -0
- package/dist/src/runtime/external.d.ts.map +1 -0
- package/dist/src/runtime/index.d.ts.map +1 -0
- package/dist/src/runtime/os.d.ts +20 -0
- package/dist/src/runtime/os.d.ts.map +1 -0
- package/dist/{search.d.ts → src/search.d.ts} +5 -2
- package/dist/src/search.d.ts.map +1 -0
- package/dist/src/shallowCopy.d.ts +2 -0
- package/dist/src/shallowCopy.d.ts.map +1 -0
- package/dist/{spatial → src/spatial}/base.d.ts +30 -5
- package/dist/src/spatial/base.d.ts.map +1 -0
- package/dist/src/spatial/bounds/bounds.d.ts +148 -0
- package/dist/src/spatial/bounds/bounds.d.ts.map +1 -0
- package/dist/src/spatial/bounds/bounds.spec.d.ts.map +1 -0
- package/dist/src/spatial/bounds/index.d.ts.map +1 -0
- package/dist/{spatial → src/spatial}/box/box.d.ts +69 -22
- package/dist/src/spatial/box/box.d.ts.map +1 -0
- package/dist/src/spatial/box/box.spec.d.ts.map +1 -0
- package/dist/src/spatial/box/index.d.ts.map +1 -0
- package/dist/{spatial → src/spatial}/dimensions/dimensions.d.ts +4 -3
- package/dist/src/spatial/dimensions/dimensions.d.ts.map +1 -0
- package/dist/src/spatial/dimensions/dimensions.spec.d.ts.map +1 -0
- package/dist/src/spatial/dimensions/index.d.ts.map +1 -0
- package/dist/{spatial → src/spatial}/direction/direction.d.ts +3 -2
- package/dist/src/spatial/direction/direction.d.ts.map +1 -0
- package/dist/src/spatial/direction/direction.spec.d.ts.map +1 -0
- package/dist/src/spatial/direction/index.d.ts.map +1 -0
- package/dist/{spatial → src/spatial}/external.d.ts +2 -2
- package/dist/src/spatial/external.d.ts.map +1 -0
- package/dist/src/spatial/index.d.ts.map +1 -0
- package/dist/src/spatial/location/index.d.ts.map +1 -0
- package/dist/{spatial → src/spatial}/location/location.d.ts +4 -3
- package/dist/src/spatial/location/location.d.ts.map +1 -0
- package/dist/src/spatial/location/location.spec.d.ts.map +1 -0
- package/dist/src/spatial/position/index.d.ts.map +1 -0
- package/dist/{spatial → src/spatial}/position/position.d.ts +4 -4
- package/dist/src/spatial/position/position.d.ts.map +1 -0
- package/dist/src/spatial/position/position.spec.d.ts.map +1 -0
- package/dist/src/spatial/scale/index.d.ts.map +1 -0
- package/dist/{spatial → src/spatial}/scale/scale.d.ts +15 -62
- package/dist/src/spatial/scale/scale.d.ts.map +1 -0
- package/dist/src/spatial/scale/scale.spec.d.ts.map +1 -0
- package/dist/src/spatial/spatial.d.ts +2 -0
- package/dist/src/spatial/spatial.d.ts.map +1 -0
- package/dist/src/spatial/xy/index.d.ts.map +1 -0
- package/dist/{spatial → src/spatial}/xy/xy.d.ts +15 -24
- package/dist/src/spatial/xy/xy.d.ts.map +1 -0
- package/dist/{spatial → src/spatial}/xy/xy.spec.d.ts.map +1 -1
- package/dist/src/telem/generate.d.ts +4 -0
- package/dist/src/telem/generate.d.ts.map +1 -0
- package/dist/src/telem/gl.d.ts.map +1 -0
- package/dist/{telem → src/telem}/index.d.ts +1 -1
- package/dist/src/telem/index.d.ts.map +1 -0
- package/dist/{telem → src/telem}/series.d.ts +10 -8
- package/dist/src/telem/series.d.ts.map +1 -0
- package/dist/{telem → src/telem}/series.spec.d.ts.map +1 -1
- package/dist/{telem → src/telem}/telem.d.ts +19 -21
- package/dist/src/telem/telem.d.ts.map +1 -0
- package/dist/{telem → src/telem}/telem.spec.d.ts.map +1 -1
- package/dist/src/toArray.d.ts.map +1 -0
- package/dist/src/transform.d.ts +6 -0
- package/dist/src/transform.d.ts.map +1 -0
- package/dist/src/unique.d.ts.map +1 -0
- package/dist/src/url/index.d.ts +2 -0
- package/dist/src/url/index.d.ts.map +1 -0
- package/dist/src/url/url.d.ts.map +1 -0
- package/dist/{url → src/url}/url.spec.d.ts.map +1 -1
- package/dist/src/worker/index.d.ts +2 -0
- package/dist/src/worker/index.d.ts.map +1 -0
- package/dist/{worker → src/worker}/worker.d.ts +4 -4
- package/dist/src/worker/worker.d.ts.map +1 -0
- package/dist/src/worker/worker.spec.d.ts.map +1 -0
- package/dist/src/zodutil/index.d.ts +2 -0
- package/dist/src/zodutil/index.d.ts.map +1 -0
- package/dist/src/zodutil/zodutil.d.ts +6 -0
- package/dist/src/zodutil/zodutil.d.ts.map +1 -0
- package/dist/src/zodutil/zodutil.spec.d.ts +2 -0
- package/dist/src/zodutil/zodutil.spec.d.ts.map +1 -0
- package/dist/telem.cjs +1 -0
- package/dist/telem.js +17 -0
- package/dist/toArray.cjs +1 -0
- package/dist/toArray.js +5 -0
- package/dist/unique.cjs +1 -0
- package/dist/unique.js +4 -0
- package/dist/url.cjs +1 -0
- package/dist/url.js +54 -0
- package/dist/worker.cjs +1 -0
- package/dist/worker.js +47 -0
- package/dist/xy-B4SvvNaG.cjs +1 -0
- package/dist/xy-H8aUVW_X.js +90 -0
- package/dist/xy.cjs +1 -0
- package/dist/xy.js +4 -0
- package/dist/zodutil.cjs +1 -0
- package/dist/zodutil.js +22 -0
- package/eslint.config.js +12 -0
- package/package.json +158 -14
- package/src/binary/encoder.spec.ts +31 -6
- package/src/binary/encoder.ts +26 -15
- package/src/binary/index.ts +1 -1
- package/src/{case.ts → caseconv/caseconv.ts} +4 -9
- package/src/caseconv/index.ts +10 -0
- package/src/change/change.ts +7 -6
- package/src/change/index.ts +1 -1
- package/src/{clamp.ts → clamp/clamp.ts} +1 -1
- package/src/clamp/index.ts +10 -0
- package/src/compare/compare.ts +6 -9
- package/src/compare/index.ts +1 -1
- package/src/control/control.ts +77 -0
- package/src/control/index.ts +1 -0
- package/src/debounce/debounce.spec.ts +52 -0
- package/src/{debounce.ts → debounce/debounce.ts} +4 -4
- package/src/debounce/index.ts +10 -0
- package/src/deep/copy.ts +2 -3
- package/src/deep/delete.spec.ts +2 -2
- package/src/deep/delete.ts +3 -2
- package/src/deep/difference.spec.ts +28 -27
- package/src/deep/difference.ts +13 -11
- package/src/deep/equal.spec.ts +4 -4
- package/src/deep/equal.ts +16 -12
- package/src/deep/external.ts +4 -5
- package/src/deep/index.ts +1 -1
- package/src/deep/merge.spec.ts +120 -4
- package/src/deep/merge.ts +50 -9
- package/src/deep/partial.ts +1 -1
- package/src/deep/path.spec.ts +90 -39
- package/src/deep/path.ts +105 -46
- package/src/destructor.ts +2 -2
- package/src/identity.ts +1 -1
- package/src/index.ts +23 -21
- package/src/invert.ts +9 -0
- package/src/join.ts +1 -1
- package/src/kv/index.ts +1 -1
- package/src/kv/types.ts +1 -1
- package/src/math/index.ts +10 -0
- package/src/math/math.ts +33 -0
- package/src/migrate/index.ts +9 -0
- package/src/migrate/migrate.spec.ts +12 -2
- package/src/migrate/migrate.ts +9 -0
- package/src/mock/MockGLBufferController.ts +6 -6
- package/src/mock/index.ts +1 -1
- package/src/observe/index.ts +1 -1
- package/src/observe/observe.ts +37 -6
- package/src/observe/obsever.spec.ts +56 -0
- package/src/optional.ts +3 -4
- package/src/primitive.ts +1 -1
- package/src/record.ts +10 -6
- package/src/renderable.ts +1 -1
- package/src/runtime/detect.ts +3 -3
- package/src/runtime/external.ts +1 -1
- package/src/runtime/index.ts +1 -1
- package/src/runtime/os.ts +17 -5
- package/src/search.ts +3 -1
- package/src/shallowCopy.ts +5 -6
- package/src/spatial/base.ts +13 -5
- package/src/spatial/bounds/bounds.spec.ts +259 -180
- package/src/spatial/bounds/bounds.ts +200 -85
- package/src/spatial/bounds/index.ts +2 -2
- package/src/spatial/box/box.spec.ts +163 -2
- package/src/spatial/box/box.ts +82 -38
- package/src/spatial/box/index.ts +2 -2
- package/src/spatial/dimensions/dimensions.spec.ts +1 -1
- package/src/spatial/dimensions/dimensions.ts +4 -4
- package/src/spatial/dimensions/index.ts +2 -2
- package/src/spatial/direction/direction.spec.ts +1 -1
- package/src/spatial/direction/direction.ts +5 -5
- package/src/spatial/direction/index.ts +2 -2
- package/src/spatial/external.ts +3 -3
- package/src/spatial/index.ts +1 -1
- package/src/spatial/location/index.ts +2 -2
- package/src/spatial/location/location.spec.ts +1 -1
- package/src/spatial/location/location.ts +21 -21
- package/src/spatial/position/index.ts +1 -1
- package/src/spatial/position/position.spec.ts +1 -1
- package/src/spatial/position/position.ts +3 -20
- package/src/spatial/scale/index.ts +2 -2
- package/src/spatial/scale/scale.spec.ts +3 -3
- package/src/spatial/scale/scale.ts +3 -3
- package/src/spatial/spatial.ts +5 -5
- package/src/spatial/xy/index.ts +2 -2
- package/src/spatial/xy/xy.spec.ts +93 -44
- package/src/spatial/xy/xy.ts +17 -25
- package/src/telem/generate.ts +1 -1
- package/src/telem/gl.ts +1 -1
- package/src/telem/index.ts +2 -2
- package/src/telem/series.spec.ts +64 -5
- package/src/telem/series.ts +47 -35
- package/src/telem/telem.spec.ts +105 -2
- package/src/telem/telem.ts +63 -23
- package/src/toArray.ts +2 -2
- package/src/transform.ts +9 -2
- package/src/unique.ts +1 -1
- package/src/url/index.ts +2 -2
- package/src/url/url.spec.ts +2 -2
- package/src/url/url.ts +4 -4
- package/src/worker/index.ts +10 -0
- package/src/worker/worker.spec.ts +2 -2
- package/src/worker/worker.ts +13 -13
- package/src/zodutil/index.ts +10 -0
- package/src/zodutil/zodutil.spec.ts +103 -0
- package/src/zodutil/zodutil.ts +45 -0
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/vite.config.ts +39 -3
- package/.eslintrc.cjs +0 -18
- package/dist/binary/encoder.d.ts.map +0 -1
- package/dist/binary/encoder.spec.d.ts.map +0 -1
- package/dist/binary/index.d.ts.map +0 -1
- package/dist/case.d.ts +0 -6
- package/dist/case.d.ts.map +0 -1
- package/dist/change/change.d.ts.map +0 -1
- package/dist/change/index.d.ts.map +0 -1
- package/dist/clamp.d.ts.map +0 -1
- package/dist/compare/compare.d.ts.map +0 -1
- package/dist/compare/index.d.ts.map +0 -1
- package/dist/debounce.d.ts.map +0 -1
- package/dist/deep/copy.d.ts.map +0 -1
- package/dist/deep/delete.d.ts.map +0 -1
- package/dist/deep/difference.d.ts.map +0 -1
- package/dist/deep/difference.spec.d.ts.map +0 -1
- package/dist/deep/equal.d.ts.map +0 -1
- package/dist/deep/external.d.ts.map +0 -1
- package/dist/deep/index.d.ts.map +0 -1
- package/dist/deep/memo.d.ts +0 -2
- package/dist/deep/memo.d.ts.map +0 -1
- package/dist/deep/merge.d.ts +0 -3
- package/dist/deep/merge.d.ts.map +0 -1
- package/dist/deep/partial.d.ts.map +0 -1
- package/dist/deep/path.d.ts +0 -37
- package/dist/deep/path.d.ts.map +0 -1
- package/dist/destructor.d.ts.map +0 -1
- package/dist/identity.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/invert.d.ts.map +0 -1
- package/dist/join.d.ts.map +0 -1
- package/dist/kv/index.d.ts.map +0 -1
- package/dist/kv/types.d.ts.map +0 -1
- package/dist/migrate/index.d.ts.map +0 -1
- package/dist/migrate/migrate.d.ts.map +0 -1
- package/dist/migrate/migrate.spec.d.ts.map +0 -1
- package/dist/mock/MockGLBufferController.d.ts.map +0 -1
- package/dist/mock/index.d.ts.map +0 -1
- package/dist/observe/index.d.ts.map +0 -1
- package/dist/observe/observe.d.ts +0 -12
- package/dist/observe/observe.d.ts.map +0 -1
- package/dist/optional.d.ts.map +0 -1
- package/dist/primitive.d.ts.map +0 -1
- package/dist/record.d.ts.map +0 -1
- package/dist/renderable.d.ts.map +0 -1
- package/dist/runtime/detect.d.ts.map +0 -1
- package/dist/runtime/external.d.ts.map +0 -1
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/os.d.ts +0 -10
- package/dist/runtime/os.d.ts.map +0 -1
- package/dist/search.d.ts.map +0 -1
- package/dist/shallowCopy.d.ts +0 -2
- package/dist/shallowCopy.d.ts.map +0 -1
- package/dist/spatial/base.d.ts.map +0 -1
- package/dist/spatial/bounds/bounds.d.ts +0 -71
- package/dist/spatial/bounds/bounds.d.ts.map +0 -1
- package/dist/spatial/bounds/bounds.spec.d.ts.map +0 -1
- package/dist/spatial/bounds/index.d.ts.map +0 -1
- package/dist/spatial/box/box.d.ts.map +0 -1
- package/dist/spatial/box/box.spec.d.ts.map +0 -1
- package/dist/spatial/box/index.d.ts.map +0 -1
- package/dist/spatial/dimensions/dimensions.d.ts.map +0 -1
- package/dist/spatial/dimensions/dimensions.spec.d.ts.map +0 -1
- package/dist/spatial/dimensions/index.d.ts.map +0 -1
- package/dist/spatial/direction/direction.d.ts.map +0 -1
- package/dist/spatial/direction/direction.spec.d.ts.map +0 -1
- package/dist/spatial/direction/index.d.ts.map +0 -1
- package/dist/spatial/external.d.ts.map +0 -1
- package/dist/spatial/index.d.ts.map +0 -1
- package/dist/spatial/location/index.d.ts.map +0 -1
- package/dist/spatial/location/location.d.ts.map +0 -1
- package/dist/spatial/location/location.spec.d.ts.map +0 -1
- package/dist/spatial/position/index.d.ts.map +0 -1
- package/dist/spatial/position/position.d.ts.map +0 -1
- package/dist/spatial/position/position.spec.d.ts.map +0 -1
- package/dist/spatial/scale/index.d.ts.map +0 -1
- package/dist/spatial/scale/scale.d.ts.map +0 -1
- package/dist/spatial/scale/scale.spec.d.ts.map +0 -1
- package/dist/spatial/spatial.d.ts +0 -2
- package/dist/spatial/spatial.d.ts.map +0 -1
- package/dist/spatial/xy/index.d.ts.map +0 -1
- package/dist/spatial/xy/xy.d.ts.map +0 -1
- package/dist/telem/generate.d.ts +0 -3
- package/dist/telem/generate.d.ts.map +0 -1
- package/dist/telem/gl.d.ts.map +0 -1
- package/dist/telem/index.d.ts.map +0 -1
- package/dist/telem/series.d.ts.map +0 -1
- package/dist/telem/telem.d.ts.map +0 -1
- package/dist/toArray.d.ts.map +0 -1
- package/dist/transform.d.ts +0 -2
- package/dist/transform.d.ts.map +0 -1
- package/dist/unique.d.ts.map +0 -1
- package/dist/url/index.d.ts +0 -2
- package/dist/url/index.d.ts.map +0 -1
- package/dist/url/url.d.ts.map +0 -1
- package/dist/worker/worker.d.ts.map +0 -1
- package/dist/worker/worker.spec.d.ts.map +0 -1
- package/dist/x.cjs +0 -12
- package/dist/x.cjs.map +0 -1
- package/dist/x.js +0 -5935
- package/dist/x.js.map +0 -1
- package/src/deep/memo.ts +0 -24
- /package/dist/{binary → src/binary}/encoder.spec.d.ts +0 -0
- /package/dist/{binary → src/binary}/index.d.ts +0 -0
- /package/dist/{change → src/change}/index.d.ts +0 -0
- /package/dist/{clamp.d.ts → src/clamp/clamp.d.ts} +0 -0
- /package/dist/{compare → src/compare}/index.d.ts +0 -0
- /package/dist/{debounce.d.ts → src/debounce/debounce.d.ts} +0 -0
- /package/dist/{deep → src/deep}/copy.d.ts +0 -0
- /package/dist/{deep → src/deep}/delete.spec.d.ts +0 -0
- /package/dist/{deep → src/deep}/difference.d.ts +0 -0
- /package/dist/{deep → src/deep}/difference.spec.d.ts +0 -0
- /package/dist/{deep → src/deep}/equal.d.ts +0 -0
- /package/dist/{deep → src/deep}/equal.spec.d.ts +0 -0
- /package/dist/{deep → src/deep}/index.d.ts +0 -0
- /package/dist/{deep → src/deep}/merge.spec.d.ts +0 -0
- /package/dist/{deep → src/deep}/partial.d.ts +0 -0
- /package/dist/{deep → src/deep}/path.spec.d.ts +0 -0
- /package/dist/{destructor.d.ts → src/destructor.d.ts} +0 -0
- /package/dist/{invert.d.ts → src/invert.d.ts} +0 -0
- /package/dist/{join.d.ts → src/join.d.ts} +0 -0
- /package/dist/{kv → src/kv}/index.d.ts +0 -0
- /package/dist/{kv → src/kv}/types.d.ts +0 -0
- /package/dist/{migrate → src/migrate}/index.d.ts +0 -0
- /package/dist/{migrate → src/migrate}/migrate.spec.d.ts +0 -0
- /package/dist/{mock → src/mock}/index.d.ts +0 -0
- /package/dist/{observe → src/observe}/index.d.ts +0 -0
- /package/dist/{optional.d.ts → src/optional.d.ts} +0 -0
- /package/dist/{runtime → src/runtime}/detect.d.ts +0 -0
- /package/dist/{runtime → src/runtime}/external.d.ts +0 -0
- /package/dist/{runtime → src/runtime}/index.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/bounds/bounds.spec.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/bounds/index.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/box/box.spec.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/box/index.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/dimensions/dimensions.spec.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/dimensions/index.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/direction/direction.spec.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/direction/index.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/index.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/location/index.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/location/location.spec.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/position/index.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/position/position.spec.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/scale/index.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/scale/scale.spec.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/xy/index.d.ts +0 -0
- /package/dist/{spatial → src/spatial}/xy/xy.spec.d.ts +0 -0
- /package/dist/{telem → src/telem}/gl.d.ts +0 -0
- /package/dist/{telem → src/telem}/series.spec.d.ts +0 -0
- /package/dist/{telem → src/telem}/telem.spec.d.ts +0 -0
- /package/dist/{toArray.d.ts → src/toArray.d.ts} +0 -0
- /package/dist/{unique.d.ts → src/unique.d.ts} +0 -0
- /package/dist/{url → src/url}/url.d.ts +0 -0
- /package/dist/{url → src/url}/url.spec.d.ts +0 -0
- /package/dist/{worker → src/worker}/worker.spec.d.ts +0 -0
package/src/telem/telem.spec.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -33,6 +33,12 @@ describe("TimeStamp", () => {
|
|
|
33
33
|
expect(ts.equals(TimeStamp.MIN)).toBeTruthy();
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
+
test("toString", () => {
|
|
37
|
+
const ts = new TimeStamp(TimeSpan.days(90)).add(TimeSpan.minutes(20)).add(TimeSpan.milliseconds(283)).add(TimeSpan.microseconds(900))
|
|
38
|
+
const tsString = ts.toString()
|
|
39
|
+
expect(tsString).toEqual("1970-04-01T00:20:00.283Z")
|
|
40
|
+
})
|
|
41
|
+
|
|
36
42
|
test("encode", () => {
|
|
37
43
|
const ts = TimeStamp.now();
|
|
38
44
|
new binary.JSONEncoderDecoder().encode(ts);
|
|
@@ -383,7 +389,20 @@ describe("TimeRange", () => {
|
|
|
383
389
|
expect(tr.overlapsWith(one)).toBeFalsy();
|
|
384
390
|
expect(one.overlapsWith(tr)).toBeFalsy();
|
|
385
391
|
});
|
|
386
|
-
it("should return")
|
|
392
|
+
it("should return true only if the overlap is within a threshold", () => {
|
|
393
|
+
const tr = new TimeRange(TimeStamp.milliseconds(0), TimeStamp.milliseconds(1000));
|
|
394
|
+
const one = new TimeRange(
|
|
395
|
+
TimeStamp.milliseconds(998),
|
|
396
|
+
TimeStamp.milliseconds(2000),
|
|
397
|
+
);
|
|
398
|
+
expect(tr.overlapsWith(one, TimeSpan.milliseconds(2))).toBeTruthy();
|
|
399
|
+
expect(one.overlapsWith(tr, TimeSpan.milliseconds(3))).toBeFalsy();
|
|
400
|
+
});
|
|
401
|
+
it("should return two for two ZERO time ranges", () => {
|
|
402
|
+
const tr = new TimeRange(TimeStamp.ZERO, TimeStamp.ZERO);
|
|
403
|
+
const one = new TimeRange(TimeStamp.ZERO, TimeStamp.ZERO);
|
|
404
|
+
expect(tr.overlapsWith(one)).toBeTruthy();
|
|
405
|
+
});
|
|
387
406
|
});
|
|
388
407
|
|
|
389
408
|
describe("boundBy", () => {
|
|
@@ -402,6 +421,26 @@ describe("TimeRange", () => {
|
|
|
402
421
|
expect(bounded.equals(expected)).toBeTruthy();
|
|
403
422
|
});
|
|
404
423
|
});
|
|
424
|
+
|
|
425
|
+
describe("roughlyEquals", () => {
|
|
426
|
+
it("should return true if the two time ranges are within the provided threshold", () => {
|
|
427
|
+
const tr = new TimeRange(TimeSpan.seconds(1), TimeSpan.seconds(4));
|
|
428
|
+
const one = new TimeRange(
|
|
429
|
+
TimeSpan.seconds(1),
|
|
430
|
+
TimeSpan.seconds(4).add(TimeSpan.milliseconds(500)),
|
|
431
|
+
);
|
|
432
|
+
expect(tr.roughlyEquals(one, TimeSpan.seconds(1))).toBeTruthy();
|
|
433
|
+
expect(tr.roughlyEquals(one, TimeSpan.seconds(0))).toBeFalsy();
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
test("toString", () => {
|
|
438
|
+
const ts = new TimeStamp(TimeSpan.days(2)).add(TimeSpan.minutes(20)).add(TimeSpan.milliseconds(283)).add(TimeSpan.microseconds(900))
|
|
439
|
+
const ts2 = new TimeStamp(TimeSpan.days(4)).add(TimeSpan.minutes(20)).add(TimeSpan.milliseconds(283)).add(TimeSpan.microseconds(900))
|
|
440
|
+
const tr = ts.range(ts2)
|
|
441
|
+
const trString = tr.toString()
|
|
442
|
+
expect(trString).toEqual("1970-01-03T00:20:00.283Z - 1970-01-05T00:20:00.283Z")
|
|
443
|
+
})
|
|
405
444
|
});
|
|
406
445
|
|
|
407
446
|
describe("DataType", () => {
|
|
@@ -419,6 +458,70 @@ describe("DataType", () => {
|
|
|
419
458
|
expect(DataType.STRING.isVariable).toBe(true);
|
|
420
459
|
});
|
|
421
460
|
});
|
|
461
|
+
|
|
462
|
+
describe("canSafelyCastTo", () => {
|
|
463
|
+
const TESTS: [DataType, DataType, boolean][] = [
|
|
464
|
+
[DataType.INT32, DataType.INT32, true],
|
|
465
|
+
[DataType.INT32, DataType.INT64, true],
|
|
466
|
+
[DataType.INT32, DataType.FLOAT32, false],
|
|
467
|
+
[DataType.INT32, DataType.FLOAT64, true],
|
|
468
|
+
[DataType.INT32, DataType.STRING, false],
|
|
469
|
+
[DataType.INT32, DataType.BOOLEAN, false],
|
|
470
|
+
[DataType.INT32, DataType.INT8, false],
|
|
471
|
+
[DataType.INT64, DataType.INT32, false],
|
|
472
|
+
[DataType.INT64, DataType.INT64, true],
|
|
473
|
+
[DataType.INT64, DataType.FLOAT32, false],
|
|
474
|
+
[DataType.INT64, DataType.FLOAT64, false],
|
|
475
|
+
[DataType.INT64, DataType.STRING, false],
|
|
476
|
+
[DataType.FLOAT64, DataType.FLOAT32, false],
|
|
477
|
+
[DataType.FLOAT64, DataType.FLOAT64, true],
|
|
478
|
+
[DataType.FLOAT64, DataType.STRING, false],
|
|
479
|
+
[DataType.FLOAT64, DataType.BOOLEAN, false],
|
|
480
|
+
[DataType.FLOAT32, DataType.FLOAT64, true],
|
|
481
|
+
[DataType.FLOAT32, DataType.FLOAT32, true],
|
|
482
|
+
[DataType.FLOAT32, DataType.STRING, false],
|
|
483
|
+
[DataType.FLOAT32, DataType.BOOLEAN, false],
|
|
484
|
+
[DataType.STRING, DataType.STRING, true],
|
|
485
|
+
[DataType.STRING, DataType.INT32, false],
|
|
486
|
+
[DataType.STRING, DataType.INT64, false],
|
|
487
|
+
[DataType.STRING, DataType.FLOAT32, false],
|
|
488
|
+
[DataType.STRING, DataType.FLOAT64, false],
|
|
489
|
+
[DataType.STRING, DataType.BOOLEAN, false],
|
|
490
|
+
[DataType.STRING, DataType.INT8, false],
|
|
491
|
+
[DataType.BOOLEAN, DataType.BOOLEAN, true],
|
|
492
|
+
[DataType.BOOLEAN, DataType.INT32, false],
|
|
493
|
+
[DataType.BOOLEAN, DataType.INT64, false],
|
|
494
|
+
[DataType.INT8, DataType.FLOAT32, true],
|
|
495
|
+
];
|
|
496
|
+
TESTS.forEach(([from, to, expected]) =>
|
|
497
|
+
it(`should return ${expected} when casting from ${from.toString()} to ${to.toString()}`, () => {
|
|
498
|
+
expect(from.canSafelyCastTo(to)).toBe(expected);
|
|
499
|
+
}),
|
|
500
|
+
);
|
|
501
|
+
});
|
|
502
|
+
describe("canCastTo", () => {
|
|
503
|
+
it("should return true for any two numeric data types", () => {
|
|
504
|
+
const numericTypes = [
|
|
505
|
+
DataType.INT32,
|
|
506
|
+
DataType.INT64,
|
|
507
|
+
DataType.FLOAT32,
|
|
508
|
+
DataType.FLOAT64,
|
|
509
|
+
];
|
|
510
|
+
for (const from of numericTypes) {
|
|
511
|
+
for (const to of numericTypes) {
|
|
512
|
+
expect(from.canCastTo(to)).toBe(true);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
it("should return true for non-numeric data types ONLY if they are equal", () => {
|
|
517
|
+
const nonNumericTypes = [DataType.STRING, DataType.BOOLEAN];
|
|
518
|
+
for (const from of nonNumericTypes) {
|
|
519
|
+
for (const to of nonNumericTypes) {
|
|
520
|
+
expect(from.canCastTo(to)).toBe(from === to);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
});
|
|
422
525
|
});
|
|
423
526
|
|
|
424
527
|
describe("Size", () => {
|
package/src/telem/telem.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -79,7 +79,7 @@ const remainder = <T extends TimeStamp | TimeSpan>(
|
|
|
79
79
|
*/
|
|
80
80
|
export class TimeStamp implements Stringer {
|
|
81
81
|
private readonly value: bigint;
|
|
82
|
-
readonly encodeValue
|
|
82
|
+
readonly encodeValue = true;
|
|
83
83
|
|
|
84
84
|
constructor(value?: CrudeTimeStamp, tzInfo: TZInfo = "UTC") {
|
|
85
85
|
if (value == null) this.value = TimeStamp.now().valueOf();
|
|
@@ -157,11 +157,11 @@ export class TimeStamp implements Stringer {
|
|
|
157
157
|
case "preciseTime":
|
|
158
158
|
return this.timeString(true, tzInfo);
|
|
159
159
|
case "date":
|
|
160
|
-
return this.dateString(
|
|
160
|
+
return this.dateString();
|
|
161
161
|
case "preciseDate":
|
|
162
|
-
return `${this.dateString(
|
|
162
|
+
return `${this.dateString()} ${this.timeString(true, tzInfo)}`;
|
|
163
163
|
case "dateTime":
|
|
164
|
-
return `${this.dateString(
|
|
164
|
+
return `${this.dateString()} ${this.timeString(false, tzInfo)}`;
|
|
165
165
|
default:
|
|
166
166
|
return this.toISOString(tzInfo);
|
|
167
167
|
}
|
|
@@ -177,7 +177,7 @@ export class TimeStamp implements Stringer {
|
|
|
177
177
|
return milliseconds ? iso.slice(11, 23) : iso.slice(11, 19);
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
private dateString(
|
|
180
|
+
private dateString(): string {
|
|
181
181
|
const date = this.date();
|
|
182
182
|
const month = date.toLocaleString("default", { month: "short" });
|
|
183
183
|
const day = date.toLocaleString("default", { day: "numeric" });
|
|
@@ -327,7 +327,7 @@ export class TimeStamp implements Stringer {
|
|
|
327
327
|
* @returns The number of milliseconds since the unix epoch.
|
|
328
328
|
*/
|
|
329
329
|
milliseconds(): number {
|
|
330
|
-
return Number(this.valueOf() / TimeStamp.MILLISECOND.valueOf());
|
|
330
|
+
return Number(this.valueOf()) / Number(TimeStamp.MILLISECOND.valueOf());
|
|
331
331
|
}
|
|
332
332
|
|
|
333
333
|
toString(): string {
|
|
@@ -463,7 +463,7 @@ export class TimeStamp implements Stringer {
|
|
|
463
463
|
/** TimeSpan represents a nanosecond precision duration. */
|
|
464
464
|
export class TimeSpan implements Stringer {
|
|
465
465
|
private readonly value: bigint;
|
|
466
|
-
readonly encodeValue
|
|
466
|
+
readonly encodeValue = true;
|
|
467
467
|
|
|
468
468
|
constructor(value: CrudeTimeSpan) {
|
|
469
469
|
if (typeof value === "number") value = Math.trunc(value.valueOf());
|
|
@@ -533,31 +533,31 @@ export class TimeSpan implements Stringer {
|
|
|
533
533
|
|
|
534
534
|
/** @returns the decimal number of days in the timespan */
|
|
535
535
|
get days(): number {
|
|
536
|
-
return Number(this.valueOf() / TimeSpan.DAY.valueOf());
|
|
536
|
+
return Number(this.valueOf()) / Number(TimeSpan.DAY.valueOf());
|
|
537
537
|
}
|
|
538
538
|
|
|
539
539
|
/** @returns the decimal number of hours in the timespan */
|
|
540
540
|
get hours(): number {
|
|
541
|
-
return Number(this.valueOf() / TimeSpan.HOUR.valueOf());
|
|
541
|
+
return Number(this.valueOf()) / Number(TimeSpan.HOUR.valueOf());
|
|
542
542
|
}
|
|
543
543
|
|
|
544
544
|
/** @returns the decimal number of minutes in the timespan */
|
|
545
545
|
get minutes(): number {
|
|
546
|
-
return Number(this.valueOf() / TimeSpan.MINUTE.valueOf());
|
|
546
|
+
return Number(this.valueOf()) / Number(TimeSpan.MINUTE.valueOf());
|
|
547
547
|
}
|
|
548
548
|
|
|
549
549
|
/** @returns The number of seconds in the TimeSpan. */
|
|
550
550
|
get seconds(): number {
|
|
551
|
-
return Number(this.valueOf() / TimeSpan.SECOND.valueOf());
|
|
551
|
+
return Number(this.valueOf()) / Number(TimeSpan.SECOND.valueOf());
|
|
552
552
|
}
|
|
553
553
|
|
|
554
554
|
/** @returns The number of milliseconds in the TimeSpan. */
|
|
555
555
|
get milliseconds(): number {
|
|
556
|
-
return Number(this.valueOf() / TimeSpan.MILLISECOND.valueOf());
|
|
556
|
+
return Number(this.valueOf()) / Number(TimeSpan.MILLISECOND.valueOf());
|
|
557
557
|
}
|
|
558
558
|
|
|
559
559
|
get microseconds(): number {
|
|
560
|
-
return Number(this.valueOf() / TimeSpan.MICROSECOND.valueOf());
|
|
560
|
+
return Number(this.valueOf()) / Number(TimeSpan.MICROSECOND.valueOf());
|
|
561
561
|
}
|
|
562
562
|
|
|
563
563
|
get nanoseconds(): number {
|
|
@@ -964,17 +964,35 @@ export class TimeRange implements Stringer {
|
|
|
964
964
|
* @param other - The other TimeRange to compare to.
|
|
965
965
|
* @returns True if the two TimeRanges overlap, false otherwise.
|
|
966
966
|
*/
|
|
967
|
-
overlapsWith(other: TimeRange): boolean {
|
|
967
|
+
overlapsWith(other: TimeRange, delta: TimeSpan = TimeSpan.ZERO): boolean {
|
|
968
968
|
other = other.makeValid();
|
|
969
969
|
const rng = this.makeValid();
|
|
970
|
-
|
|
971
|
-
if (
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
);
|
|
970
|
+
|
|
971
|
+
if (this.equals(other)) return true;
|
|
972
|
+
|
|
973
|
+
// If the ranges touch at their boundaries, they do not overlap.
|
|
974
|
+
if (other.end.equals(rng.start) || rng.end.equals(other.start)) return false;
|
|
975
|
+
|
|
976
|
+
// Determine the actual overlapping range
|
|
977
|
+
const startOverlap = TimeStamp.max(rng.start, other.start);
|
|
978
|
+
const endOverlap = TimeStamp.min(rng.end, other.end);
|
|
979
|
+
|
|
980
|
+
// If end of overlap is before start, then they don't overlap at all
|
|
981
|
+
if (endOverlap.before(startOverlap)) return false;
|
|
982
|
+
|
|
983
|
+
// Calculate the duration of the overlap
|
|
984
|
+
const overlapDuration = new TimeSpan(endOverlap.sub(startOverlap));
|
|
985
|
+
|
|
986
|
+
// Compare the overlap duration with delta
|
|
987
|
+
return overlapDuration.greaterThanOrEqual(delta);
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
roughlyEquals(other: TimeRange, delta: TimeSpan): boolean {
|
|
991
|
+
let startDist = this.start.sub(other.start).valueOf();
|
|
992
|
+
let endDist = this.end.sub(other.end).valueOf();
|
|
993
|
+
if (startDist < 0) startDist = -startDist;
|
|
994
|
+
if (endDist < 0) endDist = -endDist;
|
|
995
|
+
return startDist <= delta.valueOf() && endDist <= delta.valueOf();
|
|
978
996
|
}
|
|
979
997
|
|
|
980
998
|
contains(other: TimeRange): boolean;
|
|
@@ -1076,6 +1094,28 @@ export class DataType extends String implements Stringer {
|
|
|
1076
1094
|
return v;
|
|
1077
1095
|
}
|
|
1078
1096
|
|
|
1097
|
+
/** @returns true if the data type can be cast to the other data type without loss of precision. */
|
|
1098
|
+
canSafelyCastTo(other: DataType): boolean {
|
|
1099
|
+
if (this.equals(other)) return true;
|
|
1100
|
+
if (
|
|
1101
|
+
(this.isVariable && !other.isVariable) ||
|
|
1102
|
+
(!this.isVariable && other.isVariable)
|
|
1103
|
+
)
|
|
1104
|
+
return false;
|
|
1105
|
+
if ((this.isFloat && other.isInteger) || (this.isInteger && other.isFloat)) {
|
|
1106
|
+
return this.density.valueOf() < other.density.valueOf();
|
|
1107
|
+
}
|
|
1108
|
+
if ((this.isFloat && other.isFloat) || (this.isInteger && other.isInteger))
|
|
1109
|
+
return this.density.valueOf() <= other.density.valueOf();
|
|
1110
|
+
return false;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
/** @returns true if the data type can be cast to the other data type, even if there is a loss of precision. */
|
|
1114
|
+
canCastTo(other: DataType): boolean {
|
|
1115
|
+
if (this.isNumeric && other.isNumeric) return true;
|
|
1116
|
+
return this.equals(other);
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1079
1119
|
/**
|
|
1080
1120
|
* Checks whether the given TypedArray is of the same type as the DataType.
|
|
1081
1121
|
*
|
package/src/toArray.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -11,4 +11,4 @@ export const toArray = <T>(value: T | T[]): T[] =>
|
|
|
11
11
|
Array.isArray(value) ? value : [value];
|
|
12
12
|
|
|
13
13
|
export const nullToArr = <T>(value: T | T[] | null): T[] =>
|
|
14
|
-
Array.isArray(value) ? value : value === null ? [] : [value];
|
|
14
|
+
Array.isArray(value) ? value : value === null ? [] : [value];
|
package/src/transform.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -7,4 +7,11 @@
|
|
|
7
7
|
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
8
|
// included in the file licenses/APL.txt.
|
|
9
9
|
|
|
10
|
-
export
|
|
10
|
+
export interface ArrayTransformPayload<E = unknown> {
|
|
11
|
+
data: E[];
|
|
12
|
+
transformed: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type ArrayTransform<E = unknown, R = E> = (
|
|
16
|
+
data: ArrayTransformPayload<E>,
|
|
17
|
+
) => ArrayTransformPayload<R>;
|
package/src/unique.ts
CHANGED
package/src/url/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
8
|
// included in the file licenses/APL.txt.
|
|
9
9
|
|
|
10
|
-
export * from "
|
|
10
|
+
export * from "@/url/url";
|
package/src/url/url.spec.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -41,7 +41,7 @@ describe("URL", () => {
|
|
|
41
41
|
pathPrefix: "api",
|
|
42
42
|
});
|
|
43
43
|
expect(endpoint.child("test").replace({ protocol: "https" }).toString()).toEqual(
|
|
44
|
-
"https://localhost:8080/api/test"
|
|
44
|
+
"https://localhost:8080/api/test",
|
|
45
45
|
);
|
|
46
46
|
});
|
|
47
47
|
});
|
package/src/url/url.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -37,7 +37,7 @@ const removeTrailingSlash = (path: string): string =>
|
|
|
37
37
|
*/
|
|
38
38
|
export const buildQueryString = (
|
|
39
39
|
request: Record<string, unknown>,
|
|
40
|
-
prefix: string = ""
|
|
40
|
+
prefix: string = "",
|
|
41
41
|
): string => {
|
|
42
42
|
if (request === null) return "";
|
|
43
43
|
return (
|
|
@@ -48,7 +48,7 @@ export const buildQueryString = (
|
|
|
48
48
|
if (Array.isArray(value)) return value.length > 0;
|
|
49
49
|
return true;
|
|
50
50
|
})
|
|
51
|
-
|
|
51
|
+
|
|
52
52
|
.map(([key, value]) => `${prefix}${key}=${value}`)
|
|
53
53
|
.join("&")
|
|
54
54
|
);
|
|
@@ -105,7 +105,7 @@ export class URL {
|
|
|
105
105
|
/** @returns a string representation of the url */
|
|
106
106
|
toString(): string {
|
|
107
107
|
return removeTrailingSlash(
|
|
108
|
-
`${this.protocol}://${this.host}:${this.port}/${this.path}
|
|
108
|
+
`${this.protocol}://${this.host}:${this.port}/${this.path}`,
|
|
109
109
|
);
|
|
110
110
|
}
|
|
111
111
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
10
|
+
export * from "@/worker/worker";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import { describe, expect, it, vi } from "vitest";
|
|
11
11
|
|
|
12
|
-
import { createMockWorkers } from "
|
|
12
|
+
import { createMockWorkers } from "@/worker/worker";
|
|
13
13
|
|
|
14
14
|
interface MockMessage {
|
|
15
15
|
value: string;
|
package/src/worker/worker.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Use of this software is governed by the Business Source License included in the file
|
|
4
4
|
// licenses/BSL.txt.
|
|
@@ -19,15 +19,15 @@ export interface SenderHandler<I, O> extends Sender<I>, Handler<O> {}
|
|
|
19
19
|
|
|
20
20
|
interface TypedWorkerMessage {
|
|
21
21
|
type: string;
|
|
22
|
-
payload:
|
|
22
|
+
payload: unknown;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
type SendFunc = (value:
|
|
26
|
-
type HandlerFunc = (value:
|
|
25
|
+
type SendFunc = (value: unknown, transfer?: Transferable[]) => void;
|
|
26
|
+
type HandlerFunc = (value: unknown) => void;
|
|
27
27
|
|
|
28
28
|
export class RoutedWorker {
|
|
29
29
|
sender: SendFunc;
|
|
30
|
-
handlers: Map<string, TypedWorker<
|
|
30
|
+
handlers: Map<string, TypedWorker<unknown>>;
|
|
31
31
|
|
|
32
32
|
constructor(send: SendFunc) {
|
|
33
33
|
this.sender = send;
|
|
@@ -50,9 +50,8 @@ export class RoutedWorker {
|
|
|
50
50
|
|
|
51
51
|
const typedSend =
|
|
52
52
|
(type: string, send: SendFunc): SendFunc =>
|
|
53
|
-
(payload:
|
|
54
|
-
|
|
55
|
-
};
|
|
53
|
+
(payload: unknown, transfer?: Transferable[]) =>
|
|
54
|
+
send({ type, payload }, transfer);
|
|
56
55
|
|
|
57
56
|
export class TypedWorker<RQ, RS = RQ> implements SenderHandler<RQ, RS> {
|
|
58
57
|
private readonly _send: SendFunc;
|
|
@@ -68,19 +67,20 @@ export class TypedWorker<RQ, RS = RQ> implements SenderHandler<RQ, RS> {
|
|
|
68
67
|
}
|
|
69
68
|
|
|
70
69
|
handle(handler: (payload: RS) => void): void {
|
|
71
|
-
this.handler = handler;
|
|
70
|
+
this.handler = handler as HandlerFunc;
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
export const createMockWorkers = (): [RoutedWorker, RoutedWorker] => {
|
|
75
|
+
// eslint-disable-next-line
|
|
76
76
|
let a: RoutedWorker, b: RoutedWorker;
|
|
77
|
-
const aSend = (value:
|
|
77
|
+
const aSend = (value: TypedWorkerMessage): void => {
|
|
78
78
|
b.handle({ data: value });
|
|
79
79
|
};
|
|
80
|
-
const bSend = (value:
|
|
80
|
+
const bSend = (value: TypedWorkerMessage): void => {
|
|
81
81
|
a.handle({ data: value });
|
|
82
82
|
};
|
|
83
|
-
a = new RoutedWorker(aSend);
|
|
84
|
-
b = new RoutedWorker(bSend);
|
|
83
|
+
a = new RoutedWorker(aSend as SendFunc);
|
|
84
|
+
b = new RoutedWorker(bSend as SendFunc);
|
|
85
85
|
return [a, b];
|
|
86
86
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
10
|
+
export * as zodutil from "./zodutil";
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
10
|
+
import { describe, expect, it } from "vitest";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
|
|
13
|
+
import { zodutil } from "@/zodutil";
|
|
14
|
+
|
|
15
|
+
describe("zodutil", () => {
|
|
16
|
+
describe("getFieldShemaPath", () => {
|
|
17
|
+
interface Spec {
|
|
18
|
+
path: string;
|
|
19
|
+
expected: string;
|
|
20
|
+
}
|
|
21
|
+
const spec: Spec[] = [
|
|
22
|
+
{ path: "a.b.c", expected: "a.shape.b.shape.c" },
|
|
23
|
+
{ path: "a.0.c", expected: "a.element.shape.c" },
|
|
24
|
+
{ path: "a.0.1", expected: "a.element.element" },
|
|
25
|
+
{ path: "a.0.1.2", expected: "a.element.element.element" },
|
|
26
|
+
];
|
|
27
|
+
spec.forEach(({ path, expected }) => {
|
|
28
|
+
it(`should return ${expected} for ${path}`, () => {
|
|
29
|
+
expect(zodutil.getFieldSchemaPath(path)).toBe(expected);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
describe("getFieldSchema", () => {
|
|
34
|
+
const schema = z.object({
|
|
35
|
+
a: z.object({
|
|
36
|
+
b: z.object({
|
|
37
|
+
c: z.number(),
|
|
38
|
+
}),
|
|
39
|
+
}),
|
|
40
|
+
array: z.array(z.array(z.array(z.number()))),
|
|
41
|
+
arrayOfObjects: z.array(
|
|
42
|
+
z.object({
|
|
43
|
+
a: z.number(),
|
|
44
|
+
b: z.string(),
|
|
45
|
+
}),
|
|
46
|
+
),
|
|
47
|
+
});
|
|
48
|
+
interface Spec {
|
|
49
|
+
path: string;
|
|
50
|
+
}
|
|
51
|
+
// just assert not null
|
|
52
|
+
const spec: Spec[] = [
|
|
53
|
+
{ path: "a.b.c" },
|
|
54
|
+
{ path: "array.0.0.0" },
|
|
55
|
+
{ path: "arrayOfObjects.0.a" },
|
|
56
|
+
];
|
|
57
|
+
spec.forEach(({ path }) => {
|
|
58
|
+
it(`should return not null for ${path}`, () => {
|
|
59
|
+
schema.shape.arrayOfObjects.element.shape.a;
|
|
60
|
+
expect(zodutil.getFieldSchema(schema, path)).not.toBeNull();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
it("should return null for invalid path and allowNull is true", () => {
|
|
64
|
+
expect(zodutil.getFieldSchema(schema, "a.b.c.d", true)).toBeNull();
|
|
65
|
+
});
|
|
66
|
+
describe("with a refinement", () => {
|
|
67
|
+
const schema = z.object({
|
|
68
|
+
a: z
|
|
69
|
+
.object({
|
|
70
|
+
b: z.object({
|
|
71
|
+
c: z.number(),
|
|
72
|
+
}),
|
|
73
|
+
})
|
|
74
|
+
.refine(() => true),
|
|
75
|
+
});
|
|
76
|
+
it("should return not null for valid path", () => {
|
|
77
|
+
const v = zodutil.getFieldSchema(schema, "a.b.c");
|
|
78
|
+
expect(zodutil.getFieldSchema(schema, "a.b.c")).not.toBeNull();
|
|
79
|
+
expect(v).toBeInstanceOf(z.ZodNumber);
|
|
80
|
+
});
|
|
81
|
+
const veryComplexSchema = z.object({
|
|
82
|
+
a: z
|
|
83
|
+
.object({
|
|
84
|
+
array: z
|
|
85
|
+
.array(
|
|
86
|
+
z
|
|
87
|
+
.object({
|
|
88
|
+
c: z.number(),
|
|
89
|
+
})
|
|
90
|
+
.refine(() => true),
|
|
91
|
+
)
|
|
92
|
+
.refine(() => true),
|
|
93
|
+
})
|
|
94
|
+
.refine(() => true),
|
|
95
|
+
});
|
|
96
|
+
it("should return not null for valid path", () => {
|
|
97
|
+
const v = zodutil.getFieldSchema(veryComplexSchema, "a.array.0.c");
|
|
98
|
+
expect(v).not.toBeNull();
|
|
99
|
+
expect(v).toBeInstanceOf(z.ZodNumber);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
|
|
12
|
+
import { deep } from "@/deep";
|
|
13
|
+
import { UnknownRecord } from "@/record";
|
|
14
|
+
|
|
15
|
+
export const getFieldSchemaPath = (path: string): string =>
|
|
16
|
+
deep.transformPath(path, (part, index, parts) => {
|
|
17
|
+
const isLast = index === parts.length - 1;
|
|
18
|
+
const isNumericPart = !isNaN(parseInt(part));
|
|
19
|
+
const nextPartIsNumeric = !isNaN(parseInt(parts[index + 1]));
|
|
20
|
+
if (isNumericPart) part = "element";
|
|
21
|
+
if (isLast || nextPartIsNumeric) return part;
|
|
22
|
+
return [part, "shape"];
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const sourceTypeGetter = (obj: unknown, key: string): z.ZodAny | null => {
|
|
26
|
+
if (obj == null) return null;
|
|
27
|
+
const v = (obj as Record<string, z.ZodAny>)[key];
|
|
28
|
+
if (v == null && typeof obj === "object" && "sourceType" in obj) {
|
|
29
|
+
const sourceType = (obj as z.ZodEffects<z.ZodTypeAny>).sourceType();
|
|
30
|
+
return (sourceType as unknown as UnknownRecord)[key] as z.ZodAny | null;
|
|
31
|
+
}
|
|
32
|
+
return v;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const getFieldSchema: deep.TypedGet<z.ZodTypeAny, z.ZodTypeAny> = ((
|
|
36
|
+
schema: z.ZodTypeAny,
|
|
37
|
+
path: string,
|
|
38
|
+
allowNull?: boolean,
|
|
39
|
+
): z.ZodTypeAny | null =>
|
|
40
|
+
deep.get<z.ZodTypeAny, z.ZodTypeAny>(
|
|
41
|
+
sourceTypeGetter(schema, "shape") as unknown as z.AnyZodObject,
|
|
42
|
+
getFieldSchemaPath(path),
|
|
43
|
+
allowNull,
|
|
44
|
+
{ getter: sourceTypeGetter },
|
|
45
|
+
) as z.ZodTypeAny | null) as deep.TypedGet<z.ZodTypeAny, z.ZodTypeAny>;
|