{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "description": "ServiceNow SDK configuration schema",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "type": "string",
      "description": "Schema file to validate this configuration file"
    },
    "scope": {
      "type": "string",
      "minLength": 4,
      "maxLength": 18,
      "pattern": "^((x|sn)_[a-z0-9_]+|global)$",
      "description": "Scope of the application (example: 'x_myapp' or 'sn_myapp')"
    },
    "name": {
      "type": "string",
      "minLength": 4,
      "maxLength": 100,
      "description": "Name of the application (example: 'MyApp')"
    },
    "scopeId": {
      "type": "string",
      "minLength": 32,
      "maxLength": 32,
      "pattern": "^[0-9a-f]{32}$",
      "description": "Scope ID of the application (example: 'fc1b5713c3db3110d6489a038a40dd85')"
    },
    "entitiesDir": {
      "type": "string",
      "minLength": 1,
      "deprecated": true,
      "description": "DEPRECATED: Use 'fluentDir' instead"
    },
    "fluentDir": {
      "type": "string",
      "minLength": 1,
      "description": "Directory containing .now.ts fluent files of the application",
      "default": "src/fluent"
    },
    "serverModulesDir": {
      "type": "string",
      "description": "Directory containing modular files to be built into sys_modules",
      "default": "src/server"
    },
    "modulePaths": {
      "type": "object",
      "description": "Mapping between file glob patterns to resolve imported file paths to valid runtime paths. This is needed if your Fluent files are importing modules from a different location than the runtime modules. For example, if you have a custom TypeScript setup that transpiles modules from a 'src' directory to a 'dist' directory, you would need to specify that mapping here.",
      "patternProperties": {
        ".*": {
          "type": "string"
        }
      }
    },
    "tsconfigPath": {
      "type": "string",
      "description": "Path to tsconfig file to be used for custom transpilation of typescript (example: './src/tsconfig.json')"
    },
    "transpiledSourceDir": {
      "type": "string",
      "deprecated": true,
      "description": "DEPRECATED: Use 'modulePaths' instead"
    },
    "metadataDir": {
      "type": "string",
      "description": "Directory containing metadata xml for the app",
      "default": "metadata"
    },
    "appOutputDir": {
      "type": "string",
      "description": "Location to output built application for packaging during fluent build command",
      "default": "dist/app"
    },
    "packOutputDir": {
      "type": "string",
      "description": "Location to output the zip file during build process, to be later installed on the instance during install command",
      "default": "target"
    },
    "sourceDir": {
      "type": "string",
      "deprecated": true,
      "description": "DEPRECATED: This is no longer needed"
    },
    "ignoreTransformTableList": {
      "type": "array",
      "description": "List of tables to ignore when transforming entities to ServiceNow tables",
      "items": {
        "type": "string",
        "minLength": 1,
        "pattern": "^[a-z_\\d]+$"
      }
    },
    "dependencies": {
      "type": "object",
      "additionalProperties": false,
      "description": "Reference dependencies on other ServiceNow application tables and entities",
      "properties": {
        "applications": {
          "type": "object",
          "additionalProperties": false,
          "description": "List of applications that this application depends on",
          "patternProperties": {
            "^global$|^x|sn_[a-z0-9_]+$": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "tables": {
                  "type": "array",
                  "description": "List of tables that this application depends on (example: 'cmdb_ci').  Use * to reference all tables",
                  "items": {
                    "type": "string",
                    "minLength": 1,
                    "pattern": "^[a-z_\\d]+$"
                  }
                }
              }
            }
          }
        }
      },
      "required": [
        "applications"
      ]
    }
  },
  "required": [
    "scope",
    "scopeId"
  ],
  "not": {
    "required": ["modulePaths", "tsconfigPath"],
    "message": "Cannot specify both 'modulePaths' and 'tsconfigPath'. Use 'tsconfigPath' to supply a custom tsconfig.json file to use for internal transpilation during build. Use 'modulePaths' to map paths from 'serverModulesDir' to output directory if using a separate transpilation step"
  }
}
