pict-microapp 1.0.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.
@@ -0,0 +1,192 @@
1
+ export = PictMicroApp;
2
+ declare class PictMicroApp extends libPictProvider {
3
+ /**
4
+ * @param {Object} pFable - the fable instance
5
+ * @param {Object} [pOptions] - provider options, including the Manifest
6
+ * @param {String} [pServiceHash] - the service hash
7
+ */
8
+ constructor(pFable: any, pOptions?: any, pServiceHash?: string);
9
+ /** The normalized manifest — always fully populated, whatever the author wrote. */
10
+ manifest: any;
11
+ /** Route patterns the gate refused, in registration order. Read this when a screen is missing. */
12
+ blockedRoutes: any[];
13
+ /** Route patterns the gate admitted with an entity guard. */
14
+ guardedRoutes: any[];
15
+ /** Route patterns that survived untouched. */
16
+ allowedRoutes: any[];
17
+ /** The original addRoute, kept so releaseRouter() can put the host back the way it was. */
18
+ _originalAddRoute: any;
19
+ /** The original navigo `on`, for the same reason. */
20
+ _originalRouterOn: any;
21
+ /** The router provider the gate is currently installed on. */
22
+ _gatedRouter: any;
23
+ /** True while the provider-level gate is delegating into the navigo-level one. */
24
+ _delegating: boolean;
25
+ /**
26
+ * The host's pict-router provider, or null before it exists.
27
+ *
28
+ * @return {Object|null} the router provider
29
+ */
30
+ get pictRouter(): any | null;
31
+ /**
32
+ * The host's navigation provider, or null when the host has none.
33
+ *
34
+ * @return {Object|null} the navigation provider
35
+ */
36
+ get navigationProvider(): any | null;
37
+ /**
38
+ * Replace the manifest after construction. Only meaningful before the gate is installed.
39
+ *
40
+ * @param {Object} pManifest - a micro app manifest
41
+ * @return {Object} the normalized manifest
42
+ */
43
+ setManifest(pManifest: any): any;
44
+ /**
45
+ * What would the gate do with this route? Exposed so an app (or a test) can ask without
46
+ * registering anything.
47
+ *
48
+ * @param {String} pRoute - a route pattern
49
+ * @return {{Mode: String, Route: String, Reason: String}} the decision
50
+ */
51
+ routeDecision(pRoute: string): {
52
+ Mode: string;
53
+ Route: string;
54
+ Reason: string;
55
+ };
56
+ /**
57
+ * Install the route gate on the host's router.
58
+ *
59
+ * MUST be called after the router provider exists but BEFORE the host registers its routes. In
60
+ * a pict application that means after the provider that owns routing has been added (usually in
61
+ * onInitializeAsync) and before the login/data-load cycle that registers them.
62
+ *
63
+ * Wrapping the instance method rather than the prototype keeps the blast radius to this one
64
+ * router: a host that shares pict-router with an embedded module is unaffected.
65
+ *
66
+ * TWO funnels are wrapped, not one. Most code registers through the provider's `addRoute`, but
67
+ * some modules reach past it and call the underlying router's `on` directly — pict-section-
68
+ * recordset's list, dashboard, associate and bulk-delete views all do, which is every one of its
69
+ * highest-traffic screens. Gating only `addRoute` silently leaves those wide open, and because
70
+ * they still work you would never notice. The provider-level wrapper sets `_delegating` while it
71
+ * calls through, so a route that came in via `addRoute` is decided once, not twice.
72
+ *
73
+ * @param {Object} [pPictRouter] - the router provider; defaults to the configured one
74
+ * @return {Boolean} whether the gate was installed
75
+ */
76
+ gateRouter(pPictRouter?: any): boolean;
77
+ /**
78
+ * Record (and optionally log) a route the gate refused.
79
+ *
80
+ * @param {{Route: String, Reason: String}} pDecision - the decision that blocked it
81
+ */
82
+ _noteBlocked(pDecision: {
83
+ Route: string;
84
+ Reason: string;
85
+ }): void;
86
+ /**
87
+ * Put the host's router back the way it was. Primarily for tests.
88
+ *
89
+ * @return {Boolean} whether a gate was removed
90
+ */
91
+ releaseRouter(): boolean;
92
+ /**
93
+ * Wrap an entity-parameterized route's handler so an entity the micro app does not expose
94
+ * bounces to the fallback instead of rendering.
95
+ *
96
+ * Wildcard record-set routes ('/PSRS/:RecordSet/List') are registered once by the host and fan
97
+ * out over every entity it knows. They cannot be refused per-entity at registration time, so
98
+ * this is where the subsetting has to happen.
99
+ *
100
+ * @param {String} pRoute - the canonical route pattern
101
+ * @param {Function|String} pRenderable - the host's handler
102
+ * @return {Function|String} the guarded handler, or the renderable untouched when it is a template
103
+ */
104
+ _guardRenderable(pRoute: string, pRenderable: Function | string): Function | string;
105
+ /**
106
+ * Send the browser to a route. Uses the host router when it is available so hooks and history
107
+ * behave the same as any other navigation.
108
+ *
109
+ * @param {String} pRoute - the route to navigate to
110
+ * @return {Boolean} whether a navigation was attempted
111
+ */
112
+ navigate(pRoute: string): boolean;
113
+ /**
114
+ * Point a hash that matched no surviving route at the fallback, so a stale bookmark into a
115
+ * screen this micro app does not carry lands somewhere real instead of on a blank page.
116
+ *
117
+ * @param {Object} [pPictRouter] - the router provider; defaults to the configured one
118
+ * @return {Boolean} whether the handler was installed
119
+ */
120
+ installNotFound(pPictRouter?: any): boolean;
121
+ /**
122
+ * Swap the host's navigation graph for the micro app's, and PIN it.
123
+ *
124
+ * Pinning is not paranoia. A host application of any size rebuilds its own navigation after the
125
+ * fact — as configuration loads, as permissions resolve, as dynamically registered sections
126
+ * appear — and each rebuild calls `setNavigationGraph` with the host's graph, silently undoing
127
+ * the swap. The symptom is the worst kind: the micro app's menu is correct at first paint and
128
+ * then quietly becomes the host's, usually after login, where nobody is looking.
129
+ *
130
+ * So rather than racing the host for the last write, the setter itself is wrapped: later calls
131
+ * still re-normalize and re-render, they just always land on the micro app's sections.
132
+ *
133
+ * @param {Object} [pNavigationProvider] - the navigation provider; defaults to the configured one
134
+ * @return {Boolean} whether the graph was swapped
135
+ */
136
+ applyNavigationGraph(pNavigationProvider?: any): boolean;
137
+ /**
138
+ * Install the micro app's navigation visibility gate.
139
+ *
140
+ * A host that serves many audiences usually trims its own (large) graph hard — the Headlight
141
+ * platform app, for instance, shows platform super-users only the handful of cross-customer
142
+ * destinations. Applied to a micro app graph, which is already the slimmed surface, that trim
143
+ * empties the menu completely. So the default here keeps the host's real gates (session,
144
+ * module, capability) and drops only the audience short-circuit.
145
+ *
146
+ * @param {Function} pHostPermitted - (pItem) => Boolean, the host's own per-item capability test
147
+ * @param {Object} [pOptions] - { IsPrivileged: () => Boolean } to keep privileged sessions unfiltered
148
+ * @return {Boolean} whether the gate was installed
149
+ */
150
+ applyNavigationGate(pHostPermitted: Function, pOptions?: any): boolean;
151
+ /**
152
+ * Point the host's routing provider at the micro app's landing route.
153
+ *
154
+ * @param {Object} pHostRouterProvider - the provider that owns `defaultRoute` (often a wrapper
155
+ * around pict-router rather than pict-router itself)
156
+ * @return {Boolean} whether the landing route was set
157
+ */
158
+ applyDefaultRoute(pHostRouterProvider: any): boolean;
159
+ /**
160
+ * Apply the manifest's branding to the document.
161
+ *
162
+ * @return {Boolean} whether a title was set
163
+ */
164
+ applyBranding(): boolean;
165
+ /**
166
+ * A one-line summary of what the gate did, for the console and for tests.
167
+ *
168
+ * @return {{Name: String, Allowed: Number, Guarded: Number, Blocked: Number}} the tally
169
+ */
170
+ get routeTally(): {
171
+ Name: string;
172
+ Allowed: number;
173
+ Guarded: number;
174
+ Blocked: number;
175
+ };
176
+ }
177
+ declare namespace PictMicroApp {
178
+ export { _DEFAULT_PROVIDER_CONFIGURATION as default_configuration, libManifest as Manifest, composeMicroApp };
179
+ }
180
+ import libPictProvider = require("pict-provider");
181
+ declare namespace _DEFAULT_PROVIDER_CONFIGURATION {
182
+ let ProviderIdentifier: string;
183
+ let AutoInitialize: boolean;
184
+ let AutoInitializeOrdinal: number;
185
+ let Manifest: {};
186
+ let RouterProviderHash: string;
187
+ let NavigationProviderHash: string;
188
+ let LogBlockedRoutes: boolean;
189
+ }
190
+ import libManifest = require("./Pict-MicroApp-Manifest.js");
191
+ declare const composeMicroApp: typeof import("./Pict-MicroApp-Compose.js");
192
+ //# sourceMappingURL=Pict-MicroApp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Pict-MicroApp.d.ts","sourceRoot":"","sources":["../source/Pict-MicroApp.js"],"names":[],"mappings":";AA8CA;IAEC;;;;OAIG;IACH,gEA0BC;IAlBA,mFAAmF;IACnF,cAAoE;IAEpE,kGAAkG;IAClG,qBAAuB;IACvB,6DAA6D;IAC7D,qBAAuB;IACvB,8CAA8C;IAC9C,qBAAuB;IAEvB,2FAA2F;IAC3F,uBAA6B;IAC7B,qDAAqD;IACrD,uBAA6B;IAC7B,8DAA8D;IAC9D,kBAAwB;IACxB,kFAAkF;IAClF,qBAAwB;IAGzB;;;;OAIG;IACH,kBAFY,MAAO,IAAI,CAMtB;IAED;;;;OAIG;IACH,0BAFY,MAAO,IAAI,CAMtB;IAED;;;;;OAKG;IACH,iCAIC;IAED;;;;;;OAMG;IACH,+BAFY;QAAC,IAAI,SAAS;QAAC,KAAK,SAAS;QAAC,MAAM,SAAQ;KAAC,CAKxD;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,uCA8EC;IAED;;;;OAIG;IACH,wBAFW;QAAC,KAAK,SAAS;QAAC,MAAM,SAAQ;KAAC,QASzC;IAED;;;;OAIG;IACH,yBAeC;IAED;;;;;;;;;;;OAWG;IACH,8CAHW,iBAAe,GACd,iBAAe,CAmB1B;IAED;;;;;;OAMG;IACH,kCAeC;IAED;;;;;;OAMG;IACH,4CAkBC;IAED;;;;;;;;;;;;;;OAcG;IACH,yDAuBC;IAED;;;;;;;;;;;;OAYG;IACH,uEA+BC;IAED;;;;;;OAMG;IACH,qDASC;IAED;;;;OAIG;IACH,yBASC;IAED;;;;OAIG;IACH,kBAFY;QAAC,IAAI,SAAS;QAAC,OAAO,SAAS;QAAC,OAAO,SAAS;QAAC,OAAO,SAAQ;KAAC,CAW5E;CACD"}