From 093ec5d8edb92034f7ff41245598e26763c4e54c Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Mon, 22 Jul 2024 10:38:01 -0400 Subject: [PATCH] Adds VersionBound to actions --- .changeset/purple-students-sin.md | 5 +++++ .../ontology/actions/completeTodo.ts | 7 +++++-- .../ontology/actions/createOffice.ts | 7 +++++-- .../ontology/actions/createOfficeAndEmployee.ts | 6 ++++-- .../generatedNoCheck/ontology/actions/createTodo.ts | 7 +++++-- .../generatedNoCheck/ontology/actions/moveOffice.ts | 7 +++++-- .../ontology/actions/promoteEmployee.ts | 7 +++++-- .../ontology/actions/promoteEmployeeObject.ts | 6 ++++-- .../ontology/actions/actionTakesAllParameterTypes.ts | 12 +++++++----- .../ontology/actions/assignEmployee1.ts | 6 ++++-- .../generatedNoCheck/ontology/actions/createTodo.ts | 7 +++++-- .../ontology/actions/completeTodo.ts | 7 +++++-- .../generatedNoCheck2/ontology/actions/createTodo.ts | 7 +++++-- .../src/shared/generatePerActionDataFiles.ts | 5 +++-- 14 files changed, 67 insertions(+), 29 deletions(-) create mode 100644 .changeset/purple-students-sin.md diff --git a/.changeset/purple-students-sin.md b/.changeset/purple-students-sin.md new file mode 100644 index 000000000..d70c95f6e --- /dev/null +++ b/.changeset/purple-students-sin.md @@ -0,0 +1,5 @@ +--- +"@osdk/generator": patch +--- + +Adds VersionBound to actions diff --git a/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/completeTodo.ts b/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/completeTodo.ts index 4f40ea902..7d0e7941d 100644 --- a/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/completeTodo.ts +++ b/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/completeTodo.ts @@ -1,4 +1,4 @@ -import type { ActionDefinition, ObjectActionDataType } from '@osdk/api'; +import type { ActionDefinition, ObjectActionDataType, VersionBound } from '@osdk/api'; import type { ActionReturnTypeForOptions, ApplyActionOptions, @@ -6,6 +6,7 @@ import type { NOOP, OsdkActionParameters, } from '@osdk/client.api'; +import type { $ExpectedClientVersion } from '../../OntologyMetadata'; import { $osdkMetadata } from '../../OntologyMetadata'; import type { Todo } from '../objects'; @@ -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 } }; diff --git a/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/createOffice.ts b/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/createOffice.ts index 2b162dbdb..b84021056 100644 --- a/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/createOffice.ts +++ b/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/createOffice.ts @@ -1,4 +1,4 @@ -import type { ActionDefinition } from '@osdk/api'; +import type { ActionDefinition, VersionBound } from '@osdk/api'; import type { ActionReturnTypeForOptions, ApplyActionOptions, @@ -6,6 +6,7 @@ import type { NOOP, OsdkActionParameters, } from '@osdk/client.api'; +import type { $ExpectedClientVersion } from '../../OntologyMetadata'; import { $osdkMetadata } from '../../OntologyMetadata'; // Represents the definition of the parameters for the action @@ -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 } }; diff --git a/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/createOfficeAndEmployee.ts b/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/createOfficeAndEmployee.ts index 1c2303d54..65c64d3e8 100644 --- a/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/createOfficeAndEmployee.ts +++ b/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/createOfficeAndEmployee.ts @@ -1,4 +1,4 @@ -import type { ActionDefinition } from '@osdk/api'; +import type { ActionDefinition, VersionBound } from '@osdk/api'; import type { ActionReturnTypeForOptions, ApplyActionOptions, @@ -6,6 +6,7 @@ import type { NOOP, OsdkActionParameters, } from '@osdk/client.api'; +import type { $ExpectedClientVersion } from '../../OntologyMetadata'; import { $osdkMetadata } from '../../OntologyMetadata'; // Represents the definition of the parameters for the action @@ -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 } }; diff --git a/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/createTodo.ts b/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/createTodo.ts index bdcdd3473..dac77163e 100644 --- a/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/createTodo.ts +++ b/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/createTodo.ts @@ -1,4 +1,4 @@ -import type { ActionDefinition } from '@osdk/api'; +import type { ActionDefinition, VersionBound } from '@osdk/api'; import type { ActionReturnTypeForOptions, ApplyActionOptions, @@ -6,6 +6,7 @@ import type { NOOP, OsdkActionParameters, } from '@osdk/client.api'; +import type { $ExpectedClientVersion } from '../../OntologyMetadata'; import { $osdkMetadata } from '../../OntologyMetadata'; // Represents the definition of the parameters for the action @@ -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 } }; diff --git a/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/moveOffice.ts b/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/moveOffice.ts index 5ecc00da2..e898f7863 100644 --- a/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/moveOffice.ts +++ b/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/moveOffice.ts @@ -1,4 +1,4 @@ -import type { ActionDefinition } from '@osdk/api'; +import type { ActionDefinition, VersionBound } from '@osdk/api'; import type { ActionReturnTypeForOptions, ApplyActionOptions, @@ -6,6 +6,7 @@ import type { NOOP, OsdkActionParameters, } from '@osdk/client.api'; +import type { $ExpectedClientVersion } from '../../OntologyMetadata'; import { $osdkMetadata } from '../../OntologyMetadata'; // Represents the definition of the parameters for the action @@ -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 } }; diff --git a/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/promoteEmployee.ts b/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/promoteEmployee.ts index 74db52b0e..d4257e00b 100644 --- a/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/promoteEmployee.ts +++ b/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/promoteEmployee.ts @@ -1,4 +1,4 @@ -import type { ActionDefinition } from '@osdk/api'; +import type { ActionDefinition, VersionBound } from '@osdk/api'; import type { ActionReturnTypeForOptions, ApplyActionOptions, @@ -6,6 +6,7 @@ import type { NOOP, OsdkActionParameters, } from '@osdk/client.api'; +import type { $ExpectedClientVersion } from '../../OntologyMetadata'; import { $osdkMetadata } from '../../OntologyMetadata'; // Represents the definition of the parameters for the action @@ -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 } }; diff --git a/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/promoteEmployeeObject.ts b/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/promoteEmployeeObject.ts index a1c859e79..003ac6d3c 100644 --- a/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/promoteEmployeeObject.ts +++ b/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/promoteEmployeeObject.ts @@ -1,4 +1,4 @@ -import type { ActionDefinition, ObjectActionDataType } from '@osdk/api'; +import type { ActionDefinition, ObjectActionDataType, VersionBound } from '@osdk/api'; import type { ActionReturnTypeForOptions, ApplyActionOptions, @@ -6,6 +6,7 @@ import type { NOOP, OsdkActionParameters, } from '@osdk/client.api'; +import type { $ExpectedClientVersion } from '../../OntologyMetadata'; import { $osdkMetadata } from '../../OntologyMetadata'; import type { Employee } from '../objects'; @@ -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 } }; diff --git a/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/actions/actionTakesAllParameterTypes.ts b/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/actions/actionTakesAllParameterTypes.ts index 0fd8abb44..e2eb0eb79 100644 --- a/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/actions/actionTakesAllParameterTypes.ts +++ b/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/actions/actionTakesAllParameterTypes.ts @@ -1,4 +1,4 @@ -import type { ActionDefinition, ObjectActionDataType, ObjectSetActionDataType } from '@osdk/api'; +import type { ActionDefinition, ObjectActionDataType, ObjectSetActionDataType, VersionBound } from '@osdk/api'; import type { ActionReturnTypeForOptions, ApplyActionOptions, @@ -6,6 +6,7 @@ import type { NOOP, OsdkActionParameters, } from '@osdk/client.api'; +import type { $ExpectedClientVersion } from '../../OntologyMetadata.js'; import { $osdkMetadata } from '../../OntologyMetadata.js'; import type { Person, Todo } from '../objects.js'; @@ -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: { diff --git a/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/actions/assignEmployee1.ts b/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/actions/assignEmployee1.ts index 3b0117db9..fd8488131 100644 --- a/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/actions/assignEmployee1.ts +++ b/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/actions/assignEmployee1.ts @@ -1,4 +1,4 @@ -import type { ActionDefinition, ObjectActionDataType } from '@osdk/api'; +import type { ActionDefinition, ObjectActionDataType, VersionBound } from '@osdk/api'; import type { ActionReturnTypeForOptions, ApplyActionOptions, @@ -6,6 +6,7 @@ import type { NOOP, OsdkActionParameters, } from '@osdk/client.api'; +import type { $ExpectedClientVersion } from '../../OntologyMetadata.js'; import { $osdkMetadata } from '../../OntologyMetadata.js'; import type { Employee, Venture } from '../objects.js'; @@ -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 } }; diff --git a/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/actions/createTodo.ts b/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/actions/createTodo.ts index 2653ed1a2..72d015a5a 100644 --- a/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/actions/createTodo.ts +++ b/packages/e2e.generated.catchall/src/generatedNoCheck/ontology/actions/createTodo.ts @@ -1,4 +1,4 @@ -import type { ActionDefinition } from '@osdk/api'; +import type { ActionDefinition, VersionBound } from '@osdk/api'; import type { ActionReturnTypeForOptions, ApplyActionOptions, @@ -6,6 +6,7 @@ import type { 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 @@ -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 } }; diff --git a/packages/e2e.sandbox.todoapp/src/generatedNoCheck2/ontology/actions/completeTodo.ts b/packages/e2e.sandbox.todoapp/src/generatedNoCheck2/ontology/actions/completeTodo.ts index d8409003f..f03f2fc30 100644 --- a/packages/e2e.sandbox.todoapp/src/generatedNoCheck2/ontology/actions/completeTodo.ts +++ b/packages/e2e.sandbox.todoapp/src/generatedNoCheck2/ontology/actions/completeTodo.ts @@ -1,4 +1,4 @@ -import type { ActionDefinition, ObjectActionDataType } from '@osdk/api'; +import type { ActionDefinition, ObjectActionDataType, VersionBound } from '@osdk/api'; import type { ActionReturnTypeForOptions, ApplyActionOptions, @@ -6,6 +6,7 @@ import type { NOOP, OsdkActionParameters, } from '@osdk/client.api'; +import type { $ExpectedClientVersion } from '../../OntologyMetadata'; import { $osdkMetadata } from '../../OntologyMetadata'; import type { Todo } from '../objects'; @@ -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 } }; diff --git a/packages/e2e.sandbox.todoapp/src/generatedNoCheck2/ontology/actions/createTodo.ts b/packages/e2e.sandbox.todoapp/src/generatedNoCheck2/ontology/actions/createTodo.ts index bdcdd3473..dac77163e 100644 --- a/packages/e2e.sandbox.todoapp/src/generatedNoCheck2/ontology/actions/createTodo.ts +++ b/packages/e2e.sandbox.todoapp/src/generatedNoCheck2/ontology/actions/createTodo.ts @@ -1,4 +1,4 @@ -import type { ActionDefinition } from '@osdk/api'; +import type { ActionDefinition, VersionBound } from '@osdk/api'; import type { ActionReturnTypeForOptions, ApplyActionOptions, @@ -6,6 +6,7 @@ import type { NOOP, OsdkActionParameters, } from '@osdk/client.api'; +import type { $ExpectedClientVersion } from '../../OntologyMetadata'; import { $osdkMetadata } from '../../OntologyMetadata'; // Represents the definition of the parameters for the action @@ -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 } }; diff --git a/packages/generator/src/shared/generatePerActionDataFiles.ts b/packages/generator/src/shared/generatePerActionDataFiles.ts index edfabe10b..e07b07d1d 100644 --- a/packages/generator/src/shared/generatePerActionDataFiles.ts +++ b/packages/generator/src/shared/generatePerActionDataFiles.ts @@ -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]) @@ -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}