@protobase/schema 0.121.8 → 0.121.10

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.
@@ -15,6 +15,8 @@ export type BucketsModel = {
15
15
  by: string[];
16
16
  /** The number fields of `from` it keeps, with what it keeps of each, as the fields `<name>_sum` and `<name>_max`. */
17
17
  measures: Record<string, BucketMeasure[]>;
18
+ /** The measured fields of `from` that are optional: `events` counts their records without a value too, so a bucket cannot give their average. */
19
+ optional: string[];
18
20
  /** How late a record may arrive and still be counted by a refresh, such as `2 hours`. */
19
21
  late: string;
20
22
  };
@@ -0,0 +1,9 @@
1
+ import { BucketMeasure, BucketsModel } from "./buckets-model.js";
2
+ import "../refs.js";
3
+ //#region src/buckets/buckets-of.d.ts
4
+ /** The source field and measure that a time rollup's field `name`, such as `watts_sum`, keeps; `undefined` for any other field. */
5
+ export declare const keptMeasure: (buckets: BucketsModel, name: string) => {
6
+ field: string;
7
+ measure: BucketMeasure;
8
+ } | undefined;
9
+ //#endregion
@@ -61,6 +61,16 @@ const sumField = (field, declared) => {
61
61
  };
62
62
  /** The names of the measure fields of a time rollup, by source field and measure. */
63
63
  const measureFieldName = (field, measure) => `${field}_${measure}`;
64
+ /** The source field and measure that a time rollup's field `name`, such as `watts_sum`, keeps; `undefined` for any other field. */
65
+ const keptMeasure = (buckets, name) => {
66
+ for (const [field, fns] of Object.entries(buckets.measures)) {
67
+ const measure = fns.find((fn) => measureFieldName(field, fn) === name);
68
+ if (measure) return {
69
+ field,
70
+ measure
71
+ };
72
+ }
73
+ };
64
74
  const timeProblems = (source, time) => {
65
75
  const field = source.fields[time];
66
76
  if (!field) return [`time "${time}" is not a field of "${source.name}"`];
@@ -135,9 +145,10 @@ const bucketsState = (name, source, buckets) => {
135
145
  buckets: {
136
146
  ...buckets,
137
147
  by: [...buckets.by],
138
- measures: Object.fromEntries(Object.entries(buckets.measures).map(([field, fns]) => [field, [...fns]]))
148
+ measures: Object.fromEntries(Object.entries(buckets.measures).map(([field, fns]) => [field, [...fns]])),
149
+ optional: Object.keys(buckets.measures).filter((field) => model.fields[field].nullable)
139
150
  }
140
151
  };
141
152
  };
142
153
  //#endregion
143
- export { bucketsState, measureFieldName };
154
+ export { bucketsState, keptMeasure, measureFieldName };
@@ -0,0 +1,18 @@
1
+ //#region src/checks-problems.ts
2
+ const builtInCodes = [
3
+ "required",
4
+ "invalid-value",
5
+ "read-only",
6
+ "unknown-field",
7
+ "invalid-record"
8
+ ];
9
+ const longestName = 63;
10
+ /** What makes a resource's `.checks()` unusable: a name the database cannot hold or an error code already means, or an empty label. */
11
+ const checksProblems = (model) => Object.entries(model.checks ?? {}).flatMap(([name, check]) => [
12
+ ...name === "" ? ["check has no name"] : [],
13
+ ...new TextEncoder().encode(name).length > longestName ? [`check "${name}" is longer than the ${longestName} bytes Postgres keeps of a name`] : [],
14
+ ...builtInCodes.includes(name) ? [`check "${name}" has the name of an error code the API uses itself`] : [],
15
+ ...check.label.trim() === "" ? [`check "${name}" has no label`] : []
16
+ ]);
17
+ //#endregion
18
+ export { checksProblems };
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { DerivedModel, DerivedTarget } from "./derived/derived-model.js";
4
4
  import { BucketEvery, BucketMeasure, BucketsModel } from "./buckets/buckets-model.js";
5
5
  import { FileOptions, FileProcessor, FileProcessorInput, ImageFormat, ImageVariant, ImageVariantOptions, imageFormats } from "./files/file-options.js";
6
6
  import { BadgeTone, badgeTones, isBadgeTone } from "./badge-tones.js";
7
- import { ActionInputKind, ActionInputModel, ActionModel, ActionRun, AppAddress, BadgeShape, BlockElementModel, BlocksSectionModel, BottomBarItemModel, BottomBarModel, CalendarView, CardFavoriteModel, CardPhotosModel, ChartGranularity, ChartModel, ChartRange, CheckedFilter, CommentsSectionModel, CompareOp, ComposerSectionModel, ConversationPageModel, ConversationThreadModel, CreateModel, CustomFallbackItemModel, CustomSectionModel, DatePreset, DurationLiteral, DurationUnit, EventModel, EventOperation, ExportModel, FieldFormat, FieldModel, FieldPath, FieldType, FieldViewModel, FieldWidgetModel, FileFieldModel, FilterError, FilterErrorCode, FilterExpr, FilterLayout, FilterOf, FilterValue, FilterWidgetModel, FormModel, GalleryModel, GroupChartModel, GroupItemModel, GroupModel, HelpWhen, HistorySectionModel, JsonValue, KeyValue, LayoutItemModel, ListDisplayModel, ListDragModel, ListModel, ListQuery, Literal, MapSectionModel, MapView, NamedListModel, NavModel, NavRecentModel, NavStartModel, NowValue, OrderByItem, PageWidth, ParentAccess, ParentModel, PeriodChartModel, PositionAfterModel, ReactionsModel, ReadPositionModel, RecordChartModel, RecordChartRange, RecordMode, RecordPageModel, RecordTrendModel, RecordWhen, RelatedColumnModel, RelatedFilter, RelatedModel, RelatedPresentation, ResourceModel, RowButtonChoice, RowButtonModel, SaveFeedback, SaveSearchModel, SearchMatch, SearchResultModel, SearchesOfModel, SectionModel, SectionPresentation, ShowWhen, SignInPromptModel, SignInViewModel, SortSpec, Span, StatusTone, TabItemModel, TabModel, ThreadSectionModel, TimelineView, TitleFromModel, ToolCallFields, UserMenuItemModel, UserMenuModel, ViewModel } from "./model.js";
7
+ import { ActionInputKind, ActionInputModel, ActionModel, ActionRun, AppAddress, AttachmentsModel, BadgeShape, BlockElementModel, BlocksSectionModel, BoardDragModel, BottomBarItemModel, BottomBarModel, CalendarView, CardFavoriteModel, CardPhotosModel, ChartGranularity, ChartModel, ChartRange, CheckModel, CheckedFilter, CommentsSectionModel, CompareOp, ComposerSectionModel, ConversationPageModel, ConversationThreadModel, CreateModel, CustomFallbackItemModel, CustomSectionModel, DatePreset, DurationLiteral, DurationUnit, EventModel, EventOperation, ExportModel, FieldFormat, FieldModel, FieldPath, FieldType, FieldViewModel, FieldWidgetModel, FileFieldModel, FilterError, FilterErrorCode, FilterExpr, FilterLayout, FilterOf, FilterValue, FilterWidgetModel, FormModel, GalleryModel, GroupChartModel, GroupItemModel, GroupModel, HelpWhen, HistorySectionModel, JsonValue, KeyValue, LayoutItemModel, ListDisplayModel, ListDragModel, ListModel, ListQuery, Literal, MapSectionModel, MapView, NamedListModel, NavModel, NavRecentModel, NavStartModel, NowValue, OrderByItem, PageWidth, ParentAccess, ParentModel, PeriodChartModel, PositionAfterModel, ReactionsModel, ReadPositionModel, RecordChartModel, RecordChartRange, RecordMode, RecordPageModel, RecordTrendModel, RecordWhen, RelatedColumnModel, RelatedFilter, RelatedModel, RelatedPresentation, ResourceModel, RowButtonChoice, RowButtonModel, SaveFeedback, SaveSearchModel, SearchMatch, SearchResultModel, SearchesOfModel, SectionModel, SectionPresentation, ShowWhen, SignInPromptModel, SignInViewModel, SortSpec, Span, StatusTone, TabItemModel, TabModel, ThreadSectionModel, TimelineView, TitleFromModel, ToolCallFields, UserMenuItemModel, UserMenuModel, ViewModel } from "./model.js";
8
8
  import { AccessAction, AccessContext, AccessFn, AccessResult, AccessUser, FieldAccess, FieldRule } from "./access/types.js";
9
9
  import { Encrypted, encrypted } from "./encrypted-value.js";
10
10
  import { AnyField, Constraint, Field, FieldMeta, FieldTypeDef } from "./field.js";
@@ -58,4 +58,4 @@ import { CellKind, FileCell, FileDate, FileJson, cellKind, isEmptyFileCell } fro
58
58
  import { UserTableFieldType, UserTableNameIssue, userTableNameIssue } from "./user-tables/names.js";
59
59
  import { ColumnType, ColumnTypeReader, DecimalType, columnTypeReader, inferColumnType, maxShortText, minWholeDigits, widerFieldTypes } from "./user-tables/column-type.js";
60
60
  import { fieldNamesOf, tableNameOf } from "./user-tables/column-names.js";
61
- export { type Access, type AccessAction, type AccessContext, type AccessFn, type AccessResult, type AccessSource, type AccessUser, type ActionInputKind, type ActionInputModel, type ActionModel, type ActionRun, type AnyField, type AppAddress, type ArgumentSpec, type ArgumentType, type ArgumentsSpec, type AssistantAction, type AssistantActionRequest, type AssistantCardPart, type AssistantDiff, type AssistantEvent, type AssistantMessage, type AssistantMessageRequest, type AssistantPart, type AssistantState, type AssistantStep, type AssistantStepState, type AssistantTablePart, type AssistantTextPart, type AssistantTone, type AssistantWidgetPart, type BadgeShape, type BadgeTone, type BlockElementModel, type BlocksSectionModel, type BottomBarItemModel, type BottomBarModel, type BottomBarNames, type BottomBarSource, type BucketEvery, type BucketFields, type BucketMeasure, type BucketMeasuresInput, type BucketsModel, type BucketsSpec, type CalendarView, type Capability, type CapabilityAction, type CapabilityLimit, type CapabilityScope, type CardFavoriteModel, type CardPhotosModel, type CellKind, type ChartGranularity, type ChartInput, type ChartModel, type ChartRange, type CheckResult, type CheckedFilter, type ColumnType, type ColumnTypeReader, type CommentsSectionModel, type CompareOp, type ComponentRef, type ComposerSectionModel, type ComputedReveal, type ConnectAddress, type Constraint, type ConversationPageModel, type ConversationThreadModel, type CreateModel, type CreatedOptions, type CustomFallbackItemModel, type CustomSectionModel, type DatePreset, type DecimalType, type DeletedOptions, type DerivedModel, type DerivedSpec, type DerivedTarget, type DurationLiteral, type DurationUnit, type Encrypted, type EvaluateOptions, type EventActor, type EventContext, type EventHelpers, type EventMatch, type EventModel, type EventOperation, type EventSpec, type ExactCapability, type ExportModel, type Field, type FieldAccess, type FieldFormat, type FieldMeta, type FieldModel, type FieldPath, type FieldRefValue, type FieldRefs, type FieldRule, type FieldType, type FieldTypeDef, type FieldView, type FieldViewModel, type FieldViews, type FieldWidgetModel, type FieldsInput, type FileCell, type FileDate, type FileField, type FileFieldModel, type FileJson, type FileOptions, type FileProcessor, type FileProcessorInput, type FilterError, type FilterErrorCode, type FilterExpr, type FilterLayout, type FilterLimits, type FilterOf, type FilterParse, type FilterValue, type FilterWidgetModel, type FormAddress, type FormInput, type FormModel, type GalleryModel, type Grant, type GroupChartInput, type GroupChartModel, type GroupItemModel, type GroupModel, type HeldCapability, type HelpWhen, type HistorySectionModel, type ImageFormat, type ImageVariant, type ImageVariantOptions, type InferRecord, type Issue, type JsonValue, type KeyOf, type KeyRefs, type KeyType, type KeyValue, type LayoutItemModel, type ListColumn, type ListDisplayModel, type ListDragModel, type ListModel, type ListQuery, type Literal, type Lookup, type MapSectionModel, type MapView, type NamedListModel, type NavModel, type NavRecentModel, type NavStartModel, type NowValue, type OrderByCheck, type OrderByItem, type OrderByParse, type PageWidth, type ParentAccess, type ParentModel, type PeriodChartInput, type PeriodChartModel, type PositionAfterModel, type ReactionsModel, type ReadPositionModel, type RecordChartModel, type RecordChartRange, type RecordKey, type RecordMode, type RecordOf, type RecordPageModel, type RecordTrendModel, type RecordWhen, type Ref, type Refs, type RelatedColumnModel, type RelatedFilter, type RelatedModel, type RelatedPresentation, type RelationField, type ResolveOptions, type ResolvedAccess, type ResourceBuilder, type ResourceModel, type RevealCaller, type RoleEntry, type RoleLimit, type Roles, type RolesOptions, type Rollup, type RollupCount, type RollupFn, type RollupSource, type RollupValue, type RowButtonChoice, type RowButtonModel, type RowFilterOperation, type Rule, type SaveFeedback, type SaveSearchModel, type SearchMatch, type SearchRef, type SearchRefs, type SearchResultModel, type SearchesOfModel, type SectionModel, type SectionPresentation, type ShowWhen, type SignInAddress, type SignInPromptModel, type SignInStep, type SignInViewModel, type SortSpec, type Span, type StatusTone, type TabItemModel, type TabModel, type TenantOptions, type ThreadSectionModel, type TimelineView, type TitleFromModel, type ToolCallFields, type UndeletedOptions, type UpdatedOptions, type UserMenuItemModel, type UserMenuModel, type UserMenuSource, type UserTableFieldType, type UserTableNameIssue, type Validator, type ViewBuilder, type ViewModel, type ViewProps, accessWarnings, addressWords, anonymousRole, appPath, argumentsSchema, badgeTones, bottomBar, bottomBarErrors, cellKind, checkFilter, checkOrderBy, checkRecord, columnTypeReader, connectParams, connectPath, connectRoute, createWhere, defineRoles, encrypted, enumLabel, evaluateFilter, f, fieldNamesOf, fieldRef, fieldsUsedBy, fitsKeyType, formPath, formRoute, imageFormats, inferColumnType, isBadgeTone, isEmptyFileCell, isRecordCondition, keyTypes, layout as l, maxBottomBarItems, maxJsonDepth, maxShortText, membersRule, minWholeDigits, parseFilter, parseOrderBy, pickView, printFilter, printOrderBy, readAppPath, readConnectAddress, readFormAddress, readSignInAddress, resolveAccess, resource, restrictModel, rule, signInParams, signInPath, signInRoute, signInSteps, tableNameOf, userMenu, userTableNameIssue, view, where, widerFieldTypes };
61
+ export { type Access, type AccessAction, type AccessContext, type AccessFn, type AccessResult, type AccessSource, type AccessUser, type ActionInputKind, type ActionInputModel, type ActionModel, type ActionRun, type AnyField, type AppAddress, type ArgumentSpec, type ArgumentType, type ArgumentsSpec, type AssistantAction, type AssistantActionRequest, type AssistantCardPart, type AssistantDiff, type AssistantEvent, type AssistantMessage, type AssistantMessageRequest, type AssistantPart, type AssistantState, type AssistantStep, type AssistantStepState, type AssistantTablePart, type AssistantTextPart, type AssistantTone, type AssistantWidgetPart, type AttachmentsModel, type BadgeShape, type BadgeTone, type BlockElementModel, type BlocksSectionModel, type BoardDragModel, type BottomBarItemModel, type BottomBarModel, type BottomBarNames, type BottomBarSource, type BucketEvery, type BucketFields, type BucketMeasure, type BucketMeasuresInput, type BucketsModel, type BucketsSpec, type CalendarView, type Capability, type CapabilityAction, type CapabilityLimit, type CapabilityScope, type CardFavoriteModel, type CardPhotosModel, type CellKind, type ChartGranularity, type ChartInput, type ChartModel, type ChartRange, type CheckModel, type CheckResult, type CheckedFilter, type ColumnType, type ColumnTypeReader, type CommentsSectionModel, type CompareOp, type ComponentRef, type ComposerSectionModel, type ComputedReveal, type ConnectAddress, type Constraint, type ConversationPageModel, type ConversationThreadModel, type CreateModel, type CreatedOptions, type CustomFallbackItemModel, type CustomSectionModel, type DatePreset, type DecimalType, type DeletedOptions, type DerivedModel, type DerivedSpec, type DerivedTarget, type DurationLiteral, type DurationUnit, type Encrypted, type EvaluateOptions, type EventActor, type EventContext, type EventHelpers, type EventMatch, type EventModel, type EventOperation, type EventSpec, type ExactCapability, type ExportModel, type Field, type FieldAccess, type FieldFormat, type FieldMeta, type FieldModel, type FieldPath, type FieldRefValue, type FieldRefs, type FieldRule, type FieldType, type FieldTypeDef, type FieldView, type FieldViewModel, type FieldViews, type FieldWidgetModel, type FieldsInput, type FileCell, type FileDate, type FileField, type FileFieldModel, type FileJson, type FileOptions, type FileProcessor, type FileProcessorInput, type FilterError, type FilterErrorCode, type FilterExpr, type FilterLayout, type FilterLimits, type FilterOf, type FilterParse, type FilterValue, type FilterWidgetModel, type FormAddress, type FormInput, type FormModel, type GalleryModel, type Grant, type GroupChartInput, type GroupChartModel, type GroupItemModel, type GroupModel, type HeldCapability, type HelpWhen, type HistorySectionModel, type ImageFormat, type ImageVariant, type ImageVariantOptions, type InferRecord, type Issue, type JsonValue, type KeyOf, type KeyRefs, type KeyType, type KeyValue, type LayoutItemModel, type ListColumn, type ListDisplayModel, type ListDragModel, type ListModel, type ListQuery, type Literal, type Lookup, type MapSectionModel, type MapView, type NamedListModel, type NavModel, type NavRecentModel, type NavStartModel, type NowValue, type OrderByCheck, type OrderByItem, type OrderByParse, type PageWidth, type ParentAccess, type ParentModel, type PeriodChartInput, type PeriodChartModel, type PositionAfterModel, type ReactionsModel, type ReadPositionModel, type RecordChartModel, type RecordChartRange, type RecordKey, type RecordMode, type RecordOf, type RecordPageModel, type RecordTrendModel, type RecordWhen, type Ref, type Refs, type RelatedColumnModel, type RelatedFilter, type RelatedModel, type RelatedPresentation, type RelationField, type ResolveOptions, type ResolvedAccess, type ResourceBuilder, type ResourceModel, type RevealCaller, type RoleEntry, type RoleLimit, type Roles, type RolesOptions, type Rollup, type RollupCount, type RollupFn, type RollupSource, type RollupValue, type RowButtonChoice, type RowButtonModel, type RowFilterOperation, type Rule, type SaveFeedback, type SaveSearchModel, type SearchMatch, type SearchRef, type SearchRefs, type SearchResultModel, type SearchesOfModel, type SectionModel, type SectionPresentation, type ShowWhen, type SignInAddress, type SignInPromptModel, type SignInStep, type SignInViewModel, type SortSpec, type Span, type StatusTone, type TabItemModel, type TabModel, type TenantOptions, type ThreadSectionModel, type TimelineView, type TitleFromModel, type ToolCallFields, type UndeletedOptions, type UpdatedOptions, type UserMenuItemModel, type UserMenuModel, type UserMenuSource, type UserTableFieldType, type UserTableNameIssue, type Validator, type ViewBuilder, type ViewModel, type ViewProps, accessWarnings, addressWords, anonymousRole, appPath, argumentsSchema, badgeTones, bottomBar, bottomBarErrors, cellKind, checkFilter, checkOrderBy, checkRecord, columnTypeReader, connectParams, connectPath, connectRoute, createWhere, defineRoles, encrypted, enumLabel, evaluateFilter, f, fieldNamesOf, fieldRef, fieldsUsedBy, fitsKeyType, formPath, formRoute, imageFormats, inferColumnType, isBadgeTone, isEmptyFileCell, isRecordCondition, keyTypes, layout as l, maxBottomBarItems, maxJsonDepth, maxShortText, membersRule, minWholeDigits, parseFilter, parseOrderBy, pickView, printFilter, printOrderBy, readAppPath, readConnectAddress, readFormAddress, readSignInAddress, resolveAccess, resource, restrictModel, rule, signInParams, signInPath, signInRoute, signInSteps, tableNameOf, userMenu, userTableNameIssue, view, where, widerFieldTypes };
@@ -68,4 +68,5 @@ import { guestCallsPath } from "./calls/call-guests.js";
68
68
  import { CallRing, callsChannelEvent, declineWord, ringNotice, ringsPath } from "./calls/call-rings.js";
69
69
  import { ReorderSpan, reorderSpan } from "./reorder-span.js";
70
70
  import { MovePlan, Ranked, movePlan } from "./move-plan.js";
71
- export { type AddressCheck, type Availability, type CallCandidate, type CallClientMessage, type CallDescription, type CallGuestLink, type CallGuestRefusal, type CallGuestState, type CallLeftReason, type CallLobbyGuest, type CallMode, type CallRemoteTrack, type CallResume, type CallRing, type CallRosterMember, type CallServerMessage, type CallTrackRequest, type CallTrackSource, type CallVideoLayer, type FormulaNode, type KeyType, type Locale, type MobileReleaseAnswer, type MovePlan, type PathLookup, type PersonStatus, type PluginCapabilities, type PluginHost, type PluginRequirement, type PropShapes, type Ranked, type RecordUse, type RefShape, type ReleaseBinding, type ReorderSpan, type RunnerRegistration, type SearchTerm, type StatusInput, type TemplatePath, type WorkflowCacheAdvice, type WorkflowRunTrace, type WorkflowStatus, type WorkflowTraceHeld, type WorkflowTraceStep, type WorkflowTypeEntry, type WorkflowTypeList, actionConditionError, actionInputErrors, addressErrors, addressPlaceholders, apiOriginMeta, appHrefError, appReadMaxBytes, appReadParam, appReadUrl, applyAssistantEvent, authBasePath, availabilities, bareFilterFields, boardErrors, bottomBarFor, bridgeSocketPath, bridgeTokenParam, builtInFieldTypes, callsChannelEvent, capacitorOrigin, cardPhotoLimit, chartFields, checkEventFilter, checkedAccept, checkedProvider, confirmationMinutes, datesErrors, declineWord, decodeKey, defaultRecentLimit, deviceIdParam, devicesPath, displayFields, emailCodeMinutes, embeddedFilterFields, emptyAssistantState, encodeKey, fieldRefsIn, filePath, filesPath, fillAddress, fillAddressFrom, fillFilter, fillText, filterField, findField, firstPartyCodeKey, followableRowButton, grantsOf, guestCallsPath, heldCapabilities, heldStatus, historyIdParam, historyIdPattern, historyPath, hostPlaceholder, hrefField, hrefPlaceholders, humanize, inRange, isAppRead, isFieldRef, isGroupChart, isLocale, isUserTableName, keyTypes, labelFieldOf, layoutItems, leavesApp, linkActionError, listColumnNames, locales, lookupLink, markFieldRefs, matchedSearchField, matchesSearch, maxLabelLength, maxNameBytes, maxOrganizationNameBytes, maxRelatedDepth, maxRelatedTerms, maxStatusText, missingCapabilities, mobileReleaseBasePath, mobileReleaseParams, mobileReleasePath, mobileReleaseQuery, mobileReleasesPath, movePlan, navRecentErrors, navStartErrors, organizationColumn, parseCapability, parseFormula, parseSize, parseTable, parseTemplatePath, pickLocale, pluginProblem, promptError, promptFields, pruneByShape, pushRecord, readEventStream, recordJsonSchema, recordTitle, recordTitleField, recordValueAt, redactSecrets, relatedErrors, relatedTarget, releaseManifestFile, releaseStatementContext, releaseStatementFile, renderPrompt, reorderSpan, reservedFieldNames, reservedWords, resolvableStatuses, resourceField, ringNotice, ringsPath, rowButtonChoiceFields, rowButtonChoices, rowButtonErrors, rowButtonFields, rowButtonTarget, runnerRegistrationParam, runnerRegistrationPath, runnerRegistrationRoute, searchTerms, secondStepParam, serviceWorkerFile, shapes, shownInputs, splitRelated, statusPath, statusRuns, statusTextProblem, statusTones, storageNamePattern, storedFileRef, tableDisplay, tapUrl, templatePlaceholders, termMatches, textPlaceholders, unmarkFieldRefs, updateSetErrors, updateValues, userTableName, valueText, viewOfList, webhookResources, wholePlaceholder, withLookups, workflowResources, workflowRunParam, workflowRunTracePath, workflowRunTraceRoute, workflowRunsPath, workflowStatusTones, workflowStatuses, workflowTraceAfterParam, workflowTraceRevision, workflowTraceRevisionParam, workflowTypesPath };
71
+ import { keptMeasure } from "./buckets/buckets-of.js";
72
+ export { type AddressCheck, type Availability, type CallCandidate, type CallClientMessage, type CallDescription, type CallGuestLink, type CallGuestRefusal, type CallGuestState, type CallLeftReason, type CallLobbyGuest, type CallMode, type CallRemoteTrack, type CallResume, type CallRing, type CallRosterMember, type CallServerMessage, type CallTrackRequest, type CallTrackSource, type CallVideoLayer, type FormulaNode, type KeyType, type Locale, type MobileReleaseAnswer, type MovePlan, type PathLookup, type PersonStatus, type PluginCapabilities, type PluginHost, type PluginRequirement, type PropShapes, type Ranked, type RecordUse, type RefShape, type ReleaseBinding, type ReorderSpan, type RunnerRegistration, type SearchTerm, type StatusInput, type TemplatePath, type WorkflowCacheAdvice, type WorkflowRunTrace, type WorkflowStatus, type WorkflowTraceHeld, type WorkflowTraceStep, type WorkflowTypeEntry, type WorkflowTypeList, actionConditionError, actionInputErrors, addressErrors, addressPlaceholders, apiOriginMeta, appHrefError, appReadMaxBytes, appReadParam, appReadUrl, applyAssistantEvent, authBasePath, availabilities, bareFilterFields, boardErrors, bottomBarFor, bridgeSocketPath, bridgeTokenParam, builtInFieldTypes, callsChannelEvent, capacitorOrigin, cardPhotoLimit, chartFields, checkEventFilter, checkedAccept, checkedProvider, confirmationMinutes, datesErrors, declineWord, decodeKey, defaultRecentLimit, deviceIdParam, devicesPath, displayFields, emailCodeMinutes, embeddedFilterFields, emptyAssistantState, encodeKey, fieldRefsIn, filePath, filesPath, fillAddress, fillAddressFrom, fillFilter, fillText, filterField, findField, firstPartyCodeKey, followableRowButton, grantsOf, guestCallsPath, heldCapabilities, heldStatus, historyIdParam, historyIdPattern, historyPath, hostPlaceholder, hrefField, hrefPlaceholders, humanize, inRange, isAppRead, isFieldRef, isGroupChart, isLocale, isUserTableName, keptMeasure, keyTypes, labelFieldOf, layoutItems, leavesApp, linkActionError, listColumnNames, locales, lookupLink, markFieldRefs, matchedSearchField, matchesSearch, maxLabelLength, maxNameBytes, maxOrganizationNameBytes, maxRelatedDepth, maxRelatedTerms, maxStatusText, missingCapabilities, mobileReleaseBasePath, mobileReleaseParams, mobileReleasePath, mobileReleaseQuery, mobileReleasesPath, movePlan, navRecentErrors, navStartErrors, organizationColumn, parseCapability, parseFormula, parseSize, parseTable, parseTemplatePath, pickLocale, pluginProblem, promptError, promptFields, pruneByShape, pushRecord, readEventStream, recordJsonSchema, recordTitle, recordTitleField, recordValueAt, redactSecrets, relatedErrors, relatedTarget, releaseManifestFile, releaseStatementContext, releaseStatementFile, renderPrompt, reorderSpan, reservedFieldNames, reservedWords, resolvableStatuses, resourceField, ringNotice, ringsPath, rowButtonChoiceFields, rowButtonChoices, rowButtonErrors, rowButtonFields, rowButtonTarget, runnerRegistrationParam, runnerRegistrationPath, runnerRegistrationRoute, searchTerms, secondStepParam, serviceWorkerFile, shapes, shownInputs, splitRelated, statusPath, statusRuns, statusTextProblem, statusTones, storageNamePattern, storedFileRef, tableDisplay, tapUrl, templatePlaceholders, termMatches, textPlaceholders, unmarkFieldRefs, updateSetErrors, updateValues, userTableName, valueText, viewOfList, webhookResources, wholePlaceholder, withLookups, workflowResources, workflowRunParam, workflowRunTracePath, workflowRunTraceRoute, workflowRunsPath, workflowStatusTones, workflowStatuses, workflowTraceAfterParam, workflowTraceRevision, workflowTraceRevisionParam, workflowTypesPath };
package/dist/internal.js CHANGED
@@ -9,6 +9,7 @@ import { matchedSearchField, matchesSearch, searchTerms, termMatches } from "./s
9
9
  import { grantsOf, parseCapability } from "./access/capability.js";
10
10
  import { heldCapabilities } from "./access/role-entry.js";
11
11
  import { checkEventFilter } from "./events/event-models.js";
12
+ import { keptMeasure } from "./buckets/buckets-of.js";
12
13
  import { parseTable } from "./resource-model.js";
13
14
  import { layoutItems } from "./layout-items.js";
14
15
  import { viewOfList } from "./named-list.js";
@@ -67,4 +68,4 @@ import { guestCallsPath } from "./calls/call-guests.js";
67
68
  import { callsChannelEvent, declineWord, ringNotice, ringsPath } from "./calls/call-rings.js";
68
69
  import { reorderSpan } from "./reorder-span.js";
69
70
  import { movePlan } from "./move-plan.js";
70
- export { actionConditionError, actionInputErrors, addressErrors, addressPlaceholders, apiOriginMeta, appHrefError, appReadMaxBytes, appReadParam, appReadUrl, applyAssistantEvent, authBasePath, availabilities, bareFilterFields, boardErrors, bottomBarFor, bridgeSocketPath, bridgeTokenParam, builtInFieldTypes, callsChannelEvent, capacitorOrigin, cardPhotoLimit, chartFields, checkEventFilter, checkedAccept, checkedProvider, confirmationMinutes, datesErrors, declineWord, decodeKey, defaultRecentLimit, deviceIdParam, devicesPath, displayFields, emailCodeMinutes, embeddedFilterFields, emptyAssistantState, encodeKey, fieldRefsIn, filePath, filesPath, fillAddress, fillAddressFrom, fillFilter, fillText, filterField, findField, firstPartyCodeKey, followableRowButton, grantsOf, guestCallsPath, heldCapabilities, heldStatus, historyIdParam, historyIdPattern, historyPath, hostPlaceholder, hrefField, hrefPlaceholders, humanize, inRange, isAppRead, isFieldRef, isGroupChart, isLocale, isUserTableName, keyTypes, labelFieldOf, layoutItems, leavesApp, linkActionError, listColumnNames, locales, lookupLink, markFieldRefs, matchedSearchField, matchesSearch, maxLabelLength, maxNameBytes, maxOrganizationNameBytes, maxRelatedDepth, maxRelatedTerms, maxStatusText, missingCapabilities, mobileReleaseBasePath, mobileReleaseParams, mobileReleasePath, mobileReleaseQuery, mobileReleasesPath, movePlan, navRecentErrors, navStartErrors, organizationColumn, parseCapability, parseFormula, parseSize, parseTable, parseTemplatePath, pickLocale, pluginProblem, promptError, promptFields, pruneByShape, pushRecord, readEventStream, recordJsonSchema, recordTitle, recordTitleField, recordValueAt, redactSecrets, relatedErrors, relatedTarget, releaseManifestFile, releaseStatementContext, releaseStatementFile, renderPrompt, reorderSpan, reservedFieldNames, reservedWords, resolvableStatuses, resourceField, ringNotice, ringsPath, rowButtonChoiceFields, rowButtonChoices, rowButtonErrors, rowButtonFields, rowButtonTarget, runnerRegistrationParam, runnerRegistrationPath, runnerRegistrationRoute, searchTerms, secondStepParam, serviceWorkerFile, shapes, shownInputs, splitRelated, statusPath, statusRuns, statusTextProblem, statusTones, storageNamePattern, storedFileRef, tableDisplay, tapUrl, templatePlaceholders, termMatches, textPlaceholders, unmarkFieldRefs, updateSetErrors, updateValues, userTableName, valueText, viewOfList, webhookResources, wholePlaceholder, withLookups, workflowResources, workflowRunParam, workflowRunTracePath, workflowRunTraceRoute, workflowRunsPath, workflowStatusTones, workflowStatuses, workflowTraceAfterParam, workflowTraceRevision, workflowTraceRevisionParam, workflowTypesPath };
71
+ export { actionConditionError, actionInputErrors, addressErrors, addressPlaceholders, apiOriginMeta, appHrefError, appReadMaxBytes, appReadParam, appReadUrl, applyAssistantEvent, authBasePath, availabilities, bareFilterFields, boardErrors, bottomBarFor, bridgeSocketPath, bridgeTokenParam, builtInFieldTypes, callsChannelEvent, capacitorOrigin, cardPhotoLimit, chartFields, checkEventFilter, checkedAccept, checkedProvider, confirmationMinutes, datesErrors, declineWord, decodeKey, defaultRecentLimit, deviceIdParam, devicesPath, displayFields, emailCodeMinutes, embeddedFilterFields, emptyAssistantState, encodeKey, fieldRefsIn, filePath, filesPath, fillAddress, fillAddressFrom, fillFilter, fillText, filterField, findField, firstPartyCodeKey, followableRowButton, grantsOf, guestCallsPath, heldCapabilities, heldStatus, historyIdParam, historyIdPattern, historyPath, hostPlaceholder, hrefField, hrefPlaceholders, humanize, inRange, isAppRead, isFieldRef, isGroupChart, isLocale, isUserTableName, keptMeasure, keyTypes, labelFieldOf, layoutItems, leavesApp, linkActionError, listColumnNames, locales, lookupLink, markFieldRefs, matchedSearchField, matchesSearch, maxLabelLength, maxNameBytes, maxOrganizationNameBytes, maxRelatedDepth, maxRelatedTerms, maxStatusText, missingCapabilities, mobileReleaseBasePath, mobileReleaseParams, mobileReleasePath, mobileReleaseQuery, mobileReleasesPath, movePlan, navRecentErrors, navStartErrors, organizationColumn, parseCapability, parseFormula, parseSize, parseTable, parseTemplatePath, pickLocale, pluginProblem, promptError, promptFields, pruneByShape, pushRecord, readEventStream, recordJsonSchema, recordTitle, recordTitleField, recordValueAt, redactSecrets, relatedErrors, relatedTarget, releaseManifestFile, releaseStatementContext, releaseStatementFile, renderPrompt, reorderSpan, reservedFieldNames, reservedWords, resolvableStatuses, resourceField, ringNotice, ringsPath, rowButtonChoiceFields, rowButtonChoices, rowButtonErrors, rowButtonFields, rowButtonTarget, runnerRegistrationParam, runnerRegistrationPath, runnerRegistrationRoute, searchTerms, secondStepParam, serviceWorkerFile, shapes, shownInputs, splitRelated, statusPath, statusRuns, statusTextProblem, statusTones, storageNamePattern, storedFileRef, tableDisplay, tapUrl, templatePlaceholders, termMatches, textPlaceholders, unmarkFieldRefs, updateSetErrors, updateValues, userTableName, valueText, viewOfList, webhookResources, wholePlaceholder, withLookups, workflowResources, workflowRunParam, workflowRunTracePath, workflowRunTraceRoute, workflowRunsPath, workflowStatusTones, workflowStatuses, workflowTraceAfterParam, workflowTraceRevision, workflowTraceRevisionParam, workflowTypesPath };
package/dist/model.d.ts CHANGED
@@ -182,6 +182,11 @@ export type ResourceModel = {
182
182
  * who may read it (`.openExisting()`).
183
183
  */
184
184
  openExisting?: string[];
185
+ /**
186
+ * The database checks whose refusal the API names, by constraint name, each with the label shown for it
187
+ * (`.checks()`).
188
+ */
189
+ checks?: Record<string, CheckModel>;
185
190
  /** The resource it is a time rollup of, and how (`.bucketsOf()`): the database writes its rows, the API only reads them. */
186
191
  buckets?: BucketsModel;
187
192
  /** The values worked out from other records for each of its records, kept current by Protobase (`.derive()`). */
@@ -700,6 +705,18 @@ export type ParentModel = {
700
705
  /** The access on the parent record that writing needs. */
701
706
  access: ParentAccess;
702
707
  };
708
+ /**
709
+ * A database check that refuses a write, named by its constraint: a `CHECK` constraint of that name, or a trigger's
710
+ * `raise exception ... using errcode = 'check_violation', constraint = '<name>'`. See
711
+ * [Checks the database makes](docs/website/src/content/docs/reference/data-config.mdx#checks-the-database-makes).
712
+ */
713
+ export type CheckModel = {
714
+ /**
715
+ * What the app shows when the check refuses a write, an ICU message whose `{field}` values come from the record as
716
+ * the app has it, never from the database's error. Translated as `resources.<resource>.checks.<name>.label`.
717
+ */
718
+ label: string;
719
+ };
703
720
  /** A view's list page (`.list(...)`). */
704
721
  export type ListModel = {
705
722
  /** The table's columns, in order. */
@@ -735,17 +752,30 @@ export type ListDragModel = {
735
752
  */
736
753
  rank?: boolean;
737
754
  /**
738
- * Moving a board's card to another column: `true` saves its record with that column's value; the name of a board drop
739
- * in the UI config's `boardDrops` lets cards move only between the columns it names, each drop running its write, which
740
- * works when the board's field is read-only, such as one the database computes.
755
+ * Moving a board's card to another column: `true` saves its record with that column's value; a `BoardDragModel` saves
756
+ * that value in another field, or lets only some columns take a card; the name of a board drop in the UI config's
757
+ * `boardDrops` lets cards move only between the columns it names, each drop running its write. The last two work when
758
+ * the board's field is read-only, such as one the database computes.
741
759
  */
742
- board?: boolean | string;
760
+ board?: boolean | string | BoardDragModel;
743
761
  /**
744
762
  * Where the table's rows may land when re-ranked: the name of a drop rule in the UI config's `dropRules`. A drop where
745
763
  * it refuses lands in the first place below that it allows, with a warning saying why.
746
764
  */
747
765
  rule?: string;
748
766
  };
767
+ /**
768
+ * Which columns of a board take a card and what a drop writes, as `drag: { board: { set, columns } }`. A card dropped on
769
+ * another column saves its record with the column's value in `set`; the record is then read again and the card lands in
770
+ * the column its `by` value now puts it in. See
771
+ * [Moving cards by another field](docs/website/src/content/docs/reference/ui-config.mdx#moving-cards-by-another-field).
772
+ */
773
+ export type BoardDragModel = {
774
+ /** The writable field a drop saves the column's value in, such as a `lane` a trigger turns into the computed `by`; `by` when omitted. */
775
+ set?: string;
776
+ /** The values of the columns a card moves from and to; every column when omitted. A card in another column stays in it. */
777
+ columns?: string[];
778
+ };
749
779
  /**
750
780
  * A list column of the records of another resource that point at each row, directly or through a join resource, as a
751
781
  * dot per record in its status's colour, each opening the record (`c.related(...)`). See
@@ -1739,6 +1769,8 @@ export type ConversationPageModel = {
1739
1769
  };
1740
1770
  /** Replies in a thread under a message, shown in a panel beside the conversation rather than in it. */
1741
1771
  thread?: ConversationThreadModel;
1772
+ /** Files a message carries, kept in a resource of their own: picked, pasted or dropped in the box and shown under the message. */
1773
+ attachments?: AttachmentsModel;
1742
1774
  /**
1743
1775
  * The record's call, by the name of the API function that admits people to it with `calls.join`: the header shows
1744
1776
  * Start call, or the call going on with Join, and the page that joins it (`?call=join`) shows the call beside the
@@ -1783,6 +1815,22 @@ export type ReactionsModel = {
1783
1815
  name: string;
1784
1816
  }>;
1785
1817
  };
1818
+ /**
1819
+ * The files under a conversation's messages: one record per file, pointing at its message, written together with the
1820
+ * message and deleted before it.
1821
+ */
1822
+ export type AttachmentsModel = {
1823
+ /** The attachment resource. */
1824
+ resource: string;
1825
+ /** The filterable relation of `resource` to the message the file is in. */
1826
+ field: string;
1827
+ /** The file field, whose value gives the file's name, type, size and signed link, and whose `maxSize` the box checks before uploading. */
1828
+ file: string;
1829
+ /** The integer field of an image's width in pixels, such as one `.derive()` fills with `imageSize('width')`. */
1830
+ width?: string;
1831
+ /** The integer field of an image's height in pixels. */
1832
+ height?: string;
1833
+ };
1786
1834
  /** Threads under a conversation's messages: a reply points at the thread's first message, which counts its replies. */
1787
1835
  export type ConversationThreadModel = {
1788
1836
  /** The filterable relation of the message resource to itself that holds a reply's first message, empty for a message of the conversation. */
@@ -1,6 +1,6 @@
1
1
  import { DerivedModel } from "./derived/derived-model.js";
2
2
  import { BucketsModel } from "./buckets/buckets-model.js";
3
- import { ParentModel, PositionAfterModel, SearchMatch } from "./model.js";
3
+ import { CheckModel, ParentModel, PositionAfterModel, SearchMatch } from "./model.js";
4
4
  import { FieldsInput } from "./refs.js";
5
5
  import { EventSpec } from "./events/event-helpers.js";
6
6
  //#region src/resource-model.d.ts
@@ -32,6 +32,7 @@ export type ResourceState = {
32
32
  explicitGrants?: boolean;
33
33
  etagFrom?: string;
34
34
  openExisting?: string[];
35
+ checks?: Record<string, CheckModel>;
35
36
  buckets?: BucketsModel;
36
37
  derived?: DerivedModel[];
37
38
  };
@@ -1,6 +1,7 @@
1
1
  import { promptFields } from "./ai-prompt.js";
2
2
  import { buildEventModels } from "./events/event-models.js";
3
3
  import { computedProblems } from "./computed/computed-problems.js";
4
+ import { checksProblems } from "./checks-problems.js";
4
5
  import { openExistingProblems } from "./open-existing-problems.js";
5
6
  import { snakeCase } from "./naming.js";
6
7
  import { derivedProblems } from "./derived/derived-problems.js";
@@ -95,6 +96,7 @@ const assembleModel = (state) => {
95
96
  ...state.parents && { parents: state.parents.map((parent) => ({ ...parent })) },
96
97
  ...state.links && { links: state.links },
97
98
  ...state.openExisting && { openExisting: [...state.openExisting] },
99
+ ...state.checks && { checks: Object.fromEntries(Object.entries(state.checks).map(([name, check]) => [name, { ...check }])) },
98
100
  ...state.buckets && { buckets: structuredClone(state.buckets) },
99
101
  ...state.derived && { derived: state.derived.map((value) => ({
100
102
  ...value,
@@ -253,6 +255,7 @@ const buildResourceModel = (state) => {
253
255
  ...linkProblems(model),
254
256
  ...aiProblems(model),
255
257
  ...openExistingProblems(model),
258
+ ...checksProblems(model),
256
259
  ...computedProblems(model),
257
260
  ...bucketsProblems(model),
258
261
  ...derivedProblems(model),
@@ -1,5 +1,5 @@
1
1
  import { DerivedTarget } from "./derived/derived-model.js";
2
- import { ParentAccess, PositionAfterModel, ResourceModel, SearchMatch } from "./model.js";
2
+ import { CheckModel, ParentAccess, PositionAfterModel, ResourceModel, SearchMatch } from "./model.js";
3
3
  import { FieldAccess } from "./access/types.js";
4
4
  import { FieldRefs, FieldsInput, Ref } from "./refs.js";
5
5
  import { BucketFields, BucketMeasuresInput, BucketsSpec } from "./buckets/buckets.js";
@@ -110,6 +110,20 @@ export declare class ResourceBuilder<F extends FieldsInput = {}, K = never, N ex
110
110
  * `r.phone.digitsEnd()` matches only the end of the field's digits, for phone numbers.
111
111
  */
112
112
  search(pick: (r: SearchRefs<F>) => SearchRef[]): ResourceBuilder<F, K, N>;
113
+ /**
114
+ * The database checks whose refusal the API names, by constraint name: a `CHECK` constraint, or a trigger's
115
+ * `raise exception ... using errcode = 'check_violation', constraint = '<name>'`. A write one refuses is a `400`
116
+ * `invalid-record` whose error has the name as its `code` and the label as its message, never the database's own text;
117
+ * the admin app shows the label, translated as `resources.<resource>.checks.<name>.label`, with `{field}` values from
118
+ * the record. A name is declared once across the app. See
119
+ * [Checks the database makes](docs/website/src/content/docs/reference/data-config.mdx#checks-the-database-makes).
120
+ *
121
+ * @example
122
+ * ```ts
123
+ * .checks({ tasks_parked_by_hand: { label: '{title} waits for a day, so it stays parked.' } })
124
+ * ```
125
+ */
126
+ checks(checks: Record<string, CheckModel>): ResourceBuilder<F, K, N>;
113
127
  /** The field holding the owning user's id, which `.own` capability scopes filter on. */
114
128
  owner(pick: (r: FieldRefs<F>) => Ref): ResourceBuilder<F, K, N>;
115
129
  /**
package/dist/resource.js CHANGED
@@ -113,6 +113,22 @@ var ResourceBuilder = class ResourceBuilder {
113
113
  searchMatch
114
114
  });
115
115
  }
116
+ /**
117
+ * The database checks whose refusal the API names, by constraint name: a `CHECK` constraint, or a trigger's
118
+ * `raise exception ... using errcode = 'check_violation', constraint = '<name>'`. A write one refuses is a `400`
119
+ * `invalid-record` whose error has the name as its `code` and the label as its message, never the database's own text;
120
+ * the admin app shows the label, translated as `resources.<resource>.checks.<name>.label`, with `{field}` values from
121
+ * the record. A name is declared once across the app. See
122
+ * [Checks the database makes](docs/website/src/content/docs/reference/data-config.mdx#checks-the-database-makes).
123
+ *
124
+ * @example
125
+ * ```ts
126
+ * .checks({ tasks_parked_by_hand: { label: '{title} waits for a day, so it stays parked.' } })
127
+ * ```
128
+ */
129
+ checks(checks) {
130
+ return this.next({ checks });
131
+ }
116
132
  /** The field holding the owning user's id, which `.own` capability scopes filter on. */
117
133
  owner(pick) {
118
134
  return this.next({ owner: pick(this.refs()).name });
@@ -1,4 +1,4 @@
1
- import { CardFavoriteModel, CardPhotosModel, ListDisplayModel, ResourceModel } from "./model.js";
1
+ import { CardFavoriteModel, CardPhotosModel, ListDisplayModel, ListDragModel, ResourceModel } from "./model.js";
2
2
  import { Ref } from "./refs.js";
3
3
  import { ListColumn } from "./view-columns.js";
4
4
  //#region src/view-displays.d.ts
@@ -138,10 +138,14 @@ export declare const displays: {
138
138
  props?: ViewProps<P>;
139
139
  }) => ListDisplayModel;
140
140
  };
141
- /** What makes a board unable to put the records in columns: a `by` field that is no filterable enum. */
141
+ /**
142
+ * What makes a board unable to put the records in columns, a `by` field that is no filterable enum, or unable to move
143
+ * its cards as the list's `drag.board` says: a `set` field it cannot write, or a column it names that `by` or `set` has
144
+ * no value for.
145
+ */
142
146
  export declare const boardErrors: (display: Extract<ListDisplayModel, {
143
147
  kind: "board";
144
- }>, model: ResourceModel) => string[];
148
+ }>, model: ResourceModel, drag?: ListDragModel["board"]) => string[];
145
149
  /** What makes a calendar or a timeline unable to place the records on days: a `start` that is no filterable date or timestamp, or an `end` that is no filterable field of its type. */
146
150
  export declare const datesErrors: (display: Extract<ListDisplayModel, {
147
151
  kind: "calendar" | "timeline";
@@ -165,12 +165,26 @@ const approximateErrors = (display) => {
165
165
  if (approximate !== void 0 && exact !== void 0) return ["name approximate or exact, not both"];
166
166
  return [...(radius !== void 0 || defaultRadius !== void 0 || area !== void 0) && approximate === void 0 && exact === void 0 ? ["an area around approximate positions needs the approximate or exact field"] : [], ...defaultRadius === void 0 || Number.isFinite(defaultRadius) && defaultRadius > 0 ? [] : [`defaultRadius ${defaultRadius} is not a number of metres above 0`]];
167
167
  };
168
- /** What makes a board unable to put the records in columns: a `by` field that is no filterable enum. */
169
- const boardErrors = (display, model) => {
168
+ /**
169
+ * What makes a board unable to put the records in columns, a `by` field that is no filterable enum, or unable to move
170
+ * its cards as the list's `drag.board` says: a `set` field it cannot write, or a column it names that `by` or `set` has
171
+ * no value for.
172
+ */
173
+ const boardErrors = (display, model, drag) => {
170
174
  const field = Object.hasOwn(model.fields, display.by) ? model.fields[display.by] : void 0;
171
175
  if (!field) return [];
172
176
  if (field.type !== "enum") return [`"${display.by}" on ${model.name} is ${field.type}, not an enum, whose values are the board's columns`];
173
- return field.filterable ? [] : [`"${display.by}" on ${model.name} is not filterable, and each column of the board filters by its value`];
177
+ if (!field.filterable) return [`"${display.by}" on ${model.name} is not filterable, and each column of the board filters by its value`];
178
+ return typeof drag === "object" ? boardDragErrors(display.by, field.enumValues ?? [], drag, model) : [];
179
+ };
180
+ const boardDragErrors = (by, values, { set = by, columns }, model) => {
181
+ const unknown = columns?.filter((value) => !values.includes(value)) ?? [];
182
+ if (unknown.length > 0) return unknown.map((value) => `drag.board takes cards in column "${value}", which is no value of "${by}"`);
183
+ const target = Object.hasOwn(model.fields, set) ? model.fields[set] : void 0;
184
+ if (!target) return [`drag.board sets "${set}", which ${model.name} does not have`];
185
+ if (target.readOnly) return [`drag.board sets "${set}", which is read-only`];
186
+ if (target.type !== "enum") return [];
187
+ return (columns ?? values).filter((value) => !target.enumValues?.includes(value)).map((value) => `drag.board sets "${set}" to "${value}", which is no value of "${set}"`);
174
188
  };
175
189
  /** What makes a calendar or a timeline unable to place the records on days: a `start` that is no filterable date or timestamp, or an `end` that is no filterable field of its type. */
176
190
  const datesErrors = (display, model) => {
package/dist/view.js CHANGED
@@ -386,7 +386,7 @@ var ViewBuilder = class ViewBuilder {
386
386
  if (display.kind === "cards" && display.image !== void 0 && resource.fields[display.image].type !== "file") throw new Error(`View "${this.state.resource}": display "${display.name}" shows "${display.image}" as its image, which is not a file field`);
387
387
  const flag = display.kind === "cards" ? display.flags?.find((name) => resource.fields[name].type !== "boolean") : void 0;
388
388
  if (flag !== void 0) throw new Error(`View "${this.state.resource}": display "${display.name}" shows "${flag}" as a flag, which is not a boolean field`);
389
- const board = display.kind === "board" ? boardErrors(display, resource) : [];
389
+ const board = display.kind === "board" ? boardErrors(display, resource, list?.drag?.board) : [];
390
390
  if (board.length > 0) throw new Error(`View "${this.state.resource}": display "${display.name}": ${board.join("; ")}`);
391
391
  const dates = display.kind === "calendar" || display.kind === "timeline" ? datesErrors(display, resource) : [];
392
392
  if (dates.length > 0) throw new Error(`View "${this.state.resource}": display "${display.name}": ${dates.join("; ")}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/schema",
3
- "version": "0.121.8",
3
+ "version": "0.121.10",
4
4
  "description": "Resource, field, view and access definitions for Protobase configs.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {