@mj-biz-apps/common-activity-sync 5.42.0 → 5.44.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.
Files changed (53) hide show
  1. package/dist/ActivitySyncEngine.d.ts +93 -1
  2. package/dist/ActivitySyncEngine.d.ts.map +1 -1
  3. package/dist/ActivitySyncEngine.js +295 -15
  4. package/dist/ActivitySyncEngine.js.map +1 -1
  5. package/dist/attachments.d.ts +106 -0
  6. package/dist/attachments.d.ts.map +1 -0
  7. package/dist/attachments.js +147 -0
  8. package/dist/attachments.js.map +1 -0
  9. package/dist/content-capture.d.ts +92 -0
  10. package/dist/content-capture.d.ts.map +1 -0
  11. package/dist/content-capture.js +35 -0
  12. package/dist/content-capture.js.map +1 -0
  13. package/dist/index.d.ts +3 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +3 -0
  16. package/dist/index.js.map +1 -1
  17. package/dist/participants.d.ts +30 -0
  18. package/dist/participants.d.ts.map +1 -1
  19. package/dist/participants.js +48 -0
  20. package/dist/participants.js.map +1 -1
  21. package/dist/providers/GraphCalendarTransport.d.ts +115 -0
  22. package/dist/providers/GraphCalendarTransport.d.ts.map +1 -0
  23. package/dist/providers/GraphCalendarTransport.js +139 -0
  24. package/dist/providers/GraphCalendarTransport.js.map +1 -0
  25. package/dist/providers/GraphCommunicationTransport.d.ts.map +1 -1
  26. package/dist/providers/GraphCommunicationTransport.js +18 -4
  27. package/dist/providers/GraphCommunicationTransport.js.map +1 -1
  28. package/dist/providers/GraphMessageMapper.d.ts +2 -0
  29. package/dist/providers/GraphMessageMapper.d.ts.map +1 -1
  30. package/dist/providers/GraphMessageMapper.js +3 -0
  31. package/dist/providers/GraphMessageMapper.js.map +1 -1
  32. package/dist/providers/MSGraphActivitySyncProvider.d.ts +39 -4
  33. package/dist/providers/MSGraphActivitySyncProvider.d.ts.map +1 -1
  34. package/dist/providers/MSGraphActivitySyncProvider.js +45 -10
  35. package/dist/providers/MSGraphActivitySyncProvider.js.map +1 -1
  36. package/dist/providers/MSGraphCalendarSyncProvider.d.ts +55 -14
  37. package/dist/providers/MSGraphCalendarSyncProvider.d.ts.map +1 -1
  38. package/dist/providers/MSGraphCalendarSyncProvider.js +112 -38
  39. package/dist/providers/MSGraphCalendarSyncProvider.js.map +1 -1
  40. package/dist/providers/MessageTransport.d.ts +90 -0
  41. package/dist/providers/MessageTransport.d.ts.map +1 -1
  42. package/dist/providers/MessageTransport.js +72 -0
  43. package/dist/providers/MessageTransport.js.map +1 -1
  44. package/dist/providers/RecordedMessageTransport.d.ts.map +1 -1
  45. package/dist/providers/RecordedMessageTransport.js +25 -11
  46. package/dist/providers/RecordedMessageTransport.js.map +1 -1
  47. package/dist/stages.d.ts +11 -0
  48. package/dist/stages.d.ts.map +1 -1
  49. package/dist/stages.js.map +1 -1
  50. package/dist/types.d.ts +14 -0
  51. package/dist/types.d.ts.map +1 -1
  52. package/dist/types.js.map +1 -1
  53. package/package.json +6 -6
@@ -56,4 +56,52 @@ export function MatchesParticipantScope(scope, c) {
56
56
  return c.Internal > 0 && external > 0;
57
57
  }
58
58
  }
59
+ /** Parse one rule set's `InternalDomains`. Blank and null are legitimately "none declared". */
60
+ export function ParseInternalDomains(raw, ruleSetName) {
61
+ const text = (raw ?? '').trim();
62
+ if (!text)
63
+ return { Ok: true, Domains: [] };
64
+ let parsed;
65
+ try {
66
+ parsed = JSON.parse(text);
67
+ }
68
+ catch {
69
+ return {
70
+ Ok: false,
71
+ Issue: `Rule set "${ruleSetName}" has InternalDomains that is not valid JSON. Expected an array like ["bluecypress.io"].`,
72
+ };
73
+ }
74
+ if (!Array.isArray(parsed)) {
75
+ return {
76
+ Ok: false,
77
+ Issue: `Rule set "${ruleSetName}" has InternalDomains that is not a JSON array. Expected e.g. ["bluecypress.io"].`,
78
+ };
79
+ }
80
+ const domains = [];
81
+ for (const entry of parsed) {
82
+ // Normalised exactly as ClassifyParticipants normalises what it compares against, so a list
83
+ // written "@Bluecypress.IO" still matches an address at bluecypress.io.
84
+ const d = String(entry ?? '').trim().toLowerCase().replace(/^@/, '');
85
+ if (d && !domains.includes(d))
86
+ domains.push(d);
87
+ }
88
+ return { Ok: true, Domains: domains };
89
+ }
90
+ /**
91
+ * The warning for rules that test participants when no domain list exists.
92
+ *
93
+ * Returns null when there is nothing to say. This is a WARNING rather than a refusal because the run
94
+ * is still meaningful — the rules simply do not filter the way they read, and saying so is the
95
+ * difference between a surprising sync and an inexplicable one.
96
+ */
97
+ export function ParticipantScopeWarning(rules, internalDomains) {
98
+ if (internalDomains.length > 0)
99
+ return null;
100
+ const scoped = rules.filter((r) => r.ParticipantScope && r.ParticipantScope !== 'Any');
101
+ if (scoped.length === 0)
102
+ return null;
103
+ return (`${scoped.length} rule(s) test ParticipantScope, but no bound rule set defines InternalDomains. ` +
104
+ 'Every participant therefore counts as External, so those rules do not filter what they appear ' +
105
+ 'to. Set InternalDomains on the rule set.');
106
+ }
59
107
  //# sourceMappingURL=participants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"participants.js","sourceRoot":"","sources":["../src/participants.ts"],"names":[],"mappings":"AAoCA;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB,CAChC,YAAwC,EACxC,eAAkC;IAElC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAC9F,MAAM,WAAW,GAA2B,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IAErF,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAC7C,IAAI,MAAM,KAAK,IAAI,E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,0 +1,115 @@
1
+ /**
2
+ * The live calendar transport: MJ's Communication MS Graph provider, with credentials from MJ's
3
+ * Credentials engine.
4
+ *
5
+ * WRAPS, DOES NOT REIMPLEMENT — and until recently there was nothing to wrap. `MSGraphProvider` could
6
+ * send, read, reply, forward, draft, move, archive, search and subscribe, and had no calendar API at
7
+ * all, while the piece that would have made one possible (`getGraphClient`, which owns token
8
+ * acquisition and the credential-keyed client cache) is private. Building a client here would have
9
+ * forked exactly the behaviour `BaseActivitySyncProvider` says to wrap. So calendar retrieval was
10
+ * added to MJ first and this wraps it.
11
+ *
12
+ * WHY IT READS SourceData RATHER THAN Events. `GetEventsResult.Events` is MJ's normalized shape and
13
+ * is deliberately thin; `MapGraphEvent` in this package is written against Graph's own `event`
14
+ * resource and reads fields the normalized form drops (`iCalUId`, attendee `type`, `bodyPreview`
15
+ * nuances). `SourceData` carries the payload verbatim, which is what `NormalizedItem.Raw` is meant to
16
+ * preserve. Same choice, for the same reason, as the message transport.
17
+ *
18
+ * THE CREDENTIAL IS NEVER HELD. Resolved per fetch and passed straight into the call. `clientSecret`
19
+ * is flagged `isSecret` on the "Azure Service Principal" credential type, so MJ decrypts it at load
20
+ * and it lives only for the duration of the request. Never logged, never cached on this object,
21
+ * never interpolated into an issue string.
22
+ *
23
+ * @module @mj-biz-apps/common-activity-sync
24
+ */
25
+ import type { BaseCommunicationProvider } from '@memberjunction/communication-types';
26
+ import type { UserInfo } from '@memberjunction/core';
27
+ import type { ActivitySourceQuery, RawBatch } from '../types.js';
28
+ import type { ActivityMessageTransport } from './MessageTransport.js';
29
+ import { type GraphServicePrincipal } from './GraphCommunicationTransport.js';
30
+ /**
31
+ * How far back a FIRST run reaches when the connection has no calendar watermark.
32
+ *
33
+ * A bound is required rather than optional: `/calendarView` refuses a request without one, and the
34
+ * alternative endpoint returns series masters instead of occurrences. Thirty days is a starting
35
+ * point, not a rule — it is a constructor argument, and a run that falls back to it says so in its
36
+ * issues rather than letting an operator believe the whole calendar was read.
37
+ */
38
+ export declare const DEFAULT_FIRST_RUN_LOOKBACK_DAYS = 30;
39
+ /**
40
+ * How far FORWARD a read reaches.
41
+ *
42
+ * Not zero, deliberately. `Activity.Status` includes `Scheduled`, so a meeting that has not happened
43
+ * yet is a thing this schema models, and a calendar sync that only ever looked backwards could not
44
+ * produce one.
45
+ */
46
+ export declare const DEFAULT_FORWARD_HORIZON_DAYS = 30;
47
+ /** The slice of MJ's communication provider this uses. Structural, to avoid a hard runtime import. */
48
+ export interface GraphEventReader {
49
+ GetEvents(params: {
50
+ Identifier?: string;
51
+ NumEvents: number;
52
+ StartDateTime?: Date;
53
+ EndDateTime?: Date;
54
+ IncludeCancelled?: boolean;
55
+ ContextData?: Record<string, unknown>;
56
+ }, credentials?: unknown): Promise<{
57
+ Success: boolean;
58
+ Events?: unknown[];
59
+ SourceData?: unknown[];
60
+ ErrorMessage?: string;
61
+ RecurrenceExpanded?: boolean;
62
+ }>;
63
+ }
64
+ /**
65
+ * COMPILE-TIME PROOF THAT THE STRUCTURAL TYPE ABOVE IS NOT FICTION.
66
+ *
67
+ * Declared structurally so this package takes no runtime dependency on the Communication engine. The
68
+ * cost of that is that nothing checks the shape against MJ: the only value ever assigned to it in
69
+ * tests is a stub, and a stub cast with `as unknown as` bypasses checking entirely. Drift in MJ's
70
+ * `GetEvents` would then surface on the FIRST LIVE CALL and nowhere earlier.
71
+ *
72
+ * So the compiler checks it instead. `@memberjunction/communication-types` is already a declared peer
73
+ * and this is a TYPE-only import, so no runtime dependency is added and these lines emit no
74
+ * JavaScript. If MJ changes the signature, the BUILD breaks here rather than a live sync.
75
+ */
76
+ type AssertTrue<T extends true> = T;
77
+ export type GraphEventReaderMatchesMJ = AssertTrue<BaseCommunicationProvider extends GraphEventReader ? true : false>;
78
+ /** How the two collaborators are obtained. Injected, so neither engine is a runtime dependency. */
79
+ export interface GraphCalendarTransportDeps {
80
+ ResolveCredential(): Promise<GraphServicePrincipal>;
81
+ ResolveProvider(): Promise<GraphEventReader>;
82
+ ContextUser?: UserInfo;
83
+ }
84
+ export declare class GraphCalendarTransport implements ActivityMessageTransport {
85
+ private readonly Deps;
86
+ private readonly LookbackDays;
87
+ private readonly ForwardDays;
88
+ /** Injectable so a test can pin the window without freezing global time. */
89
+ private readonly Now;
90
+ readonly Describe = "Microsoft Graph calendar (live, via MJ Communication)";
91
+ readonly IsLive = true;
92
+ constructor(Deps: GraphCalendarTransportDeps, LookbackDays?: number, ForwardDays?: number,
93
+ /** Injectable so a test can pin the window without freezing global time. */
94
+ Now?: () => Date);
95
+ Fetch(query: ActivitySourceQuery): Promise<RawBatch>;
96
+ }
97
+ /**
98
+ * Build the deps from MJ's engines, resolving both lazily.
99
+ *
100
+ * Separate from the class so the class stays testable with neither engine loaded — the tests inject
101
+ * their own deps, which is also how a recorded run avoids dragging the Credentials engine into a
102
+ * replay that has no credential to resolve.
103
+ */
104
+ export declare function MJGraphCalendarTransportDeps(args: {
105
+ CredentialName: string;
106
+ ContextUser?: UserInfo;
107
+ GetCredentialEngine: () => {
108
+ getCredential<T>(name: string, options?: Record<string, unknown>): Promise<{
109
+ values: T;
110
+ }>;
111
+ };
112
+ GetCommunicationProvider: (name: string) => GraphEventReader | null | undefined;
113
+ }): GraphCalendarTransportDeps;
114
+ export {};
115
+ //# sourceMappingURL=GraphCalendarTransport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphCalendarTransport.d.ts","sourceRoot":"","sources":["../../src/providers/GraphCalendarTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AACrF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAGtE,OAAO,EA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,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,4EAA4E;IAC5E,OAAO,CAAC,QAAQ,CAAC,GAAG;IARxB,SAAgB,QAAQ,2DAA2D;IACnF,SAAgB,MAAM,QAAQ;gBAGT,IAAI,EAAE,0BAA0B,EAChC,YAAY,GAAE,MAAwC,EACtD,WAAW,GAAE,MAAqC;IACnE,4EAA4E;IAC3D,GAAG,GAAE,MAAM,IAAuB;IAG1C,KAAK,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC;CAkGpE;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE;IAC/C,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,QAAQ,CAAC;IACvB,mBAAmB,EAAE,MAAM;QACvB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;YAAE,MAAM,EAAE,CAAC,CAAA;SAAE,CAAC,CAAC;KAC7F,CAAC;IACF,wBAAwB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,gBAAgB,GAAG,IAAI,GAAG,SAAS,CAAC;CACnF,GAAG,0BAA0B,CAyB7B"}
@@ -0,0 +1,139 @@
1
+ // Reused, not redeclared: mail and calendar reach the SAME MJ provider under the same registration
2
+ // name and resolve the SAME credential type. Two copies could drift into naming different things.
3
+ import { GRAPH_COMMUNICATION_PROVIDER, GRAPH_CREDENTIAL_TYPE, } from './GraphCommunicationTransport.js';
4
+ /**
5
+ * How far back a FIRST run reaches when the connection has no calendar watermark.
6
+ *
7
+ * A bound is required rather than optional: `/calendarView` refuses a request without one, and the
8
+ * alternative endpoint returns series masters instead of occurrences. Thirty days is a starting
9
+ * point, not a rule — it is a constructor argument, and a run that falls back to it says so in its
10
+ * issues rather than letting an operator believe the whole calendar was read.
11
+ */
12
+ export const DEFAULT_FIRST_RUN_LOOKBACK_DAYS = 30;
13
+ /**
14
+ * How far FORWARD a read reaches.
15
+ *
16
+ * Not zero, deliberately. `Activity.Status` includes `Scheduled`, so a meeting that has not happened
17
+ * yet is a thing this schema models, and a calendar sync that only ever looked backwards could not
18
+ * produce one.
19
+ */
20
+ export const DEFAULT_FORWARD_HORIZON_DAYS = 30;
21
+ export class GraphCalendarTransport {
22
+ constructor(Deps, LookbackDays = DEFAULT_FIRST_RUN_LOOKBACK_DAYS, ForwardDays = DEFAULT_FORWARD_HORIZON_DAYS,
23
+ /** Injectable so a test can pin the window without freezing global time. */
24
+ Now = () => new Date()) {
25
+ this.Deps = Deps;
26
+ this.LookbackDays = LookbackDays;
27
+ this.ForwardDays = ForwardDays;
28
+ this.Now = Now;
29
+ this.Describe = 'Microsoft Graph calendar (live, via MJ Communication)';
30
+ this.IsLive = true;
31
+ }
32
+ async Fetch(query) {
33
+ const issues = [];
34
+ const credential = await this.Deps.ResolveCredential();
35
+ const missing = ['tenantId', 'clientId', 'clientSecret'].filter((k) => !String(credential?.[k] ?? '').trim());
36
+ if (missing.length > 0) {
37
+ // Field NAMES are reported, never values. The names are what an operator needs in order
38
+ // to fix it, and one of the values is a secret.
39
+ throw new Error(`The "${GRAPH_CREDENTIAL_TYPE}" credential is missing required field(s): ${missing.join(', ')}. ` +
40
+ 'Complete it in MJ before enabling live fetch.');
41
+ }
42
+ const now = this.Now();
43
+ /**
44
+ * THE WINDOW IS ROLLING, AND DELIBERATELY IGNORES THE WATERMARK.
45
+ *
46
+ * `WatermarkBasisForKind('Calendar')` is `ObservationTime` — for a calendar the watermark
47
+ * records WHEN WE LAST LOOKED, not how far through the data we got. That basis is correct and
48
+ * the reason is in its own docblock: a meeting can be dated in the future, so an item-time
49
+ * watermark would skip straight past anything scheduled earlier than the newest thing seen.
50
+ *
51
+ * This used to pass that same value as `StartDateTime`, which filters on the EVENT'S OWN time.
52
+ * The two are different quantities and using one as the other loses data silently: run 1 at T0
53
+ * sets the watermark to T0, and a meeting that took place last week but is added to the
54
+ * calendar tomorrow starts before T0, so it falls outside run 2's window — and outside every
55
+ * later window, since each one starts later still. It is never read, on any run, with no issue
56
+ * raised and `Success = true`. Retroactive additions and back-dated invitations are ordinary
57
+ * calendar behaviour, not an edge case.
58
+ *
59
+ * So the window is always `[now - LookbackDays, now + ForwardDays]` and the same events are
60
+ * re-read every run. That is not waste: de-duplication is by `ExternalID` in the writer, so a
61
+ * re-read costs one lookup and writes nothing, while a missed event is unrecoverable.
62
+ */
63
+ const start = new Date(now.getTime() - this.LookbackDays * 86_400_000);
64
+ const end = new Date(now.getTime() + this.ForwardDays * 86_400_000);
65
+ if (!query.Since) {
66
+ // Said out loud on the FIRST run only, because that is when someone expects full history.
67
+ // On later runs the same bound applies and saying so every time would be noise.
68
+ issues.push(`First calendar run for ${query.Mailbox}: the window starts ${this.LookbackDays} days ` +
69
+ `back (${start.toISOString()}). Anything older was not read.`);
70
+ }
71
+ const provider = await this.Deps.ResolveProvider();
72
+ const result = await provider.GetEvents({
73
+ Identifier: query.Mailbox,
74
+ NumEvents: query.Limit,
75
+ StartDateTime: start,
76
+ EndDateTime: end,
77
+ // A cancellation is a real thing that happened to a meeting somebody attended, and
78
+ // `MapGraphEvent` already carries `Cancelled` through to the Activity.
79
+ IncludeCancelled: true,
80
+ },
81
+ // Same MJ requirements as the message path, for the same reasons — see
82
+ // GraphCommunicationTransport: accountEmail is validated before any request and the
83
+ // credential type does not carry it, and disableEnvironmentFallback stops a gap being
84
+ // filled from AZURE_* on the host, which is the difference between failing on a missing
85
+ // field and reading a calendar nobody asked for.
86
+ { ...credential, accountEmail: query.Mailbox, disableEnvironmentFallback: true });
87
+ if (!result?.Success) {
88
+ throw new Error(result?.ErrorMessage?.trim() || `Graph returned no calendar result for mailbox "${query.Mailbox}".`);
89
+ }
90
+ // BOTH BOUNDS WERE SENT, so MJ should have expanded recurrence. If it says otherwise the
91
+ // payloads are series MASTERS, and one row would be filed for a weekly meeting at whatever
92
+ // date the series began. That is wrong in a way no downstream check would catch, because a
93
+ // master and an occurrence look alike.
94
+ if (result.RecurrenceExpanded === false) {
95
+ issues.push('Graph did not expand recurring series despite a bounded window, so repeating meetings ' +
96
+ 'are represented by their series master rather than by occurrences. Times for those ' +
97
+ 'will be the start of the series.');
98
+ }
99
+ const payloads = (result.SourceData ?? []);
100
+ const capped = payloads.length >= query.Limit;
101
+ if (capped) {
102
+ issues.push(`The calendar read hit its limit of ${query.Limit} events for ${query.Mailbox}; ` +
103
+ 'the window may hold more than this pass returned.');
104
+ }
105
+ return { Payloads: payloads, Issues: issues, Capped: capped };
106
+ }
107
+ }
108
+ /**
109
+ * Build the deps from MJ's engines, resolving both lazily.
110
+ *
111
+ * Separate from the class so the class stays testable with neither engine loaded — the tests inject
112
+ * their own deps, which is also how a recorded run avoids dragging the Credentials engine into a
113
+ * replay that has no credential to resolve.
114
+ */
115
+ export function MJGraphCalendarTransportDeps(args) {
116
+ return {
117
+ ContextUser: args.ContextUser,
118
+ async ResolveCredential() {
119
+ const resolved = await args
120
+ .GetCredentialEngine()
121
+ .getCredential(args.CredentialName, { contextUser: args.ContextUser });
122
+ if (!resolved?.values) {
123
+ throw new Error(`Credential "${args.CredentialName}" resolved with no values.`);
124
+ }
125
+ return resolved.values;
126
+ },
127
+ async ResolveProvider() {
128
+ const provider = args.GetCommunicationProvider(GRAPH_COMMUNICATION_PROVIDER);
129
+ if (!provider) {
130
+ // A REGISTRATION problem, not a credential one. Saying which keeps an operator from
131
+ // hunting for a secret that is present and correct.
132
+ throw new Error(`MJ communication provider "${GRAPH_COMMUNICATION_PROVIDER}" is not registered. ` +
133
+ 'Ensure @memberjunction/communication-ms-graph is loaded in this host.');
134
+ }
135
+ return provider;
136
+ },
137
+ };
138
+ }
139
+ //# sourceMappingURL=GraphCalendarTransport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphCalendarTransport.js","sourceRoot":"","sources":["../../src/providers/GraphCalendarTransport.ts"],"names":[],"mappings":"AA6BA,mG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;oBAC7E,uEAAuE,CAC9E,CAAC;YACN,CAAC;YACD,OAAO,QAAQ,CAAC;QACpB,CAAC;KACJ,CAAC;AACN,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"GraphCommunicationTransport.d.ts","sourceRoot":"","sources":["../../src/providers/GraphCommunicationTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AACrF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEtE;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,4BAA4B,CAAC;AAE/D,qGAAqG;AACrG,eAAO,MAAM,4BAA4B,oBAAoB,CAAC;AAE9D,8DAA8D;AAC9D,MAAM,WAAW,qBAAqB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACxB;AAED,sGAAsG;AACtG,MAAM,WAAW,kBAAkB;IAC/B,WAAW,CACP,MAAM,EAAE;QACJ,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACzC,EACD,WAAW,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC;QACP,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;QACrB,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC;QACvB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,cAAc,CAAC,EAAE,OAAO,CAAC;KAC5B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B,iBAAiB,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACpD,eAAe,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAC/C,WAAW,CAAC,EAAE,QAAQ,CAAC;CAC1B;AAED,qBAAa,2BAA4B,YAAW,wBAAwB;IAIrD,OAAO,CAAC,QAAQ,CAAC,IAAI;IAHxC,SAAgB,QAAQ,kDAAkD;IAC1E,SAAgB,MAAM,QAAQ;gBAEM,IAAI,EAAE,kBAAkB;IAE/C,KAAK,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC;CAkFpE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE;IACvC,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,QAAQ,CAAC;IACvB,mBAAmB,EAAE,MAAM;QACvB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;YAAE,MAAM,EAAE,CAAC,CAAA;SAAE,CAAC,CAAC;KAC7F,CAAC;IACF,wBAAwB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,kBAAkB,GAAG,IAAI,GAAG,SAAS,CAAC;CACrF,GAAG,kBAAkB,CAyBrB"}
@@ -53,11 +53,25 @@ export class GraphCommunicationTransport {
53
53
  throw new Error(result?.ErrorMessage?.trim() || `Graph returned no result for mailbox "${query.Mailbox}".`);
54
54
  }
55
55
  const payloads = (result.SourceData ?? []);
56
- const capped = !!query.Since && payloads.length >= query.Limit;
56
+ // A FULL PAGE MEANS THERE MAY BE MORE, WATERMARK OR NOT.
57
+ //
58
+ // This used to require `query.Since`, which left the FIRST run — the one most likely to
59
+ // overflow a page — unprotected. No date bound is sent, so Graph returns the newest `Limit`
60
+ // messages; `BaseActivitySyncProvider` then computes a high watermark from them and the next
61
+ // run asks for everything AFTER the newest. Every message older than that first page is
62
+ // skipped permanently, and the run reports Success with no issue. A mailbox with more history
63
+ // than one page silently loses all of it.
64
+ //
65
+ // `Capped` also withholds the watermark upstream, which is what actually prevents the loss;
66
+ // the issue below is how anyone finds out a re-run is needed.
67
+ const capped = payloads.length >= query.Limit;
57
68
  if (capped) {
58
- issues.push(`Fetched the maximum of ${query.Limit} message(s) for "${query.Mailbox}" while a watermark was set, ` +
59
- 'so older items may remain unread. Re-run to continue, or raise the limit. A server-side date ' +
60
- 'bound (MemberJunction/MJ#4123) removes this entirely.');
69
+ const context = query.Since
70
+ ? 'while a watermark was set, so older items may remain unread'
71
+ : 'on a FIRST run with no watermark, so anything older than this page has not been read';
72
+ issues.push(`Fetched the maximum of ${query.Limit} message(s) for "${query.Mailbox}" ${context}. ` +
73
+ 'The watermark is being withheld so nothing is skipped — re-run to continue, or raise ' +
74
+ 'the limit. A server-side date bound (MemberJunction/MJ#4123) removes this entirely.');
61
75
  }
62
76
  // `Capped` is what actually protects the mail; the issue above only TELLS someone. Without
63
77
  // it the watermark advanced to the newest item in a truncated batch and the remainder was
@@ -1 +1 @@
1
- {"version":3,"file":"GraphCommunicationTransport.js","sourceRoot":"","sources":["../../src/providers/GraphCommunicationTransport.ts"],"names":[],"mappings":"AA6BA;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,yBAAyB,CAAC;AAE/D,qGAAqG;AACrG,MAAM,CAAC,MAAM,4BAA4B,GAAG,iBAAiB,CAAC;AA4D9D,MAAM,OAAO,2BAA2B;IAIpC,YAAoC,IAAwB;QAAxB,SAAI,GAAJ,IAAI,CAAoB;QAH5C,aAAQ,GAAG,8CAA8C,CAAC;QAC1D,WAAM,GAAG,IAAI,CAAC;IAEiC,CAAC;IAEzD,KAAK,CAAC,KAAK,CAAC,KAA0B;QACzC,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvD,MAAM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K,CAAC,OAAO,KAAK,OAAO,IAAI;gBAClF,uFAAuF;gBACvF,qFAAqF,CAC5F,CAAC;QACN,CAAC;QAED,2FAA2F;QAC3F,0FAA0F;QAC1F,oBAAoB;QACpB,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAClE,CAAC;CACJ;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAOpC;IACG,OAAO;QACH,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,KAAK,CAAC,iBAAiB;YACnB,MAAM,QAAQ,GAAG,MAAM,IAAI;iBACtB,mBAAmB,EAAE;iBACrB,aAAa,CAAwB,IAAI,CAAC,cAAc,EAAE,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;YAClG,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;gBACpB,MAAM,IAAI,KAAK,CAAC,eAAe,IAAI,CAAC,cAAc,4BAA4B,CAAC,CAAC;YACpF,CAAC;YACD,OAAO,QAAQ,CAAC,MAAM,CAAC;QAC3B,CAAC;QACD,KAAK,CAAC,eAAe;YACjB,MAAM,QAAQ,GAAG,IAAI,CAAC,wBAAwB,CAAC,4BAA4B,CAAC,CAAC;YAC7E,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACZ,oFAAoF;gBACpF,oDAAoD;gBACpD,MAAM,IAAI,KAAK,CACX,8BAA8B,4BAA4B,uBAAuB;oBAC7E,uEAAuE,CAC9E,CAAC;YACN,CAAC;YACD,OAAO,QAAQ,CAAC;QACpB,CAAC;KACJ,CAAC;AACN,CAAC"}
@@ -27,6 +27,8 @@ export interface GraphMessage {
27
27
  ccRecipients?: GraphRecipient[] | null;
28
28
  bccRecipients?: GraphRecipient[] | null;
29
29
  [key: string]: unknown;
30
+ /** Graph's own flag. Cheap; the attachment LIST costs a separate call per message. */
31
+ hasAttachments?: boolean;
30
32
  }
31
33
  export interface MapResult {
32
34
  Items: NormalizedItem[];
@@ -1 +1 @@
1
- {"version":3,"file":"GraphMessageMapper.d.ts","sourceRoot":"","sources":["../../src/providers/GraphMessageMapper.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAsC,cAAc,EAAE,MAAM,aAAa,CAAC;AAEtF,MAAM,WAAW,iBAAiB;IAC9B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,cAAc;IAC3B,YAAY,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;CAC3C;AAED,MAAM,WAAW,YAAY;IACzB,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;IAC1C,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,IAAI,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IAC7B,MAAM,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B,YAAY,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IACvC,YAAY,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IACvC,aAAa,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IACxC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,SAAS;IACtB,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,MAAM,EAAE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,IAAI,CAAC;IACvC,aAAa,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IACxC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,sFAAsF;IACtF,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,SAAS;IACtB,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,MAAM,EAAE,MAAM,EAAE,CAAC;CACpB;AAuCD,wBAAgB,eAAe,CAC3B,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EAAE,GACjB,cAAc,GAAG,IAAI,CAyCvB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,CAkB7E"}
@@ -57,6 +57,9 @@ export function MapGraphMessage(message, mailbox, issues) {
57
57
  ExternalID: id,
58
58
  ExternalThreadID: (message.conversationId ?? '').trim() || null,
59
59
  TypeCode: 'Email',
60
+ // Graph's flag, taken at face value. Absent means "not told", which we treat as none rather
61
+ // than paying a per-message list call on the chance something is there.
62
+ HasAttachments: message.hasAttachments === true,
60
63
  Subject: (message.subject ?? '').trim() || '(no subject)',
61
64
  Body: (message.bodyPreview ?? message.body?.content ?? '').trim() || null,
62
65
  StartedAt: startedAt,
@@ -1 +1 @@
1
- {"version":3,"file":"GraphMessageMapper.js","sourceRoot":"","sources":["../../src/providers/GraphMessageMapper.ts"],"names":[],"mappings":"AAqCA,SAAS,eAAe,CAAC,OAAe;IACpC,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAC3B,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAChC,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,SAAS,C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,EAAE,CAAC;IAC5B,MAAM,GAAG,GAAG,OAAiD,CAAC;IAC9D,MAAM,IAAI,GAAc,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QACtC,CAAC,CAAC,GAAG;QACL,CAAC,CAAC,KAAK,CAAC,OAAO,CAAE,GAA2B,EAAE,KAAK,CAAC;YAClD,CAAC,CAAE,GAA4B,CAAC,KAAK;YACrC,CAAC,CAAC,EAAE,CAAC;IACX,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACf,MAAM,CAAC,IAAI,CAAC,qFAAqF,CAAC,CAAC;QACnG,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IACzC,CAAC;IACD,MAAM,KAAK,GAAqB,EAAE,CAAC;IACnC,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,MAAM,GAAG,eAAe,CAAC,KAAqB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QACvE,IAAI,MAAM;YAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC5C,CAAC"}
@@ -1,16 +1,43 @@
1
1
  import { BaseActivitySyncProvider } from '../BaseActivitySyncProvider.js';
2
2
  import type { ActivitySourceQuery, NormalizedItem, RawBatch } from '../types.js';
3
3
  import type { ActivityMessageTransport, ActivityTransportContext, ActivityTransportFactory } from './MessageTransport.js';
4
+ /**
5
+ * Why live fetch is off, and what to do about it.
6
+ *
7
+ * NAMING THE WAY OUT MATTERS AS MUCH AS THE REFUSAL: without it an operator who HAS checked the
8
+ * policy has no supported next step, and the tempting one is to go editing a database row.
9
+ *
10
+ * An earlier version of this string named only one of them — "call AllowLiveMailboxFetch() with the
11
+ * group the policy names" — which was wrong twice over. It assumed every deployment ends up with an
12
+ * Exchange RBAC assignment, when `TenantWideAccepted` exists precisely because most will not; an
13
+ * operator in a tenant with no RBAC owner read that as "you are blocked" and was left with inventing
14
+ * a group name or bypassing the gate. And it pointed at a FUNCTION when the path a deployment
15
+ * actually takes is `LoadLiveMailboxPolicyFromEnv`, already wired into `common-server`'s bootstrap,
16
+ * which reads environment variables. Telling someone to write code they do not need to write is the
17
+ * same defect in miniature: a documented route that is not the route.
18
+ *
19
+ * The variable names are referenced rather than imported — `common-server` depends on this package,
20
+ * not the other way round — which is the same way the attestation's own docblock already refers to
21
+ * `LoadLiveMailboxPolicyFromEnv` by name.
22
+ */
4
23
  export declare const LIVE_GRAPH_REFUSAL: string;
5
24
  export declare const NO_TRANSPORT_REFUSAL: string;
6
25
  export declare const NO_CREDENTIAL_REF_REFUSAL: string;
7
26
  export declare class MSGraphActivitySyncProvider extends BaseActivitySyncProvider {
8
27
  /**
9
- * Default FALSE. Turning it on is a deliberate act by someone who has confirmed the
10
- * Application Access Policy exists. Nothing in this package does that for you.
28
+ * Turning it on is a deliberate act by someone who has confirmed the Application Access
29
+ * Policy exists. Nothing in this package does that for you.
11
30
  *
12
31
  * It gates the LIVE transport only — a recorded transport needs no such confirmation
13
32
  * because it reaches no mailbox, and is allowed through below.
33
+ *
34
+ * DEFAULTS TO THE HOST'S ATTESTATION, NOT TO FALSE. A bare `false` made this unreachable in
35
+ * the only way that ships: `MJGlobal.ClassFactory` builds plugins with no arguments, so
36
+ * through the engine this was permanently off and the parameter could be set by tests and
37
+ * the demo alone. That is the same defect the transport factory had — a seam that was
38
+ * described, exported, and impossible to reach — so it gets the same fix, a host registry.
39
+ * With no attestation registered the default is still false, so an unconfigured host refuses
40
+ * exactly as before.
14
41
  */
15
42
  private readonly AllowLiveFetch;
16
43
  /** Where messages come from. Without one this provider refuses rather than pretending. */
@@ -33,11 +60,19 @@ export declare class MSGraphActivitySyncProvider extends BaseActivitySyncProvide
33
60
  get IsLive(): boolean;
34
61
  constructor(
35
62
  /**
36
- * Default FALSE. Turning it on is a deliberate act by someone who has confirmed the
37
- * Application Access Policy exists. Nothing in this package does that for you.
63
+ * Turning it on is a deliberate act by someone who has confirmed the Application Access
64
+ * Policy exists. Nothing in this package does that for you.
38
65
  *
39
66
  * It gates the LIVE transport only — a recorded transport needs no such confirmation
40
67
  * because it reaches no mailbox, and is allowed through below.
68
+ *
69
+ * DEFAULTS TO THE HOST'S ATTESTATION, NOT TO FALSE. A bare `false` made this unreachable in
70
+ * the only way that ships: `MJGlobal.ClassFactory` builds plugins with no arguments, so
71
+ * through the engine this was permanently off and the parameter could be set by tests and
72
+ * the demo alone. That is the same defect the transport factory had — a seam that was
73
+ * described, exported, and impossible to reach — so it gets the same fix, a host registry.
74
+ * With no attestation registered the default is still false, so an unconfigured host refuses
75
+ * exactly as before.
41
76
  */
42
77
  AllowLiveFetch?: boolean,
43
78
  /** Where messages come from. Without one this provider refuses rather than pretending. */
@@ -1 +1 @@
1
- {"version":3,"file":"MSGraphActivitySyncProvider.d.ts","sourceRoot":"","sources":["../../src/providers/MSGraphActivitySyncProvider.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGjF,OAAO,KAAK,EACR,wBAAwB,EACxB,wBAAwB,EACxB,wBAAwB,EAC3B,MAAM,uBAAuB,CAAC;AAE/B,eAAO,MAAM,kBAAkB,QAIoD,CAAC;AAEpF,eAAO,MAAM,oBAAoB,QAEmB,CAAC;AAErD,eAAO,MAAM,yBAAyB,QAGX,CAAC;AAE5B,qBACa,2BAA4B,SAAQ,wBAAwB;IAoBjE;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,0FAA0F;IAC1F,OAAO,CAAC,SAAS,CAAC;IAClB,6EAA6E;IAC7E,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IA9B7B,SAAgB,IAAI,EAAG,SAAS,CAAU;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C;IAtC7B,SAAgB,IAAI,EAAG,SAAS,CAAU;IAC1C,SAAgB,gBAAgB,kBAAkB;IAElD;;;;;;;;;;OAUG;IACH,IAAW,MAAM,IAAI,OAAO,CAE3B;;IAGG;;;;;;;;;;;;;;OAcG;IACc,cAAc,GAAE,OAAsC;IACvE,0FAA0F;IAClF,SAAS,CAAC,EAAE,wBAAwB,YAAA;IAC5C,6EAA6E;IAC5D,OAAO,CAAC,EAAE,wBAAwB,YAAA;IAKvD,4FAA4F;IAC5F,OAAO,CAAC,oBAAoB,CAAuB;IAEnD;;;;;;;;;;;OAWG;IACa,SAAS,CAAC,OAAO,EAAE,wBAAwB,GAAG,IAAI;cAkClD,QAAQ,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAsCvE,SAAS,CAAC,SAAS,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,mBAAmB,GAAG,cAAc,EAAE;CAuBnF"}
@@ -20,21 +20,48 @@ var __metadata = (this && this.__metadata) || function (k, v) {
20
20
  * provider and MJ's Credentials engine; a recorded one replays captured payloads through the same
21
21
  * mapping. Only the outermost call differs between them.
22
22
  *
23
- * THE TENANT-WIDE READ IS STILL REFUSED BY DEFAULT. `AllowLiveFetch` remains false, and the reason
24
- * is unchanged: app-only `Mail.Read` reads EVERY mailbox in the tenant until an Exchange Application
25
- * Access Policy scopes the app registration to a security group. Wiring a transport does not make
26
- * that safe, so the gate stays, and stays default-off.
23
+ * THE TENANT-WIDE READ IS STILL REFUSED BY DEFAULT. The reason is unchanged: app-only `Mail.Read`
24
+ * reads EVERY mailbox in the tenant until an Exchange Application Access Policy scopes the app
25
+ * registration to a security group. Wiring a transport does not make that safe, so the gate stays.
26
+ *
27
+ * What changed is that the gate is now REACHABLE. It defaults to the host's attestation
28
+ * (`AllowLiveMailboxFetch`) rather than to a bare `false` that `ClassFactory` could never override —
29
+ * an unconfigured host still refuses, but a scoped one can say so in the one place that ships.
27
30
  *
28
31
  * @module @mj-biz-apps/common-activity-sync
29
32
  */
30
33
  import { RegisterClass } from '@memberjunction/global';
31
34
  import { BaseActivitySyncProvider } from '../BaseActivitySyncProvider.js';
32
35
  import { MapGraphMessages } from './GraphMessageMapper.js';
33
- import { HostActivityTransportFactory } from './MessageTransport.js';
36
+ import { HostActivityTransportFactory, HostAllowsLiveMailboxFetch } from './MessageTransport.js';
37
+ /**
38
+ * Why live fetch is off, and what to do about it.
39
+ *
40
+ * NAMING THE WAY OUT MATTERS AS MUCH AS THE REFUSAL: without it an operator who HAS checked the
41
+ * policy has no supported next step, and the tempting one is to go editing a database row.
42
+ *
43
+ * An earlier version of this string named only one of them — "call AllowLiveMailboxFetch() with the
44
+ * group the policy names" — which was wrong twice over. It assumed every deployment ends up with an
45
+ * Exchange RBAC assignment, when `TenantWideAccepted` exists precisely because most will not; an
46
+ * operator in a tenant with no RBAC owner read that as "you are blocked" and was left with inventing
47
+ * a group name or bypassing the gate. And it pointed at a FUNCTION when the path a deployment
48
+ * actually takes is `LoadLiveMailboxPolicyFromEnv`, already wired into `common-server`'s bootstrap,
49
+ * which reads environment variables. Telling someone to write code they do not need to write is the
50
+ * same defect in miniature: a documented route that is not the route.
51
+ *
52
+ * The variable names are referenced rather than imported — `common-server` depends on this package,
53
+ * not the other way round — which is the same way the attestation's own docblock already refers to
54
+ * `LoadLiveMailboxPolicyFromEnv` by name.
55
+ */
34
56
  export const LIVE_GRAPH_REFUSAL = 'Live Graph fetch is disabled. MSGraphProvider uses app-only auth, so Mail.Read reads ' +
35
57
  'EVERY mailbox in the tenant until an Exchange Application Access Policy scopes the ' +
36
- 'app registration to a security group. Confirm that policy exists before enabling ' +
37
- 'this, and use a recorded transport or FixtureActivitySyncProvider until then.';
58
+ 'app registration to a security group. Find out whether that policy exists before enabling ' +
59
+ 'this, and use a recorded transport or FixtureActivitySyncProvider until then. ' +
60
+ 'Then record the answer, whichever it is: the app IS scoped and you name the group, or it is ' +
61
+ 'not and the tenant-wide grant is accepted deliberately, in writing, by a named person on a ' +
62
+ 'date. Both are legitimate. Not knowing is not. A host that reads deployment configuration ' +
63
+ 'sets its ACTIVITY_SYNC_MAILBOX_POLICY_* variables (see @mj-biz-apps/common-server); anything ' +
64
+ 'else calls AllowLiveMailboxFetch() once at bootstrap.';
38
65
  export const NO_TRANSPORT_REFUSAL = 'No mailbox transport was supplied. Construct this provider with a GraphCommunicationTransport ' +
39
66
  '(live) or a RecordedMessageTransport (replay).';
40
67
  export const NO_CREDENTIAL_REF_REFUSAL = 'This ActivitySyncConnection names no credential. Set its CredentialsRef to the NAME of an ' +
@@ -57,13 +84,21 @@ let MSGraphActivitySyncProvider = class MSGraphActivitySyncProvider extends Base
57
84
  }
58
85
  constructor(
59
86
  /**
60
- * Default FALSE. Turning it on is a deliberate act by someone who has confirmed the
61
- * Application Access Policy exists. Nothing in this package does that for you.
87
+ * Turning it on is a deliberate act by someone who has confirmed the Application Access
88
+ * Policy exists. Nothing in this package does that for you.
62
89
  *
63
90
  * It gates the LIVE transport only — a recorded transport needs no such confirmation
64
91
  * because it reaches no mailbox, and is allowed through below.
92
+ *
93
+ * DEFAULTS TO THE HOST'S ATTESTATION, NOT TO FALSE. A bare `false` made this unreachable in
94
+ * the only way that ships: `MJGlobal.ClassFactory` builds plugins with no arguments, so
95
+ * through the engine this was permanently off and the parameter could be set by tests and
96
+ * the demo alone. That is the same defect the transport factory had — a seam that was
97
+ * described, exported, and impossible to reach — so it gets the same fix, a host registry.
98
+ * With no attestation registered the default is still false, so an unconfigured host refuses
99
+ * exactly as before.
65
100
  */
66
- AllowLiveFetch = false,
101
+ AllowLiveFetch = HostAllowsLiveMailboxFetch(),
67
102
  /** Where messages come from. Without one this provider refuses rather than pretending. */
68
103
  Transport,
69
104
  /** How a host builds a transport for a connection. See {@link Configure}. */