@periskope/types 0.6.310 → 0.6.311-2

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/src/types.ts CHANGED
@@ -413,6 +413,7 @@ export type MessageFlagType = {
413
413
  response_email?: string;
414
414
  flagged_by?: string;
415
415
  flagged_at?: string;
416
+ response_phone?: string;
416
417
  };
417
418
 
418
419
  export type MessageSendType = {
@@ -1177,6 +1178,25 @@ export type TicketRuleInfoType = {
1177
1178
  >;
1178
1179
  message: MessageRuleInfoType['message'];
1179
1180
  };
1181
+
1182
+ export type TaskRuleInfoType = {
1183
+ associated_object:
1184
+ | MessageRuleInfoType['message']
1185
+ | TicketRuleInfoType['ticket']
1186
+ | ChatRuleInfoType;
1187
+ task: Pick<
1188
+ TaskType,
1189
+ | 'org_id'
1190
+ | 'title'
1191
+ | 'notes'
1192
+ | 'assignee'
1193
+ | 'due_date'
1194
+ | 'priority'
1195
+ | 'task_id'
1196
+ | 'created_at'
1197
+ >;
1198
+ };
1199
+
1180
1200
  export type FeatureFlagReturnType = Record<string, boolean>;
1181
1201
 
1182
1202
  export type RuleLogsType = OverrideProperties<
@@ -1225,7 +1245,66 @@ export type RuleLogsType = OverrideProperties<
1225
1245
 
1226
1246
  /************************** TASKS ***************************/
1227
1247
 
1228
- export type TaskType = OverrideProperties<
1248
+ export type ChatMetadataType = {
1249
+ type: 'chat';
1250
+ index: 'chat_id';
1251
+ id: string;
1252
+ object: Pick<ChatType, 'chat_id' | 'org_phone' | 'org_id'>;
1253
+ };
1254
+
1255
+ export type MessageMetadataType = {
1256
+ type: 'message';
1257
+ index: 'message_id';
1258
+ id: string;
1259
+ object: Pick<
1260
+ MessageType,
1261
+ 'message_id' | 'org_phone' | 'chat_id' | 'sender_phone' | 'org_id'
1262
+ >;
1263
+ };
1264
+
1265
+ export type TicketMetadataType = {
1266
+ type: 'ticket';
1267
+ index: 'ticket_id';
1268
+ id: string;
1269
+ object: Pick<
1270
+ TicketType,
1271
+ 'ticket_id' | 'quoted_message_id' | 'chat_id' | 'org_id'
1272
+ >;
1273
+ };
1274
+
1275
+ export type AssociatedObjectMetadataType<
1276
+ T extends 'chat' | 'message' | 'ticket' | 'todo' =
1277
+ | 'chat'
1278
+ | 'message'
1279
+ | 'ticket'
1280
+ | 'todo',
1281
+ > = T extends 'chat'
1282
+ ? ChatMetadataType
1283
+ : T extends 'message'
1284
+ ? MessageMetadataType
1285
+ : T extends 'ticket'
1286
+ ? TicketMetadataType
1287
+ : null;
1288
+
1289
+ export const isChatTask = (task: TaskType): task is TaskType<'chat'> =>
1290
+ task.associated_object_metadata?.type === 'chat';
1291
+
1292
+ export const isMessageTask = (task: TaskType): task is TaskType<'message'> =>
1293
+ task.associated_object_metadata?.type === 'message';
1294
+
1295
+ export const isTicketTask = (task: TaskType): task is TaskType<'ticket'> =>
1296
+ task.associated_object_metadata?.type === 'ticket';
1297
+
1298
+ export const isTodoTask = (task: TaskType): task is TaskType<'todo'> =>
1299
+ task.type === 'todo';
1300
+
1301
+ export type TaskType<
1302
+ T extends 'chat' | 'message' | 'ticket' | 'todo' =
1303
+ | 'chat'
1304
+ | 'message'
1305
+ | 'ticket'
1306
+ | 'todo',
1307
+ > = OverrideProperties<
1229
1308
  Tables<'tbl_org_tasks'>,
1230
1309
  {
1231
1310
  reminder_setting: {
@@ -1240,33 +1319,14 @@ export type TaskType = OverrideProperties<
1240
1319
  on?: string;
1241
1320
  };
1242
1321
  } | null;
1243
- associated_object_metadata:
1244
- | {
1245
- type: 'chat';
1246
- index: 'chat_id';
1247
- id: string;
1248
- object: ChatType;
1249
- }
1250
- | {
1251
- type: 'message';
1252
- index: 'message_id';
1253
- id: string;
1254
- object: MessageType;
1255
- }
1256
- | {
1257
- type: 'ticket';
1258
- index: 'ticket_id';
1259
- id: string;
1260
- object: TicketType;
1261
- }
1262
- | null;
1322
+ associated_object_metadata: AssociatedObjectMetadataType<T>;
1263
1323
  status: 'open' | 'inprogress' | 'closed';
1264
1324
  priority: 1 | 2 | 3;
1265
1325
  completed_metadata?: {
1266
1326
  completed_at: string;
1267
1327
  completed_by: string;
1268
1328
  } | null;
1269
- type: 'todo' | 'chat' | 'message' | 'ticket';
1329
+ type: T;
1270
1330
  }
1271
1331
  >;
1272
1332