diff --git a/package.json b/package.json index 2685653..5ca3ea7 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "scripts": { "generate": "node dist/ftrack-ts-schema-generator.js", "build": "esbuild source/index.ts --target=esnext --outfile=dist/ftrack-ts-schema-generator.js --platform=node --format=esm --bundle --packages=external", + "watch": "esbuild source/index.ts --target=esnext --outfile=dist/ftrack-ts-schema-generator.js --platform=node --format=esm --bundle --packages=external --watch", "prepack": "yarn build", "test": "tsc && eslint --cache --fix --max-warnings=0 ./source && prettier -c ./source", "prepublish": "yarn test" diff --git a/source/index.ts b/source/index.ts index 04b4e0f..80c36f5 100644 --- a/source/index.ts +++ b/source/index.ts @@ -20,7 +20,7 @@ const session = new Session( ); const legacySchemas = ["Conversation", "Message", "Participant"]; -export async function generate( +async function generate( outputPath = "__generated__", outputFilename = "schema.ts" ) { @@ -35,7 +35,7 @@ export async function generate( schema, schemas ); - errors.push(conversionErrors); + errors.push(...conversionErrors); interfaces += TSInterface; } @@ -78,6 +78,8 @@ export async function generate( }); fs.mkdirSync(path.resolve(outputPath), { recursive: true }); fs.writeFileSync(path.join(outputPath, outputFilename), prettifiedContent); + + return { errors, schemas }; } async function getSchemas() { @@ -123,9 +125,16 @@ function getTypedContextTypes(schemas: QuerySchemasResponse[]) { const TypedContextSubtype = `export type TypedContextSubtype = keyof TypedContextSubtypeMap;`; return { TypedContextSubtypeMap, TypedContextSubtype }; } -// Call the generate function with command line arguments if this module is being run directly -if (import.meta.url === `file://${process.argv[1]}`) { - const outputPath = process.argv[2] || "__generated__"; - const outputFilename = process.argv[3] || "schema.ts"; - generate(outputPath, outputFilename); + +const outputPath = process.argv[2] || "__generated__"; +const outputFilename = process.argv[3] || "schema.ts"; +const { errors, schemas } = await generate(outputPath, outputFilename); + +console.info(`${schemas.length} schema(s) found`); + +if (errors.length > 0) { + console.warn("One or more errors occured:"); + for (const error of errors) { + console.warn(error); + } } diff --git a/yarn.lock b/yarn.lock index 67d96d1..d646b5d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -23,156 +23,156 @@ __metadata: languageName: node linkType: hard -"@esbuild/android-arm64@npm:0.17.14": - version: 0.17.14 - resolution: "@esbuild/android-arm64@npm:0.17.14" +"@esbuild/android-arm64@npm:0.17.15": + version: 0.17.15 + resolution: "@esbuild/android-arm64@npm:0.17.15" conditions: os=android & cpu=arm64 languageName: node linkType: hard -"@esbuild/android-arm@npm:0.17.14": - version: 0.17.14 - resolution: "@esbuild/android-arm@npm:0.17.14" +"@esbuild/android-arm@npm:0.17.15": + version: 0.17.15 + resolution: "@esbuild/android-arm@npm:0.17.15" conditions: os=android & cpu=arm languageName: node linkType: hard -"@esbuild/android-x64@npm:0.17.14": - version: 0.17.14 - resolution: "@esbuild/android-x64@npm:0.17.14" +"@esbuild/android-x64@npm:0.17.15": + version: 0.17.15 + resolution: "@esbuild/android-x64@npm:0.17.15" conditions: os=android & cpu=x64 languageName: node linkType: hard -"@esbuild/darwin-arm64@npm:0.17.14": - version: 0.17.14 - resolution: "@esbuild/darwin-arm64@npm:0.17.14" +"@esbuild/darwin-arm64@npm:0.17.15": + version: 0.17.15 + resolution: "@esbuild/darwin-arm64@npm:0.17.15" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@esbuild/darwin-x64@npm:0.17.14": - version: 0.17.14 - resolution: "@esbuild/darwin-x64@npm:0.17.14" +"@esbuild/darwin-x64@npm:0.17.15": + version: 0.17.15 + resolution: "@esbuild/darwin-x64@npm:0.17.15" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@esbuild/freebsd-arm64@npm:0.17.14": - version: 0.17.14 - resolution: "@esbuild/freebsd-arm64@npm:0.17.14" +"@esbuild/freebsd-arm64@npm:0.17.15": + version: 0.17.15 + resolution: "@esbuild/freebsd-arm64@npm:0.17.15" conditions: os=freebsd & cpu=arm64 languageName: node linkType: hard -"@esbuild/freebsd-x64@npm:0.17.14": - version: 0.17.14 - resolution: "@esbuild/freebsd-x64@npm:0.17.14" +"@esbuild/freebsd-x64@npm:0.17.15": + version: 0.17.15 + resolution: "@esbuild/freebsd-x64@npm:0.17.15" conditions: os=freebsd & cpu=x64 languageName: node linkType: hard -"@esbuild/linux-arm64@npm:0.17.14": - version: 0.17.14 - resolution: "@esbuild/linux-arm64@npm:0.17.14" +"@esbuild/linux-arm64@npm:0.17.15": + version: 0.17.15 + resolution: "@esbuild/linux-arm64@npm:0.17.15" conditions: os=linux & cpu=arm64 languageName: node linkType: hard -"@esbuild/linux-arm@npm:0.17.14": - version: 0.17.14 - resolution: "@esbuild/linux-arm@npm:0.17.14" +"@esbuild/linux-arm@npm:0.17.15": + version: 0.17.15 + resolution: "@esbuild/linux-arm@npm:0.17.15" conditions: os=linux & cpu=arm languageName: node linkType: hard -"@esbuild/linux-ia32@npm:0.17.14": - version: 0.17.14 - resolution: "@esbuild/linux-ia32@npm:0.17.14" +"@esbuild/linux-ia32@npm:0.17.15": + version: 0.17.15 + resolution: "@esbuild/linux-ia32@npm:0.17.15" conditions: os=linux & cpu=ia32 languageName: node linkType: hard -"@esbuild/linux-loong64@npm:0.17.14": - version: 0.17.14 - resolution: "@esbuild/linux-loong64@npm:0.17.14" +"@esbuild/linux-loong64@npm:0.17.15": + version: 0.17.15 + resolution: "@esbuild/linux-loong64@npm:0.17.15" conditions: os=linux & cpu=loong64 languageName: node linkType: hard -"@esbuild/linux-mips64el@npm:0.17.14": - version: 0.17.14 - resolution: "@esbuild/linux-mips64el@npm:0.17.14" +"@esbuild/linux-mips64el@npm:0.17.15": + version: 0.17.15 + resolution: "@esbuild/linux-mips64el@npm:0.17.15" conditions: os=linux & cpu=mips64el languageName: node linkType: hard -"@esbuild/linux-ppc64@npm:0.17.14": - version: 0.17.14 - resolution: "@esbuild/linux-ppc64@npm:0.17.14" +"@esbuild/linux-ppc64@npm:0.17.15": + version: 0.17.15 + resolution: "@esbuild/linux-ppc64@npm:0.17.15" conditions: os=linux & cpu=ppc64 languageName: node linkType: hard -"@esbuild/linux-riscv64@npm:0.17.14": - version: 0.17.14 - resolution: "@esbuild/linux-riscv64@npm:0.17.14" +"@esbuild/linux-riscv64@npm:0.17.15": + version: 0.17.15 + resolution: "@esbuild/linux-riscv64@npm:0.17.15" conditions: os=linux & cpu=riscv64 languageName: node linkType: hard -"@esbuild/linux-s390x@npm:0.17.14": - version: 0.17.14 - resolution: "@esbuild/linux-s390x@npm:0.17.14" +"@esbuild/linux-s390x@npm:0.17.15": + version: 0.17.15 + resolution: "@esbuild/linux-s390x@npm:0.17.15" conditions: os=linux & cpu=s390x languageName: node linkType: hard -"@esbuild/linux-x64@npm:0.17.14": - version: 0.17.14 - resolution: "@esbuild/linux-x64@npm:0.17.14" +"@esbuild/linux-x64@npm:0.17.15": + version: 0.17.15 + resolution: "@esbuild/linux-x64@npm:0.17.15" conditions: os=linux & cpu=x64 languageName: node linkType: hard -"@esbuild/netbsd-x64@npm:0.17.14": - version: 0.17.14 - resolution: "@esbuild/netbsd-x64@npm:0.17.14" +"@esbuild/netbsd-x64@npm:0.17.15": + version: 0.17.15 + resolution: "@esbuild/netbsd-x64@npm:0.17.15" conditions: os=netbsd & cpu=x64 languageName: node linkType: hard -"@esbuild/openbsd-x64@npm:0.17.14": - version: 0.17.14 - resolution: "@esbuild/openbsd-x64@npm:0.17.14" +"@esbuild/openbsd-x64@npm:0.17.15": + version: 0.17.15 + resolution: "@esbuild/openbsd-x64@npm:0.17.15" conditions: os=openbsd & cpu=x64 languageName: node linkType: hard -"@esbuild/sunos-x64@npm:0.17.14": - version: 0.17.14 - resolution: "@esbuild/sunos-x64@npm:0.17.14" +"@esbuild/sunos-x64@npm:0.17.15": + version: 0.17.15 + resolution: "@esbuild/sunos-x64@npm:0.17.15" conditions: os=sunos & cpu=x64 languageName: node linkType: hard -"@esbuild/win32-arm64@npm:0.17.14": - version: 0.17.14 - resolution: "@esbuild/win32-arm64@npm:0.17.14" +"@esbuild/win32-arm64@npm:0.17.15": + version: 0.17.15 + resolution: "@esbuild/win32-arm64@npm:0.17.15" conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"@esbuild/win32-ia32@npm:0.17.14": - version: 0.17.14 - resolution: "@esbuild/win32-ia32@npm:0.17.14" +"@esbuild/win32-ia32@npm:0.17.15": + version: 0.17.15 + resolution: "@esbuild/win32-ia32@npm:0.17.15" conditions: os=win32 & cpu=ia32 languageName: node linkType: hard -"@esbuild/win32-x64@npm:0.17.14": - version: 0.17.14 - resolution: "@esbuild/win32-x64@npm:0.17.14" +"@esbuild/win32-x64@npm:0.17.15": + version: 0.17.15 + resolution: "@esbuild/win32-x64@npm:0.17.15" conditions: os=win32 & cpu=x64 languageName: node linkType: hard @@ -220,13 +220,13 @@ __metadata: linkType: hard "@ftrack/api@npm:^1.4.5": - version: 1.4.5 - resolution: "@ftrack/api@npm:1.4.5" + version: 1.4.6 + resolution: "@ftrack/api@npm:1.4.6" dependencies: loglevel: ^1.8.1 moment: ^2.29.4 uuid: ^9.0.0 - checksum: 494f0ef0768a3299537a8d0411d0a0e9f63de4f6f720cc8bab0fb1d61afb9827387ae7d3eaa3f781bd1fa69a1a0c74e6dc45de4e70e502c0dbd3a009d5816bd3 + checksum: 3bb226a9f2123693ce22c4a5be44478bba19c3d987001c7cd584c50936c01bf9ea14a55852e2f9b6d186ddf6d740f1d290cc43a480386933a55744c5b9c02517 languageName: node linkType: hard @@ -452,13 +452,13 @@ __metadata: linkType: hard "@typescript-eslint/eslint-plugin@npm:^5.57.0": - version: 5.57.0 - resolution: "@typescript-eslint/eslint-plugin@npm:5.57.0" + version: 5.57.1 + resolution: "@typescript-eslint/eslint-plugin@npm:5.57.1" dependencies: "@eslint-community/regexpp": ^4.4.0 - "@typescript-eslint/scope-manager": 5.57.0 - "@typescript-eslint/type-utils": 5.57.0 - "@typescript-eslint/utils": 5.57.0 + "@typescript-eslint/scope-manager": 5.57.1 + "@typescript-eslint/type-utils": 5.57.1 + "@typescript-eslint/utils": 5.57.1 debug: ^4.3.4 grapheme-splitter: ^1.0.4 ignore: ^5.2.0 @@ -471,43 +471,43 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: be13aa74ee6f15f0ae67781c625d9dcf3ce8a3feca2b125eef0cfee850b7f9f0cec23fc56a729ef25926298fe3ea51603ebeee2b93fc9b73fce1410638707177 + checksum: 3ea842ef9615e298e28c6687c4dc285577ea0995944410553b3ca514ce9d437534b6e89114e9398c1a370324afe7a4a251c8c49540bb3bf13dcadde9ada3ecc2 languageName: node linkType: hard "@typescript-eslint/parser@npm:^5.57.0": - version: 5.57.0 - resolution: "@typescript-eslint/parser@npm:5.57.0" + version: 5.57.1 + resolution: "@typescript-eslint/parser@npm:5.57.1" dependencies: - "@typescript-eslint/scope-manager": 5.57.0 - "@typescript-eslint/types": 5.57.0 - "@typescript-eslint/typescript-estree": 5.57.0 + "@typescript-eslint/scope-manager": 5.57.1 + "@typescript-eslint/types": 5.57.1 + "@typescript-eslint/typescript-estree": 5.57.1 debug: ^4.3.4 peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 peerDependenciesMeta: typescript: optional: true - checksum: b7e8345631911f721591ba970fea5c888f0f3bf2e2ea2dbc3e5b0dc345c0776b62b92c534edfde1379b4b182958a421f35ac26d84705fe6ae7dd37aa675d9493 + checksum: db61a12a67bc45d814297e7f089768c0849f18162b330279aa15121223ec3b18d80df4c327f4ca0a40a7bddb9150ba1a9379fce00bc0e4a10cc189d04e36f0e3 languageName: node linkType: hard -"@typescript-eslint/scope-manager@npm:5.57.0": - version: 5.57.0 - resolution: "@typescript-eslint/scope-manager@npm:5.57.0" +"@typescript-eslint/scope-manager@npm:5.57.1": + version: 5.57.1 + resolution: "@typescript-eslint/scope-manager@npm:5.57.1" dependencies: - "@typescript-eslint/types": 5.57.0 - "@typescript-eslint/visitor-keys": 5.57.0 - checksum: 4a851f23da2adbf6341b04c1e3f19fcb66415683f26805d3123725d18845bd4a150bd182de0a91279d5682f2568bb5dd831d4ad0bdb70f49d9ca7381cec4dd17 + "@typescript-eslint/types": 5.57.1 + "@typescript-eslint/visitor-keys": 5.57.1 + checksum: 4f03d54372f0591fbc5f6e0267a6f1b73e3012e8a319c1893829e0b8e71f882e17a696995dc8b11e700162daf74444fd2d8f55dba314e1a95221a9d3eabcfb2b languageName: node linkType: hard -"@typescript-eslint/type-utils@npm:5.57.0": - version: 5.57.0 - resolution: "@typescript-eslint/type-utils@npm:5.57.0" +"@typescript-eslint/type-utils@npm:5.57.1": + version: 5.57.1 + resolution: "@typescript-eslint/type-utils@npm:5.57.1" dependencies: - "@typescript-eslint/typescript-estree": 5.57.0 - "@typescript-eslint/utils": 5.57.0 + "@typescript-eslint/typescript-estree": 5.57.1 + "@typescript-eslint/utils": 5.57.1 debug: ^4.3.4 tsutils: ^3.21.0 peerDependencies: @@ -515,23 +515,23 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: 649d000edabfe4e567b8a384d0012c56396e40ce2123a78857d4b8da6bf2288627dc355745bd7d4a2877d4cc8a26e1d1dbfc422e6382ac3d3ab431b92eb5b852 + checksum: 06fab95315fc1ffdaaa011e6ec1ae538826ef3d9b422e2c926dbe9b83e55d9e8bdaa07c43317a4c0a59b40a24c5c48a7c8284e6a18780475a65894b1b949fc23 languageName: node linkType: hard -"@typescript-eslint/types@npm:5.57.0": - version: 5.57.0 - resolution: "@typescript-eslint/types@npm:5.57.0" - checksum: 79a100fb650965f63c01c20e6abd79ca0d2043c3a329b9fef89917d6b9ba3c0f946dca3f14f2975ee6349daadd6ce0e98fde3aafe4b710e5a27abe1adc590c85 +"@typescript-eslint/types@npm:5.57.1": + version: 5.57.1 + resolution: "@typescript-eslint/types@npm:5.57.1" + checksum: 21789eb697904bbb44a18df961d5918e7c5bd90c79df3a8b8b835da81d0c0f42c7eeb2d05f77cafe49a7367ae7f549a0c8281656ea44b6dc56ae1bf19a3a1eae languageName: node linkType: hard -"@typescript-eslint/typescript-estree@npm:5.57.0": - version: 5.57.0 - resolution: "@typescript-eslint/typescript-estree@npm:5.57.0" +"@typescript-eslint/typescript-estree@npm:5.57.1": + version: 5.57.1 + resolution: "@typescript-eslint/typescript-estree@npm:5.57.1" dependencies: - "@typescript-eslint/types": 5.57.0 - "@typescript-eslint/visitor-keys": 5.57.0 + "@typescript-eslint/types": 5.57.1 + "@typescript-eslint/visitor-keys": 5.57.1 debug: ^4.3.4 globby: ^11.1.0 is-glob: ^4.0.3 @@ -540,35 +540,35 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: 648b88f88ea6cc293ec67b4c0f4f3c2bf733be7e0f2eee08aadbaec6939fd724a6c287decc336abbf67b9e366cc2c48f2e0e48d8302b533e783f798332a06e83 + checksum: bf96520f6de562838a40c3f009fc61fbee5369621071cd0d1dba4470b2b2f746cf79afe4ffa3fbccb8913295a2fbb3d89681d5178529e8da4987c46ed4e5cbed languageName: node linkType: hard -"@typescript-eslint/utils@npm:5.57.0": - version: 5.57.0 - resolution: "@typescript-eslint/utils@npm:5.57.0" +"@typescript-eslint/utils@npm:5.57.1": + version: 5.57.1 + resolution: "@typescript-eslint/utils@npm:5.57.1" dependencies: "@eslint-community/eslint-utils": ^4.2.0 "@types/json-schema": ^7.0.9 "@types/semver": ^7.3.12 - "@typescript-eslint/scope-manager": 5.57.0 - "@typescript-eslint/types": 5.57.0 - "@typescript-eslint/typescript-estree": 5.57.0 + "@typescript-eslint/scope-manager": 5.57.1 + "@typescript-eslint/types": 5.57.1 + "@typescript-eslint/typescript-estree": 5.57.1 eslint-scope: ^5.1.1 semver: ^7.3.7 peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 - checksum: 461258e1194d24c5e642c65ba1afd612712fa8e617ac85cfbbe3dde2557fe4abadedbce19a6954ae0cccbfb92b8a09f38d65a3eedca0394861a5d1c4c893c5ed + checksum: 12e55144c8087f4e8f0f22e5693f3901b81bb7899dec42c7bfe540ac672a802028b688884bb43bd67bcf3cd3546a7205d207afcd948c731c19f551ea61267205 languageName: node linkType: hard -"@typescript-eslint/visitor-keys@npm:5.57.0": - version: 5.57.0 - resolution: "@typescript-eslint/visitor-keys@npm:5.57.0" +"@typescript-eslint/visitor-keys@npm:5.57.1": + version: 5.57.1 + resolution: "@typescript-eslint/visitor-keys@npm:5.57.1" dependencies: - "@typescript-eslint/types": 5.57.0 + "@typescript-eslint/types": 5.57.1 eslint-visitor-keys: ^3.3.0 - checksum: 77d53f74648e48bf1c6313cd60568c2b1539157ac13945f26204a54beb156666c24f3d033dd0db8ed5d1d4595ee63c072732b17132e4488b46763bf8fdcefa49 + checksum: d187dfac044b7c0f24264a9ba5eebcf6651412d840b4aaba8eacabff7e771babcd67c738525b1f7c9eb8c94b7edfe7658f6de99f5fdc9745e409c538c1374674 languageName: node linkType: hard @@ -1127,31 +1127,31 @@ __metadata: linkType: hard "esbuild@npm:^0.17.14": - version: 0.17.14 - resolution: "esbuild@npm:0.17.14" - dependencies: - "@esbuild/android-arm": 0.17.14 - "@esbuild/android-arm64": 0.17.14 - "@esbuild/android-x64": 0.17.14 - "@esbuild/darwin-arm64": 0.17.14 - "@esbuild/darwin-x64": 0.17.14 - "@esbuild/freebsd-arm64": 0.17.14 - "@esbuild/freebsd-x64": 0.17.14 - "@esbuild/linux-arm": 0.17.14 - "@esbuild/linux-arm64": 0.17.14 - "@esbuild/linux-ia32": 0.17.14 - "@esbuild/linux-loong64": 0.17.14 - "@esbuild/linux-mips64el": 0.17.14 - "@esbuild/linux-ppc64": 0.17.14 - "@esbuild/linux-riscv64": 0.17.14 - "@esbuild/linux-s390x": 0.17.14 - "@esbuild/linux-x64": 0.17.14 - "@esbuild/netbsd-x64": 0.17.14 - "@esbuild/openbsd-x64": 0.17.14 - "@esbuild/sunos-x64": 0.17.14 - "@esbuild/win32-arm64": 0.17.14 - "@esbuild/win32-ia32": 0.17.14 - "@esbuild/win32-x64": 0.17.14 + version: 0.17.15 + resolution: "esbuild@npm:0.17.15" + dependencies: + "@esbuild/android-arm": 0.17.15 + "@esbuild/android-arm64": 0.17.15 + "@esbuild/android-x64": 0.17.15 + "@esbuild/darwin-arm64": 0.17.15 + "@esbuild/darwin-x64": 0.17.15 + "@esbuild/freebsd-arm64": 0.17.15 + "@esbuild/freebsd-x64": 0.17.15 + "@esbuild/linux-arm": 0.17.15 + "@esbuild/linux-arm64": 0.17.15 + "@esbuild/linux-ia32": 0.17.15 + "@esbuild/linux-loong64": 0.17.15 + "@esbuild/linux-mips64el": 0.17.15 + "@esbuild/linux-ppc64": 0.17.15 + "@esbuild/linux-riscv64": 0.17.15 + "@esbuild/linux-s390x": 0.17.15 + "@esbuild/linux-x64": 0.17.15 + "@esbuild/netbsd-x64": 0.17.15 + "@esbuild/openbsd-x64": 0.17.15 + "@esbuild/sunos-x64": 0.17.15 + "@esbuild/win32-arm64": 0.17.15 + "@esbuild/win32-ia32": 0.17.15 + "@esbuild/win32-x64": 0.17.15 dependenciesMeta: "@esbuild/android-arm": optional: true @@ -1199,7 +1199,7 @@ __metadata: optional: true bin: esbuild: bin/esbuild - checksum: 8f4c05f5d3da04f05c48d65f60f3c6422253f406cd56a7ab7a898f0971b0366c454635a6340172874950771dc005a9928dd999b732a6d4caa504b537bfcbf2ff + checksum: 4e3640d7bc8f6edb3465c076eb519ccb7684382714a1b883e000a7a592f8e285501ec7e82cb68441dfec8f7be7f70f40b00129ceb05057f6fa87f95d2187370a languageName: node linkType: hard