@avtechno/sfr 2.0.8 → 2.1.0
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.mjs +24 -0
- package/dist/sfr-pipeline.mjs +3 -3
- package/dist/templates.mjs +2 -2
- package/package.json +1 -1
- package/src/index.mts +30 -0
- package/src/sfr-pipeline.mts +3 -3
- package/src/templates.mts +2 -2
package/dist/index.mjs
CHANGED
|
@@ -22,6 +22,8 @@ async function write_service_discovery(cfg, documents) {
|
|
|
22
22
|
//Setup files in case they do not exist.
|
|
23
23
|
//Setup output folder
|
|
24
24
|
await fs.mkdir(path.join(cwd, cfg.out), { recursive: true });
|
|
25
|
+
// Write combined OpenAPI index file containing all protocols
|
|
26
|
+
await write_combined_openapi_index(cfg, documents);
|
|
25
27
|
// Loop over each protocol
|
|
26
28
|
for (let [protocol, documentation] of Object.entries(documents)) {
|
|
27
29
|
//Strictly await for setup to create dirs for each protocol.
|
|
@@ -51,6 +53,28 @@ async function write_service_discovery(cfg, documents) {
|
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
}
|
|
56
|
+
// Writes a combined openapi.yml index file containing all generated documentation
|
|
57
|
+
async function write_combined_openapi_index(cfg, documents) {
|
|
58
|
+
const combined = {
|
|
59
|
+
openapi: "3.1.0",
|
|
60
|
+
info: {},
|
|
61
|
+
paths: {}
|
|
62
|
+
};
|
|
63
|
+
for (const [protocol, documentation] of Object.entries(documents)) {
|
|
64
|
+
switch (protocol) {
|
|
65
|
+
case "REST":
|
|
66
|
+
{
|
|
67
|
+
const rest_doc = documentation;
|
|
68
|
+
// Merge REST OpenAPI info and paths into combined doc
|
|
69
|
+
combined.info = rest_doc.info;
|
|
70
|
+
combined.paths = rest_doc.paths;
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Write the combined index file
|
|
76
|
+
await fs.writeFile(path.join(cwd, cfg.out, "openapi.yml"), yaml.dump(combined, { lineWidth: -1, indent: 2, noRefs: true }), { flag: "w+" });
|
|
77
|
+
}
|
|
54
78
|
//Tasked with recursively creating directories and spec files.
|
|
55
79
|
async function write_to_file(cfg, dir, data) {
|
|
56
80
|
//Path is a slash(/) delimited string, with the end delimiter indicating the filename to be used.
|
package/dist/sfr-pipeline.mjs
CHANGED
|
@@ -97,15 +97,15 @@ export class SFRPipeline {
|
|
|
97
97
|
this.pattern_channels = Object.fromEntries(channels);
|
|
98
98
|
SFRPipeline.injections.rest.handlers = {
|
|
99
99
|
...SFRPipeline.injections.rest.handlers,
|
|
100
|
-
|
|
100
|
+
mq_patterns: this.pattern_channels,
|
|
101
101
|
};
|
|
102
102
|
SFRPipeline.injections.mq.handlers = {
|
|
103
103
|
...SFRPipeline.injections.mq.handlers,
|
|
104
|
-
|
|
104
|
+
mq_patterns: this.pattern_channels,
|
|
105
105
|
};
|
|
106
106
|
SFRPipeline.injections.ws.handlers = {
|
|
107
107
|
...SFRPipeline.injections.ws.handlers,
|
|
108
|
-
|
|
108
|
+
mq_patterns: this.pattern_channels,
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
111
|
// Inject Socket.IO server into WS handlers
|
package/dist/templates.mjs
CHANGED
|
@@ -44,9 +44,9 @@ export function MQ(struct) {
|
|
|
44
44
|
Object.entries(handlers).forEach(([pattern, handlermap]) => {
|
|
45
45
|
Object.entries(handlermap).forEach(([k, v]) => {
|
|
46
46
|
/* @ts-ignore */
|
|
47
|
-
const {
|
|
47
|
+
const { mq_patterns } = (SFRPipeline.injections.mq.handlers || {});
|
|
48
48
|
/* @ts-ignore */
|
|
49
|
-
handlers[pattern][k] = { ...v, fn: v.fn.bind({ ...controllers, mq:
|
|
49
|
+
handlers[pattern][k] = { ...v, fn: v.fn.bind({ ...controllers, mq: mq_patterns[pattern], ...SFRPipeline.injections.mq.handlers }) };
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
52
|
/* @ts-ignore */
|
package/package.json
CHANGED
package/src/index.mts
CHANGED
|
@@ -31,6 +31,9 @@ async function write_service_discovery(cfg: ParserCFG, documents: ServiceDocumen
|
|
|
31
31
|
//Setup output folder
|
|
32
32
|
await fs.mkdir(path.join(cwd, cfg.out), { recursive: true });
|
|
33
33
|
|
|
34
|
+
// Write combined OpenAPI index file containing all protocols
|
|
35
|
+
await write_combined_openapi_index(cfg, documents);
|
|
36
|
+
|
|
34
37
|
// Loop over each protocol
|
|
35
38
|
for (let [protocol, documentation] of Object.entries(documents)) {
|
|
36
39
|
//Strictly await for setup to create dirs for each protocol.
|
|
@@ -60,6 +63,33 @@ async function write_service_discovery(cfg: ParserCFG, documents: ServiceDocumen
|
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
|
|
66
|
+
// Writes a combined openapi.yml index file containing all generated documentation
|
|
67
|
+
async function write_combined_openapi_index(cfg: ParserCFG, documents: ServiceDocuments) {
|
|
68
|
+
const combined: any = {
|
|
69
|
+
openapi: "3.1.0",
|
|
70
|
+
info: {},
|
|
71
|
+
paths: {}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
for (const [protocol, documentation] of Object.entries(documents)) {
|
|
75
|
+
switch (protocol) {
|
|
76
|
+
case "REST": {
|
|
77
|
+
const rest_doc = documentation as OAPI_Document;
|
|
78
|
+
// Merge REST OpenAPI info and paths into combined doc
|
|
79
|
+
combined.info = rest_doc.info;
|
|
80
|
+
combined.paths = rest_doc.paths;
|
|
81
|
+
} break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Write the combined index file
|
|
86
|
+
await fs.writeFile(
|
|
87
|
+
path.join(cwd, cfg.out, "openapi.yml"),
|
|
88
|
+
yaml.dump(combined, { lineWidth: -1, indent: 2, noRefs: true }),
|
|
89
|
+
{ flag: "w+" }
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
63
93
|
//Tasked with recursively creating directories and spec files.
|
|
64
94
|
async function write_to_file(cfg: ParserCFG, dir: string, data: object) {
|
|
65
95
|
//Path is a slash(/) delimited string, with the end delimiter indicating the filename to be used.
|
package/src/sfr-pipeline.mts
CHANGED
|
@@ -117,17 +117,17 @@ export class SFRPipeline {
|
|
|
117
117
|
|
|
118
118
|
SFRPipeline.injections.rest.handlers = {
|
|
119
119
|
...SFRPipeline.injections.rest.handlers,
|
|
120
|
-
|
|
120
|
+
mq_patterns: this.pattern_channels,
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
SFRPipeline.injections.mq.handlers = {
|
|
124
124
|
...SFRPipeline.injections.mq.handlers,
|
|
125
|
-
|
|
125
|
+
mq_patterns: this.pattern_channels,
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
SFRPipeline.injections.ws.handlers = {
|
|
129
129
|
...SFRPipeline.injections.ws.handlers,
|
|
130
|
-
|
|
130
|
+
mq_patterns: this.pattern_channels,
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
|
package/src/templates.mts
CHANGED
|
@@ -54,9 +54,9 @@ export function MQ<V, H>(struct : MQHandlerDescriptor<V, H>): H{
|
|
|
54
54
|
Object.entries(handlers).forEach(([pattern, handlermap])=>{
|
|
55
55
|
Object.entries(handlermap).forEach(([k, v])=> {
|
|
56
56
|
/* @ts-ignore */
|
|
57
|
-
const {
|
|
57
|
+
const {mq_patterns} = (SFRPipeline.injections.mq.handlers || {});
|
|
58
58
|
/* @ts-ignore */
|
|
59
|
-
handlers[pattern][k] = {...v, fn : v.fn.bind({ ...controllers, mq :
|
|
59
|
+
handlers[pattern][k] = {...v, fn : v.fn.bind({ ...controllers, mq : mq_patterns[pattern], ...SFRPipeline.injections.mq.handlers})};
|
|
60
60
|
});
|
|
61
61
|
});
|
|
62
62
|
/* @ts-ignore */
|