@speclynx/apidom-core 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.4.0](https://github.com/speclynx/apidom/compare/v2.3.0...v2.4.0) (2026-01-29)
7
+
8
+ ### Features
9
+
10
+ - **core:** use standardized field inspection ([#52](https://github.com/speclynx/apidom/issues/52)) ([cc4506c](https://github.com/speclynx/apidom/commit/cc4506c5cbd4bd03943e271ef93a7ab5574ac978))
11
+
6
12
  # [2.3.0](https://github.com/speclynx/apidom/compare/v2.2.3...v2.3.0) (2026-01-27)
7
13
 
8
14
  **Note:** Version bump only for package @speclynx/apidom-core
package/README.md CHANGED
@@ -651,3 +651,44 @@ const numberElement = new NumberElement(1);
651
651
 
652
652
  toString(numberElement); // => '{"element":"number","content":1}'
653
653
  ```
654
+
655
+ ---
656
+
657
+ ## Field introspection
658
+
659
+ ### fixedFields
660
+
661
+ Returns the fixed fields for an Element class or instance.
662
+ This is useful for introspecting which fields an element type supports.
663
+
664
+ ```js
665
+ import { fixedFields } from '@speclynx/apidom-core';
666
+ import { InfoElement } from '@speclynx/apidom-ns-openapi-3-1';
667
+
668
+ // Get fixed fields as array
669
+ const fields = fixedFields(InfoElement);
670
+ // => [{ name: 'title', ... }, { name: 'description', ... }, { name: 'termsOfService', ... }, ...]
671
+
672
+ // Get fixed fields from an instance
673
+ const infoElement = new InfoElement({ title: 'My API' });
674
+ const fieldsFromInstance = fixedFields(infoElement);
675
+ // => [{ name: 'title', ... }, { name: 'description', ... }, { name: 'termsOfService', ... }, ...]
676
+ ```
677
+
678
+ #### indexed option
679
+
680
+ Use the `indexed` option for O(1) lookups by field name:
681
+
682
+ ```js
683
+ import { fixedFields } from '@speclynx/apidom-core';
684
+ import { InfoElement } from '@speclynx/apidom-ns-openapi-3-1';
685
+
686
+ // Get fixed fields as indexed object for O(1) lookups
687
+ const fieldsIndex = fixedFields(InfoElement, { indexed: true });
688
+ // => { title: { name: 'title', ... }, description: { name: 'description', ... }, ... }
689
+
690
+ // Check if a field exists
691
+ if (Object.hasOwn(fieldsIndex, 'description')) {
692
+ // field exists
693
+ }
694
+ ```
@@ -17352,6 +17352,57 @@ function _includes(a, list) {
17352
17352
 
17353
17353
  /***/ },
17354
17354
 
17355
+ /***/ 6269
17356
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
17357
+
17358
+ __webpack_require__.r(__webpack_exports__);
17359
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
17360
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
17361
+ /* harmony export */ fixedFields: () => (/* binding */ fixedFields)
17362
+ /* harmony export */ });
17363
+ /* harmony import */ var _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(728);
17364
+
17365
+
17366
+ /**
17367
+ * Represents a fixed field definition.
17368
+ * @public
17369
+ */
17370
+
17371
+ /**
17372
+ * Returns the fixed fields for an Element class or instance.
17373
+ *
17374
+ * @param elementOrClass - Element instance or class
17375
+ * @param options - Options for return format
17376
+ * @returns Array of fixed fields, or object indexed by name if options.indexed is true
17377
+ *
17378
+ * @example
17379
+ * ```ts
17380
+ * import { fixedFields } from '@speclynx/apidom-core';
17381
+ *
17382
+ * // Get fixed fields as array
17383
+ * const fields = fixedFields(ParameterElement);
17384
+ *
17385
+ * // Get fixed fields as indexed object for O(1) lookups
17386
+ * const fieldsIndex = fixedFields(ParameterElement, { indexed: true });
17387
+ * if (Object.hasOwn(fieldsIndex, 'description')) {
17388
+ * // field exists
17389
+ * }
17390
+ * ```
17391
+ *
17392
+ * @public
17393
+ */
17394
+ function fixedFields(elementOrClass, options) {
17395
+ const constructor = elementOrClass instanceof _speclynx_apidom_datamodel__WEBPACK_IMPORTED_MODULE_0__["default"] ? elementOrClass.constructor : elementOrClass;
17396
+ const fields = constructor.fixedFields ?? [];
17397
+ if (options?.indexed) {
17398
+ return Object.fromEntries(fields.map(f => [f.name, f]));
17399
+ }
17400
+ return fields;
17401
+ }
17402
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (fixedFields);
17403
+
17404
+ /***/ },
17405
+
17355
17406
  /***/ 6390
17356
17407
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
17357
17408
 
@@ -28662,6 +28713,7 @@ __webpack_require__.r(__webpack_exports__);
28662
28713
  /* harmony export */ defaultIdentityManager: () => (/* reexport safe */ _identity_index_ts__WEBPACK_IMPORTED_MODULE_7__.defaultIdentityManager),
28663
28714
  /* harmony export */ dehydrate: () => (/* reexport safe */ _transformers_dehydrate_ts__WEBPACK_IMPORTED_MODULE_13__["default"]),
28664
28715
  /* harmony export */ dispatchRefractorPlugins: () => (/* reexport safe */ _refractor_plugins_dispatcher_index_ts__WEBPACK_IMPORTED_MODULE_0__.dispatchPluginsSync),
28716
+ /* harmony export */ fixedFields: () => (/* reexport safe */ _fields_index_ts__WEBPACK_IMPORTED_MODULE_19__.fixedFields),
28665
28717
  /* harmony export */ from: () => (/* reexport safe */ _transformers_from_ts__WEBPACK_IMPORTED_MODULE_9__["default"]),
28666
28718
  /* harmony export */ mergeLeft: () => (/* reexport safe */ _merge_merge_left_ts__WEBPACK_IMPORTED_MODULE_18__["default"]),
28667
28719
  /* harmony export */ mergeRight: () => (/* reexport safe */ _merge_merge_right_ts__WEBPACK_IMPORTED_MODULE_17__["default"]),
@@ -28694,6 +28746,7 @@ __webpack_require__.r(__webpack_exports__);
28694
28746
  /* harmony import */ var _merge_deepmerge_ts__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(4386);
28695
28747
  /* harmony import */ var _merge_merge_right_ts__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(7715);
28696
28748
  /* harmony import */ var _merge_merge_left_ts__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(9763);
28749
+ /* harmony import */ var _fields_index_ts__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(6269);
28697
28750
 
28698
28751
 
28699
28752
 
@@ -28739,6 +28792,7 @@ __webpack_require__.r(__webpack_exports__);
28739
28792
 
28740
28793
 
28741
28794
 
28795
+
28742
28796
  /******/ return __webpack_exports__;
28743
28797
  /******/ })()
28744
28798
  ;