@dyrected/core 2.5.60 → 2.5.62
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-BcuZIpvL.d.cts +1951 -0
- package/dist/app-config-BcuZIpvL.d.ts +1951 -0
- package/dist/app-config-Bm9-2Am6.d.cts +1875 -0
- package/dist/app-config-Bm9-2Am6.d.ts +1875 -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-CJAGGPrk.d.cts +1900 -0
- package/dist/app-config-CJAGGPrk.d.ts +1900 -0
- package/dist/app-config-CiEDJm0e.d.cts +1912 -0
- package/dist/app-config-CiEDJm0e.d.ts +1912 -0
- package/dist/app-config-CwaU1de2.d.cts +1868 -0
- package/dist/app-config-CwaU1de2.d.ts +1868 -0
- package/dist/app-config-DCDh8Gbx.d.cts +1926 -0
- package/dist/app-config-DCDh8Gbx.d.ts +1926 -0
- package/dist/app-config-DVdSospO.d.cts +1842 -0
- package/dist/app-config-DVdSospO.d.ts +1842 -0
- package/dist/app-config-Dv5XACR4.d.cts +2065 -0
- package/dist/app-config-Dv5XACR4.d.ts +2065 -0
- package/dist/app-config-_kkj71CB.d.cts +2010 -0
- package/dist/app-config-_kkj71CB.d.ts +2010 -0
- package/dist/app-config-ouBRb6Bf.d.cts +1716 -0
- package/dist/app-config-ouBRb6Bf.d.ts +1716 -0
- package/dist/app-config-tITj_0sn.d.cts +1926 -0
- package/dist/app-config-tITj_0sn.d.ts +1926 -0
- package/dist/chunk-35NM2WPO.js +1658 -0
- package/dist/chunk-57FNM42D.js +2392 -0
- package/dist/chunk-BAMX7YUC.js +1815 -0
- package/dist/chunk-BQV3QW3Y.js +2588 -0
- package/dist/chunk-CUOPCOU2.js +1644 -0
- package/dist/chunk-EH3MJGB5.js +2571 -0
- package/dist/chunk-M3HKRN7E.js +1665 -0
- package/dist/chunk-MQZH7RQC.js +1667 -0
- package/dist/chunk-VCYYBN5J.js +1873 -0
- package/dist/chunk-WVD7PORQ.js +1672 -0
- package/dist/chunk-XZLIBQSO.js +2397 -0
- package/dist/index.cjs +404 -44
- package/dist/index.d.cts +77 -5
- package/dist/index.d.ts +77 -5
- package/dist/index.js +37 -4
- package/dist/server.cjs +2973 -708
- package/dist/server.d.cts +124 -12
- package/dist/server.d.ts +124 -12
- package/dist/server.js +2066 -695
- package/package.json +10 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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
|
|
2
|
-
export {
|
|
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 AuthConfig, i as DateField, j as DateTimeField, E as EmailField, G as GlobalConfig, I as IconField, k as ImageField, J as JoinField, l as JsonField, M as MultiSelectField, N as NumberField, O as ObjectField, R as RadioField, m as RelationshipField, n as RichTextField, o as RowField, S as SelectField, T as TextField, p as TextareaField, q as TimeField, U as UrlField } from './app-config-Dv5XACR4.cjs';
|
|
2
|
+
export { r as AccessFunction, s as AccessFunctionArgs, t as AccessPolicyResolver, u as AccessResult, v as AccessRule, w as AdminAuthAccessResolution, x as AdminAuthClaimMapping, y as AdminAuthMember, z as AdminAuthProvider, K as AdminAuthProviderMembersConfig, Q as AdminAuthProvisioningMode, V as AdminAuthResolveAccessArgs, X as AdminAuthResolvedIdentity, Y as AdminConfig, Z as AdminDashboardComponentSlots, _ as AdminIconName, $ as BaseAdminAuthProvider, a0 as BaseFieldAdmin, a1 as BlockVariant, a2 as BooleanFieldAdmin, a3 as BooleanFormat, a4 as CharacterLimitFieldAdmin, a5 as CharacterLimitFieldConfig, a6 as CollectionAfterChangeHook, a7 as CollectionAfterDeleteHook, a8 as CollectionAfterReadHook, a9 as CollectionAfterTransitionHook, aa as CollectionBeforeChangeHook, ab as CollectionBeforeDeleteHook, ac as CollectionBeforeReadHook, ad as CollectionBeforeTransitionHook, ae as CollectionListComponentSlots, af as CustomAdminAuthProvider, ag as DatabaseAdapter, ah as DateFieldAdmin, ai as DateFormat, aj as DisplayTone, ak as DynamicOptionItem, al as DynamicOptionsConfig, am as DynamicOptionsResolver, an as DynamicOptionsResolverArgs, ao as DyrectedLoggerConfig, ap as DyrectedObservabilityConfig, aq as EmailFieldAdmin, ar as FieldAdminHooks, as as FieldAdminOnChangeHook, at as FieldAdminOnChangeHookArgs, au as FieldAdminOptionsHook, av as FieldAdminOptionsHookArgs, aw as FieldAdminOptionsHookResult, ax as FieldAfterReadHook, ay as FieldAfterReadHookArgs, az as FieldBase, aA as FieldBeforeChangeHook, aB as FieldBeforeChangeHookArgs, aC as FieldHook, aD as FieldHooks, aE as FieldType, aF as FileData, aG as GlobalAfterChangeHook, aH as GlobalAfterReadHook, aI as GlobalBeforeChangeHook, aJ as GlobalBeforeReadHook, aK as HeadingLevel, aL as HookFunction, aM as IconFieldAdmin, aN as ImageService, aO as JsonFieldAdmin, aP as JsonFormat, aQ as LIFECYCLE_EVENT_NAMES, aR as LifecycleEventHandler, aS as LinkFormat, aT as MultiSelectFieldAdmin, aU as NamedAccessPolicy, aV as NumberFieldAdmin, aW as NumberFormat, aX as NumberLimitFieldAdmin, aY as NumberLimitFieldConfig, aZ as OIDCAdminAuthProvider, a_ as OptionFormat, a$ as PaginatedResult, b0 as PublicAdminAuthProvider, b1 as RadioFieldAdmin, b2 as RateLimitConfig, b3 as ReadonlyDatabaseAdapter, b4 as RichTextFeature, b5 as RichTextFieldConfig, b6 as SelectFieldAdmin, b7 as StorageAdapter, b8 as TextFieldAdmin, b9 as TextFormat, ba as TextareaFieldAdmin, bb as TrustProxyConfig, bc as TypedField, bd as UploadConfig, be as UrlFieldAdmin, bf as UrlLinkValue, bg as WordLimitFieldAdmin, bh as WordLimitFieldConfig, bi as WorkflowMetadata, bj as WorkflowRole, bk as WorkflowState, bl as WorkflowTransitionContext } from './app-config-Dv5XACR4.cjs';
|
|
3
3
|
import 'lucide-react';
|
|
4
|
+
import 'pino';
|
|
4
5
|
|
|
5
6
|
type Prettify<T> = {
|
|
6
7
|
[K in keyof T]: T[K];
|
|
@@ -140,7 +141,13 @@ interface SqlWhereResult {
|
|
|
140
141
|
* MySQL: (f) => `JSON_UNQUOTE(JSON_EXTRACT(data, '$.${f}'))`
|
|
141
142
|
* @param placeholder '?' for SQLite/MySQL, 'pg' for auto-incrementing Postgres $1/$2/…
|
|
142
143
|
*/
|
|
143
|
-
declare function parseSqlWhere(where: WhereClause, getJsonField: (field: string) => string, placeholder?: '?' | 'pg'
|
|
144
|
+
declare function parseSqlWhere(where: WhereClause, getJsonField: (field: string) => string, placeholder?: '?' | 'pg',
|
|
145
|
+
/**
|
|
146
|
+
* SQL keyword used for `contains`/`starts_with`. Postgres `LIKE` is
|
|
147
|
+
* case-sensitive, so the Postgres adapter passes `'ILIKE'` to keep substring
|
|
148
|
+
* matching case-insensitive like SQLite and MySQL.
|
|
149
|
+
*/
|
|
150
|
+
likeOperator?: 'LIKE' | 'ILIKE'): SqlWhereResult;
|
|
144
151
|
/**
|
|
145
152
|
* Translates a WhereClause into a MongoDB filter object.
|
|
146
153
|
* Handles nested OR/AND via $or/$and, and all operators via $eq/$in/$gt etc.
|
|
@@ -153,6 +160,41 @@ interface SortClause {
|
|
|
153
160
|
direction: SortDirection;
|
|
154
161
|
}
|
|
155
162
|
declare function parseSort(sort: string | undefined, fallback?: SortClause): SortClause[];
|
|
163
|
+
/**
|
|
164
|
+
* Collects the names of top-level fields declared as numbers. SQL adapters use
|
|
165
|
+
* this to decide which JSON-extracted sort fields need a numeric cast.
|
|
166
|
+
*/
|
|
167
|
+
declare function numericFieldNames(fields?: Field[]): Set<string>;
|
|
168
|
+
/**
|
|
169
|
+
* Dialect hooks for turning a parsed sort into a SQL `ORDER BY` body.
|
|
170
|
+
* Each SQL adapter supplies its own quoting, JSON extraction, and numeric cast.
|
|
171
|
+
*/
|
|
172
|
+
interface SqlSortDialect {
|
|
173
|
+
/** Quote a real column identifier (e.g. `"created_at"` or \`created_at\`). */
|
|
174
|
+
quoteIdent: (identifier: string) => string;
|
|
175
|
+
/** SQL expression that reads a top-level field out of the JSON `data` column. */
|
|
176
|
+
jsonExtract: (field: string) => string;
|
|
177
|
+
/**
|
|
178
|
+
* Wrap a JSON-extracted expression so it sorts numerically instead of
|
|
179
|
+
* lexicographically. Adapters whose JSON extraction already preserves number
|
|
180
|
+
* types (SQLite) can return the expression unchanged.
|
|
181
|
+
*/
|
|
182
|
+
castNumeric: (expr: string) => string;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Builds the `ORDER BY` body shared by the SQL adapters.
|
|
186
|
+
*
|
|
187
|
+
* Real (promoted) columns and the `created_at`/`updated_at` timestamps are
|
|
188
|
+
* ordered by their typed column directly. Everything else is read out of the
|
|
189
|
+
* JSON `data` column — and when a field is declared as a `number`, its extracted
|
|
190
|
+
* value is cast so it orders by magnitude rather than as text ("9" < "10").
|
|
191
|
+
*
|
|
192
|
+
* @param sort The raw sort string (e.g. `"-createdAt"`, `"priority,-views"`).
|
|
193
|
+
* @param existingColumns Real column names present on the table.
|
|
194
|
+
* @param numericFields Names of top-level fields declared with `type: 'number'`.
|
|
195
|
+
* @param dialect Adapter-specific quoting, extraction, and numeric cast.
|
|
196
|
+
*/
|
|
197
|
+
declare function buildSqlOrderBy(sort: string | undefined, existingColumns: string[], numericFields: Set<string>, dialect: SqlSortDialect): string;
|
|
156
198
|
|
|
157
199
|
type AnyHookFn = (args: any) => any;
|
|
158
200
|
/**
|
|
@@ -200,7 +242,37 @@ declare function generateOpenApi(config: DyrectedConfig): any;
|
|
|
200
242
|
|
|
201
243
|
declare const WORKFLOW_HISTORY_COLLECTION = "__workflow_history";
|
|
202
244
|
declare const LIFECYCLE_EVENTS_COLLECTION = "__lifecycle_events";
|
|
245
|
+
/**
|
|
246
|
+
* Role mapping for {@link definePublishingWorkflow}. Map your app's own role
|
|
247
|
+
* values onto the publishing workflow's two capability tiers.
|
|
248
|
+
*/
|
|
249
|
+
interface PublishingWorkflowOptions {
|
|
250
|
+
/** Role values allowed to edit and submit for review. Defaults to `["editor"]`. */
|
|
251
|
+
editors?: string[];
|
|
252
|
+
/** Role values allowed to also publish and unpublish. Defaults to `["publisher", "admin"]`. */
|
|
253
|
+
publishers?: string[];
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Build a `draft → in review → published` editorial workflow, mapping your own
|
|
257
|
+
* role values onto its capability tiers. Reach for this instead of
|
|
258
|
+
* {@link publishingWorkflow} when your roles aren't named
|
|
259
|
+
* `editor`/`publisher`/`admin`.
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* workflow: definePublishingWorkflow({
|
|
263
|
+
* editors: ["writer"],
|
|
264
|
+
* publishers: ["managing-editor", "admin"],
|
|
265
|
+
* })
|
|
266
|
+
*/
|
|
267
|
+
declare function definePublishingWorkflow(options?: PublishingWorkflowOptions): WorkflowConfig;
|
|
268
|
+
/**
|
|
269
|
+
* The default `draft → in review → published` editorial workflow, using the
|
|
270
|
+
* conventional role names `editor`, `publisher`, and `admin`. Shorthand for
|
|
271
|
+
* `definePublishingWorkflow()` — use {@link definePublishingWorkflow} to map
|
|
272
|
+
* your own role names onto its capability tiers.
|
|
273
|
+
*/
|
|
203
274
|
declare function publishingWorkflow(): WorkflowConfig;
|
|
275
|
+
declare function simplePublishingWorkflow(): WorkflowConfig;
|
|
204
276
|
declare function workflowCapabilities(workflow: WorkflowConfig, user?: AuthenticatedUser): Set<string>;
|
|
205
277
|
declare function canViewWorkflowDraft(workflow: WorkflowConfig, user?: AuthenticatedUser): boolean;
|
|
206
278
|
declare function availableWorkflowTransitions(workflow: WorkflowConfig, state: string, user?: AuthenticatedUser): WorkflowTransition[];
|
|
@@ -284,7 +356,7 @@ declare function defineCollection<const TFields extends Field[]>(config: Omit<Co
|
|
|
284
356
|
id: string;
|
|
285
357
|
} & InferDocShape<TFields> & SystemDocFields & AuthDocFields>>, "fields" | "auth"> & {
|
|
286
358
|
fields: TFields;
|
|
287
|
-
auth: true;
|
|
359
|
+
auth: true | AuthConfig;
|
|
288
360
|
}): CollectionConfig<Prettify<{
|
|
289
361
|
id: string;
|
|
290
362
|
} & InferDocShape<TFields> & SystemDocFields & AuthDocFields>>;
|
|
@@ -497,4 +569,4 @@ declare function defineTab<const T extends readonly Field[]>(args: {
|
|
|
497
569
|
fields: T;
|
|
498
570
|
}): T;
|
|
499
571
|
|
|
500
|
-
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, defineTab, defineTextField, defineTextareaField, defineTimeField, defineUrlField, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, executeFieldAfterRead, executeFieldBeforeChange, generateOpenApi, getAdminAuthCollection, getPublicAdminAuthConfig, initializeWorkflowDocument, materializeWorkflowDocument, normalizeConfig, parseMongoWhere, parseSort, parseSqlWhere, publishingWorkflow, resolveAdminAuthCollection, runCollectionHooks, saveWorkflowDraft, transitionWorkflow, workflowCapabilities };
|
|
572
|
+
export { AdminAuthConfig, ArrayField, AuthConfig, 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, type PublishingWorkflowOptions, 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, definePublishingWorkflow, 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,6 +1,7 @@
|
|
|
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
|
|
2
|
-
export {
|
|
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 AuthConfig, i as DateField, j as DateTimeField, E as EmailField, G as GlobalConfig, I as IconField, k as ImageField, J as JoinField, l as JsonField, M as MultiSelectField, N as NumberField, O as ObjectField, R as RadioField, m as RelationshipField, n as RichTextField, o as RowField, S as SelectField, T as TextField, p as TextareaField, q as TimeField, U as UrlField } from './app-config-Dv5XACR4.js';
|
|
2
|
+
export { r as AccessFunction, s as AccessFunctionArgs, t as AccessPolicyResolver, u as AccessResult, v as AccessRule, w as AdminAuthAccessResolution, x as AdminAuthClaimMapping, y as AdminAuthMember, z as AdminAuthProvider, K as AdminAuthProviderMembersConfig, Q as AdminAuthProvisioningMode, V as AdminAuthResolveAccessArgs, X as AdminAuthResolvedIdentity, Y as AdminConfig, Z as AdminDashboardComponentSlots, _ as AdminIconName, $ as BaseAdminAuthProvider, a0 as BaseFieldAdmin, a1 as BlockVariant, a2 as BooleanFieldAdmin, a3 as BooleanFormat, a4 as CharacterLimitFieldAdmin, a5 as CharacterLimitFieldConfig, a6 as CollectionAfterChangeHook, a7 as CollectionAfterDeleteHook, a8 as CollectionAfterReadHook, a9 as CollectionAfterTransitionHook, aa as CollectionBeforeChangeHook, ab as CollectionBeforeDeleteHook, ac as CollectionBeforeReadHook, ad as CollectionBeforeTransitionHook, ae as CollectionListComponentSlots, af as CustomAdminAuthProvider, ag as DatabaseAdapter, ah as DateFieldAdmin, ai as DateFormat, aj as DisplayTone, ak as DynamicOptionItem, al as DynamicOptionsConfig, am as DynamicOptionsResolver, an as DynamicOptionsResolverArgs, ao as DyrectedLoggerConfig, ap as DyrectedObservabilityConfig, aq as EmailFieldAdmin, ar as FieldAdminHooks, as as FieldAdminOnChangeHook, at as FieldAdminOnChangeHookArgs, au as FieldAdminOptionsHook, av as FieldAdminOptionsHookArgs, aw as FieldAdminOptionsHookResult, ax as FieldAfterReadHook, ay as FieldAfterReadHookArgs, az as FieldBase, aA as FieldBeforeChangeHook, aB as FieldBeforeChangeHookArgs, aC as FieldHook, aD as FieldHooks, aE as FieldType, aF as FileData, aG as GlobalAfterChangeHook, aH as GlobalAfterReadHook, aI as GlobalBeforeChangeHook, aJ as GlobalBeforeReadHook, aK as HeadingLevel, aL as HookFunction, aM as IconFieldAdmin, aN as ImageService, aO as JsonFieldAdmin, aP as JsonFormat, aQ as LIFECYCLE_EVENT_NAMES, aR as LifecycleEventHandler, aS as LinkFormat, aT as MultiSelectFieldAdmin, aU as NamedAccessPolicy, aV as NumberFieldAdmin, aW as NumberFormat, aX as NumberLimitFieldAdmin, aY as NumberLimitFieldConfig, aZ as OIDCAdminAuthProvider, a_ as OptionFormat, a$ as PaginatedResult, b0 as PublicAdminAuthProvider, b1 as RadioFieldAdmin, b2 as RateLimitConfig, b3 as ReadonlyDatabaseAdapter, b4 as RichTextFeature, b5 as RichTextFieldConfig, b6 as SelectFieldAdmin, b7 as StorageAdapter, b8 as TextFieldAdmin, b9 as TextFormat, ba as TextareaFieldAdmin, bb as TrustProxyConfig, bc as TypedField, bd as UploadConfig, be as UrlFieldAdmin, bf as UrlLinkValue, bg as WordLimitFieldAdmin, bh as WordLimitFieldConfig, bi as WorkflowMetadata, bj as WorkflowRole, bk as WorkflowState, bl as WorkflowTransitionContext } from './app-config-Dv5XACR4.js';
|
|
3
3
|
import 'lucide-react';
|
|
4
|
+
import 'pino';
|
|
4
5
|
|
|
5
6
|
type Prettify<T> = {
|
|
6
7
|
[K in keyof T]: T[K];
|
|
@@ -140,7 +141,13 @@ interface SqlWhereResult {
|
|
|
140
141
|
* MySQL: (f) => `JSON_UNQUOTE(JSON_EXTRACT(data, '$.${f}'))`
|
|
141
142
|
* @param placeholder '?' for SQLite/MySQL, 'pg' for auto-incrementing Postgres $1/$2/…
|
|
142
143
|
*/
|
|
143
|
-
declare function parseSqlWhere(where: WhereClause, getJsonField: (field: string) => string, placeholder?: '?' | 'pg'
|
|
144
|
+
declare function parseSqlWhere(where: WhereClause, getJsonField: (field: string) => string, placeholder?: '?' | 'pg',
|
|
145
|
+
/**
|
|
146
|
+
* SQL keyword used for `contains`/`starts_with`. Postgres `LIKE` is
|
|
147
|
+
* case-sensitive, so the Postgres adapter passes `'ILIKE'` to keep substring
|
|
148
|
+
* matching case-insensitive like SQLite and MySQL.
|
|
149
|
+
*/
|
|
150
|
+
likeOperator?: 'LIKE' | 'ILIKE'): SqlWhereResult;
|
|
144
151
|
/**
|
|
145
152
|
* Translates a WhereClause into a MongoDB filter object.
|
|
146
153
|
* Handles nested OR/AND via $or/$and, and all operators via $eq/$in/$gt etc.
|
|
@@ -153,6 +160,41 @@ interface SortClause {
|
|
|
153
160
|
direction: SortDirection;
|
|
154
161
|
}
|
|
155
162
|
declare function parseSort(sort: string | undefined, fallback?: SortClause): SortClause[];
|
|
163
|
+
/**
|
|
164
|
+
* Collects the names of top-level fields declared as numbers. SQL adapters use
|
|
165
|
+
* this to decide which JSON-extracted sort fields need a numeric cast.
|
|
166
|
+
*/
|
|
167
|
+
declare function numericFieldNames(fields?: Field[]): Set<string>;
|
|
168
|
+
/**
|
|
169
|
+
* Dialect hooks for turning a parsed sort into a SQL `ORDER BY` body.
|
|
170
|
+
* Each SQL adapter supplies its own quoting, JSON extraction, and numeric cast.
|
|
171
|
+
*/
|
|
172
|
+
interface SqlSortDialect {
|
|
173
|
+
/** Quote a real column identifier (e.g. `"created_at"` or \`created_at\`). */
|
|
174
|
+
quoteIdent: (identifier: string) => string;
|
|
175
|
+
/** SQL expression that reads a top-level field out of the JSON `data` column. */
|
|
176
|
+
jsonExtract: (field: string) => string;
|
|
177
|
+
/**
|
|
178
|
+
* Wrap a JSON-extracted expression so it sorts numerically instead of
|
|
179
|
+
* lexicographically. Adapters whose JSON extraction already preserves number
|
|
180
|
+
* types (SQLite) can return the expression unchanged.
|
|
181
|
+
*/
|
|
182
|
+
castNumeric: (expr: string) => string;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Builds the `ORDER BY` body shared by the SQL adapters.
|
|
186
|
+
*
|
|
187
|
+
* Real (promoted) columns and the `created_at`/`updated_at` timestamps are
|
|
188
|
+
* ordered by their typed column directly. Everything else is read out of the
|
|
189
|
+
* JSON `data` column — and when a field is declared as a `number`, its extracted
|
|
190
|
+
* value is cast so it orders by magnitude rather than as text ("9" < "10").
|
|
191
|
+
*
|
|
192
|
+
* @param sort The raw sort string (e.g. `"-createdAt"`, `"priority,-views"`).
|
|
193
|
+
* @param existingColumns Real column names present on the table.
|
|
194
|
+
* @param numericFields Names of top-level fields declared with `type: 'number'`.
|
|
195
|
+
* @param dialect Adapter-specific quoting, extraction, and numeric cast.
|
|
196
|
+
*/
|
|
197
|
+
declare function buildSqlOrderBy(sort: string | undefined, existingColumns: string[], numericFields: Set<string>, dialect: SqlSortDialect): string;
|
|
156
198
|
|
|
157
199
|
type AnyHookFn = (args: any) => any;
|
|
158
200
|
/**
|
|
@@ -200,7 +242,37 @@ declare function generateOpenApi(config: DyrectedConfig): any;
|
|
|
200
242
|
|
|
201
243
|
declare const WORKFLOW_HISTORY_COLLECTION = "__workflow_history";
|
|
202
244
|
declare const LIFECYCLE_EVENTS_COLLECTION = "__lifecycle_events";
|
|
245
|
+
/**
|
|
246
|
+
* Role mapping for {@link definePublishingWorkflow}. Map your app's own role
|
|
247
|
+
* values onto the publishing workflow's two capability tiers.
|
|
248
|
+
*/
|
|
249
|
+
interface PublishingWorkflowOptions {
|
|
250
|
+
/** Role values allowed to edit and submit for review. Defaults to `["editor"]`. */
|
|
251
|
+
editors?: string[];
|
|
252
|
+
/** Role values allowed to also publish and unpublish. Defaults to `["publisher", "admin"]`. */
|
|
253
|
+
publishers?: string[];
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Build a `draft → in review → published` editorial workflow, mapping your own
|
|
257
|
+
* role values onto its capability tiers. Reach for this instead of
|
|
258
|
+
* {@link publishingWorkflow} when your roles aren't named
|
|
259
|
+
* `editor`/`publisher`/`admin`.
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* workflow: definePublishingWorkflow({
|
|
263
|
+
* editors: ["writer"],
|
|
264
|
+
* publishers: ["managing-editor", "admin"],
|
|
265
|
+
* })
|
|
266
|
+
*/
|
|
267
|
+
declare function definePublishingWorkflow(options?: PublishingWorkflowOptions): WorkflowConfig;
|
|
268
|
+
/**
|
|
269
|
+
* The default `draft → in review → published` editorial workflow, using the
|
|
270
|
+
* conventional role names `editor`, `publisher`, and `admin`. Shorthand for
|
|
271
|
+
* `definePublishingWorkflow()` — use {@link definePublishingWorkflow} to map
|
|
272
|
+
* your own role names onto its capability tiers.
|
|
273
|
+
*/
|
|
203
274
|
declare function publishingWorkflow(): WorkflowConfig;
|
|
275
|
+
declare function simplePublishingWorkflow(): WorkflowConfig;
|
|
204
276
|
declare function workflowCapabilities(workflow: WorkflowConfig, user?: AuthenticatedUser): Set<string>;
|
|
205
277
|
declare function canViewWorkflowDraft(workflow: WorkflowConfig, user?: AuthenticatedUser): boolean;
|
|
206
278
|
declare function availableWorkflowTransitions(workflow: WorkflowConfig, state: string, user?: AuthenticatedUser): WorkflowTransition[];
|
|
@@ -284,7 +356,7 @@ declare function defineCollection<const TFields extends Field[]>(config: Omit<Co
|
|
|
284
356
|
id: string;
|
|
285
357
|
} & InferDocShape<TFields> & SystemDocFields & AuthDocFields>>, "fields" | "auth"> & {
|
|
286
358
|
fields: TFields;
|
|
287
|
-
auth: true;
|
|
359
|
+
auth: true | AuthConfig;
|
|
288
360
|
}): CollectionConfig<Prettify<{
|
|
289
361
|
id: string;
|
|
290
362
|
} & InferDocShape<TFields> & SystemDocFields & AuthDocFields>>;
|
|
@@ -497,4 +569,4 @@ declare function defineTab<const T extends readonly Field[]>(args: {
|
|
|
497
569
|
fields: T;
|
|
498
570
|
}): T;
|
|
499
571
|
|
|
500
|
-
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, defineTab, defineTextField, defineTextareaField, defineTimeField, defineUrlField, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, executeFieldAfterRead, executeFieldBeforeChange, generateOpenApi, getAdminAuthCollection, getPublicAdminAuthConfig, initializeWorkflowDocument, materializeWorkflowDocument, normalizeConfig, parseMongoWhere, parseSort, parseSqlWhere, publishingWorkflow, resolveAdminAuthCollection, runCollectionHooks, saveWorkflowDraft, transitionWorkflow, workflowCapabilities };
|
|
572
|
+
export { AdminAuthConfig, ArrayField, AuthConfig, 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, type PublishingWorkflowOptions, 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, definePublishingWorkflow, 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
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
canViewWorkflowDraft,
|
|
6
6
|
createLifecycleEvent,
|
|
7
7
|
createWorkflowDocument,
|
|
8
|
+
definePublishingWorkflow,
|
|
8
9
|
dispatchLifecycleEvent,
|
|
9
10
|
dispatchPendingLifecycleEvents,
|
|
10
11
|
executeFieldAfterRead,
|
|
@@ -19,9 +20,10 @@ import {
|
|
|
19
20
|
resolveAdminAuthCollection,
|
|
20
21
|
runCollectionHooks,
|
|
21
22
|
saveWorkflowDraft,
|
|
23
|
+
simplePublishingWorkflow,
|
|
22
24
|
transitionWorkflow,
|
|
23
25
|
workflowCapabilities
|
|
24
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-BQV3QW3Y.js";
|
|
25
27
|
|
|
26
28
|
// src/types/workflows.ts
|
|
27
29
|
var LIFECYCLE_EVENT_NAMES = [
|
|
@@ -35,7 +37,7 @@ var LIFECYCLE_EVENT_NAMES = [
|
|
|
35
37
|
function assertNever(op, context) {
|
|
36
38
|
throw new Error(`[dyrected/core] Unhandled where operator "${op}" in ${context}`);
|
|
37
39
|
}
|
|
38
|
-
function parseSqlWhere(where, getJsonField, placeholder = "?") {
|
|
40
|
+
function parseSqlWhere(where, getJsonField, placeholder = "?", likeOperator = "LIKE") {
|
|
39
41
|
const params = [];
|
|
40
42
|
let pgIndex = 1;
|
|
41
43
|
function next() {
|
|
@@ -97,10 +99,10 @@ function parseSqlWhere(where, getJsonField, placeholder = "?") {
|
|
|
97
99
|
return `${c} <= ${next()}`;
|
|
98
100
|
case "contains":
|
|
99
101
|
params.push(`%${operand}%`);
|
|
100
|
-
return `${c}
|
|
102
|
+
return `${c} ${likeOperator} ${next()}`;
|
|
101
103
|
case "starts_with":
|
|
102
104
|
params.push(`${operand}%`);
|
|
103
|
-
return `${c}
|
|
105
|
+
return `${c} ${likeOperator} ${next()}`;
|
|
104
106
|
case "exists":
|
|
105
107
|
return operand ? `${c} IS NOT NULL` : `${c} IS NULL`;
|
|
106
108
|
default:
|
|
@@ -205,6 +207,33 @@ function parseSort(sort, fallback = { field: "createdAt", direction: "DESC" }) {
|
|
|
205
207
|
}).filter((clause) => Boolean(clause));
|
|
206
208
|
return clauses.length > 0 ? clauses : [fallback];
|
|
207
209
|
}
|
|
210
|
+
function numericFieldNames(fields) {
|
|
211
|
+
const names = /* @__PURE__ */ new Set();
|
|
212
|
+
for (const field of fields ?? []) {
|
|
213
|
+
if (field.type === "number" && "name" in field && field.name) {
|
|
214
|
+
names.add(field.name);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return names;
|
|
218
|
+
}
|
|
219
|
+
var TIMESTAMP_COLUMNS = {
|
|
220
|
+
createdat: "created_at",
|
|
221
|
+
created_at: "created_at",
|
|
222
|
+
updatedat: "updated_at",
|
|
223
|
+
updated_at: "updated_at"
|
|
224
|
+
};
|
|
225
|
+
function buildSqlOrderBy(sort, existingColumns, numericFields, dialect) {
|
|
226
|
+
return parseSort(sort).map(({ field, direction }) => {
|
|
227
|
+
const timestamp = TIMESTAMP_COLUMNS[field.toLowerCase()];
|
|
228
|
+
if (timestamp) return `${dialect.quoteIdent(timestamp)} ${direction}`;
|
|
229
|
+
if (existingColumns.includes(field) && field !== "id" && field !== "data") {
|
|
230
|
+
return `${dialect.quoteIdent(field)} ${direction}`;
|
|
231
|
+
}
|
|
232
|
+
const extracted = dialect.jsonExtract(field);
|
|
233
|
+
const expr = numericFields.has(field) ? dialect.castNumeric(extracted) : extracted;
|
|
234
|
+
return `${expr} ${direction}`;
|
|
235
|
+
}).join(", ");
|
|
236
|
+
}
|
|
208
237
|
|
|
209
238
|
// src/index.ts
|
|
210
239
|
function defineCollection(config) {
|
|
@@ -258,6 +287,7 @@ export {
|
|
|
258
287
|
LIFECYCLE_EVENT_NAMES,
|
|
259
288
|
WORKFLOW_HISTORY_COLLECTION,
|
|
260
289
|
availableWorkflowTransitions,
|
|
290
|
+
buildSqlOrderBy,
|
|
261
291
|
canViewWorkflowDraft,
|
|
262
292
|
createLifecycleEvent,
|
|
263
293
|
createWorkflowDocument,
|
|
@@ -279,6 +309,7 @@ export {
|
|
|
279
309
|
defineMultiSelectField,
|
|
280
310
|
defineNumberField,
|
|
281
311
|
defineObjectField,
|
|
312
|
+
definePublishingWorkflow,
|
|
282
313
|
defineRadioField,
|
|
283
314
|
defineRelationshipField,
|
|
284
315
|
defineRichTextField,
|
|
@@ -299,6 +330,7 @@ export {
|
|
|
299
330
|
initializeWorkflowDocument,
|
|
300
331
|
materializeWorkflowDocument,
|
|
301
332
|
normalizeConfig,
|
|
333
|
+
numericFieldNames,
|
|
302
334
|
parseMongoWhere,
|
|
303
335
|
parseSort,
|
|
304
336
|
parseSqlWhere,
|
|
@@ -306,6 +338,7 @@ export {
|
|
|
306
338
|
resolveAdminAuthCollection,
|
|
307
339
|
runCollectionHooks,
|
|
308
340
|
saveWorkflowDraft,
|
|
341
|
+
simplePublishingWorkflow,
|
|
309
342
|
transitionWorkflow,
|
|
310
343
|
workflowCapabilities
|
|
311
344
|
};
|