@lobu/runtime-device 24.7.0 → 24.9.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/component.json +1 -1
- package/dist/dependencies.bun.lock +35 -51
- package/npm-shrinkwrap.json +214 -334
- package/package.json +4 -2
- package/vendor/cli/dist/bundled-skills/lobu/SKILL.md +14 -3
- package/vendor/cli/dist/chrome-extension/manifest.json +5 -4
- package/vendor/cli/dist/chrome-extension/tools.js +2 -3
- package/vendor/cli/dist/commands/_lib/apply/apply-cmd.js +27 -0
- package/vendor/cli/dist/commands/_lib/apply/client.d.ts +16 -5
- package/vendor/cli/dist/commands/_lib/apply/client.js +31 -9
- package/vendor/cli/dist/commands/_lib/apply/deployment.d.ts +8 -12
- package/vendor/cli/dist/commands/_lib/apply/deployment.js +14 -1
- package/vendor/cli/dist/commands/_lib/apply/desired-state.d.ts +8 -4
- package/vendor/cli/dist/commands/_lib/apply/desired-state.js +2 -1
- package/vendor/cli/dist/commands/_lib/apply/diff.d.ts +26 -7
- package/vendor/cli/dist/commands/_lib/apply/diff.js +101 -30
- package/vendor/cli/dist/commands/_lib/apply/map-config.js +29 -2
- package/vendor/cli/dist/commands/_lib/apply/render.js +2 -0
- package/vendor/cli/dist/commands/_lib/apply/shared.d.ts +20 -0
- package/vendor/cli/dist/commands/_lib/apply/shared.js +22 -0
- package/vendor/cli/dist/commands/_lib/init-from-org/bootstrap.js +14 -0
- package/vendor/cli/dist/commands/dev.js +28 -4
- package/vendor/cli/dist/commands/memory/_lib/seed-cmd.js +6 -2
- package/vendor/cli/dist/config/define.d.ts +21 -3
- package/vendor/cli/dist/connectors/README.md +6 -2
- package/vendor/cli/dist/connectors/github.ts +16 -3
- package/vendor/cli/dist/connectors/imessage.ts +953 -0
- package/vendor/cli/dist/connectors/linkedin.ts +20 -377
- package/vendor/cli/dist/connectors/market_quotes.ts +388 -91
- package/vendor/cli/dist/connectors/postgres.ts +21 -14
- package/vendor/cli/dist/connectors/x-dm-adapter.js +55 -21
- package/vendor/cli/dist/connectors/x.ts +1 -1
- package/vendor/cli/dist/runtime-components.json +4 -4
- package/vendor/cli/dist/templates/AGENTS.md.tmpl +1 -1
- package/vendor/cli/package.json +1 -1
- package/vendor/connector-sdk/dist/connector-types.d.ts +23 -2
- package/vendor/connector-sdk/package.json +1 -1
- package/vendor/connector-worker/dist/daemon/automation.js +7 -4
- package/vendor/connector-worker/dist/env.d.ts +15 -0
- package/vendor/connector-worker/dist/env.js +17 -0
- package/vendor/connector-worker/dist/executor/isolate.d.ts +3 -1
- package/vendor/connector-worker/dist/executor/isolate.js +32 -8
- package/vendor/connector-worker/package.json +1 -1
- package/vendor/core/dist/classify-error.d.ts +3 -4
- package/vendor/core/dist/classify-error.js +8 -8
- package/vendor/core/dist/connector-query-errors.d.ts +6 -0
- package/vendor/core/dist/connector-query-errors.js +4 -0
- package/vendor/core/dist/contracts/tools/collection-presentation.d.ts +17 -1
- package/vendor/core/dist/contracts/tools/collection-presentation.js +27 -3
- package/vendor/core/dist/contracts/tools/manage-automations.d.ts +39 -0
- package/vendor/core/dist/contracts/tools/manage-automations.js +11 -1
- package/vendor/core/dist/contracts/tools/manage-entity-schema.js +1 -1
- package/vendor/core/dist/contracts/tools/manage-entity.d.ts +2 -0
- package/vendor/core/dist/contracts/tools/manage-entity.js +7 -0
- package/vendor/core/dist/contracts/tools/manage-feeds.d.ts +2 -0
- package/vendor/core/dist/contracts/tools/manage-feeds.js +3 -0
- package/vendor/core/dist/contracts/tools/manage-views.d.ts +249 -7
- package/vendor/core/dist/contracts/tools/manage-views.js +83 -21
- package/vendor/core/dist/contracts/tools/navigation.d.ts +248 -0
- package/vendor/core/dist/contracts/tools/navigation.js +284 -0
- package/vendor/core/dist/contracts/tools/view-attach.d.ts +7 -0
- package/vendor/core/dist/contracts/tools/view-attach.js +15 -0
- package/vendor/core/dist/contracts/tools/view-content-hash.d.ts +4 -1
- package/vendor/core/dist/contracts/tools/view-content-hash.js +4 -2
- package/vendor/core/dist/contracts/tools/view-definition.d.ts +2 -0
- package/vendor/core/dist/contracts/tools/view-definition.js +52 -0
- package/vendor/core/dist/contracts/tools/view-host.d.ts +68 -0
- package/vendor/core/dist/contracts/tools/view-host.js +30 -1
- package/vendor/core/dist/contracts/tools/view-scope.d.ts +31 -0
- package/vendor/core/dist/contracts/tools/view-scope.js +45 -0
- package/vendor/core/dist/error-report.js +1 -0
- package/vendor/core/dist/errors.d.ts +17 -24
- package/vendor/core/dist/errors.js +17 -24
- package/vendor/core/dist/types.d.ts +0 -6
- package/vendor/core/package.json +11 -1
- package/vendor/views/dist/api.d.ts +30 -5
- package/vendor/views/dist/api.js +22 -8
- package/vendor/views/dist/bridge.d.ts +17 -0
- package/vendor/views/dist/bridge.js +49 -1
- package/vendor/views/dist/components.d.ts +27 -5
- package/vendor/views/dist/components.js +57 -7
- package/vendor/views/dist/embed.d.ts +98 -0
- package/vendor/views/dist/embed.js +418 -0
- package/vendor/views/dist/index.d.ts +3 -1
- package/vendor/views/dist/index.js +1 -0
- package/vendor/views/package.json +1 -1
- package/vendor/cli/dist/connectors/linkedin-takeout.ts +0 -577
- package/vendor/cli/dist/connectors/takeout-utils.ts +0 -240
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResolvedNavigationSectionSchema = exports.NavigationConfigSchema = exports.NavigationSectionSchema = exports.NavigationItemSchema = exports.PageRefSchema = exports.NAVIGATION_MAX_BYTES = exports.NAVIGATION_MAX_ITEMS = exports.NAVIGATION_MAX_SECTIONS = exports.NAVIGATION_MAX_DEPTH = void 0;
|
|
4
|
+
exports.linkDestination = linkDestination;
|
|
5
|
+
exports.navigationHrefDestination = navigationHrefDestination;
|
|
6
|
+
exports.validateNavigationConfig = validateNavigationConfig;
|
|
7
|
+
const typebox_1 = require("@sinclair/typebox");
|
|
8
|
+
const value_1 = require("@sinclair/typebox/value");
|
|
9
|
+
const view_scope_1 = require("./view-scope");
|
|
10
|
+
// ============================================
|
|
11
|
+
// Workspace navigation: the sidebar's curated sections.
|
|
12
|
+
// ============================================
|
|
13
|
+
//
|
|
14
|
+
// A workspace-owned, versioned document. It only presents: a section is not a
|
|
15
|
+
// permission or an owner, and hiding a destination never authorizes or
|
|
16
|
+
// denies it. `null` (never set) means the automatic default — the workspace's
|
|
17
|
+
// attached views — and an empty `sections` array means deliberately no custom
|
|
18
|
+
// entries. The product shell (Home, Memory, Search, Settings) is never part of
|
|
19
|
+
// it, so no configuration can remove it.
|
|
20
|
+
/**
|
|
21
|
+
* Resource ceilings, not product limits: a workspace with a thousand views can
|
|
22
|
+
* nest and group them freely. The tree is recursive; these only stop a
|
|
23
|
+
* document from being unbounded.
|
|
24
|
+
*/
|
|
25
|
+
/** Deepest item nesting: a section's items are level 1. */
|
|
26
|
+
exports.NAVIGATION_MAX_DEPTH = 32;
|
|
27
|
+
exports.NAVIGATION_MAX_SECTIONS = 100;
|
|
28
|
+
/** Items across every section and level. */
|
|
29
|
+
exports.NAVIGATION_MAX_ITEMS = 5000;
|
|
30
|
+
/** The whole document, serialized as UTF-8 JSON. */
|
|
31
|
+
exports.NAVIGATION_MAX_BYTES = 1024 * 1024;
|
|
32
|
+
const NavigationIdSchema = typebox_1.Type.String({
|
|
33
|
+
pattern: "^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$",
|
|
34
|
+
description: "Stable id, unique across the whole document (sections and items). It names the menu entry, not its destination: two entries may open the same page.",
|
|
35
|
+
});
|
|
36
|
+
const NavigationLabelSchema = typebox_1.Type.String({ minLength: 1, maxLength: 80 });
|
|
37
|
+
const NavigationIconSchema = typebox_1.Type.String({
|
|
38
|
+
pattern: "^[a-z0-9-]{1,40}$",
|
|
39
|
+
description: "A Lucide icon name in kebab-case (https://lucide.dev/icons), e.g. 'building-2'; former Lucide names resolve too. Unknown names render the default icon.",
|
|
40
|
+
});
|
|
41
|
+
const ScalarParamSchema = typebox_1.Type.Union([
|
|
42
|
+
typebox_1.Type.String({ maxLength: 500 }),
|
|
43
|
+
typebox_1.Type.Number(),
|
|
44
|
+
typebox_1.Type.Boolean(),
|
|
45
|
+
]);
|
|
46
|
+
exports.PageRefSchema = typebox_1.Type.Union([
|
|
47
|
+
typebox_1.Type.Object({
|
|
48
|
+
kind: typebox_1.Type.Literal("view"),
|
|
49
|
+
key: view_scope_1.ViewKeySchema,
|
|
50
|
+
scope: typebox_1.Type.Optional(typebox_1.Type.Object(view_scope_1.ViewScopeSchema.properties, {
|
|
51
|
+
additionalProperties: false,
|
|
52
|
+
})),
|
|
53
|
+
params: typebox_1.Type.Optional(typebox_1.Type.Record(typebox_1.Type.String({ maxLength: 64 }), ScalarParamSchema, {
|
|
54
|
+
maxProperties: 20,
|
|
55
|
+
description: "Declared view params; validated against the view when resolved.",
|
|
56
|
+
})),
|
|
57
|
+
}, { additionalProperties: false }),
|
|
58
|
+
typebox_1.Type.Object({
|
|
59
|
+
kind: typebox_1.Type.Literal("collection"),
|
|
60
|
+
entityType: typebox_1.Type.String({ minLength: 1, maxLength: 120 }),
|
|
61
|
+
}, { additionalProperties: false }),
|
|
62
|
+
typebox_1.Type.Object({
|
|
63
|
+
kind: typebox_1.Type.Literal("record"),
|
|
64
|
+
entityId: typebox_1.Type.Integer({ minimum: 1 }),
|
|
65
|
+
}, { additionalProperties: false }),
|
|
66
|
+
typebox_1.Type.Object({
|
|
67
|
+
kind: typebox_1.Type.Literal("link"),
|
|
68
|
+
href: typebox_1.Type.String({
|
|
69
|
+
minLength: 1,
|
|
70
|
+
maxLength: 2048,
|
|
71
|
+
description: "Workspace-root-relative path (e.g. 'deal?stage=won', resolved under /<workspace>/) or an absolute https:// URL.",
|
|
72
|
+
}),
|
|
73
|
+
}, { additionalProperties: false }),
|
|
74
|
+
], {
|
|
75
|
+
description: "{ kind: 'view', key, scope?, params? } | { kind: 'collection', entityType } | { kind: 'record', entityId } | { kind: 'link', href }",
|
|
76
|
+
});
|
|
77
|
+
/**
|
|
78
|
+
* One item. `children` holds items of this same shape; the wire schema
|
|
79
|
+
* describes the shape once (no recursive `$ref`, which not every MCP host or
|
|
80
|
+
* JSON-schema tool reads) and `validateNavigationConfig` checks every nested
|
|
81
|
+
* item against it while it walks the tree.
|
|
82
|
+
*/
|
|
83
|
+
exports.NavigationItemSchema = typebox_1.Type.Object({
|
|
84
|
+
id: NavigationIdSchema,
|
|
85
|
+
label: typebox_1.Type.Optional(NavigationLabelSchema),
|
|
86
|
+
icon: typebox_1.Type.Optional(NavigationIconSchema),
|
|
87
|
+
target: typebox_1.Type.Optional(exports.PageRefSchema),
|
|
88
|
+
children: typebox_1.Type.Optional(typebox_1.Type.Array(typebox_1.Type.Unknown(), {
|
|
89
|
+
description: "Nested items, each the same shape as this one.",
|
|
90
|
+
})),
|
|
91
|
+
}, { additionalProperties: false });
|
|
92
|
+
exports.NavigationSectionSchema = typebox_1.Type.Object({
|
|
93
|
+
id: NavigationIdSchema,
|
|
94
|
+
label: typebox_1.Type.Optional(NavigationLabelSchema),
|
|
95
|
+
items: typebox_1.Type.Array(exports.NavigationItemSchema),
|
|
96
|
+
}, { additionalProperties: false });
|
|
97
|
+
exports.NavigationConfigSchema = typebox_1.Type.Object({
|
|
98
|
+
schemaVersion: typebox_1.Type.Literal(1),
|
|
99
|
+
sections: typebox_1.Type.Array(exports.NavigationSectionSchema, {
|
|
100
|
+
maxItems: exports.NAVIGATION_MAX_SECTIONS,
|
|
101
|
+
}),
|
|
102
|
+
}, {
|
|
103
|
+
additionalProperties: false,
|
|
104
|
+
description: "{ schemaVersion: 1, sections: [{ id, label?, items: [{ id, label?, icon?, target?, children? }] }] }. An item without a target is a labeled group; with both, the label opens the target and a separate control expands the children.",
|
|
105
|
+
});
|
|
106
|
+
// Children are typed opaque on the wire, as on the input side: a recursive
|
|
107
|
+
// schema publishes a `$ref` the OpenAPI document never defines.
|
|
108
|
+
const ResolvedItemSchema = typebox_1.Type.Object({
|
|
109
|
+
id: typebox_1.Type.String(),
|
|
110
|
+
label: typebox_1.Type.String(),
|
|
111
|
+
icon: typebox_1.Type.Optional(typebox_1.Type.String()),
|
|
112
|
+
href: typebox_1.Type.Optional(typebox_1.Type.String()),
|
|
113
|
+
external: typebox_1.Type.Optional(typebox_1.Type.Boolean()),
|
|
114
|
+
children: typebox_1.Type.Array(typebox_1.Type.Unknown(), {
|
|
115
|
+
description: "Nested items, each the same shape as this one.",
|
|
116
|
+
}),
|
|
117
|
+
});
|
|
118
|
+
exports.ResolvedNavigationSectionSchema = typebox_1.Type.Object({
|
|
119
|
+
id: typebox_1.Type.String(),
|
|
120
|
+
label: typebox_1.Type.Optional(typebox_1.Type.String()),
|
|
121
|
+
items: typebox_1.Type.Array(ResolvedItemSchema),
|
|
122
|
+
});
|
|
123
|
+
const SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*:/;
|
|
124
|
+
// C0 controls, DEL and whitespace never belong in an authored path.
|
|
125
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: rejecting control characters is the point
|
|
126
|
+
const UNSAFE_CHARS = /[\u0000- \u007f\\]/;
|
|
127
|
+
/**
|
|
128
|
+
* Where a link may go, decided once for both authored navigation links and a
|
|
129
|
+
* view's `openLink`: an absolute `https:` URL off this origin, or a path inside
|
|
130
|
+
* `/<workspace>/` on it. Everything else is refused — other schemes
|
|
131
|
+
* (`javascript:`, `data:`, `http:`), credentials in the URL, and any path that
|
|
132
|
+
* resolves outside the workspace (another workspace, `/account`, `..`).
|
|
133
|
+
*/
|
|
134
|
+
function linkDestination(url, origin, workspace) {
|
|
135
|
+
let parsed;
|
|
136
|
+
try {
|
|
137
|
+
parsed = new URL(url, `${origin}/${encodeURIComponent(workspace)}/`);
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
if (parsed.username || parsed.password)
|
|
143
|
+
return null;
|
|
144
|
+
if (parsed.origin === origin) {
|
|
145
|
+
const root = `/${encodeURIComponent(workspace)}`;
|
|
146
|
+
if (parsed.pathname !== root && !parsed.pathname.startsWith(`${root}/`)) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
kind: "internal",
|
|
151
|
+
path: parsed.pathname + parsed.search + parsed.hash,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
if (parsed.protocol !== "https:")
|
|
155
|
+
return null;
|
|
156
|
+
return { kind: "external", href: parsed.href };
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* An authored `link` href: an absolute https URL, or a path explicitly relative
|
|
160
|
+
* to the workspace root — no scheme, no leading slash, no `.`/`..` segment (in
|
|
161
|
+
* any encoding), no backslash or control character.
|
|
162
|
+
*/
|
|
163
|
+
function navigationHrefDestination(href, origin, workspace) {
|
|
164
|
+
if (UNSAFE_CHARS.test(href))
|
|
165
|
+
return null;
|
|
166
|
+
if (SCHEME.test(href)) {
|
|
167
|
+
const destination = linkDestination(href, origin, workspace);
|
|
168
|
+
return destination?.kind === "external" ? destination : null;
|
|
169
|
+
}
|
|
170
|
+
if (href.startsWith("/"))
|
|
171
|
+
return null;
|
|
172
|
+
const path = href.split(/[?#]/, 1)[0] ?? "";
|
|
173
|
+
for (const segment of path.split("/")) {
|
|
174
|
+
let decoded;
|
|
175
|
+
try {
|
|
176
|
+
decoded = decodeURIComponent(segment);
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
if (decoded === "." || decoded === ".." || /[/\\]/.test(decoded)) {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return linkDestination(href, origin, workspace);
|
|
186
|
+
}
|
|
187
|
+
// ============================================
|
|
188
|
+
// Validation
|
|
189
|
+
// ============================================
|
|
190
|
+
/** Any origin works: validation only asks whether the href can resolve. */
|
|
191
|
+
const VALIDATION_ORIGIN = "https://workspace.invalid";
|
|
192
|
+
/**
|
|
193
|
+
* The one validator every writer runs (server `set`, CLI apply and pull):
|
|
194
|
+
* schema shape and bounds, then the rules a schema cannot say. Returns every
|
|
195
|
+
* problem as `<path>: <message>`; empty means valid.
|
|
196
|
+
*/
|
|
197
|
+
function validateNavigationConfig(config) {
|
|
198
|
+
const bytes = new TextEncoder().encode(JSON.stringify(config) ?? "").length;
|
|
199
|
+
if (bytes > exports.NAVIGATION_MAX_BYTES) {
|
|
200
|
+
return [
|
|
201
|
+
`navigation: ${bytes} bytes exceed the limit of ${exports.NAVIGATION_MAX_BYTES}`,
|
|
202
|
+
];
|
|
203
|
+
}
|
|
204
|
+
const schemaErrors = (schema, value, at) => [...value_1.Value.Errors(schema, value)]
|
|
205
|
+
.slice(0, 10)
|
|
206
|
+
.map((e) => `${at}${e.path.split("/").join(".")}: ${e.message}`);
|
|
207
|
+
if (!value_1.Value.Check(exports.NavigationConfigSchema, config)) {
|
|
208
|
+
return schemaErrors(exports.NavigationConfigSchema, config, "navigation");
|
|
209
|
+
}
|
|
210
|
+
const doc = config;
|
|
211
|
+
const errors = [];
|
|
212
|
+
const seen = new Set();
|
|
213
|
+
let items = 0;
|
|
214
|
+
const claim = (id, at) => {
|
|
215
|
+
if (seen.has(id))
|
|
216
|
+
errors.push(`${at}: duplicate id '${id}'`);
|
|
217
|
+
seen.add(id);
|
|
218
|
+
};
|
|
219
|
+
// Iterative, so a deep document cannot exhaust the stack; it stops at the
|
|
220
|
+
// first ceiling it crosses.
|
|
221
|
+
const stack = [];
|
|
222
|
+
for (let s = doc.sections.length - 1; s >= 0; s -= 1) {
|
|
223
|
+
const section = doc.sections[s];
|
|
224
|
+
if (!section)
|
|
225
|
+
continue;
|
|
226
|
+
for (let i = section.items.length - 1; i >= 0; i -= 1) {
|
|
227
|
+
stack.push({
|
|
228
|
+
item: section.items[i],
|
|
229
|
+
at: `navigation.sections[${s}].items[${i}]`,
|
|
230
|
+
depth: 1,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
doc.sections.forEach((section, s) => {
|
|
235
|
+
claim(section.id, `navigation.sections[${s}]`);
|
|
236
|
+
});
|
|
237
|
+
while (stack.length > 0 && errors.length < 20) {
|
|
238
|
+
const { item: node, at, depth } = stack.pop();
|
|
239
|
+
items += 1;
|
|
240
|
+
if (items > exports.NAVIGATION_MAX_ITEMS) {
|
|
241
|
+
errors.push(`navigation: more than ${exports.NAVIGATION_MAX_ITEMS} items exceed the limit`);
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
if (depth > exports.NAVIGATION_MAX_DEPTH) {
|
|
245
|
+
errors.push(`${at}: nesting deeper than ${exports.NAVIGATION_MAX_DEPTH} levels exceeds the limit`);
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
if (!value_1.Value.Check(exports.NavigationItemSchema, node)) {
|
|
249
|
+
errors.push(...schemaErrors(exports.NavigationItemSchema, node, at));
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
const item = node;
|
|
253
|
+
claim(item.id, at);
|
|
254
|
+
const children = item.children ?? [];
|
|
255
|
+
if (!item.target && children.length === 0) {
|
|
256
|
+
errors.push(`${at}: an item needs a target, children, or both`);
|
|
257
|
+
}
|
|
258
|
+
if (!item.target && !item.label) {
|
|
259
|
+
errors.push(`${at}: a group without a target needs a label`);
|
|
260
|
+
}
|
|
261
|
+
if (item.target?.kind === "link" && !item.label) {
|
|
262
|
+
// A plain link has no resource to name it.
|
|
263
|
+
errors.push(`${at}: a link needs a label`);
|
|
264
|
+
}
|
|
265
|
+
if (item.target?.kind === "link" &&
|
|
266
|
+
!navigationHrefDestination(item.target.href, VALIDATION_ORIGIN, "w")) {
|
|
267
|
+
errors.push(`${at}.target.href: must be a workspace-relative path without '..' or an https:// URL`);
|
|
268
|
+
}
|
|
269
|
+
if (item.target?.kind === "view") {
|
|
270
|
+
const shape = (0, view_scope_1.viewScopeShapeError)(item.target.scope ?? {});
|
|
271
|
+
if (shape)
|
|
272
|
+
errors.push(`${at}.target.scope: ${shape}`);
|
|
273
|
+
}
|
|
274
|
+
for (let i = children.length - 1; i >= 0; i -= 1) {
|
|
275
|
+
stack.push({
|
|
276
|
+
item: children[i],
|
|
277
|
+
at: `${at}.children[${i}]`,
|
|
278
|
+
depth: depth + 1,
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return errors;
|
|
283
|
+
}
|
|
284
|
+
//# sourceMappingURL=navigation.js.map
|
|
@@ -11,6 +11,13 @@ export declare function matchesRecord(attachment: ViewAttachment, record: {
|
|
|
11
11
|
type: string;
|
|
12
12
|
id: number | string | null;
|
|
13
13
|
}): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Whether the view mounts on records of `typeSlug`: a tab on the type's list
|
|
16
|
+
* or a card on its record pages. With `recordId`, a record card pinned to
|
|
17
|
+
* another id does not count. A collection's `when` narrows what the tab
|
|
18
|
+
* shows, not which records the view is about, so it is ignored here.
|
|
19
|
+
*/
|
|
20
|
+
export declare function attachesToEntityType(attach: readonly ViewAttachment[], typeSlug: string, recordId?: number): boolean;
|
|
14
21
|
export declare function hasWorkspaceAttachment(attach: readonly ViewAttachment[]): boolean;
|
|
15
22
|
/** Without a kind, the web host considers every event attachment a candidate. */
|
|
16
23
|
export declare function eventAttachmentsFor(attach: readonly ViewAttachment[], semanticType?: string): EventAttachment[];
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.isEventAttachment = isEventAttachment;
|
|
4
4
|
exports.matchesCollection = matchesCollection;
|
|
5
5
|
exports.matchesRecord = matchesRecord;
|
|
6
|
+
exports.attachesToEntityType = attachesToEntityType;
|
|
6
7
|
exports.hasWorkspaceAttachment = hasWorkspaceAttachment;
|
|
7
8
|
exports.eventAttachmentsFor = eventAttachmentsFor;
|
|
8
9
|
const collection_selection_1 = require("./collection-selection");
|
|
@@ -21,6 +22,20 @@ function matchesRecord(attachment, record) {
|
|
|
21
22
|
attachment.record === record.type &&
|
|
22
23
|
(attachment.id === undefined || attachment.id === record.id));
|
|
23
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Whether the view mounts on records of `typeSlug`: a tab on the type's list
|
|
27
|
+
* or a card on its record pages. With `recordId`, a record card pinned to
|
|
28
|
+
* another id does not count. A collection's `when` narrows what the tab
|
|
29
|
+
* shows, not which records the view is about, so it is ignored here.
|
|
30
|
+
*/
|
|
31
|
+
function attachesToEntityType(attach, typeSlug, recordId) {
|
|
32
|
+
return attach.some((attachment) => ("collection" in attachment && attachment.collection === typeSlug) ||
|
|
33
|
+
("record" in attachment &&
|
|
34
|
+
attachment.record === typeSlug &&
|
|
35
|
+
(recordId === undefined ||
|
|
36
|
+
attachment.id === undefined ||
|
|
37
|
+
attachment.id === recordId)));
|
|
38
|
+
}
|
|
24
39
|
function hasWorkspaceAttachment(attach) {
|
|
25
40
|
return attach.some((attachment) => "workspace" in attachment);
|
|
26
41
|
}
|
|
@@ -4,7 +4,7 @@ import type { RetainedSource } from "./source-files";
|
|
|
4
4
|
* and the CLI (diff-before-apply): ONE function derives the key on both
|
|
5
5
|
* sides, never read off whatever carried it. The hash covers the source, the
|
|
6
6
|
* declared metadata that affects the stored row (name, description, attach,
|
|
7
|
-
* params, actions), the retained files and dependencies when present, AND
|
|
7
|
+
* params, actions, resources), the retained files and dependencies when present, AND
|
|
8
8
|
* the digest of the executable browser bundle. The
|
|
9
9
|
* bundle matters because the CLI resolves relative imports and view npm deps
|
|
10
10
|
* where node_modules exists: two different executable artifacts built from
|
|
@@ -27,6 +27,9 @@ export interface ViewContentMetadata {
|
|
|
27
27
|
attach: unknown;
|
|
28
28
|
params: unknown;
|
|
29
29
|
actions: unknown;
|
|
30
|
+
/** Hashed only when non-empty, so a view that declares none keeps the
|
|
31
|
+
* identity it had before views could declare resources. */
|
|
32
|
+
resources: readonly string[];
|
|
30
33
|
}
|
|
31
34
|
/**
|
|
32
35
|
* sha256 of the source plus the declared metadata plus the compiled
|
|
@@ -8,7 +8,7 @@ const node_crypto_1 = require("node:crypto");
|
|
|
8
8
|
* and the CLI (diff-before-apply): ONE function derives the key on both
|
|
9
9
|
* sides, never read off whatever carried it. The hash covers the source, the
|
|
10
10
|
* declared metadata that affects the stored row (name, description, attach,
|
|
11
|
-
* params, actions), the retained files and dependencies when present, AND
|
|
11
|
+
* params, actions, resources), the retained files and dependencies when present, AND
|
|
12
12
|
* the digest of the executable browser bundle. The
|
|
13
13
|
* bundle matters because the CLI resolves relative imports and view npm deps
|
|
14
14
|
* where node_modules exists: two different executable artifacts built from
|
|
@@ -45,10 +45,12 @@ function contentHash(source, metadata, compiledCode, retainedSource) {
|
|
|
45
45
|
const artifactDigest = (0, node_crypto_1.createHash)("sha256")
|
|
46
46
|
.update(compiledCode, "utf8")
|
|
47
47
|
.digest("hex");
|
|
48
|
+
const { resources, ...declared } = metadata;
|
|
49
|
+
const hashed = resources.length > 0 ? metadata : declared;
|
|
48
50
|
const hash = (0, node_crypto_1.createHash)("sha256")
|
|
49
51
|
.update(source)
|
|
50
52
|
.update("\n")
|
|
51
|
-
.update(stableStringify(
|
|
53
|
+
.update(stableStringify(hashed))
|
|
52
54
|
.update("\n")
|
|
53
55
|
.update(artifactDigest);
|
|
54
56
|
if (retainedSource)
|
|
@@ -8,6 +8,8 @@ export interface ViewDefinitionRecord {
|
|
|
8
8
|
attach: ViewAttachment[];
|
|
9
9
|
params: Record<string, ViewParamDecl>;
|
|
10
10
|
actions: Record<string, ViewActionDecl>;
|
|
11
|
+
/** Bare https origins the view may load images from, deduplicated. */
|
|
12
|
+
resources: string[];
|
|
11
13
|
}
|
|
12
14
|
/**
|
|
13
15
|
* Read `export const view = defineView({...})` out of a view module, without
|
|
@@ -47,6 +47,18 @@ function readViewDefinition(js) {
|
|
|
47
47
|
throw new Error(`${at}: ${message}`);
|
|
48
48
|
}
|
|
49
49
|
const def = raw;
|
|
50
|
+
for (const [name, action] of Object.entries(def.actions ?? {})) {
|
|
51
|
+
if (action.emits === undefined && action.updates === undefined) {
|
|
52
|
+
throw new Error(`defineView.actions.${name}: declare emits, updates, or both`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const resources = [...new Set(def.resources ?? [])];
|
|
56
|
+
for (const entry of resources) {
|
|
57
|
+
const problem = imageOriginProblem(entry);
|
|
58
|
+
if (problem) {
|
|
59
|
+
throw new Error(`defineView.resources: ${JSON.stringify(entry)} ${problem}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
50
62
|
return {
|
|
51
63
|
key: def.key,
|
|
52
64
|
name: def.name?.trim() ? def.name : def.key,
|
|
@@ -54,8 +66,48 @@ function readViewDefinition(js) {
|
|
|
54
66
|
attach: def.attach,
|
|
55
67
|
params: def.params ?? {},
|
|
56
68
|
actions: def.actions ?? {},
|
|
69
|
+
resources,
|
|
57
70
|
};
|
|
58
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Why `entry` is not a declarable image origin, or null when it is: exactly
|
|
74
|
+
* `https://<host>[:port]` as the URL parser prints the origin (so no path,
|
|
75
|
+
* query, fragment, userinfo, uppercase or default port), with a public
|
|
76
|
+
* multi-label hostname. Localhost, IP literals and single-label hosts would
|
|
77
|
+
* point a viewer's browser at their own machine or network.
|
|
78
|
+
*/
|
|
79
|
+
function imageOriginProblem(entry) {
|
|
80
|
+
let url;
|
|
81
|
+
try {
|
|
82
|
+
url = new URL(entry);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return "is not a URL; write an origin like https://tiles.example.com";
|
|
86
|
+
}
|
|
87
|
+
if (url.protocol !== "https:")
|
|
88
|
+
return "must use https";
|
|
89
|
+
if (url.hostname.includes("*"))
|
|
90
|
+
return "cannot use a wildcard; list each origin";
|
|
91
|
+
if (url.origin !== entry) {
|
|
92
|
+
return `must be a bare origin with no path, query, fragment or credentials; write ${url.origin}`;
|
|
93
|
+
}
|
|
94
|
+
const host = url.hostname;
|
|
95
|
+
// The URL parser brackets every IPv6 literal and rewrites any host whose
|
|
96
|
+
// last label is numeric into IPv4, so these two checks cover IP literals.
|
|
97
|
+
const labels = host.split(".");
|
|
98
|
+
const last = labels[labels.length - 1] ?? "";
|
|
99
|
+
const numeric = last !== "" && [...last].every((c) => c >= "0" && c <= "9");
|
|
100
|
+
if (host.startsWith("[") || numeric) {
|
|
101
|
+
return "must name a host, not an IP address";
|
|
102
|
+
}
|
|
103
|
+
if (host === "localhost" || host.endsWith(".localhost")) {
|
|
104
|
+
return "must be a public host, not localhost";
|
|
105
|
+
}
|
|
106
|
+
if (labels.length < 2 || labels.some((label) => label === "")) {
|
|
107
|
+
return "must be a fully qualified public hostname";
|
|
108
|
+
}
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
59
111
|
function defineViewLocalName(body) {
|
|
60
112
|
for (const statement of body) {
|
|
61
113
|
if (statement.type !== "ImportDeclaration")
|
|
@@ -1,7 +1,75 @@
|
|
|
1
|
+
import type { CollectionSelection } from "./collection-selection";
|
|
1
2
|
/** Browser bridge routing hints, never authority. */
|
|
2
3
|
export declare const VIEW_WORKSPACE_META_KEY = "lobu/view-workspace";
|
|
3
4
|
export declare const VIEW_OPEN_RECORD_METHOD = "lobu/open-record";
|
|
4
5
|
/** A mixed read/write tool is admitted only for these fixed read actions.
|
|
5
6
|
* The server still applies the visiting user's authorization and org scope. */
|
|
6
7
|
export declare function isViewRead(tool: string, args: Record<string, unknown> | undefined): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Embedded views: a view places another, independently registered view in a
|
|
10
|
+
* slot. The guest only reports where its slots are; the web host mounts each
|
|
11
|
+
* child as its own sandboxed frame over the slot, with the visitor's session,
|
|
12
|
+
* its own view key and its own actions — the parent never hosts the child's
|
|
13
|
+
* code, so it cannot speak for it. A host that does not implement the methods
|
|
14
|
+
* answers -32601 and the guest says so in the slot.
|
|
15
|
+
*/
|
|
16
|
+
/** guest → host request: the slots on screen now. Answered per slot. */
|
|
17
|
+
export declare const VIEW_EMBEDS_SYNC_METHOD = "lobu/embeds/sync";
|
|
18
|
+
/** guest → host request: keyboard focus moves into a slot's child, `{ id,
|
|
19
|
+
* direction? }`; `direction` says which way the visitor was tabbing. */
|
|
20
|
+
export declare const VIEW_EMBEDS_FOCUS_METHOD = "lobu/embeds/focus";
|
|
21
|
+
/** host → guest: a child's height, so the slot reserves its space. */
|
|
22
|
+
export declare const VIEW_EMBED_SIZE_NOTIFICATION = "lobu/notifications/embed-size";
|
|
23
|
+
/** host → guest: keyboard focus left a child; continue after or before it. */
|
|
24
|
+
export declare const VIEW_EMBED_FOCUS_NOTIFICATION = "lobu/notifications/embed-focus";
|
|
25
|
+
/** host → child guest: keyboard focus entered this embedded view, `{ direction
|
|
26
|
+
* }`; it lands on the first control going forward, the last going backward,
|
|
27
|
+
* so entering a child is one Tab, never a stop on its empty document. */
|
|
28
|
+
export declare const VIEW_FOCUS_ENTER_NOTIFICATION = "lobu/notifications/focus-enter";
|
|
29
|
+
export type ViewFocusDirection = "forward" | "backward";
|
|
30
|
+
/** Child frames one view may show at once. */
|
|
31
|
+
export declare const VIEW_EMBED_MAX_COUNT = 8;
|
|
32
|
+
/** Nesting below the page's own view: a child may embed, a grandchild may not. */
|
|
33
|
+
export declare const VIEW_EMBED_MAX_DEPTH = 2;
|
|
34
|
+
/** Params one slot may pass to its child. */
|
|
35
|
+
export declare const VIEW_EMBED_MAX_PARAMS = 20;
|
|
36
|
+
export type ViewEmbedParams = Record<string, string | number | boolean>;
|
|
37
|
+
/** The child's subject, combined by the same rule as `open_view`'s scope
|
|
38
|
+
* (`viewScopeShapeError`); `entity` may also be a source key, which then
|
|
39
|
+
* needs `type`. The collection selection is the host-owned list filter —
|
|
40
|
+
* never one of the child's own params. */
|
|
41
|
+
export interface ViewEmbedScope {
|
|
42
|
+
type?: string;
|
|
43
|
+
entity?: number | string;
|
|
44
|
+
event?: number;
|
|
45
|
+
collection?: CollectionSelection;
|
|
46
|
+
}
|
|
47
|
+
export interface ViewEmbedBox {
|
|
48
|
+
x: number;
|
|
49
|
+
y: number;
|
|
50
|
+
width: number;
|
|
51
|
+
height: number;
|
|
52
|
+
}
|
|
53
|
+
/** One slot as the guest reports it; `rect` is in the guest's viewport.
|
|
54
|
+
* `rect.clip` is the part of it the guest actually shows — inside every
|
|
55
|
+
* scrolling or clipping ancestor, and outside any dialog or menu laid over
|
|
56
|
+
* it — so the host never lets the child cover the parent's own controls.
|
|
57
|
+
* Absent means all of it; an empty box means none. */
|
|
58
|
+
export interface ViewEmbedSlot {
|
|
59
|
+
id: string;
|
|
60
|
+
view: string;
|
|
61
|
+
scope: ViewEmbedScope;
|
|
62
|
+
params: ViewEmbedParams;
|
|
63
|
+
rect: ViewEmbedBox & {
|
|
64
|
+
clip?: ViewEmbedBox;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export type ViewEmbedStatus = {
|
|
68
|
+
id: string;
|
|
69
|
+
status: "mounted";
|
|
70
|
+
} | {
|
|
71
|
+
id: string;
|
|
72
|
+
status: "refused";
|
|
73
|
+
reason: "cycle" | "depth" | "limit" | "invalid";
|
|
74
|
+
};
|
|
7
75
|
//# sourceMappingURL=view-host.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VIEW_OPEN_RECORD_METHOD = exports.VIEW_WORKSPACE_META_KEY = void 0;
|
|
3
|
+
exports.VIEW_EMBED_MAX_PARAMS = exports.VIEW_EMBED_MAX_DEPTH = exports.VIEW_EMBED_MAX_COUNT = exports.VIEW_FOCUS_ENTER_NOTIFICATION = exports.VIEW_EMBED_FOCUS_NOTIFICATION = exports.VIEW_EMBED_SIZE_NOTIFICATION = exports.VIEW_EMBEDS_FOCUS_METHOD = exports.VIEW_EMBEDS_SYNC_METHOD = exports.VIEW_OPEN_RECORD_METHOD = exports.VIEW_WORKSPACE_META_KEY = void 0;
|
|
4
4
|
exports.isViewRead = isViewRead;
|
|
5
5
|
/** Browser bridge routing hints, never authority. */
|
|
6
6
|
exports.VIEW_WORKSPACE_META_KEY = "lobu/view-workspace";
|
|
@@ -8,6 +8,8 @@ exports.VIEW_OPEN_RECORD_METHOD = "lobu/open-record";
|
|
|
8
8
|
/** A mixed read/write tool is admitted only for these fixed read actions.
|
|
9
9
|
* The server still applies the visiting user's authorization and org scope. */
|
|
10
10
|
function isViewRead(tool, args) {
|
|
11
|
+
if (tool === "read_knowledge")
|
|
12
|
+
return true;
|
|
11
13
|
if (tool === "manage_entity") {
|
|
12
14
|
return (args?.action === "list" ||
|
|
13
15
|
args?.action === "get" ||
|
|
@@ -25,4 +27,31 @@ function isViewRead(tool, args) {
|
|
|
25
27
|
args?.schema_type === "entity_type" &&
|
|
26
28
|
(args.action === "list" || args.action === "get"));
|
|
27
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Embedded views: a view places another, independently registered view in a
|
|
32
|
+
* slot. The guest only reports where its slots are; the web host mounts each
|
|
33
|
+
* child as its own sandboxed frame over the slot, with the visitor's session,
|
|
34
|
+
* its own view key and its own actions — the parent never hosts the child's
|
|
35
|
+
* code, so it cannot speak for it. A host that does not implement the methods
|
|
36
|
+
* answers -32601 and the guest says so in the slot.
|
|
37
|
+
*/
|
|
38
|
+
/** guest → host request: the slots on screen now. Answered per slot. */
|
|
39
|
+
exports.VIEW_EMBEDS_SYNC_METHOD = "lobu/embeds/sync";
|
|
40
|
+
/** guest → host request: keyboard focus moves into a slot's child, `{ id,
|
|
41
|
+
* direction? }`; `direction` says which way the visitor was tabbing. */
|
|
42
|
+
exports.VIEW_EMBEDS_FOCUS_METHOD = "lobu/embeds/focus";
|
|
43
|
+
/** host → guest: a child's height, so the slot reserves its space. */
|
|
44
|
+
exports.VIEW_EMBED_SIZE_NOTIFICATION = "lobu/notifications/embed-size";
|
|
45
|
+
/** host → guest: keyboard focus left a child; continue after or before it. */
|
|
46
|
+
exports.VIEW_EMBED_FOCUS_NOTIFICATION = "lobu/notifications/embed-focus";
|
|
47
|
+
/** host → child guest: keyboard focus entered this embedded view, `{ direction
|
|
48
|
+
* }`; it lands on the first control going forward, the last going backward,
|
|
49
|
+
* so entering a child is one Tab, never a stop on its empty document. */
|
|
50
|
+
exports.VIEW_FOCUS_ENTER_NOTIFICATION = "lobu/notifications/focus-enter";
|
|
51
|
+
/** Child frames one view may show at once. */
|
|
52
|
+
exports.VIEW_EMBED_MAX_COUNT = 8;
|
|
53
|
+
/** Nesting below the page's own view: a child may embed, a grandchild may not. */
|
|
54
|
+
exports.VIEW_EMBED_MAX_DEPTH = 2;
|
|
55
|
+
/** Params one slot may pass to its child. */
|
|
56
|
+
exports.VIEW_EMBED_MAX_PARAMS = 20;
|
|
28
57
|
//# sourceMappingURL=view-host.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Static } from "@sinclair/typebox";
|
|
2
|
+
export declare const ViewKeySchema: import("@sinclair/typebox").TString;
|
|
3
|
+
export declare const ViewScopeSchema: import("@sinclair/typebox").TObject<{
|
|
4
|
+
collection: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
5
|
+
search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
6
|
+
filters: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
7
|
+
field: import("@sinclair/typebox").TString;
|
|
8
|
+
op: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"eq">, import("@sinclair/typebox").TLiteral<"neq">]>;
|
|
9
|
+
value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull]>;
|
|
10
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
11
|
+
field: import("@sinclair/typebox").TString;
|
|
12
|
+
op: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"lt">, import("@sinclair/typebox").TLiteral<"lte">, import("@sinclair/typebox").TLiteral<"gt">, import("@sinclair/typebox").TLiteral<"gte">]>;
|
|
13
|
+
value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber]>;
|
|
14
|
+
}>]>>>;
|
|
15
|
+
segment: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
16
|
+
}>>;
|
|
17
|
+
type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
18
|
+
entity: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
19
|
+
event: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
20
|
+
}>;
|
|
21
|
+
export type ViewScopeInput = Static<typeof ViewScopeSchema>;
|
|
22
|
+
/** Which scope fields combine. `open_view`, a navigation entry and an
|
|
23
|
+
* embedded view all apply this one rule, so a scope one accepts the others
|
|
24
|
+
* accept too. Null when the combination is valid. */
|
|
25
|
+
export declare function viewScopeShapeError(scope: {
|
|
26
|
+
type?: unknown;
|
|
27
|
+
entity?: unknown;
|
|
28
|
+
event?: unknown;
|
|
29
|
+
collection?: unknown;
|
|
30
|
+
}): string | null;
|
|
31
|
+
//# sourceMappingURL=view-scope.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ViewScopeSchema = exports.ViewKeySchema = void 0;
|
|
4
|
+
exports.viewScopeShapeError = viewScopeShapeError;
|
|
5
|
+
const typebox_1 = require("@sinclair/typebox");
|
|
6
|
+
const collection_selection_1 = require("./collection-selection");
|
|
7
|
+
// A view key names the module: lowercase, dashes, 1-64 chars. The folder is
|
|
8
|
+
// only a convention — the key is the identity (no `custom:<name>` prefix).
|
|
9
|
+
exports.ViewKeySchema = typebox_1.Type.String({
|
|
10
|
+
pattern: "^[a-z0-9][a-z0-9-]{0,63}$",
|
|
11
|
+
minLength: 1,
|
|
12
|
+
maxLength: 64,
|
|
13
|
+
description: "View key, e.g. 'pipeline'.",
|
|
14
|
+
});
|
|
15
|
+
// What a view opens for: `open_view`'s scope, and a navigation entry's. The
|
|
16
|
+
// page it lands on follows from the view's attachments; scope is never
|
|
17
|
+
// inferred from where a link sits.
|
|
18
|
+
exports.ViewScopeSchema = typebox_1.Type.Object({
|
|
19
|
+
collection: typebox_1.Type.Optional(collection_selection_1.CollectionSelectionSchema),
|
|
20
|
+
type: typebox_1.Type.Optional(typebox_1.Type.String({
|
|
21
|
+
minLength: 1,
|
|
22
|
+
description: "Entity-type slug the view opens for.",
|
|
23
|
+
})),
|
|
24
|
+
entity: typebox_1.Type.Optional(typebox_1.Type.Integer({ description: "Entity id the view opens for." })),
|
|
25
|
+
event: typebox_1.Type.Optional(typebox_1.Type.Integer({
|
|
26
|
+
description: "Event id the view opens for. It names the event's supersede lineage, so the view shows the current version, and it opens at /events/<id>/-/views/<key>.",
|
|
27
|
+
})),
|
|
28
|
+
}, {
|
|
29
|
+
description: "Required unless the view is attached to the workspace. Pass scope.type, scope.entity, or scope.event to select its subject.",
|
|
30
|
+
});
|
|
31
|
+
/** Which scope fields combine. `open_view`, a navigation entry and an
|
|
32
|
+
* embedded view all apply this one rule, so a scope one accepts the others
|
|
33
|
+
* accept too. Null when the combination is valid. */
|
|
34
|
+
function viewScopeShapeError(scope) {
|
|
35
|
+
if (scope.collection !== undefined &&
|
|
36
|
+
(!scope.type || scope.entity !== undefined || scope.event !== undefined)) {
|
|
37
|
+
return "Collection selection requires scope.type without entity or event";
|
|
38
|
+
}
|
|
39
|
+
if (scope.event !== undefined &&
|
|
40
|
+
(scope.type !== undefined || scope.entity !== undefined)) {
|
|
41
|
+
return "scope.event names the view's subject on its own; drop scope.type and scope.entity";
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=view-scope.js.map
|