@bpmnkit/connector-gen 0.0.6 → 0.0.7
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/browser.d.ts +40 -0
- package/dist/browser.js +55 -0
- package/package.json +5 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-safe entry point for `@bpmnkit/connector-gen`.
|
|
3
|
+
*
|
|
4
|
+
* Identical to the main entry except `writeTemplates` is excluded — that
|
|
5
|
+
* function depends on `node:fs/promises` and `node:path` which are not
|
|
6
|
+
* available in browser environments. Use this entry point when bundling for
|
|
7
|
+
* the browser (e.g. with Vite or webpack).
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
export { buildTemplate, buildTemplates } from "./build-template.js";
|
|
12
|
+
export { CATALOG, getCatalogEntry } from "./catalog.js";
|
|
13
|
+
export type { CatalogEntry } from "./catalog.js";
|
|
14
|
+
export { detectDefaultAuth, getBaseUrl, getOperations, getServers, isRef, parseOpenApi, resolve, resolveRef, } from "./parse-openapi.js";
|
|
15
|
+
export type { DetectedAuth } from "./parse-openapi.js";
|
|
16
|
+
export type { ApiResponse, AuthHint, Binding, Components, ConnectorGroup, ConnectorTemplate, Constraints, GeneratorOptions, HttpMethod, MediaType, OpenApiDoc, OpenApiInfo, OpenApiServer, Operation, OperationWithMeta, OAuthFlows, Parameter, PathItem, PropertyDef, Ref, RequestBody, Schema, SecurityRequirement, WriteOptions, } from "./types.js";
|
|
17
|
+
export { CONNECTOR_SCHEMA } from "./types.js";
|
|
18
|
+
import type { CatalogEntry } from "./catalog.js";
|
|
19
|
+
import type { ConnectorTemplate, GeneratorOptions } from "./types.js";
|
|
20
|
+
export interface GenerateOptions extends GeneratorOptions {
|
|
21
|
+
filter?: GeneratorOptions["filter"];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Parse an OpenAPI spec (string or object) and generate connector templates.
|
|
25
|
+
*/
|
|
26
|
+
export declare function generate(specText: string, opts: GeneratorOptions): ConnectorTemplate[];
|
|
27
|
+
/**
|
|
28
|
+
* Download an OpenAPI spec from a URL and generate connector templates.
|
|
29
|
+
*/
|
|
30
|
+
export declare function generateFromUrl(url: string, opts: GeneratorOptions): Promise<{
|
|
31
|
+
templates: ConnectorTemplate[];
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* Generate connector templates from a catalog entry by ID.
|
|
35
|
+
*/
|
|
36
|
+
export declare function generateFromCatalog(id: string, overrides?: Partial<GenerateOptions>): Promise<{
|
|
37
|
+
templates: ConnectorTemplate[];
|
|
38
|
+
entry: CatalogEntry;
|
|
39
|
+
}>;
|
|
40
|
+
//# sourceMappingURL=browser.d.ts.map
|
package/dist/browser.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-safe entry point for `@bpmnkit/connector-gen`.
|
|
3
|
+
*
|
|
4
|
+
* Identical to the main entry except `writeTemplates` is excluded — that
|
|
5
|
+
* function depends on `node:fs/promises` and `node:path` which are not
|
|
6
|
+
* available in browser environments. Use this entry point when bundling for
|
|
7
|
+
* the browser (e.g. with Vite or webpack).
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
export { buildTemplate, buildTemplates } from "./build-template.js";
|
|
12
|
+
export { CATALOG, getCatalogEntry } from "./catalog.js";
|
|
13
|
+
export { detectDefaultAuth, getBaseUrl, getOperations, getServers, isRef, parseOpenApi, resolve, resolveRef, } from "./parse-openapi.js";
|
|
14
|
+
export { CONNECTOR_SCHEMA } from "./types.js";
|
|
15
|
+
import { buildTemplates } from "./build-template.js";
|
|
16
|
+
import { CATALOG, getCatalogEntry } from "./catalog.js";
|
|
17
|
+
import { detectDefaultAuth, getOperations, parseOpenApi } from "./parse-openapi.js";
|
|
18
|
+
/**
|
|
19
|
+
* Parse an OpenAPI spec (string or object) and generate connector templates.
|
|
20
|
+
*/
|
|
21
|
+
export function generate(specText, opts) {
|
|
22
|
+
const doc = parseOpenApi(specText);
|
|
23
|
+
const defaultAuth = opts.defaultAuthType ?? detectDefaultAuth(doc);
|
|
24
|
+
const ops = getOperations(doc, opts.filter);
|
|
25
|
+
return buildTemplates(ops, { ...opts, defaultAuthType: defaultAuth });
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Download an OpenAPI spec from a URL and generate connector templates.
|
|
29
|
+
*/
|
|
30
|
+
export async function generateFromUrl(url, opts) {
|
|
31
|
+
const res = await fetch(url);
|
|
32
|
+
if (!res.ok)
|
|
33
|
+
throw new Error(`Failed to fetch spec from ${url}: ${res.status} ${res.statusText}`);
|
|
34
|
+
const text = await res.text();
|
|
35
|
+
const templates = generate(text, opts);
|
|
36
|
+
return { templates };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Generate connector templates from a catalog entry by ID.
|
|
40
|
+
*/
|
|
41
|
+
export async function generateFromCatalog(id, overrides = {}) {
|
|
42
|
+
const entry = getCatalogEntry(id);
|
|
43
|
+
if (!entry) {
|
|
44
|
+
const ids = CATALOG.map((e) => e.id).join(", ");
|
|
45
|
+
throw new Error(`Unknown catalog entry "${id}". Available: ${ids}`);
|
|
46
|
+
}
|
|
47
|
+
const opts = {
|
|
48
|
+
idPrefix: overrides.idPrefix ?? entry.idPrefix,
|
|
49
|
+
defaultAuthType: overrides.defaultAuthType ?? entry.defaultAuth,
|
|
50
|
+
...overrides,
|
|
51
|
+
};
|
|
52
|
+
const { templates } = await generateFromUrl(entry.url, opts);
|
|
53
|
+
return { templates, entry };
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=browser.js.map
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bpmnkit/connector-gen",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
8
|
"import": "./dist/index.js",
|
|
9
9
|
"types": "./dist/index.d.ts"
|
|
10
|
+
},
|
|
11
|
+
"./browser": {
|
|
12
|
+
"import": "./dist/browser.js",
|
|
13
|
+
"types": "./dist/browser.d.ts"
|
|
10
14
|
}
|
|
11
15
|
},
|
|
12
16
|
"main": "./dist/index.js",
|