Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add transistor config schema file #18

Merged
merged 14 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"npm": "9"
},
"scripts": {
"build:schema": "ts-json-schema-generator --path ./src/schemas/Schema.ts --type Schema > src/schemas/transistor-config.schema.json",
"lint": "eslint --max-warnings=0 .",
"lint:fix": "eslint --fix --max-warnings=0 .",
"prepare": "husky install",
Expand Down Expand Up @@ -53,6 +54,7 @@
"husky": "^8.0.3",
"lint-staged": "^13.2.3",
"prettier": "^3.0.0",
"ts-json-schema-generator": "^1.2.0",
"typescript": "^5.1.6"
}
}
65 changes: 65 additions & 0 deletions src/schemas/Schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright IBM Corp. 2023, 2023
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* Configuration outline for metrics collection using IBM transistor
* @title Transistor Config Schema
* @id https://[HOSTHERE]/schemas/transistor-config.schema.json
*/
export interface Schema {
/**
* Current schema version
*/
version: 1
/**
* Unique identifier assigned on a per-project basis.
*/
projectId: string
/**
* The keys under `collect` represent the various types of data that
* Transistor is capable of collecting (i.e. `scopes`).
* @minProperties 1
*/
collect: {
/**
* Configuration for collecting telemetry data from an npm environment.
* @minProperties 1
*/
npm?: {
/**
* Enable telemetry data collection for package.json `dependencies` and `devDependencies`.
*/
dependencies?: null
}
/**
* Configuration for collecting telemetry data from JSX files.
* @minProperties 1
*/
jsx?: {
/**
* Enable telemetry data collection for JSX elements. The set of included elements is
* determined by looking at import/require statements across analyzed source files.
*/
elements?: {
/**
* Enable telemetry data collection for specific JSX attributes.
* These are collected for all included JSX elements.
* Specifying an `attributeName` here will turn on data collection for
* boolean and numeric attribute values.
* String value data collection is handled separately
* via the `allowedAttributeStringValues` key.
*/
allowedAttributeNames?: [string, ...string[]]
/**
* Enable telemetry data collection for specific string attribute values.
* These are collected for all defined attributes in the `allowedAttributeNames` key.
*/
allowedAttributeStringValues?: [string, ...string[]]
}
}
}
}
12 changes: 12 additions & 0 deletions src/schemas/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# yaml-language-server: $schema=./transistor-config.schema.json
version: 1
collect:
npm:
dependencies:
jsx:
elements:
allowedAttributeStringValues:
- "one"
- "two"

projectId: "1234"