datahike-browser-tests 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/.circleci/config.yml +405 -0
- package/.circleci/scripts/gen_ci.clj +194 -0
- package/.cirrus.yml +60 -0
- package/.clj-kondo/babashka/sci/config.edn +1 -0
- package/.clj-kondo/babashka/sci/sci/core.clj +9 -0
- package/.clj-kondo/config.edn +95 -0
- package/.dir-locals.el +2 -0
- package/.github/FUNDING.yml +3 -0
- package/.github/ISSUE_TEMPLATE/1-bug-report.yml +68 -0
- package/.github/ISSUE_TEMPLATE/2-feature-request.yml +28 -0
- package/.github/ISSUE_TEMPLATE/config.yml +6 -0
- package/.github/pull_request_template.md +24 -0
- package/.github/workflows/native-image.yml +84 -0
- package/LICENSE +203 -0
- package/README.md +273 -0
- package/bb/deps.edn +9 -0
- package/bb/resources/github-fingerprints +3 -0
- package/bb/resources/native-image-tests/run-bb-pod-tests.clj +162 -0
- package/bb/resources/native-image-tests/run-libdatahike-tests +12 -0
- package/bb/resources/native-image-tests/run-native-image-tests +74 -0
- package/bb/resources/native-image-tests/run-python-tests +22 -0
- package/bb/resources/native-image-tests/testconfig.attr-refs.edn +6 -0
- package/bb/resources/native-image-tests/testconfig.edn +5 -0
- package/bb/resources/template/.settings/org.eclipse.jdt.apt.core.prefs +2 -0
- package/bb/resources/template/.settings/org.eclipse.jdt.core.prefs +9 -0
- package/bb/resources/template/.settings/org.eclipse.m2e.core.prefs +4 -0
- package/bb/resources/template/pom.xml +22 -0
- package/bb/src/tools/build.clj +132 -0
- package/bb/src/tools/clj_kondo.clj +32 -0
- package/bb/src/tools/deploy.clj +26 -0
- package/bb/src/tools/examples.clj +19 -0
- package/bb/src/tools/npm.clj +100 -0
- package/bb/src/tools/python.clj +14 -0
- package/bb/src/tools/release.clj +94 -0
- package/bb/src/tools/test.clj +148 -0
- package/bb/src/tools/version.clj +47 -0
- package/bb.edn +269 -0
- package/benchmark/src/benchmark/cli.clj +195 -0
- package/benchmark/src/benchmark/compare.clj +157 -0
- package/benchmark/src/benchmark/config.clj +316 -0
- package/benchmark/src/benchmark/measure.clj +187 -0
- package/benchmark/src/benchmark/store.clj +190 -0
- package/benchmark/test/benchmark/measure_test.clj +156 -0
- package/build.clj +30 -0
- package/config.edn +49 -0
- package/deps.edn +138 -0
- package/dev/sandbox.clj +82 -0
- package/dev/sandbox.cljs +127 -0
- package/dev/sandbox_benchmarks.clj +27 -0
- package/dev/sandbox_client.clj +87 -0
- package/dev/sandbox_transact_bench.clj +109 -0
- package/dev/user.clj +79 -0
- package/doc/README.md +96 -0
- package/doc/adl/README.md +6 -0
- package/doc/adl/adr-000-adr.org +28 -0
- package/doc/adl/adr-001-attribute-references.org +15 -0
- package/doc/adl/adr-002-build-tooling.org +54 -0
- package/doc/adl/adr-003-db-meta-data.md +52 -0
- package/doc/adl/adr-004-github-flow.md +40 -0
- package/doc/adl/adr-XYZ-template.md +30 -0
- package/doc/adl/index.org +3 -0
- package/doc/assets/datahike-logo.svg +3 -0
- package/doc/assets/datahiking-invoice.org +85 -0
- package/doc/assets/hhtree2.png +0 -0
- package/doc/assets/network_topology.svg +624 -0
- package/doc/assets/perf.png +0 -0
- package/doc/assets/schema_mindmap.mm +132 -0
- package/doc/assets/schema_mindmap.svg +970 -0
- package/doc/assets/temporal_index.mm +74 -0
- package/doc/backend-development.md +78 -0
- package/doc/bb-pod.md +89 -0
- package/doc/benchmarking.md +360 -0
- package/doc/bindings/edn-conversion.md +383 -0
- package/doc/cli.md +162 -0
- package/doc/cljdoc.edn +27 -0
- package/doc/cljs-support.md +133 -0
- package/doc/config.md +406 -0
- package/doc/contributing.md +114 -0
- package/doc/datalog-vs-sql.md +210 -0
- package/doc/datomic_differences.md +109 -0
- package/doc/development/pull-api-ns.md +186 -0
- package/doc/development/pull-frame-state-diagram.jpg +0 -0
- package/doc/distributed.md +566 -0
- package/doc/entity_spec.md +92 -0
- package/doc/gc.md +273 -0
- package/doc/java-api.md +808 -0
- package/doc/javascript-api.md +421 -0
- package/doc/libdatahike.md +86 -0
- package/doc/logging_and_error_handling.md +43 -0
- package/doc/norms.md +66 -0
- package/doc/schema-migration.md +85 -0
- package/doc/schema.md +287 -0
- package/doc/storage-backends.md +363 -0
- package/doc/store-id-refactoring.md +596 -0
- package/doc/time_variance.md +325 -0
- package/doc/unstructured.md +167 -0
- package/doc/versioning.md +261 -0
- package/examples/basic/README.md +19 -0
- package/examples/basic/deps.edn +6 -0
- package/examples/basic/docker-compose.yml +13 -0
- package/examples/basic/src/examples/core.clj +60 -0
- package/examples/basic/src/examples/schema.clj +155 -0
- package/examples/basic/src/examples/store.clj +60 -0
- package/examples/basic/src/examples/time_travel.clj +185 -0
- package/examples/java/.settings/org.eclipse.core.resources.prefs +3 -0
- package/examples/java/.settings/org.eclipse.jdt.apt.core.prefs +2 -0
- package/examples/java/.settings/org.eclipse.jdt.core.prefs +9 -0
- package/examples/java/.settings/org.eclipse.m2e.core.prefs +4 -0
- package/examples/java/README.md +162 -0
- package/examples/java/pom.xml +62 -0
- package/examples/java/src/main/java/examples/QuickStart.java +115 -0
- package/examples/java/src/main/java/examples/SchemaExample.java +148 -0
- package/examples/java/src/main/java/examples/TimeTravelExample.java +121 -0
- package/flake.lock +27 -0
- package/flake.nix +27 -0
- package/http-server/datahike/http/middleware.clj +75 -0
- package/http-server/datahike/http/server.clj +269 -0
- package/java/src/datahike/java/Database.java +274 -0
- package/java/src/datahike/java/Datahike.java +281 -0
- package/java/src/datahike/java/DatahikeGeneratedTest.java +349 -0
- package/java/src/datahike/java/DatahikeTest.java +370 -0
- package/java/src/datahike/java/EDN.java +170 -0
- package/java/src/datahike/java/IEntity.java +11 -0
- package/java/src/datahike/java/Keywords.java +161 -0
- package/java/src/datahike/java/SchemaFlexibility.java +52 -0
- package/java/src/datahike/java/Util.java +219 -0
- package/karma.conf.js +19 -0
- package/libdatahike/compile-cpp +7 -0
- package/libdatahike/src/datahike/impl/LibDatahikeBase.java +203 -0
- package/libdatahike/src/datahike/impl/libdatahike.clj +59 -0
- package/libdatahike/src/test_cpp.cpp +61 -0
- package/npm-package/PUBLISHING.md +140 -0
- package/npm-package/README.md +226 -0
- package/npm-package/package.template.json +34 -0
- package/npm-package/test-isomorphic.ts +281 -0
- package/npm-package/test.js +557 -0
- package/npm-package/typescript-test.ts +70 -0
- package/package.json +16 -0
- package/pydatahike/README.md +569 -0
- package/pydatahike/pyproject.toml +91 -0
- package/pydatahike/setup.py +42 -0
- package/pydatahike/src/datahike/__init__.py +134 -0
- package/pydatahike/src/datahike/_native.py +250 -0
- package/pydatahike/src/datahike/_version.py +2 -0
- package/pydatahike/src/datahike/database.py +722 -0
- package/pydatahike/src/datahike/edn.py +311 -0
- package/pydatahike/src/datahike/py.typed +0 -0
- package/pydatahike/tests/conftest.py +17 -0
- package/pydatahike/tests/test_basic.py +170 -0
- package/pydatahike/tests/test_database.py +51 -0
- package/pydatahike/tests/test_edn_conversion.py +299 -0
- package/pydatahike/tests/test_query.py +99 -0
- package/pydatahike/tests/test_schema.py +55 -0
- package/resources/clj-kondo.exports/io.replikativ/datahike/config.edn +5 -0
- package/resources/example_server.edn +4 -0
- package/shadow-cljs.edn +56 -0
- package/src/data_readers.clj +7 -0
- package/src/datahike/api/impl.cljc +176 -0
- package/src/datahike/api/specification.cljc +633 -0
- package/src/datahike/api/types.cljc +261 -0
- package/src/datahike/api.cljc +41 -0
- package/src/datahike/array.cljc +99 -0
- package/src/datahike/cli.clj +166 -0
- package/src/datahike/cljs.cljs +6 -0
- package/src/datahike/codegen/cli.clj +406 -0
- package/src/datahike/codegen/clj_kondo.clj +291 -0
- package/src/datahike/codegen/java.clj +403 -0
- package/src/datahike/codegen/naming.cljc +33 -0
- package/src/datahike/codegen/native.clj +559 -0
- package/src/datahike/codegen/pod.clj +488 -0
- package/src/datahike/codegen/python.clj +838 -0
- package/src/datahike/codegen/report.clj +55 -0
- package/src/datahike/codegen/typescript.clj +262 -0
- package/src/datahike/codegen/validation.clj +145 -0
- package/src/datahike/config.cljc +294 -0
- package/src/datahike/connections.cljc +16 -0
- package/src/datahike/connector.cljc +265 -0
- package/src/datahike/constants.cljc +142 -0
- package/src/datahike/core.cljc +297 -0
- package/src/datahike/datom.cljc +459 -0
- package/src/datahike/db/interface.cljc +119 -0
- package/src/datahike/db/search.cljc +305 -0
- package/src/datahike/db/transaction.cljc +937 -0
- package/src/datahike/db/utils.cljc +338 -0
- package/src/datahike/db.cljc +956 -0
- package/src/datahike/experimental/unstructured.cljc +126 -0
- package/src/datahike/experimental/versioning.cljc +172 -0
- package/src/datahike/externs.js +31 -0
- package/src/datahike/gc.cljc +69 -0
- package/src/datahike/http/client.clj +188 -0
- package/src/datahike/http/writer.clj +79 -0
- package/src/datahike/impl/entity.cljc +218 -0
- package/src/datahike/index/interface.cljc +93 -0
- package/src/datahike/index/persistent_set.cljc +469 -0
- package/src/datahike/index/utils.cljc +44 -0
- package/src/datahike/index.cljc +32 -0
- package/src/datahike/js/api.cljs +172 -0
- package/src/datahike/js/api_macros.clj +22 -0
- package/src/datahike/js.cljs +163 -0
- package/src/datahike/json.cljc +209 -0
- package/src/datahike/lru.cljc +146 -0
- package/src/datahike/migrate.clj +39 -0
- package/src/datahike/norm/norm.clj +245 -0
- package/src/datahike/online_gc.cljc +252 -0
- package/src/datahike/pod.clj +155 -0
- package/src/datahike/pull_api.cljc +325 -0
- package/src/datahike/query.cljc +1945 -0
- package/src/datahike/query_stats.cljc +88 -0
- package/src/datahike/readers.cljc +62 -0
- package/src/datahike/remote.cljc +218 -0
- package/src/datahike/schema.cljc +228 -0
- package/src/datahike/schema_cache.cljc +42 -0
- package/src/datahike/spec.cljc +101 -0
- package/src/datahike/store.cljc +80 -0
- package/src/datahike/tools.cljc +308 -0
- package/src/datahike/transit.cljc +80 -0
- package/src/datahike/writer.cljc +239 -0
- package/src/datahike/writing.cljc +362 -0
- package/src/deps.cljs +1 -0
- package/src-hitchhiker-tree/datahike/index/hitchhiker_tree/insert.cljc +76 -0
- package/src-hitchhiker-tree/datahike/index/hitchhiker_tree/upsert.cljc +128 -0
- package/src-hitchhiker-tree/datahike/index/hitchhiker_tree.cljc +213 -0
- package/test/datahike/backward_compatibility_test/src/backward_test.clj +37 -0
- package/test/datahike/integration_test/config_record_file_test.clj +14 -0
- package/test/datahike/integration_test/config_record_test.clj +14 -0
- package/test/datahike/integration_test/depr_config_uri_test.clj +15 -0
- package/test/datahike/integration_test/return_map_test.clj +62 -0
- package/test/datahike/integration_test.cljc +67 -0
- package/test/datahike/norm/norm_test.clj +124 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/001-a1-example.edn +5 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/002-a2-example.edn +5 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/003-tx-fn-test.edn +1 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/004-tx-data-and-tx-fn-test.edn +5 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/01-transact-basic-characters.edn +2 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/02 add occupation.edn +5 -0
- package/test/datahike/norm/resources/naming-and-sorting-test/checksums.edn +12 -0
- package/test/datahike/norm/resources/simple-test/001-a1-example.edn +5 -0
- package/test/datahike/norm/resources/simple-test/002-a2-example.edn +5 -0
- package/test/datahike/norm/resources/simple-test/checksums.edn +4 -0
- package/test/datahike/norm/resources/tx-data-and-tx-fn-test/first/001-a1-example.edn +5 -0
- package/test/datahike/norm/resources/tx-data-and-tx-fn-test/first/002-a2-example.edn +5 -0
- package/test/datahike/norm/resources/tx-data-and-tx-fn-test/first/003-tx-fn-test.edn +1 -0
- package/test/datahike/norm/resources/tx-data-and-tx-fn-test/first/checksums.edn +6 -0
- package/test/datahike/norm/resources/tx-data-and-tx-fn-test/second/004-tx-data-and-tx-fn-test.edn +5 -0
- package/test/datahike/norm/resources/tx-data-and-tx-fn-test/second/checksums.edn +2 -0
- package/test/datahike/norm/resources/tx-fn-test/first/001-a1-example.edn +5 -0
- package/test/datahike/norm/resources/tx-fn-test/first/002-a2-example.edn +5 -0
- package/test/datahike/norm/resources/tx-fn-test/first/checksums.edn +4 -0
- package/test/datahike/norm/resources/tx-fn-test/second/003-tx-fn-test.edn +1 -0
- package/test/datahike/norm/resources/tx-fn-test/second/checksums.edn +2 -0
- package/test/datahike/test/api_test.cljc +895 -0
- package/test/datahike/test/array_test.cljc +40 -0
- package/test/datahike/test/attribute_refs/datoms_test.cljc +140 -0
- package/test/datahike/test/attribute_refs/db_test.cljc +42 -0
- package/test/datahike/test/attribute_refs/differences_test.cljc +515 -0
- package/test/datahike/test/attribute_refs/entity_test.cljc +89 -0
- package/test/datahike/test/attribute_refs/pull_api_test.cljc +320 -0
- package/test/datahike/test/attribute_refs/query_find_specs_test.cljc +59 -0
- package/test/datahike/test/attribute_refs/query_fns_test.cljc +130 -0
- package/test/datahike/test/attribute_refs/query_interop_test.cljc +47 -0
- package/test/datahike/test/attribute_refs/query_not_test.cljc +193 -0
- package/test/datahike/test/attribute_refs/query_or_test.cljc +137 -0
- package/test/datahike/test/attribute_refs/query_pull_test.cljc +156 -0
- package/test/datahike/test/attribute_refs/query_rules_test.cljc +176 -0
- package/test/datahike/test/attribute_refs/query_test.cljc +241 -0
- package/test/datahike/test/attribute_refs/temporal_search.cljc +22 -0
- package/test/datahike/test/attribute_refs/transact_test.cljc +220 -0
- package/test/datahike/test/attribute_refs/utils.cljc +128 -0
- package/test/datahike/test/cache_test.cljc +38 -0
- package/test/datahike/test/components_test.cljc +92 -0
- package/test/datahike/test/config_test.cljc +158 -0
- package/test/datahike/test/core_test.cljc +105 -0
- package/test/datahike/test/datom_test.cljc +44 -0
- package/test/datahike/test/db_test.cljc +54 -0
- package/test/datahike/test/entity_spec_test.cljc +159 -0
- package/test/datahike/test/entity_test.cljc +103 -0
- package/test/datahike/test/explode_test.cljc +143 -0
- package/test/datahike/test/filter_test.cljc +75 -0
- package/test/datahike/test/gc_test.cljc +159 -0
- package/test/datahike/test/http/server_test.clj +192 -0
- package/test/datahike/test/http/writer_test.clj +86 -0
- package/test/datahike/test/ident_test.cljc +32 -0
- package/test/datahike/test/index_test.cljc +345 -0
- package/test/datahike/test/insert.cljc +125 -0
- package/test/datahike/test/java_bindings_test.clj +6 -0
- package/test/datahike/test/listen_test.cljc +41 -0
- package/test/datahike/test/lookup_refs_test.cljc +266 -0
- package/test/datahike/test/lru_test.cljc +27 -0
- package/test/datahike/test/migrate_test.clj +297 -0
- package/test/datahike/test/model/core.cljc +376 -0
- package/test/datahike/test/model/invariant.cljc +142 -0
- package/test/datahike/test/model/rng.cljc +82 -0
- package/test/datahike/test/model_test.clj +217 -0
- package/test/datahike/test/nodejs_test.cljs +262 -0
- package/test/datahike/test/online_gc_test.cljc +475 -0
- package/test/datahike/test/pod_test.clj +369 -0
- package/test/datahike/test/pull_api_test.cljc +474 -0
- package/test/datahike/test/purge_test.cljc +144 -0
- package/test/datahike/test/query_aggregates_test.cljc +101 -0
- package/test/datahike/test/query_find_specs_test.cljc +52 -0
- package/test/datahike/test/query_fns_test.cljc +523 -0
- package/test/datahike/test/query_interop_test.cljc +47 -0
- package/test/datahike/test/query_not_test.cljc +189 -0
- package/test/datahike/test/query_or_test.cljc +158 -0
- package/test/datahike/test/query_pull_test.cljc +147 -0
- package/test/datahike/test/query_rules_test.cljc +248 -0
- package/test/datahike/test/query_stats_test.cljc +218 -0
- package/test/datahike/test/query_test.cljc +984 -0
- package/test/datahike/test/schema_test.cljc +424 -0
- package/test/datahike/test/specification_test.cljc +30 -0
- package/test/datahike/test/store_test.cljc +78 -0
- package/test/datahike/test/stress_test.cljc +57 -0
- package/test/datahike/test/time_variance_test.cljc +518 -0
- package/test/datahike/test/tools_test.clj +134 -0
- package/test/datahike/test/transact_test.cljc +518 -0
- package/test/datahike/test/tuples_test.cljc +564 -0
- package/test/datahike/test/unstructured_test.cljc +291 -0
- package/test/datahike/test/upsert_impl_test.cljc +205 -0
- package/test/datahike/test/upsert_test.cljc +363 -0
- package/test/datahike/test/utils.cljc +110 -0
- package/test/datahike/test/validation_test.cljc +48 -0
- package/test/datahike/test/versioning_test.cljc +56 -0
- package/test/datahike/test.cljc +66 -0
- package/tests.edn +24 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
(ns datahike.codegen.report
|
|
2
|
+
"Generate coverage reports for all code generation bindings."
|
|
3
|
+
(:require [datahike.api.specification :refer [api-specification]]
|
|
4
|
+
[datahike.codegen.validation :as validation]
|
|
5
|
+
[datahike.codegen.native :refer [native-operations native-excluded-operations]]
|
|
6
|
+
[datahike.codegen.python :refer [python-operations python-excluded-operations]]
|
|
7
|
+
[datahike.codegen.naming :refer [js-skip-list]]
|
|
8
|
+
[datahike.codegen.cli :refer [cli-excluded-operations]]))
|
|
9
|
+
|
|
10
|
+
(defn generate-report
|
|
11
|
+
"Generate and print coverage report for all bindings."
|
|
12
|
+
[]
|
|
13
|
+
(let [;; Validate each binding
|
|
14
|
+
java-result {:binding "Java"
|
|
15
|
+
:total (count api-specification)
|
|
16
|
+
:implemented (count api-specification)
|
|
17
|
+
:excluded 0
|
|
18
|
+
:missing 0
|
|
19
|
+
:missing-ops []
|
|
20
|
+
:coverage-pct 100}
|
|
21
|
+
|
|
22
|
+
;; TypeScript - all ops except js-skip-list
|
|
23
|
+
typescript-ops (into {} (remove #(contains? js-skip-list (first %)) api-specification))
|
|
24
|
+
typescript-excluded (zipmap js-skip-list (repeat "ClojureScript incompatible"))
|
|
25
|
+
typescript-result (validation/validate-coverage
|
|
26
|
+
"TypeScript"
|
|
27
|
+
typescript-ops
|
|
28
|
+
typescript-excluded)
|
|
29
|
+
|
|
30
|
+
;; CLI - all ops except cli-excluded-operations
|
|
31
|
+
cli-ops (into {} (remove #(contains? cli-excluded-operations (first %)) api-specification))
|
|
32
|
+
cli-result (validation/validate-coverage
|
|
33
|
+
"CLI"
|
|
34
|
+
cli-ops
|
|
35
|
+
cli-excluded-operations)
|
|
36
|
+
|
|
37
|
+
native-result (validation/validate-coverage
|
|
38
|
+
"Native"
|
|
39
|
+
native-operations
|
|
40
|
+
native-excluded-operations)
|
|
41
|
+
|
|
42
|
+
python-result (validation/validate-coverage
|
|
43
|
+
"Python"
|
|
44
|
+
python-operations
|
|
45
|
+
python-excluded-operations)
|
|
46
|
+
|
|
47
|
+
all-results [java-result typescript-result cli-result native-result python-result]]
|
|
48
|
+
|
|
49
|
+
;; Print report
|
|
50
|
+
(validation/print-coverage-report all-results)))
|
|
51
|
+
|
|
52
|
+
(defn -main
|
|
53
|
+
"Generate and print coverage report."
|
|
54
|
+
[& _args]
|
|
55
|
+
(generate-report))
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
(ns datahike.codegen.typescript
|
|
2
|
+
"Generate TypeScript type definitions from api.specification.
|
|
3
|
+
|
|
4
|
+
This namespace provides tooling to generate .d.ts files that:
|
|
5
|
+
- Map malli schemas to TypeScript types
|
|
6
|
+
- Provide proper Promise<T> types for async operations
|
|
7
|
+
- Include JSDoc comments with full documentation
|
|
8
|
+
- Support IDE autocompletion and type checking"
|
|
9
|
+
(:require [datahike.api.specification :refer [api-specification malli-schema->argslist]]
|
|
10
|
+
[datahike.api.types :as types]
|
|
11
|
+
[datahike.codegen.naming :refer [js-skip-list clj-name->js-name]]
|
|
12
|
+
[clojure.string :as str]))
|
|
13
|
+
|
|
14
|
+
;; =============================================================================
|
|
15
|
+
;; Malli -> TypeScript Type Mapping
|
|
16
|
+
;; =============================================================================
|
|
17
|
+
|
|
18
|
+
(defn malli->ts-type
|
|
19
|
+
"Convert a malli schema to a TypeScript type string."
|
|
20
|
+
[schema]
|
|
21
|
+
(cond
|
|
22
|
+
;; Keyword schemas (primitives)
|
|
23
|
+
(keyword? schema)
|
|
24
|
+
(case schema
|
|
25
|
+
:boolean "boolean"
|
|
26
|
+
:string "string"
|
|
27
|
+
:int "number"
|
|
28
|
+
:long "number"
|
|
29
|
+
:double "number"
|
|
30
|
+
:number "number"
|
|
31
|
+
:keyword "string"
|
|
32
|
+
:symbol "string"
|
|
33
|
+
:any "any"
|
|
34
|
+
:nil "null"
|
|
35
|
+
:map "object"
|
|
36
|
+
:vector "Array<any>"
|
|
37
|
+
:sequential "Array<any>"
|
|
38
|
+
:set "Set<any>"
|
|
39
|
+
"any")
|
|
40
|
+
|
|
41
|
+
;; Symbols (type references)
|
|
42
|
+
(symbol? schema)
|
|
43
|
+
(let [schema-name (name schema)]
|
|
44
|
+
(cond
|
|
45
|
+
;; types/SConfig → DatabaseConfig
|
|
46
|
+
(str/starts-with? schema-name "types/")
|
|
47
|
+
(get types/malli->typescript-type
|
|
48
|
+
(keyword (subs schema-name 6))
|
|
49
|
+
"any")
|
|
50
|
+
|
|
51
|
+
;; Direct type names
|
|
52
|
+
:else
|
|
53
|
+
(get types/malli->typescript-type
|
|
54
|
+
(keyword schema-name)
|
|
55
|
+
"any")))
|
|
56
|
+
|
|
57
|
+
;; Vector schemas
|
|
58
|
+
(vector? schema)
|
|
59
|
+
(let [[op & args] schema]
|
|
60
|
+
(case op
|
|
61
|
+
;; [:or Type1 Type2] → Type1 | Type2
|
|
62
|
+
:or
|
|
63
|
+
(str/join " | " (map malli->ts-type args))
|
|
64
|
+
|
|
65
|
+
;; [:maybe Type] → Type | null
|
|
66
|
+
:maybe
|
|
67
|
+
(str (malli->ts-type (first args)) " | null")
|
|
68
|
+
|
|
69
|
+
;; [:sequential Type] → Array<Type>
|
|
70
|
+
:sequential
|
|
71
|
+
(str "Array<" (malli->ts-type (first args)) ">")
|
|
72
|
+
|
|
73
|
+
;; [:vector Type] → Array<Type>
|
|
74
|
+
:vector
|
|
75
|
+
(str "Array<" (malli->ts-type (first args)) ">")
|
|
76
|
+
|
|
77
|
+
;; [:map ...] → object
|
|
78
|
+
:map
|
|
79
|
+
"object"
|
|
80
|
+
|
|
81
|
+
;; [:function ...] or [:=> ...] - extract return type
|
|
82
|
+
(:function :=>)
|
|
83
|
+
"any"
|
|
84
|
+
|
|
85
|
+
;; [:cat ...] - tuple, represent as array for now
|
|
86
|
+
:cat
|
|
87
|
+
"Array<any>"
|
|
88
|
+
|
|
89
|
+
;; [:alt ...] - union
|
|
90
|
+
:alt
|
|
91
|
+
"any"
|
|
92
|
+
|
|
93
|
+
;; [:* Type] - rest params
|
|
94
|
+
:*
|
|
95
|
+
(str "..." (malli->ts-type (first args)) "[]")
|
|
96
|
+
|
|
97
|
+
;; [:enum ...] - union of literals
|
|
98
|
+
:enum
|
|
99
|
+
(str/join " | " (map #(str "'" % "'") args))
|
|
100
|
+
|
|
101
|
+
;; [:fn ...] - function type
|
|
102
|
+
:fn
|
|
103
|
+
"Function"
|
|
104
|
+
|
|
105
|
+
;; Default
|
|
106
|
+
"any"))
|
|
107
|
+
|
|
108
|
+
;; Default
|
|
109
|
+
:else "any"))
|
|
110
|
+
|
|
111
|
+
(defn extract-params-from-malli
|
|
112
|
+
"Extract parameter information from malli function schema.
|
|
113
|
+
Returns vector of maps with :name, :type, and :optional keys."
|
|
114
|
+
[args-schema]
|
|
115
|
+
(cond
|
|
116
|
+
;; [:=> [:cat Type1 Type2] Return]
|
|
117
|
+
(and (vector? args-schema) (= :=> (first args-schema)))
|
|
118
|
+
(let [[_ input-schema _] args-schema]
|
|
119
|
+
(when (and (vector? input-schema) (= :cat (first input-schema)))
|
|
120
|
+
(vec
|
|
121
|
+
(map-indexed
|
|
122
|
+
(fn [idx type-schema]
|
|
123
|
+
{:name (str "arg" idx)
|
|
124
|
+
:type (malli->ts-type type-schema)
|
|
125
|
+
:optional false})
|
|
126
|
+
(rest input-schema)))))
|
|
127
|
+
|
|
128
|
+
;; [:function [:=> ...] [:=> ...]] - multi-arity, use first
|
|
129
|
+
(and (vector? args-schema) (= :function (first args-schema)))
|
|
130
|
+
(let [first-arity (second args-schema)]
|
|
131
|
+
(extract-params-from-malli first-arity))
|
|
132
|
+
|
|
133
|
+
;; Default
|
|
134
|
+
:else []))
|
|
135
|
+
|
|
136
|
+
(defn generate-function-signature
|
|
137
|
+
"Generate TypeScript function signature from specification entry."
|
|
138
|
+
[[fn-name {:keys [args ret doc]}]]
|
|
139
|
+
(let [ts-name (clj-name->js-name fn-name)
|
|
140
|
+
params (extract-params-from-malli args)
|
|
141
|
+
params-str (str/join ", "
|
|
142
|
+
(map (fn [{:keys [name type optional]}]
|
|
143
|
+
(str name (if optional "?" "") ": " type))
|
|
144
|
+
params))
|
|
145
|
+
return-type (malli->ts-type ret)
|
|
146
|
+
;; Wrap in Promise for async operations
|
|
147
|
+
final-return (str "Promise<" return-type ">")]
|
|
148
|
+
{:name ts-name
|
|
149
|
+
:signature (str "export function " ts-name "(" params-str "): " final-return ";")
|
|
150
|
+
:doc doc}))
|
|
151
|
+
|
|
152
|
+
(defn generate-jsdoc
|
|
153
|
+
"Generate JSDoc comment from docstring and examples."
|
|
154
|
+
[doc examples]
|
|
155
|
+
(when doc
|
|
156
|
+
(let [;; Extract first sentence for summary
|
|
157
|
+
summary (first (str/split doc #"\.\s"))
|
|
158
|
+
;; Add examples if available
|
|
159
|
+
example-text (when (seq examples)
|
|
160
|
+
(str "\n *\n * Examples:\n"
|
|
161
|
+
(str/join "\n"
|
|
162
|
+
(map (fn [{:keys [desc code]}]
|
|
163
|
+
(str " * - " desc "\n"
|
|
164
|
+
" * " code))
|
|
165
|
+
(take 2 examples)))))]
|
|
166
|
+
(str "/**\n * " summary "."
|
|
167
|
+
example-text
|
|
168
|
+
"\n */"))))
|
|
169
|
+
|
|
170
|
+
(defn generate-type-definitions
|
|
171
|
+
"Generate complete TypeScript type definitions from api-specification."
|
|
172
|
+
[]
|
|
173
|
+
(let [header "// Auto-generated TypeScript definitions for Datahike JavaScript API
|
|
174
|
+
// DO NOT EDIT - Generated from datahike.api.specification
|
|
175
|
+
|
|
176
|
+
"
|
|
177
|
+
;; Core type definitions
|
|
178
|
+
types "
|
|
179
|
+
// Core Datahike Types
|
|
180
|
+
|
|
181
|
+
export interface DatabaseConfig {
|
|
182
|
+
store: {
|
|
183
|
+
backend: string;
|
|
184
|
+
id?: string;
|
|
185
|
+
path?: string;
|
|
186
|
+
[key: string]: any;
|
|
187
|
+
};
|
|
188
|
+
'keep-history'?: boolean;
|
|
189
|
+
'schema-flexibility'?: 'read' | 'write';
|
|
190
|
+
'initial-tx'?: Transaction[];
|
|
191
|
+
name?: string;
|
|
192
|
+
[key: string]: any;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export interface Connection {
|
|
196
|
+
[key: string]: any;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export interface Database {
|
|
200
|
+
[key: string]: any;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export type Transaction =
|
|
204
|
+
| [':db/add', number | string, string, any]
|
|
205
|
+
| [':db/retract', number | string, string, any]
|
|
206
|
+
| { [key: string]: any };
|
|
207
|
+
|
|
208
|
+
export interface TransactionReport {
|
|
209
|
+
'db-before': Database;
|
|
210
|
+
'db-after': Database;
|
|
211
|
+
'tx-data': Datom[];
|
|
212
|
+
tempids: { [key: string]: number };
|
|
213
|
+
'tx-meta'?: any;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export interface Datom {
|
|
217
|
+
e: number;
|
|
218
|
+
a: string;
|
|
219
|
+
v: any;
|
|
220
|
+
tx: number;
|
|
221
|
+
added: boolean;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export interface Schema {
|
|
225
|
+
[key: string]: {
|
|
226
|
+
'db/valueType': string;
|
|
227
|
+
'db/cardinality': string;
|
|
228
|
+
'db/unique'?: string;
|
|
229
|
+
'db/index'?: boolean;
|
|
230
|
+
[key: string]: any;
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export interface Metrics {
|
|
235
|
+
[key: string]: any;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
"
|
|
239
|
+
;; Generate function signatures
|
|
240
|
+
functions (str/join "\n\n"
|
|
241
|
+
(for [entry (sort-by first api-specification)
|
|
242
|
+
:when (not (contains? js-skip-list (first entry)))
|
|
243
|
+
:let [[fn-name spec-data] entry
|
|
244
|
+
{:keys [name signature doc]} (generate-function-signature entry)
|
|
245
|
+
jsdoc (generate-jsdoc doc (:examples spec-data))]]
|
|
246
|
+
(str jsdoc "\n" signature)))]
|
|
247
|
+
(str header types "\n// API Functions\n\n" functions "\n")))
|
|
248
|
+
|
|
249
|
+
(defn write-type-definitions!
|
|
250
|
+
"Write TypeScript definitions to a file."
|
|
251
|
+
([]
|
|
252
|
+
(write-type-definitions! "npm-package/index.d.ts"))
|
|
253
|
+
([output-path]
|
|
254
|
+
(spit output-path (generate-type-definitions))
|
|
255
|
+
(println "TypeScript definitions written to:" output-path)))
|
|
256
|
+
|
|
257
|
+
(comment
|
|
258
|
+
;; Generate types
|
|
259
|
+
(println (generate-type-definitions))
|
|
260
|
+
|
|
261
|
+
;; Write to file
|
|
262
|
+
(write-type-definitions!))
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
(ns datahike.codegen.validation
|
|
2
|
+
"Validation utilities for code generation coverage.
|
|
3
|
+
|
|
4
|
+
Ensures all API operations are either implemented or explicitly excluded
|
|
5
|
+
across all language bindings."
|
|
6
|
+
(:require [datahike.api.specification :refer [api-specification]]
|
|
7
|
+
[clojure.string :as str]
|
|
8
|
+
[clojure.set :as set]))
|
|
9
|
+
|
|
10
|
+
;; =============================================================================
|
|
11
|
+
;; Coverage Validation
|
|
12
|
+
;; =============================================================================
|
|
13
|
+
|
|
14
|
+
(defn validate-coverage
|
|
15
|
+
"Validate that all operations are either implemented or excluded.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
binding-name - String name for display (e.g., 'Native', 'Python')
|
|
19
|
+
operations - Map of implemented operations
|
|
20
|
+
excluded - Map or set of excluded operations
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
Map with :missing, :implemented, :excluded, :total"
|
|
24
|
+
[binding-name operations excluded]
|
|
25
|
+
(let [all-ops (set (keys api-specification))
|
|
26
|
+
implemented (set (keys operations))
|
|
27
|
+
;; Handle both maps (with reasons) and sets (just symbols)
|
|
28
|
+
excluded-ops (if (map? excluded)
|
|
29
|
+
(set (keys excluded))
|
|
30
|
+
(set excluded))
|
|
31
|
+
missing (set/difference all-ops implemented excluded-ops)
|
|
32
|
+
total (count all-ops)
|
|
33
|
+
impl-count (count implemented)
|
|
34
|
+
excl-count (count excluded-ops)
|
|
35
|
+
miss-count (count missing)]
|
|
36
|
+
|
|
37
|
+
;; Print warnings for missing operations
|
|
38
|
+
(when (seq missing)
|
|
39
|
+
(println (str "\n⚠️ WARNING: " binding-name " bindings missing operations:"))
|
|
40
|
+
(doseq [op (sort missing)]
|
|
41
|
+
(println (str " - " op)))
|
|
42
|
+
(println (str "\n Either add to " (str/lower-case binding-name) "-operations"
|
|
43
|
+
" or " (str/lower-case binding-name) "-excluded-operations\n")))
|
|
44
|
+
|
|
45
|
+
{:binding binding-name
|
|
46
|
+
:total total
|
|
47
|
+
:implemented impl-count
|
|
48
|
+
:excluded excl-count
|
|
49
|
+
:missing miss-count
|
|
50
|
+
:missing-ops (sort missing)
|
|
51
|
+
:coverage-pct (int (* 100 (/ (+ impl-count excl-count) total)))}))
|
|
52
|
+
|
|
53
|
+
;; =============================================================================
|
|
54
|
+
;; Coverage Reporting
|
|
55
|
+
;; =============================================================================
|
|
56
|
+
|
|
57
|
+
(defn print-coverage-line
|
|
58
|
+
"Print a single line of the coverage table."
|
|
59
|
+
[{:keys [binding total implemented excluded missing coverage-pct]}]
|
|
60
|
+
(let [status (if (zero? missing) "✅" "⚠️ ")
|
|
61
|
+
impl-excl (if (zero? excluded)
|
|
62
|
+
(format "%2d" implemented)
|
|
63
|
+
(format "%2d+%d" implemented excluded))
|
|
64
|
+
coverage-str (format "%3d%%" coverage-pct)]
|
|
65
|
+
(printf "%-12s %s/%2d (%s) %s%s\n"
|
|
66
|
+
(str binding ":")
|
|
67
|
+
impl-excl
|
|
68
|
+
total
|
|
69
|
+
coverage-str
|
|
70
|
+
status
|
|
71
|
+
(if (zero? excluded)
|
|
72
|
+
""
|
|
73
|
+
(format " (%d excluded)" excluded)))))
|
|
74
|
+
|
|
75
|
+
(defn print-coverage-report
|
|
76
|
+
"Print coverage report for all bindings.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
results - Sequence of validation results from validate-coverage"
|
|
80
|
+
[results]
|
|
81
|
+
(println "\nCode Generation Coverage Report")
|
|
82
|
+
(println "================================\n")
|
|
83
|
+
(printf "Total operations in api-specification: %d\n\n"
|
|
84
|
+
(:total (first results)))
|
|
85
|
+
|
|
86
|
+
(doseq [result (sort-by :binding results)]
|
|
87
|
+
(print-coverage-line result))
|
|
88
|
+
|
|
89
|
+
;; Print missing operations detail
|
|
90
|
+
(let [missing-any (filter #(pos? (:missing %)) results)]
|
|
91
|
+
(when (seq missing-any)
|
|
92
|
+
(println "\nMissing Operations:")
|
|
93
|
+
(doseq [{:keys [binding missing-ops]} missing-any]
|
|
94
|
+
(println (str "\n" binding ":"))
|
|
95
|
+
(doseq [op missing-ops]
|
|
96
|
+
(println (str " - " op))))))
|
|
97
|
+
|
|
98
|
+
(println))
|
|
99
|
+
|
|
100
|
+
(defn validate-exclusion-reasons
|
|
101
|
+
"Validate that all exclusions have documented reasons.
|
|
102
|
+
|
|
103
|
+
Args:
|
|
104
|
+
binding-name - String name for display
|
|
105
|
+
excluded - Map of excluded operations to reason strings, or set (skips validation)
|
|
106
|
+
|
|
107
|
+
Returns true if all have reasons (or is a set), prints warnings otherwise"
|
|
108
|
+
[binding-name excluded]
|
|
109
|
+
;; Skip validation for sets (they don't have reasons)
|
|
110
|
+
(if-not (map? excluded)
|
|
111
|
+
true
|
|
112
|
+
(let [missing-reasons (filter (fn [[_ reason]]
|
|
113
|
+
(or (nil? reason)
|
|
114
|
+
(str/blank? reason)))
|
|
115
|
+
excluded)]
|
|
116
|
+
(when (seq missing-reasons)
|
|
117
|
+
(println (str "\n⚠️ WARNING: " binding-name " exclusions missing reasons:"))
|
|
118
|
+
(doseq [[op _] missing-reasons]
|
|
119
|
+
(println (str " - " op)))
|
|
120
|
+
(println))
|
|
121
|
+
(empty? missing-reasons))))
|
|
122
|
+
|
|
123
|
+
;; =============================================================================
|
|
124
|
+
;; Overlay Validation
|
|
125
|
+
;; =============================================================================
|
|
126
|
+
|
|
127
|
+
(defn validate-overlay-completeness
|
|
128
|
+
"Validate that overlay provides required config for each operation.
|
|
129
|
+
|
|
130
|
+
Args:
|
|
131
|
+
binding-name - String name for display
|
|
132
|
+
operations - Map of operation overlays
|
|
133
|
+
required-keys - Vector of required keys in overlay (e.g., [:pattern :java-call])
|
|
134
|
+
|
|
135
|
+
Prints warnings for incomplete overlays"
|
|
136
|
+
[binding-name operations required-keys]
|
|
137
|
+
(let [incomplete (filter (fn [[op-name config]]
|
|
138
|
+
(not-every? #(contains? config %) required-keys))
|
|
139
|
+
operations)]
|
|
140
|
+
(when (seq incomplete)
|
|
141
|
+
(println (str "\n⚠️ WARNING: " binding-name " incomplete overlay configs:"))
|
|
142
|
+
(doseq [[op-name config] incomplete]
|
|
143
|
+
(let [missing (filter #(not (contains? config %)) required-keys)]
|
|
144
|
+
(println (str " - " op-name ": missing " (str/join ", " missing)))))
|
|
145
|
+
(println))))
|