@dyrected/core 2.14.0 → 2.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{app-Cp8RudRI.d.cts → app-Cmp5lFLJ.d.cts} +84 -2
- package/dist/{app-Cp8RudRI.d.ts → app-Cmp5lFLJ.d.ts} +84 -2
- package/dist/index.cjs +64 -0
- package/dist/index.d.cts +56 -3
- package/dist/index.d.ts +56 -3
- package/dist/index.js +58 -0
- package/dist/server.cjs +28 -7
- package/dist/server.d.cts +10 -3
- package/dist/server.d.ts +10 -3
- package/dist/server.js +27 -7
- package/package.json +1 -1
|
@@ -1153,10 +1153,44 @@ interface DetailCustom<TDoc = any> {
|
|
|
1153
1153
|
/** Custom component options. */
|
|
1154
1154
|
options?: DetailCustomOptions<TDoc>;
|
|
1155
1155
|
}
|
|
1156
|
+
/**
|
|
1157
|
+
* Configuration options for rendering an action button in a Detail View.
|
|
1158
|
+
*/
|
|
1159
|
+
interface DetailActionOptions {
|
|
1160
|
+
/** Grid column span across the 12-column grid. */
|
|
1161
|
+
span?: DetailSpan;
|
|
1162
|
+
/** Button visual style. Defaults to `'outline'`. */
|
|
1163
|
+
variant?: "default" | "outline" | "secondary" | "ghost" | "destructive";
|
|
1164
|
+
/** Button size. Defaults to `'sm'`. */
|
|
1165
|
+
size?: "sm" | "default";
|
|
1166
|
+
/** Overrides the action's own `label` for this placement. */
|
|
1167
|
+
label?: string;
|
|
1168
|
+
/**
|
|
1169
|
+
* Visibility condition for this action item.
|
|
1170
|
+
* Can be a boolean or a JEXL expression evaluated against `{ doc, user }`.
|
|
1171
|
+
*/
|
|
1172
|
+
visible?: string | boolean;
|
|
1173
|
+
}
|
|
1174
|
+
/**
|
|
1175
|
+
* Renders a button for a named action from `collection.actions` at this
|
|
1176
|
+
* position in a Detail View. The same action (and its confirm dialog, modal
|
|
1177
|
+
* fields, and execution) can also render automatically in the Detail View's
|
|
1178
|
+
* header toolbar when the action's `type` is `'header'` — placing it here
|
|
1179
|
+
* too does not duplicate that config, it just adds another entry point to
|
|
1180
|
+
* the same action.
|
|
1181
|
+
*/
|
|
1182
|
+
interface DetailAction {
|
|
1183
|
+
/** Identifies this item as an action button. */
|
|
1184
|
+
type: "action";
|
|
1185
|
+
/** Name of the action, matching an entry in `collection.actions`. */
|
|
1186
|
+
name: string;
|
|
1187
|
+
/** Display and visibility options for this placement. */
|
|
1188
|
+
options?: DetailActionOptions;
|
|
1189
|
+
}
|
|
1156
1190
|
/**
|
|
1157
1191
|
* Union of all valid item types in a Detail View schema.
|
|
1158
1192
|
*/
|
|
1159
|
-
type DetailItem<TDoc = any> = DetailSection | DetailTabs | DetailGrid | DetailField | DetailRepeat | DetailComputed<TDoc> | DetailDivider | DetailText | DetailCustom<TDoc> | string;
|
|
1193
|
+
type DetailItem<TDoc = any> = DetailSection | DetailTabs | DetailGrid | DetailField | DetailRepeat | DetailComputed<TDoc> | DetailDivider | DetailText | DetailCustom<TDoc> | DetailAction | string;
|
|
1160
1194
|
/**
|
|
1161
1195
|
* Detail View layout schema definition for a collection or global.
|
|
1162
1196
|
*/
|
|
@@ -2088,6 +2122,31 @@ interface CollectionConfig<TDoc extends object = Record<string, unknown>> {
|
|
|
2088
2122
|
hidden?: boolean;
|
|
2089
2123
|
/** If `false`, disables the filter UI entirely for this collection. Defaults to `true`. */
|
|
2090
2124
|
filterable?: boolean;
|
|
2125
|
+
/**
|
|
2126
|
+
* Base query filter applied to this collection's default list view,
|
|
2127
|
+
* before user toolbar filters (e.g. `{ status: { equals: "published" } }`
|
|
2128
|
+
* or a JEXL string). Equivalent to `filter` on `defineView`, without
|
|
2129
|
+
* having to define a separate view and set it as the default.
|
|
2130
|
+
*/
|
|
2131
|
+
filter?: Record<string, any> | string;
|
|
2132
|
+
/**
|
|
2133
|
+
* Default sort applied to this collection's default list view when first
|
|
2134
|
+
* opened. Equivalent to `sort` on `defineView`.
|
|
2135
|
+
*/
|
|
2136
|
+
sort?: {
|
|
2137
|
+
field: string;
|
|
2138
|
+
direction: "asc" | "desc";
|
|
2139
|
+
};
|
|
2140
|
+
/**
|
|
2141
|
+
* KPI summary cards rendered above this collection's default list view.
|
|
2142
|
+
* Equivalent to `metrics` on `defineView`.
|
|
2143
|
+
*/
|
|
2144
|
+
metrics?: ViewMetric[];
|
|
2145
|
+
/**
|
|
2146
|
+
* Field name used to organize this collection's default list view into
|
|
2147
|
+
* collapsible grouped sections. Equivalent to `groupBy` on `defineView`.
|
|
2148
|
+
*/
|
|
2149
|
+
groupBy?: string;
|
|
2091
2150
|
/**
|
|
2092
2151
|
* Enables draft autosave in the Admin editor for workflow-enabled
|
|
2093
2152
|
* collections. Defaults to `true` when the collection uses `workflow` or
|
|
@@ -2219,6 +2278,29 @@ interface CollectionConfig<TDoc extends object = Record<string, unknown>> {
|
|
|
2219
2278
|
* @see {@link https://dyrected.com/docs/model-content/operational-views/overview Operational views overview}
|
|
2220
2279
|
*/
|
|
2221
2280
|
views?: ViewConfig[];
|
|
2281
|
+
/**
|
|
2282
|
+
* Custom workflow actions for this collection, independent of any single view.
|
|
2283
|
+
* These run against one document at a time (no `viewSlug` required), so they
|
|
2284
|
+
* work anywhere a document is in scope — most notably the read-only Detail
|
|
2285
|
+
* View, where they can render in the header toolbar (`type: 'header'`) and/or
|
|
2286
|
+
* inline via `displayAction(name)` in the `detail` schema. The same action
|
|
2287
|
+
* definitions can also be referenced from a `defineView`'s own `actions` for
|
|
2288
|
+
* list-page use — they are not mutually exclusive.
|
|
2289
|
+
*
|
|
2290
|
+
* @example
|
|
2291
|
+
* ```ts
|
|
2292
|
+
* actions: [
|
|
2293
|
+
* defineAction({
|
|
2294
|
+
* name: "markShipped",
|
|
2295
|
+
* label: "Mark as shipped",
|
|
2296
|
+
* type: "header",
|
|
2297
|
+
* confirm: "Mark this order as shipped?",
|
|
2298
|
+
* mutation: { status: "shipped" },
|
|
2299
|
+
* }),
|
|
2300
|
+
* ]
|
|
2301
|
+
* ```
|
|
2302
|
+
*/
|
|
2303
|
+
actions?: ActionConfig[];
|
|
2222
2304
|
}
|
|
2223
2305
|
/**
|
|
2224
2306
|
* Defines a Dyrected global — a singleton document without pagination or IDs.
|
|
@@ -3818,4 +3900,4 @@ interface DyrectedContext {
|
|
|
3818
3900
|
*/
|
|
3819
3901
|
declare function createDyrectedApp(rawConfig: DyrectedConfig | any): Promise<Hono<DyrectedContext, hono_types.BlankSchema, "/">>;
|
|
3820
3902
|
|
|
3821
|
-
export { type
|
|
3903
|
+
export { type JoinField as $, type AdminAuthConfig as A, type Block as B, type CollectionConfig as C, type DyrectedConfig as D, type DetailTabs as E, type Field as F, type GlobalConfig as G, type HookRequestContext as H, type DetailTextOptions as I, type DetailText as J, type DetailSchema as K, type LifecycleEventName as L, type DyrectedContext as M, type AIConfig as N, type AIPIIConfig as O, type PublicAdminAuthConfig as P, type ArrayField as Q, type FieldType as R, type BooleanField as S, type AuthConfig as T, type AccessPolicyResolver as U, type DateField as V, type WorkflowConfig as W, type DateTimeField as X, type EmailField as Y, type IconField as Z, type ImageField as _, type DeclarativeHookExpression as a, type BooleanFieldAdmin as a$, type JsonField as a0, type MultiSelectField as a1, type NumberField as a2, type ObjectField as a3, type RadioField as a4, type RelationshipField as a5, type RichTextField as a6, type RowField as a7, type SelectField as a8, type TextField as a9, type ActionConfig as aA, type ActionConfigBase as aB, type ActionConfigWithHandler as aC, type ActionConfigWithMutation as aD, type ActionContext as aE, type ActionType as aF, type AdminAuthAccessResolution as aG, type AdminAuthClaimMapping as aH, type AdminAuthMember as aI, type AdminAuthProvider as aJ, type AdminAuthProviderMembersConfig as aK, type AdminAuthProvisioningMode as aL, type AdminAuthResolveAccessArgs as aM, type AdminAuthResolvedIdentity as aN, type AdminConfig as aO, type AdminDashboardComponentSlots as aP, type AdminIconName as aQ, type AggregateArgs as aR, type AggregateCastType as aS, type AggregateCollectionResult as aT, type AggregateInput as aU, type AggregateOperation as aV, type AggregateResult as aW, type BaseAdminAuthProvider as aX, type BaseFieldAdmin as aY, type BlockVariant as aZ, type BlocksField as a_, type TextareaField as aa, type TimeField as ab, type UrlField as ac, type AIAction as ad, type AIActionStatus as ae, type AIActionType as af, type AIAuditActionType as ag, type AIAuditRecord as ah, type AIChunk as ai, type AIMessage as aj, type AIPIIPattern as ak, type AIRateLimitResult as al, type AIRateLimitStore as am, type AIThread as an, type AIToolContext as ao, type AIToolDefinition as ap, AI_ACTIONS_COLLECTION as aq, AI_AUDIT_COLLECTION as ar, AI_CHUNKS_COLLECTION as as, AI_MESSAGES_COLLECTION as at, AI_THREADS_COLLECTION as au, type AccessConfig as av, type AccessFunction as aw, type AccessFunctionArgs as ax, type AccessResult as ay, type AccessRule as az, type AuthenticatedUser as b, type GlobalAfterReadHookEntry as b$, type BooleanFormat as b0, type CharacterLimitFieldAdmin as b1, type CharacterLimitFieldConfig as b2, type CollectionAfterChangeHook as b3, type CollectionAfterDeleteHook as b4, type CollectionAfterReadHook as b5, type CollectionAfterReadHookEntry as b6, type CollectionAfterTransitionHook as b7, type CollectionBeforeChangeHook as b8, type CollectionBeforeChangeHookEntry as b9, type DistinctCountOperation as bA, type DistinctValuesOperation as bB, type DynamicOptionItem as bC, type DynamicOptionsConfig as bD, type DynamicOptionsResolver as bE, type DynamicOptionsResolverArgs as bF, type DyrectedAIContext as bG, type DyrectedLoggerConfig as bH, type DyrectedObservabilityConfig as bI, type EmailFieldAdmin as bJ, type FieldAdminHooks as bK, type FieldAdminOnChangeHook as bL, type FieldAdminOnChangeHookArgs as bM, type FieldAdminOptionsHook as bN, type FieldAdminOptionsHookArgs as bO, type FieldAdminOptionsHookResult as bP, type FieldAfterReadHook as bQ, type FieldAfterReadHookArgs as bR, type FieldBase as bS, type FieldBeforeChangeHook as bT, type FieldBeforeChangeHookArgs as bU, type FieldHook as bV, type FieldHooks as bW, type FileData as bX, type GetDocumentResult as bY, type GlobalAfterChangeHook as bZ, type GlobalAfterReadHook as b_, type CollectionBeforeDeleteHook as ba, type CollectionBeforeReadHook as bb, type CollectionBeforeReadHookEntry as bc, type CollectionBeforeTransitionHook as bd, type CollectionListComponentSlots as be, type CollectionRAGConfig as bf, type CollectionSchemaResult as bg, type CollectionSummaryResult as bh, type CollectionViewComponentSlots as bi, type CountOperation as bj, type CustomAdminAuthProvider as bk, type DatabaseAdapter as bl, type DateFieldAdmin as bm, type DateFormat as bn, type DefaultValueContext as bo, type DefineActionOptions as bp, type DefineCalendarViewOptions as bq, type DefineCardsViewOptions as br, type DefineGanttViewOptions as bs, type DefineKanbanViewOptions as bt, type DefineTableViewOptions as bu, type DefineViewBaseOptions as bv, type DefineViewOptions as bw, type DetailSpan as bx, type DisplayTone as by, type DisplayVariant as bz, type WorkflowTransition as c, type WorkflowTransitionContext as c$, type GlobalBeforeChangeHook as c0, type GlobalBeforeChangeHookEntry as c1, type GlobalBeforeReadHook as c2, type GlobalBeforeReadHookEntry as c3, type GlobalRAGConfig as c4, type GlobalSchemaResult as c5, type GlobalSummaryResult as c6, type HeadingLevel as c7, type HookFunction as c8, type IconFieldAdmin as c9, type RichTextFeature as cA, type RichTextFieldConfig as cB, type SelectFieldAdmin as cC, type SqlWhereResult as cD, type StorageAdapter as cE, type TextFieldAdmin as cF, type TextFormat as cG, type TextareaFieldAdmin as cH, type TrustProxyConfig as cI, type TypedField as cJ, type UploadConfig as cK, type UrlFieldAdmin as cL, type UrlLinkValue as cM, type ViewActionFeatures as cN, type ViewComponentSlots as cO, type ViewConfig as cP, type ViewLayout as cQ, type ViewMetric as cR, type ViewSubMetric as cS, type WhereClause as cT, type WhereOperator as cU, type WhereOperatorName as cV, type WordLimitFieldAdmin as cW, type WordLimitFieldConfig as cX, type WorkflowMetadata as cY, type WorkflowRole as cZ, type WorkflowState as c_, type ImageService as ca, type ImageTransformOptions as cb, type InferAggregateResult as cc, type JoinFieldAdmin as cd, type JsonFieldAdmin as ce, type JsonFormat as cf, LIFECYCLE_EVENT_NAMES as cg, type LifecycleEventHandler as ch, type LinkFormat as ci, type MetricColor as cj, type MultiSelectFieldAdmin as ck, type NamedAccessPolicy as cl, type NumberFieldAdmin as cm, type NumberFormat as cn, type NumberLimitFieldAdmin as co, type NumberLimitFieldConfig as cp, type NumericOperation as cq, type OIDCAdminAuthProvider as cr, type OptionFormat as cs, type PaginatedResult as ct, type PublicAdminAuthProvider as cu, type QueryCollectionResult as cv, type RAGSearchResult as cw, type RadioFieldAdmin as cx, type RateLimitConfig as cy, type ReadonlyDatabaseAdapter as cz, type LifecycleEvent as d, defineAction as d0, defineCalendarView as d1, defineCardsView as d2, defineGanttView as d3, defineKanbanView as d4, defineTableView as d5, defineView as d6, isAICollection as d7, parseMongoWhere as d8, parseSqlWhere as d9, verifyCollectionToken as dA, type CollectionTokenPayload as da, DEFAULT_SESSION_EXPIRY as db, type DyrectedObservabilityRuntime as dc, type RequestBodyCapture as dd, type RequestTraceContext as de, type ResolvedObservabilityConfig as df, attachRequestMetrics as dg, bindObservabilityRuntime as dh, buildRequestLogger as di, captureRequestBody as dj, createDyrectedApp as dk, createObservabilityRuntime as dl, createRequestSpan as dm, decodeCollectionToken as dn, endRequestSpan as dp, getConfigLogger as dq, getObservabilityRuntime as dr, getRequestLogger as ds, redactBody as dt, redactHeaders as du, renderPrometheusMetrics as dv, resolveObservabilityConfig as dw, resolveSessionTokenExpiry as dx, shouldSampleRequest as dy, signCollectionToken as dz, type BaseDocument as e, type DetailActionOptions as f, type DetailAction as g, type DetailComputedOptions as h, type ComputedHandler as i, type DetailComputed as j, type DetailCustomOptions as k, type DetailCustom as l, type DetailDividerOptions as m, type DetailDivider as n, type DisplayFieldOptions as o, type DetailField as p, type DetailItem as q, type DetailGridOptions as r, type DetailGrid as s, type DetailRepeatOptions as t, type DetailRepeat as u, type DetailSectionOptions as v, type DetailSection as w, type DetailTabOptions as x, type DetailTab as y, type DetailTabsOptions as z };
|
|
@@ -1153,10 +1153,44 @@ interface DetailCustom<TDoc = any> {
|
|
|
1153
1153
|
/** Custom component options. */
|
|
1154
1154
|
options?: DetailCustomOptions<TDoc>;
|
|
1155
1155
|
}
|
|
1156
|
+
/**
|
|
1157
|
+
* Configuration options for rendering an action button in a Detail View.
|
|
1158
|
+
*/
|
|
1159
|
+
interface DetailActionOptions {
|
|
1160
|
+
/** Grid column span across the 12-column grid. */
|
|
1161
|
+
span?: DetailSpan;
|
|
1162
|
+
/** Button visual style. Defaults to `'outline'`. */
|
|
1163
|
+
variant?: "default" | "outline" | "secondary" | "ghost" | "destructive";
|
|
1164
|
+
/** Button size. Defaults to `'sm'`. */
|
|
1165
|
+
size?: "sm" | "default";
|
|
1166
|
+
/** Overrides the action's own `label` for this placement. */
|
|
1167
|
+
label?: string;
|
|
1168
|
+
/**
|
|
1169
|
+
* Visibility condition for this action item.
|
|
1170
|
+
* Can be a boolean or a JEXL expression evaluated against `{ doc, user }`.
|
|
1171
|
+
*/
|
|
1172
|
+
visible?: string | boolean;
|
|
1173
|
+
}
|
|
1174
|
+
/**
|
|
1175
|
+
* Renders a button for a named action from `collection.actions` at this
|
|
1176
|
+
* position in a Detail View. The same action (and its confirm dialog, modal
|
|
1177
|
+
* fields, and execution) can also render automatically in the Detail View's
|
|
1178
|
+
* header toolbar when the action's `type` is `'header'` — placing it here
|
|
1179
|
+
* too does not duplicate that config, it just adds another entry point to
|
|
1180
|
+
* the same action.
|
|
1181
|
+
*/
|
|
1182
|
+
interface DetailAction {
|
|
1183
|
+
/** Identifies this item as an action button. */
|
|
1184
|
+
type: "action";
|
|
1185
|
+
/** Name of the action, matching an entry in `collection.actions`. */
|
|
1186
|
+
name: string;
|
|
1187
|
+
/** Display and visibility options for this placement. */
|
|
1188
|
+
options?: DetailActionOptions;
|
|
1189
|
+
}
|
|
1156
1190
|
/**
|
|
1157
1191
|
* Union of all valid item types in a Detail View schema.
|
|
1158
1192
|
*/
|
|
1159
|
-
type DetailItem<TDoc = any> = DetailSection | DetailTabs | DetailGrid | DetailField | DetailRepeat | DetailComputed<TDoc> | DetailDivider | DetailText | DetailCustom<TDoc> | string;
|
|
1193
|
+
type DetailItem<TDoc = any> = DetailSection | DetailTabs | DetailGrid | DetailField | DetailRepeat | DetailComputed<TDoc> | DetailDivider | DetailText | DetailCustom<TDoc> | DetailAction | string;
|
|
1160
1194
|
/**
|
|
1161
1195
|
* Detail View layout schema definition for a collection or global.
|
|
1162
1196
|
*/
|
|
@@ -2088,6 +2122,31 @@ interface CollectionConfig<TDoc extends object = Record<string, unknown>> {
|
|
|
2088
2122
|
hidden?: boolean;
|
|
2089
2123
|
/** If `false`, disables the filter UI entirely for this collection. Defaults to `true`. */
|
|
2090
2124
|
filterable?: boolean;
|
|
2125
|
+
/**
|
|
2126
|
+
* Base query filter applied to this collection's default list view,
|
|
2127
|
+
* before user toolbar filters (e.g. `{ status: { equals: "published" } }`
|
|
2128
|
+
* or a JEXL string). Equivalent to `filter` on `defineView`, without
|
|
2129
|
+
* having to define a separate view and set it as the default.
|
|
2130
|
+
*/
|
|
2131
|
+
filter?: Record<string, any> | string;
|
|
2132
|
+
/**
|
|
2133
|
+
* Default sort applied to this collection's default list view when first
|
|
2134
|
+
* opened. Equivalent to `sort` on `defineView`.
|
|
2135
|
+
*/
|
|
2136
|
+
sort?: {
|
|
2137
|
+
field: string;
|
|
2138
|
+
direction: "asc" | "desc";
|
|
2139
|
+
};
|
|
2140
|
+
/**
|
|
2141
|
+
* KPI summary cards rendered above this collection's default list view.
|
|
2142
|
+
* Equivalent to `metrics` on `defineView`.
|
|
2143
|
+
*/
|
|
2144
|
+
metrics?: ViewMetric[];
|
|
2145
|
+
/**
|
|
2146
|
+
* Field name used to organize this collection's default list view into
|
|
2147
|
+
* collapsible grouped sections. Equivalent to `groupBy` on `defineView`.
|
|
2148
|
+
*/
|
|
2149
|
+
groupBy?: string;
|
|
2091
2150
|
/**
|
|
2092
2151
|
* Enables draft autosave in the Admin editor for workflow-enabled
|
|
2093
2152
|
* collections. Defaults to `true` when the collection uses `workflow` or
|
|
@@ -2219,6 +2278,29 @@ interface CollectionConfig<TDoc extends object = Record<string, unknown>> {
|
|
|
2219
2278
|
* @see {@link https://dyrected.com/docs/model-content/operational-views/overview Operational views overview}
|
|
2220
2279
|
*/
|
|
2221
2280
|
views?: ViewConfig[];
|
|
2281
|
+
/**
|
|
2282
|
+
* Custom workflow actions for this collection, independent of any single view.
|
|
2283
|
+
* These run against one document at a time (no `viewSlug` required), so they
|
|
2284
|
+
* work anywhere a document is in scope — most notably the read-only Detail
|
|
2285
|
+
* View, where they can render in the header toolbar (`type: 'header'`) and/or
|
|
2286
|
+
* inline via `displayAction(name)` in the `detail` schema. The same action
|
|
2287
|
+
* definitions can also be referenced from a `defineView`'s own `actions` for
|
|
2288
|
+
* list-page use — they are not mutually exclusive.
|
|
2289
|
+
*
|
|
2290
|
+
* @example
|
|
2291
|
+
* ```ts
|
|
2292
|
+
* actions: [
|
|
2293
|
+
* defineAction({
|
|
2294
|
+
* name: "markShipped",
|
|
2295
|
+
* label: "Mark as shipped",
|
|
2296
|
+
* type: "header",
|
|
2297
|
+
* confirm: "Mark this order as shipped?",
|
|
2298
|
+
* mutation: { status: "shipped" },
|
|
2299
|
+
* }),
|
|
2300
|
+
* ]
|
|
2301
|
+
* ```
|
|
2302
|
+
*/
|
|
2303
|
+
actions?: ActionConfig[];
|
|
2222
2304
|
}
|
|
2223
2305
|
/**
|
|
2224
2306
|
* Defines a Dyrected global — a singleton document without pagination or IDs.
|
|
@@ -3818,4 +3900,4 @@ interface DyrectedContext {
|
|
|
3818
3900
|
*/
|
|
3819
3901
|
declare function createDyrectedApp(rawConfig: DyrectedConfig | any): Promise<Hono<DyrectedContext, hono_types.BlankSchema, "/">>;
|
|
3820
3902
|
|
|
3821
|
-
export { type
|
|
3903
|
+
export { type JoinField as $, type AdminAuthConfig as A, type Block as B, type CollectionConfig as C, type DyrectedConfig as D, type DetailTabs as E, type Field as F, type GlobalConfig as G, type HookRequestContext as H, type DetailTextOptions as I, type DetailText as J, type DetailSchema as K, type LifecycleEventName as L, type DyrectedContext as M, type AIConfig as N, type AIPIIConfig as O, type PublicAdminAuthConfig as P, type ArrayField as Q, type FieldType as R, type BooleanField as S, type AuthConfig as T, type AccessPolicyResolver as U, type DateField as V, type WorkflowConfig as W, type DateTimeField as X, type EmailField as Y, type IconField as Z, type ImageField as _, type DeclarativeHookExpression as a, type BooleanFieldAdmin as a$, type JsonField as a0, type MultiSelectField as a1, type NumberField as a2, type ObjectField as a3, type RadioField as a4, type RelationshipField as a5, type RichTextField as a6, type RowField as a7, type SelectField as a8, type TextField as a9, type ActionConfig as aA, type ActionConfigBase as aB, type ActionConfigWithHandler as aC, type ActionConfigWithMutation as aD, type ActionContext as aE, type ActionType as aF, type AdminAuthAccessResolution as aG, type AdminAuthClaimMapping as aH, type AdminAuthMember as aI, type AdminAuthProvider as aJ, type AdminAuthProviderMembersConfig as aK, type AdminAuthProvisioningMode as aL, type AdminAuthResolveAccessArgs as aM, type AdminAuthResolvedIdentity as aN, type AdminConfig as aO, type AdminDashboardComponentSlots as aP, type AdminIconName as aQ, type AggregateArgs as aR, type AggregateCastType as aS, type AggregateCollectionResult as aT, type AggregateInput as aU, type AggregateOperation as aV, type AggregateResult as aW, type BaseAdminAuthProvider as aX, type BaseFieldAdmin as aY, type BlockVariant as aZ, type BlocksField as a_, type TextareaField as aa, type TimeField as ab, type UrlField as ac, type AIAction as ad, type AIActionStatus as ae, type AIActionType as af, type AIAuditActionType as ag, type AIAuditRecord as ah, type AIChunk as ai, type AIMessage as aj, type AIPIIPattern as ak, type AIRateLimitResult as al, type AIRateLimitStore as am, type AIThread as an, type AIToolContext as ao, type AIToolDefinition as ap, AI_ACTIONS_COLLECTION as aq, AI_AUDIT_COLLECTION as ar, AI_CHUNKS_COLLECTION as as, AI_MESSAGES_COLLECTION as at, AI_THREADS_COLLECTION as au, type AccessConfig as av, type AccessFunction as aw, type AccessFunctionArgs as ax, type AccessResult as ay, type AccessRule as az, type AuthenticatedUser as b, type GlobalAfterReadHookEntry as b$, type BooleanFormat as b0, type CharacterLimitFieldAdmin as b1, type CharacterLimitFieldConfig as b2, type CollectionAfterChangeHook as b3, type CollectionAfterDeleteHook as b4, type CollectionAfterReadHook as b5, type CollectionAfterReadHookEntry as b6, type CollectionAfterTransitionHook as b7, type CollectionBeforeChangeHook as b8, type CollectionBeforeChangeHookEntry as b9, type DistinctCountOperation as bA, type DistinctValuesOperation as bB, type DynamicOptionItem as bC, type DynamicOptionsConfig as bD, type DynamicOptionsResolver as bE, type DynamicOptionsResolverArgs as bF, type DyrectedAIContext as bG, type DyrectedLoggerConfig as bH, type DyrectedObservabilityConfig as bI, type EmailFieldAdmin as bJ, type FieldAdminHooks as bK, type FieldAdminOnChangeHook as bL, type FieldAdminOnChangeHookArgs as bM, type FieldAdminOptionsHook as bN, type FieldAdminOptionsHookArgs as bO, type FieldAdminOptionsHookResult as bP, type FieldAfterReadHook as bQ, type FieldAfterReadHookArgs as bR, type FieldBase as bS, type FieldBeforeChangeHook as bT, type FieldBeforeChangeHookArgs as bU, type FieldHook as bV, type FieldHooks as bW, type FileData as bX, type GetDocumentResult as bY, type GlobalAfterChangeHook as bZ, type GlobalAfterReadHook as b_, type CollectionBeforeDeleteHook as ba, type CollectionBeforeReadHook as bb, type CollectionBeforeReadHookEntry as bc, type CollectionBeforeTransitionHook as bd, type CollectionListComponentSlots as be, type CollectionRAGConfig as bf, type CollectionSchemaResult as bg, type CollectionSummaryResult as bh, type CollectionViewComponentSlots as bi, type CountOperation as bj, type CustomAdminAuthProvider as bk, type DatabaseAdapter as bl, type DateFieldAdmin as bm, type DateFormat as bn, type DefaultValueContext as bo, type DefineActionOptions as bp, type DefineCalendarViewOptions as bq, type DefineCardsViewOptions as br, type DefineGanttViewOptions as bs, type DefineKanbanViewOptions as bt, type DefineTableViewOptions as bu, type DefineViewBaseOptions as bv, type DefineViewOptions as bw, type DetailSpan as bx, type DisplayTone as by, type DisplayVariant as bz, type WorkflowTransition as c, type WorkflowTransitionContext as c$, type GlobalBeforeChangeHook as c0, type GlobalBeforeChangeHookEntry as c1, type GlobalBeforeReadHook as c2, type GlobalBeforeReadHookEntry as c3, type GlobalRAGConfig as c4, type GlobalSchemaResult as c5, type GlobalSummaryResult as c6, type HeadingLevel as c7, type HookFunction as c8, type IconFieldAdmin as c9, type RichTextFeature as cA, type RichTextFieldConfig as cB, type SelectFieldAdmin as cC, type SqlWhereResult as cD, type StorageAdapter as cE, type TextFieldAdmin as cF, type TextFormat as cG, type TextareaFieldAdmin as cH, type TrustProxyConfig as cI, type TypedField as cJ, type UploadConfig as cK, type UrlFieldAdmin as cL, type UrlLinkValue as cM, type ViewActionFeatures as cN, type ViewComponentSlots as cO, type ViewConfig as cP, type ViewLayout as cQ, type ViewMetric as cR, type ViewSubMetric as cS, type WhereClause as cT, type WhereOperator as cU, type WhereOperatorName as cV, type WordLimitFieldAdmin as cW, type WordLimitFieldConfig as cX, type WorkflowMetadata as cY, type WorkflowRole as cZ, type WorkflowState as c_, type ImageService as ca, type ImageTransformOptions as cb, type InferAggregateResult as cc, type JoinFieldAdmin as cd, type JsonFieldAdmin as ce, type JsonFormat as cf, LIFECYCLE_EVENT_NAMES as cg, type LifecycleEventHandler as ch, type LinkFormat as ci, type MetricColor as cj, type MultiSelectFieldAdmin as ck, type NamedAccessPolicy as cl, type NumberFieldAdmin as cm, type NumberFormat as cn, type NumberLimitFieldAdmin as co, type NumberLimitFieldConfig as cp, type NumericOperation as cq, type OIDCAdminAuthProvider as cr, type OptionFormat as cs, type PaginatedResult as ct, type PublicAdminAuthProvider as cu, type QueryCollectionResult as cv, type RAGSearchResult as cw, type RadioFieldAdmin as cx, type RateLimitConfig as cy, type ReadonlyDatabaseAdapter as cz, type LifecycleEvent as d, defineAction as d0, defineCalendarView as d1, defineCardsView as d2, defineGanttView as d3, defineKanbanView as d4, defineTableView as d5, defineView as d6, isAICollection as d7, parseMongoWhere as d8, parseSqlWhere as d9, verifyCollectionToken as dA, type CollectionTokenPayload as da, DEFAULT_SESSION_EXPIRY as db, type DyrectedObservabilityRuntime as dc, type RequestBodyCapture as dd, type RequestTraceContext as de, type ResolvedObservabilityConfig as df, attachRequestMetrics as dg, bindObservabilityRuntime as dh, buildRequestLogger as di, captureRequestBody as dj, createDyrectedApp as dk, createObservabilityRuntime as dl, createRequestSpan as dm, decodeCollectionToken as dn, endRequestSpan as dp, getConfigLogger as dq, getObservabilityRuntime as dr, getRequestLogger as ds, redactBody as dt, redactHeaders as du, renderPrometheusMetrics as dv, resolveObservabilityConfig as dw, resolveSessionTokenExpiry as dx, shouldSampleRequest as dy, signCollectionToken as dz, type BaseDocument as e, type DetailActionOptions as f, type DetailAction as g, type DetailComputedOptions as h, type ComputedHandler as i, type DetailComputed as j, type DetailCustomOptions as k, type DetailCustom as l, type DetailDividerOptions as m, type DetailDivider as n, type DisplayFieldOptions as o, type DetailField as p, type DetailItem as q, type DetailGridOptions as r, type DetailGrid as s, type DetailRepeatOptions as t, type DetailRepeat as u, type DetailSectionOptions as v, type DetailSection as w, type DetailTabOptions as x, type DetailTab as y, type DetailTabsOptions as z };
|
package/dist/index.cjs
CHANGED
|
@@ -1791,13 +1791,18 @@ __export(index_exports, {
|
|
|
1791
1791
|
AI_THREADS_COLLECTION: () => AI_THREADS_COLLECTION,
|
|
1792
1792
|
BUILTIN_JEXL_HELPERS: () => BUILTIN_JEXL_HELPERS,
|
|
1793
1793
|
ConfigValidationError: () => ConfigValidationError,
|
|
1794
|
+
ConflictError: () => ConflictError,
|
|
1794
1795
|
DyrectedAIError: () => DyrectedAIError,
|
|
1796
|
+
DyrectedError: () => DyrectedError,
|
|
1795
1797
|
FieldConditionBuilder: () => FieldConditionBuilder,
|
|
1798
|
+
ForbiddenError: () => ForbiddenError,
|
|
1796
1799
|
LIFECYCLE_EVENTS_COLLECTION: () => LIFECYCLE_EVENTS_COLLECTION,
|
|
1797
1800
|
LIFECYCLE_EVENT_NAMES: () => LIFECYCLE_EVENT_NAMES,
|
|
1798
1801
|
MatchBuilder: () => MatchBuilder,
|
|
1799
1802
|
NON_NEGOTIABLE_CREDENTIAL_FIELDS: () => NON_NEGOTIABLE_CREDENTIAL_FIELDS,
|
|
1803
|
+
NotFoundError: () => NotFoundError,
|
|
1800
1804
|
PII_REGEX_PATTERNS: () => PII_REGEX_PATTERNS,
|
|
1805
|
+
ValidationError: () => ValidationError,
|
|
1801
1806
|
WORKFLOW_HISTORY_COLLECTION: () => WORKFLOW_HISTORY_COLLECTION,
|
|
1802
1807
|
abs: () => abs,
|
|
1803
1808
|
addDays: () => addDays,
|
|
@@ -1864,6 +1869,7 @@ __export(index_exports, {
|
|
|
1864
1869
|
diffDays: () => diffDays,
|
|
1865
1870
|
dispatchLifecycleEvent: () => dispatchLifecycleEvent,
|
|
1866
1871
|
dispatchPendingLifecycleEvents: () => dispatchPendingLifecycleEvents,
|
|
1872
|
+
displayAction: () => displayAction,
|
|
1867
1873
|
displayComputed: () => displayComputed,
|
|
1868
1874
|
displayCustom: () => displayCustom,
|
|
1869
1875
|
displayCustomComponent: () => displayCustomComponent,
|
|
@@ -3890,6 +3896,45 @@ function normalizeConfig(config) {
|
|
|
3890
3896
|
};
|
|
3891
3897
|
}
|
|
3892
3898
|
|
|
3899
|
+
// src/utils/errors.ts
|
|
3900
|
+
var DyrectedError = class _DyrectedError extends Error {
|
|
3901
|
+
statusCode;
|
|
3902
|
+
constructor(message, statusCode = 500) {
|
|
3903
|
+
super(message);
|
|
3904
|
+
this.name = "DyrectedError";
|
|
3905
|
+
this.statusCode = statusCode;
|
|
3906
|
+
Object.setPrototypeOf(this, _DyrectedError.prototype);
|
|
3907
|
+
}
|
|
3908
|
+
};
|
|
3909
|
+
var ValidationError = class _ValidationError extends DyrectedError {
|
|
3910
|
+
constructor(message) {
|
|
3911
|
+
super(message, 400);
|
|
3912
|
+
this.name = "ValidationError";
|
|
3913
|
+
Object.setPrototypeOf(this, _ValidationError.prototype);
|
|
3914
|
+
}
|
|
3915
|
+
};
|
|
3916
|
+
var ForbiddenError = class _ForbiddenError extends DyrectedError {
|
|
3917
|
+
constructor(message) {
|
|
3918
|
+
super(message, 403);
|
|
3919
|
+
this.name = "ForbiddenError";
|
|
3920
|
+
Object.setPrototypeOf(this, _ForbiddenError.prototype);
|
|
3921
|
+
}
|
|
3922
|
+
};
|
|
3923
|
+
var NotFoundError = class _NotFoundError extends DyrectedError {
|
|
3924
|
+
constructor(message) {
|
|
3925
|
+
super(message, 404);
|
|
3926
|
+
this.name = "NotFoundError";
|
|
3927
|
+
Object.setPrototypeOf(this, _NotFoundError.prototype);
|
|
3928
|
+
}
|
|
3929
|
+
};
|
|
3930
|
+
var ConflictError = class _ConflictError extends DyrectedError {
|
|
3931
|
+
constructor(message) {
|
|
3932
|
+
super(message, 409);
|
|
3933
|
+
this.name = "ConflictError";
|
|
3934
|
+
Object.setPrototypeOf(this, _ConflictError.prototype);
|
|
3935
|
+
}
|
|
3936
|
+
};
|
|
3937
|
+
|
|
3893
3938
|
// src/utils/parse-where.ts
|
|
3894
3939
|
function assertNever(op, context) {
|
|
3895
3940
|
throw new Error(`[dyrected/core] Unhandled where operator "${op}" in ${context}`);
|
|
@@ -5749,6 +5794,13 @@ function displayCustom(name, options) {
|
|
|
5749
5794
|
function displayCustomComponent(name, options) {
|
|
5750
5795
|
return displayCustom(name, options);
|
|
5751
5796
|
}
|
|
5797
|
+
function displayAction(name, options) {
|
|
5798
|
+
return {
|
|
5799
|
+
type: "action",
|
|
5800
|
+
name,
|
|
5801
|
+
options
|
|
5802
|
+
};
|
|
5803
|
+
}
|
|
5752
5804
|
async function evaluateDetailComputed(detail, doc, user, db) {
|
|
5753
5805
|
if (!doc || !detail || !Array.isArray(detail)) {
|
|
5754
5806
|
return doc;
|
|
@@ -5821,6 +5873,12 @@ function generateDefaultDetailSchema(schema) {
|
|
|
5821
5873
|
if (SENSITIVE_DETAIL_FIELDS.has(field.name)) continue;
|
|
5822
5874
|
if (field.hidden) continue;
|
|
5823
5875
|
if (field.admin?.hidden) continue;
|
|
5876
|
+
if (field.type === "join") {
|
|
5877
|
+
const joinColumns = field.admin?.columns;
|
|
5878
|
+
const repeatItems = Array.isArray(joinColumns) && joinColumns.length > 0 ? joinColumns.map((col) => displayField(col, { span: 12 })) : [displayComputed("Item", "doc.title || doc.name || doc.label || doc.slug || doc.id")];
|
|
5879
|
+
mainFields.push(displayRepeat(field.name, repeatItems, { span: 12, layout: "table" }));
|
|
5880
|
+
continue;
|
|
5881
|
+
}
|
|
5824
5882
|
const isSidebar = sidebarFieldTypes.has(field.type) && field.type !== "relationship" && !field.hasMany;
|
|
5825
5883
|
if (isSidebar && sidebarFields.length < 5) {
|
|
5826
5884
|
sidebarFields.push(
|
|
@@ -6563,13 +6621,18 @@ function defineTab(args) {
|
|
|
6563
6621
|
AI_THREADS_COLLECTION,
|
|
6564
6622
|
BUILTIN_JEXL_HELPERS,
|
|
6565
6623
|
ConfigValidationError,
|
|
6624
|
+
ConflictError,
|
|
6566
6625
|
DyrectedAIError,
|
|
6626
|
+
DyrectedError,
|
|
6567
6627
|
FieldConditionBuilder,
|
|
6628
|
+
ForbiddenError,
|
|
6568
6629
|
LIFECYCLE_EVENTS_COLLECTION,
|
|
6569
6630
|
LIFECYCLE_EVENT_NAMES,
|
|
6570
6631
|
MatchBuilder,
|
|
6571
6632
|
NON_NEGOTIABLE_CREDENTIAL_FIELDS,
|
|
6633
|
+
NotFoundError,
|
|
6572
6634
|
PII_REGEX_PATTERNS,
|
|
6635
|
+
ValidationError,
|
|
6573
6636
|
WORKFLOW_HISTORY_COLLECTION,
|
|
6574
6637
|
abs,
|
|
6575
6638
|
addDays,
|
|
@@ -6636,6 +6699,7 @@ function defineTab(args) {
|
|
|
6636
6699
|
diffDays,
|
|
6637
6700
|
dispatchLifecycleEvent,
|
|
6638
6701
|
dispatchPendingLifecycleEvents,
|
|
6702
|
+
displayAction,
|
|
6639
6703
|
displayComputed,
|
|
6640
6704
|
displayCustom,
|
|
6641
6705
|
displayCustomComponent,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as Field, B as Block, C as CollectionConfig, D as DyrectedConfig, A as AdminAuthConfig, P as PublicAdminAuthConfig, G as GlobalConfig, a as DeclarativeHookExpression, W as WorkflowConfig, b as AuthenticatedUser, c as WorkflowTransition, L as LifecycleEventName, d as LifecycleEvent, e as BaseDocument, H as HookRequestContext, f as
|
|
2
|
-
export {
|
|
1
|
+
import { F as Field, B as Block, C as CollectionConfig, D as DyrectedConfig, A as AdminAuthConfig, P as PublicAdminAuthConfig, G as GlobalConfig, a as DeclarativeHookExpression, W as WorkflowConfig, b as AuthenticatedUser, c as WorkflowTransition, L as LifecycleEventName, d as LifecycleEvent, e as BaseDocument, H as HookRequestContext, f as DetailActionOptions, g as DetailAction, h as DetailComputedOptions, i as ComputedHandler, j as DetailComputed, k as DetailCustomOptions, l as DetailCustom, m as DetailDividerOptions, n as DetailDivider, o as DisplayFieldOptions, p as DetailField, q as DetailItem, r as DetailGridOptions, s as DetailGrid, t as DetailRepeatOptions, u as DetailRepeat, v as DetailSectionOptions, w as DetailSection, x as DetailTabOptions, y as DetailTab, z as DetailTabsOptions, E as DetailTabs, I as DetailTextOptions, J as DetailText, K as DetailSchema, M as DyrectedContext, N as AIConfig, O as AIPIIConfig, Q as ArrayField, R as FieldType, S as BooleanField, T as AuthConfig, U as AccessPolicyResolver, V as DateField, X as DateTimeField, Y as EmailField, Z as IconField, _ as ImageField, $ as JoinField, a0 as JsonField, a1 as MultiSelectField, a2 as NumberField, a3 as ObjectField, a4 as RadioField, a5 as RelationshipField, a6 as RichTextField, a7 as RowField, a8 as SelectField, a9 as TextField, aa as TextareaField, ab as TimeField, ac as UrlField } from './app-Cmp5lFLJ.cjs';
|
|
2
|
+
export { ad as AIAction, ae as AIActionStatus, af as AIActionType, ag as AIAuditActionType, ah as AIAuditRecord, ai as AIChunk, aj as AIMessage, ak as AIPIIPattern, al as AIRateLimitResult, am as AIRateLimitStore, an as AIThread, ao as AIToolContext, ap as AIToolDefinition, aq as AI_ACTIONS_COLLECTION, ar as AI_AUDIT_COLLECTION, as as AI_CHUNKS_COLLECTION, at as AI_MESSAGES_COLLECTION, au as AI_THREADS_COLLECTION, av as AccessConfig, aw as AccessFunction, ax as AccessFunctionArgs, ay as AccessResult, az as AccessRule, aA as ActionConfig, aB as ActionConfigBase, aC as ActionConfigWithHandler, aD as ActionConfigWithMutation, 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 AggregateCollectionResult, aU as AggregateInput, aV as AggregateOperation, aW as AggregateResult, aX as BaseAdminAuthProvider, aY as BaseFieldAdmin, aZ as BlockVariant, a_ as BlocksField, a$ as BooleanFieldAdmin, b0 as BooleanFormat, b1 as CharacterLimitFieldAdmin, b2 as CharacterLimitFieldConfig, b3 as CollectionAfterChangeHook, b4 as CollectionAfterDeleteHook, b5 as CollectionAfterReadHook, b6 as CollectionAfterReadHookEntry, b7 as CollectionAfterTransitionHook, b8 as CollectionBeforeChangeHook, b9 as CollectionBeforeChangeHookEntry, ba as CollectionBeforeDeleteHook, bb as CollectionBeforeReadHook, bc as CollectionBeforeReadHookEntry, bd as CollectionBeforeTransitionHook, be as CollectionListComponentSlots, bf as CollectionRAGConfig, bg as CollectionSchemaResult, bh as CollectionSummaryResult, bi as CollectionViewComponentSlots, bj as CountOperation, bk as CustomAdminAuthProvider, bl as DatabaseAdapter, bm as DateFieldAdmin, bn as DateFormat, bo as DefaultValueContext, bp as DefineActionOptions, bq as DefineCalendarViewOptions, br as DefineCardsViewOptions, bs as DefineGanttViewOptions, bt as DefineKanbanViewOptions, bu as DefineTableViewOptions, bv as DefineViewBaseOptions, bw as DefineViewOptions, bx as DetailSpan, by as DisplayTone, bz as DisplayVariant, bA as DistinctCountOperation, bB as DistinctValuesOperation, bC as DynamicOptionItem, bD as DynamicOptionsConfig, bE as DynamicOptionsResolver, bF as DynamicOptionsResolverArgs, bG as DyrectedAIContext, bH as DyrectedLoggerConfig, bI as DyrectedObservabilityConfig, bJ as EmailFieldAdmin, bK as FieldAdminHooks, bL as FieldAdminOnChangeHook, bM as FieldAdminOnChangeHookArgs, bN as FieldAdminOptionsHook, bO as FieldAdminOptionsHookArgs, bP as FieldAdminOptionsHookResult, bQ as FieldAfterReadHook, bR as FieldAfterReadHookArgs, bS as FieldBase, bT as FieldBeforeChangeHook, bU as FieldBeforeChangeHookArgs, bV as FieldHook, bW as FieldHooks, bX as FileData, bY as GetDocumentResult, bZ as GlobalAfterChangeHook, b_ as GlobalAfterReadHook, b$ as GlobalAfterReadHookEntry, c0 as GlobalBeforeChangeHook, c1 as GlobalBeforeChangeHookEntry, c2 as GlobalBeforeReadHook, c3 as GlobalBeforeReadHookEntry, c4 as GlobalRAGConfig, c5 as GlobalSchemaResult, c6 as GlobalSummaryResult, c7 as HeadingLevel, c8 as HookFunction, c9 as IconFieldAdmin, ca as ImageService, cb as ImageTransformOptions, cc as InferAggregateResult, cd as JoinFieldAdmin, ce as JsonFieldAdmin, cf as JsonFormat, cg as LIFECYCLE_EVENT_NAMES, ch as LifecycleEventHandler, ci as LinkFormat, cj as MetricColor, ck as MultiSelectFieldAdmin, cl as NamedAccessPolicy, cm as NumberFieldAdmin, cn as NumberFormat, co as NumberLimitFieldAdmin, cp as NumberLimitFieldConfig, cq as NumericOperation, cr as OIDCAdminAuthProvider, cs as OptionFormat, ct as PaginatedResult, cu as PublicAdminAuthProvider, cv as QueryCollectionResult, cw as RAGSearchResult, cx as RadioFieldAdmin, cy as RateLimitConfig, cz as ReadonlyDatabaseAdapter, cA as RichTextFeature, cB as RichTextFieldConfig, cC as SelectFieldAdmin, cD as SqlWhereResult, cE as StorageAdapter, cF as TextFieldAdmin, cG as TextFormat, cH as TextareaFieldAdmin, cI as TrustProxyConfig, cJ as TypedField, cK as UploadConfig, cL as UrlFieldAdmin, cM as UrlLinkValue, cN as ViewActionFeatures, cO as ViewComponentSlots, cP as ViewConfig, cQ as ViewLayout, cR as ViewMetric, cS as ViewSubMetric, cT as WhereClause, cU as WhereOperator, cV as WhereOperatorName, cW as WordLimitFieldAdmin, cX as WordLimitFieldConfig, cY as WorkflowMetadata, cZ as WorkflowRole, c_ as WorkflowState, c$ as WorkflowTransitionContext, d0 as defineAction, d1 as defineCalendarView, d2 as defineCardsView, d3 as defineGanttView, d4 as defineKanbanView, d5 as defineTableView, d6 as defineView, d7 as isAICollection, d8 as parseMongoWhere, d9 as parseSqlWhere } from './app-Cmp5lFLJ.cjs';
|
|
3
3
|
import jexl from 'jexl';
|
|
4
4
|
import { Context } from 'hono';
|
|
5
5
|
export { z } from 'zod';
|
|
@@ -155,6 +155,48 @@ declare function getAdminRoleForCollection(collection?: CollectionConfig | null)
|
|
|
155
155
|
*/
|
|
156
156
|
declare function isUserAdmin(user: any, collection?: CollectionConfig | null): boolean;
|
|
157
157
|
|
|
158
|
+
/**
|
|
159
|
+
* User-facing errors for self-hosted server code (action handlers, hooks).
|
|
160
|
+
*
|
|
161
|
+
* Throw these instead of hand-rolling `{ statusCode }` onto a plain `Error`.
|
|
162
|
+
* The action pipeline reads `statusCode` for the HTTP status (defaulting to
|
|
163
|
+
* `500` when absent) and `message` for the response body — which is what the
|
|
164
|
+
* SDK surfaces and the admin shows in its failure toast. Write the message
|
|
165
|
+
* for the editor who will read it.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```ts
|
|
169
|
+
* import { ValidationError } from "@dyrected/core";
|
|
170
|
+
*
|
|
171
|
+
* handler: async ({ input }) => {
|
|
172
|
+
* if (!input.refundReason) {
|
|
173
|
+
* throw new ValidationError("Enter a refund reason so support can follow up.");
|
|
174
|
+
* }
|
|
175
|
+
* return { status: "refunded" };
|
|
176
|
+
* }
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
declare class DyrectedError extends Error {
|
|
180
|
+
readonly statusCode: number;
|
|
181
|
+
constructor(message: string, statusCode?: number);
|
|
182
|
+
}
|
|
183
|
+
/** Bad input the editor can fix and retry. Answered with `400`. */
|
|
184
|
+
declare class ValidationError extends DyrectedError {
|
|
185
|
+
constructor(message: string);
|
|
186
|
+
}
|
|
187
|
+
/** The editor is not allowed to do this. Answered with `403`. */
|
|
188
|
+
declare class ForbiddenError extends DyrectedError {
|
|
189
|
+
constructor(message: string);
|
|
190
|
+
}
|
|
191
|
+
/** A referenced record does not exist. Answered with `404`. */
|
|
192
|
+
declare class NotFoundError extends DyrectedError {
|
|
193
|
+
constructor(message: string);
|
|
194
|
+
}
|
|
195
|
+
/** The current state conflicts with the requested change. Answered with `409`. */
|
|
196
|
+
declare class ConflictError extends DyrectedError {
|
|
197
|
+
constructor(message: string);
|
|
198
|
+
}
|
|
199
|
+
|
|
158
200
|
type SortDirection = 'ASC' | 'DESC';
|
|
159
201
|
interface SortClause {
|
|
160
202
|
field: string;
|
|
@@ -725,6 +767,17 @@ declare function displayCustom<TDoc = any>(name: string, options?: DetailCustomO
|
|
|
725
767
|
* Alias for `displayCustom` to render a custom component in a Detail View layout.
|
|
726
768
|
*/
|
|
727
769
|
declare function displayCustomComponent<TDoc = any>(name: string, options?: DetailCustomOptions<TDoc>): DetailCustom<TDoc>;
|
|
770
|
+
/**
|
|
771
|
+
* Renders a button for a named action (defined in `collection.actions`) at this
|
|
772
|
+
* position in a Detail View — the same action, dialog, and execution as the
|
|
773
|
+
* header toolbar, just placed inline.
|
|
774
|
+
*
|
|
775
|
+
* @example
|
|
776
|
+
* ```ts
|
|
777
|
+
* displayAction('markShipped', { variant: 'default', span: 4 })
|
|
778
|
+
* ```
|
|
779
|
+
*/
|
|
780
|
+
declare function displayAction(name: string, options?: DetailActionOptions): DetailAction;
|
|
728
781
|
/**
|
|
729
782
|
* Evaluates server-side computed functions and JEXL expressions from a detail schema
|
|
730
783
|
* and attaches them to `doc._meta.computed`.
|
|
@@ -1763,4 +1816,4 @@ declare function defineTab<const T extends readonly Field[]>(args: {
|
|
|
1763
1816
|
fields: T;
|
|
1764
1817
|
}): T;
|
|
1765
1818
|
|
|
1766
|
-
export { AIConfig, type AIErrorCode, AIPIIConfig, type AccessConditions, AccessPolicyResolver, AdminAuthConfig, ArrayField, AuthConfig, type AuthDocFields, AuthenticatedUser, BUILTIN_JEXL_HELPERS, BaseDocument, Block, 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, DyrectedAIError, DyrectedConfig, EmailField, type ExprFunction, type ExtractCollectionSlugs, Field, FieldConditionBuilder, FieldType, GlobalConfig, HookRequestContext, IconField, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MatchBuilder, MultiSelectField, NON_NEGOTIABLE_CREDENTIAL_FIELDS, NumberField, ObjectField, PII_REGEX_PATTERNS, type Prettify, PublicAdminAuthConfig, type PublishingWorkflowOptions, RadioField, RelationshipField, RichTextField, RowField, type SanitizeDocForAIOptions, SelectField, type SortClause, type SortDirection, type SqlSortDialect, type SystemDocFields, TextField, TextareaField, TimeField, type UploadDocFields, UrlField, WORKFLOW_HISTORY_COLLECTION, type WhenFunction, WorkflowConfig, WorkflowTransition, abs, addDays, asCollection, assertValidAdminConditionsInConfig, assertValidDeclarativeAccessInConfig, assertValidDeclarativeHookExpression, assertValidDeclarativeHookResult, assertValidDeclarativeHooksInConfig, assertValidPreviewUrlsInConfig, availableWorkflowTransitions, buildSqlOrderBy, canViewWorkflowDraft, capitalize, ceil, clamp, coalesce, collectAdminConditionValidationIssues, collectConfigDiagnostics, collectDeclarativeAccessValidationIssues, collectDeclarativeHookValidationIssues, collectPreviewUrlValidationIssues, compact, count, createLifecycleEvent, createWorkflowDocument, defaultValue, defineArrayField, defineBlock, defineBlocksField, defineBooleanField, defineCollection, defineConfig, defineDateField, defineDateTimeField, defineEmailField, defineField, defineGlobal, defineIconField, defineImageField, defineJoinField, defineJsonField, defineMultiSelectField, defineNumberField, defineObjectField, definePublishingWorkflow, defineRadioField, defineRelationshipField, defineRichTextField, defineRowField, defineSelectField, defineTab, defineTextField, defineTextareaField, defineTimeField, defineUrlField, diffDays, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, displayComputed, displayCustom, displayCustomComponent, displayDivider, displayField, displayGrid, displayRepeat, displaySection, displayTab, displayTabs, displayText, endsWith, evaluateDetailComputed, evaluateJexl, evaluateJexlSync, executeFieldAfterRead, executeFieldBeforeChange, expr, first, floor, formatConfigDiagnostics, formatDate, formatJexlValue, generateDefaultDetailSchema, generateOpenApi, get, getAdminAuthCollection, getAdminRoleForCollection, getAllowedSitesForUser, getPublicAdminAuthConfig, includes, initializeWorkflowDocument, isConfigValidationError, isDetailItemVisible, isEmpty, isFuture, isPast, isSiteAuthorized, isUserAdmin, join, last, length, lower, maskEmail, maskPhone, maskTextPII, materializeWorkflowDocument, max, min, normalizeConfig, normalizeDetailItem, now, numericFieldNames, parseSort, pow, publishedStateName, publishingWorkflow, readingTime, registerJexlHelpers, replace, resolveAdminAuthCollection, resolveAuthorizedSiteId, round, runCollectionHooks, sanitizeDocForAI, saveWorkflowDraft, simplePublishingWorkflow, slugify, sqrt, startsWith, sum, today, transitionWorkflow, trim, truncate, unique, upper, validateAdminConditionExpression, validateDeclarativeAccessExpression, validateDeclarativeHookExpression, validatePreviewUrlExpression, when, wordCount, workflowCapabilities };
|
|
1819
|
+
export { AIConfig, type AIErrorCode, AIPIIConfig, type AccessConditions, AccessPolicyResolver, AdminAuthConfig, ArrayField, AuthConfig, type AuthDocFields, AuthenticatedUser, BUILTIN_JEXL_HELPERS, BaseDocument, Block, BooleanField, CollectionConfig, ComputedHandler, type ConfigDiagnostic, ConfigValidationError, ConflictError, DateField, DateTimeField, type DeclarativeAccessSurface, type DeclarativeAccessValidationIssue, type DeclarativeAdminSurface, type DeclarativeAdminValidationIssue, DeclarativeHookExpression, type DeclarativeHookSurface, type DeclarativeHookValidationIssue, type DeclarativePreviewSurface, type DeclarativePreviewValidationIssue, DetailAction, DetailActionOptions, DetailComputed, DetailComputedOptions, DetailCustom, DetailCustomOptions, DetailDivider, DetailDividerOptions, DetailField, DetailGrid, DetailGridOptions, DetailItem, DetailRepeat, DetailRepeatOptions, DetailSchema, DetailSection, DetailSectionOptions, DetailTab, DetailTabOptions, DetailTabs, DetailTabsOptions, DetailText, DetailTextOptions, DisplayFieldOptions, DyrectedAIError, DyrectedConfig, DyrectedError, EmailField, type ExprFunction, type ExtractCollectionSlugs, Field, FieldConditionBuilder, FieldType, ForbiddenError, GlobalConfig, HookRequestContext, IconField, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MatchBuilder, MultiSelectField, NON_NEGOTIABLE_CREDENTIAL_FIELDS, NotFoundError, NumberField, ObjectField, PII_REGEX_PATTERNS, type Prettify, PublicAdminAuthConfig, type PublishingWorkflowOptions, RadioField, RelationshipField, RichTextField, RowField, type SanitizeDocForAIOptions, SelectField, type SortClause, type SortDirection, type SqlSortDialect, type SystemDocFields, TextField, TextareaField, TimeField, type UploadDocFields, UrlField, ValidationError, WORKFLOW_HISTORY_COLLECTION, type WhenFunction, WorkflowConfig, WorkflowTransition, abs, addDays, asCollection, assertValidAdminConditionsInConfig, assertValidDeclarativeAccessInConfig, assertValidDeclarativeHookExpression, assertValidDeclarativeHookResult, assertValidDeclarativeHooksInConfig, assertValidPreviewUrlsInConfig, availableWorkflowTransitions, buildSqlOrderBy, canViewWorkflowDraft, capitalize, ceil, clamp, coalesce, collectAdminConditionValidationIssues, collectConfigDiagnostics, collectDeclarativeAccessValidationIssues, collectDeclarativeHookValidationIssues, collectPreviewUrlValidationIssues, compact, count, createLifecycleEvent, createWorkflowDocument, defaultValue, defineArrayField, defineBlock, defineBlocksField, defineBooleanField, defineCollection, defineConfig, defineDateField, defineDateTimeField, defineEmailField, defineField, defineGlobal, defineIconField, defineImageField, defineJoinField, defineJsonField, defineMultiSelectField, defineNumberField, defineObjectField, definePublishingWorkflow, defineRadioField, defineRelationshipField, defineRichTextField, defineRowField, defineSelectField, defineTab, defineTextField, defineTextareaField, defineTimeField, defineUrlField, diffDays, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, displayAction, displayComputed, displayCustom, displayCustomComponent, displayDivider, displayField, displayGrid, displayRepeat, displaySection, displayTab, displayTabs, displayText, endsWith, evaluateDetailComputed, evaluateJexl, evaluateJexlSync, executeFieldAfterRead, executeFieldBeforeChange, expr, first, floor, formatConfigDiagnostics, formatDate, formatJexlValue, generateDefaultDetailSchema, generateOpenApi, get, getAdminAuthCollection, getAdminRoleForCollection, getAllowedSitesForUser, getPublicAdminAuthConfig, includes, initializeWorkflowDocument, isConfigValidationError, isDetailItemVisible, isEmpty, isFuture, isPast, isSiteAuthorized, isUserAdmin, join, last, length, lower, maskEmail, maskPhone, maskTextPII, materializeWorkflowDocument, max, min, normalizeConfig, normalizeDetailItem, now, numericFieldNames, parseSort, pow, publishedStateName, publishingWorkflow, readingTime, registerJexlHelpers, replace, resolveAdminAuthCollection, resolveAuthorizedSiteId, round, runCollectionHooks, sanitizeDocForAI, saveWorkflowDraft, simplePublishingWorkflow, slugify, sqrt, startsWith, sum, today, transitionWorkflow, trim, truncate, unique, upper, validateAdminConditionExpression, validateDeclarativeAccessExpression, validateDeclarativeHookExpression, validatePreviewUrlExpression, when, wordCount, workflowCapabilities };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as Field, B as Block, C as CollectionConfig, D as DyrectedConfig, A as AdminAuthConfig, P as PublicAdminAuthConfig, G as GlobalConfig, a as DeclarativeHookExpression, W as WorkflowConfig, b as AuthenticatedUser, c as WorkflowTransition, L as LifecycleEventName, d as LifecycleEvent, e as BaseDocument, H as HookRequestContext, f as
|
|
2
|
-
export {
|
|
1
|
+
import { F as Field, B as Block, C as CollectionConfig, D as DyrectedConfig, A as AdminAuthConfig, P as PublicAdminAuthConfig, G as GlobalConfig, a as DeclarativeHookExpression, W as WorkflowConfig, b as AuthenticatedUser, c as WorkflowTransition, L as LifecycleEventName, d as LifecycleEvent, e as BaseDocument, H as HookRequestContext, f as DetailActionOptions, g as DetailAction, h as DetailComputedOptions, i as ComputedHandler, j as DetailComputed, k as DetailCustomOptions, l as DetailCustom, m as DetailDividerOptions, n as DetailDivider, o as DisplayFieldOptions, p as DetailField, q as DetailItem, r as DetailGridOptions, s as DetailGrid, t as DetailRepeatOptions, u as DetailRepeat, v as DetailSectionOptions, w as DetailSection, x as DetailTabOptions, y as DetailTab, z as DetailTabsOptions, E as DetailTabs, I as DetailTextOptions, J as DetailText, K as DetailSchema, M as DyrectedContext, N as AIConfig, O as AIPIIConfig, Q as ArrayField, R as FieldType, S as BooleanField, T as AuthConfig, U as AccessPolicyResolver, V as DateField, X as DateTimeField, Y as EmailField, Z as IconField, _ as ImageField, $ as JoinField, a0 as JsonField, a1 as MultiSelectField, a2 as NumberField, a3 as ObjectField, a4 as RadioField, a5 as RelationshipField, a6 as RichTextField, a7 as RowField, a8 as SelectField, a9 as TextField, aa as TextareaField, ab as TimeField, ac as UrlField } from './app-Cmp5lFLJ.js';
|
|
2
|
+
export { ad as AIAction, ae as AIActionStatus, af as AIActionType, ag as AIAuditActionType, ah as AIAuditRecord, ai as AIChunk, aj as AIMessage, ak as AIPIIPattern, al as AIRateLimitResult, am as AIRateLimitStore, an as AIThread, ao as AIToolContext, ap as AIToolDefinition, aq as AI_ACTIONS_COLLECTION, ar as AI_AUDIT_COLLECTION, as as AI_CHUNKS_COLLECTION, at as AI_MESSAGES_COLLECTION, au as AI_THREADS_COLLECTION, av as AccessConfig, aw as AccessFunction, ax as AccessFunctionArgs, ay as AccessResult, az as AccessRule, aA as ActionConfig, aB as ActionConfigBase, aC as ActionConfigWithHandler, aD as ActionConfigWithMutation, 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 AggregateCollectionResult, aU as AggregateInput, aV as AggregateOperation, aW as AggregateResult, aX as BaseAdminAuthProvider, aY as BaseFieldAdmin, aZ as BlockVariant, a_ as BlocksField, a$ as BooleanFieldAdmin, b0 as BooleanFormat, b1 as CharacterLimitFieldAdmin, b2 as CharacterLimitFieldConfig, b3 as CollectionAfterChangeHook, b4 as CollectionAfterDeleteHook, b5 as CollectionAfterReadHook, b6 as CollectionAfterReadHookEntry, b7 as CollectionAfterTransitionHook, b8 as CollectionBeforeChangeHook, b9 as CollectionBeforeChangeHookEntry, ba as CollectionBeforeDeleteHook, bb as CollectionBeforeReadHook, bc as CollectionBeforeReadHookEntry, bd as CollectionBeforeTransitionHook, be as CollectionListComponentSlots, bf as CollectionRAGConfig, bg as CollectionSchemaResult, bh as CollectionSummaryResult, bi as CollectionViewComponentSlots, bj as CountOperation, bk as CustomAdminAuthProvider, bl as DatabaseAdapter, bm as DateFieldAdmin, bn as DateFormat, bo as DefaultValueContext, bp as DefineActionOptions, bq as DefineCalendarViewOptions, br as DefineCardsViewOptions, bs as DefineGanttViewOptions, bt as DefineKanbanViewOptions, bu as DefineTableViewOptions, bv as DefineViewBaseOptions, bw as DefineViewOptions, bx as DetailSpan, by as DisplayTone, bz as DisplayVariant, bA as DistinctCountOperation, bB as DistinctValuesOperation, bC as DynamicOptionItem, bD as DynamicOptionsConfig, bE as DynamicOptionsResolver, bF as DynamicOptionsResolverArgs, bG as DyrectedAIContext, bH as DyrectedLoggerConfig, bI as DyrectedObservabilityConfig, bJ as EmailFieldAdmin, bK as FieldAdminHooks, bL as FieldAdminOnChangeHook, bM as FieldAdminOnChangeHookArgs, bN as FieldAdminOptionsHook, bO as FieldAdminOptionsHookArgs, bP as FieldAdminOptionsHookResult, bQ as FieldAfterReadHook, bR as FieldAfterReadHookArgs, bS as FieldBase, bT as FieldBeforeChangeHook, bU as FieldBeforeChangeHookArgs, bV as FieldHook, bW as FieldHooks, bX as FileData, bY as GetDocumentResult, bZ as GlobalAfterChangeHook, b_ as GlobalAfterReadHook, b$ as GlobalAfterReadHookEntry, c0 as GlobalBeforeChangeHook, c1 as GlobalBeforeChangeHookEntry, c2 as GlobalBeforeReadHook, c3 as GlobalBeforeReadHookEntry, c4 as GlobalRAGConfig, c5 as GlobalSchemaResult, c6 as GlobalSummaryResult, c7 as HeadingLevel, c8 as HookFunction, c9 as IconFieldAdmin, ca as ImageService, cb as ImageTransformOptions, cc as InferAggregateResult, cd as JoinFieldAdmin, ce as JsonFieldAdmin, cf as JsonFormat, cg as LIFECYCLE_EVENT_NAMES, ch as LifecycleEventHandler, ci as LinkFormat, cj as MetricColor, ck as MultiSelectFieldAdmin, cl as NamedAccessPolicy, cm as NumberFieldAdmin, cn as NumberFormat, co as NumberLimitFieldAdmin, cp as NumberLimitFieldConfig, cq as NumericOperation, cr as OIDCAdminAuthProvider, cs as OptionFormat, ct as PaginatedResult, cu as PublicAdminAuthProvider, cv as QueryCollectionResult, cw as RAGSearchResult, cx as RadioFieldAdmin, cy as RateLimitConfig, cz as ReadonlyDatabaseAdapter, cA as RichTextFeature, cB as RichTextFieldConfig, cC as SelectFieldAdmin, cD as SqlWhereResult, cE as StorageAdapter, cF as TextFieldAdmin, cG as TextFormat, cH as TextareaFieldAdmin, cI as TrustProxyConfig, cJ as TypedField, cK as UploadConfig, cL as UrlFieldAdmin, cM as UrlLinkValue, cN as ViewActionFeatures, cO as ViewComponentSlots, cP as ViewConfig, cQ as ViewLayout, cR as ViewMetric, cS as ViewSubMetric, cT as WhereClause, cU as WhereOperator, cV as WhereOperatorName, cW as WordLimitFieldAdmin, cX as WordLimitFieldConfig, cY as WorkflowMetadata, cZ as WorkflowRole, c_ as WorkflowState, c$ as WorkflowTransitionContext, d0 as defineAction, d1 as defineCalendarView, d2 as defineCardsView, d3 as defineGanttView, d4 as defineKanbanView, d5 as defineTableView, d6 as defineView, d7 as isAICollection, d8 as parseMongoWhere, d9 as parseSqlWhere } from './app-Cmp5lFLJ.js';
|
|
3
3
|
import jexl from 'jexl';
|
|
4
4
|
import { Context } from 'hono';
|
|
5
5
|
export { z } from 'zod';
|
|
@@ -155,6 +155,48 @@ declare function getAdminRoleForCollection(collection?: CollectionConfig | null)
|
|
|
155
155
|
*/
|
|
156
156
|
declare function isUserAdmin(user: any, collection?: CollectionConfig | null): boolean;
|
|
157
157
|
|
|
158
|
+
/**
|
|
159
|
+
* User-facing errors for self-hosted server code (action handlers, hooks).
|
|
160
|
+
*
|
|
161
|
+
* Throw these instead of hand-rolling `{ statusCode }` onto a plain `Error`.
|
|
162
|
+
* The action pipeline reads `statusCode` for the HTTP status (defaulting to
|
|
163
|
+
* `500` when absent) and `message` for the response body — which is what the
|
|
164
|
+
* SDK surfaces and the admin shows in its failure toast. Write the message
|
|
165
|
+
* for the editor who will read it.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```ts
|
|
169
|
+
* import { ValidationError } from "@dyrected/core";
|
|
170
|
+
*
|
|
171
|
+
* handler: async ({ input }) => {
|
|
172
|
+
* if (!input.refundReason) {
|
|
173
|
+
* throw new ValidationError("Enter a refund reason so support can follow up.");
|
|
174
|
+
* }
|
|
175
|
+
* return { status: "refunded" };
|
|
176
|
+
* }
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
declare class DyrectedError extends Error {
|
|
180
|
+
readonly statusCode: number;
|
|
181
|
+
constructor(message: string, statusCode?: number);
|
|
182
|
+
}
|
|
183
|
+
/** Bad input the editor can fix and retry. Answered with `400`. */
|
|
184
|
+
declare class ValidationError extends DyrectedError {
|
|
185
|
+
constructor(message: string);
|
|
186
|
+
}
|
|
187
|
+
/** The editor is not allowed to do this. Answered with `403`. */
|
|
188
|
+
declare class ForbiddenError extends DyrectedError {
|
|
189
|
+
constructor(message: string);
|
|
190
|
+
}
|
|
191
|
+
/** A referenced record does not exist. Answered with `404`. */
|
|
192
|
+
declare class NotFoundError extends DyrectedError {
|
|
193
|
+
constructor(message: string);
|
|
194
|
+
}
|
|
195
|
+
/** The current state conflicts with the requested change. Answered with `409`. */
|
|
196
|
+
declare class ConflictError extends DyrectedError {
|
|
197
|
+
constructor(message: string);
|
|
198
|
+
}
|
|
199
|
+
|
|
158
200
|
type SortDirection = 'ASC' | 'DESC';
|
|
159
201
|
interface SortClause {
|
|
160
202
|
field: string;
|
|
@@ -725,6 +767,17 @@ declare function displayCustom<TDoc = any>(name: string, options?: DetailCustomO
|
|
|
725
767
|
* Alias for `displayCustom` to render a custom component in a Detail View layout.
|
|
726
768
|
*/
|
|
727
769
|
declare function displayCustomComponent<TDoc = any>(name: string, options?: DetailCustomOptions<TDoc>): DetailCustom<TDoc>;
|
|
770
|
+
/**
|
|
771
|
+
* Renders a button for a named action (defined in `collection.actions`) at this
|
|
772
|
+
* position in a Detail View — the same action, dialog, and execution as the
|
|
773
|
+
* header toolbar, just placed inline.
|
|
774
|
+
*
|
|
775
|
+
* @example
|
|
776
|
+
* ```ts
|
|
777
|
+
* displayAction('markShipped', { variant: 'default', span: 4 })
|
|
778
|
+
* ```
|
|
779
|
+
*/
|
|
780
|
+
declare function displayAction(name: string, options?: DetailActionOptions): DetailAction;
|
|
728
781
|
/**
|
|
729
782
|
* Evaluates server-side computed functions and JEXL expressions from a detail schema
|
|
730
783
|
* and attaches them to `doc._meta.computed`.
|
|
@@ -1763,4 +1816,4 @@ declare function defineTab<const T extends readonly Field[]>(args: {
|
|
|
1763
1816
|
fields: T;
|
|
1764
1817
|
}): T;
|
|
1765
1818
|
|
|
1766
|
-
export { AIConfig, type AIErrorCode, AIPIIConfig, type AccessConditions, AccessPolicyResolver, AdminAuthConfig, ArrayField, AuthConfig, type AuthDocFields, AuthenticatedUser, BUILTIN_JEXL_HELPERS, BaseDocument, Block, 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, DyrectedAIError, DyrectedConfig, EmailField, type ExprFunction, type ExtractCollectionSlugs, Field, FieldConditionBuilder, FieldType, GlobalConfig, HookRequestContext, IconField, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MatchBuilder, MultiSelectField, NON_NEGOTIABLE_CREDENTIAL_FIELDS, NumberField, ObjectField, PII_REGEX_PATTERNS, type Prettify, PublicAdminAuthConfig, type PublishingWorkflowOptions, RadioField, RelationshipField, RichTextField, RowField, type SanitizeDocForAIOptions, SelectField, type SortClause, type SortDirection, type SqlSortDialect, type SystemDocFields, TextField, TextareaField, TimeField, type UploadDocFields, UrlField, WORKFLOW_HISTORY_COLLECTION, type WhenFunction, WorkflowConfig, WorkflowTransition, abs, addDays, asCollection, assertValidAdminConditionsInConfig, assertValidDeclarativeAccessInConfig, assertValidDeclarativeHookExpression, assertValidDeclarativeHookResult, assertValidDeclarativeHooksInConfig, assertValidPreviewUrlsInConfig, availableWorkflowTransitions, buildSqlOrderBy, canViewWorkflowDraft, capitalize, ceil, clamp, coalesce, collectAdminConditionValidationIssues, collectConfigDiagnostics, collectDeclarativeAccessValidationIssues, collectDeclarativeHookValidationIssues, collectPreviewUrlValidationIssues, compact, count, createLifecycleEvent, createWorkflowDocument, defaultValue, defineArrayField, defineBlock, defineBlocksField, defineBooleanField, defineCollection, defineConfig, defineDateField, defineDateTimeField, defineEmailField, defineField, defineGlobal, defineIconField, defineImageField, defineJoinField, defineJsonField, defineMultiSelectField, defineNumberField, defineObjectField, definePublishingWorkflow, defineRadioField, defineRelationshipField, defineRichTextField, defineRowField, defineSelectField, defineTab, defineTextField, defineTextareaField, defineTimeField, defineUrlField, diffDays, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, displayComputed, displayCustom, displayCustomComponent, displayDivider, displayField, displayGrid, displayRepeat, displaySection, displayTab, displayTabs, displayText, endsWith, evaluateDetailComputed, evaluateJexl, evaluateJexlSync, executeFieldAfterRead, executeFieldBeforeChange, expr, first, floor, formatConfigDiagnostics, formatDate, formatJexlValue, generateDefaultDetailSchema, generateOpenApi, get, getAdminAuthCollection, getAdminRoleForCollection, getAllowedSitesForUser, getPublicAdminAuthConfig, includes, initializeWorkflowDocument, isConfigValidationError, isDetailItemVisible, isEmpty, isFuture, isPast, isSiteAuthorized, isUserAdmin, join, last, length, lower, maskEmail, maskPhone, maskTextPII, materializeWorkflowDocument, max, min, normalizeConfig, normalizeDetailItem, now, numericFieldNames, parseSort, pow, publishedStateName, publishingWorkflow, readingTime, registerJexlHelpers, replace, resolveAdminAuthCollection, resolveAuthorizedSiteId, round, runCollectionHooks, sanitizeDocForAI, saveWorkflowDraft, simplePublishingWorkflow, slugify, sqrt, startsWith, sum, today, transitionWorkflow, trim, truncate, unique, upper, validateAdminConditionExpression, validateDeclarativeAccessExpression, validateDeclarativeHookExpression, validatePreviewUrlExpression, when, wordCount, workflowCapabilities };
|
|
1819
|
+
export { AIConfig, type AIErrorCode, AIPIIConfig, type AccessConditions, AccessPolicyResolver, AdminAuthConfig, ArrayField, AuthConfig, type AuthDocFields, AuthenticatedUser, BUILTIN_JEXL_HELPERS, BaseDocument, Block, BooleanField, CollectionConfig, ComputedHandler, type ConfigDiagnostic, ConfigValidationError, ConflictError, DateField, DateTimeField, type DeclarativeAccessSurface, type DeclarativeAccessValidationIssue, type DeclarativeAdminSurface, type DeclarativeAdminValidationIssue, DeclarativeHookExpression, type DeclarativeHookSurface, type DeclarativeHookValidationIssue, type DeclarativePreviewSurface, type DeclarativePreviewValidationIssue, DetailAction, DetailActionOptions, DetailComputed, DetailComputedOptions, DetailCustom, DetailCustomOptions, DetailDivider, DetailDividerOptions, DetailField, DetailGrid, DetailGridOptions, DetailItem, DetailRepeat, DetailRepeatOptions, DetailSchema, DetailSection, DetailSectionOptions, DetailTab, DetailTabOptions, DetailTabs, DetailTabsOptions, DetailText, DetailTextOptions, DisplayFieldOptions, DyrectedAIError, DyrectedConfig, DyrectedError, EmailField, type ExprFunction, type ExtractCollectionSlugs, Field, FieldConditionBuilder, FieldType, ForbiddenError, GlobalConfig, HookRequestContext, IconField, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MatchBuilder, MultiSelectField, NON_NEGOTIABLE_CREDENTIAL_FIELDS, NotFoundError, NumberField, ObjectField, PII_REGEX_PATTERNS, type Prettify, PublicAdminAuthConfig, type PublishingWorkflowOptions, RadioField, RelationshipField, RichTextField, RowField, type SanitizeDocForAIOptions, SelectField, type SortClause, type SortDirection, type SqlSortDialect, type SystemDocFields, TextField, TextareaField, TimeField, type UploadDocFields, UrlField, ValidationError, WORKFLOW_HISTORY_COLLECTION, type WhenFunction, WorkflowConfig, WorkflowTransition, abs, addDays, asCollection, assertValidAdminConditionsInConfig, assertValidDeclarativeAccessInConfig, assertValidDeclarativeHookExpression, assertValidDeclarativeHookResult, assertValidDeclarativeHooksInConfig, assertValidPreviewUrlsInConfig, availableWorkflowTransitions, buildSqlOrderBy, canViewWorkflowDraft, capitalize, ceil, clamp, coalesce, collectAdminConditionValidationIssues, collectConfigDiagnostics, collectDeclarativeAccessValidationIssues, collectDeclarativeHookValidationIssues, collectPreviewUrlValidationIssues, compact, count, createLifecycleEvent, createWorkflowDocument, defaultValue, defineArrayField, defineBlock, defineBlocksField, defineBooleanField, defineCollection, defineConfig, defineDateField, defineDateTimeField, defineEmailField, defineField, defineGlobal, defineIconField, defineImageField, defineJoinField, defineJsonField, defineMultiSelectField, defineNumberField, defineObjectField, definePublishingWorkflow, defineRadioField, defineRelationshipField, defineRichTextField, defineRowField, defineSelectField, defineTab, defineTextField, defineTextareaField, defineTimeField, defineUrlField, diffDays, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, displayAction, displayComputed, displayCustom, displayCustomComponent, displayDivider, displayField, displayGrid, displayRepeat, displaySection, displayTab, displayTabs, displayText, endsWith, evaluateDetailComputed, evaluateJexl, evaluateJexlSync, executeFieldAfterRead, executeFieldBeforeChange, expr, first, floor, formatConfigDiagnostics, formatDate, formatJexlValue, generateDefaultDetailSchema, generateOpenApi, get, getAdminAuthCollection, getAdminRoleForCollection, getAllowedSitesForUser, getPublicAdminAuthConfig, includes, initializeWorkflowDocument, isConfigValidationError, isDetailItemVisible, isEmpty, isFuture, isPast, isSiteAuthorized, isUserAdmin, join, last, length, lower, maskEmail, maskPhone, maskTextPII, materializeWorkflowDocument, max, min, normalizeConfig, normalizeDetailItem, now, numericFieldNames, parseSort, pow, publishedStateName, publishingWorkflow, readingTime, registerJexlHelpers, replace, resolveAdminAuthCollection, resolveAuthorizedSiteId, round, runCollectionHooks, sanitizeDocForAI, saveWorkflowDraft, simplePublishingWorkflow, slugify, sqrt, startsWith, sum, today, transitionWorkflow, trim, truncate, unique, upper, validateAdminConditionExpression, validateDeclarativeAccessExpression, validateDeclarativeHookExpression, validatePreviewUrlExpression, when, wordCount, workflowCapabilities };
|
package/dist/index.js
CHANGED
|
@@ -3710,6 +3710,45 @@ function normalizeConfig(config) {
|
|
|
3710
3710
|
};
|
|
3711
3711
|
}
|
|
3712
3712
|
|
|
3713
|
+
// src/utils/errors.ts
|
|
3714
|
+
var DyrectedError = class _DyrectedError extends Error {
|
|
3715
|
+
statusCode;
|
|
3716
|
+
constructor(message, statusCode = 500) {
|
|
3717
|
+
super(message);
|
|
3718
|
+
this.name = "DyrectedError";
|
|
3719
|
+
this.statusCode = statusCode;
|
|
3720
|
+
Object.setPrototypeOf(this, _DyrectedError.prototype);
|
|
3721
|
+
}
|
|
3722
|
+
};
|
|
3723
|
+
var ValidationError = class _ValidationError extends DyrectedError {
|
|
3724
|
+
constructor(message) {
|
|
3725
|
+
super(message, 400);
|
|
3726
|
+
this.name = "ValidationError";
|
|
3727
|
+
Object.setPrototypeOf(this, _ValidationError.prototype);
|
|
3728
|
+
}
|
|
3729
|
+
};
|
|
3730
|
+
var ForbiddenError = class _ForbiddenError extends DyrectedError {
|
|
3731
|
+
constructor(message) {
|
|
3732
|
+
super(message, 403);
|
|
3733
|
+
this.name = "ForbiddenError";
|
|
3734
|
+
Object.setPrototypeOf(this, _ForbiddenError.prototype);
|
|
3735
|
+
}
|
|
3736
|
+
};
|
|
3737
|
+
var NotFoundError = class _NotFoundError extends DyrectedError {
|
|
3738
|
+
constructor(message) {
|
|
3739
|
+
super(message, 404);
|
|
3740
|
+
this.name = "NotFoundError";
|
|
3741
|
+
Object.setPrototypeOf(this, _NotFoundError.prototype);
|
|
3742
|
+
}
|
|
3743
|
+
};
|
|
3744
|
+
var ConflictError = class _ConflictError extends DyrectedError {
|
|
3745
|
+
constructor(message) {
|
|
3746
|
+
super(message, 409);
|
|
3747
|
+
this.name = "ConflictError";
|
|
3748
|
+
Object.setPrototypeOf(this, _ConflictError.prototype);
|
|
3749
|
+
}
|
|
3750
|
+
};
|
|
3751
|
+
|
|
3713
3752
|
// src/utils/parse-where.ts
|
|
3714
3753
|
function assertNever(op, context) {
|
|
3715
3754
|
throw new Error(`[dyrected/core] Unhandled where operator "${op}" in ${context}`);
|
|
@@ -5569,6 +5608,13 @@ function displayCustom(name, options) {
|
|
|
5569
5608
|
function displayCustomComponent(name, options) {
|
|
5570
5609
|
return displayCustom(name, options);
|
|
5571
5610
|
}
|
|
5611
|
+
function displayAction(name, options) {
|
|
5612
|
+
return {
|
|
5613
|
+
type: "action",
|
|
5614
|
+
name,
|
|
5615
|
+
options
|
|
5616
|
+
};
|
|
5617
|
+
}
|
|
5572
5618
|
async function evaluateDetailComputed(detail, doc, user, db) {
|
|
5573
5619
|
if (!doc || !detail || !Array.isArray(detail)) {
|
|
5574
5620
|
return doc;
|
|
@@ -5641,6 +5687,12 @@ function generateDefaultDetailSchema(schema) {
|
|
|
5641
5687
|
if (SENSITIVE_DETAIL_FIELDS.has(field.name)) continue;
|
|
5642
5688
|
if (field.hidden) continue;
|
|
5643
5689
|
if (field.admin?.hidden) continue;
|
|
5690
|
+
if (field.type === "join") {
|
|
5691
|
+
const joinColumns = field.admin?.columns;
|
|
5692
|
+
const repeatItems = Array.isArray(joinColumns) && joinColumns.length > 0 ? joinColumns.map((col) => displayField(col, { span: 12 })) : [displayComputed("Item", "doc.title || doc.name || doc.label || doc.slug || doc.id")];
|
|
5693
|
+
mainFields.push(displayRepeat(field.name, repeatItems, { span: 12, layout: "table" }));
|
|
5694
|
+
continue;
|
|
5695
|
+
}
|
|
5644
5696
|
const isSidebar = sidebarFieldTypes.has(field.type) && field.type !== "relationship" && !field.hasMany;
|
|
5645
5697
|
if (isSidebar && sidebarFields.length < 5) {
|
|
5646
5698
|
sidebarFields.push(
|
|
@@ -6382,13 +6434,18 @@ export {
|
|
|
6382
6434
|
AI_THREADS_COLLECTION,
|
|
6383
6435
|
BUILTIN_JEXL_HELPERS,
|
|
6384
6436
|
ConfigValidationError,
|
|
6437
|
+
ConflictError,
|
|
6385
6438
|
DyrectedAIError,
|
|
6439
|
+
DyrectedError,
|
|
6386
6440
|
FieldConditionBuilder,
|
|
6441
|
+
ForbiddenError,
|
|
6387
6442
|
LIFECYCLE_EVENTS_COLLECTION,
|
|
6388
6443
|
LIFECYCLE_EVENT_NAMES,
|
|
6389
6444
|
MatchBuilder,
|
|
6390
6445
|
NON_NEGOTIABLE_CREDENTIAL_FIELDS,
|
|
6446
|
+
NotFoundError,
|
|
6391
6447
|
PII_REGEX_PATTERNS,
|
|
6448
|
+
ValidationError,
|
|
6392
6449
|
WORKFLOW_HISTORY_COLLECTION,
|
|
6393
6450
|
abs,
|
|
6394
6451
|
addDays,
|
|
@@ -6455,6 +6512,7 @@ export {
|
|
|
6455
6512
|
diffDays,
|
|
6456
6513
|
dispatchLifecycleEvent,
|
|
6457
6514
|
dispatchPendingLifecycleEvents,
|
|
6515
|
+
displayAction,
|
|
6458
6516
|
displayComputed,
|
|
6459
6517
|
displayCustom,
|
|
6460
6518
|
displayCustomComponent,
|
package/dist/server.cjs
CHANGED
|
@@ -2307,6 +2307,12 @@ var init_chunker = __esm({
|
|
|
2307
2307
|
});
|
|
2308
2308
|
|
|
2309
2309
|
// src/services/rag/embedding.service.ts
|
|
2310
|
+
function hasEmbeddingApiKey(config) {
|
|
2311
|
+
const ai = config?.ai;
|
|
2312
|
+
return Boolean(
|
|
2313
|
+
ai?.apiKey || process.env.OPENROUTER_API_KEY || process.env.OPENAI_API_KEY || process.env.GEMINI_API_KEY || process.env.GOOGLE_GENERATIVE_AI_API_KEY
|
|
2314
|
+
);
|
|
2315
|
+
}
|
|
2310
2316
|
function getEmbeddingModel(config) {
|
|
2311
2317
|
const ai = config?.ai;
|
|
2312
2318
|
const provider = ai?.provider;
|
|
@@ -2649,6 +2655,9 @@ var init_rag_service = __esm({
|
|
|
2649
2655
|
if (!col || !this.isCollectionRAGEnabled(config, col)) {
|
|
2650
2656
|
return { indexed: 0, skipped: 0 };
|
|
2651
2657
|
}
|
|
2658
|
+
if (!hasEmbeddingApiKey(config)) {
|
|
2659
|
+
return { indexed: 0, skipped: 0 };
|
|
2660
|
+
}
|
|
2652
2661
|
const docId = String(doc.id || doc._id || "");
|
|
2653
2662
|
if (!docId) return { indexed: 0, skipped: 0 };
|
|
2654
2663
|
const ragConfig = col.ai?.rag;
|
|
@@ -3988,6 +3997,7 @@ __export(server_exports, {
|
|
|
3988
3997
|
getLockedUntilMs: () => getLockedUntilMs,
|
|
3989
3998
|
getObservabilityRuntime: () => getObservabilityRuntime,
|
|
3990
3999
|
getRequestLogger: () => getRequestLogger,
|
|
4000
|
+
hasEmbeddingApiKey: () => hasEmbeddingApiKey,
|
|
3991
4001
|
hashContent: () => hashContent,
|
|
3992
4002
|
hashPassword: () => hashPassword,
|
|
3993
4003
|
isAuthSessionActive: () => isAuthSessionActive,
|
|
@@ -7814,13 +7824,13 @@ var CollectionController = class {
|
|
|
7814
7824
|
const config = c.get("config");
|
|
7815
7825
|
const db = config.db;
|
|
7816
7826
|
if (!db) return c.json({ message: "Database not configured" }, 500);
|
|
7817
|
-
if (!this.collection.views?.length) {
|
|
7818
|
-
return c.json({ error: true, message: `Collection ${this.collection.slug} has no views` }, 404);
|
|
7827
|
+
if (!this.collection.views?.length && !this.collection.actions?.length) {
|
|
7828
|
+
return c.json({ error: true, message: `Collection ${this.collection.slug} has no views or actions` }, 404);
|
|
7819
7829
|
}
|
|
7820
7830
|
const actionName = c.req.param("action");
|
|
7821
7831
|
const viewSlugParam = c.req.param("viewSlug");
|
|
7822
7832
|
let action;
|
|
7823
|
-
for (const view2 of this.collection.views) {
|
|
7833
|
+
for (const view2 of this.collection.views ?? []) {
|
|
7824
7834
|
if (viewSlugParam && view2.slug !== viewSlugParam) continue;
|
|
7825
7835
|
const match = view2.actions?.find((candidate) => candidate.name === actionName);
|
|
7826
7836
|
if (match) {
|
|
@@ -7828,6 +7838,9 @@ var CollectionController = class {
|
|
|
7828
7838
|
break;
|
|
7829
7839
|
}
|
|
7830
7840
|
}
|
|
7841
|
+
if (!action && !viewSlugParam) {
|
|
7842
|
+
action = this.collection.actions?.find((candidate) => candidate.name === actionName);
|
|
7843
|
+
}
|
|
7831
7844
|
if (!action) {
|
|
7832
7845
|
return c.json(
|
|
7833
7846
|
{ error: true, message: `Action "${actionName}" was not found${viewSlugParam ? ` in view "${viewSlugParam}"` : ""}` },
|
|
@@ -7845,7 +7858,7 @@ var CollectionController = class {
|
|
|
7845
7858
|
const input = body?.input ?? {};
|
|
7846
7859
|
const user = c.get("user");
|
|
7847
7860
|
const accessArgs = { user, req: this.toHookRequestContext(c) };
|
|
7848
|
-
const view = viewSlugParam ? this.collection.views
|
|
7861
|
+
const view = viewSlugParam ? this.collection.views?.find((candidate) => candidate.slug === viewSlugParam) : void 0;
|
|
7849
7862
|
if (view?.access) {
|
|
7850
7863
|
const allowed = await resolveBooleanAccess(config, view.access.update ?? view.access.read ?? true, {
|
|
7851
7864
|
...accessArgs,
|
|
@@ -7883,7 +7896,8 @@ var CollectionController = class {
|
|
|
7883
7896
|
});
|
|
7884
7897
|
resolvedData = handlerResult ?? {};
|
|
7885
7898
|
} catch (error) {
|
|
7886
|
-
|
|
7899
|
+
const status = typeof error.statusCode === "number" ? error.statusCode : 500;
|
|
7900
|
+
results.push({ id, ok: false, status, error: error instanceof Error ? error.message : String(error) });
|
|
7887
7901
|
continue;
|
|
7888
7902
|
}
|
|
7889
7903
|
} else {
|
|
@@ -7906,7 +7920,8 @@ var CollectionController = class {
|
|
|
7906
7920
|
if (requestedIds.length === 1) {
|
|
7907
7921
|
const single = results[0];
|
|
7908
7922
|
if (!single.ok) {
|
|
7909
|
-
|
|
7923
|
+
const body2 = typeof single.error === "string" ? { error: true, message: single.error } : single.error ?? { error: true, message: "Action failed" };
|
|
7924
|
+
return c.json(body2, single.status ?? 500);
|
|
7910
7925
|
}
|
|
7911
7926
|
return c.json(single.doc);
|
|
7912
7927
|
}
|
|
@@ -14351,6 +14366,8 @@ function registerRoutes(app, config) {
|
|
|
14351
14366
|
app.post(`${path}/aggregate`, (c) => controller.aggregate(c));
|
|
14352
14367
|
if (collection.views?.length) {
|
|
14353
14368
|
app.post(`${path}/views/:viewSlug/actions/:action`, optionalAuth(config), (c) => controller.runViewAction(c));
|
|
14369
|
+
}
|
|
14370
|
+
if (collection.views?.length || collection.actions?.length) {
|
|
14354
14371
|
app.post(`${path}/actions/:action`, optionalAuth(config), (c) => controller.runViewAction(c));
|
|
14355
14372
|
}
|
|
14356
14373
|
if (collection.audit) {
|
|
@@ -15128,6 +15145,8 @@ async function createDyrectedApp(rawConfig) {
|
|
|
15128
15145
|
if (err instanceof import_http_exception6.HTTPException) {
|
|
15129
15146
|
return c.json({ error: true, message: err.message }, err.status);
|
|
15130
15147
|
}
|
|
15148
|
+
const statusCode = err.statusCode;
|
|
15149
|
+
const status = typeof statusCode === "number" && Number.isInteger(statusCode) && statusCode >= 400 && statusCode <= 599 ? statusCode : 500;
|
|
15131
15150
|
const logger = getRequestLogger(c, "core");
|
|
15132
15151
|
logger.error({
|
|
15133
15152
|
err,
|
|
@@ -15140,9 +15159,10 @@ async function createDyrectedApp(rawConfig) {
|
|
|
15140
15159
|
method: c.req.method
|
|
15141
15160
|
});
|
|
15142
15161
|
return c.json({
|
|
15162
|
+
error: true,
|
|
15143
15163
|
message: err.message || "Internal Server Error",
|
|
15144
15164
|
stack: process.env.NODE_ENV === "development" ? err.stack : void 0
|
|
15145
|
-
},
|
|
15165
|
+
}, status);
|
|
15146
15166
|
});
|
|
15147
15167
|
registerRoutes(app, config);
|
|
15148
15168
|
return app;
|
|
@@ -15198,6 +15218,7 @@ init_embedding_service();
|
|
|
15198
15218
|
getLockedUntilMs,
|
|
15199
15219
|
getObservabilityRuntime,
|
|
15200
15220
|
getRequestLogger,
|
|
15221
|
+
hasEmbeddingApiKey,
|
|
15201
15222
|
hashContent,
|
|
15202
15223
|
hashPassword,
|
|
15203
15224
|
isAuthSessionActive,
|
package/dist/server.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { M as DyrectedContext, D as DyrectedConfig, C as CollectionConfig, G as GlobalConfig, bl as DatabaseAdapter, b as AuthenticatedUser, bG as DyrectedAIContext, an as AIThread, aj as AIMessage, cw as RAGSearchResult, am as AIRateLimitStore, al as AIRateLimitResult } from './app-Cmp5lFLJ.cjs';
|
|
2
|
+
export { da as CollectionTokenPayload, db as DEFAULT_SESSION_EXPIRY, dc as DyrectedObservabilityRuntime, dd as RequestBodyCapture, de as RequestTraceContext, df as ResolvedObservabilityConfig, dg as attachRequestMetrics, dh as bindObservabilityRuntime, di as buildRequestLogger, dj as captureRequestBody, dk as createDyrectedApp, dl as createObservabilityRuntime, dm as createRequestSpan, dn as decodeCollectionToken, dp as endRequestSpan, dq as getConfigLogger, dr as getObservabilityRuntime, ds as getRequestLogger, dt as redactBody, du as redactHeaders, dv as renderPrometheusMetrics, dw as resolveObservabilityConfig, dx as resolveSessionTokenExpiry, dy as shouldSampleRequest, dz as signCollectionToken, dA as verifyCollectionToken } from './app-Cmp5lFLJ.cjs';
|
|
3
3
|
import * as hono from 'hono';
|
|
4
4
|
import { Hono, Context, Next } from 'hono';
|
|
5
5
|
import * as hono_utils_http_status from 'hono/utils/http-status';
|
|
@@ -716,6 +716,13 @@ declare function estimateTokens(text: string): number;
|
|
|
716
716
|
*/
|
|
717
717
|
declare function chunkText(text: string, options?: ChunkOptions): ChunkResult[];
|
|
718
718
|
|
|
719
|
+
/**
|
|
720
|
+
* Whether any embedding API key is resolvable for this config. Mirrors the
|
|
721
|
+
* key sources consulted by `getEmbeddingModel` without constructing a
|
|
722
|
+
* provider. When this returns false, RAG indexing can never succeed, so
|
|
723
|
+
* callers should skip silently instead of throwing and logging noise.
|
|
724
|
+
*/
|
|
725
|
+
declare function hasEmbeddingApiKey(config?: DyrectedConfig): boolean;
|
|
719
726
|
declare function getEmbeddingModel(config?: DyrectedConfig): EmbeddingModel;
|
|
720
727
|
declare class EmbeddingService {
|
|
721
728
|
private config?;
|
|
@@ -738,4 +745,4 @@ declare class InMemoryRateLimitStore implements AIRateLimitStore {
|
|
|
738
745
|
}
|
|
739
746
|
declare function aiRateLimit(config?: DyrectedConfig): (c: Context<DyrectedContext>, next: Next) => Promise<void>;
|
|
740
747
|
|
|
741
|
-
export { AIAgent, type AIAgentOptions, AIController, AUTH_SESSIONS_COLLECTION, AuthController, type AuthSessionRecord, type ChunkOptions, type ChunkResult, CollectionController, DEFAULT_LOCK_TIME_MS, DEFAULT_MAX_LOGIN_ATTEMPTS, type DeleteDocumentChunksOptions, DyrectedContext, EmbeddingService, GlobalController, InMemoryRateLimitStore, type IndexDocumentOptions, MediaController, PreviewController, type RAGSearchOptions, RAGService, type ReindexAllOptions, type ReindexCollectionOptions, type ResolvedAuthLockoutConfig, aiRateLimit, buildDyrectedSystemPrompt, buildInviteEmail, buildPasswordChangedEmail, buildResetPasswordEmail, buildWelcomeEmail, chunkText, cosineSimilarity, createDyrectedAITools, estimateTokens, extractTextFromDoc, formatAIErrorMessage, getAIModel, getAuthSession, getEmbeddingModel, getLockedUntilMs, hashContent, hashPassword, isAuthSessionActive, issueAuthSessionToken, normalizeFieldValue, registerRoutes, resolveAuthLockoutConfig, revokeAllAuthSessions, revokeAuthSession, sendEmail, serializeDetailForApi, serializeViewForApi, touchAuthSession, validatePayloadAgainstFields, verifyPassword };
|
|
748
|
+
export { AIAgent, type AIAgentOptions, AIController, AUTH_SESSIONS_COLLECTION, AuthController, type AuthSessionRecord, type ChunkOptions, type ChunkResult, CollectionController, DEFAULT_LOCK_TIME_MS, DEFAULT_MAX_LOGIN_ATTEMPTS, type DeleteDocumentChunksOptions, DyrectedContext, EmbeddingService, GlobalController, InMemoryRateLimitStore, type IndexDocumentOptions, MediaController, PreviewController, type RAGSearchOptions, RAGService, type ReindexAllOptions, type ReindexCollectionOptions, type ResolvedAuthLockoutConfig, aiRateLimit, buildDyrectedSystemPrompt, buildInviteEmail, buildPasswordChangedEmail, buildResetPasswordEmail, buildWelcomeEmail, chunkText, cosineSimilarity, createDyrectedAITools, estimateTokens, extractTextFromDoc, formatAIErrorMessage, getAIModel, getAuthSession, getEmbeddingModel, getLockedUntilMs, hasEmbeddingApiKey, hashContent, hashPassword, isAuthSessionActive, issueAuthSessionToken, normalizeFieldValue, registerRoutes, resolveAuthLockoutConfig, revokeAllAuthSessions, revokeAuthSession, sendEmail, serializeDetailForApi, serializeViewForApi, touchAuthSession, validatePayloadAgainstFields, verifyPassword };
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { M as DyrectedContext, D as DyrectedConfig, C as CollectionConfig, G as GlobalConfig, bl as DatabaseAdapter, b as AuthenticatedUser, bG as DyrectedAIContext, an as AIThread, aj as AIMessage, cw as RAGSearchResult, am as AIRateLimitStore, al as AIRateLimitResult } from './app-Cmp5lFLJ.js';
|
|
2
|
+
export { da as CollectionTokenPayload, db as DEFAULT_SESSION_EXPIRY, dc as DyrectedObservabilityRuntime, dd as RequestBodyCapture, de as RequestTraceContext, df as ResolvedObservabilityConfig, dg as attachRequestMetrics, dh as bindObservabilityRuntime, di as buildRequestLogger, dj as captureRequestBody, dk as createDyrectedApp, dl as createObservabilityRuntime, dm as createRequestSpan, dn as decodeCollectionToken, dp as endRequestSpan, dq as getConfigLogger, dr as getObservabilityRuntime, ds as getRequestLogger, dt as redactBody, du as redactHeaders, dv as renderPrometheusMetrics, dw as resolveObservabilityConfig, dx as resolveSessionTokenExpiry, dy as shouldSampleRequest, dz as signCollectionToken, dA as verifyCollectionToken } from './app-Cmp5lFLJ.js';
|
|
3
3
|
import * as hono from 'hono';
|
|
4
4
|
import { Hono, Context, Next } from 'hono';
|
|
5
5
|
import * as hono_utils_http_status from 'hono/utils/http-status';
|
|
@@ -716,6 +716,13 @@ declare function estimateTokens(text: string): number;
|
|
|
716
716
|
*/
|
|
717
717
|
declare function chunkText(text: string, options?: ChunkOptions): ChunkResult[];
|
|
718
718
|
|
|
719
|
+
/**
|
|
720
|
+
* Whether any embedding API key is resolvable for this config. Mirrors the
|
|
721
|
+
* key sources consulted by `getEmbeddingModel` without constructing a
|
|
722
|
+
* provider. When this returns false, RAG indexing can never succeed, so
|
|
723
|
+
* callers should skip silently instead of throwing and logging noise.
|
|
724
|
+
*/
|
|
725
|
+
declare function hasEmbeddingApiKey(config?: DyrectedConfig): boolean;
|
|
719
726
|
declare function getEmbeddingModel(config?: DyrectedConfig): EmbeddingModel;
|
|
720
727
|
declare class EmbeddingService {
|
|
721
728
|
private config?;
|
|
@@ -738,4 +745,4 @@ declare class InMemoryRateLimitStore implements AIRateLimitStore {
|
|
|
738
745
|
}
|
|
739
746
|
declare function aiRateLimit(config?: DyrectedConfig): (c: Context<DyrectedContext>, next: Next) => Promise<void>;
|
|
740
747
|
|
|
741
|
-
export { AIAgent, type AIAgentOptions, AIController, AUTH_SESSIONS_COLLECTION, AuthController, type AuthSessionRecord, type ChunkOptions, type ChunkResult, CollectionController, DEFAULT_LOCK_TIME_MS, DEFAULT_MAX_LOGIN_ATTEMPTS, type DeleteDocumentChunksOptions, DyrectedContext, EmbeddingService, GlobalController, InMemoryRateLimitStore, type IndexDocumentOptions, MediaController, PreviewController, type RAGSearchOptions, RAGService, type ReindexAllOptions, type ReindexCollectionOptions, type ResolvedAuthLockoutConfig, aiRateLimit, buildDyrectedSystemPrompt, buildInviteEmail, buildPasswordChangedEmail, buildResetPasswordEmail, buildWelcomeEmail, chunkText, cosineSimilarity, createDyrectedAITools, estimateTokens, extractTextFromDoc, formatAIErrorMessage, getAIModel, getAuthSession, getEmbeddingModel, getLockedUntilMs, hashContent, hashPassword, isAuthSessionActive, issueAuthSessionToken, normalizeFieldValue, registerRoutes, resolveAuthLockoutConfig, revokeAllAuthSessions, revokeAuthSession, sendEmail, serializeDetailForApi, serializeViewForApi, touchAuthSession, validatePayloadAgainstFields, verifyPassword };
|
|
748
|
+
export { AIAgent, type AIAgentOptions, AIController, AUTH_SESSIONS_COLLECTION, AuthController, type AuthSessionRecord, type ChunkOptions, type ChunkResult, CollectionController, DEFAULT_LOCK_TIME_MS, DEFAULT_MAX_LOGIN_ATTEMPTS, type DeleteDocumentChunksOptions, DyrectedContext, EmbeddingService, GlobalController, InMemoryRateLimitStore, type IndexDocumentOptions, MediaController, PreviewController, type RAGSearchOptions, RAGService, type ReindexAllOptions, type ReindexCollectionOptions, type ResolvedAuthLockoutConfig, aiRateLimit, buildDyrectedSystemPrompt, buildInviteEmail, buildPasswordChangedEmail, buildResetPasswordEmail, buildWelcomeEmail, chunkText, cosineSimilarity, createDyrectedAITools, estimateTokens, extractTextFromDoc, formatAIErrorMessage, getAIModel, getAuthSession, getEmbeddingModel, getLockedUntilMs, hasEmbeddingApiKey, hashContent, hashPassword, isAuthSessionActive, issueAuthSessionToken, normalizeFieldValue, registerRoutes, resolveAuthLockoutConfig, revokeAllAuthSessions, revokeAuthSession, sendEmail, serializeDetailForApi, serializeViewForApi, touchAuthSession, validatePayloadAgainstFields, verifyPassword };
|
package/dist/server.js
CHANGED
|
@@ -2308,6 +2308,12 @@ var init_chunker = __esm({
|
|
|
2308
2308
|
import { createGoogleGenerativeAI } from "@ai-sdk/google";
|
|
2309
2309
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
2310
2310
|
import { embed, embedMany } from "ai";
|
|
2311
|
+
function hasEmbeddingApiKey(config) {
|
|
2312
|
+
const ai = config?.ai;
|
|
2313
|
+
return Boolean(
|
|
2314
|
+
ai?.apiKey || process.env.OPENROUTER_API_KEY || process.env.OPENAI_API_KEY || process.env.GEMINI_API_KEY || process.env.GOOGLE_GENERATIVE_AI_API_KEY
|
|
2315
|
+
);
|
|
2316
|
+
}
|
|
2311
2317
|
function getEmbeddingModel(config) {
|
|
2312
2318
|
const ai = config?.ai;
|
|
2313
2319
|
const provider = ai?.provider;
|
|
@@ -2647,6 +2653,9 @@ var init_rag_service = __esm({
|
|
|
2647
2653
|
if (!col || !this.isCollectionRAGEnabled(config, col)) {
|
|
2648
2654
|
return { indexed: 0, skipped: 0 };
|
|
2649
2655
|
}
|
|
2656
|
+
if (!hasEmbeddingApiKey(config)) {
|
|
2657
|
+
return { indexed: 0, skipped: 0 };
|
|
2658
|
+
}
|
|
2650
2659
|
const docId = String(doc.id || doc._id || "");
|
|
2651
2660
|
if (!docId) return { indexed: 0, skipped: 0 };
|
|
2652
2661
|
const ragConfig = col.ai?.rag;
|
|
@@ -7755,13 +7764,13 @@ var CollectionController = class {
|
|
|
7755
7764
|
const config = c.get("config");
|
|
7756
7765
|
const db = config.db;
|
|
7757
7766
|
if (!db) return c.json({ message: "Database not configured" }, 500);
|
|
7758
|
-
if (!this.collection.views?.length) {
|
|
7759
|
-
return c.json({ error: true, message: `Collection ${this.collection.slug} has no views` }, 404);
|
|
7767
|
+
if (!this.collection.views?.length && !this.collection.actions?.length) {
|
|
7768
|
+
return c.json({ error: true, message: `Collection ${this.collection.slug} has no views or actions` }, 404);
|
|
7760
7769
|
}
|
|
7761
7770
|
const actionName = c.req.param("action");
|
|
7762
7771
|
const viewSlugParam = c.req.param("viewSlug");
|
|
7763
7772
|
let action;
|
|
7764
|
-
for (const view2 of this.collection.views) {
|
|
7773
|
+
for (const view2 of this.collection.views ?? []) {
|
|
7765
7774
|
if (viewSlugParam && view2.slug !== viewSlugParam) continue;
|
|
7766
7775
|
const match = view2.actions?.find((candidate) => candidate.name === actionName);
|
|
7767
7776
|
if (match) {
|
|
@@ -7769,6 +7778,9 @@ var CollectionController = class {
|
|
|
7769
7778
|
break;
|
|
7770
7779
|
}
|
|
7771
7780
|
}
|
|
7781
|
+
if (!action && !viewSlugParam) {
|
|
7782
|
+
action = this.collection.actions?.find((candidate) => candidate.name === actionName);
|
|
7783
|
+
}
|
|
7772
7784
|
if (!action) {
|
|
7773
7785
|
return c.json(
|
|
7774
7786
|
{ error: true, message: `Action "${actionName}" was not found${viewSlugParam ? ` in view "${viewSlugParam}"` : ""}` },
|
|
@@ -7786,7 +7798,7 @@ var CollectionController = class {
|
|
|
7786
7798
|
const input = body?.input ?? {};
|
|
7787
7799
|
const user = c.get("user");
|
|
7788
7800
|
const accessArgs = { user, req: this.toHookRequestContext(c) };
|
|
7789
|
-
const view = viewSlugParam ? this.collection.views
|
|
7801
|
+
const view = viewSlugParam ? this.collection.views?.find((candidate) => candidate.slug === viewSlugParam) : void 0;
|
|
7790
7802
|
if (view?.access) {
|
|
7791
7803
|
const allowed = await resolveBooleanAccess(config, view.access.update ?? view.access.read ?? true, {
|
|
7792
7804
|
...accessArgs,
|
|
@@ -7824,7 +7836,8 @@ var CollectionController = class {
|
|
|
7824
7836
|
});
|
|
7825
7837
|
resolvedData = handlerResult ?? {};
|
|
7826
7838
|
} catch (error) {
|
|
7827
|
-
|
|
7839
|
+
const status = typeof error.statusCode === "number" ? error.statusCode : 500;
|
|
7840
|
+
results.push({ id, ok: false, status, error: error instanceof Error ? error.message : String(error) });
|
|
7828
7841
|
continue;
|
|
7829
7842
|
}
|
|
7830
7843
|
} else {
|
|
@@ -7847,7 +7860,8 @@ var CollectionController = class {
|
|
|
7847
7860
|
if (requestedIds.length === 1) {
|
|
7848
7861
|
const single = results[0];
|
|
7849
7862
|
if (!single.ok) {
|
|
7850
|
-
|
|
7863
|
+
const body2 = typeof single.error === "string" ? { error: true, message: single.error } : single.error ?? { error: true, message: "Action failed" };
|
|
7864
|
+
return c.json(body2, single.status ?? 500);
|
|
7851
7865
|
}
|
|
7852
7866
|
return c.json(single.doc);
|
|
7853
7867
|
}
|
|
@@ -14297,6 +14311,8 @@ function registerRoutes(app, config) {
|
|
|
14297
14311
|
app.post(`${path}/aggregate`, (c) => controller.aggregate(c));
|
|
14298
14312
|
if (collection.views?.length) {
|
|
14299
14313
|
app.post(`${path}/views/:viewSlug/actions/:action`, optionalAuth(config), (c) => controller.runViewAction(c));
|
|
14314
|
+
}
|
|
14315
|
+
if (collection.views?.length || collection.actions?.length) {
|
|
14300
14316
|
app.post(`${path}/actions/:action`, optionalAuth(config), (c) => controller.runViewAction(c));
|
|
14301
14317
|
}
|
|
14302
14318
|
if (collection.audit) {
|
|
@@ -15074,6 +15090,8 @@ async function createDyrectedApp(rawConfig) {
|
|
|
15074
15090
|
if (err instanceof HTTPException6) {
|
|
15075
15091
|
return c.json({ error: true, message: err.message }, err.status);
|
|
15076
15092
|
}
|
|
15093
|
+
const statusCode = err.statusCode;
|
|
15094
|
+
const status = typeof statusCode === "number" && Number.isInteger(statusCode) && statusCode >= 400 && statusCode <= 599 ? statusCode : 500;
|
|
15077
15095
|
const logger = getRequestLogger(c, "core");
|
|
15078
15096
|
logger.error({
|
|
15079
15097
|
err,
|
|
@@ -15086,9 +15104,10 @@ async function createDyrectedApp(rawConfig) {
|
|
|
15086
15104
|
method: c.req.method
|
|
15087
15105
|
});
|
|
15088
15106
|
return c.json({
|
|
15107
|
+
error: true,
|
|
15089
15108
|
message: err.message || "Internal Server Error",
|
|
15090
15109
|
stack: process.env.NODE_ENV === "development" ? err.stack : void 0
|
|
15091
|
-
},
|
|
15110
|
+
}, status);
|
|
15092
15111
|
});
|
|
15093
15112
|
registerRoutes(app, config);
|
|
15094
15113
|
return app;
|
|
@@ -15143,6 +15162,7 @@ export {
|
|
|
15143
15162
|
getLockedUntilMs,
|
|
15144
15163
|
getObservabilityRuntime,
|
|
15145
15164
|
getRequestLogger,
|
|
15165
|
+
hasEmbeddingApiKey,
|
|
15146
15166
|
hashContent,
|
|
15147
15167
|
hashPassword,
|
|
15148
15168
|
isAuthSessionActive,
|