@protobase/server 0.21.6 → 0.21.8

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 (91) hide show
  1. package/dist/aggregate-groups.js +1 -1
  2. package/dist/aggregate-service.js +3 -3
  3. package/dist/ai/ai-fields.js +9 -0
  4. package/dist/ai/ai-model.js +9 -0
  5. package/dist/ai/check-ai.d.ts +13 -0
  6. package/dist/ai/check-ai.js +11 -0
  7. package/dist/ai/fill-hook.js +47 -0
  8. package/dist/ai/fill-job.js +67 -0
  9. package/dist/ai/generate-route.js +57 -0
  10. package/dist/ai/generate-value.js +28 -0
  11. package/dist/ai/values.js +15 -0
  12. package/dist/anonymous.js +7 -2
  13. package/dist/assistant/assistant-settings.d.ts +2 -2
  14. package/dist/assistant/assistant-settings.js +7 -21
  15. package/dist/assistant/built-in-assistant.js +2 -1
  16. package/dist/assistant/model-settings.js +31 -0
  17. package/dist/assistant/turn.d.ts +1 -1
  18. package/dist/assistant/turn.js +2 -2
  19. package/dist/batch/reorder.js +2 -2
  20. package/dist/batch/run-batch.js +1 -1
  21. package/dist/better-auth/create-auth.d.ts +12 -4
  22. package/dist/better-auth/create-auth.js +0 -1
  23. package/dist/better-auth/organizations/invitation-endpoints.js +1 -1
  24. package/dist/better-auth/organizations/member-endpoints.js +1 -1
  25. package/dist/better-auth/passkey-plugin.js +1 -1
  26. package/dist/better-auth/policy-plugin.js +1 -1
  27. package/dist/better-auth/roles/roles-plugin.js +1 -1
  28. package/dist/better-auth/sign-up/sign-up-plugin.js +1 -1
  29. package/dist/better-auth/staff-sign-in-endpoints.js +1 -1
  30. package/dist/better-auth/status-route.js +1 -1
  31. package/dist/changes/match-events.js +1 -1
  32. package/dist/check-roles.js +1 -1
  33. package/dist/check-shell.js +1 -1
  34. package/dist/check-views.js +26 -4
  35. package/dist/comments/app-origin.js +11 -0
  36. package/dist/comments/comment-access.js +54 -0
  37. package/dist/comments/comment-input.js +26 -0
  38. package/dist/comments/comment-item.d.ts +16 -0
  39. package/dist/comments/comment-item.js +18 -0
  40. package/dist/comments/comment-users.d.ts +21 -0
  41. package/dist/comments/comment-users.js +35 -0
  42. package/dist/comments/comments-sql.d.ts +8 -0
  43. package/dist/comments/comments-sql.js +37 -0
  44. package/dist/comments/mention-email.js +37 -0
  45. package/dist/comments/mention-job.d.ts +3 -0
  46. package/dist/comments/mention-job.js +43 -0
  47. package/dist/comments/mentionable.js +38 -0
  48. package/dist/comments/post-comment.js +57 -0
  49. package/dist/comments/read-comments.js +45 -0
  50. package/dist/comments/record-comments.js +53 -0
  51. package/dist/comments/record-label.js +19 -0
  52. package/dist/create-admin.d.ts +9 -3
  53. package/dist/create-admin.js +55 -11
  54. package/dist/deps.d.ts +2 -0
  55. package/dist/error-handler.js +1 -1
  56. package/dist/files/attach.js +1 -1
  57. package/dist/files/upload.js +2 -2
  58. package/dist/forms/challenge.d.ts +8 -0
  59. package/dist/forms/challenge.js +71 -0
  60. package/dist/forms/check-forms.js +59 -0
  61. package/dist/forms/rate-limit.js +38 -0
  62. package/dist/forms/routes.js +83 -0
  63. package/dist/forms/runtime.js +31 -0
  64. package/dist/history/read-history.js +4 -3
  65. package/dist/index.d.ts +7 -3
  66. package/dist/index.js +11 -9
  67. package/dist/jobs/runtime.js +1 -1
  68. package/dist/list-photos.js +3 -3
  69. package/dist/list-service.js +2 -2
  70. package/dist/map-service.js +1 -1
  71. package/dist/meta.js +4 -4
  72. package/dist/openapi/resource-paths.js +151 -0
  73. package/dist/project-config.d.ts +1 -1
  74. package/dist/read-service.js +2 -2
  75. package/dist/related-labels.js +1 -1
  76. package/dist/request-access.js +26 -2
  77. package/dist/routes/record.js +17 -0
  78. package/dist/row-permissions.js +3 -3
  79. package/dist/sql-parts.js +1 -1
  80. package/dist/types.d.ts +2 -0
  81. package/dist/validate-body.js +6 -1
  82. package/dist/view-access.js +35 -6
  83. package/dist/view-related.js +15 -2
  84. package/dist/webhooks/route-events.js +1 -1
  85. package/dist/webhooks/table/schema.js +1 -1
  86. package/dist/webhooks/table/webhook-table.js +1 -1
  87. package/dist/webhooks/webhooks.js +1 -1
  88. package/dist/write-pipeline.js +8 -5
  89. package/dist/write-shared.js +3 -2
  90. package/dist/write-update.js +1 -1
  91. package/package.json +5 -4
@@ -1,5 +1,6 @@
1
1
  import { dispatchJobName, isCaptured } from "../changes/capture-sql.js";
2
2
  import { defineJob } from "../jobs/define-job.js";
3
+ import { FatalJobError } from "../jobs/run-job.js";
3
4
  import { coalesce } from "../changes/coalesce.js";
4
5
  import { EventCodeError } from "../changes/event-code-error.js";
5
6
  import { eventMatcher } from "../changes/match-events.js";
@@ -7,7 +8,6 @@ import { deleteOutbox, readOutbox } from "../changes/outbox.js";
7
8
  import { resourceChange } from "../changes/resource-change.js";
8
9
  import { callerRecords } from "../functions/records.js";
9
10
  import { writeHistory } from "../history/write-history.js";
10
- import { FatalJobError } from "../jobs/run-job.js";
11
11
  import { maxTries, nextRetryDelay } from "./retry-schedule.js";
12
12
  import { subscriberEvents } from "./subscriber-view.js";
13
13
  import { attemptDelivery } from "./attempt.js";
@@ -1,10 +1,10 @@
1
1
  import { HttpProblem, badRequest } from "./problem.js";
2
- import { isDatabaseError } from "./error-handler.js";
3
- import { deleteRecord, fetchRecord, insertRecord, restoreRecord } from "./records.js";
4
2
  import { tenantScope } from "./tenant.js";
5
3
  import { requestAccess, requireOperation, targetFilter, writableFields } from "./request-access.js";
4
+ import { deleteRecord, fetchRecord, insertRecord, restoreRecord } from "./records.js";
6
5
  import { writeTransaction } from "./transactions.js";
7
6
  import { blockedDelete } from "./blocked-delete.js";
7
+ import { isDatabaseError } from "./error-handler.js";
8
8
  import { attachFiles } from "./files/attach.js";
9
9
  import { actorSettings, wakeDispatch } from "./changes/actor.js";
10
10
  import { validateBody } from "./validate-body.js";
@@ -91,9 +91,12 @@ const writeIn = async (trx, deps, access, request) => {
91
91
  if (request.operation === "update") return update(trx, deps, access, request);
92
92
  return removeOrRestore(trx, deps, access, request);
93
93
  };
94
- /** The path every single write takes: resolve access once, then `writeIn` in its own transaction with a statement timeout. The caller has already authenticated `session`. */
95
- const runWrite = async (deps, entry, session, request) => {
96
- const access = await requestAccess(deps, entry, session);
94
+ /**
95
+ * The path every single write takes: resolve access once, then `writeIn` in its own transaction with a statement timeout.
96
+ * The caller has already authenticated `session`; `form` is the public form a visitor creates through.
97
+ */
98
+ const runWrite = async (deps, entry, session, request, form) => {
99
+ const access = await requestAccess(deps, entry, session, form);
97
100
  requireOperation(access, request.operation === "undelete" ? "update" : request.operation);
98
101
  const result = await writeTransaction(deps.db, deps.statementTimeoutMs, (trx) => writeIn(trx, deps, access, request), actorSettings(deps, session));
99
102
  wakeDispatch(deps);
@@ -1,10 +1,10 @@
1
1
  import { forbidden, notFound, preconditionFailed, preconditionRequired } from "./problem.js";
2
+ import { tenantScope } from "./tenant.js";
3
+ import { andFilters, recordDecision } from "./request-access.js";
2
4
  import { presentFiles } from "./files/present.js";
3
5
  import { ifMatchSatisfied } from "./etag.js";
4
6
  import { pickFields } from "./rows.js";
5
7
  import { fetchRecord } from "./records.js";
6
- import { tenantScope } from "./tenant.js";
7
- import { andFilters, recordDecision } from "./request-access.js";
8
8
  import { scheduleRemovedFiles } from "./files/attach.js";
9
9
  //#region src/write-shared.ts
10
10
  const missing = (entry) => notFound(`No ${entry.name} with this key`);
@@ -45,6 +45,7 @@ const notifier = (deps, access) => async (trx, kind, before, after) => {
45
45
  resource: access.full,
46
46
  user: session.user,
47
47
  ...session.tenant !== void 0 && { tenant: session.tenant },
48
+ ...session.anonymous && { anonymous: true },
48
49
  ...before && { before },
49
50
  ...after && { after }
50
51
  };
@@ -1,6 +1,6 @@
1
- import { fetchRecord, updateRecord } from "./records.js";
2
1
  import { tenantScope } from "./tenant.js";
3
2
  import { targetFilter } from "./request-access.js";
3
+ import { fetchRecord, updateRecord } from "./records.js";
4
4
  import { attachFiles } from "./files/attach.js";
5
5
  import { validateBody } from "./validate-body.js";
6
6
  import { assertWritten, checkPrecondition, decide, denied, firstKeyField, missing, notifier } from "./write-shared.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/server",
3
- "version": "0.21.6",
3
+ "version": "0.21.8",
4
4
  "description": "The Protobase REST API as a Hono app, with Better Auth sign-in.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -30,13 +30,14 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@better-auth/passkey": "^1.7.7",
33
- "@protobase/layout": "0.21.6",
34
- "@protobase/query": "0.21.6",
35
- "@protobase/schema": "0.21.6",
33
+ "@protobase/layout": "0.21.8",
34
+ "@protobase/query": "0.21.8",
35
+ "@protobase/schema": "0.21.8",
36
36
  "@react-email/render": "^2.1.0",
37
37
  "@scalar/hono-api-reference": "^0.12.10",
38
38
  "@sentry/core": "^11.7.0",
39
39
  "@simplewebauthn/server": "^13.3.1",
40
+ "altcha-lib": "^2.6.0",
40
41
  "better-auth": "^1.7.7",
41
42
  "cron-parser": "^5.10.1",
42
43
  "file-type": "^22.1.1",