create-erxes 0.1.11 → 0.1.13

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.11";
12
+ var version = "0.1.13";
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
@@ -54,8 +54,9 @@ without line-by-line review.
54
54
  through `@erxes/core-contract/client` with the member's session. Neither reads
55
55
  `core_*` tables or imports core's app code.
56
56
  - Members are signed in by core: the UI sends a session token, the API checks it
57
- with `verifyPluginSession`. There is no public route yet, because core can't
58
- tell a public request's organisation.
57
+ with `verifyPluginSession`. A caller outside erxes (a webhook) reaches a path
58
+ the manifest's `publicPaths` lists through core, which names the organisation:
59
+ check it with `verifyPublicCall` (`@erxes/plugin-sdk`'s overview has the route).
59
60
  - Skills in `.agents/skills/`: `endpoint` for a procedure, `schema-change` for a
60
61
  table or column, `ui-patterns` for any page (lists, filters, forms, record
61
62
  details look like core's), `verify` before calling a change done.__migrationSkill__
@@ -7,7 +7,9 @@ Node 26 runs the TypeScript directly; imports carry `.ts` and `#/` is `src/`.
7
7
  (`PLUGINS_AUTO_INSTALL`).
8
8
  - `src/core.ts` holds the core client and the manifest. Every permission, event
9
9
  and kind in the manifest starts with `__id__.`. A new scope waits for the
10
- owner's approval, so ask for one only when a procedure needs it.
10
+ owner's approval, so ask for one only when a procedure needs it. Owners and
11
+ admins hold every permission; a permission set with `defaultRoles: ['member']`
12
+ is what members get on install, and owners change it from there.
11
13
  - `src/server.ts` verifies the session token on `/api/rpc/*` and hands
12
14
  procedures `context.member` (`PluginMember`: `orgId`, `userId`, `can()`,
13
15
  `canChange()`).
@@ -38,7 +40,10 @@ Node 26 runs the TypeScript directly; imports carry `.ts` and `#/` is `src/`.
38
40
  and `dependsOn: 'pipelineId'` on another narrows it to that pipeline's. Web
39
41
  fills the list from `GET /api/automations/records/<recordType>?parent=<value>`,
40
42
  sent with the member's session token like `/api/rpc/*`; answer
41
- `[{ value, label }]` with the records that member may see.
43
+ `[{ value, label }]` with the records that member may see. Never ask a member
44
+ to type an id. Name what the action answers in `outputs`
45
+ (`[{ key: 'dealId', label: 'Deal', type: 'text' }]`) and what an event's
46
+ payload holds in its `fields`: later steps insert them from "Insert data".
42
47
  - A fact the plugin computes about a customer or company (total spent, last
43
48
  order) is a field in the manifest's `fields` (`code`, `contentType`, `label`,
44
49
  `type`: number, date, text, select or multiselect). Core shows it read-only
@@ -21,8 +21,8 @@
21
21
  "db:check": "drizzle-kit check"
22
22
  },
23
23
  "dependencies": {
24
- "@erxes/core-contract": "0.1.0-v2.9",
25
- "@erxes/plugin-sdk": "0.1.0-v2.8",
24
+ "@erxes/core-contract": "0.1.0-v2.11",
25
+ "@erxes/plugin-sdk": "0.1.0-v2.10",
26
26
  "@opentelemetry/instrumentation-express": "^0.73.0",
27
27
  "@opentelemetry/instrumentation-http": "^0.301.1",
28
28
  "@opentelemetry/instrumentation-pg": "^0.78.0",
@@ -36,5 +36,15 @@ export const manifest = {
36
36
  { action: PERMISSIONS.view, label: 'View items', group: '__title__' },
37
37
  { action: PERMISSIONS.manage, label: 'Create and change items', group: '__title__' },
38
38
  ],
39
+ // Ready-made sets owners add to roles; core gives Members this one when the plugin is installed.
40
+ permissionSets: [
41
+ {
42
+ key: 'member',
43
+ label: '__title__ member',
44
+ description: 'Views, creates and changes items',
45
+ permissions: [PERMISSIONS.view, PERMISSIONS.manage],
46
+ defaultRoles: ['member'],
47
+ },
48
+ ],
39
49
  jobs: manifestJobs,
40
50
  } satisfies PluginManifest;
@@ -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
@@ -41,24 +46,33 @@ and renders `./__id__` (the `__Pascal__` export) under `/__id__/*`.
41
46
  - Pages look and behave like core's: follow the `ui-patterns` skill.
42
47
  - Lists have core's bar (`src/modules/items/ItemsPage.tsx`): erxes-ui's `ViewBar` with
43
48
  `ListFilter`, given the list's fields and, for `member` fields, `members={memberQueries}`
44
- (a `tags` query for `tags` fields). It draws the bar itself, in erxes or on its own. Its conditions and search live in the
49
+ (a `tags` query for `tags` fields, `contacts={contactSearchQueries}` for `customer` and
50
+ `company` fields). It draws the bar itself, in erxes or on its own. Its conditions and search live in the
45
51
  address; `useListFilterParams()` hands them to the list's query, and the API
46
52
  applies them with `@erxes/plugin-sdk/filter`'s `compileFilter`, core's own compiler, on a map
47
53
  of the same paths to columns (`FILTER_FIELDS` in `api/src/modules/items/items.ts`). No search boxes, toggle
48
- 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
49
57
  (`recordType={ITEM_TYPE}`): in erxes the bar then shows the member's saved
50
58
  views as tabs, and the filter offers to save one, as on core's customers.
51
59
  - Records open in core's side panel, like a customer: core draws the panel and
52
60
  `CONFIG.recordTypes` (`src/config.tsx`) fills its slots, the item's `Title`,
53
61
  `Detail` and `New` (`src/modules/items/ItemPanel.tsx`). `useOpenRecord()`
54
62
  opens them, and `/__id__/:id` renders erxes-ui's `RecordPage` for the expanded
55
- record. A plugin's records of other records' customers are `relationTabs`
63
+ record; its `listPath` is the list a deleted or closed record goes back to, when
64
+ that isn't the plugin's first page. A plugin's records of other records' customers are `relationTabs`
56
65
  (the `ui-patterns` skill). A settings page is a route of the plugin's
57
66
  (`/__id__/settings/<page>`) that `CONFIG.settings` lists (`{ path, label, icon }`):
58
- core links it from its settings sidebar, under the plugin's name. Tiles for core's
67
+ core links it from its settings sidebar, under the plugin's name. Custom fields
68
+ on a record type are its `properties` (`type: '__id__.item'`, `values(id)`,
69
+ `save(id, patch)`): core keeps the fields and draws their settings page and the
70
+ Properties tab; the API keeps the values in a jsonb column and checks a patch
71
+ with core's `fields.check` before saving. Tiles for core's
59
72
  home dashboard are `CONFIG.dashboardWidgets`: `name`, `title`, `icon`, `preview`,
60
73
  `size` and a `lazy` `component`, which core draws as the tile's body under the
61
- 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
62
76
  `PanelFormRow` rows with Cancel and Save at the bottom; nothing saves until
63
77
  Save. Dialogs are for confirmations, not forms.
64
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.9",
11
+ "@erxes/core-contract": "0.1.0-v2.11",
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.15",
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",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-erxes",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
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",