@dyrected/core 2.5.59 → 2.5.61
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-9hs8DRED.d.cts +1718 -0
- package/dist/app-config-9hs8DRED.d.ts +1718 -0
- package/dist/app-config-C0twGIaF.d.cts +1597 -0
- package/dist/app-config-C0twGIaF.d.ts +1597 -0
- package/dist/app-config-C0uxEU7Q.d.cts +1874 -0
- package/dist/app-config-C0uxEU7Q.d.ts +1874 -0
- package/dist/app-config-CBOn8IyZ.d.cts +1838 -0
- package/dist/app-config-CBOn8IyZ.d.ts +1838 -0
- package/dist/app-config-CstocO9M.d.cts +1580 -0
- package/dist/app-config-CstocO9M.d.ts +1580 -0
- package/dist/app-config-CwaU1de2.d.cts +1868 -0
- package/dist/app-config-CwaU1de2.d.ts +1868 -0
- package/dist/app-config-DIwvzbpe.d.cts +1555 -0
- package/dist/app-config-DIwvzbpe.d.ts +1555 -0
- package/dist/app-config-DVdSospO.d.cts +1842 -0
- package/dist/app-config-DVdSospO.d.ts +1842 -0
- package/dist/app-config-Dkndq5ni.d.cts +1580 -0
- package/dist/app-config-Dkndq5ni.d.ts +1580 -0
- package/dist/app-config-P-SF5nnR.d.cts +1568 -0
- package/dist/app-config-P-SF5nnR.d.ts +1568 -0
- package/dist/app-config-ouBRb6Bf.d.cts +1716 -0
- package/dist/app-config-ouBRb6Bf.d.ts +1716 -0
- package/dist/chunk-2WODKOUB.js +1627 -0
- package/dist/chunk-35NM2WPO.js +1658 -0
- package/dist/chunk-3CMG2BH2.js +1618 -0
- package/dist/chunk-CUOPCOU2.js +1644 -0
- package/dist/chunk-DCY7QHRB.js +1637 -0
- package/dist/chunk-EOW4YMAV.js +1637 -0
- package/dist/chunk-JFA22YFB.js +1625 -0
- package/dist/chunk-WF5A6PDJ.js +1618 -0
- package/dist/index.cjs +209 -47
- package/dist/index.d.cts +79 -4
- package/dist/index.d.ts +79 -4
- package/dist/index.js +42 -4
- package/dist/server.cjs +388 -56
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +224 -13
- 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, W as WorkflowConfig, a as AuthenticatedUser, b as WorkflowTransition, L as LifecycleEventName, c as LifecycleEvent, d as BaseDocument, H as HookRequestContext, e as ArrayField, f as BlocksField, g as BooleanField, h as DateField, i as DateTimeField, E as EmailField, G as GlobalConfig, I as IconField, j as ImageField, J as JoinField, k as JsonField, M as MultiSelectField, N as NumberField, O as ObjectField, R as RadioField, l as RelationshipField, m as RichTextField, n as RowField, S as SelectField, T as TextField, o as TextareaField, p as TimeField, U as UrlField } from './app-config-
|
|
2
|
-
export { q as AccessFunction, r as AccessFunctionArgs, s as AccessPolicyResolver, t as AccessResult, u as AccessRule, v as AdminAuthAccessResolution, w as AdminAuthClaimMapping, x as AdminAuthMember, y as AdminAuthProvider, z as AdminAuthProviderMembersConfig, K as AdminAuthProvisioningMode, Q as AdminAuthResolveAccessArgs, V as AdminAuthResolvedIdentity, X as AdminConfig, Y as AdminDashboardComponentSlots, Z as AdminIconName, _ as BaseAdminAuthProvider, $ as BaseFieldAdmin, a0 as BlockVariant, a1 as BooleanFieldAdmin, a2 as
|
|
1
|
+
import { F as Field, B as Block, D as DyrectedConfig, C as CollectionConfig, A as AdminAuthConfig, P as PublicAdminAuthConfig, W as WorkflowConfig, a as AuthenticatedUser, b as WorkflowTransition, L as LifecycleEventName, c as LifecycleEvent, d as BaseDocument, H as HookRequestContext, e as ArrayField, f as BlocksField, g as BooleanField, h as DateField, i as DateTimeField, E as EmailField, G as GlobalConfig, I as IconField, j as ImageField, J as JoinField, k as JsonField, M as MultiSelectField, N as NumberField, O as ObjectField, R as RadioField, l as RelationshipField, m as RichTextField, n as RowField, S as SelectField, T as TextField, o as TextareaField, p as TimeField, U as UrlField } from './app-config-C0uxEU7Q.cjs';
|
|
2
|
+
export { q as AccessFunction, r as AccessFunctionArgs, s as AccessPolicyResolver, t as AccessResult, u as AccessRule, v as AdminAuthAccessResolution, w as AdminAuthClaimMapping, x as AdminAuthMember, y as AdminAuthProvider, z as AdminAuthProviderMembersConfig, K as AdminAuthProvisioningMode, Q as AdminAuthResolveAccessArgs, V as AdminAuthResolvedIdentity, X as AdminConfig, Y as AdminDashboardComponentSlots, Z as AdminIconName, _ as BaseAdminAuthProvider, $ as BaseFieldAdmin, a0 as BlockVariant, a1 as BooleanFieldAdmin, a2 as BooleanFormat, a3 as CharacterLimitFieldAdmin, a4 as CharacterLimitFieldConfig, a5 as CollectionAfterChangeHook, a6 as CollectionAfterDeleteHook, a7 as CollectionAfterReadHook, a8 as CollectionAfterTransitionHook, a9 as CollectionBeforeChangeHook, aa as CollectionBeforeDeleteHook, ab as CollectionBeforeReadHook, ac as CollectionBeforeTransitionHook, ad as CollectionListComponentSlots, ae as CustomAdminAuthProvider, af as DatabaseAdapter, ag as DateFieldAdmin, ah as DateFormat, ai as DisplayTone, aj as DynamicOptionItem, ak as DynamicOptionsConfig, al as DynamicOptionsResolver, am as DynamicOptionsResolverArgs, an as EmailFieldAdmin, ao as FieldAdminHooks, ap as FieldAdminOnChangeHook, aq as FieldAdminOnChangeHookArgs, ar as FieldAdminOptionsHook, as as FieldAdminOptionsHookArgs, at as FieldAdminOptionsHookResult, au as FieldAfterReadHook, av as FieldAfterReadHookArgs, aw as FieldBase, ax as FieldBeforeChangeHook, ay as FieldBeforeChangeHookArgs, az as FieldHook, aA as FieldHooks, aB as FieldType, aC as FileData, aD as GlobalAfterChangeHook, aE as GlobalAfterReadHook, aF as GlobalBeforeChangeHook, aG as GlobalBeforeReadHook, aH as HeadingLevel, aI as HookFunction, aJ as IconFieldAdmin, aK as ImageService, aL as JsonFieldAdmin, aM as JsonFormat, aN as LIFECYCLE_EVENT_NAMES, aO as LifecycleEventHandler, aP as LinkFormat, aQ as MultiSelectFieldAdmin, aR as NamedAccessPolicy, aS as NumberFieldAdmin, aT as NumberFormat, aU as NumberLimitFieldAdmin, aV as NumberLimitFieldConfig, aW as OIDCAdminAuthProvider, aX as OptionFormat, aY as PaginatedResult, aZ as PublicAdminAuthProvider, a_ as RadioFieldAdmin, a$ as ReadonlyDatabaseAdapter, b0 as RichTextFeature, b1 as RichTextFieldConfig, b2 as SelectFieldAdmin, b3 as StorageAdapter, b4 as TextFieldAdmin, b5 as TextFormat, b6 as TextareaFieldAdmin, b7 as TypedField, b8 as UploadConfig, b9 as UrlFieldAdmin, ba as UrlLinkValue, bb as WordLimitFieldAdmin, bc as WordLimitFieldConfig, bd as WorkflowMetadata, be as WorkflowRole, bf as WorkflowState, bg as WorkflowTransitionContext } from './app-config-C0uxEU7Q.cjs';
|
|
3
3
|
import 'lucide-react';
|
|
4
4
|
|
|
5
5
|
type Prettify<T> = {
|
|
@@ -140,7 +140,13 @@ interface SqlWhereResult {
|
|
|
140
140
|
* MySQL: (f) => `JSON_UNQUOTE(JSON_EXTRACT(data, '$.${f}'))`
|
|
141
141
|
* @param placeholder '?' for SQLite/MySQL, 'pg' for auto-incrementing Postgres $1/$2/…
|
|
142
142
|
*/
|
|
143
|
-
declare function parseSqlWhere(where: WhereClause, getJsonField: (field: string) => string, placeholder?: '?' | 'pg'
|
|
143
|
+
declare function parseSqlWhere(where: WhereClause, getJsonField: (field: string) => string, placeholder?: '?' | 'pg',
|
|
144
|
+
/**
|
|
145
|
+
* SQL keyword used for `contains`/`starts_with`. Postgres `LIKE` is
|
|
146
|
+
* case-sensitive, so the Postgres adapter passes `'ILIKE'` to keep substring
|
|
147
|
+
* matching case-insensitive like SQLite and MySQL.
|
|
148
|
+
*/
|
|
149
|
+
likeOperator?: 'LIKE' | 'ILIKE'): SqlWhereResult;
|
|
144
150
|
/**
|
|
145
151
|
* Translates a WhereClause into a MongoDB filter object.
|
|
146
152
|
* Handles nested OR/AND via $or/$and, and all operators via $eq/$in/$gt etc.
|
|
@@ -153,6 +159,41 @@ interface SortClause {
|
|
|
153
159
|
direction: SortDirection;
|
|
154
160
|
}
|
|
155
161
|
declare function parseSort(sort: string | undefined, fallback?: SortClause): SortClause[];
|
|
162
|
+
/**
|
|
163
|
+
* Collects the names of top-level fields declared as numbers. SQL adapters use
|
|
164
|
+
* this to decide which JSON-extracted sort fields need a numeric cast.
|
|
165
|
+
*/
|
|
166
|
+
declare function numericFieldNames(fields?: Field[]): Set<string>;
|
|
167
|
+
/**
|
|
168
|
+
* Dialect hooks for turning a parsed sort into a SQL `ORDER BY` body.
|
|
169
|
+
* Each SQL adapter supplies its own quoting, JSON extraction, and numeric cast.
|
|
170
|
+
*/
|
|
171
|
+
interface SqlSortDialect {
|
|
172
|
+
/** Quote a real column identifier (e.g. `"created_at"` or \`created_at\`). */
|
|
173
|
+
quoteIdent: (identifier: string) => string;
|
|
174
|
+
/** SQL expression that reads a top-level field out of the JSON `data` column. */
|
|
175
|
+
jsonExtract: (field: string) => string;
|
|
176
|
+
/**
|
|
177
|
+
* Wrap a JSON-extracted expression so it sorts numerically instead of
|
|
178
|
+
* lexicographically. Adapters whose JSON extraction already preserves number
|
|
179
|
+
* types (SQLite) can return the expression unchanged.
|
|
180
|
+
*/
|
|
181
|
+
castNumeric: (expr: string) => string;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Builds the `ORDER BY` body shared by the SQL adapters.
|
|
185
|
+
*
|
|
186
|
+
* Real (promoted) columns and the `created_at`/`updated_at` timestamps are
|
|
187
|
+
* ordered by their typed column directly. Everything else is read out of the
|
|
188
|
+
* JSON `data` column — and when a field is declared as a `number`, its extracted
|
|
189
|
+
* value is cast so it orders by magnitude rather than as text ("9" < "10").
|
|
190
|
+
*
|
|
191
|
+
* @param sort The raw sort string (e.g. `"-createdAt"`, `"priority,-views"`).
|
|
192
|
+
* @param existingColumns Real column names present on the table.
|
|
193
|
+
* @param numericFields Names of top-level fields declared with `type: 'number'`.
|
|
194
|
+
* @param dialect Adapter-specific quoting, extraction, and numeric cast.
|
|
195
|
+
*/
|
|
196
|
+
declare function buildSqlOrderBy(sort: string | undefined, existingColumns: string[], numericFields: Set<string>, dialect: SqlSortDialect): string;
|
|
156
197
|
|
|
157
198
|
type AnyHookFn = (args: any) => any;
|
|
158
199
|
/**
|
|
@@ -201,6 +242,7 @@ declare function generateOpenApi(config: DyrectedConfig): any;
|
|
|
201
242
|
declare const WORKFLOW_HISTORY_COLLECTION = "__workflow_history";
|
|
202
243
|
declare const LIFECYCLE_EVENTS_COLLECTION = "__lifecycle_events";
|
|
203
244
|
declare function publishingWorkflow(): WorkflowConfig;
|
|
245
|
+
declare function simplePublishingWorkflow(): WorkflowConfig;
|
|
204
246
|
declare function workflowCapabilities(workflow: WorkflowConfig, user?: AuthenticatedUser): Set<string>;
|
|
205
247
|
declare function canViewWorkflowDraft(workflow: WorkflowConfig, user?: AuthenticatedUser): boolean;
|
|
206
248
|
declare function availableWorkflowTransitions(workflow: WorkflowConfig, state: string, user?: AuthenticatedUser): WorkflowTransition[];
|
|
@@ -463,5 +505,38 @@ declare const defineJoinField: <const T extends Omit<JoinField, "type">>(field:
|
|
|
463
505
|
declare const defineRowField: <const T extends Omit<RowField, "type">>(field: T) => T & {
|
|
464
506
|
type: "row";
|
|
465
507
|
};
|
|
508
|
+
/**
|
|
509
|
+
* Group fields under a named tab in the Admin edit form. Tabs are presentational
|
|
510
|
+
* only: `defineTab` returns the given fields unchanged except that each one's
|
|
511
|
+
* `admin.tab` is set to `label`, and the Admin panel renders fields that share a
|
|
512
|
+
* tab name together under that tab. Spread the result into a collection, global,
|
|
513
|
+
* or group `fields` array, and add one `defineTab` call per tab. Fields left
|
|
514
|
+
* without a tab are collected into a leading tab named after the collection.
|
|
515
|
+
*
|
|
516
|
+
* ```ts
|
|
517
|
+
* defineCollection({
|
|
518
|
+
* slug: 'pages',
|
|
519
|
+
* fields: [
|
|
520
|
+
* ...defineTab({
|
|
521
|
+
* label: 'Content',
|
|
522
|
+
* fields: [
|
|
523
|
+
* defineTextField({ name: 'title', required: true }),
|
|
524
|
+
* defineRichTextField({ name: 'body' }),
|
|
525
|
+
* ],
|
|
526
|
+
* }),
|
|
527
|
+
* ...defineTab({
|
|
528
|
+
* label: 'SEO',
|
|
529
|
+
* fields: [defineTextField({ name: 'metaTitle' })],
|
|
530
|
+
* }),
|
|
531
|
+
* ],
|
|
532
|
+
* })
|
|
533
|
+
* ```
|
|
534
|
+
*/
|
|
535
|
+
declare function defineTab<const T extends readonly Field[]>(args: {
|
|
536
|
+
/** Tab name shown in the Admin edit form's tab bar. */
|
|
537
|
+
label: string;
|
|
538
|
+
/** Fields to place under this tab; each field's `admin.tab` is set to `label`. */
|
|
539
|
+
fields: T;
|
|
540
|
+
}): T;
|
|
466
541
|
|
|
467
|
-
export { AdminAuthConfig, ArrayField, type AuthDocFields, AuthenticatedUser, BaseDocument, Block, BlocksField, BooleanField, CollectionConfig, DateField, DateTimeField, DyrectedConfig, EmailField, Field, GlobalConfig, HookRequestContext, IconField, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MultiSelectField, NumberField, ObjectField, type Prettify, PublicAdminAuthConfig, RadioField, RelationshipField, RichTextField, RowField, SelectField, type SortClause, type SortDirection, type SqlWhereResult, type SystemDocFields, TextField, TextareaField, TimeField, type UploadDocFields, UrlField, WORKFLOW_HISTORY_COLLECTION, type WhereClause, type WhereOperator, type WhereOperatorName, WorkflowConfig, WorkflowTransition, availableWorkflowTransitions, canViewWorkflowDraft, createLifecycleEvent, createWorkflowDocument, defineArrayField, defineBlock, defineBlocksField, defineBooleanField, defineCollection, defineConfig, defineDateField, defineDateTimeField, defineEmailField, defineField, defineGlobal, defineIconField, defineImageField, defineJoinField, defineJsonField, defineMultiSelectField, defineNumberField, defineObjectField, defineRadioField, defineRelationshipField, defineRichTextField, defineRowField, defineSelectField, defineTextField, defineTextareaField, defineTimeField, defineUrlField, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, executeFieldAfterRead, executeFieldBeforeChange, generateOpenApi, getAdminAuthCollection, getPublicAdminAuthConfig, initializeWorkflowDocument, materializeWorkflowDocument, normalizeConfig, parseMongoWhere, parseSort, parseSqlWhere, publishingWorkflow, resolveAdminAuthCollection, runCollectionHooks, saveWorkflowDraft, transitionWorkflow, workflowCapabilities };
|
|
542
|
+
export { AdminAuthConfig, ArrayField, type AuthDocFields, AuthenticatedUser, BaseDocument, Block, BlocksField, BooleanField, CollectionConfig, DateField, DateTimeField, DyrectedConfig, EmailField, Field, GlobalConfig, HookRequestContext, IconField, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MultiSelectField, NumberField, ObjectField, type Prettify, PublicAdminAuthConfig, RadioField, RelationshipField, RichTextField, RowField, SelectField, type SortClause, type SortDirection, type SqlSortDialect, type SqlWhereResult, type SystemDocFields, TextField, TextareaField, TimeField, type UploadDocFields, UrlField, WORKFLOW_HISTORY_COLLECTION, type WhereClause, type WhereOperator, type WhereOperatorName, WorkflowConfig, WorkflowTransition, availableWorkflowTransitions, buildSqlOrderBy, canViewWorkflowDraft, createLifecycleEvent, createWorkflowDocument, defineArrayField, defineBlock, defineBlocksField, defineBooleanField, defineCollection, defineConfig, defineDateField, defineDateTimeField, defineEmailField, defineField, defineGlobal, defineIconField, defineImageField, defineJoinField, defineJsonField, defineMultiSelectField, defineNumberField, defineObjectField, defineRadioField, defineRelationshipField, defineRichTextField, defineRowField, defineSelectField, defineTab, defineTextField, defineTextareaField, defineTimeField, defineUrlField, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, executeFieldAfterRead, executeFieldBeforeChange, generateOpenApi, getAdminAuthCollection, getPublicAdminAuthConfig, initializeWorkflowDocument, materializeWorkflowDocument, normalizeConfig, numericFieldNames, parseMongoWhere, parseSort, parseSqlWhere, publishingWorkflow, resolveAdminAuthCollection, runCollectionHooks, saveWorkflowDraft, simplePublishingWorkflow, transitionWorkflow, workflowCapabilities };
|
package/dist/index.d.ts
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, W as WorkflowConfig, a as AuthenticatedUser, b as WorkflowTransition, L as LifecycleEventName, c as LifecycleEvent, d as BaseDocument, H as HookRequestContext, e as ArrayField, f as BlocksField, g as BooleanField, h as DateField, i as DateTimeField, E as EmailField, G as GlobalConfig, I as IconField, j as ImageField, J as JoinField, k as JsonField, M as MultiSelectField, N as NumberField, O as ObjectField, R as RadioField, l as RelationshipField, m as RichTextField, n as RowField, S as SelectField, T as TextField, o as TextareaField, p as TimeField, U as UrlField } from './app-config-
|
|
2
|
-
export { q as AccessFunction, r as AccessFunctionArgs, s as AccessPolicyResolver, t as AccessResult, u as AccessRule, v as AdminAuthAccessResolution, w as AdminAuthClaimMapping, x as AdminAuthMember, y as AdminAuthProvider, z as AdminAuthProviderMembersConfig, K as AdminAuthProvisioningMode, Q as AdminAuthResolveAccessArgs, V as AdminAuthResolvedIdentity, X as AdminConfig, Y as AdminDashboardComponentSlots, Z as AdminIconName, _ as BaseAdminAuthProvider, $ as BaseFieldAdmin, a0 as BlockVariant, a1 as BooleanFieldAdmin, a2 as
|
|
1
|
+
import { F as Field, B as Block, D as DyrectedConfig, C as CollectionConfig, A as AdminAuthConfig, P as PublicAdminAuthConfig, W as WorkflowConfig, a as AuthenticatedUser, b as WorkflowTransition, L as LifecycleEventName, c as LifecycleEvent, d as BaseDocument, H as HookRequestContext, e as ArrayField, f as BlocksField, g as BooleanField, h as DateField, i as DateTimeField, E as EmailField, G as GlobalConfig, I as IconField, j as ImageField, J as JoinField, k as JsonField, M as MultiSelectField, N as NumberField, O as ObjectField, R as RadioField, l as RelationshipField, m as RichTextField, n as RowField, S as SelectField, T as TextField, o as TextareaField, p as TimeField, U as UrlField } from './app-config-C0uxEU7Q.js';
|
|
2
|
+
export { q as AccessFunction, r as AccessFunctionArgs, s as AccessPolicyResolver, t as AccessResult, u as AccessRule, v as AdminAuthAccessResolution, w as AdminAuthClaimMapping, x as AdminAuthMember, y as AdminAuthProvider, z as AdminAuthProviderMembersConfig, K as AdminAuthProvisioningMode, Q as AdminAuthResolveAccessArgs, V as AdminAuthResolvedIdentity, X as AdminConfig, Y as AdminDashboardComponentSlots, Z as AdminIconName, _ as BaseAdminAuthProvider, $ as BaseFieldAdmin, a0 as BlockVariant, a1 as BooleanFieldAdmin, a2 as BooleanFormat, a3 as CharacterLimitFieldAdmin, a4 as CharacterLimitFieldConfig, a5 as CollectionAfterChangeHook, a6 as CollectionAfterDeleteHook, a7 as CollectionAfterReadHook, a8 as CollectionAfterTransitionHook, a9 as CollectionBeforeChangeHook, aa as CollectionBeforeDeleteHook, ab as CollectionBeforeReadHook, ac as CollectionBeforeTransitionHook, ad as CollectionListComponentSlots, ae as CustomAdminAuthProvider, af as DatabaseAdapter, ag as DateFieldAdmin, ah as DateFormat, ai as DisplayTone, aj as DynamicOptionItem, ak as DynamicOptionsConfig, al as DynamicOptionsResolver, am as DynamicOptionsResolverArgs, an as EmailFieldAdmin, ao as FieldAdminHooks, ap as FieldAdminOnChangeHook, aq as FieldAdminOnChangeHookArgs, ar as FieldAdminOptionsHook, as as FieldAdminOptionsHookArgs, at as FieldAdminOptionsHookResult, au as FieldAfterReadHook, av as FieldAfterReadHookArgs, aw as FieldBase, ax as FieldBeforeChangeHook, ay as FieldBeforeChangeHookArgs, az as FieldHook, aA as FieldHooks, aB as FieldType, aC as FileData, aD as GlobalAfterChangeHook, aE as GlobalAfterReadHook, aF as GlobalBeforeChangeHook, aG as GlobalBeforeReadHook, aH as HeadingLevel, aI as HookFunction, aJ as IconFieldAdmin, aK as ImageService, aL as JsonFieldAdmin, aM as JsonFormat, aN as LIFECYCLE_EVENT_NAMES, aO as LifecycleEventHandler, aP as LinkFormat, aQ as MultiSelectFieldAdmin, aR as NamedAccessPolicy, aS as NumberFieldAdmin, aT as NumberFormat, aU as NumberLimitFieldAdmin, aV as NumberLimitFieldConfig, aW as OIDCAdminAuthProvider, aX as OptionFormat, aY as PaginatedResult, aZ as PublicAdminAuthProvider, a_ as RadioFieldAdmin, a$ as ReadonlyDatabaseAdapter, b0 as RichTextFeature, b1 as RichTextFieldConfig, b2 as SelectFieldAdmin, b3 as StorageAdapter, b4 as TextFieldAdmin, b5 as TextFormat, b6 as TextareaFieldAdmin, b7 as TypedField, b8 as UploadConfig, b9 as UrlFieldAdmin, ba as UrlLinkValue, bb as WordLimitFieldAdmin, bc as WordLimitFieldConfig, bd as WorkflowMetadata, be as WorkflowRole, bf as WorkflowState, bg as WorkflowTransitionContext } from './app-config-C0uxEU7Q.js';
|
|
3
3
|
import 'lucide-react';
|
|
4
4
|
|
|
5
5
|
type Prettify<T> = {
|
|
@@ -140,7 +140,13 @@ interface SqlWhereResult {
|
|
|
140
140
|
* MySQL: (f) => `JSON_UNQUOTE(JSON_EXTRACT(data, '$.${f}'))`
|
|
141
141
|
* @param placeholder '?' for SQLite/MySQL, 'pg' for auto-incrementing Postgres $1/$2/…
|
|
142
142
|
*/
|
|
143
|
-
declare function parseSqlWhere(where: WhereClause, getJsonField: (field: string) => string, placeholder?: '?' | 'pg'
|
|
143
|
+
declare function parseSqlWhere(where: WhereClause, getJsonField: (field: string) => string, placeholder?: '?' | 'pg',
|
|
144
|
+
/**
|
|
145
|
+
* SQL keyword used for `contains`/`starts_with`. Postgres `LIKE` is
|
|
146
|
+
* case-sensitive, so the Postgres adapter passes `'ILIKE'` to keep substring
|
|
147
|
+
* matching case-insensitive like SQLite and MySQL.
|
|
148
|
+
*/
|
|
149
|
+
likeOperator?: 'LIKE' | 'ILIKE'): SqlWhereResult;
|
|
144
150
|
/**
|
|
145
151
|
* Translates a WhereClause into a MongoDB filter object.
|
|
146
152
|
* Handles nested OR/AND via $or/$and, and all operators via $eq/$in/$gt etc.
|
|
@@ -153,6 +159,41 @@ interface SortClause {
|
|
|
153
159
|
direction: SortDirection;
|
|
154
160
|
}
|
|
155
161
|
declare function parseSort(sort: string | undefined, fallback?: SortClause): SortClause[];
|
|
162
|
+
/**
|
|
163
|
+
* Collects the names of top-level fields declared as numbers. SQL adapters use
|
|
164
|
+
* this to decide which JSON-extracted sort fields need a numeric cast.
|
|
165
|
+
*/
|
|
166
|
+
declare function numericFieldNames(fields?: Field[]): Set<string>;
|
|
167
|
+
/**
|
|
168
|
+
* Dialect hooks for turning a parsed sort into a SQL `ORDER BY` body.
|
|
169
|
+
* Each SQL adapter supplies its own quoting, JSON extraction, and numeric cast.
|
|
170
|
+
*/
|
|
171
|
+
interface SqlSortDialect {
|
|
172
|
+
/** Quote a real column identifier (e.g. `"created_at"` or \`created_at\`). */
|
|
173
|
+
quoteIdent: (identifier: string) => string;
|
|
174
|
+
/** SQL expression that reads a top-level field out of the JSON `data` column. */
|
|
175
|
+
jsonExtract: (field: string) => string;
|
|
176
|
+
/**
|
|
177
|
+
* Wrap a JSON-extracted expression so it sorts numerically instead of
|
|
178
|
+
* lexicographically. Adapters whose JSON extraction already preserves number
|
|
179
|
+
* types (SQLite) can return the expression unchanged.
|
|
180
|
+
*/
|
|
181
|
+
castNumeric: (expr: string) => string;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Builds the `ORDER BY` body shared by the SQL adapters.
|
|
185
|
+
*
|
|
186
|
+
* Real (promoted) columns and the `created_at`/`updated_at` timestamps are
|
|
187
|
+
* ordered by their typed column directly. Everything else is read out of the
|
|
188
|
+
* JSON `data` column — and when a field is declared as a `number`, its extracted
|
|
189
|
+
* value is cast so it orders by magnitude rather than as text ("9" < "10").
|
|
190
|
+
*
|
|
191
|
+
* @param sort The raw sort string (e.g. `"-createdAt"`, `"priority,-views"`).
|
|
192
|
+
* @param existingColumns Real column names present on the table.
|
|
193
|
+
* @param numericFields Names of top-level fields declared with `type: 'number'`.
|
|
194
|
+
* @param dialect Adapter-specific quoting, extraction, and numeric cast.
|
|
195
|
+
*/
|
|
196
|
+
declare function buildSqlOrderBy(sort: string | undefined, existingColumns: string[], numericFields: Set<string>, dialect: SqlSortDialect): string;
|
|
156
197
|
|
|
157
198
|
type AnyHookFn = (args: any) => any;
|
|
158
199
|
/**
|
|
@@ -201,6 +242,7 @@ declare function generateOpenApi(config: DyrectedConfig): any;
|
|
|
201
242
|
declare const WORKFLOW_HISTORY_COLLECTION = "__workflow_history";
|
|
202
243
|
declare const LIFECYCLE_EVENTS_COLLECTION = "__lifecycle_events";
|
|
203
244
|
declare function publishingWorkflow(): WorkflowConfig;
|
|
245
|
+
declare function simplePublishingWorkflow(): WorkflowConfig;
|
|
204
246
|
declare function workflowCapabilities(workflow: WorkflowConfig, user?: AuthenticatedUser): Set<string>;
|
|
205
247
|
declare function canViewWorkflowDraft(workflow: WorkflowConfig, user?: AuthenticatedUser): boolean;
|
|
206
248
|
declare function availableWorkflowTransitions(workflow: WorkflowConfig, state: string, user?: AuthenticatedUser): WorkflowTransition[];
|
|
@@ -463,5 +505,38 @@ declare const defineJoinField: <const T extends Omit<JoinField, "type">>(field:
|
|
|
463
505
|
declare const defineRowField: <const T extends Omit<RowField, "type">>(field: T) => T & {
|
|
464
506
|
type: "row";
|
|
465
507
|
};
|
|
508
|
+
/**
|
|
509
|
+
* Group fields under a named tab in the Admin edit form. Tabs are presentational
|
|
510
|
+
* only: `defineTab` returns the given fields unchanged except that each one's
|
|
511
|
+
* `admin.tab` is set to `label`, and the Admin panel renders fields that share a
|
|
512
|
+
* tab name together under that tab. Spread the result into a collection, global,
|
|
513
|
+
* or group `fields` array, and add one `defineTab` call per tab. Fields left
|
|
514
|
+
* without a tab are collected into a leading tab named after the collection.
|
|
515
|
+
*
|
|
516
|
+
* ```ts
|
|
517
|
+
* defineCollection({
|
|
518
|
+
* slug: 'pages',
|
|
519
|
+
* fields: [
|
|
520
|
+
* ...defineTab({
|
|
521
|
+
* label: 'Content',
|
|
522
|
+
* fields: [
|
|
523
|
+
* defineTextField({ name: 'title', required: true }),
|
|
524
|
+
* defineRichTextField({ name: 'body' }),
|
|
525
|
+
* ],
|
|
526
|
+
* }),
|
|
527
|
+
* ...defineTab({
|
|
528
|
+
* label: 'SEO',
|
|
529
|
+
* fields: [defineTextField({ name: 'metaTitle' })],
|
|
530
|
+
* }),
|
|
531
|
+
* ],
|
|
532
|
+
* })
|
|
533
|
+
* ```
|
|
534
|
+
*/
|
|
535
|
+
declare function defineTab<const T extends readonly Field[]>(args: {
|
|
536
|
+
/** Tab name shown in the Admin edit form's tab bar. */
|
|
537
|
+
label: string;
|
|
538
|
+
/** Fields to place under this tab; each field's `admin.tab` is set to `label`. */
|
|
539
|
+
fields: T;
|
|
540
|
+
}): T;
|
|
466
541
|
|
|
467
|
-
export { AdminAuthConfig, ArrayField, type AuthDocFields, AuthenticatedUser, BaseDocument, Block, BlocksField, BooleanField, CollectionConfig, DateField, DateTimeField, DyrectedConfig, EmailField, Field, GlobalConfig, HookRequestContext, IconField, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MultiSelectField, NumberField, ObjectField, type Prettify, PublicAdminAuthConfig, RadioField, RelationshipField, RichTextField, RowField, SelectField, type SortClause, type SortDirection, type SqlWhereResult, type SystemDocFields, TextField, TextareaField, TimeField, type UploadDocFields, UrlField, WORKFLOW_HISTORY_COLLECTION, type WhereClause, type WhereOperator, type WhereOperatorName, WorkflowConfig, WorkflowTransition, availableWorkflowTransitions, canViewWorkflowDraft, createLifecycleEvent, createWorkflowDocument, defineArrayField, defineBlock, defineBlocksField, defineBooleanField, defineCollection, defineConfig, defineDateField, defineDateTimeField, defineEmailField, defineField, defineGlobal, defineIconField, defineImageField, defineJoinField, defineJsonField, defineMultiSelectField, defineNumberField, defineObjectField, defineRadioField, defineRelationshipField, defineRichTextField, defineRowField, defineSelectField, defineTextField, defineTextareaField, defineTimeField, defineUrlField, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, executeFieldAfterRead, executeFieldBeforeChange, generateOpenApi, getAdminAuthCollection, getPublicAdminAuthConfig, initializeWorkflowDocument, materializeWorkflowDocument, normalizeConfig, parseMongoWhere, parseSort, parseSqlWhere, publishingWorkflow, resolveAdminAuthCollection, runCollectionHooks, saveWorkflowDraft, transitionWorkflow, workflowCapabilities };
|
|
542
|
+
export { AdminAuthConfig, ArrayField, type AuthDocFields, AuthenticatedUser, BaseDocument, Block, BlocksField, BooleanField, CollectionConfig, DateField, DateTimeField, DyrectedConfig, EmailField, Field, GlobalConfig, HookRequestContext, IconField, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MultiSelectField, NumberField, ObjectField, type Prettify, PublicAdminAuthConfig, RadioField, RelationshipField, RichTextField, RowField, SelectField, type SortClause, type SortDirection, type SqlSortDialect, type SqlWhereResult, type SystemDocFields, TextField, TextareaField, TimeField, type UploadDocFields, UrlField, WORKFLOW_HISTORY_COLLECTION, type WhereClause, type WhereOperator, type WhereOperatorName, WorkflowConfig, WorkflowTransition, availableWorkflowTransitions, buildSqlOrderBy, canViewWorkflowDraft, createLifecycleEvent, createWorkflowDocument, defineArrayField, defineBlock, defineBlocksField, defineBooleanField, defineCollection, defineConfig, defineDateField, defineDateTimeField, defineEmailField, defineField, defineGlobal, defineIconField, defineImageField, defineJoinField, defineJsonField, defineMultiSelectField, defineNumberField, defineObjectField, defineRadioField, defineRelationshipField, defineRichTextField, defineRowField, defineSelectField, defineTab, defineTextField, defineTextareaField, defineTimeField, defineUrlField, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, executeFieldAfterRead, executeFieldBeforeChange, generateOpenApi, getAdminAuthCollection, getPublicAdminAuthConfig, initializeWorkflowDocument, materializeWorkflowDocument, normalizeConfig, numericFieldNames, parseMongoWhere, parseSort, parseSqlWhere, publishingWorkflow, resolveAdminAuthCollection, runCollectionHooks, saveWorkflowDraft, simplePublishingWorkflow, transitionWorkflow, workflowCapabilities };
|
package/dist/index.js
CHANGED
|
@@ -19,9 +19,10 @@ import {
|
|
|
19
19
|
resolveAdminAuthCollection,
|
|
20
20
|
runCollectionHooks,
|
|
21
21
|
saveWorkflowDraft,
|
|
22
|
+
simplePublishingWorkflow,
|
|
22
23
|
transitionWorkflow,
|
|
23
24
|
workflowCapabilities
|
|
24
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-35NM2WPO.js";
|
|
25
26
|
|
|
26
27
|
// src/types/workflows.ts
|
|
27
28
|
var LIFECYCLE_EVENT_NAMES = [
|
|
@@ -35,7 +36,7 @@ var LIFECYCLE_EVENT_NAMES = [
|
|
|
35
36
|
function assertNever(op, context) {
|
|
36
37
|
throw new Error(`[dyrected/core] Unhandled where operator "${op}" in ${context}`);
|
|
37
38
|
}
|
|
38
|
-
function parseSqlWhere(where, getJsonField, placeholder = "?") {
|
|
39
|
+
function parseSqlWhere(where, getJsonField, placeholder = "?", likeOperator = "LIKE") {
|
|
39
40
|
const params = [];
|
|
40
41
|
let pgIndex = 1;
|
|
41
42
|
function next() {
|
|
@@ -97,10 +98,10 @@ function parseSqlWhere(where, getJsonField, placeholder = "?") {
|
|
|
97
98
|
return `${c} <= ${next()}`;
|
|
98
99
|
case "contains":
|
|
99
100
|
params.push(`%${operand}%`);
|
|
100
|
-
return `${c}
|
|
101
|
+
return `${c} ${likeOperator} ${next()}`;
|
|
101
102
|
case "starts_with":
|
|
102
103
|
params.push(`${operand}%`);
|
|
103
|
-
return `${c}
|
|
104
|
+
return `${c} ${likeOperator} ${next()}`;
|
|
104
105
|
case "exists":
|
|
105
106
|
return operand ? `${c} IS NOT NULL` : `${c} IS NULL`;
|
|
106
107
|
default:
|
|
@@ -205,6 +206,33 @@ function parseSort(sort, fallback = { field: "createdAt", direction: "DESC" }) {
|
|
|
205
206
|
}).filter((clause) => Boolean(clause));
|
|
206
207
|
return clauses.length > 0 ? clauses : [fallback];
|
|
207
208
|
}
|
|
209
|
+
function numericFieldNames(fields) {
|
|
210
|
+
const names = /* @__PURE__ */ new Set();
|
|
211
|
+
for (const field of fields ?? []) {
|
|
212
|
+
if (field.type === "number" && "name" in field && field.name) {
|
|
213
|
+
names.add(field.name);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return names;
|
|
217
|
+
}
|
|
218
|
+
var TIMESTAMP_COLUMNS = {
|
|
219
|
+
createdat: "created_at",
|
|
220
|
+
created_at: "created_at",
|
|
221
|
+
updatedat: "updated_at",
|
|
222
|
+
updated_at: "updated_at"
|
|
223
|
+
};
|
|
224
|
+
function buildSqlOrderBy(sort, existingColumns, numericFields, dialect) {
|
|
225
|
+
return parseSort(sort).map(({ field, direction }) => {
|
|
226
|
+
const timestamp = TIMESTAMP_COLUMNS[field.toLowerCase()];
|
|
227
|
+
if (timestamp) return `${dialect.quoteIdent(timestamp)} ${direction}`;
|
|
228
|
+
if (existingColumns.includes(field) && field !== "id" && field !== "data") {
|
|
229
|
+
return `${dialect.quoteIdent(field)} ${direction}`;
|
|
230
|
+
}
|
|
231
|
+
const extracted = dialect.jsonExtract(field);
|
|
232
|
+
const expr = numericFields.has(field) ? dialect.castNumeric(extracted) : extracted;
|
|
233
|
+
return `${expr} ${direction}`;
|
|
234
|
+
}).join(", ");
|
|
235
|
+
}
|
|
208
236
|
|
|
209
237
|
// src/index.ts
|
|
210
238
|
function defineCollection(config) {
|
|
@@ -247,11 +275,18 @@ var defineUrlField = createFieldDefiner("url");
|
|
|
247
275
|
var defineIconField = createFieldDefiner("icon");
|
|
248
276
|
var defineJoinField = createFieldDefiner("join");
|
|
249
277
|
var defineRowField = createFieldDefiner("row");
|
|
278
|
+
function defineTab(args) {
|
|
279
|
+
return args.fields.map((field) => ({
|
|
280
|
+
...field,
|
|
281
|
+
admin: { ...field.admin ?? {}, tab: args.label }
|
|
282
|
+
}));
|
|
283
|
+
}
|
|
250
284
|
export {
|
|
251
285
|
LIFECYCLE_EVENTS_COLLECTION,
|
|
252
286
|
LIFECYCLE_EVENT_NAMES,
|
|
253
287
|
WORKFLOW_HISTORY_COLLECTION,
|
|
254
288
|
availableWorkflowTransitions,
|
|
289
|
+
buildSqlOrderBy,
|
|
255
290
|
canViewWorkflowDraft,
|
|
256
291
|
createLifecycleEvent,
|
|
257
292
|
createWorkflowDocument,
|
|
@@ -278,6 +313,7 @@ export {
|
|
|
278
313
|
defineRichTextField,
|
|
279
314
|
defineRowField,
|
|
280
315
|
defineSelectField,
|
|
316
|
+
defineTab,
|
|
281
317
|
defineTextField,
|
|
282
318
|
defineTextareaField,
|
|
283
319
|
defineTimeField,
|
|
@@ -292,6 +328,7 @@ export {
|
|
|
292
328
|
initializeWorkflowDocument,
|
|
293
329
|
materializeWorkflowDocument,
|
|
294
330
|
normalizeConfig,
|
|
331
|
+
numericFieldNames,
|
|
295
332
|
parseMongoWhere,
|
|
296
333
|
parseSort,
|
|
297
334
|
parseSqlWhere,
|
|
@@ -299,6 +336,7 @@ export {
|
|
|
299
336
|
resolveAdminAuthCollection,
|
|
300
337
|
runCollectionHooks,
|
|
301
338
|
saveWorkflowDraft,
|
|
339
|
+
simplePublishingWorkflow,
|
|
302
340
|
transitionWorkflow,
|
|
303
341
|
workflowCapabilities
|
|
304
342
|
};
|