plugin-data-source-postgres 0.0.0-stage → 2.0.0
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/README.md +9 -3
- package/client-v2.js +1 -0
- package/client.js +1 -0
- package/dist/client/index.js +10 -0
- package/dist/client-v2/985.34da95acdf7743ab.js +10 -0
- package/dist/client-v2/index.js +10 -0
- package/dist/constants.js +45 -0
- package/dist/externalVersion.js +28 -0
- package/dist/locale/en-US.json +141 -0
- package/dist/locale/zh-CN.json +141 -0
- package/dist/server/collections/adjacency-list-repository.js +340 -0
- package/dist/server/collections/index.js +45 -0
- package/dist/server/collections/sql-collection.js +84 -0
- package/dist/server/collections/sql-model.js +147 -0
- package/dist/server/collections/tree-collection.js +118 -0
- package/dist/server/hooks/field-hooks.js +392 -0
- package/dist/server/index.js +38 -0
- package/dist/server/plugin.js +690 -0
- package/dist/server/postgres-collection-manager.js +701 -0
- package/dist/server/postgres-datasource.js +327 -0
- package/dist/server/utils/sql-validator.js +203 -0
- package/dist/server/utils/validation-error.js +59 -0
- package/package.json +51 -4
- package/server.js +1 -0
- package/src/client/AddCollectionAction.tsx +307 -0
- package/src/client/ConfigurationForm.tsx +203 -0
- package/src/client/PostgresCollectionTemplate.tsx +109 -0
- package/src/client/__tests__/client-v1.test.tsx +265 -0
- package/src/client/collection-templates/CalendarCollectionTemplate.tsx +141 -0
- package/src/client/collection-templates/FileCollectionTemplate.tsx +154 -0
- package/src/client/collection-templates/SQLCollectionTemplate.tsx +184 -0
- package/src/client/collection-templates/TreeCollectionTemplate.tsx +136 -0
- package/src/client/collection-templates/base-template-helper.ts +62 -0
- package/src/client/collection-templates/field-interfaces-config.ts +73 -0
- package/src/client/collection-templates/index.ts +19 -0
- package/src/client/index.tsx +69 -0
- package/src/client-v2/PostgresAddCollection.tsx +422 -0
- package/src/client-v2/PostgresConfigForm.tsx +178 -0
- package/src/client-v2/PostgresDeleteCollection.tsx +83 -0
- package/src/client-v2/__tests__/plugin.test.tsx +372 -0
- package/src/client-v2/collection-options.ts +22 -0
- package/src/client-v2/index.tsx +10 -0
- package/src/client-v2/plugin.tsx +71 -0
- package/src/constants.ts +20 -0
- package/src/locale/en-US.json +141 -0
- package/src/locale/zh-CN.json +141 -0
- package/src/server/__tests__/field-hooks.test.ts +357 -0
- package/src/server/__tests__/postgres-data-source.integration.test.ts +543 -0
- package/src/server/__tests__/postgres-datasource.unit.test.ts +1538 -0
- package/src/server/__tests__/sql-model.test.ts +115 -0
- package/src/server/__tests__/sql-validator.test.ts +119 -0
- package/src/server/collections/adjacency-list-repository.ts +378 -0
- package/src/server/collections/index.ts +19 -0
- package/src/server/collections/sql-collection.ts +66 -0
- package/src/server/collections/sql-model.ts +158 -0
- package/src/server/collections/tree-collection.ts +102 -0
- package/src/server/hooks/field-hooks.ts +514 -0
- package/src/server/index.ts +13 -0
- package/src/server/plugin.ts +764 -0
- package/src/server/postgres-collection-manager.ts +827 -0
- package/src/server/postgres-datasource.ts +365 -0
- package/src/server/utils/sql-validator.ts +203 -0
- package/src/server/utils/validation-error.ts +38 -0
|
@@ -0,0 +1,690 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var plugin_exports = {};
|
|
28
|
+
__export(plugin_exports, {
|
|
29
|
+
PluginDataSourcePostgresServer: () => PluginDataSourcePostgresServer,
|
|
30
|
+
default: () => plugin_default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(plugin_exports);
|
|
33
|
+
var import_server = require("@nocobase/server");
|
|
34
|
+
var import_lodash = require("lodash");
|
|
35
|
+
var import_constants = require("../constants");
|
|
36
|
+
var import_sql_collection = require("./collections/sql-collection");
|
|
37
|
+
var import_tree_collection = require("./collections/tree-collection");
|
|
38
|
+
var import_field_hooks = require("./hooks/field-hooks");
|
|
39
|
+
var import_postgres_datasource = require("./postgres-datasource");
|
|
40
|
+
var import_sql_validator = require("./utils/sql-validator");
|
|
41
|
+
var import_validation_error = require("./utils/validation-error");
|
|
42
|
+
const FIELD_ACTIONS = /* @__PURE__ */ new Set(["create", "update", "apply", "destroy"]);
|
|
43
|
+
const WRITE_ACTIONS = /* @__PURE__ */ new Set([
|
|
44
|
+
"create",
|
|
45
|
+
"firstOrCreate",
|
|
46
|
+
"updateOrCreate",
|
|
47
|
+
"update",
|
|
48
|
+
"destroy",
|
|
49
|
+
"destroyMany",
|
|
50
|
+
"updateMany",
|
|
51
|
+
"add",
|
|
52
|
+
"remove",
|
|
53
|
+
"set",
|
|
54
|
+
"toggle",
|
|
55
|
+
"move",
|
|
56
|
+
"importXlsx"
|
|
57
|
+
]);
|
|
58
|
+
const PRESET_FIELDS = {
|
|
59
|
+
id: { name: "id", type: "bigInt", interface: "id", primaryKey: true, autoIncrement: true, allowNull: false },
|
|
60
|
+
createdAt: { name: "createdAt", type: "date", interface: "createdAt", field: "createdAt" },
|
|
61
|
+
updatedAt: { name: "updatedAt", type: "date", interface: "updatedAt", field: "updatedAt" }
|
|
62
|
+
};
|
|
63
|
+
function isRecord(value) {
|
|
64
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
65
|
+
}
|
|
66
|
+
function extractSql(values) {
|
|
67
|
+
if (!values) return void 0;
|
|
68
|
+
if (values.sql !== void 0) return values.sql;
|
|
69
|
+
return isRecord(values.options) ? values.options.sql : void 0;
|
|
70
|
+
}
|
|
71
|
+
function names(value) {
|
|
72
|
+
const values = Array.isArray(value) ? value : [value];
|
|
73
|
+
if (!values.length || values.some((item) => typeof item !== "string" || !item)) {
|
|
74
|
+
throw new import_validation_error.PostgresValidationError("A collection name is required");
|
|
75
|
+
}
|
|
76
|
+
return [...new Set(values)];
|
|
77
|
+
}
|
|
78
|
+
function prepareFields(values) {
|
|
79
|
+
if (!Array.isArray(values.fields)) return;
|
|
80
|
+
const hasStringPresets = values.fields.some((field) => typeof field === "string");
|
|
81
|
+
if (hasStringPresets || values.template === "general" && values.fields.length === 0) {
|
|
82
|
+
const selectedPresets = new Set(values.fields.filter((field) => typeof field === "string"));
|
|
83
|
+
values.autoGenId = selectedPresets.has("id");
|
|
84
|
+
values.createdAt = selectedPresets.has("createdAt");
|
|
85
|
+
values.updatedAt = selectedPresets.has("updatedAt");
|
|
86
|
+
values.timestamps = Boolean(values.createdAt || values.updatedAt);
|
|
87
|
+
} else if (values.createdAt === false && values.updatedAt === false && values.timestamps === void 0) {
|
|
88
|
+
values.timestamps = false;
|
|
89
|
+
}
|
|
90
|
+
const mapped = values.fields.map((field) => {
|
|
91
|
+
if (typeof field !== "string") return field;
|
|
92
|
+
const preset = PRESET_FIELDS[field];
|
|
93
|
+
if (!preset) throw new import_validation_error.PostgresValidationError("Unknown preset field {{name}}", { name: field });
|
|
94
|
+
return (0, import_lodash.cloneDeep)(preset);
|
|
95
|
+
});
|
|
96
|
+
const isSql = extractSql(values) !== void 0 || values.template === "sql";
|
|
97
|
+
if (!isSql) {
|
|
98
|
+
if (values.createdAt === true && !mapped.some((field) => field.name === "createdAt")) {
|
|
99
|
+
mapped.push((0, import_lodash.cloneDeep)(PRESET_FIELDS.createdAt));
|
|
100
|
+
}
|
|
101
|
+
if (values.updatedAt === true && !mapped.some((field) => field.name === "updatedAt")) {
|
|
102
|
+
mapped.push((0, import_lodash.cloneDeep)(PRESET_FIELDS.updatedAt));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
values.fields = mapped;
|
|
106
|
+
}
|
|
107
|
+
async function localizeValidationErrors(ctx, next) {
|
|
108
|
+
var _a, _b, _c, _d, _e;
|
|
109
|
+
try {
|
|
110
|
+
await next();
|
|
111
|
+
} catch (error) {
|
|
112
|
+
if (error instanceof import_validation_error.PostgresValidationError) error.message = (0, import_validation_error.translateError)(ctx, error);
|
|
113
|
+
const params = ((_a = ctx.action) == null ? void 0 : _a.params) || {};
|
|
114
|
+
const postgresConnection = ((_b = ctx.action) == null ? void 0 : _b.resourceName) === "dataSources" && (((_c = params.values) == null ? void 0 : _c.type) === import_constants.DATA_SOURCE_TYPE || ((_e = (_d = ctx.app) == null ? void 0 : _d.dataSourceManager) == null ? void 0 : _e.get(params.filterByTk)) instanceof import_postgres_datasource.PostgresDataSource);
|
|
115
|
+
if (postgresConnection && error instanceof Error && error.message === "Test connection failed: Invalid PostgreSQL port") {
|
|
116
|
+
error.message = (0, import_validation_error.translate)(ctx, "Test connection failed: {{reason}}", {
|
|
117
|
+
reason: (0, import_validation_error.translate)(ctx, "Invalid PostgreSQL port")
|
|
118
|
+
});
|
|
119
|
+
const httpError = error;
|
|
120
|
+
httpError.status = 400;
|
|
121
|
+
httpError.statusCode = 400;
|
|
122
|
+
}
|
|
123
|
+
throw error;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
class PluginDataSourcePostgresServer extends import_server.Plugin {
|
|
127
|
+
selectionSyncs = /* @__PURE__ */ new Map();
|
|
128
|
+
activeSources = /* @__PURE__ */ new Map();
|
|
129
|
+
async closeDataSource(dataSourceKey, expectedSource) {
|
|
130
|
+
var _a, _b;
|
|
131
|
+
const current = this.app.dataSourceManager.get(dataSourceKey);
|
|
132
|
+
const tracked = this.activeSources.get(dataSourceKey);
|
|
133
|
+
const source = expectedSource || (current instanceof import_postgres_datasource.PostgresDataSource ? current : tracked);
|
|
134
|
+
if (!source) return;
|
|
135
|
+
if (tracked === source) {
|
|
136
|
+
this.activeSources.delete(dataSourceKey);
|
|
137
|
+
}
|
|
138
|
+
if (current === source) {
|
|
139
|
+
this.app.dataSourceManager.dataSources.delete(dataSourceKey);
|
|
140
|
+
}
|
|
141
|
+
const replacement = this.app.dataSourceManager.get(dataSourceKey);
|
|
142
|
+
if (replacement instanceof import_postgres_datasource.PostgresDataSource && replacement !== source && replacement.collectionManager.db === source.collectionManager.db) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
try {
|
|
146
|
+
await source.close();
|
|
147
|
+
} catch (error) {
|
|
148
|
+
(_b = (_a = this.app.log) == null ? void 0 : _a.warn) == null ? void 0 : _b.call(_a, `Failed to close PostgreSQL data source "${dataSourceKey}"`, { cause: error });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
async enqueueSelectionSync(key, task) {
|
|
152
|
+
const previous = this.selectionSyncs.get(key) || Promise.resolve();
|
|
153
|
+
const current = previous.catch(() => void 0).then(task);
|
|
154
|
+
this.selectionSyncs.set(key, current);
|
|
155
|
+
try {
|
|
156
|
+
await current;
|
|
157
|
+
} finally {
|
|
158
|
+
if (this.selectionSyncs.get(key) === current) this.selectionSyncs.delete(key);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
async handleSyncMessage(message) {
|
|
162
|
+
var _a, _b, _c, _d;
|
|
163
|
+
if (!(message == null ? void 0 : message.dataSourceKey)) return;
|
|
164
|
+
const key = message.dataSourceKey;
|
|
165
|
+
if (message.type === "dataSourceRemoved") {
|
|
166
|
+
const existingRecord = await ((_d = (_c = (_b = (_a = this.app.db) == null ? void 0 : _a.getRepository) == null ? void 0 : _b.call(_a, "dataSources")) == null ? void 0 : _c.findOne) == null ? void 0 : _d.call(_c, { filterByTk: key }));
|
|
167
|
+
if (existingRecord) return;
|
|
168
|
+
await this.closeDataSource(key);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (message.type === "selectionChanged") {
|
|
172
|
+
const refreshTables = Array.isArray(message.refreshTables) ? message.refreshTables.filter((name) => typeof name === "string" && name.length > 0) : [];
|
|
173
|
+
await this.enqueueSelectionSync(key, () => this.reconcileSelection(key, refreshTables));
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (message.type === "tablesLoaded" && Array.isArray(message.tableNames)) {
|
|
177
|
+
const tableNames = message.tableNames;
|
|
178
|
+
await this.enqueueSelectionSync(key, () => this.syncLoadedTables(key, tableNames));
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const source = this.app.dataSourceManager.get(key);
|
|
182
|
+
if (!(source instanceof import_postgres_datasource.PostgresDataSource)) return;
|
|
183
|
+
if (message.type === "collectionCreated" && message.collectionName) {
|
|
184
|
+
await this.syncCreatedCollection(source, key, message.collectionName);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (message.type === "collectionRemoved" && Array.isArray(message.collectionNames)) {
|
|
188
|
+
for (const name of message.collectionNames) {
|
|
189
|
+
if (typeof name === "string" && source.collectionManager.hasCollection(name)) {
|
|
190
|
+
source.collectionManager.removeCollection(name);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (message.type === "fieldRemoved" && message.collectionName && message.fieldName) {
|
|
196
|
+
const collection = source.collectionManager.getCollection(message.collectionName);
|
|
197
|
+
if (collection == null ? void 0 : collection.getField(message.fieldName)) {
|
|
198
|
+
collection.removeField(message.fieldName);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
async syncLoadedTables(dataSourceKey, tableNames) {
|
|
203
|
+
const source = this.app.dataSourceManager.get(dataSourceKey);
|
|
204
|
+
if (!(source instanceof import_postgres_datasource.PostgresDataSource)) return;
|
|
205
|
+
const requested = [
|
|
206
|
+
...new Set(tableNames.filter((name) => typeof name === "string" && name.length > 0))
|
|
207
|
+
];
|
|
208
|
+
if (!requested.length) return;
|
|
209
|
+
const record = await this.app.db.getRepository("dataSources").findOne({ filterByTk: dataSourceKey });
|
|
210
|
+
if (!record) return;
|
|
211
|
+
const storedOptions = typeof record.get === "function" ? record.get("options") || {} : {};
|
|
212
|
+
const selectedFilter = storedOptions.addAllCollections === false && Array.isArray(storedOptions.selectedCollections) ? new Set(storedOptions.selectedCollections.filter((name) => typeof name === "string")) : void 0;
|
|
213
|
+
const allowed = selectedFilter ? requested.filter((name) => selectedFilter.has(name)) : requested;
|
|
214
|
+
if (!allowed.length) return;
|
|
215
|
+
const localData = typeof record.loadLocalData === "function" ? await record.loadLocalData() : {};
|
|
216
|
+
const available = new Set(await source.introspector.getTables());
|
|
217
|
+
const targets = allowed.filter((name) => available.has(name));
|
|
218
|
+
if (!targets.length) return;
|
|
219
|
+
const collections = await source.prepareTables(targets, localData);
|
|
220
|
+
if (this.app.dataSourceManager.get(dataSourceKey) !== source) return;
|
|
221
|
+
source.collectionManager.replaceCollections(collections);
|
|
222
|
+
}
|
|
223
|
+
async syncCreatedCollection(source, dataSourceKey, collectionName) {
|
|
224
|
+
const collectionRecord = await this.app.db.getRepository("dataSourcesCollections").findOne({
|
|
225
|
+
filter: { dataSourceKey, name: collectionName }
|
|
226
|
+
});
|
|
227
|
+
if (!collectionRecord) return;
|
|
228
|
+
const fieldRecords = await this.app.db.getRepository("dataSourcesFields").find({
|
|
229
|
+
filter: { dataSourceKey, collectionName }
|
|
230
|
+
});
|
|
231
|
+
const collectionOptions = {
|
|
232
|
+
...collectionRecord.toJSON(),
|
|
233
|
+
fields: fieldRecords.map((field) => field.toJSON())
|
|
234
|
+
};
|
|
235
|
+
if (typeof collectionOptions.sql === "string" && collectionOptions.sql.trim()) {
|
|
236
|
+
const existing2 = source.collectionManager.getCollection(collectionName);
|
|
237
|
+
if (existing2) {
|
|
238
|
+
existing2.updateOptions(collectionOptions);
|
|
239
|
+
} else {
|
|
240
|
+
source.collectionManager.defineCollection({
|
|
241
|
+
...collectionOptions,
|
|
242
|
+
tableName: typeof collectionOptions.tableName === "string" ? collectionOptions.tableName : collectionName,
|
|
243
|
+
introspected: true
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
const tableName = typeof collectionOptions.tableName === "string" ? collectionOptions.tableName : collectionName;
|
|
249
|
+
const [prepared] = await source.prepareTables([tableName], { [collectionName]: collectionOptions });
|
|
250
|
+
if (this.app.dataSourceManager.get(dataSourceKey) !== source || !prepared) return;
|
|
251
|
+
const existing = source.collectionManager.getCollection(collectionName);
|
|
252
|
+
if (existing) {
|
|
253
|
+
existing.updateOptions(prepared);
|
|
254
|
+
} else {
|
|
255
|
+
source.collectionManager.defineCollection(prepared);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
async reconcileSelection(dataSourceKey, refreshTables = []) {
|
|
259
|
+
const source = this.app.dataSourceManager.get(dataSourceKey);
|
|
260
|
+
if (!(source instanceof import_postgres_datasource.PostgresDataSource)) return;
|
|
261
|
+
const record = await this.app.db.getRepository("dataSources").findOne({ filterByTk: dataSourceKey });
|
|
262
|
+
if (!record) return;
|
|
263
|
+
const storedOptions = record.get("options") || {};
|
|
264
|
+
if (storedOptions.addAllCollections !== false || !Array.isArray(storedOptions.selectedCollections)) return;
|
|
265
|
+
const resolvedOptions = this.app.environment.renderJsonTemplate(storedOptions);
|
|
266
|
+
const activeOptions = (0, import_lodash.pick)(source.options, Object.keys(resolvedOptions));
|
|
267
|
+
const selectAll = source.options.addAllCollections ?? source.options.autoDiscover !== false;
|
|
268
|
+
if (selectAll || !(0, import_lodash.isEqual)(
|
|
269
|
+
(0, import_lodash.omit)(activeOptions, ["selectedCollections", "addAllCollections"]),
|
|
270
|
+
(0, import_lodash.omit)(resolvedOptions, ["selectedCollections", "addAllCollections"])
|
|
271
|
+
))
|
|
272
|
+
return;
|
|
273
|
+
const selected = new Set(
|
|
274
|
+
storedOptions.selectedCollections.filter((name) => typeof name === "string")
|
|
275
|
+
);
|
|
276
|
+
const available = new Set(await source.introspector.getTables());
|
|
277
|
+
const localData = await record.loadLocalData();
|
|
278
|
+
const existing = source.collectionManager.getCollections();
|
|
279
|
+
const physicalName = (collection) => {
|
|
280
|
+
const table = collection.model.getTableName();
|
|
281
|
+
return typeof table === "string" ? table : table.tableName;
|
|
282
|
+
};
|
|
283
|
+
const missing = [...selected].filter(
|
|
284
|
+
(name) => available.has(name) && !existing.some((item) => physicalName(item) === name)
|
|
285
|
+
);
|
|
286
|
+
const refreshed = refreshTables.filter((name) => selected.has(name) && available.has(name));
|
|
287
|
+
const targets = [.../* @__PURE__ */ new Set([...missing, ...refreshed])];
|
|
288
|
+
const collections = await source.prepareTables(targets, localData);
|
|
289
|
+
if (this.app.dataSourceManager.get(dataSourceKey) !== source) return;
|
|
290
|
+
source.collectionManager.replaceCollections(collections);
|
|
291
|
+
for (const collection of existing) {
|
|
292
|
+
if (!collection.options.sql && !selected.has(physicalName(collection))) {
|
|
293
|
+
source.collectionManager.removeCollection(collection.name);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
source.options = { ...source.options, addAllCollections: false, selectedCollections: [...selected] };
|
|
297
|
+
}
|
|
298
|
+
async beforeLoad() {
|
|
299
|
+
this.app.dataSourceManager.registerDataSourceType(import_constants.DATA_SOURCE_TYPE, import_postgres_datasource.PostgresDataSource);
|
|
300
|
+
this.app.dataSourceManager.beforeAddDataSource((dataSource) => {
|
|
301
|
+
if (!(dataSource instanceof import_postgres_datasource.PostgresDataSource)) return;
|
|
302
|
+
const { db } = dataSource.collectionManager;
|
|
303
|
+
db.collectionFactory.registerCollectionType(import_sql_collection.PostgresSQLCollection, {
|
|
304
|
+
condition: (options) => Boolean(options.sql),
|
|
305
|
+
async onSync() {
|
|
306
|
+
},
|
|
307
|
+
async onDump() {
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
db.collectionFactory.registerCollectionType(import_tree_collection.PostgresTreeCollection, {
|
|
311
|
+
condition: (options) => Boolean(options.postgresTree || options.template === "tree")
|
|
312
|
+
});
|
|
313
|
+
dataSource.resourceManager.use(localizeValidationErrors, {
|
|
314
|
+
tag: "postgres-validation-errors",
|
|
315
|
+
after: ["auth"],
|
|
316
|
+
before: ["acl"]
|
|
317
|
+
});
|
|
318
|
+
dataSource.resourceManager.use(
|
|
319
|
+
async (ctx, next) => {
|
|
320
|
+
var _a, _b, _c, _d;
|
|
321
|
+
if (WRITE_ACTIONS.has((_a = ctx.action) == null ? void 0 : _a.actionName)) {
|
|
322
|
+
const resourceName = (_b = ctx.action) == null ? void 0 : _b.resourceName;
|
|
323
|
+
const [sourceName, associationName] = typeof resourceName === "string" ? resourceName.split(".") : [];
|
|
324
|
+
const sourceCollection = sourceName ? dataSource.collectionManager.getCollection(sourceName) : void 0;
|
|
325
|
+
const targetCollection = sourceCollection && associationName && resourceName ? dataSource.collectionManager.getCollection(resourceName) : void 0;
|
|
326
|
+
const throughName = associationName && ((_d = (_c = sourceCollection == null ? void 0 : sourceCollection.getField(associationName)) == null ? void 0 : _c.options) == null ? void 0 : _d.through);
|
|
327
|
+
const throughCollection = typeof throughName === "string" ? dataSource.collectionManager.getCollection(throughName) : void 0;
|
|
328
|
+
const isReadOnly = (collection) => {
|
|
329
|
+
var _a2, _b2;
|
|
330
|
+
return Boolean(((_a2 = collection == null ? void 0 : collection.options) == null ? void 0 : _a2.view) || ((_b2 = collection == null ? void 0 : collection.options) == null ? void 0 : _b2.sql));
|
|
331
|
+
};
|
|
332
|
+
if (isReadOnly(sourceCollection) || isReadOnly(targetCollection) || isReadOnly(throughCollection)) {
|
|
333
|
+
ctx.throw(403, (0, import_validation_error.translate)(ctx, "This collection is read-only"));
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
await next();
|
|
337
|
+
},
|
|
338
|
+
{ tag: "postgres-read-only-collections", after: ["acl"] }
|
|
339
|
+
);
|
|
340
|
+
});
|
|
341
|
+
this.app.dataSourceManager.afterAddDataSource((dataSource) => {
|
|
342
|
+
if (dataSource instanceof import_postgres_datasource.PostgresDataSource) {
|
|
343
|
+
this.activeSources.set(dataSource.name, dataSource);
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
async load() {
|
|
348
|
+
var _a, _b;
|
|
349
|
+
(_b = (_a = this.app.db) == null ? void 0 : _a.on) == null ? void 0 : _b.call(
|
|
350
|
+
_a,
|
|
351
|
+
"dataSources.afterDestroy",
|
|
352
|
+
async (model, options) => {
|
|
353
|
+
if (model.get("type") !== import_constants.DATA_SOURCE_TYPE) return;
|
|
354
|
+
const key = String(model.get("key") || "");
|
|
355
|
+
if (!key) return;
|
|
356
|
+
const current = this.app.dataSourceManager.get(key);
|
|
357
|
+
const target = current instanceof import_postgres_datasource.PostgresDataSource ? current : this.activeSources.get(key);
|
|
358
|
+
if (target && this.activeSources.get(key) === target) {
|
|
359
|
+
this.activeSources.delete(key);
|
|
360
|
+
}
|
|
361
|
+
const close = () => target ? this.closeDataSource(key, target) : Promise.resolve();
|
|
362
|
+
if ((options == null ? void 0 : options.transaction) && typeof options.transaction.afterCommit === "function") {
|
|
363
|
+
options.transaction.afterCommit(close);
|
|
364
|
+
} else {
|
|
365
|
+
await close();
|
|
366
|
+
}
|
|
367
|
+
await this.sendSyncMessage(
|
|
368
|
+
{ type: "dataSourceRemoved", dataSourceKey: key },
|
|
369
|
+
(options == null ? void 0 : options.transaction) ? { transaction: options.transaction } : void 0
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
);
|
|
373
|
+
this.app.resourceManager.registerPreActionHandler("dataSources:readTables", async (ctx, next) => {
|
|
374
|
+
var _a2, _b2, _c;
|
|
375
|
+
const { dataSourceKey, dbOptions } = ctx.action.params.values || {};
|
|
376
|
+
if ((dbOptions == null ? void 0 : dbOptions.type) !== import_constants.DATA_SOURCE_TYPE) {
|
|
377
|
+
await next();
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
const manager = this.app.dataSourceManager;
|
|
381
|
+
const renderedOptions = ((_a2 = this.app.environment) == null ? void 0 : _a2.renderJsonTemplate) ? this.app.environment.renderJsonTemplate(dbOptions) : dbOptions;
|
|
382
|
+
const probe = manager.factory.create(import_constants.DATA_SOURCE_TYPE, {
|
|
383
|
+
name: dataSourceKey,
|
|
384
|
+
...renderedOptions,
|
|
385
|
+
pool: { max: 1, min: 0, acquire: 1e4, idle: 1e3 }
|
|
386
|
+
});
|
|
387
|
+
const owned = ![...manager.dataSources.values()].includes(probe);
|
|
388
|
+
let requestFailed = false;
|
|
389
|
+
let requestError;
|
|
390
|
+
try {
|
|
391
|
+
ctx.body = await probe.readTables();
|
|
392
|
+
} catch (error) {
|
|
393
|
+
requestFailed = true;
|
|
394
|
+
requestError = error;
|
|
395
|
+
} finally {
|
|
396
|
+
if (owned) {
|
|
397
|
+
try {
|
|
398
|
+
await probe.close();
|
|
399
|
+
} catch (error) {
|
|
400
|
+
if (requestFailed) {
|
|
401
|
+
(_c = (_b2 = this.app.log) == null ? void 0 : _b2.warn) == null ? void 0 : _c.call(_b2, "[PostgreSQL] Failed to close temporary table-list connection");
|
|
402
|
+
} else {
|
|
403
|
+
requestFailed = true;
|
|
404
|
+
requestError = error;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
if (requestFailed) throw requestError;
|
|
410
|
+
});
|
|
411
|
+
this.app.resourceManager.use(localizeValidationErrors, {
|
|
412
|
+
tag: "postgres-validation-errors",
|
|
413
|
+
after: ["auth"],
|
|
414
|
+
before: ["acl"]
|
|
415
|
+
});
|
|
416
|
+
this.app.resourceManager.use(
|
|
417
|
+
async (ctx, next) => {
|
|
418
|
+
var _a2, _b2;
|
|
419
|
+
const { resourceName, actionName, params } = ctx.action || {};
|
|
420
|
+
if (resourceName === "dataSources.collections") {
|
|
421
|
+
const dataSource = this.app.dataSourceManager.get(params.associatedIndex);
|
|
422
|
+
if (dataSource instanceof import_postgres_datasource.PostgresDataSource) {
|
|
423
|
+
if (actionName === "create" || actionName === "destroy") {
|
|
424
|
+
await this.mutateCollection(ctx, dataSource, next);
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
if (actionName === "update") {
|
|
428
|
+
const sql = extractSql(params.values);
|
|
429
|
+
if (sql !== void 0) {
|
|
430
|
+
const existing = dataSource.collectionManager.getCollection(params.filterByTk);
|
|
431
|
+
if (!((_a2 = existing == null ? void 0 : existing.options) == null ? void 0 : _a2.sql)) {
|
|
432
|
+
ctx.throw(400, (0, import_validation_error.translate)(ctx, "Only SQL collections can update SQL queries"));
|
|
433
|
+
}
|
|
434
|
+
(0, import_sql_validator.checkSQL)(typeof sql === "string" ? sql : "");
|
|
435
|
+
}
|
|
436
|
+
await next();
|
|
437
|
+
const targetName = typeof params.filterByTk === "string" ? params.filterByTk : "";
|
|
438
|
+
if (targetName) {
|
|
439
|
+
await this.sendSyncMessage({
|
|
440
|
+
type: "collectionCreated",
|
|
441
|
+
dataSourceKey: dataSource.name,
|
|
442
|
+
collectionName: targetName
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
if (resourceName === "dataSourcesCollections.fields" && FIELD_ACTIONS.has(actionName)) {
|
|
450
|
+
const index = String(params.associatedIndex || "");
|
|
451
|
+
const separator = index.indexOf(".");
|
|
452
|
+
const indexDataSourceKey = separator !== -1 ? index.slice(0, separator) : "";
|
|
453
|
+
const indexCollectionName = separator !== -1 ? index.slice(separator + 1) : "";
|
|
454
|
+
const rawBody = (_b2 = ctx.request) == null ? void 0 : _b2.body;
|
|
455
|
+
const input = params.values || (isRecord(rawBody) ? rawBody : {});
|
|
456
|
+
const dataSourceKey = actionName === "apply" && typeof input.dataSourceKey === "string" && input.dataSourceKey ? input.dataSourceKey : indexDataSourceKey;
|
|
457
|
+
const collectionName = actionName === "apply" && typeof input.collectionName === "string" && input.collectionName ? input.collectionName : indexCollectionName;
|
|
458
|
+
const dataSource = dataSourceKey && collectionName && this.app.dataSourceManager.get(dataSourceKey);
|
|
459
|
+
if (dataSource instanceof import_postgres_datasource.PostgresDataSource) {
|
|
460
|
+
await this.mutateField(ctx, dataSource, collectionName, input, next);
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
await next();
|
|
465
|
+
},
|
|
466
|
+
{ tag: "postgres-schema-actions", after: ["acl"] }
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
async mutateCollection(ctx, source, next) {
|
|
470
|
+
var _a, _b, _c, _d, _e, _f;
|
|
471
|
+
const manager = source.collectionManager;
|
|
472
|
+
const { actionName, params } = ctx.action;
|
|
473
|
+
const values = params.values || {};
|
|
474
|
+
if (actionName === "create") {
|
|
475
|
+
const [name] = names(values.name);
|
|
476
|
+
prepareFields(values);
|
|
477
|
+
if (manager.hasCollection(name)) ctx.throw(409, (0, import_validation_error.translate)(ctx, "Collection {{name}} already exists", { name }));
|
|
478
|
+
const sql = extractSql(values);
|
|
479
|
+
if (sql !== void 0 || values.template === "sql") {
|
|
480
|
+
(0, import_sql_validator.checkSQL)(typeof sql === "string" ? sql : "");
|
|
481
|
+
await next();
|
|
482
|
+
await this.sendSyncMessage({ type: "collectionCreated", dataSourceKey: source.name, collectionName: name });
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
if (values.view || values.template === "view") {
|
|
486
|
+
ctx.throw(400, (0, import_validation_error.translate)(ctx, "Use Load tables to import an existing view"));
|
|
487
|
+
}
|
|
488
|
+
let createdCollection;
|
|
489
|
+
await manager.db.sequelize.transaction(async (transaction) => {
|
|
490
|
+
await manager.db.sequelize.query("SELECT pg_advisory_xact_lock(hashtextextended(:table, 0))", {
|
|
491
|
+
replacements: { table: `${manager.db.options.schema || "public"}.${String(values.tableName || name)}` },
|
|
492
|
+
transaction
|
|
493
|
+
});
|
|
494
|
+
if (manager.hasCollection(name)) ctx.throw(409, (0, import_validation_error.translate)(ctx, "Collection {{name}} already exists", { name }));
|
|
495
|
+
if (!await manager.createTable(values, transaction))
|
|
496
|
+
ctx.throw(409, (0, import_validation_error.translate)(ctx, "Table {{name}} already exists", { name }));
|
|
497
|
+
createdCollection = manager.getCollection(name);
|
|
498
|
+
});
|
|
499
|
+
try {
|
|
500
|
+
await next();
|
|
501
|
+
} catch (error) {
|
|
502
|
+
try {
|
|
503
|
+
await manager.dropTable(name, false);
|
|
504
|
+
} catch (cleanupError) {
|
|
505
|
+
(_b = (_a = this.app.log) == null ? void 0 : _a.warn) == null ? void 0 : _b.call(_a, `Failed to roll back PostgreSQL table "${name}" after metadata error`, {
|
|
506
|
+
cause: cleanupError
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
if (createdCollection && manager.getCollection(name) === createdCollection) manager.removeCollection(name);
|
|
510
|
+
throw error;
|
|
511
|
+
}
|
|
512
|
+
await source.addSelectedTables(ctx, [String(values.tableName || name)]);
|
|
513
|
+
await this.sendSyncMessage({ type: "collectionCreated", dataSourceKey: source.name, collectionName: name });
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
const collectionNames = names(params.filterByTk);
|
|
517
|
+
const snapshots = collectionNames.map((name) => {
|
|
518
|
+
const collection = manager.getCollection(name);
|
|
519
|
+
if (!collection) ctx.throw(404, (0, import_validation_error.translate)(ctx, "Collection {{name}} does not exist", { name }));
|
|
520
|
+
return {
|
|
521
|
+
name,
|
|
522
|
+
physicalName: String(collection.options.tableName || name),
|
|
523
|
+
isSql: Boolean(collection.options.sql),
|
|
524
|
+
options: (0, import_lodash.cloneDeep)({
|
|
525
|
+
...collection.options,
|
|
526
|
+
tableName: String(collection.options.tableName || name),
|
|
527
|
+
fields: collection.getFields().map((field) => field.options)
|
|
528
|
+
})
|
|
529
|
+
};
|
|
530
|
+
});
|
|
531
|
+
const cascade = params.cascade === true || params.cascade === "true";
|
|
532
|
+
try {
|
|
533
|
+
await manager.db.sequelize.transaction(async (transaction) => {
|
|
534
|
+
for (const snapshot of [...snapshots].sort(
|
|
535
|
+
(left, right) => left.physicalName.localeCompare(right.physicalName)
|
|
536
|
+
)) {
|
|
537
|
+
await manager.db.sequelize.query("SELECT pg_advisory_xact_lock(hashtextextended(:table, 0))", {
|
|
538
|
+
replacements: { table: `${manager.db.options.schema || "public"}.${snapshot.physicalName}` },
|
|
539
|
+
transaction
|
|
540
|
+
});
|
|
541
|
+
if (!snapshot.isSql) await manager.dropTable(snapshot.name, cascade, transaction);
|
|
542
|
+
}
|
|
543
|
+
await next();
|
|
544
|
+
});
|
|
545
|
+
} catch (error) {
|
|
546
|
+
for (const snapshot of snapshots) {
|
|
547
|
+
if (!manager.hasCollection(snapshot.name)) manager.defineCollection(snapshot.options);
|
|
548
|
+
}
|
|
549
|
+
throw error;
|
|
550
|
+
}
|
|
551
|
+
const fieldsRepo = (_d = (_c = this.app.db) == null ? void 0 : _c.getRepository) == null ? void 0 : _d.call(_c, "dataSourcesFields");
|
|
552
|
+
if (fieldsRepo && typeof fieldsRepo.destroy === "function") {
|
|
553
|
+
try {
|
|
554
|
+
await fieldsRepo.destroy({
|
|
555
|
+
filter: { dataSourceKey: source.name, collectionName: { $in: collectionNames } },
|
|
556
|
+
individualHooks: false,
|
|
557
|
+
hooks: false
|
|
558
|
+
});
|
|
559
|
+
} catch (cleanupError) {
|
|
560
|
+
(_f = (_e = this.app.log) == null ? void 0 : _e.warn) == null ? void 0 : _f.call(_e, `Failed to clean up orphaned field metadata for PostgreSQL data source "${source.name}"`, {
|
|
561
|
+
cause: cleanupError
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
for (const snapshot of snapshots) {
|
|
566
|
+
if (manager.hasCollection(snapshot.name)) manager.removeCollection(snapshot.name);
|
|
567
|
+
}
|
|
568
|
+
await source.removeSelectedTables(
|
|
569
|
+
ctx,
|
|
570
|
+
snapshots.map((snapshot) => snapshot.physicalName)
|
|
571
|
+
);
|
|
572
|
+
await this.sendSyncMessage({
|
|
573
|
+
type: "collectionRemoved",
|
|
574
|
+
dataSourceKey: source.name,
|
|
575
|
+
collectionNames: snapshots.map((snapshot) => snapshot.name)
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
async mutateField(ctx, source, collectionName, input, next) {
|
|
579
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
580
|
+
const manager = source.collectionManager;
|
|
581
|
+
const collection = manager.getCollection(collectionName);
|
|
582
|
+
if (!collection) ctx.throw(404, (0, import_validation_error.translate)(ctx, "Collection {{name}} does not exist", { name: collectionName }));
|
|
583
|
+
const action = ctx.action.actionName;
|
|
584
|
+
const { params } = ctx.action;
|
|
585
|
+
const fieldName = params.filterByTk;
|
|
586
|
+
if (Array.isArray(fieldName)) ctx.throw(400, (0, import_validation_error.translate)(ctx, "Delete one field at a time"));
|
|
587
|
+
if (collection.options.sql) {
|
|
588
|
+
await next();
|
|
589
|
+
if (action === "destroy" && typeof fieldName === "string") {
|
|
590
|
+
if (collection.getField(fieldName)) collection.removeField(fieldName);
|
|
591
|
+
await this.sendSyncMessage({
|
|
592
|
+
type: "fieldRemoved",
|
|
593
|
+
dataSourceKey: source.name,
|
|
594
|
+
collectionName,
|
|
595
|
+
fieldName
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
if (collection.options.view) {
|
|
601
|
+
const targetName = fieldName || input.name;
|
|
602
|
+
if (action === "create" || action === "destroy" || !targetName || !collection.getField(targetName)) {
|
|
603
|
+
ctx.throw(403, (0, import_validation_error.translate)(ctx, "This collection is read-only"));
|
|
604
|
+
}
|
|
605
|
+
await next();
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
if (action === "destroy" && typeof fieldName === "string" && (0, import_field_hooks.removesPhysicalColumn)(collection, fieldName)) {
|
|
609
|
+
const columnName = ((_a = collection.getField(fieldName)) == null ? void 0 : _a.columnName()) || fieldName;
|
|
610
|
+
const references = await ctx.db.getRepository("dataSourcesFields").find({
|
|
611
|
+
filter: { dataSourceKey: source.name }
|
|
612
|
+
});
|
|
613
|
+
if (references.some(
|
|
614
|
+
(field) => (0, import_field_hooks.fieldReferencesColumn)(field.toJSON(), field.get("collectionName"), collectionName, [fieldName, columnName])
|
|
615
|
+
)) {
|
|
616
|
+
ctx.throw(400, (0, import_validation_error.translate)(ctx, "Field {{name}} is referenced by another field", { name: fieldName }));
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
const snapshot = (0, import_lodash.cloneDeep)({ ...collection.options, fields: collection.getFields().map((field) => field.options) });
|
|
620
|
+
const lockTables = (0, import_field_hooks.getRelationLockTables)(
|
|
621
|
+
manager,
|
|
622
|
+
collectionName,
|
|
623
|
+
input,
|
|
624
|
+
typeof fieldName === "string" ? fieldName : void 0
|
|
625
|
+
);
|
|
626
|
+
let metadataActionStarted = false;
|
|
627
|
+
try {
|
|
628
|
+
await manager.db.sequelize.transaction(async (transaction) => {
|
|
629
|
+
for (const table of lockTables) {
|
|
630
|
+
await manager.db.sequelize.query("SELECT pg_advisory_xact_lock(hashtextextended(:table, 0))", {
|
|
631
|
+
replacements: { table },
|
|
632
|
+
transaction
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
await (0, import_field_hooks.syncFieldAction)(manager, action, collectionName, fieldName, input, transaction);
|
|
636
|
+
metadataActionStarted = true;
|
|
637
|
+
await next();
|
|
638
|
+
});
|
|
639
|
+
} catch (error) {
|
|
640
|
+
const current = manager.getCollection(collectionName);
|
|
641
|
+
if (metadataActionStarted && current) {
|
|
642
|
+
current.resetFields();
|
|
643
|
+
current.updateOptions(snapshot);
|
|
644
|
+
}
|
|
645
|
+
throw error;
|
|
646
|
+
}
|
|
647
|
+
if (action === "destroy" && typeof fieldName === "string") {
|
|
648
|
+
if ((_b = manager.getCollection(collectionName)) == null ? void 0 : _b.getField(fieldName)) {
|
|
649
|
+
manager.getCollection(collectionName).removeField(fieldName);
|
|
650
|
+
}
|
|
651
|
+
await this.sendSyncMessage({
|
|
652
|
+
type: "fieldRemoved",
|
|
653
|
+
dataSourceKey: source.name,
|
|
654
|
+
collectionName,
|
|
655
|
+
fieldName
|
|
656
|
+
});
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
const savedName = typeof fieldName === "string" && fieldName ? fieldName : input.name;
|
|
660
|
+
const savedRelation = savedName ? ((_d = (_c = manager.getCollection(collectionName)) == null ? void 0 : _c.getField(savedName)) == null ? void 0 : _d.options) || input : input;
|
|
661
|
+
const companion = (0, import_field_hooks.buildArrayForeignKeyField)(manager, collectionName, savedRelation);
|
|
662
|
+
if (companion && typeof companion.name === "string") {
|
|
663
|
+
(_e = manager.getCollection(collectionName)) == null ? void 0 : _e.setField(companion.name, companion);
|
|
664
|
+
const fieldsRepo = (_g = (_f = this.app.db || ctx.db) == null ? void 0 : _f.getRepository) == null ? void 0 : _g.call(_f, "dataSourcesFields");
|
|
665
|
+
if (fieldsRepo && typeof fieldsRepo.findOne === "function" && typeof fieldsRepo.create === "function") {
|
|
666
|
+
try {
|
|
667
|
+
const existingRecord = await fieldsRepo.findOne({
|
|
668
|
+
filter: { dataSourceKey: source.name, collectionName, name: companion.name }
|
|
669
|
+
});
|
|
670
|
+
if (!existingRecord) {
|
|
671
|
+
await fieldsRepo.create({
|
|
672
|
+
values: { ...companion, collectionName, dataSourceKey: source.name }
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
} catch (companionError) {
|
|
676
|
+
(_i = (_h = this.app.log) == null ? void 0 : _h.warn) == null ? void 0 : _i.call(
|
|
677
|
+
_h,
|
|
678
|
+
`Failed to persist companion array field "${collectionName}.${companion.name}" for PostgreSQL data source "${source.name}"`,
|
|
679
|
+
{ cause: companionError }
|
|
680
|
+
);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
var plugin_default = PluginDataSourcePostgresServer;
|
|
687
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
688
|
+
0 && (module.exports = {
|
|
689
|
+
PluginDataSourcePostgresServer
|
|
690
|
+
});
|