google-marketing-solutions / Tightlock

Apache License 2.0
32 stars 15 forks source link

Add validation strings to schemas #105

Closed caiotomazelli closed 1 year ago

caiotomazelli commented 1 year ago

Added validation fields to some sources and destinations.

{
    "title": "Schemas",
    "description": "Schemas(*, source: types.local_file | types.bigquery, destination: types.GA4MP)",
    "type": "object",
    "properties": {
        "source": {
            "title": "Source",
            "anyOf": [
                {
                    "$ref": "#/definitions/local_file"
                },
                {
                    "$ref": "#/definitions/bigquery"
                }
            ]
        },
        "destination": {
            "$ref": "#/definitions/GA4MP"
        }
    },
    "required": [
        "source",
        "destination"
    ],
    "definitions": {
        "local_file": {
            "title": "local_file",
            "type": "object",
            "properties": {
                "location": {
                    "title": "Location",
                    "description": "The path to your local file, relative to the container 'data' folder.",
                    "type": "string"
                }
            },
            "required": [
                "location"
            ]
        },
        "bigquery": {
            "title": "bigquery",
            "type": "object",
            "properties": {
                "dataset": {
                    "title": "Dataset",
                    "description": "The name of your BigQuery dataset.",
                    "validation": "^[a-zA-Z0-9_]{1,1024}$",
                    "type": "string"
                },
                "table": {
                    "title": "Table",
                    "description": "The name of your BigQuery table.",
                    "type": "string"
                },
                "credentials": {
                    "title": "Credentials",
                    "description": "The full credentials service-account JSON string. Not needed if your backend is located in the same GCP project as the BigQuery table.",
                    "type": "object",
                    "additionalProperties": {
                        "type": "string"
                    }
                }
            },
            "required": [
                "dataset",
                "table"
            ]
        },
        "GA4MP": {
            "title": "GA4MP",
            "type": "object",
            "properties": {
                "api_secret": {
                    "title": "Api Secret",
                    "description": "An API SECRET generated in the Google Analytics UI.",
                    "type": "string"
                },
                "event_type": {
                    "title": "Event Type",
                    "description": "GA4 client type.",
                    "validation": "gtag|firebase",
                    "anyOf": [
                        {
                            "enum": [
                                "gtag"
                            ],
                            "type": "string"
                        },
                        {
                            "enum": [
                                "firebase"
                            ],
                            "type": "string"
                        }
                    ]
                },
                "measurement_id": {
                    "title": "Measurement Id",
                    "description": "The measurement ID associated with a stream. Found in the Google Analytics UI.",
                    "condition_field": "event_type",
                    "condition_target": "gtag",
                    "type": "string"
                },
                "firebase_app_id": {
                    "title": "Firebase App Id",
                    "description": "The Firebase App ID. The identifier for a Firebase app. Found in the Firebase console.",
                    "condition_field": "event_type",
                    "condition_target": "firebase",
                    "validation": "^[0-9a-fA-F]{32}$",
                    "type": "string"
                },
                "non_personalized_ads": {
                    "title": "Non Personalized Ads",
                    "description": "Set to true to indicate these events should not be used for personalized ads.",
                    "default": false,
                    "type": "boolean"
                },
                "debug": {
                    "title": "Debug",
                    "description": "Dry-run (validation mode).",
                    "default": false,
                    "type": "boolean"
                },
                "user_properties": {
                    "title": "User Properties",
                    "description": "The user properties for the measurement.",
                    "type": "object",
                    "additionalProperties": {
                        "type": "string"
                    }
                }
            },
            "required": [
                "api_secret",
                "event_type",
                "measurement_id",
                "firebase_app_id"
            ]
        }
    }
}