@hiraokahypertools/pst-extractor 0.1.0-alpha.1
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/BTHeap.d.ts +15 -0
- package/dist/BTHeap.js +76 -0
- package/dist/CollectionAsyncProvider.d.ts +15 -0
- package/dist/CollectionAsyncProvider.js +44 -0
- package/dist/KeyedDelay.d.ts +8 -0
- package/dist/KeyedDelay.js +37 -0
- package/dist/LZFu.class.d.ts +12 -0
- package/dist/LZFu.class.js +95 -0
- package/dist/NodeMap.class.d.ts +35 -0
- package/dist/NodeMap.class.js +86 -0
- package/dist/OutlookProperties.d.ts +278 -0
- package/dist/OutlookProperties.js +284 -0
- package/dist/PAUtil.d.ts +17 -0
- package/dist/PAUtil.js +145 -0
- package/dist/PHNodeHeap.d.ts +16 -0
- package/dist/PHNodeHeap.js +2 -0
- package/dist/PHNodeHeapReader.d.ts +6 -0
- package/dist/PHNodeHeapReader.js +5 -0
- package/dist/PHUtil.d.ts +6 -0
- package/dist/PHUtil.js +103 -0
- package/dist/PLMisc.d.ts +8 -0
- package/dist/PLMisc.js +16 -0
- package/dist/PLNode.d.ts +11 -0
- package/dist/PLNode.js +5 -0
- package/dist/PLStore.d.ts +9 -0
- package/dist/PLStore.js +5 -0
- package/dist/PLSubNode.d.ts +8 -0
- package/dist/PLSubNode.js +5 -0
- package/dist/PLUtil.d.ts +29 -0
- package/dist/PLUtil.js +683 -0
- package/dist/PSTActivity.class.d.ts +103 -0
- package/dist/PSTActivity.class.js +144 -0
- package/dist/PSTAppointment.class.d.ts +275 -0
- package/dist/PSTAppointment.class.js +381 -0
- package/dist/PSTAttachment.class.d.ts +168 -0
- package/dist/PSTAttachment.class.js +286 -0
- package/dist/PSTContact.class.d.ts +900 -0
- package/dist/PSTContact.class.js +1253 -0
- package/dist/PSTFile.class.d.ts +144 -0
- package/dist/PSTFile.class.js +221 -0
- package/dist/PSTFolder.class.d.ts +111 -0
- package/dist/PSTFolder.class.js +269 -0
- package/dist/PSTMessage.class.d.ts +773 -0
- package/dist/PSTMessage.class.js +1264 -0
- package/dist/PSTMessageStore.class.d.ts +16 -0
- package/dist/PSTMessageStore.class.js +18 -0
- package/dist/PSTObject.class.d.ts +107 -0
- package/dist/PSTObject.class.js +208 -0
- package/dist/PSTOpts.d.ts +24 -0
- package/dist/PSTOpts.js +2 -0
- package/dist/PSTRecipient.class.d.ts +68 -0
- package/dist/PSTRecipient.class.js +105 -0
- package/dist/PSTTask.class.d.ts +146 -0
- package/dist/PSTTask.class.js +206 -0
- package/dist/PSTUtil.class.d.ts +134 -0
- package/dist/PSTUtil.class.js +804 -0
- package/dist/Property.d.ts +38 -0
- package/dist/Property.js +2 -0
- package/dist/PropertyContext.d.ts +6 -0
- package/dist/PropertyContext.js +2 -0
- package/dist/PropertyContextUtil.d.ts +4 -0
- package/dist/PropertyContextUtil.js +77 -0
- package/dist/PropertyTypeObject.d.ts +12 -0
- package/dist/PropertyTypeObject.js +21 -0
- package/dist/PropertyValueResolver.d.ts +4 -0
- package/dist/PropertyValueResolver.js +2 -0
- package/dist/PropertyValueResolverV1.d.ts +7 -0
- package/dist/PropertyValueResolverV1.js +253 -0
- package/dist/RawProperty.d.ts +8 -0
- package/dist/RawProperty.js +2 -0
- package/dist/RecurrencePattern.class.d.ts +50 -0
- package/dist/RecurrencePattern.class.js +120 -0
- package/dist/RootProvider.d.ts +12 -0
- package/dist/RootProvider.js +2 -0
- package/dist/SingleAsyncProvider.d.ts +5 -0
- package/dist/SingleAsyncProvider.js +30 -0
- package/dist/TableContext.d.ts +4 -0
- package/dist/TableContext.js +2 -0
- package/dist/TableContextUtil.d.ts +4 -0
- package/dist/TableContextUtil.js +147 -0
- package/dist/TableRow.d.ts +6 -0
- package/dist/TableRow.js +2 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +28 -0
- package/dist/msftUuidStringify.d.ts +17 -0
- package/dist/msftUuidStringify.js +48 -0
- package/dist/openPstFile.d.ts +19 -0
- package/dist/openPstFile.js +67 -0
- package/package.json +105 -0
- package/readme.md +16 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PSTFolder = void 0;
|
|
13
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
14
|
+
const OutlookProperties_1 = require("./OutlookProperties");
|
|
15
|
+
const PSTObject_class_1 = require("./PSTObject.class");
|
|
16
|
+
const PSTUtil_class_1 = require("./PSTUtil.class");
|
|
17
|
+
const PAUtil_1 = require("./PAUtil");
|
|
18
|
+
const TableContextUtil_1 = require("./TableContextUtil");
|
|
19
|
+
const PHUtil_1 = require("./PHUtil");
|
|
20
|
+
const CollectionAsyncProvider_1 = require("./CollectionAsyncProvider");
|
|
21
|
+
const SingleAsyncProvider_1 = require("./SingleAsyncProvider");
|
|
22
|
+
/**
|
|
23
|
+
* Represents a folder in the PST File. Allows you to access child folders or items.
|
|
24
|
+
* Items are accessed through a sort of cursor arrangement. This allows for
|
|
25
|
+
* incremental reading of a folder which may have _lots_ of emails.
|
|
26
|
+
* @export
|
|
27
|
+
* @class PSTFolder
|
|
28
|
+
* @extends {PSTObject}
|
|
29
|
+
*/
|
|
30
|
+
class PSTFolder extends PSTObject_class_1.PSTObject {
|
|
31
|
+
/**
|
|
32
|
+
* Creates an instance of PSTFolder.
|
|
33
|
+
* Represents a folder in the PST File. Allows you to access child folders or items.
|
|
34
|
+
* Items are accessed through a sort of cursor arrangement. This allows for
|
|
35
|
+
* incremental reading of a folder which may have _lots_ of emails.
|
|
36
|
+
* @internal
|
|
37
|
+
* @param {PSTFile} rootProvider
|
|
38
|
+
* @param {DescriptorIndexNode} descriptorIndexNode
|
|
39
|
+
* @param {Map<number, PSTDescriptorItem>} [localDescriptorItems]
|
|
40
|
+
* @memberof PSTFolder
|
|
41
|
+
*/
|
|
42
|
+
constructor(rootProvider, node, subNode, propertyFinder) {
|
|
43
|
+
super(rootProvider, node, subNode, propertyFinder);
|
|
44
|
+
this._subFoldersProvider = new SingleAsyncProvider_1.SingleAsyncProvider();
|
|
45
|
+
this._emailsProvider = new SingleAsyncProvider_1.SingleAsyncProvider();
|
|
46
|
+
}
|
|
47
|
+
getEmailsProvider() {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
return this._emailsProvider.getOrCreate(() => __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
const targets = [];
|
|
51
|
+
if (this.getNodeType() === PSTUtil_class_1.PSTUtil.NID_TYPE_SEARCH_FOLDER) {
|
|
52
|
+
// some folder types don't have children:
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
// trying to read emailsTable PSTTable7C
|
|
56
|
+
const contentsTableNode = this._node.getSiblingNode(PSTUtil_class_1.PSTUtil.NID_TYPE_CONTENTS_TABLE);
|
|
57
|
+
if (contentsTableNode !== undefined) {
|
|
58
|
+
const contentsTableNodeReader = contentsTableNode.getSubNode();
|
|
59
|
+
const heap = yield (0, PHUtil_1.getHeapFrom)(contentsTableNodeReader);
|
|
60
|
+
const tc = yield (0, TableContextUtil_1.getTableContext)(heap, this._rootProvider.resolver);
|
|
61
|
+
const rows = yield tc.rows();
|
|
62
|
+
const orderOfNodes = [];
|
|
63
|
+
for (let row of rows) {
|
|
64
|
+
const props = (0, PAUtil_1.createPropertyFinder)(yield row.list());
|
|
65
|
+
const prop = props.findByKey(0x67f2);
|
|
66
|
+
if (prop !== undefined && typeof prop.value === 'number') {
|
|
67
|
+
orderOfNodes.push({ nodeId: prop.value, propertyFinder: props });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const childNodeIdMap = new Map(this._node.getChildren()
|
|
71
|
+
.map(node => [node.nodeId, node]));
|
|
72
|
+
for (let { nodeId, propertyFinder } of orderOfNodes) {
|
|
73
|
+
const found = childNodeIdMap.get(nodeId);
|
|
74
|
+
if (found !== undefined) {
|
|
75
|
+
targets.push({
|
|
76
|
+
node: found,
|
|
77
|
+
propertyFinder: propertyFinder,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
//console.log("fallback");
|
|
84
|
+
// fallback to children as listed in the descriptor b-tree
|
|
85
|
+
for (let node of this._node.getChildren()) {
|
|
86
|
+
if (this.getNodeType(node.nodeId) === PSTUtil_class_1.PSTUtil.NID_TYPE_NORMAL_MESSAGE) {
|
|
87
|
+
targets.push({ node, propertyFinder: undefined });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return new CollectionAsyncProvider_1.CollectionAsyncProvider(targets.length, (index) => __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
if (!(index in targets)) {
|
|
94
|
+
throw new RangeError(`email index ${index} out of range. maximum index is ${targets.length - 1}.`);
|
|
95
|
+
}
|
|
96
|
+
return yield this._rootProvider.getItemOf(targets[index].node, targets[index].node.getSubNode(), undefined // targets[index].propertyFinder
|
|
97
|
+
);
|
|
98
|
+
// Some important properties are not provided thru table context, like:
|
|
99
|
+
//
|
|
100
|
+
// - msg.senderName
|
|
101
|
+
// - msg.sentRepresentingEmailAddress
|
|
102
|
+
// - appt.localeId
|
|
103
|
+
// - contact.initials
|
|
104
|
+
// - activity.bodyPrefix
|
|
105
|
+
//
|
|
106
|
+
// Thus we need to load full set of properties
|
|
107
|
+
// from property context of corresponding sub node.
|
|
108
|
+
}));
|
|
109
|
+
}));
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
getSubFoldersProvider() {
|
|
113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
return this._subFoldersProvider.getOrCreate(() => __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
try {
|
|
116
|
+
const targets = [];
|
|
117
|
+
for (let node of this._node.getChildren()) {
|
|
118
|
+
const nodeType = this.getNodeType(node.nodeId);
|
|
119
|
+
if (false
|
|
120
|
+
|| nodeType === PSTUtil_class_1.PSTUtil.NID_TYPE_NORMAL_FOLDER) {
|
|
121
|
+
targets.push(node);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return new CollectionAsyncProvider_1.CollectionAsyncProvider(targets.length, (index) => __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
if (!(index in targets)) {
|
|
126
|
+
throw new RangeError(`folder index ${index} out of range. maximum index is ${targets.length - 1}.`);
|
|
127
|
+
}
|
|
128
|
+
return yield this._rootProvider.getFolderOf(targets[index]);
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
131
|
+
catch (err) {
|
|
132
|
+
console.error("PSTFolder::getSubFolders Can't get child folders for folder " +
|
|
133
|
+
this.displayName +
|
|
134
|
+
'\n' +
|
|
135
|
+
err);
|
|
136
|
+
throw err;
|
|
137
|
+
}
|
|
138
|
+
}));
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Get folders in one fell swoop, since there's not usually thousands of them.
|
|
143
|
+
* @returns {PSTFolder[]}
|
|
144
|
+
* @memberof PSTFolder
|
|
145
|
+
*/
|
|
146
|
+
getSubFolders() {
|
|
147
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
148
|
+
return yield (yield this.getSubFoldersProvider()).all();
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
getSubFolder(index) {
|
|
152
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
+
return yield (yield this.getSubFoldersProvider()).get(index);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* The number of child folders in this folder
|
|
158
|
+
* @readonly
|
|
159
|
+
* @type {number}
|
|
160
|
+
* @memberof PSTFolder
|
|
161
|
+
*/
|
|
162
|
+
getSubFolderCount() {
|
|
163
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
return (yield this.getSubFoldersProvider()).count;
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Number of emails in this folder
|
|
169
|
+
* @readonly
|
|
170
|
+
* @type {number}
|
|
171
|
+
* @memberof PSTFolder
|
|
172
|
+
*/
|
|
173
|
+
getEmailCount() {
|
|
174
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
+
return (yield this.getEmailsProvider()).count;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
getEmail(index) {
|
|
179
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
+
return (yield (yield this.getEmailsProvider()).get(index));
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
getEmails() {
|
|
184
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
+
return (yield (yield this.getEmailsProvider()).all());
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Contains a constant that indicates the folder type.
|
|
190
|
+
* https://msdn.microsoft.com/en-us/library/office/cc815373.aspx
|
|
191
|
+
* @readonly
|
|
192
|
+
* @type {number}
|
|
193
|
+
* @memberof PSTFolder
|
|
194
|
+
*/
|
|
195
|
+
get folderType() {
|
|
196
|
+
return this.getIntItem(OutlookProperties_1.OutlookProperties.PR_FOLDER_TYPE);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Contains the number of messages in a folder, as computed by the message store.
|
|
200
|
+
* For a number calculated by the library use getEmailCount
|
|
201
|
+
* @readonly
|
|
202
|
+
* @type {number}
|
|
203
|
+
* @memberof PSTFolder
|
|
204
|
+
*/
|
|
205
|
+
get contentCount() {
|
|
206
|
+
return this.getIntItem(OutlookProperties_1.OutlookProperties.PR_CONTENT_COUNT);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Contains the number of unread messages in a folder, as computed by the message store.
|
|
210
|
+
* https://msdn.microsoft.com/en-us/library/office/cc841964.aspx
|
|
211
|
+
* @readonly
|
|
212
|
+
* @type {number}
|
|
213
|
+
* @memberof PSTFolder
|
|
214
|
+
*/
|
|
215
|
+
get unreadCount() {
|
|
216
|
+
return this.getIntItem(OutlookProperties_1.OutlookProperties.PR_CONTENT_UNREAD);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Contains TRUE if a folder contains subfolders.
|
|
220
|
+
* once again, read from the PST, use getSubFolderCount if you want to know
|
|
221
|
+
* @readonly
|
|
222
|
+
* @type {boolean}
|
|
223
|
+
* @memberof PSTFolder
|
|
224
|
+
*/
|
|
225
|
+
get hasSubfolders() {
|
|
226
|
+
return false
|
|
227
|
+
|| this.getBooleanItem(OutlookProperties_1.OutlookProperties.PR_SUBFOLDERS)
|
|
228
|
+
|| this.getIntItem(OutlookProperties_1.OutlookProperties.PR_SUBFOLDERS) != 0;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Contains a text string describing the type of a folder. Although this property is
|
|
232
|
+
* generally ignored, versions of Microsoft® Exchange Server prior to Exchange Server
|
|
233
|
+
* 2003 Mailbox Manager expect this property to be present.
|
|
234
|
+
* https://msdn.microsoft.com/en-us/library/office/cc839839.aspx
|
|
235
|
+
* @readonly
|
|
236
|
+
* @type {string}
|
|
237
|
+
* @memberof PSTFolder
|
|
238
|
+
*/
|
|
239
|
+
get containerClass() {
|
|
240
|
+
return this.getStringItem(OutlookProperties_1.OutlookProperties.PR_CONTAINER_CLASS);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Contains a bitmask of flags describing capabilities of an address book container.
|
|
244
|
+
* https://msdn.microsoft.com/en-us/library/office/cc839610.aspx
|
|
245
|
+
* @readonly
|
|
246
|
+
* @type {number}
|
|
247
|
+
* @memberof PSTFolder
|
|
248
|
+
*/
|
|
249
|
+
get containerFlags() {
|
|
250
|
+
return this.getIntItem(OutlookProperties_1.OutlookProperties.PR_CONTAINER_FLAGS);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* JSON stringify the object properties.
|
|
254
|
+
* @returns {string}
|
|
255
|
+
* @memberof PSTFolder
|
|
256
|
+
*/
|
|
257
|
+
toJSON() {
|
|
258
|
+
const clone = Object.assign({
|
|
259
|
+
folderType: this.folderType,
|
|
260
|
+
contentCount: this.contentCount,
|
|
261
|
+
unreadCount: this.unreadCount,
|
|
262
|
+
hasSubfolders: this.hasSubfolders,
|
|
263
|
+
containerClass: this.containerClass,
|
|
264
|
+
containerFlags: this.containerFlags,
|
|
265
|
+
}, this);
|
|
266
|
+
return clone;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
exports.PSTFolder = PSTFolder;
|