@jentic/arazzo-parser 1.0.0-alpha.3 → 1.0.0-alpha.30

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.
@@ -0,0 +1,25 @@
1
+ import { Resolver, ResolverError } from '@speclynx/apidom-reference/configuration/empty';
2
+ /**
3
+ * @public
4
+ */
5
+ class MemoryResolver extends Resolver {
6
+ constructor() {
7
+ super({
8
+ name: 'memory'
9
+ });
10
+ }
11
+ canRead(file) {
12
+ return file.uri.startsWith('memory://') && this.document !== undefined;
13
+ }
14
+ async read(file) {
15
+ try {
16
+ const encoder = new TextEncoder();
17
+ return encoder.encode(this.document);
18
+ } catch (error) {
19
+ throw new ResolverError(`Error opening file "${file.uri}"`, {
20
+ cause: error
21
+ });
22
+ }
23
+ }
24
+ }
25
+ export default MemoryResolver;
@@ -1,56 +1,91 @@
1
+ import type { ApiDOMReferenceOptions } from '@speclynx/apidom-reference/configuration/empty';
1
2
  import { ParseResultElement } from '@speclynx/apidom-datamodel';
3
+ import type { PartialDeep } from 'type-fest';
2
4
 
3
5
  /**
4
- * Default options for parsing Arazzo Documents.
6
+ * Default reference options for parsing Arazzo Documents.
5
7
  * @public
6
8
  */
7
- export declare const defaultParseOptions: Required<ParseOptions>;
9
+ export declare const defaultParseArazzoOptions: ParseArazzoOptions;
10
+
11
+ /**
12
+ * Default reference options for parsing OpenAPI Documents.
13
+ * @public
14
+ */
15
+ export declare const defaultParseOpenAPIOptions: ParseOpenAPIOptions;
8
16
 
9
17
  /**
10
18
  * Parses an Arazzo Document from an object.
11
19
  * @param source - The Arazzo Document as a plain object
12
- * @param options - Parsing options
20
+ * @param options - Reference options (uses defaultOptions when not provided)
13
21
  * @returns A promise that resolves to the parsed Arazzo Document as ApiDOM data model
22
+ * @throws ParseError - When parsing fails for any reason. The original error is available via the `cause` property.
14
23
  * @public
15
24
  */
16
- export declare function parse(source: Record<string, unknown>, options?: ParseOptions): Promise<ParseResultElement>;
25
+ export declare function parseArazzo(source: Record<string, unknown>, options?: ParseArazzoOptions): Promise<ParseResultElement>;
17
26
 
18
27
  /**
19
28
  * Parses an Arazzo Document from a string or URI.
20
29
  * @param source - The Arazzo Document as string content, or a file system path / HTTP(S) URL
21
- * @param options - Parsing options
30
+ * @param options - Reference options (uses defaultOptions when not provided)
31
+ * @returns A promise that resolves to the parsed Arazzo Document as ApiDOM data model
32
+ * @throws ParseError - When parsing fails for any reason. The original error is available via the `cause` property.
33
+ * @public
34
+ */
35
+ export declare function parseArazzo(source: string, options?: ParseArazzoOptions): Promise<ParseResultElement>;
36
+
37
+ /**
38
+ * Parses an Arazzo Document from a string, object, or URI.
39
+ * @param source - The Arazzo Document as a plain object, string content, or URI
40
+ * @param options - Reference options (uses defaultOptions when not provided)
22
41
  * @returns A promise that resolves to the parsed Arazzo Document as ApiDOM data model
23
42
  * @throws ParseError - When parsing fails for any reason. The original error is available via the `cause` property.
24
43
  * @public
25
44
  */
26
- export declare function parse(source: string, options?: ParseOptions): Promise<ParseResultElement>;
45
+ export declare function parseArazzo(source: string | Record<string, unknown>, options?: ParseArazzoOptions): Promise<ParseResultElement>;
27
46
 
28
47
  /**
29
48
  * Options for parsing Arazzo Documents.
30
49
  * @public
31
50
  */
32
- export declare interface ParseOptions {
33
- /**
34
- * Whether to enforce strict parsing mode.
35
- * Strict parsing mode is using native JSON and YAML parsers without source maps and error recovery.
36
- * @defaultValue true
37
- */
38
- readonly strict?: boolean;
39
- /**
40
- * Whether to include source maps in the parsed result.
41
- * @defaultValue false
42
- */
43
- readonly sourceMap?: boolean;
44
- /**
45
- * Additional options passed to the underlying parsers.
46
- * @defaultValue \{\}
47
- */
48
- readonly parserOpts?: Record<string, unknown>;
49
- /**
50
- * Additional options passed to the underlying resolvers.
51
- * @defaultValue \{\}
52
- */
53
- readonly resolverOpts?: Record<string, unknown>;
54
- }
51
+ export declare type ParseArazzoOptions = PartialDeep<ApiDOMReferenceOptions>;
52
+
53
+ /**
54
+ * Parses an OpenAPI Document from an object.
55
+ * @param source - The OpenAPI Document as a plain object
56
+ * @param options - Reference options (uses defaultOptions when not provided)
57
+ * @returns A promise that resolves to the parsed OpenAPI Document as ApiDOM data model
58
+ * @throws ParseError - When parsing fails for any reason. The original error is available via the `cause` property.
59
+ * @public
60
+ */
61
+ export declare function parseOpenAPI(source: Record<string, unknown>, options?: ParseOpenAPIOptions): Promise<ParseResultElement>;
62
+
63
+ /**
64
+ * Parses an OpenAPI Document from a string or URI.
65
+ * @param source - The OpenAPI Document as string content, or a file system path / HTTP(S) URL
66
+ * @param options - Reference options (uses defaultOptions when not provided)
67
+ * @returns A promise that resolves to the parsed OpenAPI Document as ApiDOM data model
68
+ * @throws ParseError - When parsing fails for any reason. The original error is available via the `cause` property.
69
+ * @public
70
+ */
71
+ export declare function parseOpenAPI(source: string, options?: ParseOpenAPIOptions): Promise<ParseResultElement>;
72
+
73
+ /**
74
+ * Parses an OpenAPI Document from a string, object, or URI.
75
+ * @param source - The OpenAPI Document as a plain object, string content, or URI
76
+ * @param options - Reference options (uses defaultOptions when not provided)
77
+ * @returns A promise that resolves to the parsed OpenAPI Document as ApiDOM data model
78
+ * @throws ParseError - When parsing fails for any reason. The original error is available via the `cause` property.
79
+ * @public
80
+ */
81
+ export declare function parseOpenAPI(source: string | Record<string, unknown>, options?: ParseOpenAPIOptions): Promise<ParseResultElement>;
82
+
83
+ /**
84
+ * Options for parsing OpenAPI Documents.
85
+ * @public
86
+ */
87
+ export declare type ParseOpenAPIOptions = PartialDeep<ApiDOMReferenceOptions>;
88
+
89
+ export { ParseResultElement }
55
90
 
56
91
  export { }
Binary file