-
Notifications
You must be signed in to change notification settings - Fork 17
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
WIP Queries #379
Merged
Merged
WIP Queries #379
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
c5fd1e6
starting queries work
ssanjay1 64fe1f5
fix merge conflicts
ssanjay1 e1d1969
first pass, no tests
ssanjay1 df61560
refactor
ssanjay1 3166a4e
progress
ssanjay1 4de0dc0
Get objects working
ssanjay1 041f34d
object set support
ssanjay1 ef866f4
fix merge conflict
ssanjay1 7caaddb
add obejctset supoprt
ssanjay1 3b0a0b0
remove console logs
ssanjay1 173e4fc
remove newlines
ssanjay1 373ef2b
remove unsused endpoints file
ssanjay1 8680c25
add 2d agg input support
ssanjay1 dd29ff3
3d agg test
ssanjay1 0008a8b
a little cleanup
ssanjay1 5029221
fix empty index files
ssanjay1 0017f2b
start addressing PR comments
ssanjay1 ba7117e
codegen cleanup
ssanjay1 73c2988
only use provider for object defs
ssanjay1 e64f0a2
clean up bucket types
ssanjay1 5204063
a little more codegen cleanup
ssanjay1 9ecc601
update branch
ssanjay1 b5ccec3
nullable checks
ssanjay1 7acba23
add changeset
ssanjay1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
"@osdk/legacy-client": minor | ||
"@osdk/shared.test": minor | ||
"@osdk/client.api": minor | ||
"@osdk/generator": minor | ||
"@osdk/client": minor | ||
"@osdk/api": minor | ||
--- | ||
|
||
Add support for queries in 2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
examples-extra/basic/sdk/src/generatedNoCheck/ontology/queries/getTodoCount.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { QueryDefinition } from '@osdk/api'; | ||
|
||
export const getTodoCount = { | ||
apiName: 'getTodoCount', | ||
type: 'query', | ||
version: '0.1.2', | ||
parameters: {}, | ||
output: { nullable: false, type: 'integer' }, | ||
} satisfies QueryDefinition<'getTodoCount', never>; |
2 changes: 2 additions & 0 deletions
2
examples-extra/basic/sdk/src/generatedNoCheck/ontology/queries/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './getTodoCount.js'; | ||
export * from './queryTakesAllParameterTypes.js'; |
111 changes: 111 additions & 0 deletions
111
...ples-extra/basic/sdk/src/generatedNoCheck/ontology/queries/queryTakesAllParameterTypes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import { QueryDefinition } from '@osdk/api'; | ||
import { Todo } from '../objects.js'; | ||
export const queryTakesAllParameterTypes = { | ||
apiName: 'queryTakesAllParameterTypes', | ||
description: 'description of the query that takes all parameter types', | ||
displayName: 'qTAPT', | ||
type: 'query', | ||
version: 'version', | ||
parameters: { | ||
double: { description: 'a double parameter', nullable: false, type: 'double' }, | ||
float: { nullable: false, type: 'float' }, | ||
integer: { nullable: false, type: 'integer' }, | ||
long: { nullable: false, type: 'long' }, | ||
attachment: { nullable: false, type: 'attachment' }, | ||
boolean: { nullable: false, type: 'boolean' }, | ||
date: { nullable: false, type: 'date' }, | ||
string: { nullable: false, type: 'string' }, | ||
timestamp: { nullable: false, type: 'timestamp' }, | ||
object: { | ||
nullable: false, | ||
object: 'Todo', | ||
type: 'object', | ||
|
||
__OsdkTargetType: Todo, | ||
}, | ||
objectSet: { | ||
nullable: false, | ||
objectSet: 'Todo', | ||
type: 'objectSet', | ||
|
||
__OsdkTargetType: Todo, | ||
}, | ||
array: { description: 'an array of strings', multiplicity: true, nullable: false, type: 'string' }, | ||
set: { | ||
description: 'a set of strings', | ||
nullable: false, | ||
set: { | ||
type: 'string', | ||
nullable: false, | ||
}, | ||
type: 'set', | ||
}, | ||
unionNonNullable: { | ||
description: 'a union of strings and integers', | ||
nullable: false, | ||
type: 'union', | ||
union: [ | ||
{ | ||
type: 'string', | ||
nullable: false, | ||
}, | ||
{ | ||
type: 'integer', | ||
nullable: false, | ||
}, | ||
], | ||
}, | ||
unionNullable: { | ||
description: 'a union of strings and integers but its optional', | ||
nullable: true, | ||
type: 'union', | ||
union: [ | ||
{ | ||
type: 'string', | ||
nullable: false, | ||
}, | ||
{ | ||
type: 'integer', | ||
nullable: false, | ||
}, | ||
], | ||
}, | ||
struct: { | ||
description: 'a struct with some fields', | ||
nullable: false, | ||
struct: { | ||
name: { | ||
type: 'string', | ||
nullable: false, | ||
}, | ||
id: { | ||
type: 'integer', | ||
nullable: false, | ||
}, | ||
}, | ||
type: 'struct', | ||
}, | ||
twoDimensionalAggregation: { | ||
nullable: false, | ||
twoDimensionalAggregation: { | ||
keyType: 'string', | ||
valueType: 'double', | ||
}, | ||
type: 'twoDimensionalAggregation', | ||
}, | ||
threeDimensionalAggregation: { | ||
nullable: false, | ||
threeDimensionalAggregation: { | ||
keyType: 'range', | ||
keySubtype: 'date', | ||
valueType: { | ||
keyType: 'range', | ||
keySubtype: 'timestamp', | ||
valueType: 'date', | ||
}, | ||
}, | ||
type: 'threeDimensionalAggregation', | ||
}, | ||
}, | ||
output: { nullable: false, type: 'string' }, | ||
} satisfies QueryDefinition<'queryTakesAllParameterTypes', 'Todo'>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
examples-extra/docs_example/src/generatedNoCheck/ontology/queries/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
examples-extra/todoapp/src/generatedNoCheck2/ontology/queries/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,24 +14,37 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
export interface QueryDefinition<Q extends string, K extends string> { | ||
import type { OsdkMetadata } from "../OsdkMetadata.js"; | ||
import type { ObjectTypeDefinition } from "./ObjectTypeDefinition.js"; | ||
|
||
export interface QueryDefinition< | ||
Q extends string, | ||
K extends string, | ||
> { | ||
type: "query"; | ||
apiName: Q; | ||
description?: string; | ||
displayName?: string; | ||
version: string; | ||
parameters: Record<string, QueryParameterDefinition<K>>; | ||
output: QueryDataTypeDefinition<K>; | ||
parameters: Record<string, QueryParameterDefinition<K, any>>; | ||
output: QueryDataTypeDefinition<K, any>; | ||
osdkMetadata?: OsdkMetadata; | ||
} | ||
|
||
export type QueryParameterDefinition<K extends string> = { | ||
export type QueryParameterDefinition< | ||
K extends string, | ||
T_Target extends ObjectTypeDefinition<any> = never, | ||
> = { | ||
description?: string; | ||
} & QueryDataTypeDefinition<K>; | ||
} & QueryDataTypeDefinition<K, T_Target>; | ||
|
||
export type QueryDataTypeDefinition<K extends string> = | ||
export type QueryDataTypeDefinition< | ||
K extends string, | ||
T_Target extends ObjectTypeDefinition<any> = never, | ||
> = | ||
| PrimitiveDataType | ||
| ObjectQueryDataType<K> | ||
| ObjectSetQueryDataType<K> | ||
| ObjectQueryDataType<K, T_Target> | ||
| ObjectSetQueryDataType<K, T_Target> | ||
| SetQueryDataType<K> | ||
| UnionQueryDataType<K> | ||
| StructQueryDataType<K> | ||
|
@@ -59,16 +72,20 @@ export type PrimitiveDataType< | |
Q extends WireQueryDataTypes = WireQueryDataTypes, | ||
> = BaseQueryDataTypeDefinition<Q>; | ||
|
||
export interface ObjectQueryDataType<K extends string> | ||
extends BaseQueryDataTypeDefinition<"object"> | ||
{ | ||
export interface ObjectQueryDataType< | ||
K extends string, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious, what does this string represent? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It just represents the object API name |
||
T_Target extends ObjectTypeDefinition<any> = never, | ||
> extends BaseQueryDataTypeDefinition<"object"> { | ||
object: K; | ||
__OsdkTargetType?: T_Target; | ||
} | ||
|
||
export interface ObjectSetQueryDataType<K extends string> | ||
extends BaseQueryDataTypeDefinition<"objectSet"> | ||
{ | ||
export interface ObjectSetQueryDataType< | ||
K extends string, | ||
T_Target extends ObjectTypeDefinition<any> = never, | ||
> extends BaseQueryDataTypeDefinition<"objectSet"> { | ||
objectSet: K; | ||
__OsdkTargetType?: T_Target; | ||
} | ||
|
||
export interface SetQueryDataType<K extends string> | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ericanderson is this not codifying the target type here? I may be misunderstanding your comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see. Still wouldn't rely on it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To give more color, I want the option to remove the runtime cost of these and reduce them to just compile time types (for the most part). In order to do that, we need to not rely on this from bundling but instead to get the latest from the server before execution.