@nocobase/plugin-data-source-main 2.1.0-beta.8 → 2.2.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,280 @@
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 __create = Object.create;
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __export = (target, all) => {
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: true });
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
36
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
+ var collections_exports = {};
38
+ __export(collections_exports, {
39
+ buildTemplateBaseline: () => buildTemplateBaseline,
40
+ composeCollectionDefinition: () => composeCollectionDefinition,
41
+ normalizeCollectionInput: () => normalizeCollectionInput
42
+ });
43
+ module.exports = __toCommonJS(collections_exports);
44
+ var import_lodash = __toESM(require("lodash"));
45
+ var import_constants = require("./constants");
46
+ var import_fields = require("./fields");
47
+ function buildPresetFields(options) {
48
+ const fields = [];
49
+ if (options.includeId) {
50
+ fields.push((0, import_fields.normalizeFieldInput)({ name: "id", interface: "snowflakeId", title: "ID" }));
51
+ }
52
+ if (options.includeCreatedAt) {
53
+ fields.push((0, import_fields.normalizeFieldInput)({ name: "createdAt", interface: "createdAt", title: "Created at" }));
54
+ }
55
+ if (options.includeCreatedBy) {
56
+ fields.push((0, import_fields.normalizeFieldInput)({ name: "createdBy", interface: "createdBy", title: "Created by" }));
57
+ }
58
+ if (options.includeUpdatedAt) {
59
+ fields.push((0, import_fields.normalizeFieldInput)({ name: "updatedAt", interface: "updatedAt", title: "Last updated at" }));
60
+ }
61
+ if (options.includeUpdatedBy) {
62
+ fields.push((0, import_fields.normalizeFieldInput)({ name: "updatedBy", interface: "updatedBy", title: "Last updated by" }));
63
+ }
64
+ return fields;
65
+ }
66
+ function buildTemplateBaseline(input) {
67
+ const template = input.template || "general";
68
+ const name = input.name;
69
+ const titleField = input.titleField || "title";
70
+ switch (template) {
71
+ case "general":
72
+ return {
73
+ template,
74
+ logging: input.logging ?? true,
75
+ autoGenId: false,
76
+ fields: buildPresetFields({
77
+ includeId: true,
78
+ includeCreatedAt: true,
79
+ includeCreatedBy: true,
80
+ includeUpdatedAt: true,
81
+ includeUpdatedBy: true
82
+ })
83
+ };
84
+ case "tree":
85
+ return {
86
+ template,
87
+ logging: input.logging ?? true,
88
+ view: false,
89
+ tree: input.tree || "adjacencyList",
90
+ autoGenId: false,
91
+ fields: [
92
+ (0, import_fields.normalizeFieldInput)({
93
+ name: "parentId",
94
+ interface: "integer",
95
+ type: "bigInt",
96
+ isForeignKey: true,
97
+ autoFill: false,
98
+ title: "Parent ID"
99
+ }),
100
+ (0, import_fields.normalizeFieldInput)({
101
+ name: "parent",
102
+ interface: "m2o",
103
+ target: name,
104
+ foreignKey: "parentId",
105
+ treeParent: true,
106
+ onDelete: "CASCADE",
107
+ targetTitleField: titleField,
108
+ title: "Parent"
109
+ }),
110
+ (0, import_fields.normalizeFieldInput)({
111
+ name: "children",
112
+ interface: "o2m",
113
+ target: name,
114
+ foreignKey: "parentId",
115
+ treeChildren: true,
116
+ onDelete: "CASCADE",
117
+ targetTitleField: titleField,
118
+ title: "Children"
119
+ }),
120
+ ...buildPresetFields({
121
+ includeId: true,
122
+ includeCreatedAt: true,
123
+ includeCreatedBy: true,
124
+ includeUpdatedAt: true,
125
+ includeUpdatedBy: true
126
+ })
127
+ ]
128
+ };
129
+ case "file":
130
+ return {
131
+ template,
132
+ logging: input.logging ?? true,
133
+ view: false,
134
+ createdBy: true,
135
+ updatedBy: true,
136
+ fields: [
137
+ (0, import_fields.normalizeFieldInput)({ name: "title", interface: "input", title: "Title" }),
138
+ (0, import_fields.normalizeFieldInput)({ name: "filename", interface: "input", title: "File name" }),
139
+ (0, import_fields.normalizeFieldInput)({ name: "extname", interface: "input", title: "Extension name" }),
140
+ (0, import_fields.normalizeFieldInput)({ name: "size", interface: "integer", type: "integer", title: "Size" }),
141
+ (0, import_fields.normalizeFieldInput)({ name: "mimetype", interface: "input", title: "MIME type" }),
142
+ (0, import_fields.normalizeFieldInput)({ name: "path", interface: "textarea", type: "text", title: "Path" }),
143
+ (0, import_fields.normalizeFieldInput)({ name: "url", interface: "url", type: "text", title: "URL" }),
144
+ (0, import_fields.normalizeFieldInput)({ name: "preview", interface: "url", type: "text", field: "url", title: "Preview" }),
145
+ (0, import_fields.normalizeFieldInput)({
146
+ name: "storage",
147
+ interface: "m2o",
148
+ target: "storages",
149
+ foreignKey: "storageId",
150
+ targetTitleField: "title",
151
+ title: "Storage"
152
+ }),
153
+ (0, import_fields.normalizeFieldInput)({
154
+ name: "meta",
155
+ interface: "json",
156
+ type: "jsonb",
157
+ defaultValue: {},
158
+ title: "Meta"
159
+ }),
160
+ ...buildPresetFields({
161
+ includeId: true,
162
+ includeCreatedAt: true,
163
+ includeCreatedBy: true,
164
+ includeUpdatedAt: true,
165
+ includeUpdatedBy: true
166
+ })
167
+ ]
168
+ };
169
+ case "calendar":
170
+ return {
171
+ template,
172
+ logging: input.logging ?? true,
173
+ createdBy: true,
174
+ updatedBy: true,
175
+ createdAt: true,
176
+ updatedAt: true,
177
+ sortable: input.sortable ?? true,
178
+ fields: [
179
+ (0, import_fields.normalizeFieldInput)({
180
+ name: "cron",
181
+ interface: "select",
182
+ type: "string",
183
+ title: "Repeats",
184
+ uiSchema: {
185
+ type: "string",
186
+ title: "Repeats",
187
+ "x-component": "CronSet",
188
+ "x-component-props": "allowClear",
189
+ enum: [
190
+ { label: "Daily", value: "0 0 0 * * ?" },
191
+ { label: "Weekly", value: "every_week" },
192
+ { label: "Monthly", value: "every_month" },
193
+ { label: "Yearly", value: "every_year" }
194
+ ]
195
+ }
196
+ }),
197
+ (0, import_fields.normalizeFieldInput)({
198
+ name: "exclude",
199
+ interface: "json",
200
+ type: "json",
201
+ title: "Exclude"
202
+ }),
203
+ ...buildPresetFields({
204
+ includeId: true,
205
+ includeCreatedAt: true,
206
+ includeCreatedBy: true,
207
+ includeUpdatedAt: true,
208
+ includeUpdatedBy: true
209
+ })
210
+ ]
211
+ };
212
+ case "comment":
213
+ return {
214
+ template,
215
+ logging: input.logging ?? true,
216
+ autoGenId: false,
217
+ fields: [
218
+ (0, import_fields.normalizeFieldInput)({
219
+ name: "content",
220
+ interface: "vditor",
221
+ type: "text",
222
+ length: "long",
223
+ deletable: false,
224
+ title: "Comment Content"
225
+ }),
226
+ ...buildPresetFields({
227
+ includeId: true,
228
+ includeCreatedAt: true,
229
+ includeCreatedBy: true,
230
+ includeUpdatedAt: true,
231
+ includeUpdatedBy: true
232
+ })
233
+ ]
234
+ };
235
+ case "view":
236
+ return { template, view: true, schema: input.schema || "public" };
237
+ case "inherit":
238
+ return { template, inherits: input.inherits };
239
+ case "sql":
240
+ default:
241
+ return { template };
242
+ }
243
+ }
244
+ function normalizeCollectionInput(input, options = {}) {
245
+ var _a, _b;
246
+ const values = import_lodash.default.cloneDeep(input || {});
247
+ if ((options.mode || "create") === "create") {
248
+ values.template = values.template || "general";
249
+ values.title = values.title || (0, import_constants.toDisplayTitle)(values.name);
250
+ }
251
+ if (Array.isArray(values.fields)) {
252
+ values.fields = values.fields.map((field) => (0, import_fields.normalizeFieldInput)(field, { collectionName: values.name }));
253
+ }
254
+ if ((options.mode || "create") === "create" && !values.titleField) {
255
+ const primaryKeyField = (_b = (_a = values.fields) == null ? void 0 : _a.find) == null ? void 0 : _b.call(_a, (field) => (field == null ? void 0 : field.primaryKey) === true);
256
+ if (primaryKeyField == null ? void 0 : primaryKeyField.name) {
257
+ values.titleField = primaryKeyField.name;
258
+ }
259
+ }
260
+ return values;
261
+ }
262
+ function composeCollectionDefinition(input, options = {}) {
263
+ const baseline = options.mode === "create" ? buildTemplateBaseline(input) : {};
264
+ const baselineFields = Array.isArray(baseline.fields) ? baseline.fields : [];
265
+ const inputFields = Array.isArray(input.fields) ? input.fields : [];
266
+ return normalizeCollectionInput(
267
+ {
268
+ ...baseline,
269
+ ...input,
270
+ fields: (0, import_constants.uniqueByName)([...baselineFields, ...inputFields])
271
+ },
272
+ options
273
+ );
274
+ }
275
+ // Annotate the CommonJS export names for ESM import in node:
276
+ 0 && (module.exports = {
277
+ buildTemplateBaseline,
278
+ composeCollectionDefinition,
279
+ normalizeCollectionInput
280
+ });
@@ -0,0 +1,26 @@
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
+ export type PlainObject = Record<string, any>;
10
+ export type TemplateName = 'general' | 'tree' | 'file' | 'calendar' | 'comment' | 'sql' | 'view' | 'inherit';
11
+ export declare const TEMPLATE_NAMES: TemplateName[];
12
+ export declare const MULTI_COMPONENT_INTERFACES: Set<string>;
13
+ export declare const ARRAY_DEFAULT_INTERFACES: Set<string>;
14
+ export declare const CHOICE_INTERFACES: Set<string>;
15
+ export declare const RELATION_INTERFACES: Set<string>;
16
+ export declare const INTERFACE_ALIASES: Record<string, string>;
17
+ export declare const CHOICE_COLOR_OPTIONS: string[];
18
+ export declare const PLUGIN_REQUIREMENTS: Record<string, {
19
+ runtimeName: string;
20
+ packageName: string;
21
+ capability: string;
22
+ }>;
23
+ export declare function toDisplayTitle(value?: string): string;
24
+ export declare function normalizeChoiceEnum(enumValues?: any[]): any[];
25
+ export declare function validateChoiceEnumColors(enumValues?: any[], fieldName?: string): void;
26
+ export declare function uniqueByName(fields: PlainObject[]): PlainObject[];
@@ -0,0 +1,239 @@
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 __create = Object.create;
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __export = (target, all) => {
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: true });
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
36
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
+ var constants_exports = {};
38
+ __export(constants_exports, {
39
+ ARRAY_DEFAULT_INTERFACES: () => ARRAY_DEFAULT_INTERFACES,
40
+ CHOICE_COLOR_OPTIONS: () => CHOICE_COLOR_OPTIONS,
41
+ CHOICE_INTERFACES: () => CHOICE_INTERFACES,
42
+ INTERFACE_ALIASES: () => INTERFACE_ALIASES,
43
+ MULTI_COMPONENT_INTERFACES: () => MULTI_COMPONENT_INTERFACES,
44
+ PLUGIN_REQUIREMENTS: () => PLUGIN_REQUIREMENTS,
45
+ RELATION_INTERFACES: () => RELATION_INTERFACES,
46
+ TEMPLATE_NAMES: () => TEMPLATE_NAMES,
47
+ normalizeChoiceEnum: () => normalizeChoiceEnum,
48
+ toDisplayTitle: () => toDisplayTitle,
49
+ uniqueByName: () => uniqueByName,
50
+ validateChoiceEnumColors: () => validateChoiceEnumColors
51
+ });
52
+ module.exports = __toCommonJS(constants_exports);
53
+ var import_lodash = __toESM(require("lodash"));
54
+ const TEMPLATE_NAMES = [
55
+ "general",
56
+ "tree",
57
+ "file",
58
+ "calendar",
59
+ "comment",
60
+ "sql",
61
+ "view",
62
+ "inherit"
63
+ ];
64
+ const MULTI_COMPONENT_INTERFACES = /* @__PURE__ */ new Set([
65
+ "multipleSelect",
66
+ "checkboxGroup",
67
+ "m2m",
68
+ "o2m",
69
+ "attachment",
70
+ "mbm"
71
+ ]);
72
+ const ARRAY_DEFAULT_INTERFACES = /* @__PURE__ */ new Set(["multipleSelect", "checkboxGroup"]);
73
+ const CHOICE_INTERFACES = /* @__PURE__ */ new Set(["select", "multipleSelect", "radioGroup", "checkboxGroup"]);
74
+ const RELATION_INTERFACES = /* @__PURE__ */ new Set(["m2o", "o2m", "m2m", "obo", "oho", "mbm"]);
75
+ const INTERFACE_ALIASES = {
76
+ text: "textarea",
77
+ longText: "textarea",
78
+ singleSelect: "select",
79
+ multiSelect: "multipleSelect",
80
+ singleLineText: "input",
81
+ date: "dateOnly",
82
+ dateOnly: "dateOnly",
83
+ datetimeWithoutTz: "datetimeNoTz",
84
+ datetimeWithoutTimezone: "datetimeNoTz",
85
+ datetimeWithTimezone: "datetime",
86
+ unixTs: "unixTimestamp",
87
+ o2o: "obo"
88
+ };
89
+ const CHOICE_COLOR_OPTIONS = [
90
+ "red",
91
+ "magenta",
92
+ "volcano",
93
+ "orange",
94
+ "gold",
95
+ "lime",
96
+ "green",
97
+ "cyan",
98
+ "blue",
99
+ "geekblue",
100
+ "purple",
101
+ "default"
102
+ ];
103
+ const CHOICE_COLOR_OPTION_SET = new Set(CHOICE_COLOR_OPTIONS);
104
+ const PLUGIN_REQUIREMENTS = {
105
+ file: {
106
+ runtimeName: "file-manager",
107
+ packageName: "@nocobase/plugin-file-manager",
108
+ capability: "file collection template"
109
+ },
110
+ attachment: {
111
+ runtimeName: "file-manager",
112
+ packageName: "@nocobase/plugin-file-manager",
113
+ capability: "attachment field and attachments collection"
114
+ },
115
+ attachmentURL: {
116
+ runtimeName: "field-attachment-url",
117
+ packageName: "@nocobase/plugin-field-attachment-url",
118
+ capability: "attachmentURL field"
119
+ },
120
+ comment: {
121
+ runtimeName: "comments",
122
+ packageName: "@nocobase/plugin-comments",
123
+ capability: "comment collection template"
124
+ },
125
+ vditor: {
126
+ runtimeName: "field-markdown-vditor",
127
+ packageName: "@nocobase/plugin-field-markdown-vditor",
128
+ capability: "vditor field"
129
+ },
130
+ point: {
131
+ runtimeName: "map",
132
+ packageName: "@nocobase/plugin-map",
133
+ capability: "point geometry field"
134
+ },
135
+ lineString: {
136
+ runtimeName: "map",
137
+ packageName: "@nocobase/plugin-map",
138
+ capability: "lineString geometry field"
139
+ },
140
+ circle: {
141
+ runtimeName: "map",
142
+ packageName: "@nocobase/plugin-map",
143
+ capability: "circle geometry field"
144
+ },
145
+ polygon: {
146
+ runtimeName: "map",
147
+ packageName: "@nocobase/plugin-map",
148
+ capability: "polygon geometry field"
149
+ },
150
+ chinaRegion: {
151
+ runtimeName: "field-china-region",
152
+ packageName: "@nocobase/plugin-field-china-region",
153
+ capability: "chinaRegion field and chinaRegions backing collection"
154
+ },
155
+ formula: {
156
+ runtimeName: "field-formula",
157
+ packageName: "@nocobase/plugin-field-formula",
158
+ capability: "formula field"
159
+ },
160
+ sort: {
161
+ runtimeName: "field-sort",
162
+ packageName: "@nocobase/plugin-field-sort",
163
+ capability: "sort field"
164
+ },
165
+ code: {
166
+ runtimeName: "field-code",
167
+ packageName: "@nocobase/plugin-field-code",
168
+ capability: "code field"
169
+ },
170
+ sequence: {
171
+ runtimeName: "field-sequence",
172
+ packageName: "@nocobase/plugin-field-sequence",
173
+ capability: "sequence field"
174
+ },
175
+ encryption: {
176
+ runtimeName: "field-encryption",
177
+ packageName: "@nocobase/plugin-field-encryption",
178
+ capability: "encryption field"
179
+ },
180
+ mbm: {
181
+ runtimeName: "field-m2m-array",
182
+ packageName: "@nocobase/plugin-field-m2m-array",
183
+ capability: "many-to-many array field"
184
+ }
185
+ };
186
+ function toDisplayTitle(value) {
187
+ if (!value) {
188
+ return value;
189
+ }
190
+ return import_lodash.default.startCase(value.replace(/[._-]+/g, " "));
191
+ }
192
+ function normalizeChoiceEnum(enumValues = []) {
193
+ return enumValues.map((item) => {
194
+ if (import_lodash.default.isPlainObject(item)) {
195
+ return item;
196
+ }
197
+ return {
198
+ label: String(item),
199
+ value: item
200
+ };
201
+ });
202
+ }
203
+ function validateChoiceEnumColors(enumValues = [], fieldName = "(unknown)") {
204
+ const allowedColors = CHOICE_COLOR_OPTIONS.join(", ");
205
+ enumValues.forEach((item, index) => {
206
+ if (!import_lodash.default.isPlainObject(item)) {
207
+ throw new Error(
208
+ `Field ${fieldName} enum item #${index + 1} must be an object with value, label, and color; string shorthand is not allowed`
209
+ );
210
+ }
211
+ const optionName = item.value ?? item.label ?? `#${index + 1}`;
212
+ if (!item.color) {
213
+ throw new Error(`Field ${fieldName} enum item ${optionName} requires color`);
214
+ }
215
+ if (!CHOICE_COLOR_OPTION_SET.has(item.color)) {
216
+ throw new Error(
217
+ `Field ${fieldName} enum item ${optionName} color ${item.color} is invalid. Allowed colors: ${allowedColors}`
218
+ );
219
+ }
220
+ });
221
+ }
222
+ function uniqueByName(fields) {
223
+ return import_lodash.default.uniqBy(fields.filter(Boolean).reverse(), "name").reverse();
224
+ }
225
+ // Annotate the CommonJS export names for ESM import in node:
226
+ 0 && (module.exports = {
227
+ ARRAY_DEFAULT_INTERFACES,
228
+ CHOICE_COLOR_OPTIONS,
229
+ CHOICE_INTERFACES,
230
+ INTERFACE_ALIASES,
231
+ MULTI_COMPONENT_INTERFACES,
232
+ PLUGIN_REQUIREMENTS,
233
+ RELATION_INTERFACES,
234
+ TEMPLATE_NAMES,
235
+ normalizeChoiceEnum,
236
+ toDisplayTitle,
237
+ uniqueByName,
238
+ validateChoiceEnumColors
239
+ });
@@ -0,0 +1,13 @@
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
+ import { PlainObject } from './constants';
10
+ export declare function normalizeInterfaceName(value?: string): string;
11
+ export declare function validateChoiceFieldInput(field?: PlainObject): void;
12
+ export declare function normalizeFieldInput(input: PlainObject, context?: PlainObject): PlainObject;
13
+ export declare function normalizeFieldList(fields?: PlainObject[], collectionName?: string): PlainObject[];