@erxes/plugin-sdk 0.1.0-v2.18 → 0.1.0-v2.19
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.d.ts +1 -1
- package/dist/openapi.d.ts +12 -4
- package/dist/openapi.js +5 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
*
|
|
127
127
|
* api: { url: `${publicUrl}/api`, docs: [{ audience: 'member', path: '/openapi/member.json' }] },
|
|
128
128
|
* app.use('/api/v1', member check, (req, res, next) => rest.handle(req, res, { prefix: '/api/v1', context }));
|
|
129
|
-
* app.get('/api/openapi/member.json', async (_req, res) => res.json(await pluginOpenApi(router, { plugin, audience: 'member', title, version, prefix: '/v1' })));
|
|
129
|
+
* app.get('/api/openapi/member.json', async (_req, res) => res.json(await pluginOpenApi(router, { plugin, audience: 'member', title, version, server: `${publicUrl}/api`, prefix: '/v1' })));
|
|
130
130
|
*
|
|
131
131
|
* The client secret is only ever sent to `POST /plugins/token`; API calls use
|
|
132
132
|
* 15-minute tokens, fetched and renewed here. Plugins on core's database can
|
package/dist/openapi.d.ts
CHANGED
|
@@ -11,8 +11,14 @@ export interface PluginOpenApiOptions {
|
|
|
11
11
|
version: string;
|
|
12
12
|
description?: string;
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
* `
|
|
14
|
+
* The address the document's paths start from, which "try it" calls: the manifest's
|
|
15
|
+
* `api.url` (`${publicUrl}/api`) for routes under it, or the plugin's public URL for routes
|
|
16
|
+
* outside it (a website's `/public/v1`, customers' `/customer`).
|
|
17
|
+
*/
|
|
18
|
+
server: string;
|
|
19
|
+
/**
|
|
20
|
+
* Where the REST routes are mounted under `server` (`/v1`, for an `OpenAPIHandler` with
|
|
21
|
+
* prefix `<api path>/v1`): every path in the document starts with it.
|
|
16
22
|
*/
|
|
17
23
|
prefix: `/${string}`;
|
|
18
24
|
}
|
|
@@ -22,8 +28,10 @@ export interface PluginOpenApiOptions {
|
|
|
22
28
|
* Each audience signs in its own way (`securityOf`), and the document says how.
|
|
23
29
|
*
|
|
24
30
|
* const rest = new OpenAPIHandler(router); // mounted at `<api path>/v1`, like the RPC handler
|
|
25
|
-
* const doc = pluginOpenApi(router, {
|
|
31
|
+
* const doc = pluginOpenApi(router, {
|
|
32
|
+
* plugin: 'sales', audience: 'member', title, version, server: `${publicUrl}/api`, prefix: '/v1',
|
|
33
|
+
* });
|
|
26
34
|
* app.get('/api/openapi/member.json', async (_req, res) => res.json(await doc));
|
|
27
35
|
*/
|
|
28
|
-
export declare const pluginOpenApi: (router: Documented, { plugin, audience, title, version, description, prefix }: PluginOpenApiOptions) => Promise<OpenAPI.Document>;
|
|
36
|
+
export declare const pluginOpenApi: (router: Documented, { plugin, audience, title, version, description, server, prefix }: PluginOpenApiOptions) => Promise<OpenAPI.Document>;
|
|
29
37
|
export {};
|
package/dist/openapi.js
CHANGED
|
@@ -53,16 +53,19 @@ const securityOf = (plugin, audience) => {
|
|
|
53
53
|
* Each audience signs in its own way (`securityOf`), and the document says how.
|
|
54
54
|
*
|
|
55
55
|
* const rest = new OpenAPIHandler(router); // mounted at `<api path>/v1`, like the RPC handler
|
|
56
|
-
* const doc = pluginOpenApi(router, {
|
|
56
|
+
* const doc = pluginOpenApi(router, {
|
|
57
|
+
* plugin: 'sales', audience: 'member', title, version, server: `${publicUrl}/api`, prefix: '/v1',
|
|
58
|
+
* });
|
|
57
59
|
* app.get('/api/openapi/member.json', async (_req, res) => res.json(await doc));
|
|
58
60
|
*/
|
|
59
|
-
const pluginOpenApi = async (router, { plugin, audience, title, version, description, prefix }) => {
|
|
61
|
+
const pluginOpenApi = async (router, { plugin, audience, title, version, description, server, prefix }) => {
|
|
60
62
|
const doc = await new OpenAPIGenerator({ schemaConverters: [new ZodToJsonSchemaConverter()] }).generate(router, {
|
|
61
63
|
info: {
|
|
62
64
|
title,
|
|
63
65
|
version,
|
|
64
66
|
description
|
|
65
67
|
},
|
|
68
|
+
servers: [{ url: server }],
|
|
66
69
|
...securityOf(plugin, audience)
|
|
67
70
|
});
|
|
68
71
|
doc.paths = Object.fromEntries(Object.entries(doc.paths ?? {}).map(([path, item]) => [`${prefix}${path}`, item]));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@erxes/plugin-sdk",
|
|
3
|
-
"version": "0.1.0-v2.
|
|
3
|
+
"version": "0.1.0-v2.19",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "For erxes plugin servers: a typed core client with automatic plugin tokens, verification of members' plugin session tokens and of core's deliveries, and plugin jobs",
|
|
6
6
|
"license": "AGPL-3.0-only",
|