pst-extractor 1.8.0 → 1.10.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 (64) hide show
  1. package/dist/ColumnDescriptor.class.d.ts +26 -26
  2. package/dist/ColumnDescriptor.class.js +51 -48
  3. package/dist/DescriptorIndexNode.class.d.ts +25 -26
  4. package/dist/DescriptorIndexNode.class.js +53 -53
  5. package/dist/LZFu.class.d.ts +11 -12
  6. package/dist/LZFu.class.js +95 -95
  7. package/dist/NodeInfo.class.d.ts +33 -33
  8. package/dist/NodeInfo.class.js +52 -52
  9. package/dist/NodeMap.class.d.ts +35 -35
  10. package/dist/NodeMap.class.js +86 -83
  11. package/dist/OffsetIndexItem.class.d.ts +23 -24
  12. package/dist/OffsetIndexItem.class.js +45 -45
  13. package/dist/OutlookProperties.d.ts +275 -275
  14. package/dist/OutlookProperties.js +281 -281
  15. package/dist/PSTActivity.class.d.ts +103 -103
  16. package/dist/PSTActivity.class.js +144 -144
  17. package/dist/PSTAppointment.class.d.ts +270 -271
  18. package/dist/PSTAppointment.class.js +376 -376
  19. package/dist/PSTAttachment.class.d.ts +172 -172
  20. package/dist/PSTAttachment.class.js +317 -314
  21. package/dist/PSTContact.class.d.ts +884 -884
  22. package/dist/PSTContact.class.js +1227 -1227
  23. package/dist/PSTDescriptorItem.class.d.ts +45 -46
  24. package/dist/PSTDescriptorItem.class.js +99 -96
  25. package/dist/PSTFile.class.d.ts +215 -216
  26. package/dist/PSTFile.class.js +818 -792
  27. package/dist/PSTFolder.class.d.ts +129 -129
  28. package/dist/PSTFolder.class.js +318 -307
  29. package/dist/PSTMessage.class.d.ts +788 -789
  30. package/dist/PSTMessage.class.js +1321 -1318
  31. package/dist/PSTMessageStore.class.d.ts +13 -13
  32. package/dist/PSTMessageStore.class.js +17 -17
  33. package/dist/PSTNodeInputStream.class.d.ts +122 -123
  34. package/dist/PSTNodeInputStream.class.js +514 -488
  35. package/dist/PSTObject.class.d.ts +133 -134
  36. package/dist/PSTObject.class.js +326 -323
  37. package/dist/PSTRecipient.class.d.ts +65 -65
  38. package/dist/PSTRecipient.class.js +103 -103
  39. package/dist/PSTTable.class.d.ts +52 -52
  40. package/dist/PSTTable.class.js +175 -172
  41. package/dist/PSTTable7C.class.d.ts +45 -45
  42. package/dist/PSTTable7C.class.js +281 -278
  43. package/dist/PSTTableBC.class.d.ts +31 -31
  44. package/dist/PSTTableBC.class.js +111 -108
  45. package/dist/PSTTableItem.class.d.ts +47 -48
  46. package/dist/PSTTableItem.class.js +124 -121
  47. package/dist/PSTTask.class.d.ts +146 -146
  48. package/dist/PSTTask.class.js +205 -205
  49. package/dist/PSTUtil.class.d.ts +134 -135
  50. package/dist/PSTUtil.class.js +795 -790
  51. package/dist/RecurrencePattern.class.d.ts +49 -50
  52. package/dist/RecurrencePattern.class.js +120 -120
  53. package/dist/index.d.ts +6 -6
  54. package/dist/index.js +15 -15
  55. package/example/package.json +7 -7
  56. package/example/test-min.ts +31 -12
  57. package/example/{test-mem.ts → test.ts} +38 -30
  58. package/example/testdata/output.txt +278 -0
  59. package/example/testdata/outputBody.txt +3404 -0
  60. package/example/yarn.lock +112 -50
  61. package/junit.xml +36 -36
  62. package/package.json +28 -27
  63. package/readme.md +1 -3
  64. package/example/test-max.ts +0 -251
@@ -1,307 +1,318 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PSTFolder = void 0;
4
- /* eslint-disable @typescript-eslint/no-explicit-any */
5
- const long = require("long");
6
- const OutlookProperties_1 = require("./OutlookProperties");
7
- const PSTNodeInputStream_class_1 = require("./PSTNodeInputStream.class");
8
- const PSTTable7C_class_1 = require("./PSTTable7C.class");
9
- const PSTObject_class_1 = require("./PSTObject.class");
10
- const PSTUtil_class_1 = require("./PSTUtil.class");
11
- /**
12
- * Represents a folder in the PST File. Allows you to access child folders or items.
13
- * Items are accessed through a sort of cursor arrangement. This allows for
14
- * incremental reading of a folder which may have _lots_ of emails.
15
- * @export
16
- * @class PSTFolder
17
- * @extends {PSTObject}
18
- */
19
- class PSTFolder extends PSTObject_class_1.PSTObject {
20
- /**
21
- * Creates an instance of PSTFolder.
22
- * Represents a folder in the PST File. Allows you to access child folders or items.
23
- * Items are accessed through a sort of cursor arrangement. This allows for
24
- * incremental reading of a folder which may have _lots_ of emails.
25
- * @param {PSTFile} pstFile
26
- * @param {DescriptorIndexNode} descriptorIndexNode
27
- * @param {PSTTableBC} [table]
28
- * @param {Map<number, PSTDescriptorItem>} [localDescriptorItems]
29
- * @memberof PSTFolder
30
- */
31
- constructor(pstFile, descriptorIndexNode, table, localDescriptorItems) {
32
- super(pstFile, descriptorIndexNode);
33
- this.currentEmailIndex = 0;
34
- this.subfoldersTable = null;
35
- this.emailsTable = null;
36
- this.fallbackEmailsTable = null;
37
- if (table) {
38
- // pre-populate folder object with values
39
- this.prePopulate(descriptorIndexNode, table, localDescriptorItems);
40
- }
41
- }
42
- /**
43
- * Get folders in one fell swoop, since there's not usually thousands of them.
44
- * @returns {PSTFolder[]}
45
- * @memberof PSTFolder
46
- */
47
- getSubFolders() {
48
- const output = [];
49
- try {
50
- this.initSubfoldersTable();
51
- if (this.subfoldersTable) {
52
- const itemMapSet = this.subfoldersTable.getItems();
53
- for (const itemMap of itemMapSet) {
54
- const item = itemMap.get(26610);
55
- if (item) {
56
- output.push(PSTUtil_class_1.PSTUtil.detectAndLoadPSTObject(this.pstFile, long.fromNumber(item.entryValueReference)));
57
- }
58
- }
59
- }
60
- }
61
- catch (err) {
62
- console.error("PSTFolder::getSubFolders Can't get child folders for folder " +
63
- this.displayName +
64
- '\n' +
65
- err);
66
- throw err;
67
- }
68
- return output;
69
- }
70
- /**
71
- * Load subfolders table.
72
- * @private
73
- * @returns
74
- * @memberof PSTFolder
75
- */
76
- initSubfoldersTable() {
77
- if (this.subfoldersTable) {
78
- return;
79
- }
80
- if (!this.descriptorIndexNode) {
81
- throw new Error('PSTFolder::initSubfoldersTable descriptorIndexNode is null');
82
- }
83
- const folderDescriptorIndex = long.fromValue(this.descriptorIndexNode.descriptorIdentifier + 11);
84
- try {
85
- const folderDescriptor = this.pstFile.getDescriptorIndexNode(folderDescriptorIndex);
86
- let tmp = undefined;
87
- if (folderDescriptor.localDescriptorsOffsetIndexIdentifier.greaterThan(0)) {
88
- tmp = this.pstFile.getPSTDescriptorItems(folderDescriptor.localDescriptorsOffsetIndexIdentifier);
89
- }
90
- const offsetIndexItem = this.pstFile.getOffsetIndexNode(folderDescriptor.dataOffsetIndexIdentifier);
91
- const pstNodeInputStream = new PSTNodeInputStream_class_1.PSTNodeInputStream(this.pstFile, offsetIndexItem);
92
- this.subfoldersTable = new PSTTable7C_class_1.PSTTable7C(pstNodeInputStream, tmp);
93
- }
94
- catch (err) {
95
- console.error("PSTFolder::initSubfoldersTable Can't get child folders for folder " +
96
- this.displayName +
97
- '\n' +
98
- err);
99
- throw err;
100
- }
101
- }
102
- // get all of the children
103
- initEmailsTable() {
104
- if (this.emailsTable || this.fallbackEmailsTable) {
105
- return;
106
- }
107
- // some folder types don't have children:
108
- if (this.getNodeType() == PSTUtil_class_1.PSTUtil.NID_TYPE_SEARCH_FOLDER) {
109
- return;
110
- }
111
- if (!this.descriptorIndexNode) {
112
- throw new Error('PSTFolder::initEmailsTable descriptorIndexNode is null');
113
- }
114
- try {
115
- const folderDescriptorIndex = this.descriptorIndexNode.descriptorIdentifier + 12;
116
- const folderDescriptor = this.pstFile.getDescriptorIndexNode(long.fromNumber(folderDescriptorIndex));
117
- let tmp = undefined;
118
- if (folderDescriptor.localDescriptorsOffsetIndexIdentifier.greaterThan(0)) {
119
- tmp = this.pstFile.getPSTDescriptorItems(folderDescriptor.localDescriptorsOffsetIndexIdentifier);
120
- }
121
- const offsetIndexItem = this.pstFile.getOffsetIndexNode(folderDescriptor.dataOffsetIndexIdentifier);
122
- const pstNodeInputStream = new PSTNodeInputStream_class_1.PSTNodeInputStream(this.pstFile, offsetIndexItem);
123
- this.emailsTable = new PSTTable7C_class_1.PSTTable7C(pstNodeInputStream, tmp, 0x67f2);
124
- }
125
- catch (err) {
126
- // fallback to children as listed in the descriptor b-tree
127
- // console.log(`PSTFolder::initEmailsTable Can't get child folders for folder {this.displayName}, resorting to using alternate tree`);
128
- const tree = this.pstFile.getChildDescriptorTree();
129
- this.fallbackEmailsTable = [];
130
- const allChildren = tree.get(this.descriptorIndexNode.descriptorIdentifier);
131
- if (allChildren) {
132
- // remove items that aren't messages
133
- for (const node of allChildren) {
134
- if (node != null &&
135
- this.getNodeType(node.descriptorIdentifier) ==
136
- PSTUtil_class_1.PSTUtil.NID_TYPE_NORMAL_MESSAGE) {
137
- this.fallbackEmailsTable.push(node);
138
- }
139
- }
140
- }
141
- }
142
- }
143
- /**
144
- * Get the next child of this folder. As there could be thousands of emails, we have these
145
- * kind of cursor operations.
146
- * @returns {*}
147
- * @memberof PSTFolder
148
- */
149
- getNextChild() {
150
- this.initEmailsTable();
151
- if (this.emailsTable) {
152
- if (this.currentEmailIndex == this.contentCount) {
153
- // no more!
154
- return null;
155
- }
156
- // get the emails from the rows in the main email table
157
- const rows = this.emailsTable.getItems(this.currentEmailIndex, 1);
158
- const emailRow = rows[0].get(0x67f2);
159
- if ((emailRow && emailRow.itemIndex == -1) || !emailRow) {
160
- // no more!
161
- return null;
162
- }
163
- const childDescriptor = this.pstFile.getDescriptorIndexNode(long.fromNumber(emailRow.entryValueReference));
164
- const child = PSTUtil_class_1.PSTUtil.detectAndLoadPSTObject(this.pstFile, childDescriptor);
165
- this.currentEmailIndex++;
166
- return child;
167
- }
168
- else if (this.fallbackEmailsTable) {
169
- if (this.currentEmailIndex >= this.contentCount ||
170
- this.currentEmailIndex >= this.fallbackEmailsTable.length) {
171
- // no more!
172
- return null;
173
- }
174
- const childDescriptor = this.fallbackEmailsTable[this.currentEmailIndex];
175
- const child = PSTUtil_class_1.PSTUtil.detectAndLoadPSTObject(this.pstFile, childDescriptor);
176
- this.currentEmailIndex++;
177
- return child;
178
- }
179
- return null;
180
- }
181
- /**
182
- * Move the internal folder cursor to the desired position position 0 is before the first record.
183
- * @param {number} newIndex
184
- * @returns
185
- * @memberof PSTFolder
186
- */
187
- moveChildCursorTo(newIndex) {
188
- this.initEmailsTable();
189
- if (newIndex < 1) {
190
- this.currentEmailIndex = 0;
191
- return;
192
- }
193
- if (newIndex > this.contentCount) {
194
- newIndex = this.contentCount;
195
- }
196
- this.currentEmailIndex = newIndex;
197
- }
198
- /**
199
- * The number of child folders in this folder
200
- * @readonly
201
- * @type {number}
202
- * @memberof PSTFolder
203
- */
204
- get subFolderCount() {
205
- this.initSubfoldersTable();
206
- if (this.subfoldersTable != null) {
207
- return this.subfoldersTable.rowCount;
208
- }
209
- else {
210
- return 0;
211
- }
212
- }
213
- /**
214
- * Number of emails in this folder
215
- * @readonly
216
- * @type {number}
217
- * @memberof PSTFolder
218
- */
219
- get emailCount() {
220
- this.initEmailsTable();
221
- if (this.emailsTable == null) {
222
- return -1;
223
- }
224
- return this.emailsTable.rowCount;
225
- }
226
- /**
227
- * Contains a constant that indicates the folder type.
228
- * https://msdn.microsoft.com/en-us/library/office/cc815373.aspx
229
- * @readonly
230
- * @type {number}
231
- * @memberof PSTFolder
232
- */
233
- get folderType() {
234
- return this.getIntItem(OutlookProperties_1.OutlookProperties.PR_FOLDER_TYPE);
235
- }
236
- /**
237
- * Contains the number of messages in a folder, as computed by the message store.
238
- * For a number calculated by the library use getEmailCount
239
- * @readonly
240
- * @type {number}
241
- * @memberof PSTFolder
242
- */
243
- get contentCount() {
244
- return this.getIntItem(OutlookProperties_1.OutlookProperties.PR_CONTENT_COUNT);
245
- }
246
- /**
247
- * Contains the number of unread messages in a folder, as computed by the message store.
248
- * https://msdn.microsoft.com/en-us/library/office/cc841964.aspx
249
- * @readonly
250
- * @type {number}
251
- * @memberof PSTFolder
252
- */
253
- get unreadCount() {
254
- return this.getIntItem(OutlookProperties_1.OutlookProperties.PR_CONTENT_UNREAD);
255
- }
256
- /**
257
- * Contains TRUE if a folder contains subfolders.
258
- * once again, read from the PST, use getSubFolderCount if you want to know
259
- * @readonly
260
- * @type {boolean}
261
- * @memberof PSTFolder
262
- */
263
- get hasSubfolders() {
264
- return this.getIntItem(OutlookProperties_1.OutlookProperties.PR_SUBFOLDERS) != 0;
265
- }
266
- /**
267
- * Contains a text string describing the type of a folder. Although this property is
268
- * generally ignored, versions of Microsoft® Exchange Server prior to Exchange Server
269
- * 2003 Mailbox Manager expect this property to be present.
270
- * https://msdn.microsoft.com/en-us/library/office/cc839839.aspx
271
- * @readonly
272
- * @type {string}
273
- * @memberof PSTFolder
274
- */
275
- get containerClass() {
276
- return this.getStringItem(OutlookProperties_1.OutlookProperties.PR_CONTAINER_CLASS);
277
- }
278
- /**
279
- * Contains a bitmask of flags describing capabilities of an address book container.
280
- * https://msdn.microsoft.com/en-us/library/office/cc839610.aspx
281
- * @readonly
282
- * @type {number}
283
- * @memberof PSTFolder
284
- */
285
- get containerFlags() {
286
- return this.getIntItem(OutlookProperties_1.OutlookProperties.PR_CONTAINER_FLAGS);
287
- }
288
- /**
289
- * JSON stringify the object properties.
290
- * @returns {string}
291
- * @memberof PSTFolder
292
- */
293
- toJSON() {
294
- const clone = Object.assign({
295
- subFolderCount: this.subFolderCount,
296
- emailCount: this.emailCount,
297
- folderType: this.folderType,
298
- contentCount: this.contentCount,
299
- unreadCount: this.unreadCount,
300
- hasSubfolders: this.hasSubfolders,
301
- containerClass: this.containerClass,
302
- containerFlags: this.containerFlags,
303
- }, this);
304
- return clone;
305
- }
306
- }
307
- exports.PSTFolder = PSTFolder;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PSTFolder = void 0;
7
+ /* eslint-disable @typescript-eslint/no-explicit-any */
8
+ const long_1 = __importDefault(require("long"));
9
+ const OutlookProperties_1 = require("./OutlookProperties");
10
+ const PSTNodeInputStream_class_1 = require("./PSTNodeInputStream.class");
11
+ const PSTTable7C_class_1 = require("./PSTTable7C.class");
12
+ const PSTObject_class_1 = require("./PSTObject.class");
13
+ const PSTUtil_class_1 = require("./PSTUtil.class");
14
+ /**
15
+ * Represents a folder in the PST File. Allows you to access child folders or items.
16
+ * Items are accessed through a sort of cursor arrangement. This allows for
17
+ * incremental reading of a folder which may have _lots_ of emails.
18
+ * @export
19
+ * @class PSTFolder
20
+ * @extends {PSTObject}
21
+ */
22
+ class PSTFolder extends PSTObject_class_1.PSTObject {
23
+ /**
24
+ * Creates an instance of PSTFolder.
25
+ * Represents a folder in the PST File. Allows you to access child folders or items.
26
+ * Items are accessed through a sort of cursor arrangement. This allows for
27
+ * incremental reading of a folder which may have _lots_ of emails.
28
+ * @param {PSTFile} pstFile
29
+ * @param {DescriptorIndexNode} descriptorIndexNode
30
+ * @param {PSTTableBC} [table]
31
+ * @param {Map<number, PSTDescriptorItem>} [localDescriptorItems]
32
+ * @memberof PSTFolder
33
+ */
34
+ constructor(pstFile, descriptorIndexNode, table, localDescriptorItems) {
35
+ super(pstFile, descriptorIndexNode);
36
+ this.currentEmailIndex = 0;
37
+ this.subfoldersTable = null;
38
+ this.emailsTable = null;
39
+ this.fallbackEmailsTable = null;
40
+ if (table) {
41
+ // pre-populate folder object with values
42
+ this.prePopulate(descriptorIndexNode, table, localDescriptorItems);
43
+ }
44
+ }
45
+ /**
46
+ * Get folders in one fell swoop, since there's not usually thousands of them.
47
+ * @returns {PSTFolder[]}
48
+ * @memberof PSTFolder
49
+ */
50
+ getSubFolders() {
51
+ const output = [];
52
+ try {
53
+ this.initSubfoldersTable();
54
+ if (this.subfoldersTable) {
55
+ const itemMapSet = this.subfoldersTable.getItems();
56
+ for (const itemMap of itemMapSet) {
57
+ const item = itemMap.get(26610);
58
+ if (item) {
59
+ output.push(PSTUtil_class_1.PSTUtil.detectAndLoadPSTObject(this.pstFile, long_1.default.fromNumber(item.entryValueReference)));
60
+ }
61
+ }
62
+ }
63
+ }
64
+ catch (err) {
65
+ console.error("PSTFolder::getSubFolders Can't get child folders for folder " +
66
+ this.displayName +
67
+ '\n' +
68
+ err);
69
+ throw err;
70
+ }
71
+ return output;
72
+ }
73
+ /**
74
+ * Load subfolders table.
75
+ * @private
76
+ * @returns
77
+ * @memberof PSTFolder
78
+ */
79
+ initSubfoldersTable() {
80
+ if (this.subfoldersTable) {
81
+ return;
82
+ }
83
+ if (!this.descriptorIndexNode) {
84
+ throw new Error('PSTFolder::initSubfoldersTable descriptorIndexNode is null');
85
+ }
86
+ const folderDescriptorIndex = long_1.default.fromValue(this.descriptorIndexNode.descriptorIdentifier + 11);
87
+ try {
88
+ const folderDescriptor = this.pstFile.getDescriptorIndexNode(folderDescriptorIndex);
89
+ let tmp = undefined;
90
+ if (folderDescriptor.localDescriptorsOffsetIndexIdentifier.greaterThan(0)) {
91
+ tmp = this.pstFile.getPSTDescriptorItems(folderDescriptor.localDescriptorsOffsetIndexIdentifier);
92
+ }
93
+ const offsetIndexItem = this.pstFile.getOffsetIndexNode(folderDescriptor.dataOffsetIndexIdentifier);
94
+ const pstNodeInputStream = new PSTNodeInputStream_class_1.PSTNodeInputStream(this.pstFile, offsetIndexItem);
95
+ this.subfoldersTable = new PSTTable7C_class_1.PSTTable7C(pstNodeInputStream, tmp);
96
+ }
97
+ catch (err) {
98
+ console.error("PSTFolder::initSubfoldersTable Can't get child folders for folder " +
99
+ this.displayName +
100
+ '\n' +
101
+ err);
102
+ throw err;
103
+ }
104
+ }
105
+ // get all of the children
106
+ initEmailsTable() {
107
+ if (this.emailsTable || this.fallbackEmailsTable) {
108
+ return;
109
+ }
110
+ // some folder types don't have children:
111
+ if (this.getNodeType() == PSTUtil_class_1.PSTUtil.NID_TYPE_SEARCH_FOLDER) {
112
+ return;
113
+ }
114
+ if (!this.descriptorIndexNode) {
115
+ throw new Error('PSTFolder::initEmailsTable descriptorIndexNode is null');
116
+ }
117
+ try {
118
+ const folderDescriptorIndex = this.descriptorIndexNode.descriptorIdentifier + 12;
119
+ const folderDescriptor = this.pstFile.getDescriptorIndexNode(long_1.default.fromNumber(folderDescriptorIndex));
120
+ let tmp = undefined;
121
+ if (folderDescriptor.localDescriptorsOffsetIndexIdentifier.greaterThan(0)) {
122
+ tmp = this.pstFile.getPSTDescriptorItems(folderDescriptor.localDescriptorsOffsetIndexIdentifier);
123
+ }
124
+ const offsetIndexItem = this.pstFile.getOffsetIndexNode(folderDescriptor.dataOffsetIndexIdentifier);
125
+ const pstNodeInputStream = new PSTNodeInputStream_class_1.PSTNodeInputStream(this.pstFile, offsetIndexItem);
126
+ this.emailsTable = new PSTTable7C_class_1.PSTTable7C(pstNodeInputStream, tmp, 0x67f2);
127
+ }
128
+ catch (err) {
129
+ // fallback to children as listed in the descriptor b-tree
130
+ // console.log(`PSTFolder::initEmailsTable Can't get child folders for folder {this.displayName}, resorting to using alternate tree`);
131
+ const tree = this.pstFile.getChildDescriptorTree();
132
+ this.fallbackEmailsTable = [];
133
+ const allChildren = tree.get(this.descriptorIndexNode.descriptorIdentifier);
134
+ if (allChildren) {
135
+ // remove items that aren't messages
136
+ for (const node of allChildren) {
137
+ if (node != null &&
138
+ this.getNodeType(node.descriptorIdentifier) ==
139
+ PSTUtil_class_1.PSTUtil.NID_TYPE_NORMAL_MESSAGE) {
140
+ this.fallbackEmailsTable.push(node);
141
+ }
142
+ }
143
+ }
144
+ }
145
+ }
146
+ /**
147
+ * Get the next child of this folder. As there could be thousands of emails, we have these
148
+ * kind of cursor operations.
149
+ * @returns {*}
150
+ * @memberof PSTFolder
151
+ */
152
+ getNextChild() {
153
+ this.initEmailsTable();
154
+ if (this.emailsTable) {
155
+ if (this.currentEmailIndex == this.contentCount) {
156
+ // no more!
157
+ return null;
158
+ }
159
+ // get the emails from the rows in the main email table
160
+ const rows = this.emailsTable.getItems(this.currentEmailIndex, 1);
161
+ const emailRow = rows[0].get(0x67f2);
162
+ if ((emailRow && emailRow.itemIndex == -1) || !emailRow) {
163
+ // no more!
164
+ return null;
165
+ }
166
+ const childDescriptor = this.pstFile.getDescriptorIndexNode(long_1.default.fromNumber(emailRow.entryValueReference));
167
+ let child;
168
+ try {
169
+ child = PSTUtil_class_1.PSTUtil.detectAndLoadPSTObject(this.pstFile, childDescriptor);
170
+ }
171
+ catch (err) {
172
+ console.log('Exception Error in No: ', this.currentEmailIndex);
173
+ this.currentEmailIndex++;
174
+ return this.getNextChild();
175
+ }
176
+ this.currentEmailIndex++;
177
+ return child;
178
+ }
179
+ else if (this.fallbackEmailsTable) {
180
+ if (this.currentEmailIndex >= this.contentCount ||
181
+ this.currentEmailIndex >= this.fallbackEmailsTable.length) {
182
+ // no more!
183
+ return null;
184
+ }
185
+ const childDescriptor = this.fallbackEmailsTable[this.currentEmailIndex];
186
+ const child = PSTUtil_class_1.PSTUtil.detectAndLoadPSTObject(this.pstFile, childDescriptor);
187
+ this.currentEmailIndex++;
188
+ return child;
189
+ }
190
+ return null;
191
+ }
192
+ /**
193
+ * Move the internal folder cursor to the desired position position 0 is before the first record.
194
+ * @param {number} newIndex
195
+ * @returns
196
+ * @memberof PSTFolder
197
+ */
198
+ moveChildCursorTo(newIndex) {
199
+ this.initEmailsTable();
200
+ if (newIndex < 1) {
201
+ this.currentEmailIndex = 0;
202
+ return;
203
+ }
204
+ if (newIndex > this.contentCount) {
205
+ newIndex = this.contentCount;
206
+ }
207
+ this.currentEmailIndex = newIndex;
208
+ }
209
+ /**
210
+ * The number of child folders in this folder
211
+ * @readonly
212
+ * @type {number}
213
+ * @memberof PSTFolder
214
+ */
215
+ get subFolderCount() {
216
+ this.initSubfoldersTable();
217
+ if (this.subfoldersTable != null) {
218
+ return this.subfoldersTable.rowCount;
219
+ }
220
+ else {
221
+ return 0;
222
+ }
223
+ }
224
+ /**
225
+ * Number of emails in this folder
226
+ * @readonly
227
+ * @type {number}
228
+ * @memberof PSTFolder
229
+ */
230
+ get emailCount() {
231
+ this.initEmailsTable();
232
+ if (this.emailsTable == null) {
233
+ return -1;
234
+ }
235
+ return this.emailsTable.rowCount;
236
+ }
237
+ /**
238
+ * Contains a constant that indicates the folder type.
239
+ * https://msdn.microsoft.com/en-us/library/office/cc815373.aspx
240
+ * @readonly
241
+ * @type {number}
242
+ * @memberof PSTFolder
243
+ */
244
+ get folderType() {
245
+ return this.getIntItem(OutlookProperties_1.OutlookProperties.PR_FOLDER_TYPE);
246
+ }
247
+ /**
248
+ * Contains the number of messages in a folder, as computed by the message store.
249
+ * For a number calculated by the library use getEmailCount
250
+ * @readonly
251
+ * @type {number}
252
+ * @memberof PSTFolder
253
+ */
254
+ get contentCount() {
255
+ return this.getIntItem(OutlookProperties_1.OutlookProperties.PR_CONTENT_COUNT);
256
+ }
257
+ /**
258
+ * Contains the number of unread messages in a folder, as computed by the message store.
259
+ * https://msdn.microsoft.com/en-us/library/office/cc841964.aspx
260
+ * @readonly
261
+ * @type {number}
262
+ * @memberof PSTFolder
263
+ */
264
+ get unreadCount() {
265
+ return this.getIntItem(OutlookProperties_1.OutlookProperties.PR_CONTENT_UNREAD);
266
+ }
267
+ /**
268
+ * Contains TRUE if a folder contains subfolders.
269
+ * once again, read from the PST, use getSubFolderCount if you want to know
270
+ * @readonly
271
+ * @type {boolean}
272
+ * @memberof PSTFolder
273
+ */
274
+ get hasSubfolders() {
275
+ return this.getIntItem(OutlookProperties_1.OutlookProperties.PR_SUBFOLDERS) != 0;
276
+ }
277
+ /**
278
+ * Contains a text string describing the type of a folder. Although this property is
279
+ * generally ignored, versions of Microsoft® Exchange Server prior to Exchange Server
280
+ * 2003 Mailbox Manager expect this property to be present.
281
+ * https://msdn.microsoft.com/en-us/library/office/cc839839.aspx
282
+ * @readonly
283
+ * @type {string}
284
+ * @memberof PSTFolder
285
+ */
286
+ get containerClass() {
287
+ return this.getStringItem(OutlookProperties_1.OutlookProperties.PR_CONTAINER_CLASS);
288
+ }
289
+ /**
290
+ * Contains a bitmask of flags describing capabilities of an address book container.
291
+ * https://msdn.microsoft.com/en-us/library/office/cc839610.aspx
292
+ * @readonly
293
+ * @type {number}
294
+ * @memberof PSTFolder
295
+ */
296
+ get containerFlags() {
297
+ return this.getIntItem(OutlookProperties_1.OutlookProperties.PR_CONTAINER_FLAGS);
298
+ }
299
+ /**
300
+ * JSON stringify the object properties.
301
+ * @returns {string}
302
+ * @memberof PSTFolder
303
+ */
304
+ toJSON() {
305
+ const clone = Object.assign({
306
+ subFolderCount: this.subFolderCount,
307
+ emailCount: this.emailCount,
308
+ folderType: this.folderType,
309
+ contentCount: this.contentCount,
310
+ unreadCount: this.unreadCount,
311
+ hasSubfolders: this.hasSubfolders,
312
+ containerClass: this.containerClass,
313
+ containerFlags: this.containerFlags,
314
+ }, this);
315
+ return clone;
316
+ }
317
+ }
318
+ exports.PSTFolder = PSTFolder;