@protobase/schema 0.54.4 → 0.54.6
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/index.d.ts +2 -2
- package/dist/model.d.ts +15 -0
- package/dist/view.d.ts +7 -1
- package/dist/view.js +18 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Rollup, RollupCount, RollupFn, RollupSource, RollupValue } from "./computed/rollup.js";
|
|
2
2
|
import { FileOptions, FileProcessor, FileProcessorInput, ImageFormat, ImageVariant, ImageVariantOptions, imageFormats } from "./files/file-options.js";
|
|
3
|
-
import { ActionInputKind, ActionInputModel, ActionModel, ActionRun, AppAddress, BadgeShape, BottomBarItemModel, BottomBarModel, CalendarView, CardFavoriteModel, CardPhotosModel, ChartGranularity, ChartModel, ChartRange, CheckedFilter, CommentsSectionModel, CompareOp, CreateModel, 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, NowValue, OrderByItem, ParentAccess, ParentModel, PeriodChartModel, PositionAfterModel, RecordChartModel, RecordChartRange, RecordMode, RecordWhen, RelatedColumnModel, RelatedModel, RelatedPresentation, ResourceModel, SaveFeedback, SaveSearchModel, SearchMatch, SearchResultModel, SearchesOfModel, SectionModel, SectionPresentation, ShowWhen, SignInPromptModel, SignInViewModel, SortSpec, Span, StatusTone, TabItemModel, TabModel, TimelineView, UserMenuItemModel, UserMenuModel, ViewModel } from "./model.js";
|
|
3
|
+
import { ActionInputKind, ActionInputModel, ActionModel, ActionRun, AppAddress, BadgeShape, BottomBarItemModel, BottomBarModel, CalendarView, CardFavoriteModel, CardPhotosModel, ChartGranularity, ChartModel, ChartRange, CheckedFilter, CommentsSectionModel, CompareOp, CreateModel, 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, NowValue, OrderByItem, ParentAccess, ParentModel, PeriodChartModel, PositionAfterModel, RecordChartModel, RecordChartRange, RecordMode, RecordWhen, RelatedColumnModel, RelatedModel, RelatedPresentation, ResourceModel, SaveFeedback, SaveSearchModel, SearchMatch, SearchResultModel, SearchesOfModel, SectionModel, SectionPresentation, ShowWhen, SignInPromptModel, SignInViewModel, SortSpec, Span, StatusTone, TabItemModel, TabModel, TimelineView, TitleFromModel, UserMenuItemModel, UserMenuModel, ViewModel } from "./model.js";
|
|
4
4
|
import { AccessAction, AccessContext, AccessFn, AccessResult, AccessUser, FieldAccess, FieldRule } from "./access/types.js";
|
|
5
5
|
import { Encrypted, encrypted } from "./encrypted-value.js";
|
|
6
6
|
import { AnyField, Constraint, Field, FieldMeta, FieldTypeDef } from "./field.js";
|
|
@@ -47,4 +47,4 @@ import { AccessSource, ResolveOptions, ResolvedAccess, RowFilterOperation, acces
|
|
|
47
47
|
import { restrictModel } from "./access/restrict.js";
|
|
48
48
|
import "./access/index.js";
|
|
49
49
|
import { AssistantAction, AssistantActionRequest, AssistantCardPart, AssistantDiff, AssistantEvent, AssistantMessage, AssistantMessageRequest, AssistantPart, AssistantState, AssistantStep, AssistantStepState, AssistantTablePart, AssistantTextPart, AssistantTone, AssistantWidgetPart } from "./assistant/protocol.js";
|
|
50
|
-
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 BottomBarItemModel, type BottomBarModel, type BottomBarNames, type BottomBarSource, type CalendarView, type Capability, type CapabilityAction, type CapabilityLimit, type CapabilityScope, type CardFavoriteModel, type CardPhotosModel, type ChartGranularity, type ChartInput, type ChartModel, type ChartRange, type CheckResult, type CheckedFilter, type CommentsSectionModel, type CompareOp, type ComponentRef, type ComputedReveal, type ConnectAddress, type Constraint, type CreateModel, type CreatedOptions, type CustomSectionModel, type DatePreset, type DeletedOptions, 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 FileField, type FileFieldModel, 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 MapSectionModel, type MapView, type NamedListModel, type NavModel, type NavRecentModel, type NowValue, type OrderByCheck, type OrderByItem, type OrderByParse, type ParentAccess, type ParentModel, type PeriodChartInput, type PeriodChartModel, type PositionAfterModel, type RecordChartModel, type RecordChartRange, type RecordKey, type RecordMode, type RecordOf, type RecordWhen, type Ref, type Refs, type RelatedColumnModel, 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 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 TimelineView, type UndeletedOptions, type UpdatedOptions, type UserMenuItemModel, type UserMenuModel, type UserMenuSource, type Validator, type ViewBuilder, type ViewModel, type ViewProps, accessWarnings, addressWords, anonymousRole, appPath, argumentsSchema, bottomBar, bottomBarErrors, checkFilter, checkOrderBy, checkRecord, connectParams, connectPath, connectRoute, createWhere, defineRoles, encrypted, enumLabel, evaluateFilter, f, fieldRef, fieldsUsedBy, fitsKeyType, formPath, formRoute, imageFormats, isRecordCondition, keyTypes, layout as l, maxBottomBarItems, parseFilter, parseOrderBy, pickView, printFilter, printOrderBy, readAppPath, readConnectAddress, readFormAddress, readSignInAddress, resolveAccess, resource, restrictModel, rule, signInParams, signInPath, signInRoute, signInSteps, userMenu, view, where };
|
|
50
|
+
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 BottomBarItemModel, type BottomBarModel, type BottomBarNames, type BottomBarSource, type CalendarView, type Capability, type CapabilityAction, type CapabilityLimit, type CapabilityScope, type CardFavoriteModel, type CardPhotosModel, type ChartGranularity, type ChartInput, type ChartModel, type ChartRange, type CheckResult, type CheckedFilter, type CommentsSectionModel, type CompareOp, type ComponentRef, type ComputedReveal, type ConnectAddress, type Constraint, type CreateModel, type CreatedOptions, type CustomSectionModel, type DatePreset, type DeletedOptions, 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 FileField, type FileFieldModel, 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 MapSectionModel, type MapView, type NamedListModel, type NavModel, type NavRecentModel, type NowValue, type OrderByCheck, type OrderByItem, type OrderByParse, type ParentAccess, type ParentModel, type PeriodChartInput, type PeriodChartModel, type PositionAfterModel, type RecordChartModel, type RecordChartRange, type RecordKey, type RecordMode, type RecordOf, type RecordWhen, type Ref, type Refs, type RelatedColumnModel, 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 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 TimelineView, type TitleFromModel, type UndeletedOptions, type UpdatedOptions, type UserMenuItemModel, type UserMenuModel, type UserMenuSource, type Validator, type ViewBuilder, type ViewModel, type ViewProps, accessWarnings, addressWords, anonymousRole, appPath, argumentsSchema, bottomBar, bottomBarErrors, checkFilter, checkOrderBy, checkRecord, connectParams, connectPath, connectRoute, createWhere, defineRoles, encrypted, enumLabel, evaluateFilter, f, fieldRef, fieldsUsedBy, fitsKeyType, formPath, formRoute, imageFormats, isRecordCondition, keyTypes, layout as l, maxBottomBarItems, parseFilter, parseOrderBy, pickView, printFilter, printOrderBy, readAppPath, readConnectAddress, readFormAddress, readSignInAddress, resolveAccess, resource, restrictModel, rule, signInParams, signInPath, signInRoute, signInSteps, userMenu, view, where };
|
package/dist/model.d.ts
CHANGED
|
@@ -1220,6 +1220,19 @@ export type SearchResultModel = {
|
|
|
1220
1220
|
/** The field on the line under it. */
|
|
1221
1221
|
subtitle?: string;
|
|
1222
1222
|
};
|
|
1223
|
+
/**
|
|
1224
|
+
* A record's title derived in the browser, for the person reading it: the project UI's `titles[rule]` gets the record's
|
|
1225
|
+
* `fields` and the reader, such as the names of a conversation's other members. Presentation only: it is no field,
|
|
1226
|
+
* filter or sort key. `unreadable` marks one that reads a field the caller cannot read, which then titles by the key.
|
|
1227
|
+
*/
|
|
1228
|
+
export type TitleFromModel = {
|
|
1229
|
+
/** The name of the function under the project UI's `titles`. */
|
|
1230
|
+
rule: string;
|
|
1231
|
+
/** The fields the rule reads, which every request that titles a record asks for. */
|
|
1232
|
+
fields: string[];
|
|
1233
|
+
/** Set in `/meta` for a caller who cannot read one of the fields, which it then leaves out. */
|
|
1234
|
+
unreadable?: true;
|
|
1235
|
+
};
|
|
1223
1236
|
/**
|
|
1224
1237
|
* How the admin shows a resource: its names, list, filters, record page and actions, built by `view(...)` and sent to
|
|
1225
1238
|
* each user in `/meta` without what they cannot see. See [Views](website/src/content/docs/reference/ui-config.mdx).
|
|
@@ -1231,6 +1244,8 @@ export type ViewModel = {
|
|
|
1231
1244
|
roles?: string[];
|
|
1232
1245
|
/** Field used as the record's display title in breadcrumbs, relation links and search results. */
|
|
1233
1246
|
title?: string;
|
|
1247
|
+
/** A title the browser derives per reader in place of `title`, by a rule of the project's UI (see `TitleFromModel`). */
|
|
1248
|
+
titleFrom?: TitleFromModel;
|
|
1234
1249
|
/** A record in the global search: a title of one or more fields joined by spaces, over a subtitle field by default. */
|
|
1235
1250
|
searchResult?: SearchResultModel;
|
|
1236
1251
|
/** Where the resource sits in the sidebar. */
|
package/dist/view.d.ts
CHANGED
|
@@ -57,6 +57,12 @@ export declare class ViewBuilder<R extends {
|
|
|
57
57
|
forRoles(roles: string[]): ViewBuilder<R>;
|
|
58
58
|
/** The field shown as this record's title. Throws when the field does not exist. */
|
|
59
59
|
title(pick: (r: FieldRefs<FieldsOf<R>>) => Ref): ViewBuilder<R>;
|
|
60
|
+
/**
|
|
61
|
+
* A title derived per reader in the browser, in place of `title`: `rule` names a function of the project's UI
|
|
62
|
+
* `titles`, which gets the record with the `fields` picked and the signed-in reader, such as the names of the members
|
|
63
|
+
* other than the reader. The record's key shows while it returns nothing. Throws when a field does not exist.
|
|
64
|
+
*/
|
|
65
|
+
titleFrom(rule: string, pick: (r: FieldRefs<FieldsOf<R>>) => Ref[]): ViewBuilder<R>;
|
|
60
66
|
/**
|
|
61
67
|
* How a record shows in the global search: a bold `title` of one or more fields joined by spaces (default: `title`)
|
|
62
68
|
* and a `subtitle` field under it, replaced by the search field the text matched when that is neither.
|
|
@@ -205,7 +211,7 @@ export declare class ViewBuilder<R extends {
|
|
|
205
211
|
};
|
|
206
212
|
limit?: number;
|
|
207
213
|
}): ViewBuilder<R>;
|
|
208
|
-
/** With the resource's model, also verifies the title
|
|
214
|
+
/** With the resource's model, also verifies the title and `titleFrom`, search result and list display fields, related column names, a gallery's image, `listOf`, `searchesOf`, the sidebar's `recent` group and `tenant`, and the forms' fields. */
|
|
209
215
|
toModel(resource?: ResourceModel): ViewModel;
|
|
210
216
|
private refs;
|
|
211
217
|
private next;
|
package/dist/view.js
CHANGED
|
@@ -58,6 +58,20 @@ var ViewBuilder = class ViewBuilder {
|
|
|
58
58
|
return this.next({ title: pick(this.refs()).name });
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
|
+
* A title derived per reader in the browser, in place of `title`: `rule` names a function of the project's UI
|
|
62
|
+
* `titles`, which gets the record with the `fields` picked and the signed-in reader, such as the names of the members
|
|
63
|
+
* other than the reader. The record's key shows while it returns nothing. Throws when a field does not exist.
|
|
64
|
+
*/
|
|
65
|
+
titleFrom(rule, pick) {
|
|
66
|
+
const fields = pick(this.refs()).map((ref) => ref.name);
|
|
67
|
+
if (rule === "") throw new Error(`View "${this.state.resource}": titleFrom needs the name of a rule`);
|
|
68
|
+
if (fields.length === 0) throw new Error(`View "${this.state.resource}": titleFrom "${rule}" reads no fields`);
|
|
69
|
+
return this.next({ titleFrom: {
|
|
70
|
+
rule,
|
|
71
|
+
fields
|
|
72
|
+
} });
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
61
75
|
* How a record shows in the global search: a bold `title` of one or more fields joined by spaces (default: `title`)
|
|
62
76
|
* and a `subtitle` field under it, replaced by the search field the text matched when that is neither.
|
|
63
77
|
*/
|
|
@@ -287,10 +301,12 @@ var ViewBuilder = class ViewBuilder {
|
|
|
287
301
|
};
|
|
288
302
|
return this.next({ searchesOf: searches });
|
|
289
303
|
}
|
|
290
|
-
/** With the resource's model, also verifies the title
|
|
304
|
+
/** With the resource's model, also verifies the title and `titleFrom`, search result and list display fields, related column names, a gallery's image, `listOf`, `searchesOf`, the sidebar's `recent` group and `tenant`, and the forms' fields. */
|
|
291
305
|
toModel(resource) {
|
|
292
|
-
const { title, nav, searchResult, list, listOf } = this.state;
|
|
306
|
+
const { title, titleFrom, nav, searchResult, list, listOf } = this.state;
|
|
293
307
|
if (resource && title !== void 0 && !Object.hasOwn(resource.fields, title)) throw new Error(`View "${this.state.resource}": title field "${title}" does not exist on the resource`);
|
|
308
|
+
const unknownTitleField = resource ? titleFrom?.fields.find((name) => !Object.hasOwn(resource.fields, name)) : void 0;
|
|
309
|
+
if (unknownTitleField !== void 0) throw new Error(`View "${this.state.resource}": titleFrom field "${unknownTitleField}" does not exist on the resource`);
|
|
294
310
|
const missing = resource ? [...searchResult?.title ?? [], ...searchResult?.subtitle ? [searchResult.subtitle] : []].filter((name) => !Object.hasOwn(resource.fields, name)) : [];
|
|
295
311
|
if (missing.length > 0) throw new Error(`View "${this.state.resource}": search result field "${missing[0]}" does not exist on the resource`);
|
|
296
312
|
for (const display of resource ? list?.displays ?? [] : []) {
|