Skip to content

Commit 486d906

Browse files
iOvergaardclaude
andauthored
Publish @umbraco-cms/search types-only npm package (#133)
* Publish @umbraco-cms/search types-only npm package Adds TypeScript declaration publishing for the Core Client so third-party package authors get type safety when importing @umbraco-cms/search/global and @umbraco-cms/search/settings. - tsconfig.types.json: uses emitDeclarationOnly so tsc emits .d.ts files into dist-types/ without touching the existing dev/build config - package.json: renamed to @umbraco-cms/search, made public, added exports map (types-only, no JS — runtime resolution stays via Umbraco importmap), files: ["dist-types"], peerDependencies for @umbraco-cms/backoffice - .gitignore: ignores Client/dist-types/ - azure-pipeline.yml: generates declarations, versions with nbgv, packs and publishes as npm-types artifact; adds Deploy_Npm stage using npmAuthenticate@0 with the existing "NPM - Umbraco Backoffice" service connection, matching the pattern used in the main CMS pipeline Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Update package-lock.json after renaming Core Client package npm ci fails when the lock file doesn't match package.json. The package rename from @umbraco-cms/search-core-client to @umbraco-cms/search requires a lock file regeneration. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix boolean parameter comparison in Deploy_Npm condition ADO template boolean parameters expand to true/false (lowercase), so comparing against the string 'True' never matches. Use the unquoted boolean form instead. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Remove automatic npm deploy trigger on main/release tags Deploy_Npm now only runs when the npmDeploy parameter is explicitly set to true, consistent with how NuGet publishing works for this project. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Remove Deploy_Npm stage in favor of release pipeline The npm publish will be handled by a classic release pipeline configured in the DevOps UI, consuming the npm-types artifact published by the build stage. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Run nbgv cloud upfront to set pipeline build number Installs nbgv right after the .NET SDK setup and runs nbgv cloud so the pipeline build number reflects the package version. The npm version step now reuses the already-installed tool to fetch NpmPackageVersion. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Simplify npm pack pipeline steps - Add prepack script so npm pack always regenerates types, making the package self-consistent regardless of who runs it - Drop the explicit types:generate pipeline step (prepack handles it) - Merge version + pack into a single bash step with workingDirectory pointing directly at the workspace - Reuse the NBGV_NpmPackageVersion variable set by nbgv cloud instead of re-invoking nbgv get-version Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix nbgv cloud variable export and pack destination dir - nbgv cloud needs -a (--all-vars) to expose computed versions as ADO pipeline variables; without it, only the build number is updated and \$(NBGV_NpmPackageVersion) stays unresolved - npm pack --pack-destination does not create the target directory, so restore the mkdir -p that was incorrectly trimmed Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Expose manifest types, rename Examine workspace, and document npm package - Re-export ManifestSearchIndexDetailBox + MetaSearchIndexDetailBox from @umbraco-cms/search/global so extension authors can both reference the manifest type and have searchIndexDetailBox registered on the global UmbExtensionManifestMap - Drop declarationMap from tsconfig.types.json: maps reference src/ paths that are not shipped, so they cannot resolve in consumer node_modules and were dead weight (cuts published file count ~50%) - Rename the Examine workspace package from @umbraco-cms/search-examine-client to @umbraco-cms/search-examine to match the @umbraco-cms/search naming even while the package stays private - Add an installation section to docs/backoffice-extensions.md covering the npm package, the two entry points, and the peer dependency Verified by packing the tarball, installing it in a fresh test project alongside @umbraco-cms/backoffice, writing a searchIndexDetailBox extension, and confirming tsc --noEmit passes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Type ManifestSearchIndexDetailBox conditions as the full config union ManifestWithDynamicConditions defaults its conditions array to UmbConditionConfigBase, which strips away the typed properties contributed by augmentations like UmbSearchIndexProviderNameConditionConfig. Passing UmbExtensionConditionConfig (the global union of every registered condition config) restores narrowing so extension authors can write \`{ alias: 'Umb.Search.Condition.IndexProviderName', oneOf: [...] }\` inline without an explicit cast. Found via end-to-end test against an installed @umbraco-cms/search tarball. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1a17317 commit 486d906

8 files changed

Lines changed: 57 additions & 9 deletions

File tree

build/azure-pipeline.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ stages:
3737
inputs:
3838
useGlobalJson: true
3939

40+
- bash: |
41+
dotnet tool install --tool-path . nbgv
42+
./nbgv cloud -a
43+
displayName: Set build version using nbgv
44+
workingDirectory: src
45+
4046
# Client
4147
- task: NodeTool@0
4248
displayName: Use Node.js
@@ -66,6 +72,19 @@ stages:
6672
displayName: Build Client
6773
workingDirectory: src
6874

75+
- bash: |
76+
mkdir -p $(Build.ArtifactStagingDirectory)/npm
77+
npm version $(NBGV_NpmPackageVersion) --allow-same-version --no-git-tag-version
78+
npm pack --pack-destination $(Build.ArtifactStagingDirectory)/npm
79+
displayName: Pack npm types package
80+
workingDirectory: src/Umbraco.Cms.Search.Core.Client/Client
81+
82+
- task: PublishPipelineArtifact@1
83+
displayName: Publish npm types artifact
84+
inputs:
85+
targetPath: $(Build.ArtifactStagingDirectory)/npm
86+
artifactName: npm-types
87+
6988
# Cache and restore NuGet packages
7089
- task: Cache@2
7190
condition: ${{ parameters.cache_nuget }}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
wwwroot/App_Plugins/
2+
Client/dist-types/

src/Umbraco.Cms.Search.Core.Client/Client/package.json

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
{
2-
"name": "@umbraco-cms/search-core-client",
3-
"private": true,
2+
"name": "@umbraco-cms/search",
43
"version": "0.0.0",
54
"type": "module",
5+
"exports": {
6+
"./global": {
7+
"types": "./dist-types/global/index.d.ts"
8+
},
9+
"./settings": {
10+
"types": "./dist-types/settings/index.d.ts"
11+
}
12+
},
13+
"files": ["dist-types"],
14+
"peerDependencies": {
15+
"@umbraco-cms/backoffice": ">=17.0.0"
16+
},
617
"scripts": {
718
"watch": "vite build --watch",
819
"build": "tsc && vite build",
20+
"types:generate": "tsc -p tsconfig.types.json",
21+
"prepack": "npm run types:generate",
922
"generate-client": "node ../../scripts/generate-openapi.js https://localhost:44324/umbraco/swagger/search/swagger.json src/settings/api",
1023
"lint": "eslint . --max-warnings 0",
1124
"lint:fix": "eslint . --fix",

src/Umbraco.Cms.Search.Core.Client/Client/src/bundle/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import type {
44
} from '@umbraco-cms/backoffice/extension-api';
55

66
export interface ManifestSearchIndexDetailBox
7-
extends ManifestElement, ManifestWithDynamicConditions {
7+
extends ManifestElement,
8+
ManifestWithDynamicConditions<UmbExtensionConditionConfig> {
89
type: 'searchIndexDetailBox';
910
meta?: MetaSearchIndexDetailBox;
1011
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from './constants.js';
22
export * from './search.global-context.js';
3+
export type { ManifestSearchIndexDetailBox, MetaSearchIndexDetailBox } from '../bundle/types.js';
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"noEmit": false,
5+
"emitDeclarationOnly": true,
6+
"declaration": true,
7+
"declarationDir": "dist-types"
8+
}
9+
}

src/Umbraco.Cms.Search.Provider.Examine/Client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@umbraco-cms/search-examine-client",
2+
"name": "@umbraco-cms/search-examine",
33
"private": true,
44
"version": "0.0.0",
55
"type": "module",

src/package-lock.json

Lines changed: 9 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)