@protobase/schema 0.23.3 → 0.23.4
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/address-errors.d.ts +4 -2
- package/dist/address-errors.js +3 -2
- package/dist/model.d.ts +2 -0
- package/dist/resource-model.d.ts +1 -0
- package/dist/resource-model.js +1 -0
- package/dist/resource.d.ts +6 -0
- package/dist/resource.js +8 -0
- package/package.json +1 -1
package/dist/address-errors.d.ts
CHANGED
|
@@ -7,11 +7,13 @@ export type AddressCheck = {
|
|
|
7
7
|
pages?: ReadonlySet<string>;
|
|
8
8
|
/** The resource of the record the link sits on, whose fields its `{field}` placeholders name. */
|
|
9
9
|
source?: ResourceModel;
|
|
10
|
+
/** The resources whose view opens a create page of the app's own, which reads a create address's values whatever their names. */
|
|
11
|
+
createPages?: ReadonlySet<string>;
|
|
10
12
|
};
|
|
11
13
|
/**
|
|
12
14
|
* What is wrong with a link's address against these models: an unknown resource or page, a `{field}` the record it sits
|
|
13
15
|
* on does not have, a filter or order naming fields the resource does not have, or create values for fields it does not
|
|
14
|
-
* have. Empty when it can be followed.
|
|
16
|
+
* have, unless its view opens a create page, which reads them. Empty when it can be followed.
|
|
15
17
|
*/
|
|
16
|
-
export declare const addressErrors: (to: AppAddress, { models, pages, source }: AddressCheck) => string[];
|
|
18
|
+
export declare const addressErrors: (to: AppAddress, { models, pages, source, createPages }: AddressCheck) => string[];
|
|
17
19
|
//#endregion
|
package/dist/address-errors.js
CHANGED
|
@@ -32,9 +32,9 @@ const orderErrors = (model, orderBy) => {
|
|
|
32
32
|
/**
|
|
33
33
|
* What is wrong with a link's address against these models: an unknown resource or page, a `{field}` the record it sits
|
|
34
34
|
* on does not have, a filter or order naming fields the resource does not have, or create values for fields it does not
|
|
35
|
-
* have. Empty when it can be followed.
|
|
35
|
+
* have, unless its view opens a create page, which reads them. Empty when it can be followed.
|
|
36
36
|
*/
|
|
37
|
-
const addressErrors = (to, { models, pages, source }) => {
|
|
37
|
+
const addressErrors = (to, { models, pages, source, createPages }) => {
|
|
38
38
|
const placeholders = addressPlaceholders(to).flatMap((name) => {
|
|
39
39
|
if (!source) return [`"{${name}}" takes a value from the record, but the link sits on none`];
|
|
40
40
|
return Object.hasOwn(source.fields, name) ? [] : [`"{${name}}" is not a field of ${source.name}`];
|
|
@@ -46,6 +46,7 @@ const addressErrors = (to, { models, pages, source }) => {
|
|
|
46
46
|
case "create": {
|
|
47
47
|
const target = Object.hasOwn(models, to.resource) ? models[to.resource] : void 0;
|
|
48
48
|
if (!target) return [`unknown resource "${to.resource}"`];
|
|
49
|
+
if (to.kind === "create" && createPages?.has(to.resource)) return placeholders;
|
|
49
50
|
if (to.kind === "create") return [...placeholders, ...Object.keys(to.values ?? {}).filter((name) => !Object.hasOwn(target.fields, name)).map((name) => `values: unknown field "${name}" on ${to.resource}`)];
|
|
50
51
|
if (to.kind !== "list") return placeholders;
|
|
51
52
|
return [
|
package/dist/model.d.ts
CHANGED
|
@@ -112,6 +112,8 @@ export type ResourceModel = {
|
|
|
112
112
|
history?: true;
|
|
113
113
|
/** Whether people who may read its records comment on them (`.comments()`). */
|
|
114
114
|
comments?: true;
|
|
115
|
+
/** Whether open pages refresh as soon as its records change (`.live()`). */
|
|
116
|
+
live?: true;
|
|
115
117
|
};
|
|
116
118
|
/** What happened to a record: `delete` and `undelete` include setting and clearing a soft delete field. */
|
|
117
119
|
export type EventOperation = 'create' | 'update' | 'delete' | 'undelete';
|
package/dist/resource-model.d.ts
CHANGED
package/dist/resource-model.js
CHANGED
|
@@ -62,6 +62,7 @@ const assembleModel = (state) => {
|
|
|
62
62
|
...state.owner && { owner: state.owner },
|
|
63
63
|
...state.history && { history: true },
|
|
64
64
|
...state.comments && { comments: true },
|
|
65
|
+
...state.live && { live: true },
|
|
65
66
|
...state.position && { position: { ...state.position } }
|
|
66
67
|
};
|
|
67
68
|
};
|
package/dist/resource.d.ts
CHANGED
|
@@ -109,6 +109,12 @@ export declare class ResourceBuilder<F extends FieldsInput = {}, K = never> {
|
|
|
109
109
|
* [Record comments](website/src/content/docs/reference/comments.mdx).
|
|
110
110
|
*/
|
|
111
111
|
comments(): ResourceBuilder<F, K>;
|
|
112
|
+
/**
|
|
113
|
+
* Refreshes the pages open on its records and lists as soon as they change, from the API or elsewhere: the server
|
|
114
|
+
* tells each open app which records changed, never their values, and the app reads them again as its user. See
|
|
115
|
+
* [Live updates](website/src/content/docs/reference/live.mdx).
|
|
116
|
+
*/
|
|
117
|
+
live(): ResourceBuilder<F, K>;
|
|
112
118
|
/** The code predicates (`match`) of its events, by event name. */
|
|
113
119
|
eventMatches(): Record<string, EventMatch<any>>;
|
|
114
120
|
/**
|
package/dist/resource.js
CHANGED
|
@@ -128,6 +128,14 @@ var ResourceBuilder = class ResourceBuilder {
|
|
|
128
128
|
comments() {
|
|
129
129
|
return this.next({ comments: true });
|
|
130
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Refreshes the pages open on its records and lists as soon as they change, from the API or elsewhere: the server
|
|
133
|
+
* tells each open app which records changed, never their values, and the app reads them again as its user. See
|
|
134
|
+
* [Live updates](website/src/content/docs/reference/live.mdx).
|
|
135
|
+
*/
|
|
136
|
+
live() {
|
|
137
|
+
return this.next({ live: true });
|
|
138
|
+
}
|
|
131
139
|
/** The code predicates (`match`) of its events, by event name. */
|
|
132
140
|
eventMatches() {
|
|
133
141
|
return eventMatches(this.toModel(), this.state.events ?? []);
|