@tiddlywiki/mws 0.0.12 → 0.0.13

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 (65) hide show
  1. package/README.md +3 -1
  2. package/dist/server.d.ts +923 -0
  3. package/dist/server.js +1763 -1415
  4. package/dist/server.js.map +1 -1
  5. package/editions/mws-docs/tiddlers/$__StoryList.tid +3 -3
  6. package/editions/mws-docs/tiddlers/MWS and SQLite.md +11 -0
  7. package/editions/mws-docs/tiddlers/Request Server.md +20 -0
  8. package/editions/mws-docs/tiddlers/Request Server.md.meta +5 -0
  9. package/package.json +16 -10
  10. package/prisma/schema.prisma +1 -0
  11. package/react-user-mgmt/package-lock.json +76 -321
  12. package/react-user-mgmt/package.json +2 -5
  13. package/react-user-mgmt/public/chunk-YALWN5OT.js +2 -0
  14. package/react-user-mgmt/public/chunk-YALWN5OT.js.map +7 -0
  15. package/react-user-mgmt/public/esm-QKDFEP3B.js +3 -0
  16. package/react-user-mgmt/public/esm-QKDFEP3B.js.map +7 -0
  17. package/react-user-mgmt/public/index.html +1 -26
  18. package/react-user-mgmt/public/main.js +68 -109
  19. package/react-user-mgmt/public/main.js.map +4 -4
  20. package/react-user-mgmt/public/stats.css +597 -0
  21. package/react-user-mgmt/public/stats.html +59 -0
  22. package/react-user-mgmt/public/stats.js +2013 -0
  23. package/react-user-mgmt/public/stats.json +1 -0
  24. package/react-user-mgmt/public/stats.svg +4 -0
  25. package/react-user-mgmt/tsconfig.json +3 -0
  26. package/dist/server.cjs +0 -16677
  27. package/dist/server.cjs.map +0 -1
  28. package/src/StateObject.ts +0 -316
  29. package/src/commander.ts +0 -417
  30. package/src/commands/divider.ts +0 -20
  31. package/src/commands/index.ts +0 -24
  32. package/src/commands/mws-init-store.ts +0 -77
  33. package/src/commands/mws-listen.ts +0 -136
  34. package/src/commands/mws-load-archive.ts +0 -281
  35. package/src/commands/mws-load-plugin-bags.ts +0 -151
  36. package/src/commands/mws-load-tiddlers.ts +0 -37
  37. package/src/commands/mws-load-wiki-folder.ts +0 -124
  38. package/src/commands/mws-render-tiddlywiki5.ts +0 -55
  39. package/src/commands/mws-save-archive.ts +0 -111
  40. package/src/commands/mws-save-tiddler-text.ts +0 -33
  41. package/src/commands/tests-complete.ts +0 -21
  42. package/src/global.ts +0 -247
  43. package/src/routes/TiddlerStore.ts +0 -722
  44. package/src/routes/bag-file-server.ts +0 -340
  45. package/src/routes/cache.ts +0 -25
  46. package/src/routes/index.ts +0 -138
  47. package/src/routes/managers/index.ts +0 -17
  48. package/src/routes/managers/manager-recipes.ts +0 -438
  49. package/src/routes/managers/manager-users.ts +0 -201
  50. package/src/routes/managers/router-tiddlers.ts +0 -313
  51. package/src/routes/router.ts +0 -429
  52. package/src/routes/services/PasswordService.ts +0 -178
  53. package/src/routes/services/attachments.ts +0 -259
  54. package/src/routes/services/sessions.ts +0 -166
  55. package/src/routes/tw-test.ts +0 -65
  56. package/src/server.ts +0 -151
  57. package/src/setupDevServer.ts +0 -71
  58. package/src/streamer.ts +0 -430
  59. package/src/tiddlywiki.ts +0 -94
  60. package/src/utils/data-checks.ts +0 -172
  61. package/src/utils/index.ts +0 -4
  62. package/src/utils/rootRoute.ts +0 -237
  63. package/src/utils/utils.ts +0 -403
  64. package/src/utils/zodAssert.ts +0 -269
  65. /package/prisma/{migrations/notes.md → notes.md} +0 -0
@@ -1,5 +1,5 @@
1
- created: 20250418183134708
2
- list: HelloThere Installation Usage Reference
3
- modified: 20250418183248137
1
+ created: 20250426194618683
2
+ list: [[MWS and SQLite]] HelloThere Installation Usage Reference
3
+ modified: 20250426194618683
4
4
  title: $:/StoryList
5
5
  type: text/vnd.tiddlywiki
@@ -21,3 +21,14 @@ One particular misconception to avoid is the idea that SQLite replaces the folde
21
21
 
22
22
  SQLite is perfect for MWS because it doesn't require any extra setup. But MWS is not restricted to SQLite. It uses Prisma for the database access layer, which supports several other database engines, including MariaDB (the MySQL fork) and Postgres.
23
23
 
24
+ # Better-SQLite3
25
+
26
+ Currently WAL mode is not enabled. It has plenty of advantages, and a few minor disadvantages, but mostly it just takes extra thought to use correctly. It has more advantages for high-traffic servers that need serious concurrency. Better-SQLite3 defaults to synchronous=NORMAL for WAL mode. Eventually we will probably add a setting to enable it.
27
+
28
+ Better-SQLite3 supports multi-threading via Node workers. Either way we have to implement proper support for transactions, which mostly just means reserving a worker for the duration of the transaction.
29
+
30
+ Better-SQLite3 has foriegn keys enabled by default.
31
+
32
+ Better-SQLite3 uses native addons. If your platform isn't supported, or you need a wasm-only solution, feel free to [open an issue on Github](https://github.com/TiddlyWiki/MultiWikiServer) sharing your use-case.
33
+
34
+ MWS uses [Prisma](https://www.prisma.io) to communicate with SQLite, and in theory, MWS should work with [anything Prisma supports](https://www.prisma.io/docs/orm/overview/databases).
@@ -0,0 +1,20 @@
1
+
2
+ This is more or less a reference on the design philosophy.
3
+
4
+ ## HTTP request path
5
+
6
+ The server comprises several classes which handle various parts of the request path.
7
+
8
+ The Listener classes call the Router class with incoming requests. The Router class starts an async (Promise-based) code path with a catch handler protecting it.
9
+
10
+ There are two kinds of classes, routing and state.
11
+
12
+ Routing classes hold config state for that part of the request path. They are used to reach a specific objective. Examples include the Router and Authentication classes.
13
+
14
+ State classes hold information specific to each request. It may be used by any of the routing classes. The primary goal is usually to hide implementation details, or to pass information between routing classes. The StateObject class is the primary example, but modules may have their own state classes.
15
+
16
+ Both kinds of classes should check incoming information thoroughly and throw quickly if anything is wrong. The constructors of state classes are part of the request chain and may throw as well.
17
+
18
+ The request may be completed at any point in the request chain by throwing the STREAM_ENDED symbol. The catch all handler will ignore the symbol, but will send an error 500 if headers are not marked as sent at that point.
19
+
20
+ It is important that the entire request be awaited and eventually resolve or reject. A promise should never be left hanging. The Router class takes care of making sure every request has finished with some response, but if the promise never resolves or rejects, there is no way to do this.
@@ -0,0 +1,5 @@
1
+ created: 20250422233004101
2
+ modified: 20250422233027338
3
+ tags: [[Architecture]]
4
+ title: Request Server
5
+ type: text/markdown
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@tiddlywiki/mws",
3
- "version": "0.0.12",
3
+ "private": false,
4
+ "version": "0.0.13",
4
5
  "type": "module",
5
6
  "exports": {
6
7
  "types": "./src/server.ts",
@@ -9,12 +10,13 @@
9
10
  },
10
11
  "files": [
11
12
  "dist",
12
- "src",
13
13
  "prisma",
14
14
  "react-user-mgmt",
15
15
  "tiddlywiki-types",
16
16
  "editions/mws-docs",
17
- "plugins/client"
17
+ "plugins/client",
18
+ "libsql",
19
+ "libsql-android-arm64"
18
20
  ],
19
21
  "engines": {
20
22
  "node": ">14"
@@ -32,22 +34,26 @@
32
34
  "certs": "(cd runtime-config && bash localhost_certs.sh)",
33
35
  "start": "npm run build && node mws.dev.mjs",
34
36
  "build": "npm run tsc && tsup",
35
- "install": "prisma generate",
37
+ "install-android": "GYP_DEFINES=\"android_ndk_path=''\" npm install",
38
+ "postinstall": "env-cmd -e prisma-env prisma generate",
36
39
  "env": "env",
37
40
  "test:pack": "(git clean -dfx tests && npm pack --pack-destination tests && cd tests && npm install && npm install ./tiddlywiki-mws-$npm_package_version.tgz --no-save && npm test)",
38
41
  "test": "(git clean -dfx tests && cd tests && npm install .. --no-save && npm test)",
39
- "fulltest": "mv node_modules node_modules_old; npm run test:pack; mv node_modules_old node_modules"
42
+ "fulltest": "mv node_modules node_modules_old; npm run test:pack; mv node_modules_old node_modules",
43
+ "prisma:adapter:better": "cp -rfv ../prisma/packages/adapter-better-sqlite3/src/* src/adapter-better-sqlite3",
44
+ "prisma:adapter:libsql": "cp -rfv ../prisma/packages/adapter-libsql/src/* src/adapter-libsql"
40
45
  },
41
46
  "dependencies": {
42
- "@libsql/client": "^0.8.1",
43
- "@prisma/adapter-libsql": "~6.4.0",
44
- "@prisma/client": "~6.4.0",
47
+ "@prisma/adapter-better-sqlite3": "6.7.0-dev.48",
48
+ "@prisma/client": "6.6.0",
45
49
  "@serenity-kit/opaque": "^0.8.4",
46
50
  "@types/mime-types": "^2.1.4",
47
51
  "@types/node": "^22.13.1",
48
52
  "@types/send": "^0.17.4",
49
53
  "@types/sjcl": "^1.0.34",
50
- "prisma": "~6.4.0",
54
+ "@types/tiddlywiki": "file:tiddlywiki-types",
55
+ "env-cmd": "^10.1.0",
56
+ "prisma": "6.6.0",
51
57
  "source-map-support": "^0.5.21",
52
58
  "zod": "^3.24.2"
53
59
  },
@@ -64,4 +70,4 @@
64
70
  "peerDependencies": {
65
71
  "tiddlywiki": "^5.1.22"
66
72
  }
67
- }
73
+ }
@@ -7,6 +7,7 @@ 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
11
  }
11
12
 
12
13
  // generator zod {