@protobase/schema 0.121.8 → 0.121.9

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.
@@ -15,6 +15,8 @@ export type BucketsModel = {
15
15
  by: string[];
16
16
  /** The number fields of `from` it keeps, with what it keeps of each, as the fields `<name>_sum` and `<name>_max`. */
17
17
  measures: Record<string, BucketMeasure[]>;
18
+ /** The measured fields of `from` that are optional: `events` counts their records without a value too, so a bucket cannot give their average. */
19
+ optional: string[];
18
20
  /** How late a record may arrive and still be counted by a refresh, such as `2 hours`. */
19
21
  late: string;
20
22
  };
@@ -0,0 +1,9 @@
1
+ import { BucketMeasure, BucketsModel } from "./buckets-model.js";
2
+ import "../refs.js";
3
+ //#region src/buckets/buckets-of.d.ts
4
+ /** The source field and measure that a time rollup's field `name`, such as `watts_sum`, keeps; `undefined` for any other field. */
5
+ export declare const keptMeasure: (buckets: BucketsModel, name: string) => {
6
+ field: string;
7
+ measure: BucketMeasure;
8
+ } | undefined;
9
+ //#endregion
@@ -61,6 +61,16 @@ const sumField = (field, declared) => {
61
61
  };
62
62
  /** The names of the measure fields of a time rollup, by source field and measure. */
63
63
  const measureFieldName = (field, measure) => `${field}_${measure}`;
64
+ /** The source field and measure that a time rollup's field `name`, such as `watts_sum`, keeps; `undefined` for any other field. */
65
+ const keptMeasure = (buckets, name) => {
66
+ for (const [field, fns] of Object.entries(buckets.measures)) {
67
+ const measure = fns.find((fn) => measureFieldName(field, fn) === name);
68
+ if (measure) return {
69
+ field,
70
+ measure
71
+ };
72
+ }
73
+ };
64
74
  const timeProblems = (source, time) => {
65
75
  const field = source.fields[time];
66
76
  if (!field) return [`time "${time}" is not a field of "${source.name}"`];
@@ -135,9 +145,10 @@ const bucketsState = (name, source, buckets) => {
135
145
  buckets: {
136
146
  ...buckets,
137
147
  by: [...buckets.by],
138
- measures: Object.fromEntries(Object.entries(buckets.measures).map(([field, fns]) => [field, [...fns]]))
148
+ measures: Object.fromEntries(Object.entries(buckets.measures).map(([field, fns]) => [field, [...fns]])),
149
+ optional: Object.keys(buckets.measures).filter((field) => model.fields[field].nullable)
139
150
  }
140
151
  };
141
152
  };
142
153
  //#endregion
143
- export { bucketsState, measureFieldName };
154
+ export { bucketsState, keptMeasure, measureFieldName };
@@ -68,4 +68,5 @@ import { guestCallsPath } from "./calls/call-guests.js";
68
68
  import { CallRing, callsChannelEvent, declineWord, ringNotice, ringsPath } from "./calls/call-rings.js";
69
69
  import { ReorderSpan, reorderSpan } from "./reorder-span.js";
70
70
  import { MovePlan, Ranked, movePlan } from "./move-plan.js";
71
- export { type AddressCheck, type Availability, type CallCandidate, type CallClientMessage, type CallDescription, type CallGuestLink, type CallGuestRefusal, type CallGuestState, type CallLeftReason, type CallLobbyGuest, type CallMode, type CallRemoteTrack, type CallResume, type CallRing, type CallRosterMember, type CallServerMessage, type CallTrackRequest, type CallTrackSource, type CallVideoLayer, type FormulaNode, type KeyType, type Locale, type MobileReleaseAnswer, type MovePlan, type PathLookup, type PersonStatus, type PluginCapabilities, type PluginHost, type PluginRequirement, type PropShapes, type Ranked, type RecordUse, type RefShape, type ReleaseBinding, type ReorderSpan, type RunnerRegistration, type SearchTerm, type StatusInput, type TemplatePath, type WorkflowCacheAdvice, type WorkflowRunTrace, type WorkflowStatus, type WorkflowTraceHeld, type WorkflowTraceStep, type WorkflowTypeEntry, type WorkflowTypeList, actionConditionError, actionInputErrors, addressErrors, addressPlaceholders, apiOriginMeta, appHrefError, appReadMaxBytes, appReadParam, appReadUrl, applyAssistantEvent, authBasePath, availabilities, bareFilterFields, boardErrors, bottomBarFor, bridgeSocketPath, bridgeTokenParam, builtInFieldTypes, callsChannelEvent, capacitorOrigin, cardPhotoLimit, chartFields, checkEventFilter, checkedAccept, checkedProvider, confirmationMinutes, datesErrors, declineWord, decodeKey, defaultRecentLimit, deviceIdParam, devicesPath, displayFields, emailCodeMinutes, embeddedFilterFields, emptyAssistantState, encodeKey, fieldRefsIn, filePath, filesPath, fillAddress, fillAddressFrom, fillFilter, fillText, filterField, findField, firstPartyCodeKey, followableRowButton, grantsOf, guestCallsPath, heldCapabilities, heldStatus, historyIdParam, historyIdPattern, historyPath, hostPlaceholder, hrefField, hrefPlaceholders, humanize, inRange, isAppRead, isFieldRef, isGroupChart, isLocale, isUserTableName, keyTypes, labelFieldOf, layoutItems, leavesApp, linkActionError, listColumnNames, locales, lookupLink, markFieldRefs, matchedSearchField, matchesSearch, maxLabelLength, maxNameBytes, maxOrganizationNameBytes, maxRelatedDepth, maxRelatedTerms, maxStatusText, missingCapabilities, mobileReleaseBasePath, mobileReleaseParams, mobileReleasePath, mobileReleaseQuery, mobileReleasesPath, movePlan, navRecentErrors, navStartErrors, organizationColumn, parseCapability, parseFormula, parseSize, parseTable, parseTemplatePath, pickLocale, pluginProblem, promptError, promptFields, pruneByShape, pushRecord, readEventStream, recordJsonSchema, recordTitle, recordTitleField, recordValueAt, redactSecrets, relatedErrors, relatedTarget, releaseManifestFile, releaseStatementContext, releaseStatementFile, renderPrompt, reorderSpan, reservedFieldNames, reservedWords, resolvableStatuses, resourceField, ringNotice, ringsPath, rowButtonChoiceFields, rowButtonChoices, rowButtonErrors, rowButtonFields, rowButtonTarget, runnerRegistrationParam, runnerRegistrationPath, runnerRegistrationRoute, searchTerms, secondStepParam, serviceWorkerFile, shapes, shownInputs, splitRelated, statusPath, statusRuns, statusTextProblem, statusTones, storageNamePattern, storedFileRef, tableDisplay, tapUrl, templatePlaceholders, termMatches, textPlaceholders, unmarkFieldRefs, updateSetErrors, updateValues, userTableName, valueText, viewOfList, webhookResources, wholePlaceholder, withLookups, workflowResources, workflowRunParam, workflowRunTracePath, workflowRunTraceRoute, workflowRunsPath, workflowStatusTones, workflowStatuses, workflowTraceAfterParam, workflowTraceRevision, workflowTraceRevisionParam, workflowTypesPath };
71
+ import { keptMeasure } from "./buckets/buckets-of.js";
72
+ export { type AddressCheck, type Availability, type CallCandidate, type CallClientMessage, type CallDescription, type CallGuestLink, type CallGuestRefusal, type CallGuestState, type CallLeftReason, type CallLobbyGuest, type CallMode, type CallRemoteTrack, type CallResume, type CallRing, type CallRosterMember, type CallServerMessage, type CallTrackRequest, type CallTrackSource, type CallVideoLayer, type FormulaNode, type KeyType, type Locale, type MobileReleaseAnswer, type MovePlan, type PathLookup, type PersonStatus, type PluginCapabilities, type PluginHost, type PluginRequirement, type PropShapes, type Ranked, type RecordUse, type RefShape, type ReleaseBinding, type ReorderSpan, type RunnerRegistration, type SearchTerm, type StatusInput, type TemplatePath, type WorkflowCacheAdvice, type WorkflowRunTrace, type WorkflowStatus, type WorkflowTraceHeld, type WorkflowTraceStep, type WorkflowTypeEntry, type WorkflowTypeList, actionConditionError, actionInputErrors, addressErrors, addressPlaceholders, apiOriginMeta, appHrefError, appReadMaxBytes, appReadParam, appReadUrl, applyAssistantEvent, authBasePath, availabilities, bareFilterFields, boardErrors, bottomBarFor, bridgeSocketPath, bridgeTokenParam, builtInFieldTypes, callsChannelEvent, capacitorOrigin, cardPhotoLimit, chartFields, checkEventFilter, checkedAccept, checkedProvider, confirmationMinutes, datesErrors, declineWord, decodeKey, defaultRecentLimit, deviceIdParam, devicesPath, displayFields, emailCodeMinutes, embeddedFilterFields, emptyAssistantState, encodeKey, fieldRefsIn, filePath, filesPath, fillAddress, fillAddressFrom, fillFilter, fillText, filterField, findField, firstPartyCodeKey, followableRowButton, grantsOf, guestCallsPath, heldCapabilities, heldStatus, historyIdParam, historyIdPattern, historyPath, hostPlaceholder, hrefField, hrefPlaceholders, humanize, inRange, isAppRead, isFieldRef, isGroupChart, isLocale, isUserTableName, keptMeasure, keyTypes, labelFieldOf, layoutItems, leavesApp, linkActionError, listColumnNames, locales, lookupLink, markFieldRefs, matchedSearchField, matchesSearch, maxLabelLength, maxNameBytes, maxOrganizationNameBytes, maxRelatedDepth, maxRelatedTerms, maxStatusText, missingCapabilities, mobileReleaseBasePath, mobileReleaseParams, mobileReleasePath, mobileReleaseQuery, mobileReleasesPath, movePlan, navRecentErrors, navStartErrors, organizationColumn, parseCapability, parseFormula, parseSize, parseTable, parseTemplatePath, pickLocale, pluginProblem, promptError, promptFields, pruneByShape, pushRecord, readEventStream, recordJsonSchema, recordTitle, recordTitleField, recordValueAt, redactSecrets, relatedErrors, relatedTarget, releaseManifestFile, releaseStatementContext, releaseStatementFile, renderPrompt, reorderSpan, reservedFieldNames, reservedWords, resolvableStatuses, resourceField, ringNotice, ringsPath, rowButtonChoiceFields, rowButtonChoices, rowButtonErrors, rowButtonFields, rowButtonTarget, runnerRegistrationParam, runnerRegistrationPath, runnerRegistrationRoute, searchTerms, secondStepParam, serviceWorkerFile, shapes, shownInputs, splitRelated, statusPath, statusRuns, statusTextProblem, statusTones, storageNamePattern, storedFileRef, tableDisplay, tapUrl, templatePlaceholders, termMatches, textPlaceholders, unmarkFieldRefs, updateSetErrors, updateValues, userTableName, valueText, viewOfList, webhookResources, wholePlaceholder, withLookups, workflowResources, workflowRunParam, workflowRunTracePath, workflowRunTraceRoute, workflowRunsPath, workflowStatusTones, workflowStatuses, workflowTraceAfterParam, workflowTraceRevision, workflowTraceRevisionParam, workflowTypesPath };
package/dist/internal.js CHANGED
@@ -9,6 +9,7 @@ import { matchedSearchField, matchesSearch, searchTerms, termMatches } from "./s
9
9
  import { grantsOf, parseCapability } from "./access/capability.js";
10
10
  import { heldCapabilities } from "./access/role-entry.js";
11
11
  import { checkEventFilter } from "./events/event-models.js";
12
+ import { keptMeasure } from "./buckets/buckets-of.js";
12
13
  import { parseTable } from "./resource-model.js";
13
14
  import { layoutItems } from "./layout-items.js";
14
15
  import { viewOfList } from "./named-list.js";
@@ -67,4 +68,4 @@ import { guestCallsPath } from "./calls/call-guests.js";
67
68
  import { callsChannelEvent, declineWord, ringNotice, ringsPath } from "./calls/call-rings.js";
68
69
  import { reorderSpan } from "./reorder-span.js";
69
70
  import { movePlan } from "./move-plan.js";
70
- export { actionConditionError, actionInputErrors, addressErrors, addressPlaceholders, apiOriginMeta, appHrefError, appReadMaxBytes, appReadParam, appReadUrl, applyAssistantEvent, authBasePath, availabilities, bareFilterFields, boardErrors, bottomBarFor, bridgeSocketPath, bridgeTokenParam, builtInFieldTypes, callsChannelEvent, capacitorOrigin, cardPhotoLimit, chartFields, checkEventFilter, checkedAccept, checkedProvider, confirmationMinutes, datesErrors, declineWord, decodeKey, defaultRecentLimit, deviceIdParam, devicesPath, displayFields, emailCodeMinutes, embeddedFilterFields, emptyAssistantState, encodeKey, fieldRefsIn, filePath, filesPath, fillAddress, fillAddressFrom, fillFilter, fillText, filterField, findField, firstPartyCodeKey, followableRowButton, grantsOf, guestCallsPath, heldCapabilities, heldStatus, historyIdParam, historyIdPattern, historyPath, hostPlaceholder, hrefField, hrefPlaceholders, humanize, inRange, isAppRead, isFieldRef, isGroupChart, isLocale, isUserTableName, keyTypes, labelFieldOf, layoutItems, leavesApp, linkActionError, listColumnNames, locales, lookupLink, markFieldRefs, matchedSearchField, matchesSearch, maxLabelLength, maxNameBytes, maxOrganizationNameBytes, maxRelatedDepth, maxRelatedTerms, maxStatusText, missingCapabilities, mobileReleaseBasePath, mobileReleaseParams, mobileReleasePath, mobileReleaseQuery, mobileReleasesPath, movePlan, navRecentErrors, navStartErrors, organizationColumn, parseCapability, parseFormula, parseSize, parseTable, parseTemplatePath, pickLocale, pluginProblem, promptError, promptFields, pruneByShape, pushRecord, readEventStream, recordJsonSchema, recordTitle, recordTitleField, recordValueAt, redactSecrets, relatedErrors, relatedTarget, releaseManifestFile, releaseStatementContext, releaseStatementFile, renderPrompt, reorderSpan, reservedFieldNames, reservedWords, resolvableStatuses, resourceField, ringNotice, ringsPath, rowButtonChoiceFields, rowButtonChoices, rowButtonErrors, rowButtonFields, rowButtonTarget, runnerRegistrationParam, runnerRegistrationPath, runnerRegistrationRoute, searchTerms, secondStepParam, serviceWorkerFile, shapes, shownInputs, splitRelated, statusPath, statusRuns, statusTextProblem, statusTones, storageNamePattern, storedFileRef, tableDisplay, tapUrl, templatePlaceholders, termMatches, textPlaceholders, unmarkFieldRefs, updateSetErrors, updateValues, userTableName, valueText, viewOfList, webhookResources, wholePlaceholder, withLookups, workflowResources, workflowRunParam, workflowRunTracePath, workflowRunTraceRoute, workflowRunsPath, workflowStatusTones, workflowStatuses, workflowTraceAfterParam, workflowTraceRevision, workflowTraceRevisionParam, workflowTypesPath };
71
+ export { actionConditionError, actionInputErrors, addressErrors, addressPlaceholders, apiOriginMeta, appHrefError, appReadMaxBytes, appReadParam, appReadUrl, applyAssistantEvent, authBasePath, availabilities, bareFilterFields, boardErrors, bottomBarFor, bridgeSocketPath, bridgeTokenParam, builtInFieldTypes, callsChannelEvent, capacitorOrigin, cardPhotoLimit, chartFields, checkEventFilter, checkedAccept, checkedProvider, confirmationMinutes, datesErrors, declineWord, decodeKey, defaultRecentLimit, deviceIdParam, devicesPath, displayFields, emailCodeMinutes, embeddedFilterFields, emptyAssistantState, encodeKey, fieldRefsIn, filePath, filesPath, fillAddress, fillAddressFrom, fillFilter, fillText, filterField, findField, firstPartyCodeKey, followableRowButton, grantsOf, guestCallsPath, heldCapabilities, heldStatus, historyIdParam, historyIdPattern, historyPath, hostPlaceholder, hrefField, hrefPlaceholders, humanize, inRange, isAppRead, isFieldRef, isGroupChart, isLocale, isUserTableName, keptMeasure, keyTypes, labelFieldOf, layoutItems, leavesApp, linkActionError, listColumnNames, locales, lookupLink, markFieldRefs, matchedSearchField, matchesSearch, maxLabelLength, maxNameBytes, maxOrganizationNameBytes, maxRelatedDepth, maxRelatedTerms, maxStatusText, missingCapabilities, mobileReleaseBasePath, mobileReleaseParams, mobileReleasePath, mobileReleaseQuery, mobileReleasesPath, movePlan, navRecentErrors, navStartErrors, organizationColumn, parseCapability, parseFormula, parseSize, parseTable, parseTemplatePath, pickLocale, pluginProblem, promptError, promptFields, pruneByShape, pushRecord, readEventStream, recordJsonSchema, recordTitle, recordTitleField, recordValueAt, redactSecrets, relatedErrors, relatedTarget, releaseManifestFile, releaseStatementContext, releaseStatementFile, renderPrompt, reorderSpan, reservedFieldNames, reservedWords, resolvableStatuses, resourceField, ringNotice, ringsPath, rowButtonChoiceFields, rowButtonChoices, rowButtonErrors, rowButtonFields, rowButtonTarget, runnerRegistrationParam, runnerRegistrationPath, runnerRegistrationRoute, searchTerms, secondStepParam, serviceWorkerFile, shapes, shownInputs, splitRelated, statusPath, statusRuns, statusTextProblem, statusTones, storageNamePattern, storedFileRef, tableDisplay, tapUrl, templatePlaceholders, termMatches, textPlaceholders, unmarkFieldRefs, updateSetErrors, updateValues, userTableName, valueText, viewOfList, webhookResources, wholePlaceholder, withLookups, workflowResources, workflowRunParam, workflowRunTracePath, workflowRunTraceRoute, workflowRunsPath, workflowStatusTones, workflowStatuses, workflowTraceAfterParam, workflowTraceRevision, workflowTraceRevisionParam, workflowTypesPath };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/schema",
3
- "version": "0.121.8",
3
+ "version": "0.121.9",
4
4
  "description": "Resource, field, view and access definitions for Protobase configs.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {