@nocobase/plugin-mock-collections 0.21.0-alpha.1 → 0.21.0-alpha.10
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/externalVersion.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
"@nocobase/client": "0.21.0-alpha.
|
|
3
|
-
"@nocobase/database": "0.21.0-alpha.
|
|
4
|
-
"@nocobase/plugin-collection-manager": "0.21.0-alpha.
|
|
5
|
-
"@nocobase/server": "0.21.0-alpha.
|
|
6
|
-
"@nocobase/utils": "0.21.0-alpha.
|
|
2
|
+
"@nocobase/client": "0.21.0-alpha.10",
|
|
3
|
+
"@nocobase/database": "0.21.0-alpha.10",
|
|
4
|
+
"@nocobase/plugin-collection-manager": "0.21.0-alpha.10",
|
|
5
|
+
"@nocobase/server": "0.21.0-alpha.10",
|
|
6
|
+
"@nocobase/utils": "0.21.0-alpha.10",
|
|
7
7
|
"lodash": "4.17.21",
|
|
8
8
|
"pg": "8.11.3"
|
|
9
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@faker-js/faker","version":"8.1.0","description":"Generate massive amounts of fake contextual data","keywords":["faker","faker.js","fakerjs","faker-js","fake data generator","fake data","fake-data","fake-generator","fake-data-generator","fake content generator","fake contextual data generator","fake contextual data"],"repository":{"type":"git","url":"https://github.com/faker-js/faker.git"},"funding":[{"type":"opencollective","url":"https://opencollective.com/fakerjs"}],"bugs":"https://github.com/faker-js/faker/issues","license":"MIT","main":"dist/cjs/index.js","module":"dist/esm/index.mjs","types":"index.d.ts","typesVersions":{">=4.0":{"*":["dist/types/*"]}},"exports":{".":{"types":"./dist/types/index.d.ts","require":"./dist/cjs/index.js","import":"./dist/esm/index.mjs"},"./locale/*":{"types":"./dist/types/locale/*.d.ts","require":"./dist/cjs/locale/*.js","import":"./dist/esm/locale/*.mjs"},"./package.json":"./package.json"},"files":["CHANGELOG.md","dist"],"scripts":{"clean":"rimraf coverage .eslintcache dist docs/.vitepress/dist locale pnpm-lock.yaml node_modules","build:clean":"rimraf dist","build:code":"tsx ./scripts/bundle.ts","build:types":"tsc --project tsconfig.build.json","build":"run-s build:clean build:code build:types","generate":"run-s generate:locales generate:api-docs","generate:api-docs":"tsx ./scripts/apidoc.ts","generate:locales":"tsx ./scripts/generateLocales.ts","docs:build":"run-s docs:prepare docs:build:run","docs:build:run":"vitepress build docs","docs:build:ci":"run-s build docs:build","docs:prepare":"run-s generate:api-docs","docs:dev":"run-s docs:prepare docs:dev:run","docs:dev:run":"vitepress dev docs","docs:serve":"vitepress serve docs --port 5173","docs:diff":"tsx ./scripts/diff.ts","format":"prettier --cache --write .","lint":"eslint --cache --cache-strategy content --report-unused-disable-directives .","ts-check":"tsc","test":"vitest","test:update-snapshots":"vitest run -u","coverage":"vitest run --coverage","cypress":"cypress","docs:test:e2e:ci":"run-s docs:build:ci docs:test:e2e:run","docs:test:e2e:run":"run-p --race docs:serve \"cypress run\"","docs:test:e2e:open":"run-p --race docs:serve \"cypress open\"","release":"standard-version","prepublishOnly":"pnpm run clean && pnpm install && pnpm run build","preflight":"pnpm install && run-s generate format lint build test:update-snapshots ts-check"},"devDependencies":{"@actions/github":"~5.1.1","@algolia/client-search":"~4.19.1","@types/markdown-it":"~13.0.1","@types/node":"~20.6.2","@types/sanitize-html":"~2.9.0","@types/semver":"~7.5.2","@types/validator":"~13.11.1","@typescript-eslint/eslint-plugin":"~6.7.0","@typescript-eslint/parser":"~6.7.0","@vitest/coverage-v8":"~0.34.4","@vitest/ui":"~0.34.4","@vueuse/core":"~10.4.1","conventional-changelog-cli":"~4.1.0","cypress":"~13.2.0","esbuild":"~0.19.3","eslint":"~8.49.0","eslint-config-prettier":"~9.0.0","eslint-define-config":"~1.23.0","eslint-gitignore":"~0.1.0","eslint-plugin-deprecation":"~2.0.0","eslint-plugin-jsdoc":"~46.8.1","eslint-plugin-prettier":"~5.0.0","eslint-plugin-vitest":"~0.3.1","glob":"~10.3.4","npm-run-all":"~4.1.5","prettier":"3.0.3","prettier-plugin-organize-imports":"~3.2.3","rimraf":"~5.0.1","sanitize-html":"~2.11.0","semver":"~7.5.4","standard-version":"~9.5.0","tsx":"~3.12.10","typedoc":"~0.24.8","typescript":"~4.9.5","validator":"~13.11.0","vite":"~4.4.9","vitepress":"1.0.0-beta.7","vitest":"~0.34.4","vue":"~3.3.4"},"packageManager":"pnpm@8.5.1","engines":{"node":"^14.17.0 || ^16.13.0 || >=18.0.0","npm":">=6.14.13"},"_lastModified":"2024-
|
|
1
|
+
{"name":"@faker-js/faker","version":"8.1.0","description":"Generate massive amounts of fake contextual data","keywords":["faker","faker.js","fakerjs","faker-js","fake data generator","fake data","fake-data","fake-generator","fake-data-generator","fake content generator","fake contextual data generator","fake contextual data"],"repository":{"type":"git","url":"https://github.com/faker-js/faker.git"},"funding":[{"type":"opencollective","url":"https://opencollective.com/fakerjs"}],"bugs":"https://github.com/faker-js/faker/issues","license":"MIT","main":"dist/cjs/index.js","module":"dist/esm/index.mjs","types":"index.d.ts","typesVersions":{">=4.0":{"*":["dist/types/*"]}},"exports":{".":{"types":"./dist/types/index.d.ts","require":"./dist/cjs/index.js","import":"./dist/esm/index.mjs"},"./locale/*":{"types":"./dist/types/locale/*.d.ts","require":"./dist/cjs/locale/*.js","import":"./dist/esm/locale/*.mjs"},"./package.json":"./package.json"},"files":["CHANGELOG.md","dist"],"scripts":{"clean":"rimraf coverage .eslintcache dist docs/.vitepress/dist locale pnpm-lock.yaml node_modules","build:clean":"rimraf dist","build:code":"tsx ./scripts/bundle.ts","build:types":"tsc --project tsconfig.build.json","build":"run-s build:clean build:code build:types","generate":"run-s generate:locales generate:api-docs","generate:api-docs":"tsx ./scripts/apidoc.ts","generate:locales":"tsx ./scripts/generateLocales.ts","docs:build":"run-s docs:prepare docs:build:run","docs:build:run":"vitepress build docs","docs:build:ci":"run-s build docs:build","docs:prepare":"run-s generate:api-docs","docs:dev":"run-s docs:prepare docs:dev:run","docs:dev:run":"vitepress dev docs","docs:serve":"vitepress serve docs --port 5173","docs:diff":"tsx ./scripts/diff.ts","format":"prettier --cache --write .","lint":"eslint --cache --cache-strategy content --report-unused-disable-directives .","ts-check":"tsc","test":"vitest","test:update-snapshots":"vitest run -u","coverage":"vitest run --coverage","cypress":"cypress","docs:test:e2e:ci":"run-s docs:build:ci docs:test:e2e:run","docs:test:e2e:run":"run-p --race docs:serve \"cypress run\"","docs:test:e2e:open":"run-p --race docs:serve \"cypress open\"","release":"standard-version","prepublishOnly":"pnpm run clean && pnpm install && pnpm run build","preflight":"pnpm install && run-s generate format lint build test:update-snapshots ts-check"},"devDependencies":{"@actions/github":"~5.1.1","@algolia/client-search":"~4.19.1","@types/markdown-it":"~13.0.1","@types/node":"~20.6.2","@types/sanitize-html":"~2.9.0","@types/semver":"~7.5.2","@types/validator":"~13.11.1","@typescript-eslint/eslint-plugin":"~6.7.0","@typescript-eslint/parser":"~6.7.0","@vitest/coverage-v8":"~0.34.4","@vitest/ui":"~0.34.4","@vueuse/core":"~10.4.1","conventional-changelog-cli":"~4.1.0","cypress":"~13.2.0","esbuild":"~0.19.3","eslint":"~8.49.0","eslint-config-prettier":"~9.0.0","eslint-define-config":"~1.23.0","eslint-gitignore":"~0.1.0","eslint-plugin-deprecation":"~2.0.0","eslint-plugin-jsdoc":"~46.8.1","eslint-plugin-prettier":"~5.0.0","eslint-plugin-vitest":"~0.3.1","glob":"~10.3.4","npm-run-all":"~4.1.5","prettier":"3.0.3","prettier-plugin-organize-imports":"~3.2.3","rimraf":"~5.0.1","sanitize-html":"~2.11.0","semver":"~7.5.4","standard-version":"~9.5.0","tsx":"~3.12.10","typedoc":"~0.24.8","typescript":"~4.9.5","validator":"~13.11.0","vite":"~4.4.9","vitepress":"1.0.0-beta.7","vitest":"~0.34.4","vue":"~3.3.4"},"packageManager":"pnpm@8.5.1","engines":{"node":"^14.17.0 || ^16.13.0 || >=18.0.0","npm":">=6.14.13"},"_lastModified":"2024-04-16T16:10:13.289Z"}
|
package/dist/server/index.js
CHANGED
|
@@ -33,13 +33,13 @@ __export(server_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(server_exports);
|
|
34
34
|
var import_server = require("@nocobase/server");
|
|
35
35
|
var import_utils = require("@nocobase/utils");
|
|
36
|
+
var import_fs = require("fs");
|
|
36
37
|
var import_lodash = __toESM(require("lodash"));
|
|
38
|
+
var import_path = __toESM(require("path"));
|
|
39
|
+
var import_pg = require("pg");
|
|
37
40
|
var import_collection_templates = __toESM(require("./collection-templates"));
|
|
38
41
|
var fieldInterfaces = __toESM(require("./field-interfaces"));
|
|
39
42
|
var import_field_interfaces = require("./field-interfaces");
|
|
40
|
-
var import_pg = require("pg");
|
|
41
|
-
var import_path = __toESM(require("path"));
|
|
42
|
-
var import_fs = require("fs");
|
|
43
43
|
class PluginMockCollectionsServer extends import_server.Plugin {
|
|
44
44
|
async load() {
|
|
45
45
|
const templates = import_collection_templates.default;
|
|
@@ -217,8 +217,8 @@ class PluginMockCollectionsServer extends import_server.Plugin {
|
|
|
217
217
|
this.app.resourcer.registerActions({
|
|
218
218
|
mock: async (ctx, next) => {
|
|
219
219
|
const { resourceName } = ctx.action;
|
|
220
|
-
const { values, count = 10 } = ctx.action.params;
|
|
221
|
-
const mockCollectionData = async (collectionName, count2 = 1, depth = 0,
|
|
220
|
+
const { values, count = 10, maxDepth = 4 } = ctx.action.params;
|
|
221
|
+
const mockCollectionData = async (collectionName, count2 = 1, depth = 0, maxDepth2 = 4) => {
|
|
222
222
|
const collection = ctx.db.getCollection(collectionName);
|
|
223
223
|
const items = await Promise.all(
|
|
224
224
|
import_lodash.default.range(count2).map(async (i) => {
|
|
@@ -233,12 +233,12 @@ class PluginMockCollectionsServer extends import_server.Plugin {
|
|
|
233
233
|
if (!field.options.interface) {
|
|
234
234
|
continue;
|
|
235
235
|
}
|
|
236
|
-
if (depth >=
|
|
236
|
+
if (depth >= maxDepth2 && ["m2o", "m2m", "o2m", "obo", "oho"].includes(field.options.interface)) {
|
|
237
237
|
continue;
|
|
238
238
|
}
|
|
239
239
|
const fn = fieldInterfaces[field.options.interface];
|
|
240
240
|
if (fn == null ? void 0 : fn.mock) {
|
|
241
|
-
v[field.name] = await fn.mock(field.options, { mockCollectionData, maxDepth, depth });
|
|
241
|
+
v[field.name] = await fn.mock(field.options, { mockCollectionData, maxDepth: maxDepth2, depth });
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
return v;
|
|
@@ -251,7 +251,7 @@ class PluginMockCollectionsServer extends import_server.Plugin {
|
|
|
251
251
|
if (Array.isArray(values)) {
|
|
252
252
|
size = values.length;
|
|
253
253
|
}
|
|
254
|
-
const data = await mockCollectionData(resourceName, size);
|
|
254
|
+
const data = await mockCollectionData(resourceName, size, 0, Number(maxDepth));
|
|
255
255
|
ctx.body = await repository.create({
|
|
256
256
|
values: (Array.isArray(data) ? data : [data]).map((item, index) => {
|
|
257
257
|
if (Array.isArray(values)) {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@nocobase/plugin-mock-collections",
|
|
3
3
|
"displayName": "mock-collections",
|
|
4
4
|
"description": "mock-collections",
|
|
5
|
-
"version": "0.21.0-alpha.
|
|
5
|
+
"version": "0.21.0-alpha.10",
|
|
6
6
|
"main": "./dist/server/index.js",
|
|
7
7
|
"license": "AGPL-3.0",
|
|
8
8
|
"peerDependencies": {
|
|
@@ -16,5 +16,5 @@
|
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"pg": "^8.11.3"
|
|
18
18
|
},
|
|
19
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "98adf5ec996a4f359c6ca1c4a6ac837c43b6e268"
|
|
20
20
|
}
|