@dyrected/core 2.15.0 → 2.16.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-Cmp5lFLJ.d.cts → app-KSDgfXsw.d.cts} +60 -6
- package/dist/{app-Cmp5lFLJ.d.ts → app-KSDgfXsw.d.ts} +60 -6
- package/dist/index.cjs +182 -1
- package/dist/index.d.cts +76 -3
- package/dist/index.d.ts +76 -3
- package/dist/index.js +171 -1
- package/dist/server.cjs +190 -11
- package/dist/server.d.cts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +190 -11
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as Field, B as Block, C as CollectionConfig, D as DyrectedConfig, A as AdminAuthConfig, P as PublicAdminAuthConfig, G as GlobalConfig, a as DeclarativeHookExpression, W as WorkflowConfig, b as AuthenticatedUser, c as WorkflowTransition, L as LifecycleEventName, d as LifecycleEvent, e as BaseDocument, H as HookRequestContext, 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
|
|
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 IdStrategy, R as ArrayField, S as FieldType, T as BooleanField, U as AuthConfig, V as AccessPolicyResolver, X as DateField, Y as DateTimeField, Z as EmailField, _ as IconField, $ as ImageField, a0 as JoinField, a1 as JsonField, a2 as MultiSelectField, a3 as NumberField, a4 as ObjectField, a5 as RadioField, a6 as RelationshipField, a7 as RichTextField, a8 as RowField, a9 as SelectField, aa as TextField, ab as TextareaField, ac as TimeField, ad as UrlField } from './app-KSDgfXsw.cjs';
|
|
2
|
+
export { ae as AIAction, af as AIActionStatus, ag as AIActionType, ah as AIAuditActionType, ai as AIAuditRecord, aj as AIChunk, ak as AIMessage, al as AIPIIPattern, am as AIRateLimitResult, an as AIRateLimitStore, ao as AIThread, ap as AIToolContext, aq as AIToolDefinition, ar as AI_ACTIONS_COLLECTION, as as AI_AUDIT_COLLECTION, at as AI_CHUNKS_COLLECTION, au as AI_MESSAGES_COLLECTION, av as AI_THREADS_COLLECTION, aw as AccessConfig, ax as AccessFunction, ay as AccessFunctionArgs, az as AccessResult, aA as AccessRule, aB as ActionConfig, aC as ActionConfigBase, aD as ActionConfigWithHandler, aE as ActionConfigWithMutation, aF as ActionContext, aG as ActionType, aH as AdminAuthAccessResolution, aI as AdminAuthClaimMapping, aJ as AdminAuthMember, aK as AdminAuthProvider, aL as AdminAuthProviderMembersConfig, aM as AdminAuthProvisioningMode, aN as AdminAuthResolveAccessArgs, aO as AdminAuthResolvedIdentity, aP as AdminConfig, aQ as AdminDashboardComponentSlots, aR as AdminIconName, aS as AggregateArgs, aT as AggregateCastType, aU as AggregateCollectionResult, aV as AggregateInput, aW as AggregateOperation, aX as AggregateResult, aY as BaseAdminAuthProvider, aZ as BaseFieldAdmin, a_ as BlockVariant, a$ as BlocksField, b0 as BooleanFieldAdmin, b1 as BooleanFormat, b2 as CharacterLimitFieldAdmin, b3 as CharacterLimitFieldConfig, b4 as CollectionAfterChangeHook, b5 as CollectionAfterDeleteHook, b6 as CollectionAfterReadHook, b7 as CollectionAfterReadHookEntry, b8 as CollectionAfterTransitionHook, b9 as CollectionBeforeChangeHook, ba as CollectionBeforeChangeHookEntry, bb as CollectionBeforeDeleteHook, bc as CollectionBeforeReadHook, bd as CollectionBeforeReadHookEntry, be as CollectionBeforeTransitionHook, bf as CollectionIndex, bg as CollectionListComponentSlots, bh as CollectionRAGConfig, bi as CollectionSchemaResult, bj as CollectionSummaryResult, bk as CollectionViewComponentSlots, bl as CountOperation, bm as CustomAdminAuthProvider, bn as DatabaseAdapter, bo as DateFieldAdmin, bp as DateFormat, bq as DefaultValueContext, br as DefineActionOptions, bs as DefineCalendarViewOptions, bt as DefineCardsViewOptions, bu as DefineGanttViewOptions, bv as DefineKanbanViewOptions, bw as DefineTableViewOptions, bx as DefineViewBaseOptions, by as DefineViewOptions, bz as DetailSpan, bA as DisplayTone, bB as DisplayVariant, bC as DistinctCountOperation, bD as DistinctValuesOperation, bE as DynamicOptionItem, bF as DynamicOptionsConfig, bG as DynamicOptionsResolver, bH as DynamicOptionsResolverArgs, bI as DyrectedAIContext, bJ as DyrectedLoggerConfig, bK as DyrectedObservabilityConfig, bL as EmailFieldAdmin, bM as FieldAdminHooks, bN as FieldAdminOnChangeHook, bO as FieldAdminOnChangeHookArgs, bP as FieldAdminOptionsHook, bQ as FieldAdminOptionsHookArgs, bR as FieldAdminOptionsHookResult, bS as FieldAfterReadHook, bT as FieldAfterReadHookArgs, bU as FieldBase, bV as FieldBeforeChangeHook, bW as FieldBeforeChangeHookArgs, bX as FieldHook, bY as FieldHooks, bZ as FileData, b_ as GetDocumentResult, b$ as GlobalAfterChangeHook, c0 as GlobalAfterReadHook, c1 as GlobalAfterReadHookEntry, c2 as GlobalBeforeChangeHook, c3 as GlobalBeforeChangeHookEntry, c4 as GlobalBeforeReadHook, c5 as GlobalBeforeReadHookEntry, c6 as GlobalRAGConfig, c7 as GlobalSchemaResult, c8 as GlobalSummaryResult, c9 as HeadingLevel, ca as HookFunction, cb as IconFieldAdmin, cc as ImageService, cd as ImageTransformOptions, ce as InferAggregateResult, cf as JoinFieldAdmin, cg as JsonFieldAdmin, ch as JsonFormat, ci as LIFECYCLE_EVENT_NAMES, cj as LifecycleEventHandler, ck as LinkFormat, cl as MetricColor, cm as MultiSelectFieldAdmin, cn as NamedAccessPolicy, co as NumberFieldAdmin, cp as NumberFormat, cq as NumberLimitFieldAdmin, cr as NumberLimitFieldConfig, cs as NumericOperation, ct as NumericUpdateOperator, cu as OIDCAdminAuthProvider, cv as OptionFormat, cw as PaginatedResult, cx as PublicAdminAuthProvider, cy as QueryCollectionResult, cz as RAGSearchResult, cA as RadioFieldAdmin, cB as RateLimitConfig, cC as ReadonlyDatabaseAdapter, cD as RichTextFeature, cE as RichTextFieldConfig, cF as SelectFieldAdmin, cG as SqlWhereResult, cH as StorageAdapter, cI as TextFieldAdmin, cJ as TextFormat, cK as TextareaFieldAdmin, cL as TrustProxyConfig, cM as TypedField, cN as UploadConfig, cO as UrlFieldAdmin, cP as UrlLinkValue, cQ as ViewActionFeatures, cR as ViewComponentSlots, cS as ViewConfig, cT as ViewLayout, cU as ViewMetric, cV as ViewSubMetric, cW as WhereClause, cX as WhereOperator, cY as WhereOperatorName, cZ as WordLimitFieldAdmin, c_ as WordLimitFieldConfig, c$ as WorkflowMetadata, d0 as WorkflowRole, d1 as WorkflowState, d2 as WorkflowTransitionContext, d3 as defineAction, d4 as defineCalendarView, d5 as defineCardsView, d6 as defineGanttView, d7 as defineKanbanView, d8 as defineTableView, d9 as defineView, da as isAICollection, db as parseMongoWhere, dc as parseSqlWhere } from './app-KSDgfXsw.cjs';
|
|
3
3
|
import jexl from 'jexl';
|
|
4
4
|
import { Context } from 'hono';
|
|
5
5
|
export { z } from 'zod';
|
|
@@ -196,6 +196,15 @@ declare class NotFoundError extends DyrectedError {
|
|
|
196
196
|
declare class ConflictError extends DyrectedError {
|
|
197
197
|
constructor(message: string);
|
|
198
198
|
}
|
|
199
|
+
/** A unique constraint or unique index was violated on insert/update. Answered with `409`. */
|
|
200
|
+
declare class DuplicateKeyError extends ConflictError {
|
|
201
|
+
readonly field?: string;
|
|
202
|
+
readonly value?: any;
|
|
203
|
+
constructor(message: string, options?: {
|
|
204
|
+
field?: string;
|
|
205
|
+
value?: any;
|
|
206
|
+
});
|
|
207
|
+
}
|
|
199
208
|
|
|
200
209
|
type SortDirection = 'ASC' | 'DESC';
|
|
201
210
|
interface SortClause {
|
|
@@ -1320,6 +1329,70 @@ interface SanitizeDocForAIOptions {
|
|
|
1320
1329
|
*/
|
|
1321
1330
|
declare function sanitizeDocForAI(options: SanitizeDocForAIOptions): Record<string, unknown>;
|
|
1322
1331
|
|
|
1332
|
+
declare const NANOID_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";
|
|
1333
|
+
declare const BASE62_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
1334
|
+
declare const CROCKFORD_BASE32 = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
1335
|
+
/**
|
|
1336
|
+
* Generates an unbiased cryptographically secure NanoID string.
|
|
1337
|
+
*
|
|
1338
|
+
* @param size Number of characters to generate (default: 21)
|
|
1339
|
+
* @param alphabet Characters to draw from (default: URL-safe Base64 alphanumeric)
|
|
1340
|
+
*/
|
|
1341
|
+
declare function nanoid(size?: number, alphabet?: string): string;
|
|
1342
|
+
/**
|
|
1343
|
+
* Generates a 26-character time-sortable ULID (Universally Unique Lexicographically Sortable Identifier).
|
|
1344
|
+
*
|
|
1345
|
+
* The first 10 characters encode the millisecond timestamp, followed by 16 cryptographically secure
|
|
1346
|
+
* random Crockford Base32 characters. ULIDs sort in chronological order, making them optimal
|
|
1347
|
+
* for B-tree index locality in relational databases.
|
|
1348
|
+
*
|
|
1349
|
+
* @param seedTime Optional millisecond timestamp (default: Date.now())
|
|
1350
|
+
*/
|
|
1351
|
+
declare function ulid(seedTime?: number): string;
|
|
1352
|
+
/**
|
|
1353
|
+
* Standard RFC 4122 UUIDv4 generator wrapper.
|
|
1354
|
+
*/
|
|
1355
|
+
declare function uuid(): string;
|
|
1356
|
+
/**
|
|
1357
|
+
* Resolves a clean 3-4 character prefix for a collection slug or explicit prefix.
|
|
1358
|
+
*
|
|
1359
|
+
* @example
|
|
1360
|
+
* resolvePrefix('cob-daily-reports') // 'cob'
|
|
1361
|
+
* resolvePrefix('ipo-reservations') // 'ipo'
|
|
1362
|
+
* resolvePrefix('users') // 'usr'
|
|
1363
|
+
* resolvePrefix('applications') // 'app'
|
|
1364
|
+
* resolvePrefix('anything', 'custom') // 'custom'
|
|
1365
|
+
*/
|
|
1366
|
+
declare function resolvePrefix(slug?: string, explicitPrefix?: string): string;
|
|
1367
|
+
/**
|
|
1368
|
+
* Generates a Stripe-style prefixed NanoID (e.g. `col_k9pQ2mZwRtx89aB1`).
|
|
1369
|
+
*
|
|
1370
|
+
* Uses Base62 for the random suffix to prevent extra underscores and hyphens in the ID body.
|
|
1371
|
+
*
|
|
1372
|
+
* @param prefix Collection prefix (e.g. 'usr', 'cob', 'app', 'col')
|
|
1373
|
+
* @param size Length of the random suffix (default: 16)
|
|
1374
|
+
*/
|
|
1375
|
+
declare function prefixedId(prefix?: string, size?: number): string;
|
|
1376
|
+
|
|
1377
|
+
interface GenerateIdOptions {
|
|
1378
|
+
prefix?: string;
|
|
1379
|
+
type?: IdStrategy;
|
|
1380
|
+
size?: number;
|
|
1381
|
+
}
|
|
1382
|
+
/**
|
|
1383
|
+
* Generates an ID according to the specified options. Defaults to Stripe-style prefixed NanoID.
|
|
1384
|
+
*/
|
|
1385
|
+
declare function generateId(options?: GenerateIdOptions | string): string;
|
|
1386
|
+
/**
|
|
1387
|
+
* Generates a document ID based on collection configuration or slug.
|
|
1388
|
+
*/
|
|
1389
|
+
declare function generateDocumentId(collectionOrSlug?: string | {
|
|
1390
|
+
slug: string;
|
|
1391
|
+
idPrefix?: string;
|
|
1392
|
+
idType?: IdStrategy;
|
|
1393
|
+
idGenerator?: (slug: string) => string;
|
|
1394
|
+
}): string;
|
|
1395
|
+
|
|
1323
1396
|
type TopLevelFieldName<TFields extends readonly Field[]> = Extract<TFields[number], {
|
|
1324
1397
|
name: string;
|
|
1325
1398
|
}>["name"];
|
|
@@ -1816,4 +1889,4 @@ declare function defineTab<const T extends readonly Field[]>(args: {
|
|
|
1816
1889
|
fields: T;
|
|
1817
1890
|
}): T;
|
|
1818
1891
|
|
|
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 };
|
|
1892
|
+
export { AIConfig, type AIErrorCode, AIPIIConfig, type AccessConditions, AccessPolicyResolver, AdminAuthConfig, ArrayField, AuthConfig, type AuthDocFields, AuthenticatedUser, BASE62_ALPHABET, BUILTIN_JEXL_HELPERS, BaseDocument, Block, BooleanField, CROCKFORD_BASE32, CollectionConfig, ComputedHandler, type ConfigDiagnostic, ConfigValidationError, ConflictError, DateField, DateTimeField, type DeclarativeAccessSurface, type DeclarativeAccessValidationIssue, type DeclarativeAdminSurface, type DeclarativeAdminValidationIssue, DeclarativeHookExpression, type DeclarativeHookSurface, type DeclarativeHookValidationIssue, type DeclarativePreviewSurface, type DeclarativePreviewValidationIssue, DetailAction, DetailActionOptions, DetailComputed, DetailComputedOptions, DetailCustom, DetailCustomOptions, DetailDivider, DetailDividerOptions, DetailField, DetailGrid, DetailGridOptions, DetailItem, DetailRepeat, DetailRepeatOptions, DetailSchema, DetailSection, DetailSectionOptions, DetailTab, DetailTabOptions, DetailTabs, DetailTabsOptions, DetailText, DetailTextOptions, DisplayFieldOptions, DuplicateKeyError, DyrectedAIError, DyrectedConfig, DyrectedError, EmailField, type ExprFunction, type ExtractCollectionSlugs, Field, FieldConditionBuilder, FieldType, ForbiddenError, type GenerateIdOptions, GlobalConfig, HookRequestContext, IconField, IdStrategy, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MatchBuilder, MultiSelectField, NANOID_ALPHABET, NON_NEGOTIABLE_CREDENTIAL_FIELDS, NotFoundError, NumberField, ObjectField, PII_REGEX_PATTERNS, type Prettify, PublicAdminAuthConfig, type PublishingWorkflowOptions, RadioField, RelationshipField, RichTextField, RowField, type SanitizeDocForAIOptions, SelectField, type SortClause, type SortDirection, type SqlSortDialect, type SystemDocFields, TextField, TextareaField, TimeField, type UploadDocFields, UrlField, ValidationError, WORKFLOW_HISTORY_COLLECTION, type WhenFunction, WorkflowConfig, WorkflowTransition, abs, addDays, asCollection, assertValidAdminConditionsInConfig, assertValidDeclarativeAccessInConfig, assertValidDeclarativeHookExpression, assertValidDeclarativeHookResult, assertValidDeclarativeHooksInConfig, assertValidPreviewUrlsInConfig, availableWorkflowTransitions, buildSqlOrderBy, canViewWorkflowDraft, capitalize, ceil, clamp, coalesce, collectAdminConditionValidationIssues, collectConfigDiagnostics, collectDeclarativeAccessValidationIssues, collectDeclarativeHookValidationIssues, collectPreviewUrlValidationIssues, compact, count, createLifecycleEvent, createWorkflowDocument, defaultValue, defineArrayField, defineBlock, defineBlocksField, defineBooleanField, defineCollection, defineConfig, defineDateField, defineDateTimeField, defineEmailField, defineField, defineGlobal, defineIconField, defineImageField, defineJoinField, defineJsonField, defineMultiSelectField, defineNumberField, defineObjectField, definePublishingWorkflow, defineRadioField, defineRelationshipField, defineRichTextField, defineRowField, defineSelectField, defineTab, defineTextField, defineTextareaField, defineTimeField, defineUrlField, diffDays, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, displayAction, displayComputed, displayCustom, displayCustomComponent, displayDivider, displayField, displayGrid, displayRepeat, displaySection, displayTab, displayTabs, displayText, endsWith, evaluateDetailComputed, evaluateJexl, evaluateJexlSync, executeFieldAfterRead, executeFieldBeforeChange, expr, first, floor, formatConfigDiagnostics, formatDate, formatJexlValue, generateDefaultDetailSchema, generateDocumentId, generateId, generateOpenApi, get, getAdminAuthCollection, getAdminRoleForCollection, getAllowedSitesForUser, getPublicAdminAuthConfig, includes, initializeWorkflowDocument, isConfigValidationError, isDetailItemVisible, isEmpty, isFuture, isPast, isSiteAuthorized, isUserAdmin, join, last, length, lower, maskEmail, maskPhone, maskTextPII, materializeWorkflowDocument, max, min, nanoid, normalizeConfig, normalizeDetailItem, now, numericFieldNames, parseSort, pow, prefixedId, publishedStateName, publishingWorkflow, readingTime, registerJexlHelpers, replace, resolveAdminAuthCollection, resolveAuthorizedSiteId, resolvePrefix, round, runCollectionHooks, sanitizeDocForAI, saveWorkflowDraft, simplePublishingWorkflow, slugify, sqrt, startsWith, sum, today, transitionWorkflow, trim, truncate, ulid, unique, upper, uuid, validateAdminConditionExpression, validateDeclarativeAccessExpression, validateDeclarativeHookExpression, validatePreviewUrlExpression, when, wordCount, workflowCapabilities };
|
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 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
|
|
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 IdStrategy, R as ArrayField, S as FieldType, T as BooleanField, U as AuthConfig, V as AccessPolicyResolver, X as DateField, Y as DateTimeField, Z as EmailField, _ as IconField, $ as ImageField, a0 as JoinField, a1 as JsonField, a2 as MultiSelectField, a3 as NumberField, a4 as ObjectField, a5 as RadioField, a6 as RelationshipField, a7 as RichTextField, a8 as RowField, a9 as SelectField, aa as TextField, ab as TextareaField, ac as TimeField, ad as UrlField } from './app-KSDgfXsw.js';
|
|
2
|
+
export { ae as AIAction, af as AIActionStatus, ag as AIActionType, ah as AIAuditActionType, ai as AIAuditRecord, aj as AIChunk, ak as AIMessage, al as AIPIIPattern, am as AIRateLimitResult, an as AIRateLimitStore, ao as AIThread, ap as AIToolContext, aq as AIToolDefinition, ar as AI_ACTIONS_COLLECTION, as as AI_AUDIT_COLLECTION, at as AI_CHUNKS_COLLECTION, au as AI_MESSAGES_COLLECTION, av as AI_THREADS_COLLECTION, aw as AccessConfig, ax as AccessFunction, ay as AccessFunctionArgs, az as AccessResult, aA as AccessRule, aB as ActionConfig, aC as ActionConfigBase, aD as ActionConfigWithHandler, aE as ActionConfigWithMutation, aF as ActionContext, aG as ActionType, aH as AdminAuthAccessResolution, aI as AdminAuthClaimMapping, aJ as AdminAuthMember, aK as AdminAuthProvider, aL as AdminAuthProviderMembersConfig, aM as AdminAuthProvisioningMode, aN as AdminAuthResolveAccessArgs, aO as AdminAuthResolvedIdentity, aP as AdminConfig, aQ as AdminDashboardComponentSlots, aR as AdminIconName, aS as AggregateArgs, aT as AggregateCastType, aU as AggregateCollectionResult, aV as AggregateInput, aW as AggregateOperation, aX as AggregateResult, aY as BaseAdminAuthProvider, aZ as BaseFieldAdmin, a_ as BlockVariant, a$ as BlocksField, b0 as BooleanFieldAdmin, b1 as BooleanFormat, b2 as CharacterLimitFieldAdmin, b3 as CharacterLimitFieldConfig, b4 as CollectionAfterChangeHook, b5 as CollectionAfterDeleteHook, b6 as CollectionAfterReadHook, b7 as CollectionAfterReadHookEntry, b8 as CollectionAfterTransitionHook, b9 as CollectionBeforeChangeHook, ba as CollectionBeforeChangeHookEntry, bb as CollectionBeforeDeleteHook, bc as CollectionBeforeReadHook, bd as CollectionBeforeReadHookEntry, be as CollectionBeforeTransitionHook, bf as CollectionIndex, bg as CollectionListComponentSlots, bh as CollectionRAGConfig, bi as CollectionSchemaResult, bj as CollectionSummaryResult, bk as CollectionViewComponentSlots, bl as CountOperation, bm as CustomAdminAuthProvider, bn as DatabaseAdapter, bo as DateFieldAdmin, bp as DateFormat, bq as DefaultValueContext, br as DefineActionOptions, bs as DefineCalendarViewOptions, bt as DefineCardsViewOptions, bu as DefineGanttViewOptions, bv as DefineKanbanViewOptions, bw as DefineTableViewOptions, bx as DefineViewBaseOptions, by as DefineViewOptions, bz as DetailSpan, bA as DisplayTone, bB as DisplayVariant, bC as DistinctCountOperation, bD as DistinctValuesOperation, bE as DynamicOptionItem, bF as DynamicOptionsConfig, bG as DynamicOptionsResolver, bH as DynamicOptionsResolverArgs, bI as DyrectedAIContext, bJ as DyrectedLoggerConfig, bK as DyrectedObservabilityConfig, bL as EmailFieldAdmin, bM as FieldAdminHooks, bN as FieldAdminOnChangeHook, bO as FieldAdminOnChangeHookArgs, bP as FieldAdminOptionsHook, bQ as FieldAdminOptionsHookArgs, bR as FieldAdminOptionsHookResult, bS as FieldAfterReadHook, bT as FieldAfterReadHookArgs, bU as FieldBase, bV as FieldBeforeChangeHook, bW as FieldBeforeChangeHookArgs, bX as FieldHook, bY as FieldHooks, bZ as FileData, b_ as GetDocumentResult, b$ as GlobalAfterChangeHook, c0 as GlobalAfterReadHook, c1 as GlobalAfterReadHookEntry, c2 as GlobalBeforeChangeHook, c3 as GlobalBeforeChangeHookEntry, c4 as GlobalBeforeReadHook, c5 as GlobalBeforeReadHookEntry, c6 as GlobalRAGConfig, c7 as GlobalSchemaResult, c8 as GlobalSummaryResult, c9 as HeadingLevel, ca as HookFunction, cb as IconFieldAdmin, cc as ImageService, cd as ImageTransformOptions, ce as InferAggregateResult, cf as JoinFieldAdmin, cg as JsonFieldAdmin, ch as JsonFormat, ci as LIFECYCLE_EVENT_NAMES, cj as LifecycleEventHandler, ck as LinkFormat, cl as MetricColor, cm as MultiSelectFieldAdmin, cn as NamedAccessPolicy, co as NumberFieldAdmin, cp as NumberFormat, cq as NumberLimitFieldAdmin, cr as NumberLimitFieldConfig, cs as NumericOperation, ct as NumericUpdateOperator, cu as OIDCAdminAuthProvider, cv as OptionFormat, cw as PaginatedResult, cx as PublicAdminAuthProvider, cy as QueryCollectionResult, cz as RAGSearchResult, cA as RadioFieldAdmin, cB as RateLimitConfig, cC as ReadonlyDatabaseAdapter, cD as RichTextFeature, cE as RichTextFieldConfig, cF as SelectFieldAdmin, cG as SqlWhereResult, cH as StorageAdapter, cI as TextFieldAdmin, cJ as TextFormat, cK as TextareaFieldAdmin, cL as TrustProxyConfig, cM as TypedField, cN as UploadConfig, cO as UrlFieldAdmin, cP as UrlLinkValue, cQ as ViewActionFeatures, cR as ViewComponentSlots, cS as ViewConfig, cT as ViewLayout, cU as ViewMetric, cV as ViewSubMetric, cW as WhereClause, cX as WhereOperator, cY as WhereOperatorName, cZ as WordLimitFieldAdmin, c_ as WordLimitFieldConfig, c$ as WorkflowMetadata, d0 as WorkflowRole, d1 as WorkflowState, d2 as WorkflowTransitionContext, d3 as defineAction, d4 as defineCalendarView, d5 as defineCardsView, d6 as defineGanttView, d7 as defineKanbanView, d8 as defineTableView, d9 as defineView, da as isAICollection, db as parseMongoWhere, dc as parseSqlWhere } from './app-KSDgfXsw.js';
|
|
3
3
|
import jexl from 'jexl';
|
|
4
4
|
import { Context } from 'hono';
|
|
5
5
|
export { z } from 'zod';
|
|
@@ -196,6 +196,15 @@ declare class NotFoundError extends DyrectedError {
|
|
|
196
196
|
declare class ConflictError extends DyrectedError {
|
|
197
197
|
constructor(message: string);
|
|
198
198
|
}
|
|
199
|
+
/** A unique constraint or unique index was violated on insert/update. Answered with `409`. */
|
|
200
|
+
declare class DuplicateKeyError extends ConflictError {
|
|
201
|
+
readonly field?: string;
|
|
202
|
+
readonly value?: any;
|
|
203
|
+
constructor(message: string, options?: {
|
|
204
|
+
field?: string;
|
|
205
|
+
value?: any;
|
|
206
|
+
});
|
|
207
|
+
}
|
|
199
208
|
|
|
200
209
|
type SortDirection = 'ASC' | 'DESC';
|
|
201
210
|
interface SortClause {
|
|
@@ -1320,6 +1329,70 @@ interface SanitizeDocForAIOptions {
|
|
|
1320
1329
|
*/
|
|
1321
1330
|
declare function sanitizeDocForAI(options: SanitizeDocForAIOptions): Record<string, unknown>;
|
|
1322
1331
|
|
|
1332
|
+
declare const NANOID_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";
|
|
1333
|
+
declare const BASE62_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
1334
|
+
declare const CROCKFORD_BASE32 = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
1335
|
+
/**
|
|
1336
|
+
* Generates an unbiased cryptographically secure NanoID string.
|
|
1337
|
+
*
|
|
1338
|
+
* @param size Number of characters to generate (default: 21)
|
|
1339
|
+
* @param alphabet Characters to draw from (default: URL-safe Base64 alphanumeric)
|
|
1340
|
+
*/
|
|
1341
|
+
declare function nanoid(size?: number, alphabet?: string): string;
|
|
1342
|
+
/**
|
|
1343
|
+
* Generates a 26-character time-sortable ULID (Universally Unique Lexicographically Sortable Identifier).
|
|
1344
|
+
*
|
|
1345
|
+
* The first 10 characters encode the millisecond timestamp, followed by 16 cryptographically secure
|
|
1346
|
+
* random Crockford Base32 characters. ULIDs sort in chronological order, making them optimal
|
|
1347
|
+
* for B-tree index locality in relational databases.
|
|
1348
|
+
*
|
|
1349
|
+
* @param seedTime Optional millisecond timestamp (default: Date.now())
|
|
1350
|
+
*/
|
|
1351
|
+
declare function ulid(seedTime?: number): string;
|
|
1352
|
+
/**
|
|
1353
|
+
* Standard RFC 4122 UUIDv4 generator wrapper.
|
|
1354
|
+
*/
|
|
1355
|
+
declare function uuid(): string;
|
|
1356
|
+
/**
|
|
1357
|
+
* Resolves a clean 3-4 character prefix for a collection slug or explicit prefix.
|
|
1358
|
+
*
|
|
1359
|
+
* @example
|
|
1360
|
+
* resolvePrefix('cob-daily-reports') // 'cob'
|
|
1361
|
+
* resolvePrefix('ipo-reservations') // 'ipo'
|
|
1362
|
+
* resolvePrefix('users') // 'usr'
|
|
1363
|
+
* resolvePrefix('applications') // 'app'
|
|
1364
|
+
* resolvePrefix('anything', 'custom') // 'custom'
|
|
1365
|
+
*/
|
|
1366
|
+
declare function resolvePrefix(slug?: string, explicitPrefix?: string): string;
|
|
1367
|
+
/**
|
|
1368
|
+
* Generates a Stripe-style prefixed NanoID (e.g. `col_k9pQ2mZwRtx89aB1`).
|
|
1369
|
+
*
|
|
1370
|
+
* Uses Base62 for the random suffix to prevent extra underscores and hyphens in the ID body.
|
|
1371
|
+
*
|
|
1372
|
+
* @param prefix Collection prefix (e.g. 'usr', 'cob', 'app', 'col')
|
|
1373
|
+
* @param size Length of the random suffix (default: 16)
|
|
1374
|
+
*/
|
|
1375
|
+
declare function prefixedId(prefix?: string, size?: number): string;
|
|
1376
|
+
|
|
1377
|
+
interface GenerateIdOptions {
|
|
1378
|
+
prefix?: string;
|
|
1379
|
+
type?: IdStrategy;
|
|
1380
|
+
size?: number;
|
|
1381
|
+
}
|
|
1382
|
+
/**
|
|
1383
|
+
* Generates an ID according to the specified options. Defaults to Stripe-style prefixed NanoID.
|
|
1384
|
+
*/
|
|
1385
|
+
declare function generateId(options?: GenerateIdOptions | string): string;
|
|
1386
|
+
/**
|
|
1387
|
+
* Generates a document ID based on collection configuration or slug.
|
|
1388
|
+
*/
|
|
1389
|
+
declare function generateDocumentId(collectionOrSlug?: string | {
|
|
1390
|
+
slug: string;
|
|
1391
|
+
idPrefix?: string;
|
|
1392
|
+
idType?: IdStrategy;
|
|
1393
|
+
idGenerator?: (slug: string) => string;
|
|
1394
|
+
}): string;
|
|
1395
|
+
|
|
1323
1396
|
type TopLevelFieldName<TFields extends readonly Field[]> = Extract<TFields[number], {
|
|
1324
1397
|
name: string;
|
|
1325
1398
|
}>["name"];
|
|
@@ -1816,4 +1889,4 @@ declare function defineTab<const T extends readonly Field[]>(args: {
|
|
|
1816
1889
|
fields: T;
|
|
1817
1890
|
}): T;
|
|
1818
1891
|
|
|
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 };
|
|
1892
|
+
export { AIConfig, type AIErrorCode, AIPIIConfig, type AccessConditions, AccessPolicyResolver, AdminAuthConfig, ArrayField, AuthConfig, type AuthDocFields, AuthenticatedUser, BASE62_ALPHABET, BUILTIN_JEXL_HELPERS, BaseDocument, Block, BooleanField, CROCKFORD_BASE32, CollectionConfig, ComputedHandler, type ConfigDiagnostic, ConfigValidationError, ConflictError, DateField, DateTimeField, type DeclarativeAccessSurface, type DeclarativeAccessValidationIssue, type DeclarativeAdminSurface, type DeclarativeAdminValidationIssue, DeclarativeHookExpression, type DeclarativeHookSurface, type DeclarativeHookValidationIssue, type DeclarativePreviewSurface, type DeclarativePreviewValidationIssue, DetailAction, DetailActionOptions, DetailComputed, DetailComputedOptions, DetailCustom, DetailCustomOptions, DetailDivider, DetailDividerOptions, DetailField, DetailGrid, DetailGridOptions, DetailItem, DetailRepeat, DetailRepeatOptions, DetailSchema, DetailSection, DetailSectionOptions, DetailTab, DetailTabOptions, DetailTabs, DetailTabsOptions, DetailText, DetailTextOptions, DisplayFieldOptions, DuplicateKeyError, DyrectedAIError, DyrectedConfig, DyrectedError, EmailField, type ExprFunction, type ExtractCollectionSlugs, Field, FieldConditionBuilder, FieldType, ForbiddenError, type GenerateIdOptions, GlobalConfig, HookRequestContext, IconField, IdStrategy, ImageField, type InferDocShape, JoinField, JsonField, LIFECYCLE_EVENTS_COLLECTION, LifecycleEvent, LifecycleEventName, MatchBuilder, MultiSelectField, NANOID_ALPHABET, NON_NEGOTIABLE_CREDENTIAL_FIELDS, NotFoundError, NumberField, ObjectField, PII_REGEX_PATTERNS, type Prettify, PublicAdminAuthConfig, type PublishingWorkflowOptions, RadioField, RelationshipField, RichTextField, RowField, type SanitizeDocForAIOptions, SelectField, type SortClause, type SortDirection, type SqlSortDialect, type SystemDocFields, TextField, TextareaField, TimeField, type UploadDocFields, UrlField, ValidationError, WORKFLOW_HISTORY_COLLECTION, type WhenFunction, WorkflowConfig, WorkflowTransition, abs, addDays, asCollection, assertValidAdminConditionsInConfig, assertValidDeclarativeAccessInConfig, assertValidDeclarativeHookExpression, assertValidDeclarativeHookResult, assertValidDeclarativeHooksInConfig, assertValidPreviewUrlsInConfig, availableWorkflowTransitions, buildSqlOrderBy, canViewWorkflowDraft, capitalize, ceil, clamp, coalesce, collectAdminConditionValidationIssues, collectConfigDiagnostics, collectDeclarativeAccessValidationIssues, collectDeclarativeHookValidationIssues, collectPreviewUrlValidationIssues, compact, count, createLifecycleEvent, createWorkflowDocument, defaultValue, defineArrayField, defineBlock, defineBlocksField, defineBooleanField, defineCollection, defineConfig, defineDateField, defineDateTimeField, defineEmailField, defineField, defineGlobal, defineIconField, defineImageField, defineJoinField, defineJsonField, defineMultiSelectField, defineNumberField, defineObjectField, definePublishingWorkflow, defineRadioField, defineRelationshipField, defineRichTextField, defineRowField, defineSelectField, defineTab, defineTextField, defineTextareaField, defineTimeField, defineUrlField, diffDays, dispatchLifecycleEvent, dispatchPendingLifecycleEvents, displayAction, displayComputed, displayCustom, displayCustomComponent, displayDivider, displayField, displayGrid, displayRepeat, displaySection, displayTab, displayTabs, displayText, endsWith, evaluateDetailComputed, evaluateJexl, evaluateJexlSync, executeFieldAfterRead, executeFieldBeforeChange, expr, first, floor, formatConfigDiagnostics, formatDate, formatJexlValue, generateDefaultDetailSchema, generateDocumentId, generateId, generateOpenApi, get, getAdminAuthCollection, getAdminRoleForCollection, getAllowedSitesForUser, getPublicAdminAuthConfig, includes, initializeWorkflowDocument, isConfigValidationError, isDetailItemVisible, isEmpty, isFuture, isPast, isSiteAuthorized, isUserAdmin, join, last, length, lower, maskEmail, maskPhone, maskTextPII, materializeWorkflowDocument, max, min, nanoid, normalizeConfig, normalizeDetailItem, now, numericFieldNames, parseSort, pow, prefixedId, publishedStateName, publishingWorkflow, readingTime, registerJexlHelpers, replace, resolveAdminAuthCollection, resolveAuthorizedSiteId, resolvePrefix, round, runCollectionHooks, sanitizeDocForAI, saveWorkflowDraft, simplePublishingWorkflow, slugify, sqrt, startsWith, sum, today, transitionWorkflow, trim, truncate, ulid, unique, upper, uuid, validateAdminConditionExpression, validateDeclarativeAccessExpression, validateDeclarativeHookExpression, validatePreviewUrlExpression, when, wordCount, workflowCapabilities };
|
package/dist/index.js
CHANGED
|
@@ -3363,6 +3363,134 @@ function assertValidDeclarativeAccessInConfig(config, source = "config") {
|
|
|
3363
3363
|
throw new ConfigValidationError(source, diagnostics);
|
|
3364
3364
|
}
|
|
3365
3365
|
|
|
3366
|
+
// src/utils/id.ts
|
|
3367
|
+
import { randomBytes, randomUUID } from "crypto";
|
|
3368
|
+
var NANOID_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";
|
|
3369
|
+
var BASE62_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
3370
|
+
var CROCKFORD_BASE32 = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
3371
|
+
var COMMON_SLUG_PREFIXES = {
|
|
3372
|
+
users: "usr",
|
|
3373
|
+
members: "mem",
|
|
3374
|
+
accounts: "acc",
|
|
3375
|
+
applications: "app",
|
|
3376
|
+
customers: "cus",
|
|
3377
|
+
products: "prd",
|
|
3378
|
+
orders: "ord",
|
|
3379
|
+
reports: "rpt",
|
|
3380
|
+
sessions: "ses",
|
|
3381
|
+
transactions: "txn",
|
|
3382
|
+
wallets: "wal",
|
|
3383
|
+
media: "med",
|
|
3384
|
+
files: "fil",
|
|
3385
|
+
posts: "post",
|
|
3386
|
+
pages: "page",
|
|
3387
|
+
tags: "tag",
|
|
3388
|
+
categories: "cat",
|
|
3389
|
+
comments: "com"
|
|
3390
|
+
};
|
|
3391
|
+
function nanoid(size = 21, alphabet = NANOID_ALPHABET) {
|
|
3392
|
+
const mask = (2 << 31 - Math.clz32(alphabet.length - 1 | 1)) - 1;
|
|
3393
|
+
const step = Math.ceil(1.6 * mask * size / alphabet.length);
|
|
3394
|
+
let id = "";
|
|
3395
|
+
while (true) {
|
|
3396
|
+
const bytes = randomBytes(step);
|
|
3397
|
+
for (let i = 0; i < step; i++) {
|
|
3398
|
+
const byte = bytes[i] & mask;
|
|
3399
|
+
if (alphabet[byte]) {
|
|
3400
|
+
id += alphabet[byte];
|
|
3401
|
+
if (id.length === size) return id;
|
|
3402
|
+
}
|
|
3403
|
+
}
|
|
3404
|
+
}
|
|
3405
|
+
}
|
|
3406
|
+
function encodeUlidTime(now2, len = 10) {
|
|
3407
|
+
let str = "";
|
|
3408
|
+
let time = Math.floor(now2);
|
|
3409
|
+
for (let i = len - 1; i >= 0; i--) {
|
|
3410
|
+
const mod = time % 32;
|
|
3411
|
+
str = CROCKFORD_BASE32[mod] + str;
|
|
3412
|
+
time = (time - mod) / 32;
|
|
3413
|
+
}
|
|
3414
|
+
return str;
|
|
3415
|
+
}
|
|
3416
|
+
function encodeUlidRandom(bytes) {
|
|
3417
|
+
let str = "";
|
|
3418
|
+
let bitBuffer = 0;
|
|
3419
|
+
let bitsInBuffer = 0;
|
|
3420
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
3421
|
+
bitBuffer = bitBuffer << 8 | bytes[i];
|
|
3422
|
+
bitsInBuffer += 8;
|
|
3423
|
+
while (bitsInBuffer >= 5) {
|
|
3424
|
+
bitsInBuffer -= 5;
|
|
3425
|
+
const index = bitBuffer >> bitsInBuffer & 31;
|
|
3426
|
+
str += CROCKFORD_BASE32[index];
|
|
3427
|
+
}
|
|
3428
|
+
}
|
|
3429
|
+
return str;
|
|
3430
|
+
}
|
|
3431
|
+
function ulid(seedTime = Date.now()) {
|
|
3432
|
+
const timePart = encodeUlidTime(seedTime);
|
|
3433
|
+
const randPart = encodeUlidRandom(randomBytes(10));
|
|
3434
|
+
return timePart + randPart;
|
|
3435
|
+
}
|
|
3436
|
+
function uuid() {
|
|
3437
|
+
return randomUUID();
|
|
3438
|
+
}
|
|
3439
|
+
function resolvePrefix(slug, explicitPrefix) {
|
|
3440
|
+
if (explicitPrefix && typeof explicitPrefix === "string" && explicitPrefix.trim().length > 0) {
|
|
3441
|
+
const cleaned = explicitPrefix.trim().toLowerCase().replace(/[^a-z0-9_]/g, "");
|
|
3442
|
+
if (cleaned.length > 0) return cleaned;
|
|
3443
|
+
}
|
|
3444
|
+
if (!slug || typeof slug !== "string") return "col";
|
|
3445
|
+
const s = slug.trim().toLowerCase();
|
|
3446
|
+
if (COMMON_SLUG_PREFIXES[s]) return COMMON_SLUG_PREFIXES[s];
|
|
3447
|
+
const pieces = s.split(/[-_]/).filter(Boolean);
|
|
3448
|
+
if (pieces.length > 1 && pieces[0].length >= 2) {
|
|
3449
|
+
const first2 = pieces[0].replace(/[^a-z0-9]/g, "");
|
|
3450
|
+
if (first2.length >= 2) return first2.slice(0, 4);
|
|
3451
|
+
}
|
|
3452
|
+
const cleanWord = s.replace(/[^a-z0-9]/g, "");
|
|
3453
|
+
if (cleanWord.length <= 4) return cleanWord || "col";
|
|
3454
|
+
return cleanWord.slice(0, 3) || "col";
|
|
3455
|
+
}
|
|
3456
|
+
function prefixedId(prefix = "col", size = 16) {
|
|
3457
|
+
const cleanPrefix = (prefix || "col").toLowerCase().replace(/[^a-z0-9_]/g, "") || "col";
|
|
3458
|
+
return `${cleanPrefix}_${nanoid(size, BASE62_ALPHABET)}`;
|
|
3459
|
+
}
|
|
3460
|
+
function generateId(options) {
|
|
3461
|
+
if (typeof options === "string") {
|
|
3462
|
+
return prefixedId(resolvePrefix(options));
|
|
3463
|
+
}
|
|
3464
|
+
const opts = options || {};
|
|
3465
|
+
const type = opts.type || "prefixed-nanoid";
|
|
3466
|
+
switch (type) {
|
|
3467
|
+
case "uuid":
|
|
3468
|
+
return uuid();
|
|
3469
|
+
case "ulid":
|
|
3470
|
+
return ulid();
|
|
3471
|
+
case "nanoid":
|
|
3472
|
+
return nanoid(opts.size || 21);
|
|
3473
|
+
case "prefixed-nanoid":
|
|
3474
|
+
default:
|
|
3475
|
+
return prefixedId(opts.prefix || "col", opts.size || 16);
|
|
3476
|
+
}
|
|
3477
|
+
}
|
|
3478
|
+
function generateDocumentId(collectionOrSlug) {
|
|
3479
|
+
if (!collectionOrSlug) {
|
|
3480
|
+
return prefixedId("col");
|
|
3481
|
+
}
|
|
3482
|
+
if (typeof collectionOrSlug === "string") {
|
|
3483
|
+
const prefix2 = resolvePrefix(collectionOrSlug);
|
|
3484
|
+
return prefixedId(prefix2);
|
|
3485
|
+
}
|
|
3486
|
+
if (typeof collectionOrSlug.idGenerator === "function") {
|
|
3487
|
+
return collectionOrSlug.idGenerator(collectionOrSlug.slug);
|
|
3488
|
+
}
|
|
3489
|
+
const type = collectionOrSlug.idType || "prefixed-nanoid";
|
|
3490
|
+
const prefix = resolvePrefix(collectionOrSlug.slug, collectionOrSlug.idPrefix);
|
|
3491
|
+
return generateId({ prefix, type });
|
|
3492
|
+
}
|
|
3493
|
+
|
|
3366
3494
|
// src/utils/config.ts
|
|
3367
3495
|
var AUDIT_COLLECTION_SLUG = "__audit";
|
|
3368
3496
|
var SYSTEM_FIELDS = [
|
|
@@ -3684,11 +3812,31 @@ function normalizeConfig(config) {
|
|
|
3684
3812
|
}
|
|
3685
3813
|
const updatedFieldNames = new Set(fields.map((f) => f.name));
|
|
3686
3814
|
const fieldsToInject = SYSTEM_FIELDS.filter((f) => !updatedFieldNames.has(f.name));
|
|
3815
|
+
const indexedFieldNames = /* @__PURE__ */ new Set();
|
|
3816
|
+
if (col.indexes) {
|
|
3817
|
+
for (const idx of col.indexes) {
|
|
3818
|
+
if (Array.isArray(idx.fields)) {
|
|
3819
|
+
for (const f of idx.fields) {
|
|
3820
|
+
indexedFieldNames.add(f);
|
|
3821
|
+
}
|
|
3822
|
+
}
|
|
3823
|
+
}
|
|
3824
|
+
}
|
|
3825
|
+
const allFields = [...fields, ...fieldsToInject].map((field) => {
|
|
3826
|
+
if (field.unique || field.name && indexedFieldNames.has(field.name)) {
|
|
3827
|
+
return { ...field, promoted: true };
|
|
3828
|
+
}
|
|
3829
|
+
return field;
|
|
3830
|
+
});
|
|
3687
3831
|
const workflow = col.workflow || (col.drafts ? simplePublishingWorkflow() : void 0);
|
|
3832
|
+
const idPrefix = col.idPrefix || resolvePrefix(col.slug);
|
|
3833
|
+
const idType = col.idType || "prefixed-nanoid";
|
|
3688
3834
|
return {
|
|
3689
3835
|
...col,
|
|
3836
|
+
idPrefix,
|
|
3837
|
+
idType,
|
|
3690
3838
|
workflow,
|
|
3691
|
-
fields:
|
|
3839
|
+
fields: allFields
|
|
3692
3840
|
};
|
|
3693
3841
|
});
|
|
3694
3842
|
const hasAuditCollection = normalizedCollections.some((col) => col.slug === AUDIT_COLLECTION_SLUG);
|
|
@@ -3748,6 +3896,17 @@ var ConflictError = class _ConflictError extends DyrectedError {
|
|
|
3748
3896
|
Object.setPrototypeOf(this, _ConflictError.prototype);
|
|
3749
3897
|
}
|
|
3750
3898
|
};
|
|
3899
|
+
var DuplicateKeyError = class _DuplicateKeyError extends ConflictError {
|
|
3900
|
+
field;
|
|
3901
|
+
value;
|
|
3902
|
+
constructor(message, options) {
|
|
3903
|
+
super(message);
|
|
3904
|
+
this.name = "DuplicateKeyError";
|
|
3905
|
+
this.field = options?.field;
|
|
3906
|
+
this.value = options?.value;
|
|
3907
|
+
Object.setPrototypeOf(this, _DuplicateKeyError.prototype);
|
|
3908
|
+
}
|
|
3909
|
+
};
|
|
3751
3910
|
|
|
3752
3911
|
// src/utils/parse-where.ts
|
|
3753
3912
|
function assertNever(op, context) {
|
|
@@ -6432,9 +6591,12 @@ export {
|
|
|
6432
6591
|
AI_CHUNKS_COLLECTION,
|
|
6433
6592
|
AI_MESSAGES_COLLECTION,
|
|
6434
6593
|
AI_THREADS_COLLECTION,
|
|
6594
|
+
BASE62_ALPHABET,
|
|
6435
6595
|
BUILTIN_JEXL_HELPERS,
|
|
6596
|
+
CROCKFORD_BASE32,
|
|
6436
6597
|
ConfigValidationError,
|
|
6437
6598
|
ConflictError,
|
|
6599
|
+
DuplicateKeyError,
|
|
6438
6600
|
DyrectedAIError,
|
|
6439
6601
|
DyrectedError,
|
|
6440
6602
|
FieldConditionBuilder,
|
|
@@ -6442,6 +6604,7 @@ export {
|
|
|
6442
6604
|
LIFECYCLE_EVENTS_COLLECTION,
|
|
6443
6605
|
LIFECYCLE_EVENT_NAMES,
|
|
6444
6606
|
MatchBuilder,
|
|
6607
|
+
NANOID_ALPHABET,
|
|
6445
6608
|
NON_NEGOTIABLE_CREDENTIAL_FIELDS,
|
|
6446
6609
|
NotFoundError,
|
|
6447
6610
|
PII_REGEX_PATTERNS,
|
|
@@ -6537,6 +6700,8 @@ export {
|
|
|
6537
6700
|
formatDate,
|
|
6538
6701
|
formatJexlValue,
|
|
6539
6702
|
generateDefaultDetailSchema,
|
|
6703
|
+
generateDocumentId,
|
|
6704
|
+
generateId,
|
|
6540
6705
|
generateOpenApi,
|
|
6541
6706
|
get,
|
|
6542
6707
|
getAdminAuthCollection,
|
|
@@ -6563,6 +6728,7 @@ export {
|
|
|
6563
6728
|
materializeWorkflowDocument,
|
|
6564
6729
|
max,
|
|
6565
6730
|
min,
|
|
6731
|
+
nanoid,
|
|
6566
6732
|
normalizeConfig,
|
|
6567
6733
|
normalizeDetailItem,
|
|
6568
6734
|
now,
|
|
@@ -6571,6 +6737,7 @@ export {
|
|
|
6571
6737
|
parseSort,
|
|
6572
6738
|
parseSqlWhere,
|
|
6573
6739
|
pow,
|
|
6740
|
+
prefixedId,
|
|
6574
6741
|
publishedStateName,
|
|
6575
6742
|
publishingWorkflow,
|
|
6576
6743
|
readingTime,
|
|
@@ -6578,6 +6745,7 @@ export {
|
|
|
6578
6745
|
replace,
|
|
6579
6746
|
resolveAdminAuthCollection,
|
|
6580
6747
|
resolveAuthorizedSiteId,
|
|
6748
|
+
resolvePrefix,
|
|
6581
6749
|
round,
|
|
6582
6750
|
runCollectionHooks,
|
|
6583
6751
|
sanitizeDocForAI,
|
|
@@ -6591,8 +6759,10 @@ export {
|
|
|
6591
6759
|
transitionWorkflow,
|
|
6592
6760
|
trim,
|
|
6593
6761
|
truncate,
|
|
6762
|
+
ulid,
|
|
6594
6763
|
unique,
|
|
6595
6764
|
upper,
|
|
6765
|
+
uuid,
|
|
6596
6766
|
validateAdminConditionExpression,
|
|
6597
6767
|
validateDeclarativeAccessExpression,
|
|
6598
6768
|
validateDeclarativeHookExpression,
|