create-erxes 0.1.16 → 0.1.18

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.16";
12
+ var version = "0.1.18";
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 = [
@@ -55,9 +55,10 @@ without line-by-line review.
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
57
  with `verifyPluginSession`. The same procedures are REST at `/api/v1` for
58
- scripts, which get the token from core with an API key; `/api/openapi.json`
58
+ scripts, which get the token from core with an API key; `/api/openapi/member.json`
59
59
  documents them (`pluginOpenApi`), and core's Settings › Developer › API reference
60
- shows it. Renaming a procedure breaks those scripts. A caller outside erxes (a webhook) reaches a path
60
+ shows it. Routes for customers or a website get their own document with that
61
+ `audience`, listed in the manifest's `api.docs`. Renaming a procedure breaks those scripts. A caller outside erxes (a webhook) reaches a path
61
62
  the manifest's `publicPaths` lists through core, which names the organisation:
62
63
  check it with `verifyPublicCall` (`@erxes/plugin-sdk`'s overview has the route).
63
64
  - Skills in `.agents/skills/`: `endpoint` for a procedure, `schema-change` for a
@@ -21,8 +21,8 @@
21
21
  "db:check": "drizzle-kit check"
22
22
  },
23
23
  "dependencies": {
24
- "@erxes/core-contract": "0.1.0-v2.15",
25
- "@erxes/plugin-sdk": "0.1.0-v2.13",
24
+ "@erxes/core-contract": "0.1.0-v2.19",
25
+ "@erxes/plugin-sdk": "0.1.0-v2.17",
26
26
  "@opentelemetry/instrumentation-express": "^0.73.0",
27
27
  "@opentelemetry/instrumentation-http": "^0.301.1",
28
28
  "@opentelemetry/instrumentation-pg": "^0.78.0",
@@ -31,7 +31,10 @@ export const manifest = {
31
31
  version: config.version,
32
32
  ui: { remote: '__id___ui', entry: config.uiEntryUrl },
33
33
  // `server.ts` serves the REST routes at /api/v1 and their document here.
34
- api: { url: `${config.publicUrl}/api`, openapi: '/openapi.json' },
34
+ api: {
35
+ url: `${config.publicUrl}/api`,
36
+ docs: [{ audience: 'member', path: '/openapi/member.json' }],
37
+ },
35
38
  scopes: [],
36
39
  permissions: [
37
40
  { action: PERMISSIONS.view, label: 'View items', group: '__title__' },
@@ -12,17 +12,21 @@ import { runJob } from '#/jobs.ts';
12
12
  import { logger } from '#/logger.ts';
13
13
  import { router } from '#/router.ts';
14
14
 
15
- const logFailure = onError((error) => {
15
+ const logFailure = (error: unknown) => {
16
16
  if (!(error instanceof ORPCError) || error.status >= 500) logger.error(error);
17
- });
17
+ };
18
18
 
19
19
  // The same procedures twice: RPC for the plugin UI, REST (documented below) for scripts.
20
- const rpc = new RPCHandler(router, { interceptors: [logFailure] });
21
- const rest = new OpenAPIHandler(router, { interceptors: [logFailure] });
22
-
23
- /** Settings › Developer › API reference shows it (the manifest's `api.openapi`). */
24
- const openApi = pluginOpenApi(router, {
20
+ const rpc = new RPCHandler(router, { interceptors: [onError(logFailure)] });
21
+ const rest = new OpenAPIHandler(router, { interceptors: [onError(logFailure)] });
22
+
23
+ /**
24
+ * Settings › Developer › API reference shows it (the manifest's `api.docs`). Routes for
25
+ * customers or a website get their own document with that `audience`.
26
+ */
27
+ const memberDoc = pluginOpenApi(router, {
25
28
  plugin: PLUGIN,
29
+ audience: 'member',
26
30
  title: manifest.title,
27
31
  version: manifest.version,
28
32
  description: manifest.description,
@@ -48,7 +52,7 @@ export const createApp = () => {
48
52
  // Bearer session token core issues, never a cookie, so CORS guards nothing here.
49
53
  // Routes for websites (an API key, customer tokens) set their own CORS.
50
54
  app.use(
51
- ['/api/rpc', '/api/v1', '/api/openapi.json', '/ui'],
55
+ ['/api/rpc', '/api/v1', '/api/openapi', '/ui'],
52
56
  cors({ origin: true, credentials: false, maxAge: 600 }),
53
57
  );
54
58
 
@@ -56,8 +60,8 @@ export const createApp = () => {
56
60
  res.json({ ok: true });
57
61
  });
58
62
 
59
- app.get('/api/openapi.json', async (_req, res) => {
60
- res.json(await openApi);
63
+ app.get('/api/openapi/member.json', async (_req, res) => {
64
+ res.json(await memberDoc);
61
65
  });
62
66
 
63
67
  // A 5-minute session token core issued for this member and plugin: erxes-ui's pluginFetch
@@ -8,12 +8,12 @@
8
8
  "build": "rsbuild build"
9
9
  },
10
10
  "dependencies": {
11
- "@erxes/core-contract": "0.1.0-v2.15",
11
+ "@erxes/core-contract": "0.1.0-v2.19",
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.19",
16
+ "erxes-ui": "npm:@erxes/ui@4.0.0-v2.20",
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.16",
3
+ "version": "0.1.18",
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",