@protobase/schema 0.11.0 → 0.11.1

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
@@ -22,6 +22,7 @@ import { BottomBarNames, bottomBarErrors } from "./bottom-bar-errors.js";
22
22
  import { layout } from "./layout.js";
23
23
  import { KeyType, decodeKey, encodeKey, keyTypes } from "./keys.js";
24
24
  import { addressWords, appPath, readAppPath } from "./app-address.js";
25
+ import { PluginHost, PluginRequirement, inRange, pluginProblem } from "./plugin-version.js";
25
26
  import { addressPlaceholders, appHrefError, fillAddress, hrefPlaceholders, leavesApp } from "./address-template.js";
26
27
  import { AddressCheck, addressErrors } from "./address-errors.js";
27
28
  import { FilterLimits, FilterParse, parseFilter } from "./filter/parse.js";
@@ -41,4 +42,4 @@ import "./access/index.js";
41
42
  import { AssistantAction, AssistantActionRequest, AssistantCardPart, AssistantDiff, AssistantEvent, AssistantMessage, AssistantMessageRequest, AssistantPart, AssistantState, AssistantStep, AssistantStepState, AssistantTablePart, AssistantTextPart, AssistantTone, AssistantWidgetPart } from "./assistant/protocol.js";
42
43
  import { applyAssistantEvent, emptyAssistantState } from "./assistant/apply-event.js";
43
44
  import { readEventStream } from "./assistant/event-stream.js";
44
- export { type AccessAction, type AccessContext, type AccessFn, type AccessResult, type AccessSource, type AccessUser, type ActionModel, type ActionRun, type AddressCheck, type AppAddress, type AssistantAction, type AssistantActionRequest, type AssistantCardPart, type AssistantDiff, type AssistantEvent, type AssistantMessage, type AssistantMessageRequest, type AssistantPart, type AssistantState, type AssistantStep, type AssistantStepState, type AssistantTablePart, type AssistantTextPart, type AssistantTone, type AssistantWidgetPart, type BottomBarItemModel, type BottomBarModel, type BottomBarNames, type BottomBarSource, type Capability, type CapabilityAction, type CapabilityScope, type ChartGranularity, type ChartModel, type ChartRange, type CheckResult, type CheckedFilter, type CompareOp, type ComponentRef, type CustomSectionModel, type DatePreset, type DurationLiteral, type DurationUnit, type EvaluateOptions, type EventActor, type EventContext, type EventHelpers, type EventMatch, type EventModel, type EventOperation, type EventSpec, type Field, type FieldAccess, type FieldFormat, type FieldModel, type FieldPath, type FieldRefValue, type FieldRule, type FieldType, type FieldViewModel, type FileField, type FileFieldModel, type FileProcessor, type FileProcessorInput, type FilterError, type FilterErrorCode, type FilterExpr, type FilterLayout, type FilterLimits, type FilterOf, type FilterParse, type FilterValue, type FilterWidgetModel, type InferRecord, type JsonValue, type KeyType, type KeyValue, type LayoutItemModel, type ListDisplayModel, type ListModel, type ListQuery, type Literal, type NavModel, type NavRecentModel, type NowValue, type OrderByCheck, type OrderByItem, type OrderByParse, type PropShapes, type RecordKey, type RefShape, type RelatedModel, type ResolveOptions, type ResolvedAccess, type ResourceModel, type Roles, type RolesOptions, type RowFilterOperation, type Rule, type SaveFeedback, type SearchMatch, type SearchResultModel, type SearchTerm, type SortSpec, type Span, type StatusTone, type UserMenuItemModel, type UserMenuModel, type UserMenuSource, type ViewModel, type ViewProps, accessWarnings, addressErrors, addressPlaceholders, addressWords, appHrefError, appPath, applyAssistantEvent, bottomBar, bottomBarErrors, bottomBarFor, checkEventFilter, checkFilter, checkOrderBy, checkRecord, checkedAccept, checkedProvider, createWhere, decodeKey, defaultRecentLimit, defineRoles, displayFields, emptyAssistantState, encodeKey, enumLabel, evaluateFilter, f, fieldRef, fieldRefsIn, fieldsUsedBy, fillAddress, hrefPlaceholders, isFieldRef, keyTypes, layout as l, leavesApp, markFieldRefs, matchedSearchField, matchesSearch, maxBottomBarItems, navRecentErrors, parseFilter, parseOrderBy, parseSize, pickView, printFilter, printOrderBy, pruneByShape, readAppPath, readEventStream, resolveAccess, resource, restrictModel, rule, searchTerms, shapes, statusTones, tableDisplay, termMatches, unmarkFieldRefs, userMenu, view, webhookResources, where };
45
+ export { type AccessAction, type AccessContext, type AccessFn, type AccessResult, type AccessSource, type AccessUser, type ActionModel, type ActionRun, type AddressCheck, type AppAddress, type AssistantAction, type AssistantActionRequest, type AssistantCardPart, type AssistantDiff, type AssistantEvent, type AssistantMessage, type AssistantMessageRequest, type AssistantPart, type AssistantState, type AssistantStep, type AssistantStepState, type AssistantTablePart, type AssistantTextPart, type AssistantTone, type AssistantWidgetPart, type BottomBarItemModel, type BottomBarModel, type BottomBarNames, type BottomBarSource, type Capability, type CapabilityAction, type CapabilityScope, type ChartGranularity, type ChartModel, type ChartRange, type CheckResult, type CheckedFilter, type CompareOp, type ComponentRef, type CustomSectionModel, type DatePreset, type DurationLiteral, type DurationUnit, type EvaluateOptions, type EventActor, type EventContext, type EventHelpers, type EventMatch, type EventModel, type EventOperation, type EventSpec, type Field, type FieldAccess, type FieldFormat, type FieldModel, type FieldPath, type FieldRefValue, type FieldRule, type FieldType, type FieldViewModel, type FileField, type FileFieldModel, type FileProcessor, type FileProcessorInput, type FilterError, type FilterErrorCode, type FilterExpr, type FilterLayout, type FilterLimits, type FilterOf, type FilterParse, type FilterValue, type FilterWidgetModel, type InferRecord, type JsonValue, type KeyType, type KeyValue, type LayoutItemModel, type ListDisplayModel, type ListModel, type ListQuery, type Literal, type NavModel, type NavRecentModel, type NowValue, type OrderByCheck, type OrderByItem, type OrderByParse, type PluginHost, type PluginRequirement, type PropShapes, type RecordKey, type RefShape, type RelatedModel, type ResolveOptions, type ResolvedAccess, type ResourceModel, type Roles, type RolesOptions, type RowFilterOperation, type Rule, type SaveFeedback, type SearchMatch, type SearchResultModel, type SearchTerm, type SortSpec, type Span, type StatusTone, type UserMenuItemModel, type UserMenuModel, type UserMenuSource, type ViewModel, type ViewProps, accessWarnings, addressErrors, addressPlaceholders, addressWords, appHrefError, appPath, applyAssistantEvent, bottomBar, bottomBarErrors, bottomBarFor, checkEventFilter, checkFilter, checkOrderBy, checkRecord, checkedAccept, checkedProvider, createWhere, decodeKey, defaultRecentLimit, defineRoles, displayFields, emptyAssistantState, encodeKey, enumLabel, evaluateFilter, f, fieldRef, fieldRefsIn, fieldsUsedBy, fillAddress, hrefPlaceholders, inRange, isFieldRef, keyTypes, layout as l, leavesApp, markFieldRefs, matchedSearchField, matchesSearch, maxBottomBarItems, navRecentErrors, parseFilter, parseOrderBy, parseSize, pickView, pluginProblem, printFilter, printOrderBy, pruneByShape, readAppPath, readEventStream, resolveAccess, resource, restrictModel, rule, searchTerms, shapes, statusTones, tableDisplay, termMatches, unmarkFieldRefs, userMenu, view, webhookResources, where };
package/dist/index.js CHANGED
@@ -24,6 +24,7 @@ import { bottomBar, bottomBarFor, maxBottomBarItems } from "./bottom-bar.js";
24
24
  import { bottomBarErrors } from "./bottom-bar-errors.js";
25
25
  import { decodeKey, encodeKey, keyTypes } from "./keys.js";
26
26
  import { addressWords, appPath, readAppPath } from "./app-address.js";
27
+ import { inRange, pluginProblem } from "./plugin-version.js";
27
28
  import { addressErrors } from "./address-errors.js";
28
29
  import { rule } from "./access/rule.js";
29
30
  import { defineRoles } from "./access/roles.js";
@@ -31,4 +32,4 @@ import { pickView } from "./access/pick-view.js";
31
32
  import { restrictModel } from "./access/restrict.js";
32
33
  import { applyAssistantEvent, emptyAssistantState } from "./assistant/apply-event.js";
33
34
  import { readEventStream } from "./assistant/event-stream.js";
34
- export { accessWarnings, addressErrors, addressPlaceholders, addressWords, appHrefError, appPath, applyAssistantEvent, bottomBar, bottomBarErrors, bottomBarFor, checkEventFilter, checkFilter, checkOrderBy, checkRecord, checkedAccept, checkedProvider, createWhere, decodeKey, defaultRecentLimit, defineRoles, displayFields, emptyAssistantState, encodeKey, enumLabel, evaluateFilter, f, fieldRef, fieldRefsIn, fieldsUsedBy, fillAddress, hrefPlaceholders, isFieldRef, keyTypes, layout as l, leavesApp, markFieldRefs, matchedSearchField, matchesSearch, maxBottomBarItems, navRecentErrors, parseFilter, parseOrderBy, parseSize, pickView, printFilter, printOrderBy, pruneByShape, readAppPath, readEventStream, resolveAccess, resource, restrictModel, rule, searchTerms, shapes, statusTones, tableDisplay, termMatches, unmarkFieldRefs, userMenu, view, webhookResources, where };
35
+ export { accessWarnings, addressErrors, addressPlaceholders, addressWords, appHrefError, appPath, applyAssistantEvent, bottomBar, bottomBarErrors, bottomBarFor, checkEventFilter, checkFilter, checkOrderBy, checkRecord, checkedAccept, checkedProvider, createWhere, decodeKey, defaultRecentLimit, defineRoles, displayFields, emptyAssistantState, encodeKey, enumLabel, evaluateFilter, f, fieldRef, fieldRefsIn, fieldsUsedBy, fillAddress, hrefPlaceholders, inRange, isFieldRef, keyTypes, layout as l, leavesApp, markFieldRefs, matchedSearchField, matchesSearch, maxBottomBarItems, navRecentErrors, parseFilter, parseOrderBy, parseSize, pickView, pluginProblem, printFilter, printOrderBy, pruneByShape, readAppPath, readEventStream, resolveAccess, resource, restrictModel, rule, searchTerms, shapes, statusTones, tableDisplay, termMatches, unmarkFieldRefs, userMenu, view, webhookResources, where };
@@ -0,0 +1,22 @@
1
+ //#region src/plugin-version.d.ts
2
+ /**
3
+ * Whether `version` is in `range`: comparators such as `>=0.12.0 <1.0.0`, separated by spaces, all of which must hold.
4
+ * Undefined when the range is not one of those, or the version is no x.y.z version.
5
+ */
6
+ export declare const inRange: (version: string, range: string) => boolean | undefined;
7
+ /** What a plugin's plugin.json says it is built for: a plugin API, and the Protobase versions it runs on. */
8
+ export type PluginRequirement = {
9
+ api: number;
10
+ protobase: string;
11
+ };
12
+ /** An app that loads plugins: the plugin API its @protobase/ui provides, and its Protobase version. */
13
+ export type PluginHost = {
14
+ api: number;
15
+ version: string;
16
+ };
17
+ /**
18
+ * Why an app does not load a plugin built for `requirement`, or undefined when it does: the plugin API must be the
19
+ * app's, and the app's Protobase version in the plugin's range.
20
+ */
21
+ export declare const pluginProblem: (requirement: PluginRequirement, host: PluginHost) => string | undefined;
22
+ //#endregion
@@ -0,0 +1,48 @@
1
+ //#region src/plugin-version.ts
2
+ const versionPattern = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
3
+ const parseVersion = (text) => {
4
+ const match = versionPattern.exec(text);
5
+ return match ? [
6
+ Number(match[1]),
7
+ Number(match[2]),
8
+ Number(match[3])
9
+ ] : void 0;
10
+ };
11
+ const compare = (a, b) => a[0] - b[0] || a[1] - b[1] || a[2] - b[2];
12
+ const comparatorPattern = /^(>=|<=|>|<|=)?(.+)$/;
13
+ const holds = {
14
+ ">=": (order) => order >= 0,
15
+ "<=": (order) => order <= 0,
16
+ ">": (order) => order > 0,
17
+ "<": (order) => order < 0,
18
+ "=": (order) => order === 0
19
+ };
20
+ /**
21
+ * Whether `version` is in `range`: comparators such as `>=0.12.0 <1.0.0`, separated by spaces, all of which must hold.
22
+ * Undefined when the range is not one of those, or the version is no x.y.z version.
23
+ */
24
+ const inRange = (version, range) => {
25
+ const own = parseVersion(version);
26
+ const comparators = range.trim().split(/\s+/);
27
+ if (!own || range.trim() === "") return void 0;
28
+ let result = true;
29
+ for (const comparator of comparators) {
30
+ const [, operator = "=", text = ""] = comparatorPattern.exec(comparator) ?? [];
31
+ const bound = parseVersion(text);
32
+ if (!bound) return void 0;
33
+ result &&= holds[operator](compare(own, bound));
34
+ }
35
+ return result;
36
+ };
37
+ /**
38
+ * Why an app does not load a plugin built for `requirement`, or undefined when it does: the plugin API must be the
39
+ * app's, and the app's Protobase version in the plugin's range.
40
+ */
41
+ const pluginProblem = (requirement, host) => {
42
+ if (requirement.api !== host.api) return `it is built for plugin API ${requirement.api}, and this app has plugin API ${host.api}`;
43
+ const fits = inRange(host.version, requirement.protobase);
44
+ if (fits === void 0) return `its Protobase range "${requirement.protobase}" is not one this app reads, such as >=0.12.0`;
45
+ if (!fits) return `it needs Protobase ${requirement.protobase}, and this app runs ${host.version}`;
46
+ };
47
+ //#endregion
48
+ export { inRange, pluginProblem };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/schema",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "Resource, field, view and access definitions for Protobase configs.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {