create-erxes 0.1.0 → 0.1.2

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.0";
12
+ var version = "0.1.2";
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 = [
@@ -12,7 +12,6 @@ description: Add or change an API procedure. Use when editing api/src/modules, a
12
12
  3. Fail with `ORPCError` (`NOT_FOUND`, `FORBIDDEN`, `CONFLICT`, `BAD_REQUEST`);
13
13
  the UI shows its `message`.
14
14
  4. Add the module to `router` in `api/src/router.ts`. The UI's types follow.
15
- Run `pnpm openapi` and commit the contract document.
16
15
  5. In the UI, read with `orpc.<group>.<name>.queryOptions()` and write with
17
16
  `mutationOptions()`, invalidating `orpc.<group>.key()` on success.
18
17
  6. Test it in the module's `__tests__`: the happy path, another organisation
@@ -36,9 +36,7 @@ without line-by-line review.
36
36
  ## This repo
37
37
 
38
38
  - `vp run check` runs the escape guard, format, lint, types, knip, the docs guard
39
- and `pnpm check:generated`. The drift check compares migrations with the schema
40
- and `api/openapi.json` with the router's request and response schemas. After a
41
- deliberate contract change, run `pnpm openapi` and commit the document.
39
+ and `pnpm check:generated`, which compares the migrations with the schema.
42
40
  - Other gates: `vp run test` on real Postgres via `DATA_TEST_URL`,
43
41
  `pnpm check:rls`, `pnpm build`. `vp run fix` formats and fixes lint.
44
42
  - Core finds the plugin by these names, so they stay fixed: plugin `__id__`,
@@ -49,8 +47,9 @@ without line-by-line review.
49
47
  - The lint rules are `@erxes/lint`'s preset (`vite.config.ts`). It,
50
48
  `tools/test/no-skips.ts` and `tools/check-rls.sql` come from core unchanged, as
51
49
  does the quality section above. Change them in core.
52
- - The plugin reaches core only through `@erxes/plugin-sdk` (`api/src/core.ts`)
53
- and the UI's `pluginFetch`. It never reads `core_*` tables or imports core code.
50
+ - The API reaches core through `@erxes/plugin-sdk` (`api/src/core.ts`), the UI
51
+ through `@erxes/core-contract/client` with the member's session. Neither reads
52
+ `core_*` tables or imports core's app code.
54
53
  - Members are signed in by core: the UI sends a session token, the API checks it
55
54
  with `verifyPluginSession`. There is no public route yet, because core can't
56
55
  tell a public request's organisation.
@@ -17,13 +17,12 @@
17
17
  "build": "vp pack src/main.ts src/telemetry.ts --format esm --sourcemap --no-dts",
18
18
  "start": "node --enable-source-maps --import ./dist/telemetry.mjs dist/main.mjs",
19
19
  "db:generate": "drizzle-kit generate",
20
- "db:migrate": "node --env-file-if-exists=../.env src/db/migrate.ts",
21
- "openapi": "node scripts/openapi.ts",
20
+ "db:migrate": "node --env-file-if-exists=../.env src/migrate.ts",
22
21
  "db:check": "drizzle-kit check"
23
22
  },
24
23
  "dependencies": {
25
- "@erxes/core-contract": "v2-next",
26
- "@erxes/plugin-sdk": "v2-next",
24
+ "@erxes/core-contract": "0.1.0-v2.3",
25
+ "@erxes/plugin-sdk": "0.1.0-v2.3",
27
26
  "@opentelemetry/instrumentation-express": "^0.73.0",
28
27
  "@opentelemetry/instrumentation-http": "^0.301.1",
29
28
  "@opentelemetry/instrumentation-pg": "^0.78.0",
@@ -40,8 +39,6 @@
40
39
  "zod": "^4.6.7"
41
40
  },
42
41
  "devDependencies": {
43
- "@orpc/openapi": "1.16.2",
44
- "@orpc/zod": "1.16.2",
45
42
  "@types/cors": "^2.8.19",
46
43
  "@types/express": "^5.0.6",
47
44
  "@types/pg": "^8.23.1",
@@ -3,7 +3,7 @@ import { join, resolve } from 'node:path';
3
3
  import { sql } from 'drizzle-orm';
4
4
  import { readMigrationFiles } from 'drizzle-orm/migrator';
5
5
  import { z } from 'zod';
6
- import { db, pool } from './client.ts';
6
+ import { db } from './client.ts';
7
7
 
8
8
  /** Our own tracking table: core and other plugins in the same database keep theirs. */
9
9
  export const MIGRATIONS_TABLE = '__drizzle_migrations___id__';
@@ -78,9 +78,3 @@ export const runMigrations = async () => {
78
78
  return pending.map((migration) => migration.tag);
79
79
  });
80
80
  };
81
-
82
- // `pnpm db:migrate` applies them without starting the API.
83
- if (import.meta.main) {
84
- await runMigrations();
85
- await pool.end();
86
- }
@@ -0,0 +1,9 @@
1
+ // `pnpm db:migrate` applies pending migrations without starting the API. Its own entry, not an
2
+ // `import.meta.main` branch in db/migrate.ts: the bundle inlines that module into dist/main.mjs,
3
+ // where the branch would run and end the pool before the API starts.
4
+ import { pool } from '#/db/client.ts';
5
+ import { runMigrations } from '#/db/migrate.ts';
6
+
7
+ await runMigrations();
8
+
9
+ await pool.end();
@@ -38,6 +38,12 @@ describe('items', () => {
38
38
 
39
39
  expect(next.items.map((item) => item.id)).toEqual([first.id]);
40
40
  expect(next.nextCursor).toBeNull();
41
+ await expect(client.items.list({ createdBy: 'user-org-a' })).resolves.toMatchObject({
42
+ items: [{ id: second.id }, { id: first.id }],
43
+ });
44
+ await expect(client.items.list({ createdBy: 'someone-else' })).resolves.toMatchObject({
45
+ items: [],
46
+ });
41
47
 
42
48
  await expect(
43
49
  client.items.update({ id: first.id, name: 'First', description: 'Changed' }),
@@ -47,6 +47,8 @@ const list = reads(PERMISSIONS.view)
47
47
  .input(
48
48
  z.object({
49
49
  search: z.string().trim().max(200).optional(),
50
+ /** Only the items this member created. */
51
+ createdBy: z.string().optional(),
50
52
  cursor: z.string().optional(),
51
53
  limit: z.number().int().min(1).max(100).default(50),
52
54
  }),
@@ -61,7 +63,11 @@ const list = reads(PERMISSIONS.view)
61
63
  .select(columns)
62
64
  .from(items)
63
65
  .where(
64
- and(input.search ? ilike(items.name, `%${escapeLike(input.search)}%`) : undefined, after),
66
+ and(
67
+ input.search ? ilike(items.name, `%${escapeLike(input.search)}%`) : undefined,
68
+ input.createdBy ? eq(items.createdBy, input.createdBy) : undefined,
69
+ after,
70
+ ),
65
71
  )
66
72
  .orderBy(desc(items.createdAt), desc(items.id))
67
73
  .limit(input.limit + 1);
@@ -5,5 +5,5 @@
5
5
  "moduleResolution": "nodenext",
6
6
  "types": ["node"]
7
7
  },
8
- "include": ["src", "scripts", "drizzle.config.ts"]
8
+ "include": ["src", "drizzle.config.ts"]
9
9
  }
@@ -9,12 +9,11 @@ const config: KnipConfig = {
9
9
  ignoreDependencies: ['tsrs'],
10
10
  },
11
11
  api: {
12
- entry: ['scripts/*.ts'],
13
- project: ['src/**/*.ts', 'scripts/**/*.ts'],
12
+ project: ['src/**/*.ts'],
14
13
  },
15
14
  ui: {
16
15
  entry: ['src/config.tsx', 'src/__Pascal__.tsx'],
17
- project: ['src/**/*.{ts,tsx}'],
16
+ project: ['src/**/*.{ts,tsx,css}'],
18
17
  },
19
18
  },
20
19
  };
@@ -9,7 +9,6 @@
9
9
  "db:generate": "pnpm --filter @__id__/api db:generate",
10
10
  "db:check": "pnpm --filter @__id__/api db:check",
11
11
  "db:migrate": "pnpm --filter @__id__/api db:migrate",
12
- "openapi": "pnpm --filter @__id__/api openapi",
13
12
  "check:generated": "node tools/check-generated.ts",
14
13
  "check:rls": "bash tools/check-rls.sh",
15
14
  "dev:api": "pnpm --filter @__id__/api dev",
@@ -17,7 +16,7 @@
17
16
  "image:context": "pnpm build && rm -rf .runtime && pnpm --filter @__id__/api deploy --prod .runtime"
18
17
  },
19
18
  "devDependencies": {
20
- "@erxes/lint": "0.1.0",
19
+ "@erxes/lint": "0.1.1",
21
20
  "@types/node": "^26.6.6",
22
21
  "knip": "^6.45.1",
23
22
  "tsrs": "0.25.0-ts7.1.0-beta",
@@ -17,7 +17,6 @@ const scratch = join(root, '.scratch');
17
17
  mkdirSync(scratch, { recursive: true });
18
18
 
19
19
  const dir = mkdtempSync(join(scratch, 'generated-'));
20
- const contract = join(root, 'api/openapi.json');
21
20
  const api = join(root, 'api');
22
21
  const drizzle = join(api, 'node_modules/drizzle-kit/bin.cjs');
23
22
 
@@ -33,13 +32,6 @@ const run = (entry: string, ...args: string[]) => {
33
32
  };
34
33
 
35
34
  try {
36
- const document = join(dir, 'openapi.json');
37
-
38
- run(join(api, 'scripts/openapi.ts'), document);
39
-
40
- if (readFileSync(contract, 'utf8') !== readFileSync(document, 'utf8'))
41
- throw new Error('Contract drift. Run pnpm openapi and commit api/openapi.json.');
42
-
43
35
  const migrations = join(root, 'api/drizzle');
44
36
  const generated = join(dir, 'drizzle');
45
37
  const config = join(dir, 'drizzle.config.ts');
@@ -72,7 +64,7 @@ try {
72
64
  `Migration drift in ${drift.join(', ')}. Run pnpm db:generate and commit api/drizzle.`,
73
65
  );
74
66
 
75
- process.stdout.write('Migrations and OpenAPI match their sources.\n');
67
+ process.stdout.write('Migrations match the schema.\n');
76
68
  } finally {
77
69
  rmSync(dir, { recursive: true, force: true });
78
70
  }
@@ -6,12 +6,28 @@ and renders `./__id__` (the `__Pascal__` export) under `/__id__/*`.
6
6
  - `rsbuild.config.ts` declares web's shared singletons with `import: false`,
7
7
  reading the list from `erxes-ui/federation`, so it follows the installed
8
8
  erxes-ui. A missing name bundles a second copy and breaks at runtime.
9
- - Build pages from `erxes-ui` components and its public package exports. The host
10
- provides React, the router, the query client and erxes-ui; web's CSS
11
- styles them, so use Tailwind classes web already uses.
12
- - Data goes through `src/orpc.ts`: `useQuery(orpc.items.list.queryOptions(...))`,
9
+ - Build pages from `erxes-ui` components and its root export. The host provides
10
+ React, the router, the query client and erxes-ui, and web's stylesheet styles
11
+ erxes-ui's components.
12
+ - Any Tailwind class works, on erxes-ui's tokens (`bg-muted`, `text-sm`,
13
+ `md:grid-cols-2`). `src/styles.css` builds the plugin's own utilities, and
14
+ `src/__Pascal__.tsx` passes them to `addPluginStyles`, which adds only the
15
+ classes web's stylesheet lacks. erxes-ui's design rules hold here too (its
16
+ `AGENTS.md`, enforced by `vp run check`): no inline styles or raw colours.
17
+ - The plugin's API goes through `src/orpc.ts`:
18
+ `useQuery(orpc.items.list.queryOptions(...))`,
13
19
  `useMutation(orpc.items.create.mutationOptions(...))`. Types come from
14
20
  `api/src/router.ts`; after a mutation, invalidate `orpc.<group>.key()`.
21
+ - Core's API goes through `orpc` from `@erxes/core-contract/client`, the client
22
+ web uses, with the member's own session; import it as `core` beside the
23
+ plugin's `orpc`: `useQuery(core.users.get.queryOptions({ input: { id } }))`.
24
+ It shares web's query cache, and the member needs the core permission the
25
+ procedure asks for (`team.view` for team members).
26
+ - Members: `SelectMember.Field`, `SelectMember.InlineCell`, `MemberInline` and
27
+ `useMembersById` from erxes-ui, given `members={memberQueries}` from
28
+ `@erxes/core-contract/client`. `src/items/ItemsPage.tsx` has a member filter
29
+ and a "Created by" column. erxes-ui's `EntityPicker` is the searchable list
30
+ under them, for a picker of the plugin's own records.
15
31
  - Text uses `t(key, 'English default')` from `react-i18next`.
16
32
  - Development: `pnpm dev:ui` serves `http://localhost:__uiPort__/remoteEntry.js`;
17
33
  web loads it from the manifest's `UI_ENTRY_URL` or from its own
@@ -8,15 +8,16 @@
8
8
  "build": "rsbuild build"
9
9
  },
10
10
  "dependencies": {
11
+ "@erxes/core-contract": "0.1.0-v2.3",
11
12
  "@orpc/client": "1.16.2",
12
13
  "@orpc/tanstack-query": "1.16.2",
13
14
  "@tabler/icons-react": "3.34.0",
14
15
  "@tanstack/react-query": "^5.107.1",
15
- "erxes-ui": "npm:@erxes/ui@v2-next",
16
- "jotai": "^2.20.3",
16
+ "erxes-ui": "npm:@erxes/ui@4.0.0-v2.3",
17
+ "jotai": "^3.0.2",
17
18
  "react": "19.3.1",
18
19
  "react-dom": "19.3.1",
19
- "react-i18next": "^15.7.4",
20
+ "react-i18next": "^18.0.1",
20
21
  "react-router-dom": "^7.18.5"
21
22
  },
22
23
  "devDependencies": {
@@ -25,8 +26,10 @@
25
26
  "@rsbuild/core": "^2.3.2",
26
27
  "@rsbuild/plugin-babel": "^2.1.0",
27
28
  "@rsbuild/plugin-react": "^2.1.1",
29
+ "@tailwindcss/postcss": "^4.3.5",
28
30
  "@types/react": "19.3.0",
29
31
  "@types/react-dom": "19.3.0",
30
- "babel-plugin-react-compiler": "^1.0.0"
32
+ "babel-plugin-react-compiler": "^1.0.0",
33
+ "tailwindcss": "^4.3.5"
31
34
  }
32
35
  }
@@ -2,6 +2,7 @@ import { pluginModuleFederation } from '@module-federation/rsbuild-plugin';
2
2
  import { defineConfig } from '@rsbuild/core';
3
3
  import { pluginBabel } from '@rsbuild/plugin-babel';
4
4
  import { pluginReact } from '@rsbuild/plugin-react';
5
+ import tailwindcss from '@tailwindcss/postcss';
5
6
  import reactCompiler from 'babel-plugin-react-compiler';
6
7
  // What web shares. The host provides each one (`import: false`), so the plugin
7
8
  // never bundles a second React, router, query client or erxes-ui.
@@ -33,4 +34,6 @@ export default defineConfig({
33
34
  output: { assetPrefix: 'auto' },
34
35
  dev: { assetPrefix: true, lazyCompilation: false },
35
36
  server: { port: Number(process.env.UI_PORT) || __uiPort__, cors: { origin: '*' } },
37
+ // src/styles.css: the plugin's own Tailwind utilities.
38
+ tools: { postcss: (_options, { addPlugins }) => addPlugins(tailwindcss()) },
36
39
  });
@@ -1,5 +1,10 @@
1
+ import { addPluginStyles } from 'erxes-ui';
1
2
  import { Route, Routes } from 'react-router-dom';
2
3
  import { ItemsPage } from './items/ItemsPage.tsx';
4
+ import { PLUGIN } from './orpc.ts';
5
+ import css from './styles.css?inline';
6
+
7
+ addPluginStyles(PLUGIN, css);
3
8
 
4
9
  /** The page module web renders under `/__id__/*` (loaded as `__id___ui/__id__`). */
5
10
  export const __Pascal__ = () => (
@@ -1,12 +1,18 @@
1
+ import { memberQueries } from '@erxes/core-contract/client';
1
2
  import { IconBox, IconPlus, IconTrash } from '@tabler/icons-react';
2
3
  import {
3
4
  Button,
4
5
  Empty,
6
+ MemberInline,
5
7
  PageContainer,
6
8
  PageHeader,
7
9
  RecordTable,
8
10
  type RecordTableColumnDef,
11
+ RecordTableInlineCell,
12
+ SelectMember,
13
+ useFormat,
9
14
  } from 'erxes-ui';
15
+ import { useState } from 'react';
10
16
  import { useTranslation } from 'react-i18next';
11
17
  import { ItemSheet } from './ItemSheet.tsx';
12
18
  import { type Item, useItems, useOpenItem, useRemoveItem } from './useItems.ts';
@@ -21,6 +27,11 @@ const NameCell = ({ item }: { item: Item }) => {
21
27
  );
22
28
  };
23
29
 
30
+ /** Dates and numbers go through erxes-ui's useFormat, in the UI's language. */
31
+ const UpdatedCell = ({ item }: { item: Item }) => (
32
+ <span className="px-2">{useFormat().dateTime(item.updatedAt)}</span>
33
+ );
34
+
24
35
  /** Where RecordTable keeps this list's column settings. */
25
36
  const TABLE_ID = '__id___items';
26
37
 
@@ -53,11 +64,22 @@ const columns: RecordTableColumnDef<Item>[] = [
53
64
  size: 360,
54
65
  cell: ({ row }) => <span className="truncate px-2">{row.original.description}</span>,
55
66
  },
67
+ {
68
+ // The member's name and avatar come from core, through the core client.
69
+ id: 'createdBy',
70
+ header: 'Created by',
71
+ size: 200,
72
+ cell: ({ row }) => (
73
+ <RecordTableInlineCell>
74
+ <MemberInline memberId={row.original.createdBy} members={memberQueries} />
75
+ </RecordTableInlineCell>
76
+ ),
77
+ },
56
78
  {
57
79
  id: 'updatedAt',
58
80
  header: 'Updated',
59
81
  size: 200,
60
- cell: ({ row }) => <span className="px-2">{row.original.updatedAt.toLocaleString()}</span>,
82
+ cell: ({ row }) => <UpdatedCell item={row.original} />,
61
83
  },
62
84
  {
63
85
  id: 'delete',
@@ -71,7 +93,8 @@ const columns: RecordTableColumnDef<Item>[] = [
71
93
  export const ItemsPage = () => {
72
94
  const { t } = useTranslation('__id__');
73
95
  const { open } = useOpenItem();
74
- const { data, isPending, error, hasNextPage, fetchNextPage } = useItems();
96
+ const [createdBy, setCreatedBy] = useState<string | null>(null);
97
+ const { data, isPending, error, hasNextPage, fetchNextPage } = useItems(createdBy);
75
98
  const list = data?.pages.flatMap((page) => page.items) ?? [];
76
99
 
77
100
  return (
@@ -82,6 +105,16 @@ export const ItemsPage = () => {
82
105
  <h1 className="text-sm font-semibold">{t('items', 'Items')}</h1>
83
106
  </PageHeader.Start>
84
107
  <PageHeader.End>
108
+ {/* md:w-64 is in no class web uses: the plugin's own stylesheet brings it. */}
109
+ <SelectMember.Field
110
+ aria-label={t('created-by', 'Created by')}
111
+ className="w-40 md:w-64"
112
+ value={createdBy}
113
+ onValueChange={setCreatedBy}
114
+ members={memberQueries}
115
+ placeholder={t('anyone', 'Created by anyone')}
116
+ noneLabel={t('anyone', 'Created by anyone')}
117
+ />
85
118
  <Button onClick={() => open('new')}>
86
119
  <IconPlus />
87
120
  {t('add', 'Add item')}
@@ -15,11 +15,11 @@ type Outputs = InferClientOutputs<Client>['items'];
15
15
 
16
16
  export type Item = Outputs['create'];
17
17
 
18
- /** Every page loaded so far, newest first. */
19
- export const useItems = () =>
18
+ /** Every page loaded so far, newest first; only `createdBy`'s when given. */
19
+ export const useItems = (createdBy: string | null) =>
20
20
  useInfiniteQuery(
21
21
  orpc.items.list.infiniteOptions({
22
- input: (cursor: string | undefined) => ({ cursor }),
22
+ input: (cursor: string | undefined) => ({ cursor, createdBy: createdBy ?? undefined }),
23
23
  initialPageParam: undefined,
24
24
  getNextPageParam: (page) => page.nextCursor ?? undefined,
25
25
  }),
@@ -0,0 +1,8 @@
1
+ /* This plugin's own Tailwind utilities, built on erxes-ui's tokens. web's stylesheet already has
2
+ the page defaults and every class web and erxes-ui use; addPluginStyles (in __Pascal__.tsx)
3
+ adds only the classes it lacks. The themes are inline, so the utilities carry their values and
4
+ set no variable of web's. */
5
+ @import 'tailwindcss/theme.css' theme(reference inline);
6
+ @import 'erxes-ui/theme.css' theme(inline);
7
+ @import 'tailwindcss/utilities.css' layer(utilities) source(none);
8
+ @source '.';
@@ -5,7 +5,7 @@
5
5
  "module": "esnext",
6
6
  "moduleResolution": "bundler",
7
7
  "jsx": "react-jsx",
8
- "types": ["node"]
8
+ "types": ["node", "@rsbuild/core/types"]
9
9
  },
10
10
  "include": ["src", "rsbuild.config.ts"]
11
11
  }
@@ -30,7 +30,6 @@ export default defineConfig({
30
30
  '**/dist/**',
31
31
  'coverage/**',
32
32
  'api/drizzle/**',
33
- 'api/openapi.json',
34
33
  'pnpm-lock.yaml',
35
34
  ],
36
35
  },
@@ -37,11 +37,16 @@ data only. The inventory reads code, never a database.
37
37
  4. Core calls. Do what the arrow says: `sdk` is
38
38
  `core.forOrg(orgId).<procedure>` in the API with that scope in
39
39
  `manifest.scopes`; `contract` is a call from the UI with the member's own
40
- session; `plugin-owned` lives in this plugin's tables or code.
40
+ session, through `orpc` from `@erxes/core-contract/client` (members through
41
+ erxes-ui's `SelectMember` and `MemberInline`, `ui/AGENTS.md`);
42
+ `plugin-owned` lives in this plugin's tables or code.
41
43
  5. Pages. One per UI route, under `ui/src/<module>/`, built from `erxes-ui`
42
44
  the way `ui/src/items/` is. The old `ui-modules` components don't exist
43
- here: erxes-ui's old-to-new component table, `packages/ui/MIGRATION.md` in
44
- the erxes repo (branch `postgre`), says what replaces each one.
45
+ here. Member pickers and names become erxes-ui's `SelectMember` and
46
+ `MemberInline`; a picker of other records is erxes-ui's `EntityPicker` over
47
+ the plugin's own query. For erxes-ui components whose props changed, see
48
+ its old-to-new table, `packages/ui/MIGRATION.md` in the erxes repo (branch
49
+ `postgre`).
45
50
  6. Check parity in the browser, following the `verify` skill: open the old
46
51
  page and the new one side by side, and walk the same actions on both.
47
52
  7. Tick an item once it works on the new core and its old bugs and
@@ -278,7 +278,7 @@ const lines = [
278
278
  `${all.length} items, ${gaps} of them gaps. Follow \`.agents/skills/plugin-migrate\`: one module at a time,`,
279
279
  'tick an item once it works on the new core and its old bugs and workarounds are gone, and tick a gap once filed, ending its line with `(filed <issue url>)`.',
280
280
  '',
281
- `The old UI imports ${symbols} symbols from \`ui-modules\` in ${inventory.uiModules.files} files; the host has no \`ui-modules\`, so each page rebuilds them from \`erxes-ui\`. Its old-to-new component table is \`packages/ui/MIGRATION.md\` in erxes (branch \`postgre\`).`,
281
+ `The old UI imports ${symbols} symbols from \`ui-modules\` in ${inventory.uiModules.files} files; the host has no \`ui-modules\`, so each page rebuilds them from \`erxes-ui\` (members through its \`SelectMember\` and \`MemberInline\`, other records through \`EntityPicker\`). erxes-ui's own old-to-new component table is \`packages/ui/MIGRATION.md\` in erxes (branch \`postgre\`).`,
282
282
  `GraphQL types (${inventory.graphql.types.length}) are listed in \`migration/inventory.json\` for reference; procedures replace them.`,
283
283
  '',
284
284
  ];
@@ -3,7 +3,8 @@
3
3
  // apps/api/src/http/access.ts. Old calls run on the server, so:
4
4
  //
5
5
  // sdk core.forOrg(orgId).<procedure> from the API, with the scope named
6
- // contract no plugin scope; the UI calls core with the member's own session
6
+ // contract no plugin scope; the UI calls core with the member's own session,
7
+ // through orpc from @erxes/core-contract/client
7
8
  // plugin-owned the plugin keeps it in its own tables or code
8
9
  // gap core offers no equivalent yet: file it, don't work around it
9
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-erxes",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
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",
@@ -1,450 +0,0 @@
1
- {
2
- "info": {
3
- "title": "__id__",
4
- "version": "v1"
5
- },
6
- "openapi": "3.1.1",
7
- "paths": {
8
- "/items/list": {
9
- "post": {
10
- "operationId": "items.list",
11
- "requestBody": {
12
- "required": true,
13
- "content": {
14
- "application/json": {
15
- "schema": {
16
- "type": "object",
17
- "properties": {
18
- "search": {
19
- "type": "string",
20
- "maxLength": 200
21
- },
22
- "cursor": {
23
- "type": "string"
24
- },
25
- "limit": {
26
- "type": "integer",
27
- "minimum": 1,
28
- "maximum": 100,
29
- "default": 50
30
- }
31
- }
32
- }
33
- }
34
- }
35
- },
36
- "responses": {
37
- "200": {
38
- "description": "OK",
39
- "content": {
40
- "application/json": {
41
- "schema": {
42
- "type": "object",
43
- "properties": {
44
- "items": {
45
- "type": "array",
46
- "items": {
47
- "type": "object",
48
- "properties": {
49
- "id": {
50
- "type": "string"
51
- },
52
- "name": {
53
- "type": "string",
54
- "minLength": 1,
55
- "maxLength": 200
56
- },
57
- "description": {
58
- "type": "string",
59
- "maxLength": 5000
60
- },
61
- "createdBy": {
62
- "type": "string"
63
- },
64
- "createdAt": {
65
- "type": "string",
66
- "format": "date-time",
67
- "x-native-type": "date"
68
- },
69
- "updatedAt": {
70
- "type": "string",
71
- "format": "date-time",
72
- "x-native-type": "date"
73
- }
74
- },
75
- "required": [
76
- "id",
77
- "name",
78
- "description",
79
- "createdBy",
80
- "createdAt",
81
- "updatedAt"
82
- ]
83
- }
84
- },
85
- "nextCursor": {
86
- "anyOf": [
87
- {
88
- "type": "string"
89
- },
90
- {
91
- "type": "null"
92
- }
93
- ]
94
- }
95
- },
96
- "required": [
97
- "items",
98
- "nextCursor"
99
- ]
100
- }
101
- }
102
- }
103
- }
104
- }
105
- }
106
- },
107
- "/items/create": {
108
- "post": {
109
- "operationId": "items.create",
110
- "requestBody": {
111
- "required": true,
112
- "content": {
113
- "application/json": {
114
- "schema": {
115
- "type": "object",
116
- "properties": {
117
- "name": {
118
- "type": "string",
119
- "minLength": 1,
120
- "maxLength": 200
121
- },
122
- "description": {
123
- "type": "string",
124
- "maxLength": 5000,
125
- "default": ""
126
- }
127
- },
128
- "required": [
129
- "name"
130
- ]
131
- }
132
- }
133
- }
134
- },
135
- "responses": {
136
- "200": {
137
- "description": "OK",
138
- "content": {
139
- "application/json": {
140
- "schema": {
141
- "type": "object",
142
- "properties": {
143
- "id": {
144
- "type": "string"
145
- },
146
- "name": {
147
- "type": "string",
148
- "minLength": 1,
149
- "maxLength": 200
150
- },
151
- "description": {
152
- "type": "string",
153
- "maxLength": 5000
154
- },
155
- "createdBy": {
156
- "type": "string"
157
- },
158
- "createdAt": {
159
- "type": "string",
160
- "format": "date-time",
161
- "x-native-type": "date"
162
- },
163
- "updatedAt": {
164
- "type": "string",
165
- "format": "date-time",
166
- "x-native-type": "date"
167
- }
168
- },
169
- "required": [
170
- "id",
171
- "name",
172
- "description",
173
- "createdBy",
174
- "createdAt",
175
- "updatedAt"
176
- ]
177
- }
178
- }
179
- }
180
- },
181
- "409": {
182
- "description": "409",
183
- "content": {
184
- "application/json": {
185
- "schema": {
186
- "oneOf": [
187
- {
188
- "type": "object",
189
- "properties": {
190
- "defined": {
191
- "const": true
192
- },
193
- "code": {
194
- "const": "ITEM_NAME_TAKEN"
195
- },
196
- "status": {
197
- "const": 409
198
- },
199
- "message": {
200
- "type": "string",
201
- "default": "Another item has this name"
202
- },
203
- "data": {
204
- "type": "object",
205
- "properties": {
206
- "name": {
207
- "type": "string"
208
- }
209
- },
210
- "required": [
211
- "name"
212
- ]
213
- }
214
- },
215
- "required": [
216
- "defined",
217
- "code",
218
- "status",
219
- "message",
220
- "data"
221
- ]
222
- },
223
- {
224
- "type": "object",
225
- "properties": {
226
- "defined": {
227
- "const": false
228
- },
229
- "code": {
230
- "type": "string"
231
- },
232
- "status": {
233
- "type": "number"
234
- },
235
- "message": {
236
- "type": "string"
237
- },
238
- "data": {}
239
- },
240
- "required": [
241
- "defined",
242
- "code",
243
- "status",
244
- "message"
245
- ]
246
- }
247
- ]
248
- }
249
- }
250
- }
251
- }
252
- }
253
- }
254
- },
255
- "/items/update": {
256
- "post": {
257
- "operationId": "items.update",
258
- "requestBody": {
259
- "required": true,
260
- "content": {
261
- "application/json": {
262
- "schema": {
263
- "type": "object",
264
- "properties": {
265
- "id": {
266
- "type": "string"
267
- },
268
- "name": {
269
- "type": "string",
270
- "minLength": 1,
271
- "maxLength": 200
272
- },
273
- "description": {
274
- "type": "string",
275
- "maxLength": 5000
276
- }
277
- },
278
- "required": [
279
- "id",
280
- "name"
281
- ]
282
- }
283
- }
284
- }
285
- },
286
- "responses": {
287
- "200": {
288
- "description": "OK",
289
- "content": {
290
- "application/json": {
291
- "schema": {
292
- "type": "object",
293
- "properties": {
294
- "id": {
295
- "type": "string"
296
- },
297
- "name": {
298
- "type": "string",
299
- "minLength": 1,
300
- "maxLength": 200
301
- },
302
- "description": {
303
- "type": "string",
304
- "maxLength": 5000
305
- },
306
- "createdBy": {
307
- "type": "string"
308
- },
309
- "createdAt": {
310
- "type": "string",
311
- "format": "date-time",
312
- "x-native-type": "date"
313
- },
314
- "updatedAt": {
315
- "type": "string",
316
- "format": "date-time",
317
- "x-native-type": "date"
318
- }
319
- },
320
- "required": [
321
- "id",
322
- "name",
323
- "description",
324
- "createdBy",
325
- "createdAt",
326
- "updatedAt"
327
- ]
328
- }
329
- }
330
- }
331
- },
332
- "409": {
333
- "description": "409",
334
- "content": {
335
- "application/json": {
336
- "schema": {
337
- "oneOf": [
338
- {
339
- "type": "object",
340
- "properties": {
341
- "defined": {
342
- "const": true
343
- },
344
- "code": {
345
- "const": "ITEM_NAME_TAKEN"
346
- },
347
- "status": {
348
- "const": 409
349
- },
350
- "message": {
351
- "type": "string",
352
- "default": "Another item has this name"
353
- },
354
- "data": {
355
- "type": "object",
356
- "properties": {
357
- "name": {
358
- "type": "string"
359
- }
360
- },
361
- "required": [
362
- "name"
363
- ]
364
- }
365
- },
366
- "required": [
367
- "defined",
368
- "code",
369
- "status",
370
- "message",
371
- "data"
372
- ]
373
- },
374
- {
375
- "type": "object",
376
- "properties": {
377
- "defined": {
378
- "const": false
379
- },
380
- "code": {
381
- "type": "string"
382
- },
383
- "status": {
384
- "type": "number"
385
- },
386
- "message": {
387
- "type": "string"
388
- },
389
- "data": {}
390
- },
391
- "required": [
392
- "defined",
393
- "code",
394
- "status",
395
- "message"
396
- ]
397
- }
398
- ]
399
- }
400
- }
401
- }
402
- }
403
- }
404
- }
405
- },
406
- "/items/remove": {
407
- "post": {
408
- "operationId": "items.remove",
409
- "requestBody": {
410
- "required": true,
411
- "content": {
412
- "application/json": {
413
- "schema": {
414
- "type": "object",
415
- "properties": {
416
- "id": {
417
- "type": "string"
418
- }
419
- },
420
- "required": [
421
- "id"
422
- ]
423
- }
424
- }
425
- }
426
- },
427
- "responses": {
428
- "200": {
429
- "description": "OK",
430
- "content": {
431
- "application/json": {
432
- "schema": {
433
- "type": "object",
434
- "properties": {
435
- "id": {
436
- "type": "string"
437
- }
438
- },
439
- "required": [
440
- "id"
441
- ]
442
- }
443
- }
444
- }
445
- }
446
- }
447
- }
448
- }
449
- }
450
- }
@@ -1,27 +0,0 @@
1
- import { writeFile } from 'node:fs/promises';
2
- import { resolve } from 'node:path';
3
- import { OpenAPIGenerator } from '@orpc/openapi';
4
- import { ZodToJsonSchemaConverter } from '@orpc/zod/zod4';
5
-
6
- // Importing the router builds a pool but never connects. Generation needs no running services.
7
- process.env.DATA_URL ??= 'postgres://localhost/contract_generation';
8
-
9
- process.env.CORE_URL ??= 'http://localhost:9';
10
-
11
- process.env.PLUGIN_SECRET ??= 'contract-generation'.padEnd(32, 'x');
12
-
13
- const { router } = await import('../src/router.ts');
14
- const { PLUGIN } = await import('../src/config.ts');
15
- const { pool } = await import('../src/db/client.ts');
16
-
17
- try {
18
- const document = await new OpenAPIGenerator({
19
- schemaConverters: [new ZodToJsonSchemaConverter()],
20
- }).generate(router, { info: { title: PLUGIN, version: 'v1' } });
21
-
22
- const target = process.argv[2] ?? resolve(import.meta.dirname, '../openapi.json');
23
-
24
- await writeFile(target, `${JSON.stringify(document, null, 2)}\n`);
25
- } finally {
26
- await pool.end();
27
- }