@tiddlywiki/mws 0.0.12 → 0.0.14

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 (66) hide show
  1. package/.env-cmdrc +5 -0
  2. package/README.md +3 -1
  3. package/dist/server.d.ts +923 -0
  4. package/dist/server.js +1763 -1415
  5. package/dist/server.js.map +1 -1
  6. package/editions/mws-docs/tiddlers/$__StoryList.tid +3 -3
  7. package/editions/mws-docs/tiddlers/MWS and SQLite.md +11 -0
  8. package/editions/mws-docs/tiddlers/Request Server.md +20 -0
  9. package/editions/mws-docs/tiddlers/Request Server.md.meta +5 -0
  10. package/package.json +17 -10
  11. package/prisma/schema.prisma +1 -0
  12. package/react-user-mgmt/package-lock.json +76 -321
  13. package/react-user-mgmt/package.json +2 -5
  14. package/react-user-mgmt/public/chunk-YALWN5OT.js +2 -0
  15. package/react-user-mgmt/public/chunk-YALWN5OT.js.map +7 -0
  16. package/react-user-mgmt/public/esm-QKDFEP3B.js +3 -0
  17. package/react-user-mgmt/public/esm-QKDFEP3B.js.map +7 -0
  18. package/react-user-mgmt/public/index.html +1 -26
  19. package/react-user-mgmt/public/main.js +68 -109
  20. package/react-user-mgmt/public/main.js.map +4 -4
  21. package/react-user-mgmt/public/stats.css +597 -0
  22. package/react-user-mgmt/public/stats.html +59 -0
  23. package/react-user-mgmt/public/stats.js +2013 -0
  24. package/react-user-mgmt/public/stats.json +1 -0
  25. package/react-user-mgmt/public/stats.svg +4 -0
  26. package/react-user-mgmt/tsconfig.json +3 -0
  27. package/dist/server.cjs +0 -16677
  28. package/dist/server.cjs.map +0 -1
  29. package/src/StateObject.ts +0 -316
  30. package/src/commander.ts +0 -417
  31. package/src/commands/divider.ts +0 -20
  32. package/src/commands/index.ts +0 -24
  33. package/src/commands/mws-init-store.ts +0 -77
  34. package/src/commands/mws-listen.ts +0 -136
  35. package/src/commands/mws-load-archive.ts +0 -281
  36. package/src/commands/mws-load-plugin-bags.ts +0 -151
  37. package/src/commands/mws-load-tiddlers.ts +0 -37
  38. package/src/commands/mws-load-wiki-folder.ts +0 -124
  39. package/src/commands/mws-render-tiddlywiki5.ts +0 -55
  40. package/src/commands/mws-save-archive.ts +0 -111
  41. package/src/commands/mws-save-tiddler-text.ts +0 -33
  42. package/src/commands/tests-complete.ts +0 -21
  43. package/src/global.ts +0 -247
  44. package/src/routes/TiddlerStore.ts +0 -722
  45. package/src/routes/bag-file-server.ts +0 -340
  46. package/src/routes/cache.ts +0 -25
  47. package/src/routes/index.ts +0 -138
  48. package/src/routes/managers/index.ts +0 -17
  49. package/src/routes/managers/manager-recipes.ts +0 -438
  50. package/src/routes/managers/manager-users.ts +0 -201
  51. package/src/routes/managers/router-tiddlers.ts +0 -313
  52. package/src/routes/router.ts +0 -429
  53. package/src/routes/services/PasswordService.ts +0 -178
  54. package/src/routes/services/attachments.ts +0 -259
  55. package/src/routes/services/sessions.ts +0 -166
  56. package/src/routes/tw-test.ts +0 -65
  57. package/src/server.ts +0 -151
  58. package/src/setupDevServer.ts +0 -71
  59. package/src/streamer.ts +0 -430
  60. package/src/tiddlywiki.ts +0 -94
  61. package/src/utils/data-checks.ts +0 -172
  62. package/src/utils/index.ts +0 -4
  63. package/src/utils/rootRoute.ts +0 -237
  64. package/src/utils/utils.ts +0 -403
  65. package/src/utils/zodAssert.ts +0 -269
  66. /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.14",
4
5
  "type": "module",
5
6
  "exports": {
6
7
  "types": "./src/server.ts",
@@ -9,12 +10,14 @@
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",
20
+ ".env-cmdrc"
18
21
  ],
19
22
  "engines": {
20
23
  "node": ">14"
@@ -32,22 +35,26 @@
32
35
  "certs": "(cd runtime-config && bash localhost_certs.sh)",
33
36
  "start": "npm run build && node mws.dev.mjs",
34
37
  "build": "npm run tsc && tsup",
35
- "install": "prisma generate",
38
+ "install-android": "GYP_DEFINES=\"android_ndk_path=''\" npm install",
39
+ "postinstall": "env-cmd -e prisma-env prisma generate",
36
40
  "env": "env",
37
41
  "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
42
  "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"
43
+ "fulltest": "mv node_modules node_modules_old; npm run test:pack; mv node_modules_old node_modules",
44
+ "prisma:adapter:better": "cp -rfv ../prisma/packages/adapter-better-sqlite3/src/* src/adapter-better-sqlite3",
45
+ "prisma:adapter:libsql": "cp -rfv ../prisma/packages/adapter-libsql/src/* src/adapter-libsql"
40
46
  },
41
47
  "dependencies": {
42
- "@libsql/client": "^0.8.1",
43
- "@prisma/adapter-libsql": "~6.4.0",
44
- "@prisma/client": "~6.4.0",
48
+ "@prisma/adapter-better-sqlite3": "6.7.0-dev.48",
49
+ "@prisma/client": "6.6.0",
45
50
  "@serenity-kit/opaque": "^0.8.4",
46
51
  "@types/mime-types": "^2.1.4",
47
52
  "@types/node": "^22.13.1",
48
53
  "@types/send": "^0.17.4",
49
54
  "@types/sjcl": "^1.0.34",
50
- "prisma": "~6.4.0",
55
+ "@types/tiddlywiki": "file:tiddlywiki-types",
56
+ "env-cmd": "^10.1.0",
57
+ "prisma": "6.6.0",
51
58
  "source-map-support": "^0.5.21",
52
59
  "zod": "^3.24.2"
53
60
  },
@@ -64,4 +71,4 @@
64
71
  "peerDependencies": {
65
72
  "tiddlywiki": "^5.1.22"
66
73
  }
67
- }
74
+ }
@@ -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 {