@periskope/types 0.6.283 → 0.6.284

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.
@@ -0,0 +1,256 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Triggers = void 0;
4
+ exports.isSplitPathAction = isSplitPathAction;
5
+ exports.isConditionLeaf = isConditionLeaf;
6
+ function isSplitPathAction(workflow_action) {
7
+ return workflow_action.action_metadata.type === 'split_path';
8
+ }
9
+ /***************************** CONDITIONS TYPES *****************************/
10
+ // {
11
+ // "operator": "AND",
12
+ // "conditions": [
13
+ // {
14
+ // "id": "cond1",
15
+ // "variable_name": "message",
16
+ // "variable_type": "string",
17
+ // "condition": "CONTAINS",
18
+ // "value": "urgent"
19
+ // },
20
+ // {
21
+ // "operator": "OR",
22
+ // "conditions": [
23
+ // {
24
+ // "id": "cond2",
25
+ // "variable_name": "priority",
26
+ // "variable_type": "number",
27
+ // "condition": "GT",
28
+ // "value": 2
29
+ // },
30
+ // {
31
+ // "id": "cond3",
32
+ // "variable_name": "assigned",
33
+ // "variable_type": "boolean",
34
+ // "condition": "NKNOWN"
35
+ // }
36
+ // ]
37
+ // }
38
+ // ]
39
+ // }
40
+ var Conditions;
41
+ (function (Conditions) {
42
+ // string
43
+ Conditions["CONTAINS"] = "contains";
44
+ Conditions["NCONTAINS"] = "not contains";
45
+ Conditions["EQUALS"] = "equals";
46
+ Conditions["NEQUALS"] = "not equals";
47
+ Conditions["STARTS_WITH"] = "starts with";
48
+ Conditions["ENDS_WITH"] = "ends with";
49
+ // number, date, time
50
+ Conditions["GREATER_THAN"] = "greater than";
51
+ Conditions["GREATER_THAN_OR_EQUAL"] = "greater than or equal";
52
+ Conditions["LESS_THAN"] = "less than";
53
+ Conditions["LESS_THAN_OR_EQUAL"] = "less than or equal";
54
+ // none
55
+ Conditions["IS_KNOWN"] = "is known";
56
+ Conditions["IS_UNKNOWN"] = "is unknown";
57
+ // boolean
58
+ Conditions["IS"] = "is";
59
+ Conditions["IS_NOT"] = "is not";
60
+ // array
61
+ Conditions["IS_ANY_OF"] = "is any of";
62
+ Conditions["IS_NOT_ANY_OF"] = "is not any of";
63
+ // day
64
+ Conditions["ON"] = "on";
65
+ })(Conditions || (Conditions = {}));
66
+ function isConditionLeaf(condition) {
67
+ return 'id' in condition && !('operator' in condition);
68
+ }
69
+ var Triggers;
70
+ (function (Triggers) {
71
+ Triggers["MESSAGE_CREATED"] = "message.created";
72
+ Triggers["MESSAGE_UPDATED"] = "message.updated";
73
+ Triggers["MESSAGE_DELETED"] = "message.deleted";
74
+ Triggers["MESSAGE_FLAGGED"] = "message.flagged";
75
+ Triggers["MESSAGE_UNFLAGGED"] = "message.unflagged";
76
+ Triggers["REACTION_ADDED"] = "reaction.added";
77
+ Triggers["TICKET_CREATED"] = "ticket.created";
78
+ Triggers["TICKET_UPDATED"] = "ticket.updated";
79
+ Triggers["TICKET_DELETED"] = "ticket.deleted";
80
+ Triggers["TICKET_CLOSED"] = "ticket.closed";
81
+ Triggers["TICKET_DUE"] = "ticket.due";
82
+ Triggers["CHAT_CREATED"] = "chat.created";
83
+ Triggers["CHAT_LABEL_UPDATED"] = "chat.label.updated";
84
+ Triggers["CHAT_CLOSED"] = "chat.closed";
85
+ Triggers["TASK_CREATED"] = "task.created";
86
+ Triggers["TASK_DUE"] = "task.due";
87
+ })(Triggers || (exports.Triggers = Triggers = {}));
88
+ // Example workflow type ->
89
+ // const demoWorkflow: WorkflowType = {
90
+ // id: 'workflow-1',
91
+ // name: 'Urgent Chat Auto-Responder',
92
+ // trigger: Triggers.MESSAGE_CREATED,
93
+ // trigger_metadata: {
94
+ // org_phones: ['phone-1'],
95
+ // allow_internal_messages: false,
96
+ // first_action_id: 'action-validate',
97
+ // },
98
+ // actions: [
99
+ // {
100
+ // id: 'action-validate',
101
+ // action_metadata: {
102
+ // type: 'validate_action',
103
+ // metadata: {
104
+ // operator: 'AND',
105
+ // conditions: [
106
+ // {
107
+ // id: 'cond-1',
108
+ // variable_name: 'message.text',
109
+ // variable_type: 'string',
110
+ // condition: 'CONTAINS',
111
+ // value: 'urgent',
112
+ // },
113
+ // {
114
+ // id: 'cond-2',
115
+ // variable_name: 'chat.assigned',
116
+ // variable_type: 'boolean',
117
+ // condition: 'IS',
118
+ // value: false,
119
+ // },
120
+ // ],
121
+ // },
122
+ // },
123
+ // next: 'action-add-label',
124
+ // },
125
+ // {
126
+ // id: 'action-add-label',
127
+ // action_metadata: {
128
+ // type: 'add_chat_label',
129
+ // metadata: {
130
+ // labels: ['urgent'],
131
+ // },
132
+ // },
133
+ // next: 'action-assign-chat',
134
+ // },
135
+ // {
136
+ // id: 'action-assign-chat',
137
+ // action_metadata: {
138
+ // type: 'assign_chat',
139
+ // metadata: {
140
+ // assignee: {
141
+ // round_robin: true,
142
+ // emails: ['agent1@example.com', 'agent2@example.com'],
143
+ // assignee_check_for: 'all',
144
+ // },
145
+ // },
146
+ // },
147
+ // next: 'action-delay',
148
+ // },
149
+ // {
150
+ // id: 'action-delay',
151
+ // action_metadata: {
152
+ // type: 'delay',
153
+ // metadata: {
154
+ // delay: '5 minutes',
155
+ // },
156
+ // },
157
+ // next: 'action-send-message',
158
+ // },
159
+ // {
160
+ // id: 'action-send-message',
161
+ // action_metadata: {
162
+ // type: 'send_message_to_chat',
163
+ // metadata: {
164
+ // message: 'We’re on it!',
165
+ // chat_id: 'trigger_chat',
166
+ // },
167
+ // },
168
+ // next: 'action-split',
169
+ // },
170
+ // {
171
+ // id: 'action-split',
172
+ // action_metadata: {
173
+ // type: 'split_path',
174
+ // metadata: {
175
+ // paths: [
176
+ // {
177
+ // id: 'path-flagged',
178
+ // condition_action_id: 'action-condition-flagged',
179
+ // },
180
+ // {
181
+ // id: 'path-not-flagged',
182
+ // condition_action_id: 'action-condition-not-flagged',
183
+ // },
184
+ // ],
185
+ // },
186
+ // },
187
+ // {
188
+ // id: 'action-condition-flagged',
189
+ // action_metadata: {
190
+ // type: 'validate_action',
191
+ // metadata: {
192
+ // operator: 'AND',
193
+ // conditions: [
194
+ // {
195
+ // id: 'cond-flagged',
196
+ // variable_name: 'chat.has_flagged_messages',
197
+ // variable_type: 'boolean',
198
+ // condition: 'IS',
199
+ // value: true,
200
+ // },
201
+ // ],
202
+ // },
203
+ // },
204
+ // next: 'action-create-ticket',
205
+ // },
206
+ // {
207
+ // id: 'action-condition-not-flagged',
208
+ // action_metadata: {
209
+ // type: 'validate_action',
210
+ // metadata: {
211
+ // operator: 'AND',
212
+ // conditions: [
213
+ // {
214
+ // id: 'cond-unflagged',
215
+ // variable_name: 'chat.has_flagged_messages',
216
+ // variable_type: 'boolean',
217
+ // condition: 'IS',
218
+ // value: false,
219
+ // },
220
+ // ],
221
+ // },
222
+ // },
223
+ // next: 'action-send-slack',
224
+ // },
225
+ // {
226
+ // id: 'action-create-ticket',
227
+ // action_metadata: {
228
+ // type: 'create_ticket',
229
+ // metadata: {
230
+ // subject: 'Urgent Chat Follow-up',
231
+ // assignee: {
232
+ // email: 'manager@example.com',
233
+ // },
234
+ // priority: '4',
235
+ // status: 'open',
236
+ // labels: ['urgent', 'auto-created'],
237
+ // due_date: '30 minutes',
238
+ // },
239
+ // },
240
+ // next: '', // End
241
+ // },
242
+ // {
243
+ // id: 'action-send-slack',
244
+ // action_metadata: {
245
+ // type: 'send_slack_notification',
246
+ // metadata: {
247
+ // slack_payload: JSON.stringify({
248
+ // text: 'An urgent chat was received, no flagged messages.',
249
+ // }),
250
+ // url: 'https://hooks.slack.com/services/XXX/YYY/ZZZ',
251
+ // },
252
+ // },
253
+ // next: '', // End
254
+ // },
255
+ // ],
256
+ // };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@periskope/types",
3
- "version": "0.6.283",
3
+ "version": "0.6.284",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -2,3 +2,4 @@ export * from './object.types';
2
2
  export * from './rules.types';
3
3
  export * from './supabase.types';
4
4
  export * from './types';
5
+ export * from './workflows.types';
@@ -1950,6 +1950,63 @@ export type Database = {
1950
1950
  },
1951
1951
  ]
1952
1952
  }
1953
+ tbl_org_workflows: {
1954
+ Row: {
1955
+ actions: Json
1956
+ created_at: string
1957
+ deleted_at: string | null
1958
+ id: string
1959
+ is_active: boolean
1960
+ name: string
1961
+ org_id: string
1962
+ trigger: string
1963
+ trigger_metadata: Json
1964
+ updated_at: string
1965
+ updated_by: string
1966
+ }
1967
+ Insert: {
1968
+ actions?: Json
1969
+ created_at?: string
1970
+ deleted_at?: string | null
1971
+ id?: string
1972
+ is_active?: boolean
1973
+ name: string
1974
+ org_id: string
1975
+ trigger: string
1976
+ trigger_metadata?: Json
1977
+ updated_at?: string
1978
+ updated_by: string
1979
+ }
1980
+ Update: {
1981
+ actions?: Json
1982
+ created_at?: string
1983
+ deleted_at?: string | null
1984
+ id?: string
1985
+ is_active?: boolean
1986
+ name?: string
1987
+ org_id?: string
1988
+ trigger?: string
1989
+ trigger_metadata?: Json
1990
+ updated_at?: string
1991
+ updated_by?: string
1992
+ }
1993
+ Relationships: [
1994
+ {
1995
+ foreignKeyName: "tbl_org_workflows_org_id_fkey"
1996
+ columns: ["org_id"]
1997
+ isOneToOne: false
1998
+ referencedRelation: "tbl_org"
1999
+ referencedColumns: ["org_id"]
2000
+ },
2001
+ {
2002
+ foreignKeyName: "tbl_org_workflows_org_id_fkey"
2003
+ columns: ["org_id"]
2004
+ isOneToOne: false
2005
+ referencedRelation: "view_org"
2006
+ referencedColumns: ["org_id"]
2007
+ },
2008
+ ]
2009
+ }
1953
2010
  tbl_quick_replies: {
1954
2011
  Row: {
1955
2012
  command: string | null
package/src/types.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import type { default as _Stripe } from 'stripe';
2
2
  import { Merge, OverrideProperties } from 'type-fest';
3
3
  import { Filter, Rule } from './rules.types';
4
- import { Tables, TablesInsert, TablesUpdate } from './supabase.types';
4
+ import { Enums, Tables, TablesInsert, TablesUpdate } from './supabase.types';
5
+ import { WorkflowActionTypes } from './workflows.types';
5
6
 
6
7
  /* ----------------------------- TYPE SHORTHANDS ---------------------------- */
7
8
 
@@ -1287,4 +1288,4 @@ export type FreshdeskCustomFieldType = {
1287
1288
  created_at: string;
1288
1289
  updated_at: string;
1289
1290
  choices?: Choice[];
1290
- };
1291
+ };