Files
isa-project-format/README.md
T

10 KiB
Raw Permalink Blame History

ISA Project format

Version 1 is a dashboard-backed <name>.isap folder containing project.json, extensions/<extension-id>/ and assets/. The manifest contains formatVersion: 1, stable id, display name, and UTC createdAt/updatedAt timestamps. Canonical dashboard folder IDs are storage identities; names and paths do not grant access. Imports allocate a new identity and folder.

Extension namespaces organize data and are not permission boundaries. A project read-write grant permits supported edits across namespaces. Preserve unknown manifest fields, files and extension data. Each extension documents its canonical data; ISA Projects owns planning and detailed progress. Common summaries live in extensions/<extension-id>/status.json with schemaVersion: 1, status (not-started, in-progress, blocked, complete), updatedAt, and optional completion between 0 and 100. Summary data is editable project content and never grants publishing authority.

Public APIs

The root export is framework-neutral ESM with TypeScript declarations. @isa-warden/isa-project-format/dom exports DOM mounting functions. @isa-warden/isa-project-format/svelte exports ProjectWorkspace, ProjectHeader and ProjectPicker components; Svelte is an optional peer for consumers of those components. Extension packages bundle these modules and the ZIP dependency at build time. No remote runtime imports are required.

import { createProjectClient } from '@isa-warden/isa-project-format';
import { mountProjectWorkspace } from '@isa-warden/isa-project-format/dom';

const client = createProjectClient({
  bridge,
  extensionId: 'example',
  projectCommands: appInfo.projects?.commands,
  scope: { workspaceId, groupId }
});
const view = mountProjectWorkspace(target, { client, bridge, extensionName: 'Example', locale: 'en' });
// On extension teardown:
view.destroy();
await client.close();

The shared UI provides a searchable group project overview, recent activity, project creation, an active-project header, file/media browsing, transfer actions and a Tauri-compatible HTML confirmation for dirty project switches. English and Dutch labels are included. It inherits ISA extension theme tokens; detailed application workflows and planning remain in the extension. Components consume a captured client instance: remount with a new client when the launch context changes.

client.activate(reference) opens a listed or recent reference by reading its manifest through an existing grant. client.create(name, operationId?) uses host creation and retains its operation ID through uncertain retries in the current client. Callers with durable recovery journals should provide their persisted operation ID. Recent references are private, launch-scoped host preferences rather than canonical project state. Preference failures are observable on session.preferenceError and do not invalidate an already committed creation/switch.

Sessions capture their project path and abort signal. readJson returns an authoritative CAS base; writeJson(relative, value, base, {operationId?}) requires that same file’s base and sends its revision/hash. ensureDirectory(relative) creates real parent directories in order; openKv does this for its parent before opening a store. openKv, applyKv and subscribeKv use the captured project destination. Use extensionPath for extension-owned paths, publishStatus for summaries and readStatuses for the overview. Subscriptions and registered cleanup callbacks close on switching; late results cannot use a retired session. Mark unsaved work with session.markDirty(). Without explicit confirmation, dirty sessions block switching. Mounting the shared UI supplies a confirmation; applications can provide beforeSwitch to integrate an existing save/discard workflow.

Project start screen

Use the ISA Match layout for a project-based extension. Show recent activity on the left and Projects (Projecten) on the right. Place + Create project at the top right of the Projects panel. Populate this list on launch with await client.list(), which returns active shared projects for the launch group, including ones this extension has never used. client.recent() supplies optional personal shortcuts. Use the project rows to open existing projects and the create button to launch the setup form.

Use the shared ProjectWorkspace or mountProjectWorkspace overview with the extension’s display name, locale and launch-scoped client. Pass projectCommands: appInfo.projects?.commands to the client. Custom overviews call client.list() and client.openListed(row). Declare projects_open_listed, projects_read and filesystem_read for direct access. On older hosts the client reads the selected folder using its existing grant. If access is unavailable, the overview shows the error and keeps the project list available. Only explicit creation calls client.create(name, operationId).

Every project extension initializes its own data when a writable project first opens. The client ensures the extension directory exists, and the extension opens its workspace with the stored data. For a JSON-backed workspace, call await session.ensureExtensionJson('data/current.json', () => initialState(session.manifest.name)) using the extension’s canonical relative path and default schema. The result includes the saved JSON value and version. The helper creates missing parents, uses a create-only write, and reads the committed record even if another client created it. An absent record on a read-only or archived project returns status: 'absent'. Unavailable or malformed data raises an error.

For directory-backed collections, initialize the empty collection in the selected project. If the schema needs a default item, derive its UUID using await defaultProjectRecordId(session.manifest.id, extensionId) so simultaneous first opens use the same path. Users can add optional details or import content after the workspace opens.

Specialist viewers for shared data

A supplier viewer and a price-book viewer can each open on their own dataset. ISA Match and other authorised extensions can display that same data. All readers use the existing file or KV store and its schema. The viewer’s extension ID does not determine ownership of the data.

Use @isa-warden/isa-project-format/shared-folder with a folder already authorised for the current launch. For data inside an open project, pass scope: session.scope, folder: session.project and assertCurrent: session.assertCurrent. For a separately shared register, use the host-authorised workspace folder and the immutable launch scope. Host grants are per package. Reopening a linked folder uses its valid grant. A new reader needs its own host authorisation for a folder outside the project.

import { createSharedFolderReader } from '@isa-warden/isa-project-format/shared-folder';

const reader = createSharedFolderReader({ bridge, scope, folder, assertCurrent });
const index = await reader.readJson('isa-match-suppliers.json');
if (index.status === 'found') {
  const register = index.value;
  if (register.format !== 'isa-match-workspace-suppliers-v1' ||
      register.workspaceId !== scope.workspaceId ||
      typeof register.id !== 'string' || !register.id || !Array.isArray(register.suppliers)) {
    throw new Error('Unexpected supplier register');
  }
  const id = encodeURIComponent(register.id);
  // The supplier directory contains stable supplier IDs and public identities.
  const suppliers = register.suppliers;
  // The price-book viewer reads the published price rows from the same folder.
  const snapshot = await reader.readKv('isa-match-prices-' + id + '.kv');
  const prices = snapshot.entries.filter(entry => entry.key.startsWith('price/'));
}

For supplier details, read isa-match-catalog-<encoded register ID>.kv and the active generation in catalog/meta. Profiles use catalog/<active>/supplier/<supplier ID>/profile. Use the active generation to exclude retired and staged records. The prices KV contains the shared price book. The separate ISA Prijzenregister searches published records across the workspace. A viewer that only needs suppliers can skip the prices read entirely.

listFiles() lists the authorised directory. readFile and readJson distinguish authoritative absence from a failed read. readKv pages a consistent snapshot and checks store identity and revision across pages. These operations use the host’s filesystem or KV read access without creating files, modifying records or granting another extension access.

ZIP transfer

exportProject, importProject, exportProjectToDialog and importProjectFromDialog use existing host file and KV transfer primitives. Exports include media and unknown files, and capture consistent live KV snapshots instead of stale checkpoint artifacts. A versioned .isa-transfer.json sidecar maps logical KV contents to their canonical paths; the KV files are rebuilt through host operations on import, retaining list item identities/order. Runtime grants, service approvals and credentials are not part of the transfer format. Imported audit fields are historical reference data; server-owned authorization remains outside the project.

Imports validate the whole ZIP and transfer metadata before creating a project. Validation rejects traversal, absolute/backslash paths, links, duplicate/case/Unicode path collisions, overlapping headers, malformed compression/CRC, unsupported versions and bounded decompression failures. Transfer limits may be lowered: default archive and total expanded data limits are 512 MiB, individual entries 256 MiB, and entry count 10,000. Media above 16 MiB uses the host’s authorized download link and a bounded streamed fetch, verifies the snapshot hash and size, then renews authorization before completing. Other host transport limits can still be lower; a failed read is an explicit transfer failure and is never silently omitted. Export checks file generations/inventory and live KV revisions again before producing an archive. Transfers fence cancellation with the captured session.

Run npm run build to check ESM syntax, compile-check Svelte components and execute the focused format, lifecycle and real ZIP regression suites. The shared UI and large-media transport still require native/browser integration validation as part of the complete extension release.

Before an export, supply beforeExport(session) to the transfer UI when an editor uses debounced saves. It must flush that captured session or reject; the library revalidates the session and dirty state before reading the archive. Late work must never target a replacement project session.