@brandlift/payload-loggs 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/collections/SiteActivityCollection.d.ts +18 -0
  2. package/dist/collections/siteActivity.d.ts +17 -0
  3. package/dist/core/automation/tasks/cleanup/cleanup.d.ts +13 -0
  4. package/dist/core/automation/tasks/cleanup/cleanup.test.d.ts +1 -0
  5. package/dist/core/buffer/bufferManager.d.ts +14 -0
  6. package/dist/core/buffer/bufferManager.test.d.ts +1 -0
  7. package/dist/core/buffer/types.d.ts +94 -0
  8. package/dist/core/events/emitter.d.ts +3 -0
  9. package/dist/core/log-builders/helpers/extractOperation/extractOperation.d.ts +8 -0
  10. package/dist/core/log-builders/helpers/handleDebugMode.d.ts +12 -0
  11. package/dist/core/log-builders/helpers/isOperationEnabled/isOperationEnabled.d.ts +11 -0
  12. package/dist/core/log-builders/helpers/isOperationEnabled/isOperationEnabled.test.d.ts +1 -0
  13. package/dist/core/log-builders/logBuilderManager/logBuilderManager.d.ts +13 -0
  14. package/dist/core/log-builders/logBuilderManager/logBuilderManager.test.d.ts +1 -0
  15. package/dist/hooks/collectionHooks.d.ts +6 -0
  16. package/dist/hooks/globalHooks.d.ts +3 -0
  17. package/dist/index.d.ts +12 -0
  18. package/dist/plugin.d.ts +6 -0
  19. package/dist/plugin.test.d.ts +1 -0
  20. package/dist/pluginUtils/attachCollectionConfig/attachCollectionConfig.d.ts +3 -0
  21. package/dist/pluginUtils/attachGlobalConfig/attachGlobalConfig.d.ts +3 -0
  22. package/dist/pluginUtils/configHelpers.d.ts +9 -0
  23. package/dist/pluginUtils/formatUserDisplay.d.ts +5 -0
  24. package/dist/pluginUtils/formatUserDisplay.test.d.ts +1 -0
  25. package/dist/pluginUtils/getCollectionLabel.d.ts +10 -0
  26. package/dist/pluginUtils/getCollectionLabel.test.d.ts +1 -0
  27. package/dist/pluginUtils/getResourceTitle.d.ts +5 -0
  28. package/dist/pluginUtils/getResourceTitle.test.d.ts +1 -0
  29. package/dist/types/collection.d.ts +36 -0
  30. package/dist/types/config.d.ts +62 -0
  31. package/dist/types/global.d.ts +31 -0
  32. package/dist/utils/prettyDebugLog.d.ts +10 -0
  33. package/package.json +4 -24
@@ -0,0 +1,18 @@
1
+ import type { CollectionConfig } from 'payload';
2
+ export type SiteActivityLogData = {
3
+ title: string;
4
+ operation: 'create' | 'update' | 'delete' | 'login' | 'logout';
5
+ resourceName?: string;
6
+ resourceType: 'collection' | 'global';
7
+ collectionLabel?: string;
8
+ slug: string;
9
+ documentId?: string;
10
+ locale?: string;
11
+ user?: string | number;
12
+ userEmail?: string;
13
+ userDisplay?: string;
14
+ createdAt?: string;
15
+ };
16
+ export declare const SITE_ACTIVITY_SLUG = "site-activity";
17
+ export declare const SiteActivityCollection: CollectionConfig;
18
+ export default SiteActivityCollection;
@@ -0,0 +1,17 @@
1
+ import type { GlobalHooksKeys } from '../types/global.js';
2
+ import { SiteActivityCollection } from './SiteActivityCollection.js';
3
+ import type { SiteActivityLogData } from './SiteActivityCollection.js';
4
+ import type { CollectionHooksKeys, CollectionHooksOperation } from '../types/collection.js';
5
+ export interface SiteActivityLog extends Omit<Partial<SiteActivityLogData>, 'operation'> {
6
+ scope?: 'collection' | 'global' | 'field';
7
+ hook?: CollectionHooksKeys | GlobalHooksKeys | string;
8
+ operation: CollectionHooksOperation;
9
+ timestamp?: Date;
10
+ userAgent?: string;
11
+ identifier?: string;
12
+ }
13
+ export type { SiteActivityLogData };
14
+ export type TypedRootCollection = typeof SiteActivityCollection;
15
+ export declare const siteActivity: import("payload").CollectionConfig;
16
+ export declare const siteActivityCollection: import("payload").CollectionConfig;
17
+ export default siteActivity;
@@ -0,0 +1,13 @@
1
+ import type { CollectionConfig, TaskConfig } from 'payload';
2
+ import type { PluginConfig } from '../../../../types/config.js';
3
+ export declare const DEFAULT_OLDER_THAN = 2592000000;
4
+ export declare const DEFAULT_CRON_TIME = "1 0 * * *";
5
+ export declare const DEFAULT_QUEUE_NAME = "payload-loggs-queue";
6
+ export declare const CLEANUP_TASK_SLUG = "cleanup-site-activity-log";
7
+ export declare const CLEANUP_TASK_LABEL = "payload loggs - cleanup site activities";
8
+ type CleanupLogsTaskParams = {
9
+ pluginConfig: PluginConfig;
10
+ internalCollectionConfig: CollectionConfig;
11
+ };
12
+ export declare const cleanupLogsTask: (params: CleanupLogsTaskParams) => TaskConfig<typeof CLEANUP_TASK_SLUG>;
13
+ export {};
@@ -0,0 +1,14 @@
1
+ import type { CollectionConfig, Payload } from 'payload';
2
+ import type { BufferConfig } from './types.js';
3
+ import type { SiteActivityLog } from '../../collections/siteActivity.js';
4
+ export declare const DEFAULT_INTERVAL_BUFFER: NonNullable<BufferConfig["time"]>;
5
+ export declare const DEFAULT_BUFFER_SIZE: NonNullable<BufferConfig["size"]>;
6
+ export declare const DEFAULT_BUFFER_STRATEGY: NonNullable<BufferConfig["flushStrategy"]>;
7
+ export declare const bufferStore: SiteActivityLog[];
8
+ type BufferConfigParams = {
9
+ payload: Payload;
10
+ bufferConfig?: BufferConfig;
11
+ internalCollectionConfig: CollectionConfig;
12
+ };
13
+ export declare const bufferManager: (params: BufferConfigParams) => void;
14
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,94 @@
1
+ export interface BufferDebugFields {
2
+ flushStrategy: boolean;
3
+ interval: boolean;
4
+ size: boolean;
5
+ }
6
+ export type BufferDebugModeConfig = {
7
+ /**
8
+ * 📝 Enable or disable debug mode
9
+ *
10
+ * 📖 long.
11
+ *
12
+ * 📌@type {'manual' | 'table'}
13
+ *
14
+ * @default false
15
+ *
16
+ */
17
+ enabled?: boolean;
18
+ } | true;
19
+ export interface BufferConfig {
20
+ /**
21
+ * 📝 The basics of injecting logs into the database
22
+ *
23
+ *
24
+ *
25
+ * @default "time"
26
+ *
27
+ *
28
+ * 📦 Usage Example
29
+ *
30
+ * @example <caption>🧪 Data injection based on log count</caption>
31
+ * ```ts
32
+ * flushStrategy: 'size',
33
+ * ```
34
+ * ### ⚠️ Critical Notes
35
+ * - If you use the size method, your logs will be stored in RAM before being injected into the database.
36
+ *
37
+ */
38
+ flushStrategy?: 'realtime' | 'size' | 'time';
39
+ /**
40
+ * 📝 Maximum number of logs before injection
41
+ *
42
+ * 📖 If the number of logs stored in the buffer memory reaches this number, data will be injected.
43
+ *
44
+ * 📌@type {number}
45
+ *
46
+ * @default 10
47
+ *
48
+ *
49
+ * 📦 Usage Example
50
+ *
51
+ * @example <caption>🧪 Up to 18 logs can be stored in memory</caption>
52
+ * ```ts
53
+ * size: 18
54
+ * ```
55
+ *
56
+ * ---
57
+ * ### ⚠️ Critical Notes
58
+ * - Works when flushStrategy is equal to size
59
+ * - If you enter the number 1, use the realtime method and do not define a value for this.
60
+ * ```ts
61
+ * flushStrategy: 'realtime',
62
+ * ```
63
+ * - Very high numbers will increase RAM usage.
64
+ * - If you set a high number and on the other hand the logs produced are low, the logs will be recorded later.
65
+ *
66
+ */
67
+ size?: number;
68
+ /**
69
+ * 📝 Maximum time to inject logs into the buffer relative to the last injection
70
+ *
71
+ *
72
+ * 📌@type {Duration}
73
+ *
74
+ * @default 10000
75
+ *
76
+ *
77
+ * 📦 Usage Example
78
+ *
79
+ * @example <caption>🧪 Inject logs every 1 minute</caption>
80
+ * ```ts
81
+ * time: 5000
82
+ * ```
83
+ *
84
+ * ---
85
+ * ### ⚠️ Critical Notes
86
+ * - If you want to enter a value of "1s", set the flushStrategy value to time instead and do not define a value for the time property.
87
+ * ```ts
88
+ * flushStrategy: 'realtime',
89
+ * ```
90
+ * - If you set the time too low, the CPU will be severely affected.
91
+ * - If you allow too much time, the logs will be recorded later. If the server crashes, the logs will be lost.
92
+ */
93
+ time?: number;
94
+ }
@@ -0,0 +1,3 @@
1
+ import type { SiteActivityLog } from '../../collections/siteActivity.js';
2
+ export declare const emitEvent: <T>(event: string, data: T) => void;
3
+ export declare const onEventLog: (event: string, handler: (log: SiteActivityLog) => Promise<void>) => void;
@@ -0,0 +1,8 @@
1
+ import type { GlobalHooksArgsParameterUnion, GlobalHooksKeys } from '../../../../types/global.js';
2
+ import type { CollectionHooksArgsParameterUnion, CollectionHooksKeys, CollectionHooksOperation } from '../../../../types/collection.js';
3
+ interface Params {
4
+ hookArgs: CollectionHooksArgsParameterUnion | GlobalHooksArgsParameterUnion;
5
+ targetHookName: CollectionHooksKeys | GlobalHooksKeys;
6
+ }
7
+ export declare const extractOperation: (params: Params) => CollectionHooksOperation;
8
+ export {};
@@ -0,0 +1,12 @@
1
+ import type { SiteActivityLog } from '../../../collections/siteActivity.js';
2
+ import type { GlobalHookConfigForTracking, GlobalHooksKeys, GlobalOperationLogConfig } from '../../../types/global.js';
3
+ import type { CollectionHooksKeys, CollectionHooksOperation, CollectionsHookConfigForTracking } from '../../../types/collection.js';
4
+ type Params = {
5
+ hookLevelConfig?: CollectionsHookConfigForTracking[CollectionHooksKeys] | GlobalHookConfigForTracking[GlobalHooksKeys];
6
+ operationLevelConfig?: GlobalOperationLogConfig;
7
+ logData: SiteActivityLog;
8
+ operation: CollectionHooksOperation;
9
+ hookName: CollectionHooksKeys;
10
+ };
11
+ export declare const handleDebugMode: (params: Params) => void;
12
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { CollectionConfig } from 'payload';
2
+ import type { CollectionOperationLogConfig, CollectionsHookConfigForTracking } from '../../../../types/collection.js';
3
+ import type { GlobalHookConfigForTracking, GlobalHooksKeys, GlobalOperationLogConfig } from '../../../../types/global.js';
4
+ type CollectionHooksKeys = keyof NonNullable<CollectionConfig['hooks']>;
5
+ interface Params {
6
+ hookOperationLevelConfig?: CollectionOperationLogConfig<CollectionHooksKeys> | GlobalOperationLogConfig<GlobalHooksKeys> | true;
7
+ hookLevelConfig?: CollectionsHookConfigForTracking[CollectionHooksKeys] | GlobalHookConfigForTracking[GlobalHooksKeys];
8
+ }
9
+ export declare const isBooleanConfig: <T>(v: T) => boolean | undefined;
10
+ export declare const checkIsOperationEnabled: (params: Params) => boolean;
11
+ export {};
@@ -0,0 +1,13 @@
1
+ import type { PluginConfig } from '../../../types/config.js';
2
+ import type { SiteActivityLog } from '../../../collections/siteActivity.js';
3
+ import type { GlobalHookConfigForTracking, GlobalHooksArgsParameterUnion, GlobalHooksKeys } from '../../../types/global.js';
4
+ import type { CollectionHooksArgsParameterUnion, CollectionHooksKeys, CollectionsHookConfigForTracking } from '../../../types/collection.js';
5
+ export type LogBuilderManager = {
6
+ hookArgs: CollectionHooksArgsParameterUnion | GlobalHooksArgsParameterUnion;
7
+ pluginConfig: PluginConfig;
8
+ targetHookName: CollectionHooksKeys;
9
+ targetHookLevelConfig: CollectionsHookConfigForTracking[CollectionHooksKeys] | GlobalHookConfigForTracking[GlobalHooksKeys];
10
+ scopeSlug: NonNullable<SiteActivityLog['scope']>;
11
+ identifier: string;
12
+ };
13
+ export declare const logBuilderManager: (params: LogBuilderManager) => Promise<void>;
@@ -0,0 +1,6 @@
1
+ import type { CollectionAfterChangeHook, CollectionAfterDeleteHook, CollectionAfterLoginHook, CollectionAfterLogoutHook, CollectionConfig, Config } from 'payload';
2
+ import type { PluginConfig } from '../types/config.js';
3
+ export declare const createCollectionAfterChangeHook: (collection: CollectionConfig, payloadConfig: Config, _pluginConfig?: PluginConfig) => CollectionAfterChangeHook;
4
+ export declare const createCollectionAfterDeleteHook: (collection: CollectionConfig, payloadConfig: Config, _pluginConfig?: PluginConfig) => CollectionAfterDeleteHook;
5
+ export declare const createCollectionAfterLoginHook: (collection: CollectionConfig, _payloadConfig: Config, _pluginConfig?: PluginConfig) => CollectionAfterLoginHook;
6
+ export declare const createCollectionAfterLogoutHook: (collection: CollectionConfig, _payloadConfig: Config, _pluginConfig?: PluginConfig) => CollectionAfterLogoutHook;
@@ -0,0 +1,3 @@
1
+ import type { Config, GlobalAfterChangeHook, GlobalConfig } from 'payload';
2
+ import type { PluginConfig } from '../types/config.js';
3
+ export declare const createGlobalAfterChangeHook: (globalConfig: GlobalConfig, payloadConfig: Config, _pluginConfig?: PluginConfig) => GlobalAfterChangeHook;
@@ -0,0 +1,12 @@
1
+ import { getResourceTitle } from './pluginUtils/getResourceTitle.js';
2
+ import type { SiteActivityLog } from './collections/siteActivity.js';
3
+ import { formatUserDisplay } from './pluginUtils/formatUserDisplay.js';
4
+ import { getCollectionLabel } from './pluginUtils/getCollectionLabel.js';
5
+ import { payloadLoggsPlugin, siteActivity, siteActivityPlugin } from './plugin.js';
6
+ import { siteActivity as siteActivityCollection } from './collections/siteActivity.js';
7
+ import { SITE_ACTIVITY_SLUG, SiteActivityCollection } from './collections/SiteActivityCollection.js';
8
+ export type { SiteActivityLogData } from './collections/SiteActivityCollection.js';
9
+ export type { AutomationConfig, PluginConfig } from './types/config.js';
10
+ export type { SiteActivityLog };
11
+ export { formatUserDisplay, getCollectionLabel, getResourceTitle, payloadLoggsPlugin, SITE_ACTIVITY_SLUG, siteActivity, SiteActivityCollection, siteActivityCollection, siteActivityPlugin, };
12
+ export default siteActivity;
@@ -0,0 +1,6 @@
1
+ import type { Plugin } from 'payload';
2
+ import type { PluginConfig } from './types/config.js';
3
+ export declare const siteActivity: (pluginConfig?: PluginConfig) => Plugin;
4
+ export declare const siteActivityPlugin: (pluginConfig?: PluginConfig) => Plugin;
5
+ export declare const payloadLoggsPlugin: (pluginConfig?: PluginConfig) => Plugin;
6
+ export default siteActivity;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { Config } from 'payload';
2
+ import type { PluginConfig } from '../../types/config.js';
3
+ export declare const attachCollectionConfig: (userCollections: Config["collections"], pluginOpts: PluginConfig, payloadConfig: Config) => Config["collections"];
@@ -0,0 +1,3 @@
1
+ import type { Config } from 'payload';
2
+ import type { PluginConfig } from '../../types/config.js';
3
+ export declare const attachGlobalConfig: (userGlobals: Config["globals"], pluginOpts: PluginConfig, payloadConfig: Config) => Config["globals"];
@@ -0,0 +1,9 @@
1
+ import type { BasePayload, CollectionConfig, Config } from 'payload';
2
+ import type { PluginConfig } from '../types/config.js';
3
+ type OnInitManagerParams = {
4
+ payloadConfig: Config;
5
+ pluginConfig: PluginConfig;
6
+ internalCollectionConfig: CollectionConfig;
7
+ };
8
+ export declare const onInitManager: (params: OnInitManagerParams) => (payload: BasePayload) => Promise<void>;
9
+ export {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Extracts a shortened display name from an email address (everything before '@').
3
+ * Example: "rushikesh.s@brandlift.com" -> "rushikesh.s"
4
+ */
5
+ export declare const formatUserDisplay: (email?: string | null) => string | undefined;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { CollectionConfig, GlobalConfig } from 'payload';
2
+ /**
3
+ * Resolves a human-readable singular label for a collection or global.
4
+ * Defaults to capitalizing the slug if labels are omitted.
5
+ */
6
+ export declare const getCollectionLabel: (entity: CollectionConfig | GlobalConfig | {
7
+ slug: string;
8
+ labels?: any;
9
+ label?: any;
10
+ }) => string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Extracts a human-readable resource title from a document or global data object,
3
+ * falling back to document ID if title attributes are missing.
4
+ */
5
+ export declare const getResourceTitle: (doc?: Record<string, any> | null, fallbackId?: string | number | null) => string | undefined;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,36 @@
1
+ import type { AllOperations, CollectionConfig, PayloadTypes } from 'payload';
2
+ import type { SiteActivityLog } from '../collections/siteActivity.js';
3
+ export type OperationDebugConfig = {
4
+ skipDatabaseSave?: boolean;
5
+ } | true;
6
+ export type CollectionHookDebugConfig = {
7
+ skipDatabaseSave?: true;
8
+ } | true;
9
+ export type CollectionHooksKeys = keyof NonNullable<CollectionConfig['hooks']>;
10
+ export type CollectionHooksOperation = AllOperations | 'read' | 'delete' | 'error' | 'login' | 'logout' | 'me' | 'refresh' | 'forgotPassword' | '';
11
+ export type CollectionHooksArgsParameterUnion = Parameters<NonNullable<NonNullable<CollectionConfig['hooks']>[CollectionHooksKeys]>[number]>[0];
12
+ export type PayloadCollectionHooksMap = {
13
+ [K in CollectionHooksKeys]: NonNullable<NonNullable<CollectionConfig['hooks']>[K]>[number];
14
+ };
15
+ export type CollectionsHookConfigForTracking = {
16
+ [K in keyof NonNullable<CollectionConfig['hooks']>]: Partial<{
17
+ [O in Parameters<NonNullable<NonNullable<CollectionConfig['hooks']>[K]>[number]>[0]['operation']]: CollectionOperationLogConfig | boolean;
18
+ } & CollectionHookLevelLogConfig<K>> | boolean;
19
+ };
20
+ export interface CollectionOperationLogConfig<HookName extends CollectionHooksKeys = CollectionHooksKeys> {
21
+ customLogger?: (args: Parameters<PayloadCollectionHooksMap[HookName]>[0], fields: Omit<SiteActivityLog, 'hook' | 'operation'>) => any | Promise<any>;
22
+ enabled?: boolean;
23
+ debug?: OperationDebugConfig;
24
+ }
25
+ export interface CollectionHookLevelLogConfig<HookName extends CollectionHooksKeys = CollectionHooksKeys> {
26
+ customLogger?: (args: Parameters<PayloadCollectionHooksMap[HookName]>[0], fields: Omit<SiteActivityLog, 'hook'>) => Omit<SiteActivityLog, 'hook'> | Promise<Omit<SiteActivityLog, 'hook'>>;
27
+ enabled?: boolean;
28
+ debug?: CollectionHookDebugConfig;
29
+ }
30
+ export interface TrackedCollection {
31
+ hooks?: Partial<CollectionsHookConfigForTracking>;
32
+ slug: keyof PayloadTypes['collections'];
33
+ }
34
+ export interface CollectionsTrackConfig {
35
+ track: TrackedCollection[];
36
+ }
@@ -0,0 +1,62 @@
1
+ import type { CollectionConfig } from 'payload';
2
+ import type { GlobalsTrackConfig } from './global.js';
3
+ import type { BufferConfig } from '../core/buffer/types.js';
4
+ import type { CollectionsTrackConfig } from './collection.js';
5
+ import type { siteActivity } from '../collections/siteActivity.js';
6
+ export interface AutomationConfig {
7
+ logCleanup?: {
8
+ /**
9
+ * @default 2592000000 // 30 days
10
+ */
11
+ olderThan?: number;
12
+ /**
13
+ * @default "payload-loggs-queue"
14
+ */
15
+ queueName?: string;
16
+ /**
17
+ * The cron for scheduling the job.
18
+ *
19
+ * @default '1 0 * * *' // At 00:01 AM daily
20
+ *
21
+ * @example
22
+ * ┌───────────── (optional) second (0 - 59)
23
+ * │ ┌───────────── minute (0 - 59)
24
+ * │ │ ┌───────────── hour (0 - 23)
25
+ * │ │ │ ┌───────────── day of the month (1 - 31)
26
+ * │ │ │ │ ┌───────────── month (1 - 12)
27
+ * │ │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday)
28
+ * │ │ │ │ │ │
29
+ * │ │ │ │ │ │
30
+ * - '* 0 * * * *' every hour at minute 0
31
+ * - '* 0 0 * * *' daily at midnight
32
+ * - '* 0 0 * * 0' weekly at midnight on Sundays
33
+ * - '* 0 0 1 * *' monthly at midnight on the 1st day of the month
34
+ * - '* 0/5 * * * *' every 5 minutes
35
+ * - '* * * * * *' every second
36
+ */
37
+ cronTime?: string;
38
+ };
39
+ }
40
+ export interface PluginConfig {
41
+ /**
42
+ * @see {@link https://github.com/rushidshinde/payload-loggs#automation}
43
+ */
44
+ automation?: AutomationConfig;
45
+ /**
46
+ * @see {@link https://github.com/rushidshinde/payload-loggs#collectionsglobals}
47
+ */
48
+ collections?: CollectionsTrackConfig;
49
+ /**
50
+ * @see {@link https://github.com/rushidshinde/payload-loggs#buffer}
51
+ */
52
+ buffer?: BufferConfig;
53
+ /**
54
+ * @see {@link https://github.com/rushidshinde/payload-loggs#configurerootcollection}
55
+ */
56
+ configureRootCollection?: (defaults: typeof siteActivity) => CollectionConfig;
57
+ /**
58
+ * @see {@link https://github.com/rushidshinde/payload-loggs#collectionsglobals}
59
+ */
60
+ globals?: GlobalsTrackConfig;
61
+ disabled?: boolean;
62
+ }
@@ -0,0 +1,31 @@
1
+ import type { GlobalConfig, PayloadTypes } from 'payload';
2
+ import type { CollectionHookDebugConfig } from './collection.js';
3
+ import type { SiteActivityLog } from '../collections/siteActivity.js';
4
+ export type GlobalHooksKeys = keyof NonNullable<GlobalConfig['hooks']>;
5
+ export type GlobalOperationDebugConfig = {
6
+ skipDatabaseSave?: boolean;
7
+ } | true;
8
+ export type GlobalHookConfigForTracking = {
9
+ [K in keyof NonNullable<GlobalConfig['hooks']>]: Partial<{
10
+ [O in Parameters<NonNullable<NonNullable<GlobalConfig['hooks']>[K]>[number]>[0]['operation']]: GlobalOperationLogConfig | boolean;
11
+ } & GlobalHookLevelLogConfig<K>> | boolean;
12
+ };
13
+ export interface GlobalOperationLogConfig<HookName extends GlobalHooksKeys = GlobalHooksKeys> {
14
+ customLogger?: (args: Parameters<NonNullable<NonNullable<GlobalConfig['hooks']>[HookName]>[number]>[0], fields: Omit<SiteActivityLog, 'hook' | 'operation'>) => Omit<SiteActivityLog, 'hook' | 'operation'> | Promise<Omit<SiteActivityLog, 'hook' | 'operation'>>;
15
+ enabled?: boolean;
16
+ debug?: GlobalOperationDebugConfig;
17
+ }
18
+ export interface GlobalHookLevelLogConfig<HookName extends GlobalHooksKeys = GlobalHooksKeys> {
19
+ customLogger?: (args: Parameters<NonNullable<NonNullable<GlobalConfig['hooks']>[HookName]>[number]>[0], fields: Omit<SiteActivityLog, 'hook'>) => any | Promise<any>;
20
+ enabled?: boolean;
21
+ debug?: GlobalHookDebugConfig;
22
+ }
23
+ export type GlobalHookDebugConfig = CollectionHookDebugConfig;
24
+ export interface TrackedGlobal {
25
+ hooks?: Partial<GlobalHookConfigForTracking>;
26
+ slug: keyof PayloadTypes['globals'];
27
+ }
28
+ export interface GlobalsTrackConfig {
29
+ track: TrackedGlobal[];
30
+ }
31
+ export type GlobalHooksArgsParameterUnion = Parameters<NonNullable<NonNullable<GlobalConfig['hooks']>[GlobalHooksKeys]>[number]>[0];
@@ -0,0 +1,10 @@
1
+ import type { LiteralUnion } from 'type-fest';
2
+ import type { GlobalHooksKeys } from '../types/global.js';
3
+ import type { CollectionHooksKeys, CollectionHooksOperation } from '../types/collection.js';
4
+ type Params = {
5
+ title: LiteralUnion<CollectionHooksKeys | GlobalHooksKeys, string>;
6
+ subtitle: LiteralUnion<CollectionHooksOperation | CollectionHooksOperation, string>;
7
+ data: Record<string, any>;
8
+ };
9
+ export declare const prettyDebugLog: (params: Params) => void;
10
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@brandlift/payload-loggs",
3
3
  "type": "module",
4
- "version": "1.0.2",
4
+ "version": "1.0.4",
5
5
  "packageManager": "pnpm@10.2.0",
6
6
  "description": "Zero-config activity feed, audit logging, and security tracking plugin for Payload CMS",
7
7
  "author": {
@@ -34,16 +34,6 @@
34
34
  "types": "./dist/index.d.ts",
35
35
  "import": "./dist/index.js",
36
36
  "default": "./dist/index.js"
37
- },
38
- "./client": {
39
- "types": "./dist/exports/client.d.ts",
40
- "import": "./dist/exports/client.js",
41
- "default": "./dist/exports/client.js"
42
- },
43
- "./rsc": {
44
- "types": "./dist/exports/rsc.d.ts",
45
- "import": "./dist/exports/rsc.js",
46
- "default": "./dist/exports/rsc.js"
47
37
  }
48
38
  },
49
39
  "main": "./dist/index.js",
@@ -62,7 +52,7 @@
62
52
  "build": "npm run copyfiles && npm run build:types && npm run build:swc",
63
53
  "build:types": "tsc --outDir dist --rootDir ./src",
64
54
  "build:only": "npm run copyfiles && npm run build:types && npm run build:swc",
65
- "clean": "rimraf {dist,*.tsbuildinfo} --glob",
55
+ "clean": "rimraf {dist,*.tsbuildinfo,.cache/tsbuildinfo} --glob",
66
56
  "copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
67
57
  "eslint": "eslint .",
68
58
  "lint": "npm run eslint:base",
@@ -87,7 +77,7 @@
87
77
  },
88
78
  "devDependencies": {
89
79
  "@antfu/eslint-config": "^9.1.0",
90
- "@brandlift/payload-loggs": "^1.0.1",
80
+ "@brandlift/payload-loggs": "^1.0.3",
91
81
  "@commitlint/cli": "^21.2.1",
92
82
  "@commitlint/config-conventional": "^21.2.0",
93
83
  "@eslint-react/eslint-plugin": "^5.17.1",
@@ -134,19 +124,9 @@
134
124
  "access": "public",
135
125
  "exports": {
136
126
  ".": {
137
- "import": "./dist/index.js",
138
127
  "types": "./dist/index.d.ts",
128
+ "import": "./dist/index.js",
139
129
  "default": "./dist/index.js"
140
- },
141
- "./client": {
142
- "import": "./dist/exports/client.js",
143
- "types": "./dist/exports/client.d.ts",
144
- "default": "./dist/exports/client.js"
145
- },
146
- "./rsc": {
147
- "import": "./dist/exports/rsc.js",
148
- "types": "./dist/exports/rsc.d.ts",
149
- "default": "./dist/exports/rsc.js"
150
130
  }
151
131
  },
152
132
  "main": "./dist/index.js",