@agent-native/core-corpus 0.216.0 → 0.218.0
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/corpus/README.md +1 -1
- package/corpus/templates/analytics/.agents/skills/session-replay/SKILL.md +61 -1
- package/corpus/templates/analytics/AGENTS.md +1 -1
- package/corpus/templates/analytics/CHANGELOG.md +3 -0
- package/corpus/templates/analytics/actions/get-session-replay-summary.ts +9 -65
- package/corpus/templates/analytics/actions/list-event-catalog.ts +1 -1
- package/corpus/templates/analytics/actions/list-session-outputs.ts +40 -0
- package/corpus/templates/analytics/actions/list-session-recordings.ts +17 -4
- package/corpus/templates/analytics/actions/view-screen.ts +29 -3
- package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +38 -167
- package/corpus/templates/analytics/app/i18n/en-US.ts +27 -0
- package/corpus/templates/analytics/app/pages/sessions/EventCatalogPage.tsx +18 -1
- package/corpus/templates/analytics/app/pages/sessions/SessionDetailPage.tsx +3 -1
- package/corpus/templates/analytics/app/pages/sessions/SessionOutputs.tsx +197 -0
- package/corpus/templates/analytics/app/pages/sessions/SessionsTriagePage.tsx +114 -4
- package/corpus/templates/analytics/changelog/2026-10-15-sessions-can-find-people-who-made-a-slides-deck-but-didn-t-p.md +6 -0
- package/corpus/templates/analytics/changelog/2026-10-16-owned-and-shared-chats-appear-in-separate-history-sections.md +6 -0
- package/corpus/templates/analytics/changelog/2026-10-16-the-activation-funnel-counts-visitors-who-decline-analytics-.md +6 -0
- package/corpus/templates/analytics/server/db/schema.ts +67 -0
- package/corpus/templates/analytics/server/lib/canonical-first-party-dashboard-repair.ts +9 -0
- package/corpus/templates/analytics/server/lib/first-party-analytics.ts +28 -22
- package/corpus/templates/analytics/server/lib/first-party-metric-catalog.ts +36 -1
- package/corpus/templates/analytics/server/lib/output-outcomes.ts +712 -0
- package/corpus/templates/analytics/server/lib/replay-origins.ts +33 -0
- package/corpus/templates/analytics/server/lib/session-event-index.ts +20 -0
- package/corpus/templates/analytics/server/lib/session-performance.ts +6 -40
- package/corpus/templates/analytics/server/lib/session-recording-associations.ts +30 -1
- package/corpus/templates/analytics/server/lib/session-replay-triage.ts +99 -0
- package/corpus/templates/analytics/server/lib/session-replay.ts +45 -31
- package/corpus/templates/analytics/server/lib/sessions-triage-lab.ts +8 -2
- package/corpus/templates/analytics/server/plugins/db.ts +46 -0
- package/corpus/templates/analytics/shared/output-use.ts +205 -0
- package/corpus/templates/analytics/shared/session-events.ts +6 -0
- package/corpus/templates/assets/CHANGELOG.md +6 -0
- package/corpus/templates/assets/app/components/layout/Sidebar.tsx +51 -117
- package/corpus/templates/assets/changelog/2026-10-16-owned-and-shared-chats-appear-in-separate-history-sections.md +6 -0
- package/corpus/templates/brain/app/components/layout/Sidebar.tsx +34 -101
- package/corpus/templates/brain/app/routes/sources.tsx +1 -1
- package/corpus/templates/brain/vitest.config.ts +7 -0
- package/corpus/templates/calendar/CHANGELOG.md +12 -0
- package/corpus/templates/calendar/actions/create-event.ts +2 -4
- package/corpus/templates/calendar/actions/update-event.ts +35 -6
- package/corpus/templates/calendar/app/pages/BookingLinksPage.tsx +1 -1
- package/corpus/templates/calendar/changelog/2026-10-16-booking-links-show-localized-visibility-badges.md +6 -0
- package/corpus/templates/calendar/changelog/2026-10-21-solo-events-avoid-notification-approval.md +6 -0
- package/corpus/templates/chat/app/components/layout/Sidebar.tsx +62 -101
- package/corpus/templates/clips/CHANGELOG.md +7 -20
- package/corpus/templates/clips/app/components/meetings/share-meeting-dialog.tsx +20 -77
- package/corpus/templates/clips/app/components/player/share-dialog.tsx +63 -90
- package/corpus/templates/clips/app/components/sharing/share-test-support.tsx +180 -0
- package/corpus/templates/clips/app/components/sharing/share-ui.tsx +5 -584
- package/corpus/templates/clips/changelog/2026-10-16-share-dialogs-make-it-easier-to-see-who-has-access-and-manag.md +6 -0
- package/corpus/templates/clips/changelog/2026-10-21-share-panels-describe-general-access-in-a-sentence.md +6 -0
- package/corpus/templates/community/qr/package.json +1 -1
- package/corpus/templates/content/.agents/skills/document-editing/references/databases.md +6 -3
- package/corpus/templates/content/CHANGELOG.md +10 -0
- package/corpus/templates/content/actions/_browser-document-save-attempt.ts +23 -1
- package/corpus/templates/content/actions/_builder-cms-blob-custody.ts +467 -0
- package/corpus/templates/content/actions/_builder-cms-execution-lease.ts +17 -0
- package/corpus/templates/content/actions/_builder-cms-intent-lookup.ts +5 -0
- package/corpus/templates/content/actions/_builder-cms-read-client.ts +881 -21
- package/corpus/templates/content/actions/_builder-cms-write-adapter.ts +28 -2
- package/corpus/templates/content/actions/_builder-cms-write-client.ts +109 -11
- package/corpus/templates/content/actions/_builder-docs-client.ts +1 -0
- package/corpus/templates/content/actions/_builder-private-blob.test-fixture.ts +90 -0
- package/corpus/templates/content/actions/_builder-source-execution-guard.ts +48 -0
- package/corpus/templates/content/actions/_content-save-outcomes.ts +5 -0
- package/corpus/templates/content/actions/_database-source-utils.ts +290 -8
- package/corpus/templates/content/actions/_database-utils.ts +93 -7
- package/corpus/templates/content/actions/_database-view-setup.ts +21 -2
- package/corpus/templates/content/actions/_delete-content-space.ts +8 -1
- package/corpus/templates/content/actions/_github-source-freshness.ts +30 -4
- package/corpus/templates/content/actions/add-content-database-source-field-property.ts +23 -6
- package/corpus/templates/content/actions/cancel-prepared-builder-source-update.ts +110 -26
- package/corpus/templates/content/actions/change-content-database-source-role.ts +51 -7
- package/corpus/templates/content/actions/delete-document.ts +41 -3
- package/corpus/templates/content/actions/disconnect-content-database-source.ts +68 -2
- package/corpus/templates/content/actions/disconnect-local-folder-source.ts +33 -2
- package/corpus/templates/content/actions/execute-builder-source-execution.ts +900 -140
- package/corpus/templates/content/actions/get-document.ts +2 -0
- package/corpus/templates/content/actions/permanently-delete-document.ts +6 -0
- package/corpus/templates/content/actions/prepare-builder-source-execution.ts +155 -13
- package/corpus/templates/content/actions/prepare-builder-source-review.ts +299 -73
- package/corpus/templates/content/actions/set-live-body-switch.ts +45 -0
- package/corpus/templates/content/actions/update-document.ts +139 -20
- package/corpus/templates/content/actions/validate-builder-source-execution.ts +135 -26
- package/corpus/templates/content/app/components/editor/CommentsSidebar.tsx +119 -30
- package/corpus/templates/content/app/components/editor/DocumentEditor.tsx +56 -13
- package/corpus/templates/content/app/components/editor/SuggestionText.tsx +18 -3
- package/corpus/templates/content/app/components/editor/VisualEditor.tsx +89 -22
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +23 -0
- package/corpus/templates/content/app/components/editor/database/GitHubSourceStatusLine.tsx +27 -2
- package/corpus/templates/content/app/components/editor/database/ListItemLayout.tsx +32 -8
- package/corpus/templates/content/app/components/editor/database/ListItemRow.tsx +27 -2
- package/corpus/templates/content/app/components/editor/database-sources/BuilderSourceReviewDialog.tsx +1 -0
- package/corpus/templates/content/app/components/editor/extensions/SuggestionHighlight.ts +383 -34
- package/corpus/templates/content/app/components/editor/suggestions/draft-session.ts +31 -0
- package/corpus/templates/content/app/components/editor/suggestions/presentation-rebase.ts +82 -4
- package/corpus/templates/content/app/global.css +31 -0
- package/corpus/templates/content/app/hooks/use-content-database.ts +40 -2
- package/corpus/templates/content/app/hooks/use-documents.ts +14 -0
- package/corpus/templates/content/app/i18n-data.ts +1 -0
- package/corpus/templates/content/changelog/2026-10-16-accepting-a-suggestion-on-a-page-that-changed-since-it-was-s.md +6 -0
- package/corpus/templates/content/changelog/2026-10-17-builder-content-avoids-retrying-a-write-when-builder-accepte.md +6 -0
- package/corpus/templates/content/changelog/2026-10-18-link-a-new-collection-to-a-github-folder-from-its-sources.md +1 -1
- package/corpus/templates/content/changelog/2026-10-20-builder-content-sync-keeps-read-and-write-status-accurate-wh.md +6 -0
- package/corpus/templates/content/changelog/2026-10-20-suggested-edits-that-add-remove-split-or-merge-paragraphs-li.md +6 -0
- package/corpus/templates/content/changelog/2026-10-21-list-rows-can-show-each-pages-first-lines.md +6 -0
- package/corpus/templates/content/changelog/2026-10-22-a-collection-linked-to-a-big-github-folder-fills-faster-and-p.md +6 -0
- package/corpus/templates/content/docs/product/capabilities/content.source.adapters.md +29 -0
- package/corpus/templates/content/parity/matrix.md +42 -42
- package/corpus/templates/content/parity/matrix.ts +3 -1
- package/corpus/templates/content/server/db/schema.ts +20 -0
- package/corpus/templates/content/server/lib/content-trash-purge.ts +15 -1
- package/corpus/templates/content/server/lib/live-body-writer.ts +138 -26
- package/corpus/templates/content/server/live-copy/binding.ts +31 -0
- package/corpus/templates/content/server/live-copy/bounded-task.d.ts +6 -0
- package/corpus/templates/content/server/live-copy/exec-db.ts +1 -0
- package/corpus/templates/content/server/live-copy/holds.ts +59 -0
- package/corpus/templates/content/server/live-copy/persist.ts +656 -0
- package/corpus/templates/content/server/live-copy/switch.ts +136 -0
- package/corpus/templates/content/server/live-copy/task-names.ts +4 -0
- package/corpus/templates/content/server/live-copy/tasks.ts +183 -0
- package/corpus/templates/content/server/live-copy/write-cause.ts +85 -0
- package/corpus/templates/content/server/live-copy/write.ts +85 -0
- package/corpus/templates/content/server/plugins/builder-private-payload-cleanup.ts +22 -0
- package/corpus/templates/content/server/plugins/collab.ts +3 -0
- package/corpus/templates/content/server/plugins/db.ts +28 -0
- package/corpus/templates/content/shared/api.ts +30 -1
- package/corpus/templates/content/shared/database-item-layout.ts +54 -22
- package/corpus/templates/content/shared/document-intent-merge.ts +16 -9
- package/corpus/templates/content/shared/og-description.ts +258 -36
- package/corpus/templates/content/shared/suggestion-diff.ts +23 -6
- package/corpus/templates/content/shared/suggestion-formatting.ts +44 -14
- package/corpus/templates/content/shared/suggestion-text.ts +20 -5
- package/corpus/templates/design/.agents/skills/design-templates/SKILL.md +5 -1
- package/corpus/templates/design/.generated/bridge/shader-runtime.generated.ts +25 -4
- package/corpus/templates/design/CHANGELOG.md +5 -0
- package/corpus/templates/design/actions/get-getting-started.ts +53 -0
- package/corpus/templates/design/app/components/design/DesignCanvas.tsx +10 -0
- package/corpus/templates/design/app/components/design/bridge/native-shader-runtime.bridge.ts +132 -79
- package/corpus/templates/design/app/components/design/bridge/native-source-provider.ts +268 -130
- package/corpus/templates/design/app/components/design/bridge/native-worker-scene-host.ts +122 -42
- package/corpus/templates/design/app/components/design/bridge/shader-runtime.bridge.ts +41 -4
- package/corpus/templates/design/app/components/design/design-canvas/text-content-change-result.ts +46 -12
- package/corpus/templates/design/app/components/home/DesignHomeLibrary.tsx +15 -8
- package/corpus/templates/design/app/components/layout/GettingStarted.tsx +50 -0
- package/corpus/templates/design/app/components/layout/Sidebar.tsx +3 -0
- package/corpus/templates/design/app/components/templates/DesignTemplateGrid.tsx +163 -0
- package/corpus/templates/design/app/components/templates/DesignTemplateLibrary.tsx +65 -78
- package/corpus/templates/design/app/components/templates/TemplatePreview.tsx +6 -2
- package/corpus/templates/design/app/global.css +6 -0
- package/corpus/templates/design/app/i18n/en-US.ts +17 -0
- package/corpus/templates/design/app/lib/canvas-load-outcome.ts +147 -0
- package/corpus/templates/design/app/lib/canvas-outcome-tracking.ts +531 -0
- package/corpus/templates/design/app/lib/canvas-style-kind.ts +50 -0
- package/corpus/templates/design/app/pages/DesignSystems.tsx +1 -1
- package/corpus/templates/design/app/pages/Index.tsx +28 -67
- package/corpus/templates/design/app/pages/design-editor/commands/commit-visual-styles.ts +86 -29
- package/corpus/templates/design/app/pages/design-editor/commands/save-file-content.ts +38 -3
- package/corpus/templates/design/app/pages/design-editor/domains/use-editor-core.ts +9 -0
- package/corpus/templates/design/app/pages/design-editor/domains/use-editor-files-and-saving.ts +2 -0
- package/corpus/templates/design/changelog/2026-10-16-design-pages-use-localized-visibility-badges-and-a-shared-ow.md +6 -0
- package/corpus/templates/design/changelog/2026-10-21-a-getting-started-checklist-at-the-bottom-of-the-sidebar-tra.md +6 -0
- package/corpus/templates/design/changelog/2026-10-21-templates-now-open-a-read-only-preview-from-the-card-and-the.md +6 -0
- package/corpus/templates/design/changelog/2026-10-22-collapsed-shader-layers-no-longer-interrupt-other-shaders-on.md +6 -0
- package/corpus/templates/design/changelog/2026-10-22-shader-fills-keep-rendering-when-other-screen-content-cannot.md +6 -0
- package/corpus/templates/design/scripts/design-export-validation/export-baseline.json +24 -0
- package/corpus/templates/design/server/lib/getting-started.ts +267 -0
- package/corpus/templates/design/server/plugins/getting-started.ts +5 -0
- package/corpus/templates/design/shared/design-template-presets/analytics-dashboard.ts +127 -0
- package/corpus/templates/design/shared/design-template-presets/design-studio.ts +98 -0
- package/corpus/templates/design/shared/design-template-presets/messaging-app.ts +101 -0
- package/corpus/templates/design/shared/design-template-presets/project-tasks.ts +120 -0
- package/corpus/templates/design/shared/design-template-presets.ts +8 -0
- package/corpus/templates/dispatch/CHANGELOG.md +4 -0
- package/corpus/templates/dispatch/app/i18n-data.ts +75 -0
- package/corpus/templates/dispatch/changelog/2026-10-21-owned-and-shared-chats-appear-in-separate-history-sections.md +6 -0
- package/corpus/templates/factory/app/components/layout/Sidebar.tsx +34 -100
- package/corpus/templates/forms/app/pages/FormsListPage.tsx +1 -1
- package/corpus/templates/forms/server/plugins/agent-chat.ts +1 -1
- package/corpus/templates/plan/CHANGELOG.md +6 -0
- package/corpus/templates/plan/app/components/layout/Sidebar.tsx +34 -109
- package/corpus/templates/plan/changelog/2026-10-16-owned-and-shared-chats-appear-in-separate-history-sections.md +6 -0
- package/corpus/templates/slides/CHANGELOG.md +7 -0
- package/corpus/templates/slides/actions/delete-deck.ts +7 -0
- package/corpus/templates/slides/app/components/deck/DeckCard.tsx +1 -1
- package/corpus/templates/slides/app/components/design-system/DesignSystemCard.tsx +1 -1
- package/corpus/templates/slides/app/pages/Index.tsx +7 -2
- package/corpus/templates/slides/changelog/2026-10-16-deck-lists-use-the-shared-ownership-filter-and-visibility-ba.md +6 -0
- package/corpus/templates/slides/changelog/2026-10-21-connected-deck-deletion-requires-approval.md +6 -0
- package/corpus/templates/slides/scripts/edit-fidelity/client-action.ts +61 -0
- package/corpus/templates/slides/scripts/edit-fidelity/run.ts +10 -0
- package/package.json +1 -1
- package/corpus/templates/chat/app/lib/sidebar-thread-state.ts +0 -29
- package/corpus/templates/slides/app/components/deck/DeckFilterMenu.tsx +0 -83
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineAction } from "@agent-native/core/action";
|
|
1
|
+
import { defineAction, fail } from "@agent-native/core/action";
|
|
2
2
|
import { assertAccess } from "@agent-native/core/sharing";
|
|
3
3
|
import { and, eq, inArray } from "drizzle-orm";
|
|
4
4
|
import { z } from "zod";
|
|
@@ -9,6 +9,13 @@ import type {
|
|
|
9
9
|
ContentDatabaseResponse,
|
|
10
10
|
DisconnectContentDatabaseSourceRequest,
|
|
11
11
|
} from "../shared/api.js";
|
|
12
|
+
import {
|
|
13
|
+
builderExecutionPayloadReference,
|
|
14
|
+
cleanupBuilderPrivatePayload,
|
|
15
|
+
enqueueBuilderPrivatePayloadCleanup,
|
|
16
|
+
isBuilderPrivatePayloadBoundToSource,
|
|
17
|
+
} from "./_builder-cms-blob-custody.js";
|
|
18
|
+
import { isBuilderExecutionClaimStale } from "./_builder-cms-execution-lease.js";
|
|
12
19
|
import { lockContentDatabaseMutation } from "./_content-database-mutation-lock.js";
|
|
13
20
|
import {
|
|
14
21
|
getExistingSource,
|
|
@@ -18,6 +25,7 @@ import { getContentDatabaseResponse } from "./_database-utils.js";
|
|
|
18
25
|
|
|
19
26
|
async function deleteSourceRecords(databaseId: string, sourceId: string) {
|
|
20
27
|
const db = getDb();
|
|
28
|
+
const deletedBlobReferences = new Set<string>();
|
|
21
29
|
await db.transaction(async (tx) => {
|
|
22
30
|
await lockContentDatabaseMutation(
|
|
23
31
|
tx as unknown as ReturnType<typeof getDb>,
|
|
@@ -36,6 +44,35 @@ async function deleteSourceRecords(databaseId: string, sourceId: string) {
|
|
|
36
44
|
),
|
|
37
45
|
);
|
|
38
46
|
if (!source) return;
|
|
47
|
+
const candidateExecutions = await tx
|
|
48
|
+
.select({
|
|
49
|
+
id: schema.contentDatabaseSourceExecutions.id,
|
|
50
|
+
state: schema.contentDatabaseSourceExecutions.state,
|
|
51
|
+
updatedAt: schema.contentDatabaseSourceExecutions.updatedAt,
|
|
52
|
+
})
|
|
53
|
+
.from(schema.contentDatabaseSourceExecutions)
|
|
54
|
+
.where(
|
|
55
|
+
and(
|
|
56
|
+
eq(schema.contentDatabaseSourceExecutions.sourceId, sourceId),
|
|
57
|
+
inArray(schema.contentDatabaseSourceExecutions.state, [
|
|
58
|
+
"running",
|
|
59
|
+
"response_received",
|
|
60
|
+
"reconciliation_required",
|
|
61
|
+
]),
|
|
62
|
+
),
|
|
63
|
+
);
|
|
64
|
+
const now = new Date().toISOString();
|
|
65
|
+
const activeExecutions = candidateExecutions.filter(
|
|
66
|
+
(execution) =>
|
|
67
|
+
execution.state !== "running" ||
|
|
68
|
+
!isBuilderExecutionClaimStale(execution.updatedAt, now),
|
|
69
|
+
);
|
|
70
|
+
if (activeExecutions.length > 0) {
|
|
71
|
+
fail(
|
|
72
|
+
"Cannot disconnect this source while a Builder execution is running or awaiting reconciliation.",
|
|
73
|
+
{ errorCode: "builder_execution_running", statusCode: 409 },
|
|
74
|
+
);
|
|
75
|
+
}
|
|
39
76
|
if (source.sourceType === "github") {
|
|
40
77
|
// Without the link, the pages are ordinary pages again and editable.
|
|
41
78
|
await tx
|
|
@@ -64,8 +101,34 @@ async function deleteSourceRecords(databaseId: string, sourceId: string) {
|
|
|
64
101
|
.delete(schema.contentDatabaseBodyHydrationQueue)
|
|
65
102
|
.where(eq(schema.contentDatabaseBodyHydrationQueue.sourceId, sourceId));
|
|
66
103
|
await tx
|
|
104
|
+
.delete(schema.contentDatabaseSourceExecutionClaims)
|
|
105
|
+
.where(
|
|
106
|
+
eq(schema.contentDatabaseSourceExecutionClaims.sourceId, sourceId),
|
|
107
|
+
);
|
|
108
|
+
const deletedExecutions = await tx
|
|
67
109
|
.delete(schema.contentDatabaseSourceExecutions)
|
|
68
|
-
.where(eq(schema.contentDatabaseSourceExecutions.sourceId, sourceId))
|
|
110
|
+
.where(eq(schema.contentDatabaseSourceExecutions.sourceId, sourceId))
|
|
111
|
+
.returning({
|
|
112
|
+
ownerEmail: schema.contentDatabaseSourceExecutions.ownerEmail,
|
|
113
|
+
payloadJson: schema.contentDatabaseSourceExecutions.payloadJson,
|
|
114
|
+
});
|
|
115
|
+
for (const row of deletedExecutions) {
|
|
116
|
+
const reference = builderExecutionPayloadReference(row.payloadJson);
|
|
117
|
+
if (
|
|
118
|
+
reference &&
|
|
119
|
+
isBuilderPrivatePayloadBoundToSource(
|
|
120
|
+
reference,
|
|
121
|
+
row.ownerEmail,
|
|
122
|
+
sourceId,
|
|
123
|
+
)
|
|
124
|
+
) {
|
|
125
|
+
deletedBlobReferences.add(reference);
|
|
126
|
+
await enqueueBuilderPrivatePayloadCleanup(
|
|
127
|
+
tx as unknown as ReturnType<typeof getDb>,
|
|
128
|
+
reference,
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
69
132
|
await tx
|
|
70
133
|
.delete(schema.contentDatabaseSourceChangeReviews)
|
|
71
134
|
.where(eq(schema.contentDatabaseSourceChangeReviews.sourceId, sourceId));
|
|
@@ -82,6 +145,9 @@ async function deleteSourceRecords(databaseId: string, sourceId: string) {
|
|
|
82
145
|
.delete(schema.contentDatabaseSources)
|
|
83
146
|
.where(eq(schema.contentDatabaseSources.id, sourceId));
|
|
84
147
|
});
|
|
148
|
+
for (const reference of deletedBlobReferences) {
|
|
149
|
+
await cleanupBuilderPrivatePayload(reference, "disconnected source");
|
|
150
|
+
}
|
|
85
151
|
}
|
|
86
152
|
|
|
87
153
|
export default defineAction({
|
|
@@ -4,6 +4,12 @@ import { and, eq, inArray, ne } from "drizzle-orm";
|
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
|
|
6
6
|
import { getDb, schema } from "../server/db/index.js";
|
|
7
|
+
import {
|
|
8
|
+
builderExecutionPayloadReference,
|
|
9
|
+
cleanupBuilderPrivatePayload,
|
|
10
|
+
enqueueBuilderPrivatePayloadCleanup,
|
|
11
|
+
isBuilderPrivatePayloadBoundToSource,
|
|
12
|
+
} from "./_builder-cms-blob-custody.js";
|
|
7
13
|
import { resolveContentSpaceAccess } from "./_content-space-access.js";
|
|
8
14
|
import { LOCAL_FOLDER_SOURCE_TYPE } from "./_local-folder-source.js";
|
|
9
15
|
|
|
@@ -38,6 +44,7 @@ export default defineAction({
|
|
|
38
44
|
const spaceId = target.database.spaceId;
|
|
39
45
|
let disconnectedDocuments = 0;
|
|
40
46
|
const now = new Date().toISOString();
|
|
47
|
+
const deletedBlobReferences = new Set<string>();
|
|
41
48
|
|
|
42
49
|
await db.transaction(async (tx: any) => {
|
|
43
50
|
const rows = await tx
|
|
@@ -48,9 +55,27 @@ export default defineAction({
|
|
|
48
55
|
...new Set<string>(rows.map((row: any) => String(row.documentId))),
|
|
49
56
|
];
|
|
50
57
|
disconnectedDocuments = documentIds.length;
|
|
51
|
-
await tx
|
|
58
|
+
const deletedExecutions = await tx
|
|
52
59
|
.delete(schema.contentDatabaseSourceExecutions)
|
|
53
|
-
.where(eq(schema.contentDatabaseSourceExecutions.sourceId, sourceId))
|
|
60
|
+
.where(eq(schema.contentDatabaseSourceExecutions.sourceId, sourceId))
|
|
61
|
+
.returning({
|
|
62
|
+
ownerEmail: schema.contentDatabaseSourceExecutions.ownerEmail,
|
|
63
|
+
payloadJson: schema.contentDatabaseSourceExecutions.payloadJson,
|
|
64
|
+
});
|
|
65
|
+
for (const row of deletedExecutions) {
|
|
66
|
+
const reference = builderExecutionPayloadReference(row.payloadJson);
|
|
67
|
+
if (
|
|
68
|
+
reference &&
|
|
69
|
+
isBuilderPrivatePayloadBoundToSource(
|
|
70
|
+
reference,
|
|
71
|
+
row.ownerEmail,
|
|
72
|
+
sourceId,
|
|
73
|
+
)
|
|
74
|
+
) {
|
|
75
|
+
deletedBlobReferences.add(reference);
|
|
76
|
+
await enqueueBuilderPrivatePayloadCleanup(tx, reference);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
54
79
|
await tx
|
|
55
80
|
.delete(schema.contentDatabaseSourceExecutionClaims)
|
|
56
81
|
.where(
|
|
@@ -164,6 +189,12 @@ export default defineAction({
|
|
|
164
189
|
);
|
|
165
190
|
}
|
|
166
191
|
});
|
|
192
|
+
for (const reference of deletedBlobReferences) {
|
|
193
|
+
await cleanupBuilderPrivatePayload(
|
|
194
|
+
reference,
|
|
195
|
+
"disconnected local folder source",
|
|
196
|
+
);
|
|
197
|
+
}
|
|
167
198
|
await writeAppState("refresh-signal", { ts: Date.now() });
|
|
168
199
|
return {
|
|
169
200
|
success: true,
|