mirror of
https://github.com/simstudioai/sim.git
synced 2026-11-04 15:52:15 +08:00
Rework the workspace around the AI-workspace model: a Mothership home, a top-level Skills route, connected-credential and integration-detail pages, and a polished sidebar/settings surface. Replace the notifications store with a unified toast system (provider-level dismiss/pause, countdown ring). Integrations & catalog: - Add a BlockMeta layer (tags + catalog templates) scoped to catalog-visible integrations; every catalog integration carries >=7 grounded templates. - Rework the taxonomy: each block declares category tools|blocks|triggers. 3rd-party services are 'tools'; first-party primitives (postgres, mysql, knowledge, file, search, stt/tts, image/video generators, thinking, etc.) are 'blocks'. Versioned blocks follow the upgrade paradigm (old hidden, latest in toolbar/docs). - Generate integrations.json + tool docs canonically from block configs. Architecture & cleanup: - Consolidate block data extraction behind a single latest-version strategy (getCanonicalBlocksByCategory; version-consistent getBlockMeta). - Unify version-suffix handling in @sim/utils/string (stripVersionSuffix / isVersionedType, with tests); registry, generate-docs, tools/utils, and integrations all route through it. - Repair latent broken barrels, remove dead code, fix BlockMeta-related type errors and 5 broken docs links. Behavior-preserving for block execution and the toolbar's tool/block listing.
58 lines
1.8 KiB
TypeScript
58 lines
1.8 KiB
TypeScript
/**
|
|
* @vitest-environment node
|
|
*/
|
|
import { describe, expect, it } from 'vitest'
|
|
import { isVersionedType, stripVersionSuffix, truncate } from './string.js'
|
|
|
|
describe('truncate', () => {
|
|
it('appends the suffix when the string exceeds the slice length', () => {
|
|
expect(truncate('hello world', 8)).toBe('hello wo...')
|
|
})
|
|
|
|
it('uses a custom suffix when provided', () => {
|
|
expect(truncate('hello world', 8, ' …')).toBe('hello wo …')
|
|
})
|
|
|
|
it('returns the original string when within the slice length', () => {
|
|
expect(truncate('hi', 10)).toBe('hi')
|
|
})
|
|
})
|
|
|
|
describe('stripVersionSuffix', () => {
|
|
it('strips a trailing _vN suffix', () => {
|
|
expect(stripVersionSuffix('notion_search_v2')).toBe('notion_search')
|
|
expect(stripVersionSuffix('github_create_pr_v3')).toBe('github_create_pr')
|
|
})
|
|
|
|
it('strips multi-digit versions', () => {
|
|
expect(stripVersionSuffix('x_v10')).toBe('x')
|
|
})
|
|
|
|
it('leaves plain values unchanged', () => {
|
|
expect(stripVersionSuffix('plain')).toBe('plain')
|
|
})
|
|
|
|
it('does not strip a non-version trailing token', () => {
|
|
expect(stripVersionSuffix('a_version')).toBe('a_version')
|
|
})
|
|
|
|
it('only strips the single trailing suffix', () => {
|
|
expect(stripVersionSuffix('a_v2_v3')).toBe('a_v2')
|
|
})
|
|
})
|
|
|
|
describe('isVersionedType', () => {
|
|
it('returns true for trailing _vN suffixes', () => {
|
|
expect(isVersionedType('notion_search_v2')).toBe(true)
|
|
expect(isVersionedType('github_create_pr_v3')).toBe(true)
|
|
expect(isVersionedType('x_v10')).toBe(true)
|
|
expect(isVersionedType('a_v2_v3')).toBe(true)
|
|
})
|
|
|
|
it('returns false when there is no trailing version suffix', () => {
|
|
expect(isVersionedType('plain')).toBe(false)
|
|
expect(isVersionedType('a_version')).toBe(false)
|
|
expect(isVersionedType('x')).toBe(false)
|
|
})
|
|
})
|