convex-cms 0.0.1
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/cli/commands/admin.d.ts +16 -0
- package/dist/cli/commands/admin.d.ts.map +1 -0
- package/dist/cli/commands/admin.js +88 -0
- package/dist/cli/commands/admin.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +18 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/utils/detectConvexUrl.d.ts +13 -0
- package/dist/cli/utils/detectConvexUrl.d.ts.map +1 -0
- package/dist/cli/utils/detectConvexUrl.js +48 -0
- package/dist/cli/utils/detectConvexUrl.js.map +1 -0
- package/dist/cli/utils/openBrowser.d.ts +7 -0
- package/dist/cli/utils/openBrowser.d.ts.map +1 -0
- package/dist/cli/utils/openBrowser.js +17 -0
- package/dist/cli/utils/openBrowser.js.map +1 -0
- package/dist/client/admin-config.d.ts +126 -0
- package/dist/client/admin-config.d.ts.map +1 -0
- package/dist/client/admin-config.js +117 -0
- package/dist/client/admin-config.js.map +1 -0
- package/dist/client/adminApi.d.ts +2273 -0
- package/dist/client/adminApi.d.ts.map +1 -0
- package/dist/client/adminApi.js +716 -0
- package/dist/client/adminApi.js.map +1 -0
- package/dist/client/agentTools.d.ts +933 -0
- package/dist/client/agentTools.d.ts.map +1 -0
- package/dist/client/agentTools.js +1004 -0
- package/dist/client/agentTools.js.map +1 -0
- package/dist/client/argTypes.d.ts +212 -0
- package/dist/client/argTypes.d.ts.map +1 -0
- package/dist/client/argTypes.js +5 -0
- package/dist/client/argTypes.js.map +1 -0
- package/dist/client/field-types.d.ts +55 -0
- package/dist/client/field-types.d.ts.map +1 -0
- package/dist/client/field-types.js +152 -0
- package/dist/client/field-types.js.map +1 -0
- package/dist/client/index.d.ts +189 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +668 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/queryBuilder.d.ts +765 -0
- package/dist/client/queryBuilder.d.ts.map +1 -0
- package/dist/client/queryBuilder.js +970 -0
- package/dist/client/queryBuilder.js.map +1 -0
- package/dist/client/schema/codegen.d.ts +128 -0
- package/dist/client/schema/codegen.d.ts.map +1 -0
- package/dist/client/schema/codegen.js +318 -0
- package/dist/client/schema/codegen.js.map +1 -0
- package/dist/client/schema/defineContentType.d.ts +221 -0
- package/dist/client/schema/defineContentType.d.ts.map +1 -0
- package/dist/client/schema/defineContentType.js +380 -0
- package/dist/client/schema/defineContentType.js.map +1 -0
- package/dist/client/schema/index.d.ts +85 -0
- package/dist/client/schema/index.d.ts.map +1 -0
- package/dist/client/schema/index.js +92 -0
- package/dist/client/schema/index.js.map +1 -0
- package/dist/client/schema/schemaDrift.d.ts +199 -0
- package/dist/client/schema/schemaDrift.d.ts.map +1 -0
- package/dist/client/schema/schemaDrift.js +340 -0
- package/dist/client/schema/schemaDrift.js.map +1 -0
- package/dist/client/schema/typedClient.d.ts +401 -0
- package/dist/client/schema/typedClient.d.ts.map +1 -0
- package/dist/client/schema/typedClient.js +269 -0
- package/dist/client/schema/typedClient.js.map +1 -0
- package/dist/client/schema/types.d.ts +477 -0
- package/dist/client/schema/types.d.ts.map +1 -0
- package/dist/client/schema/types.js +39 -0
- package/dist/client/schema/types.js.map +1 -0
- package/dist/client/types.d.ts +449 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +149 -0
- package/dist/client/types.js.map +1 -0
- package/dist/client/workflows.d.ts +51 -0
- package/dist/client/workflows.d.ts.map +1 -0
- package/dist/client/workflows.js +103 -0
- package/dist/client/workflows.js.map +1 -0
- package/dist/client/wrapper.d.ts +2198 -0
- package/dist/client/wrapper.d.ts.map +1 -0
- package/dist/client/wrapper.js +2651 -0
- package/dist/client/wrapper.js.map +1 -0
- package/dist/component/_generated/api.d.ts +124 -0
- package/dist/component/_generated/api.d.ts.map +1 -0
- package/dist/component/_generated/api.js +31 -0
- package/dist/component/_generated/api.js.map +1 -0
- package/dist/component/_generated/component.d.ts +4321 -0
- package/dist/component/_generated/component.d.ts.map +1 -0
- package/dist/component/_generated/component.js +11 -0
- package/dist/component/_generated/component.js.map +1 -0
- package/dist/component/_generated/dataModel.d.ts +46 -0
- package/dist/component/_generated/dataModel.d.ts.map +1 -0
- package/dist/component/_generated/dataModel.js +11 -0
- package/dist/component/_generated/dataModel.js.map +1 -0
- package/dist/component/_generated/server.d.ts +121 -0
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/component/_generated/server.js +78 -0
- package/dist/component/_generated/server.js.map +1 -0
- package/dist/component/auditLog.d.ts +410 -0
- package/dist/component/auditLog.d.ts.map +1 -0
- package/dist/component/auditLog.js +607 -0
- package/dist/component/auditLog.js.map +1 -0
- package/dist/component/authorization.d.ts +323 -0
- package/dist/component/authorization.d.ts.map +1 -0
- package/dist/component/authorization.js +464 -0
- package/dist/component/authorization.js.map +1 -0
- package/dist/component/authorizationHooks.d.ts +184 -0
- package/dist/component/authorizationHooks.d.ts.map +1 -0
- package/dist/component/authorizationHooks.js +521 -0
- package/dist/component/authorizationHooks.js.map +1 -0
- package/dist/component/bulkOperations.d.ts +200 -0
- package/dist/component/bulkOperations.d.ts.map +1 -0
- package/dist/component/bulkOperations.js +568 -0
- package/dist/component/bulkOperations.js.map +1 -0
- package/dist/component/contentEntries.d.ts +719 -0
- package/dist/component/contentEntries.d.ts.map +1 -0
- package/dist/component/contentEntries.js +1617 -0
- package/dist/component/contentEntries.js.map +1 -0
- package/dist/component/contentEntryMutations.d.ts +505 -0
- package/dist/component/contentEntryMutations.d.ts.map +1 -0
- package/dist/component/contentEntryMutations.js +1009 -0
- package/dist/component/contentEntryMutations.js.map +1 -0
- package/dist/component/contentEntryValidation.d.ts +115 -0
- package/dist/component/contentEntryValidation.d.ts.map +1 -0
- package/dist/component/contentEntryValidation.js +546 -0
- package/dist/component/contentEntryValidation.js.map +1 -0
- package/dist/component/contentLock.d.ts +328 -0
- package/dist/component/contentLock.d.ts.map +1 -0
- package/dist/component/contentLock.js +471 -0
- package/dist/component/contentLock.js.map +1 -0
- package/dist/component/contentTypeMigration.d.ts +411 -0
- package/dist/component/contentTypeMigration.d.ts.map +1 -0
- package/dist/component/contentTypeMigration.js +805 -0
- package/dist/component/contentTypeMigration.js.map +1 -0
- package/dist/component/contentTypeMutations.d.ts +975 -0
- package/dist/component/contentTypeMutations.d.ts.map +1 -0
- package/dist/component/contentTypeMutations.js +768 -0
- package/dist/component/contentTypeMutations.js.map +1 -0
- package/dist/component/contentTypes.d.ts +538 -0
- package/dist/component/contentTypes.d.ts.map +1 -0
- package/dist/component/contentTypes.js +304 -0
- package/dist/component/contentTypes.js.map +1 -0
- package/dist/component/convex.config.d.ts +42 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js +43 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/documentTypes.d.ts +186 -0
- package/dist/component/documentTypes.d.ts.map +1 -0
- package/dist/component/documentTypes.js +23 -0
- package/dist/component/documentTypes.js.map +1 -0
- package/dist/component/eventEmitter.d.ts +281 -0
- package/dist/component/eventEmitter.d.ts.map +1 -0
- package/dist/component/eventEmitter.js +300 -0
- package/dist/component/eventEmitter.js.map +1 -0
- package/dist/component/exportImport.d.ts +1120 -0
- package/dist/component/exportImport.d.ts.map +1 -0
- package/dist/component/exportImport.js +931 -0
- package/dist/component/exportImport.js.map +1 -0
- package/dist/component/index.d.ts +28 -0
- package/dist/component/index.d.ts.map +1 -0
- package/dist/component/index.js +142 -0
- package/dist/component/index.js.map +1 -0
- package/dist/component/lib/deepReferenceResolver.d.ts +252 -0
- package/dist/component/lib/deepReferenceResolver.d.ts.map +1 -0
- package/dist/component/lib/deepReferenceResolver.js +601 -0
- package/dist/component/lib/deepReferenceResolver.js.map +1 -0
- package/dist/component/lib/errors.d.ts +306 -0
- package/dist/component/lib/errors.d.ts.map +1 -0
- package/dist/component/lib/errors.js +407 -0
- package/dist/component/lib/errors.js.map +1 -0
- package/dist/component/lib/index.d.ts +10 -0
- package/dist/component/lib/index.d.ts.map +1 -0
- package/dist/component/lib/index.js +33 -0
- package/dist/component/lib/index.js.map +1 -0
- package/dist/component/lib/mediaReferenceResolver.d.ts +217 -0
- package/dist/component/lib/mediaReferenceResolver.d.ts.map +1 -0
- package/dist/component/lib/mediaReferenceResolver.js +326 -0
- package/dist/component/lib/mediaReferenceResolver.js.map +1 -0
- package/dist/component/lib/metadataExtractor.d.ts +245 -0
- package/dist/component/lib/metadataExtractor.d.ts.map +1 -0
- package/dist/component/lib/metadataExtractor.js +548 -0
- package/dist/component/lib/metadataExtractor.js.map +1 -0
- package/dist/component/lib/mutationAuth.d.ts +95 -0
- package/dist/component/lib/mutationAuth.d.ts.map +1 -0
- package/dist/component/lib/mutationAuth.js +146 -0
- package/dist/component/lib/mutationAuth.js.map +1 -0
- package/dist/component/lib/queries.d.ts +17 -0
- package/dist/component/lib/queries.d.ts.map +1 -0
- package/dist/component/lib/queries.js +49 -0
- package/dist/component/lib/queries.js.map +1 -0
- package/dist/component/lib/ragContentChunker.d.ts +423 -0
- package/dist/component/lib/ragContentChunker.d.ts.map +1 -0
- package/dist/component/lib/ragContentChunker.js +897 -0
- package/dist/component/lib/ragContentChunker.js.map +1 -0
- package/dist/component/lib/referenceResolver.d.ts +175 -0
- package/dist/component/lib/referenceResolver.d.ts.map +1 -0
- package/dist/component/lib/referenceResolver.js +293 -0
- package/dist/component/lib/referenceResolver.js.map +1 -0
- package/dist/component/lib/slugGenerator.d.ts +71 -0
- package/dist/component/lib/slugGenerator.d.ts.map +1 -0
- package/dist/component/lib/slugGenerator.js +207 -0
- package/dist/component/lib/slugGenerator.js.map +1 -0
- package/dist/component/lib/slugUniqueness.d.ts +131 -0
- package/dist/component/lib/slugUniqueness.d.ts.map +1 -0
- package/dist/component/lib/slugUniqueness.js +229 -0
- package/dist/component/lib/slugUniqueness.js.map +1 -0
- package/dist/component/lib/softDelete.d.ts +18 -0
- package/dist/component/lib/softDelete.d.ts.map +1 -0
- package/dist/component/lib/softDelete.js +29 -0
- package/dist/component/lib/softDelete.js.map +1 -0
- package/dist/component/localeFallbackChain.d.ts +410 -0
- package/dist/component/localeFallbackChain.d.ts.map +1 -0
- package/dist/component/localeFallbackChain.js +467 -0
- package/dist/component/localeFallbackChain.js.map +1 -0
- package/dist/component/localeFields.d.ts +508 -0
- package/dist/component/localeFields.d.ts.map +1 -0
- package/dist/component/localeFields.js +592 -0
- package/dist/component/localeFields.js.map +1 -0
- package/dist/component/mediaAssetMutations.d.ts +235 -0
- package/dist/component/mediaAssetMutations.d.ts.map +1 -0
- package/dist/component/mediaAssetMutations.js +558 -0
- package/dist/component/mediaAssetMutations.js.map +1 -0
- package/dist/component/mediaAssets.d.ts +168 -0
- package/dist/component/mediaAssets.d.ts.map +1 -0
- package/dist/component/mediaAssets.js +618 -0
- package/dist/component/mediaAssets.js.map +1 -0
- package/dist/component/mediaFolderMutations.d.ts +642 -0
- package/dist/component/mediaFolderMutations.d.ts.map +1 -0
- package/dist/component/mediaFolderMutations.js +849 -0
- package/dist/component/mediaFolderMutations.js.map +1 -0
- package/dist/component/mediaUploadMutations.d.ts +136 -0
- package/dist/component/mediaUploadMutations.d.ts.map +1 -0
- package/dist/component/mediaUploadMutations.js +205 -0
- package/dist/component/mediaUploadMutations.js.map +1 -0
- package/dist/component/mediaVariantMutations.d.ts +468 -0
- package/dist/component/mediaVariantMutations.d.ts.map +1 -0
- package/dist/component/mediaVariantMutations.js +737 -0
- package/dist/component/mediaVariantMutations.js.map +1 -0
- package/dist/component/mediaVariants.d.ts +525 -0
- package/dist/component/mediaVariants.d.ts.map +1 -0
- package/dist/component/mediaVariants.js +661 -0
- package/dist/component/mediaVariants.js.map +1 -0
- package/dist/component/ragContentIndexer.d.ts +595 -0
- package/dist/component/ragContentIndexer.d.ts.map +1 -0
- package/dist/component/ragContentIndexer.js +794 -0
- package/dist/component/ragContentIndexer.js.map +1 -0
- package/dist/component/rateLimitHooks.d.ts +266 -0
- package/dist/component/rateLimitHooks.d.ts.map +1 -0
- package/dist/component/rateLimitHooks.js +412 -0
- package/dist/component/rateLimitHooks.js.map +1 -0
- package/dist/component/roles.d.ts +649 -0
- package/dist/component/roles.d.ts.map +1 -0
- package/dist/component/roles.js +884 -0
- package/dist/component/roles.js.map +1 -0
- package/dist/component/scheduledPublish.d.ts +182 -0
- package/dist/component/scheduledPublish.d.ts.map +1 -0
- package/dist/component/scheduledPublish.js +304 -0
- package/dist/component/scheduledPublish.js.map +1 -0
- package/dist/component/schema.d.ts +4114 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +469 -0
- package/dist/component/schema.js.map +1 -0
- package/dist/component/taxonomies.d.ts +476 -0
- package/dist/component/taxonomies.d.ts.map +1 -0
- package/dist/component/taxonomies.js +785 -0
- package/dist/component/taxonomies.js.map +1 -0
- package/dist/component/taxonomyMutations.d.ts +206 -0
- package/dist/component/taxonomyMutations.d.ts.map +1 -0
- package/dist/component/taxonomyMutations.js +1001 -0
- package/dist/component/taxonomyMutations.js.map +1 -0
- package/dist/component/trash.d.ts +265 -0
- package/dist/component/trash.d.ts.map +1 -0
- package/dist/component/trash.js +621 -0
- package/dist/component/trash.js.map +1 -0
- package/dist/component/types.d.ts +4 -0
- package/dist/component/types.d.ts.map +1 -0
- package/dist/component/types.js +2 -0
- package/dist/component/types.js.map +1 -0
- package/dist/component/userContext.d.ts +508 -0
- package/dist/component/userContext.d.ts.map +1 -0
- package/dist/component/userContext.js +615 -0
- package/dist/component/userContext.js.map +1 -0
- package/dist/component/validation.d.ts +387 -0
- package/dist/component/validation.d.ts.map +1 -0
- package/dist/component/validation.js +1052 -0
- package/dist/component/validation.js.map +1 -0
- package/dist/component/validators.d.ts +4645 -0
- package/dist/component/validators.d.ts.map +1 -0
- package/dist/component/validators.js +641 -0
- package/dist/component/validators.js.map +1 -0
- package/dist/component/versionMutations.d.ts +216 -0
- package/dist/component/versionMutations.d.ts.map +1 -0
- package/dist/component/versionMutations.js +321 -0
- package/dist/component/versionMutations.js.map +1 -0
- package/dist/component/webhookTrigger.d.ts +770 -0
- package/dist/component/webhookTrigger.d.ts.map +1 -0
- package/dist/component/webhookTrigger.js +1413 -0
- package/dist/component/webhookTrigger.js.map +1 -0
- package/dist/react/index.d.ts +316 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +558 -0
- package/dist/react/index.js.map +1 -0
- package/dist/test.d.ts +2230 -0
- package/dist/test.d.ts.map +1 -0
- package/dist/test.js +1107 -0
- package/dist/test.js.map +1 -0
- package/package.json +95 -0
- package/src/cli/commands/admin.ts +104 -0
- package/src/cli/index.ts +21 -0
- package/src/cli/utils/detectConvexUrl.ts +54 -0
- package/src/cli/utils/openBrowser.ts +16 -0
- package/src/client/admin-config.ts +138 -0
- package/src/client/adminApi.ts +942 -0
- package/src/client/agentTools.ts +1311 -0
- package/src/client/argTypes.ts +316 -0
- package/src/client/field-types.ts +187 -0
- package/src/client/index.ts +1301 -0
- package/src/client/queryBuilder.ts +1100 -0
- package/src/client/schema/codegen.ts +500 -0
- package/src/client/schema/defineContentType.ts +501 -0
- package/src/client/schema/index.ts +169 -0
- package/src/client/schema/schemaDrift.ts +574 -0
- package/src/client/schema/typedClient.ts +688 -0
- package/src/client/schema/types.ts +666 -0
- package/src/client/types.ts +723 -0
- package/src/client/workflows.ts +141 -0
- package/src/client/wrapper.ts +4304 -0
- package/src/component/_generated/api.ts +140 -0
- package/src/component/_generated/component.ts +5029 -0
- package/src/component/_generated/dataModel.ts +60 -0
- package/src/component/_generated/server.ts +156 -0
- package/src/component/authorization.ts +647 -0
- package/src/component/authorizationHooks.ts +668 -0
- package/src/component/bulkOperations.ts +687 -0
- package/src/component/contentEntries.ts +1976 -0
- package/src/component/contentEntryMutations.ts +1223 -0
- package/src/component/contentEntryValidation.ts +707 -0
- package/src/component/contentLock.ts +550 -0
- package/src/component/contentTypeMigration.ts +1064 -0
- package/src/component/contentTypeMutations.ts +969 -0
- package/src/component/contentTypes.ts +346 -0
- package/src/component/convex.config.ts +44 -0
- package/src/component/documentTypes.ts +240 -0
- package/src/component/eventEmitter.ts +485 -0
- package/src/component/exportImport.ts +1169 -0
- package/src/component/index.ts +491 -0
- package/src/component/lib/deepReferenceResolver.ts +999 -0
- package/src/component/lib/errors.ts +816 -0
- package/src/component/lib/index.ts +145 -0
- package/src/component/lib/mediaReferenceResolver.ts +495 -0
- package/src/component/lib/metadataExtractor.ts +792 -0
- package/src/component/lib/mutationAuth.ts +199 -0
- package/src/component/lib/queries.ts +79 -0
- package/src/component/lib/ragContentChunker.ts +1371 -0
- package/src/component/lib/referenceResolver.ts +430 -0
- package/src/component/lib/slugGenerator.ts +262 -0
- package/src/component/lib/slugUniqueness.ts +333 -0
- package/src/component/lib/softDelete.ts +44 -0
- package/src/component/localeFallbackChain.ts +673 -0
- package/src/component/localeFields.ts +896 -0
- package/src/component/mediaAssetMutations.ts +725 -0
- package/src/component/mediaAssets.ts +932 -0
- package/src/component/mediaFolderMutations.ts +1046 -0
- package/src/component/mediaUploadMutations.ts +224 -0
- package/src/component/mediaVariantMutations.ts +900 -0
- package/src/component/mediaVariants.ts +793 -0
- package/src/component/ragContentIndexer.ts +1067 -0
- package/src/component/rateLimitHooks.ts +572 -0
- package/src/component/roles.ts +1360 -0
- package/src/component/scheduledPublish.ts +358 -0
- package/src/component/schema.ts +617 -0
- package/src/component/taxonomies.ts +949 -0
- package/src/component/taxonomyMutations.ts +1210 -0
- package/src/component/trash.ts +724 -0
- package/src/component/userContext.ts +898 -0
- package/src/component/validation.ts +1388 -0
- package/src/component/validators.ts +949 -0
- package/src/component/versionMutations.ts +392 -0
- package/src/component/webhookTrigger.ts +1922 -0
- package/src/react/index.ts +898 -0
- package/src/test.ts +1580 -0
|
@@ -0,0 +1,621 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trash Management Functions
|
|
3
|
+
*
|
|
4
|
+
* Provides functionality for managing soft-deleted content entries in a "trash" system:
|
|
5
|
+
* - List deleted entries with pagination and filtering
|
|
6
|
+
* - Configure retention period for automatic cleanup
|
|
7
|
+
* - Manually empty trash (permanent deletion)
|
|
8
|
+
* - Automatic scheduled cleanup of old deleted items
|
|
9
|
+
*
|
|
10
|
+
* Soft Delete Workflow:
|
|
11
|
+
* 1. User deletes an entry -> `deletedAt` timestamp is set (soft delete)
|
|
12
|
+
* 2. Entry is hidden from normal queries but visible in trash
|
|
13
|
+
* 3. User can restore the entry using `restoreEntry` mutation
|
|
14
|
+
* 4. After retention period, entry is permanently deleted (hard delete)
|
|
15
|
+
*
|
|
16
|
+
* Configuration:
|
|
17
|
+
* - `retentionDays`: How long items stay in trash (default: 30 days)
|
|
18
|
+
* - `autoCleanupEnabled`: Whether to run automatic cleanup (default: true)
|
|
19
|
+
* - Setting `retentionDays` to 0 disables automatic cleanup
|
|
20
|
+
*/
|
|
21
|
+
import { v } from "convex/values";
|
|
22
|
+
import { isDeleted } from "./lib/softDelete.js";
|
|
23
|
+
import { stream } from "convex-helpers/server/stream";
|
|
24
|
+
import { query, mutation, internalMutation } from "./_generated/server.js";
|
|
25
|
+
import { internal } from "./_generated/api.js";
|
|
26
|
+
import {
|
|
27
|
+
// contentEntryDoc,
|
|
28
|
+
trashConfigDoc, updateTrashConfigArgs, listTrashArgs, emptyTrashArgs, emptyTrashResult, trashItemDoc, DEFAULT_TRASH_RETENTION_DAYS, } from "./validators.js";
|
|
29
|
+
import schema from "./schema.js";
|
|
30
|
+
// =============================================================================
|
|
31
|
+
// Constants
|
|
32
|
+
// =============================================================================
|
|
33
|
+
/** Default pagination size for trash listing */
|
|
34
|
+
const DEFAULT_NUM_ITEMS = 50;
|
|
35
|
+
/** Maximum items per page */
|
|
36
|
+
const MAX_NUM_ITEMS = 250;
|
|
37
|
+
/** Milliseconds in a day */
|
|
38
|
+
const MS_PER_DAY = 24 * 60 * 60 * 1000;
|
|
39
|
+
// =============================================================================
|
|
40
|
+
// Trash Configuration
|
|
41
|
+
// =============================================================================
|
|
42
|
+
/**
|
|
43
|
+
* Query to get the current trash configuration.
|
|
44
|
+
*
|
|
45
|
+
* If no configuration exists, returns default values.
|
|
46
|
+
* This is useful for displaying settings in the admin UI.
|
|
47
|
+
*
|
|
48
|
+
* @returns Current trash configuration
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const config = await ctx.runQuery(api.trash.getTrashConfig, {});
|
|
53
|
+
* console.log(`Retention: ${config.retentionDays} days`);
|
|
54
|
+
* console.log(`Auto-cleanup: ${config.autoCleanupEnabled}`);
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export const getTrashConfig = query({
|
|
58
|
+
args: {},
|
|
59
|
+
returns: v.object({
|
|
60
|
+
retentionDays: v.number(),
|
|
61
|
+
autoCleanupEnabled: v.boolean(),
|
|
62
|
+
lastCleanupAt: v.optional(v.number()),
|
|
63
|
+
lastCleanupCount: v.optional(v.number()),
|
|
64
|
+
}),
|
|
65
|
+
handler: async (ctx) => {
|
|
66
|
+
// Get the singleton config record
|
|
67
|
+
const config = await ctx.db.query("trashConfig").first();
|
|
68
|
+
if (config) {
|
|
69
|
+
return {
|
|
70
|
+
retentionDays: config.retentionDays,
|
|
71
|
+
autoCleanupEnabled: config.autoCleanupEnabled,
|
|
72
|
+
lastCleanupAt: config.lastCleanupAt,
|
|
73
|
+
lastCleanupCount: config.lastCleanupCount,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
// Return defaults if no config exists
|
|
77
|
+
return {
|
|
78
|
+
retentionDays: DEFAULT_TRASH_RETENTION_DAYS,
|
|
79
|
+
autoCleanupEnabled: true,
|
|
80
|
+
lastCleanupAt: undefined,
|
|
81
|
+
lastCleanupCount: undefined,
|
|
82
|
+
};
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
/**
|
|
86
|
+
* Mutation to update trash configuration settings.
|
|
87
|
+
*
|
|
88
|
+
* Creates the config record if it doesn't exist.
|
|
89
|
+
* Use this to customize retention period or disable auto-cleanup.
|
|
90
|
+
*
|
|
91
|
+
* @param retentionDays - Days to keep items in trash (0 to disable auto-cleanup)
|
|
92
|
+
* @param autoCleanupEnabled - Whether to enable automatic cleanup
|
|
93
|
+
* @param updatedBy - User ID for audit trail
|
|
94
|
+
*
|
|
95
|
+
* @returns Updated configuration
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* // Set 7-day retention period
|
|
100
|
+
* await ctx.runMutation(api.trash.updateTrashConfig, {
|
|
101
|
+
* retentionDays: 7,
|
|
102
|
+
* updatedBy: currentUserId,
|
|
103
|
+
* });
|
|
104
|
+
*
|
|
105
|
+
* // Disable auto-cleanup (keep items forever until manually deleted)
|
|
106
|
+
* await ctx.runMutation(api.trash.updateTrashConfig, {
|
|
107
|
+
* autoCleanupEnabled: false,
|
|
108
|
+
* updatedBy: currentUserId,
|
|
109
|
+
* });
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
export const updateTrashConfig = mutation({
|
|
113
|
+
args: updateTrashConfigArgs.fields,
|
|
114
|
+
returns: trashConfigDoc,
|
|
115
|
+
handler: async (ctx, args) => {
|
|
116
|
+
const { retentionDays, autoCleanupEnabled, updatedBy } = args;
|
|
117
|
+
// Validate retention days
|
|
118
|
+
if (retentionDays !== undefined) {
|
|
119
|
+
if (retentionDays < 0 || retentionDays > 365) {
|
|
120
|
+
throw new Error("Retention days must be between 0 and 365");
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// Get existing config
|
|
124
|
+
const existingConfig = await ctx.db.query("trashConfig").first();
|
|
125
|
+
if (existingConfig) {
|
|
126
|
+
// Update existing config
|
|
127
|
+
const updates = { updatedBy };
|
|
128
|
+
if (retentionDays !== undefined)
|
|
129
|
+
updates.retentionDays = retentionDays;
|
|
130
|
+
if (autoCleanupEnabled !== undefined)
|
|
131
|
+
updates.autoCleanupEnabled = autoCleanupEnabled;
|
|
132
|
+
await ctx.db.patch(existingConfig._id, updates);
|
|
133
|
+
const updated = await ctx.db.get(existingConfig._id);
|
|
134
|
+
return updated;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
// Create new config with defaults for unspecified fields
|
|
138
|
+
const configId = await ctx.db.insert("trashConfig", {
|
|
139
|
+
retentionDays: retentionDays ?? DEFAULT_TRASH_RETENTION_DAYS,
|
|
140
|
+
autoCleanupEnabled: autoCleanupEnabled ?? true,
|
|
141
|
+
updatedBy,
|
|
142
|
+
});
|
|
143
|
+
const newConfig = await ctx.db.get(configId);
|
|
144
|
+
return newConfig;
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
// =============================================================================
|
|
149
|
+
// List Trash Query
|
|
150
|
+
// =============================================================================
|
|
151
|
+
/**
|
|
152
|
+
* Paginated response for trash listing.
|
|
153
|
+
*/
|
|
154
|
+
const paginatedTrashResponse = v.object({
|
|
155
|
+
/** Array of deleted content entries with metadata */
|
|
156
|
+
page: v.array(trashItemDoc),
|
|
157
|
+
/** Cursor for fetching the next page */
|
|
158
|
+
continueCursor: v.union(v.string(), v.null()),
|
|
159
|
+
/** Whether this is the last page */
|
|
160
|
+
isDone: v.boolean(),
|
|
161
|
+
/** Total count of items in trash (approximate) */
|
|
162
|
+
totalCount: v.optional(v.number()),
|
|
163
|
+
});
|
|
164
|
+
/**
|
|
165
|
+
* Query to list soft-deleted content entries (trash).
|
|
166
|
+
*
|
|
167
|
+
* Returns entries that have been soft-deleted, sorted by deletion time
|
|
168
|
+
* (most recently deleted first). Each entry includes metadata about
|
|
169
|
+
* when it was deleted and when it will expire.
|
|
170
|
+
*
|
|
171
|
+
* @param contentTypeId - Filter by content type ID
|
|
172
|
+
* @param contentTypeName - Filter by content type name
|
|
173
|
+
* @param search - Search within deleted items
|
|
174
|
+
* @param paginationOpts - Standard pagination options
|
|
175
|
+
*
|
|
176
|
+
* @returns Paginated list of deleted entries
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```typescript
|
|
180
|
+
* // List all trash items
|
|
181
|
+
* const { page, continueCursor, isDone } = await ctx.runQuery(
|
|
182
|
+
* api.trash.listTrash,
|
|
183
|
+
* { paginationOpts: { numItems: 20 } }
|
|
184
|
+
* );
|
|
185
|
+
*
|
|
186
|
+
* // Filter by content type
|
|
187
|
+
* const deletedPosts = await ctx.runQuery(api.trash.listTrash, {
|
|
188
|
+
* contentTypeName: "blog_post",
|
|
189
|
+
* paginationOpts: { numItems: 20 },
|
|
190
|
+
* });
|
|
191
|
+
*
|
|
192
|
+
* // Each item includes deletion metadata
|
|
193
|
+
* for (const item of page) {
|
|
194
|
+
* console.log(`${item.slug} - deleted ${item.deletedDaysAgo} days ago`);
|
|
195
|
+
* if (item.expiresAt) {
|
|
196
|
+
* console.log(` Expires: ${new Date(item.expiresAt).toISOString()}`);
|
|
197
|
+
* }
|
|
198
|
+
* }
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
export const listTrash = query({
|
|
202
|
+
args: listTrashArgs.fields,
|
|
203
|
+
returns: paginatedTrashResponse,
|
|
204
|
+
handler: async (ctx, args) => {
|
|
205
|
+
const { contentTypeId, contentTypeName, search, paginationOpts } = args;
|
|
206
|
+
// Clamp pagination
|
|
207
|
+
const numItems = Math.min(Math.max(1, paginationOpts.numItems ?? DEFAULT_NUM_ITEMS), MAX_NUM_ITEMS);
|
|
208
|
+
const clampedPaginationOpts = {
|
|
209
|
+
...paginationOpts,
|
|
210
|
+
numItems,
|
|
211
|
+
};
|
|
212
|
+
// Resolve content type ID from name if provided
|
|
213
|
+
let resolvedContentTypeId = contentTypeId;
|
|
214
|
+
if (!resolvedContentTypeId && contentTypeName) {
|
|
215
|
+
const contentType = await ctx.db
|
|
216
|
+
.query("contentTypes")
|
|
217
|
+
.withIndex("by_name", (q) => q.eq("name", contentTypeName))
|
|
218
|
+
.first();
|
|
219
|
+
if (contentType) {
|
|
220
|
+
resolvedContentTypeId = contentType._id;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
// Get trash config for retention period
|
|
224
|
+
const config = await ctx.db.query("trashConfig").first();
|
|
225
|
+
const retentionDays = config?.retentionDays ?? DEFAULT_TRASH_RETENTION_DAYS;
|
|
226
|
+
const now = Date.now();
|
|
227
|
+
// Create content type cache for display names
|
|
228
|
+
const contentTypeCache = new Map();
|
|
229
|
+
// Build the query using the by_deleted index
|
|
230
|
+
const streamDb = stream(ctx.db, schema);
|
|
231
|
+
// Query deleted entries (where deletedAt is defined)
|
|
232
|
+
// We use filterWith to handle the complex filtering
|
|
233
|
+
const baseQuery = streamDb.query("contentEntries");
|
|
234
|
+
const filteredQuery = baseQuery.order("desc").filterWith(async (entry) => {
|
|
235
|
+
// Must be deleted
|
|
236
|
+
if (!isDeleted(entry)) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
// Filter by content type if specified
|
|
240
|
+
if (resolvedContentTypeId &&
|
|
241
|
+
entry.contentTypeId !== resolvedContentTypeId) {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
// Simple text search if provided
|
|
245
|
+
if (search && search.trim().length > 0) {
|
|
246
|
+
const searchLower = search.toLowerCase();
|
|
247
|
+
const slugMatch = entry.slug?.toLowerCase().includes(searchLower);
|
|
248
|
+
const searchTextMatch = entry.searchText
|
|
249
|
+
?.toLowerCase()
|
|
250
|
+
.includes(searchLower);
|
|
251
|
+
if (!slugMatch && !searchTextMatch) {
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return true;
|
|
256
|
+
});
|
|
257
|
+
// Execute pagination
|
|
258
|
+
const result = await filteredQuery.paginate({
|
|
259
|
+
...clampedPaginationOpts,
|
|
260
|
+
maximumRowsRead: numItems * 10,
|
|
261
|
+
});
|
|
262
|
+
// Enrich results with deletion metadata
|
|
263
|
+
const enrichedPage = await Promise.all(result.page.map(async (entry) => {
|
|
264
|
+
const deletedAt = entry.deletedAt;
|
|
265
|
+
const deletedDaysAgo = Math.floor((now - deletedAt) / MS_PER_DAY);
|
|
266
|
+
// Calculate expiration time based on retention
|
|
267
|
+
let expiresAt;
|
|
268
|
+
if (retentionDays > 0) {
|
|
269
|
+
expiresAt = deletedAt + retentionDays * MS_PER_DAY;
|
|
270
|
+
}
|
|
271
|
+
// Get content type display name
|
|
272
|
+
let contentTypeName = contentTypeCache.get(entry.contentTypeId.toString());
|
|
273
|
+
if (!contentTypeName) {
|
|
274
|
+
const ct = await ctx.db.get(entry.contentTypeId);
|
|
275
|
+
contentTypeName = ct?.displayName ?? ct?.name;
|
|
276
|
+
if (contentTypeName) {
|
|
277
|
+
contentTypeCache.set(entry.contentTypeId.toString(), contentTypeName);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return {
|
|
281
|
+
...entry,
|
|
282
|
+
deletedDaysAgo,
|
|
283
|
+
expiresAt,
|
|
284
|
+
contentTypeName,
|
|
285
|
+
};
|
|
286
|
+
}));
|
|
287
|
+
return {
|
|
288
|
+
page: enrichedPage,
|
|
289
|
+
continueCursor: result.continueCursor,
|
|
290
|
+
isDone: result.isDone,
|
|
291
|
+
};
|
|
292
|
+
},
|
|
293
|
+
});
|
|
294
|
+
/**
|
|
295
|
+
* Query to get trash statistics.
|
|
296
|
+
*
|
|
297
|
+
* Returns counts and metadata about items in trash.
|
|
298
|
+
* Useful for displaying trash status in the admin UI.
|
|
299
|
+
*
|
|
300
|
+
* @returns Trash statistics
|
|
301
|
+
*/
|
|
302
|
+
export const getTrashStats = query({
|
|
303
|
+
args: {},
|
|
304
|
+
returns: v.object({
|
|
305
|
+
/** Total number of items in trash */
|
|
306
|
+
totalCount: v.number(),
|
|
307
|
+
/** Number of items that have expired (past retention period) */
|
|
308
|
+
expiredCount: v.number(),
|
|
309
|
+
/** Oldest item deletion date */
|
|
310
|
+
oldestDeletedAt: v.optional(v.number()),
|
|
311
|
+
/** Most recent item deletion date */
|
|
312
|
+
newestDeletedAt: v.optional(v.number()),
|
|
313
|
+
/** Current retention period in days */
|
|
314
|
+
retentionDays: v.number(),
|
|
315
|
+
}),
|
|
316
|
+
handler: async (ctx) => {
|
|
317
|
+
// Get trash config
|
|
318
|
+
const config = await ctx.db.query("trashConfig").first();
|
|
319
|
+
const retentionDays = config?.retentionDays ?? DEFAULT_TRASH_RETENTION_DAYS;
|
|
320
|
+
const now = Date.now();
|
|
321
|
+
const expirationThreshold = now - retentionDays * MS_PER_DAY;
|
|
322
|
+
// Query all deleted entries
|
|
323
|
+
const deletedEntries = await ctx.db
|
|
324
|
+
.query("contentEntries")
|
|
325
|
+
.filter((q) => q.neq(q.field("deletedAt"), undefined))
|
|
326
|
+
.collect();
|
|
327
|
+
let totalCount = 0;
|
|
328
|
+
let expiredCount = 0;
|
|
329
|
+
let oldestDeletedAt;
|
|
330
|
+
let newestDeletedAt;
|
|
331
|
+
for (const entry of deletedEntries) {
|
|
332
|
+
if (!isDeleted(entry))
|
|
333
|
+
continue;
|
|
334
|
+
const deletedAt = entry.deletedAt;
|
|
335
|
+
totalCount++;
|
|
336
|
+
if (retentionDays > 0 && deletedAt < expirationThreshold) {
|
|
337
|
+
expiredCount++;
|
|
338
|
+
}
|
|
339
|
+
if (oldestDeletedAt === undefined || deletedAt < oldestDeletedAt) {
|
|
340
|
+
oldestDeletedAt = deletedAt;
|
|
341
|
+
}
|
|
342
|
+
if (newestDeletedAt === undefined || deletedAt > newestDeletedAt) {
|
|
343
|
+
newestDeletedAt = deletedAt;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
return {
|
|
347
|
+
totalCount,
|
|
348
|
+
expiredCount,
|
|
349
|
+
oldestDeletedAt,
|
|
350
|
+
newestDeletedAt,
|
|
351
|
+
retentionDays,
|
|
352
|
+
};
|
|
353
|
+
},
|
|
354
|
+
});
|
|
355
|
+
// =============================================================================
|
|
356
|
+
// Empty Trash Mutation
|
|
357
|
+
// =============================================================================
|
|
358
|
+
/**
|
|
359
|
+
* Mutation to permanently delete items from trash.
|
|
360
|
+
*
|
|
361
|
+
* This performs a hard delete, removing entries and all their version history.
|
|
362
|
+
* This action cannot be undone.
|
|
363
|
+
*
|
|
364
|
+
* Options:
|
|
365
|
+
* - Delete all trash items
|
|
366
|
+
* - Delete only items older than a specified number of days
|
|
367
|
+
* - Delete only items of a specific content type
|
|
368
|
+
*
|
|
369
|
+
* @param olderThanDays - Only delete items deleted more than this many days ago
|
|
370
|
+
* @param contentTypeId - Only delete items of this content type
|
|
371
|
+
* @param deletedBy - User performing the operation (for logging)
|
|
372
|
+
*
|
|
373
|
+
* @returns Count of deleted items and any errors
|
|
374
|
+
*
|
|
375
|
+
* @example
|
|
376
|
+
* ```typescript
|
|
377
|
+
* // Empty all trash
|
|
378
|
+
* const result = await ctx.runMutation(api.trash.emptyTrash, {
|
|
379
|
+
* deletedBy: currentUserId,
|
|
380
|
+
* });
|
|
381
|
+
* console.log(`Permanently deleted ${result.deletedCount} items`);
|
|
382
|
+
*
|
|
383
|
+
* // Delete only items older than 7 days
|
|
384
|
+
* await ctx.runMutation(api.trash.emptyTrash, {
|
|
385
|
+
* olderThanDays: 7,
|
|
386
|
+
* deletedBy: currentUserId,
|
|
387
|
+
* });
|
|
388
|
+
*
|
|
389
|
+
* // Delete only deleted blog posts
|
|
390
|
+
* await ctx.runMutation(api.trash.emptyTrash, {
|
|
391
|
+
* contentTypeId: blogTypeId,
|
|
392
|
+
* deletedBy: currentUserId,
|
|
393
|
+
* });
|
|
394
|
+
* ```
|
|
395
|
+
*/
|
|
396
|
+
export const emptyTrash = mutation({
|
|
397
|
+
args: emptyTrashArgs.fields,
|
|
398
|
+
returns: emptyTrashResult,
|
|
399
|
+
handler: async (ctx, args) => {
|
|
400
|
+
const { olderThanDays, contentTypeId } = args;
|
|
401
|
+
const now = Date.now();
|
|
402
|
+
let cutoffTime;
|
|
403
|
+
if (olderThanDays !== undefined) {
|
|
404
|
+
cutoffTime = now - olderThanDays * MS_PER_DAY;
|
|
405
|
+
}
|
|
406
|
+
// Query all deleted entries
|
|
407
|
+
const deletedEntries = await ctx.db
|
|
408
|
+
.query("contentEntries")
|
|
409
|
+
.filter((q) => q.neq(q.field("deletedAt"), undefined))
|
|
410
|
+
.collect();
|
|
411
|
+
let deletedCount = 0;
|
|
412
|
+
let deletedVersionsCount = 0;
|
|
413
|
+
const errors = [];
|
|
414
|
+
for (const entry of deletedEntries) {
|
|
415
|
+
// Skip if not actually deleted
|
|
416
|
+
if (!isDeleted(entry))
|
|
417
|
+
continue;
|
|
418
|
+
const deletedAt = entry.deletedAt;
|
|
419
|
+
// Apply filters
|
|
420
|
+
if (cutoffTime !== undefined && deletedAt > cutoffTime) {
|
|
421
|
+
continue; // Not old enough
|
|
422
|
+
}
|
|
423
|
+
if (contentTypeId !== undefined &&
|
|
424
|
+
entry.contentTypeId !== contentTypeId) {
|
|
425
|
+
continue; // Wrong content type
|
|
426
|
+
}
|
|
427
|
+
try {
|
|
428
|
+
// Delete all versions for this entry
|
|
429
|
+
const versions = await ctx.db
|
|
430
|
+
.query("contentVersions")
|
|
431
|
+
.withIndex("by_entry", (q) => q.eq("entryId", entry._id))
|
|
432
|
+
.collect();
|
|
433
|
+
for (const version of versions) {
|
|
434
|
+
await ctx.db.delete(version._id);
|
|
435
|
+
deletedVersionsCount++;
|
|
436
|
+
}
|
|
437
|
+
// Delete the entry itself
|
|
438
|
+
await ctx.db.delete(entry._id);
|
|
439
|
+
deletedCount++;
|
|
440
|
+
}
|
|
441
|
+
catch (error) {
|
|
442
|
+
errors.push({
|
|
443
|
+
id: entry._id,
|
|
444
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
return {
|
|
449
|
+
deletedCount,
|
|
450
|
+
deletedVersionsCount,
|
|
451
|
+
errors,
|
|
452
|
+
};
|
|
453
|
+
},
|
|
454
|
+
});
|
|
455
|
+
// =============================================================================
|
|
456
|
+
// Scheduled Cleanup Functions
|
|
457
|
+
// =============================================================================
|
|
458
|
+
/**
|
|
459
|
+
* Internal mutation for scheduled trash cleanup.
|
|
460
|
+
*
|
|
461
|
+
* This is called by the scheduler to automatically delete items that have
|
|
462
|
+
* exceeded the retention period. It runs periodically (e.g., daily) and
|
|
463
|
+
* processes items in batches to respect Convex transaction limits.
|
|
464
|
+
*
|
|
465
|
+
* The function:
|
|
466
|
+
* 1. Checks if auto-cleanup is enabled
|
|
467
|
+
* 2. Finds all items past the retention period
|
|
468
|
+
* 3. Permanently deletes them and their versions
|
|
469
|
+
* 4. Updates the config with cleanup stats
|
|
470
|
+
* 5. Reschedules itself for the next run
|
|
471
|
+
*/
|
|
472
|
+
export const executeTrashCleanup = internalMutation({
|
|
473
|
+
args: {},
|
|
474
|
+
handler: async (ctx) => {
|
|
475
|
+
// Get trash configuration
|
|
476
|
+
const config = await ctx.db.query("trashConfig").first();
|
|
477
|
+
// If no config exists, create one with defaults
|
|
478
|
+
if (!config) {
|
|
479
|
+
await ctx.db.insert("trashConfig", {
|
|
480
|
+
retentionDays: DEFAULT_TRASH_RETENTION_DAYS,
|
|
481
|
+
autoCleanupEnabled: true,
|
|
482
|
+
});
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
// Check if auto-cleanup is enabled
|
|
486
|
+
if (!config.autoCleanupEnabled) {
|
|
487
|
+
console.log("Trash auto-cleanup is disabled, skipping");
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
// Check if retention is set (0 = no auto-cleanup)
|
|
491
|
+
if (config.retentionDays === 0) {
|
|
492
|
+
console.log("Trash retention is 0 days (disabled), skipping cleanup");
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
const now = Date.now();
|
|
496
|
+
const cutoffTime = now - config.retentionDays * MS_PER_DAY;
|
|
497
|
+
// Find expired items
|
|
498
|
+
const expiredEntries = await ctx.db
|
|
499
|
+
.query("contentEntries")
|
|
500
|
+
.filter((q) => q.neq(q.field("deletedAt"), undefined))
|
|
501
|
+
.collect();
|
|
502
|
+
let deletedCount = 0;
|
|
503
|
+
for (const entry of expiredEntries) {
|
|
504
|
+
// Skip if not actually deleted or not expired
|
|
505
|
+
if (!isDeleted(entry))
|
|
506
|
+
continue;
|
|
507
|
+
if (entry.deletedAt > cutoffTime)
|
|
508
|
+
continue;
|
|
509
|
+
try {
|
|
510
|
+
// Delete all versions
|
|
511
|
+
const versions = await ctx.db
|
|
512
|
+
.query("contentVersions")
|
|
513
|
+
.withIndex("by_entry", (q) => q.eq("entryId", entry._id))
|
|
514
|
+
.collect();
|
|
515
|
+
for (const version of versions) {
|
|
516
|
+
await ctx.db.delete(version._id);
|
|
517
|
+
}
|
|
518
|
+
// Delete the entry
|
|
519
|
+
await ctx.db.delete(entry._id);
|
|
520
|
+
deletedCount++;
|
|
521
|
+
}
|
|
522
|
+
catch (error) {
|
|
523
|
+
console.error(`Failed to delete expired entry ${entry._id}:`, error);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
// Update config with cleanup stats
|
|
527
|
+
await ctx.db.patch(config._id, {
|
|
528
|
+
lastCleanupAt: now,
|
|
529
|
+
lastCleanupCount: deletedCount,
|
|
530
|
+
});
|
|
531
|
+
console.log(`Trash cleanup completed: ${deletedCount} items permanently deleted`);
|
|
532
|
+
},
|
|
533
|
+
});
|
|
534
|
+
/**
|
|
535
|
+
* Mutation to manually trigger trash cleanup.
|
|
536
|
+
*
|
|
537
|
+
* Use this to run cleanup on-demand instead of waiting for the scheduled job.
|
|
538
|
+
* Useful for testing or when you need immediate cleanup.
|
|
539
|
+
*
|
|
540
|
+
* @param updatedBy - User triggering the cleanup
|
|
541
|
+
*
|
|
542
|
+
* @returns Cleanup result statistics
|
|
543
|
+
*/
|
|
544
|
+
export const runTrashCleanup = mutation({
|
|
545
|
+
args: {
|
|
546
|
+
updatedBy: v.optional(v.string()),
|
|
547
|
+
},
|
|
548
|
+
returns: v.object({
|
|
549
|
+
deletedCount: v.number(),
|
|
550
|
+
message: v.string(),
|
|
551
|
+
}),
|
|
552
|
+
handler: async (ctx, args) => {
|
|
553
|
+
// Get trash configuration
|
|
554
|
+
const config = await ctx.db.query("trashConfig").first();
|
|
555
|
+
const retentionDays = config?.retentionDays ?? DEFAULT_TRASH_RETENTION_DAYS;
|
|
556
|
+
if (retentionDays === 0) {
|
|
557
|
+
return {
|
|
558
|
+
deletedCount: 0,
|
|
559
|
+
message: "Retention is set to 0 days (disabled). No items deleted.",
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
const now = Date.now();
|
|
563
|
+
const cutoffTime = now - retentionDays * MS_PER_DAY;
|
|
564
|
+
// Find expired items
|
|
565
|
+
const expiredEntries = await ctx.db
|
|
566
|
+
.query("contentEntries")
|
|
567
|
+
.filter((q) => q.neq(q.field("deletedAt"), undefined))
|
|
568
|
+
.collect();
|
|
569
|
+
let deletedCount = 0;
|
|
570
|
+
for (const entry of expiredEntries) {
|
|
571
|
+
if (!isDeleted(entry))
|
|
572
|
+
continue;
|
|
573
|
+
if (entry.deletedAt > cutoffTime)
|
|
574
|
+
continue;
|
|
575
|
+
// Delete versions
|
|
576
|
+
const versions = await ctx.db
|
|
577
|
+
.query("contentVersions")
|
|
578
|
+
.withIndex("by_entry", (q) => q.eq("entryId", entry._id))
|
|
579
|
+
.collect();
|
|
580
|
+
for (const version of versions) {
|
|
581
|
+
await ctx.db.delete(version._id);
|
|
582
|
+
}
|
|
583
|
+
// Delete entry
|
|
584
|
+
await ctx.db.delete(entry._id);
|
|
585
|
+
deletedCount++;
|
|
586
|
+
}
|
|
587
|
+
// Update config stats if it exists
|
|
588
|
+
if (config) {
|
|
589
|
+
await ctx.db.patch(config._id, {
|
|
590
|
+
lastCleanupAt: now,
|
|
591
|
+
lastCleanupCount: deletedCount,
|
|
592
|
+
updatedBy: args.updatedBy,
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
return {
|
|
596
|
+
deletedCount,
|
|
597
|
+
message: `Successfully deleted ${deletedCount} items older than ${retentionDays} days.`,
|
|
598
|
+
};
|
|
599
|
+
},
|
|
600
|
+
});
|
|
601
|
+
/**
|
|
602
|
+
* Mutation to schedule periodic trash cleanup.
|
|
603
|
+
*
|
|
604
|
+
* Call this once during setup to enable automatic trash cleanup.
|
|
605
|
+
* The function schedules itself to run daily.
|
|
606
|
+
*
|
|
607
|
+
* @param intervalMs - Cleanup interval in milliseconds (default: 24 hours)
|
|
608
|
+
*/
|
|
609
|
+
export const scheduleTrashCleanup = mutation({
|
|
610
|
+
args: {
|
|
611
|
+
/** Interval between cleanups in milliseconds. Default is 24 hours. */
|
|
612
|
+
intervalMs: v.optional(v.number()),
|
|
613
|
+
},
|
|
614
|
+
handler: async (ctx, args) => {
|
|
615
|
+
const intervalMs = args.intervalMs ?? 24 * 60 * 60 * 1000; // Default: 24 hours
|
|
616
|
+
// Schedule the cleanup to run
|
|
617
|
+
await ctx.scheduler.runAfter(intervalMs, internal.trash.executeTrashCleanup, {});
|
|
618
|
+
console.log(`Trash cleanup scheduled to run in ${intervalMs / 1000 / 60} minutes`);
|
|
619
|
+
},
|
|
620
|
+
});
|
|
621
|
+
//# sourceMappingURL=trash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trash.js","sourceRoot":"","sources":["../../src/component/trash.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO;AACN,mBAAmB;AACnB,cAAc,EACd,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,4BAA4B,GAC5B,MAAM,iBAAiB,CAAC;AACzB,O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AE,MAAM,UAAU,CAAC;AAE9C,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/component/types.ts"],"names":[],"mappings":""}
|