wrekenfile-converter 2.0.6 → 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/README.md +45 -26
- package/dist/example-usage.d.ts +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.js +53 -20
- package/dist/v1/index.d.ts +3 -0
- package/dist/v1/index.js +21 -0
- package/dist/{postman-to-wrekenfile.js → v1/postman-to-wrekenfile.js} +7 -19
- package/dist/{wrekenfile-validator.js → v1/wrekenfile-validator.js} +30 -8
- package/dist/v2/cli/cli-mini-wrekenfile-generator.d.ts +2 -0
- package/dist/v2/cli/cli-mini-wrekenfile-generator.js +107 -0
- package/dist/v2/cli/cli-openapi-to-wrekenfile.d.ts +2 -0
- package/dist/v2/cli/cli-openapi-to-wrekenfile.js +115 -0
- package/dist/v2/cli/cli-openapi-v2-to-wrekenfile.d.ts +2 -0
- package/dist/v2/cli/cli-openapi-v2-to-wrekenfile.js +115 -0
- package/dist/v2/cli/cli-postman-to-wrekenfile.d.ts +2 -0
- package/dist/v2/cli/cli-postman-to-wrekenfile.js +54 -0
- package/dist/v2/index.d.ts +4 -0
- package/dist/v2/index.js +25 -0
- package/dist/v2/mini-wrekenfile-generator.d.ts +13 -0
- package/dist/v2/mini-wrekenfile-generator.js +289 -0
- package/dist/v2/openapi-to-wreken.d.ts +2 -0
- package/dist/v2/openapi-to-wreken.js +829 -0
- package/dist/v2/openapi-v2-to-wrekenfile.d.ts +2 -0
- package/dist/v2/openapi-v2-to-wrekenfile.js +806 -0
- package/dist/v2/postman-to-wrekenfile.d.ts +11 -0
- package/dist/v2/postman-to-wrekenfile.js +742 -0
- package/dist/v2/utils/constants.d.ts +80 -0
- package/dist/v2/utils/constants.js +104 -0
- package/dist/v2/utils/response-utils.d.ts +11 -0
- package/dist/v2/utils/response-utils.js +39 -0
- package/dist/v2/utils/yaml-utils.d.ts +4 -0
- package/dist/v2/utils/yaml-utils.js +96 -0
- package/dist/versions.d.ts +9 -0
- package/dist/versions.js +12 -0
- package/package.json +12 -14
- package/dist/openapi-to-wrekenfile.d.ts +0 -0
- package/dist/openapi-to-wrekenfile.js +0 -10
- package/wrekenfile.md +0 -726
- /package/dist/{cli → v1/cli}/cli-mini-wrekenfile-generator.d.ts +0 -0
- /package/dist/{cli → v1/cli}/cli-mini-wrekenfile-generator.js +0 -0
- /package/dist/{cli → v1/cli}/cli-openapi-to-wrekenfile.d.ts +0 -0
- /package/dist/{cli → v1/cli}/cli-openapi-to-wrekenfile.js +0 -0
- /package/dist/{cli → v1/cli}/cli-postman-to-wrekenfile.d.ts +0 -0
- /package/dist/{cli → v1/cli}/cli-postman-to-wrekenfile.js +0 -0
- /package/dist/{mini-wrekenfile-generator.d.ts → v1/mini-wrekenfile-generator.d.ts} +0 -0
- /package/dist/{mini-wrekenfile-generator.js → v1/mini-wrekenfile-generator.js} +0 -0
- /package/dist/{openapi-to-wreken.d.ts → v1/openapi-to-wreken.d.ts} +0 -0
- /package/dist/{openapi-to-wreken.js → v1/openapi-to-wreken.js} +0 -0
- /package/dist/{openapi-v2-to-wrekenfile.d.ts → v1/openapi-v2-to-wrekenfile.d.ts} +0 -0
- /package/dist/{openapi-v2-to-wrekenfile.js → v1/openapi-v2-to-wrekenfile.js} +0 -0
- /package/dist/{postman-to-wrekenfile.d.ts → v1/postman-to-wrekenfile.d.ts} +0 -0
- /package/dist/{wrekenfile-validator.d.ts → v1/wrekenfile-validator.d.ts} +0 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrekenfile version to use for v2 converters
|
|
3
|
+
*/
|
|
4
|
+
export declare const WREKENFILE_VERSION = "2.1.0";
|
|
5
|
+
/**
|
|
6
|
+
* Default base URL when none can be extracted
|
|
7
|
+
*/
|
|
8
|
+
export declare const DEFAULT_BASE_URL = "https://api.default.com";
|
|
9
|
+
/**
|
|
10
|
+
* Common base URL variable names in Postman collections
|
|
11
|
+
*/
|
|
12
|
+
export declare const BASE_URL_VARIABLE_NAMES: string[];
|
|
13
|
+
/**
|
|
14
|
+
* Sensitive keys that should be masked in DEFAULTS
|
|
15
|
+
*/
|
|
16
|
+
export declare const SENSITIVE_KEYS: string[];
|
|
17
|
+
/**
|
|
18
|
+
* YAML dump options
|
|
19
|
+
*/
|
|
20
|
+
export declare const YAML_DUMP_OPTIONS: {
|
|
21
|
+
indent: number;
|
|
22
|
+
lineWidth: number;
|
|
23
|
+
noRefs: boolean;
|
|
24
|
+
sortKeys: boolean;
|
|
25
|
+
quotingType: "\"";
|
|
26
|
+
forceQuotes: boolean;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Execution mode constants
|
|
30
|
+
*/
|
|
31
|
+
export declare const EXECUTION_MODE_ASYNC = "async";
|
|
32
|
+
/**
|
|
33
|
+
* ASYNC section constants
|
|
34
|
+
*/
|
|
35
|
+
export declare const ASYNC_RETURNS_RESULT = "result";
|
|
36
|
+
/**
|
|
37
|
+
* Type constants
|
|
38
|
+
*/
|
|
39
|
+
export declare const TYPE_VOID = "VOID";
|
|
40
|
+
export declare const TYPE_ANY = "ANY";
|
|
41
|
+
/**
|
|
42
|
+
* Body type constants
|
|
43
|
+
*/
|
|
44
|
+
export declare const BODYTYPE_RAW = "raw";
|
|
45
|
+
/**
|
|
46
|
+
* Default HTTP scheme
|
|
47
|
+
*/
|
|
48
|
+
export declare const DEFAULT_HTTP_SCHEME = "https";
|
|
49
|
+
/**
|
|
50
|
+
* YAML document separators to remove
|
|
51
|
+
*/
|
|
52
|
+
export declare const YAML_DOCUMENT_SEPARATOR_START = "---";
|
|
53
|
+
export declare const YAML_DOCUMENT_SEPARATOR_END = "...";
|
|
54
|
+
export declare const YAML_SEPARATOR_LINES: string[];
|
|
55
|
+
/**
|
|
56
|
+
* Method group type prefixes
|
|
57
|
+
*/
|
|
58
|
+
export declare const GROUP_PREFIX_HTTP = "http:";
|
|
59
|
+
export declare const GROUP_PREFIX_SDK = "sdk:";
|
|
60
|
+
export declare const GROUP_PREFIX_OTHER = "other:";
|
|
61
|
+
/**
|
|
62
|
+
* Mini-wrekenfile filename prefix
|
|
63
|
+
*/
|
|
64
|
+
export declare const MINI_FILENAME_PREFIX = "mini-";
|
|
65
|
+
/**
|
|
66
|
+
* YAML file extension
|
|
67
|
+
*/
|
|
68
|
+
export declare const YAML_EXTENSION = ".yaml";
|
|
69
|
+
/**
|
|
70
|
+
* Default mini-wrekenfiles output directory
|
|
71
|
+
*/
|
|
72
|
+
export declare const DEFAULT_MINI_OUTPUT_DIR = "./mini-wrekenfiles";
|
|
73
|
+
/**
|
|
74
|
+
* Filename sanitization regex patterns
|
|
75
|
+
*/
|
|
76
|
+
export declare const FILENAME_INVALID_CHARS: RegExp;
|
|
77
|
+
export declare const FILENAME_MULTIPLE_HYPHENS: RegExp;
|
|
78
|
+
export declare const FILENAME_LEADING_TRAILING_HYPHENS: RegExp;
|
|
79
|
+
export declare const FILENAME_LEADING_SLASHES: RegExp;
|
|
80
|
+
export declare const FILENAME_TRAILING_SLASHES: RegExp;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FILENAME_TRAILING_SLASHES = exports.FILENAME_LEADING_SLASHES = exports.FILENAME_LEADING_TRAILING_HYPHENS = exports.FILENAME_MULTIPLE_HYPHENS = exports.FILENAME_INVALID_CHARS = exports.DEFAULT_MINI_OUTPUT_DIR = exports.YAML_EXTENSION = exports.MINI_FILENAME_PREFIX = exports.GROUP_PREFIX_OTHER = exports.GROUP_PREFIX_SDK = exports.GROUP_PREFIX_HTTP = exports.YAML_SEPARATOR_LINES = exports.YAML_DOCUMENT_SEPARATOR_END = exports.YAML_DOCUMENT_SEPARATOR_START = exports.DEFAULT_HTTP_SCHEME = exports.BODYTYPE_RAW = exports.TYPE_ANY = exports.TYPE_VOID = exports.ASYNC_RETURNS_RESULT = exports.EXECUTION_MODE_ASYNC = exports.YAML_DUMP_OPTIONS = exports.SENSITIVE_KEYS = exports.BASE_URL_VARIABLE_NAMES = exports.DEFAULT_BASE_URL = exports.WREKENFILE_VERSION = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Shared constants for v2 converters
|
|
6
|
+
*/
|
|
7
|
+
const versions_1 = require("../../versions");
|
|
8
|
+
/**
|
|
9
|
+
* Wrekenfile version to use for v2 converters
|
|
10
|
+
*/
|
|
11
|
+
exports.WREKENFILE_VERSION = versions_1.WREKENFILE_V2_VERSION;
|
|
12
|
+
/**
|
|
13
|
+
* Default base URL when none can be extracted
|
|
14
|
+
*/
|
|
15
|
+
exports.DEFAULT_BASE_URL = 'https://api.default.com';
|
|
16
|
+
/**
|
|
17
|
+
* Common base URL variable names in Postman collections
|
|
18
|
+
*/
|
|
19
|
+
exports.BASE_URL_VARIABLE_NAMES = [
|
|
20
|
+
'url',
|
|
21
|
+
'baseUrl',
|
|
22
|
+
'base_url',
|
|
23
|
+
'baseURL',
|
|
24
|
+
'api_url',
|
|
25
|
+
'apiUrl',
|
|
26
|
+
];
|
|
27
|
+
/**
|
|
28
|
+
* Sensitive keys that should be masked in DEFAULTS
|
|
29
|
+
*/
|
|
30
|
+
exports.SENSITIVE_KEYS = [
|
|
31
|
+
'api_key',
|
|
32
|
+
'api-key',
|
|
33
|
+
'x-api-key',
|
|
34
|
+
'signature',
|
|
35
|
+
'x-signature',
|
|
36
|
+
'authorization',
|
|
37
|
+
'token',
|
|
38
|
+
'password',
|
|
39
|
+
'secret',
|
|
40
|
+
];
|
|
41
|
+
/**
|
|
42
|
+
* YAML dump options
|
|
43
|
+
*/
|
|
44
|
+
exports.YAML_DUMP_OPTIONS = {
|
|
45
|
+
indent: 2,
|
|
46
|
+
lineWidth: -1,
|
|
47
|
+
noRefs: true,
|
|
48
|
+
sortKeys: false,
|
|
49
|
+
quotingType: '"',
|
|
50
|
+
forceQuotes: false,
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Execution mode constants
|
|
54
|
+
*/
|
|
55
|
+
exports.EXECUTION_MODE_ASYNC = 'async';
|
|
56
|
+
/**
|
|
57
|
+
* ASYNC section constants
|
|
58
|
+
*/
|
|
59
|
+
exports.ASYNC_RETURNS_RESULT = 'result';
|
|
60
|
+
/**
|
|
61
|
+
* Type constants
|
|
62
|
+
*/
|
|
63
|
+
exports.TYPE_VOID = 'VOID';
|
|
64
|
+
exports.TYPE_ANY = 'ANY';
|
|
65
|
+
/**
|
|
66
|
+
* Body type constants
|
|
67
|
+
*/
|
|
68
|
+
exports.BODYTYPE_RAW = 'raw';
|
|
69
|
+
/**
|
|
70
|
+
* Default HTTP scheme
|
|
71
|
+
*/
|
|
72
|
+
exports.DEFAULT_HTTP_SCHEME = 'https';
|
|
73
|
+
/**
|
|
74
|
+
* YAML document separators to remove
|
|
75
|
+
*/
|
|
76
|
+
exports.YAML_DOCUMENT_SEPARATOR_START = '---';
|
|
77
|
+
exports.YAML_DOCUMENT_SEPARATOR_END = '...';
|
|
78
|
+
exports.YAML_SEPARATOR_LINES = ['===', '___'];
|
|
79
|
+
/**
|
|
80
|
+
* Method group type prefixes
|
|
81
|
+
*/
|
|
82
|
+
exports.GROUP_PREFIX_HTTP = 'http:';
|
|
83
|
+
exports.GROUP_PREFIX_SDK = 'sdk:';
|
|
84
|
+
exports.GROUP_PREFIX_OTHER = 'other:';
|
|
85
|
+
/**
|
|
86
|
+
* Mini-wrekenfile filename prefix
|
|
87
|
+
*/
|
|
88
|
+
exports.MINI_FILENAME_PREFIX = 'mini-';
|
|
89
|
+
/**
|
|
90
|
+
* YAML file extension
|
|
91
|
+
*/
|
|
92
|
+
exports.YAML_EXTENSION = '.yaml';
|
|
93
|
+
/**
|
|
94
|
+
* Default mini-wrekenfiles output directory
|
|
95
|
+
*/
|
|
96
|
+
exports.DEFAULT_MINI_OUTPUT_DIR = './mini-wrekenfiles';
|
|
97
|
+
/**
|
|
98
|
+
* Filename sanitization regex patterns
|
|
99
|
+
*/
|
|
100
|
+
exports.FILENAME_INVALID_CHARS = /[^a-zA-Z0-9-_]/g;
|
|
101
|
+
exports.FILENAME_MULTIPLE_HYPHENS = /-+/g;
|
|
102
|
+
exports.FILENAME_LEADING_TRAILING_HYPHENS = /^-|-$/g;
|
|
103
|
+
exports.FILENAME_LEADING_SLASHES = /^\/+/;
|
|
104
|
+
exports.FILENAME_TRAILING_SLASHES = /\/+$/;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for processing responses in v2 converters
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Generate descriptive RETURNVAR name based on operation and response code
|
|
6
|
+
*/
|
|
7
|
+
export declare function generateReturnVarName(operationId: string, code: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Generate descriptive WHEN clause for error responses with HTTP status code
|
|
10
|
+
*/
|
|
11
|
+
export declare function generateErrorWhen(response: any, code: string): string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared utilities for processing responses in v2 converters
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateReturnVarName = generateReturnVarName;
|
|
7
|
+
exports.generateErrorWhen = generateErrorWhen;
|
|
8
|
+
/**
|
|
9
|
+
* Generate descriptive RETURNVAR name based on operation and response code
|
|
10
|
+
*/
|
|
11
|
+
function generateReturnVarName(operationId, code) {
|
|
12
|
+
const baseName = operationId.replace(/([A-Z])/g, '_$1').toLowerCase().replace(/^_/, '');
|
|
13
|
+
if (code === '200') {
|
|
14
|
+
// For 200 OK, use operation name with _result suffix
|
|
15
|
+
return `${baseName}_result`;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
// For other 2xx codes (201, 202, etc.), use operation name with status code
|
|
19
|
+
return `${baseName}_${code}`;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Generate descriptive WHEN clause for error responses with HTTP status code
|
|
24
|
+
*/
|
|
25
|
+
function generateErrorWhen(response, code) {
|
|
26
|
+
const statusCode = parseInt(code);
|
|
27
|
+
if (response && typeof response === 'object' && response.description) {
|
|
28
|
+
return `${response.description} (HTTP ${code})`;
|
|
29
|
+
}
|
|
30
|
+
else if (statusCode >= 400 && statusCode < 500) {
|
|
31
|
+
return `Client error (HTTP ${code})`;
|
|
32
|
+
}
|
|
33
|
+
else if (statusCode >= 500) {
|
|
34
|
+
return `Server error (HTTP ${code})`;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
return `HTTP ${code}`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function cleanYaml(yamlString: string): string;
|
|
2
|
+
export declare function checkYamlForHiddenChars(yamlString: string): void;
|
|
3
|
+
export declare function validateYaml(yamlString: string): void;
|
|
4
|
+
export declare function removeTypeQuotes(yamlString: string): string;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cleanYaml = cleanYaml;
|
|
4
|
+
exports.checkYamlForHiddenChars = checkYamlForHiddenChars;
|
|
5
|
+
exports.validateYaml = validateYaml;
|
|
6
|
+
exports.removeTypeQuotes = removeTypeQuotes;
|
|
7
|
+
const js_yaml_1 = require("js-yaml");
|
|
8
|
+
const constants_1 = require("./constants");
|
|
9
|
+
const TAB_REPLACEMENT = ' ';
|
|
10
|
+
const NON_BREAKING_SPACE = '\u00A0';
|
|
11
|
+
const NEWLINE = '\n';
|
|
12
|
+
const DOUBLE_NEWLINE = '\n\n';
|
|
13
|
+
const CONTROL_CHARS_REGEX = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g;
|
|
14
|
+
const TAB_REGEX = /\t/g;
|
|
15
|
+
const NON_BREAKING_SPACE_REGEX = /[\u00A0]/g;
|
|
16
|
+
const CRLF_REGEX = /\r\n/g;
|
|
17
|
+
const TRAILING_WHITESPACE_REGEX = /[ \t]+$/gm;
|
|
18
|
+
const EXCESSIVE_NEWLINES_REGEX = /\n{3,}/g;
|
|
19
|
+
const LEADING_WHITESPACE_REGEX = /^\s+/;
|
|
20
|
+
const TRAILING_WHITESPACE_NEWLINES_REGEX = /[\s\n]+$/;
|
|
21
|
+
function cleanYaml(yamlString) {
|
|
22
|
+
let cleaned = yamlString
|
|
23
|
+
.replace(TAB_REGEX, TAB_REPLACEMENT)
|
|
24
|
+
.replace(NON_BREAKING_SPACE_REGEX, ' ')
|
|
25
|
+
.replace(CONTROL_CHARS_REGEX, '')
|
|
26
|
+
.replace(CRLF_REGEX, NEWLINE)
|
|
27
|
+
.replace(TRAILING_WHITESPACE_REGEX, '');
|
|
28
|
+
const lines = cleaned.split(NEWLINE);
|
|
29
|
+
const filteredLines = [];
|
|
30
|
+
let isFirstLine = true;
|
|
31
|
+
for (const line of lines) {
|
|
32
|
+
const trimmed = line.trim();
|
|
33
|
+
if (trimmed === constants_1.YAML_DOCUMENT_SEPARATOR_START && !isFirstLine) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (trimmed === constants_1.YAML_DOCUMENT_SEPARATOR_END) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (constants_1.YAML_SEPARATOR_LINES.includes(trimmed)) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
filteredLines.push(line);
|
|
43
|
+
if (trimmed !== '') {
|
|
44
|
+
isFirstLine = false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
cleaned = filteredLines.join(NEWLINE)
|
|
48
|
+
.replace(EXCESSIVE_NEWLINES_REGEX, DOUBLE_NEWLINE)
|
|
49
|
+
.replace(LEADING_WHITESPACE_REGEX, '')
|
|
50
|
+
.replace(TRAILING_WHITESPACE_NEWLINES_REGEX, '');
|
|
51
|
+
if (cleaned) {
|
|
52
|
+
cleaned += NEWLINE;
|
|
53
|
+
}
|
|
54
|
+
return cleaned;
|
|
55
|
+
}
|
|
56
|
+
function checkYamlForHiddenChars(yamlString) {
|
|
57
|
+
const lines = yamlString.split(NEWLINE);
|
|
58
|
+
for (let i = 0; i < lines.length; i++) {
|
|
59
|
+
const line = lines[i];
|
|
60
|
+
const lineNum = i + 1;
|
|
61
|
+
if (TAB_REGEX.test(line)) {
|
|
62
|
+
throw new Error(`YAML contains a TAB character at line ${lineNum}:\n${line}`);
|
|
63
|
+
}
|
|
64
|
+
if (NON_BREAKING_SPACE_REGEX.test(line)) {
|
|
65
|
+
throw new Error(`YAML contains a non-breaking space (U+00A0) at line ${lineNum}:\n${line}`);
|
|
66
|
+
}
|
|
67
|
+
if (CONTROL_CHARS_REGEX.test(line)) {
|
|
68
|
+
throw new Error(`YAML contains a non-printable character at line ${lineNum}:\n${line}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function validateYaml(yamlString) {
|
|
73
|
+
try {
|
|
74
|
+
(0, js_yaml_1.load)(yamlString);
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
throw new Error(`Generated YAML is invalid: ${e.message}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const BLOCK_SCALAR_REGEX = /^(\s+)(-?\s*)(TYPE|RETURNTYPE):\s*\|\-\s*\n(\s+)(\[\]STRUCT\([^)]+\)|\[\][A-Z]+)/gm;
|
|
81
|
+
const STRUCT_QUOTED_REGEX = /(TYPE|RETURNTYPE):\s*"STRUCT\(([^)]+)\)"/g;
|
|
82
|
+
const ARRAY_TYPE_REGEX = /^(\s+)(-?\s*)(TYPE|RETURNTYPE):\s*(\[\]STRUCT\([^)]+\)|\[\][A-Z]+)(\s*)$/gm;
|
|
83
|
+
const QUOTE_START_REGEX = /^["']/;
|
|
84
|
+
function removeTypeQuotes(yamlString) {
|
|
85
|
+
yamlString = yamlString.replace(BLOCK_SCALAR_REGEX, (match, indent, arrayPrefix, key, valueIndent, value) => {
|
|
86
|
+
return `${indent}${arrayPrefix}${key}: ${value}`;
|
|
87
|
+
});
|
|
88
|
+
yamlString = yamlString.replace(STRUCT_QUOTED_REGEX, '$1: STRUCT($2)');
|
|
89
|
+
yamlString = yamlString.replace(ARRAY_TYPE_REGEX, (match, indent, arrayPrefix, key, value, trailing) => {
|
|
90
|
+
if (!QUOTE_START_REGEX.test(value)) {
|
|
91
|
+
return `${indent}${arrayPrefix}${key}: "${value}"${trailing}`;
|
|
92
|
+
}
|
|
93
|
+
return match;
|
|
94
|
+
});
|
|
95
|
+
return yamlString;
|
|
96
|
+
}
|
package/dist/versions.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_WREKENFILE_VERSION = exports.WREKENFILE_V2_VERSION = exports.WREKENFILE_V1_VERSION = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Wrekenfile version constants
|
|
6
|
+
*/
|
|
7
|
+
exports.WREKENFILE_V1_VERSION = '1.2';
|
|
8
|
+
exports.WREKENFILE_V2_VERSION = '2.1.0';
|
|
9
|
+
/**
|
|
10
|
+
* Get the default version (latest)
|
|
11
|
+
*/
|
|
12
|
+
exports.DEFAULT_WREKENFILE_VERSION = exports.WREKENFILE_V2_VERSION;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wrekenfile-converter",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Convert OpenAPI and Postman specs to Wrekenfile format with mini-chunking for vector DB storage",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
"files": [
|
|
30
30
|
"dist/**/*",
|
|
31
31
|
"README.md",
|
|
32
|
+
"USAGE.md",
|
|
33
|
+
"LOCAL_TESTING.md",
|
|
34
|
+
"QUICK_START.md",
|
|
32
35
|
"wrekenfile.md"
|
|
33
36
|
],
|
|
34
37
|
"exports": {
|
|
@@ -37,20 +40,15 @@
|
|
|
37
40
|
"require": "./dist/index.js",
|
|
38
41
|
"types": "./dist/index.d.ts"
|
|
39
42
|
},
|
|
40
|
-
"./
|
|
41
|
-
"import": "./dist/
|
|
42
|
-
"require": "./dist/
|
|
43
|
-
"types": "./dist/
|
|
43
|
+
"./v1": {
|
|
44
|
+
"import": "./dist/v1/index.js",
|
|
45
|
+
"require": "./dist/v1/index.js",
|
|
46
|
+
"types": "./dist/v1/index.d.ts"
|
|
44
47
|
},
|
|
45
|
-
"./
|
|
46
|
-
"import": "./dist/
|
|
47
|
-
"require": "./dist/
|
|
48
|
-
"types": "./dist/
|
|
49
|
-
},
|
|
50
|
-
"./converter-postman": {
|
|
51
|
-
"import": "./dist/postman-to-wrekenfile.js",
|
|
52
|
-
"require": "./dist/postman-to-wrekenfile.js",
|
|
53
|
-
"types": "./dist/postman-to-wrekenfile.d.ts"
|
|
48
|
+
"./v2": {
|
|
49
|
+
"import": "./dist/v2/index.js",
|
|
50
|
+
"require": "./dist/v2/index.js",
|
|
51
|
+
"types": "./dist/v2/index.d.ts"
|
|
54
52
|
},
|
|
55
53
|
"./validator": {
|
|
56
54
|
"import": "./dist/wrekenfile-validator.js",
|
|
File without changes
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Defensive fixes for OpenAPI v3 schema traversal
|
|
3
|
-
// 1. Guard all property accesses ($ref, type, properties, items, allOf, oneOf, anyOf) with checks for existence and correct type
|
|
4
|
-
// 2. Guard all calls to getTypeFromSchema or similar with checks for defined/object
|
|
5
|
-
// 3. Apply these checks in all recursive struct extraction and interface extraction logic
|
|
6
|
-
// Example for a recursive schema traversal:
|
|
7
|
-
// if (schema && typeof schema === 'object' && schema.$ref) { ... }
|
|
8
|
-
// if (prop && typeof prop === 'object' && prop.type === 'array' && prop.items) { ... }
|
|
9
|
-
// ...
|
|
10
|
-
// Please apply these patterns throughout the file, especially in struct extraction and interface extraction functions.
|