@mj-biz-apps/common-server 5.37.0 → 5.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,27 @@
1
+ import { GRAPH_COMMUNICATION_PROVIDER, type ActivityMessageTransport, type ActivityTransportContext } from '@mj-biz-apps/common-activity-sync';
2
+ /**
3
+ * Build a live Graph transport for one connection, or null when this factory cannot serve it.
4
+ *
5
+ * NULL IS NOT AN ERROR, and the two cases below are deliberately silent rather than throwing:
6
+ *
7
+ * - a DIFFERENT driver — a fixture or calendar connection is not this factory's business, and
8
+ * throwing would break every connection this host runs rather than the one it cannot serve;
9
+ * - NO CredentialsRef — the provider already has a specific, better-worded refusal for that
10
+ * (`NO_CREDENTIAL_REF_REFUSAL`), and pre-empting it here would replace a precise message with
11
+ * a vaguer one.
12
+ *
13
+ * Anything else is a wiring fault and is left to throw.
14
+ */
15
+ export declare function GraphTransportFactory(context: ActivityTransportContext): ActivityMessageTransport | null;
16
+ /**
17
+ * Register this host's factory. Called once from the package bootstrap.
18
+ *
19
+ * Registration alone changes NO behaviour on its own: `AllowLiveFetch` still defaults false, so the
20
+ * provider still refuses a live read until someone who has confirmed the Exchange Application Access
21
+ * Policy opts in. What this ends is the state where a correctly configured credential could not be
22
+ * resolved at all.
23
+ */
24
+ export declare function LoadGraphTransportFactory(): void;
25
+ /** Exported for tests and for a host that wants the default provider name. */
26
+ export { GRAPH_COMMUNICATION_PROVIDER };
27
+ //# sourceMappingURL=graph-transport-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph-transport-factory.d.ts","sourceRoot":"","sources":["../../src/custom/graph-transport-factory.ts"],"names":[],"mappings":"AAoBA,OAAO,EACH,4BAA4B,EAI5B,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAEhC,MAAM,mCAAmC,CAAC;AAK3C;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,wBAAwB,GAAG,wBAAwB,GAAG,IAAI,CAiBxG;AAgDD;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,IAAI,IAAI,CAEhD;AAED,8EAA8E;AAC9E,OAAO,EAAE,4BAA4B,EAAE,CAAC"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * The host's answer to "where does a live transport come from?".
3
+ *
4
+ * WHY THIS FILE HAD TO EXIST. `ActivityTransportFactory` was declared in the ActivitySync package as
5
+ * "how a HOST supplies a transport", exported, documented — and NOTHING ANYWHERE BUILT ONE. A
6
+ * connection could name a credential, the column could be set correctly, and the provider would
7
+ * still refuse, because the seam that turns a credential name into a transport had no
8
+ * implementation. That is the last link in the chain between a configured credential and live mail.
9
+ *
10
+ * WHY IT LIVES IN THE SERVER PACKAGE. ActivitySync takes MJ's Communication and Credentials engines
11
+ * as PEER dependencies and injects them deliberately, so a host that syncs only fixtures need
12
+ * install neither. Building the transport there would have made that impossible. The host is the
13
+ * layer that legitimately owns both engines, so the wiring belongs here and the seam stays clean.
14
+ *
15
+ * @module @mj-biz-apps/common-server
16
+ */
17
+ import { BaseCommunicationProvider } from '@memberjunction/communication-types';
18
+ import { CredentialEngine } from '@memberjunction/credentials';
19
+ import { MJGlobal } from '@memberjunction/global';
20
+ import { GRAPH_COMMUNICATION_PROVIDER, GraphCommunicationTransport, MJGraphTransportDeps, RegisterActivityTransportFactory, } from '@mj-biz-apps/common-activity-sync';
21
+ /** The `ActivitySyncProviderType.DriverClass` this factory serves. It serves exactly one. */
22
+ const MICROSOFT_365 = 'Microsoft365';
23
+ /**
24
+ * Build a live Graph transport for one connection, or null when this factory cannot serve it.
25
+ *
26
+ * NULL IS NOT AN ERROR, and the two cases below are deliberately silent rather than throwing:
27
+ *
28
+ * - a DIFFERENT driver — a fixture or calendar connection is not this factory's business, and
29
+ * throwing would break every connection this host runs rather than the one it cannot serve;
30
+ * - NO CredentialsRef — the provider already has a specific, better-worded refusal for that
31
+ * (`NO_CREDENTIAL_REF_REFUSAL`), and pre-empting it here would replace a precise message with
32
+ * a vaguer one.
33
+ *
34
+ * Anything else is a wiring fault and is left to throw.
35
+ */
36
+ export function GraphTransportFactory(context) {
37
+ if (context.DriverClass !== MICROSOFT_365) {
38
+ return null;
39
+ }
40
+ const credentialName = (context.CredentialsRef ?? '').trim();
41
+ if (!credentialName) {
42
+ return null;
43
+ }
44
+ return new GraphCommunicationTransport(MJGraphTransportDeps({
45
+ CredentialName: credentialName,
46
+ ContextUser: context.ContextUser,
47
+ GetCredentialEngine: () => CredentialLoader(context.ContextUser),
48
+ GetCommunicationProvider: ResolveCommunicationProvider,
49
+ }));
50
+ }
51
+ /**
52
+ * The Credentials engine, loaded on first use rather than assumed loaded.
53
+ *
54
+ * `getCredential` throws "Metadata not loaded" if the engine has not been configured, and this
55
+ * factory runs from a scheduled Action that may fire before or after anything else touches
56
+ * credentials. `EnsureLoaded` is idempotent and joins an in-flight load rather than starting a
57
+ * second, so paying it per resolution costs nothing after the first.
58
+ */
59
+ function CredentialLoader(contextUser) {
60
+ return {
61
+ async getCredential(name, options) {
62
+ const user = options?.contextUser ?? contextUser;
63
+ await CredentialEngine.Instance.EnsureLoaded(user);
64
+ return CredentialEngine.Instance.getCredential(name, {
65
+ contextUser: user,
66
+ subsystem: 'BizApps Common ActivitySync',
67
+ });
68
+ },
69
+ };
70
+ }
71
+ /**
72
+ * MJ's registered communication provider, by name.
73
+ *
74
+ * THE BASE-CLASS CHECK IS LOAD-BEARING and is copied from `CommunicationEngine.GetProvider`:
75
+ * `ClassFactory.CreateInstance` returns an instance of the BASE class when no registration matches,
76
+ * so a missing provider comes back as a truthy object that answers no calls usefully. Without this
77
+ * the transport would be built, reach `GetMessages`, and fail somewhere far less informative than
78
+ * the registration message the provider already carries.
79
+ *
80
+ * WHY NOT CALL `CommunicationEngine.GetProvider` ITSELF. It is this exact resolution and nothing
81
+ * more — it consults no provider metadata and no Status — but it throws unless the engine's
82
+ * `Config()` has loaded its five metadata entities first. That is a sending-side prerequisite this
83
+ * read-only path has no use for, so the two lines are mirrored here rather than paying the load.
84
+ */
85
+ function ResolveCommunicationProvider(name) {
86
+ const instance = MJGlobal.Instance.ClassFactory.CreateInstance(BaseCommunicationProvider, name);
87
+ if (!instance || instance.constructor.name === 'BaseCommunicationProvider') {
88
+ return null;
89
+ }
90
+ return instance;
91
+ }
92
+ /**
93
+ * Register this host's factory. Called once from the package bootstrap.
94
+ *
95
+ * Registration alone changes NO behaviour on its own: `AllowLiveFetch` still defaults false, so the
96
+ * provider still refuses a live read until someone who has confirmed the Exchange Application Access
97
+ * Policy opts in. What this ends is the state where a correctly configured credential could not be
98
+ * resolved at all.
99
+ */
100
+ export function LoadGraphTransportFactory() {
101
+ RegisterActivityTransportFactory(GraphTransportFactory);
102
+ }
103
+ /** Exported for tests and for a host that wants the default provider name. */
104
+ export { GRAPH_COMMUNICATION_PROVIDER };
105
+ //# sourceMappingURL=graph-transport-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph-transport-factory.js","sourceRoot":"","sources":["../../src/custom/graph-transport-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EACH,4BAA4B,EAC5B,2BAA2B,EAC3B,oBAAoB,EACpB,gCAAgC,GAInC,MAAM,mCAAmC,CAAC;AAE3C,6FAA6F;AAC7F,MAAM,aAAa,GAAG,cAAc,CAAC;AAErC;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAiC;IACnE,IAAI,OAAO,CAAC,WAAW,KAAK,aAAa,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,MAAM,cAAc,GAAG,CAAC,OAAO,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC,I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
package/dist/index.d.ts CHANGED
@@ -20,4 +20,5 @@ export declare const RESOLVER_PATHS: string[];
20
20
  export declare function LoadBizAppsCommonServer(): void;
21
21
  export { SyncActivitiesAction, LoadSyncActivitiesAction } from './custom/sync-activities.action.js';
22
22
  export { LogActivityAction, LoadLogActivityAction } from './custom/log-activity.action.js';
23
+ export { GraphTransportFactory, LoadGraphTransportFactory } from './custom/graph-transport-factory.js';
23
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,8BAA8B,CAAC;AACtC,OAAO,6BAA6B,CAAC;AAIrC,OAAO,0CAA0C,CAAC;AAMlD,OAAO,0BAA0B,CAAC;AAMlC,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAOlF,oFAAoF;AACpF,eAAO,MAAM,cAAc,UAAsD,CAAC;AAElF;;;;GAIG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAM9C;AAED,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AACpG,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,8BAA8B,CAAC;AACtC,OAAO,6BAA6B,CAAC;AAIrC,OAAO,0CAA0C,CAAC;AAOlD,OAAO,0BAA0B,CAAC;AAMlC,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAOlF,oFAAoF;AACpF,eAAO,MAAM,cAAc,UAAsD,CAAC;AAElF;;;;GAIG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAS9C;AAED,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AACpG,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC3F,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC"}
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ import '@mj-biz-apps/common-core-entities-server';
14
14
  import { LoadActivitySyncEngine } from '@mj-biz-apps/common-core-entities-server';
15
15
  import { LoadSyncActivitiesAction } from './custom/sync-activities.action.js';
16
16
  import { LoadLogActivityAction } from './custom/log-activity.action.js';
17
+ import { LoadGraphTransportFactory } from './custom/graph-transport-factory.js';
17
18
  // Import generated GraphQL resolvers
18
19
  import './generated/generated.js';
19
20
  // Re-export the manifest for consumers
@@ -34,7 +35,11 @@ export function LoadBizAppsCommonServer() {
34
35
  LoadActivitySyncEngine();
35
36
  LoadSyncActivitiesAction();
36
37
  LoadLogActivityAction();
38
+ // Registers the seam that turns a connection's CredentialsRef into a live Graph transport.
39
+ // Nothing about this enables a live read on its own — AllowLiveFetch still defaults false.
40
+ LoadGraphTransportFactory();
37
41
  }
38
42
  export { SyncActivitiesAction, LoadSyncActivitiesAction } from './custom/sync-activities.action.js';
39
43
  export { LogActivityAction, LoadLogActivityAction } from './custom/log-activity.action.js';
44
+ export { GraphTransportFactory, LoadGraphTransportFactory } from './custom/graph-transport-factory.js';
40
45
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,yEAAyE;AACzE,OAAO,8BAA8B,CAAC;AACtC,OAAO,6BAA6B,CAAC;AAErC,qEAAqE;AACrE,4DAA4D;AAC5D,OAAO,0CAA0C,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,C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mB,EAAE,MAAM,6CAA6C,CAAC;AAElF,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,SAAS,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE/D,oFAAoF;AACpF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,6BAA6B,CAAC,CAAC,CAAC;AAElF;;;;GAIG;AACH,MAAM,UAAU,uBAAuB;IACnC,0DAA0D;IAC1D,kFAAkF;IAClF,sBAAsB,EAAE,CAAC;IACzB,wBAAwB,EAAE,CAAC;IAC3B,qBAAqB,EAAE,CAAC;IACxB,2FAA2F;IAC3F,2FAA2F;IAC3F,yBAAyB,EAAE,CAAC;AAChC,CAAC;AAED,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AACpG,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC3F,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mj-biz-apps/common-server",
3
3
  "type": "module",
4
- "version": "5.37.0",
4
+ "version": "5.39.0",
5
5
  "description": "BizApps Common server bootstrap - GraphQL resolvers and class registrations for the Common business entities Open App",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -14,22 +14,25 @@
14
14
  "author": "MemberJunction.com",
15
15
  "license": "BUSL-1.1",
16
16
  "devDependencies": {
17
- "typescript": "^5.9.3"
17
+ "typescript": "^5.9.3",
18
+ "vitest": "^3.2.4"
18
19
  },
19
20
  "dependencies": {
20
- "@mj-biz-apps/common-activity-sync": "5.37.0",
21
- "@mj-biz-apps/common-core-entities-server": "5.37.0",
22
- "@mj-biz-apps/common-entities": "5.37.0",
23
- "@mj-biz-apps/common-actions": "5.37.0",
21
+ "@mj-biz-apps/common-activity-sync": "5.39.0",
22
+ "@mj-biz-apps/common-core-entities-server": "5.39.0",
23
+ "@mj-biz-apps/common-entities": "5.39.0",
24
+ "@mj-biz-apps/common-actions": "5.39.0",
24
25
  "class-validator": "^0.14.3"
25
26
  },
26
27
  "peerDependencies": {
27
- "@memberjunction/actions": "^6.1.0-edge.3",
28
- "@memberjunction/actions-base": "^6.1.0-edge.3",
29
- "@memberjunction/core": "^6.1.0-edge.3",
30
- "@memberjunction/global": "^6.1.0-edge.3",
31
- "@memberjunction/server": "^6.1.0-edge.3",
32
- "@memberjunction/sqlserver-dataprovider": "^6.1.0-edge.3"
28
+ "@memberjunction/actions": "^6.1.0-edge.5",
29
+ "@memberjunction/actions-base": "^6.1.0-edge.5",
30
+ "@memberjunction/communication-types": "^6.1.0-edge.5",
31
+ "@memberjunction/core": "^6.1.0-edge.5",
32
+ "@memberjunction/credentials": "^6.1.0-edge.5",
33
+ "@memberjunction/global": "^6.1.0-edge.5",
34
+ "@memberjunction/server": "^6.1.0-edge.5",
35
+ "@memberjunction/sqlserver-dataprovider": "^6.1.0-edge.5"
33
36
  },
34
37
  "repository": {
35
38
  "type": "git",
@@ -37,6 +40,6 @@
37
40
  },
38
41
  "scripts": {
39
42
  "build": "tsc && tsc-alias -f",
40
- "test": "echo \"No tests configured yet\""
43
+ "test": "vitest run"
41
44
  }
42
45
  }