@qrvey/widget-configurability 0.0.0-beta.4430 → 0.0.0-beta.4482

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.
Files changed (36) hide show
  1. package/dist/cjs/constants/configs.js +29 -1
  2. package/dist/cjs/constants/configs.js.map +1 -1
  3. package/dist/cjs/constants/structure.constants.js +14 -1
  4. package/dist/cjs/constants/structure.constants.js.map +1 -1
  5. package/dist/cjs/doc/dashboard.structure.doc.js +8 -0
  6. package/dist/cjs/doc/dashboard.structure.doc.js.map +1 -1
  7. package/dist/cjs/doc/swagger.optional.js +3 -1
  8. package/dist/cjs/doc/swagger.optional.js.map +1 -1
  9. package/dist/cjs/index.js +28 -1
  10. package/dist/cjs/index.js.map +1 -1
  11. package/dist/cjs/models/scope.models.js +3 -0
  12. package/dist/cjs/models/scope.models.js.map +1 -0
  13. package/dist/cjs/structural-manager.js +69 -5
  14. package/dist/cjs/structural-manager.js.map +1 -1
  15. package/dist/cjs/structures/chart-builder.structure.v1.js +18 -0
  16. package/dist/cjs/structures/chart-builder.structure.v1.js.map +1 -0
  17. package/dist/cjs/structures/chart-gallery.structure.v1.js +18 -0
  18. package/dist/cjs/structures/chart-gallery.structure.v1.js.map +1 -0
  19. package/dist/cjs/structures/chart-panel.structure.v1.js +71 -0
  20. package/dist/cjs/structures/chart-panel.structure.v1.js.map +1 -0
  21. package/dist/cjs/structures/dashboard.structure.v1.js +116 -13
  22. package/dist/cjs/structures/dashboard.structure.v1.js.map +1 -1
  23. package/dist/cjs/structures/download-modal.structure.v1.js +33 -0
  24. package/dist/cjs/structures/download-modal.structure.v1.js.map +1 -0
  25. package/dist/cjs/utils/defaults.helpers.js +26 -6
  26. package/dist/cjs/utils/defaults.helpers.js.map +1 -1
  27. package/dist/cjs/utils/download-modal.helpers.js +27 -0
  28. package/dist/cjs/utils/download-modal.helpers.js.map +1 -0
  29. package/dist/cjs/utils/scope.helpers.js +88 -0
  30. package/dist/cjs/utils/scope.helpers.js.map +1 -0
  31. package/dist/cjs/utils/structural.helpers.js +52 -29
  32. package/dist/cjs/utils/structural.helpers.js.map +1 -1
  33. package/dist/esm/index.mjs +655 -170
  34. package/dist/esm/index.mjs.map +1 -1
  35. package/dist/types/index.d.ts +135 -5
  36. package/package.json +8 -1
@@ -1,8 +1,15 @@
1
1
  declare enum Widget {
2
2
  DASHBOARD = "dashboard",
3
3
  REPORT = "report",
4
- DOWNLOAD_MANAGER = "download-manager"
4
+ DOWNLOAD_MANAGER = "download-manager",
5
+ DOWNLOAD_MODAL = "download-modal",
6
+ CHART_PANEL = "chart-panel",
7
+ CHART_GALLERY = "chart-gallery",
8
+ CHART_BUILDER = "chart-builder"
5
9
  }
10
+ declare const WIDGET_SUBMODULE_NAMES: Partial<Record<Widget, string>>;
11
+ declare const WIDGET_STRUCTURE_SCOPE_KIND = "qrvey.widget-structure-scope";
12
+ declare const WIDGET_STRUCTURE_SCOPE_FORMAT = 1;
6
13
  declare enum WidgetVersion {
7
14
  v1 = "1.0",
8
15
  latest = "latest"
@@ -37,7 +44,31 @@ interface WidgetCustomization extends CustomizationStructure {
37
44
  views?: View;
38
45
  }
39
46
 
40
- type SectionValue = number | boolean | string | SectionValue[] | Record<string, unknown>;
47
+ type SectionValue = number | boolean | string | undefined | SectionValue[] | Record<string, unknown>;
48
+ type SectionDefinition = WidgetStructure | (string | WidgetStructure)[] | undefined | boolean;
49
+ interface WidgetStructure {
50
+ defaults?: Record<string, SectionValue>;
51
+ subModules?: Record<string, SectionValue>;
52
+ [key: string]: SectionDefinition | Record<string, SectionValue> | undefined;
53
+ }
54
+ interface WidgetStructureRoot extends WidgetStructure {
55
+ views?: Record<string, string[]>;
56
+ }
57
+ interface WidgetConfig {
58
+ version: string;
59
+ baseStructure: WidgetStructureRoot;
60
+ keepInheritance?: Record<string, string>;
61
+ }
62
+ type ValidationFN<T = any> = (value: T) => T | undefined;
63
+ type ValidationMap = Record<string, ValidationFN>;
64
+ type SanitizeFn = (value: string) => string;
65
+ interface StructureEngineOptions {
66
+ sanitize?: SanitizeFn;
67
+ viewConditionals?: boolean;
68
+ }
69
+ interface BuildStructureOptions extends StructureEngineOptions {
70
+ validationMap?: ValidationMap;
71
+ }
41
72
  interface WidgetItemCondition {
42
73
  effect: 'keep' | 'remove';
43
74
  condition: Condition;
@@ -49,17 +80,116 @@ interface WidgetViewMapItemObj {
49
80
  }
50
81
  type WidgetViewMapItem = string | boolean | WidgetViewMapItemObj | Record<string, SectionValue>;
51
82
  type WidgetViewMap = Record<string, WidgetViewMapItem>;
83
+ interface WidgetConditionMap {
84
+ condition: Condition;
85
+ map: WidgetViewMap;
86
+ }
87
+
88
+ interface ScopeOptions {
89
+ widget?: Widget;
90
+ version?: WidgetVersion;
91
+ state?: ConditionState;
92
+ defaultsNamespace?: string | null;
93
+ }
94
+ interface WidgetStructureScope {
95
+ kind: 'qrvey.widget-structure-scope';
96
+ format: number;
97
+ widget?: Widget;
98
+ structureVersion?: string;
99
+ source: string;
100
+ present: boolean;
101
+ map: Record<string, boolean>;
102
+ defaults?: Record<string, unknown>;
103
+ }
52
104
 
53
- declare function buildStructure(widget: Widget, customization?: WidgetCustomization, version?: WidgetVersion): WidgetStructureInstance;
105
+ declare function getWidgetConfig(widget: Widget, version?: WidgetVersion): WidgetConfig;
106
+ declare function buildStructure(widget: Widget, customization?: WidgetCustomization, version?: WidgetVersion, options?: BuildStructureOptions): WidgetStructureInstance;
54
107
  declare class WidgetStructureInstance {
55
108
  private viewMap;
56
- constructor(viewMap: WidgetViewMap);
109
+ private rootDefaults?;
110
+ constructor(viewMap: WidgetViewMap, rootDefaults?: Record<string, unknown> | undefined);
57
111
  private getValue;
58
112
  isVisible(key: string, state?: ConditionState): boolean;
59
113
  getChildMap(key: string): WidgetViewMap | undefined;
60
114
  getSubmodule(module: string, view?: string): WidgetCustomization | undefined;
61
115
  getDefaults(key: string): Record<string, unknown> | undefined;
116
+ getRootDefaults(): Record<string, unknown> | undefined;
117
+ /**
118
+ * Re-roots a resolved section (`design::downloadModal`) as plain JSON another bundle can rebuild a structure from.
119
+ */
120
+ scope(prefixKey: string, options?: ScopeOptions): WidgetStructureScope;
121
+ }
122
+
123
+ declare function validateDefaults(obj: Record<string, unknown>, validatorMap: ValidationMap, sanitize?: SanitizeFn): Record<string, unknown>;
124
+ declare const validateBoolean: (value: unknown) => boolean | undefined;
125
+ declare const DX_VALIDATOR_MAP: ValidationMap;
126
+ declare const DOWNLOAD_MODAL_VALIDATOR_MAP: ValidationMap;
127
+
128
+ interface ViewMapOptions extends StructureEngineOptions {
129
+ keepInheritance?: Record<string, string>;
130
+ }
131
+ /**
132
+ * constructs the permission map structure for a widget
133
+ * @param config configuration of a widget
134
+ * @param customization customization options for a widget
135
+ * @param validationMap
136
+ * @returns object representing the view map for the widget
137
+ */
138
+ declare function getWidgetStructure(config: WidgetConfig, customization?: WidgetCustomization, validationMap?: ValidationMap, options?: StructureEngineOptions): WidgetViewMap;
139
+ declare function calculateViewMap(config: WidgetStructureRoot, customization?: WidgetCustomization, validationMap?: ValidationMap, options?: ViewMapOptions): WidgetViewMap;
140
+ /**
141
+ * Defaults at the root of a structure without views (structure defaults merged with the customization's).
142
+ */
143
+ declare function calculateRootDefaults(config: WidgetStructureRoot, customization?: WidgetCustomization, validationMap?: ValidationMap, sanitize?: SanitizeFn): Record<string, unknown> | undefined;
144
+
145
+ declare function evaluateCondition(state: ConditionState | undefined, ...conditions: Condition[]): boolean;
146
+ declare function checkConditions(state: ConditionState | undefined, conditions: WidgetItemCondition[]): boolean;
147
+
148
+ type StructureInput = WidgetStructureScope | WidgetCustomization | null | undefined;
149
+ declare function isWidgetStructureScope(value: unknown): value is WidgetStructureScope;
150
+ /**
151
+ * Turns a resolved scope back into a customization of the widget it lists: hidden keys become an explicit remove list.
152
+ */
153
+ declare function scopeToCustomization(scope: WidgetStructureScope): WidgetCustomization;
154
+ /**
155
+ * Extracts a section of a host's customization as a customization of the embedded widget, by evaluating it with the host's engine.
156
+ */
157
+ declare function extractCustomization(host: Widget, customization: WidgetCustomization | undefined, prefixKey: string, target: Widget, options?: BuildStructureOptions): WidgetCustomization;
158
+ /**
159
+ * Builds an embedded widget's structure from what its host passes: a resolved scope, a raw customization of the widget, or a host
160
+ * customization carrying the widget under subModules. Returns undefined for no input or an invalid one, so the receiver keeps its
161
+ * legacy behaviour.
162
+ */
163
+ declare function structureFrom(widget: Widget, input: unknown, view?: string, version?: WidgetVersion): WidgetStructureInstance | undefined;
164
+ /**
165
+ * Builds the structure of a widget a host embeds as a submodule (chartPanel, chartGallery, chartBuilder, downloadModal).
166
+ */
167
+ declare function structureFromSubmodule(parent: WidgetStructureInstance, module: string, view?: string, options?: BuildStructureOptions): WidgetStructureInstance;
168
+
169
+ interface DownloadModalResolvedConfig {
170
+ schedule: boolean;
171
+ subscribe: boolean;
172
+ banner: boolean;
173
+ owner: boolean;
174
+ organization: boolean;
175
+ myself: boolean;
176
+ specificPeople: boolean;
177
+ externalUsers: boolean;
178
+ subscribeMyselfDefault: boolean;
62
179
  }
180
+ interface ResolveDownloadModalOptions {
181
+ organizationAvailable?: boolean;
182
+ }
183
+ /**
184
+ * The export modal's visibility rules: Schedule hides Subscribe, and Subscribe hides when it has nothing left to show.
185
+ */
186
+ declare function resolveDownloadModalConfig(structure: WidgetStructureInstance, { organizationAvailable }?: ResolveDownloadModalOptions): DownloadModalResolvedConfig;
187
+
188
+ declare const DOWNLOAD_MODAL_V1_KEYS: readonly ["qScheduleOption", "qSubscribeOption", "qSubscribeExternalUsers", "qSubscribeBanner", "qSubscribeOwner", "qSubscribeOrganization", "qSubscribeMyself", "qSubscribeSpecificPeople", "qIncludeHyperlinks"];
189
+ type DownloadModalKey = (typeof DOWNLOAD_MODAL_V1_KEYS)[number];
190
+ declare const DOWNLOAD_MODAL_V1_DEFAULTS: {
191
+ subscribeMyself: boolean;
192
+ };
63
193
 
64
194
  declare class ViewsDto {
65
195
  list: string[];
@@ -124,4 +254,4 @@ declare namespace dashboard_structure_doc {
124
254
  export { dashboard_structure_doc_AssetListDto as AssetListDto, dashboard_structure_doc_BaseDashboardV1StructureDto as BaseDashboardV1StructureDto, dashboard_structure_doc_FilterPanelDto as FilterPanelDto, dashboard_structure_doc_MenuBarDto as MenuBarDto, dashboard_structure_doc_SubModulesDto as SubModulesDto, dashboard_structure_doc_ViewsDto as ViewsDto };
125
255
  }
126
256
 
127
- export { dashboard_structure_doc as DashboardDoc, Widget, type WidgetCustomization, WidgetStructureInstance, WidgetVersion, buildStructure };
257
+ export { type BuildStructureOptions, type Condition, type ConditionState, type ConditionValue, DOWNLOAD_MODAL_V1_DEFAULTS, DOWNLOAD_MODAL_V1_KEYS, DOWNLOAD_MODAL_VALIDATOR_MAP, DX_VALIDATOR_MAP, dashboard_structure_doc as DashboardDoc, type DownloadModalKey, type DownloadModalResolvedConfig, type Operators, type ResolveDownloadModalOptions, type SanitizeFn, type ScopeOptions, type StructureEngineOptions, type StructureInput, type ValidationFN, type ValidationMap, WIDGET_STRUCTURE_SCOPE_FORMAT, WIDGET_STRUCTURE_SCOPE_KIND, WIDGET_SUBMODULE_NAMES, Widget, type WidgetConditionMap, type WidgetConfig, type WidgetCustomization, type WidgetItemCondition, type WidgetStructure, WidgetStructureInstance, type WidgetStructureRoot, type WidgetStructureScope, type WidgetSubModuleCollection, WidgetVersion, type WidgetViewMap, type WidgetViewMapItem, buildStructure, calculateRootDefaults, calculateViewMap, checkConditions, evaluateCondition, extractCustomization, getWidgetConfig, getWidgetStructure, isWidgetStructureScope, resolveDownloadModalConfig, scopeToCustomization, structureFrom, structureFromSubmodule, validateBoolean, validateDefaults };
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "@qrvey/widget-configurability",
3
- "version": "0.0.0-beta.4430",
3
+ "version": "0.0.0-beta.4482",
4
4
  "types": "dist/types/index.d.ts",
5
5
  "main": "dist/cjs/index.js",
6
+ "module": "./dist/esm/index.mjs",
6
7
  "exports": {
7
8
  ".": {
9
+ "types": "./dist/types/index.d.ts",
8
10
  "import": "./dist/esm/index.mjs",
9
11
  "require": "./dist/cjs/index.js",
10
12
  "default": "./dist/cjs/index.js"
@@ -33,6 +35,11 @@
33
35
  "peerDependencies": {
34
36
  "@nestjs/swagger": "11.4.5"
35
37
  },
38
+ "peerDependenciesMeta": {
39
+ "@nestjs/swagger": {
40
+ "optional": true
41
+ }
42
+ },
36
43
  "devDependencies": {
37
44
  "@nestjs/swagger": "11.4.5",
38
45
  "@types/jest": "29.5.14",