@open-commune/core 0.2.21 → 0.2.22
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/dist/dtos.d.mts +1 -1
- package/dist/dtos.d.ts +1 -1
- package/dist/dtos.mjs +1 -1
- package/dist/index.d.mts +188 -76
- package/dist/index.d.ts +188 -76
- package/dist/index.mjs +3 -3
- package/dist/shared/{core.bkXizwPE.d.ts → core.BLcc-Hxe.d.ts} +46 -15
- package/dist/shared/{core.C8czg6gz.d.mts → core.C-cdTqDU.d.mts} +46 -15
- package/dist/shared/core.W03pfXvx.mjs +1 -0
- package/drizzle/0001_entries-fts.sql +63 -0
- package/drizzle/meta/0001_snapshot.json +718 -0
- package/drizzle/meta/_journal.json +8 -1
- package/package.json +1 -1
- package/dist/shared/core.BR6-3c3l.mjs +0 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
-- Full-text index of the entries, every status: SQLite's own FTS5, whose
|
|
2
|
+
-- tokenizer ignores case and accents and cuts on hyphens. A base that ran an
|
|
3
|
+
-- earlier, unmerged version of it holds a table of another shape: dropped,
|
|
4
|
+
-- since it is filled again below.
|
|
5
|
+
DROP TABLE IF EXISTS `entries_fts`;
|
|
6
|
+
--> statement-breakpoint
|
|
7
|
+
CREATE VIRTUAL TABLE `entries_fts` USING fts5(
|
|
8
|
+
`entry_id` UNINDEXED,
|
|
9
|
+
`collection_id` UNINDEXED,
|
|
10
|
+
`title`,
|
|
11
|
+
`body`,
|
|
12
|
+
`extra`,
|
|
13
|
+
tokenize = 'unicode61 remove_diacritics 2'
|
|
14
|
+
);
|
|
15
|
+
--> statement-breakpoint
|
|
16
|
+
-- Every string of every entry that holds words, with the field it comes
|
|
17
|
+
-- from: a rich text gives its text nodes, not its structure (`type`, `href`…).
|
|
18
|
+
CREATE VIEW `entry_words` AS
|
|
19
|
+
SELECT
|
|
20
|
+
`entry`.`id` AS `entry_id`,
|
|
21
|
+
`field`.`key` AS `position`,
|
|
22
|
+
json_extract(`field`.`value`, '$.name') AS `field`,
|
|
23
|
+
(coalesce(json_extract(`field`.`value`, '$.hidden'), 0) OR json_extract(`field`.`value`, '$.type') = 'json') AS `extra`,
|
|
24
|
+
`node`.`value` AS `word`
|
|
25
|
+
FROM `entries` AS `entry`
|
|
26
|
+
JOIN `collection_definitions` AS `definition` ON `definition`.`id` = `entry`.`collection_id`
|
|
27
|
+
JOIN json_each(`definition`.`fields`) AS `field`
|
|
28
|
+
JOIN json_tree(`entry`.`data`, '$."' || json_extract(`field`.`value`, '$.name') || '"') AS `node`
|
|
29
|
+
WHERE `node`.`type` = 'text' AND CASE json_extract(`field`.`value`, '$.type')
|
|
30
|
+
WHEN 'text' THEN `node`.`parent` IS NULL
|
|
31
|
+
WHEN 'select' THEN `node`.`parent` IS NULL
|
|
32
|
+
WHEN 'rich-text' THEN `node`.`key` = 'text'
|
|
33
|
+
WHEN 'steps' THEN `node`.`key` = 'text' OR (`node`.`key` = 'title' AND `node`.`fullkey` GLOB '*[[][0-9]*[]].title')
|
|
34
|
+
WHEN 'json' THEN 1
|
|
35
|
+
ELSE 0
|
|
36
|
+
END;
|
|
37
|
+
--> statement-breakpoint
|
|
38
|
+
-- What each entry gives the index, read from its fields as its collection
|
|
39
|
+
-- defines them: the text of a text or a select, the text nodes of a rich text
|
|
40
|
+
-- (ProseMirror), the titles and text of steps, every string of a JSON field.
|
|
41
|
+
-- A hidden field or a JSON one goes to `extra`, which only the admin searches.
|
|
42
|
+
-- The ligatures are written out, which the tokenizer does not do: « vœux »
|
|
43
|
+
-- must be found by « voeux ». The index is filled from here, and kept from
|
|
44
|
+
-- here by the repositories (`search/indexed.ts`).
|
|
45
|
+
CREATE VIEW `entries_search_text` AS
|
|
46
|
+
SELECT
|
|
47
|
+
`entry_id`,
|
|
48
|
+
`collection_id`,
|
|
49
|
+
replace(replace(replace(replace(`title`, 'œ', 'oe'), 'Œ', 'OE'), 'æ', 'ae'), 'Æ', 'AE') AS `title`,
|
|
50
|
+
replace(replace(replace(replace(coalesce(`body`, ''), 'œ', 'oe'), 'Œ', 'OE'), 'æ', 'ae'), 'Æ', 'AE') AS `body`,
|
|
51
|
+
replace(replace(replace(replace(coalesce(`extra`, ''), 'œ', 'oe'), 'Œ', 'OE'), 'æ', 'ae'), 'Æ', 'AE') AS `extra`
|
|
52
|
+
FROM (
|
|
53
|
+
SELECT
|
|
54
|
+
`entry`.`id` AS `entry_id`,
|
|
55
|
+
`entry`.`collection_id` AS `collection_id`,
|
|
56
|
+
`entry`.`title` AS `title`,
|
|
57
|
+
(SELECT group_concat(`word`, ' ') FROM `entry_words` WHERE `entry_words`.`entry_id` = `entry`.`id` AND NOT `entry_words`.`extra`) AS `body`,
|
|
58
|
+
(SELECT group_concat(`word`, ' ') FROM `entry_words` WHERE `entry_words`.`entry_id` = `entry`.`id` AND `entry_words`.`extra`) AS `extra`
|
|
59
|
+
FROM `entries` AS `entry`
|
|
60
|
+
);
|
|
61
|
+
--> statement-breakpoint
|
|
62
|
+
INSERT INTO `entries_fts` (`entry_id`, `collection_id`, `title`, `body`, `extra`)
|
|
63
|
+
SELECT `entry_id`, `collection_id`, `title`, `body`, `extra` FROM `entries_search_text`;
|