create-erxes 0.1.9 → 0.1.10
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 +1 -1
- package/dist/templates/base/.agents/skills/ui-patterns/SKILL.md +3 -0
- package/dist/templates/base/api/AGENTS.md +11 -0
- package/dist/templates/base/api/package.json +2 -2
- package/dist/templates/base/ui/AGENTS.md +17 -3
- package/dist/templates/base/ui/package.json +2 -2
- package/dist/templates/base/ui/src/modules/items/ItemsPage.tsx +2 -1
- package/dist/templates/base/ui/src/orpc.ts +6 -2
- package/package.json +1 -1
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
|
+
var version = "0.1.10";
|
|
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 = [
|
|
@@ -113,6 +113,9 @@ gives it its fields, and `api/src/modules/items/itemFilter.ts` applies them.
|
|
|
113
113
|
and Save at the bottom. Nothing saves until Save; a field's error shows
|
|
114
114
|
under that field. Call `onCreated(id)` after Save, and the record takes the
|
|
115
115
|
draft's place.
|
|
116
|
+
- `PanelFormRow` takes `htmlFor` (the control's id, so the label focuses it
|
|
117
|
+
and toggles a switch) and `hint` (a line under the control). Long labels wrap
|
|
118
|
+
to two lines; never draw a row of your own with `grid-cols-field`.
|
|
116
119
|
- A form gets its own page only when it has several sections or a live
|
|
117
120
|
preview (a product editor, a page builder). That page is laid out like a
|
|
118
121
|
settings page (below), not with the side panel's rows: cards with a title
|
|
@@ -29,6 +29,17 @@ Node 26 runs the TypeScript directly; imports carry `.ts` and `#/` is `src/`.
|
|
|
29
29
|
`@erxes/plugin-sdk`, so it exists only if the change commits. Core POSTs it
|
|
30
30
|
to `/api/jobs/<name>`, which `src/server.ts` checks with `verifyCoreJob`, and
|
|
31
31
|
retries until it answers 2xx. A job may run twice: key its effect by `jobId`.
|
|
32
|
+
- A fact the plugin computes about a customer or company (total spent, last
|
|
33
|
+
order) is a field in the manifest's `fields` (`code`, `contentType`, `label`,
|
|
34
|
+
`type`: number, date, text, select or multiselect). Core shows it read-only
|
|
35
|
+
and members filter and save views by it. Write values with
|
|
36
|
+
`core.forOrg(orgId).fields.setPluginValues({ contentType, values })` (scope
|
|
37
|
+
`fields:write`, up to 500, `value: null` clears) after the change commits; it
|
|
38
|
+
adds nothing to the timeline and sends no event.
|
|
39
|
+
- A segment (a price list's audience, a campaign's) is a shared view members
|
|
40
|
+
build in core. Store its id; `views.list({ recordType })` lists the shared
|
|
41
|
+
ones and `views.matches({ viewId, recordIds })` says which records it
|
|
42
|
+
matches now (scope `views:read`, up to 500 ids).
|
|
32
43
|
- Tests: `vite-plus/test`, run with `call(procedure, input, { context: { member } })`.
|
|
33
44
|
`src/test/setup.ts` gives each file its own database, owned by a role without
|
|
34
45
|
BYPASSRLS, so row-level security is real in tests.
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"db:check": "drizzle-kit check"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@erxes/core-contract": "0.1.0-v2.
|
|
25
|
-
"@erxes/plugin-sdk": "0.1.0-v2.
|
|
24
|
+
"@erxes/core-contract": "0.1.0-v2.8",
|
|
25
|
+
"@erxes/plugin-sdk": "0.1.0-v2.7",
|
|
26
26
|
"@opentelemetry/instrumentation-express": "^0.73.0",
|
|
27
27
|
"@opentelemetry/instrumentation-http": "^0.301.1",
|
|
28
28
|
"@opentelemetry/instrumentation-pg": "^0.78.0",
|
|
@@ -24,7 +24,10 @@ and renders `./__id__` (the `__Pascal__` export) under `/__id__/*`.
|
|
|
24
24
|
- The plugin's API goes through `src/orpc.ts`:
|
|
25
25
|
`useQuery(orpc.items.list.queryOptions(...))`,
|
|
26
26
|
`useMutation(orpc.items.create.mutationOptions(...))`. Types come from
|
|
27
|
-
`api/src/router.ts`; after a mutation, invalidate `orpc.<group>.key()`.
|
|
27
|
+
`api/src/router.ts`; after a mutation, invalidate `orpc.<group>.key()`. Its query
|
|
28
|
+
keys start with the plugin's name, because every plugin shares web's query cache:
|
|
29
|
+
without it, two plugins' `me` procedures answer each other. A key written by hand
|
|
30
|
+
starts with `PLUGIN` too.
|
|
28
31
|
- Core's API goes through `orpc` from `@erxes/core-contract/client`, the client
|
|
29
32
|
web uses, with the member's own session; import it as `core` beside the
|
|
30
33
|
plugin's `orpc`: `useQuery(core.users.get.queryOptions({ input: { id } }))`.
|
|
@@ -41,7 +44,9 @@ and renders `./__id__` (the `__Pascal__` export) under `/__id__/*`.
|
|
|
41
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
|
|
42
45
|
address; `useListFilterParams()` hands them to the list's query, and the API
|
|
43
46
|
applies them (`api/src/modules/items/itemFilter.ts`). No search boxes, toggle
|
|
44
|
-
tabs or pickers in a row above the table.
|
|
47
|
+
tabs or pickers in a row above the table. Give both the record type
|
|
48
|
+
(`recordType={ITEM_TYPE}`): in erxes the bar then shows the member's saved
|
|
49
|
+
views as tabs, and the filter offers to save one, as on core's customers.
|
|
45
50
|
- Records open in core's side panel, like a customer: core draws the panel and
|
|
46
51
|
`CONFIG.recordTypes` (`src/config.tsx`) fills its slots, the item's `Title`,
|
|
47
52
|
`Detail` and `New` (`src/modules/items/ItemPanel.tsx`). `useOpenRecord()`
|
|
@@ -50,7 +55,16 @@ and renders `./__id__` (the `__Pascal__` export) under `/__id__/*`.
|
|
|
50
55
|
(the `ui-patterns` skill). Forms are core's
|
|
51
56
|
`PanelFormRow` rows with Cancel and Save at the bottom; nothing saves until
|
|
52
57
|
Save. Dialogs are for confirmations, not forms.
|
|
53
|
-
- Text uses `t(key, 'English default')` from `react-i18next`.
|
|
58
|
+
- Text uses `t(key, 'English default')` from `react-i18next`. Core shows the config's words (the
|
|
59
|
+
app's name, tab labels, section titles) in the member's language by looking them up in the
|
|
60
|
+
plugin's namespace, its `name`, with the English as the key. Add them from `src/config.tsx`
|
|
61
|
+
with react-i18next's getI18n and i18next's addResourceBundle, so they are there before core
|
|
62
|
+
draws them.
|
|
63
|
+
- To pick a segment (a shared customer or company view), list
|
|
64
|
+
`orpc.views.list({ recordType: 'customer' })` and offer only the ones with
|
|
65
|
+
`shared: true`: the member's own views are in the answer too, and the API's
|
|
66
|
+
`views.matches` refuses them. The fields the manifest declares need no UI:
|
|
67
|
+
core shows them on records, in columns and in the filter.
|
|
54
68
|
- Development: `pnpm dev:ui` serves `http://localhost:__uiPort__/remoteEntry.js`;
|
|
55
69
|
web loads it from the manifest's `UI_ENTRY_URL` or from its own
|
|
56
70
|
`PUBLIC_PLUGINS=__id___ui@http://localhost:__uiPort__/remoteEntry.js`.
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"build": "rsbuild build"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@erxes/core-contract": "0.1.0-v2.
|
|
11
|
+
"@erxes/core-contract": "0.1.0-v2.8",
|
|
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
|
+
"erxes-ui": "npm:@erxes/ui@4.0.0-v2.13",
|
|
17
17
|
"jotai": "^3.0.2",
|
|
18
18
|
"nuqs": "^2.10.3",
|
|
19
19
|
"react": "19.3.1",
|
|
@@ -125,9 +125,10 @@ export const ItemsPage = () => {
|
|
|
125
125
|
</Button>
|
|
126
126
|
</PageHeader.End>
|
|
127
127
|
</PageHeader>
|
|
128
|
-
<ViewBar allLabel={t('all-items', 'All items')}>
|
|
128
|
+
<ViewBar recordType={ITEM_TYPE} allLabel={t('all-items', 'All items')}>
|
|
129
129
|
<ListFilter
|
|
130
130
|
id="__id__-items"
|
|
131
|
+
recordType={ITEM_TYPE}
|
|
131
132
|
fields={fields}
|
|
132
133
|
members={memberQueries}
|
|
133
134
|
totalCount={isPending ? undefined : list.length}
|
|
@@ -28,5 +28,9 @@ const link = new RPCLink({
|
|
|
28
28
|
/** The API, typed from api/src/router.ts: `await client.items.list({})`. */
|
|
29
29
|
const client: Client = createORPCClient(link);
|
|
30
30
|
|
|
31
|
-
/**
|
|
32
|
-
|
|
31
|
+
/**
|
|
32
|
+
* TanStack Query options per procedure: `useQuery(orpc.items.list.queryOptions({ input }))`.
|
|
33
|
+
* Keys start with the plugin name: plugins share web's query cache, so another plugin's `me`
|
|
34
|
+
* or `list` never answers this one's.
|
|
35
|
+
*/
|
|
36
|
+
export const orpc = createTanstackQueryUtils(client, { path: [PLUGIN] });
|