@memberjunction/excel-addin-server 0.0.0 → 6.2.0-edge.7

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 (43) hide show
  1. package/LICENSE +183 -0
  2. package/README.md +88 -28
  3. package/dist/catalog.d.ts +29 -0
  4. package/dist/catalog.d.ts.map +1 -0
  5. package/dist/catalog.js +242 -0
  6. package/dist/catalog.js.map +1 -0
  7. package/dist/connection.d.ts +31 -0
  8. package/dist/connection.d.ts.map +1 -0
  9. package/dist/connection.js +111 -0
  10. package/dist/connection.js.map +1 -0
  11. package/dist/extension.d.ts +46 -0
  12. package/dist/extension.d.ts.map +1 -0
  13. package/dist/extension.js +177 -0
  14. package/dist/extension.js.map +1 -0
  15. package/dist/index.d.ts +20 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +20 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/manifest-builder.d.ts +18 -0
  20. package/dist/manifest-builder.d.ts.map +1 -0
  21. package/dist/manifest-builder.js +126 -0
  22. package/dist/manifest-builder.js.map +1 -0
  23. package/dist/operations.d.ts +45 -0
  24. package/dist/operations.d.ts.map +1 -0
  25. package/dist/operations.js +160 -0
  26. package/dist/operations.js.map +1 -0
  27. package/dist/runtime.d.ts +53 -0
  28. package/dist/runtime.d.ts.map +1 -0
  29. package/dist/runtime.js +88 -0
  30. package/dist/runtime.js.map +1 -0
  31. package/dist/settings.d.ts +48 -0
  32. package/dist/settings.d.ts.map +1 -0
  33. package/dist/settings.js +115 -0
  34. package/dist/settings.js.map +1 -0
  35. package/dist/sources.d.ts +31 -0
  36. package/dist/sources.d.ts.map +1 -0
  37. package/dist/sources.js +230 -0
  38. package/dist/sources.js.map +1 -0
  39. package/dist/workbook-builder.d.ts +21 -0
  40. package/dist/workbook-builder.d.ts.map +1 -0
  41. package/dist/workbook-builder.js +122 -0
  42. package/dist/workbook-builder.js.map +1 -0
  43. package/package.json +39 -8
@@ -0,0 +1,160 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ /**
8
+ * @fileoverview Server bodies of the `ExcelAddin.*` Remote Operations.
9
+ *
10
+ * Each subclass extends the typed base from `@memberjunction/excel-addin` and registers under the
11
+ * same key, so a browser's `new ExcelAddinBuildWorkbookOperation().Execute(...)` or the Excel
12
+ * pane's `ExecuteRemoteOperation` GraphQL mutation lands here. All operations read
13
+ * {@link ExcelAddinRuntime}: on a host whose Server Extension isn't configured, status says the
14
+ * add-in is off and the other operations refuse.
15
+ *
16
+ * @module @memberjunction/excel-addin-server
17
+ */
18
+ import { BaseRemotableOperation } from '@memberjunction/core';
19
+ import { RegisterClass } from '@memberjunction/global';
20
+ import { EXCEL_WORKBOOK_CONTRACT_VERSION, ExcelAddinBuildWorkbookOperation, ExcelAddinCreateConnectionOperation, ExcelAddinGetCatalogOperation, ExcelAddinGetEntityViewsOperation, ExcelAddinGetStatusOperation, ExcelAddinResolveSourceOperation, } from '@memberjunction/excel-addin';
21
+ import { BuildExcelCatalog, LoadExcelEntityViews } from './catalog.js';
22
+ import { CreateExcelConnectionKey } from './connection.js';
23
+ import { ExcelAddinRuntime } from './runtime.js';
24
+ import { ResolveSingleWorkbookSource, ResolveWorkbookSources } from './sources.js';
25
+ import { BuildConnectedWorkbook } from './workbook-builder.js';
26
+ const MAX_FILE_NAME_LENGTH = 100;
27
+ /** Reports whether this host serves the Excel add-in. */
28
+ let ExcelAddinGetStatusServerOperation = class ExcelAddinGetStatusServerOperation extends ExcelAddinGetStatusOperation {
29
+ async InternalExecute(_input, _provider, _user) {
30
+ const runtime = ExcelAddinRuntime.Instance;
31
+ const settings = runtime.Settings;
32
+ if (!runtime.IsEnabled || !settings) {
33
+ return { Enabled: false, ServerName: '', ConnectedPageUrl: '', ManifestUrl: '', KeyLifetimeDays: 0 };
34
+ }
35
+ return {
36
+ Enabled: true,
37
+ ServerName: settings.ServerName,
38
+ ConnectedPageUrl: runtime.ConnectedPageUrl,
39
+ ManifestUrl: runtime.ManifestUrl,
40
+ KeyLifetimeDays: settings.KeyLifetimeDays,
41
+ };
42
+ }
43
+ };
44
+ ExcelAddinGetStatusServerOperation = __decorate([
45
+ RegisterClass(BaseRemotableOperation, 'ExcelAddin.GetStatus')
46
+ ], ExcelAddinGetStatusServerOperation);
47
+ export { ExcelAddinGetStatusServerOperation };
48
+ /** Mints the caller's Excel connection key. */
49
+ let ExcelAddinCreateConnectionServerOperation = class ExcelAddinCreateConnectionServerOperation extends ExcelAddinCreateConnectionOperation {
50
+ async Authorize(_input, _user) {
51
+ return ExcelAddinRuntime.Instance.IsEnabled;
52
+ }
53
+ async InternalExecute(_input, provider, user) {
54
+ const settings = ExcelAddinRuntime.Instance.RequireSettings();
55
+ const key = await CreateExcelConnectionKey(user, provider, settings.KeyLifetimeDays);
56
+ return { APIKey: key.APIKey, APIKeyID: key.APIKeyID, ExpiresAt: key.ExpiresAt.toISOString(), Label: key.Label };
57
+ }
58
+ };
59
+ ExcelAddinCreateConnectionServerOperation = __decorate([
60
+ RegisterClass(BaseRemotableOperation, 'ExcelAddin.CreateConnection')
61
+ ], ExcelAddinCreateConnectionServerOperation);
62
+ export { ExcelAddinCreateConnectionServerOperation };
63
+ /** Builds a connected workbook (headings, no rows) for saved views, entities, and queries the caller can see. */
64
+ let ExcelAddinBuildWorkbookServerOperation = class ExcelAddinBuildWorkbookServerOperation extends ExcelAddinBuildWorkbookOperation {
65
+ async Authorize(_input, _user) {
66
+ return ExcelAddinRuntime.Instance.IsEnabled;
67
+ }
68
+ async InternalExecute(input, provider, user) {
69
+ const runtime = ExcelAddinRuntime.Instance;
70
+ const settings = runtime.RequireSettings();
71
+ const sources = await ResolveWorkbookSources(input?.Sources ?? [], provider, user);
72
+ const manifest = {
73
+ ContractVersion: EXCEL_WORKBOOK_CONTRACT_VERSION,
74
+ ServerName: settings.ServerName,
75
+ AddinUrl: runtime.AddinUrl,
76
+ GeneratedAt: new Date().toISOString(),
77
+ Sources: sources,
78
+ };
79
+ const workbook = await BuildConnectedWorkbook(manifest, {
80
+ AddinId: settings.AddinId,
81
+ Version: settings.Version,
82
+ Store: settings.Store,
83
+ StoreType: settings.StoreType,
84
+ });
85
+ return { FileName: MakeWorkbookFileName(sources), ContentBase64: workbook.toString('base64') };
86
+ }
87
+ };
88
+ ExcelAddinBuildWorkbookServerOperation = __decorate([
89
+ RegisterClass(BaseRemotableOperation, 'ExcelAddin.BuildWorkbook')
90
+ ], ExcelAddinBuildWorkbookServerOperation);
91
+ export { ExcelAddinBuildWorkbookServerOperation };
92
+ /** Lists the applications, readable entities, query categories, and runnable queries for the Excel picker. */
93
+ let ExcelAddinGetCatalogServerOperation = class ExcelAddinGetCatalogServerOperation extends ExcelAddinGetCatalogOperation {
94
+ async Authorize(_input, _user) {
95
+ return ExcelAddinRuntime.Instance.IsEnabled;
96
+ }
97
+ async InternalExecute(_input, provider, user) {
98
+ ExcelAddinRuntime.Instance.RequireSettings();
99
+ return BuildExcelCatalog(provider, user);
100
+ }
101
+ };
102
+ ExcelAddinGetCatalogServerOperation = __decorate([
103
+ RegisterClass(BaseRemotableOperation, 'ExcelAddin.GetCatalog')
104
+ ], ExcelAddinGetCatalogServerOperation);
105
+ export { ExcelAddinGetCatalogServerOperation };
106
+ /** Lists the accessible saved `MJ: User Views` records on a chosen entity for the Excel picker. */
107
+ let ExcelAddinGetEntityViewsServerOperation = class ExcelAddinGetEntityViewsServerOperation extends ExcelAddinGetEntityViewsOperation {
108
+ async Authorize(_input, _user) {
109
+ return ExcelAddinRuntime.Instance.IsEnabled;
110
+ }
111
+ async InternalExecute(input, provider, user) {
112
+ ExcelAddinRuntime.Instance.RequireSettings();
113
+ return LoadExcelEntityViews(input?.EntityID ?? '', provider, user);
114
+ }
115
+ };
116
+ ExcelAddinGetEntityViewsServerOperation = __decorate([
117
+ RegisterClass(BaseRemotableOperation, 'ExcelAddin.GetEntityViews')
118
+ ], ExcelAddinGetEntityViewsServerOperation);
119
+ export { ExcelAddinGetEntityViewsServerOperation };
120
+ /** Resolves a single chosen view, entity, or saved query into its canonical columns and checked parameters. */
121
+ let ExcelAddinResolveSourceServerOperation = class ExcelAddinResolveSourceServerOperation extends ExcelAddinResolveSourceOperation {
122
+ async Authorize(_input, _user) {
123
+ return ExcelAddinRuntime.Instance.IsEnabled;
124
+ }
125
+ async InternalExecute(input, provider, user) {
126
+ ExcelAddinRuntime.Instance.RequireSettings();
127
+ const source = await ResolveSingleWorkbookSource(input?.Source, provider, user);
128
+ return { Source: source };
129
+ }
130
+ };
131
+ ExcelAddinResolveSourceServerOperation = __decorate([
132
+ RegisterClass(BaseRemotableOperation, 'ExcelAddin.ResolveSource')
133
+ ], ExcelAddinResolveSourceServerOperation);
134
+ export { ExcelAddinResolveSourceServerOperation };
135
+ /** A file name safe on every desktop platform, from the first source's name. */
136
+ export function MakeWorkbookFileName(sources) {
137
+ const first = sources[0]?.Name ?? '';
138
+ // Drop characters Windows, macOS or a browser download refuse, and control characters.
139
+ const collapsed = Array.from(first)
140
+ .filter(ch => ch.charCodeAt(0) >= 32 && !'\\/:*?"<>|'.includes(ch))
141
+ .join('')
142
+ .replace(/\s+/g, ' ');
143
+ const cleaned = trimDotsAndWhitespace(collapsed)
144
+ .slice(0, MAX_FILE_NAME_LENGTH)
145
+ .trim();
146
+ const base = cleaned || 'MemberJunction';
147
+ return sources.length > 1 ? `${base} and ${sources.length - 1} more.xlsx` : `${base}.xlsx`;
148
+ }
149
+ function trimDotsAndWhitespace(value) {
150
+ let start = 0;
151
+ let end = value.length;
152
+ while (start < end && (value[start] === '.' || value[start].trim() === '')) {
153
+ start++;
154
+ }
155
+ while (end > start && (value[end - 1] === '.' || value[end - 1].trim() === '')) {
156
+ end--;
157
+ }
158
+ return value.slice(start, end);
159
+ }
160
+ //# sourceMappingURL=operations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations.js","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,sBAAsB,EAA+B,MAAM,sBAAsB,CAAC;AAC3F,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EACH,+BAA+B,EAE/B,gCAAgC,EAKhC,mCAAmC,EAInC,6BAA6B,EAC7B,iCAAiC,EACjC,4BAA4B,EAE5B,gCAAgC,GAMnC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAEjC,yDAAyD;AAElD,IAAM,kCAAkC,GAAxC,MAAM,kCAAmC,SAAQ,4BAA4B;IACtE,KAAK,CAAC,eAAe,CAAC,MAA6B,EAAE,SAA4B,EAAE,KAAe;QACxG,MAAM,OAAO,GAAG,iBAAiB,CAAC,QAAQ,CAAC;QAC3C,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QAClC,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,gBAAgB,E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AG,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QAC7E,GAAG,EAAE,CAAC;IACV,CAAC;IACD,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACnC,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @fileoverview The Excel add-in's process-wide state: whether this host serves it, with which
3
+ * settings, and at which public URL.
4
+ *
5
+ * The Server Extension configures it when it mounts; the Remote Operations read it. An operation
6
+ * running on a host that never configured the extension sees `IsEnabled === false` and reports the
7
+ * add-in as off, which is how a host with the package installed but not configured behaves.
8
+ *
9
+ * @module @memberjunction/excel-addin-server
10
+ */
11
+ import { BaseSingleton } from '@memberjunction/global';
12
+ import type { ExcelAddinSettings } from './settings.js';
13
+ /** The Explorer route that runs the add-in's sign-in. */
14
+ export declare const EXCEL_CONNECT_ROUTE = "/office/connect";
15
+ /** The add-in's pages and files, relative to its base URL. */
16
+ export declare const EXCEL_ADDIN_PATHS: {
17
+ readonly Manifest: "/manifest.xml";
18
+ readonly Config: "/config.json";
19
+ readonly Taskpane: "/taskpane.html";
20
+ readonly ConnectStart: "/connect.html";
21
+ readonly Connected: "/connected.html";
22
+ readonly Assets: "/assets";
23
+ };
24
+ /** Holds the add-in's settings and public URL once the Server Extension has mounted. */
25
+ export declare class ExcelAddinRuntime extends BaseSingleton<ExcelAddinRuntime> {
26
+ private settings;
27
+ private addinUrl;
28
+ constructor();
29
+ static get Instance(): ExcelAddinRuntime;
30
+ /** Turns the add-in on with these settings, served at `addinUrl`. */
31
+ Configure(settings: ExcelAddinSettings, addinUrl: string): void;
32
+ /** Turns the add-in off. */
33
+ Reset(): void;
34
+ /** True once the Server Extension has mounted. */
35
+ get IsEnabled(): boolean;
36
+ /** The settings, or null when the add-in is off. */
37
+ get Settings(): ExcelAddinSettings | null;
38
+ /** The add-in's public base URL, or `''` when off. */
39
+ get AddinUrl(): string;
40
+ get ManifestUrl(): string;
41
+ get ConfigUrl(): string;
42
+ get TaskpaneUrl(): string;
43
+ /** The add-in page the sign-in window opens first. */
44
+ get ConnectStartUrl(): string;
45
+ /** The add-in page Explorer's connect page returns to. */
46
+ get ConnectedPageUrl(): string;
47
+ /** Explorer's connect page, or `''` when off. */
48
+ get ExplorerConnectUrl(): string;
49
+ /** The settings; throws when the add-in is off. */
50
+ RequireSettings(): ExcelAddinSettings;
51
+ private urlFor;
52
+ }
53
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,aAAa,EAAuB,MAAM,wBAAwB,CAAC;AAC5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,yDAAyD;AACzD,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AAErD,8DAA8D;AAC9D,eAAO,MAAM,iBAAiB;;;;;;;CAOpB,CAAC;AAEX,wFAAwF;AACxF,qBAAa,iBAAkB,SAAQ,aAAa,CAAC,iBAAiB,CAAC;IACnE,OAAO,CAAC,QAAQ,CAAmC;IACnD,OAAO,CAAC,QAAQ,CAAM;;IAOtB,WAAkB,QAAQ,IAAI,iBAAiB,CAE9C;IAED,qEAAqE;IAC9D,SAAS,CAAC,QAAQ,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAKtE,4BAA4B;IACrB,KAAK,IAAI,IAAI;IAKpB,kDAAkD;IAClD,IAAW,SAAS,IAAI,OAAO,CAE9B;IAED,oDAAoD;IACpD,IAAW,QAAQ,IAAI,kBAAkB,GAAG,IAAI,CAE/C;IAED,sDAAsD;IACtD,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED,IAAW,WAAW,IAAI,MAAM,CAE/B;IAED,IAAW,SAAS,IAAI,MAAM,CAE7B;IAED,IAAW,WAAW,IAAI,MAAM,CAE/B;IAED,sDAAsD;IACtD,IAAW,eAAe,IAAI,MAAM,CAEnC;IAED,0DAA0D;IAC1D,IAAW,gBAAgB,IAAI,MAAM,CAEpC;IAED,iDAAiD;IACjD,IAAW,kBAAkB,IAAI,MAAM,CAEtC;IAED,mDAAmD;IAC5C,eAAe,IAAI,kBAAkB;IAO5C,OAAO,CAAC,MAAM;CAGjB"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * @fileoverview The Excel add-in's process-wide state: whether this host serves it, with which
3
+ * settings, and at which public URL.
4
+ *
5
+ * The Server Extension configures it when it mounts; the Remote Operations read it. An operation
6
+ * running on a host that never configured the extension sees `IsEnabled === false` and reports the
7
+ * add-in as off, which is how a host with the package installed but not configured behaves.
8
+ *
9
+ * @module @memberjunction/excel-addin-server
10
+ */
11
+ import { BaseSingleton, TrimTrailingSlashes } from '@memberjunction/global';
12
+ /** The Explorer route that runs the add-in's sign-in. */
13
+ export const EXCEL_CONNECT_ROUTE = '/office/connect';
14
+ /** The add-in's pages and files, relative to its base URL. */
15
+ export const EXCEL_ADDIN_PATHS = {
16
+ Manifest: '/manifest.xml',
17
+ Config: '/config.json',
18
+ Taskpane: '/taskpane.html',
19
+ ConnectStart: '/connect.html',
20
+ Connected: '/connected.html',
21
+ Assets: '/assets',
22
+ };
23
+ /** Holds the add-in's settings and public URL once the Server Extension has mounted. */
24
+ export class ExcelAddinRuntime extends BaseSingleton {
25
+ // Public: BaseSingleton.getInstance is typed `this: new () => T`, which a protected constructor can't satisfy.
26
+ constructor() {
27
+ super();
28
+ this.settings = null;
29
+ this.addinUrl = '';
30
+ }
31
+ static get Instance() {
32
+ return ExcelAddinRuntime.getInstance();
33
+ }
34
+ /** Turns the add-in on with these settings, served at `addinUrl`. */
35
+ Configure(settings, addinUrl) {
36
+ this.settings = settings;
37
+ this.addinUrl = TrimTrailingSlashes(addinUrl);
38
+ }
39
+ /** Turns the add-in off. */
40
+ Reset() {
41
+ this.settings = null;
42
+ this.addinUrl = '';
43
+ }
44
+ /** True once the Server Extension has mounted. */
45
+ get IsEnabled() {
46
+ return this.settings !== null && this.addinUrl !== '';
47
+ }
48
+ /** The settings, or null when the add-in is off. */
49
+ get Settings() {
50
+ return this.settings;
51
+ }
52
+ /** The add-in's public base URL, or `''` when off. */
53
+ get AddinUrl() {
54
+ return this.addinUrl;
55
+ }
56
+ get ManifestUrl() {
57
+ return this.urlFor(EXCEL_ADDIN_PATHS.Manifest);
58
+ }
59
+ get ConfigUrl() {
60
+ return this.urlFor(EXCEL_ADDIN_PATHS.Config);
61
+ }
62
+ get TaskpaneUrl() {
63
+ return this.urlFor(EXCEL_ADDIN_PATHS.Taskpane);
64
+ }
65
+ /** The add-in page the sign-in window opens first. */
66
+ get ConnectStartUrl() {
67
+ return this.urlFor(EXCEL_ADDIN_PATHS.ConnectStart);
68
+ }
69
+ /** The add-in page Explorer's connect page returns to. */
70
+ get ConnectedPageUrl() {
71
+ return this.urlFor(EXCEL_ADDIN_PATHS.Connected);
72
+ }
73
+ /** Explorer's connect page, or `''` when off. */
74
+ get ExplorerConnectUrl() {
75
+ return this.settings ? `${TrimTrailingSlashes(this.settings.ExplorerUrl)}${EXCEL_CONNECT_ROUTE}` : '';
76
+ }
77
+ /** The settings; throws when the add-in is off. */
78
+ RequireSettings() {
79
+ if (!this.settings || !this.IsEnabled) {
80
+ throw new Error('The Excel add-in is not enabled on this server.');
81
+ }
82
+ return this.settings;
83
+ }
84
+ urlFor(path) {
85
+ return this.IsEnabled ? `${this.addinUrl}${path}` : '';
86
+ }
87
+ }
88
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG5E,yDAAyD;AACzD,MAAM,CAAC,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AAO,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IAED,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACnD,CAAC;IAED,sDAAsD;IACtD,IAAW,eAAe;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;IACvD,CAAC;IAED,0DAA0D;IAC1D,IAAW,gBAAgB;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;IAED,iDAAiD;IACjD,IAAW,kBAAkB;QACzB,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,mBAAmB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1G,CAAC;IAED,mDAAmD;IAC5C,eAAe;QAClB,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACvE,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAEO,MAAM,CAAC,IAAY;QACvB,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3D,CAAC;CACJ"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The add-in's identity in Office. Every MJ host serves the same add-in, so the default is one fixed
3
+ * GUID; a host that deploys a second, differently configured copy to the same Microsoft 365 tenant
4
+ * sets its own `AddinId`.
5
+ */
6
+ export declare const DEFAULT_EXCEL_ADDIN_ID = "AAEB4761-75CC-4DB1-99BD-7790FAD307C6";
7
+ /** The add-in version written into the manifest and every workbook (Office's four-part form). */
8
+ export declare const DEFAULT_EXCEL_ADDIN_VERSION = "1.0.0.0";
9
+ /** How long a connection key lasts by default, in days. */
10
+ export declare const DEFAULT_EXCEL_KEY_LIFETIME_DAYS = 90;
11
+ /** The most rows the pane writes for one source by default. */
12
+ export declare const DEFAULT_EXCEL_MAX_ROWS = 100000;
13
+ /**
14
+ * Where the workbook says the add-in is deployed. `EXCatalog` is Microsoft 365 centralized
15
+ * deployment (the admin center), which this package documents.
16
+ */
17
+ export declare const DEFAULT_EXCEL_STORE_TYPE = "EXCatalog";
18
+ /** The add-in's settings, after validation and defaults. */
19
+ export interface ExcelAddinSettings {
20
+ /** Where MJ Explorer runs; the add-in's sign-in window opens its `/office/connect` page. */
21
+ ExplorerUrl: string;
22
+ /** The host's name, shown in Excel and on the connect page. */
23
+ ServerName: string;
24
+ /** The add-in's GUID in the manifest and in every workbook. */
25
+ AddinId: string;
26
+ /** The add-in's version in the manifest and in every workbook. */
27
+ Version: string;
28
+ /** How long a connection key lasts. */
29
+ KeyLifetimeDays: number;
30
+ /** The `store` a workbook names for the add-in. */
31
+ Store: string;
32
+ /** The `storeType` a workbook names for the add-in. */
33
+ StoreType: string;
34
+ /** The most rows the pane writes for one source. */
35
+ MaxRows: number;
36
+ }
37
+ /** The outcome of {@link ParseExcelAddinSettings}. */
38
+ export interface ParseExcelAddinSettingsResult {
39
+ Success: boolean;
40
+ Settings?: ExcelAddinSettings;
41
+ ErrorMessage?: string;
42
+ }
43
+ /**
44
+ * Validates a host's settings and fills in defaults. Never throws: a problem returns
45
+ * `Success: false` with a message naming the setting.
46
+ */
47
+ export declare function ParseExcelAddinSettings(raw: Record<string, unknown> | null | undefined): ParseExcelAddinSettingsResult;
48
+ //# sourceMappingURL=settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,yCAAyC,CAAC;AAE7E,iGAAiG;AACjG,eAAO,MAAM,2BAA2B,YAAY,CAAC;AAErD,2DAA2D;AAC3D,eAAO,MAAM,+BAA+B,KAAK,CAAC;AAElD,+DAA+D;AAC/D,eAAO,MAAM,sBAAsB,SAAS,CAAC;AAE7C;;;GAGG;AACH,eAAO,MAAM,wBAAwB,cAAc,CAAC;AASpD,4DAA4D;AAC5D,MAAM,WAAW,kBAAkB;IAC/B,4FAA4F;IAC5F,WAAW,EAAE,MAAM,CAAC;IACpB,+DAA+D;IAC/D,UAAU,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,OAAO,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,eAAe,EAAE,MAAM,CAAC;IACxB,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,SAAS,EAAE,MAAM,CAAC;IAClB,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,sDAAsD;AACtD,MAAM,WAAW,6BAA6B;IAC1C,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,6BAA6B,CA8BtH"}
@@ -0,0 +1,115 @@
1
+ /**
2
+ * @fileoverview The Excel add-in's settings, as a host writes them in `mj.config.cjs`
3
+ * (`serverExtensions[].Settings`), and their validation.
4
+ *
5
+ * @module @memberjunction/excel-addin-server
6
+ */
7
+ import { IsValidUUID, TrimTrailingSlashes } from '@memberjunction/global';
8
+ /**
9
+ * The add-in's identity in Office. Every MJ host serves the same add-in, so the default is one fixed
10
+ * GUID; a host that deploys a second, differently configured copy to the same Microsoft 365 tenant
11
+ * sets its own `AddinId`.
12
+ */
13
+ export const DEFAULT_EXCEL_ADDIN_ID = 'AAEB4761-75CC-4DB1-99BD-7790FAD307C6';
14
+ /** The add-in version written into the manifest and every workbook (Office's four-part form). */
15
+ export const DEFAULT_EXCEL_ADDIN_VERSION = '1.0.0.0';
16
+ /** How long a connection key lasts by default, in days. */
17
+ export const DEFAULT_EXCEL_KEY_LIFETIME_DAYS = 90;
18
+ /** The most rows the pane writes for one source by default. */
19
+ export const DEFAULT_EXCEL_MAX_ROWS = 100000;
20
+ /**
21
+ * Where the workbook says the add-in is deployed. `EXCatalog` is Microsoft 365 centralized
22
+ * deployment (the admin center), which this package documents.
23
+ */
24
+ export const DEFAULT_EXCEL_STORE_TYPE = 'EXCatalog';
25
+ const MIN_KEY_LIFETIME_DAYS = 1;
26
+ const MAX_KEY_LIFETIME_DAYS = 365;
27
+ /** Excel holds 1,048,576 rows; one is the heading. */
28
+ const MAX_ROWS_LIMIT = 1048575;
29
+ const MAX_TEXT_LENGTH = 200;
30
+ const VERSION_PATTERN = /^\d{1,5}(\.\d{1,5}){0,3}$/;
31
+ /**
32
+ * Validates a host's settings and fills in defaults. Never throws: a problem returns
33
+ * `Success: false` with a message naming the setting.
34
+ */
35
+ export function ParseExcelAddinSettings(raw) {
36
+ const settings = raw ?? {};
37
+ const explorerUrl = parseExplorerUrl(settings.ExplorerUrl);
38
+ if (!explorerUrl) {
39
+ return fail('Settings.ExplorerUrl is required: the http(s) address where MJ Explorer runs.');
40
+ }
41
+ const addinId = settings.AddinId ?? DEFAULT_EXCEL_ADDIN_ID;
42
+ if (typeof addinId !== 'string' || !IsValidUUID(addinId)) {
43
+ return fail('Settings.AddinId must be a GUID.');
44
+ }
45
+ const version = settings.Version ?? DEFAULT_EXCEL_ADDIN_VERSION;
46
+ if (typeof version !== 'string' || !VERSION_PATTERN.test(version)) {
47
+ return fail('Settings.Version must look like 1.0.0.0.');
48
+ }
49
+ const lifetime = parseInteger(settings.KeyLifetimeDays, DEFAULT_EXCEL_KEY_LIFETIME_DAYS, MIN_KEY_LIFETIME_DAYS, MAX_KEY_LIFETIME_DAYS);
50
+ if (lifetime === null) {
51
+ return fail(`Settings.KeyLifetimeDays must be a whole number from ${MIN_KEY_LIFETIME_DAYS} to ${MAX_KEY_LIFETIME_DAYS}.`);
52
+ }
53
+ const maxRows = parseInteger(settings.MaxRows, DEFAULT_EXCEL_MAX_ROWS, 1, MAX_ROWS_LIMIT);
54
+ if (maxRows === null) {
55
+ return fail(`Settings.MaxRows must be a whole number from 1 to ${MAX_ROWS_LIMIT}.`);
56
+ }
57
+ const texts = parseTexts(settings);
58
+ if (typeof texts === 'string') {
59
+ return fail(texts);
60
+ }
61
+ return {
62
+ Success: true,
63
+ Settings: { ExplorerUrl: explorerUrl, AddinId: addinId.toUpperCase(), Version: version, KeyLifetimeDays: lifetime, MaxRows: maxRows, ...texts },
64
+ };
65
+ }
66
+ function parseTexts(settings) {
67
+ const serverName = parseText(settings.ServerName, 'MemberJunction');
68
+ const storeType = parseText(settings.StoreType, DEFAULT_EXCEL_STORE_TYPE);
69
+ const store = parseText(settings.Store, typeof storeType === 'string' ? storeType : DEFAULT_EXCEL_STORE_TYPE);
70
+ if (serverName === null) {
71
+ return `Settings.ServerName must be text of 1 to ${MAX_TEXT_LENGTH} characters.`;
72
+ }
73
+ if (storeType === null || store === null) {
74
+ return `Settings.Store and Settings.StoreType must be text of 1 to ${MAX_TEXT_LENGTH} characters.`;
75
+ }
76
+ return { ServerName: serverName, Store: store, StoreType: storeType };
77
+ }
78
+ function parseExplorerUrl(value) {
79
+ if (typeof value !== 'string' || !value.trim()) {
80
+ return null;
81
+ }
82
+ try {
83
+ const url = new URL(value.trim());
84
+ if (url.protocol !== 'https:' && url.protocol !== 'http:') {
85
+ return null;
86
+ }
87
+ return TrimTrailingSlashes(url.toString());
88
+ }
89
+ catch {
90
+ return null;
91
+ }
92
+ }
93
+ function parseInteger(value, fallback, min, max) {
94
+ if (value === undefined || value === null) {
95
+ return fallback;
96
+ }
97
+ if (typeof value !== 'number' || !Number.isInteger(value) || value < min || value > max) {
98
+ return null;
99
+ }
100
+ return value;
101
+ }
102
+ function parseText(value, fallback) {
103
+ if (value === undefined || value === null) {
104
+ return fallback;
105
+ }
106
+ if (typeof value !== 'string') {
107
+ return null;
108
+ }
109
+ const trimmed = value.trim();
110
+ return trimmed && trimmed.length <= MAX_TEXT_LENGTH ? trimmed : null;
111
+ }
112
+ function fail(message) {
113
+ return { Success: false, ErrorMessage: message };
114
+ }
115
+ //# sourceMappingURL=settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE1E;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,sCAAsC,CAAC;AAE7E,iGAAiG;AACjG,MAAM,CAAC,MAAM,2BAA2B,GAAG,SAAS,CAAC;AAErD,2DAA2D;AAC3D,MAAM,CAAC,MAAM,+BAA+B,GAAG,EAAE,CAAC;AAElD,+DAA+D;AAC/D,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAE7C;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,WAAW,CAAC;AAEpD,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAChC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAClC,sDAAsD;AACtD,MAAM,cAAc,GAAG,OAAO,CAAC;AAC/B,MAAM,eAAe,GAAG,GAAG,CAAC;AAC5B,MAAM,eAAe,GAAG,2BAA2B,CAAC;AA6BpD;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,GAA+C;IACnF,MAAM,QAAQ,GAAG,GAAG,IAAI,EAAE,CAAC;IAC3B,MAAM,WAAW,GAAG,gBAAgB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC3D,IAAI,CAAC,WAAW,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AC,MAAM,CAAC;QACL,OAAO,IAAI,CAAC;IAChB,CAAC;AACL,CAAC;AAED,SAAS,YAAY,CAAC,KAAc,EAAE,QAAgB,EAAE,GAAW,EAAE,GAAW;IAC5E,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACxC,OAAO,QAAQ,CAAC;IACpB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,GAAG,IAAI,KAAK,GAAG,GAAG,EAAE,CAAC;QACtF,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAS,SAAS,CAAC,KAAc,EAAE,QAAgB;IAC/C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACxC,OAAO,QAAQ,CAAC;IACpB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,OAAO,OAAO,IAAI,OAAO,CAAC,MAAM,IAAI,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AACzE,CAAC;AAED,SAAS,IAAI,CAAC,OAAe;IACzB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC;AACrD,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @fileoverview Resolves the saved views, entities, and saved queries an Open in Excel or in-pane
3
+ * picker request names into workbook sources: their names, columns and data types, and a query's
4
+ * checked parameter values.
5
+ *
6
+ * Everything is read AS the caller, so a view, entity, or query they can't see is refused here,
7
+ * before a workbook or sheet exists. This reads metadata only (no rows); the add-in pane fetches
8
+ * rows later, as whoever opens the file, through GraphQL operations that check permissions again.
9
+ *
10
+ * @module @memberjunction/excel-addin-server
11
+ */
12
+ import { EntityFieldInfo, IMetadataProvider, UserInfo } from '@memberjunction/core';
13
+ import { ExcelColumnDataType, ExcelResolvedWorkbookSource, ExcelWorkbookSource, ExcelWorkbookSourceRequest } from '@memberjunction/excel-addin';
14
+ /** A refusal whose message is safe to show the person who asked. */
15
+ export declare class ExcelSourceError extends Error {
16
+ constructor(message: string);
17
+ }
18
+ /**
19
+ * Resolves and checks every requested source, in order. Throws {@link ExcelSourceError} for the
20
+ * first one the caller can't use.
21
+ */
22
+ export declare function ResolveWorkbookSources(requests: ExcelWorkbookSourceRequest[], provider: IMetadataProvider, user: UserInfo): Promise<ExcelWorkbookSource[]>;
23
+ /**
24
+ * Resolves and authorizes a single view, entity, or saved query request for `user`.
25
+ */
26
+ export declare function ResolveSingleWorkbookSource(request: ExcelWorkbookSourceRequest, provider: IMetadataProvider, user: UserInfo): Promise<ExcelResolvedWorkbookSource>;
27
+ /** The data type the pane uses for an entity field's values. */
28
+ export declare function DataTypeForEntityField(field: EntityFieldInfo): ExcelColumnDataType;
29
+ /** The data type the pane uses for a query field, from its SQL base type; `Text` when unknown. */
30
+ export declare function DataTypeForSQLType(sqlType: string | null | undefined): ExcelColumnDataType;
31
+ //# sourceMappingURL=sources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sources.d.ts","sourceRoot":"","sources":["../src/sources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EACH,eAAe,EAGf,iBAAiB,EAKjB,QAAQ,EACX,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAEH,mBAAmB,EAEnB,2BAA2B,EAE3B,mBAAmB,EACnB,0BAA0B,EAE7B,MAAM,6BAA6B,CAAC;AAErC,oEAAoE;AACpE,qBAAa,gBAAiB,SAAQ,KAAK;gBAC3B,OAAO,EAAE,MAAM;CAI9B;AAID;;;GAGG;AACH,wBAAsB,sBAAsB,CACxC,QAAQ,EAAE,0BAA0B,EAAE,EACtC,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,QAAQ,GACf,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAWhC;AAED;;GAEG;AACH,wBAAsB,2BAA2B,CAC7C,OAAO,EAAE,0BAA0B,EACnC,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,QAAQ,GACf,OAAO,CAAC,2BAA2B,CAAC,CAUtC;AAED,gEAAgE;AAChE,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,eAAe,GAAG,mBAAmB,CAWlF;AAED,kGAAkG;AAClG,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,mBAAmB,CAe1F"}