@protobase/schema 0.121.9 → 0.121.11
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/checks-problems.js +18 -0
- package/dist/index.d.ts +2 -2
- package/dist/model.d.ts +52 -4
- package/dist/resource-model.d.ts +2 -1
- package/dist/resource-model.js +3 -0
- package/dist/resource.d.ts +15 -1
- package/dist/resource.js +16 -0
- package/dist/view-displays.d.ts +7 -3
- package/dist/view-displays.js +17 -3
- package/dist/view.js +1 -1
- package/package.json +1 -1
|
@@ -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 };
|
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;
|
|
739
|
-
* in
|
|
740
|
-
*
|
|
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. */
|
package/dist/resource-model.d.ts
CHANGED
|
@@ -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
|
};
|
package/dist/resource-model.js
CHANGED
|
@@ -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),
|
package/dist/resource.d.ts
CHANGED
|
@@ -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 });
|
package/dist/view-displays.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
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";
|
package/dist/view-displays.js
CHANGED
|
@@ -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
|
-
/**
|
|
169
|
-
|
|
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
|
-
|
|
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("; ")}`);
|