diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2f124bf..9a58aa4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,15 +30,15 @@ repos: # Run the Ruff linter. - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.9.8 + rev: v0.15.4 hooks: # Linter - - id: ruff - types_or: [python, pyi, jupyter, toml] - args: [--fix, --exit-non-zero-on-fix] + - id: ruff-check + args: [ --fix ] + types_or: [python, pyi, jupyter, pyproject] # Formatter - id: ruff-format - types_or: [python, pyi, jupyter, toml] + types_or: [python, pyi, jupyter, pyproject] - repo: https://github.com/RobertCraigie/pyright-python rev: v1.1.403 diff --git a/deploy.sh b/deploy.sh index 834a88c..a6871cb 100755 --- a/deploy.sh +++ b/deploy.sh @@ -17,7 +17,7 @@ cd "$FIREBASE_FUNCTIONS_DIR" cd "$BASE_DIR" -firebase use ${FIREBASE_PROJECT?error} +firebase use "${FIREBASE_PROJECT?error}" firebase target:apply hosting auth "$FIREBASE_AUTH_SITE" @@ -32,6 +32,11 @@ firebase functions:config:set \ osm.client_secret="$OSM_OAUTH_CLIENT_SECRET" \ osm.client_secret_web="$OSM_OAUTH_CLIENT_SECRET_WEB" -firebase deploy --only hosting +if [ "${SKIP_HOSTING:-false}" != "true" ]; then + firebase deploy --only hosting +fi + firebase deploy --only database -firebase deploy --only functions + +export FIREBASE_CLI_IMAGE_CLEANUP_DAYS=${FIREBASE_CLI_IMAGE_CLEANUP_DAYS:-30} +firebase deploy --only functions --non-interactive diff --git a/functions/definition/project/common.yaml b/functions/definition/project/common.yaml index 43a0763..099c56b 100644 --- a/functions/definition/project/common.yaml +++ b/functions/definition/project/common.yaml @@ -40,6 +40,8 @@ FbEnumProjectType: value: 4 - label: 'STREET' value: 7 + - label: 'LOCATE' + value: 9 FbProjectReadonlyType: model: alias diff --git a/functions/definition/project/project_types/locate.yaml b/functions/definition/project/project_types/locate.yaml new file mode 100644 index 0000000..b27970d --- /dev/null +++ b/functions/definition/project/project_types/locate.yaml @@ -0,0 +1,68 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/toggle-corp/typesync/refs/tags/v1.0.0/schema.local.json + +FBEnumSubGridSize: + model: alias + type: + type: enum + members: + - label: 'SIZE_2X2' + value: '2x2' + - label: 'SIZE_4X4' + value: '4x4' + - label: 'SIZE_8X8' + value: '8x8' + + +FbProjectLocateCreateOnlyInput: + model: alias + docs: Represents LOCATE project fields that are valid while creating a project + type: + type: object + fields: + zoomLevel: + type: int + tileServer: + type: FbObjRasterTileServer + subGridSize: + type: FBEnumSubGridSize + customOptions: + optional: true + type: + type: list + elementType: FbObjCustomOption + exportMetaKey: + type: string + exportMetaValue: + type: string + + +FbProjectLocateMappingResult: + model: alias + docs: Represents LOCATE mapswipe project results + # path: results/{projectId}/{groupId}/{userId} + type: + type: object + fields: + appVersion: + type: string + clientType: + # FIXME: this is an enum + type: string + optional: true + endTime: + type: timestamp + startTime: + type: timestamp + results: + optional: true + type: + type: map + valueType: + type: list + elementType: int + usergroups: + optional: true + type: + # NOTE: The key is usergroupId + type: map + valueType: boolean diff --git a/functions/definition/tutorial/project_types/locate.yaml b/functions/definition/tutorial/project_types/locate.yaml new file mode 100644 index 0000000..abc158c --- /dev/null +++ b/functions/definition/tutorial/project_types/locate.yaml @@ -0,0 +1,25 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/toggle-corp/typesync/refs/tags/v1.0.0/schema.local.json + +FbLocateTutorial: + model: alias + type: + type: object + fields: + projectType: + type: + type: literal + value: 9 + tileServer: + type: FbObjRasterTileServer + subGridSize: + type: FBEnumSubGridSize + zoomLevel: + type: int + +FbLocateTutorialTask: + model: alias + type: + type: object + fields: + url: + type: string diff --git a/functions/definition/tutorial/project_types/tileMapService.yaml b/functions/definition/tutorial/project_types/tileMapService.yaml index 7e7eb9f..ec3e58e 100644 --- a/functions/definition/tutorial/project_types/tileMapService.yaml +++ b/functions/definition/tutorial/project_types/tileMapService.yaml @@ -25,6 +25,9 @@ FbTileMapServiceTutorialTask: type: string referenceAnswer: type: int + taskPartitionIndex: + type: int + optional: true screen: type: int taskId: diff --git a/functions/generated/pyfirebase/pyfirebase_mapswipe/extended_models.py b/functions/generated/pyfirebase/pyfirebase_mapswipe/extended_models.py index 6f04f84..8957a26 100644 --- a/functions/generated/pyfirebase/pyfirebase_mapswipe/extended_models.py +++ b/functions/generated/pyfirebase/pyfirebase_mapswipe/extended_models.py @@ -76,3 +76,13 @@ class Config: # type: ignore[reportIncompatibleVariableOverride] use_enum_values = True frozen = True extra = "forbid" + + +class FbLocateTutorialTaskComplete( + models.FbTileMapServiceTutorialTask, + models.FbLocateTutorialTask, +): + class Config: # type: ignore[reportIncompatibleVariableOverride] + use_enum_values = True + frozen = True + extra = "forbid" diff --git a/functions/generated/pyfirebase/pyfirebase_mapswipe/models.py b/functions/generated/pyfirebase/pyfirebase_mapswipe/models.py index dc92a83..2cb28c7 100644 --- a/functions/generated/pyfirebase/pyfirebase_mapswipe/models.py +++ b/functions/generated/pyfirebase/pyfirebase_mapswipe/models.py @@ -122,6 +122,7 @@ class FbEnumProjectType(enum.Enum): COMPARE = 3 COMPLETENESS = 4 STREET = 7 + LOCATE = 9 class FbProjectReadonlyType(TypesyncModel): @@ -356,6 +357,37 @@ class FbEnumOverlayTileServerType(enum.Enum): VECTOR = "vector" +class FBEnumSubGridSize(enum.Enum): + SIZE_2X2 = "2x2" + SIZE_4X4 = "4x4" + SIZE_8X8 = "8x8" + + +class FbProjectLocateMappingResult(TypesyncModel): + """Represents LOCATE mapswipe project results""" + + appVersion: str + clientType: str | TypesyncUndefined | None = UNDEFINED + endTime: datetime.datetime + startTime: datetime.datetime + results: dict[str, list[int]] | TypesyncUndefined | None = UNDEFINED + usergroups: dict[str, bool] | TypesyncUndefined | None = UNDEFINED + + class Config: + use_enum_values = False + extra = "forbid" + + @typing.override + def __setattr__(self, name: str, value: typing.Any) -> None: + if name == "clientType" and value is None: + raise ValueError("'clientType' field cannot be set to None") + if name == "results" and value is None: + raise ValueError("'results' field cannot be set to None") + if name == "usergroups" and value is None: + raise ValueError("'usergroups' field cannot be set to None") + super().__setattr__(name, value) + + class FbProjectStreetCreateOnlyInput(TypesyncModel): """Represents STREET project fields that are valid while creating a project""" @@ -589,6 +621,27 @@ def __setattr__(self, name: str, value: typing.Any) -> None: super().__setattr__(name, value) +class FbProjectLocateCreateOnlyInput(TypesyncModel): + """Represents LOCATE project fields that are valid while creating a project""" + + zoomLevel: int + tileServer: FbObjRasterTileServer + subGridSize: FBEnumSubGridSize + customOptions: list[FbObjCustomOption] | TypesyncUndefined | None = UNDEFINED + exportMetaKey: str + exportMetaValue: str + + class Config: + use_enum_values = False + extra = "forbid" + + @typing.override + def __setattr__(self, name: str, value: typing.Any) -> None: + if name == "customOptions" and value is None: + raise ValueError("'customOptions' field cannot be set to None") + super().__setattr__(name, value) + + class FbProjectValidateCreateOnlyInput(TypesyncModel): """Represents VALIDATE project fields that are valid while creating a project""" @@ -940,6 +993,33 @@ def __setattr__(self, name: str, value: typing.Any) -> None: super().__setattr__(name, value) +class FbLocateTutorial(TypesyncModel): + projectType: typing.Literal[9] + tileServer: FbObjRasterTileServer + subGridSize: FBEnumSubGridSize + zoomLevel: int + + class Config: + use_enum_values = False + extra = "forbid" + + @typing.override + def __setattr__(self, name: str, value: typing.Any) -> None: + super().__setattr__(name, value) + + +class FbLocateTutorialTask(TypesyncModel): + url: str + + class Config: + use_enum_values = False + extra = "forbid" + + @typing.override + def __setattr__(self, name: str, value: typing.Any) -> None: + super().__setattr__(name, value) + + class FbStreetTutorial(TypesyncModel): projectType: typing.Literal[7] customOptions: list[FbObjCustomOption] | TypesyncUndefined | None = UNDEFINED @@ -992,6 +1072,7 @@ class FbTileMapServiceTutorialTask(TypesyncModel): groupId: int projectId: str referenceAnswer: int + taskPartitionIndex: int | TypesyncUndefined | None = UNDEFINED screen: int taskId: str taskId_real: str @@ -1004,6 +1085,8 @@ class Config: @typing.override def __setattr__(self, name: str, value: typing.Any) -> None: + if name == "taskPartitionIndex" and value is None: + raise ValueError("'taskPartitionIndex' field cannot be set to None") super().__setattr__(name, value)