@rentcheck/biz 1.0.66 → 1.0.67

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.
@@ -1,3 +1,3 @@
1
- import { Feature, ApiInspectionWithTemplate } from '@rentcheck/types';
1
+ import { ApiInspectionWithTemplate, Feature } from '@rentcheck/types';
2
2
  export declare const anAnswerRequiresPhoto: (feature: Feature) => boolean;
3
3
  export declare const noteIsRequired: (feature: Feature, inspection?: ApiInspectionWithTemplate) => boolean;
@@ -1,4 +1,36 @@
1
- import { ApiInspectionWithTemplate, Profile } from '@rentcheck/types';
2
- export declare const shouldShowLibraryOption: (inspection?: ApiInspectionWithTemplate, profile?: Profile) => boolean;
3
- export declare const shouldShow360Option: (inspection?: ApiInspectionWithTemplate) => boolean;
4
- export declare const shouldShowVideoOption: (inspection?: ApiInspectionWithTemplate, profile?: Profile) => boolean;
1
+ import { APIProperty, ApiInspection, ApiInspectionWithTemplate, Feature, MaintenanceFlag, Profile } from '@rentcheck/types';
2
+ export declare const shouldShowLibraryOption: (inspection?: ApiInspection, profile?: Profile) => boolean;
3
+ export declare const shouldShow360Option: (inspection?: ApiInspection) => boolean;
4
+ export declare const shouldShowVideoOption: (inspection?: ApiInspection, profile?: Profile, feature?: Feature) => boolean;
5
+ export declare const canApprove: (inspection: ApiInspection, profile?: Profile) => boolean;
6
+ export declare const canReject: (inspection: ApiInspection, profile?: Profile) => boolean;
7
+ export declare const canEditLabel: (inspection: ApiInspection) => boolean;
8
+ export declare const canCancelReviewRequest: (inspection: ApiInspection) => boolean;
9
+ export declare const canCancelRevisionRequest: (inspection: ApiInspection) => boolean;
10
+ export declare const canArchive: (inspection: ApiInspection) => boolean;
11
+ export declare const canUnarchive: (inspection: ApiInspection) => boolean;
12
+ export declare const canDelete: (inspection: ApiInspection) => boolean;
13
+ export declare const canSendReminder: (inspection: ApiInspection) => boolean;
14
+ export declare const canMarkAsComplete: (inspection: ApiInspection) => boolean;
15
+ export declare const canDownloadImages: (inspection: ApiInspection, features: Feature[]) => boolean;
16
+ export declare const canDownloadMaintenanceFlags: (inspection: ApiInspection, features: Feature[]) => boolean;
17
+ export declare const canRequestSignatures: (inspection: ApiInspection) => boolean;
18
+ export declare const canCreateMaintenanceReport: (inspection: ApiInspection, features: Feature[]) => boolean;
19
+ export declare const canShowCompletedDate: (inspection: ApiInspection) => boolean;
20
+ export declare const canShowCompletedBy: (inspection: ApiInspection) => boolean;
21
+ export declare const canShowDueDate: (inspection: ApiInspection) => boolean;
22
+ export declare const canShowAssignee: (inspection: ApiInspection) => boolean;
23
+ export declare const canEditAssignee: (inspection: ApiInspection) => boolean;
24
+ export declare const canShowInviteDate: (inspection: ApiInspection) => boolean;
25
+ export declare const canShowRevisionDueDate: (inspection: ApiInspection) => boolean;
26
+ export declare const canShowReviewDueDate: (inspection: ApiInspection) => boolean;
27
+ export declare const canShowHyperlinkToPropertyPage: (inspection: ApiInspection) => boolean;
28
+ export declare const canEditDueDate: (inspection: ApiInspection) => boolean;
29
+ export declare const canShare: (inspection: ApiInspection) => boolean;
30
+ export declare const canDownloadReport: (inspection: ApiInspection) => boolean;
31
+ export declare const canCopyInspectionDeeplink: (inspection: ApiInspection) => boolean;
32
+ export declare const canManualSync: (inspection: ApiInspectionWithTemplate, property: APIProperty) => boolean;
33
+ export declare const canShowSyncStatus: (inspection: ApiInspectionWithTemplate) => boolean;
34
+ export declare const canShowFlaggedItems: (inspection: ApiInspectionWithTemplate, flags: MaintenanceFlag[]) => boolean;
35
+ export declare const canPerformFeatureActions: (inspection: ApiInspectionWithTemplate) => boolean;
36
+ export declare const canMakeUnitEdits: (inspection: ApiInspection) => boolean;
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.shouldShowVideoOption = exports.shouldShow360Option = exports.shouldShowLibraryOption = void 0;
3
+ exports.canMakeUnitEdits = exports.canPerformFeatureActions = exports.canShowFlaggedItems = exports.canShowSyncStatus = exports.canManualSync = exports.canCopyInspectionDeeplink = exports.canDownloadReport = exports.canShare = exports.canEditDueDate = exports.canShowHyperlinkToPropertyPage = exports.canShowReviewDueDate = exports.canShowRevisionDueDate = exports.canShowInviteDate = exports.canEditAssignee = exports.canShowAssignee = exports.canShowDueDate = exports.canShowCompletedBy = exports.canShowCompletedDate = exports.canCreateMaintenanceReport = exports.canRequestSignatures = exports.canDownloadMaintenanceFlags = exports.canDownloadImages = exports.canMarkAsComplete = exports.canSendReminder = exports.canDelete = exports.canUnarchive = exports.canArchive = exports.canCancelRevisionRequest = exports.canCancelReviewRequest = exports.canEditLabel = exports.canReject = exports.canApprove = exports.shouldShowVideoOption = exports.shouldShow360Option = exports.shouldShowLibraryOption = void 0;
4
4
  const utils_1 = require("../../utils");
5
+ const inspections_1 = require("../../utils/inspections");
5
6
  const shouldShowLibraryOption = (inspection, profile) => {
6
7
  if (!inspection)
7
8
  return false;
@@ -16,7 +17,9 @@ const shouldShow360Option = (inspection) => {
16
17
  : false;
17
18
  };
18
19
  exports.shouldShow360Option = shouldShow360Option;
19
- const shouldShowVideoOption = (inspection, profile) => {
20
+ const shouldShowVideoOption = (inspection, profile, feature) => {
21
+ if (feature === null || feature === void 0 ? void 0 : feature.is_video_enabled)
22
+ return true;
20
23
  if (!inspection)
21
24
  return false;
22
25
  return inspection.settings.can_record_video && !utils_1.Users.isRenter(profile)
@@ -24,3 +27,446 @@ const shouldShowVideoOption = (inspection, profile) => {
24
27
  : false;
25
28
  };
26
29
  exports.shouldShowVideoOption = shouldShowVideoOption;
30
+ const canApprove = (inspection, profile) => {
31
+ const validStatuses = [
32
+ 'Awaiting Review',
33
+ 'Revision Review',
34
+ ];
35
+ if (!profile)
36
+ return false;
37
+ if (!validStatuses.includes(inspection.inspection_status))
38
+ return false;
39
+ if (inspection.role !== 'creator')
40
+ return false;
41
+ return true;
42
+ };
43
+ exports.canApprove = canApprove;
44
+ const canReject = (inspection, profile) => {
45
+ const validStatuses = [
46
+ 'Awaiting Review',
47
+ 'Revision Review',
48
+ ];
49
+ if (!profile)
50
+ return false;
51
+ if (!validStatuses.includes(inspection.inspection_status))
52
+ return false;
53
+ if (inspection.role !== 'creator')
54
+ return false;
55
+ if (inspection.review)
56
+ return false;
57
+ return true;
58
+ };
59
+ exports.canReject = canReject;
60
+ const canEditLabel = (inspection) => {
61
+ if ((0, inspections_1.userIsInvitedTeammate)(inspection))
62
+ return true;
63
+ const validRoles = ['creator', 'self-perform'];
64
+ if (!validRoles.includes(inspection.role))
65
+ return false;
66
+ return true;
67
+ };
68
+ exports.canEditLabel = canEditLabel;
69
+ const canCancelReviewRequest = (inspection) => {
70
+ const validRoles = ['creator'];
71
+ if (!validRoles.includes(inspection.role))
72
+ return false;
73
+ if (inspection.inspection_status !== 'In Review')
74
+ return false;
75
+ if (inspection.assigned_recipients.type !== 'emails')
76
+ return false;
77
+ return true;
78
+ };
79
+ exports.canCancelReviewRequest = canCancelReviewRequest;
80
+ const canCancelRevisionRequest = (inspection) => {
81
+ const validRoles = ['creator'];
82
+ if (!validRoles.includes(inspection.role))
83
+ return false;
84
+ if (inspection.inspection_status !== 'Revision Requested')
85
+ return false;
86
+ return true;
87
+ };
88
+ exports.canCancelRevisionRequest = canCancelRevisionRequest;
89
+ const canArchive = (inspection) => {
90
+ if ((0, inspections_1.userIsInvitedTeammate)(inspection))
91
+ return true;
92
+ const validRoles = ['creator', 'self-perform'];
93
+ if (!validRoles.includes(inspection.role))
94
+ return false;
95
+ if (inspection.archived)
96
+ return false;
97
+ return true;
98
+ };
99
+ exports.canArchive = canArchive;
100
+ const canUnarchive = (inspection) => {
101
+ if ((0, inspections_1.userIsInvitedTeammate)(inspection))
102
+ return true;
103
+ const validRoles = ['creator', 'self-perform'];
104
+ if (!validRoles.includes(inspection.role))
105
+ return false;
106
+ if (!inspection.archived)
107
+ return false;
108
+ return true;
109
+ };
110
+ exports.canUnarchive = canUnarchive;
111
+ const canDelete = (inspection) => {
112
+ const validRoles = ['creator', 'self-perform'];
113
+ const validStatuses = [
114
+ 'Scheduled',
115
+ 'Not Started',
116
+ 'Started',
117
+ ];
118
+ if (!validStatuses.includes(inspection.inspection_status))
119
+ return false;
120
+ if ((0, inspections_1.userIsInvitedTeammate)(inspection))
121
+ return true;
122
+ if (!validRoles.includes(inspection.role))
123
+ return false;
124
+ return true;
125
+ };
126
+ exports.canDelete = canDelete;
127
+ const canSendReminder = (inspection) => {
128
+ const validRoles = ['creator'];
129
+ const validStatuses = [
130
+ 'Not Started',
131
+ 'Started',
132
+ 'Revision Requested',
133
+ ];
134
+ if (!validRoles.includes(inspection.role))
135
+ return false;
136
+ if (!validStatuses.includes(inspection.inspection_status))
137
+ return false;
138
+ return true;
139
+ };
140
+ exports.canSendReminder = canSendReminder;
141
+ const canMarkAsComplete = (inspection) => {
142
+ const validRoles = ['creator', 'self-perform'];
143
+ const validStatuses = [
144
+ 'Started',
145
+ 'Revision Requested',
146
+ ];
147
+ if (!validRoles.includes(inspection.role))
148
+ return false;
149
+ if (!validStatuses.includes(inspection.inspection_status))
150
+ return false;
151
+ return true;
152
+ };
153
+ exports.canMarkAsComplete = canMarkAsComplete;
154
+ const canDownloadImages = (inspection, features) => {
155
+ const validStatuses = [
156
+ 'In Review',
157
+ 'Completed',
158
+ 'Awaiting Review',
159
+ 'Revision Review',
160
+ 'Approved',
161
+ ];
162
+ if (!validStatuses.includes(inspection.inspection_status))
163
+ return false;
164
+ if (!features.some((f) => f.images.length > 0 || f.videos.length > 0))
165
+ return false;
166
+ return true;
167
+ };
168
+ exports.canDownloadImages = canDownloadImages;
169
+ const canDownloadMaintenanceFlags = (inspection, features) => {
170
+ const validStatuses = [
171
+ 'In Review',
172
+ 'Completed',
173
+ 'Awaiting Review',
174
+ 'Revision Review',
175
+ 'Approved',
176
+ ];
177
+ if (!validStatuses.includes(inspection.inspection_status))
178
+ return false;
179
+ if (!features.some((f) => f.maintenance_flags.length > 0))
180
+ return false;
181
+ if ((0, inspections_1.userIsInvitedTeammate)(inspection))
182
+ return true;
183
+ const validRoles = ['creator', 'self-perform'];
184
+ if (!validRoles.includes(inspection.role))
185
+ return false;
186
+ return true;
187
+ };
188
+ exports.canDownloadMaintenanceFlags = canDownloadMaintenanceFlags;
189
+ const canRequestSignatures = (inspection) => {
190
+ const validRoles = ['creator', 'self-perform'];
191
+ const validStatuses = [
192
+ 'In Review',
193
+ 'Completed',
194
+ 'Awaiting Review',
195
+ 'Revision Review',
196
+ 'Approved',
197
+ ];
198
+ if (!validRoles.includes(inspection.role))
199
+ return false;
200
+ if (!validStatuses.includes(inspection.inspection_status))
201
+ return false;
202
+ return true;
203
+ };
204
+ exports.canRequestSignatures = canRequestSignatures;
205
+ const canCreateMaintenanceReport = (inspection, features) => {
206
+ const validRoles = ['creator', 'self-perform'];
207
+ const validStatuses = [
208
+ 'In Review',
209
+ 'Completed',
210
+ 'Awaiting Review',
211
+ 'Revision Review',
212
+ 'Approved',
213
+ ];
214
+ if (!validRoles.includes(inspection.role))
215
+ return false;
216
+ if (!validStatuses.includes(inspection.inspection_status))
217
+ return false;
218
+ if (!features.some((f) => f.maintenance_flags.length > 0))
219
+ return false;
220
+ return true;
221
+ };
222
+ exports.canCreateMaintenanceReport = canCreateMaintenanceReport;
223
+ const canShowCompletedDate = (inspection) => {
224
+ const validStatuses = [
225
+ 'Awaiting Review',
226
+ 'Completed',
227
+ 'Revision Requested',
228
+ 'Revision Review',
229
+ 'In Review',
230
+ 'Approved',
231
+ ];
232
+ if (!validStatuses.includes(inspection.inspection_status))
233
+ return false;
234
+ if (!inspection.completed_date)
235
+ return false;
236
+ return true;
237
+ };
238
+ exports.canShowCompletedDate = canShowCompletedDate;
239
+ const canShowCompletedBy = (inspection) => {
240
+ const validStatuses = [
241
+ 'Awaiting Review',
242
+ 'Completed',
243
+ 'Revision Requested',
244
+ 'Revision Review',
245
+ 'In Review',
246
+ 'Approved',
247
+ ];
248
+ if (!validStatuses.includes(inspection.inspection_status))
249
+ return false;
250
+ if (!inspection.completed_by)
251
+ return false;
252
+ return true;
253
+ };
254
+ exports.canShowCompletedBy = canShowCompletedBy;
255
+ const canShowDueDate = (inspection) => {
256
+ const validStatuses = [
257
+ 'Scheduled',
258
+ 'Not Started',
259
+ 'Started',
260
+ ];
261
+ if (!validStatuses.includes(inspection.inspection_status))
262
+ return false;
263
+ return true;
264
+ };
265
+ exports.canShowDueDate = canShowDueDate;
266
+ const canShowAssignee = (inspection) => {
267
+ const validStatuses = [
268
+ 'Scheduled',
269
+ 'Not Started',
270
+ 'Started',
271
+ ];
272
+ if (!validStatuses.includes(inspection.inspection_status))
273
+ return false;
274
+ return true;
275
+ };
276
+ exports.canShowAssignee = canShowAssignee;
277
+ const canEditAssignee = (inspection) => {
278
+ if (!(0, exports.canShowAssignee)(inspection))
279
+ return false;
280
+ if ((0, inspections_1.userIsInvitedTeammate)(inspection))
281
+ return true;
282
+ const validRoles = ['creator', 'self-perform'];
283
+ if (!validRoles.includes(inspection.role))
284
+ return false;
285
+ return true;
286
+ };
287
+ exports.canEditAssignee = canEditAssignee;
288
+ const canShowInviteDate = (inspection) => {
289
+ const validStatuses = ['Scheduled'];
290
+ const validAssigneeTypes = [
291
+ 'emails',
292
+ 'residents',
293
+ 'teammates',
294
+ ];
295
+ if (!validStatuses.includes(inspection.inspection_status))
296
+ return false;
297
+ if (!validAssigneeTypes.includes(inspection.assigned_recipients.type))
298
+ return false;
299
+ if (!inspection.invite_date)
300
+ return false;
301
+ return true;
302
+ };
303
+ exports.canShowInviteDate = canShowInviteDate;
304
+ const canShowRevisionDueDate = (inspection) => {
305
+ var _a;
306
+ const validStatuses = ['Revision Requested'];
307
+ if (!validStatuses.includes(inspection.inspection_status))
308
+ return false;
309
+ if (!((_a = inspection.rejection) === null || _a === void 0 ? void 0 : _a.due_date))
310
+ return false;
311
+ return true;
312
+ };
313
+ exports.canShowRevisionDueDate = canShowRevisionDueDate;
314
+ const canShowReviewDueDate = (inspection) => {
315
+ var _a;
316
+ const validStatuses = ['In Review'];
317
+ if (!validStatuses.includes(inspection.inspection_status))
318
+ return false;
319
+ if (!((_a = inspection.review) === null || _a === void 0 ? void 0 : _a.due_date))
320
+ return false;
321
+ return true;
322
+ };
323
+ exports.canShowReviewDueDate = canShowReviewDueDate;
324
+ const canShowHyperlinkToPropertyPage = (inspection) => {
325
+ if ((0, inspections_1.userIsInvitedTeammate)(inspection))
326
+ return true;
327
+ const validRoles = ['creator', 'self-perform'];
328
+ if (!validRoles.includes(inspection.role))
329
+ return false;
330
+ return true;
331
+ };
332
+ exports.canShowHyperlinkToPropertyPage = canShowHyperlinkToPropertyPage;
333
+ const canEditDueDate = (inspection) => {
334
+ if (!(0, exports.canShowDueDate)(inspection))
335
+ return false;
336
+ const validRoles = ['creator', 'self-perform'];
337
+ if (!validRoles.includes(inspection.role))
338
+ return false;
339
+ return true;
340
+ };
341
+ exports.canEditDueDate = canEditDueDate;
342
+ const canShare = (inspection) => {
343
+ const validStatuses = [
344
+ 'In Review',
345
+ 'Completed',
346
+ 'Awaiting Review',
347
+ 'Revision Review',
348
+ 'Approved',
349
+ ];
350
+ if (!validStatuses.includes(inspection.inspection_status))
351
+ return false;
352
+ return true;
353
+ };
354
+ exports.canShare = canShare;
355
+ const canDownloadReport = (inspection) => {
356
+ const validStatuses = [
357
+ 'In Review',
358
+ 'Completed',
359
+ 'Awaiting Review',
360
+ 'Revision Review',
361
+ 'Approved',
362
+ ];
363
+ if (!validStatuses.includes(inspection.inspection_status))
364
+ return false;
365
+ return true;
366
+ };
367
+ exports.canDownloadReport = canDownloadReport;
368
+ const canCopyInspectionDeeplink = (inspection) => {
369
+ const validStatuses = [
370
+ 'Scheduled',
371
+ 'Not Started',
372
+ 'Started',
373
+ 'Revision Requested',
374
+ ];
375
+ if (!validStatuses.includes(inspection.inspection_status))
376
+ return false;
377
+ return true;
378
+ };
379
+ exports.canCopyInspectionDeeplink = canCopyInspectionDeeplink;
380
+ const canManualSync = (inspection, property) => {
381
+ var _a;
382
+ /**
383
+ * If the property is not synced to either provider we don't
384
+ * have anywhere to sync the inspection to.
385
+ */
386
+ if (!property.rentmanager_sync && !property.appfolio_sync)
387
+ return false;
388
+ /**
389
+ * if the inspection has already been synced and we registered
390
+ * no errors, we don't need to show the button. Manual sync is
391
+ * only intended to be shown as an initial sync or a retry.
392
+ */
393
+ if (((_a = inspection.sync_data) === null || _a === void 0 ? void 0 : _a.status) === 'success')
394
+ return false;
395
+ /**
396
+ * Only inspections that are Completed or In Review can be synced.
397
+ */
398
+ const validStatuses = [
399
+ 'In Review',
400
+ 'Completed',
401
+ 'Awaiting Review',
402
+ 'Revision Review',
403
+ 'Approved',
404
+ ];
405
+ if (!validStatuses.includes(inspection.inspection_status))
406
+ return false;
407
+ if ((0, inspections_1.userIsInvitedTeammate)(inspection))
408
+ return true;
409
+ const validRoles = ['creator', 'self-perform'];
410
+ if (!validRoles.includes(inspection.role))
411
+ return false;
412
+ return true;
413
+ };
414
+ exports.canManualSync = canManualSync;
415
+ const canShowSyncStatus = (inspection) => {
416
+ if (!inspection.sync_data)
417
+ return false;
418
+ const validStatuses = [
419
+ 'In Review',
420
+ 'Completed',
421
+ 'Awaiting Review',
422
+ 'Revision Review',
423
+ 'Approved',
424
+ ];
425
+ if (!validStatuses.includes(inspection.inspection_status))
426
+ return false;
427
+ if ((0, inspections_1.userIsInvitedTeammate)(inspection))
428
+ return true;
429
+ const validRoles = ['creator', 'self-perform'];
430
+ if (!validRoles.includes(inspection.role))
431
+ return false;
432
+ return true;
433
+ };
434
+ exports.canShowSyncStatus = canShowSyncStatus;
435
+ const canShowFlaggedItems = (inspection, flags) => {
436
+ if (flags.length === 0)
437
+ return false;
438
+ if ((0, inspections_1.userIsInvitedTeammate)(inspection))
439
+ return true;
440
+ const validRoles = ['creator', 'self-perform'];
441
+ if (!validRoles.includes(inspection.role))
442
+ return false;
443
+ return true;
444
+ };
445
+ exports.canShowFlaggedItems = canShowFlaggedItems;
446
+ const canPerformFeatureActions = (inspection) => {
447
+ if ((0, inspections_1.userIsInvitedTeammate)(inspection))
448
+ return true;
449
+ const validRoles = ['creator', 'self-perform'];
450
+ if (!validRoles.includes(inspection.role))
451
+ return false;
452
+ return true;
453
+ };
454
+ exports.canPerformFeatureActions = canPerformFeatureActions;
455
+ const canMakeUnitEdits = (inspection) => {
456
+ const validStatuses = [
457
+ 'In Review',
458
+ 'Completed',
459
+ 'Awaiting Review',
460
+ 'Revision Review',
461
+ 'Approved',
462
+ ];
463
+ if (!validStatuses.includes(inspection.inspection_status))
464
+ return false;
465
+ if ((0, inspections_1.userIsInvitedTeammate)(inspection))
466
+ return true;
467
+ const validRoles = ['creator', 'self-perform'];
468
+ if (!validRoles.includes(inspection.role))
469
+ return false;
470
+ return true;
471
+ };
472
+ exports.canMakeUnitEdits = canMakeUnitEdits;
@@ -1,4 +1,4 @@
1
1
  import { Timestamp } from '@rentcheck/types';
2
2
  export type ParseDateDatabaseType = 'firestore';
3
- export declare const parseDate: (fromDatabase: ParseDateDatabaseType, date: any, defaultReturnValue?: any) => any;
3
+ export declare const parse: (fromDatabase: ParseDateDatabaseType, date: any, defaultReturnValue?: any) => any;
4
4
  export declare const buildDateFromApiOrFirebase: (a?: Timestamp | string) => Date;
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.buildDateFromApiOrFirebase = exports.parseDate = void 0;
6
+ exports.buildDateFromApiOrFirebase = exports.parse = void 0;
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
- const parseDate = (fromDatabase, date, defaultReturnValue = null) => {
8
+ const parse = (fromDatabase, date, defaultReturnValue = null) => {
9
9
  if (!date || lodash_1.default.isEmpty(date))
10
10
  return defaultReturnValue;
11
11
  if (fromDatabase === 'firestore') {
@@ -19,7 +19,7 @@ const parseDate = (fromDatabase, date, defaultReturnValue = null) => {
19
19
  }
20
20
  throw new Error(`fromDatabase (${fromDatabase}) not suported!`);
21
21
  };
22
- exports.parseDate = parseDate;
22
+ exports.parse = parse;
23
23
  const buildDateFromApiOrFirebase = (a) => {
24
24
  if (!a)
25
25
  return undefined;
@@ -38,6 +38,7 @@ const createFeaturesFromSection = (inspection, section, sectionName, sectionName
38
38
  reference_photos: [],
39
39
  number_of_photos_required: 1,
40
40
  questions: [],
41
+ is_video_enabled: true,
41
42
  };
42
43
  if (section.type === 'room') {
43
44
  basicFeatureProps.description =
@@ -0,0 +1,2 @@
1
+ import { ApiInspection } from '@rentcheck/types';
2
+ export declare const userIsInvitedTeammate: (inspection: ApiInspection) => boolean;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.userIsInvitedTeammate = void 0;
4
+ const userIsInvitedTeammate = (inspection) => {
5
+ const validRoles = ['invitee-write', 'invitee-readonly'];
6
+ const validAssigneeTypes = ['teammates'];
7
+ if (validRoles.includes(inspection.role) &&
8
+ validAssigneeTypes.includes(inspection.assigned_recipients.type)) {
9
+ return true;
10
+ }
11
+ return false;
12
+ };
13
+ exports.userIsInvitedTeammate = userIsInvitedTeammate;
@@ -1 +1,4 @@
1
+ import { APIProperty, AppFolioIntegration, Property, RentmanagerIntegration } from '@rentcheck/types';
1
2
  export * from './validations';
3
+ export declare const propertyIsOutOfSync: (property: Property, integration?: AppFolioIntegration | RentmanagerIntegration) => boolean;
4
+ export declare const getIntegrationVendor: (property: APIProperty | Property) => string | undefined;
@@ -13,5 +13,35 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
13
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
16
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.getIntegrationVendor = exports.propertyIsOutOfSync = void 0;
21
+ const moment_1 = __importDefault(require("moment"));
17
22
  __exportStar(require("./validations"), exports);
23
+ const propertyIsOutOfSync = (property, integration) => {
24
+ if (property.property_type === 'Community') {
25
+ return false;
26
+ }
27
+ if (!integration) {
28
+ return false;
29
+ }
30
+ if (!property.rentmanager_sync && !property.appfolio_sync) {
31
+ return true;
32
+ }
33
+ const sync = property.rentmanager_sync || property.appfolio_sync;
34
+ return ((sync === null || sync === void 0 ? void 0 : sync.last_sync) &&
35
+ (0, moment_1.default)((0, moment_1.default)()).diff(sync.last_sync.toDate(), 'days') >= 7);
36
+ };
37
+ exports.propertyIsOutOfSync = propertyIsOutOfSync;
38
+ const getIntegrationVendor = (property) => {
39
+ if (property.rentmanager_sync) {
40
+ return 'Rent Manager';
41
+ }
42
+ if (property.appfolio_sync) {
43
+ return 'AppFolio';
44
+ }
45
+ return undefined;
46
+ };
47
+ exports.getIntegrationVendor = getIntegrationVendor;
@@ -3,3 +3,4 @@ import { ChargebeeEventSubscription } from '@rentcheck/types/dist/integrations/C
3
3
  export declare const isOnEssentialsPlan: (subscription?: ApiSubscription | null) => boolean;
4
4
  export declare const isOnProPlan: (subscription?: ApiSubscription | ChargebeeEventSubscription | null) => boolean;
5
5
  export declare const hasPropertySyncIntegrationAddons: (subscription: ApiSubscription | Subscription | null) => boolean;
6
+ export declare const hasPremiumVideoAddons: (subscription: ApiSubscription | Subscription | null) => boolean;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasPropertySyncIntegrationAddons = exports.isOnProPlan = exports.isOnEssentialsPlan = void 0;
3
+ exports.hasPremiumVideoAddons = exports.hasPropertySyncIntegrationAddons = exports.isOnProPlan = exports.isOnEssentialsPlan = void 0;
4
4
  const integrations_1 = require("../../permissions/integrations");
5
5
  const isOnEssentialsPlan = (subscription) => {
6
6
  if (!(subscription === null || subscription === void 0 ? void 0 : subscription.plan)) {
@@ -33,3 +33,10 @@ const hasPropertySyncIntegrationAddons = (subscription) => {
33
33
  integrations_1.RentManager.canInstall(subscription));
34
34
  };
35
35
  exports.hasPropertySyncIntegrationAddons = hasPropertySyncIntegrationAddons;
36
+ const hasPremiumVideoAddons = (subscription) => {
37
+ if (!subscription) {
38
+ return false;
39
+ }
40
+ return subscription.addons.some((a) => a.id.startsWith('premium-video'));
41
+ };
42
+ exports.hasPremiumVideoAddons = hasPremiumVideoAddons;
@@ -1,2 +1,2 @@
1
- import { Tenant, TenantSyncData } from '@rentcheck/types';
2
- export declare const getSyncData: (tenant: Tenant) => TenantSyncData;
1
+ import { SyncData, Tenant } from '@rentcheck/types';
2
+ export declare const getSyncData: (tenant: Tenant) => SyncData;
@@ -4,13 +4,13 @@ exports.getSyncData = void 0;
4
4
  const dates_1 = require("../dates");
5
5
  const getSyncData = (tenant) => {
6
6
  if (tenant.appfolio_sync) {
7
- return Object.assign(Object.assign({ integration_type: 'appfolio' }, tenant.appfolio_sync), { last_sync: (0, dates_1.parseDate)('firestore', tenant.appfolio_sync.last_sync, null) });
7
+ return Object.assign(Object.assign({ vendor: 'appfolio' }, tenant.appfolio_sync), { last_sync: (0, dates_1.parse)('firestore', tenant.appfolio_sync.last_sync, null) });
8
8
  }
9
9
  if (tenant.rentmanager_sync) {
10
- return Object.assign(Object.assign({ integration_type: 'rentmanager' }, tenant.rentmanager_sync), { last_sync: (0, dates_1.parseDate)('firestore', tenant.rentmanager_sync.last_sync, null) });
10
+ return Object.assign(Object.assign({ vendor: 'rentmanager' }, tenant.rentmanager_sync), { last_sync: (0, dates_1.parse)('firestore', tenant.rentmanager_sync.last_sync, null) });
11
11
  }
12
12
  if (tenant.yardi_sync) {
13
- return Object.assign(Object.assign({ integration_type: 'yardi' }, tenant.yardi_sync), { last_sync: (0, dates_1.parseDate)('firestore', tenant.yardi_sync, null) });
13
+ return Object.assign(Object.assign({ vendor: 'yardi' }, tenant.yardi_sync), { last_sync: (0, dates_1.parse)('firestore', tenant.yardi_sync, null) });
14
14
  }
15
15
  return undefined;
16
16
  };