Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/db #66

Open
wants to merge 6,072 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
6072 commits
Select commit Hold shift + click to select a range
0eb7666
enhance(plugin): persist updates state for the web plugin
xyhp915 Jan 2, 2025
a30c2ca
fix: update deadline to be type of :datetime
tiensonqin Jan 2, 2025
3d42cf7
fix: bump nbb-logseq so that nbb scripts
logseq-cldwalker Jan 2, 2025
b7723db
fix: importer importing some pages as both Tag and Page
logseq-cldwalker Jan 2, 2025
bc9aa08
fix: case sensitive tag creation broken by previous commit
logseq-cldwalker Jan 2, 2025
ff01282
Merge branch 'feat/db' into enhance/plugin-web
xyhp915 Jan 3, 2025
6ef1b84
enhance(plugins): load web plugins asynchronously
xyhp915 Jan 3, 2025
dd17560
refactor: add clojure.string to :consistent-alias in kondo-config
RCmerci Jan 3, 2025
b65a2d5
refactor: consistent alias of clojure.string
RCmerci Jan 3, 2025
28cfdf6
feat: add profiler(dev) rightside-tab (#11668)
RCmerci Jan 3, 2025
df41e8b
fix: file content being overwritten when running db migration
tiensonqin Jan 3, 2025
9b282d6
Merge branch 'feat/db' into enhance/plugin-web
tiensonqin Jan 3, 2025
28ae59d
Merge pull request #11664 from logseq/enhance/plugin-web
tiensonqin Jan 3, 2025
f802941
enhance: backup notice when the graph hasn't been updated
tiensonqin Jan 3, 2025
e1c9641
perf: refactor frontend.db.react/remove-query-component!
RCmerci Jan 3, 2025
d7e7924
fix(plugin): missing scripts
xyhp915 Jan 3, 2025
59d31c9
Merge branch 'feat/db' of https://github.com/logseq/logseq into feat/db
xyhp915 Jan 3, 2025
d9d9d26
fix: tweak file-block schema for migrations
logseq-cldwalker Jan 3, 2025
17ee522
fix: date label
tiensonqin Jan 3, 2025
01b40b4
enhance: show Tag and Property classes in page header
logseq-cldwalker Jan 3, 2025
2c8aaed
fix: don't allow deletion of built-in class objects or property
logseq-cldwalker Jan 3, 2025
d1748a1
fix: deleting built-in blocks from queries
logseq-cldwalker Jan 3, 2025
0b87c36
chore: remove unused deps from common
logseq-cldwalker Jan 3, 2025
96c1cc5
fix: unstable deadline tests for exporter
logseq-cldwalker Jan 3, 2025
4a0f279
fix: date time from different timezones
tiensonqin Jan 4, 2025
f7e150b
enhance(plugin): add web flag for the marketplace plugin
xyhp915 Jan 4, 2025
1bba10c
fix: graph counts after validation are wrong
logseq-cldwalker Jan 4, 2025
7101a59
fix(plugin): incorrect file path for the plugin dots settings
xyhp915 Jan 4, 2025
b24ad28
feat: time tracking (#11666)
tiensonqin Jan 5, 2025
8a0a051
refactor: remove :block/format for db graphs (#11667)
tiensonqin Jan 5, 2025
c6a222e
enhance: set font-normal for time spent
tiensonqin Jan 5, 2025
caa9d4c
chore(dev): react key warnings
xyhp915 Jan 5, 2025
9b75112
wip: replace :block/schema with corresponding properties
tiensonqin Jan 6, 2025
f28d344
fix(apis): create page for journals
xyhp915 Jan 6, 2025
87e01f1
enhance(apis): add types
xyhp915 Jan 6, 2025
25adb80
enhance(plugin): app proxy call
xyhp915 Jan 6, 2025
d504ba3
chore(libs): bump version
xyhp915 Jan 6, 2025
89f5229
handle more :block/schema cases
tiensonqin Jan 6, 2025
d7cfe41
fix: transact bootstrap properties first
tiensonqin Jan 6, 2025
c15a43b
fix: hidden pages
tiensonqin Jan 6, 2025
a45da56
fix: pprint/pprint not always work for validate errors
tiensonqin Jan 6, 2025
883293a
fix: prefer db/id instead of entity for use-effect deps
tiensonqin Jan 6, 2025
60d2d46
fix: can't change checked or unchecked choice to another one
logseq-cldwalker Jan 6, 2025
7c0e5b5
fix: Don't mention 'task' for repeating properties that have nothing …
logseq-cldwalker Jan 6, 2025
5c27b47
fix: wrong :block/title data
tiensonqin Jan 7, 2025
9b86f07
fix: don't re-create contents page when migrating db
tiensonqin Jan 7, 2025
800e30c
fix: remove duplicated contents page
tiensonqin Jan 7, 2025
f7f3963
fix: file-sync dialog when switching graphs
tiensonqin Jan 7, 2025
c1f9368
enhance(plugin): load plugin from web url for debug
xyhp915 Jan 7, 2025
890a06f
enhance(plugin): install plugin from web url
xyhp915 Jan 7, 2025
2750250
chore(libs): build libs core
xyhp915 Jan 7, 2025
e522c73
fix: Task doesn't repeat with a user :date property
tiensonqin Jan 7, 2025
6be1d0c
fix lint
RCmerci Jan 7, 2025
e9a5235
chore: use gfun/debounce as util/debounce
tiensonqin Jan 7, 2025
fd0bc93
refactor: make react hooks compatible with cljs builtin types
RCmerci Jan 7, 2025
5d8f176
refactor: replace rum/use-memo
RCmerci Jan 7, 2025
172261f
refactor: replace rum/use-layout-effect!
RCmerci Jan 7, 2025
693fa3a
refactor: add use-debounced-value hook
RCmerci Jan 7, 2025
6176d5d
refactor: replace rum/use-callback
RCmerci Jan 7, 2025
2248e5e
chore: fix lint
RCmerci Jan 7, 2025
051cada
refactor: add memo-deps to wrap hook-deps
RCmerci Jan 7, 2025
cdbe7b2
fix: forget to add scheduled to #Task
tiensonqin Jan 7, 2025
6518fd9
Merge pull request #11674 from logseq/refactor/custom-react-hooks
RCmerci Jan 7, 2025
a91d1d9
fix: db test
logseq-cldwalker Jan 7, 2025
671bc93
fix: describe table header which confused me and another user
logseq-cldwalker Jan 7, 2025
9050b88
fix: node level property config mixed with property-level config
logseq-cldwalker Jan 7, 2025
5ac24ab
fix: property history schema not specifying used properties
logseq-cldwalker Jan 7, 2025
cf4de2f
chore: update lint to check for two very common db namespaces
logseq-cldwalker Jan 7, 2025
c6f3eb6
fix: history/scalar-value schema
logseq-cldwalker Jan 7, 2025
8e2f0c9
fix: property history still exists when property is deleted
logseq-cldwalker Jan 7, 2025
b2a3559
chore: add block/format to file linter
logseq-cldwalker Jan 7, 2025
cadb002
fix: exporter :datetime tests failing locally
logseq-cldwalker Jan 7, 2025
1110e81
chore(dev): remove debug
xyhp915 Jan 8, 2025
d0cd4c2
enhance(plugin): auto updates for web plugins
xyhp915 Jan 8, 2025
6105476
refactor: replace all rum/use-effect!, add kondo :discouraged-var config
RCmerci Jan 8, 2025
73e51a8
refactor: split rtc malli-schema into its own ns
RCmerci Jan 8, 2025
e7bb904
chore(libs): build libs core
xyhp915 Jan 8, 2025
f5ffcf1
chore: update docstring of defkeyword
RCmerci Jan 8, 2025
7b9ae93
enhance: add logseq.common.defkeywords
RCmerci Jan 8, 2025
8470da1
enhance: defkeywords all built-in-properties
RCmerci Jan 8, 2025
9092481
fix: common lints
logseq-cldwalker Jan 8, 2025
b44d644
fix: deps tests failing to run due to missing var
logseq-cldwalker Jan 8, 2025
0db34bc
fix: debug check failing importer
logseq-cldwalker Jan 8, 2025
e8659d6
fix: remove unused check in class?
logseq-cldwalker Jan 8, 2025
4a245b5
fix: opening new page in sidebar and clicking first block
logseq-cldwalker Jan 8, 2025
e0b5dac
fix: can't create page with tag from cmd-k
logseq-cldwalker Jan 8, 2025
e83cb0f
enhance(apis): empty page name crash for the push state
xyhp915 Jan 9, 2025
72c09e5
enhance(libs): types
xyhp915 Jan 9, 2025
99998e2
enhance(libs): utils apis
xyhp915 Jan 9, 2025
9db946c
enhance: apply defkeywords to built-in classes, add some rtc related …
RCmerci Jan 9, 2025
3a43a81
enhance(rtc): client-ops generator ignore attrs if possible
RCmerci Jan 9, 2025
0fa7da9
fix(rtc): fix export-as-blocks when ignore-attr-set not nil
RCmerci Jan 9, 2025
68f758c
fix: invalid data
tiensonqin Jan 9, 2025
6971475
fix: importer fails to find classes with property-parent-classes option
logseq-cldwalker Jan 9, 2025
b8c569f
fix: importer failing and invalid on two page to class conversion cases
logseq-cldwalker Jan 10, 2025
72b736a
enhance(rtc): don't generate update-op if only :block/updated-at changed
RCmerci Jan 10, 2025
7e9edac
dev: parse-long redefine warning when compile test
RCmerci Jan 10, 2025
1c5761e
enhance(rtc): ignore entities if possible when init upload/download
RCmerci Jan 10, 2025
ccefc2b
fix(apis): missing exports
xyhp915 Jan 10, 2025
b113967
enhance(dev): cli validation includes dispatch key
logseq-cldwalker Jan 10, 2025
18f2bd6
fix: validator incorrectly identifying hidden blocks
logseq-cldwalker Jan 10, 2025
1adeaa3
fix: migrate command throwing 'Unserializable return value' error
logseq-cldwalker Jan 10, 2025
25d1243
chore: update docstrings in kv-entity
logseq-cldwalker Jan 10, 2025
5ccb11a
fix(regression): Can't distinguish between page and class properties
logseq-cldwalker Jan 10, 2025
2782eea
enhance(dev): CLI import prints last tx
logseq-cldwalker Jan 10, 2025
0cffd64
fix: importer failing hard on page ref when
logseq-cldwalker Jan 10, 2025
4d0fbe1
fix(pdf): incorrect styles for the external window pdf viewer
xyhp915 Jan 11, 2025
9764646
enhance: profiler now support multi-arity & variadic fns
RCmerci Jan 12, 2025
f485eee
enhance: add prop :logseq.property/created-by
RCmerci Jan 12, 2025
e318e0d
Merge branch 'feat/db' into refactor/block-schema
tiensonqin Jan 12, 2025
639ca09
Remove more usage of :block/schema
tiensonqin Jan 12, 2025
18d4afa
fix: profile multi-arity fns
RCmerci Jan 12, 2025
93a7034
Remove more cases of :block/schema
tiensonqin Jan 13, 2025
1535816
Rename position to ui-position
tiensonqin Jan 13, 2025
b9b38ce
fix: db graph test
tiensonqin Jan 13, 2025
369ef99
fix: outliner tests
tiensonqin Jan 13, 2025
509456f
fix: query dsl
tiensonqin Jan 13, 2025
ba9b84c
fix(e2e): plugin apis related tests
xyhp915 Jan 13, 2025
2c04eb7
fix: db tests
tiensonqin Jan 13, 2025
d8984a0
fix: graph-parser tests
tiensonqin Jan 13, 2025
61a895f
fix: tests
tiensonqin Jan 13, 2025
c6f7f08
fix: delete existing db for db-graph-test
tiensonqin Jan 13, 2025
6f44b66
fix: outliner tests
tiensonqin Jan 13, 2025
911d456
fix: tests
tiensonqin Jan 13, 2025
c90ab6c
fix(e2e): properties related apis
xyhp915 Jan 13, 2025
1ab6210
enhance: importer displays one notification about ignored files
logseq-cldwalker Jan 13, 2025
86807f5
fix: frontend lint
logseq-cldwalker Jan 13, 2025
63eaacd
enhance(dev): import cli and tests print original error's ex-data
logseq-cldwalker Jan 13, 2025
c87da72
enhance: allow a tag to be converted back to a page
logseq-cldwalker Jan 13, 2025
b3d6744
enhance(ui): broken line for the datetime label
xyhp915 Jan 14, 2025
8d778aa
enhance(api): upsert/get property entity with caller key from the plu…
xyhp915 Jan 14, 2025
685e825
chore: remove prn
RCmerci Jan 14, 2025
9d7e164
add migration
tiensonqin Jan 14, 2025
2e12918
Merge branch 'feat/db' into refactor/block-schema
tiensonqin Jan 14, 2025
2b55e0d
chore: disable schema fix
tiensonqin Jan 14, 2025
0ac4b77
fix: react key warning
tiensonqin Jan 14, 2025
c4e8fa1
fix: react key warning
tiensonqin Jan 14, 2025
3e025dd
enhance: add created-by prop to blocks
RCmerci Jan 14, 2025
22fcaa2
chore: update docstring
RCmerci Jan 14, 2025
7f17532
fix: react key warning
tiensonqin Jan 14, 2025
0b7c9b4
chore(dev): patch console error for React
xyhp915 Jan 14, 2025
ac3b643
chore(dev): react key warnings
xyhp915 Jan 14, 2025
868f066
enhance: use :property/hide? for hidden pages instead of public?
tiensonqin Jan 14, 2025
d7590fd
fix: schema validation for hidden pages
tiensonqin Jan 14, 2025
f05cb55
Merge branch 'feat/db' into refactor/block-schema
tiensonqin Jan 14, 2025
f28c698
fix: tests
tiensonqin Jan 14, 2025
9224df5
enhance(apis): add remove property & types
xyhp915 Jan 14, 2025
03592a2
chore: typo
xyhp915 Jan 14, 2025
2a4f49e
enhance: importer can import :logseq.task/scheduled
logseq-cldwalker Jan 14, 2025
04aa88b
fix: importer fails when misconfigure journal ref is a property value
logseq-cldwalker Jan 14, 2025
d14c439
chore: update comment
RCmerci Jan 14, 2025
a7e9d07
chore: rename :property/* to :logseq.property/*
tiensonqin Jan 15, 2025
029a3e0
enhance(apis): property prefix for the block property key
xyhp915 Jan 15, 2025
1d9fbc8
perf: reduce :block/properties calls on db graphs
tiensonqin Jan 15, 2025
bd96226
fix: lint
tiensonqin Jan 15, 2025
ab6abef
fix(apis): sanitize property key from the plugin id
xyhp915 Jan 15, 2025
c1ae8f6
fix: duplicated key
tiensonqin Jan 15, 2025
20fad17
Merge branch 'feat/db' into refactor/block-schema
tiensonqin Jan 15, 2025
59054c4
fix: tests
tiensonqin Jan 15, 2025
c26b350
chore: remove bak
tiensonqin Jan 15, 2025
50bf71a
fix: tests
tiensonqin Jan 15, 2025
a2609f4
enhance: Allow built-in properties to use most properties
logseq-cldwalker Jan 15, 2025
769e68a
enhance(dev): add :dispatch-key to validate-db! errors
logseq-cldwalker Jan 15, 2025
cd4d675
fix(e2e-tests): api related tests
xyhp915 Jan 16, 2025
e61f046
fix: publishing failing to load on undefined LSPluginCore
logseq-cldwalker Jan 16, 2025
27a8ec6
fix: publishing failing to load
logseq-cldwalker Jan 16, 2025
fb5dbaa
fix(regression): multiple ways to edit property config when published
logseq-cldwalker Jan 16, 2025
7e89dd3
fix: don't initialize rtc components in publishing
logseq-cldwalker Jan 16, 2025
961f6ec
fix: tests and incorrect schema property detection after rename
logseq-cldwalker Jan 16, 2025
68896c2
Merge branch 'feat/db' into refactor/block-schema
logseq-cldwalker Jan 16, 2025
5c52cac
fix: init properties after merge
logseq-cldwalker Jan 16, 2025
a15a9e1
enhance(plugin): install plugin from Github releases for development …
xyhp915 Jan 17, 2025
7cda45e
fix: migration
tiensonqin Jan 17, 2025
fdfcc4f
fix: public publishing pages missing tags, properties
logseq-cldwalker Jan 17, 2025
bec095e
fix(regression): properties and classes collapsed on publishing
logseq-cldwalker Jan 17, 2025
3a62177
chore: rename public property to publishing-public?
logseq-cldwalker Jan 17, 2025
0181a33
Merge branch 'feat/db' into refactor/block-schema
logseq-cldwalker Jan 17, 2025
53ed226
fix: bootstrapping of properties
logseq-cldwalker Jan 18, 2025
21ff539
enhance(plugin): install plugin from Github releases for development …
xyhp915 Jan 18, 2025
4349023
fix(plugin): node file creation for the specific plugin settings
xyhp915 Jan 19, 2025
c953fb7
enhance(ui): dom attributes warning
xyhp915 Jan 20, 2025
eed3d76
fix: migrating empty graph has one invalid property
logseq-cldwalker Jan 20, 2025
69f5818
fix: delete existing graph for properties script
logseq-cldwalker Jan 20, 2025
bcd1d33
fix(regression): can't edit property name from config
logseq-cldwalker Jan 20, 2025
bb1f200
fix(regression): changing property cardinality dropped :db/valueType
logseq-cldwalker Jan 20, 2025
7b2d5ce
fix: changing property type or cardinality
logseq-cldwalker Jan 20, 2025
fab1de6
fix(regression): changing a property type
logseq-cldwalker Jan 20, 2025
878f0f8
fix: logseq.property/value isn't a schema property
logseq-cldwalker Jan 21, 2025
9ca0ca1
chore: cleanup schema mapping spread across the app
logseq-cldwalker Jan 21, 2025
5cdc35b
chore: mv 2 helper fns that are only used in one ns
logseq-cldwalker Jan 21, 2025
455ccec
chore: rename sqlite.build edn to remove mention
logseq-cldwalker Jan 21, 2025
5e558e9
fix(dev): debug edn of schema graph had duplicated data in :block/pro…
logseq-cldwalker Jan 21, 2025
4af5095
fix: convert tag to page was possible on built-ins
logseq-cldwalker Jan 22, 2025
2131112
fix: `Show as checkbox` config showing up
logseq-cldwalker Jan 22, 2025
ddf921f
fix: mention 'task' on scheduled property
logseq-cldwalker Jan 22, 2025
2e846f7
Merge branch 'feat/db' into refactor/block-schema
logseq-cldwalker Jan 22, 2025
a1f29cc
Merge pull request #11673 from logseq/refactor/block-schema
logseq-cldwalker Jan 22, 2025
88d74cb
fix: importing namespaced tags with spaces
logseq-cldwalker Jan 23, 2025
44fa4c0
chore: add docs for dev import tasks
logseq-cldwalker Jan 23, 2025
6c58af2
enhance(dev): importing cli debug option prints all tx
logseq-cldwalker Jan 23, 2025
6170ba1
chore: disable test since its unused per rcmerci
logseq-cldwalker Jan 23, 2025
926d05c
feat: table columns pinning (#11693)
tiensonqin Jan 24, 2025
423a4b0
feat: views support multiple columns sort (#11694)
tiensonqin Jan 24, 2025
c8c0e24
fix: don't add Task tag when status is used by another class
logseq-cldwalker Jan 24, 2025
a9d8591
fix: task simple query doesn't recognize default value
logseq-cldwalker Jan 24, 2025
3bad903
enhance(ux): add global app not found page
xyhp915 Jan 25, 2025
0dc45cb
fix: regression on query builder
tiensonqin Jan 26, 2025
3f9aa71
enhance: /scheduled and /deadline to create task
tiensonqin Jan 26, 2025
2cfc3f0
fix: sqlite.build should use :block/updated-at if passed in a block o…
logseq-cldwalker Jan 27, 2025
9b223be
enhance(dev): add util for logseq class idents
logseq-cldwalker Jan 27, 2025
57b4376
enhance(dev): test helper returns entity
logseq-cldwalker Jan 27, 2025
63184bc
fix: lint and test broken by previous commit
logseq-cldwalker Jan 27, 2025
ef93609
enhance(dev): build EDN supports logseq idents for :build/tags
logseq-cldwalker Jan 27, 2025
dbd1fae
fix: lint
logseq-cldwalker Jan 27, 2025
05496a0
fix: deprecate old srs config options
logseq-cldwalker Jan 28, 2025
5983bd0
enhance: update sqlite.build EDN to generate tx
logseq-cldwalker Jan 28, 2025
8550b48
enhance(dev): add test helper for ent properties
logseq-cldwalker Jan 28, 2025
fd99c0a
chore: use test helper instead of copied
logseq-cldwalker Jan 28, 2025
085872e
enhance: dev commands for exporting and importing
logseq-cldwalker Jan 29, 2025
77a6470
enhance: Allow commands to marked as :db-graph?
logseq-cldwalker Jan 29, 2025
574becd
enhance: import a block with properties across graphs
logseq-cldwalker Jan 29, 2025
b8ad82e
chore: add kondo aliases for db.sqlite namespaces
logseq-cldwalker Jan 29, 2025
3853fc5
fix: invalid data
tiensonqin Jan 30, 2025
bd4af68
enhance: can export+import classes across graphs
logseq-cldwalker Jan 30, 2025
ddf4dc0
enhance: export+import closed values across graphs
logseq-cldwalker Jan 30, 2025
002edb1
fix: sqlite.build auto-create new pages
logseq-cldwalker Jan 30, 2025
02f893f
enhance: better error handling when importing data
logseq-cldwalker Jan 31, 2025
a88c04f
fix: build-existing-tx? didn't differentiate
logseq-cldwalker Jan 31, 2025
44cf521
enhance: initial support for export+import of current page
logseq-cldwalker Feb 1, 2025
43c6633
enhance: page import works for existing pages
logseq-cldwalker Feb 3, 2025
469f77e
enhance: page export exports blocks at any level
logseq-cldwalker Feb 3, 2025
fbf7107
enhance: only build property export
logseq-cldwalker Feb 3, 2025
f66f310
fix: imported page not showing up
logseq-cldwalker Feb 3, 2025
d91b509
fix: import textarea not scrolling
logseq-cldwalker Feb 3, 2025
d06d582
enhance: can import :date properties
logseq-cldwalker Feb 3, 2025
c4fee6b
chore: remove deprecated [:page "FOO"]
logseq-cldwalker Feb 4, 2025
379752d
fix: tests broken by previous commit
logseq-cldwalker Feb 4, 2025
c925daa
enhance: export/import :node properties with classes
logseq-cldwalker Feb 4, 2025
a746a4d
enhance: import/export :node properties with block
logseq-cldwalker Feb 4, 2025
f02687b
fix: task query for "In Review" status
logseq-cldwalker Feb 5, 2025
ca011c9
enhance: add command to export/import graph's ontology
logseq-cldwalker Feb 5, 2025
38aff83
fix: export+import of blocks with built-in property closed values
logseq-cldwalker Feb 5, 2025
6848f98
fix: query builder not working for multi-word task values
logseq-cldwalker Feb 5, 2025
5faffdc
enhance: page export includes its properties and tags
logseq-cldwalker Feb 5, 2025
09ddf31
enhance(ux): force hide table header action popup for the pointer out…
xyhp915 Feb 6, 2025
b54d13b
enhance: sqlite.build EDN supports uuid refs
logseq-cldwalker Feb 6, 2025
02beff3
enhance: export+import page handles most ref types in blocks
logseq-cldwalker Feb 6, 2025
fcdfe51
enhance: export+export refs to classes
logseq-cldwalker Feb 7, 2025
3101640
chore: cleanup export tests
logseq-cldwalker Feb 7, 2025
8bc9b73
enhance: page export+import journal refs
logseq-cldwalker Feb 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
enhance: import a block with properties across graphs
Add test to confirm multiple imports are idempotent.
Also fix sqlite.build not handling valid value for :db/cardinality
  • Loading branch information
logseq-cldwalker committed Jan 29, 2025
commit 574becd8bb32d8d858b7709010076ba87cec2528
19 changes: 11 additions & 8 deletions deps/db/src/logseq/db/sqlite/build.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,18 @@
true
(into additional-tx))))

(defn- build-properties-tx [properties page-uuids all-idents]
(let [property-db-ids (->> (keys properties)
(defn- build-properties-tx [properties page-uuids all-idents {:keys [build-existing-tx?]}]
(let [properties' (if build-existing-tx?
(->> properties
(remove #(:block/uuid (val %)))
(into {}))
properties)
property-db-ids (->> (keys properties')
(map #(vector % (new-db-id)))
(into {}))
new-properties-tx (vec
(mapcat (partial build-property-tx properties page-uuids all-idents property-db-ids)
properties))]
(mapcat (partial build-property-tx properties' page-uuids all-idents property-db-ids)
properties'))]
new-properties-tx))

(defn- build-classes-tx [classes properties-config uuid-maps all-idents]
Expand Down Expand Up @@ -555,15 +560,13 @@
{:classes classes' :properties properties'}))

(defn- build-blocks-tx*
[{:keys [pages-and-blocks properties graph-namespace auto-create-ontology? build-existing-tx?]
[{:keys [pages-and-blocks properties graph-namespace auto-create-ontology?]
:as options}]
(let [pages-and-blocks' (pre-build-pages-and-blocks pages-and-blocks properties)
page-uuids (create-page-uuids pages-and-blocks')
{:keys [classes properties]} (if auto-create-ontology? (auto-create-ontology options) options)
all-idents (create-all-idents properties classes graph-namespace)
properties-tx (if (and build-existing-tx? (every? qualified-keyword? (keys properties)))
[]
(build-properties-tx properties page-uuids all-idents))
properties-tx (build-properties-tx properties page-uuids all-idents options)
classes-tx (build-classes-tx classes properties page-uuids all-idents)
class-ident->id (->> classes-tx (map (juxt :db/ident :db/id)) (into {}))
;; Replace idents with db-ids to avoid any upsert issues
Expand Down
44 changes: 33 additions & 11 deletions deps/db/src/logseq/db/sqlite/export.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
[logseq.db.sqlite.build :as sqlite-build]))

(defn build-entity-export
"Given entity id, build an EDN map"
"Given entity id, build an EDN export map"
[db eid]
(let [entity (d/entity db eid)
properties (dissoc (:block/properties entity) :block/tags)
properties (dissoc (db-property/properties entity) :block/tags)
user-defined-properties (remove db-property/logseq-property? (keys properties))
result (cond-> (select-keys entity [:block/title])
(seq (:block/tags entity))
(assoc :build/tags
Expand All @@ -29,16 +30,37 @@
:else
v)]))
(into {}))))]
result))
(cond-> {:build/block result}
(seq user-defined-properties)
(assoc :properties
(->> user-defined-properties
(map (fn [ident]
[ident (select-keys (d/entity db ident)
(-> (disj db-property/schema-properties :logseq.property/classes)
(conj :block/title)))]))
(into {}))))))

(defn build-entity-import
"Given an entity's export map, build the import tx to create it"
[db block]
(let [opts (cond-> {:pages-and-blocks [{:page (select-keys (:block/page block) [:block/title :block/uuid])
:blocks [block]}]
[db {:build/keys [block] :keys [properties]}]
(let [opts (cond-> {:pages-and-blocks [{:page (select-keys (:block/page block) [:block/uuid])
:blocks [(dissoc block :block/page)]}]
:build-existing-tx? true}
(seq (:build/properties block))
(assoc :properties (into {}
(map #(vector % (select-keys (d/entity db %) [:logseq.property/type]))
(keys (:build/properties block))))))]
(sqlite-build/build-blocks-tx opts)))
(seq properties)
(assoc :properties
(->> properties
(map (fn [[k v]]
(if-let [ent (d/entity db k)]
[k (assoc v :block/uuid (:block/uuid ent))]
[k v])))
(into {}))))]
(sqlite-build/build-blocks-tx opts)))

(defn merge-export-map
"Merges export map with the block that will receive the import"
[existing-block export-map]
(merge-with merge
export-map
{:build/block
{:block/uuid (:block/uuid existing-block)
:block/page (select-keys (:block/page existing-block) [:block/uuid])}}))
2 changes: 1 addition & 1 deletion deps/db/src/logseq/db/sqlite/util.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
:block/uuid (or block-uuid (common-uuid/gen-uuid :db-ident-block-uuid db-ident'))
:block/title (name prop-name)
:db/index true
:db/cardinality (if (= :many (:db/cardinality prop-schema))
:db/cardinality (if (#{:many :db.cardinality/many} (:db/cardinality prop-schema))
:db.cardinality/many
:db.cardinality/one)
:block/order (db-order/gen-key)}
Expand Down
7 changes: 2 additions & 5 deletions deps/db/test/logseq/db/sqlite/build_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@
:blocks [(merge {:block/title "imported block" :block/uuid (:block/uuid block2)}
{:build/properties {:user.property/p1 "foo"}
:build/tags [:user.class/MyClass]})]}]
:properties {:user.property/p1 {:logseq.property/type :default}}
:properties {:user.property/p1 (select-keys (d/entity @conn :user.property/p1)
[:logseq.property/type :block/uuid])}
:build-existing-tx? true})
_ (d/transact! conn init-tx2)
_ (d/transact! conn block-props-tx2)
Expand All @@ -112,10 +113,6 @@
"Block's properties and tags are updated"))

(testing "block with existing user properties and tags"
(is (= []
(filter #(or (:db/id %) (:db/ident %))
(concat init-tx2 block-props-tx2)))
"Tx doesn't try to create new blocks or modify existing idents")
(is (= "imported block" (:block/title updated-block2)))
(is (= {:block/tags [:user.class/MyClass]
:user.property/p1 "foo"}
Expand Down
87 changes: 87 additions & 0 deletions deps/db/test/logseq/db/sqlite/export_test.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
(ns logseq.db.sqlite.export-test
(:require [cljs.test :refer [deftest is testing]]
[datascript.core :as d]
[logseq.db.sqlite.export :as sqlite-export]
[logseq.db.test.helper :as db-test]))

(deftest import-in-same-graph
(let [conn (db-test/create-conn-with-blocks
{:properties {:default-many {:logseq.property/type :default :db/cardinality :many}}
:pages-and-blocks
[{:page {:block/title "page1"}
:blocks [{:block/title "export"
:build/properties {:default-many #{"foo" "bar" "baz"}}}
{:block/title "import"}]}]})
export-block (db-test/find-block-by-content @conn "export")
import-block* (db-test/find-block-by-content @conn "import")
{:keys [init-tx block-props-tx]}
(->> (sqlite-export/build-entity-export @conn [:block/uuid (:block/uuid export-block)])
(sqlite-export/merge-export-map (db-test/find-block-by-content @conn "import"))
(sqlite-export/build-entity-import @conn))
_ (assert (empty? block-props-tx) "This is empty for properties that already exist and thus no transacted")
_ (d/transact! conn init-tx)
import-block (d/entity @conn (:db/id import-block*))]
(is (= []
(filter #(or (:db/id %) (:db/ident %)) init-tx))
"Tx doesn't try to create new blocks or modify existing idents")

(is (= "export" (:block/title import-block))
"imported block title equals exported one")
(is (= {:user.property/default-many #{"foo" "bar" "baz"}}
(db-test/readable-properties import-block))
"imported block properties equals exported one")))

(deftest import-in-different-graph
(let [conn (db-test/create-conn-with-blocks
{:properties {:num-many {:logseq.property/type :number
:db/cardinality :many
:block/title "Num Many"
:logseq.property/hide? true}}
:pages-and-blocks
[{:page {:block/title "page1"}
:blocks [{:block/title "export"
:build/properties {:num-many #{3 6 9}}}]}]})
conn2 (db-test/create-conn-with-blocks
{:pages-and-blocks [{:page {:block/title "page2"}
:blocks [{:block/title "import"}
{:block/title "import2"}]}]})
export-block (db-test/find-block-by-content @conn "export")
import-block* (db-test/find-block-by-content @conn2 "import")
{:keys [init-tx block-props-tx] :as _txs}
(->> (sqlite-export/build-entity-export @conn [:block/uuid (:block/uuid export-block)])
(sqlite-export/merge-export-map import-block*)
(sqlite-export/build-entity-import @conn2))
_ (assert (nil? (d/entity @conn2 :user.property/num-many)) "Does not have imported property")
_ (d/transact! conn2 init-tx)
_ (d/transact! conn2 block-props-tx)
;; _ (cljs.pprint/pprint _txs)
import-block (d/entity @conn2 (:db/id import-block*))]

(is (some? (d/entity @conn2 :user.property/num-many))
"New user property is imported")
(is (= {:logseq.property/hide? true
:block/title "Num Many"}
(select-keys (d/entity @conn2 :user.property/num-many)
[:block/title :logseq.property/hide?]))
"New user property has title and schema properties copied over")

(is (= "export" (:block/title import-block))
"imported block title equals exported one")
(is (= {:user.property/num-many #{3 6 9}}
(db-test/readable-properties import-block))
"imported block properties equals exported one")

(testing "importing a 2nd time is idempotent"
(let [import-block2* (db-test/find-block-by-content @conn2 "import2")
{:keys [init-tx block-props-tx] :as _txs}
(->> (sqlite-export/build-entity-export @conn [:block/uuid (:block/uuid export-block)])
(sqlite-export/merge-export-map import-block2*)
(sqlite-export/build-entity-import @conn2))
_ (assert (empty? block-props-tx) "This is empty for properties that already exist and thus no transacted")
_ (d/transact! conn2 init-tx)
import-block2 (d/entity @conn2 (:db/id import-block2*))]
(is (= "export" (:block/title import-block2))
"imported block title equals exported one")
(is (= {:user.property/num-many #{3 6 9}}
(db-test/readable-properties import-block))
"imported block properties equals exported one")))))
19 changes: 11 additions & 8 deletions src/main/frontend/handler/common/developer.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@
(notification/show! "Copied block's data!" :success)))

(defn- import-submit [block import-input _]
(let [new-block (edn/read-string @import-input)
updated-block (merge (select-keys block [:block/uuid])
{:block/page (select-keys (:block/page block) [:block/title :block/uuid])}
new-block)
{:keys [init-tx]} (sqlite-export/build-entity-import (db/get-db) updated-block)]
(pprint/pprint init-tx)
(db/transact! (state/get-current-repo) init-tx {:save-block true})
(let [export-map (edn/read-string @import-input)
export-map' (sqlite-export/merge-export-map block export-map)
{:keys [init-tx block-props-tx] :as tx} (sqlite-export/build-entity-import (db/get-db) export-map')]
(pprint/pprint tx)
(p/do
;; FIXME: Choose better metadata so that undo works consistently
(db/transact! (state/get-current-repo) init-tx {:save-block true})
(when (seq block-props-tx)
(db/transact! (state/get-current-repo) block-props-tx {:save-block true})))
;; Also close cmd-k
(shui/dialog-close-all!)))

Expand All @@ -92,7 +94,8 @@
(shui/dialog-open!
[:div
[:label.flex.my-2 "Import into block with text " (pr-str (:block/title block))]
(shui/textarea {:placeholder "Import EDN"
(shui/textarea {:placeholder "Import EDN Data"
:rows 10
:auto-focus true
:on-key-down (fn [e]
(when (= "Enter" (util/ekey e))
Expand Down