@nocobase/plugin-mock-collections 0.16.0-alpha.5 → 0.16.0-alpha.6

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.
@@ -1,8 +1,8 @@
1
1
  module.exports = {
2
- "@nocobase/client": "0.16.0-alpha.5",
3
- "@nocobase/database": "0.16.0-alpha.5",
4
- "@nocobase/plugin-collection-manager": "0.16.0-alpha.5",
5
- "@nocobase/server": "0.16.0-alpha.5",
6
- "@nocobase/utils": "0.16.0-alpha.5",
2
+ "@nocobase/client": "0.16.0-alpha.6",
3
+ "@nocobase/database": "0.16.0-alpha.6",
4
+ "@nocobase/plugin-collection-manager": "0.16.0-alpha.6",
5
+ "@nocobase/server": "0.16.0-alpha.6",
6
+ "@nocobase/utils": "0.16.0-alpha.6",
7
7
  "lodash": "4.17.21"
8
8
  };
@@ -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":"2023-11-30T04:55:00.402Z"}
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":"2023-12-04T03:13:07.454Z"}
@@ -222,9 +222,9 @@ class PluginMockCollectionsServer extends import_server.Plugin {
222
222
  if (collection.options.template === "file") {
223
223
  return (0, import_field_interfaces.mockAttachment)();
224
224
  }
225
- const values2 = {};
225
+ const v = {};
226
226
  if (collection.options.sortable) {
227
- values2["sort"] = i + 1;
227
+ v["sort"] = i + 1;
228
228
  }
229
229
  for (const field of collection.fields.values()) {
230
230
  if (!field.options.interface) {
@@ -235,18 +235,27 @@ class PluginMockCollectionsServer extends import_server.Plugin {
235
235
  }
236
236
  const fn = fieldInterfaces[field.options.interface];
237
237
  if (fn == null ? void 0 : fn.mock) {
238
- values2[field.name] = await fn.mock(field.options, { mockCollectionData, maxDepth, depth });
238
+ v[field.name] = await fn.mock(field.options, { mockCollectionData, maxDepth, depth });
239
239
  }
240
240
  }
241
- return values2;
241
+ return v;
242
242
  })
243
243
  );
244
244
  return count2 == 1 ? items[0] : items;
245
245
  };
246
246
  const repository = ctx.db.getRepository(resourceName);
247
- const data = await mockCollectionData(resourceName, count);
247
+ let size = count;
248
+ if (Array.isArray(values)) {
249
+ size = values.length;
250
+ }
251
+ const data = await mockCollectionData(resourceName, size);
248
252
  ctx.body = await repository.create({
249
- values: (Array.isArray(data) ? data : [data]).map((item) => ({ ...item, ...values }))
253
+ values: (Array.isArray(data) ? data : [data]).map((item, index) => {
254
+ if (Array.isArray(values)) {
255
+ return { ...item, ...values[index] };
256
+ }
257
+ return { ...item, ...values };
258
+ })
250
259
  });
251
260
  await next();
252
261
  },
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.16.0-alpha.5",
5
+ "version": "0.16.0-alpha.6",
6
6
  "main": "./dist/server/index.js",
7
7
  "license": "AGPL-3.0",
8
8
  "peerDependencies": {
@@ -13,5 +13,5 @@
13
13
  "@nocobase/test": "0.x",
14
14
  "@nocobase/utils": "0.x"
15
15
  },
16
- "gitHead": "3badd2569e4658023897fa381ac4dd30e64d5bce"
16
+ "gitHead": "e8ad2328a8f85289cb19a7994d3fd726c7ae1720"
17
17
  }