@book.dev/sdk 3.10.0 → 3.13.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/backup.d.ts +106 -10
- package/dist/backup.js +7 -6
- package/dist/backup.js.map +1 -1
- package/dist/blockCatalogue.d.ts +24 -0
- package/dist/blockCatalogue.js +2 -0
- package/dist/blockCatalogue.js.map +1 -1
- package/dist/client.d.ts +48 -23
- package/dist/client.js +227 -13
- package/dist/client.js.map +1 -1
- package/dist/database.d.ts +152 -7
- package/dist/database.js +479 -5
- package/dist/database.js.map +1 -1
- package/dist/formSchema.d.ts +131 -0
- package/dist/formSchema.js +493 -0
- package/dist/formSchema.js.map +1 -0
- package/dist/forms.d.ts +117 -0
- package/dist/forms.js +65 -0
- package/dist/forms.js.map +1 -0
- package/dist/forwarding/forwardingClient.d.ts +9 -1
- package/dist/forwarding/forwardingClient.js +34 -23
- package/dist/forwarding/forwardingClient.js.map +1 -1
- package/dist/forwarding/tunnelClient.d.ts +7 -1
- package/dist/forwarding/tunnelClient.js +41 -16
- package/dist/forwarding/tunnelClient.js.map +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/pageProperties.d.ts +7 -0
- package/dist/pageProperties.js +2 -0
- package/dist/pageProperties.js.map +1 -1
- package/dist/routes.d.ts +12 -0
- package/dist/routes.js +12 -0
- package/dist/routes.js.map +1 -1
- package/dist/types.d.ts +19 -0
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
package/dist/database.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* StoredPage}. A **database** is a collection of pages (its *rows*) managed by
|
|
4
4
|
* typed *properties* and presented through one or more configurable *views*
|
|
5
5
|
* (table, list, gallery, board, calendar, timeline, map, relationship graph,
|
|
6
|
-
* or a bar/pie chart).
|
|
6
|
+
* form, or a bar/pie chart).
|
|
7
7
|
*
|
|
8
8
|
* Three ideas make OpenBook databases different from a plain spreadsheet:
|
|
9
9
|
*
|
|
@@ -40,6 +40,43 @@ import type { PageSnapshot } from './types';
|
|
|
40
40
|
* see {@link ./pageProperties}.
|
|
41
41
|
*/
|
|
42
42
|
export type DatabasePropertyType = 'text' | 'number' | 'rating' | 'select' | 'multi_select' | 'status' | 'checkbox' | 'date' | 'url' | 'email' | 'phone' | 'location' | 'files' | 'relation' | 'dependency' | 'rollup' | 'created_time' | 'last_edited_time' | 'unique_id' | 'expr' | 'formula' | 'person' | 'verification' | 'backlinks';
|
|
43
|
+
/**
|
|
44
|
+
* Whether a public form may write a property type in v1. This exhaustive map is
|
|
45
|
+
* the shared allowlist for builders and the submission validator. Reference,
|
|
46
|
+
* identity/attestation, computed, and server-managed properties fail closed.
|
|
47
|
+
*/
|
|
48
|
+
export declare const FORM_PROPERTY_TYPE_WRITABILITY: {
|
|
49
|
+
readonly text: true;
|
|
50
|
+
readonly number: true;
|
|
51
|
+
readonly rating: true;
|
|
52
|
+
readonly select: true;
|
|
53
|
+
readonly multi_select: true;
|
|
54
|
+
readonly status: true;
|
|
55
|
+
readonly checkbox: true;
|
|
56
|
+
readonly date: true;
|
|
57
|
+
readonly url: true;
|
|
58
|
+
readonly email: true;
|
|
59
|
+
readonly phone: true;
|
|
60
|
+
readonly location: true;
|
|
61
|
+
readonly files: true;
|
|
62
|
+
readonly relation: false;
|
|
63
|
+
readonly dependency: false;
|
|
64
|
+
readonly rollup: false;
|
|
65
|
+
readonly created_time: false;
|
|
66
|
+
readonly last_edited_time: false;
|
|
67
|
+
readonly unique_id: false;
|
|
68
|
+
readonly expr: false;
|
|
69
|
+
readonly formula: false;
|
|
70
|
+
readonly person: false;
|
|
71
|
+
readonly verification: false;
|
|
72
|
+
readonly backlinks: false;
|
|
73
|
+
};
|
|
74
|
+
/** Database property types accepted by public form fills. */
|
|
75
|
+
export type FormWritablePropertyType = {
|
|
76
|
+
[Type in DatabasePropertyType]: typeof FORM_PROPERTY_TYPE_WRITABILITY[Type] extends true ? Type : never;
|
|
77
|
+
}[DatabasePropertyType];
|
|
78
|
+
/** True when `type` is safe for a public form fill in v1. */
|
|
79
|
+
export declare function isFormWritablePropertyType(type: DatabasePropertyType): type is FormWritablePropertyType;
|
|
43
80
|
/** Display formatting for `number`/`formula`/`expr` numeric values. */
|
|
44
81
|
export type NumberFormat = 'plain' | 'integer' | 'decimal' | 'percent' | 'dollar' | 'euro' | 'pound' | 'yen' | 'rupee';
|
|
45
82
|
/** How a number cell is visualised: as text, a horizontal bar, or a ring. */
|
|
@@ -197,7 +234,11 @@ export interface RowTemplate {
|
|
|
197
234
|
* select property; `calendar` lays rows out on a month grid by a date property;
|
|
198
235
|
* `bar`/`pie` are charts that aggregate rows by a category property.
|
|
199
236
|
*/
|
|
200
|
-
export type DatabaseViewType = 'table' | 'list' | 'gallery' | 'board' | 'calendar' | 'timeline' | 'map' | 'graph' | 'bar' | 'pie';
|
|
237
|
+
export type DatabaseViewType = 'table' | 'list' | 'gallery' | 'board' | 'calendar' | 'timeline' | 'map' | 'graph' | 'form' | 'bar' | 'pie';
|
|
238
|
+
/** Runtime list for fail-closed decoding of persisted view types. */
|
|
239
|
+
export declare const KNOWN_DATABASE_VIEW_TYPES: readonly ["table", "list", "gallery", "board", "calendar", "timeline", "map", "graph", "form", "bar", "pie"];
|
|
240
|
+
/** True only for view layouts this SDK knows how to interpret. */
|
|
241
|
+
export declare function isDatabaseViewType(value: unknown): value is DatabaseViewType;
|
|
201
242
|
/** How a chart (or a board column footer) aggregates a group of rows. */
|
|
202
243
|
export interface ChartAggregate {
|
|
203
244
|
/** `count` tallies rows; the others fold a numeric `propertyId`. */
|
|
@@ -260,6 +301,86 @@ export interface DatabaseMetric {
|
|
|
260
301
|
/** Optional goal — when set, the card shows a progress bar of value/target. */
|
|
261
302
|
target?: number;
|
|
262
303
|
}
|
|
304
|
+
/** Per-property presentation and validation metadata for a form view. */
|
|
305
|
+
export interface DatabaseFormFieldValidation {
|
|
306
|
+
min?: number;
|
|
307
|
+
max?: number;
|
|
308
|
+
minLength?: number;
|
|
309
|
+
maxLength?: number;
|
|
310
|
+
pattern?: string;
|
|
311
|
+
}
|
|
312
|
+
export interface DatabaseFormField {
|
|
313
|
+
label?: string;
|
|
314
|
+
help?: string;
|
|
315
|
+
required?: boolean;
|
|
316
|
+
placeholder?: string;
|
|
317
|
+
/** Render a text property as a multi-line input. */
|
|
318
|
+
multiline?: boolean;
|
|
319
|
+
/** Constraints enforced by the public submission validator. */
|
|
320
|
+
validation?: DatabaseFormFieldValidation;
|
|
321
|
+
}
|
|
322
|
+
/** Post-submit behaviour for a database-view form. */
|
|
323
|
+
export type DatabaseFormConfirmation = {
|
|
324
|
+
type: 'message';
|
|
325
|
+
message: string;
|
|
326
|
+
} | {
|
|
327
|
+
type: 'redirect';
|
|
328
|
+
redirectUrl: string;
|
|
329
|
+
};
|
|
330
|
+
/** Form-wide copy and response state for a form view. */
|
|
331
|
+
export interface DatabaseFormConfig {
|
|
332
|
+
title?: string;
|
|
333
|
+
description?: string;
|
|
334
|
+
submitLabel?: string;
|
|
335
|
+
confirmation?: DatabaseFormConfirmation;
|
|
336
|
+
acceptingResponses?: boolean;
|
|
337
|
+
closedMessage?: string;
|
|
338
|
+
/** Per-view response ceiling; absence uses the legacy public-form default. */
|
|
339
|
+
maxResponses?: number;
|
|
340
|
+
}
|
|
341
|
+
/** One deliberately projected public field; no other column shape is exposed. */
|
|
342
|
+
export interface DatabaseFormDescriptorField {
|
|
343
|
+
propertyId: string;
|
|
344
|
+
type: FormWritablePropertyType;
|
|
345
|
+
label: string;
|
|
346
|
+
help: string;
|
|
347
|
+
required: boolean;
|
|
348
|
+
placeholder: string;
|
|
349
|
+
multiline?: boolean;
|
|
350
|
+
/** Display-safe constraints; pattern remains server-enforced only. */
|
|
351
|
+
validation?: Pick<DatabaseFormFieldValidation, 'min' | 'max' | 'minLength' | 'maxLength'>;
|
|
352
|
+
options?: DatabaseSelectOption[];
|
|
353
|
+
includeTime?: boolean;
|
|
354
|
+
dateRange?: boolean;
|
|
355
|
+
numberTarget?: number;
|
|
356
|
+
}
|
|
357
|
+
/** Capability-gated public rendering contract for one database form view. */
|
|
358
|
+
export interface DatabaseFormDescriptor {
|
|
359
|
+
title: string;
|
|
360
|
+
description: string;
|
|
361
|
+
submitLabel: string;
|
|
362
|
+
acceptingResponses: boolean;
|
|
363
|
+
/** Present only for a closed form that configured custom copy. */
|
|
364
|
+
closedMessage?: string;
|
|
365
|
+
fields: DatabaseFormDescriptorField[];
|
|
366
|
+
}
|
|
367
|
+
/** Stable machine-readable failures returned by {@link validateRowAgainstForm}. */
|
|
368
|
+
export declare const FORM_ROW_VALIDATION_ERROR_CODES: readonly ["view_type", "unknown_field", "required", "type", "min", "max", "minLength", "maxLength", "pattern", "option", "range", "too_large", "date_format", "email_format", "url_format", "phone_format"];
|
|
369
|
+
export type FormRowValidationErrorCode = typeof FORM_ROW_VALIDATION_ERROR_CODES[number];
|
|
370
|
+
export interface FormRowValidationError {
|
|
371
|
+
/** Empty only for a view-level failure such as validating a non-form view. */
|
|
372
|
+
propertyId: string;
|
|
373
|
+
code: FormRowValidationErrorCode;
|
|
374
|
+
}
|
|
375
|
+
/** A successful result contains only current, mapped, form-writable properties. */
|
|
376
|
+
export type FormRowValidationResult = {
|
|
377
|
+
ok: true;
|
|
378
|
+
name?: string;
|
|
379
|
+
fields: Record<string, unknown>;
|
|
380
|
+
} | {
|
|
381
|
+
ok: false;
|
|
382
|
+
errors: FormRowValidationError[];
|
|
383
|
+
};
|
|
263
384
|
/** A saved presentation of the database: a layout plus its filters and sorts. */
|
|
264
385
|
export interface DatabaseView {
|
|
265
386
|
id: string;
|
|
@@ -272,9 +393,16 @@ export interface DatabaseView {
|
|
|
272
393
|
sorts: DatabaseSort[];
|
|
273
394
|
/**
|
|
274
395
|
* Property ids to show, in order. Empty/undefined shows every property. The
|
|
275
|
-
* title is always shown and is not listed here.
|
|
396
|
+
* title is always shown and is not listed here for ordinary views. A `form`
|
|
397
|
+
* view is deliberately stricter: only explicitly listed ids are fields, in
|
|
398
|
+
* this exact order, and the reserved `title` id maps the row name.
|
|
276
399
|
*/
|
|
277
400
|
visiblePropertyIds?: string[];
|
|
401
|
+
/** Form-view field metadata, keyed by property id. Inclusion and order remain
|
|
402
|
+
* owned by {@link visiblePropertyIds}; stale/non-visible entries are ignored. */
|
|
403
|
+
formFields?: Record<string, DatabaseFormField>;
|
|
404
|
+
/** Form-view copy and whether its already-published capability accepts fills. */
|
|
405
|
+
formConfig?: DatabaseFormConfig;
|
|
278
406
|
/**
|
|
279
407
|
* Property to group rows by. Drives the kanban columns (`board`) and the
|
|
280
408
|
* category axis of a chart (`bar`/`pie`). Best paired with a `select`
|
|
@@ -623,12 +751,29 @@ export declare const STATUS_GROUPS: {
|
|
|
623
751
|
/**
|
|
624
752
|
* Remove a property from a schema and scrub **every** dangling reference to it:
|
|
625
753
|
* each view's filters (flat list *and* the nested {@link filterRoot} tree),
|
|
626
|
-
* sorts, visible columns, summaries, and the group-by /
|
|
627
|
-
* any `rollup` on another property that aggregated
|
|
628
|
-
* returns a fresh schema — so it can be unit-tested
|
|
629
|
-
* action. (Renders already tolerate stale refs; this
|
|
754
|
+
* sorts, visible columns, form-field metadata, summaries, and the group-by /
|
|
755
|
+
* date / cover config; plus any `rollup` on another property that aggregated
|
|
756
|
+
* through or over it. Pure — returns a fresh schema — so it can be unit-tested
|
|
757
|
+
* and shared by the delete action. (Renders already tolerate stale refs; this
|
|
758
|
+
* keeps the schema clean.)
|
|
630
759
|
*/
|
|
631
760
|
export declare function removeProperty(schema: DatabaseSchema, propertyId: string): DatabaseSchema;
|
|
761
|
+
/** Conservative structural screen for common exponential-backtracking forms. */
|
|
762
|
+
export declare function formPatternIsUnsafe(pattern: string): boolean;
|
|
763
|
+
/**
|
|
764
|
+
* Project only the public rendering contract from a freshly loaded form view.
|
|
765
|
+
* Returns `null` for a non-form view so callers cannot accidentally serialize a
|
|
766
|
+
* normal database view through the public endpoint.
|
|
767
|
+
*/
|
|
768
|
+
export declare function projectDatabaseFormDescriptor(schema: DatabaseSchema, view: DatabaseView): DatabaseFormDescriptor | null;
|
|
769
|
+
/**
|
|
770
|
+
* Validate an untrusted public fill against the database's current schema and
|
|
771
|
+
* form mapping. The allowlist is the form's explicit `visiblePropertyIds`
|
|
772
|
+
* intersected with current form-writable properties. Unknown, deleted,
|
|
773
|
+
* non-visible, computed, and managed fields are rejected; successful output is
|
|
774
|
+
* a fresh record containing only validated fields ready for row creation.
|
|
775
|
+
*/
|
|
776
|
+
export declare function validateRowAgainstForm(schema: DatabaseSchema, view: DatabaseView, fields: Record<string, unknown>): FormRowValidationResult;
|
|
632
777
|
/** Format a numeric value for display per a {@link NumberFormat}. Non-numbers pass through as text. */
|
|
633
778
|
export declare function formatNumber(value: unknown, format: NumberFormat | undefined): string;
|
|
634
779
|
/**
|