@synap-core/workspace-templates 0.6.3 → 0.6.4
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 +43 -1
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/catalog.test.ts +99 -1
- package/src/catalog.ts +93 -0
- package/src/index.ts +9 -1
package/dist/index.d.ts
CHANGED
|
@@ -652,6 +652,48 @@ interface AssembleCatalogInput {
|
|
|
652
652
|
* per-source `isPrivate` control (e.g. keeping browse and `/mine` distinct).
|
|
653
653
|
*/
|
|
654
654
|
declare function assembleCatalog(input: AssembleCatalogInput): MergeCatalogResult;
|
|
655
|
+
/** A template a pod has installed — the door reads `settings.packageVersion` off the workspace row. */
|
|
656
|
+
interface InstalledTemplate {
|
|
657
|
+
slug: string;
|
|
658
|
+
version: string;
|
|
659
|
+
}
|
|
660
|
+
/** Per-slug verdict: is a newer catalog version available than what's installed? */
|
|
661
|
+
interface TemplateUpdateCheck {
|
|
662
|
+
slug: string;
|
|
663
|
+
installedVersion: string;
|
|
664
|
+
/** `undefined` when the slug has no matching catalog entry, or a bundled winner and no `bundleVersion` was passed. */
|
|
665
|
+
latestVersion: string | undefined;
|
|
666
|
+
updateAvailable: boolean;
|
|
667
|
+
/** Passed through from the winning catalog entry, so callers can route private updates through the authed path. */
|
|
668
|
+
isPrivate?: boolean;
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* `true` when `version` is a CP content-hash stamp (`"h-<hash>"`) rather than semver.
|
|
672
|
+
* Content-hash versions are NOT semver-comparable — see `computeTemplateUpdates`.
|
|
673
|
+
*/
|
|
674
|
+
declare function isHashVersion(version: string | undefined): boolean;
|
|
675
|
+
/**
|
|
676
|
+
* Compute, per installed template, whether the CATALOG (bundled + remote,
|
|
677
|
+
* already merged by `mergeCatalog`/`assembleCatalog`) carries a newer version
|
|
678
|
+
* than what the pod installed — the shared "update available" check all three
|
|
679
|
+
* doors (browser, synap-app, CLI) reuse instead of re-deriving it.
|
|
680
|
+
*
|
|
681
|
+
* `installed` and `catalog` are BOTH already-fetched/computed by the caller —
|
|
682
|
+
* this stays PURE, same as the rest of this module (no fetch, no auth).
|
|
683
|
+
*
|
|
684
|
+
* The catalog's winning entry carries the latest version signal two ways:
|
|
685
|
+
* • `source: "remote"` → `remote.definition?.sourcePackage?.version` (semver
|
|
686
|
+
* OR, going forward, a CP content-hash `"h-<hash>"` stamp).
|
|
687
|
+
* • `source: "bundled"` → bundled entries carry no version field at all
|
|
688
|
+
* (`TemplateMeta` has none); pass `bundleVersion` (this client's compiled
|
|
689
|
+
* package version, the same value fed to `mergeCatalog`) to compare against
|
|
690
|
+
* it. Omit `bundleVersion` and bundled-backed slugs report `latestVersion:
|
|
691
|
+
* undefined, updateAvailable: false` (nothing comparable).
|
|
692
|
+
*
|
|
693
|
+
* A slug with no matching catalog entry ⇒ `updateAvailable: false`,
|
|
694
|
+
* `latestVersion: undefined` — there is nothing to update TO.
|
|
695
|
+
*/
|
|
696
|
+
declare function computeTemplateUpdates(installed: InstalledTemplate[], catalog: CatalogEntry[], bundleVersion?: string): TemplateUpdateCheck[];
|
|
655
697
|
|
|
656
698
|
/**
|
|
657
699
|
* @synap-core/workspace-templates — Definition adapter
|
|
@@ -810,4 +852,4 @@ interface PackageDefinitionOutput {
|
|
|
810
852
|
*/
|
|
811
853
|
declare function toPackageDefinition(slugOrYaml: string | WorkspaceYaml): PackageDefinitionOutput;
|
|
812
854
|
|
|
813
|
-
export { type AssembleCatalogInput, type BentoViewBlockWire, type BentoWidgetBlockWire, type BundledCatalogEntry, type BundledEntry, type CatalogEntry, type CpPackageRow, type MergeCatalogInput, type MergeCatalogResult, PACKAGE_DEPENDENCY_KINDS, type PackageDefinitionOutput, type PackageDependencyKind, type RemoteCatalogEntry, type RemoteEntry, type RemoteSourceStatus, type SplitBentoBlocks, type TemplateAppKind, type TemplateAppRef, type TemplateBentoBlock, type TemplateDefaultSource, type TemplateDependency, type TemplateDisplayTemplate, type TemplateEntityLink, type TemplateExtendsRef, type TemplateIntegration, type TemplateLayoutConfig, type TemplateMeta, type TemplateOnboarding, type TemplateOnboardingCollectTarget, type TemplatePlaybook, type TemplatePlaybookParam, type TemplateProfile, type TemplateProfileEntityBentoTemplates, type TemplateProperty, type TemplateSeedEntity, type TemplateSidebarItem, type TemplateSidebarSurface, type TemplateSourceRole, type TemplateSuggestedRelation, type TemplateView, type ToDefinitionResult, WORKSPACE_TEMPLATES, type WorkspaceDefinitionInput, type WorkspaceTemplateSlug, type WorkspaceYaml, assembleCatalog, getWorkspaceTemplate, listPublicTemplates, listWorkspaceTemplates, mergeCatalog, rowToRemoteEntry, splitBentoBlocks, toPackageDefinition, toWorkspaceDefinition };
|
|
855
|
+
export { type AssembleCatalogInput, type BentoViewBlockWire, type BentoWidgetBlockWire, type BundledCatalogEntry, type BundledEntry, type CatalogEntry, type CpPackageRow, type InstalledTemplate, type MergeCatalogInput, type MergeCatalogResult, PACKAGE_DEPENDENCY_KINDS, type PackageDefinitionOutput, type PackageDependencyKind, type RemoteCatalogEntry, type RemoteEntry, type RemoteSourceStatus, type SplitBentoBlocks, type TemplateAppKind, type TemplateAppRef, type TemplateBentoBlock, type TemplateDefaultSource, type TemplateDependency, type TemplateDisplayTemplate, type TemplateEntityLink, type TemplateExtendsRef, type TemplateIntegration, type TemplateLayoutConfig, type TemplateMeta, type TemplateOnboarding, type TemplateOnboardingCollectTarget, type TemplatePlaybook, type TemplatePlaybookParam, type TemplateProfile, type TemplateProfileEntityBentoTemplates, type TemplateProperty, type TemplateSeedEntity, type TemplateSidebarItem, type TemplateSidebarSurface, type TemplateSourceRole, type TemplateSuggestedRelation, type TemplateUpdateCheck, type TemplateView, type ToDefinitionResult, WORKSPACE_TEMPLATES, type WorkspaceDefinitionInput, type WorkspaceTemplateSlug, type WorkspaceYaml, assembleCatalog, computeTemplateUpdates, getWorkspaceTemplate, isHashVersion, listPublicTemplates, listWorkspaceTemplates, mergeCatalog, rowToRemoteEntry, splitBentoBlocks, toPackageDefinition, toWorkspaceDefinition };
|
package/dist/index.js
CHANGED
|
@@ -25136,6 +25136,33 @@ function assembleCatalog(input) {
|
|
|
25136
25136
|
remoteStatus: input.remoteStatus
|
|
25137
25137
|
});
|
|
25138
25138
|
}
|
|
25139
|
+
function isHashVersion(version) {
|
|
25140
|
+
return typeof version === "string" && version.startsWith("h-");
|
|
25141
|
+
}
|
|
25142
|
+
function isNewerVersion(installedVersion, latestVersion) {
|
|
25143
|
+
if (latestVersion === void 0) return false;
|
|
25144
|
+
if (isHashVersion(installedVersion) || isHashVersion(latestVersion)) {
|
|
25145
|
+
return installedVersion !== latestVersion;
|
|
25146
|
+
}
|
|
25147
|
+
return remoteIsStrictlyNewer(latestVersion, installedVersion);
|
|
25148
|
+
}
|
|
25149
|
+
function computeTemplateUpdates(installed, catalog, bundleVersion) {
|
|
25150
|
+
const bySlug = new Map(catalog.map((entry) => [entry.slug, entry]));
|
|
25151
|
+
return installed.map(({ slug, version: installedVersion }) => {
|
|
25152
|
+
const entry = bySlug.get(slug);
|
|
25153
|
+
if (!entry) {
|
|
25154
|
+
return { slug, installedVersion, latestVersion: void 0, updateAvailable: false };
|
|
25155
|
+
}
|
|
25156
|
+
const latestVersion = entry.source === "remote" ? entry.remote.definition?.sourcePackage?.version : bundleVersion;
|
|
25157
|
+
return {
|
|
25158
|
+
slug,
|
|
25159
|
+
installedVersion,
|
|
25160
|
+
latestVersion,
|
|
25161
|
+
updateAvailable: isNewerVersion(installedVersion, latestVersion),
|
|
25162
|
+
isPrivate: entry.isPrivate
|
|
25163
|
+
};
|
|
25164
|
+
});
|
|
25165
|
+
}
|
|
25139
25166
|
|
|
25140
25167
|
// src/define.ts
|
|
25141
25168
|
function resolveBlockKind(block) {
|
|
@@ -25264,7 +25291,9 @@ export {
|
|
|
25264
25291
|
PACKAGE_DEPENDENCY_KINDS,
|
|
25265
25292
|
WORKSPACE_TEMPLATES,
|
|
25266
25293
|
assembleCatalog,
|
|
25294
|
+
computeTemplateUpdates,
|
|
25267
25295
|
getWorkspaceTemplate,
|
|
25296
|
+
isHashVersion,
|
|
25268
25297
|
listPublicTemplates,
|
|
25269
25298
|
listWorkspaceTemplates,
|
|
25270
25299
|
mergeCatalog,
|