@cruba/crubal 0.0.0-stage → 0.2.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/LICENSE +202 -0
- package/README.md +97 -2
- package/dist/bin/crubal.d.ts +2 -0
- package/dist/bin/crubal.js +103 -0
- package/dist/bin/crubal.js.map +1 -0
- package/dist/src/access.d.ts +126 -0
- package/dist/src/access.js +517 -0
- package/dist/src/access.js.map +1 -0
- package/dist/src/arrival.d.ts +55 -0
- package/dist/src/arrival.js +124 -0
- package/dist/src/arrival.js.map +1 -0
- package/dist/src/browser.d.ts +10 -0
- package/dist/src/browser.js +13 -0
- package/dist/src/browser.js.map +1 -0
- package/dist/src/bundle.d.ts +66 -0
- package/dist/src/bundle.js +753 -0
- package/dist/src/bundle.js.map +1 -0
- package/dist/src/canonical.d.ts +6 -0
- package/dist/src/canonical.js +47 -0
- package/dist/src/canonical.js.map +1 -0
- package/dist/src/conditions.d.ts +28 -0
- package/dist/src/conditions.js +216 -0
- package/dist/src/conditions.js.map +1 -0
- package/dist/src/corpus.d.ts +8 -0
- package/dist/src/corpus.js +1207 -0
- package/dist/src/corpus.js.map +1 -0
- package/dist/src/defs.d.ts +151 -0
- package/dist/src/defs.js +611 -0
- package/dist/src/defs.js.map +1 -0
- package/dist/src/dictionary.d.ts +65 -0
- package/dist/src/dictionary.js +557 -0
- package/dist/src/dictionary.js.map +1 -0
- package/dist/src/exchange.d.ts +236 -0
- package/dist/src/exchange.js +1035 -0
- package/dist/src/exchange.js.map +1 -0
- package/dist/src/forms.d.ts +16 -0
- package/dist/src/forms.js +169 -0
- package/dist/src/forms.js.map +1 -0
- package/dist/src/index.d.ts +27 -0
- package/dist/src/index.js +29 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lex.d.ts +21 -0
- package/dist/src/lex.js +142 -0
- package/dist/src/lex.js.map +1 -0
- package/dist/src/lifecycle.d.ts +84 -0
- package/dist/src/lifecycle.js +415 -0
- package/dist/src/lifecycle.js.map +1 -0
- package/dist/src/log.d.ts +78 -0
- package/dist/src/log.js +506 -0
- package/dist/src/log.js.map +1 -0
- package/dist/src/migrate.d.ts +111 -0
- package/dist/src/migrate.js +286 -0
- package/dist/src/migrate.js.map +1 -0
- package/dist/src/model.d.ts +68 -0
- package/dist/src/model.js +188 -0
- package/dist/src/model.js.map +1 -0
- package/dist/src/packages.d.ts +69 -0
- package/dist/src/packages.js +232 -0
- package/dist/src/packages.js.map +1 -0
- package/dist/src/print-text.d.ts +7 -0
- package/dist/src/print-text.js +216 -0
- package/dist/src/print-text.js.map +1 -0
- package/dist/src/publish.d.ts +27 -0
- package/dist/src/publish.js +275 -0
- package/dist/src/publish.js.map +1 -0
- package/dist/src/read-text.d.ts +10 -0
- package/dist/src/read-text.js +385 -0
- package/dist/src/read-text.js.map +1 -0
- package/dist/src/records.d.ts +31 -0
- package/dist/src/records.js +72 -0
- package/dist/src/records.js.map +1 -0
- package/dist/src/review.d.ts +22 -0
- package/dist/src/review.js +198 -0
- package/dist/src/review.js.map +1 -0
- package/dist/src/rules.d.ts +96 -0
- package/dist/src/rules.js +611 -0
- package/dist/src/rules.js.map +1 -0
- package/dist/src/schedule.d.ts +24 -0
- package/dist/src/schedule.js +126 -0
- package/dist/src/schedule.js.map +1 -0
- package/dist/src/std-packages.d.ts +9 -0
- package/dist/src/std-packages.js +268 -0
- package/dist/src/std-packages.js.map +1 -0
- package/dist/src/store.d.ts +164 -0
- package/dist/src/store.js +538 -0
- package/dist/src/store.js.map +1 -0
- package/dist/src/tree.d.ts +35 -0
- package/dist/src/tree.js +159 -0
- package/dist/src/tree.js.map +1 -0
- package/dist/src/units-table.d.ts +1 -0
- package/dist/src/units-table.js +200 -0
- package/dist/src/units-table.js.map +1 -0
- package/dist/src/units.d.ts +42 -0
- package/dist/src/units.js +98 -0
- package/dist/src/units.js.map +1 -0
- package/dist/src/views.d.ts +216 -0
- package/dist/src/views.js +761 -0
- package/dist/src/views.js.map +1 -0
- package/package.json +60 -4
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import type { Access } from "./access.ts";
|
|
2
|
+
import type { Dictionary } from "./defs.ts";
|
|
3
|
+
import type { Json, JsonObject, Record } from "./model.ts";
|
|
4
|
+
import { type RecordSet } from "./records.ts";
|
|
5
|
+
export declare const AUDIENCES: readonly ["public", "member", "staff", "owner"];
|
|
6
|
+
export type Slot = {
|
|
7
|
+
from: string;
|
|
8
|
+
to: string;
|
|
9
|
+
required: boolean;
|
|
10
|
+
line: number;
|
|
11
|
+
};
|
|
12
|
+
export type Shape = {
|
|
13
|
+
name: string;
|
|
14
|
+
slots: Slot[];
|
|
15
|
+
line: number;
|
|
16
|
+
};
|
|
17
|
+
export type Bucket = {
|
|
18
|
+
name: string;
|
|
19
|
+
values?: string[];
|
|
20
|
+
range?: [number, number];
|
|
21
|
+
};
|
|
22
|
+
export type Filter = {
|
|
23
|
+
name: string;
|
|
24
|
+
facet: string;
|
|
25
|
+
buckets?: Bucket[];
|
|
26
|
+
dependent: string[];
|
|
27
|
+
line: number;
|
|
28
|
+
bucketLines: number[];
|
|
29
|
+
};
|
|
30
|
+
export type View = {
|
|
31
|
+
name: string;
|
|
32
|
+
line: number;
|
|
33
|
+
level?: string;
|
|
34
|
+
wears: string[];
|
|
35
|
+
when?: string;
|
|
36
|
+
list?: string;
|
|
37
|
+
of?: string;
|
|
38
|
+
pin: string[];
|
|
39
|
+
hide: string[];
|
|
40
|
+
order: {
|
|
41
|
+
key: string;
|
|
42
|
+
dir: "after" | "before";
|
|
43
|
+
}[];
|
|
44
|
+
page: number;
|
|
45
|
+
shapes: string[];
|
|
46
|
+
filters: string[];
|
|
47
|
+
index: string[];
|
|
48
|
+
indexLine: number;
|
|
49
|
+
show: string;
|
|
50
|
+
fresh: string;
|
|
51
|
+
/** `administered`, `controlled`, `owned`, `relation <name>` or `none` (12.2); absent takes the default. */
|
|
52
|
+
partition?: string;
|
|
53
|
+
/** The dated version; a new version starts the view's stream over (12.6). */
|
|
54
|
+
version?: string;
|
|
55
|
+
};
|
|
56
|
+
export type RoleDef = {
|
|
57
|
+
name: string;
|
|
58
|
+
audience: string;
|
|
59
|
+
see: string[];
|
|
60
|
+
seeLine: number;
|
|
61
|
+
line: number;
|
|
62
|
+
};
|
|
63
|
+
/** A show rule with a `for`: it decides for the records its class, kind or level covers (12.4). */
|
|
64
|
+
export type ShownFor = {
|
|
65
|
+
for: string;
|
|
66
|
+
audience: string;
|
|
67
|
+
};
|
|
68
|
+
export type ViewSet = {
|
|
69
|
+
shapes: Map<string, Shape>;
|
|
70
|
+
filters: Map<string, Filter>;
|
|
71
|
+
views: Map<string, View>;
|
|
72
|
+
roles: Map<string, RoleDef>;
|
|
73
|
+
shown: Map<string, string>;
|
|
74
|
+
shownFor: Map<string, ShownFor[]>;
|
|
75
|
+
};
|
|
76
|
+
/** Read shapes, filters, views (with a body), roles and `shown to` rules. */
|
|
77
|
+
export declare function readViews(source: string): ViewSet;
|
|
78
|
+
/**
|
|
79
|
+
* The lowest audience that may see a facet (12.4): a show rule whose `for` covers the record decides for it,
|
|
80
|
+
* a class over a kind or level, else the rule for everywhere; no rule, the public.
|
|
81
|
+
*/
|
|
82
|
+
export declare function shownAudience(set: Pick<ViewSet, "shown" | "shownFor">, facet: string, record?: Pick<Record, "kind" | "level" | "wears">, dict?: Pick<Dictionary, "kinds">): string | undefined;
|
|
83
|
+
/** Can an audience see a facet, of this record when one is given? */
|
|
84
|
+
export declare function visibleTo(set: Pick<ViewSet, "shown" | "shownFor">, facet: string, audience: string, record?: Pick<Record, "kind" | "level" | "wears">, dict?: Pick<Dictionary, "kinds">): boolean;
|
|
85
|
+
export declare function checkViews(set: ViewSet, dict: Dictionary): void;
|
|
86
|
+
export type ProjectOptions = {
|
|
87
|
+
audience?: string;
|
|
88
|
+
caller?: Record;
|
|
89
|
+
context?: Record;
|
|
90
|
+
picks?: {
|
|
91
|
+
[filter: string]: string[];
|
|
92
|
+
};
|
|
93
|
+
page?: number;
|
|
94
|
+
/** Access (chapter 14) for partitioned views: the index serves a caller only the rows their edges match. */
|
|
95
|
+
access?: Access;
|
|
96
|
+
/** Only these records: a projector rebuilding the rows a write made stale (12.6) asks for them alone. */
|
|
97
|
+
only?: string[];
|
|
98
|
+
/**
|
|
99
|
+
* Every row in one pass, no page and no counts: a projector publishing the view (12.6) wants the rows,
|
|
100
|
+
* and a page at a time would select and count the whole view once per page (ME: 197 pages of 9,437 units).
|
|
101
|
+
*/
|
|
102
|
+
all?: boolean;
|
|
103
|
+
};
|
|
104
|
+
export type Counts = {
|
|
105
|
+
[filter: string]: {
|
|
106
|
+
[bucket: string]: number;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
/** Dependent counts (12.3): filter → bucket → dependent facet → value → count. */
|
|
110
|
+
export type Nested = {
|
|
111
|
+
[filter: string]: {
|
|
112
|
+
[bucket: string]: {
|
|
113
|
+
[dependent: string]: {
|
|
114
|
+
[value: string]: number;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
export type Projection = {
|
|
120
|
+
rows: JsonObject[];
|
|
121
|
+
records: string[];
|
|
122
|
+
counts: Counts;
|
|
123
|
+
nested?: Nested;
|
|
124
|
+
pages: number;
|
|
125
|
+
indexable: boolean;
|
|
126
|
+
};
|
|
127
|
+
/** One entry of a view's projection stream (12.6, 12.7). */
|
|
128
|
+
export type StreamEntry = {
|
|
129
|
+
projection: string;
|
|
130
|
+
audience: string;
|
|
131
|
+
seq: number;
|
|
132
|
+
record: string;
|
|
133
|
+
row?: JsonObject;
|
|
134
|
+
buckets?: JsonObject;
|
|
135
|
+
sort?: string[];
|
|
136
|
+
pin?: number;
|
|
137
|
+
removed?: true;
|
|
138
|
+
reset?: true;
|
|
139
|
+
};
|
|
140
|
+
/** The shapes the core defines (12.1, 12.5): the portable one, and structured data for the public. */
|
|
141
|
+
export declare const CORE_SHAPES: string[];
|
|
142
|
+
/** A view's partition: what it declares, else `controlled` above member and `none` otherwise (12.2). */
|
|
143
|
+
export declare function partitionOf(v: View): string;
|
|
144
|
+
export declare class Views {
|
|
145
|
+
readonly dict: Dictionary;
|
|
146
|
+
readonly set: ViewSet;
|
|
147
|
+
private records;
|
|
148
|
+
private engine;
|
|
149
|
+
/** Over a record set of the caller's (a store's working set), or an empty memory set to `put` into. */
|
|
150
|
+
constructor(dict: Dictionary, set: ViewSet, records?: RecordSet);
|
|
151
|
+
put(r: Record): void;
|
|
152
|
+
private effective;
|
|
153
|
+
/** The classes a record wears, those of the records above it included (5.5). */
|
|
154
|
+
private wearsOf;
|
|
155
|
+
private below;
|
|
156
|
+
/** The values an address reads, as a list: own values, or a lower level's (`unit::price`). */
|
|
157
|
+
private valuesAt;
|
|
158
|
+
/** Is a value fit for this audience's eyes? New, unknown and held values never reach the public. */
|
|
159
|
+
private fit;
|
|
160
|
+
private canSee;
|
|
161
|
+
private slot;
|
|
162
|
+
/**
|
|
163
|
+
* What a condition reads of a record (6.3): the envelope under `crubal:`, and bare `id` and `status`
|
|
164
|
+
* too unless a facet of that name holds a value, which then wins.
|
|
165
|
+
*/
|
|
166
|
+
private conditionValues;
|
|
167
|
+
/** The values of the view's order keys as text, and the pin position: what an index orders rows by (12.7). */
|
|
168
|
+
sortOf(v: View, r: Record): {
|
|
169
|
+
sort: string[];
|
|
170
|
+
pin?: number;
|
|
171
|
+
};
|
|
172
|
+
/** The buckets a record falls into, per filter of the view (12.6): what an index counts from. */
|
|
173
|
+
bucketsFor(v: View, r: Record): JsonObject;
|
|
174
|
+
/** Dependent counts (12.3) over records already narrowed by the other filters. */
|
|
175
|
+
nestedCounts(v: View, pool: (f: string) => Record[]): Nested;
|
|
176
|
+
/** Does a view select this record (its own tests, before curation and the shape's required slots)? */
|
|
177
|
+
private selects;
|
|
178
|
+
/** The records a list holds, in its order (12.2): the links in its `crubal:items`. */
|
|
179
|
+
private listed;
|
|
180
|
+
private inBucket;
|
|
181
|
+
private bucketsOf;
|
|
182
|
+
/** The records a view selects, curated and ordered, before filters and paging. */
|
|
183
|
+
select(v: View, opts?: ProjectOptions): Record[];
|
|
184
|
+
/** The roles whose `see` a slot needs above member (12.6 role marks): none when members may see it. */
|
|
185
|
+
private marksFor;
|
|
186
|
+
/** A view's projection for an audience (or a caller), with filter counts and a page. */
|
|
187
|
+
project(name: string, opts?: ProjectOptions): Projection;
|
|
188
|
+
/** One record in one shape: a core shape's object, or the shape's slots with their role marks. */
|
|
189
|
+
private shaped;
|
|
190
|
+
/** A nested view's rows for a page record (12.1, 12.2 `of`): every page, in the view's order. */
|
|
191
|
+
private nestedRows;
|
|
192
|
+
/**
|
|
193
|
+
* Structured data (12.5): schema.org JSON-LD for the public from the kind's type per level (11.2) and
|
|
194
|
+
* each facet's `same-as` in the schema prefix; nothing for any other audience.
|
|
195
|
+
*/
|
|
196
|
+
jsonld(r: Record, audience?: string): JsonObject | undefined;
|
|
197
|
+
private streams;
|
|
198
|
+
/** A view's version, as its stream names it. */
|
|
199
|
+
versionOf(name: string): string;
|
|
200
|
+
/** A new version of a view: its stream starts over at the next publish (12.6). */
|
|
201
|
+
revise(name: string, version: string): void;
|
|
202
|
+
/**
|
|
203
|
+
* The projection stream (12.6): the entries since the last publish of this view for this audience, one
|
|
204
|
+
* per row that is new or changed, and one removal per row that left. Numbered per view and audience; a
|
|
205
|
+
* new version of the view starts over at 1, its first entry marked `reset`.
|
|
206
|
+
*/
|
|
207
|
+
stream(name: string, opts?: Omit<ProjectOptions, "page" | "picks">): StreamEntry[];
|
|
208
|
+
/** The current version's entries after `seq`, for an index resuming from its cursor (12.6.2). */
|
|
209
|
+
entriesSince(name: string, seq: number, audience?: string): StreamEntry[];
|
|
210
|
+
/** The portable shape (12.1): key, label, type and value for every value the audience may see. */
|
|
211
|
+
portable(r: Record, audience?: string, caller?: Record): Json[];
|
|
212
|
+
/** The keys a view reads (12.6), with level prefixes kept. */
|
|
213
|
+
readSet(name: string): Set<string>;
|
|
214
|
+
/** Which of a view's rows a write makes stale: the written record, or what reads it through. */
|
|
215
|
+
staleAfter(name: string, write: Record): string[];
|
|
216
|
+
}
|