wrekenfile-converter 2.2.3 → 2.2.4
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/README.md +1 -1
- package/dist/v2/index.d.ts +1 -0
- package/dist/v2/index.js +5 -1
- package/dist/v2/mini-wrekenfile-generator.js +4 -19
- package/dist/v2/utils/canonical-id.js +15 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -171,7 +171,7 @@ METHODS:
|
|
|
171
171
|
STATUS: 200
|
|
172
172
|
```
|
|
173
173
|
|
|
174
|
-
The full deterministic spec (for re-implementing in SDKs/other languages) is documented in [`
|
|
174
|
+
The full deterministic spec (for re-implementing in SDKs/other languages) is documented in the source at [`src/v2/utils/canonical-id.ts`](./src/v2/utils/canonical-id.ts).
|
|
175
175
|
|
|
176
176
|
## Parameter Structure
|
|
177
177
|
|
package/dist/v2/index.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export { generateWrekenfile as generateWrekenfileV2 } from './openapi-v2-to-wrek
|
|
|
3
3
|
export { generateWrekenfile as generateWrekenfileFromPostman, extractStructs, extractOperations, mapType, parseJsonExample, extractFieldsFromObject, loadEnvironmentFile, extractCollectionVariables, resolveVariables } from './postman-to-wrekenfile';
|
|
4
4
|
export { generateMiniWrekenfiles, saveMiniWrekenfiles, MiniWrekenfile } from './mini-wrekenfile-generator';
|
|
5
5
|
export { computeCanonicalId, resolveCanonicalIds, type MethodCanonicalInput, } from './utils/canonical-id';
|
|
6
|
+
export { filterStructsByUsage, extractAllStructNames, } from './utils/struct-utils';
|
package/dist/v2/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// v2 entry point - Wrekenfile spec version 2.1.0
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.resolveCanonicalIds = exports.computeCanonicalId = exports.saveMiniWrekenfiles = exports.generateMiniWrekenfiles = exports.resolveVariables = exports.extractCollectionVariables = exports.loadEnvironmentFile = exports.extractFieldsFromObject = exports.parseJsonExample = exports.mapType = exports.extractOperations = exports.extractStructs = exports.generateWrekenfileFromPostman = exports.generateWrekenfileV2 = exports.generateWrekenfile = void 0;
|
|
4
|
+
exports.extractAllStructNames = exports.filterStructsByUsage = exports.resolveCanonicalIds = exports.computeCanonicalId = exports.saveMiniWrekenfiles = exports.generateMiniWrekenfiles = exports.resolveVariables = exports.extractCollectionVariables = exports.loadEnvironmentFile = exports.extractFieldsFromObject = exports.parseJsonExample = exports.mapType = exports.extractOperations = exports.extractStructs = exports.generateWrekenfileFromPostman = exports.generateWrekenfileV2 = exports.generateWrekenfile = void 0;
|
|
5
5
|
// Export OpenAPI v3 converter
|
|
6
6
|
var openapi_to_wreken_1 = require("./openapi-to-wreken");
|
|
7
7
|
Object.defineProperty(exports, "generateWrekenfile", { enumerable: true, get: function () { return openapi_to_wreken_1.generateWrekenfile; } });
|
|
@@ -27,3 +27,7 @@ Object.defineProperty(exports, "saveMiniWrekenfiles", { enumerable: true, get: f
|
|
|
27
27
|
var canonical_id_1 = require("./utils/canonical-id");
|
|
28
28
|
Object.defineProperty(exports, "computeCanonicalId", { enumerable: true, get: function () { return canonical_id_1.computeCanonicalId; } });
|
|
29
29
|
Object.defineProperty(exports, "resolveCanonicalIds", { enumerable: true, get: function () { return canonical_id_1.resolveCanonicalIds; } });
|
|
30
|
+
// Export struct utilities
|
|
31
|
+
var struct_utils_1 = require("./utils/struct-utils");
|
|
32
|
+
Object.defineProperty(exports, "filterStructsByUsage", { enumerable: true, get: function () { return struct_utils_1.filterStructsByUsage; } });
|
|
33
|
+
Object.defineProperty(exports, "extractAllStructNames", { enumerable: true, get: function () { return struct_utils_1.extractAllStructNames; } });
|
|
@@ -39,6 +39,7 @@ const yaml = __importStar(require("js-yaml"));
|
|
|
39
39
|
const fs = __importStar(require("fs"));
|
|
40
40
|
const constants_1 = require("./utils/constants");
|
|
41
41
|
const yaml_utils_1 = require("./utils/yaml-utils");
|
|
42
|
+
const struct_utils_1 = require("./utils/struct-utils");
|
|
42
43
|
function generateMiniWrekenfiles(wrekenfileContent) {
|
|
43
44
|
if (!wrekenfileContent || typeof wrekenfileContent !== 'string') {
|
|
44
45
|
throw new Error("Argument 'wrekenfileContent' is required and must be a string");
|
|
@@ -295,7 +296,7 @@ function extractTypeFromInput(value) {
|
|
|
295
296
|
return null;
|
|
296
297
|
}
|
|
297
298
|
function collectStructRefsFromType(type, structRefs) {
|
|
298
|
-
const structNames = extractAllStructNames(type);
|
|
299
|
+
const structNames = (0, struct_utils_1.extractAllStructNames)(type);
|
|
299
300
|
for (const structName of structNames) {
|
|
300
301
|
if (structName)
|
|
301
302
|
structRefs.add(structName);
|
|
@@ -313,7 +314,7 @@ function collectStructRecursively(structName, allStructs, requiredStructs, proce
|
|
|
313
314
|
// Old format: array of fields
|
|
314
315
|
for (const field of structData) {
|
|
315
316
|
if (field.type) {
|
|
316
|
-
const nestedStructNames = extractAllStructNames(field.type);
|
|
317
|
+
const nestedStructNames = (0, struct_utils_1.extractAllStructNames)(field.type);
|
|
317
318
|
for (const nestedStructName of nestedStructNames) {
|
|
318
319
|
if (nestedStructName) {
|
|
319
320
|
collectStructRecursively(nestedStructName, allStructs, requiredStructs, processedStructs);
|
|
@@ -326,7 +327,7 @@ function collectStructRecursively(structName, allStructs, requiredStructs, proce
|
|
|
326
327
|
// New format: { DESC: ..., FIELDS: [...] }
|
|
327
328
|
for (const field of structData.FIELDS) {
|
|
328
329
|
if (field.TYPE) {
|
|
329
|
-
const nestedStructNames = extractAllStructNames(field.TYPE);
|
|
330
|
+
const nestedStructNames = (0, struct_utils_1.extractAllStructNames)(field.TYPE);
|
|
330
331
|
for (const nestedStructName of nestedStructNames) {
|
|
331
332
|
if (nestedStructName) {
|
|
332
333
|
collectStructRecursively(nestedStructName, allStructs, requiredStructs, processedStructs);
|
|
@@ -336,22 +337,6 @@ function collectStructRecursively(structName, allStructs, requiredStructs, proce
|
|
|
336
337
|
}
|
|
337
338
|
}
|
|
338
339
|
}
|
|
339
|
-
const STRUCT_REGEX = /^STRUCT\(([^)]+)\)/;
|
|
340
|
-
const ARRAY_STRUCT_REGEX = /^\[\]STRUCT\(([^)]+)\)/;
|
|
341
|
-
const MAP_STRUCT_REGEX = /map\[[^\]]+\]STRUCT\(([^)]+)\)/;
|
|
342
|
-
function extractAllStructNames(typeString) {
|
|
343
|
-
const matches = [];
|
|
344
|
-
const match1 = typeString.match(STRUCT_REGEX);
|
|
345
|
-
const match2 = typeString.match(ARRAY_STRUCT_REGEX);
|
|
346
|
-
const match3 = typeString.match(MAP_STRUCT_REGEX);
|
|
347
|
-
if (match1)
|
|
348
|
-
matches.push(match1[1]);
|
|
349
|
-
if (match2)
|
|
350
|
-
matches.push(match2[1]);
|
|
351
|
-
if (match3)
|
|
352
|
-
matches.push(match3[1]);
|
|
353
|
-
return matches;
|
|
354
|
-
}
|
|
355
340
|
function sanitizeFilename(name) {
|
|
356
341
|
return name
|
|
357
342
|
.replace(constants_1.FILENAME_LEADING_SLASHES, '')
|
|
@@ -59,15 +59,24 @@ function normalizePath(path) {
|
|
|
59
59
|
*/
|
|
60
60
|
function pathSegmentsWithoutParams(path) {
|
|
61
61
|
const segments = path.split('/').filter(Boolean);
|
|
62
|
-
return segments.
|
|
63
|
-
// Remove {param} style
|
|
62
|
+
return segments.reduce((acc, s) => {
|
|
63
|
+
// Remove pure {param} style
|
|
64
64
|
if (s.startsWith('{') && s.endsWith('}'))
|
|
65
|
-
return
|
|
65
|
+
return acc;
|
|
66
66
|
// Remove :param style
|
|
67
67
|
if (s.startsWith(':'))
|
|
68
|
-
return
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
return acc;
|
|
69
|
+
// Handle Google API-style segments like {property}:runReport —
|
|
70
|
+
// strip any {param} placeholders and remove a leading colon from the remainder.
|
|
71
|
+
if (s.includes('{')) {
|
|
72
|
+
const remainder = s.replace(/\{[^}]+\}/g, '').replace(/^:/, '');
|
|
73
|
+
if (remainder)
|
|
74
|
+
acc.push(remainder);
|
|
75
|
+
return acc;
|
|
76
|
+
}
|
|
77
|
+
acc.push(s);
|
|
78
|
+
return acc;
|
|
79
|
+
}, []);
|
|
71
80
|
}
|
|
72
81
|
/**
|
|
73
82
|
* Singularize a resource name (simple rules + irregular map).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wrekenfile-converter",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4",
|
|
4
4
|
"description": "Convert OpenAPI and Postman specs into Wrekenfiles, with chunking for vector database storage",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"homepage": "https://wreken.com",
|
|
33
33
|
"repository": {
|
|
34
34
|
"type": "git",
|
|
35
|
-
"url": "https://gitlab.com/swytchcode/wrekenfile.git"
|
|
35
|
+
"url": "git+https://gitlab.com/swytchcode/wrekenfile.git"
|
|
36
36
|
},
|
|
37
37
|
"license": "MIT",
|
|
38
38
|
"files": [
|