1- import type { QuerySchemasResponse , Session } from "@ftrack/api" ;
1+ import type { QuerySchemasResponse } from "@ftrack/api" ;
22import * as fs from "fs" ;
33import * as path from "path" ;
44import {
55 type CustomAttributeConfiguration ,
66 emitCustomAttributes ,
7- } from "./emitCustomAttributes.js" ;
8- import { emitSchemaInterface } from "./emitSchema.js" ;
9- import { TypeScriptEmitter } from "./typescriptEmitter.js" ;
10- import { isSchemaTypedContext } from "./utils.js" ;
7+ } from "./emitCustomAttributes.ts" ;
8+ import { emitSchemaInterface } from "./emitSchema.ts" ;
9+ import { TypeScriptEmitter } from "./typescriptEmitter.ts" ;
10+ import { isSchemaTypedContext } from "./utils.ts" ;
11+ import { session , type Schema } from "./session.ts" ;
1112
1213const legacySchemas = [ "Conversation" , "Message" , "Participant" ] ;
1314export async function emitToFile (
14- session : Session ,
1515 outputPath = "__generated__" ,
1616 outputFilename = "schema.ts" ,
1717) {
1818 // Get the schemas from the server and sort by id in alphabetical order
19- const schemas = await getSchemas ( session ) ;
20- const customAttributes = await getCustomAttributes ( session ) ;
21- const types = await getTypes ( session ) ;
22- const objectTypes = await getObjectTypes ( session ) ;
23- const projectSchemas = await getProjectSchemas ( session ) ;
24- const statuses = await getStatuses ( session ) ;
25- const priorities = await getPriorities ( session ) ;
19+ const schemas = await getSchemas ( ) ;
20+ const customAttributes = await getCustomAttributes ( ) ;
21+ const types = await getTypes ( ) ;
22+ const objectTypes = await getObjectTypes ( ) ;
23+ const projectSchemas = await getProjectSchemas ( ) ;
24+ const statuses = await getStatuses ( ) ;
25+ const priorities = await getPriorities ( ) ;
2626
2727 const { prettifiedContent, errors } = await emitToString (
2828 session . serverVersion ,
@@ -109,7 +109,7 @@ export type Status = {
109109export async function emitToString (
110110 serverVersion : string | undefined ,
111111 serverUrl : string | undefined ,
112- schemas : QuerySchemasResponse ,
112+ schemas : QuerySchemasResponse < Schema > ,
113113 customAttributes : CustomAttributeConfiguration [ ] ,
114114 types : Type [ ] ,
115115 objectTypes : ObjectType [ ] ,
@@ -275,15 +275,15 @@ export async function emitToString(
275275 } ;
276276}
277277
278- async function getCustomAttributes ( session : Session ) {
279- const customAttributes = await session . query < CustomAttributeConfiguration > (
278+ async function getCustomAttributes ( ) {
279+ const customAttributes = await session . query < " CustomAttributeConfiguration" > (
280280 "select default, label, key, project_id, entity_type, is_hierarchical, object_type.name, type.name from CustomAttributeConfiguration order by sort" ,
281281 ) ;
282282 return customAttributes . data ;
283283}
284284
285- async function getSchemas ( session : Session ) {
286- const schemas = await session . call < QuerySchemasResponse > ( [
285+ async function getSchemas ( ) {
286+ const schemas = await session . call < QuerySchemasResponse < Schema > > ( [
287287 {
288288 action : "query_schemas" ,
289289 } ,
@@ -292,44 +292,44 @@ async function getSchemas(session: Session) {
292292 return schemas [ 0 ] ;
293293}
294294
295- async function getTypes ( session : Session ) {
296- const types = await session . query < Type > (
295+ async function getTypes ( ) {
296+ const types = await session . query < " Type" > (
297297 "select is_billable, name, task_type_schemas from Type order by sort" ,
298298 ) ;
299299 return types . data ;
300300}
301301
302- async function getPriorities ( session : Session ) {
303- const priorities = await session . query < Priority > (
302+ async function getPriorities ( ) {
303+ const priorities = await session . query < " Priority" > (
304304 "select id, color, name, sort, value from Priority order by sort" ,
305305 ) ;
306306 return priorities . data ;
307307}
308308
309- async function getStatuses ( session : Session ) {
310- const priorities = await session . query < Status > (
309+ async function getStatuses ( ) {
310+ const priorities = await session . query < " Status" > (
311311 "select id, color, is_active, name, sort, state from Status order by sort" ,
312312 ) ;
313313 return priorities . data ;
314314}
315315
316- async function getObjectTypes ( session : Session ) {
317- const objectTypes = await session . query < ObjectType > (
316+ async function getObjectTypes ( ) {
317+ const objectTypes = await session . query < " ObjectType" > (
318318 "select id, is_leaf, is_prioritizable, is_schedulable, is_statusable, is_taskable, is_time_reportable, is_typeable, name, project_schemas from ObjectType order by sort" ,
319319 ) ;
320320 return objectTypes . data ;
321321}
322322
323- async function getProjectSchemas ( session : Session ) {
324- const projectSchemas = await session . query < ProjectSchema > (
323+ async function getProjectSchemas ( ) {
324+ const projectSchemas = await session . query < " ProjectSchema" > (
325325 "select name, asset_version_workflow_schema, name, object_type_schemas, object_types, task_templates, task_type_schema, task_workflow_schema, task_workflow_schema_overrides from ProjectSchema" ,
326326 ) ;
327327 return projectSchemas . data ;
328328}
329329
330330function emitTypedContextTypes (
331331 builder : TypeScriptEmitter ,
332- schemas : QuerySchemasResponse ,
332+ schemas : QuerySchemasResponse < Schema > ,
333333) {
334334 builder . appendCode ( `
335335 export interface TypedContextSubtypeMap {
0 commit comments