Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5,458 changes: 2,289 additions & 3,169 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@
},
"devDependencies": {
"@apollo/server": "^5.5.1",
"@graphql-tools/schema": "^10.0.33",
"@graphql-tools/schema": "^10.1.0",
"@grpc/grpc-js": "^1.14.4",
"@grpc/proto-loader": "^0.8.1",
"@playwright/test": "^1.60.0",
"@vitest/coverage-v8": "^4.1.10",
"@eslint/js": "^9.0.0",
"@playwright/test": "^1.62.1",
"@vitest/coverage-v8": "^4.1.11",
"@eslint/js": "^10.0.1",
"cors": "^2.8.6",
"eslint": "^9.0.0",
"eslint": "^10.9.1",
"express": "^5.2.1",
"graphql-ws": "^6.0.8",
"globals": "^16.0.0",
"prettier": "^3.5.0",
"tsx": "^4.22.3",
"turbo": "^2.5.0",
"typescript": "^5.8.0",
"typescript-eslint": "^8.0.0",
"graphql-ws": "^6.2.1",
"globals": "^17.11.0",
"prettier": "^3.9.6",
"tsx": "^4.23.12",
"turbo": "^2.10.12",
"typescript": "^5.9.3",
"typescript-eslint": "^8.68.0",
"vitest": "^4.1.10",
"ws": "^8.21.0"
"ws": "^8.21.3"
},
"packageManager": "npm@10.0.0",
"engines": {
Expand Down
16 changes: 8 additions & 8 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
"@cortex-docs/core": "0.1.6",
"@cortex-docs/docs-ui": "0.1.6",
"@cortex-docs/mcp-gen": "0.1.6",
"@nestjs/common": "^11.0.0",
"@nestjs/core": "^11.0.0",
"chalk": "^5.4.0",
"js-yaml": "^4.3.1",
"@nestjs/common": "^11.2.3",
"@nestjs/core": "^11.2.3",
"chalk": "^6.0.0",
"js-yaml": "^5.4.1",
"nest-commander": "^3.20.0",
"ora": "^8.2.0",
"ora": "^9.4.1",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.0"
},
Expand All @@ -65,10 +65,10 @@
"@cortex-docs/docs-ui"
],
"devDependencies": {
"@types/glob": "^8.1.0",
"@types/node": "^22.0.0",
"@types/glob": "^9.0.0",
"@types/node": "^26.4.0",
"nest-commander-testing": "^3.5.0",
"typescript": "^5.8.0",
"typescript": "^5.9.3",
"vitest": "^4.1.10"
}
}
2 changes: 2 additions & 0 deletions packages/cli/src/commands/docs/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export function resolveDocsUiPath(): string {
`Cannot find the Cortex Docs UI runtime. Reinstall @cortex-docs/cli. ${
error instanceof Error ? error.message : String(error)
}`,
{ cause: error },
);
}
}
Expand All @@ -105,6 +106,7 @@ export function resolveNextBin(docsUiPath: string): string {
`Cannot find the Next.js runtime for Cortex Docs. Reinstall @cortex-docs/cli. ${
error instanceof Error ? error.message : String(error)
}`,
{ cause: error },
);
}
}
2 changes: 1 addition & 1 deletion packages/cli/src/commands/generate/generate.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export class GenerateCommand extends CommandRunner {
totalFiles: 0,
protocols: [],
langDir: langConfig.output_dir,
error: err.message,
error: err instanceof Error ? err.message : String(err),
}),
);
worker.on('exit', (code) => {
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/commands/publish/registry-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ async function fetchRegistry(
} catch (error) {
throw new Error(
`Registry lookup failed for ${url}: ${error instanceof Error ? error.message : String(error)}`,
{ cause: error },
);
}
if (response.status === 404) return undefined;
Expand Down
12 changes: 12 additions & 0 deletions packages/codegen/__tests__/gql-codegen.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,18 @@ describe('GraphQL Codegen — All Languages', () => {
expect(client.content).not.toContain('func (c *Gql) Pets(');
});

it('retries subscriptions when the shared WebSocket closes during a write', async () => {
const files = await generateForLanguage(language);
const client = getFile(files, 'gql-client')!;
expect(client.content).toContain('wasCurrent := c.wsConn == conn');
expect(client.content).toContain(
'shouldReconnect := wasCurrent && c.reconnect && !c.disposed',
);
expect(client.content).toContain('subscribeErr = conn.WriteJSON(');
expect(client.content).toContain('if c.wsConn == conn {');
expect(client.content).toContain('c.wsConn = nil');
});

it('generates unified result types instead of per-operation types', async () => {
const files = await generateForLanguage(language);
const types = getFile(files, 'gql-types')!;
Expand Down
8 changes: 4 additions & 4 deletions packages/codegen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
},
"dependencies": {
"@cortex-docs/core": "0.1.6",
"eta": "^3.5.0",
"graphql": "^16.14.0",
"js-yaml": "^4.3.1"
"eta": "^4.6.0",
"graphql": "^17.0.2",
"js-yaml": "^5.4.1"
},
"devDependencies": {
"typescript": "^5.8.0",
"typescript": "^5.9.3",
"vitest": "^4.1.10"
}
}
54 changes: 29 additions & 25 deletions packages/codegen/src/languages/go/templates/graphql/client.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,9 @@ func (c *<%= it.clientClass %>) readWsMessages(conn *websocket.Conn) {
_, message, err := conn.ReadMessage()
if err != nil {
c.mu.Lock()
if c.wsConn == conn { c.wsConn = nil }
shouldReconnect := c.reconnect && !c.disposed && len(c.subs) > 0
wasCurrent := c.wsConn == conn
if wasCurrent { c.wsConn = nil }
shouldReconnect := wasCurrent && c.reconnect && !c.disposed && len(c.subs) > 0
c.mu.Unlock()
if shouldReconnect { go c.reconnectSubscriptions() }
return
Expand Down Expand Up @@ -372,16 +373,6 @@ func (c *<%= it.clientClass %>) Subscribe(fn func(*SubscriptionBuilder) *Subscri
c.mu.Lock()
defer c.mu.Unlock()

var connectErr error
for attempt := 0; ; attempt++ {
connectErr = c.ensureWsConn()
if connectErr == nil { break }
if !c.reconnect || attempt >= c.maxReconnectAttempts {
return nil, connectErr
}
time.Sleep(c.reconnectInterval)
}

id := fmt.Sprintf("%d", c.nextSubID)
c.nextSubID++

Expand All @@ -395,19 +386,32 @@ func (c *<%= it.clientClass %>) Subscribe(fn func(*SubscriptionBuilder) *Subscri
handler(&envelope.Data)
}}

c.writeMu.Lock()
err := c.wsConn.WriteJSON(map[string]interface{}{
"type": "subscribe",
"id": id,
"payload": map[string]interface{}{
"query": query,
"variables": variables,
},
})
c.writeMu.Unlock()
if err != nil {
delete(c.subs, id)
return nil, fmt.Errorf("ws subscribe: %w", err)
var subscribeErr error
for attempt := 0; ; attempt++ {
subscribeErr = c.ensureWsConn()
if subscribeErr == nil {
conn := c.wsConn
c.writeMu.Lock()
subscribeErr = conn.WriteJSON(map[string]interface{}{
"type": "subscribe",
"id": id,
"payload": map[string]interface{}{
"query": query,
"variables": variables,
},
})
c.writeMu.Unlock()
if subscribeErr == nil { break }
if c.wsConn == conn {
_ = conn.Close()
c.wsConn = nil
}
}
if !c.reconnect || attempt >= c.maxReconnectAttempts {
delete(c.subs, id)
return nil, fmt.Errorf("ws subscribe: %w", subscribeErr)
}
time.Sleep(c.reconnectInterval)
}

return func() {
Expand Down
10 changes: 5 additions & 5 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@
"clean": "rm -rf dist"
},
"dependencies": {
"@apidevtools/swagger-parser": "^10.1.1",
"graphql": "^16.14.0",
"js-yaml": "^4.3.1",
"@apidevtools/swagger-parser": "^12.1.0",
"graphql": "^17.0.2",
"js-yaml": "^5.4.1",
"openapi-types": "^12.1.3",
"zod": "^3.25.0"
"zod": "^4.4.3"
},
"devDependencies": {
"@types/js-yaml": "^4.0.9",
"typescript": "^5.8.0",
"typescript": "^5.9.3",
"vitest": "^4.1.10"
}
}
13 changes: 2 additions & 11 deletions packages/core/src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ export type SupportedLanguage =
| 'c';

export type SourceType =
| 'openapi-spec'
| 'asyncapi-spec'
| 'graphql-spec'
| 'grpc-spec'
| 'openrpc-spec';
'openapi-spec' | 'asyncapi-spec' | 'graphql-spec' | 'grpc-spec' | 'openrpc-spec';

export interface PublishGitHubConfig {
/** Set to false to disable this GitHub destination. */
Expand Down Expand Up @@ -66,12 +62,7 @@ export interface SourceLanguageConfig {
}

export type JsonValue =
| string
| number
| boolean
| null
| JsonValue[]
| { [key: string]: JsonValue };
string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };

export interface WebSocketHeartbeatFlowConfig {
/** Message sent by this side of the connection. */
Expand Down
6 changes: 2 additions & 4 deletions packages/core/src/openapi/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ export class OpenAPIParser {
if (!pathItem) continue;
for (const method of HTTP_METHODS) {
const op = (pathItem as Record<string, unknown>)[method] as
| Record<string, unknown>
| undefined;
Record<string, unknown> | undefined;
if (!op) continue;
if (!op['operationId']) {
warnings.push({
Expand Down Expand Up @@ -158,8 +157,7 @@ export class OpenAPIParser {

for (const method of HTTP_METHODS) {
const op = (pathItem as Record<string, unknown>)[method] as
| OpenAPIV3_1.OperationObject
| undefined;
OpenAPIV3_1.OperationObject | undefined;
if (!op) continue;

const opRecord = op as unknown as Record<string, unknown>;
Expand Down
8 changes: 4 additions & 4 deletions packages/demo-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
"clean": "rm -rf .wrangler dist coverage wrangler.static.production.jsonc"
},
"dependencies": {
"graphql": "^16.14.0"
"graphql": "^17.0.2"
},
"devDependencies": {
"@cloudflare/workers-types": "^5.20260823.1",
"typescript": "^5.8.0",
"@cloudflare/workers-types": "^5.20260828.1",
"typescript": "^5.9.3",
"vitest": "^4.1.10",
"wrangler": "^4.86.0"
"wrangler": "^4.127.0"
}
}
3 changes: 1 addition & 2 deletions packages/docs-ui/app/api/sdk-snippets/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -800,8 +800,7 @@ export async function GET() {
}
}
const globalSecurity = (spec.raw as any).security as
| Array<Record<string, string[]>>
| undefined;
Array<Record<string, string[]>> | undefined;

// Read intro
let intro: string | undefined;
Expand Down
Loading