diff --git a/packages/api-sdk/src/resources/version/diagram.ts b/packages/api-sdk/src/resources/version/diagram.ts new file mode 100644 index 000000000..652e58b19 --- /dev/null +++ b/packages/api-sdk/src/resources/version/diagram.ts @@ -0,0 +1,25 @@ +import Fetch from '@api-sdk/fetch'; +import { BaseModels } from '@voiceflow/base-types'; + +import CrudNestedResource from '../crudNested'; + +const ENDPOINT = 'diagrams'; + +export type ModelKey = 'diagramID'; + +class DiagramResource extends CrudNestedResource { + constructor(fetch: Fetch, { parentEndpoint }: { parentEndpoint: string }) { + super({ + fetch, + clazz: DiagramResource, + endpoint: ENDPOINT, + clazzOptions: { parentEndpoint }, + }); + } + + public async get(versionID: string, diagramID: string): Promise { + return this._getByID(versionID, diagramID); + } +} + +export default DiagramResource; diff --git a/packages/api-sdk/src/resources/version/index.ts b/packages/api-sdk/src/resources/version/index.ts index bea897236..e38905e72 100644 --- a/packages/api-sdk/src/resources/version/index.ts +++ b/packages/api-sdk/src/resources/version/index.ts @@ -5,7 +5,10 @@ import { AnyRecord } from '@voiceflow/common'; import { Fields } from '../base'; import CrudResource from '../crud'; import CanvasTemplate from './canvasTemplate'; +import Diagram from './diagram'; import Domain from './domain'; +import Program from './program'; +import PrototypeProgram from './prototypeProgram'; export const ENDPOINT = 'versions'; @@ -16,6 +19,12 @@ class VersionResource extends CrudResource>>(id: string, fields: Fields): Promise; diff --git a/packages/api-sdk/src/resources/version/program.ts b/packages/api-sdk/src/resources/version/program.ts new file mode 100644 index 000000000..a810e3e46 --- /dev/null +++ b/packages/api-sdk/src/resources/version/program.ts @@ -0,0 +1,25 @@ +import Fetch from '@api-sdk/fetch'; +import { BaseModels } from '@voiceflow/base-types'; + +import CrudNestedResource from '../crudNested'; + +const ENDPOINT = 'programs'; + +export type ModelKey = 'diagramID'; + +class ProgramResource extends CrudNestedResource { + constructor(fetch: Fetch, { parentEndpoint }: { parentEndpoint: string }) { + super({ + fetch, + clazz: ProgramResource, + endpoint: ENDPOINT, + clazzOptions: { parentEndpoint }, + }); + } + + public async get(versionID: string, diagramID: string): Promise { + return this._getByID(versionID, diagramID); + } +} + +export default ProgramResource; diff --git a/packages/api-sdk/src/resources/version/prototypeProgram.ts b/packages/api-sdk/src/resources/version/prototypeProgram.ts new file mode 100644 index 000000000..65d45eba7 --- /dev/null +++ b/packages/api-sdk/src/resources/version/prototypeProgram.ts @@ -0,0 +1,25 @@ +import Fetch from '@api-sdk/fetch'; +import { BaseModels } from '@voiceflow/base-types'; + +import CrudNestedResource from '../crudNested'; + +const ENDPOINT = 'prototype-programs'; + +export type ModelKey = 'diagramID'; + +class PrototypeProgramResource extends CrudNestedResource { + constructor(fetch: Fetch, { parentEndpoint }: { parentEndpoint: string }) { + super({ + fetch, + clazz: PrototypeProgramResource, + endpoint: ENDPOINT, + clazzOptions: { parentEndpoint }, + }); + } + + public async get(versionID: string, diagramID: string): Promise { + return this._getByID(versionID, diagramID); + } +} + +export default PrototypeProgramResource; diff --git a/packages/base-types/src/models/version/prototype.ts b/packages/base-types/src/models/version/prototype.ts index bcc730131..747d9363f 100644 --- a/packages/base-types/src/models/version/prototype.ts +++ b/packages/base-types/src/models/version/prototype.ts @@ -4,7 +4,7 @@ import { BaseCommand, Intent, PrototypeModel, Slot } from '../base'; export interface PrototypeStackFrame { nodeID?: Nullable; - programID: string; + diagramID: string; storage?: AnyRecord; commands?: Command[]; diff --git a/packages/base-types/src/runtimeLogs/utils/types.ts b/packages/base-types/src/runtimeLogs/utils/types.ts index 3379624cd..3cd77576d 100644 --- a/packages/base-types/src/runtimeLogs/utils/types.ts +++ b/packages/base-types/src/runtimeLogs/utils/types.ts @@ -11,7 +11,7 @@ export interface PathReference { /** A reference to a flow (frame) on the canvas. */ export interface FlowReference { name: string | null; - programID: string; + diagramID: string; } /** A common interface for representing a before & after change of a value. */