prostgles-server 4.2.159 → 4.2.161
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/Auth/setEmailProvider.js +2 -2
- package/dist/Auth/setEmailProvider.js.map +1 -1
- package/lib/Auth/AuthHandler.ts +436 -0
- package/lib/Auth/AuthTypes.ts +280 -0
- package/lib/Auth/getSafeReturnURL.ts +35 -0
- package/lib/Auth/sendEmail.ts +83 -0
- package/lib/Auth/setAuthProviders.ts +128 -0
- package/lib/Auth/setEmailProvider.ts +85 -0
- package/lib/Auth/setupAuthRoutes.ts +161 -0
- package/lib/DBEventsManager.ts +178 -0
- package/lib/DBSchemaBuilder.ts +225 -0
- package/lib/DboBuilder/DboBuilder.ts +319 -0
- package/lib/DboBuilder/DboBuilderTypes.ts +361 -0
- package/lib/DboBuilder/QueryBuilder/Functions.ts +1153 -0
- package/lib/DboBuilder/QueryBuilder/QueryBuilder.ts +288 -0
- package/lib/DboBuilder/QueryBuilder/getJoinQuery.ts +263 -0
- package/lib/DboBuilder/QueryBuilder/getNewQuery.ts +271 -0
- package/lib/DboBuilder/QueryBuilder/getSelectQuery.ts +136 -0
- package/lib/DboBuilder/QueryBuilder/prepareHaving.ts +22 -0
- package/lib/DboBuilder/QueryStreamer.ts +250 -0
- package/lib/DboBuilder/TableHandler/DataValidator.ts +428 -0
- package/lib/DboBuilder/TableHandler/TableHandler.ts +205 -0
- package/lib/DboBuilder/TableHandler/delete.ts +115 -0
- package/lib/DboBuilder/TableHandler/insert.ts +183 -0
- package/lib/DboBuilder/TableHandler/insertTest.ts +78 -0
- package/lib/DboBuilder/TableHandler/onDeleteFromFileTable.ts +62 -0
- package/lib/DboBuilder/TableHandler/runInsertUpdateQuery.ts +134 -0
- package/lib/DboBuilder/TableHandler/update.ts +126 -0
- package/lib/DboBuilder/TableHandler/updateBatch.ts +49 -0
- package/lib/DboBuilder/TableHandler/updateFile.ts +48 -0
- package/lib/DboBuilder/TableHandler/upsert.ts +34 -0
- package/lib/DboBuilder/ViewHandler/ViewHandler.ts +393 -0
- package/lib/DboBuilder/ViewHandler/count.ts +38 -0
- package/lib/DboBuilder/ViewHandler/find.ts +153 -0
- package/lib/DboBuilder/ViewHandler/getExistsCondition.ts +73 -0
- package/lib/DboBuilder/ViewHandler/getExistsFilters.ts +74 -0
- package/lib/DboBuilder/ViewHandler/getInfo.ts +32 -0
- package/lib/DboBuilder/ViewHandler/getTableJoinQuery.ts +84 -0
- package/lib/DboBuilder/ViewHandler/parseComplexFilter.ts +96 -0
- package/lib/DboBuilder/ViewHandler/parseFieldFilter.ts +105 -0
- package/lib/DboBuilder/ViewHandler/parseJoinPath.ts +208 -0
- package/lib/DboBuilder/ViewHandler/prepareSortItems.ts +163 -0
- package/lib/DboBuilder/ViewHandler/prepareWhere.ts +90 -0
- package/lib/DboBuilder/ViewHandler/size.ts +37 -0
- package/lib/DboBuilder/ViewHandler/subscribe.ts +118 -0
- package/lib/DboBuilder/ViewHandler/validateViewRules.ts +70 -0
- package/lib/DboBuilder/dboBuilderUtils.ts +222 -0
- package/lib/DboBuilder/getColumns.ts +114 -0
- package/lib/DboBuilder/getCondition.ts +201 -0
- package/lib/DboBuilder/getSubscribeRelatedTables.ts +190 -0
- package/lib/DboBuilder/getTablesForSchemaPostgresSQL.ts +426 -0
- package/lib/DboBuilder/insertNestedRecords.ts +355 -0
- package/lib/DboBuilder/parseUpdateRules.ts +187 -0
- package/lib/DboBuilder/prepareShortestJoinPaths.ts +186 -0
- package/lib/DboBuilder/runSQL.ts +182 -0
- package/lib/DboBuilder/runTransaction.ts +50 -0
- package/lib/DboBuilder/sqlErrCodeToMsg.ts +254 -0
- package/lib/DboBuilder/uploadFile.ts +69 -0
- package/lib/Event_Trigger_Tags.ts +118 -0
- package/lib/FileManager/FileManager.ts +358 -0
- package/lib/FileManager/getValidatedFileType.ts +69 -0
- package/lib/FileManager/initFileManager.ts +187 -0
- package/lib/FileManager/upload.ts +62 -0
- package/lib/FileManager/uploadStream.ts +79 -0
- package/lib/Filtering.ts +463 -0
- package/lib/JSONBValidation/validate_jsonb_schema_sql.ts +502 -0
- package/lib/JSONBValidation/validation.ts +143 -0
- package/lib/Logging.ts +127 -0
- package/lib/PostgresNotifListenManager.ts +143 -0
- package/lib/Prostgles.ts +485 -0
- package/lib/ProstglesTypes.ts +196 -0
- package/lib/PubSubManager/PubSubManager.ts +609 -0
- package/lib/PubSubManager/addSub.ts +138 -0
- package/lib/PubSubManager/addSync.ts +141 -0
- package/lib/PubSubManager/getCreatePubSubManagerError.ts +72 -0
- package/lib/PubSubManager/getPubSubManagerInitQuery.ts +662 -0
- package/lib/PubSubManager/initPubSubManager.ts +79 -0
- package/lib/PubSubManager/notifListener.ts +173 -0
- package/lib/PubSubManager/orphanTriggerCheck.ts +70 -0
- package/lib/PubSubManager/pushSubData.ts +55 -0
- package/lib/PublishParser/PublishParser.ts +162 -0
- package/lib/PublishParser/getFileTableRules.ts +124 -0
- package/lib/PublishParser/getSchemaFromPublish.ts +141 -0
- package/lib/PublishParser/getTableRulesWithoutFileTable.ts +177 -0
- package/lib/PublishParser/publishTypesAndUtils.ts +399 -0
- package/lib/RestApi.ts +127 -0
- package/lib/SchemaWatch/SchemaWatch.ts +90 -0
- package/lib/SchemaWatch/createSchemaWatchEventTrigger.ts +3 -0
- package/lib/SchemaWatch/getValidatedWatchSchemaType.ts +45 -0
- package/lib/SchemaWatch/getWatchSchemaTagList.ts +27 -0
- package/lib/SyncReplication.ts +557 -0
- package/lib/TableConfig/TableConfig.ts +468 -0
- package/lib/TableConfig/getColumnDefinitionQuery.ts +111 -0
- package/lib/TableConfig/getConstraintDefinitionQueries.ts +95 -0
- package/lib/TableConfig/getFutureTableSchema.ts +64 -0
- package/lib/TableConfig/getPGIndexes.ts +53 -0
- package/lib/TableConfig/getTableColumnQueries.ts +129 -0
- package/lib/TableConfig/initTableConfig.ts +326 -0
- package/lib/index.ts +13 -0
- package/lib/initProstgles.ts +319 -0
- package/lib/onSocketConnected.ts +102 -0
- package/lib/runClientRequest.ts +129 -0
- package/lib/shortestPath.ts +122 -0
- package/lib/typeTests/DBoGenerated.d.ts +320 -0
- package/lib/typeTests/dboTypeCheck.ts +81 -0
- package/lib/utils.ts +15 -0
- package/package.json +1 -1
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
export const sqlErrCodeToMsg = (code: string) => {
|
|
2
|
+
const errs = {
|
|
3
|
+
"00000": "successful_completion",
|
|
4
|
+
"01000": "warning",
|
|
5
|
+
"0100C": "dynamic_result_sets_returned",
|
|
6
|
+
"01008": "implicit_zero_bit_padding",
|
|
7
|
+
"01003": "null_value_eliminated_in_set_function",
|
|
8
|
+
"01007": "privilege_not_granted",
|
|
9
|
+
"01006": "privilege_not_revoked",
|
|
10
|
+
"01004": "string_data_right_truncation",
|
|
11
|
+
"01P01": "deprecated_feature",
|
|
12
|
+
"02000": "no_data",
|
|
13
|
+
"02001": "no_additional_dynamic_result_sets_returned",
|
|
14
|
+
"03000": "sql_statement_not_yet_complete",
|
|
15
|
+
"08000": "connection_exception",
|
|
16
|
+
"08003": "connection_does_not_exist",
|
|
17
|
+
"08006": "connection_failure",
|
|
18
|
+
"08001": "sqlclient_unable_to_establish_sqlconnection",
|
|
19
|
+
"08004": "sqlserver_rejected_establishment_of_sqlconnection",
|
|
20
|
+
"08007": "transaction_resolution_unknown",
|
|
21
|
+
"08P01": "protocol_violation",
|
|
22
|
+
"09000": "triggered_action_exception",
|
|
23
|
+
"0A000": "feature_not_supported",
|
|
24
|
+
"0B000": "invalid_transaction_initiation",
|
|
25
|
+
"0F000": "locator_exception",
|
|
26
|
+
"0F001": "invalid_locator_specification",
|
|
27
|
+
"0L000": "invalid_grantor",
|
|
28
|
+
"0LP01": "invalid_grant_operation",
|
|
29
|
+
"0P000": "invalid_role_specification",
|
|
30
|
+
"0Z000": "diagnostics_exception",
|
|
31
|
+
"0Z002": "stacked_diagnostics_accessed_without_active_handler",
|
|
32
|
+
"20000": "case_not_found",
|
|
33
|
+
"21000": "cardinality_violation",
|
|
34
|
+
"22000": "data_exception",
|
|
35
|
+
"2202E": "array_subscript_error",
|
|
36
|
+
"22021": "character_not_in_repertoire",
|
|
37
|
+
"22008": "datetime_field_overflow",
|
|
38
|
+
"22012": "division_by_zero",
|
|
39
|
+
"22005": "error_in_assignment",
|
|
40
|
+
"2200B": "escape_character_conflict",
|
|
41
|
+
"22022": "indicator_overflow",
|
|
42
|
+
"22015": "interval_field_overflow",
|
|
43
|
+
"2201E": "invalid_argument_for_logarithm",
|
|
44
|
+
"22014": "invalid_argument_for_ntile_function",
|
|
45
|
+
"22016": "invalid_argument_for_nth_value_function",
|
|
46
|
+
"2201F": "invalid_argument_for_power_function",
|
|
47
|
+
"2201G": "invalid_argument_for_width_bucket_function",
|
|
48
|
+
"22018": "invalid_character_value_for_cast",
|
|
49
|
+
"22007": "invalid_datetime_format",
|
|
50
|
+
"22019": "invalid_escape_character",
|
|
51
|
+
"2200D": "invalid_escape_octet",
|
|
52
|
+
"22025": "invalid_escape_sequence",
|
|
53
|
+
"22P06": "nonstandard_use_of_escape_character",
|
|
54
|
+
"22010": "invalid_indicator_parameter_value",
|
|
55
|
+
"22023": "invalid_parameter_value",
|
|
56
|
+
"2201B": "invalid_regular_expression",
|
|
57
|
+
"2201W": "invalid_row_count_in_limit_clause",
|
|
58
|
+
"2201X": "invalid_row_count_in_result_offset_clause",
|
|
59
|
+
"2202H": "invalid_tablesample_argument",
|
|
60
|
+
"2202G": "invalid_tablesample_repeat",
|
|
61
|
+
"22009": "invalid_time_zone_displacement_value",
|
|
62
|
+
"2200C": "invalid_use_of_escape_character",
|
|
63
|
+
"2200G": "most_specific_type_mismatch",
|
|
64
|
+
"22004": "null_value_not_allowed",
|
|
65
|
+
"22002": "null_value_no_indicator_parameter",
|
|
66
|
+
"22003": "numeric_value_out_of_range",
|
|
67
|
+
"2200H": "sequence_generator_limit_exceeded",
|
|
68
|
+
"22026": "string_data_length_mismatch",
|
|
69
|
+
"22001": "string_data_right_truncation",
|
|
70
|
+
"22011": "substring_error",
|
|
71
|
+
"22027": "trim_error",
|
|
72
|
+
"22024": "unterminated_c_string",
|
|
73
|
+
"2200F": "zero_length_character_string",
|
|
74
|
+
"22P01": "floating_point_exception",
|
|
75
|
+
"22P02": "invalid_text_representation",
|
|
76
|
+
"22P03": "invalid_binary_representation",
|
|
77
|
+
"22P04": "bad_copy_file_format",
|
|
78
|
+
"22P05": "untranslatable_character",
|
|
79
|
+
"2200L": "not_an_xml_document",
|
|
80
|
+
"2200M": "invalid_xml_document",
|
|
81
|
+
"2200N": "invalid_xml_content",
|
|
82
|
+
"2200S": "invalid_xml_comment",
|
|
83
|
+
"2200T": "invalid_xml_processing_instruction",
|
|
84
|
+
"23000": "integrity_constraint_violation",
|
|
85
|
+
"23001": "restrict_violation",
|
|
86
|
+
"23502": "not_null_violation",
|
|
87
|
+
"23503": "foreign_key_violation",
|
|
88
|
+
"23505": "unique_violation",
|
|
89
|
+
"23514": "check_violation",
|
|
90
|
+
"23P01": "exclusion_violation",
|
|
91
|
+
"24000": "invalid_cursor_state",
|
|
92
|
+
"25000": "invalid_transaction_state",
|
|
93
|
+
"25001": "active_sql_transaction",
|
|
94
|
+
"25002": "branch_transaction_already_active",
|
|
95
|
+
"25008": "held_cursor_requires_same_isolation_level",
|
|
96
|
+
"25003": "inappropriate_access_mode_for_branch_transaction",
|
|
97
|
+
"25004": "inappropriate_isolation_level_for_branch_transaction",
|
|
98
|
+
"25005": "no_active_sql_transaction_for_branch_transaction",
|
|
99
|
+
"25006": "read_only_sql_transaction",
|
|
100
|
+
"25007": "schema_and_data_statement_mixing_not_supported",
|
|
101
|
+
"25P01": "no_active_sql_transaction",
|
|
102
|
+
"25P02": "in_failed_sql_transaction",
|
|
103
|
+
"25P03": "idle_in_transaction_session_timeout",
|
|
104
|
+
"26000": "invalid_sql_statement_name",
|
|
105
|
+
"27000": "triggered_data_change_violation",
|
|
106
|
+
"28000": "invalid_authorization_specification",
|
|
107
|
+
"28P01": "invalid_password",
|
|
108
|
+
"2B000": "dependent_privilege_descriptors_still_exist",
|
|
109
|
+
"2BP01": "dependent_objects_still_exist",
|
|
110
|
+
"2D000": "invalid_transaction_termination",
|
|
111
|
+
"2F000": "sql_routine_exception",
|
|
112
|
+
"2F005": "function_executed_no_return_statement",
|
|
113
|
+
"2F002": "modifying_sql_data_not_permitted",
|
|
114
|
+
"2F003": "prohibited_sql_statement_attempted",
|
|
115
|
+
"2F004": "reading_sql_data_not_permitted",
|
|
116
|
+
"34000": "invalid_cursor_name",
|
|
117
|
+
"38000": "external_routine_exception",
|
|
118
|
+
"38001": "containing_sql_not_permitted",
|
|
119
|
+
"38002": "modifying_sql_data_not_permitted",
|
|
120
|
+
"38003": "prohibited_sql_statement_attempted",
|
|
121
|
+
"38004": "reading_sql_data_not_permitted",
|
|
122
|
+
"39000": "external_routine_invocation_exception",
|
|
123
|
+
"39001": "invalid_sqlstate_returned",
|
|
124
|
+
"39004": "null_value_not_allowed",
|
|
125
|
+
"39P01": "trigger_protocol_violated",
|
|
126
|
+
"39P02": "srf_protocol_violated",
|
|
127
|
+
"39P03": "event_trigger_protocol_violated",
|
|
128
|
+
"3B000": "savepoint_exception",
|
|
129
|
+
"3B001": "invalid_savepoint_specification",
|
|
130
|
+
"3D000": "invalid_catalog_name",
|
|
131
|
+
"3F000": "invalid_schema_name",
|
|
132
|
+
"40000": "transaction_rollback",
|
|
133
|
+
"40002": "transaction_integrity_constraint_violation",
|
|
134
|
+
"40001": "serialization_failure",
|
|
135
|
+
"40003": "statement_completion_unknown",
|
|
136
|
+
"40P01": "deadlock_detected",
|
|
137
|
+
"42000": "syntax_error_or_access_rule_violation",
|
|
138
|
+
"42601": "syntax_error",
|
|
139
|
+
"42501": "insufficient_privilege",
|
|
140
|
+
"42846": "cannot_coerce",
|
|
141
|
+
"42803": "grouping_error",
|
|
142
|
+
"42P20": "windowing_error",
|
|
143
|
+
"42P19": "invalid_recursion",
|
|
144
|
+
"42830": "invalid_foreign_key",
|
|
145
|
+
"42602": "invalid_name",
|
|
146
|
+
"42622": "name_too_long",
|
|
147
|
+
"42939": "reserved_name",
|
|
148
|
+
"42804": "datatype_mismatch",
|
|
149
|
+
"42P18": "indeterminate_datatype",
|
|
150
|
+
"42P21": "collation_mismatch",
|
|
151
|
+
"42P22": "indeterminate_collation",
|
|
152
|
+
"42809": "wrong_object_type",
|
|
153
|
+
"428C9": "generated_always",
|
|
154
|
+
"42703": "undefined_column",
|
|
155
|
+
"42883": "undefined_function",
|
|
156
|
+
"42P01": "undefined_table",
|
|
157
|
+
"42P02": "undefined_parameter",
|
|
158
|
+
"42704": "undefined_object",
|
|
159
|
+
"42701": "duplicate_column",
|
|
160
|
+
"42P03": "duplicate_cursor",
|
|
161
|
+
"42P04": "duplicate_database",
|
|
162
|
+
"42723": "duplicate_function",
|
|
163
|
+
"42P05": "duplicate_prepared_statement",
|
|
164
|
+
"42P06": "duplicate_schema",
|
|
165
|
+
"42P07": "duplicate_table",
|
|
166
|
+
"42712": "duplicate_alias",
|
|
167
|
+
"42710": "duplicate_object",
|
|
168
|
+
"42702": "ambiguous_column",
|
|
169
|
+
"42725": "ambiguous_function",
|
|
170
|
+
"42P08": "ambiguous_parameter",
|
|
171
|
+
"42P09": "ambiguous_alias",
|
|
172
|
+
"42P10": "invalid_column_reference",
|
|
173
|
+
"42611": "invalid_column_definition",
|
|
174
|
+
"42P11": "invalid_cursor_definition",
|
|
175
|
+
"42P12": "invalid_database_definition",
|
|
176
|
+
"42P13": "invalid_function_definition",
|
|
177
|
+
"42P14": "invalid_prepared_statement_definition",
|
|
178
|
+
"42P15": "invalid_schema_definition",
|
|
179
|
+
"42P16": "invalid_table_definition",
|
|
180
|
+
"42P17": "invalid_object_definition",
|
|
181
|
+
"44000": "with_check_option_violation",
|
|
182
|
+
"53000": "insufficient_resources",
|
|
183
|
+
"53100": "disk_full",
|
|
184
|
+
"53200": "out_of_memory",
|
|
185
|
+
"53300": "too_many_connections",
|
|
186
|
+
"53400": "configuration_limit_exceeded",
|
|
187
|
+
"54000": "program_limit_exceeded",
|
|
188
|
+
"54001": "statement_too_complex",
|
|
189
|
+
"54011": "too_many_columns",
|
|
190
|
+
"54023": "too_many_arguments",
|
|
191
|
+
"55000": "object_not_in_prerequisite_state",
|
|
192
|
+
"55006": "object_in_use",
|
|
193
|
+
"55P02": "cant_change_runtime_param",
|
|
194
|
+
"55P03": "lock_not_available",
|
|
195
|
+
"57000": "operator_intervention",
|
|
196
|
+
"57014": "query_canceled",
|
|
197
|
+
"57P01": "admin_shutdown",
|
|
198
|
+
"57P02": "crash_shutdown",
|
|
199
|
+
"57P03": "cannot_connect_now",
|
|
200
|
+
"57P04": "database_dropped",
|
|
201
|
+
"58000": "system_error",
|
|
202
|
+
"58030": "io_error",
|
|
203
|
+
"58P01": "undefined_file",
|
|
204
|
+
"58P02": "duplicate_file",
|
|
205
|
+
"72000": "snapshot_too_old",
|
|
206
|
+
"F0000": "config_file_error",
|
|
207
|
+
"F0001": "lock_file_exists",
|
|
208
|
+
"HV000": "fdw_error",
|
|
209
|
+
"HV005": "fdw_column_name_not_found",
|
|
210
|
+
"HV002": "fdw_dynamic_parameter_value_needed",
|
|
211
|
+
"HV010": "fdw_function_sequence_error",
|
|
212
|
+
"HV021": "fdw_inconsistent_descriptor_information",
|
|
213
|
+
"HV024": "fdw_invalid_attribute_value",
|
|
214
|
+
"HV007": "fdw_invalid_column_name",
|
|
215
|
+
"HV008": "fdw_invalid_column_number",
|
|
216
|
+
"HV004": "fdw_invalid_data_type",
|
|
217
|
+
"HV006": "fdw_invalid_data_type_descriptors",
|
|
218
|
+
"HV091": "fdw_invalid_descriptor_field_identifier",
|
|
219
|
+
"HV00B": "fdw_invalid_handle",
|
|
220
|
+
"HV00C": "fdw_invalid_option_index",
|
|
221
|
+
"HV00D": "fdw_invalid_option_name",
|
|
222
|
+
"HV090": "fdw_invalid_string_length_or_buffer_length",
|
|
223
|
+
"HV00A": "fdw_invalid_string_format",
|
|
224
|
+
"HV009": "fdw_invalid_use_of_null_pointer",
|
|
225
|
+
"HV014": "fdw_too_many_handles",
|
|
226
|
+
"HV001": "fdw_out_of_memory",
|
|
227
|
+
"HV00P": "fdw_no_schemas",
|
|
228
|
+
"HV00J": "fdw_option_name_not_found",
|
|
229
|
+
"HV00K": "fdw_reply_handle",
|
|
230
|
+
"HV00Q": "fdw_schema_not_found",
|
|
231
|
+
"HV00R": "fdw_table_not_found",
|
|
232
|
+
"HV00L": "fdw_unable_to_create_execution",
|
|
233
|
+
"HV00M": "fdw_unable_to_create_reply",
|
|
234
|
+
"HV00N": "fdw_unable_to_establish_connection",
|
|
235
|
+
"P0000": "plpgsql_error",
|
|
236
|
+
"P0001": "raise_exception",
|
|
237
|
+
"P0002": "no_data_found",
|
|
238
|
+
"P0003": "too_many_rows",
|
|
239
|
+
"P0004": "assert_failure",
|
|
240
|
+
"XX000": "internal_error",
|
|
241
|
+
"XX001": "data_corrupted",
|
|
242
|
+
"XX002": "index_corrupted"
|
|
243
|
+
},
|
|
244
|
+
c2 = { "20000": "case_not_found", "21000": "cardinality_violation", "22000": "data_exception", "22001": "string_data_right_truncation", "22002": "null_value_no_indicator_parameter", "22003": "numeric_value_out_of_range", "22004": "null_value_not_allowed", "22005": "error_in_assignment", "22007": "invalid_datetime_format", "22008": "datetime_field_overflow", "22009": "invalid_time_zone_displacement_value", "22010": "invalid_indicator_parameter_value", "22011": "substring_error", "22012": "division_by_zero", "22013": "invalid_preceding_or_following_size", "22014": "invalid_argument_for_ntile_function", "22015": "interval_field_overflow", "22016": "invalid_argument_for_nth_value_function", "22018": "invalid_character_value_for_cast", "22019": "invalid_escape_character", "22021": "character_not_in_repertoire", "22022": "indicator_overflow", "22023": "invalid_parameter_value", "22024": "unterminated_c_string", "22025": "invalid_escape_sequence", "22026": "string_data_length_mismatch", "22027": "trim_error", "22030": "duplicate_json_object_key_value", "22031": "invalid_argument_for_sql_json_datetime_function", "22032": "invalid_json_text", "22033": "invalid_sql_json_subscript", "22034": "more_than_one_sql_json_item", "22035": "no_sql_json_item", "22036": "non_numeric_sql_json_item", "22037": "non_unique_keys_in_a_json_object", "22038": "singleton_sql_json_item_required", "22039": "sql_json_array_not_found", "23000": "integrity_constraint_violation", "23001": "restrict_violation", "23502": "not_null_violation", "23503": "foreign_key_violation", "23505": "unique_violation", "23514": "check_violation", "24000": "invalid_cursor_state", "25000": "invalid_transaction_state", "25001": "active_sql_transaction", "25002": "branch_transaction_already_active", "25003": "inappropriate_access_mode_for_branch_transaction", "25004": "inappropriate_isolation_level_for_branch_transaction", "25005": "no_active_sql_transaction_for_branch_transaction", "25006": "read_only_sql_transaction", "25007": "schema_and_data_statement_mixing_not_supported", "25008": "held_cursor_requires_same_isolation_level", "26000": "invalid_sql_statement_name", "27000": "triggered_data_change_violation", "28000": "invalid_authorization_specification", "34000": "invalid_cursor_name", "38000": "external_routine_exception", "38001": "containing_sql_not_permitted", "38002": "modifying_sql_data_not_permitted", "38003": "prohibited_sql_statement_attempted", "38004": "reading_sql_data_not_permitted", "39000": "external_routine_invocation_exception", "39001": "invalid_sqlstate_returned", "39004": "null_value_not_allowed", "40000": "transaction_rollback", "40001": "serialization_failure", "40002": "transaction_integrity_constraint_violation", "40003": "statement_completion_unknown", "42000": "syntax_error_or_access_rule_violation", "42501": "insufficient_privilege", "42601": "syntax_error", "42602": "invalid_name", "42611": "invalid_column_definition", "42622": "name_too_long", "42701": "duplicate_column", "42702": "ambiguous_column", "42703": "undefined_column", "42704": "undefined_object", "42710": "duplicate_object", "42712": "duplicate_alias", "42723": "duplicate_function", "42725": "ambiguous_function", "42803": "grouping_error", "42804": "datatype_mismatch", "42809": "wrong_object_type", "42830": "invalid_foreign_key", "42846": "cannot_coerce", "42883": "undefined_function", "42939": "reserved_name", "44000": "with_check_option_violation", "53000": "insufficient_resources", "53100": "disk_full", "53200": "out_of_memory", "53300": "too_many_connections", "53400": "configuration_limit_exceeded", "54000": "program_limit_exceeded", "54001": "statement_too_complex", "54011": "too_many_columns", "54023": "too_many_arguments", "55000": "object_not_in_prerequisite_state", "55006": "object_in_use", "57000": "operator_intervention", "57014": "query_canceled", "58000": "system_error", "58030": "io_error", "72000": "snapshot_too_old", "00000": "successful_completion", "01000": "warning", "0100C": "dynamic_result_sets_returned", "01008": "implicit_zero_bit_padding", "01003": "null_value_eliminated_in_set_function", "01007": "privilege_not_granted", "01006": "privilege_not_revoked", "01004": "string_data_right_truncation", "01P01": "deprecated_feature", "02000": "no_data", "02001": "no_additional_dynamic_result_sets_returned", "03000": "sql_statement_not_yet_complete", "08000": "connection_exception", "08003": "connection_does_not_exist", "08006": "connection_failure", "08001": "sqlclient_unable_to_establish_sqlconnection", "08004": "sqlserver_rejected_establishment_of_sqlconnection", "08007": "transaction_resolution_unknown", "08P01": "protocol_violation", "09000": "triggered_action_exception", "0A000": "feature_not_supported", "0B000": "invalid_transaction_initiation", "0F000": "locator_exception", "0F001": "invalid_locator_specification", "0L000": "invalid_grantor", "0LP01": "invalid_grant_operation", "0P000": "invalid_role_specification", "0Z000": "diagnostics_exception", "0Z002": "stacked_diagnostics_accessed_without_active_handler", "2202E": "array_subscript_error", "2200B": "escape_character_conflict", "2201E": "invalid_argument_for_logarithm", "2201F": "invalid_argument_for_power_function", "2201G": "invalid_argument_for_width_bucket_function", "2200D": "invalid_escape_octet", "22P06": "nonstandard_use_of_escape_character", "2201B": "invalid_regular_expression", "2201W": "invalid_row_count_in_limit_clause", "2201X": "invalid_row_count_in_result_offset_clause", "2202H": "invalid_tablesample_argument", "2202G": "invalid_tablesample_repeat", "2200C": "invalid_use_of_escape_character", "2200G": "most_specific_type_mismatch", "2200H": "sequence_generator_limit_exceeded", "2200F": "zero_length_character_string", "22P01": "floating_point_exception", "22P02": "invalid_text_representation", "22P03": "invalid_binary_representation", "22P04": "bad_copy_file_format", "22P05": "untranslatable_character", "2200L": "not_an_xml_document", "2200M": "invalid_xml_document", "2200N": "invalid_xml_content", "2200S": "invalid_xml_comment", "2200T": "invalid_xml_processing_instruction", "2203A": "sql_json_member_not_found", "2203B": "sql_json_number_not_found", "2203C": "sql_json_object_not_found", "2203D": "too_many_json_array_elements", "2203E": "too_many_json_object_members", "2203F": "sql_json_scalar_required", "23P01": "exclusion_violation", "25P01": "no_active_sql_transaction", "25P02": "in_failed_sql_transaction", "25P03": "idle_in_transaction_session_timeout", "28P01": "invalid_password", "2B000": "dependent_privilege_descriptors_still_exist", "2BP01": "dependent_objects_still_exist", "2D000": "invalid_transaction_termination", "2F000": "sql_routine_exception", "2F005": "function_executed_no_return_statement", "2F002": "modifying_sql_data_not_permitted", "2F003": "prohibited_sql_statement_attempted", "2F004": "reading_sql_data_not_permitted", "39P01": "trigger_protocol_violated", "39P02": "srf_protocol_violated", "39P03": "event_trigger_protocol_violated", "3B000": "savepoint_exception", "3B001": "invalid_savepoint_specification", "3D000": "invalid_catalog_name", "3F000": "invalid_schema_name", "40P01": "deadlock_detected", "42P20": "windowing_error", "42P19": "invalid_recursion", "42P18": "indeterminate_datatype", "42P21": "collation_mismatch", "42P22": "indeterminate_collation", "428C9": "generated_always", "42P01": "undefined_table", "42P02": "undefined_parameter", "42P03": "duplicate_cursor", "42P04": "duplicate_database", "42P05": "duplicate_prepared_statement", "42P06": "duplicate_schema", "42P07": "duplicate_table", "42P08": "ambiguous_parameter", "42P09": "ambiguous_alias", "42P10": "invalid_column_reference", "42P11": "invalid_cursor_definition", "42P12": "invalid_database_definition", "42P13": "invalid_function_definition", "42P14": "invalid_prepared_statement_definition", "42P15": "invalid_schema_definition", "42P16": "invalid_table_definition", "42P17": "invalid_object_definition", "55P02": "cant_change_runtime_param", "55P03": "lock_not_available", "55P04": "unsafe_new_enum_value_usage", "57P01": "admin_shutdown", "57P02": "crash_shutdown", "57P03": "cannot_connect_now", "57P04": "database_dropped", "58P01": "undefined_file", "58P02": "duplicate_file", "F0000": "config_file_error", "F0001": "lock_file_exists", "HV000": "fdw_error", "HV005": "fdw_column_name_not_found", "HV002": "fdw_dynamic_parameter_value_needed", "HV010": "fdw_function_sequence_error", "HV021": "fdw_inconsistent_descriptor_information", "HV024": "fdw_invalid_attribute_value", "HV007": "fdw_invalid_column_name", "HV008": "fdw_invalid_column_number", "HV004": "fdw_invalid_data_type", "HV006": "fdw_invalid_data_type_descriptors", "HV091": "fdw_invalid_descriptor_field_identifier", "HV00B": "fdw_invalid_handle", "HV00C": "fdw_invalid_option_index", "HV00D": "fdw_invalid_option_name", "HV090": "fdw_invalid_string_length_or_buffer_length", "HV00A": "fdw_invalid_string_format", "HV009": "fdw_invalid_use_of_null_pointer", "HV014": "fdw_too_many_handles", "HV001": "fdw_out_of_memory", "HV00P": "fdw_no_schemas", "HV00J": "fdw_option_name_not_found", "HV00K": "fdw_reply_handle", "HV00Q": "fdw_schema_not_found", "HV00R": "fdw_table_not_found", "HV00L": "fdw_unable_to_create_execution", "HV00M": "fdw_unable_to_create_reply", "HV00N": "fdw_unable_to_establish_connection", "P0000": "plpgsql_error", "P0001": "raise_exception", "P0002": "no_data_found", "P0003": "too_many_rows", "P0004": "assert_failure", "XX000": "internal_error", "XX001": "data_corrupted", "XX002": "index_corrupted" }
|
|
245
|
+
|
|
246
|
+
//@ts-ignore
|
|
247
|
+
return c2[code] || errs[code] || code;
|
|
248
|
+
|
|
249
|
+
/*
|
|
250
|
+
https://www.postgresql.org/docs/13/errcodes-appendix.html
|
|
251
|
+
JSON.stringify([...THE_table_$0.rows].map(t => [...t.children].map(u => u.innerText)).filter((d, i) => i && d.length > 1).reduce((a, v)=>({ ...a, [v[0]]: v[1] }), {}))
|
|
252
|
+
*/
|
|
253
|
+
}
|
|
254
|
+
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { AnyObject, getKeys, isObject } from "prostgles-types";
|
|
2
|
+
import { LocalParams, Media } from "./DboBuilder";
|
|
3
|
+
import { ValidateRowBasic } from "../PublishParser/PublishParser";
|
|
4
|
+
import { TableHandler } from "./TableHandler/TableHandler";
|
|
5
|
+
|
|
6
|
+
export const isFile = (row: AnyObject) => {
|
|
7
|
+
return Boolean(row && isObject(row) && getKeys(row).sort().join() === ["name", "data"].sort().join() && row.data && (typeof row.data === "string" || Buffer.isBuffer(row.data)) && typeof row.name === "string")
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type UploadFileArgs = {
|
|
11
|
+
row: AnyObject;
|
|
12
|
+
validate: ValidateRowBasic | undefined;
|
|
13
|
+
localParams: LocalParams | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Used to update an existing file
|
|
16
|
+
*/
|
|
17
|
+
mediaId?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export async function uploadFile(this: TableHandler, { row, localParams, validate, mediaId }: UploadFileArgs): Promise<Media> {
|
|
21
|
+
if (!this.dboBuilder.prostgles?.fileManager) throw "fileManager not set up";
|
|
22
|
+
|
|
23
|
+
if (!isFile(row)) throw "Expecting only two properties for file upload: { name: string; data: File | string | Buffer }; but got: " + Object.entries(row).map(([k, v]) => `${k}: ${typeof v}`).join(", ");
|
|
24
|
+
const { data, name } = row;
|
|
25
|
+
|
|
26
|
+
const media_id = mediaId ?? (await this.db.oneOrNone("SELECT gen_random_uuid() as name")).name;
|
|
27
|
+
const nestedInsert = localParams?.nestedInsert;
|
|
28
|
+
const type = await this.dboBuilder.prostgles.fileManager.getValidatedFileType({ file: data, fileName: name, tableName: nestedInsert?.previousTable, colName: nestedInsert?.referencingColumn });
|
|
29
|
+
const media_name = `${media_id}.${type.ext}`;
|
|
30
|
+
const parsedMediaKeys = ["id", "name", "original_name", "extension", "content_type"] as const
|
|
31
|
+
const media: Required<Pick<Media, typeof parsedMediaKeys[number]>> = {
|
|
32
|
+
id: media_id,
|
|
33
|
+
name: media_name,
|
|
34
|
+
original_name: name,
|
|
35
|
+
extension: type.ext,
|
|
36
|
+
content_type: type.mime
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (validate) {
|
|
40
|
+
if(!localParams) throw "localParams missing";
|
|
41
|
+
const parsedMedia = await validate({ row: media, dbx: this.getFinalDbo(localParams), localParams });
|
|
42
|
+
const missingKeys = parsedMediaKeys.filter(k => !parsedMedia[k])
|
|
43
|
+
if(missingKeys.length){
|
|
44
|
+
throw `Some keys are missing from file insert validation: ${missingKeys}`;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const _media: Media = await this.dboBuilder.prostgles.fileManager.uploadAsMedia({
|
|
49
|
+
item: {
|
|
50
|
+
data,
|
|
51
|
+
name: media.name ?? "????",
|
|
52
|
+
content_type: media.content_type as any,
|
|
53
|
+
extension: media.extension
|
|
54
|
+
},
|
|
55
|
+
// imageCompression: {
|
|
56
|
+
// inside: {
|
|
57
|
+
// width: 1100,
|
|
58
|
+
// height: 630
|
|
59
|
+
// }
|
|
60
|
+
// }
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const mediaRow = {
|
|
64
|
+
...media,
|
|
65
|
+
..._media,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
return mediaRow;
|
|
69
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
|
|
2
|
+
export const EVENT_TRIGGER_TAGS = [
|
|
3
|
+
"ALTER AGGREGATE",
|
|
4
|
+
"ALTER COLLATION",
|
|
5
|
+
"ALTER CONVERSION",
|
|
6
|
+
"ALTER DOMAIN",
|
|
7
|
+
"ALTER DEFAULT PRIVILEGES",
|
|
8
|
+
"ALTER EXTENSION",
|
|
9
|
+
"ALTER FOREIGN DATA WRAPPER",
|
|
10
|
+
"ALTER FOREIGN TABLE",
|
|
11
|
+
"ALTER FUNCTION",
|
|
12
|
+
"ALTER LANGUAGE",
|
|
13
|
+
"ALTER LARGE OBJECT",
|
|
14
|
+
"ALTER MATERIALIZED VIEW",
|
|
15
|
+
"ALTER OPERATOR",
|
|
16
|
+
"ALTER OPERATOR CLASS",
|
|
17
|
+
"ALTER OPERATOR FAMILY",
|
|
18
|
+
"ALTER POLICY",
|
|
19
|
+
"ALTER PROCEDURE",
|
|
20
|
+
"ALTER PUBLICATION",
|
|
21
|
+
"ALTER ROUTINE",
|
|
22
|
+
"ALTER SCHEMA",
|
|
23
|
+
"ALTER SEQUENCE",
|
|
24
|
+
"ALTER SERVER",
|
|
25
|
+
"ALTER STATISTICS",
|
|
26
|
+
"ALTER SUBSCRIPTION",
|
|
27
|
+
"ALTER TABLE",
|
|
28
|
+
"ALTER TEXT SEARCH CONFIGURATION",
|
|
29
|
+
"ALTER TEXT SEARCH DICTIONARY",
|
|
30
|
+
"ALTER TEXT SEARCH PARSER",
|
|
31
|
+
"ALTER TEXT SEARCH TEMPLATE",
|
|
32
|
+
"ALTER TRIGGER",
|
|
33
|
+
"ALTER TYPE",
|
|
34
|
+
"ALTER USER MAPPING",
|
|
35
|
+
"ALTER VIEW",
|
|
36
|
+
"COMMENT",
|
|
37
|
+
"CREATE ACCESS METHOD",
|
|
38
|
+
"CREATE AGGREGATE",
|
|
39
|
+
"CREATE CAST",
|
|
40
|
+
"CREATE COLLATION",
|
|
41
|
+
"CREATE CONVERSION",
|
|
42
|
+
"CREATE DOMAIN",
|
|
43
|
+
"CREATE EXTENSION",
|
|
44
|
+
"CREATE FOREIGN DATA WRAPPER",
|
|
45
|
+
"CREATE FOREIGN TABLE",
|
|
46
|
+
"CREATE FUNCTION",
|
|
47
|
+
"CREATE INDEX",
|
|
48
|
+
"CREATE LANGUAGE",
|
|
49
|
+
"CREATE MATERIALIZED VIEW",
|
|
50
|
+
"CREATE OPERATOR",
|
|
51
|
+
"CREATE OPERATOR CLASS",
|
|
52
|
+
"CREATE OPERATOR FAMILY",
|
|
53
|
+
"CREATE POLICY",
|
|
54
|
+
"CREATE PROCEDURE",
|
|
55
|
+
"CREATE PUBLICATION",
|
|
56
|
+
"CREATE RULE",
|
|
57
|
+
"CREATE SCHEMA",
|
|
58
|
+
"CREATE SEQUENCE",
|
|
59
|
+
"CREATE SERVER",
|
|
60
|
+
"CREATE STATISTICS",
|
|
61
|
+
"CREATE SUBSCRIPTION",
|
|
62
|
+
"CREATE TABLE",
|
|
63
|
+
"CREATE TABLE AS",
|
|
64
|
+
"CREATE TEXT SEARCH CONFIGURATION",
|
|
65
|
+
"CREATE TEXT SEARCH DICTIONARY",
|
|
66
|
+
"CREATE TEXT SEARCH PARSER",
|
|
67
|
+
"CREATE TEXT SEARCH TEMPLATE",
|
|
68
|
+
"CREATE TRIGGER",
|
|
69
|
+
"CREATE TYPE",
|
|
70
|
+
"CREATE USER MAPPING",
|
|
71
|
+
"CREATE VIEW",
|
|
72
|
+
"DROP ACCESS METHOD",
|
|
73
|
+
"DROP AGGREGATE",
|
|
74
|
+
"DROP CAST",
|
|
75
|
+
"DROP COLLATION",
|
|
76
|
+
"DROP CONVERSION",
|
|
77
|
+
"DROP DOMAIN",
|
|
78
|
+
"DROP EXTENSION",
|
|
79
|
+
"DROP FOREIGN DATA WRAPPER",
|
|
80
|
+
"DROP FOREIGN TABLE",
|
|
81
|
+
"DROP FUNCTION",
|
|
82
|
+
"DROP INDEX",
|
|
83
|
+
"DROP LANGUAGE",
|
|
84
|
+
"DROP MATERIALIZED VIEW",
|
|
85
|
+
"DROP OPERATOR",
|
|
86
|
+
"DROP OPERATOR CLASS",
|
|
87
|
+
"DROP OPERATOR FAMILY",
|
|
88
|
+
"DROP OWNED",
|
|
89
|
+
"DROP POLICY",
|
|
90
|
+
"DROP PROCEDURE",
|
|
91
|
+
"DROP PUBLICATION",
|
|
92
|
+
"DROP ROUTINE",
|
|
93
|
+
"DROP RULE",
|
|
94
|
+
"DROP SCHEMA",
|
|
95
|
+
"DROP SEQUENCE",
|
|
96
|
+
"DROP SERVER",
|
|
97
|
+
"DROP STATISTICS",
|
|
98
|
+
"DROP SUBSCRIPTION",
|
|
99
|
+
"DROP TABLE",
|
|
100
|
+
"DROP TEXT SEARCH CONFIGURATION",
|
|
101
|
+
"DROP TEXT SEARCH DICTIONARY",
|
|
102
|
+
"DROP TEXT SEARCH PARSER",
|
|
103
|
+
"DROP TEXT SEARCH TEMPLATE",
|
|
104
|
+
"DROP TRIGGER",
|
|
105
|
+
"DROP TYPE",
|
|
106
|
+
"DROP USER MAPPING",
|
|
107
|
+
"DROP VIEW",
|
|
108
|
+
"GRANT",
|
|
109
|
+
"IMPORT FOREIGN SCHEMA",
|
|
110
|
+
"REFRESH MATERIALIZED VIEW",
|
|
111
|
+
"REVOKE",
|
|
112
|
+
"SECURITY LABEL",
|
|
113
|
+
"SELECT INTO"
|
|
114
|
+
] as const;
|
|
115
|
+
|
|
116
|
+
export type EventTriggerTag = typeof EVENT_TRIGGER_TAGS[number];
|
|
117
|
+
|
|
118
|
+
export type EventTriggerTagFilter = Partial<Record<EventTriggerTag, 1>> | Partial<Record<EventTriggerTag, 0>> | "*";
|