Skip to content

Commit

Permalink
Adds VersionBound to actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ericanderson committed Jul 22, 2024
1 parent d8edf10 commit 093ec5d
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 29 deletions.
5 changes: 5 additions & 0 deletions .changeset/purple-students-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@osdk/generator": patch
---

Adds VersionBound to actions
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { ActionDefinition, ObjectActionDataType } from '@osdk/api';
import type { ActionDefinition, ObjectActionDataType, VersionBound } from '@osdk/api';
import type {
ActionReturnTypeForOptions,
ApplyActionOptions,
ApplyBatchActionOptions,
NOOP,
OsdkActionParameters,
} from '@osdk/client.api';
import type { $ExpectedClientVersion } from '../../OntologyMetadata';
import { $osdkMetadata } from '../../OntologyMetadata';
import type { Todo } from '../objects';

Expand Down Expand Up @@ -46,7 +47,9 @@ export interface completeTodo {
}

// Represents the definition of the action
export interface ActionDef$completeTodo extends ActionDefinition<'completeTodo', 'Todo', completeTodo> {
export interface ActionDef$completeTodo
extends ActionDefinition<'completeTodo', 'Todo', completeTodo>,
VersionBound<$ExpectedClientVersion> {
apiName: 'completeTodo';
description: 'Completes Todo';
modifiedEntities: { Todo: { created: false; modified: true } };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { ActionDefinition } from '@osdk/api';
import type { ActionDefinition, VersionBound } from '@osdk/api';
import type {
ActionReturnTypeForOptions,
ApplyActionOptions,
ApplyBatchActionOptions,
NOOP,
OsdkActionParameters,
} from '@osdk/client.api';
import type { $ExpectedClientVersion } from '../../OntologyMetadata';
import { $osdkMetadata } from '../../OntologyMetadata';

// Represents the definition of the parameters for the action
Expand Down Expand Up @@ -57,7 +58,9 @@ export interface createOffice {
}

// Represents the definition of the action
export interface ActionDef$createOffice extends ActionDefinition<'createOffice', 'Office', createOffice> {
export interface ActionDef$createOffice
extends ActionDefinition<'createOffice', 'Office', createOffice>,
VersionBound<$ExpectedClientVersion> {
apiName: 'createOffice';
description: "Create an office's";
modifiedEntities: { Office: { created: true; modified: false } };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { ActionDefinition } from '@osdk/api';
import type { ActionDefinition, VersionBound } from '@osdk/api';
import type {
ActionReturnTypeForOptions,
ApplyActionOptions,
ApplyBatchActionOptions,
NOOP,
OsdkActionParameters,
} from '@osdk/client.api';
import type { $ExpectedClientVersion } from '../../OntologyMetadata';
import { $osdkMetadata } from '../../OntologyMetadata';

// Represents the definition of the parameters for the action
Expand Down Expand Up @@ -64,7 +65,8 @@ export interface createOfficeAndEmployee {

// Represents the definition of the action
export interface ActionDef$createOfficeAndEmployee
extends ActionDefinition<'createOfficeAndEmployee', 'Office' | 'Employee', createOfficeAndEmployee> {
extends ActionDefinition<'createOfficeAndEmployee', 'Office' | 'Employee', createOfficeAndEmployee>,
VersionBound<$ExpectedClientVersion> {
apiName: 'createOfficeAndEmployee';
description: 'Create an office and employee';
modifiedEntities: { Office: { created: true; modified: false }; Employee: { created: true; modified: false } };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { ActionDefinition } from '@osdk/api';
import type { ActionDefinition, VersionBound } from '@osdk/api';
import type {
ActionReturnTypeForOptions,
ApplyActionOptions,
ApplyBatchActionOptions,
NOOP,
OsdkActionParameters,
} from '@osdk/client.api';
import type { $ExpectedClientVersion } from '../../OntologyMetadata';
import { $osdkMetadata } from '../../OntologyMetadata';

// Represents the definition of the parameters for the action
Expand Down Expand Up @@ -44,7 +45,9 @@ export interface createTodo {
}

// Represents the definition of the action
export interface ActionDef$createTodo extends ActionDefinition<'createTodo', 'Todo', createTodo> {
export interface ActionDef$createTodo
extends ActionDefinition<'createTodo', 'Todo', createTodo>,
VersionBound<$ExpectedClientVersion> {
apiName: 'createTodo';
description: 'Creates Todo';
modifiedEntities: { Todo: { created: true; modified: false } };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { ActionDefinition } from '@osdk/api';
import type { ActionDefinition, VersionBound } from '@osdk/api';
import type {
ActionReturnTypeForOptions,
ApplyActionOptions,
ApplyBatchActionOptions,
NOOP,
OsdkActionParameters,
} from '@osdk/client.api';
import type { $ExpectedClientVersion } from '../../OntologyMetadata';
import { $osdkMetadata } from '../../OntologyMetadata';

// Represents the definition of the parameters for the action
Expand Down Expand Up @@ -57,7 +58,9 @@ export interface moveOffice {
}

// Represents the definition of the action
export interface ActionDef$moveOffice extends ActionDefinition<'moveOffice', 'Office', moveOffice> {
export interface ActionDef$moveOffice
extends ActionDefinition<'moveOffice', 'Office', moveOffice>,
VersionBound<$ExpectedClientVersion> {
apiName: 'moveOffice';
description: "Update an office's physical location";
modifiedEntities: { Office: { created: false; modified: true } };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { ActionDefinition } from '@osdk/api';
import type { ActionDefinition, VersionBound } from '@osdk/api';
import type {
ActionReturnTypeForOptions,
ApplyActionOptions,
ApplyBatchActionOptions,
NOOP,
OsdkActionParameters,
} from '@osdk/client.api';
import type { $ExpectedClientVersion } from '../../OntologyMetadata';
import { $osdkMetadata } from '../../OntologyMetadata';

// Represents the definition of the parameters for the action
Expand Down Expand Up @@ -49,7 +50,9 @@ export interface promoteEmployee {
}

// Represents the definition of the action
export interface ActionDef$promoteEmployee extends ActionDefinition<'promoteEmployee', 'Employee', promoteEmployee> {
export interface ActionDef$promoteEmployee
extends ActionDefinition<'promoteEmployee', 'Employee', promoteEmployee>,
VersionBound<$ExpectedClientVersion> {
apiName: 'promoteEmployee';
description: "Update an employee's title and compensation";
modifiedEntities: { Employee: { created: false; modified: true } };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { ActionDefinition, ObjectActionDataType } from '@osdk/api';
import type { ActionDefinition, ObjectActionDataType, VersionBound } from '@osdk/api';
import type {
ActionReturnTypeForOptions,
ApplyActionOptions,
ApplyBatchActionOptions,
NOOP,
OsdkActionParameters,
} from '@osdk/client.api';
import type { $ExpectedClientVersion } from '../../OntologyMetadata';
import { $osdkMetadata } from '../../OntologyMetadata';
import type { Employee } from '../objects';

Expand Down Expand Up @@ -51,7 +52,8 @@ export interface promoteEmployeeObject {

// Represents the definition of the action
export interface ActionDef$promoteEmployeeObject
extends ActionDefinition<'promoteEmployeeObject', 'Employee', promoteEmployeeObject> {
extends ActionDefinition<'promoteEmployeeObject', 'Employee', promoteEmployeeObject>,
VersionBound<$ExpectedClientVersion> {
apiName: 'promoteEmployeeObject';
description: "Update an employee's title and compensation";
modifiedEntities: { Employee: { created: false; modified: true } };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { ActionDefinition, ObjectActionDataType, ObjectSetActionDataType } from '@osdk/api';
import type { ActionDefinition, ObjectActionDataType, ObjectSetActionDataType, VersionBound } from '@osdk/api';
import type {
ActionReturnTypeForOptions,
ApplyActionOptions,
ApplyBatchActionOptions,
NOOP,
OsdkActionParameters,
} from '@osdk/client.api';
import type { $ExpectedClientVersion } from '../../OntologyMetadata.js';
import { $osdkMetadata } from '../../OntologyMetadata.js';
import type { Person, Todo } from '../objects.js';

Expand Down Expand Up @@ -68,10 +69,11 @@ export interface actionTakesAllParameterTypes {
// Represents the definition of the action
export interface ActionDef$actionTakesAllParameterTypes
extends ActionDefinition<
'actionTakesAllParameterTypes',
'Todo' | 'ObjectTypeWithAllPropertyTypes' | 'Person',
actionTakesAllParameterTypes
> {
'actionTakesAllParameterTypes',
'Todo' | 'ObjectTypeWithAllPropertyTypes' | 'Person',
actionTakesAllParameterTypes
>,
VersionBound<$ExpectedClientVersion> {
apiName: 'actionTakesAllParameterTypes';
description: 'An action which takes different types of parameters';
modifiedEntities: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { ActionDefinition, ObjectActionDataType } from '@osdk/api';
import type { ActionDefinition, ObjectActionDataType, VersionBound } from '@osdk/api';
import type {
ActionReturnTypeForOptions,
ApplyActionOptions,
ApplyBatchActionOptions,
NOOP,
OsdkActionParameters,
} from '@osdk/client.api';
import type { $ExpectedClientVersion } from '../../OntologyMetadata.js';
import { $osdkMetadata } from '../../OntologyMetadata.js';
import type { Employee, Venture } from '../objects.js';

Expand Down Expand Up @@ -46,7 +47,8 @@ export interface assignEmployee1 {

// Represents the definition of the action
export interface ActionDef$assignEmployee1
extends ActionDefinition<'assignEmployee1', 'Employee' | 'Venture', assignEmployee1> {
extends ActionDefinition<'assignEmployee1', 'Employee' | 'Venture', assignEmployee1>,
VersionBound<$ExpectedClientVersion> {
apiName: 'assignEmployee1';
description: 'Assigns an employee to a venture';
modifiedEntities: { Employee: { created: false; modified: true } };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { ActionDefinition } from '@osdk/api';
import type { ActionDefinition, VersionBound } from '@osdk/api';
import type {
ActionReturnTypeForOptions,
ApplyActionOptions,
ApplyBatchActionOptions,
NOOP,
OsdkActionParameters,
} from '@osdk/client.api';
import type { $ExpectedClientVersion } from '../../OntologyMetadata.js';
import { $osdkMetadata } from '../../OntologyMetadata.js';

// Represents the definition of the parameters for the action
Expand Down Expand Up @@ -33,7 +34,9 @@ export interface createTodo {
}

// Represents the definition of the action
export interface ActionDef$createTodo extends ActionDefinition<'createTodo', 'Todo', createTodo> {
export interface ActionDef$createTodo
extends ActionDefinition<'createTodo', 'Todo', createTodo>,
VersionBound<$ExpectedClientVersion> {
apiName: 'createTodo';
description: 'Creates a new Todo';
modifiedEntities: { Todo: { created: true; modified: false } };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { ActionDefinition, ObjectActionDataType } from '@osdk/api';
import type { ActionDefinition, ObjectActionDataType, VersionBound } from '@osdk/api';
import type {
ActionReturnTypeForOptions,
ApplyActionOptions,
ApplyBatchActionOptions,
NOOP,
OsdkActionParameters,
} from '@osdk/client.api';
import type { $ExpectedClientVersion } from '../../OntologyMetadata';
import { $osdkMetadata } from '../../OntologyMetadata';
import type { Todo } from '../objects';

Expand Down Expand Up @@ -46,7 +47,9 @@ export interface completeTodo {
}

// Represents the definition of the action
export interface ActionDef$completeTodo extends ActionDefinition<'completeTodo', 'Todo', completeTodo> {
export interface ActionDef$completeTodo
extends ActionDefinition<'completeTodo', 'Todo', completeTodo>,
VersionBound<$ExpectedClientVersion> {
apiName: 'completeTodo';
description: 'Completes Todo';
modifiedEntities: { Todo: { created: false; modified: true } };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { ActionDefinition } from '@osdk/api';
import type { ActionDefinition, VersionBound } from '@osdk/api';
import type {
ActionReturnTypeForOptions,
ApplyActionOptions,
ApplyBatchActionOptions,
NOOP,
OsdkActionParameters,
} from '@osdk/client.api';
import type { $ExpectedClientVersion } from '../../OntologyMetadata';
import { $osdkMetadata } from '../../OntologyMetadata';

// Represents the definition of the parameters for the action
Expand Down Expand Up @@ -44,7 +45,9 @@ export interface createTodo {
}

// Represents the definition of the action
export interface ActionDef$createTodo extends ActionDefinition<'createTodo', 'Todo', createTodo> {
export interface ActionDef$createTodo
extends ActionDefinition<'createTodo', 'Todo', createTodo>,
VersionBound<$ExpectedClientVersion> {
apiName: 'createTodo';
description: 'Creates Todo';
modifiedEntities: { Todo: { created: true; modified: false } };
Expand Down
5 changes: 3 additions & 2 deletions packages/generator/src/shared/generatePerActionDataFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export async function generatePerActionDataFiles(
// Represents the definition of the action
export interface ${actionDefIdentifier} extends ActionDefinition<"${action.apiName}", ${uniqueApiNamesString}, ${action.apiName}>{
export interface ${actionDefIdentifier} extends ActionDefinition<"${action.apiName}", ${uniqueApiNamesString}, ${action.apiName}>, VersionBound<$ExpectedClientVersion> {
${
Object.entries(actionDefSansParameters).sort((a, b) =>
a[0].localeCompare(b[0])
Expand Down Expand Up @@ -174,9 +174,10 @@ export async function generatePerActionDataFiles(
await fs.writeFile(
path.join(outDir, `${action.apiName}.ts`),
await formatTs(`
import type { ActionDefinition, ObjectActionDataType, ObjectSetActionDataType } from "@osdk/api";
import type { ActionDefinition, ObjectActionDataType, ObjectSetActionDataType, VersionBound} from "@osdk/api";
import type { ActionSignature, ApplyActionOptions, ApplyBatchActionOptions, OsdkActionParameters,ActionReturnTypeForOptions, NOOP } from '@osdk/client.api';
import { $osdkMetadata} from "../../OntologyMetadata${importExt}";
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
${importObjects}
Expand Down

0 comments on commit 093ec5d

Please sign in to comment.