create-erxes 0.1.13 → 0.1.14

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/index.js CHANGED
@@ -9,7 +9,7 @@ import { mkdir, readFile, readdir, symlink, writeFile } from "node:fs/promises";
9
9
  import { homedir } from "node:os";
10
10
  import { fileURLToPath } from "node:url";
11
11
  // package.json
12
- var version = "0.1.13";
12
+ var version = "0.1.14";
13
13
  // src/existing-plugins.ts
14
14
  /** The old erxes plugins a new-core plugin can be migrated from (`backend/plugins/<name>_api`). */
15
15
  const OLD_PLUGINS = [
@@ -21,8 +21,8 @@
21
21
  "db:check": "drizzle-kit check"
22
22
  },
23
23
  "dependencies": {
24
- "@erxes/core-contract": "0.1.0-v2.11",
25
- "@erxes/plugin-sdk": "0.1.0-v2.10",
24
+ "@erxes/core-contract": "0.1.0-v2.12",
25
+ "@erxes/plugin-sdk": "0.1.0-v2.11",
26
26
  "@opentelemetry/instrumentation-express": "^0.73.0",
27
27
  "@opentelemetry/instrumentation-http": "^0.301.1",
28
28
  "@opentelemetry/instrumentation-pg": "^0.78.0",
@@ -8,7 +8,7 @@
8
8
  "build": "rsbuild build"
9
9
  },
10
10
  "dependencies": {
11
- "@erxes/core-contract": "0.1.0-v2.11",
11
+ "@erxes/core-contract": "0.1.0-v2.12",
12
12
  "@orpc/client": "1.16.2",
13
13
  "@orpc/tanstack-query": "1.16.2",
14
14
  "@tabler/icons-react": "3.34.0",
@@ -210,15 +210,15 @@ for (const call of inventory.trpcCalls) {
210
210
  if (equivalent === OWN_TEAMS) usesTeams = true;
211
211
  }
212
212
 
213
- // Old core's structure: the plugin keeps its own departments and branches, imported with
214
- // their Mongo ids, so the ids its records hold stay valid.
213
+ // Old core's structure: core's units, imported with their Mongo ids, so the ids the plugin's
214
+ // records hold stay valid; the plugin queries its copy.
215
215
  for (const schema of inventory.schemas) {
216
216
  for (const field of schema.fields.filter((entry) => isStructureField(entry.name))) {
217
217
  usesTeams = true;
218
218
  add(
219
219
  schema.module,
220
220
  'Tables',
221
- `\`${schema.name}.${field.name}\` → plugin-owned: ids in \`${TEAMS}\`, unchanged by the import ${at(schema)}`,
221
+ `\`${schema.name}.${field.name}\` → core unit ids (copy in \`${TEAMS}\`), unchanged by the import ${at(schema)}`,
222
222
  OWN_TEAMS.kind,
223
223
  );
224
224
  }
@@ -228,7 +228,7 @@ if (usesTeams) {
228
228
  add(
229
229
  '(plugin)',
230
230
  'Tables',
231
- `\`${TEAMS}\` and \`${TEAM_MEMBERS}\` from old core's \`departments\`, \`branches\` and the members' \`departmentIds\` and \`branchIds\` (drafts in migration/schema-draft.ts, imported by scripts/import-mongo.ts): core has no departments or branches`,
231
+ `\`${TEAMS}\` and \`${TEAM_MEMBERS}\`: a read-only copy of core's units (drafts in migration/schema-draft.ts). scripts/import-mongo.ts fills it from old core's \`departments\`, \`branches\` and the members' \`departmentIds\` and \`branchIds\`; push it to core once with \`units.import\`, then refresh it on \`core.unit.*\` events (scopes \`units:read\`, \`units:write\`; subscription \`core.unit.*\`)`,
232
232
  OWN_TEAMS.kind,
233
233
  );
234
234
  }
@@ -457,7 +457,7 @@ for (const collection of inventory.collections) {
457
457
  if (usesTeams) {
458
458
  tables.push(
459
459
  [
460
- "/** Old core's departments and branches, now the plugin's. Ids are the Mongo `_id`s. */",
460
+ "/** A read-only copy of core's branches and departments. Imported ones keep the Mongo `_id`s. */",
461
461
  `export const ${camel(TEAMS)} = table(`,
462
462
  " 'teams',",
463
463
  ' {',
@@ -23,17 +23,18 @@ const gap = (note: string): Equivalent => ({ kind: 'gap', to: '', note });
23
23
  const drop = (note: string): Equivalent => ({ kind: 'drop', to: '', note });
24
24
 
25
25
  /**
26
- * Old core's structure (departments, branches, units, positions): core has none. A plugin that
27
- * used it keeps its own teams; migration/checklist.ts drafts the tables and the import.
26
+ * Old core's structure (departments, branches, units): core's `units` (decision 43). A plugin
27
+ * that used it keeps a read-only copy for its own queries; migration/checklist.ts drafts the
28
+ * copy's tables and the import. Positions are HR's.
28
29
  */
29
- export const OWN_TEAMS = owned(
30
- '<plugin>_teams',
31
- "the plugin's departments and branches; members in <plugin>_team_members, names from users.list (users:read)",
30
+ export const OWN_TEAMS = contract(
31
+ 'units.list',
32
+ "units:read; a read-only copy in <plugin>_teams and <plugin>_team_members, refreshed on core.unit.* events, for the plugin's own visibility queries. Old units go to core once with units.import (units:write), keeping their ids",
32
33
  );
33
34
 
34
- /** A field holding old structure ids or switches: `departmentIds`, `branchId`, `isCheckBranch`. */
35
+ /** A field holding old unit ids or switches: `departmentIds`, `branchId`, `isCheckBranch`. */
35
36
  export const isStructureField = (name: string) =>
36
- /^(department|branch|unit|position)Ids?$|^isCheck(Department|Branch)$/.test(name);
37
+ /^(department|branch|unit)Ids?$|^isCheck(Department|Branch)$/.test(name);
37
38
 
38
39
  const NO_SEGMENTS = drop('the new core has no segments; the plugin filters its own records');
39
40
 
@@ -47,7 +48,7 @@ export const WHOLE_MODULES: Record<string, Equivalent> = {
47
48
  branches: OWN_TEAMS,
48
49
  departments: OWN_TEAMS,
49
50
  units: OWN_TEAMS,
50
- positions: OWN_TEAMS,
51
+ positions: drop("positions are the HR plugin's; other plugins leave them out"),
51
52
  brands: drop('the new core has no brands; leave brand ids and names out'),
52
53
  clientPortal: CLIENT_PORTAL,
53
54
  clientPortals: CLIENT_PORTAL,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-erxes",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "private": false,
5
5
  "description": "Create an erxes plugin for the new core, or migrate an old erxes plugin onto it: pnpm create erxes",
6
6
  "license": "MIT",