Skip to content

Commit

Permalink
Fix version adjusting logic for snapshots (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericanderson authored Apr 11, 2024
1 parent 2af723c commit f7287ae
Show file tree
Hide file tree
Showing 22 changed files with 51 additions and 34 deletions.
5 changes: 5 additions & 0 deletions .changeset/slow-eyes-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@osdk/generator": patch
---

For 2.0, fixes codegen version matching in snapshot builds
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { OntologyMetadata as OM } from '@osdk/api';

export const expectedClientVersion = '0.15.0';
export type $ExpectedClientVersion = '0.15.0';
export const $osdkMetadata = { extraUserAgent: 'typescript-sdk/dev osdk-cli/dev' };

export interface OntologyMetadata extends OM<'0.15.0'> {
expectsClientVersion: '0.15.0';
}
export interface OntologyMetadata extends OM<$ExpectedClientVersion> {}

export const OntologyMetadata: OntologyMetadata = {
expectsClientVersion: '0.15.0',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import type { InterfaceDefinition, PropertyDef, VersionBound } from '@osdk/api';
import type { $ExpectedClientVersion } from '../../OntologyMetadata.js';
import { $osdkMetadata } from '../../OntologyMetadata.js';

export interface FooInterface extends InterfaceDefinition<'FooInterface', FooInterface>, VersionBound<'0.15.0'> {
export interface FooInterface
extends InterfaceDefinition<'FooInterface', FooInterface>,
VersionBound<$ExpectedClientVersion> {
osdkMetadata: typeof $osdkMetadata;
description: 'Its a Foo.';
links: {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { ObjectTypeDefinition, PropertyDef, VersionBound } from '@osdk/api';
import type { $ExpectedClientVersion } from '../../OntologyMetadata.js';
import { $osdkMetadata } from '../../OntologyMetadata.js';

export interface BoundariesUsState
extends ObjectTypeDefinition<'BoundariesUsState', BoundariesUsState>,
VersionBound<'0.15.0'> {
VersionBound<$ExpectedClientVersion> {
osdkMetadata: typeof $osdkMetadata;
description: 'Boundaries US State';
links: {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { ObjectTypeDefinition, PropertyDef, VersionBound } from '@osdk/api';
import type { $ExpectedClientVersion } from '../../OntologyMetadata.js';
import { $osdkMetadata } from '../../OntologyMetadata.js';

export interface BuilderDeploymentState
extends ObjectTypeDefinition<'BuilderDeploymentState', BuilderDeploymentState>,
VersionBound<'0.15.0'> {
VersionBound<$ExpectedClientVersion> {
osdkMetadata: typeof $osdkMetadata;
description: 'Builder Deployment State';
links: {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { ObjectTypeDefinition, ObjectTypeLinkDefinition, PropertyDef, VersionBound } from '@osdk/api';
import type { $ExpectedClientVersion } from '../../OntologyMetadata.js';
import { $osdkMetadata } from '../../OntologyMetadata.js';

import type { Venture } from './Venture.js';

export interface Employee extends ObjectTypeDefinition<'Employee', Employee>, VersionBound<'0.15.0'> {
export interface Employee extends ObjectTypeDefinition<'Employee', Employee>, VersionBound<$ExpectedClientVersion> {
osdkMetadata: typeof $osdkMetadata;
description: 'An employee';
implements: ['FooInterface'];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { ObjectTypeDefinition, PropertyDef, VersionBound } from '@osdk/api';
import type { $ExpectedClientVersion } from '../../OntologyMetadata.js';
import { $osdkMetadata } from '../../OntologyMetadata.js';

export interface ObjectTypeWithAllPropertyTypes
extends ObjectTypeDefinition<'ObjectTypeWithAllPropertyTypes', ObjectTypeWithAllPropertyTypes>,
VersionBound<'0.15.0'> {
VersionBound<$ExpectedClientVersion> {
osdkMetadata: typeof $osdkMetadata;
description: 'A type with all property types';
links: {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { ObjectTypeDefinition, ObjectTypeLinkDefinition, PropertyDef, VersionBound } from '@osdk/api';
import type { $ExpectedClientVersion } from '../../OntologyMetadata.js';
import { $osdkMetadata } from '../../OntologyMetadata.js';

import type { Todo } from './Todo.js';

export interface Person extends ObjectTypeDefinition<'Person', Person>, VersionBound<'0.15.0'> {
export interface Person extends ObjectTypeDefinition<'Person', Person>, VersionBound<$ExpectedClientVersion> {
osdkMetadata: typeof $osdkMetadata;
description: 'A person';
links: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { ObjectTypeDefinition, ObjectTypeLinkDefinition, PropertyDef, VersionBound } from '@osdk/api';
import type { $ExpectedClientVersion } from '../../OntologyMetadata.js';
import { $osdkMetadata } from '../../OntologyMetadata.js';

import type { Person } from './Person.js';

export interface Todo extends ObjectTypeDefinition<'Todo', Todo>, VersionBound<'0.15.0'> {
export interface Todo extends ObjectTypeDefinition<'Todo', Todo>, VersionBound<$ExpectedClientVersion> {
osdkMetadata: typeof $osdkMetadata;
description: 'Its a todo item.';
links: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { ObjectTypeDefinition, ObjectTypeLinkDefinition, PropertyDef, VersionBound } from '@osdk/api';
import type { $ExpectedClientVersion } from '../../OntologyMetadata.js';
import { $osdkMetadata } from '../../OntologyMetadata.js';

import type { Employee } from './Employee.js';

export interface Venture extends ObjectTypeDefinition<'Venture', Venture>, VersionBound<'0.15.0'> {
export interface Venture extends ObjectTypeDefinition<'Venture', Venture>, VersionBound<$ExpectedClientVersion> {
osdkMetadata: typeof $osdkMetadata;
description: 'A venture';
links: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import type { ObjectTypeDefinition, PropertyDef, VersionBound } from '@osdk/api';
import type { $ExpectedClientVersion } from '../../OntologyMetadata.js';
import { $osdkMetadata } from '../../OntologyMetadata.js';

export interface WeatherStation extends ObjectTypeDefinition<'WeatherStation', WeatherStation>, VersionBound<'0.15.0'> {
export interface WeatherStation
extends ObjectTypeDefinition<'WeatherStation', WeatherStation>,
VersionBound<$ExpectedClientVersion> {
osdkMetadata: typeof $osdkMetadata;
description: 'Weather Station';
links: {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { OntologyMetadata as OM } from '@osdk/api';

export const expectedClientVersion = '0.15.0';
export type $ExpectedClientVersion = '0.15.0';
export const $osdkMetadata = { extraUserAgent: 'typescript-sdk/dev osdk-cli/dev' };

export interface OntologyMetadata extends OM<'0.15.0'> {
expectsClientVersion: '0.15.0';
}
export interface OntologyMetadata extends OM<$ExpectedClientVersion> {}

export const OntologyMetadata: OntologyMetadata = {
expectsClientVersion: '0.15.0',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { ObjectTypeDefinition, ObjectTypeLinkDefinition, PropertyDef, VersionBound } from '@osdk/api';
import type { $ExpectedClientVersion } from '../../OntologyMetadata';
import { $osdkMetadata } from '../../OntologyMetadata';

export interface Employee extends ObjectTypeDefinition<'Employee', Employee>, VersionBound<'0.15.0'> {
export interface Employee extends ObjectTypeDefinition<'Employee', Employee>, VersionBound<$ExpectedClientVersion> {
osdkMetadata: typeof $osdkMetadata;
description: 'A full-time or part-time employee of our firm';
links: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { ObjectTypeDefinition, PropertyDef, VersionBound } from '@osdk/api';
import type { $ExpectedClientVersion } from '../../OntologyMetadata';
import { $osdkMetadata } from '../../OntologyMetadata';

export interface Office extends ObjectTypeDefinition<'Office', Office>, VersionBound<'0.15.0'> {
export interface Office extends ObjectTypeDefinition<'Office', Office>, VersionBound<$ExpectedClientVersion> {
osdkMetadata: typeof $osdkMetadata;
description: 'A office in our Company';
links: {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { ObjectTypeDefinition, PropertyDef, VersionBound } from '@osdk/api';
import type { $ExpectedClientVersion } from '../../OntologyMetadata';
import { $osdkMetadata } from '../../OntologyMetadata';

export interface Todo extends ObjectTypeDefinition<'Todo', Todo>, VersionBound<'0.15.0'> {
export interface Todo extends ObjectTypeDefinition<'Todo', Todo>, VersionBound<$ExpectedClientVersion> {
osdkMetadata: typeof $osdkMetadata;
description: 'Its a todo item.';
links: {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { ObjectTypeDefinition, PropertyDef, VersionBound } from '@osdk/api';
import type { $ExpectedClientVersion } from '../../OntologyMetadata';
import { $osdkMetadata } from '../../OntologyMetadata';

export interface equipment extends ObjectTypeDefinition<'equipment', equipment>, VersionBound<'0.15.0'> {
export interface equipment extends ObjectTypeDefinition<'equipment', equipment>, VersionBound<$ExpectedClientVersion> {
osdkMetadata: typeof $osdkMetadata;
links: {};
primaryKeyApiName: 'equipmentId';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { OntologyMetadata as OM } from '@osdk/api';

export const expectedClientVersion = '0.15.0';
export type $ExpectedClientVersion = '0.15.0';
export const $osdkMetadata = { extraUserAgent: 'typescript-sdk/dev osdk-cli/dev' };

export interface OntologyMetadata extends OM<'0.15.0'> {
expectsClientVersion: '0.15.0';
}
export interface OntologyMetadata extends OM<$ExpectedClientVersion> {}

export const OntologyMetadata: OntologyMetadata = {
expectsClientVersion: '0.15.0',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { ObjectTypeDefinition, PropertyDef, VersionBound } from '@osdk/api';
import type { $ExpectedClientVersion } from '../../OntologyMetadata';
import { $osdkMetadata } from '../../OntologyMetadata';

export interface Todo extends ObjectTypeDefinition<'Todo', Todo>, VersionBound<'0.15.0'> {
export interface Todo extends ObjectTypeDefinition<'Todo', Todo>, VersionBound<$ExpectedClientVersion> {
osdkMetadata: typeof $osdkMetadata;
description: 'Its a todo item.';
links: {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function __UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(

function getV2Types() {
return `
export interface ${objectDefIdentifier} extends InterfaceDefinition<"${interfaceDef.apiName}", ${interfaceDef.apiName}>, VersionBound<"${process.env.PACKAGE_CLIENT_VERSION}"> {
export interface ${objectDefIdentifier} extends InterfaceDefinition<"${interfaceDef.apiName}", ${interfaceDef.apiName}>, VersionBound<$ExpectedClientVersion> {
osdkMetadata: typeof $osdkMetadata;
${
stringify(definition, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function wireObjectTypeV2ToSdkObjectConst(

function getV2Types() {
return `
export interface ${objectDefIdentifier} extends ObjectTypeDefinition<"${object.objectType.apiName}", ${object.objectType.apiName}>, VersionBound<"${process.env.PACKAGE_CLIENT_VERSION}"> {
export interface ${objectDefIdentifier} extends ObjectTypeDefinition<"${object.objectType.apiName}", ${object.objectType.apiName}>, VersionBound<$ExpectedClientVersion> {
osdkMetadata: typeof $osdkMetadata;
${
stringify(definition, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ export async function generateClientSdkVersionTwoPointZero(
await formatTs(`
import type { ObjectTypeDefinition, VersionBound, ObjectTypeLinkDefinition, PropertyDef } from "@osdk/api";
import { Osdk } from "@osdk/client";
import { $osdkMetadata} from "../../OntologyMetadata${importExt}";
import { $osdkMetadata } from "../../OntologyMetadata${importExt}";
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
${wireObjectTypeV2ToSdkObjectConst(obj, importExt, true)}
`),
Expand Down Expand Up @@ -191,7 +192,8 @@ async function generateOntologyInterfaces(
await formatTs(`
import type { InterfaceDefinition, PropertyDef, VersionBound } from "@osdk/api";
import { $osdkMetadata} from "../../OntologyMetadata${importExt}";
import { $osdkMetadata, $expectedClientVersion } from "../../OntologyMetadata${importExt}";
import type { $ExpectedClientVersion } from "../../OntologyMetadata${importExt}";
${__UNSTABLE_wireInterfaceTypeV2ToSdkObjectConst(obj, true)}
`),
Expand Down
6 changes: 2 additions & 4 deletions packages/generator/src/v2.0/generateMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ export async function generateOntologyMetadataFile(
`
import { OntologyMetadata as OM } from "@osdk/api";
export const expectedClientVersion = "${process.env.PACKAGE_CLIENT_VERSION}";
export type $ExpectedClientVersion = "${ExpectedOsdkVersion}";
export const $osdkMetadata = { extraUserAgent: "${userAgent}" };
export interface OntologyMetadata extends OM<"${ExpectedOsdkVersion}"> {
expectsClientVersion: "${ExpectedOsdkVersion}",
};
export interface OntologyMetadata extends OM<$ExpectedClientVersion> {};
export const OntologyMetadata: OntologyMetadata = {
expectsClientVersion: "${ExpectedOsdkVersion}",
Expand Down

0 comments on commit f7287ae

Please sign in to comment.