Change model source generator to yield data array with layer entries
Change AsyncCatalogModelSourceGenerator from yielding
{ layers: CatalogModelLayer[] } to { data: Array<{ layer: CatalogModelLayer }> }
so that additional contextual data can be attached alongside each layer
in the future.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Fredrik Adelöw <freben@spotify.com>
This commit is contained in:
@@ -16,7 +16,9 @@ export interface AlphaEntity extends Entity {
|
||||
// @alpha
|
||||
export type AsyncCatalogModelSourceGenerator = AsyncGenerator<
|
||||
{
|
||||
layers: CatalogModelLayer[];
|
||||
data: Array<{
|
||||
layer: CatalogModelLayer;
|
||||
}>;
|
||||
},
|
||||
void,
|
||||
void
|
||||
|
||||
@@ -37,6 +37,6 @@ export class StaticCatalogModelSource implements CatalogModelSource {
|
||||
async *read(
|
||||
_options?: CatalogModelSourceReadOptions,
|
||||
): AsyncCatalogModelSourceGenerator {
|
||||
yield { layers: this.#layers };
|
||||
yield { data: this.#layers.map(layer => ({ layer })) };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ export interface CatalogModelSourceReadOptions {
|
||||
* @alpha
|
||||
*/
|
||||
export type AsyncCatalogModelSourceGenerator = AsyncGenerator<
|
||||
{ layers: CatalogModelLayer[] },
|
||||
{ data: Array<{ layer: CatalogModelLayer }> },
|
||||
void,
|
||||
void
|
||||
>;
|
||||
@@ -49,7 +49,7 @@ export type AsyncCatalogModelSourceGenerator = AsyncGenerator<
|
||||
* class MyCatalogModelSource implements CatalogModelSource {
|
||||
* async *read() {
|
||||
* yield {
|
||||
* layers: [defaultCatalogEntityModel]
|
||||
* data: [{ layer: defaultCatalogEntityModel }]
|
||||
* };
|
||||
* }
|
||||
* }
|
||||
|
||||
@@ -62,11 +62,11 @@ export class ModelHolder {
|
||||
try {
|
||||
const result = await iter.next();
|
||||
readyCount += 1;
|
||||
const ls = result.value?.layers ?? [];
|
||||
for (const layer of ls) {
|
||||
logger.info(`Loaded catalog model layer: ${layer.layerId}`);
|
||||
const entries = result.value?.data ?? [];
|
||||
for (const entry of entries) {
|
||||
logger.info(`Loaded catalog model layer: ${entry.layer.layerId}`);
|
||||
}
|
||||
return ls;
|
||||
return entries.map(entry => entry.layer);
|
||||
} finally {
|
||||
await iter.return(undefined);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user