@protobase/schema 0.11.1 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -2
- package/dist/model.d.ts +13 -2
- package/dist/view-displays.d.ts +6 -2
- package/dist/view-displays.js +5 -2
- package/dist/view-field.d.ts +7 -1
- package/dist/view-field.js +11 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActionModel, ActionRun, AppAddress, BottomBarItemModel, BottomBarModel, ChartGranularity, ChartModel, ChartRange, CheckedFilter, CompareOp, CustomSectionModel, DatePreset, DurationLiteral, DurationUnit, EventModel, EventOperation, FieldFormat, FieldModel, FieldPath, FieldType, FieldViewModel, FileFieldModel, FilterError, FilterErrorCode, FilterExpr, FilterLayout, FilterOf, FilterValue, FilterWidgetModel, JsonValue, KeyValue, LayoutItemModel, ListDisplayModel, ListModel, ListQuery, Literal, NavModel, NavRecentModel, NowValue, OrderByItem, RelatedModel, ResourceModel, SaveFeedback, SearchMatch, SearchResultModel, SortSpec, Span, StatusTone, UserMenuItemModel, UserMenuModel, ViewModel } from "./model.js";
|
|
1
|
+
import { ActionModel, ActionRun, AppAddress, BottomBarItemModel, BottomBarModel, ChartGranularity, ChartModel, ChartRange, CheckedFilter, CompareOp, CustomSectionModel, DatePreset, DurationLiteral, DurationUnit, EventModel, EventOperation, FieldFormat, FieldModel, FieldPath, FieldType, FieldViewModel, FieldWidgetModel, FileFieldModel, FilterError, FilterErrorCode, FilterExpr, FilterLayout, FilterOf, FilterValue, FilterWidgetModel, JsonValue, KeyValue, LayoutItemModel, ListDisplayModel, ListModel, ListQuery, Literal, NavModel, NavRecentModel, NowValue, OrderByItem, RelatedModel, ResourceModel, SaveFeedback, SearchMatch, SearchResultModel, SortSpec, Span, StatusTone, UserMenuItemModel, UserMenuModel, ViewModel } from "./model.js";
|
|
2
2
|
import { AccessAction, AccessContext, AccessFn, AccessResult, AccessUser, FieldAccess, FieldRule } from "./access/types.js";
|
|
3
3
|
import { FileProcessor, FileProcessorInput, checkedAccept, checkedProvider, parseSize } from "./files/file-options.js";
|
|
4
4
|
import { Field } from "./field.js";
|
|
@@ -42,4 +42,4 @@ import "./access/index.js";
|
|
|
42
42
|
import { AssistantAction, AssistantActionRequest, AssistantCardPart, AssistantDiff, AssistantEvent, AssistantMessage, AssistantMessageRequest, AssistantPart, AssistantState, AssistantStep, AssistantStepState, AssistantTablePart, AssistantTextPart, AssistantTone, AssistantWidgetPart } from "./assistant/protocol.js";
|
|
43
43
|
import { applyAssistantEvent, emptyAssistantState } from "./assistant/apply-event.js";
|
|
44
44
|
import { readEventStream } from "./assistant/event-stream.js";
|
|
45
|
-
export { type AccessAction, type AccessContext, type AccessFn, type AccessResult, type AccessSource, type AccessUser, type ActionModel, type ActionRun, type AddressCheck, type AppAddress, 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 BottomBarItemModel, type BottomBarModel, type BottomBarNames, type BottomBarSource, type Capability, type CapabilityAction, type CapabilityScope, type ChartGranularity, type ChartModel, type ChartRange, type CheckResult, type CheckedFilter, type CompareOp, type ComponentRef, type CustomSectionModel, type DatePreset, type DurationLiteral, type DurationUnit, type EvaluateOptions, type EventActor, type EventContext, type EventHelpers, type EventMatch, type EventModel, type EventOperation, type EventSpec, type Field, type FieldAccess, type FieldFormat, type FieldModel, type FieldPath, type FieldRefValue, type FieldRule, type FieldType, type FieldViewModel, type FileField, type FileFieldModel, type FileProcessor, type FileProcessorInput, type FilterError, type FilterErrorCode, type FilterExpr, type FilterLayout, type FilterLimits, type FilterOf, type FilterParse, type FilterValue, type FilterWidgetModel, type InferRecord, type JsonValue, type KeyType, type KeyValue, type LayoutItemModel, type ListDisplayModel, type ListModel, type ListQuery, type Literal, type NavModel, type NavRecentModel, type NowValue, type OrderByCheck, type OrderByItem, type OrderByParse, type PluginHost, type PluginRequirement, type PropShapes, type RecordKey, type RefShape, type RelatedModel, type ResolveOptions, type ResolvedAccess, type ResourceModel, type Roles, type RolesOptions, type RowFilterOperation, type Rule, type SaveFeedback, type SearchMatch, type SearchResultModel, type SearchTerm, type SortSpec, type Span, type StatusTone, type UserMenuItemModel, type UserMenuModel, type UserMenuSource, type ViewModel, type ViewProps, accessWarnings, addressErrors, addressPlaceholders, addressWords, appHrefError, appPath, applyAssistantEvent, bottomBar, bottomBarErrors, bottomBarFor, checkEventFilter, checkFilter, checkOrderBy, checkRecord, checkedAccept, checkedProvider, createWhere, decodeKey, defaultRecentLimit, defineRoles, displayFields, emptyAssistantState, encodeKey, enumLabel, evaluateFilter, f, fieldRef, fieldRefsIn, fieldsUsedBy, fillAddress, hrefPlaceholders, inRange, isFieldRef, keyTypes, layout as l, leavesApp, markFieldRefs, matchedSearchField, matchesSearch, maxBottomBarItems, navRecentErrors, parseFilter, parseOrderBy, parseSize, pickView, pluginProblem, printFilter, printOrderBy, pruneByShape, readAppPath, readEventStream, resolveAccess, resource, restrictModel, rule, searchTerms, shapes, statusTones, tableDisplay, termMatches, unmarkFieldRefs, userMenu, view, webhookResources, where };
|
|
45
|
+
export { type AccessAction, type AccessContext, type AccessFn, type AccessResult, type AccessSource, type AccessUser, type ActionModel, type ActionRun, type AddressCheck, type AppAddress, 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 BottomBarItemModel, type BottomBarModel, type BottomBarNames, type BottomBarSource, type Capability, type CapabilityAction, type CapabilityScope, type ChartGranularity, type ChartModel, type ChartRange, type CheckResult, type CheckedFilter, type CompareOp, type ComponentRef, type CustomSectionModel, type DatePreset, type DurationLiteral, type DurationUnit, type EvaluateOptions, type EventActor, type EventContext, type EventHelpers, type EventMatch, type EventModel, type EventOperation, type EventSpec, type Field, type FieldAccess, type FieldFormat, type FieldModel, type FieldPath, type FieldRefValue, type FieldRule, type FieldType, type FieldViewModel, type FieldWidgetModel, type FileField, type FileFieldModel, type FileProcessor, type FileProcessorInput, type FilterError, type FilterErrorCode, type FilterExpr, type FilterLayout, type FilterLimits, type FilterOf, type FilterParse, type FilterValue, type FilterWidgetModel, type InferRecord, type JsonValue, type KeyType, type KeyValue, type LayoutItemModel, type ListDisplayModel, type ListModel, type ListQuery, type Literal, type NavModel, type NavRecentModel, type NowValue, type OrderByCheck, type OrderByItem, type OrderByParse, type PluginHost, type PluginRequirement, type PropShapes, type RecordKey, type RefShape, type RelatedModel, type ResolveOptions, type ResolvedAccess, type ResourceModel, type Roles, type RolesOptions, type RowFilterOperation, type Rule, type SaveFeedback, type SearchMatch, type SearchResultModel, type SearchTerm, type SortSpec, type Span, type StatusTone, type UserMenuItemModel, type UserMenuModel, type UserMenuSource, type ViewModel, type ViewProps, accessWarnings, addressErrors, addressPlaceholders, addressWords, appHrefError, appPath, applyAssistantEvent, bottomBar, bottomBarErrors, bottomBarFor, checkEventFilter, checkFilter, checkOrderBy, checkRecord, checkedAccept, checkedProvider, createWhere, decodeKey, defaultRecentLimit, defineRoles, displayFields, emptyAssistantState, encodeKey, enumLabel, evaluateFilter, f, fieldRef, fieldRefsIn, fieldsUsedBy, fillAddress, hrefPlaceholders, inRange, isFieldRef, keyTypes, layout as l, leavesApp, markFieldRefs, matchedSearchField, matchesSearch, maxBottomBarItems, navRecentErrors, parseFilter, parseOrderBy, parseSize, pickView, pluginProblem, printFilter, printOrderBy, pruneByShape, readAppPath, readEventStream, resolveAccess, resource, restrictModel, rule, searchTerms, shapes, statusTones, tableDisplay, termMatches, unmarkFieldRefs, userMenu, view, webhookResources, where };
|
package/dist/model.d.ts
CHANGED
|
@@ -116,10 +116,20 @@ export type FieldViewModel = {
|
|
|
116
116
|
decimals?: number;
|
|
117
117
|
/** What an enum value reads as wherever it is shown; a value without one reads as itself in words (`enumLabel`). */
|
|
118
118
|
valueLabels?: Record<string, string>;
|
|
119
|
+
/**
|
|
120
|
+
* The field type a plugin registers (`definePlugin({ fields })`) that shows and edits this field, with its props;
|
|
121
|
+
* without that plugin, or for a storage type it does not show, the field shows as it would without it.
|
|
122
|
+
*/
|
|
123
|
+
widget?: FieldWidgetModel;
|
|
124
|
+
};
|
|
125
|
+
/** A field type by the name a plugin registers it under, and the plain data it is given. */
|
|
126
|
+
export type FieldWidgetModel = {
|
|
127
|
+
name: string;
|
|
128
|
+
props?: Record<string, JsonValue>;
|
|
119
129
|
};
|
|
120
130
|
/**
|
|
121
|
-
* A way to show a list besides its table: a card per record, or a
|
|
122
|
-
* list page loads. `name` is what the address names (`?display=cards`); `label` and `icon` are its switch's.
|
|
131
|
+
* A way to show a list besides its table: a card per record, its content the built-in one or a component's (`card`),
|
|
132
|
+
* or a project component (`custom`) drawing the rows the list page loads. `name` is what the address names (`?display=cards`); `label` and `icon` are its switch's.
|
|
123
133
|
*/
|
|
124
134
|
export type ListDisplayModel = {
|
|
125
135
|
kind: 'cards';
|
|
@@ -130,6 +140,7 @@ export type ListDisplayModel = {
|
|
|
130
140
|
subtitle?: string;
|
|
131
141
|
badge?: string;
|
|
132
142
|
meta?: string[];
|
|
143
|
+
card?: string;
|
|
133
144
|
} | {
|
|
134
145
|
kind: 'custom';
|
|
135
146
|
name: string;
|
package/dist/view-displays.d.ts
CHANGED
|
@@ -18,14 +18,18 @@ export declare const tableDisplay = "table";
|
|
|
18
18
|
export declare const displays: {
|
|
19
19
|
/**
|
|
20
20
|
* A card per record: `title` (default: the view's title) over `subtitle`, `badge` drawn as a badge with its value
|
|
21
|
-
* labels, and a few small `meta` fields such as dates.
|
|
21
|
+
* labels, and a few small `meta` fields such as dates. With `card`, a component of the project or a plugin draws each
|
|
22
|
+
* card's content instead, from the row of those fields (`{ row }`); without it, or when it throws, the card is the
|
|
23
|
+
* built-in one. Named `cards` unless `name` says otherwise.
|
|
22
24
|
*/
|
|
23
25
|
cards: (fields: {
|
|
24
26
|
title?: Ref;
|
|
25
27
|
subtitle?: Ref;
|
|
26
28
|
badge?: Ref;
|
|
27
29
|
meta?: Ref[];
|
|
28
|
-
}, o?: Naming
|
|
30
|
+
}, o?: Naming & {
|
|
31
|
+
card?: ComponentRef<never>;
|
|
32
|
+
}) => ListDisplayModel;
|
|
29
33
|
/**
|
|
30
34
|
* The list drawn by a component of the project, registered in `protobase.ui.tsx` under its name. It gets `props` and
|
|
31
35
|
* reads the rows with `useListDisplay()`; `fields` are the fields it shows, fetched with relation names.
|
package/dist/view-displays.js
CHANGED
|
@@ -14,7 +14,9 @@ const customComponent = (component, where) => {
|
|
|
14
14
|
const displays = {
|
|
15
15
|
/**
|
|
16
16
|
* A card per record: `title` (default: the view's title) over `subtitle`, `badge` drawn as a badge with its value
|
|
17
|
-
* labels, and a few small `meta` fields such as dates.
|
|
17
|
+
* labels, and a few small `meta` fields such as dates. With `card`, a component of the project or a plugin draws each
|
|
18
|
+
* card's content instead, from the row of those fields (`{ row }`); without it, or when it throws, the card is the
|
|
19
|
+
* built-in one. Named `cards` unless `name` says otherwise.
|
|
18
20
|
*/
|
|
19
21
|
cards: (fields, o = {}) => ({
|
|
20
22
|
kind: "cards",
|
|
@@ -23,7 +25,8 @@ const displays = {
|
|
|
23
25
|
...fields.title && { title: fields.title.name },
|
|
24
26
|
...fields.subtitle && { subtitle: fields.subtitle.name },
|
|
25
27
|
...fields.badge && { badge: fields.badge.name },
|
|
26
|
-
...fields.meta && { meta: fields.meta.map((ref) => ref.name) }
|
|
28
|
+
...fields.meta && { meta: fields.meta.map((ref) => ref.name) },
|
|
29
|
+
...o.card && { card: customComponent(o.card, "d.cards card") }
|
|
27
30
|
}),
|
|
28
31
|
/**
|
|
29
32
|
* The list drawn by a component of the project, registered in `protobase.ui.tsx` under its name. It gets `props` and
|
package/dist/view-field.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldFormat, FieldViewModel } from "./model.js";
|
|
1
|
+
import { FieldFormat, FieldViewModel, JsonValue } from "./model.js";
|
|
2
2
|
//#region src/view-field.d.ts
|
|
3
3
|
export declare class FieldView<N extends string = string, V = unknown> {
|
|
4
4
|
readonly name: N;
|
|
@@ -11,6 +11,12 @@ export declare class FieldView<N extends string = string, V = unknown> {
|
|
|
11
11
|
decimals(decimals: number): FieldView<N, V>;
|
|
12
12
|
/** Labels for an enum's values, such as `{ co_signer: 'Co-signer' }`; values left out read as themselves in words. */
|
|
13
13
|
valueLabels(labels: { readonly [P in Extract<V, string>]?: string; }): FieldView<N, V>;
|
|
14
|
+
/**
|
|
15
|
+
* Shows and edits the field with the field type a plugin registers under `name` (`definePlugin({ fields })`), given
|
|
16
|
+
* `props`, such as `r.score.widget('rating', { max: 5 })`. Without that plugin, or when the field type does not show
|
|
17
|
+
* this field's storage type, the field shows as it would without it.
|
|
18
|
+
*/
|
|
19
|
+
widget(name: string, props?: Record<string, JsonValue>): FieldView<N, V>;
|
|
14
20
|
private with;
|
|
15
21
|
}
|
|
16
22
|
//#endregion
|
package/dist/view-field.js
CHANGED
|
@@ -28,6 +28,17 @@ var FieldView = class FieldView {
|
|
|
28
28
|
...labels
|
|
29
29
|
} });
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Shows and edits the field with the field type a plugin registers under `name` (`definePlugin({ fields })`), given
|
|
33
|
+
* `props`, such as `r.score.widget('rating', { max: 5 })`. Without that plugin, or when the field type does not show
|
|
34
|
+
* this field's storage type, the field shows as it would without it.
|
|
35
|
+
*/
|
|
36
|
+
widget(name, props) {
|
|
37
|
+
return this.with({ widget: {
|
|
38
|
+
name,
|
|
39
|
+
...props && { props }
|
|
40
|
+
} });
|
|
41
|
+
}
|
|
31
42
|
with(patch) {
|
|
32
43
|
return new FieldView(this.name, {
|
|
33
44
|
...this.props,
|