@protobase/schema 0.63.5 → 0.64.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assistant/event-stream.js +5 -15
- package/dist/badge-tones.d.ts +8 -0
- package/dist/badge-tones.js +14 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/model.d.ts +11 -4
- package/dist/view-field.d.ts +12 -5
- package/dist/view-field.js +17 -6
- package/dist/webhooks/webhook-resources.js +2 -1
- package/package.json +2 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createParser } from "eventsource-parser";
|
|
1
2
|
//#region src/assistant/event-stream.ts
|
|
2
3
|
/**
|
|
3
4
|
* Reads a `text/event-stream` body and calls `onData` with the data of every event, its `data:` lines joined by
|
|
@@ -5,27 +6,16 @@
|
|
|
5
6
|
* Aborting `signal` cancels the body and resolves.
|
|
6
7
|
*/
|
|
7
8
|
const readEventStream = async (body, onData, signal) => {
|
|
9
|
+
const parser = createParser({ onEvent: (event) => onData(event.data) });
|
|
8
10
|
const decoder = new TextDecoder();
|
|
9
11
|
const reader = body.getReader();
|
|
10
12
|
signal?.addEventListener("abort", () => void reader.cancel(), { once: true });
|
|
11
|
-
let buffer = "";
|
|
12
|
-
let data = [];
|
|
13
|
-
const line = (text) => {
|
|
14
|
-
if (text === "") {
|
|
15
|
-
if (data.length > 0) onData(data.join("\n"));
|
|
16
|
-
data = [];
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
if (text.startsWith("data:")) data.push(text.slice(text.startsWith("data: ") ? 6 : 5));
|
|
20
|
-
};
|
|
21
13
|
for (;;) {
|
|
22
14
|
const { done, value } = await reader.read();
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
buffer = done ? "" : lines.pop() ?? "";
|
|
26
|
-
lines.forEach(line);
|
|
27
|
-
if (done) return line("");
|
|
15
|
+
if (done) break;
|
|
16
|
+
parser.feed(decoder.decode(value, { stream: true }));
|
|
28
17
|
}
|
|
18
|
+
parser.feed(`${decoder.decode()}\n\n`);
|
|
29
19
|
};
|
|
30
20
|
//#endregion
|
|
31
21
|
export { readEventStream };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/badge-tones.d.ts
|
|
2
|
+
/** The tones an enum value's badge takes by name in `valueColors`; a value without one is `neutral`. */
|
|
3
|
+
export declare const badgeTones: readonly ["neutral", "blue", "green", "amber", "red", "violet"];
|
|
4
|
+
/** A badge's tone by name, one of `badgeTones`. */
|
|
5
|
+
export type BadgeTone = (typeof badgeTones)[number];
|
|
6
|
+
/** Whether `name` is one of the badge tones, rather than a hex colour. */
|
|
7
|
+
export declare const isBadgeTone: (name: string) => name is BadgeTone;
|
|
8
|
+
//#endregion
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/badge-tones.ts
|
|
2
|
+
/** The tones an enum value's badge takes by name in `valueColors`; a value without one is `neutral`. */
|
|
3
|
+
const badgeTones = [
|
|
4
|
+
"neutral",
|
|
5
|
+
"blue",
|
|
6
|
+
"green",
|
|
7
|
+
"amber",
|
|
8
|
+
"red",
|
|
9
|
+
"violet"
|
|
10
|
+
];
|
|
11
|
+
/** Whether `name` is one of the badge tones, rather than a hex colour. */
|
|
12
|
+
const isBadgeTone = (name) => badgeTones.includes(name);
|
|
13
|
+
//#endregion
|
|
14
|
+
export { badgeTones, isBadgeTone };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Rollup, RollupCount, RollupFn, RollupSource, RollupValue } from "./computed/rollup.js";
|
|
2
2
|
import { FileOptions, FileProcessor, FileProcessorInput, ImageFormat, ImageVariant, ImageVariantOptions, imageFormats } from "./files/file-options.js";
|
|
3
|
+
import { BadgeTone, badgeTones, isBadgeTone } from "./badge-tones.js";
|
|
3
4
|
import { ActionInputKind, ActionInputModel, ActionModel, ActionRun, AppAddress, BadgeShape, BottomBarItemModel, BottomBarModel, CalendarView, CardFavoriteModel, CardPhotosModel, ChartGranularity, ChartModel, ChartRange, CheckedFilter, CommentsSectionModel, CompareOp, CreateModel, CustomSectionModel, DatePreset, DurationLiteral, DurationUnit, EventModel, EventOperation, ExportModel, FieldFormat, FieldModel, FieldPath, FieldType, FieldViewModel, FieldWidgetModel, FileFieldModel, FilterError, FilterErrorCode, FilterExpr, FilterLayout, FilterOf, FilterValue, FilterWidgetModel, FormModel, GalleryModel, GroupChartModel, GroupItemModel, GroupModel, HelpWhen, HistorySectionModel, JsonValue, KeyValue, LayoutItemModel, ListDisplayModel, ListDragModel, ListModel, ListQuery, Literal, MapSectionModel, MapView, NamedListModel, NavModel, NavRecentModel, NowValue, OrderByItem, ParentAccess, ParentModel, PeriodChartModel, PositionAfterModel, RecordChartModel, RecordChartRange, RecordMode, RecordPageModel, RecordWhen, RelatedColumnModel, RelatedModel, RelatedPresentation, ResourceModel, SaveFeedback, SaveSearchModel, SearchMatch, SearchResultModel, SearchesOfModel, SectionModel, SectionPresentation, ShowWhen, SignInPromptModel, SignInViewModel, SortSpec, Span, StatusTone, TabItemModel, TabModel, TimelineView, TitleFromModel, UserMenuItemModel, UserMenuModel, ViewModel } from "./model.js";
|
|
4
5
|
import { AccessAction, AccessContext, AccessFn, AccessResult, AccessUser, FieldAccess, FieldRule } from "./access/types.js";
|
|
5
6
|
import { Encrypted, encrypted } from "./encrypted-value.js";
|
|
@@ -47,4 +48,4 @@ import { AccessSource, ResolveOptions, ResolvedAccess, RowFilterOperation, acces
|
|
|
47
48
|
import { restrictModel } from "./access/restrict.js";
|
|
48
49
|
import "./access/index.js";
|
|
49
50
|
import { AssistantAction, AssistantActionRequest, AssistantCardPart, AssistantDiff, AssistantEvent, AssistantMessage, AssistantMessageRequest, AssistantPart, AssistantState, AssistantStep, AssistantStepState, AssistantTablePart, AssistantTextPart, AssistantTone, AssistantWidgetPart } from "./assistant/protocol.js";
|
|
50
|
-
export { type Access, type AccessAction, type AccessContext, type AccessFn, type AccessResult, type AccessSource, type AccessUser, type ActionInputKind, type ActionInputModel, type ActionModel, type ActionRun, type AnyField, type AppAddress, type ArgumentSpec, type ArgumentType, type ArgumentsSpec, type AssistantAction, type AssistantActionRequest, type AssistantCardPart, type AssistantDiff, type AssistantEvent, type AssistantMessage, type AssistantMessageRequest, type AssistantPart, type AssistantState, type AssistantStep, type AssistantStepState, type AssistantTablePart, type AssistantTextPart, type AssistantTone, type AssistantWidgetPart, type BadgeShape, type BottomBarItemModel, type BottomBarModel, type BottomBarNames, type BottomBarSource, type CalendarView, type Capability, type CapabilityAction, type CapabilityLimit, type CapabilityScope, type CardFavoriteModel, type CardPhotosModel, type ChartGranularity, type ChartInput, type ChartModel, type ChartRange, type CheckResult, type CheckedFilter, type CommentsSectionModel, type CompareOp, type ComponentRef, type ComputedReveal, type ConnectAddress, type Constraint, type CreateModel, type CreatedOptions, type CustomSectionModel, type DatePreset, type DeletedOptions, type DurationLiteral, type DurationUnit, type Encrypted, type EvaluateOptions, type EventActor, type EventContext, type EventHelpers, type EventMatch, type EventModel, type EventOperation, type EventSpec, type ExactCapability, type ExportModel, type Field, type FieldAccess, type FieldFormat, type FieldMeta, type FieldModel, type FieldPath, type FieldRefValue, type FieldRefs, type FieldRule, type FieldType, type FieldTypeDef, type FieldView, type FieldViewModel, type FieldViews, type FieldWidgetModel, type FieldsInput, type FileField, type FileFieldModel, type FileOptions, type FileProcessor, type FileProcessorInput, type FilterError, type FilterErrorCode, type FilterExpr, type FilterLayout, type FilterLimits, type FilterOf, type FilterParse, type FilterValue, type FilterWidgetModel, type FormAddress, type FormInput, type FormModel, type GalleryModel, type Grant, type GroupChartInput, type GroupChartModel, type GroupItemModel, type GroupModel, type HeldCapability, type HelpWhen, type HistorySectionModel, type ImageFormat, type ImageVariant, type ImageVariantOptions, type InferRecord, type Issue, type JsonValue, type KeyOf, type KeyRefs, type KeyType, type KeyValue, type LayoutItemModel, type ListColumn, type ListDisplayModel, type ListDragModel, type ListModel, type ListQuery, type Literal, type MapSectionModel, type MapView, type NamedListModel, type NavModel, type NavRecentModel, type NowValue, type OrderByCheck, type OrderByItem, type OrderByParse, type ParentAccess, type ParentModel, type PeriodChartInput, type PeriodChartModel, type PositionAfterModel, type RecordChartModel, type RecordChartRange, type RecordKey, type RecordMode, type RecordOf, type RecordPageModel, type RecordWhen, type Ref, type Refs, type RelatedColumnModel, type RelatedModel, type RelatedPresentation, type RelationField, type ResolveOptions, type ResolvedAccess, type ResourceBuilder, type ResourceModel, type RevealCaller, type RoleEntry, type RoleLimit, type Roles, type RolesOptions, type Rollup, type RollupCount, type RollupFn, type RollupSource, type RollupValue, type RowFilterOperation, type Rule, type SaveFeedback, type SaveSearchModel, type SearchMatch, type SearchRef, type SearchRefs, type SearchResultModel, type SearchesOfModel, type SectionModel, type SectionPresentation, type ShowWhen, type SignInAddress, type SignInPromptModel, type SignInStep, type SignInViewModel, type SortSpec, type Span, type StatusTone, type TabItemModel, type TabModel, type TenantOptions, type TimelineView, type TitleFromModel, type UndeletedOptions, type UpdatedOptions, type UserMenuItemModel, type UserMenuModel, type UserMenuSource, type Validator, type ViewBuilder, type ViewModel, type ViewProps, accessWarnings, addressWords, anonymousRole, appPath, argumentsSchema, bottomBar, bottomBarErrors, checkFilter, checkOrderBy, checkRecord, connectParams, connectPath, connectRoute, createWhere, defineRoles, encrypted, enumLabel, evaluateFilter, f, fieldRef, fieldsUsedBy, fitsKeyType, formPath, formRoute, imageFormats, isRecordCondition, keyTypes, layout as l, maxBottomBarItems, parseFilter, parseOrderBy, pickView, printFilter, printOrderBy, readAppPath, readConnectAddress, readFormAddress, readSignInAddress, resolveAccess, resource, restrictModel, rule, signInParams, signInPath, signInRoute, signInSteps, userMenu, view, where };
|
|
51
|
+
export { type Access, type AccessAction, type AccessContext, type AccessFn, type AccessResult, type AccessSource, type AccessUser, type ActionInputKind, type ActionInputModel, type ActionModel, type ActionRun, type AnyField, type AppAddress, type ArgumentSpec, type ArgumentType, type ArgumentsSpec, type AssistantAction, type AssistantActionRequest, type AssistantCardPart, type AssistantDiff, type AssistantEvent, type AssistantMessage, type AssistantMessageRequest, type AssistantPart, type AssistantState, type AssistantStep, type AssistantStepState, type AssistantTablePart, type AssistantTextPart, type AssistantTone, type AssistantWidgetPart, type BadgeShape, type BadgeTone, type BottomBarItemModel, type BottomBarModel, type BottomBarNames, type BottomBarSource, type CalendarView, type Capability, type CapabilityAction, type CapabilityLimit, type CapabilityScope, type CardFavoriteModel, type CardPhotosModel, type ChartGranularity, type ChartInput, type ChartModel, type ChartRange, type CheckResult, type CheckedFilter, type CommentsSectionModel, type CompareOp, type ComponentRef, type ComputedReveal, type ConnectAddress, type Constraint, type CreateModel, type CreatedOptions, type CustomSectionModel, type DatePreset, type DeletedOptions, type DurationLiteral, type DurationUnit, type Encrypted, type EvaluateOptions, type EventActor, type EventContext, type EventHelpers, type EventMatch, type EventModel, type EventOperation, type EventSpec, type ExactCapability, type ExportModel, type Field, type FieldAccess, type FieldFormat, type FieldMeta, type FieldModel, type FieldPath, type FieldRefValue, type FieldRefs, type FieldRule, type FieldType, type FieldTypeDef, type FieldView, type FieldViewModel, type FieldViews, type FieldWidgetModel, type FieldsInput, type FileField, type FileFieldModel, type FileOptions, type FileProcessor, type FileProcessorInput, type FilterError, type FilterErrorCode, type FilterExpr, type FilterLayout, type FilterLimits, type FilterOf, type FilterParse, type FilterValue, type FilterWidgetModel, type FormAddress, type FormInput, type FormModel, type GalleryModel, type Grant, type GroupChartInput, type GroupChartModel, type GroupItemModel, type GroupModel, type HeldCapability, type HelpWhen, type HistorySectionModel, type ImageFormat, type ImageVariant, type ImageVariantOptions, type InferRecord, type Issue, type JsonValue, type KeyOf, type KeyRefs, type KeyType, type KeyValue, type LayoutItemModel, type ListColumn, type ListDisplayModel, type ListDragModel, type ListModel, type ListQuery, type Literal, type MapSectionModel, type MapView, type NamedListModel, type NavModel, type NavRecentModel, type NowValue, type OrderByCheck, type OrderByItem, type OrderByParse, type ParentAccess, type ParentModel, type PeriodChartInput, type PeriodChartModel, type PositionAfterModel, type RecordChartModel, type RecordChartRange, type RecordKey, type RecordMode, type RecordOf, type RecordPageModel, type RecordWhen, type Ref, type Refs, type RelatedColumnModel, type RelatedModel, type RelatedPresentation, type RelationField, type ResolveOptions, type ResolvedAccess, type ResourceBuilder, type ResourceModel, type RevealCaller, type RoleEntry, type RoleLimit, type Roles, type RolesOptions, type Rollup, type RollupCount, type RollupFn, type RollupSource, type RollupValue, type RowFilterOperation, type Rule, type SaveFeedback, type SaveSearchModel, type SearchMatch, type SearchRef, type SearchRefs, type SearchResultModel, type SearchesOfModel, type SectionModel, type SectionPresentation, type ShowWhen, type SignInAddress, type SignInPromptModel, type SignInStep, type SignInViewModel, type SortSpec, type Span, type StatusTone, type TabItemModel, type TabModel, type TenantOptions, type TimelineView, type TitleFromModel, type UndeletedOptions, type UpdatedOptions, type UserMenuItemModel, type UserMenuModel, type UserMenuSource, type Validator, type ViewBuilder, type ViewModel, type ViewProps, accessWarnings, addressWords, anonymousRole, appPath, argumentsSchema, badgeTones, bottomBar, bottomBarErrors, checkFilter, checkOrderBy, checkRecord, connectParams, connectPath, connectRoute, createWhere, defineRoles, encrypted, enumLabel, evaluateFilter, f, fieldRef, fieldsUsedBy, fitsKeyType, formPath, formRoute, imageFormats, isBadgeTone, isRecordCondition, keyTypes, layout as l, maxBottomBarItems, parseFilter, parseOrderBy, pickView, printFilter, printOrderBy, readAppPath, readConnectAddress, readFormAddress, readSignInAddress, resolveAccess, resource, restrictModel, rule, signInParams, signInPath, signInRoute, signInSteps, userMenu, view, where };
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import { resource } from "./resource.js";
|
|
|
13
13
|
import { isRecordCondition } from "./record-when.js";
|
|
14
14
|
import { formPath, formRoute, readFormAddress } from "./form-address.js";
|
|
15
15
|
import { fieldRef } from "./field-ref.js";
|
|
16
|
+
import { badgeTones, isBadgeTone } from "./badge-tones.js";
|
|
16
17
|
import { view } from "./view.js";
|
|
17
18
|
import { enumLabel } from "./enum-label.js";
|
|
18
19
|
import { userMenu } from "./user-menu.js";
|
|
@@ -28,4 +29,4 @@ import { rule } from "./access/rule.js";
|
|
|
28
29
|
import { defineRoles } from "./access/roles.js";
|
|
29
30
|
import { pickView } from "./access/pick-view.js";
|
|
30
31
|
import { restrictModel } from "./access/restrict.js";
|
|
31
|
-
export { accessWarnings, addressWords, anonymousRole, appPath, argumentsSchema, bottomBar, bottomBarErrors, checkFilter, checkOrderBy, checkRecord, connectParams, connectPath, connectRoute, createWhere, defineRoles, encrypted, enumLabel, evaluateFilter, f, fieldRef, fieldsUsedBy, fitsKeyType, formPath, formRoute, imageFormats, isRecordCondition, keyTypes, layout as l, maxBottomBarItems, parseFilter, parseOrderBy, pickView, printFilter, printOrderBy, readAppPath, readConnectAddress, readFormAddress, readSignInAddress, resolveAccess, resource, restrictModel, rule, signInParams, signInPath, signInRoute, signInSteps, userMenu, view, where };
|
|
32
|
+
export { accessWarnings, addressWords, anonymousRole, appPath, argumentsSchema, badgeTones, bottomBar, bottomBarErrors, checkFilter, checkOrderBy, checkRecord, connectParams, connectPath, connectRoute, createWhere, defineRoles, encrypted, enumLabel, evaluateFilter, f, fieldRef, fieldsUsedBy, fitsKeyType, formPath, formRoute, imageFormats, isBadgeTone, isRecordCondition, keyTypes, layout as l, maxBottomBarItems, parseFilter, parseOrderBy, pickView, printFilter, printOrderBy, readAppPath, readConnectAddress, readFormAddress, readSignInAddress, resolveAccess, resource, restrictModel, rule, signInParams, signInPath, signInRoute, signInSteps, userMenu, view, where };
|
package/dist/model.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Rollup } from "./computed/rollup.js";
|
|
2
2
|
import { ImageVariant } from "./files/file-options.js";
|
|
3
|
+
import { BadgeTone } from "./badge-tones.js";
|
|
3
4
|
//#region src/model.d.ts
|
|
4
5
|
/** A field's storage type, as `f.*` declares it; see [Field types](docs/website/src/content/docs/reference/data-config.mdx#field-types). */
|
|
5
6
|
export type FieldType = 'text' | 'integer' | 'bigint' | 'decimal' | 'boolean' | 'date' | 'timestamp' | 'uuid' | 'enum' | 'json' | 'relation' | 'file' | 'currency' | 'country';
|
|
@@ -300,11 +301,12 @@ export type AppAddress = {
|
|
|
300
301
|
tab?: string;
|
|
301
302
|
};
|
|
302
303
|
/**
|
|
303
|
-
* How a value is shown: `badge` as a coloured badge, `code` in monospace, `percent` with a
|
|
304
|
+
* How a value is shown: `badge` as a coloured badge, `code` in monospace (a list's identifier column), `percent` with a
|
|
305
|
+
* % sign, `signed` as a number with its sign, green above zero and red below; a text field's
|
|
304
306
|
* `email`, `phone` and `url` as a link that writes, calls or opens it, edited with the keyboard for it. `relative`,
|
|
305
307
|
* `absolute` and `compact` are carried in `/meta` for apps that render their own lists.
|
|
306
308
|
*/
|
|
307
|
-
export type FieldFormat = 'relative' | 'absolute' | 'compact' | 'percent' | 'badge' | 'code' | 'email' | 'phone' | 'url';
|
|
309
|
+
export type FieldFormat = 'relative' | 'absolute' | 'compact' | 'percent' | 'signed' | 'badge' | 'code' | 'email' | 'phone' | 'url';
|
|
308
310
|
/** A view's hints for one field (`.fields((r) => ...)`); see [Names and columns](docs/website/src/content/docs/reference/ui-config.mdx#names-and-columns). */
|
|
309
311
|
export type FieldViewModel = {
|
|
310
312
|
/** What the field is called, instead of its name in words. */
|
|
@@ -325,6 +327,8 @@ export type FieldViewModel = {
|
|
|
325
327
|
markdown?: boolean;
|
|
326
328
|
/** Text before a number wherever it is shown, such as `€`. */
|
|
327
329
|
prefix?: string;
|
|
330
|
+
/** The ISO 4217 code of the currency a decimal is an amount of, such as `EUR`: lists show it as money in that currency. */
|
|
331
|
+
currency?: string;
|
|
328
332
|
/** Text after a number wherever it is shown, such as a unit: `m²` shows `120 m²`. */
|
|
329
333
|
suffix?: string;
|
|
330
334
|
/** How many decimals a number shows. */
|
|
@@ -336,8 +340,11 @@ export type FieldViewModel = {
|
|
|
336
340
|
icon?: string;
|
|
337
341
|
/** What an enum value reads as wherever it is shown; a value without one reads as itself in words (`enumLabel`). */
|
|
338
342
|
valueLabels?: Record<string, string>;
|
|
339
|
-
/**
|
|
340
|
-
|
|
343
|
+
/**
|
|
344
|
+
* A badge tone or a hex colour per enum value, such as `{ paid: 'green', a: '#00a651' }`; a hex colour fills the badge.
|
|
345
|
+
* A value without one is `neutral`.
|
|
346
|
+
*/
|
|
347
|
+
valueColors?: Record<string, BadgeTone | (string & {})>;
|
|
341
348
|
/** `arrow` draws the field's badges as arrows pointing right, as on a rating scale such as the EU energy label. */
|
|
342
349
|
badgeShape?: BadgeShape;
|
|
343
350
|
/**
|
package/dist/view-field.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BadgeTone } from "./badge-tones.js";
|
|
1
2
|
import { BadgeShape, FieldFormat, FieldViewModel, HelpWhen, JsonValue, ShowWhen } from "./model.js";
|
|
2
3
|
//#region src/view-field.d.ts
|
|
3
4
|
/** How a view shows one field, as `.fields((r) => ...)` hands it out: each hint returns a new field view. */
|
|
@@ -33,8 +34,9 @@ export declare class FieldView<N extends string = string, V = unknown> {
|
|
|
33
34
|
*/
|
|
34
35
|
confirm(question: string): FieldView<N, V>;
|
|
35
36
|
/**
|
|
36
|
-
* How the value shows: `badge` for statuses, `code` in monospace, `percent` with a % sign
|
|
37
|
-
* `phone` and `url` as a mail, call or open link, edited with an
|
|
37
|
+
* How the value shows: `badge` for statuses, `code` in monospace, `percent` with a % sign, `signed` with its sign, green
|
|
38
|
+
* above zero and red below; for a text field, `email`, `phone` and `url` as a mail, call or open link, edited with an
|
|
39
|
+
* email, phone or address keyboard on a mobile screen.
|
|
38
40
|
*/
|
|
39
41
|
format(format: FieldFormat): FieldView<N, V>;
|
|
40
42
|
/**
|
|
@@ -48,16 +50,21 @@ export declare class FieldView<N extends string = string, V = unknown> {
|
|
|
48
50
|
* table shows its text on one line. Only a text field takes it.
|
|
49
51
|
*/
|
|
50
52
|
markdown(): FieldView<N, V>;
|
|
51
|
-
/** Text before a number wherever it is shown, such as a currency: `.prefix('€')`. */
|
|
53
|
+
/** Text before a number wherever it is shown, such as a currency sign: `.prefix('€')`. */
|
|
52
54
|
prefix(prefix: string): FieldView<N, V>;
|
|
55
|
+
/** The ISO 4217 code of the currency a decimal is an amount of, such as `.currency('EUR')`: lists show it as money in it. */
|
|
56
|
+
currency(currency: string): FieldView<N, V>;
|
|
53
57
|
/** Text after a number wherever it is shown, such as a unit: `.suffix(' m²')`. */
|
|
54
58
|
suffix(suffix: string): FieldView<N, V>;
|
|
55
59
|
/** How many decimals a number shows wherever it is shown. */
|
|
56
60
|
decimals(decimals: number): FieldView<N, V>;
|
|
57
61
|
/** Labels for an enum's values, such as `{ co_signer: 'Co-signer' }`; values left out read as themselves in words. */
|
|
58
62
|
valueLabels(labels: { readonly [P in Extract<V, string>]?: string; }): FieldView<N, V>;
|
|
59
|
-
/**
|
|
60
|
-
|
|
63
|
+
/**
|
|
64
|
+
* A badge tone (`neutral`, `blue`, `green`, `amber`, `red` or `violet`) or a hex colour that fills the badge, per enum
|
|
65
|
+
* value, such as `{ paid: 'green', a: '#00a651' }`; values left out are `neutral`.
|
|
66
|
+
*/
|
|
67
|
+
valueColors(colors: { readonly [P in Extract<V, string>]?: BadgeTone | (string & {}); }): FieldView<N, V>;
|
|
61
68
|
/** `arrow` draws the field's badges as arrows pointing right, as on a rating scale such as the EU energy label. */
|
|
62
69
|
badgeShape(badgeShape: BadgeShape): FieldView<N, V>;
|
|
63
70
|
/**
|
package/dist/view-field.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { badgeTones, isBadgeTone } from "./badge-tones.js";
|
|
1
2
|
//#region src/view-field.ts
|
|
2
3
|
const hexColor = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
|
|
4
|
+
const currencyCode = /^[A-Z]{3}$/;
|
|
3
5
|
/** How a view shows one field, as `.fields((r) => ...)` hands it out: each hint returns a new field view. */
|
|
4
6
|
var FieldView = class FieldView {
|
|
5
7
|
name;
|
|
@@ -40,8 +42,9 @@ var FieldView = class FieldView {
|
|
|
40
42
|
return this.with({ confirm: question });
|
|
41
43
|
}
|
|
42
44
|
/**
|
|
43
|
-
* How the value shows: `badge` for statuses, `code` in monospace, `percent` with a % sign
|
|
44
|
-
* `phone` and `url` as a mail, call or open link, edited with an
|
|
45
|
+
* How the value shows: `badge` for statuses, `code` in monospace, `percent` with a % sign, `signed` with its sign, green
|
|
46
|
+
* above zero and red below; for a text field, `email`, `phone` and `url` as a mail, call or open link, edited with an
|
|
47
|
+
* email, phone or address keyboard on a mobile screen.
|
|
45
48
|
*/
|
|
46
49
|
format(format) {
|
|
47
50
|
return this.with({ format });
|
|
@@ -61,10 +64,15 @@ var FieldView = class FieldView {
|
|
|
61
64
|
markdown() {
|
|
62
65
|
return this.with({ markdown: true });
|
|
63
66
|
}
|
|
64
|
-
/** Text before a number wherever it is shown, such as a currency: `.prefix('€')`. */
|
|
67
|
+
/** Text before a number wherever it is shown, such as a currency sign: `.prefix('€')`. */
|
|
65
68
|
prefix(prefix) {
|
|
66
69
|
return this.with({ prefix });
|
|
67
70
|
}
|
|
71
|
+
/** The ISO 4217 code of the currency a decimal is an amount of, such as `.currency('EUR')`: lists show it as money in it. */
|
|
72
|
+
currency(currency) {
|
|
73
|
+
if (!currencyCode.test(currency)) throw new Error(`Field "${this.name}": currency "${currency}" is not an ISO 4217 code such as EUR`);
|
|
74
|
+
return this.with({ currency });
|
|
75
|
+
}
|
|
68
76
|
/** Text after a number wherever it is shown, such as a unit: `.suffix(' m²')`. */
|
|
69
77
|
suffix(suffix) {
|
|
70
78
|
return this.with({ suffix });
|
|
@@ -80,11 +88,14 @@ var FieldView = class FieldView {
|
|
|
80
88
|
...labels
|
|
81
89
|
} });
|
|
82
90
|
}
|
|
83
|
-
/**
|
|
91
|
+
/**
|
|
92
|
+
* A badge tone (`neutral`, `blue`, `green`, `amber`, `red` or `violet`) or a hex colour that fills the badge, per enum
|
|
93
|
+
* value, such as `{ paid: 'green', a: '#00a651' }`; values left out are `neutral`.
|
|
94
|
+
*/
|
|
84
95
|
valueColors(colors) {
|
|
85
96
|
const entries = Object.entries(colors);
|
|
86
|
-
const wrong = entries.find(([, color]) => !hexColor.test(color));
|
|
87
|
-
if (wrong) throw new Error(`Field "${this.name}": value colour "${wrong[1]}" of "${wrong[0]}" is not a hex colour such as #00a651`);
|
|
97
|
+
const wrong = entries.find(([, color]) => !isBadgeTone(color) && !hexColor.test(color));
|
|
98
|
+
if (wrong) throw new Error(`Field "${this.name}": value colour "${wrong[1]}" of "${wrong[0]}" is not a tone (${badgeTones.join(", ")}) or a hex colour such as #00a651`);
|
|
88
99
|
return this.with({ valueColors: {
|
|
89
100
|
...this.props.valueColors,
|
|
90
101
|
...Object.fromEntries(entries)
|
|
@@ -184,7 +184,8 @@ const deliveryLogView = view("webhook_delivery_log").names({
|
|
|
184
184
|
event_type: r.event_type.label("Event"),
|
|
185
185
|
status_code: r.status_code.label("Status code"),
|
|
186
186
|
duration_ms: r.duration_ms.label("Duration (ms)"),
|
|
187
|
-
at: r.at.label("When")
|
|
187
|
+
at: r.at.label("When"),
|
|
188
|
+
status: r.status.valueColors({ delivered: "green" })
|
|
188
189
|
})).list((r) => ({
|
|
189
190
|
columns: [
|
|
190
191
|
r.at,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/schema",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.64.0",
|
|
4
4
|
"description": "Resource, field, view and access definitions for Protobase configs.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"aip-parsers": "^1.0.0",
|
|
35
|
+
"eventsource-parser": "^4.1.3",
|
|
35
36
|
"semver": "^7.8.5",
|
|
36
37
|
"zod": "^4.6.5"
|
|
37
38
|
},
|