@periskope/types 0.6.285 → 0.6.286
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/dist/supabase.types.d.ts +54 -7
- package/dist/supabase.types.d.ts.map +1 -1
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/workflows.types.d.ts +348 -0
- package/dist/workflows.types.d.ts.map +1 -0
- package/dist/workflows.types.js +305 -0
- package/mod_json_type.ps1 +108 -108
- package/mod_json_type.sh +22 -22
- package/package.json +19 -19
- package/src/index.ts +4 -4
- package/src/object.types.ts +100 -100
- package/src/rules.types.ts +2199 -2199
- package/src/supabase.types.ts +3495 -3455
- package/src/types.ts +1296 -1292
- package/tsconfig.json +18 -18
- package/tsconfig.tsbuildinfo +1 -0
- package/update_package.ps1 +21 -21
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkflowActionNameMap = exports.TriggerNameMap = exports.Triggers = void 0;
|
|
4
|
+
exports.isNormalWorkflowAction = isNormalWorkflowAction;
|
|
5
|
+
exports.isSplitPathAction = isSplitPathAction;
|
|
6
|
+
exports.isConditionLeaf = isConditionLeaf;
|
|
7
|
+
function isNormalWorkflowAction(workflow_action) {
|
|
8
|
+
return ('action_metadata' in workflow_action &&
|
|
9
|
+
workflow_action?.action_metadata?.type !== 'split_path');
|
|
10
|
+
}
|
|
11
|
+
function isSplitPathAction(workflow_action) {
|
|
12
|
+
return workflow_action.action_metadata.type === 'split_path';
|
|
13
|
+
}
|
|
14
|
+
/***************************** CONDITIONS TYPES *****************************/
|
|
15
|
+
// {
|
|
16
|
+
// "operator": "AND",
|
|
17
|
+
// "conditions": [
|
|
18
|
+
// {
|
|
19
|
+
// "id": "cond1",
|
|
20
|
+
// "variable_name": "message",
|
|
21
|
+
// "variable_type": "string",
|
|
22
|
+
// "condition": "CONTAINS",
|
|
23
|
+
// "value": "urgent"
|
|
24
|
+
// },
|
|
25
|
+
// {
|
|
26
|
+
// "operator": "OR",
|
|
27
|
+
// "conditions": [
|
|
28
|
+
// {
|
|
29
|
+
// "id": "cond2",
|
|
30
|
+
// "variable_name": "priority",
|
|
31
|
+
// "variable_type": "number",
|
|
32
|
+
// "condition": "GT",
|
|
33
|
+
// "value": 2
|
|
34
|
+
// },
|
|
35
|
+
// {
|
|
36
|
+
// "id": "cond3",
|
|
37
|
+
// "variable_name": "assigned",
|
|
38
|
+
// "variable_type": "boolean",
|
|
39
|
+
// "condition": "NKNOWN"
|
|
40
|
+
// }
|
|
41
|
+
// ]
|
|
42
|
+
// }
|
|
43
|
+
// ]
|
|
44
|
+
// }
|
|
45
|
+
var Conditions;
|
|
46
|
+
(function (Conditions) {
|
|
47
|
+
// string
|
|
48
|
+
Conditions["CONTAINS"] = "contains";
|
|
49
|
+
Conditions["NCONTAINS"] = "not contains";
|
|
50
|
+
Conditions["EQUALS"] = "equals";
|
|
51
|
+
Conditions["NEQUALS"] = "not equals";
|
|
52
|
+
Conditions["STARTS_WITH"] = "starts with";
|
|
53
|
+
Conditions["ENDS_WITH"] = "ends with";
|
|
54
|
+
// number, date, time
|
|
55
|
+
Conditions["GREATER_THAN"] = "greater than";
|
|
56
|
+
Conditions["GREATER_THAN_OR_EQUAL"] = "greater than or equal";
|
|
57
|
+
Conditions["LESS_THAN"] = "less than";
|
|
58
|
+
Conditions["LESS_THAN_OR_EQUAL"] = "less than or equal";
|
|
59
|
+
// none
|
|
60
|
+
Conditions["IS_KNOWN"] = "is known";
|
|
61
|
+
Conditions["IS_UNKNOWN"] = "is unknown";
|
|
62
|
+
// boolean
|
|
63
|
+
Conditions["IS"] = "is";
|
|
64
|
+
Conditions["IS_NOT"] = "is not";
|
|
65
|
+
// array
|
|
66
|
+
Conditions["IS_ANY_OF"] = "is any of";
|
|
67
|
+
Conditions["IS_NOT_ANY_OF"] = "is not any of";
|
|
68
|
+
// day
|
|
69
|
+
Conditions["ON"] = "on";
|
|
70
|
+
})(Conditions || (Conditions = {}));
|
|
71
|
+
function isConditionLeaf(condition) {
|
|
72
|
+
return 'id' in condition && !('operator' in condition);
|
|
73
|
+
}
|
|
74
|
+
var Triggers;
|
|
75
|
+
(function (Triggers) {
|
|
76
|
+
Triggers["MESSAGE_CREATED"] = "message.created";
|
|
77
|
+
Triggers["MESSAGE_UPDATED"] = "message.updated";
|
|
78
|
+
Triggers["MESSAGE_DELETED"] = "message.deleted";
|
|
79
|
+
Triggers["MESSAGE_FLAGGED"] = "message.flagged";
|
|
80
|
+
Triggers["MESSAGE_UNFLAGGED"] = "message.unflagged";
|
|
81
|
+
Triggers["REACTION_ADDED"] = "reaction.added";
|
|
82
|
+
Triggers["TICKET_CREATED"] = "ticket.created";
|
|
83
|
+
Triggers["TICKET_UPDATED"] = "ticket.updated";
|
|
84
|
+
Triggers["TICKET_DELETED"] = "ticket.deleted";
|
|
85
|
+
Triggers["TICKET_CLOSED"] = "ticket.closed";
|
|
86
|
+
Triggers["TICKET_DUE"] = "ticket.due";
|
|
87
|
+
Triggers["CHAT_CREATED"] = "chat.created";
|
|
88
|
+
Triggers["CHAT_LABEL_UPDATED"] = "chat.label.updated";
|
|
89
|
+
Triggers["CHAT_CLOSED"] = "chat.closed";
|
|
90
|
+
Triggers["TASK_CREATED"] = "task.created";
|
|
91
|
+
Triggers["TASK_DUE"] = "task.due";
|
|
92
|
+
})(Triggers || (exports.Triggers = Triggers = {}));
|
|
93
|
+
exports.TriggerNameMap = {
|
|
94
|
+
'chat.closed': 'Chat Closed',
|
|
95
|
+
'chat.created': 'Chat Created',
|
|
96
|
+
'chat.label.updated': 'Chat Label Updated',
|
|
97
|
+
'message.created': 'Message Created',
|
|
98
|
+
'message.deleted': 'Message Deleted',
|
|
99
|
+
'message.flagged': 'Message Flagged',
|
|
100
|
+
'message.unflagged': 'Message Unflagged',
|
|
101
|
+
'message.updated': 'Message Updated',
|
|
102
|
+
'reaction.added': 'Reaction Added',
|
|
103
|
+
'ticket.closed': 'Ticket Closed',
|
|
104
|
+
'ticket.created': 'Ticket Created',
|
|
105
|
+
'ticket.deleted': 'Ticket Deleted',
|
|
106
|
+
'ticket.due': 'Ticket Due',
|
|
107
|
+
'ticket.updated': 'Ticket Updated',
|
|
108
|
+
'task.created': 'Task Created',
|
|
109
|
+
'task.due': 'Task Due',
|
|
110
|
+
};
|
|
111
|
+
exports.WorkflowActionNameMap = {
|
|
112
|
+
add_chat_label: 'Add Chat Label',
|
|
113
|
+
add_ticket_label: 'Add Ticket Label',
|
|
114
|
+
assign_chat: 'Assign Chat',
|
|
115
|
+
assign_ticket: 'Assign Ticket',
|
|
116
|
+
attach_to_latest_ticket: 'Attach to Latest Ticket',
|
|
117
|
+
close_chat: 'Close Chat',
|
|
118
|
+
close_ticket: 'Close Ticket',
|
|
119
|
+
create_ticket: 'Create Ticket',
|
|
120
|
+
delete_message: 'Delete Message',
|
|
121
|
+
delay: 'Delay',
|
|
122
|
+
ai_prompt_check: 'AI Prompt',
|
|
123
|
+
flag_message: 'Flag Message',
|
|
124
|
+
forward_message: 'Forward Message',
|
|
125
|
+
notify_http: 'Notify HTTP',
|
|
126
|
+
remove_chat_label: 'Remove Chat Label',
|
|
127
|
+
remove_ticket_label: 'Remove Ticket Label',
|
|
128
|
+
send_email: 'Send Email',
|
|
129
|
+
send_message_to_chat: 'Send Message to Chat',
|
|
130
|
+
send_reply_message: 'Send Reply Message',
|
|
131
|
+
send_slack_notification: 'Send Slack Notification',
|
|
132
|
+
split_path: 'Split Path',
|
|
133
|
+
unflag_message: 'Unflag Message',
|
|
134
|
+
validate_action: 'Validate Action',
|
|
135
|
+
};
|
|
136
|
+
// Example workflow type ->
|
|
137
|
+
// const demoWorkflow: WorkflowType = {
|
|
138
|
+
// id: 'workflow-1',
|
|
139
|
+
// name: 'Urgent Chat Auto-Responder',
|
|
140
|
+
// trigger: Triggers.MESSAGE_CREATED,
|
|
141
|
+
// trigger_metadata: {
|
|
142
|
+
// org_phones: ['phone-1'],
|
|
143
|
+
// allow_internal_messages: false,
|
|
144
|
+
// first_action_id: 'action-validate',
|
|
145
|
+
// },
|
|
146
|
+
// actions: [
|
|
147
|
+
// {
|
|
148
|
+
// id: 'action-validate',
|
|
149
|
+
// action_metadata: {
|
|
150
|
+
// type: 'validate_action',
|
|
151
|
+
// metadata: {
|
|
152
|
+
// operator: 'AND',
|
|
153
|
+
// conditions: [
|
|
154
|
+
// {
|
|
155
|
+
// id: 'cond-1',
|
|
156
|
+
// variable_name: 'message.text',
|
|
157
|
+
// variable_type: 'string',
|
|
158
|
+
// condition: 'CONTAINS',
|
|
159
|
+
// value: 'urgent',
|
|
160
|
+
// },
|
|
161
|
+
// {
|
|
162
|
+
// id: 'cond-2',
|
|
163
|
+
// variable_name: 'chat.assigned',
|
|
164
|
+
// variable_type: 'boolean',
|
|
165
|
+
// condition: 'IS',
|
|
166
|
+
// value: false,
|
|
167
|
+
// },
|
|
168
|
+
// ],
|
|
169
|
+
// },
|
|
170
|
+
// },
|
|
171
|
+
// next: 'action-add-label',
|
|
172
|
+
// },
|
|
173
|
+
// {
|
|
174
|
+
// id: 'action-add-label',
|
|
175
|
+
// action_metadata: {
|
|
176
|
+
// type: 'add_chat_label',
|
|
177
|
+
// metadata: {
|
|
178
|
+
// labels: ['urgent'],
|
|
179
|
+
// },
|
|
180
|
+
// },
|
|
181
|
+
// next: 'action-assign-chat',
|
|
182
|
+
// },
|
|
183
|
+
// {
|
|
184
|
+
// id: 'action-assign-chat',
|
|
185
|
+
// action_metadata: {
|
|
186
|
+
// type: 'assign_chat',
|
|
187
|
+
// metadata: {
|
|
188
|
+
// assignee: {
|
|
189
|
+
// round_robin: true,
|
|
190
|
+
// emails: ['agent1@example.com', 'agent2@example.com'],
|
|
191
|
+
// assignee_check_for: 'all',
|
|
192
|
+
// },
|
|
193
|
+
// },
|
|
194
|
+
// },
|
|
195
|
+
// next: 'action-delay',
|
|
196
|
+
// },
|
|
197
|
+
// {
|
|
198
|
+
// id: 'action-delay',
|
|
199
|
+
// action_metadata: {
|
|
200
|
+
// type: 'delay',
|
|
201
|
+
// metadata: {
|
|
202
|
+
// delay: '5 minutes',
|
|
203
|
+
// },
|
|
204
|
+
// },
|
|
205
|
+
// next: 'action-send-message',
|
|
206
|
+
// },
|
|
207
|
+
// {
|
|
208
|
+
// id: 'action-send-message',
|
|
209
|
+
// action_metadata: {
|
|
210
|
+
// type: 'send_message_to_chat',
|
|
211
|
+
// metadata: {
|
|
212
|
+
// message: 'We’re on it!',
|
|
213
|
+
// chat_id: 'trigger_chat',
|
|
214
|
+
// },
|
|
215
|
+
// },
|
|
216
|
+
// next: 'action-split',
|
|
217
|
+
// },
|
|
218
|
+
// {
|
|
219
|
+
// id: 'action-split',
|
|
220
|
+
// action_metadata: {
|
|
221
|
+
// type: 'split_path',
|
|
222
|
+
// metadata: {
|
|
223
|
+
// paths: [
|
|
224
|
+
// {
|
|
225
|
+
// id: 'path-flagged',
|
|
226
|
+
// condition_action_id: 'action-condition-flagged',
|
|
227
|
+
// },
|
|
228
|
+
// {
|
|
229
|
+
// id: 'path-not-flagged',
|
|
230
|
+
// condition_action_id: 'action-condition-not-flagged',
|
|
231
|
+
// },
|
|
232
|
+
// ],
|
|
233
|
+
// },
|
|
234
|
+
// },
|
|
235
|
+
// {
|
|
236
|
+
// id: 'action-condition-flagged',
|
|
237
|
+
// action_metadata: {
|
|
238
|
+
// type: 'validate_action',
|
|
239
|
+
// metadata: {
|
|
240
|
+
// operator: 'AND',
|
|
241
|
+
// conditions: [
|
|
242
|
+
// {
|
|
243
|
+
// id: 'cond-flagged',
|
|
244
|
+
// variable_name: 'chat.has_flagged_messages',
|
|
245
|
+
// variable_type: 'boolean',
|
|
246
|
+
// condition: 'IS',
|
|
247
|
+
// value: true,
|
|
248
|
+
// },
|
|
249
|
+
// ],
|
|
250
|
+
// },
|
|
251
|
+
// },
|
|
252
|
+
// next: 'action-create-ticket',
|
|
253
|
+
// },
|
|
254
|
+
// {
|
|
255
|
+
// id: 'action-condition-not-flagged',
|
|
256
|
+
// action_metadata: {
|
|
257
|
+
// type: 'validate_action',
|
|
258
|
+
// metadata: {
|
|
259
|
+
// operator: 'AND',
|
|
260
|
+
// conditions: [
|
|
261
|
+
// {
|
|
262
|
+
// id: 'cond-unflagged',
|
|
263
|
+
// variable_name: 'chat.has_flagged_messages',
|
|
264
|
+
// variable_type: 'boolean',
|
|
265
|
+
// condition: 'IS',
|
|
266
|
+
// value: false,
|
|
267
|
+
// },
|
|
268
|
+
// ],
|
|
269
|
+
// },
|
|
270
|
+
// },
|
|
271
|
+
// next: 'action-send-slack',
|
|
272
|
+
// },
|
|
273
|
+
// {
|
|
274
|
+
// id: 'action-create-ticket',
|
|
275
|
+
// action_metadata: {
|
|
276
|
+
// type: 'create_ticket',
|
|
277
|
+
// metadata: {
|
|
278
|
+
// subject: 'Urgent Chat Follow-up',
|
|
279
|
+
// assignee: {
|
|
280
|
+
// email: 'manager@example.com',
|
|
281
|
+
// },
|
|
282
|
+
// priority: '4',
|
|
283
|
+
// status: 'open',
|
|
284
|
+
// labels: ['urgent', 'auto-created'],
|
|
285
|
+
// due_date: '30 minutes',
|
|
286
|
+
// },
|
|
287
|
+
// },
|
|
288
|
+
// next: '', // End
|
|
289
|
+
// },
|
|
290
|
+
// {
|
|
291
|
+
// id: 'action-send-slack',
|
|
292
|
+
// action_metadata: {
|
|
293
|
+
// type: 'send_slack_notification',
|
|
294
|
+
// metadata: {
|
|
295
|
+
// slack_payload: JSON.stringify({
|
|
296
|
+
// text: 'An urgent chat was received, no flagged messages.',
|
|
297
|
+
// }),
|
|
298
|
+
// url: 'https://hooks.slack.com/services/XXX/YYY/ZZZ',
|
|
299
|
+
// },
|
|
300
|
+
// },
|
|
301
|
+
// next: '', // End
|
|
302
|
+
// },
|
|
303
|
+
// ],
|
|
304
|
+
// };
|
|
305
|
+
/***************************** WORKFLOW FE TYPES @harshgour *****************************/
|
package/mod_json_type.ps1
CHANGED
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
# Define the path to the TypeScript file
|
|
2
|
-
$filePath = ".\src\supabase.types.ts"
|
|
3
|
-
|
|
4
|
-
# Read the content of the file as a single string
|
|
5
|
-
$fileContent = Get-Content $filePath -Raw
|
|
6
|
-
|
|
7
|
-
# Define the current and new type definitions
|
|
8
|
-
$oldTypeDefinition = 'export type Json =\s*\| string\s*\| number\s*\| boolean\s*\| null\s*\| \{ \[key: string\]: Json \| undefined \}\s*\| Json\[\]'
|
|
9
|
-
$newTypeDefinition = 'export type Json = { [key: string]: any } | any'
|
|
10
|
-
|
|
11
|
-
# Replace the old type definition with the new one
|
|
12
|
-
$updatedContent = $fileContent -replace $oldTypeDefinition, $newTypeDefinition
|
|
13
|
-
|
|
14
|
-
# Update interface to type
|
|
15
|
-
$oldText = 'export interface Database '
|
|
16
|
-
$newText = 'export type Database = '
|
|
17
|
-
|
|
18
|
-
$updatedContent = $updatedContent -replace $oldText, $newText
|
|
19
|
-
|
|
20
|
-
# # Append the new type definition if it doesn't exist
|
|
21
|
-
# $addContent = @"
|
|
22
|
-
# type PublicSchema = Database[Extract<keyof Database, "public">]
|
|
23
|
-
|
|
24
|
-
# export type Tables<
|
|
25
|
-
# PublicTableNameOrOptions extends
|
|
26
|
-
# | keyof (PublicSchema["Tables"] & PublicSchema["Views"])
|
|
27
|
-
# | { schema: keyof Database },
|
|
28
|
-
# TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
|
|
29
|
-
# ? keyof (Database[PublicTableNameOrOptions["schema"]]["Tables"] &
|
|
30
|
-
# Database[PublicTableNameOrOptions["schema"]]["Views"])
|
|
31
|
-
# : never = never,
|
|
32
|
-
# > = PublicTableNameOrOptions extends { schema: keyof Database }
|
|
33
|
-
# ? (Database[PublicTableNameOrOptions["schema"]]["Tables"] &
|
|
34
|
-
# Database[PublicTableNameOrOptions["schema"]]["Views"])[TableName] extends {
|
|
35
|
-
# Row: infer R
|
|
36
|
-
# }
|
|
37
|
-
# ? R
|
|
38
|
-
# : never
|
|
39
|
-
# : PublicTableNameOrOptions extends keyof (PublicSchema["Tables"] &
|
|
40
|
-
# PublicSchema["Views"])
|
|
41
|
-
# ? (PublicSchema["Tables"] &
|
|
42
|
-
# PublicSchema["Views"])[PublicTableNameOrOptions] extends {
|
|
43
|
-
# Row: infer R
|
|
44
|
-
# }
|
|
45
|
-
# ? R
|
|
46
|
-
# : never
|
|
47
|
-
# : never
|
|
48
|
-
|
|
49
|
-
# export type TablesInsert<
|
|
50
|
-
# PublicTableNameOrOptions extends
|
|
51
|
-
# | keyof PublicSchema["Tables"]
|
|
52
|
-
# | { schema: keyof Database },
|
|
53
|
-
# TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
|
|
54
|
-
# ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"]
|
|
55
|
-
# : never = never,
|
|
56
|
-
# > = PublicTableNameOrOptions extends { schema: keyof Database }
|
|
57
|
-
# ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends {
|
|
58
|
-
# Insert: infer I
|
|
59
|
-
# }
|
|
60
|
-
# ? I
|
|
61
|
-
# : never
|
|
62
|
-
# : PublicTableNameOrOptions extends keyof PublicSchema["Tables"]
|
|
63
|
-
# ? PublicSchema["Tables"][PublicTableNameOrOptions] extends {
|
|
64
|
-
# Insert: infer I
|
|
65
|
-
# }
|
|
66
|
-
# ? I
|
|
67
|
-
# : never
|
|
68
|
-
# : never
|
|
69
|
-
|
|
70
|
-
# export type TablesUpdate<
|
|
71
|
-
# PublicTableNameOrOptions extends
|
|
72
|
-
# | keyof PublicSchema["Tables"]
|
|
73
|
-
# | { schema: keyof Database },
|
|
74
|
-
# TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
|
|
75
|
-
# ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"]
|
|
76
|
-
# : never = never,
|
|
77
|
-
# > = PublicTableNameOrOptions extends { schema: keyof Database }
|
|
78
|
-
# ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends {
|
|
79
|
-
# Update: infer U
|
|
80
|
-
# }
|
|
81
|
-
# ? U
|
|
82
|
-
# : never
|
|
83
|
-
# : PublicTableNameOrOptions extends keyof PublicSchema["Tables"]
|
|
84
|
-
# ? PublicSchema["Tables"][PublicTableNameOrOptions] extends {
|
|
85
|
-
# Update: infer U
|
|
86
|
-
# }
|
|
87
|
-
# ? U
|
|
88
|
-
# : never
|
|
89
|
-
# : never
|
|
90
|
-
|
|
91
|
-
# export type Enums<
|
|
92
|
-
# PublicEnumNameOrOptions extends
|
|
93
|
-
# | keyof PublicSchema["Enums"]
|
|
94
|
-
# | { schema: keyof Database },
|
|
95
|
-
# EnumName extends PublicEnumNameOrOptions extends { schema: keyof Database }
|
|
96
|
-
# ? keyof Database[PublicEnumNameOrOptions["schema"]]["Enums"]
|
|
97
|
-
# : never = never,
|
|
98
|
-
# > = PublicEnumNameOrOptions extends { schema: keyof Database }
|
|
99
|
-
# ? Database[PublicEnumNameOrOptions["schema"]]["Enums"][EnumName]
|
|
100
|
-
# : PublicEnumNameOrOptions extends keyof PublicSchema["Enums"]
|
|
101
|
-
# ? PublicSchema["Enums"][PublicEnumNameOrOptions]
|
|
102
|
-
# : never
|
|
103
|
-
# "@
|
|
104
|
-
|
|
105
|
-
# # Append the new content to the updated content
|
|
106
|
-
# $updatedContent += $addContent
|
|
107
|
-
|
|
108
|
-
# Write the updated content back to the file
|
|
1
|
+
# Define the path to the TypeScript file
|
|
2
|
+
$filePath = ".\src\supabase.types.ts"
|
|
3
|
+
|
|
4
|
+
# Read the content of the file as a single string
|
|
5
|
+
$fileContent = Get-Content $filePath -Raw
|
|
6
|
+
|
|
7
|
+
# Define the current and new type definitions
|
|
8
|
+
$oldTypeDefinition = 'export type Json =\s*\| string\s*\| number\s*\| boolean\s*\| null\s*\| \{ \[key: string\]: Json \| undefined \}\s*\| Json\[\]'
|
|
9
|
+
$newTypeDefinition = 'export type Json = { [key: string]: any } | any'
|
|
10
|
+
|
|
11
|
+
# Replace the old type definition with the new one
|
|
12
|
+
$updatedContent = $fileContent -replace $oldTypeDefinition, $newTypeDefinition
|
|
13
|
+
|
|
14
|
+
# Update interface to type
|
|
15
|
+
$oldText = 'export interface Database '
|
|
16
|
+
$newText = 'export type Database = '
|
|
17
|
+
|
|
18
|
+
$updatedContent = $updatedContent -replace $oldText, $newText
|
|
19
|
+
|
|
20
|
+
# # Append the new type definition if it doesn't exist
|
|
21
|
+
# $addContent = @"
|
|
22
|
+
# type PublicSchema = Database[Extract<keyof Database, "public">]
|
|
23
|
+
|
|
24
|
+
# export type Tables<
|
|
25
|
+
# PublicTableNameOrOptions extends
|
|
26
|
+
# | keyof (PublicSchema["Tables"] & PublicSchema["Views"])
|
|
27
|
+
# | { schema: keyof Database },
|
|
28
|
+
# TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
|
|
29
|
+
# ? keyof (Database[PublicTableNameOrOptions["schema"]]["Tables"] &
|
|
30
|
+
# Database[PublicTableNameOrOptions["schema"]]["Views"])
|
|
31
|
+
# : never = never,
|
|
32
|
+
# > = PublicTableNameOrOptions extends { schema: keyof Database }
|
|
33
|
+
# ? (Database[PublicTableNameOrOptions["schema"]]["Tables"] &
|
|
34
|
+
# Database[PublicTableNameOrOptions["schema"]]["Views"])[TableName] extends {
|
|
35
|
+
# Row: infer R
|
|
36
|
+
# }
|
|
37
|
+
# ? R
|
|
38
|
+
# : never
|
|
39
|
+
# : PublicTableNameOrOptions extends keyof (PublicSchema["Tables"] &
|
|
40
|
+
# PublicSchema["Views"])
|
|
41
|
+
# ? (PublicSchema["Tables"] &
|
|
42
|
+
# PublicSchema["Views"])[PublicTableNameOrOptions] extends {
|
|
43
|
+
# Row: infer R
|
|
44
|
+
# }
|
|
45
|
+
# ? R
|
|
46
|
+
# : never
|
|
47
|
+
# : never
|
|
48
|
+
|
|
49
|
+
# export type TablesInsert<
|
|
50
|
+
# PublicTableNameOrOptions extends
|
|
51
|
+
# | keyof PublicSchema["Tables"]
|
|
52
|
+
# | { schema: keyof Database },
|
|
53
|
+
# TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
|
|
54
|
+
# ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"]
|
|
55
|
+
# : never = never,
|
|
56
|
+
# > = PublicTableNameOrOptions extends { schema: keyof Database }
|
|
57
|
+
# ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends {
|
|
58
|
+
# Insert: infer I
|
|
59
|
+
# }
|
|
60
|
+
# ? I
|
|
61
|
+
# : never
|
|
62
|
+
# : PublicTableNameOrOptions extends keyof PublicSchema["Tables"]
|
|
63
|
+
# ? PublicSchema["Tables"][PublicTableNameOrOptions] extends {
|
|
64
|
+
# Insert: infer I
|
|
65
|
+
# }
|
|
66
|
+
# ? I
|
|
67
|
+
# : never
|
|
68
|
+
# : never
|
|
69
|
+
|
|
70
|
+
# export type TablesUpdate<
|
|
71
|
+
# PublicTableNameOrOptions extends
|
|
72
|
+
# | keyof PublicSchema["Tables"]
|
|
73
|
+
# | { schema: keyof Database },
|
|
74
|
+
# TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
|
|
75
|
+
# ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"]
|
|
76
|
+
# : never = never,
|
|
77
|
+
# > = PublicTableNameOrOptions extends { schema: keyof Database }
|
|
78
|
+
# ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends {
|
|
79
|
+
# Update: infer U
|
|
80
|
+
# }
|
|
81
|
+
# ? U
|
|
82
|
+
# : never
|
|
83
|
+
# : PublicTableNameOrOptions extends keyof PublicSchema["Tables"]
|
|
84
|
+
# ? PublicSchema["Tables"][PublicTableNameOrOptions] extends {
|
|
85
|
+
# Update: infer U
|
|
86
|
+
# }
|
|
87
|
+
# ? U
|
|
88
|
+
# : never
|
|
89
|
+
# : never
|
|
90
|
+
|
|
91
|
+
# export type Enums<
|
|
92
|
+
# PublicEnumNameOrOptions extends
|
|
93
|
+
# | keyof PublicSchema["Enums"]
|
|
94
|
+
# | { schema: keyof Database },
|
|
95
|
+
# EnumName extends PublicEnumNameOrOptions extends { schema: keyof Database }
|
|
96
|
+
# ? keyof Database[PublicEnumNameOrOptions["schema"]]["Enums"]
|
|
97
|
+
# : never = never,
|
|
98
|
+
# > = PublicEnumNameOrOptions extends { schema: keyof Database }
|
|
99
|
+
# ? Database[PublicEnumNameOrOptions["schema"]]["Enums"][EnumName]
|
|
100
|
+
# : PublicEnumNameOrOptions extends keyof PublicSchema["Enums"]
|
|
101
|
+
# ? PublicSchema["Enums"][PublicEnumNameOrOptions]
|
|
102
|
+
# : never
|
|
103
|
+
# "@
|
|
104
|
+
|
|
105
|
+
# # Append the new content to the updated content
|
|
106
|
+
# $updatedContent += $addContent
|
|
107
|
+
|
|
108
|
+
# Write the updated content back to the file
|
|
109
109
|
$updatedContent | Set-Content $filePath
|
package/mod_json_type.sh
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Define the path to the TypeScript file
|
|
4
|
-
filePath="./src/supabase.types.ts"
|
|
5
|
-
|
|
6
|
-
# Read the content of the file as a single string
|
|
7
|
-
fileContent=$(cat "$filePath")
|
|
8
|
-
|
|
9
|
-
# Define the current and new type definitions using Perl-style regular expressions
|
|
10
|
-
oldTypeDefinition='export type Json =\s*\| string\s*\| number\s*\| boolean\s*\| null\s*\| \{ \[key: string\]: Json \| undefined \}\s*\| Json\[\]'
|
|
11
|
-
newTypeDefinition='export type Json = { [key: string]: any } | any'
|
|
12
|
-
|
|
13
|
-
# Replace the old type definition with the new one
|
|
14
|
-
updatedContent=$(echo "$fileContent" | perl -0777 -pe "s/$oldTypeDefinition/$newTypeDefinition/g")
|
|
15
|
-
|
|
16
|
-
# Update interface to type
|
|
17
|
-
oldText='export interface Database '
|
|
18
|
-
newText='export type Database = '
|
|
19
|
-
|
|
20
|
-
updatedContent=$(echo "$updatedContent" | sed "s/$oldText/$newText/g")
|
|
21
|
-
|
|
22
|
-
# Write the updated content back to the file
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Define the path to the TypeScript file
|
|
4
|
+
filePath="./src/supabase.types.ts"
|
|
5
|
+
|
|
6
|
+
# Read the content of the file as a single string
|
|
7
|
+
fileContent=$(cat "$filePath")
|
|
8
|
+
|
|
9
|
+
# Define the current and new type definitions using Perl-style regular expressions
|
|
10
|
+
oldTypeDefinition='export type Json =\s*\| string\s*\| number\s*\| boolean\s*\| null\s*\| \{ \[key: string\]: Json \| undefined \}\s*\| Json\[\]'
|
|
11
|
+
newTypeDefinition='export type Json = { [key: string]: any } | any'
|
|
12
|
+
|
|
13
|
+
# Replace the old type definition with the new one
|
|
14
|
+
updatedContent=$(echo "$fileContent" | perl -0777 -pe "s/$oldTypeDefinition/$newTypeDefinition/g")
|
|
15
|
+
|
|
16
|
+
# Update interface to type
|
|
17
|
+
oldText='export interface Database '
|
|
18
|
+
newText='export type Database = '
|
|
19
|
+
|
|
20
|
+
updatedContent=$(echo "$updatedContent" | sed "s/$oldText/$newText/g")
|
|
21
|
+
|
|
22
|
+
# Write the updated content back to the file
|
|
23
23
|
echo "$updatedContent" > "$filePath"
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name":
|
|
3
|
-
"version":
|
|
4
|
-
"private":
|
|
5
|
-
"main":
|
|
6
|
-
"types":
|
|
7
|
-
"dependencies":
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"scripts":
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@periskope/types",
|
|
3
|
+
"version": "0.6.286",
|
|
4
|
+
"private": false,
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@types/pg": "8.11.2",
|
|
9
|
+
"pg": "^8.11.3",
|
|
10
|
+
"stripe": "17.6.0",
|
|
11
|
+
"ts-node": "^10.9.2",
|
|
12
|
+
"type-fest": "^4.8.3"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"dev": "tsc --watch",
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"update-package": "tsc && npm publish --access public"
|
|
18
|
+
}
|
|
19
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './object.types';
|
|
2
|
-
export * from './rules.types';
|
|
3
|
-
export * from './supabase.types';
|
|
4
|
-
export * from './types';
|
|
1
|
+
export * from './object.types';
|
|
2
|
+
export * from './rules.types';
|
|
3
|
+
export * from './supabase.types';
|
|
4
|
+
export * from './types';
|