@contractspec/bundle.workspace 4.5.0 → 4.5.1

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.
@@ -35,6 +35,7 @@ export * from './llm/index';
35
35
  export * from './module-loader';
36
36
  export * as onboarding from './onboarding/index';
37
37
  export * from './openapi/index';
38
+ export * as packageDeclarations from './package-declarations/index';
38
39
  export * from './package-scaffold';
39
40
  export * from './quickstart/index';
40
41
  export * from './regenerator';
@@ -0,0 +1,13 @@
1
+ import type { PackageDeclarationTarget } from '@contractspec/lib.contracts-spec/workspace-config';
2
+ import type { WorkspacePackageKind } from './types';
3
+ export declare function inferWorkspacePackageKind(relativePackageRoot: string): WorkspacePackageKind | null;
4
+ export declare function getCanonicalDeclarationRelativePath(kind: WorkspacePackageKind, packageDirName: string): string;
5
+ export declare function getIndexExportPath(kind: WorkspacePackageKind, packageDirName: string): string;
6
+ export declare function buildPackageDeclarationKey(relativePackageRoot: string): string;
7
+ export declare function buildPackageTitle(packageDirName: string): string;
8
+ export declare function buildDomain(packageDirName: string): string;
9
+ export declare function buildDeclarationTags(packageDirName: string, kind: WorkspacePackageKind, defaultTags: string[]): string[];
10
+ export declare function matchesAllowMissing(allowMissing: string[], relativePackageRoot: string, packageName: string): boolean;
11
+ export declare function normalizePath(value: string): string;
12
+ export declare function toPascalCase(value: string): string;
13
+ export declare function buildExportName(target: PackageDeclarationTarget, packageDirName: string): string;
@@ -0,0 +1,5 @@
1
+ export * from './helpers';
2
+ export * from './inventory';
3
+ export * from './render';
4
+ export * from './sync';
5
+ export * from './types';
@@ -0,0 +1,4 @@
1
+ import type { FsAdapter } from '../../ports/fs';
2
+ import { type PackageDeclarationAuditOptions, type PackageDeclarationAuditResult, type WorkspacePackageInfo } from './types';
3
+ export declare function discoverWorkspacePackages(fs: FsAdapter, options?: PackageDeclarationAuditOptions): Promise<WorkspacePackageInfo[]>;
4
+ export declare function auditPackageDeclarations(fs: FsAdapter, options?: PackageDeclarationAuditOptions): Promise<PackageDeclarationAuditResult[]>;
@@ -0,0 +1,41 @@
1
+ import type { WorkspacePackageInfo } from './types';
2
+ export interface PackageSpecRefs {
3
+ operations: Array<{
4
+ key: string;
5
+ version: string;
6
+ }>;
7
+ events: Array<{
8
+ key: string;
9
+ version: string;
10
+ }>;
11
+ presentations: Array<{
12
+ key: string;
13
+ version: string;
14
+ }>;
15
+ experiments: Array<{
16
+ key: string;
17
+ version: string;
18
+ }>;
19
+ workflows: Array<{
20
+ key: string;
21
+ version: string;
22
+ }>;
23
+ dataViews: Array<{
24
+ key: string;
25
+ version: string;
26
+ }>;
27
+ capabilities: Array<{
28
+ key: string;
29
+ version: string;
30
+ }>;
31
+ features: Array<{
32
+ key: string;
33
+ version: string;
34
+ }>;
35
+ }
36
+ export declare function renderPackageDeclaration(input: {
37
+ pkg: WorkspacePackageInfo;
38
+ refs: PackageSpecRefs;
39
+ owners: string[];
40
+ defaultTags: string[];
41
+ }): string;
@@ -0,0 +1,8 @@
1
+ import type { FsAdapter } from '../../ports/fs';
2
+ import { auditPackageDeclarations } from './inventory';
3
+ import { type PackageDeclarationSyncEntry, type PackageDeclarationSyncOptions, type PackageDeclarationSyncResult } from './types';
4
+ export declare function syncPackageDeclarations(fs: FsAdapter, options?: PackageDeclarationSyncOptions): Promise<PackageDeclarationSyncResult>;
5
+ export declare function createPackageDeclarationIssue(entry: PackageDeclarationSyncEntry | Awaited<ReturnType<typeof auditPackageDeclarations>>[number], allowMissing: string[]): {
6
+ allowlisted: boolean;
7
+ message: string;
8
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,48 @@
1
+ import type { PackageDeclarationConfig, PackageDeclarationRequiredByKind, PackageDeclarationTarget, ResolvedContractsrcConfig } from '@contractspec/lib.contracts-spec/workspace-config';
2
+ export type WorkspacePackageKind = 'libs' | 'modules' | 'integrations' | 'bundles' | 'apps' | 'appsRegistry' | 'examples';
3
+ export interface WorkspacePackageDeclarationRequirement {
4
+ kind: WorkspacePackageKind;
5
+ target: PackageDeclarationTarget;
6
+ }
7
+ export interface WorkspacePackageInfo {
8
+ workspaceRoot: string;
9
+ relativePackageRoot: string;
10
+ packageRoot: string;
11
+ packageName: string;
12
+ packageDirName: string;
13
+ description?: string;
14
+ kind: WorkspacePackageKind;
15
+ target: PackageDeclarationTarget;
16
+ canonicalDeclarationRelativePath: string;
17
+ canonicalDeclarationPath: string;
18
+ indexPath: string;
19
+ indexExportPath: string;
20
+ }
21
+ export interface PackageDeclarationAuditResult extends WorkspacePackageInfo {
22
+ exists: boolean;
23
+ matchesExpectedTarget: boolean;
24
+ detectedSpecType?: string;
25
+ }
26
+ export interface PackageDeclarationSyncEntry extends PackageDeclarationAuditResult {
27
+ action: 'created' | 'updated' | 'skipped';
28
+ declarationCreated: boolean;
29
+ indexUpdated: boolean;
30
+ packageJsonUpdated: boolean;
31
+ dependenciesUpdated: string[];
32
+ }
33
+ export interface PackageDeclarationAuditOptions {
34
+ config?: ResolvedContractsrcConfig;
35
+ workspaceRoot?: string;
36
+ }
37
+ export interface PackageDeclarationSyncOptions extends PackageDeclarationAuditOptions {
38
+ dryRun?: boolean;
39
+ force?: boolean;
40
+ }
41
+ export interface PackageDeclarationSyncResult {
42
+ packages: PackageDeclarationSyncEntry[];
43
+ createdFiles: string[];
44
+ updatedFiles: string[];
45
+ }
46
+ export declare const DEFAULT_PACKAGE_DECLARATION_REQUIRED_BY_KIND: Required<PackageDeclarationRequiredByKind>;
47
+ export declare const WORKSPACE_PACKAGE_KIND_BY_PREFIX: Readonly<Record<string, WorkspacePackageKind>>;
48
+ export declare function resolvePackageDeclarationConfig(config?: ResolvedContractsrcConfig): PackageDeclarationConfig;
@@ -4,9 +4,24 @@
4
4
  * Orchestrates the full ContractSpec setup flow.
5
5
  * Supports both single projects and monorepos.
6
6
  */
7
+ import { findPackageRoot, findWorkspaceRoot, getPackageName, isMonorepo } from '../../adapters/workspace';
7
8
  import type { FsAdapter } from '../../ports/fs';
8
- import type { SetupOptions, SetupPromptCallbacks, SetupResult } from './types';
9
+ import { setupGitignore } from './gitignore';
10
+ import type { SetupFileResult, SetupOptions, SetupPromptCallbacks, SetupResult, SetupTarget } from './types';
11
+ type SetupTargetHandler = (fs: FsAdapter, options: SetupOptions, prompts: SetupPromptCallbacks) => Promise<SetupFileResult>;
12
+ interface SetupWorkspaceAdapters {
13
+ findWorkspaceRoot: typeof findWorkspaceRoot;
14
+ findPackageRoot: typeof findPackageRoot;
15
+ isMonorepo: typeof isMonorepo;
16
+ getPackageName: typeof getPackageName;
17
+ }
18
+ export interface SetupServiceDeps {
19
+ targets?: Partial<Record<SetupTarget, SetupTargetHandler>>;
20
+ workspace?: Partial<SetupWorkspaceAdapters>;
21
+ setupGitignore?: typeof setupGitignore;
22
+ }
9
23
  /**
10
24
  * Run the ContractSpec setup.
11
25
  */
12
- export declare function runSetup(fs: FsAdapter, options: SetupOptions, prompts?: SetupPromptCallbacks): Promise<SetupResult>;
26
+ export declare function runSetup(fs: FsAdapter, options: SetupOptions, prompts?: SetupPromptCallbacks, deps?: SetupServiceDeps): Promise<SetupResult>;
27
+ export {};
@@ -1,18 +1,22 @@
1
1
  import type { OperationSpec } from '@contractspec/lib.contracts-spec';
2
2
  import { type TestSpec } from '@contractspec/lib.contracts-spec/tests';
3
3
  import type { LanguageModel } from 'ai';
4
+ import { generateText } from 'ai';
4
5
  import type { LoggerAdapter } from '../../ports/logger';
5
6
  export interface TestGeneratorOptions {
6
7
  model?: LanguageModel;
7
8
  maxScenarios?: number;
8
9
  }
10
+ type GenerateText = typeof generateText;
9
11
  export declare class TestGeneratorService {
10
12
  private readonly logger;
11
13
  private readonly defaultModel?;
12
- constructor(logger: LoggerAdapter, defaultModel?: LanguageModel | undefined);
14
+ private readonly generateTextImpl;
15
+ constructor(logger: LoggerAdapter, defaultModel?: LanguageModel | undefined, generateTextImpl?: GenerateText);
13
16
  generateTests(spec: OperationSpec<any, any>, // Use any to satisfy generics for now
14
17
  options?: TestGeneratorOptions): Promise<TestSpec>;
15
18
  private parseResponse;
16
19
  private enrichSpec;
17
20
  private logUsage;
18
21
  }
22
+ export {};
@@ -40,10 +40,13 @@ export interface ExtendedWorkspaceInfo extends WorkspaceInfo {
40
40
  */
41
41
  packageConfigPath?: string;
42
42
  }
43
+ export interface WorkspaceInfoDeps {
44
+ getWorkspaceInfo?: typeof getWorkspaceInfo;
45
+ }
43
46
  /**
44
47
  * Get extended workspace information including config paths.
45
48
  */
46
- export declare function getExtendedWorkspaceInfo(fs: FsAdapter, startDir?: string): Promise<ExtendedWorkspaceInfo>;
49
+ export declare function getExtendedWorkspaceInfo(fs: FsAdapter, startDir?: string, deps?: WorkspaceInfoDeps): Promise<ExtendedWorkspaceInfo>;
47
50
  /**
48
51
  * Find all .contractsrc.json files in a monorepo.
49
52
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contractspec/bundle.workspace",
3
- "version": "4.5.0",
3
+ "version": "4.5.1",
4
4
  "description": "Workspace utilities for monorepo development",
5
5
  "keywords": [
6
6
  "contractspec",
@@ -34,16 +34,16 @@
34
34
  "@ai-sdk/anthropic": "3.0.68",
35
35
  "@ai-sdk/openai": "3.0.52",
36
36
  "@contractspec/biome-config": "3.8.8",
37
- "@contractspec/integration.runtime": "3.9.2",
38
- "@contractspec/lib.ai-agent": "8.0.8",
39
- "@contractspec/lib.ai-providers": "3.7.13",
40
- "@contractspec/lib.contracts-spec": "5.4.0",
41
- "@contractspec/lib.contracts-integrations": "3.8.12",
42
- "@contractspec/lib.contracts-transformers": "3.7.20",
43
- "@contractspec/lib.surface-runtime": "0.5.20",
44
- "@contractspec/lib.source-extractors": "2.7.20",
45
- "@contractspec/module.workspace": "4.3.0",
46
- "@contractspec/lib.utils-typescript": "3.7.13",
37
+ "@contractspec/integration.runtime": "3.9.3",
38
+ "@contractspec/lib.ai-agent": "8.0.9",
39
+ "@contractspec/lib.ai-providers": "3.7.14",
40
+ "@contractspec/lib.contracts-spec": "5.5.0",
41
+ "@contractspec/lib.contracts-integrations": "3.8.13",
42
+ "@contractspec/lib.contracts-transformers": "3.7.21",
43
+ "@contractspec/lib.surface-runtime": "0.5.21",
44
+ "@contractspec/lib.source-extractors": "2.7.21",
45
+ "@contractspec/module.workspace": "4.3.1",
46
+ "@contractspec/lib.utils-typescript": "3.7.14",
47
47
  "ai": "6.0.156",
48
48
  "chalk": "^5.6.2",
49
49
  "chokidar": "^5.0.0",
@@ -57,11 +57,11 @@
57
57
  },
58
58
  "devDependencies": {
59
59
  "@contractspec/tool.typescript": "3.7.13",
60
- "@types/bun": "^1.3.11",
60
+ "@types/bun": "^1.3.12",
61
61
  "@types/micromatch": "^4.0.10",
62
62
  "@types/node": "^25.6.0",
63
63
  "typescript": "^5.9.3",
64
- "@contractspec/tool.bun": "3.7.14"
64
+ "@contractspec/tool.bun": "3.7.15"
65
65
  },
66
66
  "exports": {
67
67
  ".": {