Gesamte Mono-Repo des Baukastens (alle apps/clients, examples/tests und packages)
dh_heyart
vor 7 Std. 7b1747b3214ec3de482f775cede2649c26e836a9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/** 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>;