@shop-os/modelkit 0.2.4 → 0.2.5
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 +5 -0
- package/dist/catalog.cjs +21 -2
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.d.cts +14 -1
- package/dist/catalog.d.ts +14 -1
- package/dist/catalog.js +21 -2
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +22 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +20 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/catalog.d.cts
CHANGED
|
@@ -413,6 +413,7 @@ declare class Catalog {
|
|
|
413
413
|
resolveId(idOrAlias: string): string | undefined;
|
|
414
414
|
get(idOrAlias: string): CatalogModel | undefined;
|
|
415
415
|
require(idOrAlias: string): CatalogModel;
|
|
416
|
+
/** Rows in picker order: `display.sortOrder` descending, then label. See `compareCatalogOrder`. */
|
|
416
417
|
list(filter?: {
|
|
417
418
|
type?: ModelType;
|
|
418
419
|
lifecycle?: Lifecycle[];
|
|
@@ -423,6 +424,18 @@ declare class Catalog {
|
|
|
423
424
|
replace(rows: CatalogModel[]): void;
|
|
424
425
|
}
|
|
425
426
|
|
|
427
|
+
/**
|
|
428
|
+
* Picker order for every surface: `display.sortOrder` descending (a higher
|
|
429
|
+
* number shows first), rows without one after the ordered ones, then `label`
|
|
430
|
+
* ascending (case-insensitive), then `id` so the order is total.
|
|
431
|
+
*
|
|
432
|
+
* pro-backend applies the same rule in SQL (`ORDER BY sortOrder DESC NULLS
|
|
433
|
+
* LAST, lower(label), id`); this comparator covers the snapshot and cache
|
|
434
|
+
* fallbacks and any consumer that sorts a subset.
|
|
435
|
+
*/
|
|
436
|
+
declare function compareCatalogOrder(a: CatalogModel, b: CatalogModel): number;
|
|
437
|
+
declare function sortCatalogRows<T extends CatalogModel>(rows: readonly T[]): T[];
|
|
438
|
+
|
|
426
439
|
/** Seeded from Cowork, Space Builder and trigger-workflows. See catalog/*.ts. */
|
|
427
440
|
declare const MODELS: CatalogModel[];
|
|
428
441
|
|
|
@@ -532,4 +545,4 @@ declare function isModelKitError(err: unknown): err is ModelKitError;
|
|
|
532
545
|
/** Resolve caller options against a catalog row, dispatching on `model.type`. */
|
|
533
546
|
declare function resolveOptions(model: CatalogModel, request: ImageRequest | VideoRequest | AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest | VideoRequest | AudioRequest>;
|
|
534
547
|
|
|
535
|
-
export { ADAPTER_IDS, type AdapterEndpoints, type AdapterId, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, type CatalogOrigin, CatalogSchema, type CatalogSource, type GeneratedImage, IMAGE_MODELS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, type JsonPrimitive, type JsonValue, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, OTHER_MODELS, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type ReferenceLimits, type RequiredInput, type ResolveResult, type Routing, type SupportedOption, TEXT_MODELS, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, isModelKitError, liveCatalog, liveState, nearestAspectRatio, primeCatalog, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions };
|
|
548
|
+
export { ADAPTER_IDS, type AdapterEndpoints, type AdapterId, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, type CatalogOrigin, CatalogSchema, type CatalogSource, type GeneratedImage, IMAGE_MODELS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, type JsonPrimitive, type JsonValue, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, OTHER_MODELS, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type ReferenceLimits, type RequiredInput, type ResolveResult, type Routing, type SupportedOption, TEXT_MODELS, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, compareCatalogOrder, isModelKitError, liveCatalog, liveState, nearestAspectRatio, primeCatalog, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions, sortCatalogRows };
|
package/dist/catalog.d.ts
CHANGED
|
@@ -413,6 +413,7 @@ declare class Catalog {
|
|
|
413
413
|
resolveId(idOrAlias: string): string | undefined;
|
|
414
414
|
get(idOrAlias: string): CatalogModel | undefined;
|
|
415
415
|
require(idOrAlias: string): CatalogModel;
|
|
416
|
+
/** Rows in picker order: `display.sortOrder` descending, then label. See `compareCatalogOrder`. */
|
|
416
417
|
list(filter?: {
|
|
417
418
|
type?: ModelType;
|
|
418
419
|
lifecycle?: Lifecycle[];
|
|
@@ -423,6 +424,18 @@ declare class Catalog {
|
|
|
423
424
|
replace(rows: CatalogModel[]): void;
|
|
424
425
|
}
|
|
425
426
|
|
|
427
|
+
/**
|
|
428
|
+
* Picker order for every surface: `display.sortOrder` descending (a higher
|
|
429
|
+
* number shows first), rows without one after the ordered ones, then `label`
|
|
430
|
+
* ascending (case-insensitive), then `id` so the order is total.
|
|
431
|
+
*
|
|
432
|
+
* pro-backend applies the same rule in SQL (`ORDER BY sortOrder DESC NULLS
|
|
433
|
+
* LAST, lower(label), id`); this comparator covers the snapshot and cache
|
|
434
|
+
* fallbacks and any consumer that sorts a subset.
|
|
435
|
+
*/
|
|
436
|
+
declare function compareCatalogOrder(a: CatalogModel, b: CatalogModel): number;
|
|
437
|
+
declare function sortCatalogRows<T extends CatalogModel>(rows: readonly T[]): T[];
|
|
438
|
+
|
|
426
439
|
/** Seeded from Cowork, Space Builder and trigger-workflows. See catalog/*.ts. */
|
|
427
440
|
declare const MODELS: CatalogModel[];
|
|
428
441
|
|
|
@@ -532,4 +545,4 @@ declare function isModelKitError(err: unknown): err is ModelKitError;
|
|
|
532
545
|
/** Resolve caller options against a catalog row, dispatching on `model.type`. */
|
|
533
546
|
declare function resolveOptions(model: CatalogModel, request: ImageRequest | VideoRequest | AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest | VideoRequest | AudioRequest>;
|
|
534
547
|
|
|
535
|
-
export { ADAPTER_IDS, type AdapterEndpoints, type AdapterId, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, type CatalogOrigin, CatalogSchema, type CatalogSource, type GeneratedImage, IMAGE_MODELS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, type JsonPrimitive, type JsonValue, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, OTHER_MODELS, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type ReferenceLimits, type RequiredInput, type ResolveResult, type Routing, type SupportedOption, TEXT_MODELS, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, isModelKitError, liveCatalog, liveState, nearestAspectRatio, primeCatalog, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions };
|
|
548
|
+
export { ADAPTER_IDS, type AdapterEndpoints, type AdapterId, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, type CatalogOrigin, CatalogSchema, type CatalogSource, type GeneratedImage, IMAGE_MODELS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, type JsonPrimitive, type JsonValue, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, OTHER_MODELS, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type ReferenceLimits, type RequiredInput, type ResolveResult, type Routing, type SupportedOption, TEXT_MODELS, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, compareCatalogOrder, isModelKitError, liveCatalog, liveState, nearestAspectRatio, primeCatalog, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions, sortCatalogRows };
|
package/dist/catalog.js
CHANGED
|
@@ -24,6 +24,22 @@ function isModelKitError(err) {
|
|
|
24
24
|
return err instanceof ModelKitError;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
// src/catalog/order.ts
|
|
28
|
+
function compareCatalogOrder(a, b) {
|
|
29
|
+
const sa = a.display?.sortOrder;
|
|
30
|
+
const sb = b.display?.sortOrder;
|
|
31
|
+
if (sa !== void 0 && sb !== void 0 && sa !== sb) return sb - sa;
|
|
32
|
+
if (sa !== void 0 && sb === void 0) return -1;
|
|
33
|
+
if (sa === void 0 && sb !== void 0) return 1;
|
|
34
|
+
return compareText(a.label.toLowerCase(), b.label.toLowerCase()) || compareText(a.id, b.id);
|
|
35
|
+
}
|
|
36
|
+
function compareText(a, b) {
|
|
37
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
38
|
+
}
|
|
39
|
+
function sortCatalogRows(rows) {
|
|
40
|
+
return [...rows].sort(compareCatalogOrder);
|
|
41
|
+
}
|
|
42
|
+
|
|
27
43
|
// src/catalog/registry.ts
|
|
28
44
|
var Catalog = class _Catalog {
|
|
29
45
|
byId = /* @__PURE__ */ new Map();
|
|
@@ -80,11 +96,12 @@ var Catalog = class _Catalog {
|
|
|
80
96
|
}
|
|
81
97
|
return model;
|
|
82
98
|
}
|
|
99
|
+
/** Rows in picker order: `display.sortOrder` descending, then label. See `compareCatalogOrder`. */
|
|
83
100
|
list(filter = {}) {
|
|
84
101
|
const lifecycles = filter.lifecycle ?? ["active"];
|
|
85
102
|
return [...this.byId.values()].filter(
|
|
86
103
|
(m) => (filter.type ? m.type === filter.type : true) && lifecycles.includes(m.lifecycle)
|
|
87
|
-
);
|
|
104
|
+
).sort(compareCatalogOrder);
|
|
88
105
|
}
|
|
89
106
|
/** Merge rows by id. Used for catalogOverride. */
|
|
90
107
|
withOverrides(rows) {
|
|
@@ -2571,6 +2588,7 @@ export {
|
|
|
2571
2588
|
OTHER_MODELS,
|
|
2572
2589
|
TEXT_MODELS,
|
|
2573
2590
|
VIDEO_MODELS,
|
|
2591
|
+
compareCatalogOrder,
|
|
2574
2592
|
isModelKitError,
|
|
2575
2593
|
liveCatalog,
|
|
2576
2594
|
liveState,
|
|
@@ -2580,6 +2598,7 @@ export {
|
|
|
2580
2598
|
resolveAudioOptions,
|
|
2581
2599
|
resolveImageOptions,
|
|
2582
2600
|
resolveOptions,
|
|
2583
|
-
resolveVideoOptions
|
|
2601
|
+
resolveVideoOptions,
|
|
2602
|
+
sortCatalogRows
|
|
2584
2603
|
};
|
|
2585
2604
|
//# sourceMappingURL=catalog.js.map
|