pst-extractor 1.9.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 (59) hide show
  1. package/dist/ColumnDescriptor.class.d.ts +26 -26
  2. package/dist/ColumnDescriptor.class.js +51 -51
  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 -86
  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 -317
  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 -99
  25. package/dist/PSTFile.class.d.ts +215 -216
  26. package/dist/PSTFile.class.js +818 -818
  27. package/dist/PSTFolder.class.d.ts +129 -129
  28. package/dist/PSTFolder.class.js +318 -310
  29. package/dist/PSTMessage.class.d.ts +788 -789
  30. package/dist/PSTMessage.class.js +1321 -1321
  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 -514
  35. package/dist/PSTObject.class.d.ts +133 -134
  36. package/dist/PSTObject.class.js +326 -326
  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 -175
  41. package/dist/PSTTable7C.class.d.ts +45 -45
  42. package/dist/PSTTable7C.class.js +281 -281
  43. package/dist/PSTTableBC.class.d.ts +31 -31
  44. package/dist/PSTTableBC.class.js +111 -111
  45. package/dist/PSTTableItem.class.d.ts +47 -48
  46. package/dist/PSTTableItem.class.js +124 -124
  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 -795
  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 +6 -6
  56. package/example/yarn.lock +95 -44
  57. package/junit.xml +68 -68
  58. package/package.json +26 -26
  59. package/readme.md +1 -3
@@ -1,310 +1,318 @@
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
- const child = PSTUtil_class_1.PSTUtil.detectAndLoadPSTObject(this.pstFile, childDescriptor);
168
- this.currentEmailIndex++;
169
- return child;
170
- }
171
- else if (this.fallbackEmailsTable) {
172
- if (this.currentEmailIndex >= this.contentCount ||
173
- this.currentEmailIndex >= this.fallbackEmailsTable.length) {
174
- // no more!
175
- return null;
176
- }
177
- const childDescriptor = this.fallbackEmailsTable[this.currentEmailIndex];
178
- const child = PSTUtil_class_1.PSTUtil.detectAndLoadPSTObject(this.pstFile, childDescriptor);
179
- this.currentEmailIndex++;
180
- return child;
181
- }
182
- return null;
183
- }
184
- /**
185
- * Move the internal folder cursor to the desired position position 0 is before the first record.
186
- * @param {number} newIndex
187
- * @returns
188
- * @memberof PSTFolder
189
- */
190
- moveChildCursorTo(newIndex) {
191
- this.initEmailsTable();
192
- if (newIndex < 1) {
193
- this.currentEmailIndex = 0;
194
- return;
195
- }
196
- if (newIndex > this.contentCount) {
197
- newIndex = this.contentCount;
198
- }
199
- this.currentEmailIndex = newIndex;
200
- }
201
- /**
202
- * The number of child folders in this folder
203
- * @readonly
204
- * @type {number}
205
- * @memberof PSTFolder
206
- */
207
- get subFolderCount() {
208
- this.initSubfoldersTable();
209
- if (this.subfoldersTable != null) {
210
- return this.subfoldersTable.rowCount;
211
- }
212
- else {
213
- return 0;
214
- }
215
- }
216
- /**
217
- * Number of emails in this folder
218
- * @readonly
219
- * @type {number}
220
- * @memberof PSTFolder
221
- */
222
- get emailCount() {
223
- this.initEmailsTable();
224
- if (this.emailsTable == null) {
225
- return -1;
226
- }
227
- return this.emailsTable.rowCount;
228
- }
229
- /**
230
- * Contains a constant that indicates the folder type.
231
- * https://msdn.microsoft.com/en-us/library/office/cc815373.aspx
232
- * @readonly
233
- * @type {number}
234
- * @memberof PSTFolder
235
- */
236
- get folderType() {
237
- return this.getIntItem(OutlookProperties_1.OutlookProperties.PR_FOLDER_TYPE);
238
- }
239
- /**
240
- * Contains the number of messages in a folder, as computed by the message store.
241
- * For a number calculated by the library use getEmailCount
242
- * @readonly
243
- * @type {number}
244
- * @memberof PSTFolder
245
- */
246
- get contentCount() {
247
- return this.getIntItem(OutlookProperties_1.OutlookProperties.PR_CONTENT_COUNT);
248
- }
249
- /**
250
- * Contains the number of unread messages in a folder, as computed by the message store.
251
- * https://msdn.microsoft.com/en-us/library/office/cc841964.aspx
252
- * @readonly
253
- * @type {number}
254
- * @memberof PSTFolder
255
- */
256
- get unreadCount() {
257
- return this.getIntItem(OutlookProperties_1.OutlookProperties.PR_CONTENT_UNREAD);
258
- }
259
- /**
260
- * Contains TRUE if a folder contains subfolders.
261
- * once again, read from the PST, use getSubFolderCount if you want to know
262
- * @readonly
263
- * @type {boolean}
264
- * @memberof PSTFolder
265
- */
266
- get hasSubfolders() {
267
- return this.getIntItem(OutlookProperties_1.OutlookProperties.PR_SUBFOLDERS) != 0;
268
- }
269
- /**
270
- * Contains a text string describing the type of a folder. Although this property is
271
- * generally ignored, versions of Microsoft® Exchange Server prior to Exchange Server
272
- * 2003 Mailbox Manager expect this property to be present.
273
- * https://msdn.microsoft.com/en-us/library/office/cc839839.aspx
274
- * @readonly
275
- * @type {string}
276
- * @memberof PSTFolder
277
- */
278
- get containerClass() {
279
- return this.getStringItem(OutlookProperties_1.OutlookProperties.PR_CONTAINER_CLASS);
280
- }
281
- /**
282
- * Contains a bitmask of flags describing capabilities of an address book container.
283
- * https://msdn.microsoft.com/en-us/library/office/cc839610.aspx
284
- * @readonly
285
- * @type {number}
286
- * @memberof PSTFolder
287
- */
288
- get containerFlags() {
289
- return this.getIntItem(OutlookProperties_1.OutlookProperties.PR_CONTAINER_FLAGS);
290
- }
291
- /**
292
- * JSON stringify the object properties.
293
- * @returns {string}
294
- * @memberof PSTFolder
295
- */
296
- toJSON() {
297
- const clone = Object.assign({
298
- subFolderCount: this.subFolderCount,
299
- emailCount: this.emailCount,
300
- folderType: this.folderType,
301
- contentCount: this.contentCount,
302
- unreadCount: this.unreadCount,
303
- hasSubfolders: this.hasSubfolders,
304
- containerClass: this.containerClass,
305
- containerFlags: this.containerFlags,
306
- }, this);
307
- return clone;
308
- }
309
- }
310
- 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;