refactor: rename AIResource to AiResource for PascalCase consistency
Signed-off-by: benjdlambert <ben@blam.sh>
This commit is contained in:
@@ -2,4 +2,4 @@
|
||||
'@backstage/plugin-catalog-backend-module-ai-resource-entity-model': minor
|
||||
---
|
||||
|
||||
Introduced the `AIResource` catalog entity kind as an opt-in backend module. Install this module to register support for `AIResource` entities in your catalog, used to represent contextual information consumed by AI coding tools such as skills and rules.
|
||||
Introduced the `AiResource` catalog entity kind as an opt-in backend module. Install this module to register support for `AiResource` entities in your catalog, used to represent contextual information consumed by AI coding tools such as skills and rules.
|
||||
|
||||
+1
-1
@@ -287,7 +287,7 @@ catalog:
|
||||
pullRequestBranchName: backstage-integration
|
||||
rules:
|
||||
- allow:
|
||||
- AIResource
|
||||
- AiResource
|
||||
- Component
|
||||
- API
|
||||
- Resource
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
apiVersion: backstage.io/v1alpha1
|
||||
kind: AIResource
|
||||
kind: AiResource
|
||||
metadata:
|
||||
name: frontend-design
|
||||
description: Skill for creating production-grade frontend interfaces using the internal design system
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
apiVersion: backstage.io/v1alpha1
|
||||
kind: AIResource
|
||||
kind: AiResource
|
||||
metadata:
|
||||
name: use-internal-apis
|
||||
description: Agents must use internal API clients instead of raw HTTP calls
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# @backstage/plugin-catalog-backend-module-ai-resource-entity-model
|
||||
|
||||
Adds support for the `AIResource` entity kind to the catalog backend plugin. AI resources represent contextual information consumed by AI coding tools, such as skills and rules.
|
||||
Adds support for the `AiResource` entity kind to the catalog backend plugin. AI resources represent contextual information consumed by AI coding tools, such as skills and rules.
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -16,7 +16,7 @@ backend.add(
|
||||
|
||||
```yaml
|
||||
apiVersion: backstage.io/v1alpha1
|
||||
kind: AIResource
|
||||
kind: AiResource
|
||||
metadata:
|
||||
name: frontend-design
|
||||
description: Skill for creating production-grade frontend interfaces
|
||||
|
||||
@@ -8,16 +8,16 @@ import { Entity } from '@backstage/catalog-model';
|
||||
import { KindValidator } from '@backstage/catalog-model';
|
||||
|
||||
// @public
|
||||
export type AIResourceEntityV1alpha1 =
|
||||
| AIResourceEntityV1alpha1Default
|
||||
| SkillAIResourceEntityV1alpha1;
|
||||
export type AiResourceEntityV1alpha1 =
|
||||
| AiResourceEntityV1alpha1Default
|
||||
| SkillAiResourceEntityV1alpha1;
|
||||
|
||||
// @public
|
||||
export interface AIResourceEntityV1alpha1Default extends Entity {
|
||||
export interface AiResourceEntityV1alpha1Default extends Entity {
|
||||
// (undocumented)
|
||||
apiVersion: 'backstage.io/v1alpha1';
|
||||
// (undocumented)
|
||||
kind: 'AIResource';
|
||||
kind: 'AiResource';
|
||||
// (undocumented)
|
||||
spec: {
|
||||
type: string;
|
||||
@@ -31,25 +31,25 @@ export interface AIResourceEntityV1alpha1Default extends Entity {
|
||||
export const aiResourceEntityV1alpha1Validator: KindValidator;
|
||||
|
||||
// @public
|
||||
const catalogModuleAIResourceEntityModel: BackendFeature;
|
||||
export default catalogModuleAIResourceEntityModel;
|
||||
const catalogModuleAiResourceEntityModel: BackendFeature;
|
||||
export default catalogModuleAiResourceEntityModel;
|
||||
|
||||
// @public
|
||||
export const isAIResourceEntity: (
|
||||
export const isAiResourceEntity: (
|
||||
entity: Entity,
|
||||
) => entity is AIResourceEntityV1alpha1;
|
||||
) => entity is AiResourceEntityV1alpha1;
|
||||
|
||||
// @public
|
||||
export const isSkillAIResourceEntity: (
|
||||
export const isSkillAiResourceEntity: (
|
||||
entity: Entity,
|
||||
) => entity is SkillAIResourceEntityV1alpha1;
|
||||
) => entity is SkillAiResourceEntityV1alpha1;
|
||||
|
||||
// @public
|
||||
export interface SkillAIResourceEntityV1alpha1 extends Entity {
|
||||
export interface SkillAiResourceEntityV1alpha1 extends Entity {
|
||||
// (undocumented)
|
||||
apiVersion: 'backstage.io/v1alpha1';
|
||||
// (undocumented)
|
||||
kind: 'AIResource';
|
||||
kind: 'AiResource';
|
||||
// (undocumented)
|
||||
spec: {
|
||||
type: 'skill';
|
||||
@@ -64,5 +64,5 @@ export interface SkillAIResourceEntityV1alpha1 extends Entity {
|
||||
}
|
||||
|
||||
// @public
|
||||
export const skillAIResourceEntityV1alpha1Validator: KindValidator;
|
||||
export const skillAiResourceEntityV1alpha1Validator: KindValidator;
|
||||
```
|
||||
|
||||
+26
-26
@@ -16,21 +16,21 @@
|
||||
|
||||
import type { Entity } from '@backstage/catalog-model';
|
||||
import {
|
||||
type AIResourceEntityV1alpha1Default,
|
||||
type SkillAIResourceEntityV1alpha1,
|
||||
type AiResourceEntityV1alpha1Default,
|
||||
type SkillAiResourceEntityV1alpha1,
|
||||
aiResourceEntityV1alpha1Validator as defaultValidator,
|
||||
skillAIResourceEntityV1alpha1Validator as skillValidator,
|
||||
isAIResourceEntity,
|
||||
isSkillAIResourceEntity,
|
||||
} from './AIResourceEntityV1alpha1';
|
||||
skillAiResourceEntityV1alpha1Validator as skillValidator,
|
||||
isAiResourceEntity,
|
||||
isSkillAiResourceEntity,
|
||||
} from './AiResourceEntityV1alpha1';
|
||||
|
||||
describe('AIResourceV1alpha1 default validator', () => {
|
||||
let entity: AIResourceEntityV1alpha1Default;
|
||||
describe('AiResourceV1alpha1 default validator', () => {
|
||||
let entity: AiResourceEntityV1alpha1Default;
|
||||
|
||||
beforeEach(() => {
|
||||
entity = {
|
||||
apiVersion: 'backstage.io/v1alpha1',
|
||||
kind: 'AIResource',
|
||||
kind: 'AiResource',
|
||||
metadata: {
|
||||
name: 'internal-design-system',
|
||||
},
|
||||
@@ -118,13 +118,13 @@ describe('AIResourceV1alpha1 default validator', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('AIResourceV1alpha1 skill validator', () => {
|
||||
let entity: SkillAIResourceEntityV1alpha1;
|
||||
describe('AiResourceV1alpha1 skill validator', () => {
|
||||
let entity: SkillAiResourceEntityV1alpha1;
|
||||
|
||||
beforeEach(() => {
|
||||
entity = {
|
||||
apiVersion: 'backstage.io/v1alpha1',
|
||||
kind: 'AIResource',
|
||||
kind: 'AiResource',
|
||||
metadata: {
|
||||
name: 'frontend-design',
|
||||
},
|
||||
@@ -199,14 +199,14 @@ describe('AIResourceV1alpha1 skill validator', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('isAIResourceEntity', () => {
|
||||
describe('isAiResourceEntity', () => {
|
||||
it('returns true when apiVersion and kind match', () => {
|
||||
const entity: Entity = {
|
||||
apiVersion: 'backstage.io/v1alpha1',
|
||||
kind: 'AIResource',
|
||||
kind: 'AiResource',
|
||||
metadata: { name: 'test' },
|
||||
};
|
||||
expect(isAIResourceEntity(entity)).toBe(true);
|
||||
expect(isAiResourceEntity(entity)).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false for a different kind', () => {
|
||||
@@ -215,38 +215,38 @@ describe('isAIResourceEntity', () => {
|
||||
kind: 'Component',
|
||||
metadata: { name: 'test' },
|
||||
};
|
||||
expect(isAIResourceEntity(entity)).toBe(false);
|
||||
expect(isAiResourceEntity(entity)).toBe(false);
|
||||
});
|
||||
|
||||
it('returns false for a different apiVersion', () => {
|
||||
const entity: Entity = {
|
||||
apiVersion: 'backstage.io/v1beta1',
|
||||
kind: 'AIResource',
|
||||
kind: 'AiResource',
|
||||
metadata: { name: 'test' },
|
||||
};
|
||||
expect(isAIResourceEntity(entity)).toBe(false);
|
||||
expect(isAiResourceEntity(entity)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isSkillAIResourceEntity', () => {
|
||||
it('returns true for a skill AIResource', () => {
|
||||
describe('isSkillAiResourceEntity', () => {
|
||||
it('returns true for a skill AiResource', () => {
|
||||
const entity: Entity = {
|
||||
apiVersion: 'backstage.io/v1alpha1',
|
||||
kind: 'AIResource',
|
||||
kind: 'AiResource',
|
||||
metadata: { name: 'test' },
|
||||
spec: { type: 'skill' },
|
||||
};
|
||||
expect(isSkillAIResourceEntity(entity)).toBe(true);
|
||||
expect(isSkillAiResourceEntity(entity)).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false for a non-skill AIResource', () => {
|
||||
it('returns false for a non-skill AiResource', () => {
|
||||
const entity: Entity = {
|
||||
apiVersion: 'backstage.io/v1alpha1',
|
||||
kind: 'AIResource',
|
||||
kind: 'AiResource',
|
||||
metadata: { name: 'test' },
|
||||
spec: { type: 'rule' },
|
||||
};
|
||||
expect(isSkillAIResourceEntity(entity)).toBe(false);
|
||||
expect(isSkillAiResourceEntity(entity)).toBe(false);
|
||||
});
|
||||
|
||||
it('returns false for a different kind', () => {
|
||||
@@ -256,6 +256,6 @@ describe('isSkillAIResourceEntity', () => {
|
||||
metadata: { name: 'test' },
|
||||
spec: { type: 'skill' },
|
||||
};
|
||||
expect(isSkillAIResourceEntity(entity)).toBe(false);
|
||||
expect(isSkillAiResourceEntity(entity)).toBe(false);
|
||||
});
|
||||
});
|
||||
+29
-29
@@ -21,17 +21,17 @@ import {
|
||||
} from '@backstage/catalog-model';
|
||||
import { createCatalogModelLayer } from '@backstage/catalog-model/alpha';
|
||||
import type { JsonObject } from '@backstage/types';
|
||||
import defaultJsonSchema from './schema/AIResource.v1alpha1.schema.json';
|
||||
import skillJsonSchema from './schema/AIResource.v1alpha1.skill.schema.json';
|
||||
import defaultJsonSchema from './schema/AiResource.v1alpha1.schema.json';
|
||||
import skillJsonSchema from './schema/AiResource.v1alpha1.skill.schema.json';
|
||||
|
||||
/**
|
||||
* Default AIResource entity for types that don't have a structured spec.
|
||||
* Default AiResource entity for types that don't have a structured spec.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface AIResourceEntityV1alpha1Default extends Entity {
|
||||
export interface AiResourceEntityV1alpha1Default extends Entity {
|
||||
apiVersion: 'backstage.io/v1alpha1';
|
||||
kind: 'AIResource';
|
||||
kind: 'AiResource';
|
||||
spec: {
|
||||
type: string;
|
||||
lifecycle: string;
|
||||
@@ -41,14 +41,14 @@ export interface AIResourceEntityV1alpha1Default extends Entity {
|
||||
}
|
||||
|
||||
/**
|
||||
* AIResource entity with spec.type 'skill'. Represents reusable contextual
|
||||
* AiResource entity with spec.type 'skill'. Represents reusable contextual
|
||||
* knowledge consumed by AI coding tools.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface SkillAIResourceEntityV1alpha1 extends Entity {
|
||||
export interface SkillAiResourceEntityV1alpha1 extends Entity {
|
||||
apiVersion: 'backstage.io/v1alpha1';
|
||||
kind: 'AIResource';
|
||||
kind: 'AiResource';
|
||||
spec: {
|
||||
type: 'skill';
|
||||
lifecycle: string;
|
||||
@@ -62,19 +62,19 @@ export interface SkillAIResourceEntityV1alpha1 extends Entity {
|
||||
}
|
||||
|
||||
/**
|
||||
* Backstage catalog AIResource kind Entity. Represents contextual information
|
||||
* Backstage catalog AiResource kind Entity. Represents contextual information
|
||||
* consumed by AI coding tools, such as skills and rules.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type AIResourceEntityV1alpha1 =
|
||||
| AIResourceEntityV1alpha1Default
|
||||
| SkillAIResourceEntityV1alpha1;
|
||||
export type AiResourceEntityV1alpha1 =
|
||||
| AiResourceEntityV1alpha1Default
|
||||
| SkillAiResourceEntityV1alpha1;
|
||||
|
||||
const defaultValidator = entityKindSchemaValidator(defaultJsonSchema);
|
||||
|
||||
/**
|
||||
* Entity data validator for the default {@link AIResourceEntityV1alpha1}.
|
||||
* Entity data validator for the default {@link AiResourceEntityV1alpha1}.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
@@ -87,54 +87,54 @@ export const aiResourceEntityV1alpha1Validator: KindValidator = {
|
||||
const skillValidator = entityKindSchemaValidator(skillJsonSchema);
|
||||
|
||||
/**
|
||||
* Entity data validator for {@link SkillAIResourceEntityV1alpha1}.
|
||||
* Entity data validator for {@link SkillAiResourceEntityV1alpha1}.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const skillAIResourceEntityV1alpha1Validator: KindValidator = {
|
||||
export const skillAiResourceEntityV1alpha1Validator: KindValidator = {
|
||||
async check(data: Entity) {
|
||||
return skillValidator(data) === data;
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Type guard for {@link AIResourceEntityV1alpha1}.
|
||||
* Type guard for {@link AiResourceEntityV1alpha1}.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const isAIResourceEntity = (
|
||||
export const isAiResourceEntity = (
|
||||
entity: Entity,
|
||||
): entity is AIResourceEntityV1alpha1 =>
|
||||
entity.apiVersion === 'backstage.io/v1alpha1' && entity.kind === 'AIResource';
|
||||
): entity is AiResourceEntityV1alpha1 =>
|
||||
entity.apiVersion === 'backstage.io/v1alpha1' && entity.kind === 'AiResource';
|
||||
|
||||
/**
|
||||
* Type guard for {@link SkillAIResourceEntityV1alpha1}.
|
||||
* Type guard for {@link SkillAiResourceEntityV1alpha1}.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const isSkillAIResourceEntity = (
|
||||
export const isSkillAiResourceEntity = (
|
||||
entity: Entity,
|
||||
): entity is SkillAIResourceEntityV1alpha1 =>
|
||||
isAIResourceEntity(entity) && entity.spec?.type === 'skill';
|
||||
): entity is SkillAiResourceEntityV1alpha1 =>
|
||||
isAiResourceEntity(entity) && entity.spec?.type === 'skill';
|
||||
|
||||
const baseRelationFields = [
|
||||
{
|
||||
selector: { path: 'spec.owner' },
|
||||
relation: 'ownedBy',
|
||||
defaultKind: 'Group',
|
||||
defaultNamespace: 'inherit',
|
||||
defaultNamespace: 'inherit' as const,
|
||||
allowedKinds: ['Group', 'User'],
|
||||
},
|
||||
{
|
||||
selector: { path: 'spec.system' },
|
||||
relation: 'partOf',
|
||||
defaultKind: 'System',
|
||||
defaultNamespace: 'inherit',
|
||||
defaultNamespace: 'inherit' as const,
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Extends the catalog model with the AIResource kind.
|
||||
* Extends the catalog model with the AiResource kind.
|
||||
*
|
||||
* @alpha
|
||||
*/
|
||||
@@ -144,7 +144,7 @@ export const aiResourceEntityModel = createCatalogModelLayer({
|
||||
model.addKind({
|
||||
group: 'backstage.io',
|
||||
names: {
|
||||
kind: 'AIResource',
|
||||
kind: 'AiResource',
|
||||
singular: 'airesource',
|
||||
plural: 'airesources',
|
||||
},
|
||||
@@ -166,8 +166,8 @@ export const aiResourceEntityModel = createCatalogModelLayer({
|
||||
{
|
||||
selector: { path: 'spec.dependsOn' },
|
||||
relation: 'dependsOn',
|
||||
defaultKind: 'AIResource',
|
||||
defaultNamespace: 'inherit',
|
||||
defaultKind: 'AiResource',
|
||||
defaultNamespace: 'inherit' as const,
|
||||
},
|
||||
],
|
||||
schema: {
|
||||
@@ -14,4 +14,4 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export { aiResourceEntityModel } from './AIResourceEntityV1alpha1';
|
||||
export { aiResourceEntityModel } from './AiResourceEntityV1alpha1';
|
||||
|
||||
@@ -15,20 +15,20 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adds support for the AIResource entity kind to the catalog backend plugin.
|
||||
* Adds support for the AiResource entity kind to the catalog backend plugin.
|
||||
*
|
||||
* @packageDocumentation
|
||||
*/
|
||||
|
||||
export type {
|
||||
AIResourceEntityV1alpha1,
|
||||
AIResourceEntityV1alpha1Default,
|
||||
SkillAIResourceEntityV1alpha1,
|
||||
} from './AIResourceEntityV1alpha1';
|
||||
AiResourceEntityV1alpha1,
|
||||
AiResourceEntityV1alpha1Default,
|
||||
SkillAiResourceEntityV1alpha1,
|
||||
} from './AiResourceEntityV1alpha1';
|
||||
export {
|
||||
aiResourceEntityV1alpha1Validator,
|
||||
skillAIResourceEntityV1alpha1Validator,
|
||||
isAIResourceEntity,
|
||||
isSkillAIResourceEntity,
|
||||
} from './AIResourceEntityV1alpha1';
|
||||
export { catalogModuleAIResourceEntityModel as default } from './module';
|
||||
skillAiResourceEntityV1alpha1Validator,
|
||||
isAiResourceEntity,
|
||||
isSkillAiResourceEntity,
|
||||
} from './AiResourceEntityV1alpha1';
|
||||
export { catalogModuleAiResourceEntityModel as default } from './module';
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
import { startTestBackend } from '@backstage/backend-test-utils';
|
||||
import { catalogModelExtensionPoint } from '@backstage/plugin-catalog-node/alpha';
|
||||
import { catalogModuleAIResourceEntityModel } from './module';
|
||||
import { catalogModuleAiResourceEntityModel } from './module';
|
||||
|
||||
describe('catalogModuleAIResourceEntityModel', () => {
|
||||
describe('catalogModuleAiResourceEntityModel', () => {
|
||||
it('should register the model source', async () => {
|
||||
const extensionPoint = {
|
||||
setFieldValidators: jest.fn(),
|
||||
@@ -28,7 +28,7 @@ describe('catalogModuleAIResourceEntityModel', () => {
|
||||
|
||||
await startTestBackend({
|
||||
extensionPoints: [[catalogModelExtensionPoint, extensionPoint]],
|
||||
features: [catalogModuleAIResourceEntityModel],
|
||||
features: [catalogModuleAiResourceEntityModel],
|
||||
});
|
||||
|
||||
expect(extensionPoint.addModelSource).toHaveBeenCalledTimes(1);
|
||||
|
||||
@@ -17,14 +17,14 @@
|
||||
import { createBackendModule } from '@backstage/backend-plugin-api';
|
||||
import { CatalogModelSources } from '@backstage/catalog-model/alpha';
|
||||
import { catalogModelExtensionPoint } from '@backstage/plugin-catalog-node/alpha';
|
||||
import { aiResourceEntityModel } from './AIResourceEntityV1alpha1';
|
||||
import { aiResourceEntityModel } from './AiResourceEntityV1alpha1';
|
||||
|
||||
/**
|
||||
* Registers support for the AIResource entity kind in the catalog.
|
||||
* Registers support for the AiResource entity kind in the catalog.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const catalogModuleAIResourceEntityModel = createBackendModule({
|
||||
export const catalogModuleAiResourceEntityModel = createBackendModule({
|
||||
pluginId: 'catalog',
|
||||
moduleId: 'ai-resource-entity-model',
|
||||
register(reg) {
|
||||
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"$id": "AIResourceV1alpha1",
|
||||
"$id": "AiResourceV1alpha1",
|
||||
"description": "An AI resource represents contextual information consumed by AI coding tools, such as skills and rules.",
|
||||
"examples": [
|
||||
{
|
||||
"apiVersion": "backstage.io/v1alpha1",
|
||||
"kind": "AIResource",
|
||||
"kind": "AiResource",
|
||||
"metadata": {
|
||||
"name": "frontend-design",
|
||||
"description": "Skill for creating production-grade frontend interfaces"
|
||||
@@ -30,7 +30,7 @@
|
||||
"enum": ["backstage.io/v1alpha1"]
|
||||
},
|
||||
"kind": {
|
||||
"enum": ["AIResource"]
|
||||
"enum": ["AiResource"]
|
||||
},
|
||||
"spec": {
|
||||
"type": "object",
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"$id": "AIResourceV1alpha1Skill",
|
||||
"$id": "AiResourceV1alpha1Skill",
|
||||
"description": "An AI resource of type 'skill', representing reusable contextual knowledge consumed by AI coding tools.",
|
||||
"examples": [
|
||||
{
|
||||
"apiVersion": "backstage.io/v1alpha1",
|
||||
"kind": "AIResource",
|
||||
"kind": "AiResource",
|
||||
"metadata": {
|
||||
"name": "frontend-design",
|
||||
"description": "Skill for creating production-grade frontend interfaces"
|
||||
@@ -33,7 +33,7 @@
|
||||
"enum": ["backstage.io/v1alpha1"]
|
||||
},
|
||||
"kind": {
|
||||
"enum": ["AIResource"]
|
||||
"enum": ["AiResource"]
|
||||
},
|
||||
"spec": {
|
||||
"type": "object",
|
||||
Reference in New Issue
Block a user