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,607 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audit Log Module
|
|
3
|
+
*
|
|
4
|
+
* Comprehensive audit logging for all CMS operations.
|
|
5
|
+
* Records user, action, timestamp, and before/after states.
|
|
6
|
+
* Provides query functions for audit trail retrieval and filtering.
|
|
7
|
+
*
|
|
8
|
+
* Design Philosophy:
|
|
9
|
+
* - Audit logs are immutable once created (append-only)
|
|
10
|
+
* - Complete before/after snapshots enable diff analysis
|
|
11
|
+
* - Rich filtering supports compliance and security auditing
|
|
12
|
+
* - Optimized for read-heavy audit trail queries
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
* ```typescript
|
|
16
|
+
* // In a mutation handler:
|
|
17
|
+
* await logAuditEntry(ctx, {
|
|
18
|
+
* resourceType: "contentEntry",
|
|
19
|
+
* resourceId: entry._id.toString(),
|
|
20
|
+
* action: "updated",
|
|
21
|
+
* userId: updatedBy,
|
|
22
|
+
* previousState: oldEntry,
|
|
23
|
+
* newState: newEntry,
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
import { v } from "convex/values";
|
|
28
|
+
import { mutation, query, internalMutation } from "./_generated/server.js";
|
|
29
|
+
// =============================================================================
|
|
30
|
+
// Validators (imported from central validators.ts)
|
|
31
|
+
// =============================================================================
|
|
32
|
+
// Import validators from the central validators module to avoid duplication.
|
|
33
|
+
// The auditLogDoc validator is derived from schema using convex-helpers doc().
|
|
34
|
+
import { auditResourceTypeValidator, auditActionValidator, auditLogDoc as auditLogDocValidator, } from "./validators.js";
|
|
35
|
+
// Re-export for consumers of this module
|
|
36
|
+
export { auditResourceTypeValidator, auditActionValidator, auditLogDocValidator };
|
|
37
|
+
// =============================================================================
|
|
38
|
+
// Internal Helper: Log Audit Entry
|
|
39
|
+
// =============================================================================
|
|
40
|
+
/**
|
|
41
|
+
* Internal helper function to create an audit log entry within mutation handlers.
|
|
42
|
+
*
|
|
43
|
+
* This function inserts an audit log record into the auditLogs table.
|
|
44
|
+
* It's designed to be called from within other mutations to ensure
|
|
45
|
+
* the audit log is part of the same atomic transaction.
|
|
46
|
+
*
|
|
47
|
+
* @param ctx - The mutation context
|
|
48
|
+
* @param params - Audit log parameters
|
|
49
|
+
* @returns The created audit log ID
|
|
50
|
+
*/
|
|
51
|
+
export async function logAuditEntry(ctx, params) {
|
|
52
|
+
const { resourceType, resourceId, action, userId, userDisplayName, previousState, newState, changeSummary, changedFields, ipAddress, userAgent, sessionId, requestId, metadata, contentTypeName, entrySlug, } = params;
|
|
53
|
+
// Auto-generate change summary if not provided for update actions
|
|
54
|
+
let summary = changeSummary;
|
|
55
|
+
if (!summary &&
|
|
56
|
+
action === "updated" &&
|
|
57
|
+
changedFields &&
|
|
58
|
+
changedFields.length > 0) {
|
|
59
|
+
summary = `Updated ${changedFields.length} field${changedFields.length > 1 ? "s" : ""}: ${changedFields.slice(0, 5).join(", ")}${changedFields.length > 5 ? "..." : ""}`;
|
|
60
|
+
}
|
|
61
|
+
const auditLogId = await ctx.db.insert("auditLogs", {
|
|
62
|
+
resourceType,
|
|
63
|
+
resourceId,
|
|
64
|
+
action,
|
|
65
|
+
userId,
|
|
66
|
+
userDisplayName,
|
|
67
|
+
previousState,
|
|
68
|
+
newState,
|
|
69
|
+
changeSummary: summary,
|
|
70
|
+
changedFields,
|
|
71
|
+
ipAddress,
|
|
72
|
+
userAgent,
|
|
73
|
+
sessionId,
|
|
74
|
+
requestId,
|
|
75
|
+
metadata,
|
|
76
|
+
contentTypeName,
|
|
77
|
+
entrySlug,
|
|
78
|
+
});
|
|
79
|
+
return auditLogId;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Helper to detect changed fields between two objects.
|
|
83
|
+
* Useful for automatically populating changedFields in audit logs.
|
|
84
|
+
*/
|
|
85
|
+
export function detectChangedFields(previousState, newState) {
|
|
86
|
+
if (!previousState || !newState) {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
const changedFields = [];
|
|
90
|
+
const allKeys = new Set([
|
|
91
|
+
...Object.keys(previousState),
|
|
92
|
+
...Object.keys(newState),
|
|
93
|
+
]);
|
|
94
|
+
for (const key of allKeys) {
|
|
95
|
+
// Skip internal fields
|
|
96
|
+
if (key.startsWith("_"))
|
|
97
|
+
continue;
|
|
98
|
+
const oldValue = previousState[key];
|
|
99
|
+
const newValue = newState[key];
|
|
100
|
+
// Simple comparison (deep comparison for objects)
|
|
101
|
+
if (JSON.stringify(oldValue) !== JSON.stringify(newValue)) {
|
|
102
|
+
changedFields.push(key);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return changedFields;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Helper to generate a human-readable change summary.
|
|
109
|
+
*/
|
|
110
|
+
export function generateChangeSummary(action, resourceType, changedFields, metadata) {
|
|
111
|
+
const resourceName = resourceType
|
|
112
|
+
.replace(/([A-Z])/g, " $1")
|
|
113
|
+
.toLowerCase()
|
|
114
|
+
.trim();
|
|
115
|
+
switch (action) {
|
|
116
|
+
case "created":
|
|
117
|
+
return `Created new ${resourceName}`;
|
|
118
|
+
case "updated":
|
|
119
|
+
if (changedFields && changedFields.length > 0) {
|
|
120
|
+
return `Updated ${changedFields.length} field${changedFields.length > 1 ? "s" : ""}: ${changedFields.slice(0, 3).join(", ")}${changedFields.length > 3 ? "..." : ""}`;
|
|
121
|
+
}
|
|
122
|
+
return `Updated ${resourceName}`;
|
|
123
|
+
case "published":
|
|
124
|
+
return `Published ${resourceName}`;
|
|
125
|
+
case "unpublished":
|
|
126
|
+
return `Unpublished ${resourceName} (reverted to draft)`;
|
|
127
|
+
case "deleted":
|
|
128
|
+
return metadata?.hardDelete
|
|
129
|
+
? `Permanently deleted ${resourceName}`
|
|
130
|
+
: `Moved ${resourceName} to trash`;
|
|
131
|
+
case "restored":
|
|
132
|
+
return `Restored ${resourceName} from trash`;
|
|
133
|
+
case "duplicated":
|
|
134
|
+
return `Duplicated ${resourceName}`;
|
|
135
|
+
case "scheduled":
|
|
136
|
+
return `Scheduled ${resourceName} for publication`;
|
|
137
|
+
case "locked":
|
|
138
|
+
return `Locked ${resourceName} for editing`;
|
|
139
|
+
case "unlocked":
|
|
140
|
+
return `Released lock on ${resourceName}`;
|
|
141
|
+
case "rolledBack": {
|
|
142
|
+
const version = metadata?.toVersion;
|
|
143
|
+
return version
|
|
144
|
+
? `Rolled back to version ${version}`
|
|
145
|
+
: `Rolled back to previous version`;
|
|
146
|
+
}
|
|
147
|
+
case "migrated":
|
|
148
|
+
return `Applied migration to ${resourceName}`;
|
|
149
|
+
default:
|
|
150
|
+
return `Performed ${action} on ${resourceName}`;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// =============================================================================
|
|
154
|
+
// Query Functions
|
|
155
|
+
// =============================================================================
|
|
156
|
+
/**
|
|
157
|
+
* Query to get audit logs for a specific resource.
|
|
158
|
+
*
|
|
159
|
+
* @param resourceType - The resource type
|
|
160
|
+
* @param resourceId - The resource ID
|
|
161
|
+
* @param limit - Maximum number of logs to return (default: 50)
|
|
162
|
+
*
|
|
163
|
+
* @returns Array of audit log entries for the resource, ordered by creation time (newest first)
|
|
164
|
+
*/
|
|
165
|
+
export const getResourceAuditLogs = query({
|
|
166
|
+
args: {
|
|
167
|
+
resourceType: auditResourceTypeValidator,
|
|
168
|
+
resourceId: v.string(),
|
|
169
|
+
limit: v.optional(v.number()),
|
|
170
|
+
},
|
|
171
|
+
returns: v.array(auditLogDocValidator),
|
|
172
|
+
handler: async (ctx, args) => {
|
|
173
|
+
const { resourceType, resourceId, limit = 50 } = args;
|
|
174
|
+
const logs = await ctx.db
|
|
175
|
+
.query("auditLogs")
|
|
176
|
+
.withIndex("by_resource", (q) => q.eq("resourceType", resourceType).eq("resourceId", resourceId))
|
|
177
|
+
.order("desc")
|
|
178
|
+
.take(limit);
|
|
179
|
+
return logs;
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
/**
|
|
183
|
+
* Query to get audit logs by user.
|
|
184
|
+
*
|
|
185
|
+
* @param userId - The user ID
|
|
186
|
+
* @param limit - Maximum number of logs to return (default: 50)
|
|
187
|
+
*
|
|
188
|
+
* @returns Array of audit log entries by the user, ordered by creation time (newest first)
|
|
189
|
+
*/
|
|
190
|
+
export const getUserAuditLogs = query({
|
|
191
|
+
args: {
|
|
192
|
+
userId: v.string(),
|
|
193
|
+
limit: v.optional(v.number()),
|
|
194
|
+
},
|
|
195
|
+
returns: v.array(auditLogDocValidator),
|
|
196
|
+
handler: async (ctx, args) => {
|
|
197
|
+
const { userId, limit = 50 } = args;
|
|
198
|
+
const logs = await ctx.db
|
|
199
|
+
.query("auditLogs")
|
|
200
|
+
.withIndex("by_user", (q) => q.eq("userId", userId))
|
|
201
|
+
.order("desc")
|
|
202
|
+
.take(limit);
|
|
203
|
+
return logs;
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
/**
|
|
207
|
+
* Query to list audit logs with filtering and pagination.
|
|
208
|
+
*
|
|
209
|
+
* @param resourceType - Filter by resource type
|
|
210
|
+
* @param action - Filter by action
|
|
211
|
+
* @param userId - Filter by user ID
|
|
212
|
+
* @param contentTypeName - Filter by content type name (for content entries)
|
|
213
|
+
* @param startDate - Filter logs created after this timestamp
|
|
214
|
+
* @param endDate - Filter logs created before this timestamp
|
|
215
|
+
* @param limit - Maximum number of logs to return (default: 50)
|
|
216
|
+
* @param cursor - Cursor for pagination
|
|
217
|
+
*
|
|
218
|
+
* @returns Paginated audit log entries
|
|
219
|
+
*/
|
|
220
|
+
export const listAuditLogs = query({
|
|
221
|
+
args: {
|
|
222
|
+
resourceType: v.optional(auditResourceTypeValidator),
|
|
223
|
+
action: v.optional(auditActionValidator),
|
|
224
|
+
userId: v.optional(v.string()),
|
|
225
|
+
contentTypeName: v.optional(v.string()),
|
|
226
|
+
startDate: v.optional(v.number()),
|
|
227
|
+
endDate: v.optional(v.number()),
|
|
228
|
+
limit: v.optional(v.number()),
|
|
229
|
+
cursor: v.optional(v.string()),
|
|
230
|
+
},
|
|
231
|
+
returns: v.object({
|
|
232
|
+
logs: v.array(auditLogDocValidator),
|
|
233
|
+
hasMore: v.boolean(),
|
|
234
|
+
nextCursor: v.optional(v.string()),
|
|
235
|
+
}),
|
|
236
|
+
handler: async (ctx, args) => {
|
|
237
|
+
const { resourceType, action, userId, contentTypeName, startDate, endDate, limit = 50, } = args;
|
|
238
|
+
// Start with the most specific index based on filters
|
|
239
|
+
let queryBuilder;
|
|
240
|
+
if (userId && action) {
|
|
241
|
+
queryBuilder = ctx.db
|
|
242
|
+
.query("auditLogs")
|
|
243
|
+
.withIndex("by_user_and_action", (q) => q.eq("userId", userId).eq("action", action));
|
|
244
|
+
}
|
|
245
|
+
else if (resourceType && action) {
|
|
246
|
+
queryBuilder = ctx.db
|
|
247
|
+
.query("auditLogs")
|
|
248
|
+
.withIndex("by_resource_type_and_action", (q) => q.eq("resourceType", resourceType).eq("action", action));
|
|
249
|
+
}
|
|
250
|
+
else if (userId) {
|
|
251
|
+
queryBuilder = ctx.db
|
|
252
|
+
.query("auditLogs")
|
|
253
|
+
.withIndex("by_user", (q) => q.eq("userId", userId));
|
|
254
|
+
}
|
|
255
|
+
else if (contentTypeName) {
|
|
256
|
+
queryBuilder = ctx.db
|
|
257
|
+
.query("auditLogs")
|
|
258
|
+
.withIndex("by_content_type", (q) => q.eq("contentTypeName", contentTypeName));
|
|
259
|
+
}
|
|
260
|
+
else if (action) {
|
|
261
|
+
queryBuilder = ctx.db
|
|
262
|
+
.query("auditLogs")
|
|
263
|
+
.withIndex("by_action", (q) => q.eq("action", action));
|
|
264
|
+
}
|
|
265
|
+
else if (resourceType) {
|
|
266
|
+
queryBuilder = ctx.db
|
|
267
|
+
.query("auditLogs")
|
|
268
|
+
.withIndex("by_resource_type", (q) => q.eq("resourceType", resourceType));
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
queryBuilder = ctx.db.query("auditLogs");
|
|
272
|
+
}
|
|
273
|
+
// Fetch more than needed to apply additional filters
|
|
274
|
+
let logs = await queryBuilder.order("desc").take(limit * 3);
|
|
275
|
+
// Apply time-based filters in memory
|
|
276
|
+
if (startDate !== undefined) {
|
|
277
|
+
logs = logs.filter((log) => log._creationTime >= startDate);
|
|
278
|
+
}
|
|
279
|
+
if (endDate !== undefined) {
|
|
280
|
+
logs = logs.filter((log) => log._creationTime <= endDate);
|
|
281
|
+
}
|
|
282
|
+
// Apply any remaining filters not covered by the index
|
|
283
|
+
if (resourceType && !action) {
|
|
284
|
+
logs = logs.filter((log) => log.resourceType === resourceType);
|
|
285
|
+
}
|
|
286
|
+
// Limit results
|
|
287
|
+
const limitedLogs = logs.slice(0, limit);
|
|
288
|
+
const hasMore = logs.length > limit;
|
|
289
|
+
const nextCursor = hasMore && limitedLogs.length > 0
|
|
290
|
+
? limitedLogs[limitedLogs.length - 1]._id
|
|
291
|
+
: undefined;
|
|
292
|
+
return {
|
|
293
|
+
logs: limitedLogs,
|
|
294
|
+
hasMore,
|
|
295
|
+
nextCursor,
|
|
296
|
+
};
|
|
297
|
+
},
|
|
298
|
+
});
|
|
299
|
+
/**
|
|
300
|
+
* Query to get a single audit log entry by ID.
|
|
301
|
+
*
|
|
302
|
+
* @param id - The audit log entry ID
|
|
303
|
+
*
|
|
304
|
+
* @returns The audit log entry or null if not found
|
|
305
|
+
*/
|
|
306
|
+
export const getAuditLog = query({
|
|
307
|
+
args: {
|
|
308
|
+
id: v.id("auditLogs"),
|
|
309
|
+
},
|
|
310
|
+
returns: v.union(auditLogDocValidator, v.null()),
|
|
311
|
+
handler: async (ctx, args) => {
|
|
312
|
+
const log = await ctx.db.get(args.id);
|
|
313
|
+
return log;
|
|
314
|
+
},
|
|
315
|
+
});
|
|
316
|
+
/**
|
|
317
|
+
* Query to get audit log statistics.
|
|
318
|
+
*
|
|
319
|
+
* @param resourceType - Filter by resource type
|
|
320
|
+
* @param startDate - Filter logs created after this timestamp
|
|
321
|
+
* @param endDate - Filter logs created before this timestamp
|
|
322
|
+
*
|
|
323
|
+
* @returns Statistics about audit logs
|
|
324
|
+
*/
|
|
325
|
+
export const getAuditLogStats = query({
|
|
326
|
+
args: {
|
|
327
|
+
resourceType: v.optional(auditResourceTypeValidator),
|
|
328
|
+
startDate: v.optional(v.number()),
|
|
329
|
+
endDate: v.optional(v.number()),
|
|
330
|
+
},
|
|
331
|
+
returns: v.object({
|
|
332
|
+
totalCount: v.number(),
|
|
333
|
+
actionCounts: v.any(),
|
|
334
|
+
topUsers: v.array(v.object({
|
|
335
|
+
userId: v.string(),
|
|
336
|
+
count: v.number(),
|
|
337
|
+
})),
|
|
338
|
+
}),
|
|
339
|
+
handler: async (ctx, args) => {
|
|
340
|
+
const { resourceType, startDate, endDate } = args;
|
|
341
|
+
let queryBuilder;
|
|
342
|
+
if (resourceType) {
|
|
343
|
+
queryBuilder = ctx.db
|
|
344
|
+
.query("auditLogs")
|
|
345
|
+
.withIndex("by_resource_type", (q) => q.eq("resourceType", resourceType));
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
queryBuilder = ctx.db.query("auditLogs");
|
|
349
|
+
}
|
|
350
|
+
let logs = await queryBuilder.collect();
|
|
351
|
+
// Apply time-based filters
|
|
352
|
+
if (startDate !== undefined) {
|
|
353
|
+
logs = logs.filter((log) => log._creationTime >= startDate);
|
|
354
|
+
}
|
|
355
|
+
if (endDate !== undefined) {
|
|
356
|
+
logs = logs.filter((log) => log._creationTime <= endDate);
|
|
357
|
+
}
|
|
358
|
+
// Calculate action counts
|
|
359
|
+
const actionCounts = {};
|
|
360
|
+
for (const log of logs) {
|
|
361
|
+
actionCounts[log.action] = (actionCounts[log.action] || 0) + 1;
|
|
362
|
+
}
|
|
363
|
+
// Calculate top users
|
|
364
|
+
const userCounts = {};
|
|
365
|
+
for (const log of logs) {
|
|
366
|
+
if (log.userId) {
|
|
367
|
+
userCounts[log.userId] = (userCounts[log.userId] || 0) + 1;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
const topUsers = Object.entries(userCounts)
|
|
371
|
+
.map(([userId, count]) => ({ userId, count }))
|
|
372
|
+
.sort((a, b) => b.count - a.count)
|
|
373
|
+
.slice(0, 10);
|
|
374
|
+
return {
|
|
375
|
+
totalCount: logs.length,
|
|
376
|
+
actionCounts,
|
|
377
|
+
topUsers,
|
|
378
|
+
};
|
|
379
|
+
},
|
|
380
|
+
});
|
|
381
|
+
/**
|
|
382
|
+
* Query to compare two versions of a resource using audit logs.
|
|
383
|
+
* Returns the diff between previousState and newState for an update action.
|
|
384
|
+
*
|
|
385
|
+
* @param id - The audit log entry ID (should be an "updated" action)
|
|
386
|
+
*
|
|
387
|
+
* @returns The diff between states
|
|
388
|
+
*/
|
|
389
|
+
export const getAuditLogDiff = query({
|
|
390
|
+
args: {
|
|
391
|
+
id: v.id("auditLogs"),
|
|
392
|
+
},
|
|
393
|
+
returns: v.object({
|
|
394
|
+
hasChanges: v.boolean(),
|
|
395
|
+
changedFields: v.array(v.string()),
|
|
396
|
+
fieldDiffs: v.array(v.object({
|
|
397
|
+
field: v.string(),
|
|
398
|
+
previousValue: v.optional(v.any()),
|
|
399
|
+
newValue: v.optional(v.any()),
|
|
400
|
+
})),
|
|
401
|
+
}),
|
|
402
|
+
handler: async (ctx, args) => {
|
|
403
|
+
const log = await ctx.db.get(args.id);
|
|
404
|
+
if (!log) {
|
|
405
|
+
return {
|
|
406
|
+
hasChanges: false,
|
|
407
|
+
changedFields: [],
|
|
408
|
+
fieldDiffs: [],
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
const { previousState, newState, changedFields } = log;
|
|
412
|
+
// If changedFields is already stored, use it
|
|
413
|
+
if (changedFields && changedFields.length > 0) {
|
|
414
|
+
const fieldDiffs = changedFields.map((field) => ({
|
|
415
|
+
field,
|
|
416
|
+
previousValue: previousState
|
|
417
|
+
? previousState[field]
|
|
418
|
+
: undefined,
|
|
419
|
+
newValue: newState
|
|
420
|
+
? newState[field]
|
|
421
|
+
: undefined,
|
|
422
|
+
}));
|
|
423
|
+
return {
|
|
424
|
+
hasChanges: true,
|
|
425
|
+
changedFields,
|
|
426
|
+
fieldDiffs,
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
// Otherwise, compute the diff
|
|
430
|
+
const detectedChanges = detectChangedFields(previousState, newState);
|
|
431
|
+
const fieldDiffs = detectedChanges.map((field) => ({
|
|
432
|
+
field,
|
|
433
|
+
previousValue: previousState
|
|
434
|
+
? previousState[field]
|
|
435
|
+
: undefined,
|
|
436
|
+
newValue: newState
|
|
437
|
+
? newState[field]
|
|
438
|
+
: undefined,
|
|
439
|
+
}));
|
|
440
|
+
return {
|
|
441
|
+
hasChanges: detectedChanges.length > 0,
|
|
442
|
+
changedFields: detectedChanges,
|
|
443
|
+
fieldDiffs,
|
|
444
|
+
};
|
|
445
|
+
},
|
|
446
|
+
});
|
|
447
|
+
// =============================================================================
|
|
448
|
+
// Mutation Functions
|
|
449
|
+
// =============================================================================
|
|
450
|
+
/**
|
|
451
|
+
* Internal mutation to create an audit log entry.
|
|
452
|
+
* Used by scheduled functions and internal operations.
|
|
453
|
+
*/
|
|
454
|
+
export const internalLogAuditEntry = internalMutation({
|
|
455
|
+
args: {
|
|
456
|
+
resourceType: auditResourceTypeValidator,
|
|
457
|
+
resourceId: v.string(),
|
|
458
|
+
action: auditActionValidator,
|
|
459
|
+
userId: v.optional(v.string()),
|
|
460
|
+
userDisplayName: v.optional(v.string()),
|
|
461
|
+
previousState: v.optional(v.any()),
|
|
462
|
+
newState: v.optional(v.any()),
|
|
463
|
+
changeSummary: v.optional(v.string()),
|
|
464
|
+
changedFields: v.optional(v.array(v.string())),
|
|
465
|
+
ipAddress: v.optional(v.string()),
|
|
466
|
+
userAgent: v.optional(v.string()),
|
|
467
|
+
sessionId: v.optional(v.string()),
|
|
468
|
+
requestId: v.optional(v.string()),
|
|
469
|
+
metadata: v.optional(v.any()),
|
|
470
|
+
contentTypeName: v.optional(v.string()),
|
|
471
|
+
entrySlug: v.optional(v.string()),
|
|
472
|
+
},
|
|
473
|
+
returns: v.id("auditLogs"),
|
|
474
|
+
handler: async (ctx, args) => {
|
|
475
|
+
const auditLogId = await ctx.db.insert("auditLogs", {
|
|
476
|
+
resourceType: args.resourceType,
|
|
477
|
+
resourceId: args.resourceId,
|
|
478
|
+
action: args.action,
|
|
479
|
+
userId: args.userId,
|
|
480
|
+
userDisplayName: args.userDisplayName,
|
|
481
|
+
previousState: args.previousState,
|
|
482
|
+
newState: args.newState,
|
|
483
|
+
changeSummary: args.changeSummary,
|
|
484
|
+
changedFields: args.changedFields,
|
|
485
|
+
ipAddress: args.ipAddress,
|
|
486
|
+
userAgent: args.userAgent,
|
|
487
|
+
sessionId: args.sessionId,
|
|
488
|
+
requestId: args.requestId,
|
|
489
|
+
metadata: args.metadata,
|
|
490
|
+
contentTypeName: args.contentTypeName,
|
|
491
|
+
entrySlug: args.entrySlug,
|
|
492
|
+
});
|
|
493
|
+
return auditLogId;
|
|
494
|
+
},
|
|
495
|
+
});
|
|
496
|
+
/**
|
|
497
|
+
* Mutation to clean up old audit logs.
|
|
498
|
+
*
|
|
499
|
+
* Note: This is typically NOT recommended for audit logs as they serve
|
|
500
|
+
* compliance purposes. Only use this if you have a specific retention policy.
|
|
501
|
+
*
|
|
502
|
+
* @param retentionDays - Number of days to retain audit logs (default: 365)
|
|
503
|
+
*
|
|
504
|
+
* @returns Count of audit logs deleted
|
|
505
|
+
*/
|
|
506
|
+
export const cleanupOldAuditLogs = mutation({
|
|
507
|
+
args: {
|
|
508
|
+
retentionDays: v.optional(v.number()),
|
|
509
|
+
},
|
|
510
|
+
returns: v.object({
|
|
511
|
+
deletedCount: v.number(),
|
|
512
|
+
}),
|
|
513
|
+
handler: async (ctx, args) => {
|
|
514
|
+
const { retentionDays = 365 } = args;
|
|
515
|
+
const cutoffTime = Date.now() - retentionDays * 24 * 60 * 60 * 1000;
|
|
516
|
+
let deletedCount = 0;
|
|
517
|
+
// Get old audit logs
|
|
518
|
+
const oldLogs = await ctx.db
|
|
519
|
+
.query("auditLogs")
|
|
520
|
+
.filter((q) => q.lt(q.field("_creationTime"), cutoffTime))
|
|
521
|
+
.take(1000); // Batch limit for safety
|
|
522
|
+
for (const log of oldLogs) {
|
|
523
|
+
await ctx.db.delete(log._id);
|
|
524
|
+
deletedCount++;
|
|
525
|
+
}
|
|
526
|
+
return { deletedCount };
|
|
527
|
+
},
|
|
528
|
+
});
|
|
529
|
+
// =============================================================================
|
|
530
|
+
// Convenience Functions for Common Audit Scenarios
|
|
531
|
+
// =============================================================================
|
|
532
|
+
/**
|
|
533
|
+
* Helper to create an audit log for content entry operations.
|
|
534
|
+
*/
|
|
535
|
+
export async function logContentEntryAudit(ctx, params) {
|
|
536
|
+
const { entryId, action, previousState, newState, contentTypeName, entrySlug, changedFields, ...rest } = params;
|
|
537
|
+
// Auto-detect changed fields if not provided
|
|
538
|
+
const detectedChanges = changedFields ??
|
|
539
|
+
detectChangedFields(previousState, newState);
|
|
540
|
+
return logAuditEntry(ctx, {
|
|
541
|
+
resourceType: "contentEntry",
|
|
542
|
+
resourceId: entryId,
|
|
543
|
+
action,
|
|
544
|
+
previousState,
|
|
545
|
+
newState,
|
|
546
|
+
contentTypeName,
|
|
547
|
+
entrySlug,
|
|
548
|
+
changedFields: detectedChanges.length > 0 ? detectedChanges : undefined,
|
|
549
|
+
changeSummary: generateChangeSummary(action, "contentEntry", detectedChanges, rest.metadata),
|
|
550
|
+
...rest,
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Helper to create an audit log for content type operations.
|
|
555
|
+
*/
|
|
556
|
+
export async function logContentTypeAudit(ctx, params) {
|
|
557
|
+
const { contentTypeId, action, previousState, newState, changedFields, ...rest } = params;
|
|
558
|
+
const detectedChanges = changedFields ??
|
|
559
|
+
detectChangedFields(previousState, newState);
|
|
560
|
+
return logAuditEntry(ctx, {
|
|
561
|
+
resourceType: "contentType",
|
|
562
|
+
resourceId: contentTypeId,
|
|
563
|
+
action,
|
|
564
|
+
previousState,
|
|
565
|
+
newState,
|
|
566
|
+
changedFields: detectedChanges.length > 0 ? detectedChanges : undefined,
|
|
567
|
+
changeSummary: generateChangeSummary(action, "contentType", detectedChanges, rest.metadata),
|
|
568
|
+
...rest,
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Helper to create an audit log for media asset operations.
|
|
573
|
+
*/
|
|
574
|
+
export async function logMediaAssetAudit(ctx, params) {
|
|
575
|
+
const { assetId, action, previousState, newState, changedFields, ...rest } = params;
|
|
576
|
+
const detectedChanges = changedFields ??
|
|
577
|
+
detectChangedFields(previousState, newState);
|
|
578
|
+
return logAuditEntry(ctx, {
|
|
579
|
+
resourceType: "mediaAsset",
|
|
580
|
+
resourceId: assetId,
|
|
581
|
+
action,
|
|
582
|
+
previousState,
|
|
583
|
+
newState,
|
|
584
|
+
changedFields: detectedChanges.length > 0 ? detectedChanges : undefined,
|
|
585
|
+
changeSummary: generateChangeSummary(action, "mediaAsset", detectedChanges, rest.metadata),
|
|
586
|
+
...rest,
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* Helper to create an audit log for media folder operations.
|
|
591
|
+
*/
|
|
592
|
+
export async function logMediaFolderAudit(ctx, params) {
|
|
593
|
+
const { folderId, action, previousState, newState, changedFields, ...rest } = params;
|
|
594
|
+
const detectedChanges = changedFields ??
|
|
595
|
+
detectChangedFields(previousState, newState);
|
|
596
|
+
return logAuditEntry(ctx, {
|
|
597
|
+
resourceType: "mediaFolder",
|
|
598
|
+
resourceId: folderId,
|
|
599
|
+
action,
|
|
600
|
+
previousState,
|
|
601
|
+
newState,
|
|
602
|
+
changedFields: detectedChanges.length > 0 ? detectedChanges : undefined,
|
|
603
|
+
changeSummary: generateChangeSummary(action, "mediaFolder", detectedChanges, rest.metadata),
|
|
604
|
+
...rest,
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
//# sourceMappingURL=auditLog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auditLog.js","sourceRoot":"","sources":["../../src/component/auditLog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;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