Skip to content

Commit

Permalink
Improve binding helper inline doc of each property (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
mildronize authored Feb 26, 2023
2 parents 672f391 + 17ea7a5 commit c4a7fc4
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 45 deletions.
64 changes: 35 additions & 29 deletions packages/core/src/bindings/binding/cosmos-db-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ import {
* @param bindings - `CosmosDBTriggerBinding_V4`
* @returns `CosmosDBTriggerBinding_V4` Object with `{ type: 'cosmosDBTrigger', direction: 'in' }`
*/
export function cosmosDBTrigger_v2<T extends PartialBy<CosmosDBTriggerBinding_V2<unknown>, 'type' | 'direction'>>(
bindings: T
): CosmosDBTriggerBinding_V2<T['name']> {
export function cosmosDBTrigger_v2<Binding extends CosmosDBTriggerBinding_V2<unknown>, Name extends Binding['name']>(
bindings: PartialBy<CosmosDBTriggerBinding_V2<Name>, 'type' | 'direction'>
): CosmosDBTriggerBinding_V2<Name> {
return {
...bindings,
type: 'cosmosDBTrigger',
Expand Down Expand Up @@ -88,9 +88,9 @@ export function cosmosDBTrigger_v2<T extends PartialBy<CosmosDBTriggerBinding_V2
* @param bindings - `CosmosDBTriggerBinding_V4`
* @returns `CosmosDBTriggerBinding_V4` Object with `{ type: 'cosmosDBTrigger', direction: 'in' }`
*/
export function cosmosDBTrigger_v4<T extends PartialBy<CosmosDBTriggerBinding_V4<unknown>, 'type' | 'direction'>>(
bindings: T
): CosmosDBTriggerBinding_V4<T['name']> {
export function cosmosDBTrigger_v4<Binding extends CosmosDBTriggerBinding_V4<unknown>, Name extends Binding['name']>(
bindings: PartialBy<CosmosDBTriggerBinding_V4<Name>, 'type' | 'direction'>
): CosmosDBTriggerBinding_V4<Name> {
return {
...bindings,
type: 'cosmosDBTrigger',
Expand Down Expand Up @@ -133,9 +133,15 @@ export function cosmosDBTrigger_v4<T extends PartialBy<CosmosDBTriggerBinding_V4
* @param bindings - `CosmosDBTriggerBinding_V4`
* @returns `CosmosDBTriggerBinding_V4` Object with `{ type: 'cosmosDBTrigger', direction: 'in' }`
*/
export function cosmosDBTrigger<T extends PartialBy<CosmosDBTriggerBinding_V4<unknown>, 'type' | 'direction'>>(
bindings: T
) {
// export function cosmosDBTrigger<T extends PartialBy<CosmosDBTriggerBinding_V4<unknown>, 'type' | 'direction'>>(
// bindings: T
// ) {
// return cosmosDBTrigger_v4(bindings);
// }

export function cosmosDBTrigger<Binding extends CosmosDBTriggerBinding_V4<unknown>, Name extends Binding['name']>(
bindings: PartialBy<CosmosDBTriggerBinding_V4<Name>, 'type' | 'direction'>
): CosmosDBTriggerBinding_V4<Name> {
return cosmosDBTrigger_v4(bindings);
}

Expand Down Expand Up @@ -174,9 +180,9 @@ export function cosmosDBTrigger<T extends PartialBy<CosmosDBTriggerBinding_V4<un
* @param bindings - `CosmosDBBinding_Output_V2`
* @returns `CosmosDBBinding_Output_V2` Object with `{ type: 'cosmosDB', direction: 'out' }`
*/
export function cosmosDB_output_v2<T extends PartialBy<CosmosDBBinding_Output_V2<unknown>, 'type' | 'direction'>>(
bindings: T
): CosmosDBBinding_Output_V2<T['name']> {
export function cosmosDB_output_v2<Binding extends CosmosDBBinding_Output_V2<unknown>, Name extends Binding['name']>(
bindings: PartialBy<CosmosDBBinding_Output_V2<Name>, 'type' | 'direction'>
): CosmosDBBinding_Output_V2<Name> {
return {
...bindings,
type: 'cosmosDB',
Expand Down Expand Up @@ -219,9 +225,9 @@ export function cosmosDB_output_v2<T extends PartialBy<CosmosDBBinding_Output_V2
* @param bindings - `CosmosDBBinding_Output_V4`
* @returns `CosmosDBBinding_Output_V4` Object with `{ type: 'cosmosDB', direction: 'out' }`
*/
export function cosmosDB_output_v4<T extends PartialBy<CosmosDBBinding_Output_V4<unknown>, 'type' | 'direction'>>(
bindings: T
): CosmosDBBinding_Output_V4<T['name']> {
export function cosmosDB_output_v4<Binding extends CosmosDBBinding_Output_V4<unknown>, Name extends Binding['name']>(
bindings: PartialBy<CosmosDBBinding_Output_V4<Name>, 'type' | 'direction'>
): CosmosDBBinding_Output_V4<Name> {
return {
...bindings,
type: 'cosmosDB',
Expand Down Expand Up @@ -264,9 +270,9 @@ export function cosmosDB_output_v4<T extends PartialBy<CosmosDBBinding_Output_V4
* @param bindings - `CosmosDBBinding_Output_V4`
* @returns `CosmosDBBinding_Output_V4` Object with `{ type: 'cosmosDB', direction: 'out' }`
*/
export function cosmosDB_output<T extends PartialBy<CosmosDBBinding_Output_V4<unknown>, 'type' | 'direction'>>(
bindings: T
) {
export function cosmosDB_output<Binding extends CosmosDBBinding_Output_V4<unknown>, Name extends Binding['name']>(
bindings: PartialBy<CosmosDBBinding_Output_V4<Name>, 'type' | 'direction'>
): CosmosDBBinding_Output_V4<Name> {
return cosmosDB_output_v4(bindings);
}

Expand Down Expand Up @@ -305,13 +311,13 @@ export function cosmosDB_output<T extends PartialBy<CosmosDBBinding_Output_V4<un
* @param bindings - `CosmosDBBinding_Input_V2`
* @returns `CosmosDBBinding_Input_V2` Object with `{ type: 'cosmosDB', direction: 'out' }`
*/
export function cosmosDB_input_v2<T extends PartialBy<CosmosDBBinding_Input_V2<unknown>, 'type' | 'direction'>>(
bindings: T
): CosmosDBBinding_Input_V2<T['name']> {
export function cosmosDB_input_v2<Binding extends CosmosDBBinding_Input_V2<unknown>, Name extends Binding['name']>(
bindings: PartialBy<CosmosDBBinding_Input_V2<Name>, 'type' | 'direction'>
): CosmosDBBinding_Input_V2<Name> {
return {
...bindings,
type: 'cosmosDB',
direction: 'out',
direction: 'in',
};
}

Expand Down Expand Up @@ -350,13 +356,13 @@ export function cosmosDB_input_v2<T extends PartialBy<CosmosDBBinding_Input_V2<u
* @param bindings - `CosmosDBBinding_Input_V4`
* @returns `CosmosDBBinding_Input_V4` Object with `{ type: 'cosmosDB', direction: 'out' }`
*/
export function cosmosDB_input_v4<T extends PartialBy<CosmosDBBinding_Input_V4<unknown>, 'type' | 'direction'>>(
bindings: T
): CosmosDBBinding_Input_V4<T['name']> {
export function cosmosDB_input_v4<Binding extends CosmosDBBinding_Input_V4<unknown>, Name extends Binding['name']>(
bindings: PartialBy<CosmosDBBinding_Input_V4<Name>, 'type' | 'direction'>
): CosmosDBBinding_Input_V4<Name> {
return {
...bindings,
type: 'cosmosDB',
direction: 'out',
direction: 'in',
};
}

Expand Down Expand Up @@ -395,8 +401,8 @@ export function cosmosDB_input_v4<T extends PartialBy<CosmosDBBinding_Input_V4<u
* @param bindings - `CosmosDBBinding_Input_V4`
* @returns `CosmosDBBinding_Input_V4` Object with `{ type: 'cosmosDB', direction: 'out' }`
*/
export function cosmosDB_input<T extends PartialBy<CosmosDBBinding_Input_V4<unknown>, 'type' | 'direction'>>(
bindings: T
) {
export function cosmosDB_input<Binding extends CosmosDBBinding_Input_V4<unknown>, Name extends Binding['name']>(
bindings: PartialBy<CosmosDBBinding_Input_V4<Name>, 'type' | 'direction'>
): CosmosDBBinding_Input_V4<Name> {
return cosmosDB_input_v4(bindings);
}
2 changes: 1 addition & 1 deletion packages/core/src/bindings/binding/custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ import { CustomFunctionBinding } from '../interfaces';
* @param bindings - `CustomFunctionBinding` Object
* @returns `CustomFunctionBinding` Object
*/
export function custom<T extends CustomFunctionBinding<unknown>>(bindings: T): CustomFunctionBinding<T['name']> {
export function custom<Binding extends CustomFunctionBinding<unknown>>(bindings: Binding): CustomFunctionBinding<Binding['name']> {
return bindings;
}
6 changes: 3 additions & 3 deletions packages/core/src/bindings/binding/http-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ import { HttpTriggerBinding } from '../interfaces';
* @param bindings - `HttpTriggerBinding`
* @returns `HttpTriggerBinding` Object with `{ type: 'httpTrigger', direction: 'in' }`
*/
export function httpTrigger<T extends PartialBy<HttpTriggerBinding<unknown>, 'type' | 'direction'>>(
bindings: T
): HttpTriggerBinding<T['name']> {
export function httpTrigger<Binding extends HttpTriggerBinding<unknown>, Name extends Binding['name']>(
bindings: PartialBy<HttpTriggerBinding<Name>, 'type' | 'direction'>
): HttpTriggerBinding<Name> {
return {
...bindings,
type: 'httpTrigger',
Expand Down
14 changes: 7 additions & 7 deletions packages/core/src/bindings/binding/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ import { HttpBinding } from '../interfaces';
* @param bindings - `HttpBinding` Object
* @returns `HttpBinding` Object Object with `{ type: 'http', direction: 'out' }`
*/
export function http<T extends PartialBy<HttpBinding<unknown>, 'type' | 'direction'>>(
bindings: T
): HttpBinding<T['name']> {
export function http<Binding extends HttpBinding<unknown>, Name extends Binding['name']>(
bindings: PartialBy<HttpBinding<Name>, 'type' | 'direction'>
): HttpBinding<Name> {
return {
...bindings,
type: 'http',
Expand Down Expand Up @@ -80,14 +80,14 @@ export function http<T extends PartialBy<HttpBinding<unknown>, 'type' | 'directi
* @param bindings - `HttpBinding` (Optional)
* @returns `HttpBinding` Object with `{ name: '$return', type: 'http', direction: 'out' }`
*/
export function http_withReturn<T extends PartialBy<HttpBinding<unknown>, 'name' | 'type' | 'direction'>>(
bindings?: T

export function http_withReturn<Binding extends HttpBinding<unknown>, Name extends Binding['name']>(
bindings?: PartialBy<HttpBinding<Name>, 'name' | 'type' | 'direction'>
): HttpBinding<'$return'> {
bindings = bindings ?? ({} as T);
return {
...bindings,
name: '$return' as const,
type: 'http',
direction: 'out',
};
}
}
6 changes: 3 additions & 3 deletions packages/core/src/bindings/binding/timer-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ import { TimerTriggerBinding } from '../interfaces';
* @param bindings - `TimerTriggerBinding` Object
* @returns `TimerTriggerBinding` Object Object with `{ type: 'timerTrigger', direction: 'in' }`
*/
export function timerTrigger<T extends PartialBy<TimerTriggerBinding<unknown>, 'type' | 'direction'>>(
bindings: T
): TimerTriggerBinding<T['name']> {
export function timerTrigger<Binding extends TimerTriggerBinding<unknown>, Name extends Binding['name']>(
bindings: PartialBy<TimerTriggerBinding<Name>, 'type' | 'direction'>
): TimerTriggerBinding<Name> {
return {
...bindings,
type: 'timerTrigger',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ const bindings = [
binding.cosmosDBTrigger_v2({
name: 'document_trigger_v2' as const,
collectionName: '',
connection: '',
connectionStringSetting: '',
containerName: '',
databaseName: '',
}),
binding.cosmosDBTrigger_v4({
Expand Down

0 comments on commit c4a7fc4

Please sign in to comment.