@memberjunction/ng-dashboard-viewer 6.2.0-edge.4 → 6.2.0-edge.6

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 (84) hide show
  1. package/README.md +17 -3
  2. package/dist/lib/config-panels/artifact-config-panel.component.js +2 -2
  3. package/dist/lib/config-panels/component-config-panel.component.d.ts +51 -0
  4. package/dist/lib/config-panels/component-config-panel.component.d.ts.map +1 -0
  5. package/dist/lib/config-panels/component-config-panel.component.js +246 -0
  6. package/dist/lib/config-panels/component-config-panel.component.js.map +1 -0
  7. package/dist/lib/config-panels/index.d.ts +1 -0
  8. package/dist/lib/config-panels/index.d.ts.map +1 -1
  9. package/dist/lib/config-panels/index.js +1 -0
  10. package/dist/lib/config-panels/index.js.map +1 -1
  11. package/dist/lib/config-panels/query-config-panel.component.js +2 -2
  12. package/dist/lib/config-panels/view-config-panel.component.js +2 -2
  13. package/dist/lib/config-panels/weburl-config-panel.component.js +2 -2
  14. package/dist/lib/dashboard-viewer/dashboard-viewer.component.d.ts +58 -1
  15. package/dist/lib/dashboard-viewer/dashboard-viewer.component.d.ts.map +1 -1
  16. package/dist/lib/dashboard-viewer/dashboard-viewer.component.js +186 -4
  17. package/dist/lib/dashboard-viewer/dashboard-viewer.component.js.map +1 -1
  18. package/dist/lib/dashboard-viewer.module.d.ts +22 -17
  19. package/dist/lib/dashboard-viewer.module.d.ts.map +1 -1
  20. package/dist/lib/dashboard-viewer.module.js +29 -4
  21. package/dist/lib/dashboard-viewer.module.js.map +1 -1
  22. package/dist/lib/dialogs/part-dialog/dashboard-part-dialog.component.d.ts +35 -1
  23. package/dist/lib/dialogs/part-dialog/dashboard-part-dialog.component.d.ts.map +1 -1
  24. package/dist/lib/dialogs/part-dialog/dashboard-part-dialog.component.js +307 -34
  25. package/dist/lib/dialogs/part-dialog/dashboard-part-dialog.component.js.map +1 -1
  26. package/dist/lib/dialogs/properties-dialog/dashboard-properties-dialog.component.d.ts +79 -0
  27. package/dist/lib/dialogs/properties-dialog/dashboard-properties-dialog.component.d.ts.map +1 -0
  28. package/dist/lib/dialogs/properties-dialog/dashboard-properties-dialog.component.js +461 -0
  29. package/dist/lib/dialogs/properties-dialog/dashboard-properties-dialog.component.js.map +1 -0
  30. package/dist/lib/dialogs/property-default-editor/property-default-editor.component.d.ts +41 -0
  31. package/dist/lib/dialogs/property-default-editor/property-default-editor.component.d.ts.map +1 -0
  32. package/dist/lib/dialogs/property-default-editor/property-default-editor.component.js +248 -0
  33. package/dist/lib/dialogs/property-default-editor/property-default-editor.component.js.map +1 -0
  34. package/dist/lib/models/dashboard-config-validator.d.ts +30 -0
  35. package/dist/lib/models/dashboard-config-validator.d.ts.map +1 -0
  36. package/dist/lib/models/dashboard-config-validator.js +107 -0
  37. package/dist/lib/models/dashboard-config-validator.js.map +1 -0
  38. package/dist/lib/models/dashboard-part-interfaces.d.ts +42 -0
  39. package/dist/lib/models/dashboard-part-interfaces.d.ts.map +1 -0
  40. package/dist/lib/models/dashboard-part-interfaces.js +180 -0
  41. package/dist/lib/models/dashboard-part-interfaces.js.map +1 -0
  42. package/dist/lib/models/dashboard-properties.d.ts +182 -0
  43. package/dist/lib/models/dashboard-properties.d.ts.map +1 -0
  44. package/dist/lib/models/dashboard-properties.js +263 -0
  45. package/dist/lib/models/dashboard-properties.js.map +1 -0
  46. package/dist/lib/models/dashboard-types.d.ts +8 -0
  47. package/dist/lib/models/dashboard-types.d.ts.map +1 -1
  48. package/dist/lib/models/dashboard-types.js.map +1 -1
  49. package/dist/lib/models/part-inputs-editor.d.ts +36 -0
  50. package/dist/lib/models/part-inputs-editor.d.ts.map +1 -0
  51. package/dist/lib/models/part-inputs-editor.js +53 -0
  52. package/dist/lib/models/part-inputs-editor.js.map +1 -0
  53. package/dist/lib/parts/artifact-part.component.d.ts.map +1 -1
  54. package/dist/lib/parts/artifact-part.component.js +5 -4
  55. package/dist/lib/parts/artifact-part.component.js.map +1 -1
  56. package/dist/lib/parts/base-dashboard-part.d.ts +50 -1
  57. package/dist/lib/parts/base-dashboard-part.d.ts.map +1 -1
  58. package/dist/lib/parts/base-dashboard-part.js +108 -1
  59. package/dist/lib/parts/base-dashboard-part.js.map +1 -1
  60. package/dist/lib/parts/component-part.component.d.ts +54 -0
  61. package/dist/lib/parts/component-part.component.d.ts.map +1 -0
  62. package/dist/lib/parts/component-part.component.js +221 -0
  63. package/dist/lib/parts/component-part.component.js.map +1 -0
  64. package/dist/lib/parts/index.d.ts +1 -0
  65. package/dist/lib/parts/index.d.ts.map +1 -1
  66. package/dist/lib/parts/index.js +1 -0
  67. package/dist/lib/parts/index.js.map +1 -1
  68. package/dist/lib/parts/query-part.component.d.ts +25 -1
  69. package/dist/lib/parts/query-part.component.d.ts.map +1 -1
  70. package/dist/lib/parts/query-part.component.js +93 -10
  71. package/dist/lib/parts/query-part.component.js.map +1 -1
  72. package/dist/lib/parts/view-part.component.d.ts +18 -1
  73. package/dist/lib/parts/view-part.component.d.ts.map +1 -1
  74. package/dist/lib/parts/view-part.component.js +74 -10
  75. package/dist/lib/parts/view-part.component.js.map +1 -1
  76. package/dist/lib/parts/weburl-part.component.d.ts +14 -0
  77. package/dist/lib/parts/weburl-part.component.d.ts.map +1 -1
  78. package/dist/lib/parts/weburl-part.component.js +62 -5
  79. package/dist/lib/parts/weburl-part.component.js.map +1 -1
  80. package/dist/public-api.d.ts +8 -0
  81. package/dist/public-api.d.ts.map +1 -1
  82. package/dist/public-api.js +8 -0
  83. package/dist/public-api.js.map +1 -1
  84. package/package.json +15 -13
@@ -0,0 +1,180 @@
1
+ /**
2
+ * What each part type declares (plan § 4 and § 4.1): its inputs and its events.
3
+ *
4
+ * - View: its view's properties (`MJ: User Views.Properties`); `RecordSelected`, carrying the
5
+ * record's fields.
6
+ * - Query: its query's parameters (`MJ: Query Parameters`); `RowSelected`, carrying the row's columns.
7
+ * - Component: its component's declared props and events (`ComponentSpec.properties` / `.events`).
8
+ * - Web URL: the `{Name}` placeholders in its URL; no events.
9
+ * - Artifact (and any other type): nothing.
10
+ *
11
+ * The `...PartInterface` functions are pure; `LoadPartInterface` loads what they need through a provider.
12
+ */
13
+ import { RunView } from '@memberjunction/core';
14
+ import { EscapeSQLString, UUIDsEqual } from '@memberjunction/global';
15
+ import { QueryEngine, } from '@memberjunction/core-entities';
16
+ import { ComponentTypeToValueType, EMPTY_PART_INTERFACE, ParseUrlPlaceholders, RECORD_SELECTED_EVENT, ROW_SELECTED_EVENT, SqlTypeToValueType, } from './dashboard-properties';
17
+ /** A View part's interface: the view's properties, and `RecordSelected` with the entity's fields. */
18
+ export function ViewPartInterface(view, entity) {
19
+ const inputs = (view?.PropertiesObject ?? []).map(property => ({
20
+ Name: property.Name,
21
+ Type: property.Type,
22
+ Description: property.Description,
23
+ IsRequired: property.IsRequired === true,
24
+ HasOwnDefault: property.Default != null,
25
+ ServerSet: property.AllowOverride === false,
26
+ }));
27
+ const values = (entity?.Fields ?? [])
28
+ .filter(f => !f.IsBinaryFieldType)
29
+ .map(f => ({ Name: f.Name, Type: SqlTypeToValueType(f.Type) }));
30
+ return { Inputs: inputs, Events: entity ? [{ Name: RECORD_SELECTED_EVENT, Values: values }] : [] };
31
+ }
32
+ /** A Query part's interface: the query's parameters, and `RowSelected` with its columns. */
33
+ export function QueryPartInterface(parameters, fields) {
34
+ const inputs = parameters.map(p => ({
35
+ Name: p.Name,
36
+ Type: queryParameterType(p.Type),
37
+ Description: p.Description ?? undefined,
38
+ IsRequired: p.IsRequired === true,
39
+ HasOwnDefault: p.DefaultValue != null && p.DefaultValue !== '',
40
+ ServerSet: p.IsServerSet === true,
41
+ UserCanFill: true,
42
+ }));
43
+ const values = fields.map(f => ({ Name: f.Name, Type: SqlTypeToValueType(f.SQLBaseType) }));
44
+ return { Inputs: inputs, Events: [{ Name: ROW_SELECTED_EVENT, Values: values }] };
45
+ }
46
+ function queryParameterType(type) {
47
+ switch (type) {
48
+ case 'string':
49
+ case 'number':
50
+ case 'boolean':
51
+ case 'date':
52
+ return type;
53
+ default:
54
+ return 'unsupported';
55
+ }
56
+ }
57
+ /** A Component part's interface: the component's declared props and events. */
58
+ export function ComponentPartInterface(spec) {
59
+ const inputs = (spec?.properties ?? []).map(prop => ({
60
+ Name: prop.name,
61
+ Type: ComponentTypeToValueType(prop.type),
62
+ Description: prop.description,
63
+ IsRequired: prop.required === true,
64
+ HasOwnDefault: prop.defaultValue !== undefined,
65
+ ServerSet: false,
66
+ }));
67
+ const events = (spec?.events ?? []).map(event => ({
68
+ Name: event.name,
69
+ Values: (event.parameters ?? []).map(p => ({ Name: p.name, Type: ComponentTypeToValueType(p.type) })),
70
+ }));
71
+ return { Inputs: inputs, Events: events };
72
+ }
73
+ /** A Web URL part's interface: one required input per `{Name}` placeholder; any value, URL-encoded. */
74
+ export function WebUrlPartInterface(url) {
75
+ const inputs = ParseUrlPlaceholders(url).map(name => ({
76
+ Name: name, Type: 'any', IsRequired: true, HasOwnDefault: false, ServerSet: false,
77
+ }));
78
+ return { Inputs: inputs, Events: [] };
79
+ }
80
+ /** The part config keys a Component part keeps. */
81
+ export const COMPONENT_NAME_KEY = 'componentName';
82
+ export const COMPONENT_NAMESPACE_KEY = 'componentNamespace';
83
+ export const COMPONENT_VERSION_KEY = 'componentVersion';
84
+ /**
85
+ * Loads the registered component a Component part names (`MJ: Components` by name, and namespace and
86
+ * version when given; the highest version otherwise) and parses its specification.
87
+ * @throws when the part names no component, none matches, or its specification isn't valid JSON
88
+ */
89
+ export async function LoadComponentSpec(config, provider) {
90
+ const name = stringKey(config, COMPONENT_NAME_KEY);
91
+ if (!name)
92
+ throw new Error('No component is selected.');
93
+ const rv = RunView.FromMetadataProvider(provider);
94
+ const result = await rv.RunView({
95
+ EntityName: 'MJ: Components',
96
+ Fields: ['ID', 'Name', 'Specification'],
97
+ ExtraFilter: componentFilter(name, stringKey(config, COMPONENT_NAMESPACE_KEY), stringKey(config, COMPONENT_VERSION_KEY)),
98
+ OrderBy: 'VersionSequence DESC',
99
+ MaxRows: 1,
100
+ ResultType: 'simple',
101
+ }, provider.CurrentUser);
102
+ if (!result.Success)
103
+ throw new Error(result.ErrorMessage || `Component "${name}" could not be loaded.`);
104
+ const row = result.Results[0];
105
+ if (!row)
106
+ throw new Error(`Component "${name}" was not found.`);
107
+ try {
108
+ return JSON.parse(row.Specification);
109
+ }
110
+ catch {
111
+ throw new Error(`Component "${name}" has an invalid specification.`);
112
+ }
113
+ }
114
+ /** The filter for one component: its name (a Unicode literal on SQL Server), and namespace and version when given. */
115
+ function componentFilter(name, namespace, version) {
116
+ const others = [
117
+ namespace ? ` AND Namespace = '${EscapeSQLString(namespace)}'` : '',
118
+ version ? ` AND Version = '${EscapeSQLString(version)}'` : '',
119
+ ].join('');
120
+ const literal = EscapeSQLString(name);
121
+ return { default: `Name = '${literal}'${others}`, sqlserver: `Name = N'${literal}'${others}` };
122
+ }
123
+ function stringKey(config, key) {
124
+ const value = config[key];
125
+ return typeof value === 'string' && value.trim() ? value.trim() : null;
126
+ }
127
+ /** The QueryEngine for a provider, loaded on first use. */
128
+ async function queryEngineFor(provider) {
129
+ const engine = QueryEngine.GetProviderInstance(provider, QueryEngine);
130
+ await engine.Config(false, provider.CurrentUser, provider);
131
+ return engine;
132
+ }
133
+ /** The query a Query part names, by ID or by name. */
134
+ function findQuery(engine, config) {
135
+ const queryId = stringKey(config, 'queryId');
136
+ if (queryId)
137
+ return engine.Queries.find(q => UUIDsEqual(q.ID, queryId));
138
+ const queryName = stringKey(config, 'queryName');
139
+ return queryName ? engine.FindQueryByName(queryName) : undefined;
140
+ }
141
+ async function loadViewInterface(config, provider) {
142
+ const viewId = stringKey(config, 'viewId');
143
+ if (!viewId) {
144
+ const entityName = stringKey(config, 'entityName');
145
+ return ViewPartInterface(null, entityName ? provider.EntityByName(entityName) ?? null : null);
146
+ }
147
+ const view = await provider.GetEntityObject('MJ: User Views', provider.CurrentUser);
148
+ if (!(await view.Load(viewId)))
149
+ throw new Error('View not found');
150
+ return ViewPartInterface(view, view.ViewEntityInfo ?? null);
151
+ }
152
+ async function loadQueryInterface(config, provider) {
153
+ if (!stringKey(config, 'queryId') && !stringKey(config, 'queryName'))
154
+ return EMPTY_PART_INTERFACE;
155
+ const engine = await queryEngineFor(provider);
156
+ const query = findQuery(engine, config);
157
+ if (!query)
158
+ return EMPTY_PART_INTERFACE;
159
+ return QueryPartInterface(engine.GetQueryParameters(query.ID), engine.GetQueryFields(query.ID));
160
+ }
161
+ /**
162
+ * Loads what a part declares, from its config: through the provider for a View, Query or Component
163
+ * part; from the URL for a Web URL part; nothing for any other type.
164
+ * @throws when the part's view or component can't be loaded
165
+ */
166
+ export async function LoadPartInterface(config, provider) {
167
+ switch (config?.type) {
168
+ case 'View':
169
+ return loadViewInterface(config, provider);
170
+ case 'Query':
171
+ return loadQueryInterface(config, provider);
172
+ case 'Component':
173
+ return stringKey(config, COMPONENT_NAME_KEY) ? ComponentPartInterface(await LoadComponentSpec(config, provider)) : EMPTY_PART_INTERFACE;
174
+ case 'WebURL':
175
+ return WebUrlPartInterface(stringKey(config, 'url'));
176
+ default:
177
+ return EMPTY_PART_INTERFACE;
178
+ }
179
+ }
180
+ //# sourceMappingURL=dashboard-part-interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dashboard-part-interfaces.js","sourceRoot":"","sources":["../../../src/lib/models/dashboard-part-interfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAA8C,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAKH,WAAW,GACd,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EACH,wBAAwB,EAIxB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,GACrB,MAAM,wBAAwB,CAAC;AAEhC,qGAAqG;AACrG,MAAM,UAAU,iBAAiB,CAAC,IAA+D,EAAE,M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AAC,MAAsC,EAAE,QAA2B;IACvG,QAAQ,MAAM,EAAE,IAAI,EAAE,CAAC;QACnB,KAAK,MAAM;YACP,OAAO,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC/C,KAAK,OAAO;YACR,OAAO,kBAAkB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAChD,KAAK,WAAW;YACZ,OAAO,SAAS,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,sBAAsB,CAAC,MAAM,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC;QAC5I,KAAK,QAAQ;YACT,OAAO,mBAAmB,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;QACzD;YACI,OAAO,oBAAoB,CAAC;IACpC,CAAC;AACL,CAAC","sourcesContent":["/**\n * What each part type declares (plan § 4 and § 4.1): its inputs and its events.\n *\n * - View: its view's properties (`MJ: User Views.Properties`); `RecordSelected`, carrying the\n * record's fields.\n * - Query: its query's parameters (`MJ: Query Parameters`); `RowSelected`, carrying the row's columns.\n * - Component: its component's declared props and events (`ComponentSpec.properties` / `.events`).\n * - Web URL: the `{Name}` placeholders in its URL; no events.\n * - Artifact (and any other type): nothing.\n *\n * The `...PartInterface` functions are pure; `LoadPartInterface` loads what they need through a provider.\n */\nimport { EntityInfo, IMetadataProvider, PlatformSQL, RunView } from '@memberjunction/core';\nimport { EscapeSQLString, UUIDsEqual } from '@memberjunction/global';\nimport {\n MJQueryEntityExtended,\n MJQueryFieldEntity,\n MJQueryParameterEntity,\n MJUserViewEntityExtended,\n QueryEngine,\n} from '@memberjunction/core-entities';\nimport type { ComponentSpec } from '@memberjunction/interactive-component-types';\nimport type { PanelConfig } from './dashboard-types';\nimport {\n ComponentTypeToValueType,\n DashboardPartInput,\n DashboardPartInterface,\n DashboardValueType,\n EMPTY_PART_INTERFACE,\n ParseUrlPlaceholders,\n RECORD_SELECTED_EVENT,\n ROW_SELECTED_EVENT,\n SqlTypeToValueType,\n} from './dashboard-properties';\n\n/** A View part's interface: the view's properties, and `RecordSelected` with the entity's fields. */\nexport function ViewPartInterface(view: Pick<MJUserViewEntityExtended, 'PropertiesObject'> | null, entity: EntityInfo | null): DashboardPartInterface {\n const inputs: DashboardPartInput[] = (view?.PropertiesObject ?? []).map(property => ({\n Name: property.Name,\n Type: property.Type,\n Description: property.Description,\n IsRequired: property.IsRequired === true,\n HasOwnDefault: property.Default != null,\n ServerSet: property.AllowOverride === false,\n }));\n const values = (entity?.Fields ?? [])\n .filter(f => !f.IsBinaryFieldType)\n .map(f => ({ Name: f.Name, Type: SqlTypeToValueType(f.Type) }));\n return { Inputs: inputs, Events: entity ? [{ Name: RECORD_SELECTED_EVENT, Values: values }] : [] };\n}\n\n/** A Query part's interface: the query's parameters, and `RowSelected` with its columns. */\nexport function QueryPartInterface(\n parameters: readonly Pick<MJQueryParameterEntity, 'Name' | 'Type' | 'Description' | 'IsRequired' | 'DefaultValue' | 'IsServerSet'>[],\n fields: readonly Pick<MJQueryFieldEntity, 'Name' | 'SQLBaseType'>[],\n): DashboardPartInterface {\n const inputs: DashboardPartInput[] = parameters.map(p => ({\n Name: p.Name,\n Type: queryParameterType(p.Type),\n Description: p.Description ?? undefined,\n IsRequired: p.IsRequired === true,\n HasOwnDefault: p.DefaultValue != null && p.DefaultValue !== '',\n ServerSet: p.IsServerSet === true,\n UserCanFill: true,\n }));\n const values = fields.map(f => ({ Name: f.Name, Type: SqlTypeToValueType(f.SQLBaseType) }));\n return { Inputs: inputs, Events: [{ Name: ROW_SELECTED_EVENT, Values: values }] };\n}\n\nfunction queryParameterType(type: MJQueryParameterEntity['Type']): DashboardValueType {\n switch (type) {\n case 'string':\n case 'number':\n case 'boolean':\n case 'date':\n return type;\n default:\n return 'unsupported';\n }\n}\n\n/** A Component part's interface: the component's declared props and events. */\nexport function ComponentPartInterface(spec: Pick<ComponentSpec, 'properties' | 'events'> | null): DashboardPartInterface {\n const inputs: DashboardPartInput[] = (spec?.properties ?? []).map(prop => ({\n Name: prop.name,\n Type: ComponentTypeToValueType(prop.type),\n Description: prop.description,\n IsRequired: prop.required === true,\n HasOwnDefault: prop.defaultValue !== undefined,\n ServerSet: false,\n }));\n const events = (spec?.events ?? []).map(event => ({\n Name: event.name,\n Values: (event.parameters ?? []).map(p => ({ Name: p.name, Type: ComponentTypeToValueType(p.type) })),\n }));\n return { Inputs: inputs, Events: events };\n}\n\n/** A Web URL part's interface: one required input per `{Name}` placeholder; any value, URL-encoded. */\nexport function WebUrlPartInterface(url: string | null | undefined): DashboardPartInterface {\n const inputs = ParseUrlPlaceholders(url).map(name => ({\n Name: name, Type: 'any' as const, IsRequired: true, HasOwnDefault: false, ServerSet: false,\n }));\n return { Inputs: inputs, Events: [] };\n}\n\n/** The part config keys a Component part keeps. */\nexport const COMPONENT_NAME_KEY = 'componentName';\nexport const COMPONENT_NAMESPACE_KEY = 'componentNamespace';\nexport const COMPONENT_VERSION_KEY = 'componentVersion';\n\n/**\n * Loads the registered component a Component part names (`MJ: Components` by name, and namespace and\n * version when given; the highest version otherwise) and parses its specification.\n * @throws when the part names no component, none matches, or its specification isn't valid JSON\n */\nexport async function LoadComponentSpec(config: PanelConfig, provider: IMetadataProvider): Promise<ComponentSpec> {\n const name = stringKey(config, COMPONENT_NAME_KEY);\n if (!name) throw new Error('No component is selected.');\n const rv = RunView.FromMetadataProvider(provider);\n const result = await rv.RunView<{ Name: string; Specification: string }>({\n EntityName: 'MJ: Components',\n Fields: ['ID', 'Name', 'Specification'],\n ExtraFilter: componentFilter(name, stringKey(config, COMPONENT_NAMESPACE_KEY), stringKey(config, COMPONENT_VERSION_KEY)),\n OrderBy: 'VersionSequence DESC',\n MaxRows: 1,\n ResultType: 'simple',\n }, provider.CurrentUser);\n if (!result.Success) throw new Error(result.ErrorMessage || `Component \"${name}\" could not be loaded.`);\n const row = result.Results[0];\n if (!row) throw new Error(`Component \"${name}\" was not found.`);\n try {\n return JSON.parse(row.Specification) as ComponentSpec;\n } catch {\n throw new Error(`Component \"${name}\" has an invalid specification.`);\n }\n}\n\n/** The filter for one component: its name (a Unicode literal on SQL Server), and namespace and version when given. */\nfunction componentFilter(name: string, namespace: string | null, version: string | null): PlatformSQL {\n const others = [\n namespace ? ` AND Namespace = '${EscapeSQLString(namespace)}'` : '',\n version ? ` AND Version = '${EscapeSQLString(version)}'` : '',\n ].join('');\n const literal = EscapeSQLString(name);\n return { default: `Name = '${literal}'${others}`, sqlserver: `Name = N'${literal}'${others}` };\n}\n\nfunction stringKey(config: PanelConfig, key: string): string | null {\n const value = config[key];\n return typeof value === 'string' && value.trim() ? value.trim() : null;\n}\n\n/** The QueryEngine for a provider, loaded on first use. */\nasync function queryEngineFor(provider: IMetadataProvider): Promise<QueryEngine> {\n const engine = QueryEngine.GetProviderInstance<QueryEngine>(provider, QueryEngine) as QueryEngine;\n await engine.Config(false, provider.CurrentUser, provider);\n return engine;\n}\n\n/** The query a Query part names, by ID or by name. */\nfunction findQuery(engine: QueryEngine, config: PanelConfig): MJQueryEntityExtended | undefined {\n const queryId = stringKey(config, 'queryId');\n if (queryId) return engine.Queries.find(q => UUIDsEqual(q.ID, queryId));\n const queryName = stringKey(config, 'queryName');\n return queryName ? engine.FindQueryByName(queryName) : undefined;\n}\n\nasync function loadViewInterface(config: PanelConfig, provider: IMetadataProvider): Promise<DashboardPartInterface> {\n const viewId = stringKey(config, 'viewId');\n if (!viewId) {\n const entityName = stringKey(config, 'entityName');\n return ViewPartInterface(null, entityName ? provider.EntityByName(entityName) ?? null : null);\n }\n const view = await provider.GetEntityObject<MJUserViewEntityExtended>('MJ: User Views', provider.CurrentUser);\n if (!(await view.Load(viewId))) throw new Error('View not found');\n return ViewPartInterface(view, view.ViewEntityInfo ?? null);\n}\n\nasync function loadQueryInterface(config: PanelConfig, provider: IMetadataProvider): Promise<DashboardPartInterface> {\n if (!stringKey(config, 'queryId') && !stringKey(config, 'queryName')) return EMPTY_PART_INTERFACE;\n const engine = await queryEngineFor(provider);\n const query = findQuery(engine, config);\n if (!query) return EMPTY_PART_INTERFACE;\n return QueryPartInterface(engine.GetQueryParameters(query.ID), engine.GetQueryFields(query.ID));\n}\n\n/**\n * Loads what a part declares, from its config: through the provider for a View, Query or Component\n * part; from the URL for a Web URL part; nothing for any other type.\n * @throws when the part's view or component can't be loaded\n */\nexport async function LoadPartInterface(config: PanelConfig | null | undefined, provider: IMetadataProvider): Promise<DashboardPartInterface> {\n switch (config?.type) {\n case 'View':\n return loadViewInterface(config, provider);\n case 'Query':\n return loadQueryInterface(config, provider);\n case 'Component':\n return stringKey(config, COMPONENT_NAME_KEY) ? ComponentPartInterface(await LoadComponentSpec(config, provider)) : EMPTY_PART_INTERFACE;\n case 'WebURL':\n return WebUrlPartInterface(stringKey(config, 'url'));\n default:\n return EMPTY_PART_INTERFACE;\n }\n}\n"]}
@@ -0,0 +1,182 @@
1
+ /**
2
+ * Dashboard properties, part input mappings, events and wires (plan § 4 and § 4.1).
3
+ *
4
+ * A dashboard declares properties; a host sets their values once; each part maps them onto its own
5
+ * inputs under its own names. A wire sets a dashboard property from a part's event (a selection),
6
+ * never a part's input. All of it is optional and lives in the dashboard's saved config: a dashboard
7
+ * with no properties, mappings or wires renders and saves exactly as before.
8
+ *
9
+ * Everything here is plain TypeScript, so it is tested without Angular.
10
+ */
11
+ import { PropertyDefault, PropertyResolutionContext, PropertyValue, PropertyValueType } from '@memberjunction/core';
12
+ /** A dashboard property: a view property's shape without Target and AllowOverride. */
13
+ export interface DashboardProperty {
14
+ /** Unique within the dashboard. */
15
+ Name: string;
16
+ Type: PropertyValueType;
17
+ Description?: string;
18
+ /** Used when neither the host nor a wired event gives a value: a fixed value or a context token. */
19
+ Default?: PropertyDefault;
20
+ /** True: a part input it feeds has no value until something sets it. Shown in the designer. */
21
+ IsRequired?: boolean;
22
+ }
23
+ /** One of a part's inputs, fed by a dashboard property, fixed by a default, or both. */
24
+ export interface DashboardPartInputMapping {
25
+ /** The part's own input: a view property, a query parameter, a component prop or a URL placeholder. */
26
+ Input: string;
27
+ /** The dashboard property that feeds it. Omitted: the input takes Default alone. */
28
+ Property?: string;
29
+ /** Used when the dashboard property has no value, and always when Property is omitted. */
30
+ Default?: PropertyDefault;
31
+ }
32
+ /** Sets a dashboard property from one value of a part's event. */
33
+ export interface DashboardWire {
34
+ /** The panel (part) that raises the event. */
35
+ Panel: string;
36
+ /** One of the events that part declares. */
37
+ Event: string;
38
+ /** Which of the event's values: a record's field, a row's column or an event's parameter. */
39
+ Value: string;
40
+ /** The dashboard property it sets. */
41
+ Property: string;
42
+ }
43
+ /**
44
+ * The type of a part's input or event value. `any` takes every property type (a URL placeholder, a
45
+ * component prop typed `any`); `unsupported` takes none (an array parameter, an object prop).
46
+ */
47
+ export type DashboardValueType = PropertyValueType | 'any' | 'unsupported';
48
+ /** One input a part declares. */
49
+ export interface DashboardPartInput {
50
+ Name: string;
51
+ Type: DashboardValueType;
52
+ Description?: string;
53
+ /** The part can't run without a value for it. */
54
+ IsRequired: boolean;
55
+ /** The input has a default of its own (a view property's or query parameter's default, a prop's defaultValue). */
56
+ HasOwnDefault: boolean;
57
+ /** Only server code sets it (a view property with AllowOverride false, a server-set query parameter): never mapped. */
58
+ ServerSet: boolean;
59
+ /** The user fills it on the part when it is not mapped (a query parameter in the parameter form). */
60
+ UserCanFill?: boolean;
61
+ }
62
+ /** One value an event carries. */
63
+ export interface DashboardEventValue {
64
+ Name: string;
65
+ Type: DashboardValueType;
66
+ }
67
+ /** One event a part declares. */
68
+ export interface DashboardPartEventInfo {
69
+ Name: string;
70
+ Values: DashboardEventValue[];
71
+ }
72
+ /** What a part declares: its inputs and its events. */
73
+ export interface DashboardPartInterface {
74
+ Inputs: DashboardPartInput[];
75
+ Events: DashboardPartEventInfo[];
76
+ }
77
+ /** A part that declares nothing (an Artifact part, or a part whose source isn't chosen yet). */
78
+ export declare const EMPTY_PART_INTERFACE: DashboardPartInterface;
79
+ /** The values of a dashboard's properties as one part sees them. */
80
+ export type DashboardPropertyValues = Record<string, PropertyValue>;
81
+ /** What the viewer hands a part: the dashboard's properties and their values for that part. */
82
+ export interface DashboardPartContext {
83
+ Properties: DashboardProperty[];
84
+ Values: DashboardPropertyValues;
85
+ }
86
+ /** An event a part raised (informational, so no Before/After pair). Values null: the selection was cleared. */
87
+ export declare class DashboardPartEventArgs {
88
+ /** The event's name, one the part declares. */
89
+ Event: string;
90
+ /** The event's values by name (a record's fields, a row's columns, an event's parameters), or null. */
91
+ Values: Record<string, unknown> | null;
92
+ constructor(
93
+ /** The event's name, one the part declares. */
94
+ Event: string,
95
+ /** The event's values by name (a record's fields, a row's columns, an event's parameters), or null. */
96
+ Values: Record<string, unknown> | null);
97
+ }
98
+ /** A part's inputs worked out from the dashboard. */
99
+ export interface PartInputResolution {
100
+ /** A value for each mapped input that has one. An input without a key takes its own default. */
101
+ Values: Record<string, PropertyValue>;
102
+ /** Required inputs with no value: the part stops and names them. */
103
+ Missing: string[];
104
+ /** Mappings that no longer fit the part or the dashboard: the part stops and shows them. */
105
+ Broken: string[];
106
+ }
107
+ /** The part config key that holds a part's input mappings. */
108
+ export declare const INPUT_MAPPINGS_KEY = "inputMappings";
109
+ /** The View part's selection event and the Query part's. */
110
+ export declare const RECORD_SELECTED_EVENT = "RecordSelected";
111
+ export declare const ROW_SELECTED_EVENT = "RowSelected";
112
+ /**
113
+ * True when a value of type `source` can fill an input or property of type `target`: the same type,
114
+ * either side `any`, or a uuid or date into a string.
115
+ */
116
+ export declare function IsTypeCompatible(source: DashboardValueType, target: DashboardValueType): boolean;
117
+ /** A SQL type name (an entity field's or a query column's) as a dashboard value type. */
118
+ export declare function SqlTypeToValueType(sqlType: string | null | undefined): DashboardValueType;
119
+ /** A component prop's or event parameter's declared type as a dashboard value type. */
120
+ export declare function ComponentTypeToValueType(type: string | null | undefined): DashboardValueType;
121
+ /** The distinct `{Name}` placeholders in a URL, in order. */
122
+ export declare function ParseUrlPlaceholders(url: string | null | undefined): string[];
123
+ /** The URL with each placeholder that has a value replaced by the URL-encoded value. Others stay. */
124
+ export declare function FillUrlPlaceholders(url: string, values: Record<string, PropertyValue>): string;
125
+ /** The input mappings in a part's config; empty when it has none. */
126
+ export declare function GetInputMappings(config: Record<string, unknown> | null | undefined): DashboardPartInputMapping[];
127
+ /**
128
+ * A value from an event (a record field, a row column, an event parameter) as a property value: a
129
+ * Date becomes an ISO string, a primitive stays, anything else (an object, a list) is no value.
130
+ */
131
+ export declare function NormalizeEventValue(value: unknown): PropertyValue;
132
+ /**
133
+ * Works out the dashboard's property values. For each property, the first of: the value the host
134
+ * set; the value the latest wired event set; the property's default (a token worked out with the
135
+ * context's user, clock and zone). A host value of null or undefined counts as not set.
136
+ *
137
+ * No loops: the values a panel sees leave out the values its own events set, so a part is never
138
+ * refreshed by its own selection.
139
+ */
140
+ export declare class DashboardPropertyResolver {
141
+ private properties;
142
+ private readonly ctx;
143
+ private hostValues;
144
+ private readonly eventValues;
145
+ constructor(properties: DashboardProperty[], ctx: () => PropertyResolutionContext);
146
+ /** The dashboard's properties. */
147
+ get Properties(): DashboardProperty[];
148
+ /** Takes a new list of properties; event values for properties that no longer exist are dropped. */
149
+ SetProperties(properties: DashboardProperty[]): void;
150
+ /** Takes the host's values (the viewer's Properties input). */
151
+ SetHostValues(values: Record<string, unknown> | null | undefined): void;
152
+ /** Records that a panel's event set a property. A null value clears it, as a cleared selection does. */
153
+ SetEventValue(property: string, value: PropertyValue, panel: string): void;
154
+ /** Removes every event value, as when the parts are rebuilt and their selections are gone. */
155
+ ClearEventValues(): void;
156
+ /** Removes the event value of a property, when that panel set it. */
157
+ ClearEventValue(property: string, panel: string): void;
158
+ /** Every property's value as the panel sees it (without the values its own events set). */
159
+ ValuesFor(panel: string | null): DashboardPropertyValues;
160
+ private valueOf;
161
+ }
162
+ /**
163
+ * Why a mapping doesn't fit, or null when it does: an input the part doesn't declare, an input only
164
+ * the server may set, a property the dashboard doesn't have, or types that don't match.
165
+ */
166
+ export declare function MappingProblem(mapping: DashboardPartInputMapping, inputs: DashboardPartInput[], properties: DashboardProperty[]): string | null;
167
+ /**
168
+ * Works out a part's inputs from its mappings, in the plan's order: the dashboard property's value
169
+ * (host, then event, then the property's default, already in `values`), then the mapping's default,
170
+ * then the input's own default (no key: the part applies it).
171
+ *
172
+ * A required input with none of these is missing. An unmapped input the user fills on the part (a
173
+ * query parameter) is left to the user; one only the server sets is never missing here.
174
+ */
175
+ export declare function ResolvePartInputs(inputs: DashboardPartInput[], mappings: DashboardPartInputMapping[], properties: DashboardProperty[], values: DashboardPropertyValues, ctx: PropertyResolutionContext): PartInputResolution;
176
+ /** A stable key for a resolution, so a part reloads only when what it runs with changed. */
177
+ export declare function PartInputResolutionKey(resolution: PartInputResolution | null): string;
178
+ /** The message a part shows when it stops: its broken mappings, then its missing inputs. */
179
+ export declare function PartInputProblemMessage(resolution: PartInputResolution | null): string | null;
180
+ /** True when a value fits a dashboard value type (`any` takes every value; null fits all). */
181
+ export declare function IsValueOfDashboardType(value: PropertyValue, type: DashboardValueType): boolean;
182
+ //# sourceMappingURL=dashboard-properties.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dashboard-properties.d.ts","sourceRoot":"","sources":["../../../src/lib/models/dashboard-properties.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAEH,eAAe,EACf,yBAAyB,EACzB,aAAa,EACb,iBAAiB,EAEpB,MAAM,sBAAsB,CAAC;AAE9B,sFAAsF;AACtF,MAAM,WAAW,iBAAiB;IAC9B,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,iBAAiB,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oGAAoG;IACpG,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,+FAA+F;IAC/F,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,wFAAwF;AACxF,MAAM,WAAW,yBAAyB;IACtC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