@nocobase/plugin-mock-collections 0.20.0-alpha.8 → 0.21.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.
@@ -1,8 +1,9 @@
1
1
  module.exports = {
2
- "@nocobase/client": "0.20.0-alpha.8",
3
- "@nocobase/database": "0.20.0-alpha.8",
4
- "@nocobase/plugin-collection-manager": "0.20.0-alpha.8",
5
- "@nocobase/server": "0.20.0-alpha.8",
6
- "@nocobase/utils": "0.20.0-alpha.8",
7
- "lodash": "4.17.21"
2
+ "@nocobase/client": "0.21.0-alpha.1",
3
+ "@nocobase/database": "0.21.0-alpha.1",
4
+ "@nocobase/plugin-collection-manager": "0.21.0-alpha.1",
5
+ "@nocobase/server": "0.21.0-alpha.1",
6
+ "@nocobase/utils": "0.21.0-alpha.1",
7
+ "lodash": "4.17.21",
8
+ "pg": "8.11.3"
8
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-03-11T02:08:36.659Z"}
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-03-29T09:53:07.424Z"}
@@ -0,0 +1,175 @@
1
+ CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
2
+
3
+ -- 创建 users 表
4
+ CREATE TABLE users (
5
+ user_uuid UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
6
+ username VARCHAR(100) NOT NULL
7
+ );
8
+
9
+ -- 创建 profiles 表
10
+ CREATE TABLE profiles (
11
+ profile_uuid UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
12
+ address VARCHAR(255),
13
+ user_uuid UUID REFERENCES users(user_uuid)
14
+ );
15
+
16
+ -- 创建 roles 表
17
+ CREATE TABLE roles (
18
+ role_uuid UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
19
+ role_name VARCHAR(100) NOT NULL
20
+ );
21
+
22
+ -- 创建 user_roles 关联表
23
+ CREATE TABLE user_roles (
24
+ user_uuid UUID REFERENCES users(user_uuid),
25
+ role_uuid UUID REFERENCES roles(role_uuid),
26
+ PRIMARY KEY (user_uuid, role_uuid)
27
+ );
28
+
29
+
30
+ -- 创建 orders 表
31
+ CREATE TABLE orders (
32
+ order_uuid UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
33
+ user_uuid UUID REFERENCES users(user_uuid),
34
+ order_name VARCHAR(255) NOT NULL
35
+ -- ... 其他字段
36
+ );
37
+
38
+ -- 向 users 表插入测试数据
39
+ INSERT INTO users (username) VALUES
40
+ ('Alice'),
41
+ ('Bob');
42
+
43
+ INSERT INTO orders (user_uuid, order_name) VALUES
44
+ ((SELECT user_uuid FROM users WHERE username = 'Alice'), 'Order1'),
45
+ ((SELECT user_uuid FROM users WHERE username = 'Bob'), 'Order2');
46
+
47
+
48
+ -- 向 profiles 表插入测试数据
49
+ INSERT INTO profiles (address, user_uuid) VALUES
50
+ ('123 Main St', (SELECT user_uuid FROM users WHERE username = 'Alice')),
51
+ ('456 High St', (SELECT user_uuid FROM users WHERE username = 'Bob'));
52
+
53
+ -- 向 roles 表插入测试数据
54
+ INSERT INTO roles (role_name) VALUES
55
+ ('Admin'),
56
+ ('User');
57
+
58
+ -- 建立 users 和 roles 之间的关系
59
+ INSERT INTO user_roles (user_uuid, role_uuid) VALUES
60
+ ((SELECT user_uuid FROM users WHERE username = 'Alice'), (SELECT role_uuid FROM roles WHERE role_name = 'Admin')),
61
+ ((SELECT user_uuid FROM users WHERE username = 'Bob'), (SELECT role_uuid FROM roles WHERE role_name = 'User'));
62
+
63
+
64
+ CREATE TABLE "test_table" (
65
+ "id2" SERIAL PRIMARY KEY,
66
+ "smallint" int2,
67
+ "integer" int4,
68
+ "bigint" int8,
69
+ "boolean" bool,
70
+ "numeric" numeric,
71
+ "real" float4,
72
+ "double" float8,
73
+ "money" money,
74
+ "date" date,
75
+ "time" time,
76
+ "timestamp" timestamp,
77
+ "timestamptz" timestamptz,
78
+ "interval" interval,
79
+ "char" bpchar,
80
+ "varchar" varchar,
81
+ "text" text,
82
+ "tsquery" tsquery,
83
+ "tsvector" tsvector,
84
+ "uuid" uuid,
85
+ "xml" xml,
86
+ "json" json,
87
+ "jsonb" jsonb,
88
+ "bit" bit,
89
+ "bitvarying" varbit,
90
+ "bytea" bytea,
91
+ "cidr" cidr,
92
+ "inet" inet,
93
+ "macaddr" macaddr,
94
+ "txidsnapshot" txid_snapshot,
95
+ "box" box,
96
+ "circle" circle,
97
+ "line" line,
98
+ "lseg" lseg,
99
+ "path" path,
100
+ "point" point,
101
+ "polygon" polygon
102
+ );
103
+
104
+
105
+ -- 创建 authors 表
106
+ CREATE TABLE authors (
107
+ author_id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
108
+ author_name VARCHAR(100) NOT NULL
109
+ );
110
+
111
+ -- 创建 posts 表
112
+ CREATE TABLE posts (
113
+ post_id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
114
+ post_title VARCHAR(100) NOT NULL,
115
+ post_content TEXT NOT NULL,
116
+ author_id UUID REFERENCES authors(author_id)
117
+ );
118
+
119
+ -- 创建 comments 表
120
+ CREATE TABLE comments (
121
+ comment_id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
122
+ comment_content TEXT NOT NULL,
123
+ post_id UUID REFERENCES posts(post_id),
124
+ author_id UUID REFERENCES authors(author_id)
125
+ );
126
+
127
+ -- 创建 tags 表
128
+ CREATE TABLE tags (
129
+ tag_id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
130
+ tag_name VARCHAR(100) NOT NULL
131
+ );
132
+
133
+ -- 创建 post_tags 关联表
134
+ CREATE TABLE post_tags (
135
+ post_id UUID REFERENCES posts(post_id),
136
+ tag_id UUID REFERENCES tags(tag_id),
137
+ PRIMARY KEY (post_id, tag_id)
138
+ );
139
+
140
+ -- 向 authors 表插入测试数据
141
+ INSERT INTO authors (author_name) VALUES
142
+ ('Author1'),
143
+ ('Author2');
144
+
145
+ -- 向 posts 表插入测试数据
146
+ INSERT INTO posts (post_title, post_content, author_id) VALUES
147
+ ('Post1', 'This is the content of Post1', (SELECT author_id FROM authors WHERE author_name = 'Author1')),
148
+ ('Post2', 'This is the content of Post2', (SELECT author_id FROM authors WHERE author_name = 'Author2'));
149
+
150
+ -- 向 comments 表插入测试数据
151
+ INSERT INTO comments (comment_content, post_id, author_id) VALUES
152
+ ('This is a comment on Post1', (SELECT post_id FROM posts WHERE post_title = 'Post1'), (SELECT author_id FROM authors WHERE author_name = 'Author1')),
153
+ ('This is a comment on Post2', (SELECT post_id FROM posts WHERE post_title = 'Post2'), (SELECT author_id FROM authors WHERE author_name = 'Author2'));
154
+
155
+ -- 向 tags 表插入测试数据
156
+ INSERT INTO tags (tag_name) VALUES
157
+ ('Tag1'),
158
+ ('Tag2');
159
+
160
+ -- 建立 posts 和 tags 之间的关系
161
+ INSERT INTO post_tags (post_id, tag_id) VALUES
162
+ ((SELECT post_id FROM posts WHERE post_title = 'Post1'), (SELECT tag_id FROM tags WHERE tag_name = 'Tag1')),
163
+ ((SELECT post_id FROM posts WHERE post_title = 'Post2'), (SELECT tag_id FROM tags WHERE tag_name = 'Tag2'));
164
+
165
+
166
+ -- 创建无主键的表 test_table_no_pk
167
+ CREATE TABLE test_table_no_pk (
168
+ column1 VARCHAR(100),
169
+ column2 INT
170
+ );
171
+
172
+ -- 向 test_table_no_pk 表插入测试数据
173
+ INSERT INTO test_table_no_pk (column1, column2) VALUES
174
+ ('TestData1', 1),
175
+ ('TestData2', 2);
@@ -1,5 +1,6 @@
1
- import { Plugin } from '@nocobase/server';
1
+ import { InstallOptions, Plugin } from '@nocobase/server';
2
2
  export declare class PluginMockCollectionsServer extends Plugin {
3
3
  load(): Promise<void>;
4
+ install(options?: InstallOptions): Promise<void>;
4
5
  }
5
6
  export default PluginMockCollectionsServer;
@@ -37,6 +37,9 @@ var import_lodash = __toESM(require("lodash"));
37
37
  var import_collection_templates = __toESM(require("./collection-templates"));
38
38
  var fieldInterfaces = __toESM(require("./field-interfaces"));
39
39
  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");
40
43
  class PluginMockCollectionsServer extends import_server.Plugin {
41
44
  async load() {
42
45
  const templates = import_collection_templates.default;
@@ -316,6 +319,33 @@ class PluginMockCollectionsServer extends import_server.Plugin {
316
319
  }
317
320
  });
318
321
  }
322
+ async install(options) {
323
+ const dbName = this.app.db.options.database;
324
+ const externalDB = `${dbName}_external_test`;
325
+ let client = new import_pg.Client({
326
+ user: process.env.DB_USER,
327
+ password: process.env.DB_PASSWORD,
328
+ host: process.env.DB_HOST,
329
+ database: process.env.DB_DATABASE,
330
+ port: parseInt(process.env.DB_PORT)
331
+ });
332
+ await client.connect();
333
+ await client.query(`DROP DATABASE IF EXISTS ${externalDB}`);
334
+ await client.query(`CREATE DATABASE ${externalDB}`);
335
+ await client.end();
336
+ client = new import_pg.Client({
337
+ user: process.env.DB_USER,
338
+ password: process.env.DB_PASSWORD,
339
+ host: process.env.DB_HOST,
340
+ database: externalDB,
341
+ port: parseInt(process.env.DB_PORT)
342
+ });
343
+ await client.connect();
344
+ const sqlFile = import_path.default.resolve(__dirname, "./external.sql");
345
+ const sql = await import_fs.promises.readFile(sqlFile, "utf8");
346
+ await client.query(sql);
347
+ await client.end();
348
+ }
319
349
  }
320
350
  var server_default = PluginMockCollectionsServer;
321
351
  // Annotate the CommonJS export names for ESM import in node:
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.20.0-alpha.8",
5
+ "version": "0.21.0-alpha.1",
6
6
  "main": "./dist/server/index.js",
7
7
  "license": "AGPL-3.0",
8
8
  "peerDependencies": {
@@ -13,5 +13,8 @@
13
13
  "@nocobase/test": "0.x",
14
14
  "@nocobase/utils": "0.x"
15
15
  },
16
- "gitHead": "39ebc1cefe5a826aecf0b14d73530dfa5f9c2b1c"
16
+ "devDependencies": {
17
+ "pg": "^8.11.3"
18
+ },
19
+ "gitHead": "afd2f3d1341b85ea9daa7b2667dd4ace1fafb7ff"
17
20
  }