@capybara-hq/kernel 0.1.0-rc.105 → 0.1.0-rc.107
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/admin/admin.schemas.d.ts +3 -0
- package/dist/agents/agents.schemas.d.ts +9 -9
- package/dist/{schedules/schedules.controller.d.ts → automations/automations.controller.d.ts} +37 -32
- package/dist/{schedules/schedules.controller.js → automations/automations.controller.js} +68 -57
- package/dist/automations/automations.module.d.ts +16 -0
- package/dist/{schedules/schedules.module.js → automations/automations.module.js} +18 -15
- package/dist/{schedules/schedules.schemas.d.ts → automations/automations.schemas.d.ts} +151 -50
- package/dist/automations/automations.schemas.js +253 -0
- package/dist/{schedules/scheduled-tasks.service.d.ts → automations/automations.service.d.ts} +99 -52
- package/dist/{schedules/scheduled-tasks.service.js → automations/automations.service.js} +303 -134
- package/dist/{schedules → automations}/calendar.d.ts +8 -8
- package/dist/{schedules → automations}/calendar.js +2 -2
- package/dist/automations/effective-settings.d.ts +28 -0
- package/dist/automations/effective-settings.js +25 -0
- package/dist/automations/errors.d.ts +19 -0
- package/dist/automations/errors.js +19 -0
- package/dist/automations/events/coalesce.d.ts +28 -0
- package/dist/automations/events/coalesce.js +131 -0
- package/dist/automations/events/deadline.d.ts +10 -0
- package/dist/automations/events/deadline.js +24 -0
- package/dist/automations/events/dispatcher.d.ts +74 -0
- package/dist/automations/events/dispatcher.js +353 -0
- package/dist/automations/events/events.module.d.ts +7 -0
- package/dist/automations/events/events.module.js +26 -0
- package/dist/automations/events/guards.d.ts +32 -0
- package/dist/automations/events/guards.js +87 -0
- package/dist/automations/events/sweep.job.d.ts +49 -0
- package/dist/automations/events/sweep.job.js +202 -0
- package/dist/automations/events/token.d.ts +5 -0
- package/dist/automations/events/token.js +5 -0
- package/dist/automations/events/trigger-events.service.d.ts +47 -0
- package/dist/automations/events/trigger-events.service.js +254 -0
- package/dist/{schedules → automations}/fire.d.ts +57 -17
- package/dist/{schedules → automations}/fire.js +311 -79
- package/dist/{schedules → automations}/grant-rules.d.ts +1 -1
- package/dist/{schedules → automations}/grant-rules.js +5 -5
- package/dist/automations/job-ids.d.ts +113 -0
- package/dist/automations/job-ids.js +117 -0
- package/dist/{schedules → automations}/pause.d.ts +3 -3
- package/dist/{schedules → automations}/pause.js +3 -3
- package/dist/{schedules → automations}/run-tracker.d.ts +21 -10
- package/dist/{schedules → automations}/run-tracker.js +68 -56
- package/dist/{schedules → automations}/scan.job.d.ts +12 -8
- package/dist/{schedules → automations}/scan.job.js +39 -23
- package/dist/{schedules → automations}/schedule-math.d.ts +19 -12
- package/dist/{schedules → automations}/schedule-math.js +17 -7
- package/dist/{schedules → automations}/store.d.ts +57 -27
- package/dist/{schedules → automations}/store.js +102 -52
- package/dist/automations/store.module.d.ts +6 -0
- package/dist/{schedules → automations}/store.module.js +9 -9
- package/dist/automations/types.d.ts +178 -0
- package/dist/{schedules → automations}/unattended.d.ts +22 -11
- package/dist/{schedules → automations}/unattended.js +53 -30
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/channels/channels.module.js +7 -6
- package/dist/channels/file-delivery.d.ts +26 -11
- package/dist/channels/file-delivery.js +32 -11
- package/dist/channels/outbound.d.ts +8 -8
- package/dist/channels/outbound.js +32 -30
- package/dist/channels/threads.d.ts +1 -1
- package/dist/channels/threads.js +1 -1
- package/dist/config/schema.d.ts +8 -1
- package/dist/config/schema.js +56 -6
- package/dist/conversations/approval-profile.d.ts +2 -2
- package/dist/conversations/approval-profile.js +3 -3
- package/dist/conversations/artifacts.d.ts +20 -17
- package/dist/conversations/artifacts.js +30 -37
- package/dist/conversations/attachments.controller.d.ts +6 -19
- package/dist/conversations/attachments.controller.js +8 -59
- package/dist/conversations/attachments.service.d.ts +30 -74
- package/dist/conversations/attachments.service.js +51 -193
- package/dist/conversations/conversations.controller.d.ts +7 -1
- package/dist/conversations/conversations.controller.js +26 -10
- package/dist/conversations/conversations.module.js +4 -0
- package/dist/conversations/conversations.service.d.ts +112 -35
- package/dist/conversations/conversations.service.js +160 -43
- package/dist/conversations/event-log.d.ts +1 -0
- package/dist/conversations/events.d.ts +95 -27
- package/dist/conversations/events.js +108 -10
- package/dist/conversations/files.d.ts +66 -64
- package/dist/conversations/files.js +127 -147
- package/dist/conversations/message-context.d.ts +2 -2
- package/dist/conversations/message-context.js +1 -1
- package/dist/conversations/permission-profile-store.d.ts +2 -1
- package/dist/conversations/permission-profiles.controller.d.ts +3 -0
- package/dist/conversations/permission-profiles.service.js +1 -1
- package/dist/conversations/prompt-suggestion-request.d.ts +1 -1
- package/dist/conversations/prompt-suggestion-request.js +4 -2
- package/dist/conversations/prompt-suggestions.d.ts +3 -3
- package/dist/conversations/prompt-suggestions.js +11 -10
- package/dist/conversations/queue.d.ts +7 -4
- package/dist/conversations/queue.js +6 -2
- package/dist/conversations/queue.service.d.ts +5 -5
- package/dist/conversations/queue.service.js +27 -16
- package/dist/ctx/create-ctx.d.ts +23 -2
- package/dist/ctx/create-ctx.js +78 -3
- package/dist/db/kernel-schema.d.ts +184 -27
- package/dist/devices/device-project-files.service.d.ts +88 -0
- package/dist/devices/device-project-files.service.js +249 -0
- package/dist/devices/device-projects.service.d.ts +40 -0
- package/dist/devices/device-projects.service.js +16 -13
- package/dist/devices/devices.controller.d.ts +9 -3
- package/dist/devices/devices.controller.js +27 -5
- package/dist/devices/devices.module.js +9 -1
- package/dist/devices/devices.schemas.js +6 -1
- package/dist/devices/dto.d.ts +15 -0
- package/dist/devices/dto.js +11 -0
- package/dist/devices/project-paths.d.ts +29 -0
- package/dist/devices/project-paths.js +66 -0
- package/dist/devices/project-rules.d.ts +5 -1
- package/dist/devices/project-rules.js +5 -1
- package/dist/errors.d.ts +53 -13
- package/dist/errors.js +53 -13
- package/dist/evals/canonical-json.d.ts +7 -0
- package/dist/evals/canonical-json.js +21 -0
- package/dist/evals/reconstruct.d.ts +10 -1
- package/dist/evals/reconstruct.js +20 -1
- package/dist/evals/recorded-tools.d.ts +0 -2
- package/dist/evals/recorded-tools.js +1 -16
- package/dist/evals/snapshot.d.ts +26 -3
- package/dist/evals/snapshot.js +110 -57
- package/dist/evals/worker.d.ts +4 -3
- package/dist/evals/worker.js +8 -4
- package/dist/extensions/host.d.ts +9 -2
- package/dist/extensions/host.js +12 -0
- package/dist/extensions/instance.d.ts +3 -1
- package/dist/extensions/instance.js +4 -0
- package/dist/extensions/ledger.d.ts +1 -1
- package/dist/extensions/permission-set.d.ts +17 -1
- package/dist/extensions/permission-set.js +13 -1
- package/dist/extensions/permission-view.d.ts +1 -1
- package/dist/extensions/permission-view.js +4 -1
- package/dist/files/blob-objects.d.ts +124 -0
- package/dist/files/blob-objects.js +341 -0
- package/dist/files/blob-sweep.job.d.ts +122 -0
- package/dist/files/blob-sweep.job.js +389 -0
- package/dist/files/blobs.service.d.ts +135 -0
- package/dist/files/blobs.service.js +300 -0
- package/dist/files/conversation-media.d.ts +41 -0
- package/dist/files/conversation-media.js +124 -0
- package/dist/files/deliveries.d.ts +64 -0
- package/dist/files/deliveries.js +156 -0
- package/dist/files/deliveries.module.d.ts +6 -0
- package/dist/files/deliveries.module.js +24 -0
- package/dist/files/draft-cleanup.job.d.ts +26 -0
- package/dist/files/draft-cleanup.job.js +93 -0
- package/dist/files/files.module.d.ts +1 -1
- package/dist/files/files.module.js +3 -2
- package/dist/files/hash-job.d.ts +127 -0
- package/dist/files/hash-job.js +447 -0
- package/dist/files/library-backfill.d.ts +63 -0
- package/dist/files/library-backfill.js +143 -0
- package/dist/files/library-files.service.d.ts +255 -0
- package/dist/files/library-files.service.js +883 -0
- package/dist/files/library-jobs.module.d.ts +8 -0
- package/dist/files/library-jobs.module.js +27 -0
- package/dist/files/library-query.d.ts +127 -0
- package/dist/files/library-query.js +322 -0
- package/dist/files/library-read.module.d.ts +9 -0
- package/dist/files/library-read.module.js +30 -0
- package/dist/files/library.controller.d.ts +77 -0
- package/dist/files/library.controller.js +235 -0
- package/dist/files/library.module.d.ts +9 -0
- package/dist/files/library.module.js +29 -0
- package/dist/files/library.schemas.d.ts +46 -0
- package/dist/files/library.schemas.js +49 -0
- package/dist/files/previewers.controller.d.ts +20 -0
- package/dist/files/previewers.controller.js +47 -0
- package/dist/files/previewers.d.ts +25 -11
- package/dist/files/previewers.js +43 -27
- package/dist/files/referenced-files.d.ts +150 -0
- package/dist/files/referenced-files.js +234 -0
- package/dist/git/gateway.js +2 -2
- package/dist/html/html-document.controller.d.ts +8 -1
- package/dist/html/html-document.controller.js +19 -1
- package/dist/html/html-document.service.d.ts +19 -4
- package/dist/html/html-document.service.js +43 -22
- package/dist/html/html-token.d.ts +10 -1
- package/dist/html/html-token.js +14 -0
- package/dist/html/html.module.js +8 -1
- package/dist/http/api.module.js +10 -5
- package/dist/http/request-signal.d.ts +8 -0
- package/dist/http/request-signal.js +14 -0
- package/dist/identity/settings.d.ts +26 -0
- package/dist/identity/settings.js +33 -2
- package/dist/inbox/inbox.module.js +2 -2
- package/dist/inbox/inbox.service.d.ts +8 -8
- package/dist/inbox/inbox.service.js +7 -7
- package/dist/infra/config/kernel-config.service.js +10 -5
- package/dist/infra/outbox/registry.d.ts +111 -2
- package/dist/infra/outbox/registry.js +104 -9
- package/dist/infra/throttler/named-throttlers.d.ts +2 -0
- package/dist/infra/throttler/named-throttlers.js +14 -0
- package/dist/kernel.module.js +3 -0
- package/dist/lifecycle/kernel-lifecycle.js +6 -0
- package/dist/models/purposes.js +1 -1
- package/dist/orgs/offboarding.js +1 -1
- package/dist/orgs/roles.d.ts +1 -1
- package/dist/orgs/roles.js +3 -3
- package/dist/orgs/settings.controller.d.ts +1 -1
- package/dist/orgs/settings.service.d.ts +75 -13
- package/dist/orgs/settings.service.js +104 -26
- package/dist/platform/exclusions.js +45 -8
- package/dist/platform/file-ref.d.ts +18 -3
- package/dist/platform/file-ref.js +22 -11
- package/dist/platform/operation.js +6 -2
- package/dist/platform/ops/admin.ops.js +5 -2
- package/dist/platform/ops/{schedules.ops.d.ts → automations.ops.d.ts} +4 -4
- package/dist/platform/ops/automations.ops.js +560 -0
- package/dist/platform/ops/devices.ops.d.ts +3 -1
- package/dist/platform/ops/devices.ops.js +77 -3
- package/dist/platform/ops/files.ops.d.ts +18 -0
- package/dist/platform/ops/files.ops.js +267 -0
- package/dist/platform/ops/inbox.ops.js +4 -4
- package/dist/platform/ops/org-settings.ops.js +6 -2
- package/dist/platform/ops/orgs.ops.js +2 -1
- package/dist/platform/ops/platform.ops.js +4 -4
- package/dist/platform/ops/shares.ops.js +2 -2
- package/dist/platform/platform-ops.module.d.ts +3 -2
- package/dist/platform/platform-ops.module.js +10 -5
- package/dist/platform/route-schemas.js +6 -3
- package/dist/push/jobs.d.ts +3 -3
- package/dist/push/jobs.js +2 -2
- package/dist/push/preferences.service.js +1 -1
- package/dist/push/push-owed.d.ts +3 -3
- package/dist/push/push-owed.js +6 -6
- package/dist/push/push.schemas.d.ts +4 -4
- package/dist/push/push.schemas.js +3 -3
- package/dist/push/recipients.d.ts +4 -4
- package/dist/push/recipients.js +23 -23
- package/dist/push/texts.d.ts +3 -3
- package/dist/push/texts.js +2 -2
- package/dist/push/triggers.d.ts +1 -1
- package/dist/roles/worker.module.js +18 -4
- package/dist/runtime/compaction-settings.service.d.ts +13 -1
- package/dist/runtime/compaction-settings.service.js +16 -1
- package/dist/runtime/compaction.service.d.ts +3 -1
- package/dist/runtime/compaction.service.js +3 -1
- package/dist/runtime/context/build.d.ts +24 -1
- package/dist/runtime/context/build.js +33 -11
- package/dist/runtime/context/cache-expiry.d.ts +31 -0
- package/dist/runtime/context/cache-expiry.js +60 -0
- package/dist/runtime/context/cache-ttl.d.ts +18 -0
- package/dist/runtime/context/cache-ttl.js +30 -0
- package/dist/runtime/context/compaction.d.ts +9 -2
- package/dist/runtime/context/compaction.js +64 -21
- package/dist/runtime/context/in-context-compaction.d.ts +156 -0
- package/dist/runtime/context/in-context-compaction.js +310 -0
- package/dist/runtime/context/run-context.d.ts +38 -0
- package/dist/runtime/context/run-context.js +54 -0
- package/dist/runtime/hook-calls.d.ts +2 -1
- package/dist/runtime/hook-calls.js +5 -2
- package/dist/runtime/maintenance.d.ts +16 -4
- package/dist/runtime/maintenance.js +79 -18
- package/dist/runtime/model-call.d.ts +34 -5
- package/dist/runtime/model-call.js +207 -22
- package/dist/runtime/providers.js +11 -1
- package/dist/runtime/run-finish.d.ts +4 -4
- package/dist/runtime/run-finish.js +3 -3
- package/dist/runtime/run-queue.js +12 -7
- package/dist/runtime/run-steps.d.ts +4 -2
- package/dist/runtime/run-steps.js +10 -5
- package/dist/runtime/run-worker.js +7 -1
- package/dist/runtime/runtime.module.js +6 -3
- package/dist/runtime/subagents/dispatch.js +11 -3
- package/dist/sandbox/browse-roots.d.ts +8 -0
- package/dist/sandbox/browse-roots.js +22 -0
- package/dist/sandbox/network-grants.d.ts +4 -4
- package/dist/sandbox/network-grants.js +7 -7
- package/dist/sandbox/operation-authority.d.ts +10 -3
- package/dist/sandbox/operation-authority.js +20 -10
- package/dist/sandbox/operation-intents.d.ts +3 -1
- package/dist/sandbox/operation-intents.js +11 -4
- package/dist/sandbox/permission-call-grants.js +2 -2
- package/dist/sandbox/permission-facts.js +1 -1
- package/dist/sandbox/review/classifier.d.ts +2 -2
- package/dist/sandbox/review/classifier.js +22 -11
- package/dist/sandbox/review/permission-candidate.d.ts +1 -1
- package/dist/sandbox/review/permission-candidate.js +1 -1
- package/dist/sandbox/sandbox.service.d.ts +15 -5
- package/dist/sandbox/sandbox.service.js +14 -8
- package/dist/shares/liveness.d.ts +26 -12
- package/dist/shares/liveness.js +79 -20
- package/dist/shares/revoke.d.ts +16 -11
- package/dist/shares/revoke.js +18 -14
- package/dist/shares/share-objects.d.ts +16 -21
- package/dist/shares/share-objects.js +25 -55
- package/dist/shares/share-open.service.d.ts +8 -4
- package/dist/shares/share-open.service.js +14 -11
- package/dist/shares/shares.controller.d.ts +16 -5
- package/dist/shares/shares.controller.js +39 -5
- package/dist/shares/shares.module.d.ts +4 -4
- package/dist/shares/shares.module.js +7 -6
- package/dist/shares/shares.schemas.d.ts +4 -0
- package/dist/shares/shares.schemas.js +2 -0
- package/dist/shares/shares.service.d.ts +93 -54
- package/dist/shares/shares.service.js +292 -131
- package/dist/shares/sweep.job.d.ts +18 -39
- package/dist/shares/sweep.job.js +47 -206
- package/dist/storage/purge.d.ts +1 -1
- package/dist/storage/purge.js +2 -2
- package/dist/tools/approvals.service.d.ts +6 -6
- package/dist/tools/approvals.service.js +19 -19
- package/dist/tools/builtin-names.d.ts +12 -12
- package/dist/tools/builtin-names.js +29 -29
- package/dist/tools/builtins/artifacts.d.ts +21 -13
- package/dist/tools/builtins/artifacts.js +81 -51
- package/dist/tools/builtins/{schedules.d.ts → automations.d.ts} +35 -33
- package/dist/tools/builtins/{schedules.js → automations.js} +236 -105
- package/dist/tools/builtins/builtin-tools.d.ts +15 -9
- package/dist/tools/builtins/builtin-tools.js +33 -22
- package/dist/tools/builtins/conversation-files.d.ts +23 -13
- package/dist/tools/builtins/conversation-files.js +62 -83
- package/dist/tools/builtins/image/generate.d.ts +7 -1
- package/dist/tools/builtins/image/generate.js +1 -1
- package/dist/tools/builtins/platform.js +1 -0
- package/dist/tools/builtins/sandbox/common.d.ts +6 -2
- package/dist/tools/builtins/sandbox/deliver.js +6 -7
- package/dist/tools/builtins/sandbox/fetch-attachment.d.ts +6 -5
- package/dist/tools/builtins/sandbox/fetch-attachment.js +19 -12
- package/dist/tools/call-scope.d.ts +1 -1
- package/dist/tools/git-asks.js +1 -1
- package/dist/tools/git-push-policy.d.ts +3 -3
- package/dist/tools/git-push-policy.js +6 -6
- package/dist/tools/network-asks.d.ts +3 -3
- package/dist/tools/network-asks.js +3 -3
- package/dist/tools/pipeline.d.ts +4 -4
- package/dist/tools/pipeline.js +2 -2
- package/dist/tools/policy.d.ts +3 -3
- package/dist/tools/policy.js +3 -3
- package/dist/tools/tools.module.js +15 -9
- package/dist/ui/call-extension.d.ts +6 -4
- package/dist/ui/call-extension.js +5 -4
- package/dist/ui/embed-token.js +6 -3
- package/dist/ui/registry.d.ts +21 -5
- package/dist/ui/registry.js +24 -6
- package/dist/ui/ui.schemas.d.ts +22 -0
- package/dist/ui/ui.schemas.js +22 -4
- package/dist/ui/views.controller.d.ts +13 -3
- package/dist/ui/views.controller.js +33 -2
- package/dist/ui/views.d.ts +29 -1
- package/dist/ui/views.js +131 -7
- package/package.json +3 -3
- package/src/migrations/0188_automations_rename.sql +309 -0
- package/src/migrations/0189_event_automations.sql +136 -0
- package/src/migrations/0190_file_library.sql +285 -0
- package/src/migrations/0191_file_library_copy.sql +4 -0
- package/dist/platform/ops/schedules.ops.js +0 -509
- package/dist/schedules/effective-settings.d.ts +0 -22
- package/dist/schedules/effective-settings.js +0 -18
- package/dist/schedules/errors.d.ts +0 -8
- package/dist/schedules/errors.js +0 -8
- package/dist/schedules/job-ids.d.ts +0 -81
- package/dist/schedules/job-ids.js +0 -95
- package/dist/schedules/schedules.module.d.ts +0 -16
- package/dist/schedules/schedules.schemas.js +0 -213
- package/dist/schedules/store.module.d.ts +0 -6
- package/dist/schedules/types.d.ts +0 -110
- /package/dist/{schedules → automations}/types.js +0 -0
|
@@ -15,6 +15,7 @@ import { sql } from "kysely";
|
|
|
15
15
|
import { isInlineArtifactType, isTextArtifactType } from "../conversations/artifacts.js";
|
|
16
16
|
import { FILE_CONTENT_MAX_BYTES, previewKind, readPrefix, trimUtf8, } from "../conversations/files.js";
|
|
17
17
|
import { ApiError } from "../errors.js";
|
|
18
|
+
import { BlobsService } from "../files/blobs.service.js";
|
|
18
19
|
import { PreviewerRegistry } from "../files/previewers.js";
|
|
19
20
|
import { HTML_TOKEN_TTL_SECONDS, HtmlTokens } from "../html/html-token.js";
|
|
20
21
|
import { isHtmlType } from "../html/html-type.js";
|
|
@@ -24,7 +25,6 @@ import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
|
24
25
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
25
26
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
26
27
|
import { CredentialThrottler } from "../infra/throttler/credential-throttler.js";
|
|
27
|
-
import { StorageService } from "../storage/storage.service.js";
|
|
28
28
|
import { ShareLiveness } from "./liveness.js";
|
|
29
29
|
/** The share-open throttler (`NAMED_THROTTLERS`): per client address, misses count. */
|
|
30
30
|
const THROTTLER = ["share-open"];
|
|
@@ -66,23 +66,26 @@ export function attachmentDisposition(name) {
|
|
|
66
66
|
* share needs a web session of an active member of the share's own org (not the session's current
|
|
67
67
|
* org): without one 401 `share.sign_in_required`, a signed-in non-member 404. `ShareLiveness`
|
|
68
68
|
* checks the share and its creator; this service checks the viewer. The bytes are always streamed
|
|
69
|
-
* by the kernel from the
|
|
69
|
+
* by the kernel from the share's blob (`BlobsService.open`: size and etag checked), never a
|
|
70
|
+
* presigned URL; nothing lives in process memory (the
|
|
70
71
|
* throttler and the open dedupe are Redis keys with a TTL).
|
|
71
72
|
*/
|
|
72
73
|
let ShareOpenService = class ShareOpenService {
|
|
73
74
|
db;
|
|
74
75
|
txHost;
|
|
75
76
|
liveness;
|
|
76
|
-
|
|
77
|
+
blobs;
|
|
77
78
|
tokens;
|
|
78
79
|
locks;
|
|
79
80
|
previewers;
|
|
80
81
|
throttler;
|
|
81
|
-
constructor(db, txHost, liveness,
|
|
82
|
+
constructor(db, txHost, liveness,
|
|
83
|
+
/** The share's blob, size and etag checked (a replaced object is not the snapshot). */
|
|
84
|
+
blobs, tokens, locks, previewers, throttler) {
|
|
82
85
|
this.db = db;
|
|
83
86
|
this.txHost = txHost;
|
|
84
87
|
this.liveness = liveness;
|
|
85
|
-
this.
|
|
88
|
+
this.blobs = blobs;
|
|
86
89
|
this.tokens = tokens;
|
|
87
90
|
this.locks = locks;
|
|
88
91
|
this.previewers = previewers;
|
|
@@ -146,7 +149,7 @@ let ShareOpenService = class ShareOpenService {
|
|
|
146
149
|
}
|
|
147
150
|
/** Streams the snapshot as `application/octet-stream` (spec §3); `download` adds the attachment name. */
|
|
148
151
|
async content(share, download, reply) {
|
|
149
|
-
const got = await this.
|
|
152
|
+
const got = await this.blobs.open(share.orgId, share.blob);
|
|
150
153
|
if (!got)
|
|
151
154
|
throw shareNotFound();
|
|
152
155
|
sandboxedBytes(reply)
|
|
@@ -166,9 +169,9 @@ let ShareOpenService = class ShareOpenService {
|
|
|
166
169
|
throw notPreviewable("Only text files have content");
|
|
167
170
|
}
|
|
168
171
|
const max = Math.min(limit, FILE_CONTENT_MAX_BYTES);
|
|
169
|
-
const got = await this.
|
|
170
|
-
|
|
171
|
-
|
|
172
|
+
const got = await this.blobs.open(share.orgId, share.blob, {
|
|
173
|
+
range: { start: 0, end: max - 1 },
|
|
174
|
+
});
|
|
172
175
|
if (!got)
|
|
173
176
|
throw shareNotFound();
|
|
174
177
|
let body = await readPrefix(got.body, max);
|
|
@@ -190,7 +193,7 @@ let ShareOpenService = class ShareOpenService {
|
|
|
190
193
|
async inline(share, reply) {
|
|
191
194
|
if (!isInlineArtifactType(share.contentType))
|
|
192
195
|
throw shareNotFound();
|
|
193
|
-
const got = await this.
|
|
196
|
+
const got = await this.blobs.open(share.orgId, share.blob);
|
|
194
197
|
if (!got)
|
|
195
198
|
throw shareNotFound();
|
|
196
199
|
const type = (share.contentType.split(";")[0] ?? "").trim().toLowerCase();
|
|
@@ -279,7 +282,7 @@ ShareOpenService = __decorate([
|
|
|
279
282
|
__param(0, Inject(KernelDb)),
|
|
280
283
|
__param(1, Inject(TransactionHost)),
|
|
281
284
|
__param(2, Inject(ShareLiveness)),
|
|
282
|
-
__param(3, Inject(
|
|
285
|
+
__param(3, Inject(BlobsService)),
|
|
283
286
|
__param(4, Inject(HtmlTokens)),
|
|
284
287
|
__param(5, Inject(LockService)),
|
|
285
288
|
__param(6, Inject(PreviewerRegistry)),
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import type { z } from "zod";
|
|
2
2
|
import { type Principal } from "../identity/principal.js";
|
|
3
3
|
import { type OrgContext } from "../orgs/org.guard.js";
|
|
4
|
-
import { CreateShareBody, ListSharesQuery, ShareFileParams, ShareIdParams } from "./shares.schemas.js";
|
|
4
|
+
import { CreateShareBody, LibraryShareParams, ListSharesQuery, ShareFileParams, ShareIdParams } from "./shares.schemas.js";
|
|
5
5
|
import { type SharePolicy, SharesService, type ShareView } from "./shares.service.js";
|
|
6
6
|
/**
|
|
7
|
-
* Shares of
|
|
8
|
-
* token is refused by `requireUser`). Creating and listing a file's shares
|
|
9
|
-
* owner (`ConversationAccess.isAccessible`, else `conversation.not_found`);
|
|
10
|
-
*
|
|
7
|
+
* Shares of files (file sharing spec §2, file library spec §6): `agents.use`, a person only (a
|
|
8
|
+
* service token is refused by `requireUser`). Creating and listing a conversation file's shares
|
|
9
|
+
* need the conversation's owner (`ConversationAccess.isAccessible`, else `conversation.not_found`);
|
|
10
|
+
* a library file's, the file's owner (else `file.not_found`); the anonymous guest creates none
|
|
11
|
+
* (`member.anonymous_guest`). Refreshing needs the creator, revoking the creator or an org admin
|
|
12
|
+
* (else `share.not_found`).
|
|
11
13
|
*/
|
|
12
14
|
export declare class SharesController {
|
|
13
15
|
private readonly shares;
|
|
@@ -21,6 +23,15 @@ export declare class SharesController {
|
|
|
21
23
|
shares: ShareView[];
|
|
22
24
|
policy: SharePolicy;
|
|
23
25
|
}>;
|
|
26
|
+
/** Shares one of the caller's library files (no conversation): 201 `{ share }`. */
|
|
27
|
+
createForFile(principal: Principal, org: OrgContext, params: z.infer<typeof LibraryShareParams>, body: z.infer<typeof CreateShareBody>): Promise<{
|
|
28
|
+
share: ShareView;
|
|
29
|
+
}>;
|
|
30
|
+
/** The live and recent shares the caller made of one library file (any version of it). */
|
|
31
|
+
forLibraryFile(principal: Principal, org: OrgContext, params: z.infer<typeof LibraryShareParams>): Promise<{
|
|
32
|
+
shares: ShareView[];
|
|
33
|
+
policy: SharePolicy;
|
|
34
|
+
}>;
|
|
24
35
|
/** "Update to latest": the newest available version as the next generation (creator only). */
|
|
25
36
|
refresh(principal: Principal, org: OrgContext, params: z.infer<typeof ShareIdParams>): Promise<{
|
|
26
37
|
share: ShareView;
|
|
@@ -12,10 +12,12 @@ import { CurrentPrincipal, patTokenId, requireUser, } from "../identity/principa
|
|
|
12
12
|
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
13
13
|
import { ZBody, ZParam, ZQuery } from "../infra/validation/zod-params.js";
|
|
14
14
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
15
|
-
import { CreateShareBody, ListSharesQuery, ShareFileParams, ShareIdParams, } from "./shares.schemas.js";
|
|
15
|
+
import { CreateShareBody, LibraryShareParams, ListSharesQuery, ShareFileParams, ShareIdParams, } from "./shares.schemas.js";
|
|
16
16
|
import { SharesService } from "./shares.service.js";
|
|
17
17
|
class ShareFileParamsDto extends createZodDto(ShareFileParams, "ShareFileParams") {
|
|
18
18
|
}
|
|
19
|
+
class LibraryShareParamsDto extends createZodDto(LibraryShareParams, "LibraryShareParams") {
|
|
20
|
+
}
|
|
19
21
|
class CreateShareBodyDto extends createZodDto(CreateShareBody, "CreateShareBody") {
|
|
20
22
|
}
|
|
21
23
|
class ShareIdParamsDto extends createZodDto(ShareIdParams, "ShareIdParams") {
|
|
@@ -23,10 +25,12 @@ class ShareIdParamsDto extends createZodDto(ShareIdParams, "ShareIdParams") {
|
|
|
23
25
|
class ListSharesQueryDto extends createZodDto(ListSharesQuery, "ListSharesQuery") {
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
26
|
-
* Shares of
|
|
27
|
-
* token is refused by `requireUser`). Creating and listing a file's shares
|
|
28
|
-
* owner (`ConversationAccess.isAccessible`, else `conversation.not_found`);
|
|
29
|
-
*
|
|
28
|
+
* Shares of files (file sharing spec §2, file library spec §6): `agents.use`, a person only (a
|
|
29
|
+
* service token is refused by `requireUser`). Creating and listing a conversation file's shares
|
|
30
|
+
* need the conversation's owner (`ConversationAccess.isAccessible`, else `conversation.not_found`);
|
|
31
|
+
* a library file's, the file's owner (else `file.not_found`); the anonymous guest creates none
|
|
32
|
+
* (`member.anonymous_guest`). Refreshing needs the creator, revoking the creator or an org admin
|
|
33
|
+
* (else `share.not_found`).
|
|
30
34
|
*/
|
|
31
35
|
let SharesController = class SharesController {
|
|
32
36
|
shares;
|
|
@@ -47,6 +51,20 @@ let SharesController = class SharesController {
|
|
|
47
51
|
const p = requireUser(principal);
|
|
48
52
|
return this.shares.forFile(org.orgId, p.account.id, params.id, params.fileId);
|
|
49
53
|
}
|
|
54
|
+
/** Shares one of the caller's library files (no conversation): 201 `{ share }`. */
|
|
55
|
+
async createForFile(principal, org, params, body) {
|
|
56
|
+
const p = requireUser(principal);
|
|
57
|
+
return {
|
|
58
|
+
share: await this.shares.createForFile(org.orgId, p.account.id, params.fileId, body, {
|
|
59
|
+
tokenId: patTokenId(p),
|
|
60
|
+
}),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/** The live and recent shares the caller made of one library file (any version of it). */
|
|
64
|
+
async forLibraryFile(principal, org, params) {
|
|
65
|
+
const p = requireUser(principal);
|
|
66
|
+
return this.shares.forLibraryFile(org.orgId, p.account.id, params.fileId);
|
|
67
|
+
}
|
|
50
68
|
/** "Update to latest": the newest available version as the next generation (creator only). */
|
|
51
69
|
async refresh(principal, org, params) {
|
|
52
70
|
const p = requireUser(principal);
|
|
@@ -83,6 +101,22 @@ __decorate([
|
|
|
83
101
|
__param(1, CurrentOrg()),
|
|
84
102
|
__param(2, ZParam(ShareFileParamsDto))
|
|
85
103
|
], SharesController.prototype, "forFile", null);
|
|
104
|
+
__decorate([
|
|
105
|
+
Post("files/:fileId/shares"),
|
|
106
|
+
OrgAction("agents.use"),
|
|
107
|
+
__param(0, CurrentPrincipal()),
|
|
108
|
+
__param(1, CurrentOrg()),
|
|
109
|
+
__param(2, ZParam(LibraryShareParamsDto)),
|
|
110
|
+
__param(3, ZBody(CreateShareBodyDto))
|
|
111
|
+
], SharesController.prototype, "createForFile", null);
|
|
112
|
+
__decorate([
|
|
113
|
+
Get("files/:fileId/shares"),
|
|
114
|
+
Header("cache-control", "private, no-store"),
|
|
115
|
+
OrgAction("agents.use"),
|
|
116
|
+
__param(0, CurrentPrincipal()),
|
|
117
|
+
__param(1, CurrentOrg()),
|
|
118
|
+
__param(2, ZParam(LibraryShareParamsDto))
|
|
119
|
+
], SharesController.prototype, "forLibraryFile", null);
|
|
86
120
|
__decorate([
|
|
87
121
|
Post("shares/:shareId/refresh"),
|
|
88
122
|
HttpCode(200),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* File sharing (file sharing spec): creating, refreshing, revoking and listing
|
|
3
|
-
* ({@link SharesService}), the live check the open routes use (`ShareLiveness`), the public
|
|
4
|
-
* routes' service (`ShareOpenService
|
|
5
|
-
* (`ShareObjects`).
|
|
2
|
+
* File sharing (file sharing spec, file library spec §6): creating, refreshing, revoking and listing
|
|
3
|
+
* shares ({@link SharesService}), the live check the open routes use (`ShareLiveness`), the public
|
|
4
|
+
* open routes' service (`ShareOpenService`, streaming the share's blob) and the legacy snapshot
|
|
5
|
+
* deletion the maintenance worker runs (`ShareObjects`).
|
|
6
6
|
*/
|
|
7
7
|
export declare class SharesModule {
|
|
8
8
|
}
|
|
@@ -7,18 +7,18 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { Module } from "@nestjs/common";
|
|
8
8
|
import { ConversationsModule } from "../conversations/conversations.module.js";
|
|
9
9
|
import { FilesModule } from "../files/files.module.js";
|
|
10
|
+
import { LibraryReadModule } from "../files/library-read.module.js";
|
|
10
11
|
import { HtmlTokensModule } from "../html/html-token.js";
|
|
11
12
|
import { OrgLockModule } from "../orgs/org-lock.js";
|
|
12
|
-
import { StorageModule } from "../storage/storage.module.js";
|
|
13
13
|
import { ShareLivenessModule } from "./liveness.js";
|
|
14
14
|
import { ShareObjectsModule } from "./share-objects.js";
|
|
15
15
|
import { ShareOpenService } from "./share-open.service.js";
|
|
16
16
|
import { SharesService } from "./shares.service.js";
|
|
17
17
|
/**
|
|
18
|
-
* File sharing (file sharing spec): creating, refreshing, revoking and listing
|
|
19
|
-
* ({@link SharesService}), the live check the open routes use (`ShareLiveness`), the public
|
|
20
|
-
* routes' service (`ShareOpenService
|
|
21
|
-
* (`ShareObjects`).
|
|
18
|
+
* File sharing (file sharing spec, file library spec §6): creating, refreshing, revoking and listing
|
|
19
|
+
* shares ({@link SharesService}), the live check the open routes use (`ShareLiveness`), the public
|
|
20
|
+
* open routes' service (`ShareOpenService`, streaming the share's blob) and the legacy snapshot
|
|
21
|
+
* deletion the maintenance worker runs (`ShareObjects`).
|
|
22
22
|
*/
|
|
23
23
|
let SharesModule = class SharesModule {
|
|
24
24
|
};
|
|
@@ -26,7 +26,8 @@ SharesModule = __decorate([
|
|
|
26
26
|
Module({
|
|
27
27
|
imports: [
|
|
28
28
|
ConversationsModule,
|
|
29
|
-
|
|
29
|
+
// the library files shares are made from and the blobs they point at
|
|
30
|
+
LibraryReadModule,
|
|
30
31
|
OrgLockModule,
|
|
31
32
|
ShareLivenessModule,
|
|
32
33
|
ShareObjectsModule,
|
|
@@ -5,6 +5,10 @@ export declare const ShareFileParams: z.ZodObject<{
|
|
|
5
5
|
id: z.ZodString;
|
|
6
6
|
fileId: z.ZodString;
|
|
7
7
|
}, z.core.$strip>;
|
|
8
|
+
/** `POST …/files/:fileId/shares` (a library file) and its per-file list. */
|
|
9
|
+
export declare const LibraryShareParams: z.ZodObject<{
|
|
10
|
+
fileId: z.ZodString;
|
|
11
|
+
}, z.core.$strip>;
|
|
8
12
|
/**
|
|
9
13
|
* A new share: who may open it and when it expires (days; null = never, internal only). An
|
|
10
14
|
* external share needs a non-null expiry within the platform maximum (`share.expiry_too_long`).
|
|
@@ -4,6 +4,8 @@ export const ShareFileParams = z.object({
|
|
|
4
4
|
id: z.string().min(1).max(100),
|
|
5
5
|
fileId: z.string().min(1).max(100),
|
|
6
6
|
});
|
|
7
|
+
/** `POST …/files/:fileId/shares` (a library file) and its per-file list. */
|
|
8
|
+
export const LibraryShareParams = z.object({ fileId: z.string().min(1).max(100) });
|
|
7
9
|
/**
|
|
8
10
|
* A new share: who may open it and when it expires (days; null = never, internal only). An
|
|
9
11
|
* external share needs a non-null expiry within the platform maximum (`share.expiry_too_long`).
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import { ConversationAccess } from "../conversations/access.js";
|
|
2
2
|
import { ConversationFiles } from "../conversations/files.js";
|
|
3
|
+
import { type BlobRef, BlobsService } from "../files/blobs.service.js";
|
|
4
|
+
import { ReferencedFiles } from "../files/referenced-files.js";
|
|
3
5
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
4
6
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
5
7
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
6
8
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
7
|
-
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
8
9
|
import type { KernelLogger } from "../log.js";
|
|
9
10
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
10
|
-
import { StorageService } from "../storage/storage.service.js";
|
|
11
11
|
import { type ExternalSharingState } from "./settings.js";
|
|
12
12
|
/**
|
|
13
|
-
* Shares of
|
|
14
|
-
* file,
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
13
|
+
* Shares of files (file sharing spec §1, §2; file library spec §6): a share is a frozen snapshot of
|
|
14
|
+
* one file, which is the file's blob: the row points at it (`blob_id`, locked `ready` by
|
|
15
|
+
* `BlobsService.lockReady` in the transaction that writes the pointer), so nothing is copied and
|
|
16
|
+
* nothing is owed when the share stops (the blob sweep frees a blob no file or share needs). A share
|
|
17
|
+
* is made from a conversation (its file, `conversation_id` set) or from the library (`conversation_id`
|
|
18
|
+
* null); either names the library file it came from (`source_file_id`). Nothing is held in process
|
|
19
|
+
* memory; every read is live.
|
|
18
20
|
*/
|
|
19
21
|
/**
|
|
20
22
|
* `live`: opens now. `suspended`: not revoked or expired, but it does not open now: an external
|
|
@@ -30,7 +32,7 @@ export interface ShareView {
|
|
|
30
32
|
*/
|
|
31
33
|
url: string | null;
|
|
32
34
|
audience: "internal" | "external";
|
|
33
|
-
conversationId: string;
|
|
35
|
+
conversationId: string | null;
|
|
34
36
|
fileId: string;
|
|
35
37
|
sourcePath: string | null;
|
|
36
38
|
name: string;
|
|
@@ -49,9 +51,9 @@ export interface ShareView {
|
|
|
49
51
|
revokedAt: string | null;
|
|
50
52
|
revokeReason: string | null;
|
|
51
53
|
/**
|
|
52
|
-
*
|
|
53
|
-
* per-file
|
|
54
|
-
* counts; in the org and personal lists the
|
|
54
|
+
* The creator has a newer ready version of the snapshot's file (same source conversation and
|
|
55
|
+
* `sourcePath`; refresh offered). In the per-file lists only a version whose bytes are still
|
|
56
|
+
* stored counts; in the org and personal lists the file rows alone decide (no storage reads).
|
|
55
57
|
*/
|
|
56
58
|
newerVersion: boolean;
|
|
57
59
|
}
|
|
@@ -69,80 +71,93 @@ export interface ShareActor {
|
|
|
69
71
|
export declare const SHARE_RECENT_DAYS = 7;
|
|
70
72
|
/** The most shares one list returns (newest first). */
|
|
71
73
|
export declare const SHARES_LIST_MAX = 500;
|
|
74
|
+
/** The file a share snapshots: its row and its blob (read after the viewer's checks). */
|
|
75
|
+
interface ShareSource {
|
|
76
|
+
id: string;
|
|
77
|
+
name: string;
|
|
78
|
+
contentType: string;
|
|
79
|
+
/** The version group of a delivered file; null for an upload. */
|
|
80
|
+
sourcePath: string | null;
|
|
81
|
+
blob: BlobRef;
|
|
82
|
+
}
|
|
72
83
|
export declare class SharesService {
|
|
73
84
|
private readonly db;
|
|
74
85
|
readonly txHost: TransactionHost;
|
|
75
86
|
private readonly files;
|
|
87
|
+
private readonly library;
|
|
88
|
+
private readonly blobs;
|
|
76
89
|
private readonly access;
|
|
77
|
-
private readonly storage;
|
|
78
|
-
private readonly outbox;
|
|
79
90
|
private readonly orgLock;
|
|
80
91
|
private readonly locks;
|
|
81
92
|
private readonly config;
|
|
82
93
|
private readonly log?;
|
|
83
|
-
constructor(db: KernelDb, txHost: TransactionHost, files: Pick<ConversationFiles, "file" | "identify"
|
|
94
|
+
constructor(db: KernelDb, txHost: TransactionHost, files: Pick<ConversationFiles, "file" | "identify">, library: Pick<ReferencedFiles, "owned">, blobs: Pick<BlobsService, "lockReady" | "head">, access: Pick<ConversationAccess, "isAccessible">, orgLock: Pick<OrgLock, "lockAndAuthorize">, locks: Pick<LockService, "run">, config: Pick<KernelConfigService, "get" | "fieldSource">, log?: KernelLogger | undefined);
|
|
84
95
|
/** The effective external switch for the org and the platform's expiry maximum, read live. */
|
|
85
96
|
policy(orgId: string): Promise<SharePolicy>;
|
|
86
97
|
/**
|
|
87
98
|
* Shares one file of the viewer's conversation (any version shown in the panel, or an
|
|
88
|
-
* attachment sent in it)
|
|
89
|
-
*
|
|
90
|
-
* collision retries the insert with a new code (the object is keyed by the id, not the code).
|
|
99
|
+
* attachment sent in it): {@link insertShare} points the row at the file's blob. The anonymous
|
|
100
|
+
* guest cannot share (`member.anonymous_guest`).
|
|
91
101
|
*/
|
|
92
102
|
create(orgId: string, accountId: string, conversationId: string, fileId: string, body: {
|
|
93
103
|
audience: "internal" | "external";
|
|
94
104
|
expiresInDays: 1 | 7 | 30 | null;
|
|
95
105
|
}, actor?: ShareActor): Promise<ShareView>;
|
|
96
106
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
|
|
107
|
+
* Shares one of the viewer's library files (file library spec §6): the file must be the
|
|
108
|
+
* viewer's and `ready` (else `file.not_found`) with its bytes still stored (else
|
|
109
|
+
* `share.file_unavailable`). The share has no conversation. The anonymous guest cannot share.
|
|
110
|
+
*/
|
|
111
|
+
createForFile(orgId: string, accountId: string, fileId: string, body: {
|
|
112
|
+
audience: "internal" | "external";
|
|
113
|
+
expiresInDays: 1 | 7 | 30 | null;
|
|
114
|
+
}, actor?: ShareActor): Promise<ShareView>;
|
|
115
|
+
/** The policy checks of a new share, then its insert (a code collision retries with a new code). */
|
|
116
|
+
private insertWithCode;
|
|
117
|
+
/**
|
|
118
|
+
* The row and audit of a new share. A conversation's share locks the conversation `FOR SHARE`
|
|
119
|
+
* (a concurrent delete waits and then revokes this share too) and checks the viewer's access
|
|
120
|
+
* again. Either kind locks the file row `FOR SHARE` while it is the creator's and `ready` (a
|
|
121
|
+
* concurrent delete waits and then revokes this share too) and the blob through
|
|
122
|
+
* `BlobsService.lockReady` (a blob a deletion claimed is never pointed at again); a file deleted
|
|
123
|
+
* or bytes claimed meanwhile → `share.file_unavailable`. Internal: called by {@link create} and
|
|
124
|
+
* {@link createForFile} only.
|
|
101
125
|
*/
|
|
102
126
|
insertShare(s: {
|
|
103
127
|
id: string;
|
|
104
128
|
orgId: string;
|
|
105
129
|
code: string;
|
|
106
|
-
conversationId: string;
|
|
107
|
-
|
|
108
|
-
sourcePath: string | null;
|
|
130
|
+
conversationId: string | null;
|
|
131
|
+
file: ShareSource;
|
|
109
132
|
accountId: string;
|
|
110
133
|
audience: "internal" | "external";
|
|
111
|
-
name: string;
|
|
112
|
-
contentType: string;
|
|
113
|
-
size: number;
|
|
114
|
-
objectKey: string;
|
|
115
134
|
expiresInDays: number | null;
|
|
116
135
|
}, actor: ShareActor): Promise<void>;
|
|
117
136
|
/**
|
|
118
|
-
* "Update to latest" (creator only):
|
|
119
|
-
*
|
|
120
|
-
* {@link
|
|
121
|
-
*
|
|
122
|
-
*
|
|
137
|
+
* "Update to latest" (creator only): points the share at the creator's newest ready version of
|
|
138
|
+
* the same file (same source conversation and source path) made after the current one whose
|
|
139
|
+
* bytes are still stored ({@link nextVersion}), as the next generation under the same code; nothing
|
|
140
|
+
* is copied or deleted. A share of an upload has no versions (`validation_failed`). A
|
|
141
|
+
* conversation's share also needs the creator to still own the conversation. Refreshes of one
|
|
142
|
+
* share are serialized by a lock (taken outside any transaction).
|
|
123
143
|
*/
|
|
124
144
|
refresh(orgId: string, accountId: string, shareId: string, actor?: ShareActor): Promise<ShareView>;
|
|
125
145
|
/**
|
|
126
|
-
* The row move of a refresh: generation `from` → `from + 1`
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
* returns whether it moved. Internal: called by
|
|
146
|
+
* The row move of a refresh: generation `from` → `from + 1` pointing at `next`'s file and blob
|
|
147
|
+
* (the file locked while it is the creator's and `ready`, the blob through `lockReady`; either
|
|
148
|
+
* gone meanwhile → `share.file_unavailable`), `share.refreshed` audited. If the share was revoked
|
|
149
|
+
* or expired (or moved) meanwhile, nothing moves; returns whether it moved. Internal: called by
|
|
150
|
+
* {@link refresh} only.
|
|
130
151
|
*/
|
|
131
152
|
commitRefresh(at: {
|
|
132
153
|
orgId: string;
|
|
133
154
|
accountId: string;
|
|
134
155
|
shareId: string;
|
|
135
156
|
from: number;
|
|
136
|
-
},
|
|
137
|
-
fileId: string;
|
|
138
|
-
name: string;
|
|
139
|
-
contentType: string;
|
|
140
|
-
size: number;
|
|
141
|
-
objectKey: string;
|
|
142
|
-
}, actor: ShareActor): Promise<boolean>;
|
|
157
|
+
}, next: ShareSource, actor: ShareActor): Promise<boolean>;
|
|
143
158
|
/**
|
|
144
|
-
* Revokes a share (its creator, or an org admin with `org.update`; anyone else: `share.not_found`)
|
|
145
|
-
*
|
|
159
|
+
* Revokes a share (its creator, or an org admin with `org.update`; anyone else: `share.not_found`).
|
|
160
|
+
* Nothing is owed: the blob sweep frees the blob once nothing needs it. Idempotent: an already revoked share is left as it is, with
|
|
146
161
|
* no second audit. An admin's role is re-read under the org row lock (taken before the share row).
|
|
147
162
|
*/
|
|
148
163
|
revoke(orgId: string, accountId: string, shareId: string, actor?: ShareActor): Promise<void>;
|
|
@@ -154,6 +169,18 @@ export declare class SharesService {
|
|
|
154
169
|
shares: ShareView[];
|
|
155
170
|
policy: SharePolicy;
|
|
156
171
|
}>;
|
|
172
|
+
/**
|
|
173
|
+
* The live and recent shares the viewer made of one of their library files (file library spec
|
|
174
|
+
* §6): of any version of it (the same source conversation and source path) or, for an upload, of
|
|
175
|
+
* the file itself, from a conversation or from the library; newest first, with the share policy.
|
|
176
|
+
* Not the viewer's ready file → `file.not_found`.
|
|
177
|
+
*/
|
|
178
|
+
forLibraryFile(orgId: string, accountId: string, fileId: string): Promise<{
|
|
179
|
+
shares: ShareView[];
|
|
180
|
+
policy: SharePolicy;
|
|
181
|
+
}>;
|
|
182
|
+
/** The views of a per-file list: a newer version counts only while its bytes are stored. */
|
|
183
|
+
private confirmed;
|
|
157
184
|
/**
|
|
158
185
|
* The org's live and recent shares: the actor's own (`mine`), or every member's (`all`, org
|
|
159
186
|
* admins with `org.update`, re-read live; anyone else `forbidden`). Newest first, at most
|
|
@@ -168,16 +195,28 @@ export declare class SharesService {
|
|
|
168
195
|
private views;
|
|
169
196
|
private toView;
|
|
170
197
|
/**
|
|
171
|
-
* The file to share, after the viewer's access check: a delivered version, or an attachment
|
|
172
|
-
* stored
|
|
198
|
+
* The file to share, after the viewer's access check: a delivered version, or an attachment,
|
|
199
|
+
* whose stored bytes are still its blob's (else `share.file_unavailable`).
|
|
173
200
|
*/
|
|
174
201
|
private fileToShare;
|
|
202
|
+
/** One of the account's library files while it is `ready`; else `file.not_found`. */
|
|
203
|
+
private ownedReady;
|
|
204
|
+
/**
|
|
205
|
+
* In the caller's transaction: locks the file row `FOR SHARE` while it is the account's, `ready`
|
|
206
|
+
* and still on `blobId` (the blob the caller then locks; a hashing merge that moved the file
|
|
207
|
+
* meanwhile refuses), so a delete waits for the caller, then revokes what it wrote; false
|
|
208
|
+
* otherwise.
|
|
209
|
+
*/
|
|
210
|
+
private lockFile;
|
|
175
211
|
/**
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
212
|
+
* The creator's newest ready version of a share's file made after the current one (the same
|
|
213
|
+
* source conversation and source path; file library spec §6) whose bytes are still stored, or
|
|
214
|
+
* null. The current file is the share's `source_file_id` (else `file_id`); when it no longer
|
|
215
|
+
* exists, the group is the share's conversation and versions made after the share last moved.
|
|
216
|
+
* At most {@link FILE_VERSIONS_MAX} candidates are looked at. Reads storage: no transaction open.
|
|
179
217
|
*/
|
|
180
|
-
private
|
|
181
|
-
/**
|
|
182
|
-
private
|
|
218
|
+
private nextVersion;
|
|
219
|
+
/** The anonymous guest (channel guests, no sign-in) cannot share (file library spec §2). */
|
|
220
|
+
private rejectGuest;
|
|
183
221
|
}
|
|
222
|
+
export {};
|