@grandlinex/swagger-mate 1.3.1 → 1.3.2

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.
@@ -38,13 +38,20 @@ export interface ConHandle {
38
38
  patch<T, J>(url: string, body?: J, config?: ConHandleConfig): Promise<ConHandleResponse<T>>;
39
39
  delete<T>(url: string, config?: ConHandleConfig): Promise<ConHandleResponse<T>>;
40
40
  }
41
+ /**
42
+ * BaseCon provides a minimal client for interacting with an HTTP backend.
43
+ * It manages connection state, authentication tokens, and reconnection
44
+ * logic while delegating actual HTTP requests to a supplied {@link ConHandle}.
45
+ *
46
+ * @class
47
+ */
41
48
  export default class BaseCon {
42
- api: string;
43
- permanentHeader: undefined | Record<string, string>;
44
- authorization: string | null;
45
- disconnected: boolean;
46
- failFlag: boolean;
47
- logger: (arg: any) => void;
49
+ private api;
50
+ private permanentHeader;
51
+ private authorization;
52
+ private noAuth;
53
+ private disconnected;
54
+ private readonly logger;
48
55
  con: ConHandle;
49
56
  reconnect: () => Promise<boolean>;
50
57
  onReconnect: (con: BaseCon) => Promise<boolean>;
@@ -53,16 +60,113 @@ export default class BaseCon {
53
60
  endpoint: string;
54
61
  logger?: (arg: any) => void;
55
62
  });
63
+ /**
64
+ * Retrieves the API endpoint.
65
+ *
66
+ * @return {string} The API endpoint string.
67
+ */
68
+ getApiEndpoint(): string;
69
+ /**
70
+ * Sets the API endpoint URL used by the client.
71
+ *
72
+ * @param {string} endpoint - The full URL of the API endpoint.
73
+ * @returns {void}
74
+ */
75
+ setApiEndpoint(endpoint: string): void;
76
+ /**
77
+ * Indicates whether the instance is considered connected.
78
+ *
79
+ * The instance is regarded as connected when it either does not require authentication
80
+ * (`noAuth` is true) or it has an authorization token set (`authorization` is not null),
81
+ * and it is not currently marked as disconnected.
82
+ *
83
+ * @return {boolean} `true` if the instance is connected, `false` otherwise.
84
+ */
56
85
  isConnected(): boolean;
86
+ /**
87
+ * Returns the current authorization token.
88
+ *
89
+ * @return {string} The authorization token or an empty string if none is set.
90
+ */
57
91
  token(): string;
58
- p(path: string, config?: ConHandleConfig): string;
92
+ private p;
93
+ /**
94
+ * Sends a ping request to the API to verify connectivity and version availability.
95
+ *
96
+ * @return {boolean} `true` if the API responded with a 200 status code and a valid version object; `false` otherwise.
97
+ */
59
98
  ping(): Promise<boolean>;
60
- test(email: string, password: string): Promise<boolean>;
99
+ /**
100
+ * Validates the current authentication token by performing a ping and a test request
101
+ * to the backend. The method first ensures connectivity via {@link ping}. If the ping
102
+ * succeeds, it attempts to retrieve a token from the `/test/auth` endpoint using the
103
+ * current token in the `Authorization` header. The operation is considered successful
104
+ * if the response status code is 200 or 201.
105
+ *
106
+ * If any step fails, an error is logged and the method returns {@code false}. On
107
+ * success, it returns {@code true}.
108
+ *
109
+ * @return {Promise<boolean>} A promise that resolves to {@code true} if the token
110
+ * test succeeds, otherwise {@code false}.
111
+ */
61
112
  testToken(): Promise<boolean>;
62
- connect(email: string, pw: string): Promise<boolean>;
63
113
  /**
64
- * Enable client before auth
114
+ * Attempts to establish a connection to the backend without authentication.
115
+ *
116
+ * This method sends a ping request. If the ping succeeds, it clears any
117
+ * existing authorization data, marks the instance as connected,
118
+ * enables the no‑authentication mode, and returns `true`. If the ping
119
+ * fails, it logs a warning, clears authorization, marks the instance
120
+ * as disconnected, and returns `false`.
121
+ *
122
+ * @return {Promise<boolean>} `true` when a connection is successfully
123
+ * established without authentication, otherwise `false`.
124
+ */
125
+ connectNoAuth(): Promise<boolean>;
126
+ /**
127
+ * Forces a connection using the provided bearer token.
128
+ *
129
+ * @param {string} token The token to be used for authentication.
130
+ * @returns {void}
131
+ */
132
+ forceConnectWithToken(token: string): void;
133
+ /**
134
+ * Establishes a connection to the backend using the supplied credentials.
135
+ * Performs a health‑check ping first; if successful, it requests an authentication
136
+ * token from the `/token` endpoint. When the token is obtained, the method
137
+ * updates internal state (authorization header, connection flags) and, unless
138
+ * a dry run is requested, sets up a reconnection routine. Any errors are
139
+ * logged and the method resolves to `false`.
140
+ *
141
+ * @param {string} email - The user's email address for authentication.
142
+ * @param {string} pw - The password (or token) for the specified user.
143
+ * @param {boolean} [dry=false] - If `true`, the method performs a dry run
144
+ * without persisting credentials or configuring reconnection logic.
145
+ *
146
+ * @returns Promise<boolean> `true` if the connection was successfully
147
+ * established, otherwise `false`.
148
+ */
149
+ connect(email: string, pw: string, dry?: boolean): Promise<boolean>;
150
+ /**
151
+ * Performs an HTTP request using the client’s internal connection.
152
+ *
153
+ * The method verifies that the client is connected before attempting a request.
154
+ * It automatically injects the authorization token, permanent headers, and any
155
+ * headers supplied in `config`. If the request body is a `FormData` instance
156
+ * (or provides a `getHeaders` method), the appropriate form headers are added.
157
+ *
158
+ * Response handling:
159
+ * - `200` or `201`: returns `success: true` with the received data.
160
+ * - `498`: attempts to reconnect and retries the request once.
161
+ * - `401`: logs an authentication error, marks the client as disconnected.
162
+ * - `403` and other status codes: return `success: false` with the status code.
163
+ *
164
+ * @param {'POST'|'GET'|'PATCH'|'DELETE'} type The HTTP method to use.
165
+ * @param {string} path The endpoint path relative to the base URL.
166
+ * @param {J} [body] Optional request payload. May be `FormData` or a plain object.
167
+ * @param {ConHandleConfig} [config] Optional Axios-like configuration for the request.
168
+ * @returns {Promise<HandleRes<T>>} A promise that resolves to a `HandleRes` object
169
+ * containing the response data, status code, any error information, and headers.
65
170
  */
66
- fakeEnableClient(): void;
67
171
  handle<T, J>(type: 'POST' | 'GET' | 'PATCH' | 'DELETE', path: string, body?: J, config?: ConHandleConfig): Promise<HandleRes<T>>;
68
172
  }
@@ -12,13 +12,20 @@ const form_data_1 = __importDefault(require("form-data"));
12
12
  function isErrorType(x) {
13
13
  return x && typeof x === 'object' && x.type === 'error';
14
14
  }
15
+ /**
16
+ * BaseCon provides a minimal client for interacting with an HTTP backend.
17
+ * It manages connection state, authentication tokens, and reconnection
18
+ * logic while delegating actual HTTP requests to a supplied {@link ConHandle}.
19
+ *
20
+ * @class
21
+ */
15
22
  class BaseCon {
16
23
  constructor(conf) {
17
24
  this.api = conf.endpoint;
18
- this.logger = conf.logger || console.log;
25
+ this.logger = conf.logger ?? console.log;
19
26
  this.disconnected = true;
27
+ this.noAuth = false;
20
28
  this.authorization = null;
21
- this.failFlag = false;
22
29
  this.con = conf.con;
23
30
  this.reconnect = async () => {
24
31
  this.disconnected = true;
@@ -27,10 +34,40 @@ class BaseCon {
27
34
  this.onReconnect = () => Promise.resolve(true);
28
35
  this.handle = this.handle.bind(this);
29
36
  }
30
- // Class helper functions
37
+ /**
38
+ * Retrieves the API endpoint.
39
+ *
40
+ * @return {string} The API endpoint string.
41
+ */
42
+ getApiEndpoint() {
43
+ return this.api;
44
+ }
45
+ /**
46
+ * Sets the API endpoint URL used by the client.
47
+ *
48
+ * @param {string} endpoint - The full URL of the API endpoint.
49
+ * @returns {void}
50
+ */
51
+ setApiEndpoint(endpoint) {
52
+ this.api = endpoint;
53
+ }
54
+ /**
55
+ * Indicates whether the instance is considered connected.
56
+ *
57
+ * The instance is regarded as connected when it either does not require authentication
58
+ * (`noAuth` is true) or it has an authorization token set (`authorization` is not null),
59
+ * and it is not currently marked as disconnected.
60
+ *
61
+ * @return {boolean} `true` if the instance is connected, `false` otherwise.
62
+ */
31
63
  isConnected() {
32
- return this.authorization !== null && !this.disconnected;
64
+ return (this.noAuth || this.authorization !== null) && !this.disconnected;
33
65
  }
66
+ /**
67
+ * Returns the current authorization token.
68
+ *
69
+ * @return {string} The authorization token or an empty string if none is set.
70
+ */
34
71
  token() {
35
72
  return this.authorization || '';
36
73
  }
@@ -56,35 +93,34 @@ class BaseCon {
56
93
  }
57
94
  return `${this.api}${pp}`;
58
95
  }
96
+ /**
97
+ * Sends a ping request to the API to verify connectivity and version availability.
98
+ *
99
+ * @return {boolean} `true` if the API responded with a 200 status code and a valid version object; `false` otherwise.
100
+ */
59
101
  async ping() {
60
102
  try {
61
103
  const version = await this.con.get(this.p('/version'));
62
- return version.data?.api === 1 && version.code === 200;
104
+ return version.data?.api !== undefined && version.code === 200;
63
105
  }
64
106
  catch (e) {
65
107
  this.logger('ping failed');
66
108
  return false;
67
109
  }
68
110
  }
69
- async test(email, password) {
70
- const ping = await this.ping();
71
- if (ping) {
72
- try {
73
- this.logger({ email, password });
74
- const con = await this.con.post(this.p('/token'), {
75
- username: email,
76
- token: password,
77
- });
78
- return con.code === 200 || con.code === 201;
79
- }
80
- catch (e) {
81
- this.logger(e);
82
- this.logger('cant connect to backend');
83
- }
84
- }
85
- this.logger('test ping failed');
86
- return false;
87
- }
111
+ /**
112
+ * Validates the current authentication token by performing a ping and a test request
113
+ * to the backend. The method first ensures connectivity via {@link ping}. If the ping
114
+ * succeeds, it attempts to retrieve a token from the `/test/auth` endpoint using the
115
+ * current token in the `Authorization` header. The operation is considered successful
116
+ * if the response status code is 200 or 201.
117
+ *
118
+ * If any step fails, an error is logged and the method returns {@code false}. On
119
+ * success, it returns {@code true}.
120
+ *
121
+ * @return {Promise<boolean>} A promise that resolves to {@code true} if the token
122
+ * test succeeds, otherwise {@code false}.
123
+ */
88
124
  async testToken() {
89
125
  const ping = await this.ping();
90
126
  if (ping) {
@@ -104,7 +140,59 @@ class BaseCon {
104
140
  this.logger('test ping failed');
105
141
  return false;
106
142
  }
107
- async connect(email, pw) {
143
+ /**
144
+ * Attempts to establish a connection to the backend without authentication.
145
+ *
146
+ * This method sends a ping request. If the ping succeeds, it clears any
147
+ * existing authorization data, marks the instance as connected,
148
+ * enables the no‑authentication mode, and returns `true`. If the ping
149
+ * fails, it logs a warning, clears authorization, marks the instance
150
+ * as disconnected, and returns `false`.
151
+ *
152
+ * @return {Promise<boolean>} `true` when a connection is successfully
153
+ * established without authentication, otherwise `false`.
154
+ */
155
+ async connectNoAuth() {
156
+ const ping = await this.ping();
157
+ if (ping) {
158
+ this.authorization = null;
159
+ this.disconnected = false;
160
+ this.noAuth = true;
161
+ return true;
162
+ }
163
+ this.logger('cant connect to backend');
164
+ this.authorization = null;
165
+ this.disconnected = true;
166
+ return false;
167
+ }
168
+ /**
169
+ * Forces a connection using the provided bearer token.
170
+ *
171
+ * @param {string} token The token to be used for authentication.
172
+ * @returns {void}
173
+ */
174
+ forceConnectWithToken(token) {
175
+ this.authorization = `Bearer ${token}`;
176
+ this.disconnected = false;
177
+ this.noAuth = false;
178
+ }
179
+ /**
180
+ * Establishes a connection to the backend using the supplied credentials.
181
+ * Performs a health‑check ping first; if successful, it requests an authentication
182
+ * token from the `/token` endpoint. When the token is obtained, the method
183
+ * updates internal state (authorization header, connection flags) and, unless
184
+ * a dry run is requested, sets up a reconnection routine. Any errors are
185
+ * logged and the method resolves to `false`.
186
+ *
187
+ * @param {string} email - The user's email address for authentication.
188
+ * @param {string} pw - The password (or token) for the specified user.
189
+ * @param {boolean} [dry=false] - If `true`, the method performs a dry run
190
+ * without persisting credentials or configuring reconnection logic.
191
+ *
192
+ * @returns Promise<boolean> `true` if the connection was successfully
193
+ * established, otherwise `false`.
194
+ */
195
+ async connect(email, pw, dry = false) {
108
196
  const ping = await this.ping();
109
197
  if (ping) {
110
198
  try {
@@ -112,13 +200,15 @@ class BaseCon {
112
200
  username: email,
113
201
  token: pw,
114
202
  });
115
- // TODO check token
116
203
  if (token.code === 200 || token.code === 201) {
117
- this.authorization = `Bearer ${token.data?.token}`;
118
- this.disconnected = false;
119
- this.reconnect = async () => {
120
- return (await this.connect(email, pw)) && (await this.testToken());
121
- };
204
+ if (!dry) {
205
+ this.authorization = `Bearer ${token.data?.token}`;
206
+ this.disconnected = false;
207
+ this.noAuth = false;
208
+ this.reconnect = async () => {
209
+ return ((await this.connect(email, pw)) && (await this.testToken()));
210
+ };
211
+ }
122
212
  return true;
123
213
  }
124
214
  }
@@ -129,17 +219,32 @@ class BaseCon {
129
219
  this.logger('cant connect to backend');
130
220
  this.authorization = null;
131
221
  this.disconnected = true;
222
+ this.noAuth = false;
132
223
  return false;
133
224
  }
134
225
  /**
135
- * Enable client before auth
226
+ * Performs an HTTP request using the client’s internal connection.
227
+ *
228
+ * The method verifies that the client is connected before attempting a request.
229
+ * It automatically injects the authorization token, permanent headers, and any
230
+ * headers supplied in `config`. If the request body is a `FormData` instance
231
+ * (or provides a `getHeaders` method), the appropriate form headers are added.
232
+ *
233
+ * Response handling:
234
+ * - `200` or `201`: returns `success: true` with the received data.
235
+ * - `498`: attempts to reconnect and retries the request once.
236
+ * - `401`: logs an authentication error, marks the client as disconnected.
237
+ * - `403` and other status codes: return `success: false` with the status code.
238
+ *
239
+ * @param {'POST'|'GET'|'PATCH'|'DELETE'} type The HTTP method to use.
240
+ * @param {string} path The endpoint path relative to the base URL.
241
+ * @param {J} [body] Optional request payload. May be `FormData` or a plain object.
242
+ * @param {ConHandleConfig} [config] Optional Axios-like configuration for the request.
243
+ * @returns {Promise<HandleRes<T>>} A promise that resolves to a `HandleRes` object
244
+ * containing the response data, status code, any error information, and headers.
136
245
  */
137
- fakeEnableClient() {
138
- this.authorization = 'DEBUG';
139
- this.disconnected = false;
140
- }
141
246
  async handle(type, path, body, config) {
142
- if (!this.authorization || this.disconnected) {
247
+ if (!this.isConnected()) {
143
248
  this.logger('Disconnected');
144
249
  return {
145
250
  success: false,
@@ -246,7 +351,6 @@ class BaseCon {
246
351
  };
247
352
  case 401:
248
353
  this.logger('AUTH NOT VALID');
249
- this.disconnected = true;
250
354
  return {
251
355
  success: false,
252
356
  data: null,
package/dist/cjs/cli.js CHANGED
@@ -76,7 +76,11 @@ async function run() {
76
76
  console.log('Serving Swagger Meta');
77
77
  const auth = process.env.SW_AUTH || undefined;
78
78
  const port = process.env.SW_PORT || undefined;
79
- SwaggerUtil_js_1.default.serveMeta(conf, port ? parseInt(port, 10) : undefined, auth);
79
+ SwaggerUtil_js_1.default.serveMeta(conf, {
80
+ port: port ? parseInt(port, 10) : undefined,
81
+ auth,
82
+ type: 'rapi-doc',
83
+ });
80
84
  }
81
85
  if (arg[arg.length - 2] === '--build') {
82
86
  console.log('Building Swagger Meta');
@@ -2,15 +2,104 @@ import { CoreEntity } from '@grandlinex/core';
2
2
  import { HttpStatusTypes } from '../Meta/SwaggerTypesStatic.js';
3
3
  import { SKey, SSchemaEl, SwaggerContent, SwaggerRPathConfResponse, SwaggerRPathReqBody } from '../Meta/SwaggerTypes.js';
4
4
  export default class SPathUtil {
5
+ /**
6
+ * Generates a default response mapping for the specified HTTP status types.
7
+ *
8
+ * @param {HttpStatusTypes[]} types - The HTTP status types for which default responses should be created.
9
+ * @return {SwaggerRPathConfResponse} An object mapping each provided status type to its default response definition. */
5
10
  static defaultResponse(...types: HttpStatusTypes[]): SwaggerRPathConfResponse;
11
+ /**
12
+ * Creates a request body definition for JSON content type using the provided schema.
13
+ *
14
+ * @param {SSchemaEl} schema - The JSON schema used for validating the request body.
15
+ * @return {SwaggerRPathReqBody} A Swagger path request body object specifying application/json content type with the provided schema.
16
+ */
6
17
  static jsonBody(schema: SSchemaEl): SwaggerRPathReqBody;
18
+ /**
19
+ * Builds a Swagger request body for `multipart/form-data` requests.
20
+ *
21
+ * @param {SSchemaEl} [schema] Optional schema describing the form data.
22
+ * If omitted, a default schema with a single binary `file` field is provided.
23
+ * @return {SwaggerRPathReqBody} Swagger request body definition with
24
+ * `multipart/form-data` content and the supplied or default schema. */
7
25
  static formBody(schema?: SSchemaEl): SwaggerRPathReqBody;
26
+ /**
27
+ * Generates a Swagger content definition for the provided entity.
28
+ *
29
+ * @param {T} entity - The entity instance to derive the Swagger schema from.
30
+ * @param {boolean} [list] - When true, the schema will be wrapped in an array type, representing a list of entities.
31
+ *
32
+ * @returns {SwaggerContent|undefined} The Swagger content object for the entity, or `undefined` if the entity does not have a schema.
33
+ */
8
34
  static entityContent<T extends CoreEntity>(entity: T, list?: boolean): SwaggerContent | undefined;
35
+ /**
36
+ * @template T extends CoreEntity
37
+ * @param {T} entity - The entity instance for which to build the response configuration.
38
+ * @param {boolean} [list] - Indicates whether the response should represent a list of entities.
39
+ * @param {boolean} [create] - Indicates whether the response corresponds to a creation operation (status code 201); otherwise 200.
40
+ * @returns {SwaggerRPathConfResponse} The Swagger response configuration object containing the appropriate status code and content.
41
+ */
9
42
  static entityResponse<T extends CoreEntity>(entity: T, list?: boolean, create?: boolean): SwaggerRPathConfResponse;
43
+ /**
44
+ * Builds a JSON schema reference path for the given component name.
45
+ *
46
+ * @param {string} inp - The name of the schema component.
47
+ * @return {string} The JSON reference path formatted as `#/components/schemas/<inp>`.
48
+ */
10
49
  static schemaPath(inp: string): string;
50
+ /**
51
+ * Creates a Swagger request body definition that references a schema.
52
+ *
53
+ * @param {string | CoreEntity} $ref
54
+ * Either the string reference to a schema or a `CoreEntity` instance whose
55
+ * class name will be used to build the reference path.
56
+ * @param {boolean} list
57
+ * If true, the referenced schema is wrapped in an array; otherwise the
58
+ * schema is used directly.
59
+ * @returns {SwaggerRPathReqBody}
60
+ * The request body object containing the appropriate content and schema
61
+ * configuration.
62
+ */
63
+ static refRequest($ref: string | CoreEntity, list: boolean): SwaggerRPathReqBody;
64
+ /**
65
+ * Creates a Swagger response configuration for a given HTTP status code.
66
+ *
67
+ * @param {HttpStatusTypes} code - The primary HTTP status code for */
11
68
  static refResponse(code: HttpStatusTypes, $ref: string | CoreEntity, list: boolean, ...addCodes: HttpStatusTypes[]): SwaggerRPathConfResponse;
69
+ /**
70
+ * Builds a Swagger response configuration object for a given HTTP status code and schema.
71
+ *
72
+ * @param {HttpStatusTypes} code - The primary HTTP status code for the response.
73
+ * @param {SSchemaEl} schema - The JSON schema definition for the response body.
74
+ * @param {boolean} list - If true, the schema is wrapped in an array for list responses.
75
+ * @param {...HttpStatusTypes} addCodes - Additional HTTP status codes for default responses.
76
+ * @return {SwaggerRPathConfResponse} The constructed response configuration object.
77
+ */
12
78
  static jsonResponse(code: HttpStatusTypes, schema: SSchemaEl, list: boolean, ...addCodes: HttpStatusTypes[]): SwaggerRPathConfResponse;
79
+ /**
80
+ * Generates a JSON schema representation from a CoreEntity instance.
81
+ *
82
+ * This method inspects the entity's metadata to construct a schema object
83
+ * describing the entity's shape. The resulting schema contains:
84
+ * - `type`: always `"object"`.
85
+ * - `description`: a string indicating the entity name.
86
+ * - `required`: an array of property names that are defined on the entity.
87
+ * - `properties`: an object mapping each property name to an object that
88
+ * includes the resolved database type and its nullability.
89
+ *
90
+ * If no metadata is found for the provided entity, the method returns `undefined`.
91
+ *
92
+ * @param {T} entity - The entity instance for which to create a schema.
93
+ * @returns {SSchemaEl | undefined} The generated schema object, or `undefined`
94
+ * if the entity's metadata could not be retrieved.
95
+ */
13
96
  static schemaFromEntity<T extends CoreEntity>(entity: T): SSchemaEl | undefined;
97
+ /**
98
+ * Generates a content schema object for the given entity. The schema contains a description derived from the entity metadata and a JSON content schema based on the entity's structure.
99
+ *
100
+ * @param {T} entity - The entity instance for which to generate the content schema. The generic type `T` must extend {@link CoreEntity}.
101
+ * @returns {{ description: string; content: { 'application/json': { schema: SSchemaEl } }; } | undefined} An object containing the content schema, or `undefined` if no metadata is available for the entity.
102
+ */
14
103
  static contentSchemaFromEntity<T extends CoreEntity>(entity: T): {
15
104
  description: string;
16
105
  content: {
@@ -20,9 +109,91 @@ export default class SPathUtil {
20
109
  };
21
110
  } | undefined;
22
111
  /**
23
- * generate global schema
24
- * @param e
112
+ * Generates a mapping from entity names to their corresponding schema objects.
113
+ *
114
+ * @param {CoreEntity[]} e The entities for which schema entries should be generated.
115
+ * @return {SKey<SSchemaEl>} An object whose keys are entity names and values are the schemas derived from those entities.
25
116
  */
26
117
  static schemaEntryGen(...e: CoreEntity[]): SKey<SSchemaEl>;
118
+ /**
119
+ * Builds a JSON schema representation for an entity view that includes both the
120
+ * entity data and its related entity map.
121
+ *
122
+ * @param entity The primary entity used to construct the `dat` portion of the schema.
123
+ * @param entityMap The related entity map used to construct the `join_map` portion of the schema.
124
+ * @returns A {@link SSchemaEl} object schema with properties `i`, `dat`, and `join_map`.
125
+ */
27
126
  static schemaFromEntityView<A extends CoreEntity, B extends CoreEntity>(entity: A, entityMap: B): SSchemaEl;
127
+ /**
128
+ * Extends an entity schema object by merging additional schema options.
129
+ *
130
+ * @param {CoreEntity} entity
131
+ * The entity for which the schema should be extended.
132
+ *
133
+ * @param {...Object} options
134
+ * One or more objects defining schema extensions. Each object may contain:
135
+ * - `key` (string): The property key to add or extend.
136
+ * - `list` (boolean, optional): Indicates whether the property is a list.
137
+ * - `entity` (CoreEntity, optional): The entity type for the property.
138
+ * - `schema` (SSchemaEl, optional): A custom schema definition for the property.
139
+ * - `required` (boolean, optional): Whether the property is required.
140
+ *
141
+ * @return {SSchemaEl}
142
+ * The resulting schema element. If a single property is returned by
143
+ * `extendEntitySchema`, its schema is returned directly; otherwise an
144
+ * object schema with a type of `'object'` is returned.
145
+ */
146
+ static extendEntitySchemaObject(entity: CoreEntity, ...options: {
147
+ key: string;
148
+ list?: boolean;
149
+ entity?: CoreEntity;
150
+ schema?: SSchemaEl;
151
+ required?: boolean;
152
+ }[]): SSchemaEl;
153
+ /**
154
+ * Extends the schema of a given {@link CoreEntity} with additional properties.
155
+ *
156
+ * @param {CoreEntity} entity
157
+ * The entity whose schema will be extended.
158
+ *
159
+ * @param {...{
160
+ * key: string,
161
+ * list?: boolean,
162
+ * entity?: CoreEntity,
163
+ * schema?: SSchemaEl,
164
+ * required?: boolean
165
+ * }} options
166
+ * One or more option objects specifying the extensions to apply. Each option
167
+ * may provide either a direct schema (`schema`) or an entity reference
168
+ * (`entity`). The `list` flag indicates whether the property should be
169
+ * represented as an array of the provided schema. The `required` flag
170
+ * adds the property to the schema’s required list.
171
+ *
172
+ * @returns {SKey<SSchemaEl>}
173
+ * An object containing the updated schema for the entity, keyed by the
174
+ * entity’s name. If the entity metadata cannot be found, an empty
175
+ * object is returned.
176
+ */
177
+ static extendEntitySchema(entity: CoreEntity, ...options: {
178
+ key: string;
179
+ list?: boolean;
180
+ entity?: CoreEntity;
181
+ schema?: SSchemaEl;
182
+ required?: boolean;
183
+ }[]): SKey<SSchemaEl>;
184
+ /**
185
+ * Reduces the entity schema to a single schema element or a generic object.
186
+ *
187
+ * @param entity The entity whose schema should be reduced.
188
+ * @param keys Optional list of keys to include in the reduced schema. If omitted, all keys are considered.
189
+ * @return Returns the schema element of the sole key if only one key is present; otherwise, returns a generic object schema with type `'object'`. */
190
+ static reduceEntitySchemaObject<T extends CoreEntity>(entity: T, ...keys: (keyof T)[]): SSchemaEl;
191
+ /**
192
+ * Creates a reduced version of an entity's schema by excluding specified properties.
193
+ *
194
+ * @param {CoreEntity} entity - The entity whose schema is to be processed.
195
+ * @param {...string} keys - Property names to remove from the schema's `properties` and `required` lists.
196
+ *
197
+ * @returns */
198
+ static reduceEntitySchema<T extends CoreEntity>(entity: T, ...keys: (keyof T)[]): SKey<SSchemaEl>;
28
199
  }