@dyrected/core 2.16.0 → 2.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{app-KSDgfXsw.d.cts → app-Dd9cBbCs.d.cts} +1460 -1184
- package/dist/{app-KSDgfXsw.d.ts → app-Dd9cBbCs.d.ts} +1460 -1184
- package/dist/index.cjs +988 -6
- package/dist/index.d.cts +155 -4
- package/dist/index.d.ts +155 -4
- package/dist/index.js +969 -6
- package/dist/server.cjs +1079 -40
- package/dist/server.d.cts +20 -4
- package/dist/server.d.ts +20 -4
- package/dist/server.js +1078 -40
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as Field, B as Block, C as CollectionConfig, D as DyrectedConfig, A as AdminAuthConfig, P as PublicAdminAuthConfig, G as GlobalConfig, a as DeclarativeHookExpression, W as WorkflowConfig, b as AuthenticatedUser, c as WorkflowTransition, L as LifecycleEventName, d as LifecycleEvent, e as BaseDocument, H as HookRequestContext,
|
|
2
|
-
export {
|
|
1
|
+
import { F as Field, B as Block, C as CollectionConfig, D as DyrectedConfig, A as AdminAuthConfig, P as PublicAdminAuthConfig, G as GlobalConfig, a as DeclarativeHookExpression, W as WorkflowConfig, b as AuthenticatedUser, c as WorkflowTransition, L as LifecycleEventName, d as LifecycleEvent, e as DatabaseAdapter, f as BaseDocument, H as HookRequestContext, T as TaskRunResult, g as TaskConfig, h as DetailActionOptions, i as DetailAction, j as DetailComputedOptions, k as ComputedHandler, l as DetailComputed, m as DetailCustomOptions, n as DetailCustom, o as DetailDividerOptions, p as DetailDivider, q as DisplayFieldOptions, r as DetailField, s as DetailItem, t as DetailGridOptions, u as DetailGrid, v as DetailRepeatOptions, w as DetailRepeat, x as DetailSectionOptions, y as DetailSection, z as DetailTabOptions, E as DetailTab, I as DetailTabsOptions, J as DetailTabs, K as DetailTextOptions, M as DetailText, N as DetailSchema, O as DyrectedContext, Q as AIConfig, R as AIPIIConfig, S as IdStrategy, U as CompiledNavTree, V as CompiledNavItem, X as UserNavigationPreferences, Y as DefineWorkspaceOptions, Z as ArrayField, _ as FieldType, $ as BooleanField, a0 as AuthConfig, a1 as AccessPolicyResolver, a2 as DateField, a3 as DateTimeField, a4 as EmailField, a5 as IconField, a6 as ImageField, a7 as JoinField, a8 as JsonField, a9 as MoneyField, aa as MultiSelectField, ab as NumberField, ac as ObjectField, ad as RadioField, ae as RelationshipField, af as RichTextField, ag as RowField, ah as SelectField, ai as TextField, aj as TextareaField, ak as TimeField, al as UrlField } from './app-Dd9cBbCs.cjs';
|
|
2
|
+
export { am as AIAction, an as AIActionStatus, ao as AIActionType, ap as AIAuditActionType, aq as AIAuditRecord, ar as AIChunk, as as AIMessage, at as AIPIIPattern, au as AIRateLimitResult, av as AIRateLimitStore, aw as AIThread, ax as AIToolContext, ay as AIToolDefinition, az as AI_ACTIONS_COLLECTION, aA as AI_AUDIT_COLLECTION, aB as AI_CHUNKS_COLLECTION, aC as AI_MESSAGES_COLLECTION, aD as AI_THREADS_COLLECTION, aE as AccessConfig, aF as AccessFunction, aG as AccessFunctionArgs, aH as AccessResult, aI as AccessRule, aJ as ActionConfig, aK as ActionConfigBase, aL as ActionConfigWithHandler, aM as ActionConfigWithMutation, aN as ActionContext, aO as ActionType, aP as AdminAuthAccessResolution, aQ as AdminAuthClaimMapping, aR as AdminAuthMember, aS as AdminAuthProvider, aT as AdminAuthProviderMembersConfig, aU as AdminAuthProvisioningMode, aV as AdminAuthResolveAccessArgs, aW as AdminAuthResolvedIdentity, aX as AdminConfig, aY as AdminDashboardComponentSlots, aZ as AdminIconName, a_ as AggregateArgs, a$ as AggregateCastType, b0 as AggregateCollectionResult, b1 as AggregateInput, b2 as AggregateOperation, b3 as AggregateResult, b4 as BaseAdminAuthProvider, b5 as BaseFieldAdmin, b6 as BlockVariant, b7 as BlocksField, b8 as BooleanFieldAdmin, b9 as BooleanFormat, ba as CURRENT_NAV_PREFERENCES_VERSION, bb as CalendarViewConfig, bc as CardsViewConfig, bd as CharacterLimitFieldAdmin, be as CharacterLimitFieldConfig, bf as CollectionAfterChangeHook, bg as CollectionAfterDeleteHook, bh as CollectionAfterReadHook, bi as CollectionAfterReadHookEntry, bj as CollectionAfterTransitionHook, bk as CollectionBeforeChangeHook, bl as CollectionBeforeChangeHookEntry, bm as CollectionBeforeCommitHook, bn as CollectionBeforeDeleteHook, bo as CollectionBeforeReadHook, bp as CollectionBeforeReadHookEntry, bq as CollectionBeforeTransitionHook, br as CollectionIndex, bs as CollectionListComponentSlots, bt as CollectionRAGConfig, bu as CollectionSchemaResult, bv as CollectionSummaryResult, bw as CollectionViewComponentSlots, bx as CompiledNavGroup, by as CountOperation, bz as CustomAdminAuthProvider, bA as DEFAULT_USER_NAV_PREFERENCES, bB as DateFieldAdmin, bC as DateFormat, bD as DefaultValueContext, bE as DefineActionOptions, bF as DefineCalendarViewOptions, bG as DefineCardsViewOptions, bH as DefineGanttViewOptions, bI as DefineKanbanViewOptions, bJ as DefineTableViewOptions, bK as DefineViewBaseOptions, bL as DefineViewOptions, bM as DetailSpan, bN as DisplayTone, bO as DisplayVariant, bP as DistinctCountOperation, bQ as DistinctValuesOperation, bR as DynamicOptionItem, bS as DynamicOptionsConfig, bT as DynamicOptionsResolver, bU as DynamicOptionsResolverArgs, bV as DyrectedAIContext, bW as DyrectedLoggerConfig, bX as DyrectedObservabilityConfig, bY as EmailFieldAdmin, bZ as FieldAdminHooks, b_ as FieldAdminOnChangeHook, b$ as FieldAdminOnChangeHookArgs, c0 as FieldAdminOptionsHook, c1 as FieldAdminOptionsHookArgs, c2 as FieldAdminOptionsHookResult, c3 as FieldAfterReadHook, c4 as FieldAfterReadHookArgs, c5 as FieldBase, c6 as FieldBeforeChangeHook, c7 as FieldBeforeChangeHookArgs, c8 as FieldHook, c9 as FieldHooks, ca as FileData, cb as GanttViewConfig, cc as GetDocumentResult, cd as GlobalAfterChangeHook, ce as GlobalAfterReadHook, cf as GlobalAfterReadHookEntry, cg as GlobalBeforeChangeHook, ch as GlobalBeforeChangeHookEntry, ci as GlobalBeforeReadHook, cj as GlobalBeforeReadHookEntry, ck as GlobalRAGConfig, cl as GlobalSchemaResult, cm as GlobalSummaryResult, cn as HeadingLevel, co as HookFunction, cp as IconFieldAdmin, cq as ImageService, cr as ImageTransformOptions, cs as InferAggregateResult, ct as JoinFieldAdmin, cu as JsonFieldAdmin, cv as JsonFormat, cw as KanbanViewConfig, cx as LIFECYCLE_EVENT_NAMES, cy as LifecycleEventHandler, cz as LinkFormat, cA as MetricColor, cB as MoneyFieldAdmin, cC as MoneyFieldConfig, cD as MultiSelectFieldAdmin, cE as NamedAccessPolicy, cF as NavBadgeConfig, cG as NavGroup, cH as NumberFieldAdmin, cI as NumberFormat, cJ as NumberLimitFieldAdmin, cK as NumberLimitFieldConfig, cL as NumericOperation, cM as NumericUpdateOperator, cN as OIDCAdminAuthProvider, cO as OptionFormat, cP as PaginatedResult, cQ as PinnedNavItemRef, cR as PublicAdminAuthProvider, cS as QueryCollectionResult, cT as RAGSearchResult, cU as RadioFieldAdmin, cV as RateLimitConfig, cW as ReadonlyDatabaseAdapter, cX as RichTextFeature, cY as RichTextFieldConfig, cZ as SelectFieldAdmin, c_ as SqlWhereResult, c$ as StorageAdapter, d0 as TableViewConfig, d1 as TaskContext, d2 as TaskLogger, d3 as TaskRunStatus, d4 as TextFieldAdmin, d5 as TextFormat, d6 as TextareaFieldAdmin, d7 as TrustProxyConfig, d8 as TypedField, d9 as UploadConfig, da as UrlFieldAdmin, db as UrlLinkValue, dc as ViewActionFeatures, dd as ViewComponentSlots, de as ViewConfig, df as ViewConfigBase, dg as ViewLayout, dh as ViewMetric, di as ViewSubMetric, dj as WhereClause, dk as WhereOperator, dl as WhereOperatorName, dm as WordLimitFieldAdmin, dn as WordLimitFieldConfig, dp as WorkflowMetadata, dq as WorkflowOnTransitionContext, dr as WorkflowOnTransitionHook, ds as WorkflowRole, dt as WorkflowState, du as WorkflowTransitionContext, dv as coerceBooleanWhere, dw as defineAction, dx as defineCalendarView, dy as defineCardsView, dz as defineGanttView, dA as defineKanbanView, dB as defineTableView, dC as defineView, dD as defineWorkspace, dE as isAICollection, dF as parseMongoWhere, dG as parseSqlWhere } from './app-Dd9cBbCs.cjs';
|
|
3
3
|
import jexl from 'jexl';
|
|
4
4
|
import { Context } from 'hono';
|
|
5
5
|
export { z } from 'zod';
|
|
@@ -13,7 +13,7 @@ import '@opentelemetry/exporter-prometheus';
|
|
|
13
13
|
type Prettify<T> = {
|
|
14
14
|
[K in keyof T]: T[K];
|
|
15
15
|
};
|
|
16
|
-
type FieldValueType<F extends Field> = F["type"] extends "text" | "textarea" | "email" | "url" | "icon" | "date" | "datetime" | "time" | "select" | "radio" ? string : F["type"] extends "number" ? number : F["type"] extends "boolean" ? boolean : F["type"] extends "multiSelect" ? string[] : F["type"] extends "relationship" ? F extends {
|
|
16
|
+
type FieldValueType<F extends Field> = F["type"] extends "text" | "textarea" | "email" | "url" | "icon" | "date" | "datetime" | "time" | "select" | "radio" ? string : F["type"] extends "number" | "money" ? number : F["type"] extends "boolean" ? boolean : F["type"] extends "multiSelect" ? string[] : F["type"] extends "relationship" ? F extends {
|
|
17
17
|
hasMany: true;
|
|
18
18
|
} ? string[] : string : F["type"] extends "image" ? F extends {
|
|
19
19
|
hasMany: true;
|
|
@@ -639,6 +639,8 @@ declare function saveWorkflowDraft(args: {
|
|
|
639
639
|
originalDoc: BaseDocument;
|
|
640
640
|
data: Record<string, unknown>;
|
|
641
641
|
user?: AuthenticatedUser;
|
|
642
|
+
/** Runs inside the write transaction, after the draft is saved. */
|
|
643
|
+
beforeCommit?: (tx: DatabaseAdapter, doc: BaseDocument) => Promise<void>;
|
|
642
644
|
}): Promise<{
|
|
643
645
|
doc: BaseDocument;
|
|
644
646
|
event: LifecycleEvent;
|
|
@@ -648,6 +650,8 @@ declare function createWorkflowDocument(args: {
|
|
|
648
650
|
collection: CollectionConfig;
|
|
649
651
|
data: Record<string, unknown>;
|
|
650
652
|
user?: AuthenticatedUser;
|
|
653
|
+
/** Runs inside the write transaction, after the document is created. */
|
|
654
|
+
beforeCommit?: (tx: DatabaseAdapter, doc: BaseDocument) => Promise<void>;
|
|
651
655
|
}): Promise<{
|
|
652
656
|
doc: BaseDocument;
|
|
653
657
|
event: LifecycleEvent;
|
|
@@ -659,10 +663,74 @@ declare function transitionWorkflow(args: {
|
|
|
659
663
|
transitionName: string;
|
|
660
664
|
expectedRevision?: number;
|
|
661
665
|
comment?: string;
|
|
666
|
+
input?: Record<string, unknown>;
|
|
662
667
|
user?: AuthenticatedUser;
|
|
663
668
|
req: HookRequestContext;
|
|
664
669
|
}): Promise<BaseDocument>;
|
|
665
670
|
|
|
671
|
+
declare const TASK_LOCKS_COLLECTION = "__task_locks";
|
|
672
|
+
/** Internal collection holding one lock row per task. Created on demand by the runner. */
|
|
673
|
+
declare const TASK_LOCKS_COLLECTION_CONFIG: CollectionConfig;
|
|
674
|
+
interface CronSchedule {
|
|
675
|
+
minutes: Set<number>;
|
|
676
|
+
hours: Set<number>;
|
|
677
|
+
daysOfMonth: Set<number>;
|
|
678
|
+
months: Set<number>;
|
|
679
|
+
daysOfWeek: Set<number>;
|
|
680
|
+
/** Standard cron semantics: when both day fields are restricted, either may match. */
|
|
681
|
+
dayFieldsBothRestricted: boolean;
|
|
682
|
+
}
|
|
683
|
+
/** Parses a five-field cron expression. Throws a descriptive error when it is invalid. */
|
|
684
|
+
declare function parseCron(expression: string): CronSchedule;
|
|
685
|
+
/** The first cron slot strictly after `after`, in UTC. */
|
|
686
|
+
declare function nextCronRun(expression: string | CronSchedule, after: Date): Date;
|
|
687
|
+
/**
|
|
688
|
+
* Defines a background task. Validates the name, cron expression and lock
|
|
689
|
+
* timeout immediately, so a typo fails at startup rather than at 3am.
|
|
690
|
+
*
|
|
691
|
+
* @example
|
|
692
|
+
* ```ts
|
|
693
|
+
* export const ledgerDrift = defineTask({
|
|
694
|
+
* name: "wallet:ledger-drift",
|
|
695
|
+
* cron: "*\/15 * * * *",
|
|
696
|
+
* lockTimeout: 300,
|
|
697
|
+
* async run({ db, logger }) {
|
|
698
|
+
* const drifts = await checkLedgerDrift(db);
|
|
699
|
+
* if (drifts.length) logger.error({ drifts }, "Ledger drift detected");
|
|
700
|
+
* },
|
|
701
|
+
* });
|
|
702
|
+
* ```
|
|
703
|
+
*/
|
|
704
|
+
declare function defineTask<const T extends TaskConfig>(task: T): T;
|
|
705
|
+
interface TaskRunner {
|
|
706
|
+
/**
|
|
707
|
+
* Runs one task now, ignoring its schedule. Returns `skipped` with reason
|
|
708
|
+
* `"locked"` when another instance is already running it.
|
|
709
|
+
*/
|
|
710
|
+
runTask(name: string): Promise<TaskRunResult>;
|
|
711
|
+
/**
|
|
712
|
+
* Runs every scheduled task that is due. Safe to call from any number of
|
|
713
|
+
* instances or from a platform cron: each due slot runs exactly once.
|
|
714
|
+
*/
|
|
715
|
+
runDue(now?: Date): Promise<TaskRunResult[]>;
|
|
716
|
+
/** Starts polling for due tasks. Returns immediately and never blocks startup. */
|
|
717
|
+
start(options?: {
|
|
718
|
+
intervalMs?: number;
|
|
719
|
+
}): void;
|
|
720
|
+
/** Stops polling and waits for any run in progress to settle. */
|
|
721
|
+
stop(): Promise<void>;
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Creates the runner for the tasks in `config.tasks`. Coordination between
|
|
725
|
+
* instances uses a lock row per task in the database, taken with a single
|
|
726
|
+
* conditional update, so it works across processes and on every adapter.
|
|
727
|
+
*
|
|
728
|
+
* Core does not start it for you: a timer is unreliable on serverless, so the
|
|
729
|
+
* host chooses. Call `start()` on a long-lived Node server, or call `runDue()`
|
|
730
|
+
* from a platform cron.
|
|
731
|
+
*/
|
|
732
|
+
declare function createTaskRunner(config: DyrectedConfig): TaskRunner;
|
|
733
|
+
|
|
666
734
|
/**
|
|
667
735
|
* Normalizes a DetailItem (which may be a shorthand string) into a standard DetailItem object.
|
|
668
736
|
*
|
|
@@ -1393,6 +1461,85 @@ declare function generateDocumentId(collectionOrSlug?: string | {
|
|
|
1393
1461
|
idGenerator?: (slug: string) => string;
|
|
1394
1462
|
}): string;
|
|
1395
1463
|
|
|
1464
|
+
/**
|
|
1465
|
+
* Builds the physical name of an index, for example `uniq_collection_wallets_currency`.
|
|
1466
|
+
*
|
|
1467
|
+
* MySQL rejects names over 64 characters and Postgres silently truncates at 63, which can
|
|
1468
|
+
* collide or, on MySQL, leave a unique constraint uncreated. Names that would be too long are
|
|
1469
|
+
* shortened to `<prefix>_<hash>_<last field>`, where the hash is derived from the full name so
|
|
1470
|
+
* the result stays stable and unique per table and field set.
|
|
1471
|
+
*/
|
|
1472
|
+
declare function resolveIndexName(prefix: "uniq" | "idx", table: string, fields: string[]): string;
|
|
1473
|
+
|
|
1474
|
+
/** Key used for the group whose value is null or missing. */
|
|
1475
|
+
declare const UNASSIGNED_GROUP_KEY = "__unassigned__";
|
|
1476
|
+
/**
|
|
1477
|
+
* Turns the raw value of a `groupBy` column into the string key used in aggregate results.
|
|
1478
|
+
*
|
|
1479
|
+
* Databases hand the same logical value back in different shapes: a boolean is `true`, `1` or
|
|
1480
|
+
* `'1'`; a decimal column returns `'1.0000'`; a timestamp is a `Date` or a space-separated string.
|
|
1481
|
+
* Normalizing by the field's declared type keeps the keys identical on every adapter, so callers
|
|
1482
|
+
* can look up `groups["true"]`, `groups["1"]` or an ISO date whichever database they run on.
|
|
1483
|
+
*/
|
|
1484
|
+
declare function normalizeGroupKey(raw: unknown, fieldType?: string): string;
|
|
1485
|
+
|
|
1486
|
+
interface ReconciledNavTree extends CompiledNavTree {
|
|
1487
|
+
pinnedItems: CompiledNavItem[];
|
|
1488
|
+
}
|
|
1489
|
+
/**
|
|
1490
|
+
* Reconciles developer-defined navigation tree from code (`baseTree`)
|
|
1491
|
+
* with operator personal/role preferences (`prefs`), ensuring:
|
|
1492
|
+
* 1. Sparse delta merging (newly deployed code resources are never dropped).
|
|
1493
|
+
* 2. User-created custom groups and operational workspaces are injected.
|
|
1494
|
+
* 3. User visibility overrides (`hidden`) are respected.
|
|
1495
|
+
* 4. User ordering overrides (`groupOrder`, `itemOrder`) are applied.
|
|
1496
|
+
* 5. Pinned favorite shortcuts are extracted.
|
|
1497
|
+
* 6. Tombstone shielding: deleted collections/views don't crash the sidebar.
|
|
1498
|
+
*/
|
|
1499
|
+
interface ReconcileNavigationOptions {
|
|
1500
|
+
/**
|
|
1501
|
+
* If true, hidden groups, items, and views are retained in the returned tree
|
|
1502
|
+
* (useful for customizers/editors that need to display and unhide them).
|
|
1503
|
+
* If false (default), hidden groups, items, and views are omitted.
|
|
1504
|
+
*/
|
|
1505
|
+
includeHidden?: boolean;
|
|
1506
|
+
}
|
|
1507
|
+
declare function reconcileNavigation(baseTree: CompiledNavTree | null | undefined, prefs: UserNavigationPreferences | null | undefined, schemas?: {
|
|
1508
|
+
collections?: Array<any>;
|
|
1509
|
+
globals?: Array<any>;
|
|
1510
|
+
}, options?: ReconcileNavigationOptions): ReconciledNavTree;
|
|
1511
|
+
|
|
1512
|
+
/**
|
|
1513
|
+
* System route prefixes reserved by Dyrected.
|
|
1514
|
+
* Cannot be used as operational workspace slugs.
|
|
1515
|
+
*/
|
|
1516
|
+
declare const RESERVED_NAVIGATION_SLUGS: Set<string>;
|
|
1517
|
+
/**
|
|
1518
|
+
* Validates that no navigation item uses a reserved system route slug.
|
|
1519
|
+
*/
|
|
1520
|
+
declare function assertValidNavigationSlugs(navigation: DefineWorkspaceOptions[]): void;
|
|
1521
|
+
/**
|
|
1522
|
+
* Compile the complete admin navigation tree from DyrectedConfig.
|
|
1523
|
+
*
|
|
1524
|
+
* Implements a deterministic 5-step compilation pipeline:
|
|
1525
|
+
* 1. Discover all collections, globals, and media resources.
|
|
1526
|
+
* 2. Apply explicit navigation overrides from `config.admin.navigation`.
|
|
1527
|
+
* 3. Evaluate `before` and `after` anchors via relative splicing.
|
|
1528
|
+
* 4. Sort groups and items by `order` and `position: 'first' | 'last'`.
|
|
1529
|
+
* 5. Auto-merge unmentioned resources into fallback sections.
|
|
1530
|
+
*/
|
|
1531
|
+
declare function compileNavigation(config: DyrectedConfig<any> | {
|
|
1532
|
+
collections?: readonly any[];
|
|
1533
|
+
globals?: readonly any[];
|
|
1534
|
+
admin?: {
|
|
1535
|
+
navigation?: DefineWorkspaceOptions[];
|
|
1536
|
+
};
|
|
1537
|
+
}): CompiledNavTree;
|
|
1538
|
+
/**
|
|
1539
|
+
* Filter compiled navigation based on user access rules.
|
|
1540
|
+
*/
|
|
1541
|
+
declare function pruneNavigationForUser(tree: CompiledNavTree, user?: any): CompiledNavTree;
|
|
1542
|
+
|
|
1396
1543
|
type TopLevelFieldName<TFields extends readonly Field[]> = Extract<TFields[number], {
|
|
1397
1544
|
name: string;
|
|
1398
1545
|
}>["name"];
|
|
@@ -1713,6 +1860,10 @@ declare const defineRichTextField: <const T extends Omit<RichTextField, "type">>
|
|
|
1713
1860
|
declare const defineNumberField: <const T extends Omit<NumberField, "type">>(field: T) => T & {
|
|
1714
1861
|
type: "number";
|
|
1715
1862
|
};
|
|
1863
|
+
/** Define a `money` field stored as integer minor units. */
|
|
1864
|
+
declare const defineMoneyField: <const T extends Omit<MoneyField, "type">>(field: T) => T & {
|
|
1865
|
+
type: "money";
|
|
1866
|
+
};
|
|
1716
1867
|
/** Define a `boolean` field. */
|
|
1717
1868
|
declare const defineBooleanField: <const T extends Omit<BooleanField, "type">>(field: T) => T & {
|
|
1718
1869
|
type: "boolean";
|
|
@@ -1889,4 +2040,4 @@ declare function defineTab<const T extends readonly Field[]>(args: {
|
|
|
1889
2040
|
fields: T;
|
|
1890
2041
|
}): T;
|
|
1891
2042
|
|
|
1892
|
-
export { AIConfig, type AIErrorCode, AIPIIConfig, type AccessConditions, AccessPolicyResolver, AdminAuthConfig, ArrayField, AuthConfig, type AuthDocFields, AuthenticatedUser, BASE62_ALPHABET, BUILTIN_JEXL_HELPERS, BaseDocument, Block, BooleanField, CROCKFORD_BASE32, CollectionConfig, ComputedHandler, type ConfigDiagnostic, ConfigValidationError, ConflictError, DateField, DateTimeField, type DeclarativeAccessSurface, type DeclarativeAccessValidationIssue, type DeclarativeAdminSurface, type DeclarativeAdminValidationIssue, DeclarativeHookExpression, type DeclarativeHookSurface, type DeclarativeHookValidationIssue, type DeclarativePreviewSurface, type DeclarativePreviewValidationIssue, DetailAction, DetailActionOptions, DetailComputed, DetailComputedOptions, DetailCustom, DetailCustomOptions, DetailDivider, DetailDividerOptions, DetailField, DetailGrid, DetailGridOptions, DetailItem, DetailRepeat, DetailRepeatOptions, DetailSchema, DetailSection, DetailSectionOptions, DetailTab, DetailTabOptions, DetailTabs, DetailTabsOptions, DetailText, DetailTextOptions, DisplayFieldOptions, DuplicateKeyError, DyrectedAIError, DyrectedConfig, DyrectedError, EmailField, type ExprFunction, type ExtractCollectionSlugs, Field, FieldConditionBuilder, FieldType, ForbiddenError, type GenerateIdOptions, GlobalConfig, HookRequestContext, IconField, IdStrategy, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MatchBuilder, MultiSelectField, NANOID_ALPHABET, NON_NEGOTIABLE_CREDENTIAL_FIELDS, NotFoundError, NumberField, ObjectField, PII_REGEX_PATTERNS, type Prettify, PublicAdminAuthConfig, type PublishingWorkflowOptions, RadioField, RelationshipField, RichTextField, RowField, type SanitizeDocForAIOptions, SelectField, type SortClause, type SortDirection, type SqlSortDialect, type SystemDocFields, TextField, TextareaField, TimeField, type UploadDocFields, UrlField, ValidationError, WORKFLOW_HISTORY_COLLECTION, type WhenFunction, WorkflowConfig, WorkflowTransition, abs, addDays, asCollection, assertValidAdminConditionsInConfig, assertValidDeclarativeAccessInConfig, assertValidDeclarativeHookExpression, assertValidDeclarativeHookResult, assertValidDeclarativeHooksInConfig, assertValidPreviewUrlsInConfig, availableWorkflowTransitions, buildSqlOrderBy, canViewWorkflowDraft, capitalize, ceil, clamp, coalesce, collectAdminConditionValidationIssues, collectConfigDiagnostics, collectDeclarativeAccessValidationIssues, collectDeclarativeHookValidationIssues, collectPreviewUrlValidationIssues, compact, count, createLifecycleEvent, createWorkflowDocument, defaultValue, defineArrayField, defineBlock, defineBlocksField, defineBooleanField, defineCollection, defineConfig, defineDateField, defineDateTimeField, defineEmailField, defineField, defineGlobal, defineIconField, defineImageField, defineJoinField, defineJsonField, defineMultiSelectField, defineNumberField, defineObjectField, definePublishingWorkflow, defineRadioField, defineRelationshipField, defineRichTextField, defineRowField, defineSelectField, defineTab, defineTextField, defineTextareaField, defineTimeField, defineUrlField, diffDays, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, displayAction, displayComputed, displayCustom, displayCustomComponent, displayDivider, displayField, displayGrid, displayRepeat, displaySection, displayTab, displayTabs, displayText, endsWith, evaluateDetailComputed, evaluateJexl, evaluateJexlSync, executeFieldAfterRead, executeFieldBeforeChange, expr, first, floor, formatConfigDiagnostics, formatDate, formatJexlValue, generateDefaultDetailSchema, generateDocumentId, generateId, generateOpenApi, get, getAdminAuthCollection, getAdminRoleForCollection, getAllowedSitesForUser, getPublicAdminAuthConfig, includes, initializeWorkflowDocument, isConfigValidationError, isDetailItemVisible, isEmpty, isFuture, isPast, isSiteAuthorized, isUserAdmin, join, last, length, lower, maskEmail, maskPhone, maskTextPII, materializeWorkflowDocument, max, min, nanoid, normalizeConfig, normalizeDetailItem, now, numericFieldNames, parseSort, pow, prefixedId, publishedStateName, publishingWorkflow, readingTime, registerJexlHelpers, replace, resolveAdminAuthCollection, resolveAuthorizedSiteId, resolvePrefix, round, runCollectionHooks, sanitizeDocForAI, saveWorkflowDraft, simplePublishingWorkflow, slugify, sqrt, startsWith, sum, today, transitionWorkflow, trim, truncate, ulid, unique, upper, uuid, validateAdminConditionExpression, validateDeclarativeAccessExpression, validateDeclarativeHookExpression, validatePreviewUrlExpression, when, wordCount, workflowCapabilities };
|
|
2043
|
+
export { AIConfig, type AIErrorCode, AIPIIConfig, type AccessConditions, AccessPolicyResolver, AdminAuthConfig, ArrayField, AuthConfig, type AuthDocFields, AuthenticatedUser, BASE62_ALPHABET, BUILTIN_JEXL_HELPERS, BaseDocument, Block, BooleanField, CROCKFORD_BASE32, CollectionConfig, CompiledNavItem, CompiledNavTree, ComputedHandler, type ConfigDiagnostic, ConfigValidationError, ConflictError, DatabaseAdapter, DateField, DateTimeField, type DeclarativeAccessSurface, type DeclarativeAccessValidationIssue, type DeclarativeAdminSurface, type DeclarativeAdminValidationIssue, DeclarativeHookExpression, type DeclarativeHookSurface, type DeclarativeHookValidationIssue, type DeclarativePreviewSurface, type DeclarativePreviewValidationIssue, DefineWorkspaceOptions, DetailAction, DetailActionOptions, DetailComputed, DetailComputedOptions, DetailCustom, DetailCustomOptions, DetailDivider, DetailDividerOptions, DetailField, DetailGrid, DetailGridOptions, DetailItem, DetailRepeat, DetailRepeatOptions, DetailSchema, DetailSection, DetailSectionOptions, DetailTab, DetailTabOptions, DetailTabs, DetailTabsOptions, DetailText, DetailTextOptions, DisplayFieldOptions, DuplicateKeyError, DyrectedAIError, DyrectedConfig, DyrectedError, EmailField, type ExprFunction, type ExtractCollectionSlugs, Field, FieldConditionBuilder, FieldType, ForbiddenError, type GenerateIdOptions, GlobalConfig, HookRequestContext, IconField, IdStrategy, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MatchBuilder, MoneyField, MultiSelectField, NANOID_ALPHABET, NON_NEGOTIABLE_CREDENTIAL_FIELDS, NotFoundError, NumberField, ObjectField, PII_REGEX_PATTERNS, type Prettify, PublicAdminAuthConfig, type PublishingWorkflowOptions, RESERVED_NAVIGATION_SLUGS, RadioField, type ReconcileNavigationOptions, type ReconciledNavTree, RelationshipField, RichTextField, RowField, type SanitizeDocForAIOptions, SelectField, type SortClause, type SortDirection, type SqlSortDialect, type SystemDocFields, TASK_LOCKS_COLLECTION, TASK_LOCKS_COLLECTION_CONFIG, TaskConfig, TaskRunResult, type TaskRunner, TextField, TextareaField, TimeField, UNASSIGNED_GROUP_KEY, type UploadDocFields, UrlField, UserNavigationPreferences, ValidationError, WORKFLOW_HISTORY_COLLECTION, type WhenFunction, WorkflowConfig, WorkflowTransition, abs, addDays, asCollection, assertValidAdminConditionsInConfig, assertValidDeclarativeAccessInConfig, assertValidDeclarativeHookExpression, assertValidDeclarativeHookResult, assertValidDeclarativeHooksInConfig, assertValidNavigationSlugs, assertValidPreviewUrlsInConfig, availableWorkflowTransitions, buildSqlOrderBy, canViewWorkflowDraft, capitalize, ceil, clamp, coalesce, collectAdminConditionValidationIssues, collectConfigDiagnostics, collectDeclarativeAccessValidationIssues, collectDeclarativeHookValidationIssues, collectPreviewUrlValidationIssues, compact, compileNavigation, count, createLifecycleEvent, createTaskRunner, createWorkflowDocument, defaultValue, defineArrayField, defineBlock, defineBlocksField, defineBooleanField, defineCollection, defineConfig, defineDateField, defineDateTimeField, defineEmailField, defineField, defineGlobal, defineIconField, defineImageField, defineJoinField, defineJsonField, defineMoneyField, defineMultiSelectField, defineNumberField, defineObjectField, definePublishingWorkflow, defineRadioField, defineRelationshipField, defineRichTextField, defineRowField, defineSelectField, defineTab, defineTask, defineTextField, defineTextareaField, defineTimeField, defineUrlField, diffDays, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, displayAction, displayComputed, displayCustom, displayCustomComponent, displayDivider, displayField, displayGrid, displayRepeat, displaySection, displayTab, displayTabs, displayText, endsWith, evaluateDetailComputed, evaluateJexl, evaluateJexlSync, executeFieldAfterRead, executeFieldBeforeChange, expr, first, floor, formatConfigDiagnostics, formatDate, formatJexlValue, generateDefaultDetailSchema, generateDocumentId, generateId, generateOpenApi, get, getAdminAuthCollection, getAdminRoleForCollection, getAllowedSitesForUser, getPublicAdminAuthConfig, includes, initializeWorkflowDocument, isConfigValidationError, isDetailItemVisible, isEmpty, isFuture, isPast, isSiteAuthorized, isUserAdmin, join, last, length, lower, maskEmail, maskPhone, maskTextPII, materializeWorkflowDocument, max, min, nanoid, nextCronRun, normalizeConfig, normalizeDetailItem, normalizeGroupKey, now, numericFieldNames, parseCron, parseSort, pow, prefixedId, pruneNavigationForUser, publishedStateName, publishingWorkflow, readingTime, reconcileNavigation, registerJexlHelpers, replace, resolveAdminAuthCollection, resolveAuthorizedSiteId, resolveIndexName, resolvePrefix, round, runCollectionHooks, sanitizeDocForAI, saveWorkflowDraft, simplePublishingWorkflow, slugify, sqrt, startsWith, sum, today, transitionWorkflow, trim, truncate, ulid, unique, upper, uuid, validateAdminConditionExpression, validateDeclarativeAccessExpression, validateDeclarativeHookExpression, validatePreviewUrlExpression, when, wordCount, workflowCapabilities };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as Field, B as Block, C as CollectionConfig, D as DyrectedConfig, A as AdminAuthConfig, P as PublicAdminAuthConfig, G as GlobalConfig, a as DeclarativeHookExpression, W as WorkflowConfig, b as AuthenticatedUser, c as WorkflowTransition, L as LifecycleEventName, d as LifecycleEvent, e as BaseDocument, H as HookRequestContext,
|
|
2
|
-
export {
|
|
1
|
+
import { F as Field, B as Block, C as CollectionConfig, D as DyrectedConfig, A as AdminAuthConfig, P as PublicAdminAuthConfig, G as GlobalConfig, a as DeclarativeHookExpression, W as WorkflowConfig, b as AuthenticatedUser, c as WorkflowTransition, L as LifecycleEventName, d as LifecycleEvent, e as DatabaseAdapter, f as BaseDocument, H as HookRequestContext, T as TaskRunResult, g as TaskConfig, h as DetailActionOptions, i as DetailAction, j as DetailComputedOptions, k as ComputedHandler, l as DetailComputed, m as DetailCustomOptions, n as DetailCustom, o as DetailDividerOptions, p as DetailDivider, q as DisplayFieldOptions, r as DetailField, s as DetailItem, t as DetailGridOptions, u as DetailGrid, v as DetailRepeatOptions, w as DetailRepeat, x as DetailSectionOptions, y as DetailSection, z as DetailTabOptions, E as DetailTab, I as DetailTabsOptions, J as DetailTabs, K as DetailTextOptions, M as DetailText, N as DetailSchema, O as DyrectedContext, Q as AIConfig, R as AIPIIConfig, S as IdStrategy, U as CompiledNavTree, V as CompiledNavItem, X as UserNavigationPreferences, Y as DefineWorkspaceOptions, Z as ArrayField, _ as FieldType, $ as BooleanField, a0 as AuthConfig, a1 as AccessPolicyResolver, a2 as DateField, a3 as DateTimeField, a4 as EmailField, a5 as IconField, a6 as ImageField, a7 as JoinField, a8 as JsonField, a9 as MoneyField, aa as MultiSelectField, ab as NumberField, ac as ObjectField, ad as RadioField, ae as RelationshipField, af as RichTextField, ag as RowField, ah as SelectField, ai as TextField, aj as TextareaField, ak as TimeField, al as UrlField } from './app-Dd9cBbCs.js';
|
|
2
|
+
export { am as AIAction, an as AIActionStatus, ao as AIActionType, ap as AIAuditActionType, aq as AIAuditRecord, ar as AIChunk, as as AIMessage, at as AIPIIPattern, au as AIRateLimitResult, av as AIRateLimitStore, aw as AIThread, ax as AIToolContext, ay as AIToolDefinition, az as AI_ACTIONS_COLLECTION, aA as AI_AUDIT_COLLECTION, aB as AI_CHUNKS_COLLECTION, aC as AI_MESSAGES_COLLECTION, aD as AI_THREADS_COLLECTION, aE as AccessConfig, aF as AccessFunction, aG as AccessFunctionArgs, aH as AccessResult, aI as AccessRule, aJ as ActionConfig, aK as ActionConfigBase, aL as ActionConfigWithHandler, aM as ActionConfigWithMutation, aN as ActionContext, aO as ActionType, aP as AdminAuthAccessResolution, aQ as AdminAuthClaimMapping, aR as AdminAuthMember, aS as AdminAuthProvider, aT as AdminAuthProviderMembersConfig, aU as AdminAuthProvisioningMode, aV as AdminAuthResolveAccessArgs, aW as AdminAuthResolvedIdentity, aX as AdminConfig, aY as AdminDashboardComponentSlots, aZ as AdminIconName, a_ as AggregateArgs, a$ as AggregateCastType, b0 as AggregateCollectionResult, b1 as AggregateInput, b2 as AggregateOperation, b3 as AggregateResult, b4 as BaseAdminAuthProvider, b5 as BaseFieldAdmin, b6 as BlockVariant, b7 as BlocksField, b8 as BooleanFieldAdmin, b9 as BooleanFormat, ba as CURRENT_NAV_PREFERENCES_VERSION, bb as CalendarViewConfig, bc as CardsViewConfig, bd as CharacterLimitFieldAdmin, be as CharacterLimitFieldConfig, bf as CollectionAfterChangeHook, bg as CollectionAfterDeleteHook, bh as CollectionAfterReadHook, bi as CollectionAfterReadHookEntry, bj as CollectionAfterTransitionHook, bk as CollectionBeforeChangeHook, bl as CollectionBeforeChangeHookEntry, bm as CollectionBeforeCommitHook, bn as CollectionBeforeDeleteHook, bo as CollectionBeforeReadHook, bp as CollectionBeforeReadHookEntry, bq as CollectionBeforeTransitionHook, br as CollectionIndex, bs as CollectionListComponentSlots, bt as CollectionRAGConfig, bu as CollectionSchemaResult, bv as CollectionSummaryResult, bw as CollectionViewComponentSlots, bx as CompiledNavGroup, by as CountOperation, bz as CustomAdminAuthProvider, bA as DEFAULT_USER_NAV_PREFERENCES, bB as DateFieldAdmin, bC as DateFormat, bD as DefaultValueContext, bE as DefineActionOptions, bF as DefineCalendarViewOptions, bG as DefineCardsViewOptions, bH as DefineGanttViewOptions, bI as DefineKanbanViewOptions, bJ as DefineTableViewOptions, bK as DefineViewBaseOptions, bL as DefineViewOptions, bM as DetailSpan, bN as DisplayTone, bO as DisplayVariant, bP as DistinctCountOperation, bQ as DistinctValuesOperation, bR as DynamicOptionItem, bS as DynamicOptionsConfig, bT as DynamicOptionsResolver, bU as DynamicOptionsResolverArgs, bV as DyrectedAIContext, bW as DyrectedLoggerConfig, bX as DyrectedObservabilityConfig, bY as EmailFieldAdmin, bZ as FieldAdminHooks, b_ as FieldAdminOnChangeHook, b$ as FieldAdminOnChangeHookArgs, c0 as FieldAdminOptionsHook, c1 as FieldAdminOptionsHookArgs, c2 as FieldAdminOptionsHookResult, c3 as FieldAfterReadHook, c4 as FieldAfterReadHookArgs, c5 as FieldBase, c6 as FieldBeforeChangeHook, c7 as FieldBeforeChangeHookArgs, c8 as FieldHook, c9 as FieldHooks, ca as FileData, cb as GanttViewConfig, cc as GetDocumentResult, cd as GlobalAfterChangeHook, ce as GlobalAfterReadHook, cf as GlobalAfterReadHookEntry, cg as GlobalBeforeChangeHook, ch as GlobalBeforeChangeHookEntry, ci as GlobalBeforeReadHook, cj as GlobalBeforeReadHookEntry, ck as GlobalRAGConfig, cl as GlobalSchemaResult, cm as GlobalSummaryResult, cn as HeadingLevel, co as HookFunction, cp as IconFieldAdmin, cq as ImageService, cr as ImageTransformOptions, cs as InferAggregateResult, ct as JoinFieldAdmin, cu as JsonFieldAdmin, cv as JsonFormat, cw as KanbanViewConfig, cx as LIFECYCLE_EVENT_NAMES, cy as LifecycleEventHandler, cz as LinkFormat, cA as MetricColor, cB as MoneyFieldAdmin, cC as MoneyFieldConfig, cD as MultiSelectFieldAdmin, cE as NamedAccessPolicy, cF as NavBadgeConfig, cG as NavGroup, cH as NumberFieldAdmin, cI as NumberFormat, cJ as NumberLimitFieldAdmin, cK as NumberLimitFieldConfig, cL as NumericOperation, cM as NumericUpdateOperator, cN as OIDCAdminAuthProvider, cO as OptionFormat, cP as PaginatedResult, cQ as PinnedNavItemRef, cR as PublicAdminAuthProvider, cS as QueryCollectionResult, cT as RAGSearchResult, cU as RadioFieldAdmin, cV as RateLimitConfig, cW as ReadonlyDatabaseAdapter, cX as RichTextFeature, cY as RichTextFieldConfig, cZ as SelectFieldAdmin, c_ as SqlWhereResult, c$ as StorageAdapter, d0 as TableViewConfig, d1 as TaskContext, d2 as TaskLogger, d3 as TaskRunStatus, d4 as TextFieldAdmin, d5 as TextFormat, d6 as TextareaFieldAdmin, d7 as TrustProxyConfig, d8 as TypedField, d9 as UploadConfig, da as UrlFieldAdmin, db as UrlLinkValue, dc as ViewActionFeatures, dd as ViewComponentSlots, de as ViewConfig, df as ViewConfigBase, dg as ViewLayout, dh as ViewMetric, di as ViewSubMetric, dj as WhereClause, dk as WhereOperator, dl as WhereOperatorName, dm as WordLimitFieldAdmin, dn as WordLimitFieldConfig, dp as WorkflowMetadata, dq as WorkflowOnTransitionContext, dr as WorkflowOnTransitionHook, ds as WorkflowRole, dt as WorkflowState, du as WorkflowTransitionContext, dv as coerceBooleanWhere, dw as defineAction, dx as defineCalendarView, dy as defineCardsView, dz as defineGanttView, dA as defineKanbanView, dB as defineTableView, dC as defineView, dD as defineWorkspace, dE as isAICollection, dF as parseMongoWhere, dG as parseSqlWhere } from './app-Dd9cBbCs.js';
|
|
3
3
|
import jexl from 'jexl';
|
|
4
4
|
import { Context } from 'hono';
|
|
5
5
|
export { z } from 'zod';
|
|
@@ -13,7 +13,7 @@ import '@opentelemetry/exporter-prometheus';
|
|
|
13
13
|
type Prettify<T> = {
|
|
14
14
|
[K in keyof T]: T[K];
|
|
15
15
|
};
|
|
16
|
-
type FieldValueType<F extends Field> = F["type"] extends "text" | "textarea" | "email" | "url" | "icon" | "date" | "datetime" | "time" | "select" | "radio" ? string : F["type"] extends "number" ? number : F["type"] extends "boolean" ? boolean : F["type"] extends "multiSelect" ? string[] : F["type"] extends "relationship" ? F extends {
|
|
16
|
+
type FieldValueType<F extends Field> = F["type"] extends "text" | "textarea" | "email" | "url" | "icon" | "date" | "datetime" | "time" | "select" | "radio" ? string : F["type"] extends "number" | "money" ? number : F["type"] extends "boolean" ? boolean : F["type"] extends "multiSelect" ? string[] : F["type"] extends "relationship" ? F extends {
|
|
17
17
|
hasMany: true;
|
|
18
18
|
} ? string[] : string : F["type"] extends "image" ? F extends {
|
|
19
19
|
hasMany: true;
|
|
@@ -639,6 +639,8 @@ declare function saveWorkflowDraft(args: {
|
|
|
639
639
|
originalDoc: BaseDocument;
|
|
640
640
|
data: Record<string, unknown>;
|
|
641
641
|
user?: AuthenticatedUser;
|
|
642
|
+
/** Runs inside the write transaction, after the draft is saved. */
|
|
643
|
+
beforeCommit?: (tx: DatabaseAdapter, doc: BaseDocument) => Promise<void>;
|
|
642
644
|
}): Promise<{
|
|
643
645
|
doc: BaseDocument;
|
|
644
646
|
event: LifecycleEvent;
|
|
@@ -648,6 +650,8 @@ declare function createWorkflowDocument(args: {
|
|
|
648
650
|
collection: CollectionConfig;
|
|
649
651
|
data: Record<string, unknown>;
|
|
650
652
|
user?: AuthenticatedUser;
|
|
653
|
+
/** Runs inside the write transaction, after the document is created. */
|
|
654
|
+
beforeCommit?: (tx: DatabaseAdapter, doc: BaseDocument) => Promise<void>;
|
|
651
655
|
}): Promise<{
|
|
652
656
|
doc: BaseDocument;
|
|
653
657
|
event: LifecycleEvent;
|
|
@@ -659,10 +663,74 @@ declare function transitionWorkflow(args: {
|
|
|
659
663
|
transitionName: string;
|
|
660
664
|
expectedRevision?: number;
|
|
661
665
|
comment?: string;
|
|
666
|
+
input?: Record<string, unknown>;
|
|
662
667
|
user?: AuthenticatedUser;
|
|
663
668
|
req: HookRequestContext;
|
|
664
669
|
}): Promise<BaseDocument>;
|
|
665
670
|
|
|
671
|
+
declare const TASK_LOCKS_COLLECTION = "__task_locks";
|
|
672
|
+
/** Internal collection holding one lock row per task. Created on demand by the runner. */
|
|
673
|
+
declare const TASK_LOCKS_COLLECTION_CONFIG: CollectionConfig;
|
|
674
|
+
interface CronSchedule {
|
|
675
|
+
minutes: Set<number>;
|
|
676
|
+
hours: Set<number>;
|
|
677
|
+
daysOfMonth: Set<number>;
|
|
678
|
+
months: Set<number>;
|
|
679
|
+
daysOfWeek: Set<number>;
|
|
680
|
+
/** Standard cron semantics: when both day fields are restricted, either may match. */
|
|
681
|
+
dayFieldsBothRestricted: boolean;
|
|
682
|
+
}
|
|
683
|
+
/** Parses a five-field cron expression. Throws a descriptive error when it is invalid. */
|
|
684
|
+
declare function parseCron(expression: string): CronSchedule;
|
|
685
|
+
/** The first cron slot strictly after `after`, in UTC. */
|
|
686
|
+
declare function nextCronRun(expression: string | CronSchedule, after: Date): Date;
|
|
687
|
+
/**
|
|
688
|
+
* Defines a background task. Validates the name, cron expression and lock
|
|
689
|
+
* timeout immediately, so a typo fails at startup rather than at 3am.
|
|
690
|
+
*
|
|
691
|
+
* @example
|
|
692
|
+
* ```ts
|
|
693
|
+
* export const ledgerDrift = defineTask({
|
|
694
|
+
* name: "wallet:ledger-drift",
|
|
695
|
+
* cron: "*\/15 * * * *",
|
|
696
|
+
* lockTimeout: 300,
|
|
697
|
+
* async run({ db, logger }) {
|
|
698
|
+
* const drifts = await checkLedgerDrift(db);
|
|
699
|
+
* if (drifts.length) logger.error({ drifts }, "Ledger drift detected");
|
|
700
|
+
* },
|
|
701
|
+
* });
|
|
702
|
+
* ```
|
|
703
|
+
*/
|
|
704
|
+
declare function defineTask<const T extends TaskConfig>(task: T): T;
|
|
705
|
+
interface TaskRunner {
|
|
706
|
+
/**
|
|
707
|
+
* Runs one task now, ignoring its schedule. Returns `skipped` with reason
|
|
708
|
+
* `"locked"` when another instance is already running it.
|
|
709
|
+
*/
|
|
710
|
+
runTask(name: string): Promise<TaskRunResult>;
|
|
711
|
+
/**
|
|
712
|
+
* Runs every scheduled task that is due. Safe to call from any number of
|
|
713
|
+
* instances or from a platform cron: each due slot runs exactly once.
|
|
714
|
+
*/
|
|
715
|
+
runDue(now?: Date): Promise<TaskRunResult[]>;
|
|
716
|
+
/** Starts polling for due tasks. Returns immediately and never blocks startup. */
|
|
717
|
+
start(options?: {
|
|
718
|
+
intervalMs?: number;
|
|
719
|
+
}): void;
|
|
720
|
+
/** Stops polling and waits for any run in progress to settle. */
|
|
721
|
+
stop(): Promise<void>;
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Creates the runner for the tasks in `config.tasks`. Coordination between
|
|
725
|
+
* instances uses a lock row per task in the database, taken with a single
|
|
726
|
+
* conditional update, so it works across processes and on every adapter.
|
|
727
|
+
*
|
|
728
|
+
* Core does not start it for you: a timer is unreliable on serverless, so the
|
|
729
|
+
* host chooses. Call `start()` on a long-lived Node server, or call `runDue()`
|
|
730
|
+
* from a platform cron.
|
|
731
|
+
*/
|
|
732
|
+
declare function createTaskRunner(config: DyrectedConfig): TaskRunner;
|
|
733
|
+
|
|
666
734
|
/**
|
|
667
735
|
* Normalizes a DetailItem (which may be a shorthand string) into a standard DetailItem object.
|
|
668
736
|
*
|
|
@@ -1393,6 +1461,85 @@ declare function generateDocumentId(collectionOrSlug?: string | {
|
|
|
1393
1461
|
idGenerator?: (slug: string) => string;
|
|
1394
1462
|
}): string;
|
|
1395
1463
|
|
|
1464
|
+
/**
|
|
1465
|
+
* Builds the physical name of an index, for example `uniq_collection_wallets_currency`.
|
|
1466
|
+
*
|
|
1467
|
+
* MySQL rejects names over 64 characters and Postgres silently truncates at 63, which can
|
|
1468
|
+
* collide or, on MySQL, leave a unique constraint uncreated. Names that would be too long are
|
|
1469
|
+
* shortened to `<prefix>_<hash>_<last field>`, where the hash is derived from the full name so
|
|
1470
|
+
* the result stays stable and unique per table and field set.
|
|
1471
|
+
*/
|
|
1472
|
+
declare function resolveIndexName(prefix: "uniq" | "idx", table: string, fields: string[]): string;
|
|
1473
|
+
|
|
1474
|
+
/** Key used for the group whose value is null or missing. */
|
|
1475
|
+
declare const UNASSIGNED_GROUP_KEY = "__unassigned__";
|
|
1476
|
+
/**
|
|
1477
|
+
* Turns the raw value of a `groupBy` column into the string key used in aggregate results.
|
|
1478
|
+
*
|
|
1479
|
+
* Databases hand the same logical value back in different shapes: a boolean is `true`, `1` or
|
|
1480
|
+
* `'1'`; a decimal column returns `'1.0000'`; a timestamp is a `Date` or a space-separated string.
|
|
1481
|
+
* Normalizing by the field's declared type keeps the keys identical on every adapter, so callers
|
|
1482
|
+
* can look up `groups["true"]`, `groups["1"]` or an ISO date whichever database they run on.
|
|
1483
|
+
*/
|
|
1484
|
+
declare function normalizeGroupKey(raw: unknown, fieldType?: string): string;
|
|
1485
|
+
|
|
1486
|
+
interface ReconciledNavTree extends CompiledNavTree {
|
|
1487
|
+
pinnedItems: CompiledNavItem[];
|
|
1488
|
+
}
|
|
1489
|
+
/**
|
|
1490
|
+
* Reconciles developer-defined navigation tree from code (`baseTree`)
|
|
1491
|
+
* with operator personal/role preferences (`prefs`), ensuring:
|
|
1492
|
+
* 1. Sparse delta merging (newly deployed code resources are never dropped).
|
|
1493
|
+
* 2. User-created custom groups and operational workspaces are injected.
|
|
1494
|
+
* 3. User visibility overrides (`hidden`) are respected.
|
|
1495
|
+
* 4. User ordering overrides (`groupOrder`, `itemOrder`) are applied.
|
|
1496
|
+
* 5. Pinned favorite shortcuts are extracted.
|
|
1497
|
+
* 6. Tombstone shielding: deleted collections/views don't crash the sidebar.
|
|
1498
|
+
*/
|
|
1499
|
+
interface ReconcileNavigationOptions {
|
|
1500
|
+
/**
|
|
1501
|
+
* If true, hidden groups, items, and views are retained in the returned tree
|
|
1502
|
+
* (useful for customizers/editors that need to display and unhide them).
|
|
1503
|
+
* If false (default), hidden groups, items, and views are omitted.
|
|
1504
|
+
*/
|
|
1505
|
+
includeHidden?: boolean;
|
|
1506
|
+
}
|
|
1507
|
+
declare function reconcileNavigation(baseTree: CompiledNavTree | null | undefined, prefs: UserNavigationPreferences | null | undefined, schemas?: {
|
|
1508
|
+
collections?: Array<any>;
|
|
1509
|
+
globals?: Array<any>;
|
|
1510
|
+
}, options?: ReconcileNavigationOptions): ReconciledNavTree;
|
|
1511
|
+
|
|
1512
|
+
/**
|
|
1513
|
+
* System route prefixes reserved by Dyrected.
|
|
1514
|
+
* Cannot be used as operational workspace slugs.
|
|
1515
|
+
*/
|
|
1516
|
+
declare const RESERVED_NAVIGATION_SLUGS: Set<string>;
|
|
1517
|
+
/**
|
|
1518
|
+
* Validates that no navigation item uses a reserved system route slug.
|
|
1519
|
+
*/
|
|
1520
|
+
declare function assertValidNavigationSlugs(navigation: DefineWorkspaceOptions[]): void;
|
|
1521
|
+
/**
|
|
1522
|
+
* Compile the complete admin navigation tree from DyrectedConfig.
|
|
1523
|
+
*
|
|
1524
|
+
* Implements a deterministic 5-step compilation pipeline:
|
|
1525
|
+
* 1. Discover all collections, globals, and media resources.
|
|
1526
|
+
* 2. Apply explicit navigation overrides from `config.admin.navigation`.
|
|
1527
|
+
* 3. Evaluate `before` and `after` anchors via relative splicing.
|
|
1528
|
+
* 4. Sort groups and items by `order` and `position: 'first' | 'last'`.
|
|
1529
|
+
* 5. Auto-merge unmentioned resources into fallback sections.
|
|
1530
|
+
*/
|
|
1531
|
+
declare function compileNavigation(config: DyrectedConfig<any> | {
|
|
1532
|
+
collections?: readonly any[];
|
|
1533
|
+
globals?: readonly any[];
|
|
1534
|
+
admin?: {
|
|
1535
|
+
navigation?: DefineWorkspaceOptions[];
|
|
1536
|
+
};
|
|
1537
|
+
}): CompiledNavTree;
|
|
1538
|
+
/**
|
|
1539
|
+
* Filter compiled navigation based on user access rules.
|
|
1540
|
+
*/
|
|
1541
|
+
declare function pruneNavigationForUser(tree: CompiledNavTree, user?: any): CompiledNavTree;
|
|
1542
|
+
|
|
1396
1543
|
type TopLevelFieldName<TFields extends readonly Field[]> = Extract<TFields[number], {
|
|
1397
1544
|
name: string;
|
|
1398
1545
|
}>["name"];
|
|
@@ -1713,6 +1860,10 @@ declare const defineRichTextField: <const T extends Omit<RichTextField, "type">>
|
|
|
1713
1860
|
declare const defineNumberField: <const T extends Omit<NumberField, "type">>(field: T) => T & {
|
|
1714
1861
|
type: "number";
|
|
1715
1862
|
};
|
|
1863
|
+
/** Define a `money` field stored as integer minor units. */
|
|
1864
|
+
declare const defineMoneyField: <const T extends Omit<MoneyField, "type">>(field: T) => T & {
|
|
1865
|
+
type: "money";
|
|
1866
|
+
};
|
|
1716
1867
|
/** Define a `boolean` field. */
|
|
1717
1868
|
declare const defineBooleanField: <const T extends Omit<BooleanField, "type">>(field: T) => T & {
|
|
1718
1869
|
type: "boolean";
|
|
@@ -1889,4 +2040,4 @@ declare function defineTab<const T extends readonly Field[]>(args: {
|
|
|
1889
2040
|
fields: T;
|
|
1890
2041
|
}): T;
|
|
1891
2042
|
|
|
1892
|
-
export { AIConfig, type AIErrorCode, AIPIIConfig, type AccessConditions, AccessPolicyResolver, AdminAuthConfig, ArrayField, AuthConfig, type AuthDocFields, AuthenticatedUser, BASE62_ALPHABET, BUILTIN_JEXL_HELPERS, BaseDocument, Block, BooleanField, CROCKFORD_BASE32, CollectionConfig, ComputedHandler, type ConfigDiagnostic, ConfigValidationError, ConflictError, DateField, DateTimeField, type DeclarativeAccessSurface, type DeclarativeAccessValidationIssue, type DeclarativeAdminSurface, type DeclarativeAdminValidationIssue, DeclarativeHookExpression, type DeclarativeHookSurface, type DeclarativeHookValidationIssue, type DeclarativePreviewSurface, type DeclarativePreviewValidationIssue, DetailAction, DetailActionOptions, DetailComputed, DetailComputedOptions, DetailCustom, DetailCustomOptions, DetailDivider, DetailDividerOptions, DetailField, DetailGrid, DetailGridOptions, DetailItem, DetailRepeat, DetailRepeatOptions, DetailSchema, DetailSection, DetailSectionOptions, DetailTab, DetailTabOptions, DetailTabs, DetailTabsOptions, DetailText, DetailTextOptions, DisplayFieldOptions, DuplicateKeyError, DyrectedAIError, DyrectedConfig, DyrectedError, EmailField, type ExprFunction, type ExtractCollectionSlugs, Field, FieldConditionBuilder, FieldType, ForbiddenError, type GenerateIdOptions, GlobalConfig, HookRequestContext, IconField, IdStrategy, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MatchBuilder, MultiSelectField, NANOID_ALPHABET, NON_NEGOTIABLE_CREDENTIAL_FIELDS, NotFoundError, NumberField, ObjectField, PII_REGEX_PATTERNS, type Prettify, PublicAdminAuthConfig, type PublishingWorkflowOptions, RadioField, RelationshipField, RichTextField, RowField, type SanitizeDocForAIOptions, SelectField, type SortClause, type SortDirection, type SqlSortDialect, type SystemDocFields, TextField, TextareaField, TimeField, type UploadDocFields, UrlField, ValidationError, WORKFLOW_HISTORY_COLLECTION, type WhenFunction, WorkflowConfig, WorkflowTransition, abs, addDays, asCollection, assertValidAdminConditionsInConfig, assertValidDeclarativeAccessInConfig, assertValidDeclarativeHookExpression, assertValidDeclarativeHookResult, assertValidDeclarativeHooksInConfig, assertValidPreviewUrlsInConfig, availableWorkflowTransitions, buildSqlOrderBy, canViewWorkflowDraft, capitalize, ceil, clamp, coalesce, collectAdminConditionValidationIssues, collectConfigDiagnostics, collectDeclarativeAccessValidationIssues, collectDeclarativeHookValidationIssues, collectPreviewUrlValidationIssues, compact, count, createLifecycleEvent, createWorkflowDocument, defaultValue, defineArrayField, defineBlock, defineBlocksField, defineBooleanField, defineCollection, defineConfig, defineDateField, defineDateTimeField, defineEmailField, defineField, defineGlobal, defineIconField, defineImageField, defineJoinField, defineJsonField, defineMultiSelectField, defineNumberField, defineObjectField, definePublishingWorkflow, defineRadioField, defineRelationshipField, defineRichTextField, defineRowField, defineSelectField, defineTab, defineTextField, defineTextareaField, defineTimeField, defineUrlField, diffDays, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, displayAction, displayComputed, displayCustom, displayCustomComponent, displayDivider, displayField, displayGrid, displayRepeat, displaySection, displayTab, displayTabs, displayText, endsWith, evaluateDetailComputed, evaluateJexl, evaluateJexlSync, executeFieldAfterRead, executeFieldBeforeChange, expr, first, floor, formatConfigDiagnostics, formatDate, formatJexlValue, generateDefaultDetailSchema, generateDocumentId, generateId, generateOpenApi, get, getAdminAuthCollection, getAdminRoleForCollection, getAllowedSitesForUser, getPublicAdminAuthConfig, includes, initializeWorkflowDocument, isConfigValidationError, isDetailItemVisible, isEmpty, isFuture, isPast, isSiteAuthorized, isUserAdmin, join, last, length, lower, maskEmail, maskPhone, maskTextPII, materializeWorkflowDocument, max, min, nanoid, normalizeConfig, normalizeDetailItem, now, numericFieldNames, parseSort, pow, prefixedId, publishedStateName, publishingWorkflow, readingTime, registerJexlHelpers, replace, resolveAdminAuthCollection, resolveAuthorizedSiteId, resolvePrefix, round, runCollectionHooks, sanitizeDocForAI, saveWorkflowDraft, simplePublishingWorkflow, slugify, sqrt, startsWith, sum, today, transitionWorkflow, trim, truncate, ulid, unique, upper, uuid, validateAdminConditionExpression, validateDeclarativeAccessExpression, validateDeclarativeHookExpression, validatePreviewUrlExpression, when, wordCount, workflowCapabilities };
|
|
2043
|
+
export { AIConfig, type AIErrorCode, AIPIIConfig, type AccessConditions, AccessPolicyResolver, AdminAuthConfig, ArrayField, AuthConfig, type AuthDocFields, AuthenticatedUser, BASE62_ALPHABET, BUILTIN_JEXL_HELPERS, BaseDocument, Block, BooleanField, CROCKFORD_BASE32, CollectionConfig, CompiledNavItem, CompiledNavTree, ComputedHandler, type ConfigDiagnostic, ConfigValidationError, ConflictError, DatabaseAdapter, DateField, DateTimeField, type DeclarativeAccessSurface, type DeclarativeAccessValidationIssue, type DeclarativeAdminSurface, type DeclarativeAdminValidationIssue, DeclarativeHookExpression, type DeclarativeHookSurface, type DeclarativeHookValidationIssue, type DeclarativePreviewSurface, type DeclarativePreviewValidationIssue, DefineWorkspaceOptions, DetailAction, DetailActionOptions, DetailComputed, DetailComputedOptions, DetailCustom, DetailCustomOptions, DetailDivider, DetailDividerOptions, DetailField, DetailGrid, DetailGridOptions, DetailItem, DetailRepeat, DetailRepeatOptions, DetailSchema, DetailSection, DetailSectionOptions, DetailTab, DetailTabOptions, DetailTabs, DetailTabsOptions, DetailText, DetailTextOptions, DisplayFieldOptions, DuplicateKeyError, DyrectedAIError, DyrectedConfig, DyrectedError, EmailField, type ExprFunction, type ExtractCollectionSlugs, Field, FieldConditionBuilder, FieldType, ForbiddenError, type GenerateIdOptions, GlobalConfig, HookRequestContext, IconField, IdStrategy, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MatchBuilder, MoneyField, MultiSelectField, NANOID_ALPHABET, NON_NEGOTIABLE_CREDENTIAL_FIELDS, NotFoundError, NumberField, ObjectField, PII_REGEX_PATTERNS, type Prettify, PublicAdminAuthConfig, type PublishingWorkflowOptions, RESERVED_NAVIGATION_SLUGS, RadioField, type ReconcileNavigationOptions, type ReconciledNavTree, RelationshipField, RichTextField, RowField, type SanitizeDocForAIOptions, SelectField, type SortClause, type SortDirection, type SqlSortDialect, type SystemDocFields, TASK_LOCKS_COLLECTION, TASK_LOCKS_COLLECTION_CONFIG, TaskConfig, TaskRunResult, type TaskRunner, TextField, TextareaField, TimeField, UNASSIGNED_GROUP_KEY, type UploadDocFields, UrlField, UserNavigationPreferences, ValidationError, WORKFLOW_HISTORY_COLLECTION, type WhenFunction, WorkflowConfig, WorkflowTransition, abs, addDays, asCollection, assertValidAdminConditionsInConfig, assertValidDeclarativeAccessInConfig, assertValidDeclarativeHookExpression, assertValidDeclarativeHookResult, assertValidDeclarativeHooksInConfig, assertValidNavigationSlugs, assertValidPreviewUrlsInConfig, availableWorkflowTransitions, buildSqlOrderBy, canViewWorkflowDraft, capitalize, ceil, clamp, coalesce, collectAdminConditionValidationIssues, collectConfigDiagnostics, collectDeclarativeAccessValidationIssues, collectDeclarativeHookValidationIssues, collectPreviewUrlValidationIssues, compact, compileNavigation, count, createLifecycleEvent, createTaskRunner, createWorkflowDocument, defaultValue, defineArrayField, defineBlock, defineBlocksField, defineBooleanField, defineCollection, defineConfig, defineDateField, defineDateTimeField, defineEmailField, defineField, defineGlobal, defineIconField, defineImageField, defineJoinField, defineJsonField, defineMoneyField, defineMultiSelectField, defineNumberField, defineObjectField, definePublishingWorkflow, defineRadioField, defineRelationshipField, defineRichTextField, defineRowField, defineSelectField, defineTab, defineTask, defineTextField, defineTextareaField, defineTimeField, defineUrlField, diffDays, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, displayAction, displayComputed, displayCustom, displayCustomComponent, displayDivider, displayField, displayGrid, displayRepeat, displaySection, displayTab, displayTabs, displayText, endsWith, evaluateDetailComputed, evaluateJexl, evaluateJexlSync, executeFieldAfterRead, executeFieldBeforeChange, expr, first, floor, formatConfigDiagnostics, formatDate, formatJexlValue, generateDefaultDetailSchema, generateDocumentId, generateId, generateOpenApi, get, getAdminAuthCollection, getAdminRoleForCollection, getAllowedSitesForUser, getPublicAdminAuthConfig, includes, initializeWorkflowDocument, isConfigValidationError, isDetailItemVisible, isEmpty, isFuture, isPast, isSiteAuthorized, isUserAdmin, join, last, length, lower, maskEmail, maskPhone, maskTextPII, materializeWorkflowDocument, max, min, nanoid, nextCronRun, normalizeConfig, normalizeDetailItem, normalizeGroupKey, now, numericFieldNames, parseCron, parseSort, pow, prefixedId, pruneNavigationForUser, publishedStateName, publishingWorkflow, readingTime, reconcileNavigation, registerJexlHelpers, replace, resolveAdminAuthCollection, resolveAuthorizedSiteId, resolveIndexName, resolvePrefix, round, runCollectionHooks, sanitizeDocForAI, saveWorkflowDraft, simplePublishingWorkflow, slugify, sqrt, startsWith, sum, today, transitionWorkflow, trim, truncate, ulid, unique, upper, uuid, validateAdminConditionExpression, validateDeclarativeAccessExpression, validateDeclarativeHookExpression, validatePreviewUrlExpression, when, wordCount, workflowCapabilities };
|