create-erxes 0.1.12 → 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.12";
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 = [
@@ -46,6 +46,13 @@ what erxes-ui already has, and the screen each kind of page copies.
46
46
  checkbox each and its `RecordList.useSelection` hook for the bulk command bar.
47
47
  Give `DisplayMenu` and `useListDisplay` the same `displays`, such as
48
48
  `['list', 'board', 'table']`; the first shows until the member picks another.
49
+ - A display core doesn't have, such as a cards grid or a chart, is the list's
50
+ own entry in those `displays`, an erxes-ui `TListDisplayOption`:
51
+ `[{ key: 'cards', label: t('cards', 'Cards'), icon: IconLayoutGrid }, 'table']`.
52
+ It shows in the Display menu beside the built-in ones and is remembered the
53
+ same way; `useListDisplay` returns `'cards'` and the page draws the cards
54
+ under the same header and bar. A display only some members may see is left
55
+ out of `displays` for the others.
49
56
 
50
57
  ## Filter
51
58
 
@@ -63,10 +70,13 @@ gives it its fields, and `FILTER_FIELDS` in `api/src/modules/items/items.ts` app
63
70
  `compileFilter` from `@erxes/plugin-sdk/filter`, which refuses a path it has
64
71
  no column for.
65
72
  - Never: a search box, toggle buttons ("Mine", "Archived"), status tabs, a
66
- ToggleGroup for table and board, or a row of pickers above the table. Each of
67
- those is a field in the menu or the Display menu.
68
- - Saved views (the tabs core's contacts lists have) are core's lists only;
69
- a plugin list shows the one "All …" tab.
73
+ ToggleGroup for table, board, cards or chart, or a row of pickers above the
74
+ table. Each of those is a field in the menu or an entry in the Display menu.
75
+ - Saved views (the tabs core's contacts lists have) come from the record type:
76
+ `<ViewBar recordType="<plugin>:<thing>" allLabel>` and the same `recordType`
77
+ on `ListFilter`. Core stores the member's views of that list and draws their
78
+ tabs and the filter's save; opening one puts its conditions and search in the
79
+ address, so the API applies it through the `filter` and `search` it already gets.
70
80
 
71
81
  ## Records in core's side panel
72
82
 
@@ -94,7 +104,11 @@ gives it its fields, and `FILTER_FIELDS` in `api/src/modules/items/items.ts` app
94
104
  tab is `PanelSection`s of `PanelField` rows. Never an erxes-ui `Sheet`, a
95
105
  header or tabs of the plugin's own, or a `?item=` param.
96
106
  - Open a record with `useOpenRecord().open({ contentType, contentId })` and a
97
- draft with `openNew(contentType, defaults)`. `detailPath(id)` is a route of
107
+ draft with `openNew(contentType, defaults)`. `tab` opens the record on one of
108
+ its tabs, a `tabs` entry's `value`, `detail` or `activity`:
109
+ `open({ contentType: 'hr:employee', contentId, tab: 'leave' })` from a leave
110
+ list or a dashboard tile. A tab the record lacks opens its default, and
111
+ expanding the panel keeps the tab. `detailPath(id)` is a route of
98
112
  the plugin's that renders `<RecordPage contentType contentId />`
99
113
  (`ui/src/__Pascal__.tsx`): the expanded record.
100
114
  - A plugin whose records belong to customers or companies lists them on those
@@ -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",
@@ -21,6 +21,11 @@ and renders `./__id__` (the `__Pascal__` export) under `/__id__/*`.
21
21
  `src/__Pascal__.tsx` passes them to `addPluginStyles`, which adds only the
22
22
  classes web's stylesheet lacks. erxes-ui's design rules hold here too (its
23
23
  `AGENTS.md`, enforced by `vp run check`): no inline styles or raw colours.
24
+ - Charts: add `recharts` to the plugin and draw the chart with it, inside
25
+ erxes-ui's `ChartContainer`: `<BarChart responsive data={rows}>` fills the
26
+ container and follows its size, with no wrapper or fixed size. Its `Tooltip`
27
+ and `Legend` take erxes-ui's `ChartTooltipContent` and `ChartLegendContent`
28
+ as `content`.
24
29
  - The plugin's API goes through `src/orpc.ts`:
25
30
  `useQuery(orpc.items.list.queryOptions(...))`,
26
31
  `useMutation(orpc.items.create.mutationOptions(...))`. Types come from
@@ -46,7 +51,9 @@ and renders `./__id__` (the `__Pascal__` export) under `/__id__/*`.
46
51
  address; `useListFilterParams()` hands them to the list's query, and the API
47
52
  applies them with `@erxes/plugin-sdk/filter`'s `compileFilter`, core's own compiler, on a map
48
53
  of the same paths to columns (`FILTER_FIELDS` in `api/src/modules/items/items.ts`). No search boxes, toggle
49
- tabs or pickers in a row above the table. Give both the record type
54
+ tabs or pickers in a row above the table. Another display (board, cards, a chart) is an
55
+ entry in erxes-ui's `DisplayMenu`, the list's own as a `TListDisplayOption`, read back with
56
+ `useListDisplay`. Give both the record type
50
57
  (`recordType={ITEM_TYPE}`): in erxes the bar then shows the member's saved
51
58
  views as tabs, and the filter offers to save one, as on core's customers.
52
59
  - Records open in core's side panel, like a customer: core draws the panel and
@@ -64,7 +71,8 @@ and renders `./__id__` (the `__Pascal__` export) under `/__id__/*`.
64
71
  with core's `fields.check` before saving. Tiles for core's
65
72
  home dashboard are `CONFIG.dashboardWidgets`: `name`, `title`, `icon`, `preview`,
66
73
  `size` and a `lazy` `component`, which core draws as the tile's body under the
67
- title. Forms are core's
74
+ title. A tile or list that leads to one part of a record opens it on that tab:
75
+ `useOpenRecord().open({ contentType, contentId, tab: 'leave' })`. Forms are core's
68
76
  `PanelFormRow` rows with Cancel and Save at the bottom; nothing saves until
69
77
  Save. Dialogs are for confirmations, not forms.
70
78
  - Something that must outlive a page, such as a softphone during a call, is
@@ -8,12 +8,12 @@
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",
15
15
  "@tanstack/react-query": "^5.107.1",
16
- "erxes-ui": "npm:@erxes/ui@4.0.0-v2.16",
16
+ "erxes-ui": "npm:@erxes/ui@4.0.0-v2.17",
17
17
  "jotai": "^3.0.2",
18
18
  "nuqs": "^2.10.3",
19
19
  "react": "19.3.1",
@@ -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.12",
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",