@selvajs/selva 4.21.0-beta.17 → 4.21.0-beta.18
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/build/adapter-node.js +2 -2
- package/build/client/_app/immutable/assets/baseHDR.Dkr46J8-.hdr +0 -0
- package/build/client/_app/immutable/chunks/a5NclWb-.js +2 -0
- package/build/client/_app/immutable/chunks/a5NclWb-.js.br +0 -0
- package/build/client/_app/immutable/chunks/a5NclWb-.js.gz +0 -0
- package/build/client/_app/immutable/entry/{app.CqykPefk.js → app.D3YN7-nC.js} +2 -2
- package/build/client/_app/immutable/entry/app.D3YN7-nC.js.br +0 -0
- package/build/client/_app/immutable/entry/app.D3YN7-nC.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{20.B2EnikH5.js → 20.B8bN-AYw.js} +1 -1
- package/build/client/_app/immutable/nodes/20.B8bN-AYw.js.br +0 -0
- package/build/client/_app/immutable/nodes/20.B8bN-AYw.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{25.C7VDbaM3.js → 25.DbMk0htM.js} +20 -20
- package/build/client/_app/immutable/nodes/25.DbMk0htM.js.br +0 -0
- package/build/client/_app/immutable/nodes/25.DbMk0htM.js.gz +0 -0
- package/build/client/_app/version.json +1 -1
- package/build/client/_app/version.json.br +0 -0
- package/build/client/_app/version.json.gz +0 -0
- package/build/server/.vite/manifest.json +88 -6
- package/build/server/_app/immutable/assets/baseHDR.Dkr46J8-.hdr +0 -0
- package/build/server/chunks/DefinitionCard.js +1 -1
- package/build/server/chunks/DefinitionCard.js.map +1 -1
- package/build/server/chunks/api.js +1 -1
- package/build/server/chunks/baseHDR.js +5 -0
- package/build/server/chunks/baseHDR.js.map +1 -0
- package/build/server/chunks/capture.js +5 -0
- package/build/server/chunks/capture.js.map +1 -0
- package/build/server/chunks/diff.js +1 -8
- package/build/server/chunks/diff.js.map +1 -1
- package/build/server/chunks/functions.js +1 -1
- package/build/server/chunks/handlers.js +71 -25
- package/build/server/chunks/handlers.js.map +1 -1
- package/build/server/chunks/instance.js +5 -5
- package/build/server/chunks/instanceAdmins.server.js +1 -1
- package/build/server/chunks/internal.js +3 -3
- package/build/server/chunks/inventory.js +59 -16
- package/build/server/chunks/inventory.js.map +1 -1
- package/build/server/chunks/package.js +2 -1
- package/build/server/chunks/package.js.map +1 -1
- package/build/server/chunks/path.js +7 -0
- package/build/server/chunks/path.js.map +1 -0
- package/build/server/chunks/presets.server.js +1 -1
- package/build/server/chunks/providers.server.js +21 -12
- package/build/server/chunks/providers.server.js.map +1 -1
- package/build/server/chunks/registry.js +18 -3
- package/build/server/chunks/registry.js.map +1 -1
- package/build/server/chunks/remote.js +1559 -0
- package/build/server/chunks/remote.js.map +1 -0
- package/build/server/chunks/rhino3dm.js.map +1 -1
- package/build/server/chunks/server-errors.js +19 -1
- package/build/server/chunks/server-errors.js.map +1 -1
- package/build/server/chunks/server5.js +52 -0
- package/build/server/chunks/server5.js.map +1 -0
- package/build/server/chunks/solve.js +5 -0
- package/build/server/chunks/solve.js.map +1 -0
- package/build/server/chunks/stash-instance.js +94 -0
- package/build/server/chunks/stash-instance.js.map +1 -0
- package/build/server/chunks/sveltekit.js +2 -1
- package/build/server/chunks/sveltekit.js.map +1 -1
- package/build/server/chunks/types4.js +10 -0
- package/build/server/chunks/types4.js.map +1 -0
- package/build/server/entries/endpoints/api/admin/users/_id_/disable/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/image/_server.ts.js +3 -2
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/image/_server.ts.js.map +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/publish/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/schema/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/share-links/_linkId_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/share-links/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/changes/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/inventory/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/schema/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/scripts/_scriptId_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/check/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/definitions/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/me/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/me/starred/_guid_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/me/token/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/assets/_kind_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/members/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/members/_userId_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/tokens/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/orgs/_orgId_/tokens/_tokenId_/_server.ts.js +1 -1
- package/build/server/entries/endpoints/api/v1/projects/_id_/reclaim/_server.ts.js +1 -1
- package/build/server/entries/endpoints/docs/api/openapi.yaml/_server.ts.js +1 -1
- package/build/server/entries/endpoints/mcp/_server.ts.js +1085 -91
- package/build/server/entries/endpoints/mcp/_server.ts.js.map +1 -1
- package/build/server/entries/endpoints/mcp/files/_token_/_name_/_server.ts.js +18 -0
- package/build/server/entries/endpoints/mcp/files/_token_/_name_/_server.ts.js.map +1 -0
- package/build/server/entries/hooks.server.js +8 -3
- package/build/server/entries/hooks.server.js.map +1 -1
- package/build/server/entries/pages/projects/_page.svelte.js +12 -6
- package/build/server/entries/pages/projects/_page.svelte.js.map +1 -1
- package/build/server/entries/pages/team/tokens/_page.server.ts.js +1 -1
- package/build/server/index.js +1 -1
- package/build/server/manifest-full.js +8 -1
- package/build/server/manifest.js +8 -1
- package/build/server/nodes/20.js +1 -1
- package/build/server/nodes/25.js +1 -1
- package/build/server/remote-entry.js +1 -1559
- package/build/server/server.js +8 -1
- package/package.json +6 -5
- package/templates/.env.example +6 -0
- package/build/client/_app/immutable/chunks/Cv7GBWJh.js +0 -2
- package/build/client/_app/immutable/chunks/Cv7GBWJh.js.br +0 -0
- package/build/client/_app/immutable/chunks/Cv7GBWJh.js.gz +0 -0
- package/build/client/_app/immutable/entry/app.CqykPefk.js.br +0 -0
- package/build/client/_app/immutable/entry/app.CqykPefk.js.gz +0 -0
- package/build/client/_app/immutable/nodes/20.B2EnikH5.js.br +0 -0
- package/build/client/_app/immutable/nodes/20.B2EnikH5.js.gz +0 -0
- package/build/client/_app/immutable/nodes/25.C7VDbaM3.js.br +0 -0
- package/build/client/_app/immutable/nodes/25.C7VDbaM3.js.gz +0 -0
- package/build/server/remote-entry.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as ENDPOINT_METHODS, At as invalid_export_location, C as has_prerendered_path, Ct as disable_search, D as throw_devalue_error, Dt as resolve, E as serialize_uses, Et as relative_pathname, Ft as strip_data_suffix,
|
|
2
|
-
import { C as prerender_endpoint_methods, E as prerender_template_nonce,
|
|
1
|
+
import { A as ENDPOINT_METHODS, At as invalid_export_location, Bt as text_encoder, C as has_prerendered_path, Ct as disable_search, D as throw_devalue_error, Dt as resolve, E as serialize_uses, Et as relative_pathname, Ft as strip_data_suffix, I as handle_error_and_jsonify, It as strip_resolution_suffix, J as normalize_error, Mt as add_resolution_suffix, N as PAGE_METHODS, Nt as has_data_suffix, O as with_version_header, Ot as find_route, P as REROUTED_URL_HEADER, Pt as has_resolution_suffix, Q as fetch_cache_url, Rt as base64_encode, S as get_node_type, St as decode_pathname, T as redirect_response, Tt as normalize_path, Ut as app_dir, Wt as assets, X as TRAILING_SLASH_PARAM, Y as INVALIDATED_PARAM, _ as handle_action_request, _t as stringify, a as set_hooks, at as init_transport, b as uneval_action_response, bt as options, ct as uneval, d as get_remote_action, f as get_remote_id, g as handle_action_json_request, h as action_json_redirect, i as read_implementation, it as has_custom_transporters, j as IN_WEBCONTAINER, jt as add_data_suffix, k as BODY_DEPENDENT_METHODS, kt as invalid_export, lt as negotiate, m as handle_remote_form_post, n as hooks, p as handle_remote_call, q as get_status, r as manifest, rt as encoders, u as collect_remote_data, v as is_action_json_request, w as method_not_allowed, wt as make_trackable, y as is_action_request, yt as get_hooks, zt as stream_text } from "./internal.js";
|
|
2
|
+
import { C as prerender_endpoint_methods, E as prerender_template_nonce, J as set_headers_cookie, Q as capture_error, S as prerender_actions, T as prerender_nonce, _ as load_fetch_cors, b as load_promise_not_serializable, c as client_address_unsupported, d as cookies_set_after_response, f as csp_report_only_missing_report, g as header_already_set, p as endpoint_invalid_response, q as set_headers_after_response, u as cookies_serialize_before_route, w as prerender_endpoint_not_prerenderable, x as load_response_header_not_serialized } from "./server-errors.js";
|
|
3
3
|
import { t as uneval$1 } from "./uneval.js";
|
|
4
4
|
import { n as noop, r as once } from "./functions.js";
|
|
5
5
|
import { i as set_env, n as explicit_public_env, r as rendered_env } from "./config.js";
|
|
@@ -213,7 +213,7 @@ function server_data_serializer(event, state) {
|
|
|
213
213
|
let promise_id = 1;
|
|
214
214
|
let max_nodes = -1;
|
|
215
215
|
const iterator = create_async_iterator();
|
|
216
|
-
const global = "
|
|
216
|
+
const global = "__sveltekit_l2wc46";
|
|
217
217
|
/** @param {number} index */
|
|
218
218
|
function get_replacer(index) {
|
|
219
219
|
/** @param {any} thing */
|
|
@@ -1443,7 +1443,7 @@ async function render_response({ branch, fetched, page_config, status, error = n
|
|
|
1443
1443
|
"crossorigin"
|
|
1444
1444
|
]);
|
|
1445
1445
|
}
|
|
1446
|
-
const global = "
|
|
1446
|
+
const global = "__sveltekit_l2wc46";
|
|
1447
1447
|
const { data, chunks } = data_serializer.get_data(csp);
|
|
1448
1448
|
if (page_config.ssr && page_config.csr) body += `\n\t\t\t${fetched.map((item) => serialize_data(item, resolve_opts.filterSerializedResponseHeaders, !!(state.prerendering || state.prerender_default === true))).join("\n ")}`;
|
|
1449
1449
|
if (page_config.csr && client) {
|
|
@@ -1467,7 +1467,7 @@ async function render_response({ branch, fetched, page_config, status, error = n
|
|
|
1467
1467
|
}
|
|
1468
1468
|
}
|
|
1469
1469
|
const blocks = [];
|
|
1470
|
-
const properties = [`base: ${base_expression}`, `version: ${s("
|
|
1470
|
+
const properties = [`base: ${base_expression}`, `version: ${s("1795082151789")}`];
|
|
1471
1471
|
if (assets) properties.push(`assets: ${s(assets)}`);
|
|
1472
1472
|
if (client.uses_env_dynamic_public) properties.push(`env: ${load_env_eagerly ? "null" : uneval$1(rendered_env)}`);
|
|
1473
1473
|
if (chunks) {
|
|
@@ -2,7 +2,7 @@ import { g as getPermissionStore, h as getOrganizationProvider, r as getAuthProv
|
|
|
2
2
|
import { O as ApiErrorCode } from "./access.js";
|
|
3
3
|
import { r as hasPermission, t as SYSTEM_CONTEXT } from "./context.js";
|
|
4
4
|
import { v as walkPages } from "./logging.js";
|
|
5
|
-
import {
|
|
5
|
+
import { K as orgHasAnotherOwner, q as serializeOwnerChanges } from "./handlers.js";
|
|
6
6
|
import { t as apiError } from "./api-errors.js";
|
|
7
7
|
// src/lib/server/admin/instanceAdmins.server.ts
|
|
8
8
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Q as capture_error, Z as url_search_unavailable_prerender, h as handle_error_hook_failed, i as action_response_not_serializable, n as action_default_with_named, r as action_name_reserved, s as action_throw_fail, t as action_data_not_serializable, v as load_not_plain_object, y as load_not_serializable } from "./server-errors.js";
|
|
2
2
|
import { a as is_buffer, c as is_valid_array_len, d as valid_array_indices, f as MAX_ARRAY_INDEX, i as get_type, l as stringify_key, n as DevalueError, o as is_plain_object$1, r as enumerable_symbols, s as is_valid_array_index, t as uneval$1, u as stringify_string } from "./uneval.js";
|
|
3
3
|
import { n as noop } from "./functions.js";
|
|
4
4
|
import { error, text } from "@sveltejs/kit";
|
|
@@ -2363,7 +2363,7 @@ function redirect_response(status, location) {
|
|
|
2363
2363
|
* @param {Response} response
|
|
2364
2364
|
*/
|
|
2365
2365
|
function with_version_header(response) {
|
|
2366
|
-
response.headers.set("x-sveltekit-version", "
|
|
2366
|
+
response.headers.set("x-sveltekit-version", "1795082151789");
|
|
2367
2367
|
return response;
|
|
2368
2368
|
}
|
|
2369
2369
|
/**
|
|
@@ -3185,6 +3185,6 @@ function format_response(status, request) {
|
|
|
3185
3185
|
} else log += requested;
|
|
3186
3186
|
return log;
|
|
3187
3187
|
}
|
|
3188
|
-
export { parse_remote_arg as $, ENDPOINT_METHODS as A, invalid_export_location as At, cookie_path_mismatch as B,
|
|
3188
|
+
export { parse_remote_arg as $, ENDPOINT_METHODS as A, invalid_export_location as At, cookie_path_mismatch as B, text_encoder as Bt, has_prerendered_path as C, disable_search as Ct, throw_devalue_error as D, resolve$1 as Dt, serialize_uses as E, relative_pathname as Et, SVELTE_KIT_ASSETS as F, strip_data_suffix as Ft, streaming_without_csr as G, set_assets as Gt, form_action_error_without_ssr as H, save as Ht, handle_error_and_jsonify as I, strip_resolution_suffix as It, normalize_error as J, transform_page_chunk_comments as K, enable_verbose_errors as Kt, cache_control_empty_directive as L, base64_decode as Lt, MUTATIVE_METHODS as M, add_resolution_suffix as Mt, PAGE_METHODS as N, has_data_suffix as Nt, with_version_header as O, find_route as Ot, REROUTED_URL_HEADER as P, has_resolution_suffix as Pt, fetch_cache_url as Q, cache_control_invalid_directive as R, base64_encode as Rt, get_node_type as S, decode_pathname as St, redirect_response as T, normalize_path as Tt, load_tracking_after_return as U, app_dir as Ut, form_action_data_without_ssr as V, restore as Vt, ssr_fetch_eager as W, assets as Wt, TRAILING_SLASH_PARAM as X, INVALIDATED_PARAM as Y, create_remote_key as Z, handle_action_request as _, stringify$1 as _t, set_hooks as a, init_transport as at, uneval_action_response as b, options as bt, fix_stack_trace as c, uneval as ct, get_remote_action as d, deep_set as dt, stringify_remote_arg as et, get_remote_id as f, flatten_issues as ft, handle_action_json_request as g, split_path as gt, action_json_redirect as h, parse_form_key as ht, read_implementation as i, has_custom_transporters as it, IN_WEBCONTAINER as j, add_data_suffix as jt, BODY_DEPENDENT_METHODS as k, invalid_export as kt, set_fix_stack_trace as l, negotiate as lt, handle_remote_form_post as m, normalize_issue as mt, hooks as n, validate_load_response as nt, set_manifest as o, parse as ot, handle_remote_call as p, group_formdata as pt, get_status as q, manifest as r, encoders as rt, set_read_implementation as s, stringify as st, format_response as t, validate_depends as tt, collect_remote_data as u, create_field_proxy as ut, is_action_json_request as v, resolve as vt, method_not_allowed as w, make_trackable as wt, count_non_ssi_comments as x, SCHEME as xt, is_action_request as y, get_hooks as yt, content_type_invalid as z, stream_text as zt };
|
|
3189
3189
|
|
|
3190
3190
|
//# sourceMappingURL=internal.js.map
|
|
@@ -84,29 +84,43 @@ function platformServers(config) {
|
|
|
84
84
|
return config.servers.filter(isPlatformServer);
|
|
85
85
|
}
|
|
86
86
|
// ../schemas/src/inventory.ts
|
|
87
|
-
/** Missing plugins first: they are the ones that make solves fail. */
|
|
87
|
+
/** Missing plugins and components first: they are the ones that make solves fail. */
|
|
88
88
|
function inventoryWarnings(inventory) {
|
|
89
89
|
const warnings = [];
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
90
|
+
const libraryById = librariesById(inventory);
|
|
91
|
+
const plugins = inventory.libraries.filter((l) => !l.core);
|
|
92
|
+
for (const lib of plugins) if (!lib.serverVersion) warnings.push({
|
|
93
|
+
kind: "missingPlugin",
|
|
94
|
+
plugin: lib.name,
|
|
95
|
+
version: lib.version
|
|
96
|
+
});
|
|
97
|
+
const unloaded = /* @__PURE__ */ new Map();
|
|
98
|
+
for (const o of unloadedOfLoadedPlugins(inventory)) {
|
|
99
|
+
const lib = o.library ? libraryById.get(o.library.toLowerCase()) : void 0;
|
|
100
|
+
const key = `${o.name}\u0000${o.library ?? ""}`;
|
|
101
|
+
const entry = unloaded.get(key) ?? {
|
|
102
|
+
kind: "unloaded",
|
|
103
|
+
component: o.name,
|
|
104
|
+
plugin: lib?.name ?? null,
|
|
105
|
+
version: lib?.version ?? null,
|
|
106
|
+
serverVersion: lib?.serverVersion ?? null,
|
|
107
|
+
count: 0
|
|
108
|
+
};
|
|
109
|
+
entry.count += 1;
|
|
110
|
+
unloaded.set(key, entry);
|
|
104
111
|
}
|
|
112
|
+
warnings.push(...unloaded.values());
|
|
113
|
+
for (const lib of plugins) if (lib.serverVersion && lib.serverVersion !== lib.version) warnings.push({
|
|
114
|
+
kind: "pluginVersion",
|
|
115
|
+
plugin: lib.name,
|
|
116
|
+
version: lib.version,
|
|
117
|
+
serverVersion: lib.serverVersion
|
|
118
|
+
});
|
|
105
119
|
const obsolete = /* @__PURE__ */ new Map();
|
|
106
120
|
for (const c of inventory.components) {
|
|
107
121
|
if (!c.obsolete) continue;
|
|
108
122
|
const entry = obsolete.get(c.name) ?? {
|
|
109
|
-
plugin: c.library &&
|
|
123
|
+
plugin: c.library && libraryById.get(c.library.toLowerCase())?.name || null,
|
|
110
124
|
count: 0
|
|
111
125
|
};
|
|
112
126
|
entry.count += 1;
|
|
@@ -135,14 +149,43 @@ function inventoryWarnings(inventory) {
|
|
|
135
149
|
function inventoryWarningText(w) {
|
|
136
150
|
switch (w.kind) {
|
|
137
151
|
case "missingPlugin": return `${w.plugin} ${w.version} is not installed on the Compute server: its components are dropped and solves miss their outputs.`;
|
|
152
|
+
case "unloaded": {
|
|
153
|
+
const what = `${w.count > 1 ? `${w.count}× ` : ""}${w.component}`;
|
|
154
|
+
if (!w.plugin) return `${what} did not load on the Compute server: no plugin it has provides it, so solves skip it and miss what it computes.`;
|
|
155
|
+
const versions = w.version && w.serverVersion && w.version !== w.serverVersion ? ` The file was saved with ${w.plugin} ${w.version}; the server runs ${w.serverVersion}, which lacks it.` : "";
|
|
156
|
+
return `${what} (${w.plugin}) did not load on the Compute server, so solves skip it and miss what it computes.${versions} Install a ${w.plugin} release that has it.`;
|
|
157
|
+
}
|
|
138
158
|
case "pluginVersion": return `Saved with ${w.plugin} ${w.version}; the Compute server runs ${w.serverVersion}.`;
|
|
139
159
|
case "obsolete": return `${w.count > 1 ? `${w.count}× ` : ""}${w.component}${w.plugin ? ` (${w.plugin})` : ""} is obsolete. Open and re-save the file in Grasshopper to upgrade it.`;
|
|
140
160
|
case "secret": return `${w.in === "script" ? "Script" : "Value"} "${w.label}" looks like it holds a secret (${w.rules.join(", ")}). Anyone who can download the file can read it.`;
|
|
141
161
|
}
|
|
142
162
|
}
|
|
163
|
+
var librariesById = (inventory) => new Map(inventory.libraries.map((l) => [l.id.toLowerCase(), l]));
|
|
164
|
+
/**
|
|
165
|
+
* Objects that did not load, less those of a plugin the server lacks altogether: the missing
|
|
166
|
+
* plugin already explains them.
|
|
167
|
+
*/
|
|
168
|
+
function unloadedOfLoadedPlugins(inventory) {
|
|
169
|
+
const missing = new Set(inventory.libraries.filter((l) => !l.core && !l.serverVersion).map((l) => l.id.toLowerCase()));
|
|
170
|
+
return (inventory.unloaded ?? []).filter((o) => !o.library || !missing.has(o.library.toLowerCase()));
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Objects that did not load although the server runs the plugin the file names for them: that
|
|
174
|
+
* release lacks them. Core components, and those whose plugin the file does not name, are left
|
|
175
|
+
* out: a Compute server that cannot load a core component (one that needs Windows, say) never
|
|
176
|
+
* will, and no plugin install changes that.
|
|
177
|
+
*/
|
|
178
|
+
function unloadedOfInstalledPlugins(inventory) {
|
|
179
|
+
const libraryById = librariesById(inventory);
|
|
180
|
+
return (inventory.unloaded ?? []).filter((o) => {
|
|
181
|
+
const lib = o.library ? libraryById.get(o.library.toLowerCase()) : void 0;
|
|
182
|
+
return !!lib && !lib.core && !!lib.serverVersion;
|
|
183
|
+
});
|
|
184
|
+
}
|
|
143
185
|
function summarizeInventory(inventory) {
|
|
144
186
|
return {
|
|
145
187
|
missingPlugins: inventory.libraries.filter((l) => !l.core && !l.serverVersion).map((l) => l.name),
|
|
188
|
+
unloadedComponents: [...new Set(unloadedOfInstalledPlugins(inventory).map((o) => o.name))],
|
|
146
189
|
obsoleteComponents: inventory.components.filter((c) => c.obsolete).length
|
|
147
190
|
};
|
|
148
191
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inventory.js","names":[],"sources":["../../../../platform/src/computeServer/types.ts","../../../../platform/src/computeServer/utils.ts","../../../../schemas/src/inventory.ts"],"sourcesContent":["/**\n * Compute servers belong to one of two scopes — never both.\n *\n * - **Platform server** (`scope: 'platform'`) — created by `manage_compute`.\n * `sharedWith` controls which orgs see it. The global `defaultServerId`\n * (in {@link ComputeConfig}) must reference a platform server and is\n * *always* visible to every org regardless of `sharedWith`.\n *\n * - **Org-private server** (`scope: 'org'`) — created by an org owner/admin\n * with `manage_org_compute`. Visible only to its `ownerOrgId`. Gated by\n * the `ALLOW_ORG_COMPUTE_OVERRIDE` platform flag.\n */\nexport type ComputeServerConfig = PlatformComputeServer | OrgComputeServer;\n\ninterface ComputeServerCommon {\n\tid: string;\n\tlabel: string;\n\t/** Base URL of the Rhino.Compute instance. */\n\tserverUrl: string;\n\t/**\n\t * Sent as the `RhinoComputeKey` header. Populated only when the config was\n\t * read with `includeApiKeys` — `undefined` means \"not loaded\" as often as\n\t * it means \"none stored\"; use {@link ComputeServerCommon.hasApiKey} to\n\t * tell those apart.\n\t */\n\tapiKey?: string;\n\t/**\n\t * Whether a key is stored, independent of whether `apiKey` was loaded —\n\t * lets pickers and admin pages show \"key set\" without decrypting a secret\n\t * they'd only throw away.\n\t */\n\thasApiKey?: boolean;\n}\n\nexport interface PlatformComputeServer extends ComputeServerCommon {\n\tscope: 'platform';\n\t/**\n\t * Which orgs can see this server in pickers / use it for solves.\n\t * - `'all'` — every org. Default in `tenancy: 'single'`.\n\t * - `string[]` — explicit org-id allowlist. `[]` = dormant\n\t * (admin-only) unless this server is the global `defaultServerId`,\n\t * which is always usable everywhere.\n\t */\n\tsharedWith: 'all' | string[];\n}\n\nexport interface OrgComputeServer extends ComputeServerCommon {\n\tscope: 'org';\n\t/** The org that owns this server. Visible only to members of this org. */\n\townerOrgId: string;\n}\n\nexport interface ComputeConfig {\n\tservers: ComputeServerConfig[];\n\t/**\n\t * Global default. Must reference a platform server. Usable by every org\n\t * regardless of that server's `sharedWith` — the baseline every user falls\n\t * back to.\n\t */\n\tdefaultServerId?: string;\n\t/**\n\t * Per-org default override. `orgDefaults[orgId]` must reference a server\n\t * visible to `orgId` (a platform server with `orgId` in `sharedWith` or\n\t * `'all'`, or an org server owned by `orgId`).\n\t */\n\torgDefaults?: Record<string, string>;\n}\n\n// ============================================================================\n// Type guards\n// ============================================================================\n\nexport function isPlatformServer(s: ComputeServerConfig): s is PlatformComputeServer {\n\treturn s.scope === 'platform';\n}\n\nexport function isOrgServer(s: ComputeServerConfig): s is OrgComputeServer {\n\treturn s.scope === 'org';\n}\n","import { isPlatformServer, type ComputeConfig, type ComputeServerConfig } from './types.js';\n\n/**\n * Servers an org can see in pickers and use for solves:\n * platform servers shared with this org (or `'all'`, or the global default)\n * ∪ org-private servers owned by this org.\n */\nexport function serversVisibleTo(\n\tconfig: ComputeConfig,\n\torgId: string | null | undefined\n): ComputeServerConfig[] {\n\treturn config.servers.filter((s) => {\n\t\tif (isPlatformServer(s)) {\n\t\t\tif (s.id === config.defaultServerId) return true;\n\t\t\tif (s.sharedWith === 'all') return true;\n\t\t\tif (orgId && s.sharedWith.includes(orgId)) return true;\n\t\t\treturn false;\n\t\t}\n\t\t// Org-private — visible only to its owner org.\n\t\treturn !!orgId && s.ownerOrgId === orgId;\n\t});\n}\n\n/**\n * Resolves the default server id for an org: per-org override, then global\n * default. Returns `undefined` if neither is set or visible.\n */\nexport function defaultServerIdFor(\n\tconfig: ComputeConfig,\n\torgId: string | null | undefined\n): string | undefined {\n\tconst visible = serversVisibleTo(config, orgId);\n\tconst visibleIds = new Set(visible.map((s) => s.id));\n\n\tif (orgId) {\n\t\tconst orgChoice = config.orgDefaults?.[orgId];\n\t\tif (orgChoice && visibleIds.has(orgChoice)) return orgChoice;\n\t}\n\tif (config.defaultServerId && visibleIds.has(config.defaultServerId)) {\n\t\treturn config.defaultServerId;\n\t}\n\treturn undefined;\n}\n\nexport interface ResolveOptions {\n\t/** Per-definition pin. Falls through silently if not visible. */\n\tdefinitionPin?: string | null;\n}\n\n/**\n * From servers already filtered for visibility, the pin if it is among them, then\n * the default, then the first. Only for a caller holding the filtered list: use\n * {@link resolveServerForOrg} when you have the config.\n */\nexport function pickServer<T extends { id: string }>(\n\tvisible: readonly T[],\n\tdefaultId: string | null | undefined,\n\tpin: string | null | undefined\n): T | undefined {\n\t// A pin can go stale when an admin un-shares the server, so it falls through.\n\treturn visible.find((s) => s.id === pin) ?? visible.find((s) => s.id === defaultId) ?? visible[0];\n}\n\n/**\n * Resolves a definition's compute server, in order:\n * 1. Definition pin (`computeServerId`) if visible to the project's org.\n * 2. `orgDefaults[orgId]` if set.\n * 3. Global `defaultServerId`.\n * 4. The first visible server, mainly before a default is chosen.\n *\n * Throws if no usable server exists.\n */\nexport function resolveServerForOrg(\n\tconfig: ComputeConfig,\n\torgId: string | null | undefined,\n\topts: ResolveOptions = {}\n): ComputeServerConfig {\n\tconst visible = serversVisibleTo(config, orgId);\n\tconst server = pickServer(visible, defaultServerIdFor(config, orgId), opts.definitionPin);\n\tif (!server) throw new Error('No compute servers are configured or visible for this org.');\n\treturn server;\n}\n\n/**\n * The config as one org may see it: visible servers only, `orgDefaults` reduced\n * to this org's own entry, and `defaultServerId` dropped when the global default\n * is not visible here.\n *\n * Applied inside `getConfig` when `scopeToOrgId` is passed, so an org-facing\n * caller cannot forget the filter and leak other orgs' server URLs or the\n * instance's default choice.\n */\nexport function scopeConfigToOrg(config: ComputeConfig, orgId: string): ComputeConfig {\n\tconst servers = serversVisibleTo(config, orgId);\n\tconst visibleIds = new Set(servers.map((s) => s.id));\n\tconst orgDefault = config.orgDefaults?.[orgId];\n\n\treturn {\n\t\tservers,\n\t\tdefaultServerId:\n\t\t\tconfig.defaultServerId && visibleIds.has(config.defaultServerId)\n\t\t\t\t? config.defaultServerId\n\t\t\t\t: undefined,\n\t\torgDefaults: orgDefault && visibleIds.has(orgDefault) ? { [orgId]: orgDefault } : {}\n\t};\n}\n\n/** Lookup by id, ignoring scope or visibility — for admin contexts that display a server outside the visibility filter. */\nexport function findServerById(config: ComputeConfig, id: string): ComputeServerConfig | undefined {\n\treturn config.servers.find((s) => s.id === id);\n}\n\n// ============================================================================\n// Filters\n// ============================================================================\n\nexport function platformServers(config: ComputeConfig) {\n\treturn config.servers.filter(isPlatformServer);\n}\n","// What a .gh holds beyond its form, and what changed in it: the plugins, components, values set on\n// the canvas, scripts and wiring that the form diff cannot see. The inventory itself comes from the\n// plugin on Compute (`DocumentInventory` in wire-schema.json); everything here is pure.\n//\n// Objects match by InstanceGuid, as in the form diff. Script source is never in the inventory:\n// only per-line hashes, which are enough to count added and removed lines.\n\nimport type { DocumentInventory, InventoryValue } from './generated/index.js';\n\n// ============================================================================\n// Warnings about one file\n// ============================================================================\n\nexport type InventoryWarning =\n\t| { kind: 'missingPlugin'; plugin: string; version: string }\n\t| { kind: 'pluginVersion'; plugin: string; version: string; serverVersion: string }\n\t| { kind: 'obsolete'; component: string; plugin: string | null; count: number }\n\t| { kind: 'secret'; in: 'script' | 'value'; label: string; rules: string[] };\n\n/** Missing plugins first: they are the ones that make solves fail. */\nexport function inventoryWarnings(inventory: DocumentInventory): InventoryWarning[] {\n\tconst warnings: InventoryWarning[] = [];\n\tconst pluginName = new Map(inventory.libraries.map((l) => [l.id, l.name]));\n\n\tfor (const lib of inventory.libraries) {\n\t\tif (lib.core) continue;\n\t\tif (!lib.serverVersion) {\n\t\t\twarnings.push({ kind: 'missingPlugin', plugin: lib.name, version: lib.version });\n\t\t} else if (lib.serverVersion !== lib.version) {\n\t\t\twarnings.push({\n\t\t\t\tkind: 'pluginVersion',\n\t\t\t\tplugin: lib.name,\n\t\t\t\tversion: lib.version,\n\t\t\t\tserverVersion: lib.serverVersion\n\t\t\t});\n\t\t}\n\t}\n\n\tconst obsolete = new Map<string, { plugin: string | null; count: number }>();\n\tfor (const c of inventory.components) {\n\t\tif (!c.obsolete) continue;\n\t\tconst entry = obsolete.get(c.name) ?? {\n\t\t\tplugin: (c.library && pluginName.get(c.library)) || null,\n\t\t\tcount: 0\n\t\t};\n\t\tentry.count += 1;\n\t\tobsolete.set(c.name, entry);\n\t}\n\tfor (const [component, { plugin, count }] of obsolete) {\n\t\twarnings.push({ kind: 'obsolete', component, plugin, count });\n\t}\n\n\tfor (const s of inventory.scripts) {\n\t\tif (s.secrets.length)\n\t\t\twarnings.push({ kind: 'secret', in: 'script', label: s.label, rules: s.secrets });\n\t}\n\tfor (const v of inventory.values) {\n\t\tif (v.secrets?.length)\n\t\t\twarnings.push({ kind: 'secret', in: 'value', label: v.label, rules: v.secrets });\n\t}\n\treturn warnings;\n}\n\nexport function inventoryWarningText(w: InventoryWarning): string {\n\tswitch (w.kind) {\n\t\tcase 'missingPlugin':\n\t\t\treturn `${w.plugin} ${w.version} is not installed on the Compute server: its components are dropped and solves miss their outputs.`;\n\t\tcase 'pluginVersion':\n\t\t\treturn `Saved with ${w.plugin} ${w.version}; the Compute server runs ${w.serverVersion}.`;\n\t\tcase 'obsolete':\n\t\t\treturn `${w.count > 1 ? `${w.count}× ` : ''}${w.component}${w.plugin ? ` (${w.plugin})` : ''} is obsolete. Open and re-save the file in Grasshopper to upgrade it.`;\n\t\tcase 'secret':\n\t\t\treturn `${w.in === 'script' ? 'Script' : 'Value'} \"${w.label}\" looks like it holds a secret (${w.rules.join(', ')}). Anyone who can download the file can read it.`;\n\t}\n}\n\n/** What the version list shows without loading the inventory. */\nexport interface InventorySummary {\n\t/** Plugins the file needs that the Compute server had not loaded at the last check. */\n\tmissingPlugins: string[];\n\tobsoleteComponents: number;\n}\n\nexport function summarizeInventory(inventory: DocumentInventory): InventorySummary {\n\treturn {\n\t\tmissingPlugins: inventory.libraries\n\t\t\t.filter((l) => !l.core && !l.serverVersion)\n\t\t\t.map((l) => l.name),\n\t\tobsoleteComponents: inventory.components.filter((c) => c.obsolete).length\n\t};\n}\n\n// ============================================================================\n// What changed between two files\n// ============================================================================\n\nexport interface PluginChange {\n\tplugin: string;\n\tchange: 'added' | 'removed' | 'changed';\n\tbefore?: string;\n\tafter?: string;\n}\n\nexport interface ComponentCount {\n\tname: string;\n\tcount: number;\n}\n\nexport interface ScriptChange {\n\tid: string;\n\tlabel: string;\n\tlanguage: string;\n\tchange: 'added' | 'removed' | 'changed';\n\tlinesAdded: number;\n\tlinesRemoved: number;\n}\n\nexport interface ValueChange {\n\tid: string;\n\tlabel: string;\n\tkind: InventoryValue['kind'];\n\t/** Text as stored: cut at 500 characters, and `null` where it looked like a secret. */\n\tbefore: string | null;\n\tafter: string | null;\n\t/** Slider range, when it changed. */\n\trange?: { before: string; after: string };\n}\n\nexport interface InventoryDiff {\n\tplugins: PluginChange[];\n\tcomponents: { added: ComponentCount[]; removed: ComponentCount[] };\n\tscripts: ScriptChange[];\n\tvalues: ValueChange[];\n\twires: { before: number; after: number; changed: boolean };\n\tidentical: boolean;\n}\n\nexport interface InventoryDiffOptions {\n\t/**\n\t * Ids of form inputs. Their values are the form diff's to report, so values on those objects,\n\t * or on their input parameters, are left out here.\n\t */\n\tformIds?: Iterable<string>;\n}\n\nexport function diffInventories(\n\tbefore: DocumentInventory,\n\tafter: DocumentInventory,\n\toptions: InventoryDiffOptions = {}\n): InventoryDiff {\n\tconst formIds = new Set([...(options.formIds ?? [])].map((id) => id.toLowerCase()));\n\tconst plugins = diffPlugins(before, after);\n\tconst components = diffComponents(before, after);\n\tconst scripts = diffScripts(before, after);\n\tconst values = diffValues(before, after, formIds);\n\tconst wires = {\n\t\tbefore: before.wires.count,\n\t\tafter: after.wires.count,\n\t\tchanged: before.wires.sha256 !== after.wires.sha256\n\t};\n\treturn {\n\t\tplugins,\n\t\tcomponents,\n\t\tscripts,\n\t\tvalues,\n\t\twires,\n\t\tidentical:\n\t\t\t!plugins.length &&\n\t\t\t!components.added.length &&\n\t\t\t!components.removed.length &&\n\t\t\t!scripts.length &&\n\t\t\t!values.length &&\n\t\t\t!wires.changed\n\t};\n}\n\nfunction diffPlugins(before: DocumentInventory, after: DocumentInventory): PluginChange[] {\n\tconst key = (l: { id: string; name: string }) =>\n\t\t/^0{8}-/.test(l.id) ? `name:${l.name}` : l.id.toLowerCase();\n\tconst old = new Map(before.libraries.map((l) => [key(l), l]));\n\tconst now = new Map(after.libraries.map((l) => [key(l), l]));\n\tconst changes: PluginChange[] = [];\n\tfor (const [k, l] of now) {\n\t\tconst prev = old.get(k);\n\t\tif (!prev) changes.push({ plugin: l.name, change: 'added', after: l.version });\n\t\telse if (prev.version !== l.version)\n\t\t\tchanges.push({ plugin: l.name, change: 'changed', before: prev.version, after: l.version });\n\t}\n\tfor (const [k, l] of old) {\n\t\tif (!now.has(k)) changes.push({ plugin: l.name, change: 'removed', before: l.version });\n\t}\n\treturn changes;\n}\n\nfunction diffComponents(before: DocumentInventory, after: DocumentInventory) {\n\tconst oldIds = new Set(before.components.map((c) => c.id.toLowerCase()));\n\tconst newIds = new Set(after.components.map((c) => c.id.toLowerCase()));\n\tconst countBy = (list: DocumentInventory['components'], skip: Set<string>) => {\n\t\tconst counts = new Map<string, number>();\n\t\tfor (const c of list) {\n\t\t\tif (!skip.has(c.id.toLowerCase())) counts.set(c.name, (counts.get(c.name) ?? 0) + 1);\n\t\t}\n\t\treturn [...counts]\n\t\t\t.map(([name, count]) => ({ name, count }))\n\t\t\t.sort((a, b) => b.count - a.count || a.name.localeCompare(b.name));\n\t};\n\treturn { added: countBy(after.components, oldIds), removed: countBy(before.components, newIds) };\n}\n\nfunction diffScripts(before: DocumentInventory, after: DocumentInventory): ScriptChange[] {\n\tconst old = new Map(before.scripts.map((s) => [s.id.toLowerCase(), s]));\n\tconst now = new Map(after.scripts.map((s) => [s.id.toLowerCase(), s]));\n\tconst changes: ScriptChange[] = [];\n\tfor (const [id, s] of now) {\n\t\tconst prev = old.get(id);\n\t\tif (!prev) {\n\t\t\tchanges.push({ ...scriptRef(s), change: 'added', linesAdded: s.lineCount, linesRemoved: 0 });\n\t\t} else if (prev.sha256 !== s.sha256) {\n\t\t\tconst { added, removed } = countLineChanges(prev.lineHashes, s.lineHashes);\n\t\t\tchanges.push({\n\t\t\t\t...scriptRef(s),\n\t\t\t\tchange: 'changed',\n\t\t\t\tlinesAdded: added,\n\t\t\t\tlinesRemoved: removed\n\t\t\t});\n\t\t}\n\t}\n\tfor (const [id, s] of old) {\n\t\tif (!now.has(id))\n\t\t\tchanges.push({\n\t\t\t\t...scriptRef(s),\n\t\t\t\tchange: 'removed',\n\t\t\t\tlinesAdded: 0,\n\t\t\t\tlinesRemoved: s.lineCount\n\t\t\t});\n\t}\n\treturn changes;\n}\n\nconst scriptRef = (s: DocumentInventory['scripts'][number]) => ({\n\tid: s.id,\n\tlabel: s.label,\n\tlanguage: s.language\n});\n\nfunction diffValues(\n\tbefore: DocumentInventory,\n\tafter: DocumentInventory,\n\tformIds: Set<string>\n): ValueChange[] {\n\tconst onForm = (v: InventoryValue) =>\n\t\tformIds.has(v.id.toLowerCase()) || (!!v.owner && formIds.has(v.owner.toLowerCase()));\n\tconst old = new Map(before.values.map((v) => [v.id.toLowerCase(), v]));\n\tconst changes: ValueChange[] = [];\n\t// Values added or removed come and go with their components, which the counts already show.\n\tfor (const v of after.values) {\n\t\tconst prev = old.get(v.id.toLowerCase());\n\t\tif (!prev || onForm(v)) continue;\n\t\tconst range =\n\t\t\tprev.min !== v.min || prev.max !== v.max\n\t\t\t\t? { before: `${prev.min ?? ''}–${prev.max ?? ''}`, after: `${v.min ?? ''}–${v.max ?? ''}` }\n\t\t\t\t: undefined;\n\t\tif (prev.sha256 === v.sha256 && !range) continue;\n\t\tchanges.push({\n\t\t\tid: v.id,\n\t\t\tlabel: v.label,\n\t\t\tkind: v.kind,\n\t\t\tbefore: prev.secrets?.length ? null : prev.text,\n\t\t\tafter: v.secrets?.length ? null : v.text,\n\t\t\t...(range && { range })\n\t\t});\n\t}\n\treturn changes;\n}\n\n// ============================================================================\n// Line diff\n// ============================================================================\n\nexport type LineOp = { op: 'same' | 'add' | 'remove'; text: string };\n\n/** Above this many cells the middle is compared as a multiset: close enough for a count. */\nconst LCS_CELL_LIMIT = 4_000_000;\n\n/** Lines added and removed between two sequences, by LCS. Works on hashes or text alike. */\nexport function countLineChanges(\n\tbefore: readonly string[],\n\tafter: readonly string[]\n): { added: number; removed: number } {\n\tlet added = 0;\n\tlet removed = 0;\n\tfor (const op of lineOps(before, after)) {\n\t\tif (op.op === 'add') added++;\n\t\telse if (op.op === 'remove') removed++;\n\t}\n\treturn { added, removed };\n}\n\n/** A line-by-line diff of two texts, for showing a script change. */\nexport function diffLines(before: string, after: string): LineOp[] {\n\tconst split = (s: string) => {\n\t\tconst lines = s.replace(/\\r\\n?/g, '\\n').split('\\n');\n\t\twhile (lines.length && !lines.at(-1)!.trim()) lines.pop();\n\t\treturn lines;\n\t};\n\treturn lineOps(split(before), split(after));\n}\n\nfunction lineOps(a: readonly string[], b: readonly string[]): LineOp[] {\n\tlet start = 0;\n\twhile (start < a.length && start < b.length && a[start] === b[start]) start++;\n\tlet endA = a.length;\n\tlet endB = b.length;\n\twhile (endA > start && endB > start && a[endA - 1] === b[endB - 1]) {\n\t\tendA--;\n\t\tendB--;\n\t}\n\n\tconst head = a.slice(0, start).map((text) => ({ op: 'same' as const, text }));\n\tconst tail = a.slice(endA).map((text) => ({ op: 'same' as const, text }));\n\tconst midA = a.slice(start, endA);\n\tconst midB = b.slice(start, endB);\n\n\tconst middle =\n\t\tmidA.length * midB.length > LCS_CELL_LIMIT ? multisetOps(midA, midB) : lcsOps(midA, midB);\n\treturn [...head, ...middle, ...tail];\n}\n\nfunction lcsOps(a: readonly string[], b: readonly string[]): LineOp[] {\n\tconst n = a.length;\n\tconst m = b.length;\n\t// lengths[i][j] = LCS of a[i..] and b[j..], flattened.\n\tconst lengths = new Uint32Array((n + 1) * (m + 1));\n\tfor (let i = n - 1; i >= 0; i--) {\n\t\tfor (let j = m - 1; j >= 0; j--) {\n\t\t\tlengths[i * (m + 1) + j] =\n\t\t\t\ta[i] === b[j]\n\t\t\t\t\t? lengths[(i + 1) * (m + 1) + j + 1] + 1\n\t\t\t\t\t: Math.max(lengths[(i + 1) * (m + 1) + j], lengths[i * (m + 1) + j + 1]);\n\t\t}\n\t}\n\tconst ops: LineOp[] = [];\n\tlet i = 0;\n\tlet j = 0;\n\twhile (i < n && j < m) {\n\t\tif (a[i] === b[j]) {\n\t\t\tops.push({ op: 'same', text: a[i] });\n\t\t\ti++;\n\t\t\tj++;\n\t\t} else if (lengths[(i + 1) * (m + 1) + j] >= lengths[i * (m + 1) + j + 1]) {\n\t\t\tops.push({ op: 'remove', text: a[i++] });\n\t\t} else {\n\t\t\tops.push({ op: 'add', text: b[j++] });\n\t\t}\n\t}\n\twhile (i < n) ops.push({ op: 'remove', text: a[i++] });\n\twhile (j < m) ops.push({ op: 'add', text: b[j++] });\n\treturn ops;\n}\n\nfunction multisetOps(a: readonly string[], b: readonly string[]): LineOp[] {\n\tconst left = new Map<string, number>();\n\tfor (const line of b) left.set(line, (left.get(line) ?? 0) + 1);\n\tconst ops: LineOp[] = [];\n\tfor (const line of a) {\n\t\tconst n = left.get(line) ?? 0;\n\t\tif (n > 0) left.set(line, n - 1);\n\t\telse ops.push({ op: 'remove', text: line });\n\t}\n\tconst kept = new Map<string, number>();\n\tfor (const line of a) kept.set(line, (kept.get(line) ?? 0) + 1);\n\tfor (const line of b) {\n\t\tconst n = kept.get(line) ?? 0;\n\t\tif (n > 0) kept.set(line, n - 1);\n\t\telse ops.push({ op: 'add', text: line });\n\t}\n\treturn ops;\n}\n\n// ============================================================================\n// Release notes\n// ============================================================================\n\n/** \"Inside the definition\" as Markdown list items, for release notes. Empty when identical. */\nexport function inventoryDiffToMarkdown(diff: InventoryDiff): string {\n\tconst lines: string[] = [];\n\tfor (const p of diff.plugins) {\n\t\tlines.push(\n\t\t\tp.change === 'added'\n\t\t\t\t? `- Uses ${p.plugin} ${p.after}`\n\t\t\t\t: p.change === 'removed'\n\t\t\t\t\t? `- No longer uses ${p.plugin}`\n\t\t\t\t\t: `- ${p.plugin} ${p.before} → ${p.after}`\n\t\t);\n\t}\n\tconst counts = (list: ComponentCount[], sign: string) =>\n\t\tlist.map((c) => `${sign}${c.count > 1 ? `${c.count} ` : ''}${c.name}`).join(', ');\n\tif (diff.components.added.length)\n\t\tlines.push(`- Components added: ${counts(diff.components.added, '+')}`);\n\tif (diff.components.removed.length)\n\t\tlines.push(`- Components removed: ${counts(diff.components.removed, '−')}`);\n\tfor (const s of diff.scripts) {\n\t\tlines.push(\n\t\t\ts.change === 'changed'\n\t\t\t\t? `- Script **${s.label}** edited (+${s.linesAdded} −${s.linesRemoved} lines)`\n\t\t\t\t: `- Script **${s.label}** ${s.change}`\n\t\t);\n\t}\n\tfor (const v of diff.values) {\n\t\tconst text = (t: string | null) => (t === null ? '(hidden)' : `\\`${oneLine(t)}\\``);\n\t\tlines.push(`- **${v.label}** ${text(v.before)} → ${text(v.after)}`);\n\t}\n\tif (diff.wires.changed && !lines.length) lines.push('- Wiring changed');\n\treturn lines.join('\\n');\n}\n\nconst oneLine = (text: string) => {\n\tconst line = text.replace(/\\s+/g, ' ').replace(/`/g, \"'\").trim();\n\treturn line.length > 60 ? `${line.slice(0, 59)}…` : line;\n};\n"],"mappings":";AAwEA,SAAgB,iBAAiB,GAAoD;CACpF,OAAO,EAAE,UAAU;AACpB;AAEA,SAAgB,YAAY,GAA+C;CAC1E,OAAO,EAAE,UAAU;AACpB;;;;;;;ACvEA,SAAgB,iBACf,QACA,OACwB;CACxB,OAAO,OAAO,QAAQ,QAAQ,MAAM;EACnC,IAAI,iBAAiB,CAAC,GAAG;GACxB,IAAI,EAAE,OAAO,OAAO,iBAAiB,OAAO;GAC5C,IAAI,EAAE,eAAe,OAAO,OAAO;GACnC,IAAI,SAAS,EAAE,WAAW,SAAS,KAAK,GAAG,OAAO;GAClD,OAAO;EACR;EAEA,OAAO,CAAC,CAAC,SAAS,EAAE,eAAe;CACpC,CAAC;AACF;;;;;AAMA,SAAgB,mBACf,QACA,OACqB;CACrB,MAAM,UAAU,iBAAiB,QAAQ,KAAK;CAC9C,MAAM,aAAa,IAAI,IAAI,QAAQ,KAAK,MAAM,EAAE,EAAE,CAAC;CAEnD,IAAI,OAAO;EACV,MAAM,YAAY,OAAO,cAAc;EACvC,IAAI,aAAa,WAAW,IAAI,SAAS,GAAG,OAAO;CACpD;CACA,IAAI,OAAO,mBAAmB,WAAW,IAAI,OAAO,eAAe,GAClE,OAAO,OAAO;AAGhB;;;;;;AAYA,SAAgB,WACf,SACA,WACA,KACgB;CAEhB,OAAO,QAAQ,MAAM,MAAM,EAAE,OAAO,GAAG,KAAK,QAAQ,MAAM,MAAM,EAAE,OAAO,SAAS,KAAK,QAAQ;AAChG;;;;;;;;;;AAWA,SAAgB,oBACf,QACA,OACA,OAAuB,CAAC,GACF;CAEtB,MAAM,SAAS,WADC,iBAAiB,QAAQ,KACf,GAAS,mBAAmB,QAAQ,KAAK,GAAG,KAAK,aAAa;CACxF,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,4DAA4D;CACzF,OAAO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AAK,KAAK,SACpB,MAAM,KACL,EAAE,WAAW,YACV,cAAc,EAAE,MAAM,cAAc,EAAE,WAAW,IAAI,EAAE,aAAa,WACpE,cAAc,EAAE,MAAM,KAAK,EAAE,QACjC;CAED,KAAK,MAAM,KAAK,KAAK,QAAQ;EAC5B,MAAM,QAAQ,MAAsB,MAAM,OAAO,aAAa,KAAK,QAAQ,CAAC,EAAE;EAC9E,MAAM,KAAK,OAAO,EAAE,MAAM,KAAK,KAAK,EAAE,MAAM,EAAE,KAAK,KAAK,EAAE,KAAK,GAAG;CACnE;CACA,IAAI,KAAK,MAAM,WAAW,CAAC,MAAM,QAAQ,MAAM,KAAK,kBAAkB;CACtE,OAAO,MAAM,KAAK,IAAI;AACvB;AAEA,IAAM,WAAW,SAAiB;CACjC,MAAM,OAAO,KAAK,QAAQ,QAAQ,GAAG,CAAC,CAAC,QAAQ,MAAM,GAAG,CAAC,CAAC,KAAK;CAC/D,OAAO,KAAK,SAAS,KAAK,GAAG,KAAK,MAAM,GAAG,EAAE,EAAE,KAAK;AACrD"}
|
|
1
|
+
{"version":3,"file":"inventory.js","names":[],"sources":["../../../../platform/src/computeServer/types.ts","../../../../platform/src/computeServer/utils.ts","../../../../schemas/src/inventory.ts"],"sourcesContent":["/**\n * Compute servers belong to one of two scopes — never both.\n *\n * - **Platform server** (`scope: 'platform'`) — created by `manage_compute`.\n * `sharedWith` controls which orgs see it. The global `defaultServerId`\n * (in {@link ComputeConfig}) must reference a platform server and is\n * *always* visible to every org regardless of `sharedWith`.\n *\n * - **Org-private server** (`scope: 'org'`) — created by an org owner/admin\n * with `manage_org_compute`. Visible only to its `ownerOrgId`. Gated by\n * the `ALLOW_ORG_COMPUTE_OVERRIDE` platform flag.\n */\nexport type ComputeServerConfig = PlatformComputeServer | OrgComputeServer;\n\ninterface ComputeServerCommon {\n\tid: string;\n\tlabel: string;\n\t/** Base URL of the Rhino.Compute instance. */\n\tserverUrl: string;\n\t/**\n\t * Sent as the `RhinoComputeKey` header. Populated only when the config was\n\t * read with `includeApiKeys` — `undefined` means \"not loaded\" as often as\n\t * it means \"none stored\"; use {@link ComputeServerCommon.hasApiKey} to\n\t * tell those apart.\n\t */\n\tapiKey?: string;\n\t/**\n\t * Whether a key is stored, independent of whether `apiKey` was loaded —\n\t * lets pickers and admin pages show \"key set\" without decrypting a secret\n\t * they'd only throw away.\n\t */\n\thasApiKey?: boolean;\n}\n\nexport interface PlatformComputeServer extends ComputeServerCommon {\n\tscope: 'platform';\n\t/**\n\t * Which orgs can see this server in pickers / use it for solves.\n\t * - `'all'` — every org. Default in `tenancy: 'single'`.\n\t * - `string[]` — explicit org-id allowlist. `[]` = dormant\n\t * (admin-only) unless this server is the global `defaultServerId`,\n\t * which is always usable everywhere.\n\t */\n\tsharedWith: 'all' | string[];\n}\n\nexport interface OrgComputeServer extends ComputeServerCommon {\n\tscope: 'org';\n\t/** The org that owns this server. Visible only to members of this org. */\n\townerOrgId: string;\n}\n\nexport interface ComputeConfig {\n\tservers: ComputeServerConfig[];\n\t/**\n\t * Global default. Must reference a platform server. Usable by every org\n\t * regardless of that server's `sharedWith` — the baseline every user falls\n\t * back to.\n\t */\n\tdefaultServerId?: string;\n\t/**\n\t * Per-org default override. `orgDefaults[orgId]` must reference a server\n\t * visible to `orgId` (a platform server with `orgId` in `sharedWith` or\n\t * `'all'`, or an org server owned by `orgId`).\n\t */\n\torgDefaults?: Record<string, string>;\n}\n\n// ============================================================================\n// Type guards\n// ============================================================================\n\nexport function isPlatformServer(s: ComputeServerConfig): s is PlatformComputeServer {\n\treturn s.scope === 'platform';\n}\n\nexport function isOrgServer(s: ComputeServerConfig): s is OrgComputeServer {\n\treturn s.scope === 'org';\n}\n","import { isPlatformServer, type ComputeConfig, type ComputeServerConfig } from './types.js';\n\n/**\n * Servers an org can see in pickers and use for solves:\n * platform servers shared with this org (or `'all'`, or the global default)\n * ∪ org-private servers owned by this org.\n */\nexport function serversVisibleTo(\n\tconfig: ComputeConfig,\n\torgId: string | null | undefined\n): ComputeServerConfig[] {\n\treturn config.servers.filter((s) => {\n\t\tif (isPlatformServer(s)) {\n\t\t\tif (s.id === config.defaultServerId) return true;\n\t\t\tif (s.sharedWith === 'all') return true;\n\t\t\tif (orgId && s.sharedWith.includes(orgId)) return true;\n\t\t\treturn false;\n\t\t}\n\t\t// Org-private — visible only to its owner org.\n\t\treturn !!orgId && s.ownerOrgId === orgId;\n\t});\n}\n\n/**\n * Resolves the default server id for an org: per-org override, then global\n * default. Returns `undefined` if neither is set or visible.\n */\nexport function defaultServerIdFor(\n\tconfig: ComputeConfig,\n\torgId: string | null | undefined\n): string | undefined {\n\tconst visible = serversVisibleTo(config, orgId);\n\tconst visibleIds = new Set(visible.map((s) => s.id));\n\n\tif (orgId) {\n\t\tconst orgChoice = config.orgDefaults?.[orgId];\n\t\tif (orgChoice && visibleIds.has(orgChoice)) return orgChoice;\n\t}\n\tif (config.defaultServerId && visibleIds.has(config.defaultServerId)) {\n\t\treturn config.defaultServerId;\n\t}\n\treturn undefined;\n}\n\nexport interface ResolveOptions {\n\t/** Per-definition pin. Falls through silently if not visible. */\n\tdefinitionPin?: string | null;\n}\n\n/**\n * From servers already filtered for visibility, the pin if it is among them, then\n * the default, then the first. Only for a caller holding the filtered list: use\n * {@link resolveServerForOrg} when you have the config.\n */\nexport function pickServer<T extends { id: string }>(\n\tvisible: readonly T[],\n\tdefaultId: string | null | undefined,\n\tpin: string | null | undefined\n): T | undefined {\n\t// A pin can go stale when an admin un-shares the server, so it falls through.\n\treturn visible.find((s) => s.id === pin) ?? visible.find((s) => s.id === defaultId) ?? visible[0];\n}\n\n/**\n * Resolves a definition's compute server, in order:\n * 1. Definition pin (`computeServerId`) if visible to the project's org.\n * 2. `orgDefaults[orgId]` if set.\n * 3. Global `defaultServerId`.\n * 4. The first visible server, mainly before a default is chosen.\n *\n * Throws if no usable server exists.\n */\nexport function resolveServerForOrg(\n\tconfig: ComputeConfig,\n\torgId: string | null | undefined,\n\topts: ResolveOptions = {}\n): ComputeServerConfig {\n\tconst visible = serversVisibleTo(config, orgId);\n\tconst server = pickServer(visible, defaultServerIdFor(config, orgId), opts.definitionPin);\n\tif (!server) throw new Error('No compute servers are configured or visible for this org.');\n\treturn server;\n}\n\n/**\n * The config as one org may see it: visible servers only, `orgDefaults` reduced\n * to this org's own entry, and `defaultServerId` dropped when the global default\n * is not visible here.\n *\n * Applied inside `getConfig` when `scopeToOrgId` is passed, so an org-facing\n * caller cannot forget the filter and leak other orgs' server URLs or the\n * instance's default choice.\n */\nexport function scopeConfigToOrg(config: ComputeConfig, orgId: string): ComputeConfig {\n\tconst servers = serversVisibleTo(config, orgId);\n\tconst visibleIds = new Set(servers.map((s) => s.id));\n\tconst orgDefault = config.orgDefaults?.[orgId];\n\n\treturn {\n\t\tservers,\n\t\tdefaultServerId:\n\t\t\tconfig.defaultServerId && visibleIds.has(config.defaultServerId)\n\t\t\t\t? config.defaultServerId\n\t\t\t\t: undefined,\n\t\torgDefaults: orgDefault && visibleIds.has(orgDefault) ? { [orgId]: orgDefault } : {}\n\t};\n}\n\n/** Lookup by id, ignoring scope or visibility — for admin contexts that display a server outside the visibility filter. */\nexport function findServerById(config: ComputeConfig, id: string): ComputeServerConfig | undefined {\n\treturn config.servers.find((s) => s.id === id);\n}\n\n// ============================================================================\n// Filters\n// ============================================================================\n\nexport function platformServers(config: ComputeConfig) {\n\treturn config.servers.filter(isPlatformServer);\n}\n","// What a .gh holds beyond its form, and what changed in it: the plugins, components, values set on\n// the canvas, scripts and wiring that the form diff cannot see. The inventory itself comes from the\n// plugin on Compute (`DocumentInventory` in wire-schema.json); everything here is pure.\n//\n// Objects match by InstanceGuid, as in the form diff. Script source is never in the inventory:\n// only per-line hashes, which are enough to count added and removed lines.\n\nimport type { DocumentInventory, InventoryValue } from './generated/index.js';\n\n// ============================================================================\n// Warnings about one file\n// ============================================================================\n\nexport type InventoryWarning =\n\t| { kind: 'missingPlugin'; plugin: string; version: string }\n\t| {\n\t\t\tkind: 'unloaded';\n\t\t\tcomponent: string;\n\t\t\tplugin: string | null;\n\t\t\t/** What the file was saved with, and what the server runs; null when unknown. */\n\t\t\tversion: string | null;\n\t\t\tserverVersion: string | null;\n\t\t\tcount: number;\n\t }\n\t| { kind: 'pluginVersion'; plugin: string; version: string; serverVersion: string }\n\t| { kind: 'obsolete'; component: string; plugin: string | null; count: number }\n\t| { kind: 'secret'; in: 'script' | 'value'; label: string; rules: string[] };\n\n/** Missing plugins and components first: they are the ones that make solves fail. */\nexport function inventoryWarnings(inventory: DocumentInventory): InventoryWarning[] {\n\tconst warnings: InventoryWarning[] = [];\n\tconst libraryById = librariesById(inventory);\n\tconst plugins = inventory.libraries.filter((l) => !l.core);\n\n\tfor (const lib of plugins) {\n\t\tif (!lib.serverVersion)\n\t\t\twarnings.push({ kind: 'missingPlugin', plugin: lib.name, version: lib.version });\n\t}\n\n\tconst unloaded = new Map<string, Extract<InventoryWarning, { kind: 'unloaded' }>>();\n\tfor (const o of unloadedOfLoadedPlugins(inventory)) {\n\t\tconst lib = o.library ? libraryById.get(o.library.toLowerCase()) : undefined;\n\t\tconst key = `${o.name}\\u0000${o.library ?? ''}`;\n\t\tconst entry = unloaded.get(key) ?? {\n\t\t\tkind: 'unloaded',\n\t\t\tcomponent: o.name,\n\t\t\tplugin: lib?.name ?? null,\n\t\t\tversion: lib?.version ?? null,\n\t\t\tserverVersion: lib?.serverVersion ?? null,\n\t\t\tcount: 0\n\t\t};\n\t\tentry.count += 1;\n\t\tunloaded.set(key, entry);\n\t}\n\twarnings.push(...unloaded.values());\n\n\tfor (const lib of plugins) {\n\t\tif (lib.serverVersion && lib.serverVersion !== lib.version)\n\t\t\twarnings.push({\n\t\t\t\tkind: 'pluginVersion',\n\t\t\t\tplugin: lib.name,\n\t\t\t\tversion: lib.version,\n\t\t\t\tserverVersion: lib.serverVersion\n\t\t\t});\n\t}\n\n\tconst obsolete = new Map<string, { plugin: string | null; count: number }>();\n\tfor (const c of inventory.components) {\n\t\tif (!c.obsolete) continue;\n\t\tconst entry = obsolete.get(c.name) ?? {\n\t\t\tplugin: (c.library && libraryById.get(c.library.toLowerCase())?.name) || null,\n\t\t\tcount: 0\n\t\t};\n\t\tentry.count += 1;\n\t\tobsolete.set(c.name, entry);\n\t}\n\tfor (const [component, { plugin, count }] of obsolete) {\n\t\twarnings.push({ kind: 'obsolete', component, plugin, count });\n\t}\n\n\tfor (const s of inventory.scripts) {\n\t\tif (s.secrets.length)\n\t\t\twarnings.push({ kind: 'secret', in: 'script', label: s.label, rules: s.secrets });\n\t}\n\tfor (const v of inventory.values) {\n\t\tif (v.secrets?.length)\n\t\t\twarnings.push({ kind: 'secret', in: 'value', label: v.label, rules: v.secrets });\n\t}\n\treturn warnings;\n}\n\nexport function inventoryWarningText(w: InventoryWarning): string {\n\tswitch (w.kind) {\n\t\tcase 'missingPlugin':\n\t\t\treturn `${w.plugin} ${w.version} is not installed on the Compute server: its components are dropped and solves miss their outputs.`;\n\t\tcase 'unloaded': {\n\t\t\tconst what = `${w.count > 1 ? `${w.count}× ` : ''}${w.component}`;\n\t\t\tif (!w.plugin)\n\t\t\t\treturn `${what} did not load on the Compute server: no plugin it has provides it, so solves skip it and miss what it computes.`;\n\t\t\tconst versions =\n\t\t\t\tw.version && w.serverVersion && w.version !== w.serverVersion\n\t\t\t\t\t? ` The file was saved with ${w.plugin} ${w.version}; the server runs ${w.serverVersion}, which lacks it.`\n\t\t\t\t\t: '';\n\t\t\treturn `${what} (${w.plugin}) did not load on the Compute server, so solves skip it and miss what it computes.${versions} Install a ${w.plugin} release that has it.`;\n\t\t}\n\t\tcase 'pluginVersion':\n\t\t\treturn `Saved with ${w.plugin} ${w.version}; the Compute server runs ${w.serverVersion}.`;\n\t\tcase 'obsolete':\n\t\t\treturn `${w.count > 1 ? `${w.count}× ` : ''}${w.component}${w.plugin ? ` (${w.plugin})` : ''} is obsolete. Open and re-save the file in Grasshopper to upgrade it.`;\n\t\tcase 'secret':\n\t\t\treturn `${w.in === 'script' ? 'Script' : 'Value'} \"${w.label}\" looks like it holds a secret (${w.rules.join(', ')}). Anyone who can download the file can read it.`;\n\t}\n}\n\nconst librariesById = (inventory: DocumentInventory) =>\n\tnew Map(inventory.libraries.map((l) => [l.id.toLowerCase(), l]));\n\n/**\n * Objects that did not load, less those of a plugin the server lacks altogether: the missing\n * plugin already explains them.\n */\nfunction unloadedOfLoadedPlugins(inventory: DocumentInventory) {\n\tconst missing = new Set(\n\t\tinventory.libraries.filter((l) => !l.core && !l.serverVersion).map((l) => l.id.toLowerCase())\n\t);\n\treturn (inventory.unloaded ?? []).filter(\n\t\t(o) => !o.library || !missing.has(o.library.toLowerCase())\n\t);\n}\n\n/**\n * Objects that did not load although the server runs the plugin the file names for them: that\n * release lacks them. Core components, and those whose plugin the file does not name, are left\n * out: a Compute server that cannot load a core component (one that needs Windows, say) never\n * will, and no plugin install changes that.\n */\nfunction unloadedOfInstalledPlugins(inventory: DocumentInventory) {\n\tconst libraryById = librariesById(inventory);\n\treturn (inventory.unloaded ?? []).filter((o) => {\n\t\tconst lib = o.library ? libraryById.get(o.library.toLowerCase()) : undefined;\n\t\treturn !!lib && !lib.core && !!lib.serverVersion;\n\t});\n}\n\n/** What the version list shows without loading the inventory. */\nexport interface InventorySummary {\n\t/** Plugins the file needs that the Compute server had not loaded at the last check. */\n\tmissingPlugins: string[];\n\t/**\n\t * Components the server could not create although their plugin loaded: an older release\n\t * lacks them. Absent from summaries stored before it was counted.\n\t */\n\tunloadedComponents?: string[];\n\tobsoleteComponents: number;\n}\n\nexport function summarizeInventory(inventory: DocumentInventory): InventorySummary {\n\treturn {\n\t\tmissingPlugins: inventory.libraries\n\t\t\t.filter((l) => !l.core && !l.serverVersion)\n\t\t\t.map((l) => l.name),\n\t\tunloadedComponents: [...new Set(unloadedOfInstalledPlugins(inventory).map((o) => o.name))],\n\t\tobsoleteComponents: inventory.components.filter((c) => c.obsolete).length\n\t};\n}\n\n// ============================================================================\n// What changed between two files\n// ============================================================================\n\nexport interface PluginChange {\n\tplugin: string;\n\tchange: 'added' | 'removed' | 'changed';\n\tbefore?: string;\n\tafter?: string;\n}\n\nexport interface ComponentCount {\n\tname: string;\n\tcount: number;\n}\n\nexport interface ScriptChange {\n\tid: string;\n\tlabel: string;\n\tlanguage: string;\n\tchange: 'added' | 'removed' | 'changed';\n\tlinesAdded: number;\n\tlinesRemoved: number;\n}\n\nexport interface ValueChange {\n\tid: string;\n\tlabel: string;\n\tkind: InventoryValue['kind'];\n\t/** Text as stored: cut at 500 characters, and `null` where it looked like a secret. */\n\tbefore: string | null;\n\tafter: string | null;\n\t/** Slider range, when it changed. */\n\trange?: { before: string; after: string };\n}\n\nexport interface InventoryDiff {\n\tplugins: PluginChange[];\n\tcomponents: { added: ComponentCount[]; removed: ComponentCount[] };\n\tscripts: ScriptChange[];\n\tvalues: ValueChange[];\n\twires: { before: number; after: number; changed: boolean };\n\tidentical: boolean;\n}\n\nexport interface InventoryDiffOptions {\n\t/**\n\t * Ids of form inputs. Their values are the form diff's to report, so values on those objects,\n\t * or on their input parameters, are left out here.\n\t */\n\tformIds?: Iterable<string>;\n}\n\nexport function diffInventories(\n\tbefore: DocumentInventory,\n\tafter: DocumentInventory,\n\toptions: InventoryDiffOptions = {}\n): InventoryDiff {\n\tconst formIds = new Set([...(options.formIds ?? [])].map((id) => id.toLowerCase()));\n\tconst plugins = diffPlugins(before, after);\n\tconst components = diffComponents(before, after);\n\tconst scripts = diffScripts(before, after);\n\tconst values = diffValues(before, after, formIds);\n\tconst wires = {\n\t\tbefore: before.wires.count,\n\t\tafter: after.wires.count,\n\t\tchanged: before.wires.sha256 !== after.wires.sha256\n\t};\n\treturn {\n\t\tplugins,\n\t\tcomponents,\n\t\tscripts,\n\t\tvalues,\n\t\twires,\n\t\tidentical:\n\t\t\t!plugins.length &&\n\t\t\t!components.added.length &&\n\t\t\t!components.removed.length &&\n\t\t\t!scripts.length &&\n\t\t\t!values.length &&\n\t\t\t!wires.changed\n\t};\n}\n\nfunction diffPlugins(before: DocumentInventory, after: DocumentInventory): PluginChange[] {\n\tconst key = (l: { id: string; name: string }) =>\n\t\t/^0{8}-/.test(l.id) ? `name:${l.name}` : l.id.toLowerCase();\n\tconst old = new Map(before.libraries.map((l) => [key(l), l]));\n\tconst now = new Map(after.libraries.map((l) => [key(l), l]));\n\tconst changes: PluginChange[] = [];\n\tfor (const [k, l] of now) {\n\t\tconst prev = old.get(k);\n\t\tif (!prev) changes.push({ plugin: l.name, change: 'added', after: l.version });\n\t\telse if (prev.version !== l.version)\n\t\t\tchanges.push({ plugin: l.name, change: 'changed', before: prev.version, after: l.version });\n\t}\n\tfor (const [k, l] of old) {\n\t\tif (!now.has(k)) changes.push({ plugin: l.name, change: 'removed', before: l.version });\n\t}\n\treturn changes;\n}\n\nfunction diffComponents(before: DocumentInventory, after: DocumentInventory) {\n\tconst oldIds = new Set(before.components.map((c) => c.id.toLowerCase()));\n\tconst newIds = new Set(after.components.map((c) => c.id.toLowerCase()));\n\tconst countBy = (list: DocumentInventory['components'], skip: Set<string>) => {\n\t\tconst counts = new Map<string, number>();\n\t\tfor (const c of list) {\n\t\t\tif (!skip.has(c.id.toLowerCase())) counts.set(c.name, (counts.get(c.name) ?? 0) + 1);\n\t\t}\n\t\treturn [...counts]\n\t\t\t.map(([name, count]) => ({ name, count }))\n\t\t\t.sort((a, b) => b.count - a.count || a.name.localeCompare(b.name));\n\t};\n\treturn { added: countBy(after.components, oldIds), removed: countBy(before.components, newIds) };\n}\n\nfunction diffScripts(before: DocumentInventory, after: DocumentInventory): ScriptChange[] {\n\tconst old = new Map(before.scripts.map((s) => [s.id.toLowerCase(), s]));\n\tconst now = new Map(after.scripts.map((s) => [s.id.toLowerCase(), s]));\n\tconst changes: ScriptChange[] = [];\n\tfor (const [id, s] of now) {\n\t\tconst prev = old.get(id);\n\t\tif (!prev) {\n\t\t\tchanges.push({ ...scriptRef(s), change: 'added', linesAdded: s.lineCount, linesRemoved: 0 });\n\t\t} else if (prev.sha256 !== s.sha256) {\n\t\t\tconst { added, removed } = countLineChanges(prev.lineHashes, s.lineHashes);\n\t\t\tchanges.push({\n\t\t\t\t...scriptRef(s),\n\t\t\t\tchange: 'changed',\n\t\t\t\tlinesAdded: added,\n\t\t\t\tlinesRemoved: removed\n\t\t\t});\n\t\t}\n\t}\n\tfor (const [id, s] of old) {\n\t\tif (!now.has(id))\n\t\t\tchanges.push({\n\t\t\t\t...scriptRef(s),\n\t\t\t\tchange: 'removed',\n\t\t\t\tlinesAdded: 0,\n\t\t\t\tlinesRemoved: s.lineCount\n\t\t\t});\n\t}\n\treturn changes;\n}\n\nconst scriptRef = (s: DocumentInventory['scripts'][number]) => ({\n\tid: s.id,\n\tlabel: s.label,\n\tlanguage: s.language\n});\n\nfunction diffValues(\n\tbefore: DocumentInventory,\n\tafter: DocumentInventory,\n\tformIds: Set<string>\n): ValueChange[] {\n\tconst onForm = (v: InventoryValue) =>\n\t\tformIds.has(v.id.toLowerCase()) || (!!v.owner && formIds.has(v.owner.toLowerCase()));\n\tconst old = new Map(before.values.map((v) => [v.id.toLowerCase(), v]));\n\tconst changes: ValueChange[] = [];\n\t// Values added or removed come and go with their components, which the counts already show.\n\tfor (const v of after.values) {\n\t\tconst prev = old.get(v.id.toLowerCase());\n\t\tif (!prev || onForm(v)) continue;\n\t\tconst range =\n\t\t\tprev.min !== v.min || prev.max !== v.max\n\t\t\t\t? { before: `${prev.min ?? ''}–${prev.max ?? ''}`, after: `${v.min ?? ''}–${v.max ?? ''}` }\n\t\t\t\t: undefined;\n\t\tif (prev.sha256 === v.sha256 && !range) continue;\n\t\tchanges.push({\n\t\t\tid: v.id,\n\t\t\tlabel: v.label,\n\t\t\tkind: v.kind,\n\t\t\tbefore: prev.secrets?.length ? null : prev.text,\n\t\t\tafter: v.secrets?.length ? null : v.text,\n\t\t\t...(range && { range })\n\t\t});\n\t}\n\treturn changes;\n}\n\n// ============================================================================\n// Line diff\n// ============================================================================\n\nexport type LineOp = { op: 'same' | 'add' | 'remove'; text: string };\n\n/** Above this many cells the middle is compared as a multiset: close enough for a count. */\nconst LCS_CELL_LIMIT = 4_000_000;\n\n/** Lines added and removed between two sequences, by LCS. Works on hashes or text alike. */\nexport function countLineChanges(\n\tbefore: readonly string[],\n\tafter: readonly string[]\n): { added: number; removed: number } {\n\tlet added = 0;\n\tlet removed = 0;\n\tfor (const op of lineOps(before, after)) {\n\t\tif (op.op === 'add') added++;\n\t\telse if (op.op === 'remove') removed++;\n\t}\n\treturn { added, removed };\n}\n\n/** A line-by-line diff of two texts, for showing a script change. */\nexport function diffLines(before: string, after: string): LineOp[] {\n\tconst split = (s: string) => {\n\t\tconst lines = s.replace(/\\r\\n?/g, '\\n').split('\\n');\n\t\twhile (lines.length && !lines.at(-1)!.trim()) lines.pop();\n\t\treturn lines;\n\t};\n\treturn lineOps(split(before), split(after));\n}\n\nfunction lineOps(a: readonly string[], b: readonly string[]): LineOp[] {\n\tlet start = 0;\n\twhile (start < a.length && start < b.length && a[start] === b[start]) start++;\n\tlet endA = a.length;\n\tlet endB = b.length;\n\twhile (endA > start && endB > start && a[endA - 1] === b[endB - 1]) {\n\t\tendA--;\n\t\tendB--;\n\t}\n\n\tconst head = a.slice(0, start).map((text) => ({ op: 'same' as const, text }));\n\tconst tail = a.slice(endA).map((text) => ({ op: 'same' as const, text }));\n\tconst midA = a.slice(start, endA);\n\tconst midB = b.slice(start, endB);\n\n\tconst middle =\n\t\tmidA.length * midB.length > LCS_CELL_LIMIT ? multisetOps(midA, midB) : lcsOps(midA, midB);\n\treturn [...head, ...middle, ...tail];\n}\n\nfunction lcsOps(a: readonly string[], b: readonly string[]): LineOp[] {\n\tconst n = a.length;\n\tconst m = b.length;\n\t// lengths[i][j] = LCS of a[i..] and b[j..], flattened.\n\tconst lengths = new Uint32Array((n + 1) * (m + 1));\n\tfor (let i = n - 1; i >= 0; i--) {\n\t\tfor (let j = m - 1; j >= 0; j--) {\n\t\t\tlengths[i * (m + 1) + j] =\n\t\t\t\ta[i] === b[j]\n\t\t\t\t\t? lengths[(i + 1) * (m + 1) + j + 1] + 1\n\t\t\t\t\t: Math.max(lengths[(i + 1) * (m + 1) + j], lengths[i * (m + 1) + j + 1]);\n\t\t}\n\t}\n\tconst ops: LineOp[] = [];\n\tlet i = 0;\n\tlet j = 0;\n\twhile (i < n && j < m) {\n\t\tif (a[i] === b[j]) {\n\t\t\tops.push({ op: 'same', text: a[i] });\n\t\t\ti++;\n\t\t\tj++;\n\t\t} else if (lengths[(i + 1) * (m + 1) + j] >= lengths[i * (m + 1) + j + 1]) {\n\t\t\tops.push({ op: 'remove', text: a[i++] });\n\t\t} else {\n\t\t\tops.push({ op: 'add', text: b[j++] });\n\t\t}\n\t}\n\twhile (i < n) ops.push({ op: 'remove', text: a[i++] });\n\twhile (j < m) ops.push({ op: 'add', text: b[j++] });\n\treturn ops;\n}\n\nfunction multisetOps(a: readonly string[], b: readonly string[]): LineOp[] {\n\tconst left = new Map<string, number>();\n\tfor (const line of b) left.set(line, (left.get(line) ?? 0) + 1);\n\tconst ops: LineOp[] = [];\n\tfor (const line of a) {\n\t\tconst n = left.get(line) ?? 0;\n\t\tif (n > 0) left.set(line, n - 1);\n\t\telse ops.push({ op: 'remove', text: line });\n\t}\n\tconst kept = new Map<string, number>();\n\tfor (const line of a) kept.set(line, (kept.get(line) ?? 0) + 1);\n\tfor (const line of b) {\n\t\tconst n = kept.get(line) ?? 0;\n\t\tif (n > 0) kept.set(line, n - 1);\n\t\telse ops.push({ op: 'add', text: line });\n\t}\n\treturn ops;\n}\n\n// ============================================================================\n// Release notes\n// ============================================================================\n\n/** \"Inside the definition\" as Markdown list items, for release notes. Empty when identical. */\nexport function inventoryDiffToMarkdown(diff: InventoryDiff): string {\n\tconst lines: string[] = [];\n\tfor (const p of diff.plugins) {\n\t\tlines.push(\n\t\t\tp.change === 'added'\n\t\t\t\t? `- Uses ${p.plugin} ${p.after}`\n\t\t\t\t: p.change === 'removed'\n\t\t\t\t\t? `- No longer uses ${p.plugin}`\n\t\t\t\t\t: `- ${p.plugin} ${p.before} → ${p.after}`\n\t\t);\n\t}\n\tconst counts = (list: ComponentCount[], sign: string) =>\n\t\tlist.map((c) => `${sign}${c.count > 1 ? `${c.count} ` : ''}${c.name}`).join(', ');\n\tif (diff.components.added.length)\n\t\tlines.push(`- Components added: ${counts(diff.components.added, '+')}`);\n\tif (diff.components.removed.length)\n\t\tlines.push(`- Components removed: ${counts(diff.components.removed, '−')}`);\n\tfor (const s of diff.scripts) {\n\t\tlines.push(\n\t\t\ts.change === 'changed'\n\t\t\t\t? `- Script **${s.label}** edited (+${s.linesAdded} −${s.linesRemoved} lines)`\n\t\t\t\t: `- Script **${s.label}** ${s.change}`\n\t\t);\n\t}\n\tfor (const v of diff.values) {\n\t\tconst text = (t: string | null) => (t === null ? '(hidden)' : `\\`${oneLine(t)}\\``);\n\t\tlines.push(`- **${v.label}** ${text(v.before)} → ${text(v.after)}`);\n\t}\n\tif (diff.wires.changed && !lines.length) lines.push('- Wiring changed');\n\treturn lines.join('\\n');\n}\n\nconst oneLine = (text: string) => {\n\tconst line = text.replace(/\\s+/g, ' ').replace(/`/g, \"'\").trim();\n\treturn line.length > 60 ? `${line.slice(0, 59)}…` : line;\n};\n"],"mappings":";AAwEA,SAAgB,iBAAiB,GAAoD;CACpF,OAAO,EAAE,UAAU;AACpB;AAEA,SAAgB,YAAY,GAA+C;CAC1E,OAAO,EAAE,UAAU;AACpB;;;;;;;ACvEA,SAAgB,iBACf,QACA,OACwB;CACxB,OAAO,OAAO,QAAQ,QAAQ,MAAM;EACnC,IAAI,iBAAiB,CAAC,GAAG;GACxB,IAAI,EAAE,OAAO,OAAO,iBAAiB,OAAO;GAC5C,IAAI,EAAE,eAAe,OAAO,OAAO;GACnC,IAAI,SAAS,EAAE,WAAW,SAAS,KAAK,GAAG,OAAO;GAClD,OAAO;EACR;EAEA,OAAO,CAAC,CAAC,SAAS,EAAE,eAAe;CACpC,CAAC;AACF;;;;;AAMA,SAAgB,mBACf,QACA,OACqB;CACrB,M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,KAAK,KAAK,QAAQ;EAC5B,MAAM,QAAQ,MAAsB,MAAM,OAAO,aAAa,KAAK,QAAQ,CAAC,EAAE;EAC9E,MAAM,KAAK,OAAO,EAAE,MAAM,KAAK,KAAK,EAAE,MAAM,EAAE,KAAK,KAAK,EAAE,KAAK,GAAG;CACnE;CACA,IAAI,KAAK,MAAM,WAAW,CAAC,MAAM,QAAQ,MAAM,KAAK,kBAAkB;CACtE,OAAO,MAAM,KAAK,IAAI;AACvB;AAEA,IAAM,WAAW,SAAiB;CACjC,MAAM,OAAO,KAAK,QAAQ,QAAQ,GAAG,CAAC,CAAC,QAAQ,MAAM,GAAG,CAAC,CAAC,KAAK;CAC/D,OAAO,KAAK,SAAS,KAAK,GAAG,KAAK,MAAM,GAAG,EAAE,EAAE,KAAK;AACrD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var package_default = {
|
|
2
2
|
name: "@selvajs/selva",
|
|
3
|
-
version: "4.21.0-beta.
|
|
3
|
+
version: "4.21.0-beta.18",
|
|
4
4
|
description: "Selva — self-contained Grasshopper-driven web app. Install, configure via .env, deploy.",
|
|
5
5
|
license: "MIT",
|
|
6
6
|
author: "VektorNode",
|
|
@@ -51,6 +51,7 @@ var package_default = {
|
|
|
51
51
|
"mode-watcher": "catalog:",
|
|
52
52
|
"nodemailer": "catalog:",
|
|
53
53
|
"pino": "^10.4.0",
|
|
54
|
+
"playwright-core": "catalog:",
|
|
54
55
|
"rhino3dm": "catalog:",
|
|
55
56
|
"sharp": "catalog:",
|
|
56
57
|
"tailwind-merge": "catalog:",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.js","names":[],"sources":["../../../package.json"],"sourcesContent":["{\n\t\"name\": \"@selvajs/selva\",\n\t\"version\": \"4.21.0-beta.
|
|
1
|
+
{"version":3,"file":"package.js","names":[],"sources":["../../../package.json"],"sourcesContent":["{\n\t\"name\": \"@selvajs/selva\",\n\t\"version\": \"4.21.0-beta.18\",\n\t\"description\": \"Selva — self-contained Grasshopper-driven web app. Install, configure via .env, deploy.\",\n\t\"license\": \"MIT\",\n\t\"author\": \"VektorNode\",\n\t\"homepage\": \"https://selva.dev\",\n\t\"bugs\": \"https://github.com/VektorNode/selva/issues\",\n\t\"keywords\": [\n\t\t\"grasshopper\",\n\t\t\"rhino\",\n\t\t\"rhino-compute\",\n\t\t\"parametric-design\",\n\t\t\"web-app\",\n\t\t\"sveltekit\"\n\t],\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t},\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/VektorNode/selva.git\",\n\t\t\"directory\": \"packages/selva\"\n\t},\n\t\"type\": \"module\",\n\t\"main\": \"./build/index.js\",\n\t\"files\": [\n\t\t\"build\",\n\t\t\"templates\"\n\t],\n\t\"engines\": {\n\t\t\"node\": \">=24.0.0\"\n\t},\n\t\"selva\": {\n\t\t\"dataFormat\": 3\n\t},\n\t\"scripts\": {\n\t\t\"dev\": \"vite dev\",\n\t\t\"dev:lan\": \"vite dev --host\",\n\t\t\"build\": \"rimraf build && vite build && node ./scripts/generate-templates.js && node ./scripts/write-runtime-meta.js\",\n\t\t\"preview\": \"vite preview\",\n\t\t\"start\": \"node build/index.js\",\n\t\t\"clean\": \"rimraf build templates\",\n\t\t\"prepare\": \"svelte-kit sync || echo ''\",\n\t\t\"check\": \"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json\",\n\t\t\"test\": \"vitest run\",\n\t\t\"test:watch\": \"vitest\",\n\t\t\"openapi:generate\": \"node scripts/generate-openapi.js\",\n\t\t\"test:e2e\": \"playwright test\",\n\t\t\"lint\": \"eslint .\",\n\t\t\"lint:types\": \"eslint . --config eslint.typed.config.js\",\n\t\t\"generate:cli-config\": \"node scripts/generate-cli-config.js\"\n\t},\n\t\"dependencies\": {\n\t\t\"@lucide/svelte\": \"catalog:\",\n\t\t\"@supabase/supabase-js\": \"catalog:\",\n\t\t\"@sveltejs/kit\": \"catalog:\",\n\t\t\"bits-ui\": \"catalog:\",\n\t\t\"clsx\": \"catalog:\",\n\t\t\"mode-watcher\": \"catalog:\",\n\t\t\"nodemailer\": \"catalog:\",\n\t\t\"pino\": \"^10.4.0\",\n\t\t\"playwright-core\": \"catalog:\",\n\t\t\"rhino3dm\": \"catalog:\",\n\t\t\"sharp\": \"catalog:\",\n\t\t\"tailwind-merge\": \"catalog:\",\n\t\t\"tailwind-variants\": \"catalog:\",\n\t\t\"three\": \"catalog:\",\n\t\t\"zod\": \"catalog:\"\n\t},\n\t\"optionalDependencies\": {\n\t\t\"@sentry/node\": \"^11.10.0\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@playwright/test\": \"catalog:\",\n\t\t\"@selvajs/compute\": \"workspace:*\",\n\t\t\"@selvajs/config\": \"workspace:*\",\n\t\t\"@selvajs/header-auth-provider\": \"workspace:*\",\n\t\t\"@selvajs/local-provider\": \"workspace:*\",\n\t\t\"@selvajs/mcp\": \"workspace:*\",\n\t\t\"@selvajs/notifications\": \"workspace:*\",\n\t\t\"@selvajs/platform\": \"workspace:*\",\n\t\t\"@selvajs/schemas\": \"workspace:*\",\n\t\t\"@selvajs/server\": \"workspace:*\",\n\t\t\"@selvajs/solve\": \"workspace:*\",\n\t\t\"@selvajs/supabase-provider\": \"workspace:*\",\n\t\t\"@selvajs/ui\": \"workspace:*\",\n\t\t\"@selvajs/visualization\": \"workspace:*\",\n\t\t\"@sveltejs/adapter-node\": \"catalog:\",\n\t\t\"@types/nodemailer\": \"catalog:\",\n\t\t\"@types/three\": \"catalog:\",\n\t\t\"rimraf\": \"catalog:\",\n\t\t\"tw-animate-css\": \"catalog:\",\n\t\t\"vitest\": \"catalog:\"\n\t},\n\t\"imports\": {\n\t\t\"#lib/*\": \"./src/lib/*\"\n\t}\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// src/lib/server/mcp/path.ts
|
|
2
|
+
var MCP_PATH = "/mcp";
|
|
3
|
+
/** Download links for a solve's output files. The token in the path is the credential. */
|
|
4
|
+
var MCP_FILES_PREFIX = "/mcp/files/";
|
|
5
|
+
export { MCP_PATH as n, MCP_FILES_PREFIX as t };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.js","names":[],"sources":["../../../src/lib/server/mcp/path.ts"],"sourcesContent":["// Its own module: the hook needs the path on every request, and importing it from `server.ts`\n// would load the MCP SDK and the OpenAPI builder at boot.\nexport const MCP_PATH = '/mcp';\n\n/** Download links for a solve's output files. The token in the path is the credential. */\nexport const MCP_FILES_PREFIX = '/mcp/files/';\n"],"mappings":";AAEA,IAAa,WAAW;;AAGxB,IAAa,mBAAmB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Q as mayHoldApiTokens } from "./handlers.js";
|
|
2
2
|
import { n as toApiRequest } from "./sveltekit.js";
|
|
3
3
|
import { t as requestMemo } from "./requestMemo.server.js";
|
|
4
4
|
import { t as ACCESS_PRESETS } from "./apiTokens.js";
|
|
@@ -6558,7 +6558,7 @@ function parseCallbackParams(raw) {
|
|
|
6558
6558
|
// ../providers/header-auth/src/users.ts
|
|
6559
6559
|
var empty = () => ({ users: [] });
|
|
6560
6560
|
var LAST_LOGIN_DEBOUNCE_MS = 6e4;
|
|
6561
|
-
async function readFile(filePath) {
|
|
6561
|
+
async function readFile$1(filePath) {
|
|
6562
6562
|
try {
|
|
6563
6563
|
const raw = await fs$1.readFile(filePath, "utf-8");
|
|
6564
6564
|
return JSON.parse(raw);
|
|
@@ -6583,26 +6583,26 @@ function createAllowlistStore(filePath) {
|
|
|
6583
6583
|
}
|
|
6584
6584
|
return {
|
|
6585
6585
|
async findByUpn(upn) {
|
|
6586
|
-
const { users } = await readFile(filePath);
|
|
6586
|
+
const { users } = await readFile$1(filePath);
|
|
6587
6587
|
const key = norm(upn);
|
|
6588
6588
|
return users.find((u) => u.upn === key) ?? null;
|
|
6589
6589
|
},
|
|
6590
6590
|
async findByEmail(email) {
|
|
6591
|
-
const { users } = await readFile(filePath);
|
|
6591
|
+
const { users } = await readFile$1(filePath);
|
|
6592
6592
|
const key = norm(email);
|
|
6593
6593
|
return users.find((u) => u.upn === key) ?? null;
|
|
6594
6594
|
},
|
|
6595
6595
|
async findById(id) {
|
|
6596
|
-
const { users } = await readFile(filePath);
|
|
6596
|
+
const { users } = await readFile$1(filePath);
|
|
6597
6597
|
return users.find((u) => u.id === id) ?? null;
|
|
6598
6598
|
},
|
|
6599
6599
|
async listUsers() {
|
|
6600
|
-
const { users } = await readFile(filePath);
|
|
6600
|
+
const { users } = await readFile$1(filePath);
|
|
6601
6601
|
return users;
|
|
6602
6602
|
},
|
|
6603
6603
|
createUser(upn) {
|
|
6604
6604
|
return locked(async () => {
|
|
6605
|
-
const file = await readFile(filePath);
|
|
6605
|
+
const file = await readFile$1(filePath);
|
|
6606
6606
|
const key = norm(upn);
|
|
6607
6607
|
if (file.users.some((u) => u.upn === key)) throw new ProviderError(`User with UPN "${upn}" already exists`, 409);
|
|
6608
6608
|
const entry = {
|
|
@@ -6617,7 +6617,7 @@ function createAllowlistStore(filePath) {
|
|
|
6617
6617
|
},
|
|
6618
6618
|
syncFromHeaders(id, fields) {
|
|
6619
6619
|
return locked(async () => {
|
|
6620
|
-
const file = await readFile(filePath);
|
|
6620
|
+
const file = await readFile$1(filePath);
|
|
6621
6621
|
const user = file.users.find((u) => u.id === id);
|
|
6622
6622
|
if (!user) return;
|
|
6623
6623
|
let dirty = false;
|
|
@@ -6634,7 +6634,7 @@ function createAllowlistStore(filePath) {
|
|
|
6634
6634
|
},
|
|
6635
6635
|
claim(id, upn, opts) {
|
|
6636
6636
|
return locked(async () => {
|
|
6637
|
-
const file = await readFile(filePath);
|
|
6637
|
+
const file = await readFile$1(filePath);
|
|
6638
6638
|
const user = file.users.find((u) => u.id === id);
|
|
6639
6639
|
if (!user) return null;
|
|
6640
6640
|
const key = norm(upn);
|
|
@@ -6647,7 +6647,7 @@ function createAllowlistStore(filePath) {
|
|
|
6647
6647
|
},
|
|
6648
6648
|
rebindUpn(id, upn) {
|
|
6649
6649
|
return locked(async () => {
|
|
6650
|
-
const file = await readFile(filePath);
|
|
6650
|
+
const file = await readFile$1(filePath);
|
|
6651
6651
|
const key = norm(upn);
|
|
6652
6652
|
const user = file.users.find((u) => u.id === id);
|
|
6653
6653
|
if (!user || user.upn === key && user.claimedByUpn === key) return;
|
|
@@ -6659,7 +6659,7 @@ function createAllowlistStore(filePath) {
|
|
|
6659
6659
|
},
|
|
6660
6660
|
setDisabled(id, disabled) {
|
|
6661
6661
|
return locked(async () => {
|
|
6662
|
-
const file = await readFile(filePath);
|
|
6662
|
+
const file = await readFile$1(filePath);
|
|
6663
6663
|
const user = file.users.find((u) => u.id === id);
|
|
6664
6664
|
if (!user) throw new ProviderError(`User "${id}" not found`, 404);
|
|
6665
6665
|
user.disabled = disabled;
|
|
@@ -6668,7 +6668,7 @@ function createAllowlistStore(filePath) {
|
|
|
6668
6668
|
},
|
|
6669
6669
|
touchLastLogin(id) {
|
|
6670
6670
|
return locked(async () => {
|
|
6671
|
-
const file = await readFile(filePath);
|
|
6671
|
+
const file = await readFile$1(filePath);
|
|
6672
6672
|
const user = file.users.find((u) => u.id === id);
|
|
6673
6673
|
if (!user) return;
|
|
6674
6674
|
const now = Date.now();
|
|
@@ -6682,7 +6682,7 @@ function createAllowlistStore(filePath) {
|
|
|
6682
6682
|
},
|
|
6683
6683
|
deleteUser(id) {
|
|
6684
6684
|
return locked(async () => {
|
|
6685
|
-
const file = await readFile(filePath);
|
|
6685
|
+
const file = await readFile$1(filePath);
|
|
6686
6686
|
const before = file.users.length;
|
|
6687
6687
|
file.users = file.users.filter((u) => u.id !== id);
|
|
6688
6688
|
if (file.users.length === before) throw new ProviderError(`User "${id}" not found`, 404);
|
|
@@ -35677,6 +35677,15 @@ var APP_SETTINGS = composeManifest([
|
|
|
35677
35677
|
class: "setting",
|
|
35678
35678
|
description: "Browser origins /mcp accepts besides its own."
|
|
35679
35679
|
}),
|
|
35680
|
+
defineSetting({
|
|
35681
|
+
key: "MCP_PREVIEW_BROWSER",
|
|
35682
|
+
label: "MCP preview browser",
|
|
35683
|
+
type: "string",
|
|
35684
|
+
default: "",
|
|
35685
|
+
onInvalid: "default",
|
|
35686
|
+
class: "setting",
|
|
35687
|
+
description: "Chromium or Chrome executable that selva_capture_preview renders with. Empty: the one `npx playwright install chromium` installs."
|
|
35688
|
+
}),
|
|
35680
35689
|
defineSetting({
|
|
35681
35690
|
key: "LOG_LEVEL",
|
|
35682
35691
|
label: "Log level",
|