Thank you for the example. I’m really glad y’all are starting (at least in this example) migrate over to typescript, and more importantly, i really appreciate that your example has tests unlike the current documentation or template projects. That said, i do have a question about your example. You configure typescript for ES2023:
"lib": ["ES2023"]
but when i try that on my project i get:
$ forge deploy
Deploying your app to the development environment.
Press Ctrl+C to cancel.
Running forge lint...
Error: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'esnext.array', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref'.
Is there some secret setting to allow ES2023 with forge? If i switch to ES2022, it does seem to deploy fine…
Also, i noticed that the swagger.v3 json doc for Assets (downloaded from the Assets API page) has bugs. Specifically, i am attempting to use the /objectschema/{id}/objecttypes endpoint and it says the 200 response for application/json type is:
"schema": {
"type": "object",
"properties": {
"entries": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ObjectType"
}
}
}
}
But the response i get back (and the example) is just an array, not an object with an entries property that is an array. This causes the code generation to be incompatible with the response. Is there a standard way to report bugs like this? is there a fair chance they get resolved or should i use a hand modified version of that json to generate that client:
#!/bin/bash
### Generates assets-api.d.ts from the official json schema.
###
### Usage:
### src/lib/gen_assets_api.sh
###
### Remarks:
### Assumes openapi-typescript is previously installed:
### npm install openapi-typescript --global
set -e
# if you navigate to the API documentation page:
# https://developer.atlassian.com/cloud/assets/rest/api-group-importsource
# this is the download link for OpenAPI
readonly API_VERSION=v3
readonly VERSION=1.135.74
readonly JSON_SCHEMA="https://dac-static.atlassian.com/cloud/assets/swagger.${API_VERSION}.json?_v=${VERSION}"
readonly ROOT_DIR="$(dirname "$(readlink --canonicalize-existing "$0")")"
readonly file="${ROOT_DIR}/assets-api.swagger.${API_VERSION}.${VERSION}-patched.json"
curl --location --silent "${JSON_SCHEMA}" \
| jq '.paths."/objectschema/{id}/objecttypes".get.responses."200".content."application/json".schema = {
"type": "array",
"items": { "$ref": "#/components/schemas/ObjectType" }
}' \
> "${file}"
openapi-typescript "${file}" --output "${ROOT_DIR}/assets-api.d.ts"