@skmtc/core 0.58.3 → 0.58.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/esm/context/BuiltOnRead.d.ts +37 -0
- package/esm/context/BuiltOnRead.js +199 -0
- package/esm/context/CoreContext.js +11 -5
- package/esm/context/GenerateContext.js +8 -1
- package/esm/context/ParseContext.js +116 -11
- package/esm/context/Subject.d.ts +29 -2
- package/esm/context/Subject.js +67 -6
- package/esm/oas/document/Document.d.ts +5 -1
- package/esm/oas/document/Document.js +10 -1
- package/esm/oas/document/documentSource.d.ts +37 -0
- package/esm/oas/document/documentSource.js +27 -0
- package/esm/parse/v3-0/operation/toOperationsV3.d.ts +14 -0
- package/esm/parse/v3-0/operation/toOperationsV3.js +68 -67
- package/esm/parse/v3-1/operation/toOperationsV3.d.ts +14 -0
- package/esm/parse/v3-1/operation/toOperationsV3.js +68 -67
- package/esm/parse/v3-2/operation/toOperationsV3.d.ts +14 -0
- package/esm/parse/v3-2/operation/toOperationsV3.js +69 -68
- package/package.json +1 -1
- package/script/context/BuiltOnRead.d.ts +37 -0
- package/script/context/BuiltOnRead.js +203 -0
- package/script/context/CoreContext.js +11 -5
- package/script/context/GenerateContext.js +8 -1
- package/script/context/ParseContext.js +116 -11
- package/script/context/Subject.d.ts +29 -2
- package/script/context/Subject.js +67 -6
- package/script/oas/document/Document.d.ts +5 -1
- package/script/oas/document/Document.js +10 -1
- package/script/oas/document/documentSource.d.ts +37 -0
- package/script/oas/document/documentSource.js +36 -0
- package/script/parse/v3-0/operation/toOperationsV3.d.ts +14 -0
- package/script/parse/v3-0/operation/toOperationsV3.js +71 -69
- package/script/parse/v3-1/operation/toOperationsV3.d.ts +14 -0
- package/script/parse/v3-1/operation/toOperationsV3.js +71 -69
- package/script/parse/v3-2/operation/toOperationsV3.d.ts +14 -0
- package/script/parse/v3-2/operation/toOperationsV3.js +72 -70
|
@@ -55,75 +55,76 @@ export const toOperationsV3 = ({ paths, stackTrail, context }) => {
|
|
|
55
55
|
if (!paths) {
|
|
56
56
|
return [];
|
|
57
57
|
}
|
|
58
|
-
return Object.entries(paths).flatMap(([path, pathItem]) => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
58
|
+
return Object.entries(paths).flatMap(([path, pathItem]) => stackTrail.trace(path, pathStack => pathItem ? toPathOperationsV3({ path, pathItem, stackTrail: pathStack, context }) : []));
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* The operations of the path item at `path`. They share one parsed path
|
|
62
|
+
* item. With `method`, only the operation at that method is parsed.
|
|
63
|
+
*/
|
|
64
|
+
export const toPathOperationsV3 = ({ path, pathItem, stackTrail: pathStack, context, method: only }) => {
|
|
65
|
+
const fixedFields = dropAdditionalOperationsV3({ pathItem, stackTrail: pathStack, context });
|
|
66
|
+
const cleaned = Object.entries(fixedFields).reduce(({ rest, methodObject }, [key, operation]) => {
|
|
67
|
+
const method = toPathItemMethod(key);
|
|
68
|
+
if (method) {
|
|
69
|
+
const { [method]: _deleted, ...remaining } = rest;
|
|
70
|
+
return {
|
|
71
|
+
rest: remaining,
|
|
72
|
+
methodObject: {
|
|
73
|
+
...methodObject,
|
|
74
|
+
[method]: operation
|
|
75
75
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const normalized = error instanceof Error ? error : new Error(String(error));
|
|
114
|
-
context.logIssueNoKey({
|
|
115
|
-
parent: operation,
|
|
116
|
-
level: 'error',
|
|
117
|
-
message: normalized.message,
|
|
118
|
-
cause: normalized,
|
|
119
|
-
stackTrail: st,
|
|
120
|
-
type: 'INVALID_OPERATION'
|
|
121
|
-
});
|
|
122
|
-
return undefined;
|
|
123
|
-
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return { rest, methodObject };
|
|
79
|
+
}, {
|
|
80
|
+
rest: fixedFields,
|
|
81
|
+
methodObject: {}
|
|
82
|
+
});
|
|
83
|
+
const pathItemResult = !isEmpty(cleaned.rest)
|
|
84
|
+
? toPathItemV3({ pathItem: cleaned.rest, stackTrail: pathStack, context })
|
|
85
|
+
: undefined;
|
|
86
|
+
const pathItemObject = pathItemResult?.pathItem;
|
|
87
|
+
const brokenParameters = pathItemResult?.brokenParameters ?? [];
|
|
88
|
+
return Object.entries(cleaned.methodObject)
|
|
89
|
+
.filter(([method]) => only === undefined || method === only)
|
|
90
|
+
.map(([method, operation]) => {
|
|
91
|
+
// Use `pathStack` (the trail with `path` already pushed),
|
|
92
|
+
// not the outer `stackTrail` — otherwise downstream traces
|
|
93
|
+
// record paths:<method>:... and lose the actual path
|
|
94
|
+
// segment, which breaks `OasDocument.removeItem` and the
|
|
95
|
+
// dependency-ref invalidation it backs.
|
|
96
|
+
return pathStack.trace(method, st => {
|
|
97
|
+
if (!operation) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (isDroppedByPathParameter({ brokenParameters, operation, stackTrail: st, context })) {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
return toOperationV3({
|
|
105
|
+
operation,
|
|
106
|
+
operationInfo: {
|
|
107
|
+
method: method,
|
|
108
|
+
path,
|
|
109
|
+
pathItem: pathItemObject
|
|
110
|
+
},
|
|
111
|
+
stackTrail: st,
|
|
112
|
+
context
|
|
124
113
|
});
|
|
125
|
-
}
|
|
126
|
-
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
const normalized = error instanceof Error ? error : new Error(String(error));
|
|
117
|
+
context.logIssueNoKey({
|
|
118
|
+
parent: operation,
|
|
119
|
+
level: 'error',
|
|
120
|
+
message: normalized.message,
|
|
121
|
+
cause: normalized,
|
|
122
|
+
stackTrail: st,
|
|
123
|
+
type: 'INVALID_OPERATION'
|
|
124
|
+
});
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
127
|
});
|
|
128
|
-
})
|
|
128
|
+
})
|
|
129
|
+
.filter((item) => Boolean(item));
|
|
129
130
|
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In a run with `onArtifact`, the operations and the component schemas that
|
|
3
|
+
* pass 1 parsed are let go once the file plan is built. Each is built again
|
|
4
|
+
* from the input document when a generator reads it, and let go after the
|
|
5
|
+
* last subject that can read it. Internal: `mod.ts` does not list this file.
|
|
6
|
+
*/
|
|
7
|
+
import type { OasDocument } from '../oas/document/Document.js';
|
|
8
|
+
import type { Reach } from '../parse/Reach.js';
|
|
9
|
+
import type { PlannedSubject } from './Subject.js';
|
|
10
|
+
type BuiltOnReadArgs = {
|
|
11
|
+
document: OasDocument;
|
|
12
|
+
/** The subjects of the run, in the order their steps run. */
|
|
13
|
+
subjects: PlannedSubject[];
|
|
14
|
+
reach: Reach;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The run's operations and component schemas, built when read. `start` and
|
|
18
|
+
* `finish` go round each step, as `FilePlan.finish` does.
|
|
19
|
+
*/
|
|
20
|
+
export declare class BuiltOnRead {
|
|
21
|
+
#private;
|
|
22
|
+
private constructor();
|
|
23
|
+
/**
|
|
24
|
+
* Lets the parsed operations and component schemas of `document` go, or
|
|
25
|
+
* returns `undefined` when its parse context builds nothing again (a run
|
|
26
|
+
* without `onArtifact`). Call it once the file plan is built.
|
|
27
|
+
*/
|
|
28
|
+
static start({ document, subjects, reach }: BuiltOnReadArgs): BuiltOnRead | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* `subject`'s step starts. The first read of its operation in the step
|
|
31
|
+
* builds it, and every generator of the step gets that object.
|
|
32
|
+
*/
|
|
33
|
+
start(subject: PlannedSubject): void;
|
|
34
|
+
/** `subject`'s step has run: its operation goes, and each schema no subject left reaches. */
|
|
35
|
+
finish(subject: PlannedSubject): void;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _BuiltOnRead_schemas, _OperationsOnRead_instances, _OperationsOnRead_source, _OperationsOnRead_places, _OperationsOnRead_held, _OperationsOnRead_listed, _OperationsOnRead_list, _SchemasOnRead_instances, _SchemasOnRead_source, _SchemasOnRead_reach, _SchemasOnRead_names, _SchemasOnRead_built, _SchemasOnRead_readInStep, _SchemasOnRead_named, _SchemasOnRead_namedLeft, _SchemasOnRead_reachedLeft, _SchemasOnRead_read, _SchemasOnRead_toReached;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.BuiltOnRead = void 0;
|
|
16
|
+
const Subject_js_1 = require("./Subject.js");
|
|
17
|
+
const refFns_js_1 = require("../helpers/refFns.js");
|
|
18
|
+
const documentSource_js_1 = require("../oas/document/documentSource.js");
|
|
19
|
+
/**
|
|
20
|
+
* The run's operations and component schemas, built when read. `start` and
|
|
21
|
+
* `finish` go round each step, as `FilePlan.finish` does.
|
|
22
|
+
*/
|
|
23
|
+
class BuiltOnRead {
|
|
24
|
+
constructor(schemas) {
|
|
25
|
+
_BuiltOnRead_schemas.set(this, void 0);
|
|
26
|
+
__classPrivateFieldSet(this, _BuiltOnRead_schemas, schemas, "f");
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Lets the parsed operations and component schemas of `document` go, or
|
|
30
|
+
* returns `undefined` when its parse context builds nothing again (a run
|
|
31
|
+
* without `onArtifact`). Call it once the file plan is built.
|
|
32
|
+
*/
|
|
33
|
+
static start({ document, subjects, reach }) {
|
|
34
|
+
const source = (0, documentSource_js_1.toDocumentSource)(document);
|
|
35
|
+
if (source === undefined) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
const operations = new OperationsOnRead({ document, source });
|
|
39
|
+
subjects.forEach(subject => {
|
|
40
|
+
if (subject instanceof Subject_js_1.OasOperationSubject) {
|
|
41
|
+
subject.buildOnRead(operations);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return new BuiltOnRead(new SchemasOnRead({ document, source, subjects, reach }));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* `subject`'s step starts. The first read of its operation in the step
|
|
48
|
+
* builds it, and every generator of the step gets that object.
|
|
49
|
+
*/
|
|
50
|
+
start(subject) {
|
|
51
|
+
if (subject instanceof Subject_js_1.OasOperationSubject) {
|
|
52
|
+
subject.startStep();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** `subject`'s step has run: its operation goes, and each schema no subject left reaches. */
|
|
56
|
+
finish(subject) {
|
|
57
|
+
if (subject instanceof Subject_js_1.OasOperationSubject) {
|
|
58
|
+
subject.finishStep();
|
|
59
|
+
}
|
|
60
|
+
__classPrivateFieldGet(this, _BuiltOnRead_schemas, "f").finish(subject);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.BuiltOnRead = BuiltOnRead;
|
|
64
|
+
_BuiltOnRead_schemas = new WeakMap();
|
|
65
|
+
/** The key of an operation's place. A method has no space in it. */
|
|
66
|
+
const toPlaceKey = ({ path, method }) => `${method} ${path}`;
|
|
67
|
+
/**
|
|
68
|
+
* The operations of a document, built when a step loads one. Listing
|
|
69
|
+
* `document.operations` builds every one and keeps it for the rest of the
|
|
70
|
+
* run: a subject's operation is then the listed object.
|
|
71
|
+
*/
|
|
72
|
+
class OperationsOnRead {
|
|
73
|
+
constructor({ document, source }) {
|
|
74
|
+
_OperationsOnRead_instances.add(this);
|
|
75
|
+
_OperationsOnRead_source.set(this, void 0);
|
|
76
|
+
/** The place of each operation pass 1 kept, in document order. */
|
|
77
|
+
_OperationsOnRead_places.set(this, void 0);
|
|
78
|
+
/** The operations loaded and not let go yet. */
|
|
79
|
+
_OperationsOnRead_held.set(this, new Map()
|
|
80
|
+
/** Every operation, once they are listed. */
|
|
81
|
+
);
|
|
82
|
+
/** Every operation, once they are listed. */
|
|
83
|
+
_OperationsOnRead_listed.set(this, void 0);
|
|
84
|
+
__classPrivateFieldSet(this, _OperationsOnRead_source, source, "f");
|
|
85
|
+
const operations = document.operations;
|
|
86
|
+
__classPrivateFieldSet(this, _OperationsOnRead_places, operations.map(({ path, method }) => ({ path, method })), "f");
|
|
87
|
+
// The getter gives the document's own array: emptying it lets the parsed operations go.
|
|
88
|
+
operations.splice(0);
|
|
89
|
+
(0, documentSource_js_1.setUnlistedOperations)(document, () => __classPrivateFieldGet(this, _OperationsOnRead_instances, "m", _OperationsOnRead_list).call(this));
|
|
90
|
+
}
|
|
91
|
+
load(place) {
|
|
92
|
+
const key = toPlaceKey(place);
|
|
93
|
+
const found = __classPrivateFieldGet(this, _OperationsOnRead_listed, "f")?.get(key) ?? __classPrivateFieldGet(this, _OperationsOnRead_held, "f").get(key);
|
|
94
|
+
if (found !== undefined) {
|
|
95
|
+
return found;
|
|
96
|
+
}
|
|
97
|
+
const operation = __classPrivateFieldGet(this, _OperationsOnRead_source, "f").toOperation(place);
|
|
98
|
+
__classPrivateFieldGet(this, _OperationsOnRead_held, "f").set(key, operation);
|
|
99
|
+
return operation;
|
|
100
|
+
}
|
|
101
|
+
letGo(place) {
|
|
102
|
+
__classPrivateFieldGet(this, _OperationsOnRead_held, "f").delete(toPlaceKey(place));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
_OperationsOnRead_source = new WeakMap(), _OperationsOnRead_places = new WeakMap(), _OperationsOnRead_held = new WeakMap(), _OperationsOnRead_listed = new WeakMap(), _OperationsOnRead_instances = new WeakSet(), _OperationsOnRead_list = function _OperationsOnRead_list() {
|
|
106
|
+
const operations = __classPrivateFieldGet(this, _OperationsOnRead_places, "f").map(place => this.load(place));
|
|
107
|
+
__classPrivateFieldSet(this, _OperationsOnRead_listed, new Map(operations.map(operation => [toPlaceKey(operation), operation])), "f");
|
|
108
|
+
__classPrivateFieldGet(this, _OperationsOnRead_held, "f").clear();
|
|
109
|
+
return operations;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* The component schemas of a document, built when read. `components.schemas`
|
|
113
|
+
* keeps its names in their order, and each entry is built when it is read. A
|
|
114
|
+
* built schema is kept while a subject left to run reaches it, and while the
|
|
115
|
+
* step that read it runs. A read after that builds it again.
|
|
116
|
+
*
|
|
117
|
+
* The count is the plan's two-step count: by a model's key, how many
|
|
118
|
+
* subjects left name it; by a schema's name, how many named models with
|
|
119
|
+
* subjects left reach it.
|
|
120
|
+
*/
|
|
121
|
+
class SchemasOnRead {
|
|
122
|
+
constructor({ document, source, subjects, reach }) {
|
|
123
|
+
_SchemasOnRead_instances.add(this);
|
|
124
|
+
_SchemasOnRead_source.set(this, void 0);
|
|
125
|
+
_SchemasOnRead_reach.set(this, void 0);
|
|
126
|
+
/** The names of the schemas, which are their model keys. */
|
|
127
|
+
_SchemasOnRead_names.set(this, void 0);
|
|
128
|
+
_SchemasOnRead_built.set(this, new Map()
|
|
129
|
+
/** The schemas built in this step that no subject left reaches. */
|
|
130
|
+
);
|
|
131
|
+
/** The schemas built in this step that no subject left reaches. */
|
|
132
|
+
_SchemasOnRead_readInStep.set(this, new Set());
|
|
133
|
+
_SchemasOnRead_named.set(this, new Map()
|
|
134
|
+
/** By a model's key: how many subjects that name it are left to run. */
|
|
135
|
+
);
|
|
136
|
+
/** By a model's key: how many subjects that name it are left to run. */
|
|
137
|
+
_SchemasOnRead_namedLeft.set(this, new Map()
|
|
138
|
+
/** By a schema's name: how many named models with subjects left reach it. */
|
|
139
|
+
);
|
|
140
|
+
/** By a schema's name: how many named models with subjects left reach it. */
|
|
141
|
+
_SchemasOnRead_reachedLeft.set(this, new Map());
|
|
142
|
+
__classPrivateFieldSet(this, _SchemasOnRead_source, source, "f");
|
|
143
|
+
__classPrivateFieldSet(this, _SchemasOnRead_reach, reach, "f");
|
|
144
|
+
const record = document.components?.schemas ?? {};
|
|
145
|
+
const names = document.components?.toSchemasRefNames() ?? [];
|
|
146
|
+
__classPrivateFieldSet(this, _SchemasOnRead_names, new Set(names), "f");
|
|
147
|
+
subjects.forEach(subject => {
|
|
148
|
+
const named = subject.toNamedModels(reach);
|
|
149
|
+
named.forEach(key => {
|
|
150
|
+
const namedLeft = __classPrivateFieldGet(this, _SchemasOnRead_namedLeft, "f").get(key) ?? 0;
|
|
151
|
+
if (namedLeft === 0) {
|
|
152
|
+
__classPrivateFieldGet(this, _SchemasOnRead_instances, "m", _SchemasOnRead_toReached).call(this, key).forEach(name => {
|
|
153
|
+
__classPrivateFieldGet(this, _SchemasOnRead_reachedLeft, "f").set(name, (__classPrivateFieldGet(this, _SchemasOnRead_reachedLeft, "f").get(name) ?? 0) + 1);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
__classPrivateFieldGet(this, _SchemasOnRead_namedLeft, "f").set(key, namedLeft + 1);
|
|
157
|
+
});
|
|
158
|
+
__classPrivateFieldGet(this, _SchemasOnRead_named, "f").set(subject, named);
|
|
159
|
+
});
|
|
160
|
+
// Each entry becomes a getter at its own position, so the names keep
|
|
161
|
+
// their order, and the parsed schema it held is let go.
|
|
162
|
+
names.forEach(name => {
|
|
163
|
+
Object.defineProperty(record, name, {
|
|
164
|
+
get: () => __classPrivateFieldGet(this, _SchemasOnRead_instances, "m", _SchemasOnRead_read).call(this, name),
|
|
165
|
+
enumerable: true,
|
|
166
|
+
configurable: true
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
finish(subject) {
|
|
171
|
+
const named = __classPrivateFieldGet(this, _SchemasOnRead_named, "f").get(subject) ?? [];
|
|
172
|
+
__classPrivateFieldGet(this, _SchemasOnRead_named, "f").delete(subject);
|
|
173
|
+
named.forEach(key => {
|
|
174
|
+
const namedLeft = (__classPrivateFieldGet(this, _SchemasOnRead_namedLeft, "f").get(key) ?? 0) - 1;
|
|
175
|
+
__classPrivateFieldGet(this, _SchemasOnRead_namedLeft, "f").set(key, namedLeft);
|
|
176
|
+
if (namedLeft === 0) {
|
|
177
|
+
__classPrivateFieldGet(this, _SchemasOnRead_instances, "m", _SchemasOnRead_toReached).call(this, key).forEach(name => {
|
|
178
|
+
const reachedLeft = (__classPrivateFieldGet(this, _SchemasOnRead_reachedLeft, "f").get(name) ?? 0) - 1;
|
|
179
|
+
__classPrivateFieldGet(this, _SchemasOnRead_reachedLeft, "f").set(name, reachedLeft);
|
|
180
|
+
if (reachedLeft === 0) {
|
|
181
|
+
__classPrivateFieldGet(this, _SchemasOnRead_built, "f").delete(name);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
__classPrivateFieldGet(this, _SchemasOnRead_readInStep, "f").forEach(name => __classPrivateFieldGet(this, _SchemasOnRead_built, "f").delete(name));
|
|
187
|
+
__classPrivateFieldGet(this, _SchemasOnRead_readInStep, "f").clear();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
_SchemasOnRead_source = new WeakMap(), _SchemasOnRead_reach = new WeakMap(), _SchemasOnRead_names = new WeakMap(), _SchemasOnRead_built = new WeakMap(), _SchemasOnRead_readInStep = new WeakMap(), _SchemasOnRead_named = new WeakMap(), _SchemasOnRead_namedLeft = new WeakMap(), _SchemasOnRead_reachedLeft = new WeakMap(), _SchemasOnRead_instances = new WeakSet(), _SchemasOnRead_read = function _SchemasOnRead_read(name) {
|
|
191
|
+
const found = __classPrivateFieldGet(this, _SchemasOnRead_built, "f").get(name);
|
|
192
|
+
if (found !== undefined) {
|
|
193
|
+
return found;
|
|
194
|
+
}
|
|
195
|
+
const schema = __classPrivateFieldGet(this, _SchemasOnRead_source, "f").toSchema(name);
|
|
196
|
+
__classPrivateFieldGet(this, _SchemasOnRead_built, "f").set(name, schema);
|
|
197
|
+
if ((__classPrivateFieldGet(this, _SchemasOnRead_reachedLeft, "f").get(name) ?? 0) === 0) {
|
|
198
|
+
__classPrivateFieldGet(this, _SchemasOnRead_readInStep, "f").add(name);
|
|
199
|
+
}
|
|
200
|
+
return schema;
|
|
201
|
+
}, _SchemasOnRead_toReached = function _SchemasOnRead_toReached(key) {
|
|
202
|
+
return __classPrivateFieldGet(this, _SchemasOnRead_reach, "f").ofModel((0, refFns_js_1.fromModelKey)(key)).filter(model => __classPrivateFieldGet(this, _SchemasOnRead_names, "f").has(model));
|
|
203
|
+
};
|
|
@@ -65,6 +65,7 @@ const colors_js_1 = require("../deps/jsr.io/@std/fmt/1.0.10/colors.js");
|
|
|
65
65
|
const SerializedError_js_1 = require("../types/SerializedError.js");
|
|
66
66
|
const toGenerationFailure_js_1 = require("./toGenerationFailure.js");
|
|
67
67
|
const toCountPhrase_js_1 = require("../helpers/toCountPhrase.js");
|
|
68
|
+
const documentSource_js_1 = require("../oas/document/documentSource.js");
|
|
68
69
|
/**
|
|
69
70
|
* The main orchestration class for the SKMTC transformation pipeline.
|
|
70
71
|
*
|
|
@@ -346,7 +347,12 @@ class CoreContext {
|
|
|
346
347
|
__classPrivateFieldSet(this, _CoreContext_phaseName, 'parse', "f");
|
|
347
348
|
__classPrivateFieldSet(this, _CoreContext_parseIssues, [], "f");
|
|
348
349
|
__classPrivateFieldSet(this, _CoreContext_enrichmentWarnings, [], "f");
|
|
349
|
-
|
|
350
|
+
// A capturing render and an inspection read every file at the end
|
|
351
|
+
// of the run, so such a run gives no file before then. A run that
|
|
352
|
+
// gives files early can build its operations and schemas again when
|
|
353
|
+
// a generator reads them, so the parse context knows it first.
|
|
354
|
+
const givesFilesEarly = onArtifact !== undefined && !attribution?.postPass && !inspect;
|
|
355
|
+
const phase = __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupParsePhase).call(this, document, settings, givesFilesEarly);
|
|
350
356
|
__classPrivateFieldSet(this, _CoreContext_phase, phase, "f");
|
|
351
357
|
__classPrivateFieldSet(this, _CoreContext_parseIssues, phase.context.issues, "f");
|
|
352
358
|
const parsedDocument = stackTrail.trace('parse', st => phase.context.parse(st));
|
|
@@ -372,9 +378,6 @@ class CoreContext {
|
|
|
372
378
|
captureChannel
|
|
373
379
|
});
|
|
374
380
|
__classPrivateFieldSet(this, _CoreContext_phase, generatePhase, "f");
|
|
375
|
-
// A capturing render and an inspection read every file at the end
|
|
376
|
-
// of the run, so such a run gives no file before then.
|
|
377
|
-
const givesFilesEarly = onArtifact !== undefined && !attribution?.postPass && !inspect;
|
|
378
381
|
const generated = generatePhase.context.toArtifacts(st, givesFilesEarly
|
|
379
382
|
? {
|
|
380
383
|
reach: phase.context.toReach(),
|
|
@@ -678,7 +681,7 @@ _CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreC
|
|
|
678
681
|
throw new Error(`Unhandled protocol type: ${JSON.stringify(_exhaustive)}`);
|
|
679
682
|
}
|
|
680
683
|
}
|
|
681
|
-
}, _CoreContext_setupParsePhase = function _CoreContext_setupParsePhase(input, settings) {
|
|
684
|
+
}, _CoreContext_setupParsePhase = function _CoreContext_setupParsePhase(input, settings, planned = false) {
|
|
682
685
|
if (settings?.parse && settings.system) {
|
|
683
686
|
this.logger.warn('settings.parse and settings.system are both set: settings.parse is used and settings.system is ignored. ' +
|
|
684
687
|
'settings.system is the deprecated name of settings.parse; remove it.');
|
|
@@ -689,6 +692,9 @@ _CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreC
|
|
|
689
692
|
silent: this.silent,
|
|
690
693
|
system: settings?.parse ?? settings?.system
|
|
691
694
|
});
|
|
695
|
+
if (planned) {
|
|
696
|
+
(0, documentSource_js_1.markPlannedParse)(parseContext);
|
|
697
|
+
}
|
|
692
698
|
return { type: 'parse', context: parseContext };
|
|
693
699
|
}, _CoreContext_setupGeneratePhase = function _CoreContext_setupGeneratePhase({ document, settings, toGeneratorConfigMap, captureChannel }) {
|
|
694
700
|
const generateContext = new GenerateContext_js_1.GenerateContext({
|
|
@@ -33,6 +33,7 @@ const Variant_js_1 = require("../types/Variant.js");
|
|
|
33
33
|
const toVariantList_js_1 = require("../helpers/toVariantList.js");
|
|
34
34
|
const Subject_js_1 = require("./Subject.js");
|
|
35
35
|
const FilePlan_js_1 = require("./FilePlan.js");
|
|
36
|
+
const BuiltOnRead_js_1 = require("./BuiltOnRead.js");
|
|
36
37
|
var Subject_js_2 = require("./Subject.js");
|
|
37
38
|
Object.defineProperty(exports, "toGqlOperationSource", { enumerable: true, get: function () { return Subject_js_2.toGqlOperationSource; } });
|
|
38
39
|
Object.defineProperty(exports, "toModelSource", { enumerable: true, get: function () { return Subject_js_2.toModelSource; } });
|
|
@@ -1036,11 +1037,17 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1036
1037
|
...(readyAfter.get(0) ?? []),
|
|
1037
1038
|
...modelSteps.flatMap((step, index) => [step, ...(readyAfter.get(index + 1) ?? [])])
|
|
1038
1039
|
];
|
|
1039
|
-
const
|
|
1040
|
+
const subjects = steps.map(({ subject }) => subject);
|
|
1041
|
+
const plan = this.toFilePlan({ subjects, reach });
|
|
1042
|
+
// The plan asked the pass 1 operations. From here each step builds its
|
|
1043
|
+
// operation again, and each schema is built when it is read.
|
|
1044
|
+
const builtOnRead = BuiltOnRead_js_1.BuiltOnRead.start({ document: oasDocument, subjects, reach });
|
|
1040
1045
|
steps.forEach(step => {
|
|
1046
|
+
builtOnRead?.start(step.subject);
|
|
1041
1047
|
step.run();
|
|
1042
1048
|
// A run that has failed gives no more files: it will write nothing.
|
|
1043
1049
|
const complete = plan.finish(step.subject);
|
|
1050
|
+
builtOnRead?.finish(step.subject);
|
|
1044
1051
|
if (__classPrivateFieldGet(this, _GenerateContext_failedItems, "f").length === 0) {
|
|
1045
1052
|
complete.forEach(path => __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_release).call(this, path, onFile));
|
|
1046
1053
|
}
|