@streamline-pulse/formkrafter-core 0.32.1 → 0.33.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/dist/index.d.ts CHANGED
@@ -48,4 +48,4 @@ export type { SpecSourceService, FetchSpecSourceDefaults } from "./services/spec
48
48
  export { FetchOptionSourceService } from "./services/option_source_service.js";
49
49
  export { FilePickOptions, FilePickerService } from "./services/file_picker_service.js";
50
50
  export { DocumentReading, DocumentReadOptions, DocumentReaderService, FetchDocumentReaderDefaults, FetchDocumentReaderService, readDocumentReading, } from "./services/document_reader_service.js";
51
- export type { OptionSourceService, FetchOptionSourceDefaults } from "./services/option_source_service.js";
51
+ export type { OptionSourceService, OptionCatalogEntry, FetchOptionSourceDefaults } from "./services/option_source_service.js";
package/dist/index.js CHANGED
@@ -8217,6 +8217,37 @@ class FetchOptionSourceService {
8217
8217
  }
8218
8218
  return pending;
8219
8219
  }
8220
+ catalogs;
8221
+ listCatalogs() {
8222
+ const url = this.defaults.catalogsUrl ?? this.defaults.baseUrl;
8223
+ if (!url)
8224
+ return Promise.resolve([]);
8225
+ if (!this.catalogs) {
8226
+ const fetchImplementation = this.defaults.fetch ?? globalThis.fetch.bind(globalThis);
8227
+ this.catalogs = fetchImplementation(url, { headers: this.defaults.headers, credentials: this.defaults.credentials }).then(async (response) => {
8228
+ if (!response.ok)
8229
+ throw new Error(`Failed to list option catalogs (${response.status})`);
8230
+ const body = await response.json();
8231
+ const rows = Array.isArray(body) ? body : Array.isArray(body?.data) ? body.data : [];
8232
+ return rows.flatMap((row) => {
8233
+ const entry = row ?? {};
8234
+ const ref = String(entry.ref ?? entry.value ?? "");
8235
+ if (!ref)
8236
+ return [];
8237
+ return [
8238
+ {
8239
+ ref,
8240
+ label: String(entry.name ?? entry.label ?? ref),
8241
+ ...typeof entry.description === "string" && { description: entry.description },
8242
+ ...Array.isArray(entry.filters) && { filters: entry.filters.map(String) }
8243
+ }
8244
+ ];
8245
+ });
8246
+ });
8247
+ this.catalogs.catch(() => this.catalogs = undefined);
8248
+ }
8249
+ return this.catalogs;
8250
+ }
8220
8251
  }
8221
8252
 
8222
8253
  // lib/services/document_reader_service.ts
@@ -10128,5 +10159,5 @@ export {
10128
10159
  wrapBrickData
10129
10160
  };
10130
10161
 
10131
- //# debugId=341A25F9D52B15BE64756E2164756E21
10162
+ //# debugId=C3D4B3C74EC4E31D64756E2164756E21
10132
10163
  //# sourceMappingURL=index.js.map