@protobase/schema 0.25.3 → 0.25.5

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 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, PeriodChartModel, RecordMode, RecordWhen, RelatedColumnModel, RelatedModel, 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, PeriodChartModel, PositionAfterModel, RecordMode, RecordWhen, RelatedColumnModel, RelatedModel, ResourceModel, SaveFeedback, SaveSearchModel, SearchMatch, SearchResultModel, SearchesOfModel, SectionModel, SectionPresentation, ShowWhen, SignInPromptModel, SignInViewModel, SortSpec, Span, StatusTone, TabItemModel, TabModel, TimelineView, UserMenuItemModel, UserMenuModel, ViewModel } from "./model.js";
4
4
  import { AccessAction, AccessContext, AccessFn, AccessResult, AccessUser, FieldAccess, FieldRule } from "./access/types.js";
5
5
  import { AnyField, Constraint, Field, FieldMeta, FieldTypeDef } from "./field.js";
6
6
  import { RelationField } from "./relation-field.js";
@@ -43,4 +43,4 @@ import { AccessSource, ResolveOptions, ResolvedAccess, RowFilterOperation, acces
43
43
  import { restrictModel } from "./access/restrict.js";
44
44
  import "./access/index.js";
45
45
  import { AssistantAction, AssistantActionRequest, AssistantCardPart, AssistantDiff, AssistantEvent, AssistantMessage, AssistantMessageRequest, AssistantPart, AssistantState, AssistantStep, AssistantStepState, AssistantTablePart, AssistantTextPart, AssistantTone, AssistantWidgetPart } from "./assistant/protocol.js";
46
- 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 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 Constraint, type CreateModel, type CreatedOptions, type CustomSectionModel, type DatePreset, type DeletedOptions, type DurationLiteral, type DurationUnit, type EvaluateOptions, type EventActor, type EventContext, type EventHelpers, type EventMatch, type EventModel, type EventOperation, type EventSpec, 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 PeriodChartInput, type PeriodChartModel, type RecordKey, type RecordMode, type RecordOf, type RecordWhen, type Ref, type Refs, type RelatedColumnModel, type RelatedModel, type RelationField, type ResolveOptions, type ResolvedAccess, type ResourceBuilder, type ResourceModel, 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 TimelineView, type UndeletedOptions, type UpdatedOptions, type UserMenuItemModel, type UserMenuModel, type UserMenuSource, type Validator, type ViewBuilder, type ViewModel, type ViewProps, accessWarnings, addressWords, anonymousRole, appPath, bottomBar, bottomBarErrors, checkFilter, checkOrderBy, checkRecord, createWhere, defineRoles, enumLabel, evaluateFilter, f, fieldRef, fieldsUsedBy, fitsKeyType, formPath, formRoute, imageFormats, isRecordCondition, keyTypes, layout as l, maxBottomBarItems, parseFilter, parseOrderBy, pickView, printFilter, printOrderBy, readAppPath, readFormAddress, readSignInAddress, resolveAccess, resource, restrictModel, rule, signInParams, signInPath, signInRoute, signInSteps, userMenu, view, where };
46
+ 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 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 Constraint, type CreateModel, type CreatedOptions, type CustomSectionModel, type DatePreset, type DeletedOptions, type DurationLiteral, type DurationUnit, type EvaluateOptions, type EventActor, type EventContext, type EventHelpers, type EventMatch, type EventModel, type EventOperation, type EventSpec, 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 PeriodChartInput, type PeriodChartModel, type PositionAfterModel, type RecordKey, type RecordMode, type RecordOf, type RecordWhen, type Ref, type Refs, type RelatedColumnModel, type RelatedModel, type RelationField, type ResolveOptions, type ResolvedAccess, type ResourceBuilder, type ResourceModel, 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 TimelineView, type UndeletedOptions, type UpdatedOptions, type UserMenuItemModel, type UserMenuModel, type UserMenuSource, type Validator, type ViewBuilder, type ViewModel, type ViewProps, accessWarnings, addressWords, anonymousRole, appPath, bottomBar, bottomBarErrors, checkFilter, checkOrderBy, checkRecord, createWhere, defineRoles, enumLabel, evaluateFilter, f, fieldRef, fieldsUsedBy, fitsKeyType, formPath, formRoute, imageFormats, isRecordCondition, keyTypes, layout as l, maxBottomBarItems, parseFilter, parseOrderBy, pickView, printFilter, printOrderBy, readAppPath, readFormAddress, readSignInAddress, resolveAccess, resource, restrictModel, rule, signInParams, signInPath, signInRoute, signInSteps, userMenu, view, where };
package/dist/model.d.ts CHANGED
@@ -117,6 +117,8 @@ export type ResourceModel = {
117
117
  field: string;
118
118
  /** The relation whose records each have an order of their own, as an invoice's items do; one order for all records when omitted. */
119
119
  within?: string;
120
+ /** The records each record ranks after while they are pending, such as the tasks it waits for (`.position(..., { after })`). */
121
+ after?: PositionAfterModel;
120
122
  };
121
123
  /** The events its changes raise (`.events()`), the catalogue subscriptions pick from. */
122
124
  events?: EventModel[];
@@ -561,6 +563,24 @@ export type SearchesOfModel = {
561
563
  /** How many records each search shows at most; default every one it finds, loaded as its row scrolls. */
562
564
  limit?: number;
563
565
  };
566
+ /**
567
+ * The records a record of a ranked resource may never rank above: the `key` values of the `resource` records whose
568
+ * `field` holds its key, such as the tasks a task depends on, as long as they match `while`. A `reorder` that would put
569
+ * a record at or above one of them, or one of them at or below it, is refused, and a ranked list or board drops it at
570
+ * the first place below that keeps the order.
571
+ */
572
+ export type PositionAfterModel = {
573
+ /** The join resource, such as `task_dependencies`. */
574
+ resource: string;
575
+ /** Its filterable relation that holds the dependent record's key. */
576
+ field: string;
577
+ /** Its filterable relation that holds the key of the record depended on. */
578
+ key: string;
579
+ /** An AIP-160 filter on the join records, such as `type = "blocked-by"`. */
580
+ filter?: string;
581
+ /** An AIP-160 filter on the records depended on, which they keep the order only while they match, such as `status != "done"`. */
582
+ while?: string;
583
+ };
564
584
  /** A view's list page (`.list(...)`). */
565
585
  export type ListModel = {
566
586
  /** The table's columns, in order. */
@@ -942,7 +962,7 @@ export type ActionModel = {
942
962
  /** The button's label. */
943
963
  label: string;
944
964
  /**
945
- * The button's icon: `bath`, `bed`, `bell`, `bookmark`, `calendar`, `door-open`, `external-link`, `file-text`, `heart`,
965
+ * The button's icon: `ban`, `bath`, `bed`, `bell`, `bookmark`, `calendar`, `door-open`, `external-link`, `file-text`, `heart`,
946
966
  * `house`, `key`, `land-plot`, `leaf`, `ruler`, `send`, `tag` or `wallet`; another name shows a lightning bolt.
947
967
  */
948
968
  icon?: string;
@@ -1,4 +1,4 @@
1
- import { SearchMatch } from "./model.js";
1
+ import { PositionAfterModel, SearchMatch } from "./model.js";
2
2
  import { FieldsInput } from "./refs.js";
3
3
  import { EventSpec } from "./events/event-helpers.js";
4
4
  //#region src/resource-model.d.ts
@@ -15,6 +15,7 @@ export type ResourceState = {
15
15
  position?: {
16
16
  field: string;
17
17
  within?: string;
18
+ after?: PositionAfterModel;
18
19
  };
19
20
  events?: EventSpec[];
20
21
  history?: boolean;
@@ -126,7 +126,8 @@ const positionProblems = (model) => {
126
126
  ...model.primaryKey.includes(name) ? [`position "${name}" is part of the key, which a move would change`] : [],
127
127
  ...within === name ? [`position "${name}" cannot be within itself`] : [],
128
128
  ...parent && parent.type !== "relation" ? [`position "${name}" is within "${within}", which is ${parent.type}, not a relation`] : [],
129
- ...parent && !parent.filterable ? [`position "${name}" is within "${within}", which is not filterable, and each parent's records are found by it`] : []
129
+ ...parent && !parent.filterable ? [`position "${name}" is within "${within}", which is not filterable, and each parent's records are found by it`] : [],
130
+ ...model.position.after && model.primaryKey.length !== 1 ? [`position "${name}" ranks after other records, which needs a key of one field`] : []
130
131
  ];
131
132
  };
132
133
  const aiProblems = (model) => Object.values(model.fields).filter((field) => field.ai).flatMap((field) => [
@@ -1,4 +1,4 @@
1
- import { ResourceModel, SearchMatch } from "./model.js";
1
+ import { PositionAfterModel, ResourceModel, SearchMatch } from "./model.js";
2
2
  import { FieldAccess } from "./access/types.js";
3
3
  import { FieldRefs, FieldsInput, Ref } from "./refs.js";
4
4
  import { EventHelpers, EventMatch, EventSpec } from "./events/event-helpers.js";
@@ -72,15 +72,19 @@ export declare class ResourceBuilder<F extends FieldsInput = {}, K = never> {
72
72
  * The integer field holding the records' order, 1 the first, which a list's **Reorder** button changes by dragging the
73
73
  * records; a move renumbers them 1, 2, 3, ... in one batch `reorder`. With `within`, a relation, each parent's records
74
74
  * have an order of their own, as an invoice's items do, sorted in the parent's related section. The field must be
75
- * sortable and `within` filterable. See [Reordering by hand](website/src/content/docs/reference/ui-config.mdx#reordering-by-hand).
75
+ * sortable and `within` filterable. With `after`, a record never ranks above the records it depends on through a join
76
+ * resource (see {@link PositionAfterModel}), which `reorder` checks. See
77
+ * [Reordering by hand](website/src/content/docs/reference/ui-config.mdx#reordering-by-hand).
76
78
  *
77
79
  * @example
78
80
  * ```ts
79
81
  * .position((r) => r.position, { within: (r) => r.invoice_id })
82
+ * .position((r) => r.position, { after: { resource: 'task_dependencies', field: 'task_id', key: 'depends_on_id', while: 'status != "done"' } })
80
83
  * ```
81
84
  */
82
85
  position(pick: (r: FieldRefs<F>) => Ref, o?: {
83
86
  within?: (r: FieldRefs<F>) => Ref;
87
+ after?: PositionAfterModel;
84
88
  }): ResourceBuilder<F, K>;
85
89
  /**
86
90
  * The events changes to its records raise, captured in the database for every write, from the API or elsewhere. See
package/dist/resource.js CHANGED
@@ -81,18 +81,22 @@ var ResourceBuilder = class ResourceBuilder {
81
81
  * The integer field holding the records' order, 1 the first, which a list's **Reorder** button changes by dragging the
82
82
  * records; a move renumbers them 1, 2, 3, ... in one batch `reorder`. With `within`, a relation, each parent's records
83
83
  * have an order of their own, as an invoice's items do, sorted in the parent's related section. The field must be
84
- * sortable and `within` filterable. See [Reordering by hand](website/src/content/docs/reference/ui-config.mdx#reordering-by-hand).
84
+ * sortable and `within` filterable. With `after`, a record never ranks above the records it depends on through a join
85
+ * resource (see {@link PositionAfterModel}), which `reorder` checks. See
86
+ * [Reordering by hand](website/src/content/docs/reference/ui-config.mdx#reordering-by-hand).
85
87
  *
86
88
  * @example
87
89
  * ```ts
88
90
  * .position((r) => r.position, { within: (r) => r.invoice_id })
91
+ * .position((r) => r.position, { after: { resource: 'task_dependencies', field: 'task_id', key: 'depends_on_id', while: 'status != "done"' } })
89
92
  * ```
90
93
  */
91
94
  position(pick, o = {}) {
92
95
  const within = o.within?.(this.refs()).name;
93
96
  return this.next({ position: {
94
97
  field: pick(this.refs()).name,
95
- ...within !== void 0 && { within }
98
+ ...within !== void 0 && { within },
99
+ ...o.after && { after: { ...o.after } }
96
100
  } });
97
101
  }
98
102
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/schema",
3
- "version": "0.25.3",
3
+ "version": "0.25.5",
4
4
  "description": "Resource, field, view and access definitions for Protobase configs.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {