viewkitjs 0.28.0 → 0.30.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/CHANGELOG.md +218 -0
- package/MIGRATION.md +181 -11
- package/fields/dist/derived.d.ts +2 -1
- package/fields/dist/derived.js +9 -3
- package/fields/dist/entities.js +41 -3
- package/fields/dist/index.d.ts +1 -1
- package/fields/dist/index.js +1 -1
- package/fields/dist/messages.d.ts +8 -2
- package/fields/dist/messages.js +3 -0
- package/fields/dist/range.d.ts +6 -0
- package/fields/dist/range.js +8 -0
- package/fields/dist/registry.js +11 -1
- package/fields/dist/spec-changes.js +1 -0
- package/fields/dist/types.d.ts +23 -1
- package/fields/docs/guides/derived-fields.md +7 -5
- package/fields/docs/guides/field-types.md +2 -2
- package/fields/docs/guides/the-index.md +1 -1
- package/fields/docs/reference/fields.md +3 -1
- package/fields/docs/reference/types.md +3 -1
- package/fields/skills/viewkit/SKILL.md +1 -1
- package/package.json +2 -1
- package/postgres/dist/definitions/build.js +29 -5
- package/postgres/dist/definitions/label.d.ts +7 -0
- package/postgres/dist/definitions/label.js +9 -1
- package/postgres/dist/definitions/lookup.js +6 -2
- package/postgres/dist/definitions/place.d.ts +6 -3
- package/postgres/dist/definitions/rollup.js +5 -1
- package/postgres/dist/definitions/storage.d.ts +15 -0
- package/postgres/dist/definitions/storage.js +52 -1
- package/postgres/dist/definitions/stored.js +21 -0
- package/postgres/dist/phone.d.ts +13 -1
- package/postgres/dist/phone.js +23 -3
- package/postgres/dist/search-indexes.d.ts +6 -1
- package/postgres/dist/search-indexes.js +71 -25
- package/postgres/dist/search.js +3 -3
- package/postgres/docs/guides/definitions.md +22 -5
- package/postgres/docs/guides/field-map.md +5 -4
- package/postgres/docs/reference/definitions.md +3 -3
- package/postgres/docs/reference/postgres.md +1 -1
- package/views/dist/cells/cell-format.d.ts +2 -2
- package/views/dist/cells/cell-format.js +2 -2
- package/views/dist/cells/cell-values.js +9 -12
- package/views/dist/contract.d.ts +161 -18
- package/views/dist/contract.js +170 -28
- package/views/dist/controls/bulk-bar/bulk-bar-of.d.ts +66 -0
- package/views/dist/controls/bulk-bar/bulk-bar-of.js +22 -0
- package/views/dist/controls/bulk-bar/bulk-bar.d.ts +40 -0
- package/views/dist/controls/bulk-bar/bulk-bar.js +278 -0
- package/views/dist/controls/bulk-bar/looks.d.ts +10 -0
- package/views/dist/controls/bulk-bar/looks.js +14 -0
- package/views/dist/controls/bulk-bar/map-selection-bar.d.ts +19 -0
- package/views/dist/controls/bulk-bar/map-selection-bar.js +57 -0
- package/views/dist/controls/bulk-bar/tokens.d.ts +136 -0
- package/views/dist/controls/bulk-bar/tokens.js +36 -0
- package/views/dist/controls/bulk-bar/words.d.ts +50 -0
- package/views/dist/controls/bulk-bar/words.js +19 -0
- package/views/dist/controls/bulk-bar.css +96 -0
- package/views/dist/controls/button/button.js +3 -1
- package/views/dist/controls/button.css +5 -4
- package/views/dist/controls/checkbox/checkbox.js +3 -1
- package/views/dist/controls/checkbox.css +1 -1
- package/views/dist/controls/choice/tokens.d.ts +79 -0
- package/views/dist/controls/choice/tokens.js +22 -0
- package/views/dist/controls/choice.css +31 -0
- package/views/dist/controls/compound-editor/looks.js +1 -1
- package/views/dist/controls/controls.d.ts +8 -0
- package/views/dist/controls/controls.js +8 -0
- package/views/dist/controls/customize/customize.d.ts +176 -0
- package/views/dist/controls/customize/customize.js +348 -0
- package/views/dist/controls/customize/glide.d.ts +10 -0
- package/views/dist/controls/customize/glide.js +55 -0
- package/views/dist/controls/customize/looks.d.ts +13 -0
- package/views/dist/controls/customize/looks.js +11 -0
- package/views/dist/controls/customize/map-customize-body.d.ts +15 -0
- package/views/dist/controls/customize/map-customize-body.js +195 -0
- package/views/dist/controls/customize/map-ranges.d.ts +23 -0
- package/views/dist/controls/customize/map-ranges.js +41 -0
- package/views/dist/controls/customize/rules.d.ts +39 -0
- package/views/dist/controls/customize/rules.js +21 -0
- package/views/dist/controls/customize/tokens.d.ts +40 -0
- package/views/dist/controls/customize/tokens.js +12 -0
- package/views/dist/controls/customize/words.d.ts +65 -0
- package/views/dist/controls/customize/words.js +42 -0
- package/views/dist/controls/customize.css +57 -0
- package/views/dist/controls/date-editor/looks.js +1 -1
- package/views/dist/controls/filter-editor/block.d.ts +31 -0
- package/views/dist/controls/filter-editor/block.js +27 -0
- package/views/dist/controls/filter-editor/filter-editor.d.ts +4 -0
- package/views/dist/controls/filter-editor/filter-editor.js +86 -43
- package/views/dist/controls/filter-editor/how.d.ts +1 -1
- package/views/dist/controls/filter-editor/how.js +1 -0
- package/views/dist/controls/filter-editor/map-filter-body.d.ts +16 -1
- package/views/dist/controls/filter-editor/map-filter-body.js +39 -13
- package/views/dist/controls/filter-editor/map-rules.d.ts +27 -11
- package/views/dist/controls/filter-editor/map-rules.js +73 -42
- package/views/dist/controls/filter-editor/rules.d.ts +42 -5
- package/views/dist/controls/filter-editor/rules.js +55 -2
- package/views/dist/controls/filter-editor/words.d.ts +15 -0
- package/views/dist/controls/filter-editor/words.js +6 -0
- package/views/dist/controls/filter-editor.css +18 -0
- package/views/dist/controls/index.d.ts +33 -9
- package/views/dist/controls/index.js +32 -9
- package/views/dist/controls/inline-input/looks.js +1 -1
- package/views/dist/controls/input/input.js +10 -4
- package/views/dist/controls/internal/phone.d.ts +5 -4
- package/views/dist/controls/internal/phone.js +7 -7
- package/views/dist/controls/internal/scroll.js +5 -1
- package/views/dist/controls/internal/typed-run.d.ts +2 -0
- package/views/dist/controls/internal/typed-run.js +5 -0
- package/views/dist/controls/menu/map-menu.js +2 -2
- package/views/dist/controls/menu-list/menu-list.d.ts +16 -1
- package/views/dist/controls/menu-list/menu-list.js +26 -8
- package/views/dist/controls/menu-list.css +8 -0
- package/views/dist/controls/number-editor/looks.js +1 -1
- package/views/dist/controls/option/option.js +3 -1
- package/views/dist/controls/option.css +1 -1
- package/views/dist/controls/pane/pane.d.ts +4 -0
- package/views/dist/controls/pane/pane.js +2 -1
- package/views/dist/controls/picker/looks.js +1 -1
- package/views/dist/controls/picker/map-picker.d.ts +6 -2
- package/views/dist/controls/picker/map-picker.js +4 -2
- package/views/dist/controls/picker/picker.d.ts +7 -0
- package/views/dist/controls/picker/picker.js +57 -8
- package/views/dist/controls/popover/map-popover.d.ts +1 -1
- package/views/dist/controls/popover/map-popover.js +2 -2
- package/views/dist/controls/popover/popover.js +2 -1
- package/views/dist/controls/popover.css +3 -0
- package/views/dist/controls/ports-host/map-ports-host.d.ts +7 -0
- package/views/dist/controls/ports-host/map-ports-host.js +43 -0
- package/views/dist/controls/press/tokens.d.ts +8 -0
- package/views/dist/controls/press/tokens.js +4 -0
- package/views/dist/controls/press.css +44 -0
- package/views/dist/controls/quick-filters/looks.d.ts +11 -0
- package/views/dist/controls/quick-filters/looks.js +9 -0
- package/views/dist/controls/quick-filters/map-quick-filters-body.d.ts +31 -0
- package/views/dist/controls/quick-filters/map-quick-filters-body.js +59 -0
- package/views/dist/controls/quick-filters/quick-filters.d.ts +37 -0
- package/views/dist/controls/quick-filters/quick-filters.js +89 -0
- package/views/dist/controls/quick-filters/reminder.d.ts +18 -0
- package/views/dist/controls/quick-filters/reminder.js +41 -0
- package/views/dist/controls/quick-filters/rules.d.ts +89 -0
- package/views/dist/controls/quick-filters/rules.js +52 -0
- package/views/dist/controls/quick-filters/tokens.d.ts +112 -0
- package/views/dist/controls/quick-filters/tokens.js +30 -0
- package/views/dist/controls/quick-filters/words.d.ts +25 -0
- package/views/dist/controls/quick-filters/words.js +13 -0
- package/views/dist/controls/quick-filters.css +118 -0
- package/views/dist/controls/sheet/bottom-sheet.d.ts +9 -4
- package/views/dist/controls/sheet/bottom-sheet.js +4 -4
- package/views/dist/controls/sheet/map-sheet.d.ts +4 -1
- package/views/dist/controls/sheet/map-sheet.js +19 -6
- package/views/dist/controls/sheet/sheet-parts.d.ts +10 -0
- package/views/dist/controls/sheet/sheet-parts.js +2 -0
- package/views/dist/controls/switch-row/switch-row.d.ts +15 -0
- package/views/dist/controls/switch-row/switch-row.js +9 -0
- package/views/dist/controls/switch-row/tokens.d.ts +51 -0
- package/views/dist/controls/switch-row/tokens.js +15 -0
- package/views/dist/controls/switch-row.css +39 -0
- package/views/dist/controls/switch.css +1 -1
- package/views/dist/controls/tag/tag.js +3 -1
- package/views/dist/controls/tag-field/tag-field.d.ts +20 -0
- package/views/dist/controls/tag-field/tag-field.js +19 -0
- package/views/dist/controls/tag-field/tokens.d.ts +7 -0
- package/views/dist/controls/tag-field/tokens.js +4 -0
- package/views/dist/controls/tag-field.css +13 -0
- package/views/dist/controls/text-editor/looks.js +1 -1
- package/views/dist/controls/text-editor/map-text-body.d.ts +1 -1
- package/views/dist/controls/text-editor/map-text-body.js +2 -2
- package/views/dist/controls/text-editor/text-editor.d.ts +3 -0
- package/views/dist/controls/text-editor/text-editor.js +17 -7
- package/views/dist/controls/text-editor.css +11 -0
- package/views/dist/controls/toast/toast.d.ts +5 -1
- package/views/dist/controls/toast/toast.js +5 -3
- package/views/dist/controls/tokens.js +18 -0
- package/views/dist/controls/toolbar/keys.d.ts +3 -0
- package/views/dist/controls/toolbar/keys.js +11 -0
- package/views/dist/controls/toolbar/looks.d.ts +10 -0
- package/views/dist/controls/toolbar/looks.js +40 -0
- package/views/dist/controls/toolbar/tokens.d.ts +28 -0
- package/views/dist/controls/toolbar/tokens.js +9 -0
- package/views/dist/controls/toolbar/toolbar.d.ts +111 -0
- package/views/dist/controls/toolbar/toolbar.js +370 -0
- package/views/dist/controls/toolbar/words.d.ts +28 -0
- package/views/dist/controls/toolbar/words.js +17 -0
- package/views/dist/controls/toolbar-button/looks.d.ts +4 -0
- package/views/dist/controls/toolbar-button/looks.js +21 -0
- package/views/dist/controls/toolbar-button/tokens.d.ts +103 -0
- package/views/dist/controls/toolbar-button/tokens.js +28 -0
- package/views/dist/controls/toolbar-button/toolbar-button.d.ts +66 -0
- package/views/dist/controls/toolbar-button/toolbar-button.js +51 -0
- package/views/dist/controls/toolbar-button.css +75 -0
- package/views/dist/controls/toolbar.css +65 -0
- package/views/dist/controls/tooltip/map-tooltip.d.ts +1 -1
- package/views/dist/controls/tooltip/map-tooltip.js +2 -2
- package/views/dist/controls/tooltip/tooltip.d.ts +3 -1
- package/views/dist/controls/tooltip/tooltip.js +2 -2
- package/views/dist/controls/values-editor/looks.js +1 -1
- package/views/dist/controls/values-editor/values.js +6 -2
- package/views/dist/controls/views-list/map-views-list-body.d.ts +4 -1
- package/views/dist/controls/views-list/map-views-list-body.js +128 -4
- package/views/dist/controls/views-list/rules.d.ts +26 -0
- package/views/dist/controls/views-list/rules.js +63 -0
- package/views/dist/controls/views-list/view-menu.d.ts +84 -0
- package/views/dist/controls/views-list/view-menu.js +201 -0
- package/views/dist/controls/views-list/views-list.d.ts +8 -1
- package/views/dist/controls/views-list/views-list.js +18 -3
- package/views/dist/controls/views-list/words.d.ts +54 -0
- package/views/dist/controls/views-list/words.js +10 -1
- package/views/dist/controls/views-list.css +5 -1
- package/views/dist/display/date.js +3 -3
- package/views/dist/display/format.d.ts +6 -0
- package/views/dist/display/format.js +3 -0
- package/views/dist/display/index.d.ts +1 -1
- package/views/dist/display/index.js +1 -1
- package/views/dist/display/options.d.ts +1 -1
- package/views/dist/display/range.d.ts +2 -1
- package/views/dist/display/range.js +4 -1
- package/views/dist/display/rich-text.js +0 -1
- package/views/dist/editors/ChipsEditor.d.ts +4 -5
- package/views/dist/editors/ChipsEditor.js +12 -78
- package/views/dist/editors/DateEditor.d.ts +12 -16
- package/views/dist/editors/DateEditor.js +40 -191
- package/views/dist/editors/EditorPanel.d.ts +2 -6
- package/views/dist/editors/EditorPanel.js +2 -2
- package/views/dist/editors/LocationEditor.d.ts +11 -19
- package/views/dist/editors/LocationEditor.js +19 -211
- package/views/dist/editors/NameEditor.d.ts +8 -16
- package/views/dist/editors/NameEditor.js +11 -100
- package/views/dist/editors/NumberEditor.d.ts +14 -21
- package/views/dist/editors/NumberEditor.js +22 -49
- package/views/dist/editors/RangeEditor.d.ts +9 -33
- package/views/dist/editors/RangeEditor.js +12 -97
- package/views/dist/editors/RelationEditor.d.ts +6 -9
- package/views/dist/editors/RelationEditor.js +11 -30
- package/views/dist/editors/RelationSetEditor.d.ts +13 -24
- package/views/dist/editors/RelationSetEditor.js +33 -101
- package/views/dist/editors/SelectEditor.d.ts +15 -17
- package/views/dist/editors/SelectEditor.js +15 -94
- package/views/dist/editors/TextEditor.d.ts +23 -26
- package/views/dist/editors/TextEditor.js +11 -48
- package/views/dist/editors/ValueListEditor.d.ts +14 -23
- package/views/dist/editors/ValueListEditor.js +16 -202
- package/views/dist/editors/body-panel.d.ts +13 -7
- package/views/dist/editors/body-panel.js +3 -7
- package/views/dist/editors/edit-cores.d.ts +15 -15
- package/views/dist/editors/edit-cores.js +14 -14
- package/views/dist/editors/number-body.d.ts +1 -1
- package/views/dist/editors/number-step.d.ts +0 -34
- package/views/dist/editors/number-step.js +0 -37
- package/views/dist/editors/option-add-flow.d.ts +1 -13
- package/views/dist/editors/option-add-flow.js +0 -22
- package/views/dist/editors/relation-links-body.d.ts +2 -3
- package/views/dist/editors/relation-picker.d.ts +13 -3
- package/views/dist/editors/relation-source.d.ts +0 -22
- package/views/dist/editors/relation-source.js +0 -21
- package/views/dist/field-row/FieldRow.js +5 -6
- package/views/dist/field-row/FieldRowLane.js +0 -1
- package/views/dist/field-row/editors/RowChipsEditor.js +2 -2
- package/views/dist/field-row/editors/RowDateEditor.d.ts +2 -2
- package/views/dist/field-row/editors/RowDateEditor.js +2 -2
- package/views/dist/field-row/editors/RowNameEditor.d.ts +2 -5
- package/views/dist/field-row/editors/RowNameEditor.js +7 -12
- package/views/dist/field-row/editors/RowNumberEditor.d.ts +1 -1
- package/views/dist/field-row/editors/RowNumberEditor.js +4 -4
- package/views/dist/field-row/editors/RowPlaceEditor.js +3 -3
- package/views/dist/field-row/editors/RowRangeEditor.d.ts +2 -5
- package/views/dist/field-row/editors/RowRangeEditor.js +7 -14
- package/views/dist/field-row/editors/RowRelationEditor.js +3 -3
- package/views/dist/field-row/editors/RowSelectEditor.js +2 -2
- package/views/dist/field-row/editors/RowTextEditor.d.ts +1 -1
- package/views/dist/field-row/editors/RowTextEditor.js +3 -4
- package/views/dist/field-row/editors/RowValueListEditor.js +5 -5
- package/views/dist/field-row/field-row-button.d.ts +6 -9
- package/views/dist/field-row/field-row-button.js +1 -6
- package/views/dist/field-row/field-row-checkbox.d.ts +1 -1
- package/views/dist/field-row/row-target.d.ts +0 -7
- package/views/dist/field-row/row-target.js +0 -2
- package/views/dist/grid/chrome/GridAddColumn.d.ts +2 -1
- package/views/dist/grid/chrome/GridAddColumn.js +8 -66
- package/views/dist/grid/chrome/GridAggregateMenu.d.ts +5 -7
- package/views/dist/grid/chrome/GridAggregateMenu.js +20 -39
- package/views/dist/grid/chrome/GridCellEditors.d.ts +2 -2
- package/views/dist/grid/chrome/GridCellEditors.js +12 -12
- package/views/dist/grid/chrome/GridChipsEditor.js +3 -3
- package/views/dist/grid/chrome/GridColumnMenu.d.ts +11 -12
- package/views/dist/grid/chrome/GridColumnMenu.js +32 -93
- package/views/dist/grid/chrome/GridDateEditor.d.ts +6 -6
- package/views/dist/grid/chrome/GridDateEditor.js +3 -3
- package/views/dist/grid/chrome/GridGroupMenu.d.ts +4 -6
- package/views/dist/grid/chrome/GridGroupMenu.js +21 -62
- package/views/dist/grid/chrome/GridHeader.d.ts +1 -2
- package/views/dist/grid/chrome/GridHeader.js +3 -2
- package/views/dist/grid/chrome/GridLongTextEditor.d.ts +17 -38
- package/views/dist/grid/chrome/GridLongTextEditor.js +6 -7
- package/views/dist/grid/chrome/GridNameEditor.js +4 -4
- package/views/dist/grid/chrome/GridNumberEditor.d.ts +4 -5
- package/views/dist/grid/chrome/GridNumberEditor.js +5 -6
- package/views/dist/grid/chrome/GridPlaceEditor.d.ts +2 -5
- package/views/dist/grid/chrome/GridPlaceEditor.js +5 -5
- package/views/dist/grid/chrome/GridRangeEditor.d.ts +6 -12
- package/views/dist/grid/chrome/GridRangeEditor.js +7 -15
- package/views/dist/grid/chrome/GridRelationEditor.js +5 -5
- package/views/dist/grid/chrome/GridRow.js +0 -3
- package/views/dist/grid/chrome/GridRowActions.d.ts +1 -1
- package/views/dist/grid/chrome/GridRowActions.js +0 -5
- package/views/dist/grid/chrome/GridRowCells.js +11 -7
- package/views/dist/grid/chrome/GridSelectEditor.js +3 -3
- package/views/dist/grid/chrome/GridStructure.js +0 -1
- package/views/dist/grid/chrome/GridTable.js +1 -1
- package/views/dist/grid/chrome/GridTextEditor.d.ts +5 -7
- package/views/dist/grid/chrome/GridTextEditor.js +5 -18
- package/views/dist/grid/chrome/GridValueListEditor.js +4 -4
- package/views/dist/grid/chrome/grid-body-place.d.ts +2 -3
- package/views/dist/grid/chrome/grid-body-place.js +4 -8
- package/views/dist/grid/chrome/grid-button.d.ts +7 -10
- package/views/dist/grid/chrome/grid-button.js +1 -6
- package/views/dist/grid/chrome/grid-cell-classes.js +1 -1
- package/views/dist/grid/chrome/grid-column-menu-items.d.ts +4 -4
- package/views/dist/grid/chrome/grid-column-menu-items.js +10 -6
- package/views/dist/grid/chrome/grid-editor-layer.d.ts +5 -1
- package/views/dist/grid/chrome/grid-editor-layer.js +1 -0
- package/views/dist/grid/chrome/grid-fitted-box.d.ts +7 -1
- package/views/dist/grid/chrome/grid-fitted-box.js +4 -4
- package/views/dist/grid/chrome/grid-group-menu-parts.d.ts +5 -9
- package/views/dist/grid/chrome/grid-group-menu-parts.js +1 -3
- package/views/dist/grid/chrome/grid-hover.js +0 -1
- package/views/dist/grid/chrome/grid-menu-focus.d.ts +7 -31
- package/views/dist/grid/chrome/grid-menu-focus.js +7 -47
- package/views/dist/grid/chrome/grid-styles.d.ts +0 -3
- package/views/dist/grid/chrome/grid-styles.js +0 -1
- package/views/dist/grid/chrome/grid-table-props.d.ts +6 -10
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +2 -4
- package/views/dist/grid/core/clipboard-model.js +9 -4
- package/views/dist/grid/core/editing-controller.d.ts +2 -1
- package/views/dist/grid/core/editing-controller.js +10 -2
- package/views/dist/grid/core/refusal-sentence.d.ts +3 -0
- package/views/dist/grid/core/refusal-sentence.js +2 -2
- package/views/dist/grid/core/write-states.d.ts +3 -1
- package/views/dist/grid/core/write-states.js +6 -2
- package/views/dist/grid/grid.css +240 -0
- package/views/dist/grid/looks.d.ts +5 -1
- package/views/dist/grid/looks.js +20 -12
- package/views/dist/grid-tokens.d.ts +109 -0
- package/views/dist/grid-tokens.js +29 -0
- package/views/dist/looks/index.d.ts +5 -0
- package/views/dist/looks/index.js +5 -0
- package/views/dist/looks/pieces.js +10 -0
- package/views/dist/model/body-frame.d.ts +0 -32
- package/views/dist/model/body-frame.js +1 -15
- package/views/dist/model/column-capabilities.d.ts +2 -0
- package/views/dist/model/column-filters.d.ts +2 -1
- package/views/dist/model/column-from.js +2 -2
- package/views/dist/model/column-inspect.d.ts +5 -5
- package/views/dist/model/column-inspect.js +2 -2
- package/views/dist/model/relation-filters.d.ts +2 -0
- package/views/dist/panels/customize-body.d.ts +1 -10
- package/views/dist/panels/customize-body.js +0 -3
- package/views/dist/panels/filter/MenuSelect.js +0 -5
- package/views/dist/panels/filter/RangeFilterBody.js +0 -1
- package/views/dist/panels/filter/details.d.ts +1 -5
- package/views/dist/panels/filter/details.js +0 -13
- package/views/dist/panels/filter/filter-list.d.ts +0 -1
- package/views/dist/panels/filter/filter-list.js +1 -1
- package/views/dist/panels/index.d.ts +2 -2
- package/views/dist/panels/index.js +2 -2
- package/views/dist/panels/labels.d.ts +4 -0
- package/views/dist/panels/labels.js +8 -0
- package/views/dist/panels/model.d.ts +10 -2
- package/views/dist/panels/panel-button.d.ts +10 -12
- package/views/dist/panels/panel-button.js +1 -6
- package/views/dist/panels/quick/model.d.ts +4 -0
- package/views/dist/panels/react/chrome.d.ts +0 -17
- package/views/dist/panels/react/chrome.js +0 -8
- package/views/dist/panels/react/customize-body.d.ts +14 -12
- package/views/dist/panels/react/customize-body.js +93 -19
- package/views/dist/panels/react/customize.d.ts +16 -12
- package/views/dist/panels/react/customize.js +4 -110
- package/views/dist/panels/react/filter/FilterEditor.d.ts +4 -18
- package/views/dist/panels/react/filter/FilterEditor.js +6 -330
- package/views/dist/panels/react/filter/FilterFieldList.d.ts +1 -1
- package/views/dist/panels/react/filter/FilterFieldList.js +27 -51
- package/views/dist/panels/react/filter/PhoneFilterEditor.d.ts +1 -11
- package/views/dist/panels/react/filter/PhoneFilterEditor.js +8 -144
- package/views/dist/panels/react/filter/editor-ctx.d.ts +1 -33
- package/views/dist/panels/react/filter/editor-ctx.js +5 -33
- package/views/dist/panels/react/filter/filter-body.js +5 -2
- package/views/dist/panels/react/filter/filter-part-body.d.ts +3 -6
- package/views/dist/panels/react/filter/filter-part-body.js +0 -5
- package/views/dist/panels/react/filter/rule-writes.d.ts +1 -26
- package/views/dist/panels/react/filter/rule-writes.js +4 -95
- package/views/dist/panels/react/order-details.d.ts +1 -26
- package/views/dist/panels/react/order-details.js +3 -69
- package/views/dist/panels/react/panel-header.js +0 -1
- package/views/dist/panels/react/panel-step.d.ts +3 -0
- package/views/dist/panels/react/panel-step.js +2 -1
- package/views/dist/panels/react/popover.d.ts +4 -7
- package/views/dist/panels/react/quick/QuickFiltersPanel.d.ts +2 -4
- package/views/dist/panels/react/quick/QuickFiltersPanel.js +16 -136
- package/views/dist/panels/react/sort/SortEditor.d.ts +4 -4
- package/views/dist/panels/react/sort/SortEditor.js +8 -245
- package/views/dist/panels/react/sort/SortFieldList.d.ts +1 -1
- package/views/dist/panels/react/sort/SortFieldList.js +11 -25
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +13 -3
- package/views/dist/panels/react/toolbar/ReadyToolbar.js +10 -3
- package/views/dist/panels/react/toolbar/Toolbar.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarAdvancedFilters.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarAsideFilter.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +16 -18
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +2 -1
- package/views/dist/panels/react/toolbar/ToolbarFilters.js +3 -3
- package/views/dist/panels/react/toolbar/ToolbarOptions.d.ts +12 -4
- package/views/dist/panels/react/toolbar/ToolbarOptions.js +6 -2
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarSave.js +0 -4
- package/views/dist/panels/react/toolbar/ToolbarSearch.js +0 -1
- package/views/dist/panels/react/toolbar/ToolbarSortPill.js +3 -3
- package/views/dist/panels/react/view-actions.js +0 -1
- package/views/dist/panels/react/views-row/FoldingViewRow.js +2 -5
- package/views/dist/panels/react/views-row/ViewCreatePill.js +0 -1
- package/views/dist/panels/react/views-row/ViewPicker.js +30 -45
- package/views/dist/panels/react/views-row/ViewPickerRow.js +0 -2
- package/views/dist/panels/react/views-row/menu-classes.d.ts +0 -4
- package/views/dist/panels/react/views-row/menu-classes.js +0 -2
- package/views/dist/panels/react.d.ts +5 -12
- package/views/dist/panels/react.js +5 -12
- package/views/dist/panels/settings/filter-groups.d.ts +3 -0
- package/views/dist/panels/settings/filter-groups.js +40 -9
- package/views/dist/panels/settings/filters.d.ts +5 -0
- package/views/dist/panels/settings/filters.js +12 -6
- package/views/dist/panels/views-row/model.d.ts +10 -1
- package/views/dist/provider/ViewsProvider.d.ts +2 -46
- package/views/dist/provider/ViewsProvider.js +31 -27
- package/views/dist/provider/components.d.ts +295 -107
- package/views/dist/provider/context.d.ts +7 -21
- package/views/dist/provider/missing-slot.d.ts +3 -7
- package/views/dist/provider/missing-slot.js +2 -9
- package/views/dist/provider/ports.d.ts +18 -6
- package/views/dist/provider/ports.js +2 -1
- package/views/dist/react.d.ts +2 -3
- package/views/dist/react.js +1 -1
- package/views/dist/selection/SelectionBar.d.ts +2 -16
- package/views/dist/selection/SelectionBar.js +6 -4
- package/views/dist/selection/bar-props.d.ts +26 -0
- package/views/dist/selection/bar-props.js +1 -0
- package/views/dist/selection/index.d.ts +1 -1
- package/views/dist/selection/verbs.d.ts +32 -5
- package/views/dist/styles.css +694 -191
- package/views/dist/styles.unlayered.css +691 -188
- package/views/docs/contract.md +133 -130
- package/views/docs/controls/bulk-bar.md +41 -0
- package/views/docs/controls/choice.md +25 -0
- package/views/docs/controls/customize.md +17 -0
- package/views/docs/controls/popover.md +2 -0
- package/views/docs/controls/press.md +9 -0
- package/views/docs/controls/quick-filters.md +35 -0
- package/views/docs/controls/radio.md +1 -1
- package/views/docs/controls/switch-row.md +18 -0
- package/views/docs/controls/tag-field.md +7 -0
- package/views/docs/controls/toolbar-button.md +31 -0
- package/views/docs/controls/toolbar.md +14 -0
- package/views/docs/getting-started.md +222 -2
- package/views/docs/guides/atoms.md +2 -2
- package/views/docs/guides/cells.md +224 -4
- package/views/docs/guides/display.md +3 -3
- package/views/docs/guides/editors.md +235 -20
- package/views/docs/guides/looks.md +8 -2
- package/views/docs/guides/ports.md +7 -7
- package/views/docs/guides/selection.md +5 -1
- package/views/docs/guides/the-grid.md +15 -17
- package/views/docs/guides/the-provider.md +9 -15
- package/views/docs/install.md +4 -1
- package/views/docs/reference/cells.md +2 -2
- package/views/docs/reference/controls.md +215 -21
- package/views/docs/reference/display.md +1 -0
- package/views/docs/reference/editors-chips.md +2 -2
- package/views/docs/reference/editors-date.md +4 -4
- package/views/docs/reference/editors-location.md +4 -7
- package/views/docs/reference/editors-name.md +3 -5
- package/views/docs/reference/editors-number.md +10 -10
- package/views/docs/reference/editors-panel.md +3 -3
- package/views/docs/reference/editors-range.md +3 -5
- package/views/docs/reference/editors-relation.md +4 -4
- package/views/docs/reference/editors-select.md +3 -3
- package/views/docs/reference/editors-text.md +3 -4
- package/views/docs/reference/editors-value-list.md +3 -3
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/grid.md +2 -2
- package/views/docs/reference/looks.md +25 -11
- package/views/docs/reference/panels-react.md +23 -37
- package/views/docs/reference/panels.md +8 -6
- package/views/docs/reference/react.md +24 -24
- package/views/docs/reference/selection.md +4 -2
- package/views/docs/reference/views.md +12 -11
- package/views/skills/views/SKILL.md +2 -2
- package/views/dist/editors/relation-panel.d.ts +0 -69
- package/views/dist/editors/relation-panel.js +0 -46
- package/views/dist/grid/chrome/GridColumnColorSection.d.ts +0 -13
- package/views/dist/grid/chrome/GridColumnColorSection.js +0 -40
- package/views/dist/grid/chrome/GridColumnDateSection.d.ts +0 -28
- package/views/dist/grid/chrome/GridColumnDateSection.js +0 -23
- package/views/dist/grid/chrome/GridColumnDurationSection.d.ts +0 -23
- package/views/dist/grid/chrome/GridColumnDurationSection.js +0 -24
- package/views/dist/grid/chrome/GridColumnNumberSection.d.ts +0 -29
- package/views/dist/grid/chrome/GridColumnNumberSection.js +0 -27
- package/views/dist/grid/chrome/GridColumnPercentSection.d.ts +0 -16
- package/views/dist/grid/chrome/GridColumnPercentSection.js +0 -16
- package/views/dist/grid/chrome/GridColumnSortSection.d.ts +0 -38
- package/views/dist/grid/chrome/GridColumnSortSection.js +0 -33
- package/views/dist/grid/chrome/GridFlyout.d.ts +0 -44
- package/views/dist/grid/chrome/GridFlyout.js +0 -80
- package/views/dist/grid/chrome/GridMenuRow.d.ts +0 -15
- package/views/dist/grid/chrome/GridMenuRow.js +0 -15
- package/views/dist/grid/chrome/grid-menu-search.d.ts +0 -7
- package/views/dist/grid/chrome/grid-menu-search.js +0 -7
- package/views/dist/panels/react/GroupBucketsList.d.ts +0 -16
- package/views/dist/panels/react/GroupBucketsList.js +0 -44
- package/views/dist/panels/react/LayoutColumnsList.d.ts +0 -24
- package/views/dist/panels/react/LayoutColumnsList.js +0 -101
- package/views/dist/panels/react/PopoverColumnDetail.d.ts +0 -11
- package/views/dist/panels/react/PopoverColumnDetail.js +0 -24
- package/views/dist/panels/react/drag.d.ts +0 -2
- package/views/dist/panels/react/drag.js +0 -5
- package/views/dist/panels/react/layout-detail.d.ts +0 -4
- package/views/dist/panels/react/layout-detail.js +0 -29
- package/views/dist/panels/react/root-list.d.ts +0 -6
- package/views/dist/panels/react/root-list.js +0 -31
- package/views/dist/panels/react/sort/use-sort-drag.d.ts +0 -17
- package/views/dist/panels/react/sort/use-sort-drag.js +0 -39
- package/views/dist/panels/react/view-footer.d.ts +0 -20
- package/views/dist/panels/react/view-footer.js +0 -41
|
@@ -66,6 +66,15 @@ string
|
|
|
66
66
|
readonly from: string;
|
|
67
67
|
readonly to: string;
|
|
68
68
|
};
|
|
69
|
+
}
|
|
70
|
+
/** A value kept as another kind's record: the column holding that record's key, the kind, and its column holding the
|
|
71
|
+
* value (a status kept as a code table's row id, valued by its code). */
|
|
72
|
+
| {
|
|
73
|
+
readonly column: string;
|
|
74
|
+
readonly from: {
|
|
75
|
+
readonly kind: string;
|
|
76
|
+
readonly value: string;
|
|
77
|
+
};
|
|
69
78
|
};
|
|
70
79
|
/** What `buildFieldMap` takes. */
|
|
71
80
|
export type BuildFieldMapInput = {
|
|
@@ -79,6 +88,8 @@ export type BuildFieldMapInput = {
|
|
|
79
88
|
readonly money?: ConvertMoney;
|
|
80
89
|
/** Your own entry for a field the storage can't say, by kind and field. It replaces the built one wherever that kind is read, and answers for its own access. */
|
|
81
90
|
readonly handWritten?: Readonly<Record<string, Readonly<Record<string, FieldMapping>>>>;
|
|
91
|
+
/** Lookups and rollups that read their far records under a condition of their own, by kind and field: the name of that condition. Each reads through tables keyed `far:<kind>:<name>`, which `reads` names for you to hand a condition and a list of readable fields; fields named alike share them. */
|
|
92
|
+
readonly readUnder?: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
82
93
|
};
|
|
83
94
|
/** A storage refused: `path` names the place in the input. */
|
|
84
95
|
export declare class StorageError extends Error {
|
|
@@ -109,6 +120,8 @@ export type CheckedInput = {
|
|
|
109
120
|
readonly money: ConvertMoney | undefined;
|
|
110
121
|
readonly kind: string;
|
|
111
122
|
readonly handWritten: Readonly<Record<string, Readonly<Record<string, FieldMapping>>>>;
|
|
123
|
+
/** The name each named lookup or rollup reads under, by kind and field: `{}` when none is named. */
|
|
124
|
+
readonly readUnder: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
112
125
|
/** The kind a user field points at, or undefined when the storage names none. */
|
|
113
126
|
readonly users: string | undefined;
|
|
114
127
|
};
|
|
@@ -118,3 +131,5 @@ export declare const TEXT_TYPES: ReadonlySet<ValueType>;
|
|
|
118
131
|
export declare function holdsSeveral(def: FieldDef): boolean;
|
|
119
132
|
/** Refuses with a `StorageError` at the first thing the input can't hold. */
|
|
120
133
|
export declare function checkInput(given: BuildFieldMapInput): CheckedInput;
|
|
134
|
+
/** The name `field` of `kind` reads under (`readUnder`), or undefined when it reads as every field does. */
|
|
135
|
+
export declare function underOf(input: CheckedInput, kind: string, field: string): string | undefined;
|
|
@@ -30,8 +30,10 @@ const JSON_TYPES = new Set([
|
|
|
30
30
|
"datetime",
|
|
31
31
|
"boolean",
|
|
32
32
|
]);
|
|
33
|
+
const UNDER_NAME = /^[A-Za-z0-9_-]{1,63}$/;
|
|
34
|
+
const NAMED_FIELDS = "give the named fields by kind and field";
|
|
33
35
|
const WORKED_OUT = "a lookup, a rollup or a formula is worked out from the definitions, never kept";
|
|
34
|
-
const NO_FORM = "a field is kept as a column, { column, stored }, { parts }, { json, path }, { rows } or { through }";
|
|
36
|
+
const NO_FORM = "a field is kept as a column, { column, stored }, { column, from }, { parts }, { json, path }, { rows } or { through }";
|
|
35
37
|
const UNKEPT = /\u0000|[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/;
|
|
36
38
|
export function holdsSeveral(def) {
|
|
37
39
|
const type = valueTypeOf(def);
|
|
@@ -205,6 +207,7 @@ export function checkInput(given) {
|
|
|
205
207
|
throw new StorageError(path, "an amount that converts is read through your money function");
|
|
206
208
|
}
|
|
207
209
|
}
|
|
210
|
+
const readUnder = checkReadUnder(given.readUnder, checkedKinds, handWritten);
|
|
208
211
|
const users = storage.users;
|
|
209
212
|
if (users !== undefined) {
|
|
210
213
|
if (typeof users !== "string")
|
|
@@ -227,9 +230,44 @@ export function checkInput(given) {
|
|
|
227
230
|
money: money,
|
|
228
231
|
kind: listKind,
|
|
229
232
|
handWritten,
|
|
233
|
+
readUnder,
|
|
230
234
|
users: users,
|
|
231
235
|
});
|
|
232
236
|
}
|
|
237
|
+
export function underOf(input, kind, field) {
|
|
238
|
+
return own(own(input.readUnder, kind), field);
|
|
239
|
+
}
|
|
240
|
+
function checkReadUnder(given, kinds, handWritten) {
|
|
241
|
+
if (given === undefined)
|
|
242
|
+
return Object.freeze({});
|
|
243
|
+
const copy = frozenCopy(given);
|
|
244
|
+
if (!isRecord(copy))
|
|
245
|
+
throw new StorageError("readUnder", NAMED_FIELDS);
|
|
246
|
+
for (const kind of Object.keys(copy)) {
|
|
247
|
+
if (kind.includes(":"))
|
|
248
|
+
throw new StorageError(`readUnder.${kind}`, 'a kind\'s name holds no ":"');
|
|
249
|
+
}
|
|
250
|
+
for (const [kind, fields] of Object.entries(copy)) {
|
|
251
|
+
const checked = own(kinds, kind);
|
|
252
|
+
if (checked === undefined)
|
|
253
|
+
throw new StorageError(`readUnder.${kind}`, `${kind} is not one of the storage's kinds`);
|
|
254
|
+
if (!isRecord(fields))
|
|
255
|
+
throw new StorageError(`readUnder.${kind}`, NAMED_FIELDS);
|
|
256
|
+
for (const [key, name] of Object.entries(fields)) {
|
|
257
|
+
const path = `readUnder.${kind}.${key}`;
|
|
258
|
+
const named = checked.entity === undefined ? undefined : own(checked.entity.fields, key);
|
|
259
|
+
if (named === undefined)
|
|
260
|
+
throw new StorageError(path, `${key} is no field of ${kind}`);
|
|
261
|
+
if (named.type !== "lookup" && named.type !== "rollup")
|
|
262
|
+
throw new StorageError(path, "only a lookup or a rollup reads under a condition of its own");
|
|
263
|
+
if (Object.hasOwn(own(handWritten, kind) ?? {}, key))
|
|
264
|
+
throw new StorageError(path, "a hand-written field answers for its own reads");
|
|
265
|
+
if (typeof name !== "string" || !UNDER_NAME.test(name))
|
|
266
|
+
throw new StorageError(path, "a name is 1 to 63 letters, digits, - and _");
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return copy;
|
|
270
|
+
}
|
|
233
271
|
function checkForm(path, kind, def, form, kinds) {
|
|
234
272
|
const type = valueTypeOf(def);
|
|
235
273
|
const several = holdsSeveral(def);
|
|
@@ -265,6 +303,19 @@ function checkForm(path, kind, def, form, kinds) {
|
|
|
265
303
|
if (!("through" in form))
|
|
266
304
|
throw new StorageError(path, "a relation of several records is kept through its inverse or a link kind");
|
|
267
305
|
}
|
|
306
|
+
if ("from" in form) {
|
|
307
|
+
onlyKeys(path, form, ["column", "from"]);
|
|
308
|
+
if (several || (type !== "select" && type !== "status" && !TEXT_TYPES.has(type)))
|
|
309
|
+
throw new StorageError(path, "only a select, a status or a text of one value is read from the row its column points at");
|
|
310
|
+
name(path, form.column);
|
|
311
|
+
const from = form.from;
|
|
312
|
+
if (!isRecord(from))
|
|
313
|
+
throw new StorageError(path, "from names a kind and its value column");
|
|
314
|
+
onlyKeys(path, from, ["kind", "value"]);
|
|
315
|
+
isKind(path, from.kind);
|
|
316
|
+
name(path, from.value);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
268
319
|
if ("column" in form) {
|
|
269
320
|
onlyKeys(path, form, ["column", "stored"]);
|
|
270
321
|
if (!TEXT_TYPES.has(type) || several)
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { valueTypeOf } from "viewkitjs/fields";
|
|
2
|
+
import { openedOf } from "../access.js";
|
|
2
3
|
import { trimmedSql } from "../fold.js";
|
|
3
4
|
import { sql } from "../sql.js";
|
|
5
|
+
import { joinedOf } from "../values.js";
|
|
4
6
|
import { jsonMember, memberOf } from "./json.js";
|
|
5
7
|
import { holdsSeveral, TEXT_TYPES } from "./storage.js";
|
|
6
8
|
function withPhoneSort(mapping) {
|
|
@@ -50,6 +52,25 @@ export function placeStored(at) {
|
|
|
50
52
|
const member = jsonMember(type, form.json, form.path);
|
|
51
53
|
return placed({ value: member.read, stored: member.stored }, [read(form.json)]);
|
|
52
54
|
}
|
|
55
|
+
if (isForm(form, "from")) {
|
|
56
|
+
const key = at.relationKey(table, def.key);
|
|
57
|
+
const to = at.farTable(form.from.kind);
|
|
58
|
+
const value = form.from.value;
|
|
59
|
+
const through = (row) => {
|
|
60
|
+
const opened = openedOf(row);
|
|
61
|
+
if (opened === undefined)
|
|
62
|
+
throw new TypeError(`${def.key}: a value kept as another kind's record is read only on a row the translator opened`);
|
|
63
|
+
if (opened.at.table !== table)
|
|
64
|
+
throw new TypeError(`${def.key} is read on ${table}'s rows, not ${opened.at.table}'s`);
|
|
65
|
+
const joined = joinedOf(opened.scope, opened.at, key);
|
|
66
|
+
return joined.read(sql `(${joined.far.row.column(value)})::text`);
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
mapping: { value: through, sort: through, search: through, stored: "text" },
|
|
70
|
+
reads: [read(form.column), { table: to, column: value }],
|
|
71
|
+
relation: { key, map: { from: table, to, column: form.column } },
|
|
72
|
+
};
|
|
73
|
+
}
|
|
53
74
|
if (isForm(form, "column"))
|
|
54
75
|
return placed({ value: asText(form.column), stored: "text" }, [read(form.column)]);
|
|
55
76
|
if (typeof form !== "string")
|
package/postgres/dist/phone.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type FilterRule } from "viewkitjs/fields/query";
|
|
2
2
|
import type { Opened, Scope } from "./access.js";
|
|
3
3
|
import { type Read, type ValueRow } from "./map.js";
|
|
4
4
|
import { type Sql } from "./sql.js";
|
|
@@ -26,3 +26,15 @@ export declare function phoneAt(scope: Scope, at: Opened, key: string): PhoneRea
|
|
|
26
26
|
export declare function phoneOfElement(element: Sql, text: Sql): PhoneReading;
|
|
27
27
|
/** `rule` on the phone `reading`, as matchesRule's phone case answers it, the operand read in `region`. */
|
|
28
28
|
export declare function phoneRuleSql(reading: PhoneReading, rule: FilterRule, region: string | undefined): Sql;
|
|
29
|
+
/**
|
|
30
|
+
* A search word on the phone `reading`, answering what phoneRuleSql's "contains" answers, written as arms an index
|
|
31
|
+
* serves: `(international AND number contains operand) OR (NOT international AND typed contains word)` in
|
|
32
|
+
* place of a CASE chosen on each row, which no index serves; the same predicate, every part being two-valued. Each
|
|
33
|
+
* contains is a LIKE over a folded text, which a trigram index on that text serves (searchIndexes prints both). The
|
|
34
|
+
* number's arm is left out when no international number can hold the word (a letter in it), and a phone that is never
|
|
35
|
+
* international (no number part) is its typed arm alone.
|
|
36
|
+
*/
|
|
37
|
+
export declare function phoneWordSql(reading: PhoneReading, word: string): Sql;
|
|
38
|
+
/** Whether a trigram index serves every arm phoneWordSql writes for `word`: three folded characters or more in the
|
|
39
|
+
* word, and in the number's operand where that arm is kept. */
|
|
40
|
+
export declare function phoneWordIndexed(word: string): boolean;
|
package/postgres/dist/phone.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { phoneFilterOperand } from "viewkitjs/fields";
|
|
2
|
-
import {
|
|
2
|
+
import { foldText } from "viewkitjs/fields/query";
|
|
3
|
+
import { TRIGRAM, trimmedSql } from "./fold.js";
|
|
3
4
|
import { textSql } from "./rules.js";
|
|
4
|
-
import { sql } from "./sql.js";
|
|
5
|
+
import { FALSE, sql } from "./sql.js";
|
|
5
6
|
import { readSql, rowJoinOf } from "./values.js";
|
|
6
7
|
import { readableField } from "./readable.js";
|
|
7
8
|
const E164 = "^\\+[1-9][0-9]{1,14}$";
|
|
@@ -9,7 +10,7 @@ const EXTENSION = "^[0-9]{1,20}$";
|
|
|
9
10
|
export function phoneOf(row, parts, typed, key) {
|
|
10
11
|
const fallback = typed === null ? sql `NULL::text` : sql `(${typed})`;
|
|
11
12
|
if (parts === undefined || !Object.hasOwn(parts, "number"))
|
|
12
|
-
return { international:
|
|
13
|
+
return { international: FALSE, number: sql `NULL::text`, typed: fallback };
|
|
13
14
|
const number = sql `(${readSql(row, parts.number, key)})`;
|
|
14
15
|
const ext = Object.hasOwn(parts, "extension") ? readSql(row, parts.extension, key) : null;
|
|
15
16
|
const extension = ext === null ? sql `` : sql ` AND (${ext} IS NULL OR ${ext} ~ ${EXTENSION}::text)`;
|
|
@@ -52,3 +53,22 @@ export function phoneRuleSql(reading, rule, region) {
|
|
|
52
53
|
: textSql(reading.number, operator, operand);
|
|
53
54
|
return sql `(CASE WHEN ${reading.international} THEN ${international} ELSE ${textSql(reading.typed, operator, query)} END)`;
|
|
54
55
|
}
|
|
56
|
+
const NUMBER_TEXT = /^[+0-9]*$/;
|
|
57
|
+
function numberOperand(word) {
|
|
58
|
+
const operand = foldText(phoneFilterOperand("contains", word, undefined).trim());
|
|
59
|
+
return NUMBER_TEXT.test(operand) ? operand : null;
|
|
60
|
+
}
|
|
61
|
+
export function phoneWordSql(reading, word) {
|
|
62
|
+
const typed = textSql(reading.typed, "contains", word);
|
|
63
|
+
if (reading.international === FALSE)
|
|
64
|
+
return typed;
|
|
65
|
+
const operand = numberOperand(word);
|
|
66
|
+
if (operand === null)
|
|
67
|
+
return sql `(NOT ${reading.international} AND ${typed})`;
|
|
68
|
+
const number = operand === "" ? sql `TRUE` : textSql(reading.number, "contains", operand);
|
|
69
|
+
return sql `((${reading.international} AND ${number}) OR (NOT ${reading.international} AND ${typed}))`;
|
|
70
|
+
}
|
|
71
|
+
export function phoneWordIndexed(word) {
|
|
72
|
+
const operand = numberOperand(word);
|
|
73
|
+
return [...foldText(word.trim())].length >= TRIGRAM && (operand === null || [...operand].length >= TRIGRAM);
|
|
74
|
+
}
|
|
@@ -38,7 +38,8 @@ export type SearchStatistics = {
|
|
|
38
38
|
* second map over the same table prints the same statement, which then changes nothing. */
|
|
39
39
|
readonly statement: string;
|
|
40
40
|
};
|
|
41
|
-
/** A field the search names that no index serves, and why: a search naming one reads every row.
|
|
41
|
+
/** A field the search names that no index serves, and why: a search naming one reads every row. A relation whose far
|
|
42
|
+
* label no index can hold is named too, its own column's index still printed: each word reads the far table whole. */
|
|
42
43
|
export type UnservedField = {
|
|
43
44
|
readonly field: string;
|
|
44
45
|
readonly reason: string;
|
|
@@ -50,9 +51,13 @@ export type SearchIndexes = {
|
|
|
50
51
|
readonly statistics: readonly SearchStatistics[];
|
|
51
52
|
};
|
|
52
53
|
export declare const SEARCH_INDEX_REASONS: {
|
|
54
|
+
/** No longer given: a phone is searched by its number and its typed text, each served by a trigram index.
|
|
55
|
+
* Kept for an app that compares a reason to it. */
|
|
53
56
|
readonly phone: "a phone is searched by its number's own rule, which no index serves";
|
|
54
57
|
readonly option: "an option is searched by its options' labels, which no index serves yet";
|
|
55
58
|
readonly otherTable: "it is read through another table or a subquery, which an index on this table can't hold";
|
|
59
|
+
readonly notImmutable: "it is written with a function whose answer can change from one statement to the next, which no index can hold";
|
|
60
|
+
readonly farLabel: "its far table's label can't be held by an index, so each search word reads that table whole";
|
|
56
61
|
};
|
|
57
62
|
/** The indexes the search over `fields` reads through on `map`, the statistics beside its trigram ones, and the fields no
|
|
58
63
|
* index serves. */
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
import { EVERY_ROW, open, quotedName, scopeOf } from "./access.js";
|
|
2
2
|
import { foldedSql } from "./fold.js";
|
|
3
|
+
import { phoneOnRow } from "./phone.js";
|
|
3
4
|
import { keyTextSql, searchedReadOf } from "./search.js";
|
|
4
|
-
import { join, pickLiteral, render, sql } from "./sql.js";
|
|
5
|
+
import { FALSE, join, pickLiteral, render, sql } from "./sql.js";
|
|
5
6
|
import { labelOf } from "./values.js";
|
|
6
7
|
import { EVERY_FIELD } from "./readable.js";
|
|
7
8
|
export const SEARCH_INDEX_REASONS = {
|
|
8
9
|
phone: "a phone is searched by its number's own rule, which no index serves",
|
|
9
10
|
option: "an option is searched by its options' labels, which no index serves yet",
|
|
10
11
|
otherTable: "it is read through another table or a subquery, which an index on this table can't hold",
|
|
12
|
+
notImmutable: "it is written with a function whose answer can change from one statement to the next, which no index can hold",
|
|
13
|
+
farLabel: "its far table's label can't be held by an index, so each search word reads that table whole",
|
|
11
14
|
};
|
|
15
|
+
const NOT_IMMUTABLE_CALLS = [
|
|
16
|
+
"concat_ws", "concat", "format", "to_char", "to_date", "to_timestamp", "to_number", "now", "clock_timestamp",
|
|
17
|
+
"statement_timestamp", "transaction_timestamp", "timeofday", "age", "random", "gen_random_uuid", "nextval", "currval",
|
|
18
|
+
"unaccent",
|
|
19
|
+
];
|
|
20
|
+
const NOT_IMMUTABLE = new RegExp(`\\b(?:(?:${NOT_IMMUTABLE_CALLS.join("|")})\\s*\\(|(?:current_date|current_time|current_timestamp|localtime|localtimestamp)\\b)`, "i");
|
|
21
|
+
const ASKS_A_JOIN = "render: a fragment asks for a part its statement doesn't write";
|
|
12
22
|
function escaped(character) {
|
|
13
23
|
if (character === "\\")
|
|
14
24
|
return "\\\\";
|
|
@@ -31,15 +41,28 @@ function literal(value) {
|
|
|
31
41
|
return null;
|
|
32
42
|
}
|
|
33
43
|
function indexText(fragment, alias) {
|
|
34
|
-
const {
|
|
44
|
+
const otherTable = { reason: SEARCH_INDEX_REASONS.otherTable };
|
|
45
|
+
let rendered;
|
|
46
|
+
try {
|
|
47
|
+
rendered = render(fragment);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
if (error instanceof TypeError && error.message === ASKS_A_JOIN)
|
|
51
|
+
return otherTable;
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
const { text, values } = rendered;
|
|
35
55
|
if (/\$\d+(?!\d|::)/.test(text))
|
|
36
|
-
return
|
|
37
|
-
|
|
38
|
-
|
|
56
|
+
return otherTable;
|
|
57
|
+
const unquoted = text.replace(/"(?:[^"]|"")*"/g, '""');
|
|
58
|
+
if (/\bselect\b/i.test(unquoted))
|
|
59
|
+
return otherTable;
|
|
60
|
+
if (NOT_IMMUTABLE.test(unquoted.replace(/'(?:[^']|'')*'/g, "''")))
|
|
61
|
+
return { reason: SEARCH_INDEX_REASONS.notImmutable };
|
|
39
62
|
const qualifier = `"${alias.replace(/"/g, '""')}".`;
|
|
40
63
|
const bare = text.split(qualifier).join("");
|
|
41
64
|
if (bare.includes('"vk_'))
|
|
42
|
-
return
|
|
65
|
+
return otherTable;
|
|
43
66
|
let failed = false;
|
|
44
67
|
const written = bare.replace(/\$(\d+)/g, (_, n) => {
|
|
45
68
|
const one = literal(values[Number(n) - 1]);
|
|
@@ -47,8 +70,9 @@ function indexText(fragment, alias) {
|
|
|
47
70
|
failed = true;
|
|
48
71
|
return one ?? "";
|
|
49
72
|
});
|
|
50
|
-
return failed ?
|
|
73
|
+
return failed ? otherTable : written;
|
|
51
74
|
}
|
|
75
|
+
const isHeld = (one) => typeof one === "string";
|
|
52
76
|
function hashOf(text) {
|
|
53
77
|
let hash = 0x811c9dc5;
|
|
54
78
|
for (let i = 0; i < text.length; i += 1) {
|
|
@@ -86,7 +110,7 @@ export function searchIndexes(input) {
|
|
|
86
110
|
return undefined;
|
|
87
111
|
const row = open(scope, table, "f").row;
|
|
88
112
|
const written = indexText(join(pick.map(([column, value]) => sql `${row.column(column)} = ${pickLiteral(value)}`), sql ` AND `), aliasOf(row.key));
|
|
89
|
-
return written
|
|
113
|
+
return isHeld(written) ? written : undefined;
|
|
90
114
|
};
|
|
91
115
|
const bases = new Map();
|
|
92
116
|
const add = (table, method, expression, field, base) => {
|
|
@@ -113,60 +137,82 @@ export function searchIndexes(input) {
|
|
|
113
137
|
const far = open(scope, to, "f");
|
|
114
138
|
return indexText(foldedSql(labelOf(scope, far)), aliasOf(far.row.key));
|
|
115
139
|
};
|
|
140
|
+
const phoneIndexes = (field, table, reading, alias, base) => {
|
|
141
|
+
const number = reading.international === FALSE ? undefined : indexText(foldedSql(reading.number), alias);
|
|
142
|
+
const typed = indexText(foldedSql(reading.typed), alias);
|
|
143
|
+
if (number !== undefined && !isHeld(number))
|
|
144
|
+
return number;
|
|
145
|
+
if (!isHeld(typed))
|
|
146
|
+
return typed;
|
|
147
|
+
if (number !== undefined)
|
|
148
|
+
add(table, "gin", number, field, base);
|
|
149
|
+
add(table, "gin", typed, field, base);
|
|
150
|
+
return undefined;
|
|
151
|
+
};
|
|
152
|
+
const unheld = (field, why) => {
|
|
153
|
+
if (why !== undefined)
|
|
154
|
+
unserved.push({ field, reason: why.reason });
|
|
155
|
+
};
|
|
116
156
|
for (const field of input.fields) {
|
|
117
157
|
const read = searchedReadOf(scope, main, field);
|
|
118
158
|
if (read === null)
|
|
119
159
|
continue;
|
|
120
160
|
switch (read.kind) {
|
|
121
161
|
case "phone":
|
|
122
|
-
|
|
162
|
+
unheld(field, phoneIndexes(field, map.table, read.reading, mainAlias, field));
|
|
123
163
|
break;
|
|
124
164
|
case "option":
|
|
125
165
|
unserved.push({ field, reason: SEARCH_INDEX_REASONS.option });
|
|
126
166
|
break;
|
|
127
167
|
case "row": {
|
|
168
|
+
const row = map.fields[field].mapping.row;
|
|
128
169
|
if (read.phone) {
|
|
129
|
-
|
|
170
|
+
const probe = open(scope, row.table, "f");
|
|
171
|
+
const base = row.parts?.number ?? row.value ?? field;
|
|
172
|
+
unheld(field, phoneIndexes(field, row.table, phoneOnRow(probe, row, field), aliasOf(probe.row.key), base));
|
|
130
173
|
break;
|
|
131
174
|
}
|
|
132
175
|
if (read.option) {
|
|
133
176
|
unserved.push({ field, reason: SEARCH_INDEX_REASONS.option });
|
|
134
177
|
break;
|
|
135
178
|
}
|
|
136
|
-
const row = map.fields[field].mapping.row;
|
|
137
179
|
const probe = row.value === undefined ? null : open(scope, row.table, "f");
|
|
138
|
-
const expression = probe === null
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
180
|
+
const expression = probe === null
|
|
181
|
+
? { reason: SEARCH_INDEX_REASONS.otherTable }
|
|
182
|
+
: indexText(foldedSql(probe.row.column(row.value)), aliasOf(probe.row.key));
|
|
183
|
+
if (isHeld(expression))
|
|
142
184
|
add(row.table, "gin", expression, field, row.value);
|
|
185
|
+
else
|
|
186
|
+
unheld(field, expression);
|
|
143
187
|
break;
|
|
144
188
|
}
|
|
145
189
|
case "text": {
|
|
146
190
|
const expression = indexText(foldedSql(read.text), mainAlias);
|
|
147
|
-
if (expression
|
|
148
|
-
unserved.push({ field, reason: SEARCH_INDEX_REASONS.otherTable });
|
|
149
|
-
else
|
|
191
|
+
if (isHeld(expression))
|
|
150
192
|
add(map.table, "gin", expression, field);
|
|
193
|
+
else
|
|
194
|
+
unheld(field, expression);
|
|
151
195
|
break;
|
|
152
196
|
}
|
|
153
197
|
case "lead": {
|
|
154
198
|
const label = farLabelIndex(read.to);
|
|
155
|
-
if (label
|
|
156
|
-
unserved.push({ field, reason: SEARCH_INDEX_REASONS.otherTable });
|
|
157
|
-
else
|
|
199
|
+
if (isHeld(label))
|
|
158
200
|
add(read.to, "gin", label, field);
|
|
201
|
+
else
|
|
202
|
+
unserved.push({ field, reason: SEARCH_INDEX_REASONS.farLabel });
|
|
159
203
|
break;
|
|
160
204
|
}
|
|
161
205
|
case "relation": {
|
|
162
206
|
const own = indexText(read.own, mainAlias);
|
|
163
|
-
if (own
|
|
164
|
-
|
|
207
|
+
if (!isHeld(own)) {
|
|
208
|
+
unheld(field, own);
|
|
165
209
|
break;
|
|
166
210
|
}
|
|
167
211
|
const label = farLabelIndex(read.to);
|
|
168
|
-
if (label
|
|
212
|
+
if (isHeld(label))
|
|
169
213
|
add(read.to, "gin", label, field);
|
|
214
|
+
else
|
|
215
|
+
unserved.push({ field, reason: SEARCH_INDEX_REASONS.farLabel });
|
|
170
216
|
add(map.table, "btree", own, field);
|
|
171
217
|
break;
|
|
172
218
|
}
|
|
@@ -175,7 +221,7 @@ export function searchIndexes(input) {
|
|
|
175
221
|
const stored = map.tables[map.table].keyStored;
|
|
176
222
|
if (stored !== "uuid" && stored !== "integer" && stored !== "bigint") {
|
|
177
223
|
const key = indexText(keyTextSql(main), mainAlias);
|
|
178
|
-
if (key
|
|
224
|
+
if (isHeld(key))
|
|
179
225
|
add(map.table, "btree", key, null);
|
|
180
226
|
}
|
|
181
227
|
const statistics = indexes.filter((one) => one.method === "gin").map((one) => statisticsOf(one, bases.get(one)));
|
package/postgres/dist/search.js
CHANGED
|
@@ -4,7 +4,7 @@ import { open } from "./access.js";
|
|
|
4
4
|
import { keptText } from "./check.js";
|
|
5
5
|
import { fitsKey, spelledAsKept } from "./cursor.js";
|
|
6
6
|
import { foldedContainsSql, TRIGRAM } from "./fold.js";
|
|
7
|
-
import { phoneAt, phoneOnRow,
|
|
7
|
+
import { phoneAt, phoneOnRow, phoneWordIndexed, phoneWordSql } from "./phone.js";
|
|
8
8
|
import { isOneRelation } from "./map.js";
|
|
9
9
|
import { REFUSALS } from "./refusals.js";
|
|
10
10
|
import { FALSE, isSql, join, sql } from "./sql.js";
|
|
@@ -92,11 +92,11 @@ function wordOf(scope, read, fenced) {
|
|
|
92
92
|
case "option":
|
|
93
93
|
return optionWord(read.def, read.value);
|
|
94
94
|
case "phone":
|
|
95
|
-
return (word) =>
|
|
95
|
+
return (word) => phoneWordSql(read.reading, word);
|
|
96
96
|
case "row":
|
|
97
97
|
if (read.phone) {
|
|
98
98
|
const row = readableField(scope, read.at.table, read.key).mapping.row;
|
|
99
|
-
return (word) => rowProbeOn(scope, read.at, read.key, (probe) =>
|
|
99
|
+
return (word) => rowProbeOn(scope, read.at, read.key, (probe) => phoneWordSql(phoneOnRow(probe, row, read.key), word), fenced, phoneWordIndexed(word));
|
|
100
100
|
}
|
|
101
101
|
return (word) => rowProbeSql(scope, read.at, read.key, (value) => (read.option ? optionWord(read.def, value)(word) : foldedContainsSql(value, word)), fenced, !read.option && [...word].length >= TRIGRAM);
|
|
102
102
|
case "relation":
|
|
@@ -12,6 +12,7 @@ An `AppStorage` names each kind of record you keep, by the name your index gives
|
|
|
12
12
|
- **`columns`**: where a field is kept when it isn't the column of its own key. Each entry is a `FieldStorage`:
|
|
13
13
|
- a column's name: a value, a list of several values in an array column, a relation of one record's key, or a user's id;
|
|
14
14
|
- `{ column, stored }`: a text kept in a `uuid`, `integer` or `bigint` column;
|
|
15
|
+
- `{ column, from: { kind, value } }`: a select, a status or a text of one value kept as another kind's record, a status kept as a code table's row id for instance: `column` holds that record's key, and the field's value is its `value` column, read as text. The kind is declared like a link kind (its table, key and soft-delete column, no definitions), read as `far:<kind>` under the condition you hand for it, through one join: an empty id, one no record holds, and one whose record is hidden or in the trash read as no value. It filters, sorts, groups and counts by that value;
|
|
15
16
|
- `{ parts }`: a name, a place, a range or a phone, each part's column;
|
|
16
17
|
- `{ json, path }`: a member of a `jsonb` column by its path of keys (`[]` is the column itself, a list for a field of several values);
|
|
17
18
|
- `{ rows: { kind, record, value, main? } }`: several values as rows of a kind of their own; `main`, the boolean column marking a record's main one, which a sort by the field reads;
|
|
@@ -19,7 +20,7 @@ An `AppStorage` names each kind of record you keep, by the name your index gives
|
|
|
19
20
|
- **`notKept`**: fields the table keeps nothing for.
|
|
20
21
|
- **`notNull`**: fields whose value is never NULL on a row of this kind (a number, a percent, a date, an instant or a yes-or-no), which sort by their direction alone, so one index serves them both ways (the field-map guide, *Ordering a page*). A field with a hand-written entry says it in its own mapping instead. Only the list's own kind carries it: a field read on a far record never does, as that record may be missing. A field kept in a `jsonb` member reads a member of another type as empty, so a `NOT NULL` column doesn't keep the promise for it unless every member holds the field's type. A built map names no `textSort` yet, so its text sorts in your database's own order.
|
|
21
22
|
|
|
22
|
-
A link table
|
|
23
|
+
A link table, a table of several values and a code table are kinds too, with their own table, key and soft-delete column, and they need no definitions. A relation of several records that names its inverse needs no entry: the far kind's column for the inverse field is read. A lookup, a rollup and a formula are never named: they are worked out from the definitions.
|
|
23
24
|
|
|
24
25
|
## Building the map
|
|
25
26
|
|
|
@@ -87,10 +88,26 @@ assert.throws(
|
|
|
87
88
|
|
|
88
89
|
## The tables it reads and the condition each needs
|
|
89
90
|
|
|
90
|
-
The list's own table is keyed by its kind (`person`). Every table a relation reaches is a far read, keyed `far:<kind>` (`far:company`), one key per kind, and a relation from a kind to itself reads `far:person`, never `person`. So the condition you hand for your list's own table, which may narrow it to one tab or one person's records, never narrows what a relation reads: a far read is held to the condition you hand for that kind as a far read. A link kind and a kind of several values are far reads too.
|
|
91
|
+
The list's own table is keyed by its kind (`person`). Every table a relation reaches is a far read, keyed `far:<kind>` (`far:company`), one key per kind (and one per kind and name a field reads under: [A field read under a condition of its own](#a-field-read-under-a-condition-of-its-own)), and a relation from a kind to itself reads `far:person`, never `person`. So the condition you hand for your list's own table, which may narrow it to one tab or one person's records, never narrows what a relation reads: a far read is held to the condition you hand for that kind as a far read. A link kind and a kind of several values are far reads too.
|
|
91
92
|
|
|
92
93
|
`reads` gives each table key its `kind` and `far`, so you write `access` from it, one condition per key. Every table is opened by the translator under its condition and its soft delete, so a record in the trash or hidden by its condition reads as empty through a relation.
|
|
93
94
|
|
|
95
|
+
## A field read under a condition of its own
|
|
96
|
+
|
|
97
|
+
Every lookup and rollup through a relation reads its far records under the one condition you hand for `far:<kind>`. When a list should show a related record's name to everyone who sees the row, but that record's other fields only to readers who may see the record itself, name those fields in `readUnder`: by kind and field, the name of the condition each reads under.
|
|
98
|
+
|
|
99
|
+
For a list of calls whose `email` and `phone` are lookups through its `person`: `readUnder: { call: { email: "own", phone: "own" } }`. `reads` then holds `far:person`, the call's person by name, and `far:person:own`, their email and phone; your `access` hands `far:person` the condition every reader of the call passes, and `far:person:own` the person's own reach.
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
- A named field reads through tables keyed `far:<kind>:<name>`, which `reads` names (their `kind` is the far kind), so you hand each its own condition in `access` and its own list in `readable`. A request that hands no condition for one of them is refused (`no-condition`), never read under `far:<kind>`'s.
|
|
103
|
+
- Fields given one name share their tables, and one join through each relation: name them alike when they show under one condition, apart when they don't.
|
|
104
|
+
- The relation itself, and every field you don't name, still reads `far:<kind>`: the related record's name shows to whoever sees the row, and a far record the named condition hides reads as no value in the named field, in every filter, sort, search, group, count, figure and read by id.
|
|
105
|
+
- A named rollup opens every table it reads under its name: its far table, the middle one across two relations and a link table. A far field it reads that is itself worked out (a lookup on the far kind, a formula) reads as its own table reads it.
|
|
106
|
+
- It holds wherever the kind is read, as your own entries do: a list of deals reading its calls reads their named fields under the same name, so that map's `reads` names the same key.
|
|
107
|
+
- A named field is held to the named table's list of readable fields for its far field. A named rollup is still held, for the relation it goes over, as that relation is: keep that relation's back column (the lead's `person`) readable on `far:<kind>` too.
|
|
108
|
+
|
|
109
|
+
A relation rule (`person › email`) reads a far field on `far:<kind>`, under that table's condition. So hand `far:<kind>` a list of readable fields without the fields only `far:<kind>:<name>` may show (here `email` and `phone`), or a filter through the relation reads them under `far:<kind>`'s condition. The same list then refuses any unnamed lookup of those fields on another kind: name it too, or let it be refused.
|
|
110
|
+
|
|
94
111
|
## What it reads, as data
|
|
95
112
|
|
|
96
113
|
Each `TableReads` names the table as the database spells it, and `columns`: every column a built read names on it, each once and sorted: its key, its soft-delete column, its label's, and every field's. A guard that checks each list against who owns each table reads it. A field read through your own entry is named in `handWritten` instead: its columns are yours to name.
|
|
@@ -115,7 +132,7 @@ Each `TableReads` names the table as the database spells it, and `columns`: ever
|
|
|
115
132
|
|
|
116
133
|
## Lookups
|
|
117
134
|
|
|
118
|
-
A lookup reads its far record's field through its relation: the far table opened by the translator under the condition you hand for it and its soft delete, so a far record the reader may not see, or one in the trash, reads as no value in a filter, a sort, a search, a group, an option count, a figure and a filter row's values. A lookup of a lookup reads through both, each far table under its own condition. In a read by id a lookup gives its far field's value as that field gives it: a lookup of a user `{ id, label }`, `null` through a far record or a user the reader may not see or in the trash. Each read goes through one LEFT JOIN per relation onto the far table, opened under its own condition and soft delete, shared by every lookup through that relation; a lookup of a lookup joins its second far table inside the first's join, and a list that reads no lookup writes no join. A lookup sorts by its far field's sort: its value, its own `sort`, for a name the name as written, and for a phone its text as typed, trimmed, as a phone sorts. A lookup of a place sorts by its parts as a place does: by its city, its region, its postal code, or its country by name in the request's `language`, else its `locale`, each part read through its far record. A lookup of a range, or of an amount whose currency each record carries, has no single read to sort by and is refused by name.
|
|
135
|
+
A lookup reads its far record's field through its relation: the far table opened by the translator under the condition you hand for it and its soft delete, so a far record the reader may not see, or one in the trash, reads as no value in a filter, a sort, a search, a group, an option count, a figure and a filter row's values. A lookup of a lookup reads through both, each far table under its own condition. In a read by id a lookup gives its far field's value as that field gives it: a lookup of a user `{ id, label }`, `null` through a far record or a user the reader may not see or in the trash. Each read goes through one LEFT JOIN per relation onto the far table, opened under its own condition and soft delete, shared by every lookup through that relation (a lookup named in `readUnder` joins its own named table, shared by the lookups given that name); a lookup of a lookup joins its second far table inside the first's join, and a list that reads no lookup writes no join. A lookup sorts by its far field's sort: its value, its own `sort`, for a name the name as written, and for a phone its text as typed, trimmed, as a phone sorts. A lookup of a place sorts by its parts as a place does: by its city, its region, its postal code, or its country by name in the request's `language`, else its `locale`, each part read through its far record. A lookup of a range, or of an amount whose currency each record carries, has no single read to sort by and is refused by name.
|
|
119
136
|
|
|
120
137
|
## Formulas
|
|
121
138
|
|
|
@@ -181,7 +198,7 @@ Whether a deleted user hides is your own choice, through the soft delete and the
|
|
|
181
198
|
|
|
182
199
|
## How fast it answers
|
|
183
200
|
|
|
184
|
-
A lookup, a user and a relation's name are read through one join of the far table onto the list's rows, and a rollup a sort or a filter reads is worked out for every row at once, so a list sorted or filtered by one of them reads each far table once. A formula and a converted amount are worked out row by row, and a list sorted by one works it out for every row it keeps, not only for the page it shows. A page writes its cursor only for its own rows. Measured over lists of 100,000 rows answered through a built map, every table under a permission condition and about 2 % of rows in the trash, each time the median of 5 calls after one warm-up, against the test kit's database limits (a page of 50 within 100 ms, a total within 500 ms):
|
|
201
|
+
A lookup, a user and a relation's name are read through one join of the far table onto the list's rows, and a rollup a sort or a filter reads is worked out for every row at once, so a list sorted or filtered by one of them reads each far table once (a table read under a name is a table of its own, read once too). A formula and a converted amount are worked out row by row, and a list sorted by one works it out for every row it keeps, not only for the page it shows. A page writes its cursor only for its own rows. Measured over lists of 100,000 rows answered through a built map, every table under a permission condition and about 2 % of rows in the trash, each time the median of 5 calls after one warm-up, against the test kit's database limits (a page of 50 within 100 ms, a total within 500 ms):
|
|
185
202
|
|
|
186
203
|
| A list | Sorted page | Filtered total |
|
|
187
204
|
|---|---|---|
|
|
@@ -218,4 +235,4 @@ The machine measured them under a load average of 15 to 30, so a figure near its
|
|
|
218
235
|
|
|
219
236
|
## What it refuses
|
|
220
237
|
|
|
221
|
-
A storage that says something wrong is refused with a `StorageError` whose `path` names the place in your input (`kinds.person.columns.location`, `defaults.instant`, `kind`), at the first thing it can't hold: an unknown field or kind, a form a field's type can't take, a key it doesn't know on a form, a name Postgres can't read as written, a key whose type nobody says.
|
|
238
|
+
A storage that says something wrong is refused with a `StorageError` whose `path` names the place in your input (`kinds.person.columns.location`, `defaults.instant`, `kind`), at the first thing it can't hold: an unknown field or kind, a form a field's type can't take, a key it doesn't know on a form, a name Postgres can't read as written, a key whose type nobody says. `readUnder` is refused at `readUnder.<kind>.<field>` for a field that is no lookup or rollup, a field with your own entry, or a name other than 1 to 63 letters, digits, `-` and `_`.
|
|
@@ -53,7 +53,7 @@ assert.throws(
|
|
|
53
53
|
An app that lets a workspace make its own objects and fields keeps them in a few tables every object and workspace shares: one of records; one of values per value type (text, an option's id too; number; date; yes-or-no), one row per value, its value never NULL; one per type made of parts (a name, a place, a range, a phone, an amount and its code), its parts in typed columns; and one of links. The map reads them through three optional keys.
|
|
54
54
|
|
|
55
55
|
- **A kind kept in a shared table.** A table's `pick` names the columns that pick its kind's records out of it, each with the value it holds: `{ object_id: "…" }`. It is written inside the table's opening, beside its soft delete and your condition, wherever the table is read, as a far table too. An index for it leads with the pick's columns, or is partial on the pick: `searchIndexes` prints each search index on such a table with the pick as its `where`.
|
|
56
|
-
- **A field of one value kept in a row of its own** (`row`): the table (one of the map's), its column holding the record's key (`record`), the typed column holding the value (`value`), and the `pick` of the field's rows (`{ field_id: "…" }`). An empty value has no row, and a record has at most one row per field of one value: your write path keeps that, as nothing in the table can. Broken anyway, a count, a filter and a search count the record once; a page, a group, figures and the values read it once per row, and a walk still ends. A sort, a group and figures read the row LEFT JOINed onto the record, once per field. The values of given records (`valuesQuery`) bind the keys first and probe each such row by record, a `LEFT JOIN LATERAL (… OFFSET 0)` through the table's index on its record and field (the workspace first when its condition names it), so a page reads only its own records' rows however many fields it shows: a page of 51 companies with 19 fields kept in rows of a table per type, out of 100,000, reads its values in 6.7 ms warm, where a plain join of them read every row of every field first (about a second; 0.4 s from seven fields on). A rule or a search word on such a row under an `or` (a search over a name and the row) is probed by record on a page, so the page stops when it is full. Where the trigram index on the fold of the value column serves it (a `contains` or a search word of three characters or more, on a text), the page first counts the rows that hold it, at most 1,001, through that index: when at most 1,000 do, the record's key is looked up in those rows, a set Postgres hashes, and when more do, each record's row is probed as before. A word few or no rows hold then reads the records once instead of probing each one's row (a million people, a name and a text kept in a table of values: 2.7 s → 0.4 s a page for a word none holds, 0.75 s → 0.12 s for a word in 300 rows), and a common word still stops when the page is full, at the cost of the count (2.1 → 8.2 ms for a word in a tenth of the rows, 2.3 → 4.1 ms for one in a quarter): the trigram index finds every row holding the word before the count can stop. Without that index the count would read the field's rows until 1,001 match, up to all of them, so a word under three characters, an option, a number, a date, a phone and any rule but `contains` are always probed by record. Make the trigram index: without it a word in a few hundred rows is about 15% slower on a page than when every row was probed (0.78 → 0.90 s at a million). A total, capped or exact, reads the matching rows once, as Postgres plans it, which a trigram index on the fold of the value column serves.
|
|
56
|
+
- **A field of one value kept in a row of its own** (`row`): the table (one of the map's), its column holding the record's key (`record`), the typed column holding the value (`value`), and the `pick` of the field's rows (`{ field_id: "…" }`). An empty value has no row, and a record has at most one row per field of one value: your write path keeps that, as nothing in the table can. Broken anyway, a count, a filter and a search count the record once; a page, a group, figures and the values read it once per row, and a walk still ends. A sort, a group and figures read the row LEFT JOINed onto the record, once per field. The values of given records (`valuesQuery`) bind the keys first and probe each such row by record, a `LEFT JOIN LATERAL (… OFFSET 0)` through the table's index on its record and field (the workspace first when its condition names it), so a page reads only its own records' rows however many fields it shows: a page of 51 companies with 19 fields kept in rows of a table per type, out of 100,000, reads its values in 6.7 ms warm, where a plain join of them read every row of every field first (about a second; 0.4 s from seven fields on). A rule or a search word on such a row under an `or` (a search over a name and the row) is probed by record on a page, so the page stops when it is full. Where the trigram index on the fold of the value column serves it (a `contains` or a search word of three characters or more, on a text; a search word on a phone, through its number's and its typed text's indexes), the page first counts the rows that hold it, at most 1,001, through that index: when at most 1,000 do, the record's key is looked up in those rows, a set Postgres hashes, and when more do, each record's row is probed as before. A word few or no rows hold then reads the records once instead of probing each one's row (a million people, a name and a text kept in a table of values: 2.7 s → 0.4 s a page for a word none holds, 0.75 s → 0.12 s for a word in 300 rows), and a common word still stops when the page is full, at the cost of the count (2.1 → 8.2 ms for a word in a tenth of the rows, 2.3 → 4.1 ms for one in a quarter): the trigram index finds every row holding the word before the count can stop. Without that index the count would read the field's rows until 1,001 match, up to all of them, so a word under three characters, an option, a number, a date, a phone's rule and any rule but `contains` are always probed by record. Make the trigram index: without it a word in a few hundred rows is about 15% slower on a page than when every row was probed (0.78 → 0.90 s at a million). A total, capped or exact, reads the matching rows once, as Postgres plans it, which a trigram index on the fold of the value column serves.
|
|
57
57
|
- **A value made of parts kept in its type's own table** (`row.parts`): a name's, a place's or a range's parts, each named as a field's own `parts` are and each a column of the row's table, `{ given: "given", family: "family" }`, with no `value`; a phone's `number` and `extension` as parts, its number as typed as `value`, or both. Every part is read through the row's one join, a rule and a search word by record, as a value of one column is. Keep a part trimmed and a blank part NULL, as fields' own values hold it: a page sorted by a part walks the part as kept, so `''` sorts first among the values and `' Paris'` before `'Amsterdam'`, where a list in memory would trim them.
|
|
58
58
|
- **An amount and its code on one row.** The amount's `row` names its table, its `value` the amount's column; the code field's `row` names the same table, record column and pick, its `value` the code's column. Each is read through its own join of the row, but a sort by the amount, which reads the code through the amount's one join.
|
|
59
59
|
- **Several values or a relation's links in a shared table.** Several values kept as rows of their own and a relation `through` a link table take a `pick` too: `{ field_id: "…" }`, `{ relation_id: "…" }`. Both ends of a relation read the same links, each with its own `from` and `to`. A field's or a link's pick never names a column its table's own pick names.
|
|
@@ -386,7 +386,7 @@ assert.equal(searched.values[0], "ștefan, acme");
|
|
|
386
386
|
assert.ok(searched.values.includes("%stefan%") && searched.values.includes("%acme%"));
|
|
387
387
|
```
|
|
388
388
|
|
|
389
|
-
A field is searched by what a person reads in it. Its `search` read, when the map gives one, is searched as text, whatever the field's type. Otherwise text, a link, a domain, an email and rich text are searched by their own `contains`; a select or a status by its options' labels, an archived option's too, and a value no option names by itself; a relation of one record by its far record's `label`, read under that table's own condition, so a record the condition hides is never found by its label (one kept on a link's lead row, the lead row probed by record); a user read through its users' table by that table's label, under its condition. Numbers, dates, yes-or-no and ranges are never searched. A relation whose far table names no `label` is refused as `no-label`. A phone is searched by its own `contains` rule: a word's separators stripped, compared with its number, or as typed when it isn't in international form. A name, a place, an actor, a user, a field of several values and a relation of several records are refused as `not-yet` unless the map gives them a `search` read, and a text holding a NUL or a lone surrogate, which Postgres can't keep, is refused as `bad-rule` at `search`. Every predicate is true or false, never NULL.
|
|
389
|
+
A field is searched by what a person reads in it. Its `search` read, when the map gives one, is searched as text, whatever the field's type. Otherwise text, a link, a domain, an email and rich text are searched by their own `contains`; a select or a status by its options' labels, an archived option's too, and a value no option names by itself; a relation of one record by its far record's `label`, read under that table's own condition, so a record the condition hides is never found by its label (one kept on a link's lead row, the lead row probed by record); a user read through its users' table by that table's label, under its condition. Numbers, dates, yes-or-no and ranges are never searched. A relation whose far table names no `label` is refused as `no-label`. A phone is searched by its own `contains` rule: a word's separators stripped, compared with its number, or as typed when it isn't in international form. It is written as two arms an index serves, never one chosen row by row: an international phone whose number holds the word, or any other phone whose text as typed holds it; a word holding anything but digits and `+` can't be in an international number, so it reaches the typed text alone. A name, a place, an actor, a user, a field of several values and a relation of several records are refused as `not-yet` unless the map gives them a `search` read, and a text holding a NUL or a lone surrogate, which Postgres can't keep, is refused as `bad-rule` at `search`. Every predicate is true or false, never NULL.
|
|
390
390
|
|
|
391
391
|
### A search over a large list
|
|
392
392
|
|
|
@@ -404,14 +404,15 @@ assert.deepEqual(unserved, []);
|
|
|
404
404
|
|
|
405
405
|
- A text field, a link, a domain, an email, rich text, a field with a `search` read, and a formula with a text result read from the row alone each take a trigram index (`gin_trgm_ops`, from the `pg_trgm` extension, which must be on the migration's search path).
|
|
406
406
|
- A relation of one record takes a trigram index on the far table's folded label and a btree on the relation's column. A uuid, integer or bigint key is served by its primary key; a text key, or one the map doesn't type, by a btree on its lowercased text.
|
|
407
|
+
- A phone takes a trigram index on its folded number, when it keeps one in its `parts`, and one on its folded text as typed: on the record, or on its row's table when it is kept in a row of its own, under that table's pick. A search naming a phone then reads through them and the other fields' indexes (on 20,000 contacts, a search for `ana` over a name and two phones reads a BitmapOr of their three indexes), where before its arm, chosen row by row, made the whole search read every row.
|
|
407
408
|
- A text, a link, a domain, an email or rich text kept in a row of a table of values (`row`) takes one trigram index on that table's folded value column, which serves every field the table holds, so it is printed once with all of them in its `fields`. It carries the table's own pick, never the field's: one index for every field, as the storage test measured (a search for a word nobody holds, on a million people: 5.4 s with no index, 2.6 ms through it).
|
|
408
409
|
- An index on a table many kinds share (its `pick`) is printed with the pick as its `where`, so it holds one kind's rows: on 2,200,000 records half of them people, the people's title index took 21 MB instead of 51 MB, and another kind's writes don't pay for it. Create it with the statistics printed beside it: Postgres reads no statistics from a partial index, so with the index alone a word nobody holds is estimated at thousands of rows, and a page in an index's order walks every record of the kind (657 ms, against 1.0 ms with the statistics).
|
|
409
410
|
- Each trigram index comes with its statistics in `statistics`: run each `statement` as printed, then `ANALYZE` the table (*A "contains" no index serves*, below).
|
|
410
|
-
- A field in `unserved` (a
|
|
411
|
+
- A field in `unserved` (a select or a status, a read through another table such as a lookup through its relation, a read written with a function Postgres won't index) reads every row, and so does any search that names one: a word's fields are ORed, and one arm no index serves makes Postgres read the whole table. A relation whose far table's label no index can hold is named too (`farLabel`), its column's btree still printed: each word reads the far table whole.
|
|
411
412
|
- A word of one or two letters reads every row: a trigram index has nothing to look it up by.
|
|
412
413
|
- The indexes serve a statement Postgres plans with its values, as it plans one sent unnamed (`pg`, Prisma's driver adapters, a transaction pooler). A prepared statement planned generically reads every row, with the same answers.
|
|
413
414
|
- A relation's column, when it is your expression, now runs on every row a search reads, so it must never raise.
|
|
414
|
-
- An index holds only immutable SQL
|
|
415
|
+
- An index holds only immutable SQL. A `search` read, a label or a formula that calls a function Postgres won't index (`concat_ws`, `concat`, `to_char`, `unaccent`, `now()`) is named in `unserved` (`notImmutable`, or `farLabel` for a relation's far label) and never printed. A name kept in parts is labelled in immutable SQL, so its index builds. Write your own label the same way: `COALESCE(given || ' ' || family, given, family)`, not `concat_ws`. A stable cast (text to a date or a timestamp) is not recognised: an index on one is printed, and `CREATE INDEX` refuses it (`42P17`).
|
|
415
416
|
- Each trigram index adds cost to every insert and update on its table, so index only the fields a list searches. Built without `CONCURRENTLY` inside a migration's transaction, an index blocks writes to its table until the migration commits.
|
|
416
417
|
|
|
417
418
|
Measured on a list of about 26,000 records searched across five fields, one a formula and one a relation: with every word of three letters or more, each statement took under 50 ms through its indexes, where reading every row took 110–270 ms.
|
|
@@ -5,8 +5,8 @@ A field map from your definitions and a storage declaration. Guide: [a field map
|
|
|
5
5
|
## Building the map
|
|
6
6
|
|
|
7
7
|
- `buildFieldMap` — the field map for a list of one kind, from your index, your storage and your hand-written entries, checked by `defineFieldMap`; refuses with a `StorageError` a storage it can't hold.
|
|
8
|
-
- `BuildFieldMapInput` — what `buildFieldMap` takes: your index (`defineIndex`), your storage, the kind the list shows, your one money function (`money`), needed when a definition converts an amount,
|
|
9
|
-
- `BuiltFieldMap` — what `buildFieldMap` gives: the checked `map`, every table it reads (`reads`, by its key in the map), and the fields it leaves out (`leftOut`).
|
|
8
|
+
- `BuildFieldMapInput` — what `buildFieldMap` takes: your index (`defineIndex`), your storage, the kind the list shows, your one money function (`money`), needed when a definition converts an amount, your own entry (`handWritten`) for a field the storage can't say, by kind and field, and the lookups and rollups that read under a condition of their own (`readUnder`), by kind and field: the name of that condition, their tables keyed `far:<kind>:<name>`.
|
|
9
|
+
- `BuiltFieldMap` — what `buildFieldMap` gives: the checked `map`, every table it reads (`reads`, by its key in the map; a table read under a name is keyed `far:<kind>:<name>`), and the fields it leaves out (`leftOut`).
|
|
10
10
|
- `TableReads` — a table the map reads: its kind, whether it is read through a relation (`far`), its name as the database spells it, every column a built read names on it (`columns`, sorted), and the fields read through your own entries (`handWritten`).
|
|
11
11
|
- `LeftOut` — a field the map leaves out: its table key, its key and the reason; a request naming it is refused.
|
|
12
12
|
- `StorageError` — a storage refused; `path` names the place in your input.
|
|
@@ -15,7 +15,7 @@ A field map from your definitions and a storage declaration. Guide: [a field map
|
|
|
15
15
|
|
|
16
16
|
- `AppStorage` — where an app keeps its records: each kind of record's storage (`kinds`), what most of them share (`defaults`: how a key is kept, how an instant is kept), and the kind a user field points at (`users`).
|
|
17
17
|
- `KindStorage` — where one kind of record is kept: its table, its key column, how its key is kept, its soft-delete column or null, where a field is kept when not in the column of its own key (`columns`), the fields it keeps nothing for (`notKept`), and the fields whose value is never NULL (`notNull`).
|
|
18
|
-
- `FieldStorage` — where one field is kept: a column; a text kept in a column of another type (`{ column, stored }`); a value's parts (`{ parts }`); a member of a jsonb column (`{ json, path }`); several values as rows of a kind of their own (`{ rows }`, its `main` the column marking a record's main one); several records through a link kind (`{ through }`).
|
|
18
|
+
- `FieldStorage` — where one field is kept: a column; a text kept in a column of another type (`{ column, stored }`); a value kept as another kind's record, its key in `column` and its value in that kind's `value` column (`{ column, from: { kind, value } }`), read under the condition you hand for `far:<kind>`; a value's parts (`{ parts }`); a member of a jsonb column (`{ json, path }`); several values as rows of a kind of their own (`{ rows }`, its `main` the column marking a record's main one); several records through a link kind (`{ through }`).
|
|
19
19
|
|
|
20
20
|
## Your money function
|
|
21
21
|
|