microsoft-graph-client 1.0.52 → 1.0.53
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.
- package/dist/api/calendar.d.ts.map +1 -1
- package/dist/api/calendar.js +6 -1
- package/dist/api/calendar.js.map +1 -1
- package/dist/api/chats.d.ts.map +1 -1
- package/dist/api/chats.js +17 -18
- package/dist/api/chats.js.map +1 -1
- package/dist/api/mail.d.ts.map +1 -1
- package/dist/api/mail.js +21 -6
- package/dist/api/mail.js.map +1 -1
- package/dist/api/mailFolders.d.ts +5 -1
- package/dist/api/mailFolders.d.ts.map +1 -1
- package/dist/api/mailFolders.js +48 -4
- package/dist/api/mailFolders.js.map +1 -1
- package/dist/api/messages.d.ts +1 -1
- package/dist/api/messages.d.ts.map +1 -1
- package/dist/api/messages.js +3 -2
- package/dist/api/messages.js.map +1 -1
- package/dist/api/transcripts.d.ts.map +1 -1
- package/dist/api/transcripts.js +7 -1
- package/dist/api/transcripts.js.map +1 -1
- package/dist/api/users.d.ts.map +1 -1
- package/dist/api/users.js +5 -1
- package/dist/api/users.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/mail.d.ts +3 -2
- package/dist/types/mail.d.ts.map +1 -1
- package/dist/types/mailFolder.d.ts +39 -1
- package/dist/types/mailFolder.d.ts.map +1 -1
- package/dist/utils/index.d.ts +4 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/odata.d.ts +118 -19
- package/dist/utils/odata.d.ts.map +1 -1
- package/dist/utils/odata.js +136 -20
- package/dist/utils/odata.js.map +1 -1
- package/dist/utils/retention.d.ts +59 -0
- package/dist/utils/retention.d.ts.map +1 -0
- package/dist/utils/retention.js +132 -0
- package/dist/utils/retention.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @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AAG,wBAAwB,EAAE,CAiB7B"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mail folder retention policies — Outlook's "Assign Policy".
|
|
3
|
+
*
|
|
4
|
+
* There is no `retentionPolicy` property on `mailFolder`. The policy lives in
|
|
5
|
+
* three MAPI properties reachable through the `singleValueExtendedProperties`
|
|
6
|
+
* navigation property, which is why a scan of the declared `<Property>` list in
|
|
7
|
+
* `$metadata` concludes the feature is missing:
|
|
8
|
+
*
|
|
9
|
+
* PR_POLICY_TAG `Binary 0x3019` the retention tag, a GUID in bytes
|
|
10
|
+
* PR_RETENTION_PERIOD `Integer 0x301A` days before the tag's action applies
|
|
11
|
+
* PR_RETENTION_FLAGS `Integer 0x301D` Exchange's own bookkeeping
|
|
12
|
+
*
|
|
13
|
+
* Three behaviours verified against a live mailbox, each of which shapes the
|
|
14
|
+
* code below:
|
|
15
|
+
*
|
|
16
|
+
* - **Flags do not round-trip.** Write 9, read back 137: Exchange ORs in 128
|
|
17
|
+
* (NeedsRescan) itself. Never assert on them, and never send them back.
|
|
18
|
+
* - **Clearing works only with `value: null`.** An empty string is stored as
|
|
19
|
+
* an empty string, so the property survives and the folder still looks
|
|
20
|
+
* policed. After a clear, `PR_RETENTION_FLAGS` is left behind as 128, so a
|
|
21
|
+
* folder is "policed" when it has a tag, not when it has any of the three.
|
|
22
|
+
* - **An invented tag GUID is accepted silently.** The PATCH succeeds, the
|
|
23
|
+
* value reads back perfectly, and the Managed Folder Assistant then ignores
|
|
24
|
+
* it forever. Every observable signal says a dead policy is live, which is
|
|
25
|
+
* why callers must validate a tag against the ones a mailbox actually uses
|
|
26
|
+
* rather than trusting a successful write.
|
|
27
|
+
*/
|
|
28
|
+
import { odataFilter, odataRaw } from './odata.js';
|
|
29
|
+
/** MAPI id of PR_POLICY_TAG — the retention tag GUID, stored as bytes. */
|
|
30
|
+
export const RETENTION_TAG_PROPERTY = 'Binary 0x3019';
|
|
31
|
+
/** MAPI id of PR_RETENTION_PERIOD — days before the tag's action applies. */
|
|
32
|
+
export const RETENTION_PERIOD_PROPERTY = 'Integer 0x301A';
|
|
33
|
+
/** MAPI id of PR_RETENTION_FLAGS — Exchange bookkeeping; read-only in practice. */
|
|
34
|
+
export const RETENTION_FLAGS_PROPERTY = 'Integer 0x301D';
|
|
35
|
+
/** `$filter` selecting exactly the three retention properties in an `$expand`. */
|
|
36
|
+
export const RETENTION_PROPERTY_FILTER = [RETENTION_TAG_PROPERTY, RETENTION_PERIOD_PROPERTY, RETENTION_FLAGS_PROPERTY]
|
|
37
|
+
// odataRaw because these are our own constants, not caller values: encoding
|
|
38
|
+
// them would send `Binary%200x3019`, which matches no property. Going through
|
|
39
|
+
// the tag anyway keeps the last hand-built OData string out of the package
|
|
40
|
+
// that exists to stop hand-built OData strings.
|
|
41
|
+
//
|
|
42
|
+
// Joined rather than composed with odataAnyOf: this sits inside
|
|
43
|
+
// `$expand=singleValueExtendedProperties($filter=…)`, where the parentheses
|
|
44
|
+
// odataAnyOf adds would be a change to a request that already works.
|
|
45
|
+
.map((id) => odataFilter `id eq '${odataRaw(id)}'`)
|
|
46
|
+
.join(' or ');
|
|
47
|
+
const GUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
48
|
+
/**
|
|
49
|
+
* Decodes PR_POLICY_TAG's bytes into a GUID string.
|
|
50
|
+
*
|
|
51
|
+
* The bytes are in .NET `Guid` layout — the first three fields little-endian,
|
|
52
|
+
* the last two big-endian — not a flat big-endian read. Reading them flat
|
|
53
|
+
* produces a string that looks like a GUID and is not one: tags read off a real
|
|
54
|
+
* mailbox decode to a valid version-4 GUID under this layout, and to an
|
|
55
|
+
* impossible version nibble when the bytes are read straight through.
|
|
56
|
+
*/
|
|
57
|
+
export function decodeRetentionTag(base64Value) {
|
|
58
|
+
const bytes = Buffer.from(base64Value, 'base64');
|
|
59
|
+
if (bytes.length !== 16)
|
|
60
|
+
return null;
|
|
61
|
+
// `bytes` is freshly allocated per call, so reversing sub-ranges in place is
|
|
62
|
+
// contained, and each range is reversed exactly once.
|
|
63
|
+
const hex = (start, end, littleEndian) => (littleEndian ? bytes.subarray(start, end).reverse() : bytes.subarray(start, end)).toString('hex');
|
|
64
|
+
return [hex(0, 4, true), hex(4, 6, true), hex(6, 8, true), hex(8, 10, false), hex(10, 16, false)].join('-');
|
|
65
|
+
}
|
|
66
|
+
/** Encodes a GUID string back into PR_POLICY_TAG's bytes. Inverse of {@link decodeRetentionTag}. */
|
|
67
|
+
export function encodeRetentionTag(guid) {
|
|
68
|
+
if (!GUID_PATTERN.test(guid)) {
|
|
69
|
+
throw new Error(`Not a GUID: "${guid}". A retention tag is a GUID, e.g. 1b2c3d4e-5f60-4a7b-8c9d-0e1f2a3b4c5d.`);
|
|
70
|
+
}
|
|
71
|
+
const bytes = Buffer.from(guid.replace(/-/g, ''), 'hex');
|
|
72
|
+
// The first three fields are little-endian; the last two are already in order.
|
|
73
|
+
bytes.subarray(0, 4).reverse();
|
|
74
|
+
bytes.subarray(4, 6).reverse();
|
|
75
|
+
bytes.subarray(6, 8).reverse();
|
|
76
|
+
return bytes.toString('base64');
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Reads a folder's retention policy out of its expanded extended properties.
|
|
80
|
+
*
|
|
81
|
+
* Returns `null` when the folder carries no tag. A folder whose policy has been
|
|
82
|
+
* cleared keeps a `PR_RETENTION_FLAGS` of 128, so presence of the properties is
|
|
83
|
+
* not the test — presence of a tag is.
|
|
84
|
+
*/
|
|
85
|
+
export function parseRetentionPolicy(properties) {
|
|
86
|
+
if (!properties?.length)
|
|
87
|
+
return null;
|
|
88
|
+
// Graph lowercases the hex in the ids it returns (`Integer 0x301a`), so match
|
|
89
|
+
// case-insensitively rather than against the constants verbatim.
|
|
90
|
+
const find = (id) => {
|
|
91
|
+
const wanted = id.toLowerCase();
|
|
92
|
+
return properties.find((p) => p.id?.toLowerCase() === wanted)?.value ?? null;
|
|
93
|
+
};
|
|
94
|
+
const rawTag = find(RETENTION_TAG_PROPERTY);
|
|
95
|
+
if (!rawTag)
|
|
96
|
+
return null;
|
|
97
|
+
const tag = decodeRetentionTag(rawTag);
|
|
98
|
+
if (!tag)
|
|
99
|
+
return null;
|
|
100
|
+
const toInt = (value) => {
|
|
101
|
+
if (value === null || value === '')
|
|
102
|
+
return null;
|
|
103
|
+
const n = Number.parseInt(value, 10);
|
|
104
|
+
return Number.isNaN(n) ? null : n;
|
|
105
|
+
};
|
|
106
|
+
return { tag, periodDays: toInt(find(RETENTION_PERIOD_PROPERTY)), flags: toInt(find(RETENTION_FLAGS_PROPERTY)) };
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Builds the `singleValueExtendedProperties` payload for a PATCH.
|
|
110
|
+
*
|
|
111
|
+
* Pass a tag and period to assign a policy, or `null` for both to clear one.
|
|
112
|
+
* `PR_RETENTION_FLAGS` is only ever sent as `null`, on a clear: Exchange owns
|
|
113
|
+
* that value and rewrites whatever is sent.
|
|
114
|
+
*/
|
|
115
|
+
export function buildRetentionProperties(policy) {
|
|
116
|
+
if (policy.tag === null) {
|
|
117
|
+
return [
|
|
118
|
+
{ id: RETENTION_TAG_PROPERTY, value: null },
|
|
119
|
+
{ id: RETENTION_PERIOD_PROPERTY, value: null },
|
|
120
|
+
{ id: RETENTION_FLAGS_PROPERTY, value: null },
|
|
121
|
+
];
|
|
122
|
+
}
|
|
123
|
+
return [
|
|
124
|
+
{ id: RETENTION_TAG_PROPERTY, value: encodeRetentionTag(policy.tag) },
|
|
125
|
+
// Always sent, `null` included. Omitting it leaves whatever period the
|
|
126
|
+
// previous policy wrote, so assigning a "delete after 7 days" tag to a
|
|
127
|
+
// folder that carried a 30-day one would produce a folder reporting the new
|
|
128
|
+
// tag with the old period — a mismatch every read reports as intentional.
|
|
129
|
+
{ id: RETENTION_PERIOD_PROPERTY, value: policy.periodDays === null ? null : String(policy.periodDays) },
|
|
130
|
+
];
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=retention.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retention.js","sourceRoot":"","sources":["../../src/utils/retention.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEnD,0EAA0E;AAC1E,MAAM,CAAC,MAAM,sBAAsB,GAAG,eAAe,CAAC;AACtD,6EAA6E;AAC7E,MAAM,CAAC,MAAM,yBAAyB,GAAG,gBAAgB,CAAC;AAC1D,mFAAmF;AACnF,MAAM,CAAC,MAAM,wBAAwB,GAAG,gBAAgB,CAAC;AAEzD,kFAAkF;AAClF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,sBAAsB,EAAE,yBAAyB,EAAE,wBAAwB,CAAC;IACpH,4EAA4E;IAC5E,8EAA8E;IAC9E,2EAA2E;IAC3E,gDAAgD;IAChD,EAAE;IACF,gEAAgE;IAChE,4EAA4E;IAC5E,qEAAqE;KACpE,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,WAAW,CAAA,UAAU,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC;KACjD,IAAI,CAAC,MAAM,CAAC,CAAC;AAwBhB,MAAM,YAAY,GAAG,iEAAiE,CAAC;AAEvF;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,WAAmB;IACpD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACjD,IAAI,KAAK,CAAC,MAAM,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IACrC,6EAA6E;IAC7E,sDAAsD;IACtD,MAAM,GAAG,GAAG,CAAC,KAAa,EAAE,GAAW,EAAE,YAAqB,EAAU,EAAE,CACxE,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,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