@tiddlywiki/mws 0.0.21 → 0.1.1

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.
Files changed (202) hide show
  1. package/README.md +42 -9
  2. package/dist/metafile-esm.json +1 -0
  3. package/dist/mws.d.ts +1 -0
  4. package/dist/mws.js +34710 -0
  5. package/dist/mws.js.map +1 -0
  6. package/editions/mws-docs/tiddlers/$__StoryList.tid +1 -2
  7. package/editions/mws-docs/tiddlers/2025-02-18 - User Management.md.meta +2 -2
  8. package/editions/mws-docs/tiddlers/2025-04-14 - client plugins /342/234/224/357/270/217.md" +31 -0
  9. package/editions/mws-docs/tiddlers/2025-04-14 - client plugins /342/234/224/357/270/217.md.meta" +5 -0
  10. package/editions/mws-docs/tiddlers/{2025-05-04.md → 2025-05-04 - event hooks /342/234/224/357/270/217.md" } +7 -1
  11. package/editions/mws-docs/tiddlers/2025-05-04 - event hooks /342/234/224/357/270/217.md.meta" +5 -0
  12. package/editions/mws-docs/tiddlers/{2025-05-06.md → 2025-05-06 - syncer design.md } +0 -4
  13. package/editions/mws-docs/tiddlers/2025-05-06 - syncer design.md.meta +5 -0
  14. package/editions/mws-docs/tiddlers/Allowed Methods.tid +8 -0
  15. package/editions/mws-docs/tiddlers/Application Access & Security.md +14 -84
  16. package/editions/mws-docs/tiddlers/Application Access & Security.md.meta +1 -1
  17. package/editions/mws-docs/tiddlers/Body Format.md +19 -0
  18. package/editions/mws-docs/tiddlers/Body Format.md.meta +4 -0
  19. package/editions/mws-docs/tiddlers/Checklists and Features.md +0 -3
  20. package/editions/mws-docs/tiddlers/Checklists and Features.md.meta +1 -1
  21. package/editions/mws-docs/tiddlers/Client Plugins.md +17 -0
  22. package/editions/mws-docs/tiddlers/Client Plugins.md.meta +5 -0
  23. package/editions/mws-docs/tiddlers/HTTP API.md +4 -3
  24. package/editions/mws-docs/tiddlers/HTTP API.md.meta +1 -1
  25. package/editions/mws-docs/tiddlers/HelloThere.tid +2 -2
  26. package/editions/mws-docs/tiddlers/Installation.tid +2 -3
  27. package/editions/mws-docs/tiddlers/MWS Architecture.tid +6 -1
  28. package/editions/mws-docs/tiddlers/Multi-user Trust.md +12 -0
  29. package/editions/mws-docs/tiddlers/Multi-user Trust.md.meta +5 -0
  30. package/editions/mws-docs/tiddlers/Notes.tid +5 -3
  31. package/editions/mws-docs/tiddlers/Oracle Attacks.md +29 -0
  32. package/editions/mws-docs/tiddlers/Oracle Attacks.md.meta +5 -0
  33. package/editions/mws-docs/tiddlers/Reference.md +1 -0
  34. package/editions/mws-docs/tiddlers/Reference.md.meta +1 -1
  35. package/editions/mws-docs/tiddlers/Request Handling.md +53 -0
  36. package/editions/mws-docs/tiddlers/Request Handling.md.meta +5 -0
  37. package/editions/mws-docs/tiddlers/Roadmap.tid +7 -0
  38. package/editions/mws-docs/tiddlers/Route Definers.md +206 -0
  39. package/editions/mws-docs/tiddlers/Route Definers.md.meta +5 -0
  40. package/editions/mws-docs/tiddlers/Security.md +75 -0
  41. package/editions/mws-docs/tiddlers/Security.md.meta +5 -0
  42. package/editions/mws-docs/tiddlers/Server Plugins.md +7 -0
  43. package/editions/mws-docs/tiddlers/Server Plugins.md.meta +5 -0
  44. package/editions/mws-docs/tiddlers/Startup Cache.md +28 -0
  45. package/editions/mws-docs/tiddlers/Startup Cache.md.meta +5 -0
  46. package/editions/mws-docs/tiddlers/TiddlerFields.md +5 -0
  47. package/editions/mws-docs/tiddlers/TiddlerFields.md.meta +4 -0
  48. package/editions/mws-docs/tiddlers/Usage.tid +2 -2
  49. package/editions/mws-docs/tiddlers/system/$__mws_cssvar-macro.tid +10 -0
  50. package/editions/mws-docs/tiddlers/system/$__palettes_MUI +143 -0
  51. package/editions/mws-docs/tiddlers/system/$__palettes_MUI.meta +7 -0
  52. package/editions/mws-docs/tiddlers/system/$__palettes_MUI_styles.css +567 -0
  53. package/editions/mws-docs/tiddlers/system/$__palettes_MUI_styles.css.meta +6 -0
  54. package/editions/mws-docs/tiddlers/system/$__theme.tid +6 -0
  55. package/editions/mws-docs/tiddlers/system/SplashScreen.tid +21 -0
  56. package/editions/mws-docs/tiddlers/system/StaticBanner.tid +1 -1
  57. package/editions/mws-docs/tiddlers/system/Styles.tid +13 -0
  58. package/editions/mws-docs/tiddlers/system/palette.tid +4 -1
  59. package/editions/mws-docs/tiddlers/system/sidebarlayout.tid +4 -1
  60. package/editions/mws-docs/tiddlers/x-mws-tiddler.md +35 -0
  61. package/editions/mws-docs/tiddlers/x-mws-tiddler.md.meta +5 -0
  62. package/mws.run.mjs +30 -0
  63. package/package.json +47 -36
  64. package/plugins/client/package-lock.json +46 -83
  65. package/plugins/client/package.json +1 -6
  66. package/plugins/client/plugin.info +2 -2
  67. package/plugins/client/src/fflate.d.ts +1501 -0
  68. package/plugins/client/src/multiwikiclientadaptor.ts +768 -317
  69. package/plugins/client/src/mws.d.ts +4 -0
  70. package/plugins/client/src/types.d.ts +3928 -0
  71. package/plugins/client/tiddlers/en-US.multids +3 -0
  72. package/plugins/client/tiddlers/status/SaveWikiButtonTemplate.tid +3 -0
  73. package/plugins/client/tiddlers/status/icon-cloud.tid +4 -0
  74. package/plugins/client/tiddlers/status/info-segment.tid +8 -0
  75. package/plugins/client/tiddlers/status/readonly-styles.tid +27 -0
  76. package/plugins/client/tiddlers/status/save-offline.tid +7 -0
  77. package/plugins/client/tiddlers/status/save-wiki-button.tid +26 -0
  78. package/plugins/client/tiddlers/status/styles.tid +44 -0
  79. package/plugins/client/tiddlers/status/syncer-actions-copy-logs.tid +6 -0
  80. package/plugins/client/tiddlers/status/syncer-actions-login-status.tid +9 -0
  81. package/plugins/client/tiddlers/status/syncer-actions-login.tid +8 -0
  82. package/plugins/client/tiddlers/status/syncer-actions-logout.tid +8 -0
  83. package/plugins/client/tiddlers/status/syncer-actions-refresh.tid +9 -0
  84. package/plugins/client/tiddlers/status/syncer-actions-save-snapshot.tid +9 -0
  85. package/plugins/client/tiddlers/status/tags-syncerdropdown.tid +2 -0
  86. package/plugins/client/tiddlers/syncer/multiwikiclientadaptor.js +640 -0
  87. package/plugins/client/tiddlers/syncer/syncer.js +831 -0
  88. package/plugins/client/tsconfig.json +19 -16
  89. package/plugins/filter-ast-to-sql/example-run-series.ts +146 -0
  90. package/plugins/server/SplashScreen.tid +150 -0
  91. package/plugins/server/fflate.js +9 -0
  92. package/plugins/server/plugin.info +8 -0
  93. package/plugins/server/readme +1 -0
  94. package/plugins/server/url-polyfill.js +294 -0
  95. package/prisma/client/client.d.ts +1 -0
  96. package/prisma/client/client.js +3 -0
  97. package/prisma/client/default.d.ts +1 -0
  98. package/prisma/client/default.js +3 -0
  99. package/prisma/client/edge.d.ts +1 -0
  100. package/prisma/client/edge.js +297 -0
  101. package/prisma/client/index-browser.js +275 -0
  102. package/prisma/client/index.d.ts +17770 -0
  103. package/prisma/client/index.js +324 -0
  104. package/prisma/client/package.json +173 -0
  105. package/prisma/client/query_engine_bg.js +811 -0
  106. package/prisma/client/query_engine_bg.wasm +0 -0
  107. package/prisma/client/runtime/edge-esm.js +10000 -0
  108. package/prisma/client/runtime/edge.js +10036 -0
  109. package/prisma/client/runtime/index-browser.d.ts +370 -0
  110. package/prisma/client/runtime/index-browser.js +2300 -0
  111. package/prisma/client/runtime/library.d.ts +3681 -0
  112. package/prisma/client/runtime/library.js +10604 -0
  113. package/prisma/client/runtime/react-native.js +10629 -0
  114. package/prisma/client/runtime/wasm-compiler-edge.js +11238 -0
  115. package/prisma/client/runtime/wasm-engine-edge.js +7801 -0
  116. package/prisma/client/schema.prisma +156 -0
  117. package/prisma/client/wasm-edge-light-loader.mjs +4 -0
  118. package/prisma/client/wasm-worker-loader.mjs +4 -0
  119. package/prisma/client/wasm.d.ts +1 -0
  120. package/prisma/client/wasm.js +304 -0
  121. package/prisma/global.ts +53 -0
  122. package/prisma/migrations/{20250406213424_init → 20250606001949_init}/migration.sql +46 -48
  123. package/prisma/migrations/20250613000526_remove_group/migration.sql +22 -0
  124. package/prisma/migrations/20250620014502_settings/migration.sql +5 -0
  125. package/prisma/migrations/20250707205229_recipes/migration.sql +20 -0
  126. package/prisma/migrations/migration_lock.toml +1 -1
  127. package/prisma/notes.md +1 -2
  128. package/prisma/schema.prisma +52 -49
  129. package/prisma/test.sqlite +0 -0
  130. package/prisma/test.sqlite-journal +0 -0
  131. package/public/react-admin/android-chrome-192x192.png +0 -0
  132. package/public/react-admin/android-chrome-512x512.png +0 -0
  133. package/public/react-admin/apple-touch-icon.png +0 -0
  134. package/{react-user-mgmt/public/esm-QKDFEP3B.js → public/react-admin/esm-L4WLVWJN.js} +1 -1
  135. package/public/react-admin/esm-L4WLVWJN.js.map +7 -0
  136. package/public/react-admin/esm-QMNGI3LF.js +3 -0
  137. package/public/react-admin/favicon-16x16.png +0 -0
  138. package/public/react-admin/favicon-32x32.png +0 -0
  139. package/public/react-admin/favicon.ico +0 -0
  140. package/public/react-admin/index.html +36 -0
  141. package/public/react-admin/main.js +268 -0
  142. package/public/react-admin/main.js.map +7 -0
  143. package/public/react-admin/site.webmanifest +20 -0
  144. package/public/react-admin/stats.json +1 -0
  145. package/scripts.mjs +134 -25
  146. package/dist/server.d.ts +0 -945
  147. package/dist/server.js +0 -20775
  148. package/dist/server.js.map +0 -1
  149. package/editions/mws-docs/tiddlers/2025-04-03 - Phases of Development.md +0 -64
  150. package/editions/mws-docs/tiddlers/2025-04-03 - Phases of Development.md.meta +0 -5
  151. package/editions/mws-docs/tiddlers/2025-04-13 - Plugins.md +0 -18
  152. package/editions/mws-docs/tiddlers/2025-04-13 - Plugins.md.meta +0 -5
  153. package/editions/mws-docs/tiddlers/2025-05-04.md.meta +0 -5
  154. package/editions/mws-docs/tiddlers/2025-05-06.md.meta +0 -5
  155. package/editions/mws-docs/tiddlers/Moduler Design.md +0 -29
  156. package/editions/mws-docs/tiddlers/Moduler Design.md.meta +0 -5
  157. package/editions/mws-docs/tiddlers/Request Server.md +0 -20
  158. package/editions/mws-docs/tiddlers/Request Server.md.meta +0 -5
  159. package/editions/mws-docs/tiddlers/system/$__palettes_MUI-Dark +0 -173
  160. package/editions/mws-docs/tiddlers/system/$__palettes_MUI-Dark.meta +0 -6
  161. package/editions/mws-docs/tiddlers/system/$__palettes_MUI-Light +0 -172
  162. package/editions/mws-docs/tiddlers/system/$__palettes_MUI-Light.meta +0 -6
  163. package/plugins/client/tiddlers/config-tiddlers-filter.tid +0 -2
  164. package/plugins/client/tiddlers/config-use-server-sent-events.tid +0 -2
  165. package/plugins/client/tiddlers/info-segment.tid +0 -8
  166. package/plugins/client/tiddlers/multiwikiclientadaptor.js +0 -444
  167. package/prisma/migrations/20250407002306_disconnect_user_tables/migration.sql +0 -52
  168. package/prisma/old-db.sql +0 -144
  169. package/react-user-mgmt/README.md +0 -50
  170. package/react-user-mgmt/eslint.config.js +0 -28
  171. package/react-user-mgmt/package-lock.json +0 -2738
  172. package/react-user-mgmt/package.json +0 -31
  173. package/react-user-mgmt/public/index.html +0 -1
  174. package/react-user-mgmt/public/main.js +0 -295
  175. package/react-user-mgmt/public/main.js.map +0 -7
  176. package/react-user-mgmt/public/stats.json +0 -1
  177. package/react-user-mgmt/tsconfig.json +0 -40
  178. package/react-user-mgmt/types.d.ts +0 -2
  179. package/tiddlywiki-types/boot/boot.d.ts +0 -378
  180. package/tiddlywiki-types/boot/bootprefix.d.ts +0 -110
  181. package/tiddlywiki-types/core/modules/filters.d.ts +0 -107
  182. package/tiddlywiki-types/core/modules/tiddler.d.ts +0 -47
  183. package/tiddlywiki-types/core/modules/wiki-bulkops.d.ts +0 -36
  184. package/tiddlywiki-types/core/modules/wiki.d.ts +0 -208
  185. package/tiddlywiki-types/index.d.ts +0 -7
  186. package/tiddlywiki-types/package.json +0 -3
  187. /package/plugins/client/tiddlers/{sidebarsegment.tid → status/sidebarsegment.tid} +0 -0
  188. /package/plugins/client/tiddlers/{GettingStarted.tid → syncer/GettingStarted.tid} +0 -0
  189. /package/plugins/client/tiddlers/{config-incoming-updates-filter.tid → syncer/config-incoming-updates-filter.tid} +0 -0
  190. /package/plugins/client/tiddlers/{readme.tid → syncer/readme.tid} +0 -0
  191. /package/{react-user-mgmt/public → public/react-admin}/chunk-YALWN5OT.js +0 -0
  192. /package/{react-user-mgmt/public → public/react-admin}/chunk-YALWN5OT.js.map +0 -0
  193. /package/{react-user-mgmt/public/esm-QKDFEP3B.js.map → public/react-admin/esm-QMNGI3LF.js.map} +0 -0
  194. /package/{react-user-mgmt/public → public/react-admin}/favicon.png +0 -0
  195. /package/{react-user-mgmt/public → public/react-admin}/missing-favicon.png +0 -0
  196. /package/{react-user-mgmt/public → public/react-admin}/motovun-jack.jpg +0 -0
  197. /package/{react-user-mgmt/public → public/react-admin}/mws-icon.png +0 -0
  198. /package/{react-user-mgmt/public → public/react-admin}/stats.css +0 -0
  199. /package/{react-user-mgmt/public → public/react-admin}/stats.html +0 -0
  200. /package/{react-user-mgmt/public → public/react-admin}/stats.js +0 -0
  201. /package/{react-user-mgmt/public → public/react-admin}/stats.svg +0 -0
  202. /package/{react-user-mgmt/public → public/react-admin}/vite.svg +0 -0
@@ -1,70 +1,55 @@
1
1
  -- CreateTable
2
2
  CREATE TABLE "recipes" (
3
- "recipe_id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
3
+ "recipe_id" TEXT NOT NULL PRIMARY KEY,
4
4
  "recipe_name" TEXT NOT NULL,
5
5
  "description" TEXT NOT NULL,
6
- "owner_id" INTEGER,
7
- CONSTRAINT "recipes_owner_id_fkey" FOREIGN KEY ("owner_id") REFERENCES "users" ("user_id") ON DELETE NO ACTION ON UPDATE NO ACTION
6
+ "owner_id" TEXT,
7
+ "plugin_names" JSONB NOT NULL,
8
+ "skip_required_plugins" BOOLEAN NOT NULL DEFAULT false,
9
+ "skip_core" BOOLEAN NOT NULL DEFAULT false
8
10
  );
9
11
 
10
12
  -- CreateTable
11
13
  CREATE TABLE "recipe_acl" (
12
14
  "acl_id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
13
- "role_id" INTEGER NOT NULL,
15
+ "role_id" TEXT NOT NULL,
14
16
  "permission" TEXT NOT NULL,
15
- "recipe_id" INTEGER,
16
- CONSTRAINT "recipe_acl_role_id_fkey" FOREIGN KEY ("role_id") REFERENCES "roles" ("role_id") ON DELETE NO ACTION ON UPDATE NO ACTION,
17
+ "recipe_id" TEXT NOT NULL,
17
18
  CONSTRAINT "recipe_acl_recipe_id_fkey" FOREIGN KEY ("recipe_id") REFERENCES "recipes" ("recipe_id") ON DELETE CASCADE ON UPDATE CASCADE
18
19
  );
19
20
 
20
21
  -- CreateTable
21
22
  CREATE TABLE "recipe_bags" (
22
- "recipe_id" INTEGER NOT NULL,
23
- "bag_id" INTEGER NOT NULL,
23
+ "recipe_id" TEXT NOT NULL,
24
+ "bag_id" TEXT NOT NULL,
24
25
  "position" INTEGER NOT NULL,
25
- "with_acl" BOOLEAN NOT NULL,
26
+ "with_acl" BOOLEAN NOT NULL DEFAULT false,
27
+ "load_modules" BOOLEAN NOT NULL DEFAULT false,
26
28
  CONSTRAINT "recipe_bags_bag_id_fkey" FOREIGN KEY ("bag_id") REFERENCES "bags" ("bag_id") ON DELETE CASCADE ON UPDATE CASCADE,
27
29
  CONSTRAINT "recipe_bags_recipe_id_fkey" FOREIGN KEY ("recipe_id") REFERENCES "recipes" ("recipe_id") ON DELETE CASCADE ON UPDATE CASCADE
28
30
  );
29
31
 
30
32
  -- CreateTable
31
33
  CREATE TABLE "bags" (
32
- "bag_id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
34
+ "bag_id" TEXT NOT NULL PRIMARY KEY,
33
35
  "bag_name" TEXT NOT NULL,
34
36
  "description" TEXT NOT NULL,
35
- "is_plugin" BOOLEAN NOT NULL,
36
- "owner_id" INTEGER,
37
- CONSTRAINT "bags_owner_id_fkey" FOREIGN KEY ("owner_id") REFERENCES "users" ("user_id") ON DELETE NO ACTION ON UPDATE NO ACTION
37
+ "owner_id" TEXT
38
38
  );
39
39
 
40
40
  -- CreateTable
41
41
  CREATE TABLE "bag_acl" (
42
42
  "acl_id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
43
- "bag_id" INTEGER NOT NULL,
44
- "role_id" INTEGER NOT NULL,
43
+ "bag_id" TEXT NOT NULL,
44
+ "role_id" TEXT NOT NULL,
45
45
  "permission" TEXT NOT NULL,
46
- CONSTRAINT "bag_acl_bag_id_fkey" FOREIGN KEY ("bag_id") REFERENCES "bags" ("bag_id") ON DELETE CASCADE ON UPDATE CASCADE,
47
- CONSTRAINT "bag_acl_role_id_fkey" FOREIGN KEY ("role_id") REFERENCES "roles" ("role_id") ON DELETE NO ACTION ON UPDATE NO ACTION
48
- );
49
-
50
- -- CreateTable
51
- CREATE TABLE "groups" (
52
- "group_id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
53
- "group_name" TEXT NOT NULL,
54
- "description" TEXT
55
- );
56
-
57
- -- CreateTable
58
- CREATE TABLE "roles" (
59
- "role_id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
60
- "role_name" TEXT NOT NULL,
61
- "description" TEXT
46
+ CONSTRAINT "bag_acl_bag_id_fkey" FOREIGN KEY ("bag_id") REFERENCES "bags" ("bag_id") ON DELETE CASCADE ON UPDATE CASCADE
62
47
  );
63
48
 
64
49
  -- CreateTable
65
50
  CREATE TABLE "tiddlers" (
66
- "tiddler_id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
67
- "bag_id" INTEGER NOT NULL,
51
+ "revision_id" TEXT NOT NULL PRIMARY KEY,
52
+ "bag_id" TEXT NOT NULL,
68
53
  "title" TEXT NOT NULL,
69
54
  "is_deleted" BOOLEAN NOT NULL,
70
55
  "attachment_hash" TEXT,
@@ -73,17 +58,31 @@ CREATE TABLE "tiddlers" (
73
58
 
74
59
  -- CreateTable
75
60
  CREATE TABLE "fields" (
76
- "tiddler_id" INTEGER NOT NULL,
61
+ "revision_id" TEXT NOT NULL,
77
62
  "field_name" TEXT NOT NULL,
78
63
  "field_value" TEXT NOT NULL,
79
64
 
80
- PRIMARY KEY ("tiddler_id", "field_name"),
81
- CONSTRAINT "fields_tiddler_id_fkey" FOREIGN KEY ("tiddler_id") REFERENCES "tiddlers" ("tiddler_id") ON DELETE CASCADE ON UPDATE CASCADE
65
+ PRIMARY KEY ("revision_id", "field_name"),
66
+ CONSTRAINT "fields_revision_id_fkey" FOREIGN KEY ("revision_id") REFERENCES "tiddlers" ("revision_id") ON DELETE CASCADE ON UPDATE CASCADE
67
+ );
68
+
69
+ -- CreateTable
70
+ CREATE TABLE "groups" (
71
+ "group_id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
72
+ "group_name" TEXT NOT NULL,
73
+ "description" TEXT
74
+ );
75
+
76
+ -- CreateTable
77
+ CREATE TABLE "roles" (
78
+ "role_id" TEXT NOT NULL PRIMARY KEY,
79
+ "role_name" TEXT NOT NULL,
80
+ "description" TEXT
82
81
  );
83
82
 
84
83
  -- CreateTable
85
84
  CREATE TABLE "users" (
86
- "user_id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
85
+ "user_id" TEXT NOT NULL PRIMARY KEY,
87
86
  "username" TEXT NOT NULL,
88
87
  "email" TEXT NOT NULL,
89
88
  "password" TEXT NOT NULL,
@@ -97,14 +96,14 @@ CREATE TABLE "sessions" (
97
96
  "created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
98
97
  "last_accessed" DATETIME NOT NULL,
99
98
  "session_key" TEXT,
100
- "user_id" INTEGER NOT NULL,
99
+ "user_id" TEXT NOT NULL,
101
100
  CONSTRAINT "sessions_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users" ("user_id") ON DELETE NO ACTION ON UPDATE NO ACTION
102
101
  );
103
102
 
104
103
  -- CreateTable
105
104
  CREATE TABLE "_GroupsToRoles" (
106
105
  "A" INTEGER NOT NULL,
107
- "B" INTEGER NOT NULL,
106
+ "B" TEXT NOT NULL,
108
107
  CONSTRAINT "_GroupsToRoles_A_fkey" FOREIGN KEY ("A") REFERENCES "groups" ("group_id") ON DELETE CASCADE ON UPDATE CASCADE,
109
108
  CONSTRAINT "_GroupsToRoles_B_fkey" FOREIGN KEY ("B") REFERENCES "roles" ("role_id") ON DELETE CASCADE ON UPDATE CASCADE
110
109
  );
@@ -112,15 +111,15 @@ CREATE TABLE "_GroupsToRoles" (
112
111
  -- CreateTable
113
112
  CREATE TABLE "_GroupsToUsers" (
114
113
  "A" INTEGER NOT NULL,
115
- "B" INTEGER NOT NULL,
114
+ "B" TEXT NOT NULL,
116
115
  CONSTRAINT "_GroupsToUsers_A_fkey" FOREIGN KEY ("A") REFERENCES "groups" ("group_id") ON DELETE CASCADE ON UPDATE CASCADE,
117
116
  CONSTRAINT "_GroupsToUsers_B_fkey" FOREIGN KEY ("B") REFERENCES "users" ("user_id") ON DELETE CASCADE ON UPDATE CASCADE
118
117
  );
119
118
 
120
119
  -- CreateTable
121
120
  CREATE TABLE "_RolesToUsers" (
122
- "A" INTEGER NOT NULL,
123
- "B" INTEGER NOT NULL,
121
+ "A" TEXT NOT NULL,
122
+ "B" TEXT NOT NULL,
124
123
  CONSTRAINT "_RolesToUsers_A_fkey" FOREIGN KEY ("A") REFERENCES "roles" ("role_id") ON DELETE CASCADE ON UPDATE CASCADE,
125
124
  CONSTRAINT "_RolesToUsers_B_fkey" FOREIGN KEY ("B") REFERENCES "users" ("user_id") ON DELETE CASCADE ON UPDATE CASCADE
126
125
  );
@@ -138,19 +137,19 @@ CREATE UNIQUE INDEX "recipe_bags_recipe_id_bag_id_key" ON "recipe_bags"("recipe_
138
137
  CREATE UNIQUE INDEX "bags_bag_name_key" ON "bags"("bag_name");
139
138
 
140
139
  -- CreateIndex
141
- CREATE UNIQUE INDEX "groups_group_name_key" ON "groups"("group_name");
140
+ CREATE INDEX "tiddlers_bag_id_idx" ON "tiddlers"("bag_id");
142
141
 
143
142
  -- CreateIndex
144
- CREATE UNIQUE INDEX "roles_role_name_key" ON "roles"("role_name");
143
+ CREATE UNIQUE INDEX "tiddlers_bag_id_title_key" ON "tiddlers"("bag_id", "title");
145
144
 
146
145
  -- CreateIndex
147
- CREATE INDEX "tiddlers_bag_id_idx" ON "tiddlers"("bag_id");
146
+ CREATE INDEX "fields_revision_id_idx" ON "fields"("revision_id");
148
147
 
149
148
  -- CreateIndex
150
- CREATE UNIQUE INDEX "tiddlers_bag_id_title_key" ON "tiddlers"("bag_id", "title");
149
+ CREATE UNIQUE INDEX "groups_group_name_key" ON "groups"("group_name");
151
150
 
152
151
  -- CreateIndex
153
- CREATE INDEX "fields_tiddler_id_idx" ON "fields"("tiddler_id");
152
+ CREATE UNIQUE INDEX "roles_role_name_key" ON "roles"("role_name");
154
153
 
155
154
  -- CreateIndex
156
155
  CREATE UNIQUE INDEX "users_username_key" ON "users"("username");
@@ -175,4 +174,3 @@ CREATE UNIQUE INDEX "_RolesToUsers_AB_unique" ON "_RolesToUsers"("A", "B");
175
174
 
176
175
  -- CreateIndex
177
176
  CREATE INDEX "_RolesToUsers_B_index" ON "_RolesToUsers"("B");
178
-
@@ -0,0 +1,22 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the `_GroupsToRoles` table. If the table is not empty, all the data it contains will be lost.
5
+ - You are about to drop the `_GroupsToUsers` table. If the table is not empty, all the data it contains will be lost.
6
+ - You are about to drop the `groups` table. If the table is not empty, all the data it contains will be lost.
7
+
8
+ */
9
+ -- DropTable
10
+ PRAGMA foreign_keys=off;
11
+ DROP TABLE "_GroupsToRoles";
12
+ PRAGMA foreign_keys=on;
13
+
14
+ -- DropTable
15
+ PRAGMA foreign_keys=off;
16
+ DROP TABLE "_GroupsToUsers";
17
+ PRAGMA foreign_keys=on;
18
+
19
+ -- DropTable
20
+ PRAGMA foreign_keys=off;
21
+ DROP TABLE "groups";
22
+ PRAGMA foreign_keys=on;
@@ -0,0 +1,5 @@
1
+ -- CreateTable
2
+ CREATE TABLE "settings" (
3
+ "key" TEXT NOT NULL PRIMARY KEY,
4
+ "value" TEXT NOT NULL
5
+ );
@@ -0,0 +1,20 @@
1
+ -- RedefineTables
2
+ PRAGMA defer_foreign_keys=ON;
3
+ PRAGMA foreign_keys=OFF;
4
+ CREATE TABLE "new_recipes" (
5
+ "recipe_id" TEXT NOT NULL PRIMARY KEY,
6
+ "recipe_name" TEXT NOT NULL,
7
+ "description" TEXT NOT NULL,
8
+ "owner_id" TEXT,
9
+ "plugin_names" JSONB NOT NULL,
10
+ "skip_required_plugins" BOOLEAN NOT NULL DEFAULT false,
11
+ "skip_core" BOOLEAN NOT NULL DEFAULT false,
12
+ "preload_store" BOOLEAN NOT NULL DEFAULT false,
13
+ "custom_wiki" TEXT
14
+ );
15
+ INSERT INTO "new_recipes" ("description", "owner_id", "plugin_names", "recipe_id", "recipe_name", "skip_core", "skip_required_plugins") SELECT "description", "owner_id", "plugin_names", "recipe_id", "recipe_name", "skip_core", "skip_required_plugins" FROM "recipes";
16
+ DROP TABLE "recipes";
17
+ ALTER TABLE "new_recipes" RENAME TO "recipes";
18
+ CREATE UNIQUE INDEX "recipes_recipe_name_key" ON "recipes"("recipe_name");
19
+ PRAGMA foreign_keys=ON;
20
+ PRAGMA defer_foreign_keys=OFF;
@@ -1,3 +1,3 @@
1
1
  # Please do not edit this file manually
2
2
  # It should be added in your version-control system (e.g., Git)
3
- provider = "sqlite"
3
+ provider = "sqlite"
package/prisma/notes.md CHANGED
@@ -10,6 +10,5 @@ We'll probably end up importing and exporting bags via tiddlywiki.
10
10
 
11
11
  ### Line endings (in case git ever messes this up)
12
12
 
13
- 20250406213424_init - LF
14
- 20250407002306_disconnect_user_tables - LF
13
+
15
14
 
@@ -7,15 +7,13 @@ generator client {
7
7
  // prisma 7 will remove the need for native node files, everything will be js and wasm
8
8
  provider = "prisma-client-js"
9
9
  previewFeatures = ["relationJoins", "driverAdapters"]
10
- binaryTargets = []
10
+ binaryTargets = []
11
+ output = "client"
11
12
  }
12
13
 
13
- // generator zod {
14
- // provider = "zod-prisma-types"
15
- // output = "./generated/zod-prisma"
16
- // useMultipleFiles = false
17
- // createRelationValuesTypes = true
18
- // }
14
+ generator json {
15
+ provider = "prisma-json-types-generator"
16
+ }
19
17
 
20
18
  enum Permission {
21
19
  READ
@@ -23,34 +21,52 @@ enum Permission {
23
21
  ADMIN
24
22
  }
25
23
 
24
+ // The `packages/mws/src/managers/` folder is the primary place this schema is used.
25
+ // SQLite initialization is done in `packages/mws/src/db/sqlite-adapter.ts`.
26
+
27
+ model Settings {
28
+ key String @id
29
+ value String
30
+
31
+ @@map("settings")
32
+ }
33
+
26
34
  model Recipes {
27
- recipe_id Int @id @default(autoincrement())
28
- recipe_name String @unique
29
- description String
30
- owner_id Int?
31
- recipe_bags Recipe_bags[]
32
- acl RecipeAcl[]
35
+ recipe_id String @id @default(uuid(7))
36
+ recipe_name String @unique
37
+ description String
38
+ owner_id String?
39
+ /// [Recipes_plugin_names]
40
+ plugin_names Json
41
+ skip_required_plugins Boolean @default(false)
42
+ skip_core Boolean @default(false)
43
+ preload_store Boolean @default(false)
44
+ custom_wiki String?
45
+ recipe_bags Recipe_bags[]
46
+ acl RecipeAcl[]
33
47
 
34
48
  @@map("recipes")
35
49
  }
36
50
 
37
51
  model RecipeAcl {
38
52
  acl_id Int @id @default(autoincrement())
39
- role_id Int
53
+ role_id String
40
54
  permission Permission
41
- recipe Recipes @relation(fields: [recipe_id], references: [recipe_id], onDelete: Cascade)
42
- recipe_id Int
55
+ recipe Recipes @relation(fields: [recipe_id], references: [recipe_id], onDelete: Cascade)
56
+ recipe_id String
43
57
 
44
58
  @@map("recipe_acl")
45
59
  }
46
60
 
47
61
  model Recipe_bags {
48
- recipe_id Int
49
- bag_id Int
50
- position Int
51
- with_acl Boolean
52
- bag Bags @relation(fields: [bag_id], references: [bag_id], onDelete: Cascade)
53
- recipe Recipes @relation(fields: [recipe_id], references: [recipe_id], onDelete: Cascade)
62
+ recipe_id String
63
+ bag_id String
64
+ position Int
65
+ with_acl Boolean @default(false)
66
+ load_modules Boolean @default(false)
67
+
68
+ bag Bags @relation(fields: [bag_id], references: [bag_id], onDelete: Cascade)
69
+ recipe Recipes @relation(fields: [recipe_id], references: [recipe_id], onDelete: Cascade)
54
70
 
55
71
  @@unique([recipe_id, bag_id])
56
72
  @@index([recipe_id])
@@ -58,11 +74,10 @@ model Recipe_bags {
58
74
  }
59
75
 
60
76
  model Bags {
61
- bag_id Int @id @default(autoincrement())
77
+ bag_id String @id @default(uuid(7))
62
78
  bag_name String @unique
63
79
  description String
64
- is_plugin Boolean
65
- owner_id Int?
80
+ owner_id String?
66
81
  recipe_bags Recipe_bags[]
67
82
  tiddlers Tiddlers[]
68
83
  acl BagAcl[]
@@ -72,17 +87,17 @@ model Bags {
72
87
 
73
88
  model BagAcl {
74
89
  acl_id Int @id @default(autoincrement())
75
- bag_id Int
90
+ bag_id String
76
91
  bag Bags @relation(fields: [bag_id], references: [bag_id], onDelete: Cascade)
77
- role_id Int
92
+ role_id String
78
93
  permission Permission
79
94
 
80
95
  @@map("bag_acl")
81
96
  }
82
97
 
83
98
  model Tiddlers {
84
- tiddler_id Int @id @default(autoincrement())
85
- bag_id Int
99
+ revision_id String @id @default(uuid(7))
100
+ bag_id String
86
101
  title String
87
102
  is_deleted Boolean
88
103
  attachment_hash String?
@@ -96,46 +111,34 @@ model Tiddlers {
96
111
  }
97
112
 
98
113
  model Fields {
99
- tiddler_id Int
114
+ revision_id String
100
115
  field_name String
101
116
  field_value String
102
117
  // Deleting a referenced record (tiddler) will trigger the deletion of referencing record (field).
103
- tiddler Tiddlers @relation(fields: [tiddler_id], references: [tiddler_id], onDelete: Cascade)
118
+ tiddler Tiddlers @relation(fields: [revision_id], references: [revision_id], onDelete: Cascade)
104
119
 
105
- @@id([tiddler_id, field_name])
106
- @@index([tiddler_id])
120
+ @@id([revision_id, field_name])
121
+ @@index([revision_id])
107
122
  @@map("fields")
108
123
  }
109
124
 
110
- model Groups {
111
- group_id Int @id @default(autoincrement())
112
- group_name String @unique()
113
- description String?
114
- roles Roles[]
115
- users Users[]
116
-
117
- @@map("groups")
118
- }
119
-
120
125
  model Roles {
121
- role_id Int @id @default(autoincrement())
122
- role_name String @unique()
126
+ role_id String @id @default(uuid(7))
127
+ role_name String @unique()
123
128
  description String?
124
- groups Groups[]
125
129
  users Users[]
126
130
 
127
131
  @@map("roles")
128
132
  }
129
133
 
130
134
  model Users {
131
- user_id Int @id @default(autoincrement())
135
+ user_id String @id @default(uuid(7))
132
136
  username String @unique
133
137
  email String @unique
134
138
  password String
135
139
  created_at DateTime @default(now())
136
140
  last_login DateTime?
137
141
  sessions Sessions[]
138
- groups Groups[]
139
142
  roles Roles[]
140
143
 
141
144
  @@map("users")
@@ -146,7 +149,7 @@ model Sessions {
146
149
  created_at DateTime @default(now())
147
150
  last_accessed DateTime
148
151
  session_key String?
149
- user_id Int
152
+ user_id String
150
153
  user Users @relation(fields: [user_id], references: [user_id], onDelete: NoAction, onUpdate: NoAction)
151
154
 
152
155
  @@map("sessions")
Binary file
Binary file