diff --git a/examples-extra/basic/sdk/src/generatedNoCheck/Ontology.ts b/examples-extra/basic/sdk/src/generatedNoCheck/Ontology.ts index 36f45c5b6..46c6ac1f7 100644 --- a/examples-extra/basic/sdk/src/generatedNoCheck/Ontology.ts +++ b/examples-extra/basic/sdk/src/generatedNoCheck/Ontology.ts @@ -7,18 +7,18 @@ import * as Objects from './ontology/objects.js'; const _Ontology = { metadata: OntologyMetadata, objects: { - WeatherStation: Objects.WeatherStation, BoundariesUsState: Objects.BoundariesUsState, - Todo: Objects.Todo, - Person: Objects.Person, Employee: Objects.Employee, - Venture: Objects.Venture, ObjectTypeWithAllPropertyTypes: Objects.ObjectTypeWithAllPropertyTypes, + Person: Objects.Person, + Todo: Objects.Todo, + Venture: Objects.Venture, + WeatherStation: Objects.WeatherStation, }, actions: { actionTakesAllParameterTypes: Actions.actionTakesAllParameterTypes, - createTodo: Actions.createTodo, assignEmployee1: Actions.assignEmployee1, + createTodo: Actions.createTodo, }, queries: { // TODO @@ -27,7 +27,7 @@ const _Ontology = { FooInterface: Interfaces.FooInterface, }, } satisfies OntologyDefinition< - 'WeatherStation' | 'BoundariesUsState' | 'Todo' | 'Person' | 'Employee' | 'Venture' | 'ObjectTypeWithAllPropertyTypes' + 'BoundariesUsState' | 'Employee' | 'ObjectTypeWithAllPropertyTypes' | 'Person' | 'Todo' | 'Venture' | 'WeatherStation' >; type _Ontology = typeof _Ontology; diff --git a/examples-extra/basic/sdk/src/generatedNoCheck/ontology/actions/actionTakesAllParameterTypes.ts b/examples-extra/basic/sdk/src/generatedNoCheck/ontology/actions/actionTakesAllParameterTypes.ts index e24f42b5c..c8d14ef1c 100644 --- a/examples-extra/basic/sdk/src/generatedNoCheck/ontology/actions/actionTakesAllParameterTypes.ts +++ b/examples-extra/basic/sdk/src/generatedNoCheck/ontology/actions/actionTakesAllParameterTypes.ts @@ -4,36 +4,36 @@ import type { Person, Todo } from '../objects.js'; // Represents the definition of the parameters for the action export type ActionDef$actionTakesAllParameterTypes$Params = { - objectSet: { - multiplicity: false; - type: ObjectSetActionDataType<'Todo', Todo>; + attachmentArray: { + multiplicity: true; nullable: false; + type: 'attachment'; + }; + dateArray: { + multiplicity: true; + nullable: true; + type: 'datetime'; }; object: { + description: 'A person Object'; multiplicity: false; - type: ObjectActionDataType<'Person', Person>; nullable: true; - description: 'A person Object'; + type: ObjectActionDataType<'Person', Person>; }; - string: { + objectSet: { multiplicity: false; - type: 'string'; nullable: false; + type: ObjectSetActionDataType<'Todo', Todo>; }; - 'time-stamp': { + string: { multiplicity: false; - type: 'timestamp'; nullable: false; + type: 'string'; }; - dateArray: { - multiplicity: true; - type: 'datetime'; - nullable: true; - }; - attachmentArray: { - multiplicity: true; - type: 'attachment'; + 'time-stamp': { + multiplicity: false; nullable: false; + type: 'timestamp'; }; }; @@ -60,13 +60,13 @@ export interface ActionDef$actionTakesAllParameterTypes 'Todo' | 'ObjectTypeWithAllPropertyTypes' | 'Person', actionTakesAllParameterTypes > { - type: 'action'; apiName: 'actionTakesAllParameterTypes'; description: 'An action which takes different types of parameters'; modifiedEntities: { Todo: { created: true; modified: true }; ObjectTypeWithAllPropertyTypes: { created: false; modified: true }; }; + type: 'action'; parameters: ActionDef$actionTakesAllParameterTypes$Params; } diff --git a/examples-extra/basic/sdk/src/generatedNoCheck/ontology/actions/assignEmployee1.ts b/examples-extra/basic/sdk/src/generatedNoCheck/ontology/actions/assignEmployee1.ts index 4fa8118f0..77ba48c21 100644 --- a/examples-extra/basic/sdk/src/generatedNoCheck/ontology/actions/assignEmployee1.ts +++ b/examples-extra/basic/sdk/src/generatedNoCheck/ontology/actions/assignEmployee1.ts @@ -6,13 +6,13 @@ import type { Employee, Venture } from '../objects.js'; export type ActionDef$assignEmployee1$Params = { 'employee-1': { multiplicity: false; - type: ObjectActionDataType<'Employee', Employee>; nullable: false; + type: ObjectActionDataType<'Employee', Employee>; }; 'venture-1': { multiplicity: false; - type: ObjectActionDataType<'Venture', Venture>; nullable: false; + type: ObjectActionDataType<'Venture', Venture>; }; }; @@ -30,10 +30,10 @@ export interface assignEmployee1 { // Represents the definition of the action export interface ActionDef$assignEmployee1 extends ActionDefinition<'assignEmployee1', 'Employee' | 'Venture', assignEmployee1> { - type: 'action'; apiName: 'assignEmployee1'; description: 'Assigns an employee to a venture'; modifiedEntities: { Employee: { created: false; modified: true } }; + type: 'action'; parameters: ActionDef$assignEmployee1$Params; } diff --git a/examples-extra/basic/sdk/src/generatedNoCheck/ontology/actions/createTodo.ts b/examples-extra/basic/sdk/src/generatedNoCheck/ontology/actions/createTodo.ts index 6f3acbcec..179c1d630 100644 --- a/examples-extra/basic/sdk/src/generatedNoCheck/ontology/actions/createTodo.ts +++ b/examples-extra/basic/sdk/src/generatedNoCheck/ontology/actions/createTodo.ts @@ -17,10 +17,10 @@ export interface createTodo { // Represents the definition of the action export interface ActionDef$createTodo extends ActionDefinition<'createTodo', 'Todo', createTodo> { - type: 'action'; apiName: 'createTodo'; description: 'Creates a new Todo'; modifiedEntities: { Todo: { created: true; modified: false } }; + type: 'action'; parameters: ActionDef$createTodo$Params; } diff --git a/examples-extra/basic/sdk/src/generatedNoCheck/ontology/interfaces/FooInterface.ts b/examples-extra/basic/sdk/src/generatedNoCheck/ontology/interfaces/FooInterface.ts index f94d960ab..723e2304f 100644 --- a/examples-extra/basic/sdk/src/generatedNoCheck/ontology/interfaces/FooInterface.ts +++ b/examples-extra/basic/sdk/src/generatedNoCheck/ontology/interfaces/FooInterface.ts @@ -2,17 +2,17 @@ import type { InterfaceDefinition, PropertyDef } from '@osdk/api'; export interface FooInterface extends InterfaceDefinition<'FooInterface', FooInterface> { description: 'Its a Foo.'; + links: {}; properties: { - name: PropertyDef<'string', 'nullable', 'single'>; description: PropertyDef<'string', 'nullable', 'single'>; + name: PropertyDef<'string', 'nullable', 'single'>; }; - links: {}; } export const FooInterface: FooInterface = { - type: 'interface', apiName: 'FooInterface', description: 'Its a Foo.', + links: {}, properties: { name: { multiplicity: false, @@ -27,5 +27,5 @@ export const FooInterface: FooInterface = { nullable: true, }, }, - links: {}, + type: 'interface', }; diff --git a/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/BoundariesUsState.ts b/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/BoundariesUsState.ts index e68ff34a1..0f1c3f57f 100644 --- a/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/BoundariesUsState.ts +++ b/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/BoundariesUsState.ts @@ -2,24 +2,23 @@ import type { ObjectTypeDefinition, PropertyDef } from '@osdk/api'; export interface BoundariesUsState extends ObjectTypeDefinition<'BoundariesUsState', BoundariesUsState> { description: 'Boundaries US State'; + links: {}; primaryKeyApiName: 'usState'; primaryKeyType: 'string'; - links: {}; properties: { - usState: PropertyDef<'string', 'non-nullable', 'single'>; + geometry10M: PropertyDef<'geoshape', 'nullable', 'single'>; latitude: PropertyDef<'double', 'nullable', 'single'>; longitude: PropertyDef<'double', 'nullable', 'single'>; - geometry10M: PropertyDef<'geoshape', 'nullable', 'single'>; + usState: PropertyDef<'string', 'non-nullable', 'single'>; }; } export const BoundariesUsState: BoundariesUsState = { - type: 'object', apiName: 'BoundariesUsState', description: 'Boundaries US State', + links: {}, primaryKeyApiName: 'usState', primaryKeyType: 'string', - links: {}, properties: { usState: { multiplicity: false, @@ -43,4 +42,5 @@ export const BoundariesUsState: BoundariesUsState = { nullable: true, }, }, + type: 'object', }; diff --git a/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/Employee.ts b/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/Employee.ts index a3cf20225..15b9a4205 100644 --- a/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/Employee.ts +++ b/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/Employee.ts @@ -4,44 +4,46 @@ import type { Venture } from './Venture.js'; export interface Employee extends ObjectTypeDefinition<'Employee', Employee> { description: 'An employee'; - primaryKeyApiName: 'id'; - primaryKeyType: 'string'; + implements: ['FooInterface']; + inverseSpts: { + name: 'firstName'; + description: 'email'; + }; links: { lead: ObjectTypeLinkDefinition; peeps: ObjectTypeLinkDefinition; ventures: ObjectTypeLinkDefinition; }; + primaryKeyApiName: 'id'; + primaryKeyType: 'string'; properties: { - id: PropertyDef<'string', 'non-nullable', 'single'>; - firstName: PropertyDef<'string', 'nullable', 'single'>; - email: PropertyDef<'string', 'nullable', 'single'>; adUsername: PropertyDef<'string', 'nullable', 'single'>; - locationName: PropertyDef<'string', 'nullable', 'single'>; - locationCity: PropertyDef<'string', 'nullable', 'single'>; - firstFullTimeStartDate: PropertyDef<'datetime', 'nullable', 'single'>; businessTitle: PropertyDef<'string', 'nullable', 'single'>; + email: PropertyDef<'string', 'nullable', 'single'>; employeeNumber: PropertyDef<'double', 'nullable', 'single'>; + favPlace: PropertyDef<'geopoint', 'nullable', 'single'>; + firstFullTimeStartDate: PropertyDef<'datetime', 'nullable', 'single'>; + firstName: PropertyDef<'string', 'nullable', 'single'>; + id: PropertyDef<'string', 'non-nullable', 'single'>; jobProfile: PropertyDef<'string', 'nullable', 'single'>; + locationCity: PropertyDef<'string', 'nullable', 'single'>; + locationName: PropertyDef<'string', 'nullable', 'single'>; locationType: PropertyDef<'string', 'nullable', 'single'>; - favPlace: PropertyDef<'geopoint', 'nullable', 'single'>; }; spts: { firstName: 'name'; email: 'description'; }; - inverseSpts: { - name: 'firstName'; - description: 'email'; - }; - implements: ['FooInterface']; } export const Employee: Employee = { - type: 'object', apiName: 'Employee', description: 'An employee', - primaryKeyApiName: 'id', - primaryKeyType: 'string', + implements: ['FooInterface'], + inverseSpts: { + name: 'firstName', + description: 'email', + }, links: { lead: { multiplicity: false, @@ -56,6 +58,8 @@ export const Employee: Employee = { targetType: 'Venture', }, }, + primaryKeyApiName: 'id', + primaryKeyType: 'string', properties: { id: { multiplicity: false, @@ -122,9 +126,5 @@ export const Employee: Employee = { firstName: 'name', email: 'description', }, - inverseSpts: { - name: 'firstName', - description: 'email', - }, - implements: ['FooInterface'], + type: 'object', }; diff --git a/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/ObjectTypeWithAllPropertyTypes.ts b/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/ObjectTypeWithAllPropertyTypes.ts index 5481735b9..31f23b54a 100644 --- a/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/ObjectTypeWithAllPropertyTypes.ts +++ b/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/ObjectTypeWithAllPropertyTypes.ts @@ -3,51 +3,50 @@ import type { ObjectTypeDefinition, PropertyDef } from '@osdk/api'; export interface ObjectTypeWithAllPropertyTypes extends ObjectTypeDefinition<'ObjectTypeWithAllPropertyTypes', ObjectTypeWithAllPropertyTypes> { description: 'A type with all property types'; + links: {}; primaryKeyApiName: 'id'; primaryKeyType: 'integer'; - links: {}; properties: { - id: PropertyDef<'integer', 'non-nullable', 'single'>; - string: PropertyDef<'string', 'nullable', 'single'>; + attachment: PropertyDef<'attachment', 'nullable', 'single'>; + attachmentArray: PropertyDef<'attachment', 'nullable', 'array'>; boolean: PropertyDef<'boolean', 'nullable', 'single'>; + booleanArray: PropertyDef<'boolean', 'nullable', 'array'>; + byte: PropertyDef<'byte', 'nullable', 'single'>; + byteArray: PropertyDef<'byte', 'nullable', 'array'>; date: PropertyDef<'datetime', 'nullable', 'single'>; + dateArray: PropertyDef<'datetime', 'nullable', 'array'>; dateTime: PropertyDef<'timestamp', 'nullable', 'single'>; + dateTimeArray: PropertyDef<'timestamp', 'nullable', 'array'>; decimal: PropertyDef<'decimal', 'nullable', 'single'>; - integer: PropertyDef<'integer', 'nullable', 'single'>; - long: PropertyDef<'long', 'nullable', 'single'>; - short: PropertyDef<'short', 'nullable', 'single'>; - float: PropertyDef<'float', 'nullable', 'single'>; + decimalArray: PropertyDef<'decimal', 'nullable', 'array'>; double: PropertyDef<'double', 'nullable', 'single'>; - byte: PropertyDef<'byte', 'nullable', 'single'>; - attachment: PropertyDef<'attachment', 'nullable', 'single'>; + doubleArray: PropertyDef<'double', 'nullable', 'array'>; + float: PropertyDef<'float', 'nullable', 'single'>; + floatArray: PropertyDef<'float', 'nullable', 'array'>; geoPoint: PropertyDef<'geopoint', 'nullable', 'single'>; + geoPointArray: PropertyDef<'geopoint', 'nullable', 'array'>; geoShape: PropertyDef<'geoshape', 'nullable', 'single'>; - stringArray: PropertyDef<'string', 'nullable', 'array'>; - booleanArray: PropertyDef<'boolean', 'nullable', 'array'>; - dateArray: PropertyDef<'datetime', 'nullable', 'array'>; - dateTimeArray: PropertyDef<'timestamp', 'nullable', 'array'>; - decimalArray: PropertyDef<'decimal', 'nullable', 'array'>; + geoShapeArray: PropertyDef<'geoshape', 'nullable', 'array'>; + id: PropertyDef<'integer', 'non-nullable', 'single'>; + integer: PropertyDef<'integer', 'nullable', 'single'>; integerArray: PropertyDef<'integer', 'nullable', 'array'>; + long: PropertyDef<'long', 'nullable', 'single'>; longArray: PropertyDef<'long', 'nullable', 'array'>; - shortArray: PropertyDef<'short', 'nullable', 'array'>; - floatArray: PropertyDef<'float', 'nullable', 'array'>; - doubleArray: PropertyDef<'double', 'nullable', 'array'>; - byteArray: PropertyDef<'byte', 'nullable', 'array'>; - attachmentArray: PropertyDef<'attachment', 'nullable', 'array'>; - geoPointArray: PropertyDef<'geopoint', 'nullable', 'array'>; - geoShapeArray: PropertyDef<'geoshape', 'nullable', 'array'>; numericTimeseries: PropertyDef<'numericTimeseries', 'nullable', 'single'>; + short: PropertyDef<'short', 'nullable', 'single'>; + shortArray: PropertyDef<'short', 'nullable', 'array'>; + string: PropertyDef<'string', 'nullable', 'single'>; + stringArray: PropertyDef<'string', 'nullable', 'array'>; stringTimeseries: PropertyDef<'stringTimeseries', 'nullable', 'single'>; }; } export const ObjectTypeWithAllPropertyTypes: ObjectTypeWithAllPropertyTypes = { - type: 'object', apiName: 'ObjectTypeWithAllPropertyTypes', description: 'A type with all property types', + links: {}, primaryKeyApiName: 'id', primaryKeyType: 'integer', - links: {}, properties: { id: { multiplicity: false, @@ -205,4 +204,5 @@ export const ObjectTypeWithAllPropertyTypes: ObjectTypeWithAllPropertyTypes = { nullable: true, }, }, + type: 'object', }; diff --git a/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/Person.ts b/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/Person.ts index 15b4ba06f..6e12c17c8 100644 --- a/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/Person.ts +++ b/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/Person.ts @@ -4,23 +4,20 @@ import type { Todo } from './Todo.js'; export interface Person extends ObjectTypeDefinition<'Person', Person> { description: 'A person'; - primaryKeyApiName: 'email'; - primaryKeyType: 'string'; links: { - Todos: ObjectTypeLinkDefinition; Friends: ObjectTypeLinkDefinition; + Todos: ObjectTypeLinkDefinition; }; + primaryKeyApiName: 'email'; + primaryKeyType: 'string'; properties: { email: PropertyDef<'string', 'non-nullable', 'single'>; }; } export const Person: Person = { - type: 'object', apiName: 'Person', description: 'A person', - primaryKeyApiName: 'email', - primaryKeyType: 'string', links: { Todos: { multiplicity: true, @@ -31,6 +28,8 @@ export const Person: Person = { targetType: 'Person', }, }, + primaryKeyApiName: 'email', + primaryKeyType: 'string', properties: { email: { multiplicity: false, @@ -38,4 +37,5 @@ export const Person: Person = { nullable: false, }, }, + type: 'object', }; diff --git a/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/Todo.ts b/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/Todo.ts index 8f0f46dd0..ae8076ae7 100644 --- a/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/Todo.ts +++ b/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/Todo.ts @@ -4,32 +4,31 @@ import type { Person } from './Person.js'; export interface Todo extends ObjectTypeDefinition<'Todo', Todo> { description: 'Its a todo item.'; - primaryKeyApiName: 'id'; - primaryKeyType: 'integer'; links: { Assignee: ObjectTypeLinkDefinition; }; + primaryKeyApiName: 'id'; + primaryKeyType: 'integer'; properties: { - id: PropertyDef<'integer', 'non-nullable', 'single'>; body: PropertyDef<'string', 'nullable', 'single'>; - text: PropertyDef<'string', 'nullable', 'single'>; - priority: PropertyDef<'integer', 'nullable', 'single'>; complete: PropertyDef<'boolean', 'nullable', 'single'>; + id: PropertyDef<'integer', 'non-nullable', 'single'>; + priority: PropertyDef<'integer', 'nullable', 'single'>; + text: PropertyDef<'string', 'nullable', 'single'>; }; } export const Todo: Todo = { - type: 'object', apiName: 'Todo', description: 'Its a todo item.', - primaryKeyApiName: 'id', - primaryKeyType: 'integer', links: { Assignee: { multiplicity: false, targetType: 'Person', }, }, + primaryKeyApiName: 'id', + primaryKeyType: 'integer', properties: { id: { multiplicity: false, @@ -58,4 +57,5 @@ export const Todo: Todo = { nullable: true, }, }, + type: 'object', }; diff --git a/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/Venture.ts b/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/Venture.ts index 25d017176..f6c87d076 100644 --- a/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/Venture.ts +++ b/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/Venture.ts @@ -4,11 +4,11 @@ import type { Employee } from './Employee.js'; export interface Venture extends ObjectTypeDefinition<'Venture', Venture> { description: 'A venture'; - primaryKeyApiName: 'ventureId'; - primaryKeyType: 'string'; links: { employees: ObjectTypeLinkDefinition; }; + primaryKeyApiName: 'ventureId'; + primaryKeyType: 'string'; properties: { ventureId: PropertyDef<'string', 'non-nullable', 'single'>; ventureName: PropertyDef<'string', 'nullable', 'single'>; @@ -17,17 +17,16 @@ export interface Venture extends ObjectTypeDefinition<'Venture', Venture> { } export const Venture: Venture = { - type: 'object', apiName: 'Venture', description: 'A venture', - primaryKeyApiName: 'ventureId', - primaryKeyType: 'string', links: { employees: { multiplicity: true, targetType: 'Employee', }, }, + primaryKeyApiName: 'ventureId', + primaryKeyType: 'string', properties: { ventureId: { multiplicity: false, @@ -45,4 +44,5 @@ export const Venture: Venture = { nullable: true, }, }, + type: 'object', }; diff --git a/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/WeatherStation.ts b/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/WeatherStation.ts index ab9b60420..547f729d6 100644 --- a/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/WeatherStation.ts +++ b/examples-extra/basic/sdk/src/generatedNoCheck/ontology/objects/WeatherStation.ts @@ -2,22 +2,21 @@ import type { ObjectTypeDefinition, PropertyDef } from '@osdk/api'; export interface WeatherStation extends ObjectTypeDefinition<'WeatherStation', WeatherStation> { description: 'Weather Station'; + links: {}; primaryKeyApiName: 'stationId'; primaryKeyType: 'string'; - links: {}; properties: { - stationId: PropertyDef<'string', 'non-nullable', 'single'>; geohash: PropertyDef<'geopoint', 'nullable', 'single'>; + stationId: PropertyDef<'string', 'non-nullable', 'single'>; }; } export const WeatherStation: WeatherStation = { - type: 'object', apiName: 'WeatherStation', description: 'Weather Station', + links: {}, primaryKeyApiName: 'stationId', primaryKeyType: 'string', - links: {}, properties: { stationId: { multiplicity: false, @@ -31,4 +30,5 @@ export const WeatherStation: WeatherStation = { nullable: true, }, }, + type: 'object', }; diff --git a/examples-extra/docs_example/src/generatedNoCheck/Ontology.ts b/examples-extra/docs_example/src/generatedNoCheck/Ontology.ts index fab1e7a24..df2e63520 100644 --- a/examples-extra/docs_example/src/generatedNoCheck/Ontology.ts +++ b/examples-extra/docs_example/src/generatedNoCheck/Ontology.ts @@ -6,25 +6,25 @@ import * as Objects from './ontology/objects'; const _Ontology = { metadata: OntologyMetadata, objects: { - Todo: Objects.Todo, Employee: Objects.Employee, - Office: Objects.Office, equipment: Objects.equipment, + Office: Objects.Office, + Todo: Objects.Todo, }, actions: { - createTodo: Actions.createTodo, completeTodo: Actions.completeTodo, - promoteEmployee: Actions.promoteEmployee, - promoteEmployeeObject: Actions.promoteEmployeeObject, createOffice: Actions.createOffice, createOfficeAndEmployee: Actions.createOfficeAndEmployee, + createTodo: Actions.createTodo, moveOffice: Actions.moveOffice, + promoteEmployee: Actions.promoteEmployee, + promoteEmployeeObject: Actions.promoteEmployeeObject, }, queries: { // TODO }, interfaces: {}, -} satisfies OntologyDefinition<'Todo' | 'Employee' | 'Office' | 'equipment'>; +} satisfies OntologyDefinition<'Employee' | 'equipment' | 'Office' | 'Todo'>; type _Ontology = typeof _Ontology; export interface Ontology extends _Ontology {} 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 13ae050eb..9751e2415 100644 --- a/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/completeTodo.ts +++ b/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/completeTodo.ts @@ -4,16 +4,16 @@ import type { Todo } from '../objects'; // Represents the definition of the parameters for the action export type ActionDef$completeTodo$Params = { - Todo: { + is_complete: { multiplicity: false; - type: ObjectActionDataType<'Todo', Todo>; nullable: false; - description: 'A todo Object'; + type: 'boolean'; }; - is_complete: { + Todo: { + description: 'A todo Object'; multiplicity: false; - type: 'boolean'; nullable: false; + type: ObjectActionDataType<'Todo', Todo>; }; }; @@ -30,10 +30,10 @@ export interface completeTodo { // Represents the definition of the action export interface ActionDef$completeTodo extends ActionDefinition<'completeTodo', 'Todo', completeTodo> { - type: 'action'; apiName: 'completeTodo'; description: 'Completes Todo'; modifiedEntities: { Todo: { created: false; modified: true } }; + type: 'action'; parameters: ActionDef$completeTodo$Params; } 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 89793a471..fe4bfcdf5 100644 --- a/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/createOffice.ts +++ b/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/createOffice.ts @@ -3,28 +3,28 @@ import type { ActionReturnTypeForOptions, ApplyActionOptions, NOOP, OsdkActionPa // Represents the definition of the parameters for the action export type ActionDef$createOffice$Params = { - officeId: { - multiplicity: false; - type: 'string'; - nullable: false; - }; address: { + description: "The office's physical address (not necessarily shipping address)"; multiplicity: false; - type: 'string'; nullable: true; - description: "The office's physical address (not necessarily shipping address)"; + type: 'string'; }; capacity: { + description: 'The maximum seated-at-desk capacity of the office (maximum fire-safe capacity may be higher)'; multiplicity: false; - type: 'integer'; nullable: true; - description: 'The maximum seated-at-desk capacity of the office (maximum fire-safe capacity may be higher)'; + type: 'integer'; + }; + officeId: { + multiplicity: false; + nullable: false; + type: 'string'; }; officeNames: { + description: 'A list of all office names'; multiplicity: true; - type: 'string'; nullable: true; - description: 'A list of all office names'; + type: 'string'; }; }; @@ -41,10 +41,10 @@ export interface createOffice { // Represents the definition of the action export interface ActionDef$createOffice extends ActionDefinition<'createOffice', 'Office', createOffice> { - type: 'action'; apiName: 'createOffice'; description: "Create an office's"; modifiedEntities: { Office: { created: true; modified: false } }; + type: 'action'; parameters: ActionDef$createOffice$Params; } 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 f118a16ec..0f383d473 100644 --- a/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/createOfficeAndEmployee.ts +++ b/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/createOfficeAndEmployee.ts @@ -3,34 +3,34 @@ import type { ActionReturnTypeForOptions, ApplyActionOptions, NOOP, OsdkActionPa // Represents the definition of the parameters for the action export type ActionDef$createOfficeAndEmployee$Params = { - officeId: { - multiplicity: false; - type: 'string'; - nullable: false; - }; address: { + description: "The office's physical address (not necessarily shipping address)"; multiplicity: false; - type: 'string'; nullable: true; - description: "The office's physical address (not necessarily shipping address)"; + type: 'string'; }; capacity: { - multiplicity: false; - type: 'integer'; - nullable: true; description: 'The maximum seated-at-desk capacity of the office (maximum fire-safe capacity may be higher)'; - }; - officeNames: { - multiplicity: true; - type: 'string'; + multiplicity: false; nullable: true; - description: 'A list of all office names'; + type: 'integer'; }; employeeId: { + description: 'New employee Id'; multiplicity: false; + nullable: false; type: 'integer'; + }; + officeId: { + multiplicity: false; nullable: false; - description: 'New employee Id'; + type: 'string'; + }; + officeNames: { + description: 'A list of all office names'; + multiplicity: true; + nullable: true; + type: 'string'; }; }; @@ -51,10 +51,10 @@ export interface createOfficeAndEmployee { // Represents the definition of the action export interface ActionDef$createOfficeAndEmployee extends ActionDefinition<'createOfficeAndEmployee', 'Office' | 'Employee', createOfficeAndEmployee> { - type: 'action'; apiName: 'createOfficeAndEmployee'; description: 'Create an office and employee'; modifiedEntities: { Office: { created: true; modified: false }; Employee: { created: true; modified: false } }; + type: 'action'; parameters: ActionDef$createOfficeAndEmployee$Params; } 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 9b6dc9343..29262195c 100644 --- a/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/createTodo.ts +++ b/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/createTodo.ts @@ -3,15 +3,15 @@ import type { ActionReturnTypeForOptions, ApplyActionOptions, NOOP, OsdkActionPa // Represents the definition of the parameters for the action export type ActionDef$createTodo$Params = { - Todo: { + is_complete: { multiplicity: false; - type: 'string'; nullable: false; + type: 'boolean'; }; - is_complete: { + Todo: { multiplicity: false; - type: 'boolean'; nullable: false; + type: 'string'; }; }; @@ -28,10 +28,10 @@ export interface createTodo { // Represents the definition of the action export interface ActionDef$createTodo extends ActionDefinition<'createTodo', 'Todo', createTodo> { - type: 'action'; apiName: 'createTodo'; description: 'Creates Todo'; modifiedEntities: { Todo: { created: true; modified: false } }; + type: 'action'; parameters: ActionDef$createTodo$Params; } 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 1ffbb683d..3188aa028 100644 --- a/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/moveOffice.ts +++ b/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/moveOffice.ts @@ -3,28 +3,28 @@ import type { ActionReturnTypeForOptions, ApplyActionOptions, NOOP, OsdkActionPa // Represents the definition of the parameters for the action export type ActionDef$moveOffice$Params = { - officeId: { - multiplicity: false; - type: 'string'; - nullable: false; - }; newAddress: { + description: "The office's new physical address (not necessarily shipping address)"; multiplicity: false; - type: 'string'; nullable: true; - description: "The office's new physical address (not necessarily shipping address)"; + type: 'string'; }; newCapacity: { + description: 'The maximum seated-at-desk capacity of the new office (maximum fire-safe capacity may be higher)'; multiplicity: false; - type: 'integer'; nullable: true; - description: 'The maximum seated-at-desk capacity of the new office (maximum fire-safe capacity may be higher)'; + type: 'integer'; + }; + officeId: { + multiplicity: false; + nullable: false; + type: 'string'; }; officeNames: { + description: 'A list of all office names'; multiplicity: true; - type: 'integer'; nullable: true; - description: 'A list of all office names'; + type: 'integer'; }; }; @@ -41,10 +41,10 @@ export interface moveOffice { // Represents the definition of the action export interface ActionDef$moveOffice extends ActionDefinition<'moveOffice', 'Office', moveOffice> { - type: 'action'; apiName: 'moveOffice'; description: "Update an office's physical location"; modifiedEntities: { Office: { created: false; modified: true } }; + type: 'action'; parameters: ActionDef$moveOffice$Params; } 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 b8aafe94b..64524aef5 100644 --- a/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/promoteEmployee.ts +++ b/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/promoteEmployee.ts @@ -5,18 +5,18 @@ import type { ActionReturnTypeForOptions, ApplyActionOptions, NOOP, OsdkActionPa export type ActionDef$promoteEmployee$Params = { employeeId: { multiplicity: false; - type: 'integer'; nullable: false; + type: 'integer'; }; - newTitle: { + newCompensation: { multiplicity: false; - type: 'string'; nullable: false; + type: 'double'; }; - newCompensation: { + newTitle: { multiplicity: false; - type: 'double'; nullable: false; + type: 'string'; }; }; @@ -33,10 +33,10 @@ export interface promoteEmployee { // Represents the definition of the action export interface ActionDef$promoteEmployee extends ActionDefinition<'promoteEmployee', 'Employee', promoteEmployee> { - type: 'action'; apiName: 'promoteEmployee'; description: "Update an employee's title and compensation"; modifiedEntities: { Employee: { created: false; modified: true } }; + type: 'action'; parameters: ActionDef$promoteEmployee$Params; } 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 2ed36ec17..2c9f636f3 100644 --- a/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/promoteEmployeeObject.ts +++ b/examples-extra/docs_example/src/generatedNoCheck/ontology/actions/promoteEmployeeObject.ts @@ -6,18 +6,18 @@ import type { Employee } from '../objects'; export type ActionDef$promoteEmployeeObject$Params = { employee: { multiplicity: false; - type: ObjectActionDataType<'Employee', Employee>; nullable: false; + type: ObjectActionDataType<'Employee', Employee>; }; - newTitle: { + newCompensation: { multiplicity: false; - type: 'string'; nullable: false; + type: 'double'; }; - newCompensation: { + newTitle: { multiplicity: false; - type: 'double'; nullable: false; + type: 'string'; }; }; @@ -38,10 +38,10 @@ export interface promoteEmployeeObject { // Represents the definition of the action export interface ActionDef$promoteEmployeeObject extends ActionDefinition<'promoteEmployeeObject', 'Employee', promoteEmployeeObject> { - type: 'action'; apiName: 'promoteEmployeeObject'; description: "Update an employee's title and compensation"; modifiedEntities: { Employee: { created: false; modified: true } }; + type: 'action'; parameters: ActionDef$promoteEmployeeObject$Params; } diff --git a/examples-extra/docs_example/src/generatedNoCheck/ontology/objects/Employee.ts b/examples-extra/docs_example/src/generatedNoCheck/ontology/objects/Employee.ts index 7d3023816..9279bb4b1 100644 --- a/examples-extra/docs_example/src/generatedNoCheck/ontology/objects/Employee.ts +++ b/examples-extra/docs_example/src/generatedNoCheck/ontology/objects/Employee.ts @@ -2,28 +2,25 @@ import type { ObjectTypeDefinition, ObjectTypeLinkDefinition, PropertyDef } from export interface Employee extends ObjectTypeDefinition<'Employee', Employee> { description: 'A full-time or part-time employee of our firm'; - primaryKeyApiName: 'employeeId'; - primaryKeyType: 'integer'; links: { lead: ObjectTypeLinkDefinition; peeps: ObjectTypeLinkDefinition; }; + primaryKeyApiName: 'employeeId'; + primaryKeyType: 'integer'; properties: { - employeeId: PropertyDef<'integer', 'non-nullable', 'single'>; class: PropertyDef<'string', 'nullable', 'single'>; + employeeId: PropertyDef<'integer', 'non-nullable', 'single'>; + employeeStatus: PropertyDef<'numericTimeseries', 'nullable', 'single'>; fullName: PropertyDef<'string', 'nullable', 'single'>; office: PropertyDef<'integer', 'nullable', 'single'>; startDate: PropertyDef<'datetime', 'nullable', 'single'>; - employeeStatus: PropertyDef<'numericTimeseries', 'nullable', 'single'>; }; } export const Employee: Employee = { - type: 'object', apiName: 'Employee', description: 'A full-time or part-time employee of our firm', - primaryKeyApiName: 'employeeId', - primaryKeyType: 'integer', links: { lead: { multiplicity: false, @@ -34,6 +31,8 @@ export const Employee: Employee = { targetType: 'Employee', }, }, + primaryKeyApiName: 'employeeId', + primaryKeyType: 'integer', properties: { employeeId: { multiplicity: false, @@ -69,4 +68,5 @@ export const Employee: Employee = { nullable: true, }, }, + type: 'object', }; diff --git a/examples-extra/docs_example/src/generatedNoCheck/ontology/objects/Office.ts b/examples-extra/docs_example/src/generatedNoCheck/ontology/objects/Office.ts index 4c1c0e38a..d0081c3e6 100644 --- a/examples-extra/docs_example/src/generatedNoCheck/ontology/objects/Office.ts +++ b/examples-extra/docs_example/src/generatedNoCheck/ontology/objects/Office.ts @@ -2,24 +2,23 @@ import type { ObjectTypeDefinition, PropertyDef } from '@osdk/api'; export interface Office extends ObjectTypeDefinition<'Office', Office> { description: 'A office in our Company'; + links: {}; primaryKeyApiName: 'officeId'; primaryKeyType: 'string'; - links: {}; properties: { - officeId: PropertyDef<'string', 'non-nullable', 'single'>; entrance: PropertyDef<'geopoint', 'nullable', 'single'>; - occupiedArea: PropertyDef<'geoshape', 'nullable', 'single'>; name: PropertyDef<'string', 'nullable', 'single'>; + occupiedArea: PropertyDef<'geoshape', 'nullable', 'single'>; + officeId: PropertyDef<'string', 'non-nullable', 'single'>; }; } export const Office: Office = { - type: 'object', apiName: 'Office', description: 'A office in our Company', + links: {}, primaryKeyApiName: 'officeId', primaryKeyType: 'string', - links: {}, properties: { officeId: { multiplicity: false, @@ -44,4 +43,5 @@ export const Office: Office = { nullable: true, }, }, + type: 'object', }; diff --git a/examples-extra/docs_example/src/generatedNoCheck/ontology/objects/Todo.ts b/examples-extra/docs_example/src/generatedNoCheck/ontology/objects/Todo.ts index 0094f8b00..d9e08c0e1 100644 --- a/examples-extra/docs_example/src/generatedNoCheck/ontology/objects/Todo.ts +++ b/examples-extra/docs_example/src/generatedNoCheck/ontology/objects/Todo.ts @@ -2,23 +2,22 @@ import type { ObjectTypeDefinition, PropertyDef } from '@osdk/api'; export interface Todo extends ObjectTypeDefinition<'Todo', Todo> { description: 'Its a todo item.'; + links: {}; primaryKeyApiName: 'id'; primaryKeyType: 'string'; - links: {}; properties: { id: PropertyDef<'string', 'non-nullable', 'single'>; - title: PropertyDef<'string', 'nullable', 'single'>; isComplete: PropertyDef<'boolean', 'nullable', 'single'>; + title: PropertyDef<'string', 'nullable', 'single'>; }; } export const Todo: Todo = { - type: 'object', apiName: 'Todo', description: 'Its a todo item.', + links: {}, primaryKeyApiName: 'id', primaryKeyType: 'string', - links: {}, properties: { id: { multiplicity: false, @@ -37,4 +36,5 @@ export const Todo: Todo = { nullable: true, }, }, + type: 'object', }; diff --git a/examples-extra/docs_example/src/generatedNoCheck/ontology/objects/equipment.ts b/examples-extra/docs_example/src/generatedNoCheck/ontology/objects/equipment.ts index 7088df97c..dafc86c80 100644 --- a/examples-extra/docs_example/src/generatedNoCheck/ontology/objects/equipment.ts +++ b/examples-extra/docs_example/src/generatedNoCheck/ontology/objects/equipment.ts @@ -1,9 +1,9 @@ import type { ObjectTypeDefinition, PropertyDef } from '@osdk/api'; export interface equipment extends ObjectTypeDefinition<'equipment', equipment> { + links: {}; primaryKeyApiName: 'equipmentId'; primaryKeyType: 'string'; - links: {}; properties: { equipmentId: PropertyDef<'string', 'non-nullable', 'single'>; type: PropertyDef<'string', 'nullable', 'single'>; @@ -11,11 +11,10 @@ export interface equipment extends ObjectTypeDefinition<'equipment', equipment> } export const equipment: equipment = { - type: 'object', apiName: 'equipment', + links: {}, primaryKeyApiName: 'equipmentId', primaryKeyType: 'string', - links: {}, properties: { equipmentId: { multiplicity: false, @@ -29,4 +28,5 @@ export const equipment: equipment = { nullable: true, }, }, + type: 'object', }; diff --git a/examples-extra/one_dot_one/src/generatedNoCheck/ontology/objects/ObjectTypeWithAllPropertyTypes.ts b/examples-extra/one_dot_one/src/generatedNoCheck/ontology/objects/ObjectTypeWithAllPropertyTypes.ts index 54bb1c069..1339c73bd 100644 --- a/examples-extra/one_dot_one/src/generatedNoCheck/ontology/objects/ObjectTypeWithAllPropertyTypes.ts +++ b/examples-extra/one_dot_one/src/generatedNoCheck/ontology/objects/ObjectTypeWithAllPropertyTypes.ts @@ -50,12 +50,11 @@ export interface ObjectTypeWithAllPropertyTypes extends OntologyObject { export interface ObjectTypeWithAllPropertyTypesDef extends ObjectTypeDefinition<'ObjectTypeWithAllPropertyTypes', ObjectTypeWithAllPropertyTypes> { - type: 'object'; apiName: 'ObjectTypeWithAllPropertyTypes'; description: 'A type with all property types'; + links: {}; primaryKeyApiName: 'id'; primaryKeyType: 'integer'; - links: {}; properties: { id: { multiplicity: false; @@ -213,15 +212,15 @@ export interface ObjectTypeWithAllPropertyTypesDef nullable: true; }; }; + type: 'object'; } export const ObjectTypeWithAllPropertyTypes: ObjectTypeWithAllPropertyTypesDef = { - type: 'object', apiName: 'ObjectTypeWithAllPropertyTypes', description: 'A type with all property types', + links: {}, primaryKeyApiName: 'id', primaryKeyType: 'integer', - links: {}, properties: { id: { multiplicity: false, @@ -379,4 +378,5 @@ export const ObjectTypeWithAllPropertyTypes: ObjectTypeWithAllPropertyTypesDef = nullable: true, }, }, + type: 'object', }; diff --git a/examples-extra/one_dot_one/src/generatedNoCheck/ontology/objects/Person.ts b/examples-extra/one_dot_one/src/generatedNoCheck/ontology/objects/Person.ts index f1d9be150..ff06ba6b6 100644 --- a/examples-extra/one_dot_one/src/generatedNoCheck/ontology/objects/Person.ts +++ b/examples-extra/one_dot_one/src/generatedNoCheck/ontology/objects/Person.ts @@ -16,15 +16,14 @@ export interface Person extends OntologyObject { import type { TodoDef } from './Todo'; export interface PersonDef extends ObjectTypeDefinition<'Person', Person> { - type: 'object'; apiName: 'Person'; description: 'A person'; - primaryKeyApiName: 'email'; - primaryKeyType: 'string'; links: { - Todos: ObjectTypeLinkDefinition; Friends: ObjectTypeLinkDefinition; + Todos: ObjectTypeLinkDefinition; }; + primaryKeyApiName: 'email'; + primaryKeyType: 'string'; properties: { email: { multiplicity: false; @@ -32,14 +31,12 @@ export interface PersonDef extends ObjectTypeDefinition<'Person', Person> { nullable: true; }; }; + type: 'object'; } export const Person: PersonDef = { - type: 'object', apiName: 'Person', description: 'A person', - primaryKeyApiName: 'email', - primaryKeyType: 'string', links: { Todos: { multiplicity: true, @@ -50,6 +47,8 @@ export const Person: PersonDef = { targetType: 'Person', }, }, + primaryKeyApiName: 'email', + primaryKeyType: 'string', properties: { email: { multiplicity: false, @@ -57,4 +56,5 @@ export const Person: PersonDef = { nullable: true, }, }, + type: 'object', }; diff --git a/examples-extra/one_dot_one/src/generatedNoCheck/ontology/objects/Todo.ts b/examples-extra/one_dot_one/src/generatedNoCheck/ontology/objects/Todo.ts index d0c648c86..9d0d138e5 100644 --- a/examples-extra/one_dot_one/src/generatedNoCheck/ontology/objects/Todo.ts +++ b/examples-extra/one_dot_one/src/generatedNoCheck/ontology/objects/Todo.ts @@ -20,14 +20,13 @@ export interface Todo extends OntologyObject { import type { PersonDef } from './Person'; export interface TodoDef extends ObjectTypeDefinition<'Todo', Todo> { - type: 'object'; apiName: 'Todo'; description: 'Its a todo item.'; - primaryKeyApiName: 'id'; - primaryKeyType: 'integer'; links: { Assignee: ObjectTypeLinkDefinition; }; + primaryKeyApiName: 'id'; + primaryKeyType: 'integer'; properties: { id: { multiplicity: false; @@ -46,20 +45,20 @@ export interface TodoDef extends ObjectTypeDefinition<'Todo', Todo> { nullable: true; }; }; + type: 'object'; } export const Todo: TodoDef = { - type: 'object', apiName: 'Todo', description: 'Its a todo item.', - primaryKeyApiName: 'id', - primaryKeyType: 'integer', links: { Assignee: { multiplicity: false, targetType: 'Person', }, }, + primaryKeyApiName: 'id', + primaryKeyType: 'integer', properties: { id: { multiplicity: false, @@ -78,4 +77,5 @@ export const Todo: TodoDef = { nullable: true, }, }, + type: 'object', }; diff --git a/examples-extra/todoapp/src/generatedNoCheck/ontology/objects/Todo.ts b/examples-extra/todoapp/src/generatedNoCheck/ontology/objects/Todo.ts index 9dae49e12..c9b9b3a28 100644 --- a/examples-extra/todoapp/src/generatedNoCheck/ontology/objects/Todo.ts +++ b/examples-extra/todoapp/src/generatedNoCheck/ontology/objects/Todo.ts @@ -16,12 +16,11 @@ export interface Todo extends OntologyObject { } export interface TodoDef extends ObjectTypeDefinition<'Todo', Todo> { - type: 'object'; apiName: 'Todo'; description: 'Its a todo item.'; + links: {}; primaryKeyApiName: 'id'; primaryKeyType: 'string'; - links: {}; properties: { id: { multiplicity: false; @@ -40,15 +39,15 @@ export interface TodoDef extends ObjectTypeDefinition<'Todo', Todo> { nullable: true; }; }; + type: 'object'; } export const Todo: TodoDef = { - type: 'object', apiName: 'Todo', description: 'Its a todo item.', + links: {}, primaryKeyApiName: 'id', primaryKeyType: 'string', - links: {}, properties: { id: { multiplicity: false, @@ -67,4 +66,5 @@ export const Todo: TodoDef = { nullable: true, }, }, + type: 'object', }; diff --git a/examples-extra/todoapp/src/generatedNoCheck2/Ontology.ts b/examples-extra/todoapp/src/generatedNoCheck2/Ontology.ts index 09e0fc972..a8074c08e 100644 --- a/examples-extra/todoapp/src/generatedNoCheck2/Ontology.ts +++ b/examples-extra/todoapp/src/generatedNoCheck2/Ontology.ts @@ -9,8 +9,8 @@ const _Ontology = { Todo: Objects.Todo, }, actions: { - createTodo: Actions.createTodo, completeTodo: Actions.completeTodo, + createTodo: Actions.createTodo, }, queries: { // TODO diff --git a/examples-extra/todoapp/src/generatedNoCheck2/ontology/actions/completeTodo.ts b/examples-extra/todoapp/src/generatedNoCheck2/ontology/actions/completeTodo.ts index 13ae050eb..9751e2415 100644 --- a/examples-extra/todoapp/src/generatedNoCheck2/ontology/actions/completeTodo.ts +++ b/examples-extra/todoapp/src/generatedNoCheck2/ontology/actions/completeTodo.ts @@ -4,16 +4,16 @@ import type { Todo } from '../objects'; // Represents the definition of the parameters for the action export type ActionDef$completeTodo$Params = { - Todo: { + is_complete: { multiplicity: false; - type: ObjectActionDataType<'Todo', Todo>; nullable: false; - description: 'A todo Object'; + type: 'boolean'; }; - is_complete: { + Todo: { + description: 'A todo Object'; multiplicity: false; - type: 'boolean'; nullable: false; + type: ObjectActionDataType<'Todo', Todo>; }; }; @@ -30,10 +30,10 @@ export interface completeTodo { // Represents the definition of the action export interface ActionDef$completeTodo extends ActionDefinition<'completeTodo', 'Todo', completeTodo> { - type: 'action'; apiName: 'completeTodo'; description: 'Completes Todo'; modifiedEntities: { Todo: { created: false; modified: true } }; + type: 'action'; parameters: ActionDef$completeTodo$Params; } diff --git a/examples-extra/todoapp/src/generatedNoCheck2/ontology/actions/createTodo.ts b/examples-extra/todoapp/src/generatedNoCheck2/ontology/actions/createTodo.ts index 9b6dc9343..29262195c 100644 --- a/examples-extra/todoapp/src/generatedNoCheck2/ontology/actions/createTodo.ts +++ b/examples-extra/todoapp/src/generatedNoCheck2/ontology/actions/createTodo.ts @@ -3,15 +3,15 @@ import type { ActionReturnTypeForOptions, ApplyActionOptions, NOOP, OsdkActionPa // Represents the definition of the parameters for the action export type ActionDef$createTodo$Params = { - Todo: { + is_complete: { multiplicity: false; - type: 'string'; nullable: false; + type: 'boolean'; }; - is_complete: { + Todo: { multiplicity: false; - type: 'boolean'; nullable: false; + type: 'string'; }; }; @@ -28,10 +28,10 @@ export interface createTodo { // Represents the definition of the action export interface ActionDef$createTodo extends ActionDefinition<'createTodo', 'Todo', createTodo> { - type: 'action'; apiName: 'createTodo'; description: 'Creates Todo'; modifiedEntities: { Todo: { created: true; modified: false } }; + type: 'action'; parameters: ActionDef$createTodo$Params; } diff --git a/examples-extra/todoapp/src/generatedNoCheck2/ontology/objects/Todo.ts b/examples-extra/todoapp/src/generatedNoCheck2/ontology/objects/Todo.ts index 0094f8b00..d9e08c0e1 100644 --- a/examples-extra/todoapp/src/generatedNoCheck2/ontology/objects/Todo.ts +++ b/examples-extra/todoapp/src/generatedNoCheck2/ontology/objects/Todo.ts @@ -2,23 +2,22 @@ import type { ObjectTypeDefinition, PropertyDef } from '@osdk/api'; export interface Todo extends ObjectTypeDefinition<'Todo', Todo> { description: 'Its a todo item.'; + links: {}; primaryKeyApiName: 'id'; primaryKeyType: 'string'; - links: {}; properties: { id: PropertyDef<'string', 'non-nullable', 'single'>; - title: PropertyDef<'string', 'nullable', 'single'>; isComplete: PropertyDef<'boolean', 'nullable', 'single'>; + title: PropertyDef<'string', 'nullable', 'single'>; }; } export const Todo: Todo = { - type: 'object', apiName: 'Todo', description: 'Its a todo item.', + links: {}, primaryKeyApiName: 'id', primaryKeyType: 'string', - links: {}, properties: { id: { multiplicity: false, @@ -37,4 +36,5 @@ export const Todo: Todo = { nullable: true, }, }, + type: 'object', }; diff --git a/packages/client/src/actions/actions.test.ts b/packages/client/src/actions/actions.test.ts index 5bdfccf7b..ef7577fd0 100644 --- a/packages/client/src/actions/actions.test.ts +++ b/packages/client/src/actions/actions.test.ts @@ -54,13 +54,13 @@ describe("actions", () => { it("has an enumerable list of actions", () => { expect(Object.getOwnPropertyNames(client.actions)).toMatchInlineSnapshot(` [ - "promoteEmployee", - "promoteEmployeeObject", + "actionTakesAttachment", + "actionTakesObjectSet", "createOffice", "createOfficeAndEmployee", "moveOffice", - "actionTakesObjectSet", - "actionTakesAttachment", + "promoteEmployee", + "promoteEmployeeObject", ] `); }); diff --git a/packages/generator/changelog/@unreleased/pr-124.v2.yml b/packages/generator/changelog/@unreleased/pr-124.v2.yml new file mode 100644 index 000000000..e24e6ab04 --- /dev/null +++ b/packages/generator/changelog/@unreleased/pr-124.v2.yml @@ -0,0 +1,5 @@ +type: improvement +improvement: + description: Sort keys in generated files for smaller (future) diffs + links: + - https://github.com/palantir/osdk-ts/pull/124 diff --git a/packages/generator/src/util/stringify.ts b/packages/generator/src/util/stringify.ts index 6669eab09..cbc03b91a 100644 --- a/packages/generator/src/util/stringify.ts +++ b/packages/generator/src/util/stringify.ts @@ -53,7 +53,10 @@ export function stringify>( const defaultKeyFormatter = (key: string) => `${JSON.stringify(key)}`; const entries: Array = []; - for (const [key, value] of Object.entries(obj)) { + const sortedKeys = Object.keys(obj).sort((a, b) => a.localeCompare(b)); + + for (const key of sortedKeys) { + const value = obj[key]; const res = (customizer[key as keyof T] ?? customizer["*"] ?? defaultCustomizer)( value, diff --git a/packages/generator/src/v1.1/generatePerActionDataFiles.ts b/packages/generator/src/v1.1/generatePerActionDataFiles.ts index 92ff7d13b..597e9f2d1 100644 --- a/packages/generator/src/v1.1/generatePerActionDataFiles.ts +++ b/packages/generator/src/v1.1/generatePerActionDataFiles.ts @@ -55,6 +55,8 @@ export async function generatePerActionDataFiles( function createParamsDef() { const entries = Object.entries(parameters); + entries.sort((a, b) => a[0].localeCompare(b[0])); + if (entries.length === 0) { return `// Represents the definition of the parameters for the action export type ${paramsDefIdentifier} = Record;`; @@ -63,30 +65,29 @@ export async function generatePerActionDataFiles( return `// Represents the definition of the parameters for the action export type ${paramsDefIdentifier} = { ${ - Object.entries(parameters) - .map(([key, value]) => { - return `"${key}": { + entries.map(([key, value]) => { + return `"${key}": { ${ - stringify(value, { - description: (value, d) => value ? d(value) : undefined, // trick to remove undefineds - type: (type) => { - if (typeof type === "string") { - return JSON.stringify(type); - } else if (type.type === "object") { - return `ObjectActionDataType<"${type.object}", ${ - getObjectDefIdentifier(type.object, v2) - }>`; - } else if (type.type === "objectSet") { - return `ObjectSetActionDataType<"${type.objectSet}", ${ - getObjectDefIdentifier(type.objectSet, v2) - }>`; - } - return undefined; - }, - }) - } + stringify(value, { + description: (value, d) => value ? d(value) : undefined, // trick to remove undefineds + type: (type) => { + if (typeof type === "string") { + return JSON.stringify(type); + } else if (type.type === "object") { + return `ObjectActionDataType<"${type.object}", ${ + getObjectDefIdentifier(type.object, v2) + }>`; + } else if (type.type === "objectSet") { + return `ObjectSetActionDataType<"${type.objectSet}", ${ + getObjectDefIdentifier(type.objectSet, v2) + }>`; + } + return undefined; + }, + }) + } }`; - }) + }) .join(";\n") } }`; @@ -114,7 +115,9 @@ export async function generatePerActionDataFiles( // Represents the definition of the action export interface ${actionDefIdentifier} extends ActionDefinition<"${action.apiName}", ${uniqueApiNamesString}, ${action.apiName}>{ ${ - Object.entries(actionDefSansParameters).map(([key, value]) => { + Object.entries(actionDefSansParameters).sort((a, b) => + a[0].localeCompare(b[0]) + ).map(([key, value]) => { return `${key}: ${JSON.stringify(value)};`; }).join("\n") } diff --git a/packages/generator/src/v2.0/generateClientSdkVersionTwoPointZero.ts b/packages/generator/src/v2.0/generateClientSdkVersionTwoPointZero.ts index 88bdee0d7..7cdb00419 100644 --- a/packages/generator/src/v2.0/generateClientSdkVersionTwoPointZero.ts +++ b/packages/generator/src/v2.0/generateClientSdkVersionTwoPointZero.ts @@ -38,12 +38,18 @@ export async function generateClientSdkVersionTwoPointZero( const sanitizedOntology = sanitizeMetadata(ontology); - const objectNames = Object.keys(sanitizedOntology.objectTypes); - const actionNames = Object.keys(sanitizedOntology.actionTypes); - const queryNames = Object.keys(sanitizedOntology.queryTypes); + const objectNames = Object.keys(sanitizedOntology.objectTypes).sort((a, b) => + a.localeCompare(b) + ); + const actionNames = Object.keys(sanitizedOntology.actionTypes).sort((a, b) => + a.localeCompare(b) + ); + const queryNames = Object.keys(sanitizedOntology.queryTypes).sort((a, b) => + a.localeCompare(b) + ); const interfaceNames = Object.keys( sanitizedOntology.interfaceTypes ?? {}, - ); + ).sort((a, b) => a.localeCompare(b)); const importExt = packageType === "module" ? ".js" : ""; await fs.mkdir(outDir, { recursive: true }); @@ -146,8 +152,8 @@ export async function generateClientSdkVersionTwoPointZero( path.join(outDir, "ontology", "objects.ts"), await formatTs(` ${ - Object.keys(ontology.objectTypes).map(apiName => - `export * from "./objects/${apiName}${importExt}";` + Object.keys(ontology.objectTypes).sort((a, b) => a.localeCompare(b)).map( + apiName => `export * from "./objects/${apiName}${importExt}";`, ).join("\n") } ${Object.keys(ontology.objectTypes).length === 0 ? "export {};" : ""}