Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate new result type methods for Conjure services #298

Open
wants to merge 40 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
97ad547
Fix integration tests script
samialfhaily Dec 13, 2024
298a9c8
Add POC code generation
samialfhaily Dec 17, 2024
f4f9282
Fix ordered import issue
samialfhaily Dec 17, 2024
8801698
Add ES2015 to lib
samialfhaily Dec 17, 2024
3a79ea0
Update lib config
samialfhaily Dec 17, 2024
86c0606
Drop es5 from lib
samialfhaily Dec 17, 2024
ae83c5f
Replace es6 with es2015
samialfhaily Dec 17, 2024
c6e9378
Replace es2015 with ES2015
samialfhaily Dec 17, 2024
1846147
Update lib
samialfhaily Dec 17, 2024
92e2bb8
Update lib
samialfhaily Dec 17, 2024
d89304b
Revert lib changes
samialfhaily Dec 17, 2024
eabc6be
Remove async usage
samialfhaily Dec 17, 2024
7992b6a
Update comment
samialfhaily Dec 17, 2024
4a9b659
Inline types instead of using custom types
samialfhaily Dec 18, 2024
6bb7d86
Make catch block generation conditional
samialfhaily Dec 18, 2024
56a0b6e
Fix conditional logic
samialfhaily Dec 18, 2024
b3aaace
Fix jsdoc generated error types
samialfhaily Dec 18, 2024
3475602
Import error types
samialfhaily Dec 18, 2024
0d938bc
Fix build
samialfhaily Dec 18, 2024
1e76a8c
Add changelog entry
samialfhaily Dec 18, 2024
389143e
Add test to prevent duplicate imports
samialfhaily Dec 18, 2024
c81d3d5
Merge branch 'sami/fix-error-types-in-docs' into sami/support-union-t…
samialfhaily Dec 18, 2024
f788a24
Add TODO to remove visitor
samialfhaily Dec 18, 2024
0661725
Fix conflicts
samialfhaily Dec 18, 2024
9459d29
Fix build error
samialfhaily Dec 18, 2024
d406cb5
Refactor code
samialfhaily Dec 18, 2024
d2950f8
Merge branch 'sami/fix-error-types-in-docs' into sami/support-union-t…
samialfhaily Dec 18, 2024
8a752b1
Add changelog entry
samialfhaily Dec 18, 2024
2d54e1f
Fix build
samialfhaily Dec 18, 2024
1bb5e1b
Improve code gen
samialfhaily Dec 18, 2024
d0e32ec
Improve code gen #2
samialfhaily Dec 18, 2024
2d3b2b9
Merge branch 'develop' into sami/support-union-types
samialfhaily Dec 18, 2024
3fa3401
Fix conflict
samialfhaily Dec 18, 2024
6163c2e
Remove old changelog entry
samialfhaily Dec 18, 2024
6d0363e
Merge branch 'develop' into sami/support-union-types
samialfhaily Dec 20, 2024
3426575
Remove unnecessary await
samialfhaily Jan 21, 2025
7e1225f
Simplify condition
samialfhaily Jan 21, 2025
cb8ddd2
Make code more readable
samialfhaily Jan 21, 2025
7ac6ac7
Refactor code
samialfhaily Jan 21, 2025
421285a
Merge branch 'develop' into sami/support-union-types
samialfhaily Jan 22, 2025
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
6 changes: 5 additions & 1 deletion scripts/run-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ set -euo pipefail
./build/downloads/bin/conjure-verification-server ./build/resources/verification-server-test-cases.json ./build/resources/verification-server-api.conjure.json &
SERVER_PID=$!
yarn karma start --single-run --browsers ChromeHeadless karma.conf.js
kill -kill ${SERVER_PID}

if ps -p ${SERVER_PID} > /dev/null
then
kill -kill ${SERVER_PID}
fi
samialfhaily marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const __undefined: undefined = undefined;

export interface IOptionalService {
foo(header: string, name?: string | null): Promise<void>;
fooOrError(header: string, name?: string | null): Promise<{ status: "success", response: void }>;
}

export class OptionalService {
Expand All @@ -29,4 +30,15 @@ export class OptionalService {
__undefined
);
}

public async fooOrError(header: string, name?: string | null): Promise<{ status: "success", response: void }> {
try {
return { status: "success", response: await this.foo(header, name) }
} catch (e: any) {
if (e == null || e.body == null) {
throw e;
}
throw e;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const __undefined: undefined = undefined;

export interface IOutOfOrderPathService {
foo(param1: string, param2: string): Promise<void>;
fooOrError(param1: string, param2: string): Promise<{ status: "success", response: void }>;
}

export class OutOfOrderPathService {
Expand All @@ -29,4 +30,15 @@ export class OutOfOrderPathService {
__undefined
);
}

public async fooOrError(param1: string, param2: string): Promise<{ status: "success", response: void }> {
try {
return { status: "success", response: await this.foo(param1, param2) }
} catch (e: any) {
if (e == null || e.body == null) {
throw e;
}
throw e;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const __undefined: undefined = undefined;

export interface IParamTypeService {
foo(body: string, header: string, path: string, query: string): Promise<void>;
fooOrError(body: string, header: string, path: string, query: string): Promise<{ status: "success", response: void }>;
}

export class ParamTypeService {
Expand All @@ -31,4 +32,15 @@ export class ParamTypeService {
__undefined
);
}

public async fooOrError(body: string, header: string, path: string, query: string): Promise<{ status: "success", response: void }> {
try {
return { status: "success", response: await this.foo(body, header, path, query) }
} catch (e: any) {
if (e == null || e.body == null) {
throw e;
}
throw e;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const __undefined: undefined = undefined;

export interface IPrimitiveService {
getPrimitive(): Promise<number>;
getPrimitiveOrError(): Promise<{ status: "success", response: number }>;
}

export class PrimitiveService {
Expand All @@ -25,4 +26,15 @@ export class PrimitiveService {
__undefined
);
}

public async getPrimitiveOrError(): Promise<{ status: "success", response: number }> {
try {
return { status: "success", response: await this.getPrimitive() }
} catch (e: any) {
if (e == null || e.body == null) {
throw e;
}
throw e;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const __undefined: undefined = undefined;

export interface IServiceWithSafelongHeader {
foo(investigation: number): Promise<void>;
fooOrError(investigation: number): Promise<{ status: "success", response: void }>;
}

export class ServiceWithSafelongHeader {
Expand All @@ -27,4 +28,15 @@ export class ServiceWithSafelongHeader {
__undefined
);
}

public async fooOrError(investigation: number): Promise<{ status: "success", response: void }> {
try {
return { status: "success", response: await this.foo(investigation) }
} catch (e: any) {
if (e == null || e.body == null) {
throw e;
}
throw e;
}
}
}
Loading