@dyrected/core 2.10.0 → 2.10.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/{app-config-DQhcrGDE.d.cts → app-config-BLC7WoyL.d.cts} +141 -6
- package/dist/{app-config-DQhcrGDE.d.ts → app-config-BLC7WoyL.d.ts} +141 -6
- package/dist/{chunk-TYPDQTE2.js → chunk-H7DVVW2P.js} +5 -0
- package/dist/index.cjs +353 -0
- package/dist/index.d.cts +401 -86
- package/dist/index.d.ts +401 -86
- package/dist/index.js +345 -1
- package/dist/server.cjs +30 -7
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +25 -8
- package/dist/{where-sanitizer-3MNFMYA2.js → where-sanitizer-47QPJQ6O.js} +3 -2
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as Field, B as Block, D as DyrectedConfig, C as CollectionConfig, 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, f as DetailComputedOptions, g as ComputedHandler, h as DetailComputed, i as DetailCustomOptions, j as DetailCustom, k as DetailDividerOptions, l as DetailDivider, m as DisplayFieldOptions, n as DetailField, o as DetailItem, p as DetailGridOptions, q as DetailGrid, r as DetailRepeatOptions, s as DetailRepeat, t as DetailSectionOptions, u as DetailSection, v as DetailTabOptions, w as DetailTab, x as DetailTabsOptions, y as DetailTabs, z as DetailTextOptions, E as DetailText, I as DetailSchema, J as ArrayField, K as BlocksField, M as BooleanField, N as AuthConfig, O as AccessPolicyResolver, Q as DateField, R as DateTimeField, S as EmailField, T as IconField, U as ImageField, V as JoinField, X as JsonField, Y as MultiSelectField, Z as NumberField, _ as ObjectField, $ as RadioField, a0 as RelationshipField, a1 as RichTextField, a2 as RowField, a3 as SelectField, a4 as TextField, a5 as TextareaField, a6 as TimeField, a7 as UrlField } from './app-config-
|
|
2
|
-
export { a8 as AccessConfig, a9 as AccessFunction, aa as AccessFunctionArgs, ab as AccessResult, ac as AccessRule, ad as ActionConfig, ae as ActionContext, af as ActionType, ag as AdminAuthAccessResolution, ah as AdminAuthClaimMapping, ai as AdminAuthMember, aj as AdminAuthProvider, ak as AdminAuthProviderMembersConfig, al as AdminAuthProvisioningMode, am as AdminAuthResolveAccessArgs, an as AdminAuthResolvedIdentity, ao as AdminConfig, ap as AdminDashboardComponentSlots, aq as AdminIconName, ar as AggregateArgs, as as AggregateCastType, at as AggregateInput, au as AggregateOperation, av as AggregateResult, aw as BaseAdminAuthProvider, ax as BaseFieldAdmin, ay as BlockVariant, az as BooleanFieldAdmin, aA as BooleanFormat, aB as CharacterLimitFieldAdmin, aC as CharacterLimitFieldConfig, aD as CollectionAfterChangeHook, aE as CollectionAfterDeleteHook, aF as CollectionAfterReadHook, aG as CollectionAfterReadHookEntry, aH as CollectionAfterTransitionHook, aI as CollectionBeforeChangeHook, aJ as CollectionBeforeChangeHookEntry, aK as CollectionBeforeDeleteHook, aL as CollectionBeforeReadHook, aM as CollectionBeforeReadHookEntry, aN as CollectionBeforeTransitionHook, aO as CollectionListComponentSlots, aP as
|
|
1
|
+
import { F as Field, B as Block, D as DyrectedConfig, C as CollectionConfig, 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, f as DetailComputedOptions, g as ComputedHandler, h as DetailComputed, i as DetailCustomOptions, j as DetailCustom, k as DetailDividerOptions, l as DetailDivider, m as DisplayFieldOptions, n as DetailField, o as DetailItem, p as DetailGridOptions, q as DetailGrid, r as DetailRepeatOptions, s as DetailRepeat, t as DetailSectionOptions, u as DetailSection, v as DetailTabOptions, w as DetailTab, x as DetailTabsOptions, y as DetailTabs, z as DetailTextOptions, E as DetailText, I as DetailSchema, J as ArrayField, K as BlocksField, M as BooleanField, N as AuthConfig, O as AccessPolicyResolver, Q as DateField, R as DateTimeField, S as EmailField, T as IconField, U as ImageField, V as JoinField, X as JsonField, Y as MultiSelectField, Z as NumberField, _ as ObjectField, $ as RadioField, a0 as RelationshipField, a1 as RichTextField, a2 as RowField, a3 as SelectField, a4 as TextField, a5 as TextareaField, a6 as TimeField, a7 as UrlField } from './app-config-BLC7WoyL.cjs';
|
|
2
|
+
export { a8 as AccessConfig, a9 as AccessFunction, aa as AccessFunctionArgs, ab as AccessResult, ac as AccessRule, ad as ActionConfig, ae as ActionContext, af as ActionType, ag as AdminAuthAccessResolution, ah as AdminAuthClaimMapping, ai as AdminAuthMember, aj as AdminAuthProvider, ak as AdminAuthProviderMembersConfig, al as AdminAuthProvisioningMode, am as AdminAuthResolveAccessArgs, an as AdminAuthResolvedIdentity, ao as AdminConfig, ap as AdminDashboardComponentSlots, aq as AdminIconName, ar as AggregateArgs, as as AggregateCastType, at as AggregateInput, au as AggregateOperation, av as AggregateResult, aw as BaseAdminAuthProvider, ax as BaseFieldAdmin, ay as BlockVariant, az as BooleanFieldAdmin, aA as BooleanFormat, aB as CharacterLimitFieldAdmin, aC as CharacterLimitFieldConfig, aD as CollectionAfterChangeHook, aE as CollectionAfterDeleteHook, aF as CollectionAfterReadHook, aG as CollectionAfterReadHookEntry, aH as CollectionAfterTransitionHook, aI as CollectionBeforeChangeHook, aJ as CollectionBeforeChangeHookEntry, aK as CollectionBeforeDeleteHook, aL as CollectionBeforeReadHook, aM as CollectionBeforeReadHookEntry, aN as CollectionBeforeTransitionHook, aO as CollectionListComponentSlots, aP as CollectionViewComponentSlots, aQ as CountOperation, aR as CustomAdminAuthProvider, aS as DatabaseAdapter, aT as DateFieldAdmin, aU as DateFormat, aV as DefineActionOptions, aW as DefineViewOptions, aX as DetailSpan, aY as DisplayTone, aZ as DisplayVariant, a_ as DistinctCountOperation, a$ as DistinctValuesOperation, b0 as DynamicOptionItem, b1 as DynamicOptionsConfig, b2 as DynamicOptionsResolver, b3 as DynamicOptionsResolverArgs, b4 as DyrectedLoggerConfig, b5 as DyrectedObservabilityConfig, b6 as EmailFieldAdmin, b7 as FieldAdminHooks, b8 as FieldAdminOnChangeHook, b9 as FieldAdminOnChangeHookArgs, ba as FieldAdminOptionsHook, bb as FieldAdminOptionsHookArgs, bc as FieldAdminOptionsHookResult, bd as FieldAfterReadHook, be as FieldAfterReadHookArgs, bf as FieldBase, bg as FieldBeforeChangeHook, bh as FieldBeforeChangeHookArgs, bi as FieldHook, bj as FieldHooks, bk as FieldType, bl as FileData, bm as GlobalAfterChangeHook, bn as GlobalAfterReadHook, bo as GlobalAfterReadHookEntry, bp as GlobalBeforeChangeHook, bq as GlobalBeforeChangeHookEntry, br as GlobalBeforeReadHook, bs as GlobalBeforeReadHookEntry, bt as HeadingLevel, bu as HookFunction, bv as IconFieldAdmin, bw as ImageService, bx as InferAggregateResult, by as JoinFieldAdmin, bz as JsonFieldAdmin, bA as JsonFormat, bB as LIFECYCLE_EVENT_NAMES, bC as LifecycleEventHandler, bD as LinkFormat, bE as MetricColor, bF as MultiSelectFieldAdmin, bG as NamedAccessPolicy, bH as NumberFieldAdmin, bI as NumberFormat, bJ as NumberLimitFieldAdmin, bK as NumberLimitFieldConfig, bL as NumericOperation, bM as OIDCAdminAuthProvider, bN as OptionFormat, bO as PaginatedResult, bP as PublicAdminAuthProvider, bQ as RadioFieldAdmin, bR as RateLimitConfig, bS as ReadonlyDatabaseAdapter, bT as RichTextFeature, bU as RichTextFieldConfig, bV as SelectFieldAdmin, bW as SqlWhereResult, bX as StorageAdapter, bY as TextFieldAdmin, bZ as TextFormat, b_ as TextareaFieldAdmin, b$ as TrustProxyConfig, c0 as TypedField, c1 as UploadConfig, c2 as UrlFieldAdmin, c3 as UrlLinkValue, c4 as ViewActionFeatures, c5 as ViewComponentSlots, c6 as ViewConfig, c7 as ViewLayout, c8 as ViewMetric, c9 as ViewSubMetric, ca as WhereClause, cb as WhereOperator, cc as WhereOperatorName, cd as WordLimitFieldAdmin, ce as WordLimitFieldConfig, cf as WorkflowMetadata, cg as WorkflowRole, ch as WorkflowState, ci as WorkflowTransitionContext, cj as defineAction, ck as defineView, cl as parseMongoWhere, cm as parseSqlWhere } from './app-config-BLC7WoyL.cjs';
|
|
3
3
|
import jexl from 'jexl';
|
|
4
4
|
import 'lucide-react';
|
|
5
5
|
import 'pino';
|
|
@@ -86,89 +86,6 @@ declare function getAdminAuthCollection(config: Pick<DyrectedConfig, "collection
|
|
|
86
86
|
declare function resolveAdminAuthCollection(collections: CollectionConfig[], collectionSlug?: string): CollectionConfig | undefined;
|
|
87
87
|
declare function getPublicAdminAuthConfig(adminAuth?: AdminAuthConfig, collections?: CollectionConfig[]): PublicAdminAuthConfig;
|
|
88
88
|
|
|
89
|
-
/**
|
|
90
|
-
* Dyrected Where Clause DSL — shared query language across all database adapters.
|
|
91
|
-
*
|
|
92
|
-
* Adapters translate this DSL into their native format:
|
|
93
|
-
* - SQL adapters (SQLite, Postgres, MySQL): use parseSqlWhere()
|
|
94
|
-
* - MongoDB adapter: use parseMongoWhere()
|
|
95
|
-
* - Future adapters: implement their own translator against WhereClause
|
|
96
|
-
*
|
|
97
|
-
* Exhaustive operator handling is enforced at compile time via `assertNever`,
|
|
98
|
-
* so adding a new operator without handling it will produce a TypeScript error
|
|
99
|
-
* in every adapter translator.
|
|
100
|
-
*/
|
|
101
|
-
type WhereOperatorName = 'equals' | 'not_equals' | 'in' | 'not_in' | 'gt' | 'greater_than' | 'gte' | 'greater_than_equal' | 'greater_than_or_equal' | 'lt' | 'less_than' | 'lte' | 'less_than_equal' | 'less_than_or_equal' | 'contains' | 'like' | 'starts_with' | 'exists';
|
|
102
|
-
type WhereOperator = {
|
|
103
|
-
equals: any;
|
|
104
|
-
} | {
|
|
105
|
-
not_equals: any;
|
|
106
|
-
} | {
|
|
107
|
-
in: any[];
|
|
108
|
-
} | {
|
|
109
|
-
not_in: any[];
|
|
110
|
-
} | {
|
|
111
|
-
gt: any;
|
|
112
|
-
} | {
|
|
113
|
-
greater_than: any;
|
|
114
|
-
} | {
|
|
115
|
-
gte: any;
|
|
116
|
-
} | {
|
|
117
|
-
greater_than_equal: any;
|
|
118
|
-
} | {
|
|
119
|
-
greater_than_or_equal: any;
|
|
120
|
-
} | {
|
|
121
|
-
lt: any;
|
|
122
|
-
} | {
|
|
123
|
-
less_than: any;
|
|
124
|
-
} | {
|
|
125
|
-
lte: any;
|
|
126
|
-
} | {
|
|
127
|
-
less_than_equal: any;
|
|
128
|
-
} | {
|
|
129
|
-
less_than_or_equal: any;
|
|
130
|
-
} | {
|
|
131
|
-
contains: string;
|
|
132
|
-
} | {
|
|
133
|
-
like: string;
|
|
134
|
-
} | {
|
|
135
|
-
starts_with: string;
|
|
136
|
-
} | {
|
|
137
|
-
exists: boolean;
|
|
138
|
-
};
|
|
139
|
-
/** Top-level where clause. Fields map to operator objects or shorthand scalar values. */
|
|
140
|
-
type WhereClause = {
|
|
141
|
-
[field: string]: WhereOperator | any;
|
|
142
|
-
OR?: WhereClause[];
|
|
143
|
-
AND?: WhereClause[];
|
|
144
|
-
};
|
|
145
|
-
interface SqlWhereResult {
|
|
146
|
-
sql: string;
|
|
147
|
-
params: any[];
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Translates a WhereClause into a parameterized SQL WHERE fragment.
|
|
151
|
-
*
|
|
152
|
-
* @param where The Dyrected where DSL object
|
|
153
|
-
* @param getJsonField Returns the SQL expression for a JSON-stored field (dialect-specific):
|
|
154
|
-
* SQLite: (f) => `json_extract(data, '$.${f}')`
|
|
155
|
-
* Postgres: (f) => `data->>'${f}'`
|
|
156
|
-
* MySQL: (f) => `JSON_UNQUOTE(JSON_EXTRACT(data, '$.${f}'))`
|
|
157
|
-
* @param placeholder '?' for SQLite/MySQL, 'pg' for auto-incrementing Postgres $1/$2/…
|
|
158
|
-
*/
|
|
159
|
-
declare function parseSqlWhere(where: WhereClause, getJsonField: (field: string) => string, placeholder?: '?' | 'pg',
|
|
160
|
-
/**
|
|
161
|
-
* SQL keyword used for `contains`/`starts_with`. Postgres `LIKE` is
|
|
162
|
-
* case-sensitive, so the Postgres adapter defaults to `'ILIKE'` to keep substring
|
|
163
|
-
* matching case-insensitive like SQLite and MySQL.
|
|
164
|
-
*/
|
|
165
|
-
likeOperator?: 'LIKE' | 'ILIKE'): SqlWhereResult;
|
|
166
|
-
/**
|
|
167
|
-
* Translates a WhereClause into a MongoDB filter object.
|
|
168
|
-
* Handles nested OR/AND via $or/$and, and all operators via $eq/$in/$gt etc.
|
|
169
|
-
*/
|
|
170
|
-
declare function parseMongoWhere(where: WhereClause): Record<string, any>;
|
|
171
|
-
|
|
172
89
|
type SortDirection = 'ASC' | 'DESC';
|
|
173
90
|
interface SortClause {
|
|
174
91
|
field: string;
|
|
@@ -770,6 +687,404 @@ declare function generateDefaultDetailSchema(schema: {
|
|
|
770
687
|
*/
|
|
771
688
|
declare function isDetailItemVisible(item: DetailItem, doc: any, user?: any): boolean;
|
|
772
689
|
|
|
690
|
+
/**
|
|
691
|
+
* Formats a value for serializable JEXL expressions.
|
|
692
|
+
* Handles paths, expressions, identifiers, strings, and primitives.
|
|
693
|
+
*/
|
|
694
|
+
declare function formatJexlValue(v: string | number | boolean | null | undefined): string;
|
|
695
|
+
/**
|
|
696
|
+
* Multi-branch conditional builder for chaining if-else / switch-case expressions in JEXL.
|
|
697
|
+
*
|
|
698
|
+
* @example
|
|
699
|
+
* when.match()
|
|
700
|
+
* .case(when('slug').equals('home'), '/')
|
|
701
|
+
* .case(when.fieldNotEmpty('path'), 'path')
|
|
702
|
+
* .case(when('category').equals('news'), "'/news/' + slug")
|
|
703
|
+
* .otherwise("'/' + slug")
|
|
704
|
+
*/
|
|
705
|
+
declare class MatchBuilder {
|
|
706
|
+
private branches;
|
|
707
|
+
/**
|
|
708
|
+
* Adds a conditional branch (`condition ? value : ...`).
|
|
709
|
+
*/
|
|
710
|
+
case(condition: string, value: string | number | boolean | null): this;
|
|
711
|
+
/**
|
|
712
|
+
* Final fallback value when no cases match.
|
|
713
|
+
*/
|
|
714
|
+
otherwise(fallback?: string | number | boolean | null): string;
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Fluent builder for creating single-field conditions.
|
|
718
|
+
*/
|
|
719
|
+
declare class FieldConditionBuilder {
|
|
720
|
+
private field;
|
|
721
|
+
constructor(field: string);
|
|
722
|
+
/**
|
|
723
|
+
* Generates equality condition (`field == value`).
|
|
724
|
+
*/
|
|
725
|
+
equals(value: string | number | boolean | null): string;
|
|
726
|
+
/**
|
|
727
|
+
* Generates inequality condition (`field != value`).
|
|
728
|
+
*/
|
|
729
|
+
notEquals(value: string | number | boolean | null): string;
|
|
730
|
+
/**
|
|
731
|
+
* Generates set membership condition (`field in [val1, val2]`).
|
|
732
|
+
*/
|
|
733
|
+
in(...values: (string | number | boolean | (string | number | boolean)[])[]): string;
|
|
734
|
+
/**
|
|
735
|
+
* Generates inverted set membership condition (`!(field in [val1, val2])`).
|
|
736
|
+
*/
|
|
737
|
+
notIn(...values: (string | number | boolean | (string | number | boolean)[])[]): string;
|
|
738
|
+
/**
|
|
739
|
+
* Generates boolean true check (`field == true`).
|
|
740
|
+
*/
|
|
741
|
+
isTrue(): string;
|
|
742
|
+
/**
|
|
743
|
+
* Generates boolean false check (`field != true`).
|
|
744
|
+
*/
|
|
745
|
+
isFalse(): string;
|
|
746
|
+
/**
|
|
747
|
+
* Checks that the field is neither null/undefined nor an empty string.
|
|
748
|
+
*/
|
|
749
|
+
notEmpty(): string;
|
|
750
|
+
/**
|
|
751
|
+
* Checks that the field is null, undefined, or an empty string.
|
|
752
|
+
*/
|
|
753
|
+
isEmpty(): string;
|
|
754
|
+
/**
|
|
755
|
+
* Numerical greater than (`field > num`).
|
|
756
|
+
*/
|
|
757
|
+
greaterThan(num: number | string): string;
|
|
758
|
+
/**
|
|
759
|
+
* Numerical greater than or equal (`field >= num`).
|
|
760
|
+
*/
|
|
761
|
+
greaterThanOrEqual(num: number | string): string;
|
|
762
|
+
/**
|
|
763
|
+
* Numerical less than (`field < num`).
|
|
764
|
+
*/
|
|
765
|
+
lessThan(num: number | string): string;
|
|
766
|
+
/**
|
|
767
|
+
* Numerical less than or equal (`field <= num`).
|
|
768
|
+
*/
|
|
769
|
+
lessThanOrEqual(num: number | string): string;
|
|
770
|
+
/**
|
|
771
|
+
* Numerical range check (`field >= min && field <= max`).
|
|
772
|
+
*/
|
|
773
|
+
between(min: number, max: number): string;
|
|
774
|
+
/**
|
|
775
|
+
* String prefix check using JEXL `startsWith(field, prefix)`.
|
|
776
|
+
*/
|
|
777
|
+
startsWith(prefix: string): string;
|
|
778
|
+
/**
|
|
779
|
+
* String suffix check using JEXL `endsWith(field, suffix)`.
|
|
780
|
+
*/
|
|
781
|
+
endsWith(suffix: string): string;
|
|
782
|
+
/**
|
|
783
|
+
* Substring or array item check using JEXL `includes(field, item)`.
|
|
784
|
+
*/
|
|
785
|
+
contains(val: string | number): string;
|
|
786
|
+
/**
|
|
787
|
+
* Checks if array/string length exceeds a threshold.
|
|
788
|
+
*/
|
|
789
|
+
hasLengthGreaterThan(length: number): string;
|
|
790
|
+
/**
|
|
791
|
+
* Checks if array/string length is at least a threshold.
|
|
792
|
+
*/
|
|
793
|
+
hasLengthAtLeast(length: number): string;
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* Pre-built access control condition helpers.
|
|
797
|
+
*/
|
|
798
|
+
interface AccessConditions {
|
|
799
|
+
/**
|
|
800
|
+
* Checks if current user is the document owner (matches `user.id`).
|
|
801
|
+
* @default ownerField 'author'
|
|
802
|
+
*
|
|
803
|
+
* @example
|
|
804
|
+
* access: { update: when.access.isOwner('authorId') }
|
|
805
|
+
*/
|
|
806
|
+
isOwner: (ownerField?: string) => string;
|
|
807
|
+
/**
|
|
808
|
+
* Checks if current user has the 'admin' role or 'admin' in `user.roles`.
|
|
809
|
+
*
|
|
810
|
+
* @example
|
|
811
|
+
* access: { delete: when.access.isAdmin() }
|
|
812
|
+
*/
|
|
813
|
+
isAdmin: () => string;
|
|
814
|
+
/**
|
|
815
|
+
* Checks if current user has one of the specified roles.
|
|
816
|
+
*
|
|
817
|
+
* @example
|
|
818
|
+
* access: { update: when.access.hasRole('admin', 'editor') }
|
|
819
|
+
*/
|
|
820
|
+
hasRole: (...roles: (string | string[])[]) => string;
|
|
821
|
+
/**
|
|
822
|
+
* Common read access policy: document is published OR user is an admin/editor.
|
|
823
|
+
*
|
|
824
|
+
* @example
|
|
825
|
+
* access: { read: when.access.isPublishedOrAdmin() }
|
|
826
|
+
*/
|
|
827
|
+
isPublishedOrAdmin: (statusField?: string) => string;
|
|
828
|
+
}
|
|
829
|
+
/**
|
|
830
|
+
* Condition builder utilities for serializable JEXL expressions in `admin.condition`,
|
|
831
|
+
* access control rules, computed fields, and dynamic `admin.previewUrl`.
|
|
832
|
+
*/
|
|
833
|
+
interface WhenFunction {
|
|
834
|
+
/**
|
|
835
|
+
* Starts a fluent condition builder for a specific field name.
|
|
836
|
+
*
|
|
837
|
+
* @example
|
|
838
|
+
* admin: { condition: when('price').greaterThan(100) }
|
|
839
|
+
* admin: { condition: when('status').in('published', 'archived') }
|
|
840
|
+
* admin: { previewUrl: when.then(when('slug').equals('home'), '/', "'/' + slug") }
|
|
841
|
+
*/
|
|
842
|
+
(fieldName: string): FieldConditionBuilder;
|
|
843
|
+
/**
|
|
844
|
+
* Starts a fluent condition builder on the `user` context (e.g. `when.user('email').endsWith('@company.com')`).
|
|
845
|
+
*/
|
|
846
|
+
user: (userProp: string) => FieldConditionBuilder;
|
|
847
|
+
/**
|
|
848
|
+
* Starts a fluent condition builder on `siblingData` (e.g. `when.sibling('_variant').equals('split')`).
|
|
849
|
+
*/
|
|
850
|
+
sibling: (siblingProp: string) => FieldConditionBuilder;
|
|
851
|
+
/**
|
|
852
|
+
* Pre-packaged role and ownership access condition builders.
|
|
853
|
+
*/
|
|
854
|
+
access: AccessConditions;
|
|
855
|
+
/**
|
|
856
|
+
* Concatenates paths, literal strings, and field identifiers into a JEXL string concatenation expression.
|
|
857
|
+
* Automatically quotes literal segments (like paths) and preserves field identifiers.
|
|
858
|
+
*
|
|
859
|
+
* @example
|
|
860
|
+
* when.concat('/country-portals/', 'slug')
|
|
861
|
+
* // => "'/country-portals/' + slug"
|
|
862
|
+
*
|
|
863
|
+
* when.concat('/blog/', 'category', '/', 'slug')
|
|
864
|
+
* // => "'/blog/' + category + '/' + slug"
|
|
865
|
+
*/
|
|
866
|
+
concat: (...parts: string[]) => string;
|
|
867
|
+
/**
|
|
868
|
+
* Generates a JEXL `slugify(field)` transform expression.
|
|
869
|
+
*/
|
|
870
|
+
slugify: (field: string) => string;
|
|
871
|
+
/**
|
|
872
|
+
* Generates a JEXL `lower(field)` transform expression.
|
|
873
|
+
*/
|
|
874
|
+
lower: (field: string) => string;
|
|
875
|
+
/**
|
|
876
|
+
* Generates a JEXL `upper(field)` transform expression.
|
|
877
|
+
*/
|
|
878
|
+
upper: (field: string) => string;
|
|
879
|
+
/**
|
|
880
|
+
* Generates a JEXL `trim(field)` transform expression.
|
|
881
|
+
*/
|
|
882
|
+
trim: (field: string) => string;
|
|
883
|
+
/**
|
|
884
|
+
* Creates a ternary expression: `condition ? ifTrue : ifFalse`.
|
|
885
|
+
* Can be nested to create ternary chains.
|
|
886
|
+
*
|
|
887
|
+
* @example
|
|
888
|
+
* admin: { previewUrl: when.then(when.fieldEquals('slug', 'home'), '/', "'/' + slug") }
|
|
889
|
+
*/
|
|
890
|
+
then: (condition: string, ifTrue: string | number | boolean | null, ifFalse?: string | number | boolean | null) => string;
|
|
891
|
+
/**
|
|
892
|
+
* Starts a multi-branch chained ternary builder (`case().case().otherwise()`).
|
|
893
|
+
*
|
|
894
|
+
* @example
|
|
895
|
+
* admin: {
|
|
896
|
+
* previewUrl: when.match()
|
|
897
|
+
* .case(when('slug').equals('home'), '/')
|
|
898
|
+
* .case(when.fieldNotEmpty('path'), 'path')
|
|
899
|
+
* .case(when('category').equals('news'), "'/news/' + slug")
|
|
900
|
+
* .otherwise("'/' + slug")
|
|
901
|
+
* }
|
|
902
|
+
*/
|
|
903
|
+
match: () => MatchBuilder;
|
|
904
|
+
/**
|
|
905
|
+
* Declarative multi-case ternary builder.
|
|
906
|
+
*
|
|
907
|
+
* @example
|
|
908
|
+
* admin: {
|
|
909
|
+
* previewUrl: when.cases(
|
|
910
|
+
* [when.fieldEquals('slug', 'home'), '/'],
|
|
911
|
+
* [when.fieldNotEmpty('path'), 'path'],
|
|
912
|
+
* "'/' + slug"
|
|
913
|
+
* )
|
|
914
|
+
* }
|
|
915
|
+
*/
|
|
916
|
+
cases: (...branches: ([condition: string, value: string | number | boolean | null] | string | number | boolean | null)[]) => string;
|
|
917
|
+
/**
|
|
918
|
+
* Combines multiple conditions with AND (`&&`).
|
|
919
|
+
*/
|
|
920
|
+
all: (...conditions: (string | undefined | null | false)[]) => string;
|
|
921
|
+
/**
|
|
922
|
+
* Alias for `when.all(...)`.
|
|
923
|
+
*/
|
|
924
|
+
and: (...conditions: (string | undefined | null | false)[]) => string;
|
|
925
|
+
/**
|
|
926
|
+
* Combines multiple conditions with OR (`||`).
|
|
927
|
+
*/
|
|
928
|
+
any: (...conditions: (string | undefined | null | false)[]) => string;
|
|
929
|
+
/**
|
|
930
|
+
* Alias for `when.any(...)`.
|
|
931
|
+
*/
|
|
932
|
+
or: (...conditions: (string | undefined | null | false)[]) => string;
|
|
933
|
+
/**
|
|
934
|
+
* Inverts a condition (`!(condition)`).
|
|
935
|
+
*/
|
|
936
|
+
not: (condition: string) => string;
|
|
937
|
+
/**
|
|
938
|
+
* Generates a condition matching one or multiple variant names.
|
|
939
|
+
*
|
|
940
|
+
* @example
|
|
941
|
+
* admin: { condition: when.variant('split') }
|
|
942
|
+
* admin: { condition: when.variant('imageLeft', 'imageRight') }
|
|
943
|
+
*/
|
|
944
|
+
variant: (...variants: (string | string[])[]) => string;
|
|
945
|
+
/**
|
|
946
|
+
* Generates a condition matching everything EXCEPT the given variant names.
|
|
947
|
+
*/
|
|
948
|
+
notVariant: (...variants: (string | string[])[]) => string;
|
|
949
|
+
/**
|
|
950
|
+
* Generates a condition matching one or multiple block slugs.
|
|
951
|
+
*
|
|
952
|
+
* @example
|
|
953
|
+
* admin: { condition: when.block('hero', 'cta') }
|
|
954
|
+
*/
|
|
955
|
+
block: (...blocks: (string | string[])[]) => string;
|
|
956
|
+
/**
|
|
957
|
+
* Generates a condition matching everything EXCEPT the given block slugs.
|
|
958
|
+
*/
|
|
959
|
+
notBlock: (...blocks: (string | string[])[]) => string;
|
|
960
|
+
/**
|
|
961
|
+
* Generates a condition checking equality against a field value.
|
|
962
|
+
*
|
|
963
|
+
* @example
|
|
964
|
+
* admin: { condition: when.fieldEquals('status', 'published') }
|
|
965
|
+
*/
|
|
966
|
+
fieldEquals: (field: string, value: string | number | boolean | null) => string;
|
|
967
|
+
/**
|
|
968
|
+
* Generates a condition checking inequality against a field value.
|
|
969
|
+
*/
|
|
970
|
+
fieldNotEquals: (field: string, value: string | number | boolean | null) => string;
|
|
971
|
+
/**
|
|
972
|
+
* Generates a condition checking if a field is in a list of allowed values.
|
|
973
|
+
*/
|
|
974
|
+
fieldIn: (field: string, ...values: (string | number | boolean | (string | number | boolean)[])[]) => string;
|
|
975
|
+
/**
|
|
976
|
+
* Generates a condition checking if a field is NOT in a list of values.
|
|
977
|
+
*/
|
|
978
|
+
fieldNotIn: (field: string, ...values: (string | number | boolean | (string | number | boolean)[])[]) => string;
|
|
979
|
+
/**
|
|
980
|
+
* Generates a condition checking that a field is not null and not empty.
|
|
981
|
+
*
|
|
982
|
+
* @example
|
|
983
|
+
* admin: { condition: when.fieldNotEmpty('couponCode') }
|
|
984
|
+
*/
|
|
985
|
+
fieldNotEmpty: (field: string) => string;
|
|
986
|
+
/**
|
|
987
|
+
* Generates a condition checking that a field is null, undefined, or empty.
|
|
988
|
+
*/
|
|
989
|
+
fieldEmpty: (field: string) => string;
|
|
990
|
+
/**
|
|
991
|
+
* Generates a condition checking that a boolean field is true.
|
|
992
|
+
*/
|
|
993
|
+
fieldIsTrue: (field: string) => string;
|
|
994
|
+
/**
|
|
995
|
+
* Generates a condition checking that a boolean field is false / falsy.
|
|
996
|
+
*/
|
|
997
|
+
fieldIsFalse: (field: string) => string;
|
|
998
|
+
/**
|
|
999
|
+
* Generates a numerical greater-than condition (`field > value`).
|
|
1000
|
+
*/
|
|
1001
|
+
fieldGreaterThan: (field: string, value: number | string) => string;
|
|
1002
|
+
/**
|
|
1003
|
+
* Generates a numerical greater-than-or-equal condition (`field >= value`).
|
|
1004
|
+
*/
|
|
1005
|
+
fieldGreaterThanOrEqual: (field: string, value: number | string) => string;
|
|
1006
|
+
/**
|
|
1007
|
+
* Generates a numerical less-than condition (`field < value`).
|
|
1008
|
+
*/
|
|
1009
|
+
fieldLessThan: (field: string, value: number | string) => string;
|
|
1010
|
+
/**
|
|
1011
|
+
* Generates a numerical less-than-or-equal condition (`field <= value`).
|
|
1012
|
+
*/
|
|
1013
|
+
fieldLessThanOrEqual: (field: string, value: number | string) => string;
|
|
1014
|
+
/**
|
|
1015
|
+
* Generates a range condition (`field >= min && field <= max`).
|
|
1016
|
+
*/
|
|
1017
|
+
fieldBetween: (field: string, min: number, max: number) => string;
|
|
1018
|
+
/**
|
|
1019
|
+
* Generates a string prefix condition using JEXL `startsWith(...)`.
|
|
1020
|
+
*/
|
|
1021
|
+
fieldStartsWith: (field: string, prefix: string) => string;
|
|
1022
|
+
/**
|
|
1023
|
+
* Generates a string suffix condition using JEXL `endsWith(...)`.
|
|
1024
|
+
*/
|
|
1025
|
+
fieldEndsWith: (field: string, suffix: string) => string;
|
|
1026
|
+
/**
|
|
1027
|
+
* Generates a string/array inclusion condition using JEXL `includes(...)`.
|
|
1028
|
+
*/
|
|
1029
|
+
fieldContains: (field: string, item: string | number) => string;
|
|
1030
|
+
/**
|
|
1031
|
+
* Generates a condition checking that an array is non-empty (`length(field) > 0`).
|
|
1032
|
+
*/
|
|
1033
|
+
arrayNotEmpty: (field: string) => string;
|
|
1034
|
+
/**
|
|
1035
|
+
* Generates a condition checking that an array is empty (`length(field) == 0`).
|
|
1036
|
+
*/
|
|
1037
|
+
arrayEmpty: (field: string) => string;
|
|
1038
|
+
/**
|
|
1039
|
+
* Generates a condition checking that an array has more than N items.
|
|
1040
|
+
*/
|
|
1041
|
+
arrayCountGreaterThan: (field: string, count: number) => string;
|
|
1042
|
+
/**
|
|
1043
|
+
* Generates a condition checking that an array has at least N items.
|
|
1044
|
+
*/
|
|
1045
|
+
arrayCountAtLeast: (field: string, count: number) => string;
|
|
1046
|
+
/**
|
|
1047
|
+
* Generates a condition checking that an array has less than N items.
|
|
1048
|
+
*/
|
|
1049
|
+
arrayCountLessThan: (field: string, count: number) => string;
|
|
1050
|
+
/**
|
|
1051
|
+
* Generates a condition checking the authenticated editor's role.
|
|
1052
|
+
* Checks both `user.role` (string) and `user.roles` (array).
|
|
1053
|
+
*
|
|
1054
|
+
* @example
|
|
1055
|
+
* admin: { condition: when.userRole('admin', 'developer') }
|
|
1056
|
+
*/
|
|
1057
|
+
userRole: (...roles: (string | string[])[]) => string;
|
|
1058
|
+
/**
|
|
1059
|
+
* Generates a condition checking the editor's email domain.
|
|
1060
|
+
*
|
|
1061
|
+
* @example
|
|
1062
|
+
* admin: { condition: when.userEmailDomain('agrictrail.com') }
|
|
1063
|
+
*/
|
|
1064
|
+
userEmailDomain: (domain: string) => string;
|
|
1065
|
+
/**
|
|
1066
|
+
* Generates a condition checking a custom attribute on the user object.
|
|
1067
|
+
*/
|
|
1068
|
+
userAttributeEquals: (attr: string, value: string | number | boolean | null) => string;
|
|
1069
|
+
/**
|
|
1070
|
+
* Condition that evaluates to true only for unsaved, newly-created documents.
|
|
1071
|
+
*/
|
|
1072
|
+
isNewDocument: () => string;
|
|
1073
|
+
/**
|
|
1074
|
+
* Condition that evaluates to true only for persisted, existing documents.
|
|
1075
|
+
*/
|
|
1076
|
+
isExistingDocument: () => string;
|
|
1077
|
+
/**
|
|
1078
|
+
* Generates a condition checking the document's workflow status.
|
|
1079
|
+
*/
|
|
1080
|
+
statusEquals: (status: string) => string;
|
|
1081
|
+
/**
|
|
1082
|
+
* Generates a condition checking if status is within a set of statuses.
|
|
1083
|
+
*/
|
|
1084
|
+
statusIn: (...statuses: (string | string[])[]) => string;
|
|
1085
|
+
}
|
|
1086
|
+
declare const when: WhenFunction;
|
|
1087
|
+
|
|
773
1088
|
type TopLevelFieldName<TFields extends readonly Field[]> = Extract<TFields[number], {
|
|
774
1089
|
name: string;
|
|
775
1090
|
}>["name"];
|
|
@@ -1189,4 +1504,4 @@ declare function defineTab<const T extends readonly Field[]>(args: {
|
|
|
1189
1504
|
fields: T;
|
|
1190
1505
|
}): T;
|
|
1191
1506
|
|
|
1192
|
-
export { AccessPolicyResolver, AdminAuthConfig, ArrayField, AuthConfig, type AuthDocFields, AuthenticatedUser, BUILTIN_JEXL_HELPERS, BaseDocument, Block, BlocksField, BooleanField, CollectionConfig, ComputedHandler, type ConfigDiagnostic, ConfigValidationError, DateField, DateTimeField, type DeclarativeAccessSurface, type DeclarativeAccessValidationIssue, type DeclarativeAdminSurface, type DeclarativeAdminValidationIssue, DeclarativeHookExpression, type DeclarativeHookSurface, type DeclarativeHookValidationIssue, type DeclarativePreviewSurface, type DeclarativePreviewValidationIssue, DetailComputed, DetailComputedOptions, DetailCustom, DetailCustomOptions, DetailDivider, DetailDividerOptions, DetailField, DetailGrid, DetailGridOptions, DetailItem, DetailRepeat, DetailRepeatOptions, DetailSchema, DetailSection, DetailSectionOptions, DetailTab, DetailTabOptions, DetailTabs, DetailTabsOptions, DetailText, DetailTextOptions, DisplayFieldOptions, DyrectedConfig, EmailField, Field, GlobalConfig, HookRequestContext, IconField, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MultiSelectField, NumberField, ObjectField, type Prettify, PublicAdminAuthConfig, type PublishingWorkflowOptions, RadioField, RelationshipField, RichTextField, RowField, SelectField, type SortClause, type SortDirection, type SqlSortDialect, type
|
|
1507
|
+
export { type AccessConditions, AccessPolicyResolver, AdminAuthConfig, ArrayField, AuthConfig, type AuthDocFields, AuthenticatedUser, BUILTIN_JEXL_HELPERS, BaseDocument, Block, BlocksField, BooleanField, CollectionConfig, ComputedHandler, type ConfigDiagnostic, ConfigValidationError, DateField, DateTimeField, type DeclarativeAccessSurface, type DeclarativeAccessValidationIssue, type DeclarativeAdminSurface, type DeclarativeAdminValidationIssue, DeclarativeHookExpression, type DeclarativeHookSurface, type DeclarativeHookValidationIssue, type DeclarativePreviewSurface, type DeclarativePreviewValidationIssue, DetailComputed, DetailComputedOptions, DetailCustom, DetailCustomOptions, DetailDivider, DetailDividerOptions, DetailField, DetailGrid, DetailGridOptions, DetailItem, DetailRepeat, DetailRepeatOptions, DetailSchema, DetailSection, DetailSectionOptions, DetailTab, DetailTabOptions, DetailTabs, DetailTabsOptions, DetailText, DetailTextOptions, DisplayFieldOptions, DyrectedConfig, EmailField, Field, FieldConditionBuilder, GlobalConfig, HookRequestContext, IconField, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MatchBuilder, MultiSelectField, NumberField, ObjectField, type Prettify, PublicAdminAuthConfig, type PublishingWorkflowOptions, RadioField, RelationshipField, RichTextField, RowField, SelectField, type SortClause, type SortDirection, type SqlSortDialect, type SystemDocFields, TextField, TextareaField, TimeField, type UploadDocFields, UrlField, WORKFLOW_HISTORY_COLLECTION, type WhenFunction, WorkflowConfig, WorkflowTransition, abs, addDays, 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, displayComputed, displayCustom, displayCustomComponent, displayDivider, displayField, displayGrid, displayRepeat, displaySection, displayTab, displayTabs, displayText, endsWith, evaluateDetailComputed, evaluateJexl, evaluateJexlSync, executeFieldAfterRead, executeFieldBeforeChange, first, floor, formatConfigDiagnostics, formatDate, formatJexlValue, generateDefaultDetailSchema, generateOpenApi, get, getAdminAuthCollection, getPublicAdminAuthConfig, includes, initializeWorkflowDocument, isConfigValidationError, isDetailItemVisible, isEmpty, isFuture, isPast, join, last, length, lower, materializeWorkflowDocument, max, min, normalizeConfig, normalizeDetailItem, now, numericFieldNames, parseSort, pow, publishedStateName, publishingWorkflow, readingTime, registerJexlHelpers, replace, resolveAdminAuthCollection, round, runCollectionHooks, saveWorkflowDraft, simplePublishingWorkflow, slugify, sqrt, startsWith, sum, today, transitionWorkflow, trim, truncate, unique, upper, validateAdminConditionExpression, validateDeclarativeAccessExpression, validateDeclarativeHookExpression, validatePreviewUrlExpression, when, wordCount, workflowCapabilities };
|