@polycyphers/bim 0.1.1 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  Commercial React sketch-to-layout and BIM studio. One browser UI calls the canonical server engine; no architectural catalogue, geometry solver, exporter, provider key or machine credential ships in this npm package.
4
4
 
5
+ ## 0.1.4 release candidate
6
+
7
+ This source candidate includes durable pending-draft persistence and typed quota/purchase responses from the canonical API. A pending draft is not a validated layout or a paid entitlement; resume and payment actions remain subject to server ownership, version and entitlement checks. Version 0.1.3 was not approved for a public paid launch. Neither this candidate nor its local consumer proof authorizes public checkout, provider processing or deployment. Publication and live application pins require a separate owner release.
8
+
5
9
  ```sh
6
10
  npm install @polycyphers/bim react react-dom
7
11
  ```
@@ -11,12 +15,12 @@ import {BimStudio, setLicense} from '@polycyphers/bim';
11
15
  import '@polycyphers/bim/style.css';
12
16
  setLicense(import.meta.env.VITE_BIM_UI_LICENSE); // browser-safe signed UI token only
13
17
  // Route this transport through your authenticated server proxy, never a machine secret.
14
- <BimStudio embedded workspaceKey={verifiedScope} transport={authenticatedHostTransport}/>
18
+ <BimStudio embedded language="de" workspaceKey={verifiedScope} transport={authenticatedHostTransport}/>
15
19
  ```
16
20
 
17
21
  UI installation tokens are issued under catalog `bim-ui`, signed claim `pkg:["bim"]`, version `0.1.x`, and the licensed hostnames. Server licenses are issued separately under `bim` with `pkg:["Polycyphers.Bim"]`. A browser token grants no server compute, AI budget, tenant access or paid project rights. Never expose server license secrets, HMAC credentials, Stripe or Anthropic keys through Vite environment variables.
18
22
 
19
- Version 0.1.1 requires a valid signed component license before mounting any studio workflow. Missing, invalid, expired, revoked or unverified grants render only the installation-license screen: no project hooks, storage handles, user session or engine API transport starts. A configured token alone is insufficient. The package reuses the actual `@polycyphers/license` Ed25519 verifier and strictly checks package, version, hostname, tier, issue/expiry times and token identity. Development hosts require a genuine grant too. Only `pro`, `team`, `enterprise` and `internal` installation tiers enable BIM; signed OSS or public-trial tokens are rejected.
23
+ Version 0.1.4 retains the signed component license requirement before mounting any studio workflow. Missing, invalid, expired, revoked or unverified grants render only the installation-license screen: no project hooks, storage handles, user session or engine API transport starts. A configured token alone is insufficient. The package reuses the actual `@polycyphers/license` Ed25519 verifier and strictly checks package, version, hostname, tier, issue/expiry times and token identity. Development hosts require a genuine grant too. Only `pro`, `team`, `enterprise` and `internal` installation tiers enable BIM; signed OSS or public-trial tokens are rejected.
20
24
 
21
25
  Fresh signed revocation evidence comes from the existing fixed management endpoint using a bounded, timed request. Unsigned local caches, network failures, stale or inconsistent revocation envelopes do not grant access. An in-memory grant lease lasts at most sixty seconds, is refreshed every thirty seconds and never exceeds signed expiry; every engine transport checks that lease again. Changing or clearing the token immediately closes the studio. These checks protect the supplied component, not arbitrary modified JavaScript: server licensing, tenant access, original AI quotas and project entitlements remain independent and authoritative.
22
26
 
@@ -28,7 +32,7 @@ Distribution proof: `npm pack` builds ESM/CJS, declarations, scoped CSS, font li
28
32
 
29
33
  ## Shared studio integration
30
34
 
31
- One React component is mounted in the public service and both original apps. `BimStudio` accepts `embedded`, an authenticated host `transport`, `workspaceKey` and optional `initialInput`. Host pages derive the workspace key from their already verified user and physical tender/project; the backend rechecks scope on every request.
35
+ One React component is mounted in the public service and both original apps. `BimStudio` accepts `embedded`, an authenticated host `transport`, `workspaceKey`, optional `language` (`en`, `de`, `fr`, `ar`), `onStateChange` and optional `initialInput`. Host pages derive the workspace key from their already verified user and physical tender/project; the backend rechecks scope on every request.
32
36
 
33
37
  Only an opaque project UUID is saved in localStorage under that scoped key. JWTs, account credentials, verification tokens, sketch bytes, programme inputs and model data are never persisted by this component. Public authentication obtains its key from authenticated `/v1/session`; JWTs remain in component memory. A refresh requires signing in again before a public project can resume. Verification uses `/verify-email`, strips its token from the address bar, and waits for explicit submission. The canonical email service must configure its fixed HTTPS verification destination; a browser cannot select a return URL.
34
38
 
@@ -38,7 +42,7 @@ AI edits return an unsaved, recomputed preview. Apply sends its typed edit and e
38
42
 
39
43
  Prices and free allowances come from configuration, including legitimate zero values. Currency minor-unit conversion follows the currency's Intl exponent instead of assuming two decimals. Core workflow labels support EN/DE/FR/AR and the shared Arabic container uses RTL.
40
44
 
41
- Build: `npm run build`. Source-repository workflow checks: `node --experimental-strip-types --test tests/state.test.mjs`. The BauLynq host's `SketchStudio.shared.test.tsx` exercises real rendering, host-only401 handling, scoped resume, explicit preview/apply, signup, verification URL scrubbing, provenance and pending deletion. Vite hosts deduplicate React/ReactDOM when using local file dependencies.
45
+ Build: `npm run build`. `npm test` runs the real signed-license checks, pure state checks and canonical DOM workflow suite. The DOM suite mocks the cryptographic boundary only; it exercises real rendering, host-only401 handling, scoped resume, explicit preview/apply, signup, verification URL scrubbing, provenance, pending deletion, reactive locale changes and stale-output guards. Vite hosts deduplicate React/ReactDOM when using local file dependencies.
42
46
 
43
47
  Image uploads require explicit permission and AI-processing acknowledgements. Selecting an image remains local. Upload requests send both acknowledgement flags to the secure server scanner; reading a stored sketch with Claude is a separate explicit action. EU storage is disclosed separately from provider inference region/DPA configuration.
44
48
 
@@ -53,3 +57,29 @@ Owner-only `/artifacts` metadata restores successful saved uploads/drawing/model
53
57
  Public session changes clear prior private workspace state; epoch checks reject late requests/JSON from an old session. A first anonymous manual draft survives initial login. Consented analytics authenticates with the current in-memory bearer without putting identity in its typed payload. Account project-content deletion is distinct from account/billing deletion and reports pending work explicitly. Checkout uses the control API's canonical availability flag and displays numeric paid usage caps before enabling Stripe.
54
58
 
55
59
  Brand presentation uses the existing runtime singleton: one host should choose one brand. Karamentreprises selects its Karament presentation; BauLynq restores hostname-based presentation. This affects branding only. BIM license validity never reads the shared runtime’s cached status.
60
+
61
+ Host language changes update labels and RTL in place; they do not remount the studio, reload a project or change its measured geometry. Without a host language, the public studio uses the supported browser language (regional language tags normalize to their base language). A host must never manufacture an `initialInput` just to select language. Embedded rendering leaves the host document's `lang` and `dir` untouched. Changing a locale is presentation only; engine-authored titles, rule messages and drawings retain their saved language until a normal user-requested recomputation.
62
+
63
+ `onStateChange(state: StudioState)` reports `{busy, hasUnsavedChanges}` for the host's navigation/update guard and clears both flags on unmount. A saved project alone is clean. Changed measurements, unsent chat/brief, an unsaved AI edit or outline preview, and a local image awaiting upload are unsaved work. The callback does not cancel a server operation or promise that an interrupted request consumed no allowance. Hosts should use a stable callback and retain their user/project mount key across locale changes.
64
+
65
+ Measurement fields and stage/proposal switches lock during an operation. Editing a measurement invalidates the earlier reconciliation evidence and confirmation; an engine-requested diagonal remains editable. Switching the displayed proposal clears bundles for the earlier proposal, while its owner-authorized saved artifacts remain accessible with their original metadata. A result without proposals shows its engine status/findings and a return to measurements, without export controls or a success claim. Programme and build-up form labels use the server's per-field origins; omitted concept defaults stay estimated. Locally typing a value makes it user-given and unconfirmed, never measured or certified. The server discards browser-supplied origin maps and derives its own field-presence/adoption evidence.
66
+
67
+ Version history is loaded on demand through owner-authorized GET `/history`; comparison calls GET `/compare?left=…&right=…` and shows the server's changed-input list, selected layout IDs and area delta marked calculated/unconfirmed. These reads do not request AI or generation/export credits. Restore calls the normal CAS `/undo` endpoint with the current expected version and chosen earlier target, creating a new version. Earlier versions are immutable, stale restore conflicts remain visible, and history/comparison state clears on trusted workspace changes. The studio content resets only when the verified workspace changes, never when its language changes.
68
+
69
+ ### Existing-plan review candidate (0.1.3 source)
70
+
71
+ `enableExistingPlanReview` is opt-in and defaults to false, preserving existing
72
+ hosts. Enable it only after deploying the authenticated digitization API and
73
+ updating the host's scoped Client/gateway routes. It provides manual metric
74
+ coordinates, rooms and hosted-opening review. Explicit image recognition can
75
+ request unconfirmed pixel observations from Anthropic; that provider path still
76
+ requires live accuracy and cost validation. A calibration preview requires a
77
+ user-entered known distance and keeps every resulting dimension estimated. It
78
+ assumes a rectified image, reports missing values, and does not correct perspective
79
+ or confirm source geometry. Starting review from these suggestions keeps numeric
80
+ fields unconfirmed until the user supplies source values individually. Values entered by the user remain user-given, never certified
81
+ measurements. No save/export is trusted solely because the browser checked a box.
82
+ The server validates the exact graph hash, provenance and reviewed paths and
83
+ requires a successfully funded revision before export. PDF scale/paper options
84
+ appear only when the service reports PDF availability. The existing default
85
+ layout workflow and the frozen published 0.1.2 archive remain unchanged.
@@ -1,6 +1,13 @@
1
- import type { ProjectInput } from './types';
1
+ import type { Lang, ProjectInput } from './types';
2
2
  import './style.css';
3
+ export interface StudioState {
4
+ busy: boolean;
5
+ hasUnsavedChanges: boolean;
6
+ }
3
7
  export interface StudioProps {
8
+ enableExistingPlanReview?: boolean;
9
+ onStateChange?: (state: StudioState) => void;
10
+ language?: Lang;
4
11
  brand?: 'baulynq' | 'karamentreprises';
5
12
  embedded?: boolean;
6
13
  transport?: (path: string, init?: RequestInit) => Promise<Response>;
@@ -0,0 +1,22 @@
1
+ import type { PendingDraft, Snapshot } from './types';
2
+ import type { Lang, Bundle } from './types';
3
+ import { type PlanApi } from './digitizationTypes';
4
+ export declare function DigitizationReview({ projectId, projectVersion, language, api, onState, onDownload, disabled, sourceObjectId, imageUrl, pendingDraft, persistPending, onPendingSaved, registerPendingSaver, loadSavedOnMount }: {
5
+ projectId: string;
6
+ projectVersion: number;
7
+ loadSavedOnMount?: boolean;
8
+ pendingDraft?: PendingDraft;
9
+ persistPending?: (pending: PendingDraft, expectedVersion: number, projectId: string) => Promise<Snapshot>;
10
+ onPendingSaved?: (snapshot: Snapshot) => void;
11
+ registerPendingSaver?: (save: (() => Promise<Snapshot | null>) | null) => void;
12
+ language: Lang;
13
+ sourceObjectId?: string;
14
+ imageUrl?: string;
15
+ disabled?: boolean;
16
+ api: PlanApi;
17
+ onState: (s: {
18
+ busy: boolean;
19
+ hasUnsavedChanges: boolean;
20
+ }) => void;
21
+ onDownload: (format: string, bundle: Bundle) => void;
22
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,20 @@
1
+ import type { Lang, ProjectComparison, ProjectVersionInfo } from './types';
2
+ interface Props {
3
+ language: Lang;
4
+ version: number;
5
+ busy: boolean;
6
+ preview: boolean;
7
+ open: boolean;
8
+ versions: ProjectVersionInfo[] | null;
9
+ comparison: ProjectComparison | null;
10
+ left: number;
11
+ right: number;
12
+ onToggle: () => void;
13
+ onLeftChange: (version: number) => void;
14
+ onRightChange: (version: number) => void;
15
+ onCompare: () => void;
16
+ onRestore: () => void;
17
+ }
18
+ /** Presentation only: all reads, comparison values and CAS restoration belong to the host API. */
19
+ export declare function VersionHistory({ language: lang, version, busy, preview, open, versions, comparison, left, right, onToggle, onLeftChange, onRightChange, onCompare, onRestore }: Props): import("react/jsx-runtime").JSX.Element;
20
+ export {};
@@ -0,0 +1,125 @@
1
+ import type { ValueReport } from './types';
2
+ export type PlanValue = {
3
+ value: number;
4
+ origin: 'measured' | 'user-given' | 'calculated' | 'estimated';
5
+ source: string;
6
+ };
7
+ export type ExistingGraph = {
8
+ schemaVersion: number;
9
+ units: string;
10
+ vertices: {
11
+ id: string;
12
+ x: PlanValue;
13
+ y: PlanValue;
14
+ }[];
15
+ boundaryVertexIds: string[];
16
+ walls: {
17
+ id: string;
18
+ startVertexId: string;
19
+ endVertexId: string;
20
+ thickness: PlanValue;
21
+ type: string;
22
+ }[];
23
+ rooms: {
24
+ id: string;
25
+ name: string;
26
+ function: string;
27
+ vertexIds: string[];
28
+ }[];
29
+ openings: {
30
+ id: string;
31
+ kind: string;
32
+ hostWallId: string;
33
+ offset: PlanValue;
34
+ width: PlanValue;
35
+ height?: PlanValue | null;
36
+ sill?: PlanValue | null;
37
+ operation: string;
38
+ }[];
39
+ };
40
+ export type PlanReview = {
41
+ pricingNotice?: string;
42
+ requiredReviewPaths?: string[];
43
+ svg?: string;
44
+ contentHash: string;
45
+ geometryValidated: boolean;
46
+ canExport: boolean;
47
+ values: ValueReport;
48
+ findings: {
49
+ code: string;
50
+ message: string;
51
+ suggestedAction?: string;
52
+ }[];
53
+ };
54
+ export type PlanRevision = {
55
+ revision: number;
56
+ graph: ExistingGraph;
57
+ review: PlanReview;
58
+ sourceObjectId?: string | null;
59
+ svg?: string;
60
+ availableFormats?: string[];
61
+ pricingNotice?: string;
62
+ };
63
+ export type PlanApi = <T>(path: string, body?: unknown, method?: string) => Promise<T>;
64
+ export declare const emptyGraph: () => ExistingGraph;
65
+ export declare const enteredValue: (value: number) => PlanValue;
66
+ export declare const draftValue: () => PlanValue;
67
+ export declare const reviewedPaths: (r: PlanReview) => string[];
68
+ export declare const geometryNumbersPresent: (g: ExistingGraph) => boolean;
69
+ export type RasterReading = {
70
+ needsCalibration: boolean;
71
+ questions: string[];
72
+ findings: unknown[];
73
+ candidate: null | {
74
+ imageWidthPx: number;
75
+ imageHeightPx: number;
76
+ units: string;
77
+ vertices: {
78
+ id: string;
79
+ xPx: number;
80
+ yPx: number;
81
+ }[];
82
+ walls: {
83
+ id: string;
84
+ startVertexId: string;
85
+ endVertexId: string;
86
+ }[];
87
+ };
88
+ };
89
+ export type MetricDraft = {
90
+ schemaVersion: number;
91
+ units: string;
92
+ vertices: ExistingGraph['vertices'];
93
+ boundaryVertexIds: string[];
94
+ walls: {
95
+ id: string;
96
+ startVertexId: string;
97
+ endVertexId: string;
98
+ thickness: PlanValue | null;
99
+ type: string;
100
+ }[];
101
+ rooms: ExistingGraph['rooms'];
102
+ openings: {
103
+ id: string;
104
+ kind: string;
105
+ hostWallId: string;
106
+ offset: PlanValue | null;
107
+ width: PlanValue | null;
108
+ operation: string;
109
+ }[];
110
+ };
111
+ export type CalibrationResult = {
112
+ draft: MetricDraft | null;
113
+ findings: {
114
+ code: string;
115
+ message: string;
116
+ }[];
117
+ questions: string[];
118
+ independentCheck?: {
119
+ predictedLengthM: number;
120
+ independentLengthM: number;
121
+ signedResidualM: number;
122
+ } | null;
123
+ };
124
+ /** Draft observations are suggestions only. Caller review cannot turn them into confirmed measurements. */
125
+ export declare function graphFromSuggestions(d: MetricDraft): ExistingGraph;