@sdcorejs/angular 20.2.0 → 20.2.1
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/components/api-contract-builder/index.d.ts +694 -0
- package/components/badge/index.d.ts +1 -0
- package/components/index.d.ts +1 -0
- package/components/section/index.d.ts +2 -0
- package/fesm2022/sdcorejs-angular-components-api-contract-builder.mjs +3417 -0
- package/fesm2022/sdcorejs-angular-components-api-contract-builder.mjs.map +1 -0
- package/fesm2022/sdcorejs-angular-components-badge.mjs +14 -2
- package/fesm2022/sdcorejs-angular-components-badge.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-operator.mjs +2 -2
- package/fesm2022/sdcorejs-angular-components-operator.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-section.mjs +22 -5
- package/fesm2022/sdcorejs-angular-components-section.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components-table.mjs +14 -13
- package/fesm2022/sdcorejs-angular-components-table.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-components.mjs +1 -0
- package/fesm2022/sdcorejs-angular-components.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-i18n.mjs +405 -0
- package/fesm2022/sdcorejs-angular-i18n.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-modules-icon.mjs.map +1 -1
- package/fesm2022/sdcorejs-angular-modules-layout.mjs +15 -5
- package/fesm2022/sdcorejs-angular-modules-layout.mjs.map +1 -1
- package/i18n/index.d.ts +80 -0
- package/package.json +5 -1
|
@@ -0,0 +1,694 @@
|
|
|
1
|
+
import { SdTemporalValueTransform } from '@sdcorejs/angular/forms/models';
|
|
2
|
+
import * as _angular_core from '@angular/core';
|
|
3
|
+
import { InjectionToken, EnvironmentProviders } from '@angular/core';
|
|
4
|
+
import { SdSideDrawer } from '@sdcorejs/angular/components/side-drawer';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Data-type vocabulary of an API contract.
|
|
8
|
+
*
|
|
9
|
+
* Deliberately NOT reusing `SdQueryBuilderFieldType`: that union describes *filterable* fields in a
|
|
10
|
+
* query UI, this one describes the *shape of transported data*. They drift for different reasons.
|
|
11
|
+
*
|
|
12
|
+
* `date` / `datetime` are **logical** types — in the persisted JSON they are transported as strings,
|
|
13
|
+
* never as a JavaScript `Date`.
|
|
14
|
+
*/
|
|
15
|
+
type SdApiContractDataType = 'string' | 'number' | 'boolean' | 'date' | 'datetime' | 'object' | 'array';
|
|
16
|
+
/** Every type that carries a single value (no `properties`, no `items`). */
|
|
17
|
+
type SdApiContractScalarDataType = Exclude<SdApiContractDataType, 'object' | 'array'>;
|
|
18
|
+
/** Types that may appear as a temporal node and therefore accept `transform`. */
|
|
19
|
+
type SdApiContractTemporalDataType = Extract<SdApiContractDataType, 'date' | 'datetime'>;
|
|
20
|
+
declare const SD_API_CONTRACT_DATA_TYPES: readonly SdApiContractDataType[];
|
|
21
|
+
declare const SD_API_CONTRACT_SCALAR_DATA_TYPES: readonly SdApiContractScalarDataType[];
|
|
22
|
+
declare function sdIsApiContractDataType(value: unknown): value is SdApiContractDataType;
|
|
23
|
+
declare function sdIsApiContractScalarDataType(value: unknown): value is SdApiContractScalarDataType;
|
|
24
|
+
declare function sdIsApiContractTemporalDataType(value: unknown): value is SdApiContractTemporalDataType;
|
|
25
|
+
/**
|
|
26
|
+
* Anything a static literal may be. Mirrors what `JSON.parse` can produce, so a contract always
|
|
27
|
+
* round-trips through `JSON.stringify` without losing information.
|
|
28
|
+
*/
|
|
29
|
+
type SdApiContractJsonValue = string | number | boolean | null | SdApiContractJsonValue[] | {
|
|
30
|
+
[key: string]: SdApiContractJsonValue;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Shared by every node in every layer.
|
|
34
|
+
*
|
|
35
|
+
* `required` is a **tri-state** and lives next to `type` (never a `required: string[]` array on the
|
|
36
|
+
* parent object, the way JSON Schema does it): `undefined` = not declared, `true` = mandatory,
|
|
37
|
+
* `false` = explicitly optional. The serializer omits `undefined` and keeps `false`.
|
|
38
|
+
*/
|
|
39
|
+
interface SdApiContractNodeBase {
|
|
40
|
+
required?: boolean;
|
|
41
|
+
label?: string;
|
|
42
|
+
description?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The two mutually exclusive ways a mapped node receives a value.
|
|
46
|
+
*
|
|
47
|
+
* - `source` — a template referencing `${input.*}` / `${env.*}` / `${res.*}`.
|
|
48
|
+
* - `value` — a static JSON literal.
|
|
49
|
+
*
|
|
50
|
+
* A node carrying both is invalid (`mapping.source-and-value`).
|
|
51
|
+
*/
|
|
52
|
+
interface SdApiContractMapping {
|
|
53
|
+
source?: string;
|
|
54
|
+
value?: SdApiContractJsonValue;
|
|
55
|
+
}
|
|
56
|
+
interface SdApiContractFeScalarNode extends SdApiContractNodeBase {
|
|
57
|
+
type: SdApiContractScalarDataType;
|
|
58
|
+
/** Only meaningful on `date` / `datetime`; reused verbatim from the temporal form controls. */
|
|
59
|
+
transform?: SdTemporalValueTransform;
|
|
60
|
+
}
|
|
61
|
+
interface SdApiContractFeObjectNode extends SdApiContractNodeBase {
|
|
62
|
+
type: 'object';
|
|
63
|
+
properties: Record<string, SdApiContractFeSchemaNode>;
|
|
64
|
+
}
|
|
65
|
+
interface SdApiContractFeArrayNode extends SdApiContractNodeBase {
|
|
66
|
+
type: 'array';
|
|
67
|
+
items: SdApiContractFeSchemaNode;
|
|
68
|
+
}
|
|
69
|
+
/** A pure declaration — no `source` / `value`, because `input` is what the caller hands in. */
|
|
70
|
+
type SdApiContractFeSchemaNode = SdApiContractFeScalarNode | SdApiContractFeObjectNode | SdApiContractFeArrayNode;
|
|
71
|
+
interface SdApiContractRestScalarNode extends SdApiContractNodeBase {
|
|
72
|
+
type: SdApiContractScalarDataType;
|
|
73
|
+
}
|
|
74
|
+
interface SdApiContractRestObjectNode extends SdApiContractNodeBase {
|
|
75
|
+
type: 'object';
|
|
76
|
+
properties: Record<string, SdApiContractRestNode>;
|
|
77
|
+
}
|
|
78
|
+
interface SdApiContractRestArrayNode extends SdApiContractNodeBase {
|
|
79
|
+
type: 'array';
|
|
80
|
+
items: SdApiContractRestNode;
|
|
81
|
+
}
|
|
82
|
+
/** Describes what the backend returns. Never carries a mapping — nothing maps *into* a response. */
|
|
83
|
+
type SdApiContractRestNode = SdApiContractRestScalarNode | SdApiContractRestObjectNode | SdApiContractRestArrayNode;
|
|
84
|
+
interface SdApiContractMappedRestScalarNode extends SdApiContractNodeBase, SdApiContractMapping {
|
|
85
|
+
type: SdApiContractScalarDataType;
|
|
86
|
+
}
|
|
87
|
+
interface SdApiContractMappedRestObjectNode extends SdApiContractNodeBase, SdApiContractMapping {
|
|
88
|
+
type: 'object';
|
|
89
|
+
/** Omitted when the whole object is mapped through `source` / `value`. */
|
|
90
|
+
properties?: Record<string, SdApiContractMappedRestNode>;
|
|
91
|
+
}
|
|
92
|
+
interface SdApiContractMappedRestArrayNode extends SdApiContractNodeBase, SdApiContractMapping {
|
|
93
|
+
type: 'array';
|
|
94
|
+
/** Describes the element type. Per-item projection is intentionally out of scope. */
|
|
95
|
+
items: SdApiContractMappedRestNode;
|
|
96
|
+
}
|
|
97
|
+
type SdApiContractMappedRestNode = SdApiContractMappedRestScalarNode | SdApiContractMappedRestObjectNode | SdApiContractMappedRestArrayNode;
|
|
98
|
+
interface SdApiContractMappedFeScalarNode extends SdApiContractNodeBase, SdApiContractMapping {
|
|
99
|
+
type: SdApiContractScalarDataType;
|
|
100
|
+
transform?: SdTemporalValueTransform;
|
|
101
|
+
}
|
|
102
|
+
interface SdApiContractMappedFeObjectNode extends SdApiContractNodeBase, SdApiContractMapping {
|
|
103
|
+
type: 'object';
|
|
104
|
+
properties?: Record<string, SdApiContractMappedFeSchemaNode>;
|
|
105
|
+
}
|
|
106
|
+
interface SdApiContractMappedFeArrayNode extends SdApiContractNodeBase, SdApiContractMapping {
|
|
107
|
+
type: 'array';
|
|
108
|
+
items: SdApiContractMappedFeSchemaNode;
|
|
109
|
+
}
|
|
110
|
+
type SdApiContractMappedFeSchemaNode = SdApiContractMappedFeScalarNode | SdApiContractMappedFeObjectNode | SdApiContractMappedFeArrayNode;
|
|
111
|
+
/** Structural union of every node shape, for utilities that traverse any layer. */
|
|
112
|
+
type SdApiContractAnyNode = SdApiContractFeSchemaNode | SdApiContractRestNode | SdApiContractMappedRestNode | SdApiContractMappedFeSchemaNode;
|
|
113
|
+
type SdApiContractHttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
114
|
+
declare const SD_API_CONTRACT_HTTP_METHODS: readonly SdApiContractHttpMethod[];
|
|
115
|
+
declare function sdIsApiContractHttpMethod(value: unknown): value is SdApiContractHttpMethod;
|
|
116
|
+
/**
|
|
117
|
+
* The real HTTP request. No `.schema` wrapper on purpose — `req` *is* REST, so it exposes REST
|
|
118
|
+
* structure directly, while `input` / `output` are frontend contracts and keep their `.schema`.
|
|
119
|
+
*/
|
|
120
|
+
interface SdApiContractRequest {
|
|
121
|
+
method: SdApiContractHttpMethod;
|
|
122
|
+
/** May interpolate `${env.*}` and carry REST placeholders such as `{id}`. */
|
|
123
|
+
url: string;
|
|
124
|
+
path?: Record<string, SdApiContractMappedRestNode>;
|
|
125
|
+
query?: Record<string, SdApiContractMappedRestNode>;
|
|
126
|
+
headers?: Record<string, SdApiContractMappedRestNode>;
|
|
127
|
+
body?: SdApiContractMappedRestNode;
|
|
128
|
+
}
|
|
129
|
+
interface SdApiContractResponse {
|
|
130
|
+
/** One success status, or several. Each must be an integer in `100..599`. */
|
|
131
|
+
status: number | number[];
|
|
132
|
+
headers?: Record<string, SdApiContractRestNode>;
|
|
133
|
+
body?: SdApiContractRestNode;
|
|
134
|
+
}
|
|
135
|
+
/** The only `contractVersion` this release understands. */
|
|
136
|
+
declare const SD_API_CONTRACT_VERSION = 1;
|
|
137
|
+
interface SdApiContract {
|
|
138
|
+
contractVersion: 1;
|
|
139
|
+
code: string;
|
|
140
|
+
name: string;
|
|
141
|
+
description?: string;
|
|
142
|
+
input: {
|
|
143
|
+
schema: SdApiContractFeSchemaNode;
|
|
144
|
+
};
|
|
145
|
+
req: SdApiContractRequest;
|
|
146
|
+
res: SdApiContractResponse;
|
|
147
|
+
output: {
|
|
148
|
+
schema: SdApiContractMappedFeSchemaNode;
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
type SdApiContractDiagnosticSeverity = 'error' | 'warning';
|
|
152
|
+
interface SdApiContractDiagnostic {
|
|
153
|
+
/** Stable machine-readable identifier, e.g. `mapping.env.unknown`. Safe to switch on. */
|
|
154
|
+
code: string;
|
|
155
|
+
severity: SdApiContractDiagnosticSeverity;
|
|
156
|
+
/** Structural path into the contract, e.g. `req.body.properties.x`. Never localized. */
|
|
157
|
+
path: string;
|
|
158
|
+
/** Human-readable, English. The UI localizes by `code` when it wants a translated string. */
|
|
159
|
+
message: string;
|
|
160
|
+
}
|
|
161
|
+
/** Roots an expression may address. `output` is never a root — nothing reads from the output. */
|
|
162
|
+
type SdApiContractExpressionRoot = 'input' | 'env' | 'res';
|
|
163
|
+
declare const SD_API_CONTRACT_EXPRESSION_ROOTS: readonly SdApiContractExpressionRoot[];
|
|
164
|
+
/**
|
|
165
|
+
* Where a mapping lives, which decides the roots it may read.
|
|
166
|
+
*
|
|
167
|
+
* - `request` (`req.url` / `path` / `query` / `headers` / `body`) → `input`, `env`.
|
|
168
|
+
* - `output` (`output.schema`) → `res`, `input`, `env`.
|
|
169
|
+
*/
|
|
170
|
+
type SdApiContractMappingContext = 'request' | 'output';
|
|
171
|
+
declare const SD_API_CONTRACT_ALLOWED_ROOTS: Readonly<Record<SdApiContractMappingContext, readonly SdApiContractExpressionRoot[]>>;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Declaration of one global variable a contract may reference as `${env.<key>}`.
|
|
175
|
+
*
|
|
176
|
+
* Definition only — **never a value**. The builder is a design-time tool: it must be able to
|
|
177
|
+
* autocomplete and validate `${env.token}` without the token itself ever entering the app, the
|
|
178
|
+
* component, or the persisted JSON.
|
|
179
|
+
*/
|
|
180
|
+
interface SdApiContractEnvironmentVariable {
|
|
181
|
+
/** Composite env variables are not supported — a global is always a single scalar. */
|
|
182
|
+
type: SdApiContractScalarDataType;
|
|
183
|
+
label?: string;
|
|
184
|
+
description?: string;
|
|
185
|
+
/**
|
|
186
|
+
* Marks a secret (token, api key). The UI badges it and never previews a value — there is no
|
|
187
|
+
* value to preview, so this is purely an authoring signal.
|
|
188
|
+
*/
|
|
189
|
+
sensitive?: boolean;
|
|
190
|
+
}
|
|
191
|
+
interface SdApiContractConfiguration {
|
|
192
|
+
env: Record<string, SdApiContractEnvironmentVariable>;
|
|
193
|
+
}
|
|
194
|
+
/** What the builder falls back to when the host application provides no configuration. */
|
|
195
|
+
declare const SD_API_CONTRACT_EMPTY_CONFIGURATION: SdApiContractConfiguration;
|
|
196
|
+
declare const SD_API_CONTRACT_CONFIGURATION: InjectionToken<SdApiContractConfiguration>;
|
|
197
|
+
/**
|
|
198
|
+
* Registers the env catalog available to every `<sd-api-contract-builder>` in the injector.
|
|
199
|
+
*
|
|
200
|
+
* ```ts
|
|
201
|
+
* provideSdApiContract({
|
|
202
|
+
* env: {
|
|
203
|
+
* baseUrl: { type: 'string', label: 'Backend base URL' },
|
|
204
|
+
* token: { type: 'string', label: 'Access token', sensitive: true },
|
|
205
|
+
* },
|
|
206
|
+
* });
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
declare function provideSdApiContract(configuration: SdApiContractConfiguration): EnvironmentProviders;
|
|
210
|
+
/** Normalizes an optionally-injected configuration into one that is always safe to read. */
|
|
211
|
+
declare function resolveSdApiContractConfiguration(configuration: SdApiContractConfiguration | null | undefined): SdApiContractConfiguration;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* How a `source` string relates to the expression grammar.
|
|
215
|
+
*
|
|
216
|
+
* - `literal` — no `${…}` at all.
|
|
217
|
+
* - `exact` — the whole string is one expression, so the referenced value keeps its own type.
|
|
218
|
+
* - `interpolated` — expressions embedded in surrounding text, so the result is always a string.
|
|
219
|
+
*/
|
|
220
|
+
type SdApiContractTemplateKind = 'literal' | 'exact' | 'interpolated';
|
|
221
|
+
type SdApiContractTemplateErrorCode = 'template.unterminated' | 'template.nested' | 'template.empty' | 'template.invalid-path' | 'template.unknown-root' | 'template.forbidden-segment';
|
|
222
|
+
interface SdApiContractTemplateError {
|
|
223
|
+
code: SdApiContractTemplateErrorCode;
|
|
224
|
+
message: string;
|
|
225
|
+
/** Offset of the `${` that opened the offending expression. */
|
|
226
|
+
index: number;
|
|
227
|
+
raw: string;
|
|
228
|
+
}
|
|
229
|
+
interface SdApiContractExpressionReference {
|
|
230
|
+
root: SdApiContractExpressionRoot;
|
|
231
|
+
/** Segments *after* the root. `${input.customer.id}` → `['customer', 'id']`. */
|
|
232
|
+
path: readonly string[];
|
|
233
|
+
/** The inner text, e.g. `input.customer.id`. */
|
|
234
|
+
expression: string;
|
|
235
|
+
/** The full match including delimiters, e.g. `${input.customer.id}`. */
|
|
236
|
+
raw: string;
|
|
237
|
+
start: number;
|
|
238
|
+
end: number;
|
|
239
|
+
}
|
|
240
|
+
interface SdApiContractTemplate {
|
|
241
|
+
kind: SdApiContractTemplateKind;
|
|
242
|
+
valid: boolean;
|
|
243
|
+
references: readonly SdApiContractExpressionReference[];
|
|
244
|
+
errors: readonly SdApiContractTemplateError[];
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Parses a `source` / URL template into references and errors.
|
|
248
|
+
*
|
|
249
|
+
* Pure string scanning — no `eval`, no `new Function`, no expression evaluation of any kind. The
|
|
250
|
+
* grammar accepts exactly `${<root>.<identifier>(.<identifier>)*}` and nothing else.
|
|
251
|
+
*/
|
|
252
|
+
declare function parseSdApiContractTemplate(source: unknown): SdApiContractTemplate;
|
|
253
|
+
/** The well-formed references of a template. Malformed expressions are dropped, not thrown. */
|
|
254
|
+
declare function extractSdApiContractReferences(source: unknown): readonly SdApiContractExpressionReference[];
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Structural view of a node from any layer (`input.schema`, `req.*`, `res.*`, `output.schema`).
|
|
258
|
+
*
|
|
259
|
+
* The traversal utilities are deliberately layer-agnostic: the four public node unions differ only
|
|
260
|
+
* in which members they *allow*, and every one of them is structurally assignable to this shape.
|
|
261
|
+
* Whether a member is legal where it appears is the validator's job, not the traversal's.
|
|
262
|
+
*/
|
|
263
|
+
interface SdApiContractStructuralNode {
|
|
264
|
+
type: SdApiContractDataType;
|
|
265
|
+
required?: boolean;
|
|
266
|
+
label?: string;
|
|
267
|
+
description?: string;
|
|
268
|
+
transform?: SdTemporalValueTransform;
|
|
269
|
+
source?: string;
|
|
270
|
+
value?: SdApiContractJsonValue;
|
|
271
|
+
properties?: Record<string, SdApiContractStructuralNode>;
|
|
272
|
+
items?: SdApiContractStructuralNode;
|
|
273
|
+
}
|
|
274
|
+
/** A node narrowed to the object shape, so `properties` is safe to read. */
|
|
275
|
+
interface SdApiContractObjectShape extends SdApiContractStructuralNode {
|
|
276
|
+
type: 'object';
|
|
277
|
+
properties: Record<string, SdApiContractStructuralNode>;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Structural pointer into a node tree: alternating `'properties', <key>` and `'items'` segments.
|
|
281
|
+
* The same shape the diagnostics use, so a diagnostic path can drive navigation in the UI.
|
|
282
|
+
*/
|
|
283
|
+
type SdApiContractNodePointer = readonly string[];
|
|
284
|
+
/**
|
|
285
|
+
* One addressable field discovered by traversal.
|
|
286
|
+
*
|
|
287
|
+
* **Path convention:** dot-joined property names. Array items are *flattened under the array's own
|
|
288
|
+
* path* (`items.id`, and for a root array simply `id`), which is what a dropdown / table consumer
|
|
289
|
+
* wants. Set `arrays: 'stop'` to instead get exactly the set of paths an `${…}` expression can
|
|
290
|
+
* address — expressions never index into an array.
|
|
291
|
+
*/
|
|
292
|
+
interface SdApiContractSchemaField {
|
|
293
|
+
path: string;
|
|
294
|
+
segments: readonly string[];
|
|
295
|
+
type: SdApiContractDataType;
|
|
296
|
+
required?: boolean;
|
|
297
|
+
label?: string;
|
|
298
|
+
description?: string;
|
|
299
|
+
/** `true` when traversal did not descend any further from this field. */
|
|
300
|
+
leaf: boolean;
|
|
301
|
+
/** `true` when the field was reached by descending through an array's `items`. */
|
|
302
|
+
arrayItem: boolean;
|
|
303
|
+
}
|
|
304
|
+
interface SdApiContractFieldListOptions {
|
|
305
|
+
/** `'flatten'` (default) descends into array items; `'stop'` treats an array as a leaf. */
|
|
306
|
+
arrays?: 'flatten' | 'stop';
|
|
307
|
+
/** Dotted prefix prepended to every emitted path, e.g. `'body'`. */
|
|
308
|
+
basePath?: string;
|
|
309
|
+
}
|
|
310
|
+
interface SdApiContractResolvedReference {
|
|
311
|
+
type: SdApiContractDataType;
|
|
312
|
+
required?: boolean;
|
|
313
|
+
label?: string;
|
|
314
|
+
description?: string;
|
|
315
|
+
/** `null` for synthetic references such as `res.status`, which have no declared node. */
|
|
316
|
+
node: SdApiContractStructuralNode | null;
|
|
317
|
+
}
|
|
318
|
+
interface SdApiContractUrlPlaceholders {
|
|
319
|
+
/** Unique placeholder names, in first-appearance order. */
|
|
320
|
+
names: readonly string[];
|
|
321
|
+
duplicates: readonly string[];
|
|
322
|
+
/** Raw fragments that look like a placeholder but are not one, e.g. `{}` or `{first name}`. */
|
|
323
|
+
malformed: readonly string[];
|
|
324
|
+
}
|
|
325
|
+
/** Flattens a node tree into addressable fields. See `SdApiContractSchemaField` for the convention. */
|
|
326
|
+
declare function listSdApiContractSchemaFields(node: SdApiContractStructuralNode, options?: SdApiContractFieldListOptions): readonly SdApiContractSchemaField[];
|
|
327
|
+
/** Every `${res.…}` path the output layer may address, in a stable order. */
|
|
328
|
+
declare function listSdApiContractResponseFields(response: SdApiContractResponse): readonly SdApiContractSchemaField[];
|
|
329
|
+
/**
|
|
330
|
+
* Resolves a *logical* reference path (`customer.id`) against a schema.
|
|
331
|
+
*
|
|
332
|
+
* Arrays are terminal: `${res.body.items}` addresses the whole array, `${res.body.items.id}` does
|
|
333
|
+
* not exist because there is no element to address. Per-item projection is out of scope.
|
|
334
|
+
*/
|
|
335
|
+
declare function resolveSdApiContractSchemaPath(root: SdApiContractStructuralNode, path: readonly string[]): SdApiContractStructuralNode | null;
|
|
336
|
+
/** Resolves `status` / `headers.<name>` / `body.<path>` against a response declaration. */
|
|
337
|
+
declare function resolveSdApiContractResponsePath(response: SdApiContractResponse, path: readonly string[]): SdApiContractResolvedReference | null;
|
|
338
|
+
/** Reads the node a structural pointer addresses, or `null` when the pointer does not resolve. */
|
|
339
|
+
declare function getSdApiContractNodeAt(root: SdApiContractStructuralNode, pointer: SdApiContractNodePointer): SdApiContractStructuralNode | null;
|
|
340
|
+
/** Replaces the node a pointer addresses, rebuilding only the spine. Never mutates `root`. */
|
|
341
|
+
declare function setSdApiContractNodeAt<T extends SdApiContractStructuralNode>(root: T, pointer: SdApiContractNodePointer, node: SdApiContractStructuralNode): T;
|
|
342
|
+
/** Appends a property. A key that already exists is left untouched — the caller must dedupe first. */
|
|
343
|
+
declare function addSdApiContractProperty(node: SdApiContractStructuralNode, key: string, child: SdApiContractStructuralNode): SdApiContractObjectShape;
|
|
344
|
+
/** Renames a property **in place in the key order**, so the JSON diff stays readable. */
|
|
345
|
+
declare function renameSdApiContractProperty(node: SdApiContractStructuralNode, from: string, to: string): SdApiContractObjectShape;
|
|
346
|
+
declare function removeSdApiContractProperty(node: SdApiContractStructuralNode, key: string): SdApiContractObjectShape;
|
|
347
|
+
/** A minimal well-formed node of the given type. */
|
|
348
|
+
declare function createSdApiContractNode(type: SdApiContractDataType): SdApiContractStructuralNode;
|
|
349
|
+
/**
|
|
350
|
+
* Retypes a node, dropping the members the new type cannot carry.
|
|
351
|
+
*
|
|
352
|
+
* Returns the same reference when the type is unchanged, so an idempotent UI write never produces a
|
|
353
|
+
* spurious `modelChange`.
|
|
354
|
+
*/
|
|
355
|
+
declare function changeSdApiContractNodeType(node: SdApiContractStructuralNode, type: SdApiContractDataType): SdApiContractStructuralNode;
|
|
356
|
+
/** Deep copy of a node subtree. Used when a response subtree is adopted as the output schema. */
|
|
357
|
+
declare function cloneSdApiContractNode<T extends SdApiContractStructuralNode>(node: T): T;
|
|
358
|
+
/**
|
|
359
|
+
* Deep copy of a whole contract.
|
|
360
|
+
*
|
|
361
|
+
* The builder clones on the way in so the object a parent owns is never reachable from an edit, and
|
|
362
|
+
* a consumer can do the same before handing a contract to anything that might mutate it.
|
|
363
|
+
*/
|
|
364
|
+
declare function cloneSdApiContract<T>(contract: T): T;
|
|
365
|
+
declare function sdApiContractRecordSet<T>(record: Record<string, T> | undefined, key: string, value: T): Record<string, T>;
|
|
366
|
+
declare function sdApiContractRecordRemove<T>(record: Record<string, T>, key: string): Record<string, T>;
|
|
367
|
+
/** Renames a key in place. A collision or an empty target is a no-op — the caller reports it. */
|
|
368
|
+
declare function sdApiContractRecordRename<T>(record: Record<string, T>, from: string, to: string): Record<string, T>;
|
|
369
|
+
/** Builds the canonical expression text — the inverse of `parseSdApiContractTemplate`. */
|
|
370
|
+
declare function formatSdApiContractExpression(root: SdApiContractExpressionRoot, path: readonly string[]): string;
|
|
371
|
+
/** Joins a diagnostic base path with a structural pointer, e.g. `req.body` + `properties.x`. */
|
|
372
|
+
declare function formatSdApiContractPointer(base: string, pointer: SdApiContractNodePointer): string;
|
|
373
|
+
/**
|
|
374
|
+
* Reads REST placeholders out of a URL template.
|
|
375
|
+
*
|
|
376
|
+
* `${…}` interpolation is masked out first, so `${env.baseUrl}` is never mistaken for a `{…}`
|
|
377
|
+
* path placeholder.
|
|
378
|
+
*/
|
|
379
|
+
declare function parseSdApiContractUrlPlaceholders(url: string): SdApiContractUrlPlaceholders;
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Deterministic JSON for an API contract.
|
|
383
|
+
*
|
|
384
|
+
* Three guarantees the persisted file depends on:
|
|
385
|
+
*
|
|
386
|
+
* 1. **System keys are ordered**, so two authors editing the same contract produce the same bytes
|
|
387
|
+
* and a `git diff` shows the semantic change instead of a reshuffle.
|
|
388
|
+
* 2. **User-declared keys keep their order** (`properties`, `query`, `headers`, …) — that order is
|
|
389
|
+
* authored information, and sorting it would churn every diff.
|
|
390
|
+
* 3. **Only contract vocabulary survives.** The builder's transient UI state (expansion, selection,
|
|
391
|
+
* internal ids) is dropped by construction: the serializer copies a fixed key whitelist rather
|
|
392
|
+
* than the object it was handed, so a new piece of UI state can never leak into the file.
|
|
393
|
+
*
|
|
394
|
+
* `undefined` members are omitted; declared `false`, `0`, `null` and `""` are kept.
|
|
395
|
+
*/
|
|
396
|
+
declare function serializeSdApiContract(contract: SdApiContract | null | undefined): string;
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Validates a contract against the grammar, the schema rules, the REST rules and the injected env
|
|
400
|
+
* catalog.
|
|
401
|
+
*
|
|
402
|
+
* Pure and UI-free: it takes `unknown` because an externally supplied contract may be malformed,
|
|
403
|
+
* and it **never repairs anything** — a silent fix would hide the very mistake the author needs to
|
|
404
|
+
* see. Diagnostics come back in a fixed traversal order (metadata → `input` → `req` → `res` →
|
|
405
|
+
* `output`, declaration order within each), so the same contract always yields the same list.
|
|
406
|
+
*/
|
|
407
|
+
declare function validateSdApiContract(contract: unknown, configuration?: SdApiContractConfiguration): SdApiContractDiagnostic[];
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Reference contracts, shared by the docs, the showcase and the test-suite so the canonical example
|
|
411
|
+
* can never drift between them.
|
|
412
|
+
*
|
|
413
|
+
* Each is a **factory**, not a constant: the builder takes a two-way `[(model)]`, and handing two
|
|
414
|
+
* demos the same object would let one seed the other.
|
|
415
|
+
*/
|
|
416
|
+
/** The env catalog the samples reference. Definitions only — no secret ever has a value here. */
|
|
417
|
+
declare const SD_API_CONTRACT_SAMPLE_ENVIRONMENT: SdApiContractConfiguration;
|
|
418
|
+
/** `GET` list endpoint whose output is a root array — the dropdown / table shape. */
|
|
419
|
+
declare function sdApiContractSearchSample(): SdApiContract;
|
|
420
|
+
/**
|
|
421
|
+
* `POST` endpoint showing every mapping flavour at once:
|
|
422
|
+
* `input.a → req.body.x`, `input.b → req.body.y`, `input.c → req.body.z`,
|
|
423
|
+
* `env.userId → req.body.u`, and a static literal in `req.body.v`.
|
|
424
|
+
*/
|
|
425
|
+
declare function sdApiContractCreateSample(): SdApiContract;
|
|
426
|
+
/**
|
|
427
|
+
* Deliberately broken contract used to demonstrate the diagnostics: an undeclared env variable, a
|
|
428
|
+
* `{id}` placeholder with no `req.path` entry, a `${input.page}` that does not exist, and an output
|
|
429
|
+
* source pointing at a scalar while the output declares an array.
|
|
430
|
+
*/
|
|
431
|
+
declare function sdApiContractInvalidSample(): SdApiContract;
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* One `${…}` reference the source editor can offer.
|
|
435
|
+
*
|
|
436
|
+
* Internal to the builder UI — it is derived from the contract and the injected env catalog on every
|
|
437
|
+
* edit, so it is never persisted and never part of the public surface.
|
|
438
|
+
*/
|
|
439
|
+
interface SdApiContractSuggestion {
|
|
440
|
+
/** Ready-to-insert text, e.g. `${input.customer.id}`. */
|
|
441
|
+
expression: string;
|
|
442
|
+
/** Dotted path without the delimiters, e.g. `input.customer.id`. */
|
|
443
|
+
path: string;
|
|
444
|
+
root: SdApiContractExpressionRoot;
|
|
445
|
+
type: SdApiContractDataType;
|
|
446
|
+
/** What the picker shows. Never contains a value — a sensitive variable only shows its name. */
|
|
447
|
+
display: string;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/** What the drawer hands back when the author closes the books on one node. */
|
|
451
|
+
interface SdApiContractNodeCommit {
|
|
452
|
+
name: string;
|
|
453
|
+
node: SdApiContractStructuralNode;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* A layer list asking for the drawer to be opened.
|
|
457
|
+
*
|
|
458
|
+
* The list does not own the drawer — the builder does, so there is exactly one drawer and one staged
|
|
459
|
+
* draft on the page. The list only says which node the author reached for; the builder knows which
|
|
460
|
+
* section that list was wired into and applies the commit there.
|
|
461
|
+
*/
|
|
462
|
+
interface SdApiContractNodeEditRequest {
|
|
463
|
+
/** `null` means "add a new node to this collection". */
|
|
464
|
+
name: string | null;
|
|
465
|
+
node: SdApiContractStructuralNode | null;
|
|
466
|
+
/** Names already taken at this level, so the drawer can refuse a duplicate. */
|
|
467
|
+
siblingNames: readonly string[];
|
|
468
|
+
/**
|
|
469
|
+
* Where the listed collection sits inside its layer root — `[]` for an object layer, `['items']`
|
|
470
|
+
* for an array layer whose fields belong to the element.
|
|
471
|
+
*
|
|
472
|
+
* why cần: drawer không dùng field này, nhưng builder thì có. Một tầng `array` (vd `output.schema`
|
|
473
|
+
* nhận `${res.body.items}`) khai field ở `items.properties`, còn tầng `object` khai ở `properties`.
|
|
474
|
+
* Danh sách đã biết mình đang đọc chỗ nào, nên nó nói ra thay vì để builder đoán lại.
|
|
475
|
+
*/
|
|
476
|
+
pointer?: readonly string[];
|
|
477
|
+
}
|
|
478
|
+
interface SdApiContractOption$1 {
|
|
479
|
+
value: string;
|
|
480
|
+
label: string;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Editing surface for exactly one node, staged and committed in one go.
|
|
484
|
+
*
|
|
485
|
+
* The layer lists outside are read-only, so this drawer is the only place a node changes. It holds a
|
|
486
|
+
* DEEP COPY of the node it was seeded from and emits `nodeCommit` once, when the author saves — that
|
|
487
|
+
* is what makes "Huỷ" able to actually cancel, and what keeps the tree from changing under the
|
|
488
|
+
* author's cursor on every keystroke.
|
|
489
|
+
*
|
|
490
|
+
* Save is blocked only for the two problems that stop a node from existing at all: no name, or a name
|
|
491
|
+
* a sibling already holds. Everything else — a reference to a field that does not exist yet, a type
|
|
492
|
+
* that will not fit — saves and is reported by `validateSdApiContract`, because inventing rules here
|
|
493
|
+
* would stop an author declaring one end of a mapping before the other exists.
|
|
494
|
+
*/
|
|
495
|
+
declare class SdApiContractNodeDrawer {
|
|
496
|
+
#private;
|
|
497
|
+
/** `mapping` shows the value editor; `schema` is a plain declaration with no mapping. */
|
|
498
|
+
layer: _angular_core.InputSignal<"schema" | "mapping">;
|
|
499
|
+
allowTransform: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
|
500
|
+
suggestions: _angular_core.InputSignal<readonly SdApiContractSuggestion[]>;
|
|
501
|
+
autoId: _angular_core.InputSignal<string | null | undefined>;
|
|
502
|
+
nodeCommit: _angular_core.OutputEmitterRef<SdApiContractNodeCommit>;
|
|
503
|
+
protected readonly drawerRef: _angular_core.Signal<SdSideDrawer>;
|
|
504
|
+
protected readonly draftName: _angular_core.Signal<string>;
|
|
505
|
+
protected readonly discardPrompt: _angular_core.Signal<boolean>;
|
|
506
|
+
/** The node the author is looking at right now — the draft root, or a descendant of it. */
|
|
507
|
+
protected readonly current: _angular_core.Signal<SdApiContractStructuralNode | null>;
|
|
508
|
+
/** Every key on the breadcrumb. The pointer alternates `properties`/key, so keys sit on odd slots. */
|
|
509
|
+
protected readonly breadcrumb: _angular_core.Signal<string[]>;
|
|
510
|
+
/**
|
|
511
|
+
* What the name field shows.
|
|
512
|
+
*
|
|
513
|
+
* why một signal riêng chứ không đọc thẳng từ draft: một tên KHÔNG áp được — rỗng, hoặc trùng
|
|
514
|
+
* sibling — vẫn phải hiện ra để người dùng thấy mình vừa gõ gì và đọc được lý do bị chặn. Đọc
|
|
515
|
+
* thẳng từ draft thì ô input nhảy về tên cũ ngay khi gõ, tức là từ chối im lặng.
|
|
516
|
+
*/
|
|
517
|
+
protected readonly currentName: _angular_core.Signal<string>;
|
|
518
|
+
protected readonly children: _angular_core.Signal<{
|
|
519
|
+
key: string;
|
|
520
|
+
node: SdApiContractStructuralNode;
|
|
521
|
+
}[]>;
|
|
522
|
+
/** Siblings on the level the author is on — the root list, or the parent object's keys. */
|
|
523
|
+
protected readonly siblingNames: _angular_core.Signal<readonly string[]>;
|
|
524
|
+
protected readonly typeOptions: SdApiContractOption$1[];
|
|
525
|
+
protected readonly requiredOptions: SdApiContractOption$1[];
|
|
526
|
+
protected readonly transformOptions: SdApiContractOption$1[];
|
|
527
|
+
protected readonly title: _angular_core.Signal<string>;
|
|
528
|
+
protected readonly dirty: _angular_core.Signal<boolean>;
|
|
529
|
+
protected readonly nameError: _angular_core.Signal<string | null>;
|
|
530
|
+
protected readonly canSave: _angular_core.Signal<boolean>;
|
|
531
|
+
/**
|
|
532
|
+
* `beforeClose` guard for `<sd-side-drawer>`.
|
|
533
|
+
*
|
|
534
|
+
* why an arrow field, not a method: the drawer takes it as an input value, so it must keep `this`
|
|
535
|
+
* without the template having to bind it.
|
|
536
|
+
*/
|
|
537
|
+
protected readonly closeGuard: () => boolean;
|
|
538
|
+
openForAdd(siblingNames?: readonly string[], type?: SdApiContractDataType): void;
|
|
539
|
+
openForEdit(name: string, node: SdApiContractStructuralNode, siblingNames?: readonly string[]): void;
|
|
540
|
+
/**
|
|
541
|
+
* Types into the name field.
|
|
542
|
+
*
|
|
543
|
+
* The typed text is ALWAYS kept, then applied to the draft only when it can be. A name that cannot
|
|
544
|
+
* be applied — empty, or already taken by a sibling — stays visible and `nameError()` explains it,
|
|
545
|
+
* which is what blocks Save. Refusing the keystroke instead would leave the field showing one name
|
|
546
|
+
* while the contract holds another.
|
|
547
|
+
*/
|
|
548
|
+
protected setName(value: unknown): void;
|
|
549
|
+
protected setType(value: unknown): void;
|
|
550
|
+
protected setRequired(value: unknown): void;
|
|
551
|
+
protected setText(key: 'label' | 'description', value: unknown): void;
|
|
552
|
+
protected setTransform(value: unknown): void;
|
|
553
|
+
protected applyCurrent(node: SdApiContractStructuralNode): void;
|
|
554
|
+
protected enter(key: string): void;
|
|
555
|
+
/** `depth` counts breadcrumb entries, so 0 is the draft root. */
|
|
556
|
+
protected backTo(depth: number): void;
|
|
557
|
+
protected addChild(): void;
|
|
558
|
+
protected removeChild(key: string): void;
|
|
559
|
+
protected save(): void;
|
|
560
|
+
protected requestCancel(): void;
|
|
561
|
+
protected confirmDiscard(): void;
|
|
562
|
+
protected cancelDiscard(): void;
|
|
563
|
+
/**
|
|
564
|
+
* Blocks the close while the draft is dirty and raises an inline prompt instead.
|
|
565
|
+
*
|
|
566
|
+
* why inline chứ không `window.confirm`: một component thư viện không được dựng dialog của browser
|
|
567
|
+
* — nó không style được, không test được, và chặn cả tab.
|
|
568
|
+
*/
|
|
569
|
+
protected guardClose(): boolean;
|
|
570
|
+
protected onClosed(): void;
|
|
571
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<SdApiContractNodeDrawer, never>;
|
|
572
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<SdApiContractNodeDrawer, "sd-api-contract-node-drawer", never, { "layer": { "alias": "layer"; "required": false; "isSignal": true; }; "allowTransform": { "alias": "allowTransform"; "required": false; "isSignal": true; }; "suggestions": { "alias": "suggestions"; "required": false; "isSignal": true; }; "autoId": { "alias": "autoId"; "required": false; "isSignal": true; }; }, { "nodeCommit": "nodeCommit"; }, never, never, true, never>;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
interface SdApiContractOption {
|
|
576
|
+
value: string;
|
|
577
|
+
label: string;
|
|
578
|
+
}
|
|
579
|
+
interface SdApiContractStep {
|
|
580
|
+
index: number;
|
|
581
|
+
key: string;
|
|
582
|
+
label: string;
|
|
583
|
+
}
|
|
584
|
+
type SdApiContractNodeRecord = Record<string, SdApiContractStructuralNode>;
|
|
585
|
+
/** Every place a node can live. The builder needs it to route a commit back to its owner. */
|
|
586
|
+
type SdApiContractDrawerSection = 'input.schema' | 'req.path' | 'req.query' | 'req.headers' | 'req.body' | 'res.headers' | 'res.body' | 'output.schema';
|
|
587
|
+
/**
|
|
588
|
+
* Visual builder for an `SdApiContract`.
|
|
589
|
+
*
|
|
590
|
+
* The component is a **design-time** tool: it never performs a request, never resolves an
|
|
591
|
+
* expression and never holds a secret. It edits, validates and serializes the contract; executing
|
|
592
|
+
* it is a separate concern for a future `form-builder` / `form-render` integration.
|
|
593
|
+
*
|
|
594
|
+
* @example
|
|
595
|
+
* ```html
|
|
596
|
+
* <sd-api-contract-builder [(model)]="contract" autoId="product-search"></sd-api-contract-builder>
|
|
597
|
+
* ```
|
|
598
|
+
*/
|
|
599
|
+
declare class SdApiContractBuilder {
|
|
600
|
+
#private;
|
|
601
|
+
model: _angular_core.ModelSignal<SdApiContract | null>;
|
|
602
|
+
mode: _angular_core.InputSignal<"edit" | "view">;
|
|
603
|
+
disabled: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
|
604
|
+
autoId: _angular_core.InputSignal<string | null | undefined>;
|
|
605
|
+
/** Fires whenever the diagnostics change, including once for the initially seeded contract. */
|
|
606
|
+
diagnosticsChange: _angular_core.OutputEmitterRef<readonly SdApiContractDiagnostic[]>;
|
|
607
|
+
/** Fires only when validity flips, so a consumer can gate a Save button without debouncing. */
|
|
608
|
+
validChange: _angular_core.OutputEmitterRef<boolean>;
|
|
609
|
+
protected readonly activeStep: _angular_core.WritableSignal<number>;
|
|
610
|
+
protected readonly contractVersion = 1;
|
|
611
|
+
protected readonly responseFieldToken: _angular_core.WritableSignal<string | null>;
|
|
612
|
+
protected readonly urlPlaceholder = "${env.baseUrl}/products/{id}";
|
|
613
|
+
protected readonly draft: _angular_core.Signal<SdApiContract | null>;
|
|
614
|
+
protected readonly readonly: _angular_core.Signal<boolean>;
|
|
615
|
+
protected readonly isView: _angular_core.Signal<boolean>;
|
|
616
|
+
protected readonly steps: SdApiContractStep[];
|
|
617
|
+
protected readonly methodOptions: SdApiContractOption[];
|
|
618
|
+
protected readonly allTypes: readonly SdApiContractDataType[];
|
|
619
|
+
protected readonly scalarTypes: readonly SdApiContractDataType[];
|
|
620
|
+
protected readonly queryTypes: readonly SdApiContractDataType[];
|
|
621
|
+
protected readonly nodeDrawer: _angular_core.Signal<SdApiContractNodeDrawer | undefined>;
|
|
622
|
+
protected readonly drawerLayer: _angular_core.Signal<"schema" | "mapping">;
|
|
623
|
+
protected readonly drawerAllowsTransform: _angular_core.Signal<boolean>;
|
|
624
|
+
protected readonly drawerSuggestions: _angular_core.Signal<readonly SdApiContractSuggestion[]>;
|
|
625
|
+
protected readonly diagnostics: _angular_core.Signal<readonly SdApiContractDiagnostic[]>;
|
|
626
|
+
protected readonly json: _angular_core.Signal<string>;
|
|
627
|
+
protected readonly requestSuggestions: _angular_core.Signal<SdApiContractSuggestion[]>;
|
|
628
|
+
protected readonly outputSuggestions: _angular_core.Signal<SdApiContractSuggestion[]>;
|
|
629
|
+
/** Response paths offered by the "use a response field as the output" action. */
|
|
630
|
+
protected readonly responseFieldOptions: _angular_core.Signal<SdApiContractOption[]>;
|
|
631
|
+
/** Leaf fields a dropdown / table consumer will see once this contract runs. */
|
|
632
|
+
protected readonly outputFields: _angular_core.Signal<SdApiContractSchemaField[]>;
|
|
633
|
+
protected readonly statusText: _angular_core.Signal<string>;
|
|
634
|
+
get autoIdAttr(): string | null;
|
|
635
|
+
constructor();
|
|
636
|
+
protected goToStep(index: number): void;
|
|
637
|
+
protected goToDiagnostic(diagnostic: SdApiContractDiagnostic): void;
|
|
638
|
+
protected createContract(): void;
|
|
639
|
+
protected setText(key: 'code' | 'name' | 'description', value: unknown): void;
|
|
640
|
+
protected setInputSchema(node: SdApiContractStructuralNode): void;
|
|
641
|
+
protected setMethod(value: unknown): void;
|
|
642
|
+
protected setUrl(value: unknown): void;
|
|
643
|
+
/**
|
|
644
|
+
* Opens the one drawer for whichever list asked.
|
|
645
|
+
*
|
|
646
|
+
* why gác `readonly` ở đây nữa: hàng thu gọn đã tự chặn khi read-only, nhưng builder là nơi duy nhất
|
|
647
|
+
* biết `mode`/`disabled` thật. Hai lớp gác rẻ hơn một đường mở drawer lọt trong chế độ xem.
|
|
648
|
+
*/
|
|
649
|
+
protected openNodeDrawer(section: SdApiContractDrawerSection, request: SdApiContractNodeEditRequest): void;
|
|
650
|
+
/**
|
|
651
|
+
* Writes a committed node back where it came from — one `modelChange`, at Save time.
|
|
652
|
+
*
|
|
653
|
+
* A rename goes through `sdApiContractRecordRename` first so the entry keeps its position in the
|
|
654
|
+
* JSON instead of jumping to the end. The drawer has already refused a duplicate name, so the
|
|
655
|
+
* rename cannot collide by the time it reaches here.
|
|
656
|
+
*/
|
|
657
|
+
protected applyNodeCommit(commit: SdApiContractNodeCommit): void;
|
|
658
|
+
protected setRequestRecord(section: 'path' | 'query' | 'headers', record: SdApiContractNodeRecord): void;
|
|
659
|
+
protected setRequestBody(node: SdApiContractStructuralNode): void;
|
|
660
|
+
protected addRequestBody(): void;
|
|
661
|
+
protected removeRequestBody(): void;
|
|
662
|
+
protected setStatus(value: unknown): void;
|
|
663
|
+
protected setResponseHeaders(record: SdApiContractNodeRecord): void;
|
|
664
|
+
protected setResponseBody(node: SdApiContractStructuralNode): void;
|
|
665
|
+
protected addResponseBody(): void;
|
|
666
|
+
protected removeResponseBody(): void;
|
|
667
|
+
protected setOutputSchema(node: SdApiContractStructuralNode): void;
|
|
668
|
+
/**
|
|
669
|
+
* Adopts a response subtree as the output schema.
|
|
670
|
+
*
|
|
671
|
+
* The subtree is **deep-copied**, never referenced: editing the output afterwards must not reach
|
|
672
|
+
* back into the response declaration. An array or scalar target takes a whole-node `source`; an
|
|
673
|
+
* object target keeps its shape and each branch gets its own `source`, because an object with both
|
|
674
|
+
* a whole-node source and child mappings is invalid by design.
|
|
675
|
+
*/
|
|
676
|
+
protected useResponseFieldAsOutput(value: unknown): void;
|
|
677
|
+
/**
|
|
678
|
+
* Adopts a contract pasted into the review editor.
|
|
679
|
+
*
|
|
680
|
+
* `<sd-code-editor language="json">` emits the PARSED value when the text is valid JSON and the
|
|
681
|
+
* raw STRING while it is still half-typed. A string therefore means "not parseable yet": keep the
|
|
682
|
+
* current draft and report it, because replacing a contract with a fragment of text would destroy
|
|
683
|
+
* the author's work on a keystroke.
|
|
684
|
+
*
|
|
685
|
+
* A parseable object is adopted VERBATIM — no field is added, removed or repaired. Whatever is
|
|
686
|
+
* wrong with it surfaces through `validateSdApiContract`, which is the whole point of pasting.
|
|
687
|
+
*/
|
|
688
|
+
protected applyPastedJson(value: unknown): void;
|
|
689
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<SdApiContractBuilder, never>;
|
|
690
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<SdApiContractBuilder, "sd-api-contract-builder", never, { "model": { "alias": "model"; "required": false; "isSignal": true; }; "mode": { "alias": "mode"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "autoId": { "alias": "autoId"; "required": false; "isSignal": true; }; }, { "model": "modelChange"; "diagnosticsChange": "diagnosticsChange"; "validChange": "validChange"; }, never, never, true, never>;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
export { SD_API_CONTRACT_ALLOWED_ROOTS, SD_API_CONTRACT_CONFIGURATION, SD_API_CONTRACT_DATA_TYPES, SD_API_CONTRACT_EMPTY_CONFIGURATION, SD_API_CONTRACT_EXPRESSION_ROOTS, SD_API_CONTRACT_HTTP_METHODS, SD_API_CONTRACT_SAMPLE_ENVIRONMENT, SD_API_CONTRACT_SCALAR_DATA_TYPES, SD_API_CONTRACT_VERSION, SdApiContractBuilder, addSdApiContractProperty, changeSdApiContractNodeType, cloneSdApiContract, cloneSdApiContractNode, createSdApiContractNode, extractSdApiContractReferences, formatSdApiContractExpression, formatSdApiContractPointer, getSdApiContractNodeAt, listSdApiContractResponseFields, listSdApiContractSchemaFields, parseSdApiContractTemplate, parseSdApiContractUrlPlaceholders, provideSdApiContract, removeSdApiContractProperty, renameSdApiContractProperty, resolveSdApiContractConfiguration, resolveSdApiContractResponsePath, resolveSdApiContractSchemaPath, sdApiContractCreateSample, sdApiContractInvalidSample, sdApiContractRecordRemove, sdApiContractRecordRename, sdApiContractRecordSet, sdApiContractSearchSample, sdIsApiContractDataType, sdIsApiContractHttpMethod, sdIsApiContractScalarDataType, sdIsApiContractTemporalDataType, serializeSdApiContract, setSdApiContractNodeAt, validateSdApiContract };
|
|
694
|
+
export type { SdApiContract, SdApiContractAnyNode, SdApiContractConfiguration, SdApiContractDataType, SdApiContractDiagnostic, SdApiContractDiagnosticSeverity, SdApiContractEnvironmentVariable, SdApiContractExpressionReference, SdApiContractExpressionRoot, SdApiContractFeArrayNode, SdApiContractFeObjectNode, SdApiContractFeScalarNode, SdApiContractFeSchemaNode, SdApiContractFieldListOptions, SdApiContractHttpMethod, SdApiContractJsonValue, SdApiContractMappedFeArrayNode, SdApiContractMappedFeObjectNode, SdApiContractMappedFeScalarNode, SdApiContractMappedFeSchemaNode, SdApiContractMappedRestArrayNode, SdApiContractMappedRestNode, SdApiContractMappedRestObjectNode, SdApiContractMappedRestScalarNode, SdApiContractMapping, SdApiContractMappingContext, SdApiContractNodeBase, SdApiContractNodePointer, SdApiContractObjectShape, SdApiContractRequest, SdApiContractResolvedReference, SdApiContractResponse, SdApiContractRestArrayNode, SdApiContractRestNode, SdApiContractRestObjectNode, SdApiContractRestScalarNode, SdApiContractScalarDataType, SdApiContractSchemaField, SdApiContractStructuralNode, SdApiContractTemplate, SdApiContractTemplateError, SdApiContractTemplateErrorCode, SdApiContractTemplateKind, SdApiContractTemporalDataType, SdApiContractUrlPlaceholders };
|