@floless/app 0.107.0 → 0.108.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/floless-server.cjs
CHANGED
|
@@ -51021,8 +51021,129 @@ var import_node_os3 = require("node:os");
|
|
|
51021
51021
|
var import_node_path3 = require("node:path");
|
|
51022
51022
|
var import_node_crypto2 = require("node:crypto");
|
|
51023
51023
|
var import_node_perf_hooks = require("node:perf_hooks");
|
|
51024
|
+
var MAX_EXPECTED_MS = 2 * 60 * 6e4;
|
|
51025
|
+
var MAX_LABEL_LENGTH = 60;
|
|
51026
|
+
function busyMeta(owner) {
|
|
51027
|
+
const label = typeof owner.label === "string" && owner.label.trim() && owner.label.length <= MAX_LABEL_LENGTH ? owner.label.trim() : null;
|
|
51028
|
+
const expectedMs = typeof owner.expectedMs === "number" && Number.isFinite(owner.expectedMs) && owner.expectedMs > 0 && owner.expectedMs <= MAX_EXPECTED_MS ? owner.expectedMs : null;
|
|
51029
|
+
return { label, expectedMs };
|
|
51030
|
+
}
|
|
51031
|
+
var LifecycleLockBusyError = class extends Error {
|
|
51032
|
+
constructor(message, busy) {
|
|
51033
|
+
super(message);
|
|
51034
|
+
this.busy = busy;
|
|
51035
|
+
this.name = "LifecycleLockBusyError";
|
|
51036
|
+
}
|
|
51037
|
+
busy;
|
|
51038
|
+
status = 409;
|
|
51039
|
+
};
|
|
51040
|
+
function subjectFor(kind) {
|
|
51041
|
+
if (kind === "project") return "This project";
|
|
51042
|
+
if (kind === "app") return "This workflow";
|
|
51043
|
+
return "This app";
|
|
51044
|
+
}
|
|
51045
|
+
function remainingPhrase(remainingMs) {
|
|
51046
|
+
if (remainingMs < 6e4) return "less than a minute left";
|
|
51047
|
+
const minutes = Math.round(remainingMs / 6e4);
|
|
51048
|
+
return `about ${minutes} minute${minutes === 1 ? "" : "s"} left`;
|
|
51049
|
+
}
|
|
51050
|
+
function busyDetail(kind, key, owner) {
|
|
51051
|
+
const { label, expectedMs } = busyMeta(owner);
|
|
51052
|
+
const startedMs = Date.parse(owner.acquiredAt);
|
|
51053
|
+
const elapsedMs = Number.isFinite(startedMs) ? Math.max(0, Date.now() - startedMs) : 0;
|
|
51054
|
+
const usableEta = expectedMs != null && Number.isFinite(startedMs) ? expectedMs : null;
|
|
51055
|
+
const remaining = usableEta == null ? null : usableEta - elapsedMs;
|
|
51056
|
+
return {
|
|
51057
|
+
kind,
|
|
51058
|
+
key,
|
|
51059
|
+
label,
|
|
51060
|
+
startedAt: owner.acquiredAt,
|
|
51061
|
+
expectedMs: usableEta,
|
|
51062
|
+
elapsedMs,
|
|
51063
|
+
remainingMs: remaining != null && remaining > 0 ? remaining : null
|
|
51064
|
+
};
|
|
51065
|
+
}
|
|
51066
|
+
function busyError(kind, key, owner) {
|
|
51067
|
+
const detail = owner ? busyDetail(kind, key, owner) : {
|
|
51068
|
+
kind,
|
|
51069
|
+
key,
|
|
51070
|
+
label: null,
|
|
51071
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
51072
|
+
expectedMs: null,
|
|
51073
|
+
elapsedMs: 0,
|
|
51074
|
+
remainingMs: null
|
|
51075
|
+
};
|
|
51076
|
+
const subject = subjectFor(kind);
|
|
51077
|
+
if (!detail.label) {
|
|
51078
|
+
return new LifecycleLockBusyError(`${subject} is busy with another operation. Try again when it finishes.`, detail);
|
|
51079
|
+
}
|
|
51080
|
+
if (detail.expectedMs == null) {
|
|
51081
|
+
return new LifecycleLockBusyError(`${subject} is busy ${detail.label}. Try again when it finishes.`, detail);
|
|
51082
|
+
}
|
|
51083
|
+
const clause = detail.remainingMs == null ? "taking longer than usual" : remainingPhrase(detail.remainingMs);
|
|
51084
|
+
return new LifecycleLockBusyError(`${subject} is busy ${detail.label} \u2014 ${clause}. Try again when it finishes.`, detail);
|
|
51085
|
+
}
|
|
51024
51086
|
var held = new import_node_async_hooks.AsyncLocalStorage();
|
|
51025
51087
|
var localTails = /* @__PURE__ */ new Map();
|
|
51088
|
+
var localIntents = /* @__PURE__ */ new Map();
|
|
51089
|
+
function registerIntent(token, options) {
|
|
51090
|
+
const { label, expectedMs } = busyMeta(options);
|
|
51091
|
+
const intent = { label, expectedMs, acquiredAt: null };
|
|
51092
|
+
const set2 = localIntents.get(token) ?? /* @__PURE__ */ new Set();
|
|
51093
|
+
set2.add(intent);
|
|
51094
|
+
localIntents.set(token, set2);
|
|
51095
|
+
return intent;
|
|
51096
|
+
}
|
|
51097
|
+
function forgetIntent(token, intent) {
|
|
51098
|
+
const set2 = localIntents.get(token);
|
|
51099
|
+
if (!set2) return;
|
|
51100
|
+
set2.delete(intent);
|
|
51101
|
+
if (!set2.size) localIntents.delete(token);
|
|
51102
|
+
}
|
|
51103
|
+
function localProjectedFreeAt(token, now, exclude) {
|
|
51104
|
+
const set2 = localIntents.get(token);
|
|
51105
|
+
if (!set2?.size) return { at: now, blocker: null };
|
|
51106
|
+
let at = now;
|
|
51107
|
+
let holding = null;
|
|
51108
|
+
let longest = null;
|
|
51109
|
+
for (const intent of set2) {
|
|
51110
|
+
if (intent === exclude) continue;
|
|
51111
|
+
if (intent.label) {
|
|
51112
|
+
if (intent.acquiredAt != null) holding = intent;
|
|
51113
|
+
if (!longest || (intent.expectedMs ?? 0) > (longest.expectedMs ?? 0)) longest = intent;
|
|
51114
|
+
}
|
|
51115
|
+
if (intent.expectedMs == null) continue;
|
|
51116
|
+
const start = intent.acquiredAt ?? Math.max(at, now);
|
|
51117
|
+
at = Math.max(now, start + intent.expectedMs);
|
|
51118
|
+
}
|
|
51119
|
+
return { at, blocker: holding ?? longest };
|
|
51120
|
+
}
|
|
51121
|
+
function localBusyError(kind, key, at, blocker, now) {
|
|
51122
|
+
const startedMs = blocker.acquiredAt ?? now;
|
|
51123
|
+
const expectedMs = blocker.expectedMs == null ? void 0 : Math.max(1, at - startedMs);
|
|
51124
|
+
return busyError(kind, key, {
|
|
51125
|
+
acquiredAt: new Date(startedMs).toISOString(),
|
|
51126
|
+
label: blocker.label ?? void 0,
|
|
51127
|
+
expectedMs
|
|
51128
|
+
});
|
|
51129
|
+
}
|
|
51130
|
+
function waitForTurn(previous, budget, onExpiry) {
|
|
51131
|
+
return new Promise((resolve11, reject) => {
|
|
51132
|
+
let settled = false;
|
|
51133
|
+
const timer = setTimeout(() => {
|
|
51134
|
+
if (settled) return;
|
|
51135
|
+
settled = true;
|
|
51136
|
+
reject(onExpiry());
|
|
51137
|
+
}, budget);
|
|
51138
|
+
previous.catch(() => {
|
|
51139
|
+
}).then(() => {
|
|
51140
|
+
if (settled) return;
|
|
51141
|
+
settled = true;
|
|
51142
|
+
clearTimeout(timer);
|
|
51143
|
+
resolve11();
|
|
51144
|
+
});
|
|
51145
|
+
});
|
|
51146
|
+
}
|
|
51026
51147
|
var PROCESS_TOKEN = (0, import_node_crypto2.randomUUID)();
|
|
51027
51148
|
var STALE_MS = 3e4;
|
|
51028
51149
|
var WAIT_MS = 50;
|
|
@@ -51203,9 +51324,10 @@ function retireStaleLock(path, generation) {
|
|
|
51203
51324
|
}
|
|
51204
51325
|
return true;
|
|
51205
51326
|
}
|
|
51206
|
-
async function acquire(path) {
|
|
51327
|
+
async function acquire(path, kind, key, options) {
|
|
51207
51328
|
(0, import_node_fs4.mkdirSync)(root(), { recursive: true });
|
|
51208
|
-
const
|
|
51329
|
+
const budget = options.timeoutMsForTest ?? TIMEOUT_MS;
|
|
51330
|
+
const deadline = Date.now() + budget;
|
|
51209
51331
|
while (true) {
|
|
51210
51332
|
try {
|
|
51211
51333
|
(0, import_node_fs4.mkdirSync)(path);
|
|
@@ -51213,7 +51335,11 @@ async function acquire(path) {
|
|
|
51213
51335
|
pid: process.pid,
|
|
51214
51336
|
token: PROCESS_TOKEN,
|
|
51215
51337
|
acquiredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
51216
|
-
started: PROCESS_STARTED
|
|
51338
|
+
started: PROCESS_STARTED,
|
|
51339
|
+
// Omitted entirely when undefined, so an undeclared lock writes byte-identical bytes
|
|
51340
|
+
// to what every previous build wrote.
|
|
51341
|
+
...options.label ? { label: options.label } : {},
|
|
51342
|
+
...options.expectedMs != null ? { expectedMs: options.expectedMs } : {}
|
|
51217
51343
|
};
|
|
51218
51344
|
if (publishExclusive(ownerPath(path), JSON.stringify(owner))) {
|
|
51219
51345
|
const canonical = readOwner(path);
|
|
@@ -51226,16 +51352,30 @@ async function acquire(path) {
|
|
|
51226
51352
|
const generation = staleGeneration(path);
|
|
51227
51353
|
if (generation) {
|
|
51228
51354
|
if (retireStaleLock(path, generation)) continue;
|
|
51355
|
+
} else {
|
|
51356
|
+
const owner = readOwner(path);
|
|
51357
|
+
const startedMs = owner ? Date.parse(owner.acquiredAt) : NaN;
|
|
51358
|
+
const expected = owner ? busyMeta(owner).expectedMs : null;
|
|
51359
|
+
if (owner && expected != null && startedMs + expected > deadline) {
|
|
51360
|
+
throw busyError(kind, key, owner);
|
|
51361
|
+
}
|
|
51229
51362
|
}
|
|
51230
|
-
if (Date.now() >= deadline) throw
|
|
51363
|
+
if (Date.now() >= deadline) throw busyError(kind, key, readOwner(path));
|
|
51231
51364
|
await sleep(WAIT_MS);
|
|
51232
51365
|
}
|
|
51233
51366
|
}
|
|
51234
51367
|
}
|
|
51235
|
-
async function withLifecycleLock(kind, key, fn) {
|
|
51368
|
+
async function withLifecycleLock(kind, key, fn, options = {}) {
|
|
51236
51369
|
const token = `${kind}:${safe(key)}`;
|
|
51237
51370
|
const inherited = held.getStore();
|
|
51238
51371
|
if (inherited?.has(token)) return await fn();
|
|
51372
|
+
const budget = options.timeoutMsForTest ?? TIMEOUT_MS;
|
|
51373
|
+
const enteredAt = Date.now();
|
|
51374
|
+
const { at: freeAt, blocker } = localProjectedFreeAt(token, enteredAt);
|
|
51375
|
+
if (freeAt > enteredAt + budget) {
|
|
51376
|
+
throw blocker ? localBusyError(kind, key, freeAt, blocker, enteredAt) : busyError(kind, key, null);
|
|
51377
|
+
}
|
|
51378
|
+
const intent = registerIntent(token, options);
|
|
51239
51379
|
const previous = localTails.get(token) ?? Promise.resolve();
|
|
51240
51380
|
let releaseLocal;
|
|
51241
51381
|
const mine = new Promise((resolve11) => {
|
|
@@ -51244,11 +51384,15 @@ async function withLifecycleLock(kind, key, fn) {
|
|
|
51244
51384
|
const tail = previous.catch(() => {
|
|
51245
51385
|
}).then(() => mine);
|
|
51246
51386
|
localTails.set(token, tail);
|
|
51247
|
-
await previous.catch(() => {
|
|
51248
|
-
});
|
|
51249
51387
|
const path = pathFor(kind, key);
|
|
51250
51388
|
try {
|
|
51251
|
-
await
|
|
51389
|
+
await waitForTurn(previous, budget, () => {
|
|
51390
|
+
const now = Date.now();
|
|
51391
|
+
const late = localProjectedFreeAt(token, now, intent);
|
|
51392
|
+
return late.blocker ? localBusyError(kind, key, late.at, late.blocker, now) : busyError(kind, key, null);
|
|
51393
|
+
});
|
|
51394
|
+
await acquire(path, kind, key, options);
|
|
51395
|
+
intent.acquiredAt = Date.now();
|
|
51252
51396
|
const next = new Set(inherited ?? []);
|
|
51253
51397
|
next.add(token);
|
|
51254
51398
|
return await held.run(next, fn);
|
|
@@ -51262,6 +51406,7 @@ async function withLifecycleLock(kind, key, fn) {
|
|
|
51262
51406
|
}
|
|
51263
51407
|
}
|
|
51264
51408
|
}
|
|
51409
|
+
forgetIntent(token, intent);
|
|
51265
51410
|
releaseLocal();
|
|
51266
51411
|
if (localTails.get(token) === tail) localTails.delete(token);
|
|
51267
51412
|
}
|
|
@@ -53633,7 +53778,7 @@ function appVersion() {
|
|
|
53633
53778
|
return resolveVersion({
|
|
53634
53779
|
isSea: isSea2(),
|
|
53635
53780
|
sqVersionXml: readSqVersionXml(),
|
|
53636
|
-
define: true ? "0.
|
|
53781
|
+
define: true ? "0.108.0" : void 0,
|
|
53637
53782
|
pkgVersion: readPkgVersion()
|
|
53638
53783
|
});
|
|
53639
53784
|
}
|
|
@@ -53643,7 +53788,7 @@ function resolveChannel(s) {
|
|
|
53643
53788
|
return "dev";
|
|
53644
53789
|
}
|
|
53645
53790
|
function appChannel() {
|
|
53646
|
-
return resolveChannel({ isSea: isSea2(), define: true ? "0.
|
|
53791
|
+
return resolveChannel({ isSea: isSea2(), define: true ? "0.108.0" : void 0 });
|
|
53647
53792
|
}
|
|
53648
53793
|
|
|
53649
53794
|
// workflow-update.ts
|
|
@@ -58044,13 +58189,6 @@ var PreconditionFailedError = class extends Error {
|
|
|
58044
58189
|
this.name = "PreconditionFailedError";
|
|
58045
58190
|
}
|
|
58046
58191
|
};
|
|
58047
|
-
var StoreBusyError = class extends Error {
|
|
58048
|
-
code = "store-busy";
|
|
58049
|
-
constructor(message) {
|
|
58050
|
-
super(message);
|
|
58051
|
-
this.name = "StoreBusyError";
|
|
58052
|
-
}
|
|
58053
|
-
};
|
|
58054
58192
|
var refused = /* @__PURE__ */ new Map();
|
|
58055
58193
|
var REFUSAL_STORES_MAX = 256;
|
|
58056
58194
|
function countRefusal(store) {
|
|
@@ -58116,17 +58254,9 @@ async function writeContractChecked(appId, doc, projectId, origin) {
|
|
|
58116
58254
|
return { etag: etagOf(doc), conditional: !!(pre.ifMatch || pre.ifNoneMatch) };
|
|
58117
58255
|
});
|
|
58118
58256
|
} catch (e) {
|
|
58119
|
-
if (e instanceof Error && /lifecycle lock/i.test(e.message)) {
|
|
58120
|
-
throw new StoreBusyError("this project is busy publishing an export \u2014 try saving again in a moment");
|
|
58121
|
-
}
|
|
58122
58257
|
throw e;
|
|
58123
58258
|
}
|
|
58124
|
-
return run
|
|
58125
|
-
if (e instanceof Error && /lifecycle lock/i.test(e.message)) {
|
|
58126
|
-
throw new StoreBusyError("this project is busy publishing an export \u2014 try saving again in a moment");
|
|
58127
|
-
}
|
|
58128
|
-
throw e;
|
|
58129
|
-
});
|
|
58259
|
+
return run;
|
|
58130
58260
|
}
|
|
58131
58261
|
function readAcceptedVersion(projectId, n, opts) {
|
|
58132
58262
|
const doc = readVersion(projectId, n);
|
|
@@ -70141,6 +70271,17 @@ async function renderReadiness(deps = DEFAULT_DEPS2) {
|
|
|
70141
70271
|
}
|
|
70142
70272
|
}
|
|
70143
70273
|
|
|
70274
|
+
// render-cost.ts
|
|
70275
|
+
var RENDER_COST_SECONDS = {
|
|
70276
|
+
still: { draft: [8, 15], production: [50, 115] },
|
|
70277
|
+
turntable: { draft: [390, 540], production: [390, 540] }
|
|
70278
|
+
};
|
|
70279
|
+
function renderExpectedMs(output, quality, viewpoints) {
|
|
70280
|
+
const effective = output === "turntable" ? "draft" : quality;
|
|
70281
|
+
const [, hi] = RENDER_COST_SECONDS[output][effective];
|
|
70282
|
+
return hi * 1e3 * Math.max(1, viewpoints);
|
|
70283
|
+
}
|
|
70284
|
+
|
|
70144
70285
|
// downstream-bake.ts
|
|
70145
70286
|
async function bakeDownstream(sourcePath, appId, contract) {
|
|
70146
70287
|
const { scene } = contractToScene(contract);
|
|
@@ -74271,6 +74412,15 @@ async function startServer() {
|
|
|
74271
74412
|
if (err2 instanceof ProjectError) {
|
|
74272
74413
|
return reply.status(400).send({ ok: false, error: err2.message });
|
|
74273
74414
|
}
|
|
74415
|
+
if (err2 instanceof LifecycleLockBusyError) {
|
|
74416
|
+
const retryAfter = err2.busy.remainingMs == null ? 5 : Math.min(60, Math.max(1, Math.ceil(err2.busy.remainingMs / 1e3)));
|
|
74417
|
+
return reply.status(err2.status).header("Retry-After", String(retryAfter)).send({
|
|
74418
|
+
ok: false,
|
|
74419
|
+
error: err2.message,
|
|
74420
|
+
code: "lifecycle-busy",
|
|
74421
|
+
busy: err2.busy
|
|
74422
|
+
});
|
|
74423
|
+
}
|
|
74274
74424
|
if (err2 instanceof RoutineError) {
|
|
74275
74425
|
return reply.status(err2.status).send({ ok: false, error: err2.message });
|
|
74276
74426
|
}
|
|
@@ -74958,9 +75108,6 @@ async function startServer() {
|
|
|
74958
75108
|
if (e instanceof PreconditionFailedError) {
|
|
74959
75109
|
return reply.status(412).send({ ok: false, error: e.message, code: e.code });
|
|
74960
75110
|
}
|
|
74961
|
-
if (e instanceof StoreBusyError) {
|
|
74962
|
-
return reply.status(503).header("Retry-After", "5").send({ ok: false, error: e.message, code: e.code });
|
|
74963
|
-
}
|
|
74964
75111
|
if (e instanceof ContractError) return reply.status(400).send({ ok: false, error: e.message, ...e.code ? { code: e.code } : {} });
|
|
74965
75112
|
throw e;
|
|
74966
75113
|
}
|
|
@@ -75132,56 +75279,64 @@ async function startServer() {
|
|
|
75132
75279
|
});
|
|
75133
75280
|
}
|
|
75134
75281
|
}
|
|
75135
|
-
return withLifecycleLock(
|
|
75136
|
-
|
|
75137
|
-
|
|
75138
|
-
|
|
75139
|
-
|
|
75282
|
+
return withLifecycleLock(
|
|
75283
|
+
project ? "project" : "app",
|
|
75284
|
+
project || appId,
|
|
75285
|
+
async () => withLifecycleLock("app", `${appId}-3d`, async () => {
|
|
75286
|
+
let projectSnapshot;
|
|
75287
|
+
if (project) {
|
|
75288
|
+
const gate = projectExportGate(appId, project);
|
|
75289
|
+
if (gate) return reply.status(gate.status).send({ ok: false, error: gate.error });
|
|
75290
|
+
try {
|
|
75291
|
+
projectSnapshot = currentApprovedSnapshot(project);
|
|
75292
|
+
} catch (error) {
|
|
75293
|
+
if (error instanceof WorkspaceSnapshotError) return reply.status(error.status).send({ ok: false, error: error.message });
|
|
75294
|
+
throw error;
|
|
75295
|
+
}
|
|
75296
|
+
}
|
|
75297
|
+
const candidate = projectSnapshot ? projectSnapshot.contract : readAcceptedForRequest(appId, void 0);
|
|
75298
|
+
if (candidate == null) return reply.status(404).send({ ok: false, error: "no contract to export" });
|
|
75299
|
+
const steel = acceptSteelForRoute(candidate, { appId, projectId: project }, "stored");
|
|
75300
|
+
if (!steel.accepted) return reply.status(400).send(steel.refusal);
|
|
75301
|
+
const { scene, skipped } = contractToScene(steel.doc);
|
|
75302
|
+
if (scene.elements.length === 0) {
|
|
75303
|
+
return reply.status(422).send({ ok: false, error: "no resolvable members to render \u2014 every member is an RFI (no AISC size yet)", skipped });
|
|
75304
|
+
}
|
|
75305
|
+
const companionId = `${appId}-3d`;
|
|
75306
|
+
let flo;
|
|
75140
75307
|
try {
|
|
75141
|
-
|
|
75142
|
-
} catch (
|
|
75143
|
-
|
|
75144
|
-
|
|
75308
|
+
flo = writeViewer3dApp(appPath(companionId), companionId, scene);
|
|
75309
|
+
} catch (e) {
|
|
75310
|
+
app.log.error({ companionId, err: e instanceof Error ? e.message : e }, "export-3d: companion app write failed");
|
|
75311
|
+
return reply.status(500).send({ ok: false, error: `could not write the 3D companion app: ${e instanceof Error ? e.message : "write error"}` });
|
|
75145
75312
|
}
|
|
75146
|
-
|
|
75147
|
-
|
|
75148
|
-
|
|
75149
|
-
|
|
75150
|
-
|
|
75151
|
-
const { scene, skipped } = contractToScene(steel.doc);
|
|
75152
|
-
if (scene.elements.length === 0) {
|
|
75153
|
-
return reply.status(422).send({ ok: false, error: "no resolvable members to render \u2014 every member is an RFI (no AISC size yet)", skipped });
|
|
75154
|
-
}
|
|
75155
|
-
const companionId = `${appId}-3d`;
|
|
75156
|
-
let flo;
|
|
75157
|
-
try {
|
|
75158
|
-
flo = writeViewer3dApp(appPath(companionId), companionId, scene);
|
|
75159
|
-
} catch (e) {
|
|
75160
|
-
app.log.error({ companionId, err: e instanceof Error ? e.message : e }, "export-3d: companion app write failed");
|
|
75161
|
-
return reply.status(500).send({ ok: false, error: `could not write the 3D companion app: ${e instanceof Error ? e.message : "write error"}` });
|
|
75162
|
-
}
|
|
75163
|
-
try {
|
|
75164
|
-
await aware.compile(flo);
|
|
75165
|
-
} catch (e) {
|
|
75166
|
-
app.log.warn({ companionId, detail: e instanceof AwareError ? e.detail : void 0 }, "3D compile failed");
|
|
75167
|
-
return reply.status(422).send({ ok: false, error: `3D compile failed: ${e instanceof Error ? e.message : "compile error"}`, reason: awareStderr(e) });
|
|
75168
|
-
}
|
|
75169
|
-
let result;
|
|
75170
|
-
try {
|
|
75171
|
-
result = await aware.run(companionId, {});
|
|
75172
|
-
} catch (e) {
|
|
75173
|
-
if (e instanceof AwareError) {
|
|
75174
|
-
app.log.warn({ companionId, detail: e.detail }, "3D render failed");
|
|
75175
|
-
return reply.send({ ok: false, error: e.message, reason: awareStderr(e) });
|
|
75313
|
+
try {
|
|
75314
|
+
await aware.compile(flo);
|
|
75315
|
+
} catch (e) {
|
|
75316
|
+
app.log.warn({ companionId, detail: e instanceof AwareError ? e.detail : void 0 }, "3D compile failed");
|
|
75317
|
+
return reply.status(422).send({ ok: false, error: `3D compile failed: ${e instanceof Error ? e.message : "compile error"}`, reason: awareStderr(e) });
|
|
75176
75318
|
}
|
|
75177
|
-
|
|
75178
|
-
|
|
75179
|
-
|
|
75180
|
-
|
|
75181
|
-
|
|
75182
|
-
|
|
75183
|
-
|
|
75184
|
-
|
|
75319
|
+
let result;
|
|
75320
|
+
try {
|
|
75321
|
+
result = await aware.run(companionId, {});
|
|
75322
|
+
} catch (e) {
|
|
75323
|
+
if (e instanceof AwareError) {
|
|
75324
|
+
app.log.warn({ companionId, detail: e.detail }, "3D render failed");
|
|
75325
|
+
return reply.send({ ok: false, error: e.message, reason: awareStderr(e) });
|
|
75326
|
+
}
|
|
75327
|
+
throw e;
|
|
75328
|
+
}
|
|
75329
|
+
const events = result.traceText ? parseTrace(result.traceText) : [];
|
|
75330
|
+
const extracted = extractReportHtml(events);
|
|
75331
|
+
if (!extracted) return reply.send({ ok: false, error: "the 3D render produced no html" });
|
|
75332
|
+
broadcast({ type: "apps-changed" });
|
|
75333
|
+
return { ok: true, report: { ...extracted, interactive: true }, skipped };
|
|
75334
|
+
}),
|
|
75335
|
+
// Names the job for anyone blocked on the project, with no countdown — same reasoning as the
|
|
75336
|
+
// Tekla bake: slow sometimes, not predictably so. The label goes on the OUTER (project) lock,
|
|
75337
|
+
// which is the one a sibling export contends with.
|
|
75338
|
+
{ label: "building the 3D view" }
|
|
75339
|
+
);
|
|
75185
75340
|
});
|
|
75186
75341
|
async function stableExportSourceId(appId, project) {
|
|
75187
75342
|
const ownerId = project ? await getOrCreateProjectExportSourceId(project) : await getOrCreateWorkflowExportSourceId(appId);
|
|
@@ -75498,6 +75653,12 @@ async function startServer() {
|
|
|
75498
75653
|
} finally {
|
|
75499
75654
|
(0, import_node_fs45.rmSync)(scratch, { recursive: true, force: true });
|
|
75500
75655
|
}
|
|
75656
|
+
}, {
|
|
75657
|
+
// What anyone blocked on this project is told, and for how long to expect it. Erring long
|
|
75658
|
+
// on purpose: over-declaring costs a waiter one needless refusal, under-declaring costs it
|
|
75659
|
+
// a silent multi-minute stall, which is the failure this exists to remove.
|
|
75660
|
+
label: "rendering",
|
|
75661
|
+
expectedMs: renderExpectedMs(output, quality, viewpoints.length)
|
|
75501
75662
|
});
|
|
75502
75663
|
});
|
|
75503
75664
|
app.post("/api/contract/:appId/export-tekla", async (req, reply) => {
|
|
@@ -75595,7 +75756,7 @@ async function startServer() {
|
|
|
75595
75756
|
app.log.error({ companionId: companion.id, error: error instanceof Error ? error.message : error }, "could not remove Tekla export companion");
|
|
75596
75757
|
}
|
|
75597
75758
|
}
|
|
75598
|
-
});
|
|
75759
|
+
}, { label: "sending the model to Tekla" });
|
|
75599
75760
|
});
|
|
75600
75761
|
app.post("/api/contract/:appId/export-bom/:format", async (req, reply) => {
|
|
75601
75762
|
const { appId, format } = req.params;
|
|
@@ -122,7 +122,14 @@ with an explicit OK at each kind (this is the interactive heart — never one-sh
|
|
|
122
122
|
- **Framing plans** — the sheets that get read into members. Confirm the list before reading.
|
|
123
123
|
- **Elevations / sections** — used for member heights (TOS/BOS), moment-frame schedules, and as
|
|
124
124
|
jump targets for clickable callouts (stage 6). Confirm which sheets these are.
|
|
125
|
-
- **Details
|
|
125
|
+
- **Details — CHASED TO A FIXED POINT, not one hop.** The plans' callouts get you to the first rank of
|
|
126
|
+
detail sheets; those details then reference further sheets, usually for the numbers (a schedule held
|
|
127
|
+
elsewhere, a related connection type drawn on another sheet), and those may reference on again. Walk the
|
|
128
|
+
references sheet-to-sheet until a pass turns up nothing new, and confirm the WHOLE resolved set with the
|
|
129
|
+
user, not just the sheets the plans happened to name. Follow references written as PROSE inside a detail,
|
|
130
|
+
not only drawn bubbles. If the chain leaves the set, say which sheet is missing and what it cost: a
|
|
131
|
+
connection whose schedule sheet is absent has an arrangement but no sizes, and must be reported that way
|
|
132
|
+
rather than read as complete. (See `reading-structural-drawings` → "The set is a GRAPH".)
|
|
126
133
|
- **A sample line + profile** — on the first plan, read ONE member (its segment + profile label)
|
|
127
134
|
and show it back; get an OK that the geometry + size mapping is right before reading the rest.
|
|
128
135
|
|
|
@@ -141,6 +148,28 @@ the user at the editor:
|
|
|
141
148
|
- **Pre-fill the connection library** from `company-rules.md` (stage 2): emit the firm's rows into
|
|
142
149
|
the contract's `connections[]` with `source:"company-rules"`; the user reviews/assigns them per
|
|
143
150
|
member end in the editor's **Connections** panel (the per-end picker + confidence card).
|
|
151
|
+
- **Read the CHASED details into that same library — this is the point of chasing them.** Once the
|
|
152
|
+
reference graph is resolved (stage 5), each terminal detail says how its connection is actually built.
|
|
153
|
+
Put that on the `connections[]` row it belongs to, with `source:"drawing"`:
|
|
154
|
+
- `detail` — the callout as drawn, in whatever form this set writes it; that string is what a member
|
|
155
|
+
end's callout is matched against, so keep it verbatim rather than normalising it to a house style;
|
|
156
|
+
- `recipe.kind` — what it builds (`shear-plate`, `base-plate`);
|
|
157
|
+
- `recipe.params` — the numbers on the typical figure itself (plate thickness, weld leg, bolt Ø);
|
|
158
|
+
- `recipe.schedule[]` — the table that varies those numbers by member size, **which often lives on the
|
|
159
|
+
sheet the detail points AT rather than the detail's own sheet**, so it only exists if the chain was
|
|
160
|
+
followed; one row per size band, matched by `profile` / `profilePrefix` / `depth`;
|
|
161
|
+
- `recipe.notes[]` — the rules written round the figure (material grades, oversize-hole notes, weld
|
|
162
|
+
callouts, finish requirements). Carry them verbatim; they are not decoration, and floless surfaces
|
|
163
|
+
them on every end that uses the detail.
|
|
164
|
+
|
|
165
|
+
A row with a `recipe` is what lets a member end carrying that callout be **built** (issue #386). A row
|
|
166
|
+
read from the drawing but whose schedule sheet was missing must be left WITHOUT a schedule and said so —
|
|
167
|
+
an invented size band is worse than an end that honestly refuses to build.
|
|
168
|
+
- **Bind callouts to member ends where the drawing shows it.** A detail bubble on a plan has a leader
|
|
169
|
+
pointing at a specific connection; that link is legible at read time and guesswork afterwards. Where the
|
|
170
|
+
leader clearly lands on a member end, set that end's `detail` to the callout text so the end is buildable
|
|
171
|
+
without the user re-picking it by hand. Where it is ambiguous, leave it unset — the editor's ⌖ pick is
|
|
172
|
+
the fallback, and a wrong binding is worse than none.
|
|
144
173
|
- **Point at the rest of the canvas:** the **filter** view (refine the kept linework), **Approve**
|
|
145
174
|
(bake the lock — the determinism gate), **3D** model, **IFC** / **Tekla** export, the **BOM**
|
|
146
175
|
(exportable to **CSV / Excel**), the **confidence report**, and the **callout bubbles** (click a
|
|
@@ -71,6 +71,34 @@ The vector linework is ground truth; your judgement binds LABELS to it, it does
|
|
|
71
71
|
The same applies to the **linked detail/section sheets a callout points to** — extract each referenced
|
|
72
72
|
sheet to vector SVG (e.g. PyMuPDF `get_svg_image`, strip the embedded raster) so the callout opens crisp.
|
|
73
73
|
|
|
74
|
+
## The set is a GRAPH — follow every callout to a fixed point, not one hop
|
|
75
|
+
|
|
76
|
+
**A plan callout is the START of a chain, never the end.** It gets you to a sheet; the detail on that
|
|
77
|
+
sheet then points onward for the numbers — a schedule held on a different sheet, a related connection
|
|
78
|
+
type drawn elsewhere — and that sheet may point on again. Reading only the sheets the *plans* name leaves
|
|
79
|
+
you with a picture of the connection and none of its numbers: the arrangement without the sizes.
|
|
80
|
+
|
|
81
|
+
**Resolve the reference graph transitively:**
|
|
82
|
+
|
|
83
|
+
1. Start from every callout on every framing plan (detail bubbles, section marks — whatever form this set
|
|
84
|
+
uses; read the set's own conventions rather than assuming a numbering scheme).
|
|
85
|
+
2. Extract each referenced sheet, then **read ITS callouts and its in-detail cross-references too** —
|
|
86
|
+
including references written as PROSE inside a detail ("see schedule on …", "per detail …", "see sheet
|
|
87
|
+
… for …"), not just drawn bubbles. Those are the ones a bubble-only extractor misses.
|
|
88
|
+
3. Repeat until a pass adds no new sheets. That fixed point is the set you actually have to read.
|
|
89
|
+
4. **Record the edges** (which sheet/detail references which), so the chain is traceable afterwards and
|
|
90
|
+
a gap is visible rather than silent.
|
|
91
|
+
|
|
92
|
+
**A missing link is a FINDING, not a shrug.** If the chain reaches a sheet that is not in the PDF — or you
|
|
93
|
+
stop early — say so explicitly and name what it cost: *"this detail sizes its plate from a schedule sheet
|
|
94
|
+
that is not in this set, so the connection cannot be sized."* Silently keeping the one-hop read produces a
|
|
95
|
+
model that looks detailed and has no fabrication numbers behind it.
|
|
96
|
+
|
|
97
|
+
**Assume the plans under-name the set.** On a set measured while writing this rule, the framing plans'
|
|
98
|
+
callouts reached only a small minority of the connection-detail sheets directly — the rest were reachable
|
|
99
|
+
only on a second or third hop, and the sheet carrying the plate schedule was two hops from the plan. Let
|
|
100
|
+
the graph tell you the real extent; the plans' own callout list is a starting point, not an inventory.
|
|
101
|
+
|
|
74
102
|
## Symbols mean what THIS set's legend says — never a remembered mapping
|
|
75
103
|
|
|
76
104
|
A framing plan draws several things as "a line with marks on its ends", and they are not the same kind
|