diff --git a/package-lock.json b/package-lock.json index 7b36ab9..8973054 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.1.1", "license": "AGPL-3.0-or-later", "dependencies": { - "@plures/praxis": "^2.4.21" + "@plures/praxis": "^2.4.27" }, "devDependencies": { "@vitest/coverage-v8": "^4.1.1", diff --git a/src/chronicle.js b/src/chronicle.js index 100bd1f..d4c13f8 100644 --- a/src/chronicle.js +++ b/src/chronicle.js @@ -346,4 +346,39 @@ export function createChronicle(db, options = {}) { }; } -export { withCause, currentCause }; +/** + * Run a function within a causal context so that all nodes created during + * execution carry `causeId` as their causal parent. + * + * Re-exported from `@plures/chronos/causal` for convenience. + * + * @param {string} causeId - ID of the parent node to set as the active cause + * @param {Function} fn - Synchronous or async function to execute inside the scope + * @returns {*} The return value of `fn` + * + * @example + * ```js + * import { withCause } from '@plures/chronos/chronicle'; + * + * withCause('chrono:1699000000000-1', () => { + * // All chronicle nodes created here carry the causeId + * }); + * ``` + */ +export { withCause }; + +/** + * Get the current causal parent ID. + * + * Re-exported from `@plures/chronos/causal` for convenience. + * + * @returns {string|null} The active causal parent ID, or `null` outside a causal scope. + * + * @example + * ```js + * import { currentCause } from '@plures/chronos/chronicle'; + * + * console.log(currentCause()); // null (outside any causal scope) + * ``` + */ +export { currentCause }; diff --git a/src/index.js b/src/index.js index 4df8986..298ff6b 100644 --- a/src/index.js +++ b/src/index.js @@ -269,4 +269,39 @@ export function createChronos(db, options = {}) { }; } -export { withCause, currentCause }; +/** + * Run a function within a causal context so that all nodes created during + * execution carry `causeId` as their causal parent. + * + * Re-exported from `@plures/chronos/causal` for convenience. + * + * @param {string} causeId - ID of the parent node to set as the active cause + * @param {Function} fn - Synchronous or async function to execute inside the scope + * @returns {*} The return value of `fn` + * + * @example + * ```js + * import { withCause } from '@plures/chronos'; + * + * withCause('chrono:1699000000000-1', () => { + * // All nodes created here carry the causeId + * }); + * ``` + */ +export { withCause }; + +/** + * Get the current causal parent ID. + * + * Re-exported from `@plures/chronos/causal` for convenience. + * + * @returns {string|null} The active causal parent ID, or `null` outside a causal scope. + * + * @example + * ```js + * import { currentCause } from '@plures/chronos'; + * + * console.log(currentCause()); // null (outside any causal scope) + * ``` + */ +export { currentCause }; diff --git a/src/praxis.js b/src/praxis.js index 81efb0a..a9aa4e9 100644 --- a/src/praxis.js +++ b/src/praxis.js @@ -93,8 +93,63 @@ export function createChronosEngine(options = {}) { } // Re-export all rule modules and event tag constants for convenience +/** + * Praxis module bundling all diff-classification rules and constraints. + * + * Re-exported from `@plures/chronos/rules` for convenience. + * + * @type {object} + * + * @example + * ```js + * import { diffClassificationModule } from '@plures/chronos/praxis'; + * registry.registerModule(diffClassificationModule); + * ``` + */ export { diffClassificationModule } from './rules/diff-classification.js'; + +/** + * Praxis module bundling all retention-policy rules and constraints. + * + * Re-exported from `@plures/chronos/rules` for convenience. + * + * @type {object} + * + * @example + * ```js + * import { retentionPolicyModule } from '@plures/chronos/praxis'; + * registry.registerModule(retentionPolicyModule); + * ``` + */ export { retentionPolicyModule } from './rules/retention-policy.js'; + +/** + * Praxis module bundling all alerting rules and constraints. + * + * Re-exported from `@plures/chronos/rules` for convenience. + * + * @type {object} + * + * @example + * ```js + * import { alertingModule } from '@plures/chronos/praxis'; + * registry.registerModule(alertingModule); + * ``` + */ export { alertingModule } from './rules/alerting.js'; + +/** + * Praxis module bundling all integrity rules and constraints. + * + * Re-exported from `@plures/chronos/rules` for convenience. + * + * @type {object} + * + * @example + * ```js + * import { integrityModule } from '@plures/chronos/praxis'; + * registry.registerModule(integrityModule); + * ``` + */ export { integrityModule } from './rules/integrity.js'; export * from './rules/index.js';