/** A furnplan customer number (Kundennummer), e.g. "14243". */
|
export type CustomerNumber = string;
|
|
/** A JSON value as read from a configuration file. */
|
export type JsonValue =
|
| null
|
| boolean
|
| number
|
| string
|
| JsonValue[]
|
| { [key: string]: JsonValue };
|
|
/** The special, manually-maintained global customer folder. */
|
export const GLOBAL_CUSTOMER_NUMBER = "14243";
|
|
/** Folder names matching this are treated as customer-number folders. */
|
export const CUSTOMER_NUMBER_PATTERN = /^\d+$/;
|
|
/**
|
* Access rules as written inside a normal customer's fileinfo.json entry.
|
* The global 14243 folder does NOT use this — its access is derived from the
|
* public/ vs private/ location instead.
|
*/
|
export interface AccessPermission {
|
/** Customer numbers explicitly granted access, in addition to the owner. */
|
consumers: CustomerNumber[];
|
/**
|
* "stores" -> every customer in the owner's StoreTree may use the config.
|
* "self" -> only the owning customer may use it.
|
*/
|
"blanket-permission": "stores" | "self";
|
}
|
|
/** One entry inside a fileinfo.json (keyed by configuration key). */
|
export interface FileInfoEntry {
|
"display-name": string;
|
/** Present for normal customers; absent for the global 14243 folder. */
|
"access-permission"?: AccessPermission;
|
}
|
|
/**
|
* A parsed fileinfo.json: configuration key -> metadata. The key is the
|
* configuration file's path relative to the customer's resolution root, without
|
* the ".json" extension (e.g. "subfolders are possible/unique-id-2").
|
*/
|
export type FileInfo = Record<string, FileInfoEntry>;
|
|
/** How a configuration may be consumed once resolved. */
|
export interface ResolvedPermission {
|
/** The customer-number folder that owns the configuration. */
|
owner: CustomerNumber;
|
/** Explicit additional consumers (empty for the global folder). */
|
consumers: CustomerNumber[];
|
/**
|
* "self" -> only the owner.
|
* "stores" -> owner + everyone in the owner's StoreTree.
|
* "public" -> any customer (global 14243/public only).
|
* "private" -> only the owner (global 14243/private only).
|
*/
|
blanket: "self" | "stores" | "public" | "private";
|
}
|
|
/** A single selectable configuration in the catalog. */
|
export interface ConfigurationEntry {
|
/** Owner customer-number folder. */
|
customerNumber: CustomerNumber;
|
/** Configuration key (relative path without ".json"). */
|
key: string;
|
/** Human-readable name from fileinfo.json. */
|
displayName: string;
|
/** Resolved permission descriptor. */
|
permission: ResolvedPermission;
|
}
|
|
/**
|
* A stored reference to one configuration. The AUC persists an ordered list of
|
* these (the merge order) in the database; no JSON content is stored there.
|
*/
|
export interface ConfigurationReference {
|
customerNumber: CustomerNumber;
|
key: string;
|
}
|
|
/** Where a resolved configuration file physically lives. */
|
export type ConfigurationLocation = "normal" | "public" | "private";
|
|
/** A reference resolved to a concrete file + its location. */
|
export interface ResolvedConfiguration {
|
absolutePath: string;
|
location: ConfigurationLocation;
|
}
|
|
/**
|
* Synchronous StoreTree membership check used by the permissions filter.
|
* (The facade accepts an async resolver and pre-resolves it to this.)
|
*/
|
export interface PermissionOptions {
|
isStoreMember?: (
|
ownerCustomerNumber: CustomerNumber,
|
requestingCustomerNumber: CustomerNumber,
|
) => boolean;
|
}
|
|
/**
|
* Resolves whether `requestingCustomerNumber` is in `ownerCustomerNumber`'s
|
* StoreTree (furncloudcredentials). Supplied by the host (furnplan_web) so the
|
* library never touches the database. May be sync or async.
|
*/
|
export type StoreMembershipResolver = (
|
ownerCustomerNumber: CustomerNumber,
|
requestingCustomerNumber: CustomerNumber,
|
) => boolean | Promise<boolean>;
|