@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
package/LICENSE ADDED
@@ -0,0 +1,183 @@
1
+ Business Source License 1.1
2
+
3
+ License text copyright (c) 2024 MariaDB plc, All Rights Reserved.
4
+ "Business Source License" is a trademark of MariaDB plc.
5
+
6
+ -----------------------------------------------------------------------------
7
+
8
+ Parameters
9
+
10
+ Licensor: Blue Cypress, Inc.
11
+
12
+ Licensed Work: MemberJunction.
13
+ The Licensed Work is (c) 2023-2026 Blue Cypress, Inc.
14
+
15
+ Additional Use Grant: Subject to the terms of this License, Licensor grants
16
+ you the following additional rights to make Production
17
+ Use of the Licensed Work.
18
+
19
+ 1. Internal Use
20
+
21
+ You may make production use of the Licensed Work for
22
+ your own internal business or organizational operations.
23
+
24
+ 2. Nonprofit Use
25
+
26
+ If you are a Nonprofit, you may make production use of
27
+ the Licensed Work for the operations and activities of
28
+ your Organizational Family.
29
+
30
+ 3. MemberJunction Certified Program Use
31
+
32
+ If you are authorized by Licensor under the
33
+ MemberJunction Certified Program to provide professional
34
+ services using the Licensed Work, you may make
35
+ production use of the Licensed Work in providing such
36
+ professional services to a client, provided that:
37
+
38
+ (a) the Licensed Work is deployed in, and the applicable
39
+ production use occurs within, an environment owned,
40
+ leased, licensed, subscribed to, or otherwise controlled
41
+ by that client; and
42
+
43
+ (b) the production use is for that client's own internal
44
+ business or organizational operations or is otherwise
45
+ independently permitted to that client under this
46
+ Additional Use Grant.
47
+
48
+ 4. Definitions Applicable to the Additional Use Grant
49
+
50
+ "Affiliate" means, with respect to a specified Person,
51
+ any other Person that directly or indirectly Controls,
52
+ is Controlled by, or is under common Control with such
53
+ specified Person.
54
+
55
+ "Control" (including the terms "Controls," "Controlled
56
+ by," and "under common Control with") means the direct
57
+ or indirect possession of the power to direct or cause
58
+ the direction of the management and policies of a
59
+ Person, whether through ownership of voting interests,
60
+ by contract, or otherwise.
61
+
62
+ "Organizational Family" means, with respect to a Person,
63
+ (a) such Person and its Affiliates, and (b) any
64
+ nonprofit organization, governmental entity, chapter,
65
+ division, local affiliate, regional affiliate, state
66
+ affiliate, national affiliate, or other entity that is
67
+ formally affiliated with such Person through governing
68
+ documents, a charter, bylaws, a membership agreement, or
69
+ another written organizational instrument, and is
70
+ recognized under such documents as part of the same
71
+ organizational structure.
72
+
73
+ "Nonprofit" means a Person recognized by the Internal
74
+ Revenue Service as exempt from federal income taxation
75
+ under Section 501(c)(3), 501(c)(4), 501(c)(5), or
76
+ 501(c)(6) of the Internal Revenue Code, or a foreign
77
+ organization recognized under substantially equivalent
78
+ laws.
79
+
80
+ A Person claiming eligibility as a Nonprofit shall, upon
81
+ Licensor's reasonable request, provide documentation
82
+ reasonably sufficient to demonstrate that it qualifies
83
+ as a Nonprofit. If such Person materially misrepresents,
84
+ or is unable to demonstrate, its qualification as a
85
+ Nonprofit, the rights granted to such Person under
86
+ Section 2 of this Additional Use Grant shall terminate.
87
+
88
+ "MemberJunction Certified Program" means Licensor's
89
+ then-current program for certifying and authorizing a
90
+ Person to provide professional services using the
91
+ Licensed Work.
92
+
93
+ "Person" means any individual, corporation, limited
94
+ liability company, partnership, association, nonprofit
95
+ organization, governmental entity, or other legal or
96
+ organizational entity.
97
+
98
+ Change Date: Four (4) years from the date the Licensed Work is first
99
+ made available.
100
+
101
+ Change License: MIT License.
102
+
103
+ For information about alternative licensing arrangements for the Licensed
104
+ Work, please contact Blue Cypress, Inc.
105
+
106
+ -----------------------------------------------------------------------------
107
+
108
+ Terms
109
+
110
+ The Licensor hereby grants you the right to copy, modify, create derivative
111
+ works, redistribute, and make non-production use of the Licensed Work. The
112
+ Licensor may make an Additional Use Grant, above, permitting limited
113
+ production use.
114
+
115
+ Effective on the Change Date, or the fourth anniversary of the first publicly
116
+ available distribution of a specific version of the Licensed Work under this
117
+ License, whichever comes first, the Licensor hereby grants you rights under
118
+ the terms of the Change License, and the rights granted in the paragraph
119
+ above terminate.
120
+
121
+ If your use of the Licensed Work does not comply with the requirements
122
+ currently in effect as described in this License, you must purchase a
123
+ commercial license from the Licensor, its affiliated entities, or authorized
124
+ resellers, or you must refrain from using the Licensed Work.
125
+
126
+ All copies of the original and modified Licensed Work, and derivative works
127
+ of the Licensed Work, are subject to this License. This License applies
128
+ separately for each version of the Licensed Work and the Change Date may vary
129
+ for each version of the Licensed Work released by Licensor.
130
+
131
+ You must conspicuously display this License on each original or modified copy
132
+ of the Licensed Work. If you receive the Licensed Work in original or
133
+ modified form from a third party, the terms and conditions set forth in this
134
+ License apply to your use of that work.
135
+
136
+ Any use of the Licensed Work in violation of this License will automatically
137
+ terminate your rights under this License for the current and all other
138
+ versions of the Licensed Work.
139
+
140
+ This License does not grant you any right in any trademark or logo of
141
+ Licensor or its affiliates (provided that you may use a trademark or logo of
142
+ Licensor as expressly required by this License).
143
+
144
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
145
+ AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
146
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
147
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
148
+ TITLE.
149
+
150
+ MariaDB hereby grants you permission to use this License's text to license
151
+ your works, and to refer to it using the trademark "Business Source License",
152
+ as long as you comply with the Covenants of Licensor below.
153
+
154
+ -----------------------------------------------------------------------------
155
+
156
+ Covenants of Licensor
157
+
158
+ In consideration of the right to use this License's text and the "Business
159
+ Source License" name and trademark, Licensor covenants to MariaDB, and to all
160
+ other recipients of the licensed work to be provided by Licensor:
161
+
162
+ 1. To specify as the Change License the GPL Version 2.0 or any later version,
163
+ or a license that is compatible with GPL Version 2.0 or a later version,
164
+ where "compatible" means that software provided under the Change License
165
+ can be included in a program with software provided under GPL Version 2.0
166
+ or a later version. Licensor may specify additional Change Licenses without
167
+ limitation.
168
+
169
+ 2. To either: (a) specify an additional grant of rights to use that does not
170
+ impose any additional restriction on the right granted in this License, as
171
+ the Additional Use Grant; or (b) insert the text "None".
172
+
173
+ 3. To specify a Change Date.
174
+
175
+ 4. Not to modify this License in any other way.
176
+
177
+ -----------------------------------------------------------------------------
178
+
179
+ Notice
180
+
181
+ The Business Source License (this document, or the "License") is not an Open
182
+ Source license. However, the Licensed Work will eventually be made available
183
+ under an Open Source License, as stated in this License.
package/README.md CHANGED
@@ -1,45 +1,105 @@
1
1
  # @memberjunction/excel-addin-server
2
2
 
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
3
+ The server half of the MemberJunction Excel add-in. Each MJ host serves the add-in to Excel itself, so people get **Open in Excel** on saved views and saved queries: a workbook that holds headings and no rows, and fills from MJ as whoever opens it.
4
4
 
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
5
+ The browser-safe half — the workbook contract, the typed Remote Operations Explorer calls, and the add-in pane — is [`@memberjunction/excel-addin`](../Excel).
6
6
 
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
7
+ ## What it provides
8
8
 
9
- ## Purpose
9
+ | Piece | What it does |
10
+ |---|---|
11
+ | `ExcelAddinServerExtension` | A Server Extension (pre-auth) that serves the add-in's manifest, its `config.json`, and the pane's pages and icons from this host |
12
+ | `ExcelAddin.GetStatus` | Tells Explorer whether this host serves the add-in, and where |
13
+ | `ExcelAddin.CreateConnection` | Mints the signed-in user's Excel connection key |
14
+ | `ExcelAddin.BuildWorkbook` | Builds the connected workbook for saved views, entities, and queries the caller can see |
15
+ | `ExcelAddin.GetCatalog` | Lists the caller's active applications, readable entities, query categories, and runnable saved queries for the in-pane browser |
16
+ | `ExcelAddin.GetEntityViews` | Lists accessible saved `MJ: User Views` on a chosen entity for the in-pane browser |
17
+ | `ExcelAddin.ResolveSource` | Resolves a chosen entity, view, or query into canonical columns and checked parameters before writing to `MJ_Sources` |
18
+ | `BuildExcelAddinManifest`, `BuildConnectedWorkbook` | The builders those use |
10
19
 
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `@memberjunction/excel-addin-server`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
20
+ The operations are registered whenever this package is loaded. Until the Server Extension is configured, `GetStatus` reports the add-in as off, the other two refuse, and Explorer hides the Open in Excel button.
15
21
 
16
- ## What is OIDC Trusted Publishing?
22
+ ## Turning it on
17
23
 
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
24
+ Add the extension to the host's `mj.config.cjs`:
19
25
 
20
- ## Setup Instructions
26
+ ```js
27
+ module.exports = {
28
+ serverExtensions: [
29
+ {
30
+ Name: 'ExcelAddin',
31
+ DriverClass: 'ExcelAddinServerExtension',
32
+ PackagePath: '@memberjunction/excel-addin-server',
33
+ RootPath: '/office/excel',
34
+ Phase: 'pre-auth',
35
+ Enabled: true,
36
+ Settings: {
37
+ ExplorerUrl: 'https://explorer.example.org', // required: where MJ Explorer runs
38
+ ServerName: 'Example Association', // shown in Excel and on the connect page
39
+ },
40
+ },
41
+ ],
42
+ };
43
+ ```
21
44
 
22
- To properly configure OIDC trusted publishing for this package:
45
+ MJAPI also needs a public URL (`MJAPI_PUBLIC_URL`), because Excel loads the add-in from outside the server. The extension refuses to start without one and logs why.
23
46
 
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
47
+ ### Settings
28
48
 
29
- ## DO NOT USE THIS PACKAGE
49
+ | Setting | Default | Meaning |
50
+ |---|---|---|
51
+ | `ExplorerUrl` | required | Where MJ Explorer runs. The add-in's sign-in window opens its `/office/connect` page |
52
+ | `ServerName` | `MemberJunction` | The add-in's name in Excel and on the connect page |
53
+ | `KeyLifetimeDays` | `90` | How long a connection key lasts (1–365) |
54
+ | `MaxRows` | `100000` | The most rows the pane writes for one source |
55
+ | `AddinId` | `AAEB4761-75CC-4DB1-99BD-7790FAD307C6` | The add-in's GUID. Change it only to deploy a second, differently configured copy to the same Microsoft 365 tenant |
56
+ | `Version` | `1.0.0.0` | The add-in version in the manifest and in every workbook |
57
+ | `StoreType`, `Store` | `EXCatalog` | How a workbook names where the add-in is deployed. `EXCatalog` is Microsoft 365 centralized deployment |
30
58
 
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
59
+ ## Deploying the add-in to people
36
60
 
37
- ## More Information
61
+ Once MJAPI is running with the extension, its manifest is at:
38
62
 
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
63
+ ```
64
+ https://<MJAPI public URL>/office/excel/manifest.xml
65
+ ```
42
66
 
43
- ---
67
+ A Microsoft 365 administrator deploys it once:
44
68
 
45
- **Maintained for OIDC setup purposes only**
69
+ 1. Open the **Microsoft 365 admin center** → **Settings** → **Integrated apps** → **Upload custom apps**.
70
+ 2. Choose **Office Add-in**, then **Provide link to manifest file**, and paste the manifest URL.
71
+ 3. Choose who gets it (everyone, or specific users or groups) and finish.
72
+
73
+ The add-in then appears on the **Data** tab of Excel for Windows, Mac and the web, and a workbook made by Open in Excel opens its pane automatically. Deployment can take up to a day to reach everyone.
74
+
75
+ For development, sideload the same manifest (Excel → **Insert** → **Add-ins** → **Upload My Add-in**). A workbook names its add-in's deployment through `StoreType`; a sideloaded add-in may not open automatically with a workbook made for centralized deployment, but it opens from the ribbon button.
76
+
77
+ ## How it works
78
+
79
+ 1. **Open in Excel.** A person picks Open in Excel on a saved view or saved query. `ExcelAddin.BuildWorkbook` reads the view or query **as that person** (refusing one they can't see), and writes a workbook with:
80
+ - one sheet per source, holding only its headings;
81
+ - a very-hidden `MJ_Sources` sheet recording each source (the view, or the query and its chosen parameter values);
82
+ - the Office web-extension parts that open this add-in with the file.
83
+
84
+ No rows, no credential, and no server-set query parameter are ever written into the file.
85
+ 2. **Sign in.** The pane opens Explorer's `/office/connect` page in an Office sign-in window. The person signs in the way they always do and approves. `ExcelAddin.CreateConnection` mints their connection key, and Explorer hands it back encrypted to a key pair the pane made for that sign-in.
86
+ 3. **Refresh.** The pane fetches each source's rows through MJ's GraphQL `RunViewByID` and `GetQueryData`, sending the key as `X-API-Key`, and writes them into the sheet.
87
+
88
+ ## Security model
89
+
90
+ - **Nothing here returns data.** The pre-auth routes serve only static pages, the manifest and a config file with public URLs. Data comes only from GraphQL, with the person's key.
91
+ - **The connection key is narrow.** It belongs to the person, holds only the `view:run` and `query:run` scopes, and MJ denies an API key every scope-checked operation outside its scopes. It can't save, delete or mint more keys. It is bound to the `MJAPI` application when one is defined, so it can't be used against MJ's MCP or A2A servers.
92
+ - **It is created as the person.** MJ's own permissions decide whether they may create an API key. If their role can't, Open in Excel's sign-in says so and asks them to contact an administrator.
93
+ - **It is revocable.** It is labelled `Excel add-in` on the API Keys page, expires (90 days by default), and stops working the moment it is revoked or its user is deactivated.
94
+ - **No half-made keys.** If any step after the key is created fails, the key is revoked before the error is reported.
95
+ - **Every refresh is checked again.** Rows come from the same operations Explorer uses, with the person's row- and field-level security. A forwarded workbook shows each person only their own rows.
96
+ - **The file is untrusted.** The pane validates the recorded sources before using them, and the server re-checks each one on every refresh.
97
+
98
+ ## Development
99
+
100
+ ```bash
101
+ pnpm run build # tsc
102
+ pnpm test # vitest
103
+ ```
104
+
105
+ The pane is built by `@memberjunction/excel-addin` (`dist/web`); this package serves it from there and refuses to start if it isn't built.
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @fileoverview Builds the permission-filtered catalog (Applications, readable Entities, Query
3
+ * Categories, and runnable Saved Queries) and per-entity Saved Views list for the Excel task pane.
4
+ *
5
+ * Every check runs strictly against the calling `UserInfo`:
6
+ * - Entities require `IncludeInAPI !== false`, active status, and `GetUserPermisions(user).CanRead`.
7
+ * - Saved Views are queried via `RunView.FromMetadataProvider(provider)` AS `user` (avoiding the
8
+ * process-wide `UserViewEngine.Instance` singleton's mutable `_contextUserId`) and filtered by
9
+ * `v.UserCanView`.
10
+ * - Saved Queries require `q.UserCanRun(user)` and expose only non-server-set parameters.
11
+ *
12
+ * @module @memberjunction/excel-addin-server
13
+ */
14
+ import { IMetadataProvider, RunViewParams, RunViewResult, UserInfo } from '@memberjunction/core';
15
+ import { ExcelAddinCatalogOutput, ExcelAddinEntityViewsOutput } from '@memberjunction/excel-addin';
16
+ /** Minimal RunView runner shape so unit tests can supply a stub without global provider wiring. */
17
+ export interface ExcelViewRunner {
18
+ RunView<T>(params: RunViewParams, contextUser?: UserInfo): Promise<RunViewResult<T>>;
19
+ }
20
+ /**
21
+ * Builds the signed-in user's permission-filtered catalog of applications, entities, query categories,
22
+ * and saved queries.
23
+ */
24
+ export declare function BuildExcelCatalog(provider: IMetadataProvider, user: UserInfo): ExcelAddinCatalogOutput;
25
+ /**
26
+ * Loads the saved `MJ: User Views` records `user` is permitted to view on `entityId`.
27
+ */
28
+ export declare function LoadExcelEntityViews(entityId: string, provider: IMetadataProvider, user: UserInfo, runner?: ExcelViewRunner): Promise<ExcelAddinEntityViewsOutput>;
29
+ //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAGH,iBAAiB,EAKjB,aAAa,EACb,aAAa,EACb,QAAQ,EACX,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACH,uBAAuB,EACvB,2BAA2B,EAQ9B,MAAM,6BAA6B,CAAC;AAGrC,mGAAmG;AACnG,MAAM,WAAW,eAAe;IAC5B,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;CACxF;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,EAAE,QAAQ,GAAG,uBAAuB,CAetG;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACtC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,QAAQ,EACd,MAAM,CAAC,EAAE,eAAe,GACzB,OAAO,CAAC,2BAA2B,CAAC,CAwDtC"}
@@ -0,0 +1,242 @@
1
+ /**
2
+ * @fileoverview Builds the permission-filtered catalog (Applications, readable Entities, Query
3
+ * Categories, and runnable Saved Queries) and per-entity Saved Views list for the Excel task pane.
4
+ *
5
+ * Every check runs strictly against the calling `UserInfo`:
6
+ * - Entities require `IncludeInAPI !== false`, active status, and `GetUserPermisions(user).CanRead`.
7
+ * - Saved Views are queried via `RunView.FromMetadataProvider(provider)` AS `user` (avoiding the
8
+ * process-wide `UserViewEngine.Instance` singleton's mutable `_contextUserId`) and filtered by
9
+ * `v.UserCanView`.
10
+ * - Saved Queries require `q.UserCanRun(user)` and expose only non-server-set parameters.
11
+ *
12
+ * @module @memberjunction/excel-addin-server
13
+ */
14
+ import { RunView, } from '@memberjunction/core';
15
+ import { ResourcePermissionEngine } from '@memberjunction/core-entities';
16
+ import { IsValidUUID, UUIDsEqual } from '@memberjunction/global';
17
+ import { ExcelSourceError } from './sources.js';
18
+ /**
19
+ * Builds the signed-in user's permission-filtered catalog of applications, entities, query categories,
20
+ * and saved queries.
21
+ */
22
+ export function BuildExcelCatalog(provider, user) {
23
+ const entities = buildReadableEntities(provider.Entities ?? [], user);
24
+ const canonicalEntityIdByLower = new Map(entities.map(e => [e.ID.toLowerCase(), e.ID]));
25
+ const applications = buildApplications(provider.Applications ?? [], canonicalEntityIdByLower);
26
+ const { Categories: queryCategories, Queries: queries } = buildQueriesAndCategories(provider.Queries ?? [], provider.QueryCategories ?? [], user);
27
+ return {
28
+ Applications: applications,
29
+ Entities: entities,
30
+ QueryCategories: queryCategories,
31
+ Queries: queries,
32
+ };
33
+ }
34
+ /**
35
+ * Loads the saved `MJ: User Views` records `user` is permitted to view on `entityId`.
36
+ */
37
+ export async function LoadExcelEntityViews(entityId, provider, user, runner) {
38
+ if (!IsValidUUID(entityId)) {
39
+ throw new ExcelSourceError('That entity ID is not valid.');
40
+ }
41
+ if (!IsValidUUID(user.ID)) {
42
+ throw new ExcelSourceError('The current user context is not valid.');
43
+ }
44
+ const entity = (provider.Entities ?? []).find(e => UUIDsEqual(e.ID, entityId));
45
+ if (!entity || entity.IncludeInAPI === false || entity.Status === 'Disabled' || !entity.GetUserPermisions(user).CanRead) {
46
+ throw new ExcelSourceError('That entity doesn\'t exist, or you don\'t have access to read it.');
47
+ }
48
+ if (!runner && !ResourcePermissionEngine.Instance.Loaded) {
49
+ try {
50
+ await ResourcePermissionEngine.Instance.Config(false, user, provider);
51
+ }
52
+ catch {
53
+ // If ResourcePermissionEngine cannot load in a minimal test environment, safeCanView handles fallback.
54
+ }
55
+ }
56
+ const viewRunner = runner ?? RunView.FromMetadataProvider(provider);
57
+ const result = await viewRunner.RunView({
58
+ EntityName: 'MJ: User Views',
59
+ ExtraFilter: `EntityID='${entity.ID}' AND (UserID='${user.ID}' OR IsShared=1)`,
60
+ OrderBy: 'Name',
61
+ ResultType: 'entity_object',
62
+ }, user);
63
+ if (!result.Success) {
64
+ throw new ExcelSourceError(result.ErrorMessage || `Saved views for "${entity.DisplayNameOrName}" could not be loaded.`);
65
+ }
66
+ const accessible = (result.Results ?? []).filter(view => safeUserCanView(view, user));
67
+ const mapped = accessible.map(view => {
68
+ const isOwned = UUIDsEqual(view.UserID, user.ID);
69
+ return {
70
+ ID: view.ID,
71
+ Name: view.Name,
72
+ Description: view.Description ?? '',
73
+ IsOwned: isOwned,
74
+ IsShared: Boolean(view.IsShared),
75
+ IsDefault: isOwned && Boolean(view.IsDefault),
76
+ };
77
+ });
78
+ mapped.sort((a, b) => {
79
+ if (a.IsDefault !== b.IsDefault) {
80
+ return a.IsDefault ? -1 : 1;
81
+ }
82
+ if (a.IsOwned !== b.IsOwned) {
83
+ return a.IsOwned ? -1 : 1;
84
+ }
85
+ return a.Name.localeCompare(b.Name);
86
+ });
87
+ return {
88
+ EntityID: entity.ID,
89
+ Views: mapped,
90
+ };
91
+ }
92
+ function buildReadableEntities(entities, user) {
93
+ return entities
94
+ .filter(e => e.IncludeInAPI !== false &&
95
+ e.Status !== 'Disabled' &&
96
+ e.Status !== 'Deprecated' &&
97
+ e.GetUserPermisions(user).CanRead)
98
+ .map(e => ({
99
+ ID: e.ID,
100
+ Name: e.Name,
101
+ DisplayName: e.DisplayNameOrName,
102
+ Description: e.Description ?? '',
103
+ }))
104
+ .sort((a, b) => a.DisplayName.localeCompare(b.DisplayName));
105
+ }
106
+ function buildApplications(applications, canonicalEntityIdByLower) {
107
+ return [...applications]
108
+ .filter(app => !app.Status || app.Status === 'Active')
109
+ .sort((a, b) => {
110
+ const seqDiff = (a.DefaultSequence ?? 100) - (b.DefaultSequence ?? 100);
111
+ return seqDiff !== 0 ? seqDiff : (a.Name ?? '').localeCompare(b.Name ?? '');
112
+ })
113
+ .map(app => {
114
+ const seen = new Set();
115
+ const entityIds = [];
116
+ const appEntities = [...(app.ApplicationEntities ?? [])].sort((a, b) => (a.Sequence ?? 0) - (b.Sequence ?? 0));
117
+ for (const ae of appEntities) {
118
+ const canonical = ae.EntityID ? canonicalEntityIdByLower.get(ae.EntityID.toLowerCase()) : undefined;
119
+ if (canonical && !seen.has(canonical)) {
120
+ seen.add(canonical);
121
+ entityIds.push(canonical);
122
+ }
123
+ }
124
+ return {
125
+ ID: app.ID,
126
+ Name: app.Name,
127
+ Description: app.Description ?? '',
128
+ EntityIDs: entityIds,
129
+ };
130
+ })
131
+ .filter(app => app.EntityIDs.length > 0);
132
+ }
133
+ function buildQueriesAndCategories(allQueries, allCategories, user) {
134
+ const categoryById = new Map();
135
+ for (const cat of allCategories) {
136
+ if (cat.ID) {
137
+ categoryById.set(cat.ID.toLowerCase(), cat);
138
+ }
139
+ }
140
+ const computePath = (categoryId) => {
141
+ if (!categoryId) {
142
+ return '';
143
+ }
144
+ const parts = [];
145
+ const visited = new Set();
146
+ let cursor = categoryId;
147
+ while (cursor) {
148
+ const key = cursor.toLowerCase();
149
+ if (visited.has(key)) {
150
+ break;
151
+ }
152
+ visited.add(key);
153
+ const cat = categoryById.get(key);
154
+ if (!cat) {
155
+ break;
156
+ }
157
+ parts.unshift(cat.Name);
158
+ cursor = cat.ParentID;
159
+ }
160
+ return parts.join(' / ');
161
+ };
162
+ const usedCategoryAndAncestors = new Set();
163
+ const markCategoryAncestors = (categoryId) => {
164
+ let cursor = categoryId;
165
+ while (cursor) {
166
+ const key = cursor.toLowerCase();
167
+ if (usedCategoryAndAncestors.has(key)) {
168
+ break;
169
+ }
170
+ const cat = categoryById.get(key);
171
+ if (!cat) {
172
+ break;
173
+ }
174
+ usedCategoryAndAncestors.add(key);
175
+ cursor = cat.ParentID;
176
+ }
177
+ };
178
+ const queries = allQueries
179
+ .filter(q => q.Status !== 'Rejected' && q.Status !== 'Expired' && q.UserCanRun(user))
180
+ .map(q => {
181
+ markCategoryAncestors(q.CategoryID);
182
+ const categoryPath = computePath(q.CategoryID);
183
+ const callerParams = (q.Parameters ?? [])
184
+ .filter(p => !p.IsServerSet)
185
+ .map(mapQueryParameter);
186
+ return {
187
+ ID: q.ID,
188
+ Name: q.Name,
189
+ Description: q.Description ?? '',
190
+ CategoryID: q.CategoryID ?? null,
191
+ CategoryPath: categoryPath,
192
+ Parameters: callerParams,
193
+ };
194
+ })
195
+ .sort((a, b) => {
196
+ const pathCmp = a.CategoryPath.localeCompare(b.CategoryPath);
197
+ return pathCmp !== 0 ? pathCmp : a.Name.localeCompare(b.Name);
198
+ });
199
+ const categories = allCategories
200
+ .filter(c => c.ID && usedCategoryAndAncestors.has(c.ID.toLowerCase()))
201
+ .map(c => ({
202
+ ID: c.ID,
203
+ Name: c.Name,
204
+ ParentID: c.ParentID ?? null,
205
+ Path: computePath(c.ID),
206
+ }))
207
+ .sort((a, b) => a.Path.localeCompare(b.Path));
208
+ return { Categories: categories, Queries: queries };
209
+ }
210
+ function mapQueryParameter(param) {
211
+ return {
212
+ Name: param.Name,
213
+ Type: normalizeParameterType(param.Type),
214
+ IsRequired: Boolean(param.IsRequired),
215
+ DefaultValue: param.DefaultValue ?? null,
216
+ Description: param.Description ?? '',
217
+ SampleValue: param.SampleValue ?? '',
218
+ };
219
+ }
220
+ function normalizeParameterType(rawType) {
221
+ switch (rawType) {
222
+ case 'number':
223
+ case 'date':
224
+ case 'boolean':
225
+ case 'array':
226
+ return rawType;
227
+ default:
228
+ return 'string';
229
+ }
230
+ }
231
+ function safeUserCanView(view, user) {
232
+ if (UUIDsEqual(view.UserID, user.ID)) {
233
+ return true;
234
+ }
235
+ try {
236
+ return Boolean(view.UserCanView);
237
+ }
238
+ catch {
239
+ return false;
240
+ }
241
+ }
242
+ //# sourceMappingURL=catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.js","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAOH,OAAO,GAIV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA4B,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACnG,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAYjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAO7C;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAA2B,EAAE,IAAc;IACzE,MAAM,QAAQ,GAAG,qBAAqB,CAAC,QAAQ,CAAC,QAAQ,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;IACtE,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAiB,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE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AAC,CAAC;SACF,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAElD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AACxD,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAyB;IAChD,OAAO;QACH,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,IAAI,EAAE,sBAAsB,CAAC,KAAK,CAAC,IAAI,CAAC;QACxC,UAAU,EAAE,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC;QACrC,YAAY,EAAE,KAAK,CAAC,YAAY,IAAI,IAAI;QACxC,WAAW,EAAE,KAAK,CAAC,WAAW,IAAI,EAAE;QACpC,WAAW,EAAE,KAAK,CAAC,WAAW,IAAI,EAAE;KACvC,CAAC;AACN,CAAC;AAED,SAAS,sBAAsB,CAAC,OAAmC;IAC/D,QAAQ,OAAO,EAAE,CAAC;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,MAAM,CAAC;QACZ,KAAK,SAAS,CAAC;QACf,KAAK,OAAO;YACR,OAAO,OAAO,CAAC;QACnB;YACI,OAAO,QAAQ,CAAC;IACxB,CAAC;AACL,CAAC;AAED,SAAS,eAAe,CAAC,IAA8B,EAAE,IAAc;IACnE,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;QACnC,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,IAAI,CAAC;QACD,OAAO,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,KAAK,CAAC;IACjB,CAAC;AACL,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @fileoverview Mints the API key the Excel add-in signs in with.
3
+ *
4
+ * The key belongs to the signed-in user and is created AS that user, so MJ's own permissions decide
5
+ * whether they may connect Excel at all (plan O10). It is limited to the `view:run` and `query:run`
6
+ * scopes; MJ's API keys deny every scope-checked operation outside a key's scopes, so it can't save,
7
+ * delete or mint more keys. It is bound to the `MJAPI` application when one is defined, expires, and
8
+ * shows up on the API Keys page, where it can be revoked.
9
+ *
10
+ * A key is never left without its scopes: if any step after creation fails, the key is revoked
11
+ * before the error is reported.
12
+ *
13
+ * @module @memberjunction/excel-addin-server
14
+ */
15
+ import { IMetadataProvider, UserInfo } from '@memberjunction/core';
16
+ /** The label every Excel connection key carries on the API Keys page. */
17
+ export declare const EXCEL_CONNECTION_KEY_LABEL = "Excel add-in";
18
+ /** The only scopes an Excel connection key holds. */
19
+ export declare const EXCEL_CONNECTION_SCOPES: readonly string[];
20
+ /** The application a key is bound to, so it works against MJAPI only. */
21
+ export declare const EXCEL_CONNECTION_APPLICATION = "MJAPI";
22
+ /** A new connection key. `APIKey` is the raw key, available only now. */
23
+ export interface ExcelConnectionKey {
24
+ APIKey: string;
25
+ APIKeyID: string;
26
+ ExpiresAt: Date;
27
+ Label: string;
28
+ }
29
+ /** Creates, scopes and binds the user's Excel connection key. Throws with a message fit to show them. */
30
+ export declare function CreateExcelConnectionKey(user: UserInfo, provider: IMetadataProvider, lifetimeDays: number, now?: Date): Promise<ExcelConnectionKey>;
31
+ //# sourceMappingURL=connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,iBAAiB,EAAY,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAK7E,yEAAyE;AACzE,eAAO,MAAM,0BAA0B,iBAAiB,CAAC;AAEzD,qDAAqD;AACrD,eAAO,MAAM,uBAAuB,EAAE,SAAS,MAAM,EAA8B,CAAC;AAEpF,yEAAyE;AACzE,eAAO,MAAM,4BAA4B,UAAU,CAAC;AAEpD,yEAAyE;AACzE,MAAM,WAAW,kBAAkB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,IAAI,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACjB;AAID,yGAAyG;AACzG,wBAAsB,wBAAwB,CAC1C,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE,iBAAiB,EAC3B,YAAY,EAAE,MAAM,EACpB,GAAG,GAAE,IAAiB,GACvB,OAAO,CAAC,kBAAkB,CAAC,CAqB7B"}