Skip to content

Commit

Permalink
typescript package
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianBeilschmidt committed Dec 8, 2023
1 parent 0f78270 commit 5d41d8a
Show file tree
Hide file tree
Showing 249 changed files with 23,846 additions and 10 deletions.
26 changes: 17 additions & 9 deletions .generation/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from pathlib import Path
from urllib import request
from urllib.error import URLError
from urllib.parse import urlsplit
import configparser
import json
import os
Expand Down Expand Up @@ -176,8 +177,14 @@ def generate_python_code(*, package_name: str, package_version: str, package_url
)


def generate_typescript_code(*, package_name: str, package_version: str, package_url: str):
def generate_typescript_code(*, npm_name: str, npm_version: str, repository_url: str):
'''Run the generator.'''

parsed_url = urlsplit(repository_url)
(url_path, _url_ext) = os.path.splitext(parsed_url.path)
(url_path, git_user_id) = os.path.split(url_path)
(url_path, git_repo_id) = os.path.split(url_path)

subprocess.run(
[
"podman", "run",
Expand All @@ -191,12 +198,13 @@ def generate_typescript_code(*, package_name: str, package_version: str, package
"-i", f"{'/local' / CWD / 'input/openapi.json'}",
"-g", "typescript-fetch",
"--additional-properties=" + ",".join([
"useOneOfDiscriminatorLookup=true",
# "generateSourceCodeOnly=true",
f"packageName={package_name}",
f"packageVersion={package_version}",
f"packageUrl={package_url}",
"supportsES6=true",
f"npmName={npm_name}",
f"npmVersion={npm_version}",
]),
"--git-host", parsed_url.netloc,
"--git-user-id", git_user_id,
"--git-repo-id", git_repo_id,
"--enable-post-process-file",
"-o", "/local/typescript/",
],
Expand Down Expand Up @@ -225,9 +233,9 @@ def main():
)
elif args.language == 'typescript':
generate_typescript_code(
package_name=config.typescript_package_name,
package_version=config.typescript_package_version,
package_url=config.github_url,
npm_name=config.typescript_package_name,
npm_version=config.typescript_package_version,
repository_url=config.github_url,
)
else:
raise RuntimeError(f'Unknown language {args.language}.')
Expand Down
2 changes: 1 addition & 1 deletion .generation/override.env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
PYTHON_POST_PROCESS_FILE=python3 /local/.generation/post_process.py
PYTHON_POST_PROCESS_FILE=python3 /local/.generation/post_process_python.py
File renamed without changes.
4 changes: 4 additions & 0 deletions typescript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
wwwroot/*.js
node_modules
typings
dist
1 change: 1 addition & 0 deletions typescript/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
README.md
23 changes: 23 additions & 0 deletions typescript/.openapi-generator-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
243 changes: 243 additions & 0 deletions typescript/.openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
.gitignore
.npmignore
README.md
package.json
src/apis/DatasetsApi.ts
src/apis/GeneralApi.ts
src/apis/LayersApi.ts
src/apis/OGCWCSApi.ts
src/apis/OGCWFSApi.ts
src/apis/OGCWMSApi.ts
src/apis/PermissionsApi.ts
src/apis/PlotsApi.ts
src/apis/ProjectsApi.ts
src/apis/SessionApi.ts
src/apis/SpatialReferencesApi.ts
src/apis/TasksApi.ts
src/apis/UploadsApi.ts
src/apis/UserApi.ts
src/apis/WorkflowsApi.ts
src/apis/index.ts
src/index.ts
src/models/AbortedTaskStatus.ts
src/models/AddCollection200Response.ts
src/models/AddDataset.ts
src/models/AddLayer.ts
src/models/AddLayerCollection.ts
src/models/AddRole.ts
src/models/AutoCreateDataset.ts
src/models/AutoOgrSourceTimeFormat.ts
src/models/AxisOrder.ts
src/models/BoundingBox2D.ts
src/models/Breakpoint.ts
src/models/ClassificationMeasurement.ts
src/models/ClassificationMeasurementWithType.ts
src/models/CollectionItem.ts
src/models/CollectionType.ts
src/models/ColorParam.ts
src/models/Colorizer.ts
src/models/CompletedTaskStatus.ts
src/models/ContinuousMeasurement.ts
src/models/ContinuousMeasurementWithType.ts
src/models/Coordinate2D.ts
src/models/CreateDataset.ts
src/models/CreateDatasetHandler200Response.ts
src/models/CreateProject.ts
src/models/CsvHeader.ts
src/models/CustomOgrSourceTimeFormat.ts
src/models/DataId.ts
src/models/DataPath.ts
src/models/DataPathOneOf.ts
src/models/DataPathOneOf1.ts
src/models/Dataset.ts
src/models/DatasetDefinition.ts
src/models/DatasetIdResourceId.ts
src/models/DatasetListing.ts
src/models/DatasetResource.ts
src/models/DateTime.ts
src/models/DateTimeParseFormat.ts
src/models/DerivedColor.ts
src/models/DerivedColorWithType.ts
src/models/DerivedNumber.ts
src/models/DerivedNumberWithType.ts
src/models/DescribeCoverageRequest.ts
src/models/ErrorResponse.ts
src/models/ExternalDataId.ts
src/models/ExternalDataIdWithType.ts
src/models/FailedTaskStatus.ts
src/models/FeatureDataType.ts
src/models/FileNotFoundHandling.ts
src/models/FormatSpecifics.ts
src/models/FormatSpecificsOneOf.ts
src/models/FormatSpecificsOneOfCsv.ts
src/models/GdalDatasetGeoTransform.ts
src/models/GdalDatasetParameters.ts
src/models/GdalLoadingInfoTemporalSlice.ts
src/models/GdalMetaDataList.ts
src/models/GdalMetaDataListWithType.ts
src/models/GdalMetaDataRegular.ts
src/models/GdalMetaDataRegularWithType.ts
src/models/GdalMetaDataStatic.ts
src/models/GdalMetaDataStaticWithType.ts
src/models/GdalMetadataMapping.ts
src/models/GdalMetadataNetCdfCf.ts
src/models/GdalMetadataNetCdfCfWithType.ts
src/models/GdalSourceTimePlaceholder.ts
src/models/GeoJson.ts
src/models/GetCapabilitiesFormat.ts
src/models/GetCapabilitiesRequest.ts
src/models/GetCoverageFormat.ts
src/models/GetCoverageRequest.ts
src/models/GetFeatureRequest.ts
src/models/GetLegendGraphicRequest.ts
src/models/GetMapExceptionFormat.ts
src/models/GetMapFormat.ts
src/models/GetMapRequest.ts
src/models/InfiniteOgrSourceDurationSpec.ts
src/models/InternalDataId.ts
src/models/Layer.ts
src/models/LayerCollection.ts
src/models/LayerCollectionListing.ts
src/models/LayerCollectionListingWithType.ts
src/models/LayerCollectionResource.ts
src/models/LayerCollectionResourceId.ts
src/models/LayerListing.ts
src/models/LayerListingWithType.ts
src/models/LayerResource.ts
src/models/LayerResourceId.ts
src/models/LayerUpdate.ts
src/models/LayerVisibility.ts
src/models/LineSymbology.ts
src/models/LineSymbologyWithType.ts
src/models/LinearGradient.ts
src/models/LinearGradientWithType.ts
src/models/LogarithmicGradient.ts
src/models/LogarithmicGradientWithType.ts
src/models/Measurement.ts
src/models/MetaDataDefinition.ts
src/models/MetaDataSuggestion.ts
src/models/MockDatasetDataSourceLoadingInfo.ts
src/models/MockMetaData.ts
src/models/MockMetaDataWithType.ts
src/models/ModelIdResourceId.ts
src/models/MultiLineString.ts
src/models/MultiPoint.ts
src/models/MultiPolygon.ts
src/models/NoneOgrSourceDatasetTimeType.ts
src/models/NumberParam.ts
src/models/OgrMetaData.ts
src/models/OgrMetaDataWithType.ts
src/models/OgrSourceColumnSpec.ts
src/models/OgrSourceDataset.ts
src/models/OgrSourceDatasetTimeType.ts
src/models/OgrSourceDurationSpec.ts
src/models/OgrSourceErrorSpec.ts
src/models/OgrSourceTimeFormat.ts
src/models/OrderBy.ts
src/models/PaletteColorizer.ts
src/models/Permission.ts
src/models/PermissionRequest.ts
src/models/Plot.ts
src/models/PlotOutputFormat.ts
src/models/PlotQueryRectangle.ts
src/models/PlotResultDescriptor.ts
src/models/PlotResultDescriptorWithType.ts
src/models/PlotUpdate.ts
src/models/PointSymbology.ts
src/models/PointSymbologyWithType.ts
src/models/PolygonSymbology.ts
src/models/PolygonSymbologyWithType.ts
src/models/Project.ts
src/models/ProjectLayer.ts
src/models/ProjectListing.ts
src/models/ProjectResource.ts
src/models/ProjectResourceId.ts
src/models/ProjectVersion.ts
src/models/Provenance.ts
src/models/ProvenanceEntry.ts
src/models/ProvenanceOutput.ts
src/models/ProviderLayerCollectionId.ts
src/models/ProviderLayerId.ts
src/models/Quota.ts
src/models/RasterBandDescriptor.ts
src/models/RasterDataType.ts
src/models/RasterDatasetFromWorkflow.ts
src/models/RasterDatasetFromWorkflowResult.ts
src/models/RasterPropertiesEntryType.ts
src/models/RasterPropertiesKey.ts
src/models/RasterQueryRectangle.ts
src/models/RasterResultDescriptor.ts
src/models/RasterResultDescriptorWithType.ts
src/models/RasterStreamWebsocketResultType.ts
src/models/RasterSymbology.ts
src/models/RasterSymbologyWithType.ts
src/models/Resource.ts
src/models/ResourceId.ts
src/models/RgbaColorizer.ts
src/models/Role.ts
src/models/RoleDescription.ts
src/models/RunningTaskStatus.ts
src/models/STRectangle.ts
src/models/ServerInfo.ts
src/models/SpatialPartition2D.ts
src/models/SpatialReferenceAuthority.ts
src/models/SpatialReferenceSpecification.ts
src/models/SpatialResolution.ts
src/models/StartDurationOgrSourceDatasetTimeType.ts
src/models/StartEndOgrSourceDatasetTimeType.ts
src/models/StartOgrSourceDatasetTimeType.ts
src/models/StaticColorParam.ts
src/models/StaticNumberParam.ts
src/models/StrokeParam.ts
src/models/Symbology.ts
src/models/TaskAbortOptions.ts
src/models/TaskFilter.ts
src/models/TaskListOptions.ts
src/models/TaskResponse.ts
src/models/TaskStatus.ts
src/models/TaskStatusWithId.ts
src/models/TextSymbology.ts
src/models/TimeGranularity.ts
src/models/TimeInterval.ts
src/models/TimeReference.ts
src/models/TimeStep.ts
src/models/TimeStepWithType.ts
src/models/TypedGeometry.ts
src/models/TypedGeometryOneOf.ts
src/models/TypedGeometryOneOf1.ts
src/models/TypedGeometryOneOf2.ts
src/models/TypedGeometryOneOf3.ts
src/models/TypedOperator.ts
src/models/TypedOperatorOperator.ts
src/models/TypedResultDescriptor.ts
src/models/UnitlessMeasurement.ts
src/models/UnixTimeStampOgrSourceTimeFormat.ts
src/models/UnixTimeStampType.ts
src/models/UpdateProject.ts
src/models/UpdateQuota.ts
src/models/UploadFileLayersResponse.ts
src/models/UploadFilesResponse.ts
src/models/UserCredentials.ts
src/models/UserInfo.ts
src/models/UserRegistration.ts
src/models/UserSession.ts
src/models/VectorColumnInfo.ts
src/models/VectorDataType.ts
src/models/VectorQueryRectangle.ts
src/models/VectorResultDescriptor.ts
src/models/VectorResultDescriptorWithType.ts
src/models/Volume.ts
src/models/WcsBoundingbox.ts
src/models/WcsService.ts
src/models/WcsVersion.ts
src/models/WfsService.ts
src/models/WfsVersion.ts
src/models/WmsService.ts
src/models/WmsVersion.ts
src/models/Workflow.ts
src/models/WrappedPlotOutput.ts
src/models/ZeroOgrSourceDurationSpec.ts
src/models/index.ts
src/runtime.ts
tsconfig.esm.json
tsconfig.json
1 change: 1 addition & 0 deletions typescript/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.0.1
45 changes: 45 additions & 0 deletions typescript/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
## [email protected]

This generator creates TypeScript/JavaScript client that utilizes [Fetch API](https://fetch.spec.whatwg.org/). The generated Node module can be used in the following environments:

Environment
* Node.js
* Webpack
* Browserify

Language level
* ES5 - you must have a Promises/A+ library installed
* ES6

Module system
* CommonJS
* ES6 module system

It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html))

### Building

To build and compile the typescript sources to javascript use:
```
npm install
npm run build
```

### Publishing

First build the package then run ```npm publish```

### Consuming

navigate to the folder of your consuming project and run one of the following commands.

_published:_

```
npm install [email protected] --save
```

_unPublished (not recommended):_

```
npm install PATH_TO_GENERATED_PACKAGE --save
Loading

0 comments on commit 5d41d8a

Please sign in to comment.