@trackunit/iris-app 2.11.10 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -0
- package/README.md +0 -17
- package/package.json +7 -7
- package/src/generators/preset/files/.agents/skills/browser-testing/SKILL.md +36 -174
- package/src/generators/preset/files/.agents/skills/create-app/SKILL.md +22 -180
- package/src/generators/preset/files/.agents/skills/customfields/SKILL.md +38 -140
- package/src/generators/preset/files/.agents/skills/databricks-unity-catalog/SKILL.md +43 -90
- package/src/generators/preset/files/.agents/skills/graphql/SKILL.md +25 -122
- package/src/generators/preset/files/.agents/skills/graphql-timeseries/SKILL.md +27 -142
- package/src/generators/preset/files/.agents/skills/irisx-app-sdk/SKILL.md +11 -88
- package/src/generators/preset/files/.agents/skills/react-core-hooks/SKILL.md +21 -157
- package/src/generators/preset/files/.agents/skills/set-up-react-map/SKILL.md +8 -18
- package/src/generators/preset/files/.agents/skills/tables-and-sorting/SKILL.md +63 -63
- package/src/generators/preset/files/.agents/skills/widget-extensions/SKILL.md +53 -180
|
@@ -3,158 +3,61 @@ name: graphql
|
|
|
3
3
|
description: Use when setting up GraphQL tooling, writing queries/mutations, generating hooks, or fetching data from Trackunit API.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# GraphQL API
|
|
6
|
+
# GraphQL API
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Generate typed React hooks from `.graphql` files with `@trackunit/react-graphql-tools`. For time series data, use the `graphql-timeseries` skill.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
## Explore the schema
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Before writing a query or mutation, check whether Trackunit MCP is connected, as described in the "Trackunit MCP" section of `AGENTS.md`.
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
- Writing queries or mutations
|
|
16
|
-
- Generating React hooks from `.graphql` files
|
|
17
|
-
- Fetching data from Trackunit API
|
|
14
|
+
**If Trackunit MCP is connected:** look up types and fields with `explore_introspect_gql_schema`, and validate each operation with `explore_validate_gql_query` before saving the `.graphql` file.
|
|
18
15
|
|
|
19
|
-
**
|
|
16
|
+
**If Trackunit MCP is not connected:** do not block or wait for authentication. Use the [Developer Hub GraphQL docs](https://developers.trackunit.com/docs/apps-and-extensions/overview/public-apis/graphql-api/) and the [GraphQL Explorer](https://apps.iris.trackunit.com/graphql-public-viewer/), then rely on the `graphql-hooks` codegen, which validates against the public schema.
|
|
20
17
|
|
|
21
|
-
|
|
18
|
+
Never invent schema fields. Treat codegen errors as the final check, and fix every unknown field or type it reports.
|
|
22
19
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
**If Trackunit MCP is connected:**
|
|
26
|
-
- Look up types and fields with `explore_introspect_gql_schema`
|
|
27
|
-
- Validate each query or mutation with `explore_validate_gql_query` before saving the `.graphql` file and running codegen
|
|
28
|
-
|
|
29
|
-
**If Trackunit MCP is not connected:** do not block or wait for authentication. Use the [Developer Hub GraphQL docs](https://developers.trackunit.com/docs/apps-and-extensions/overview/public-apis/graphql-api/) and the [GraphQL Explorer](https://apps.iris.trackunit.com/graphql-public-viewer/) to find types, write the `.graphql` file, then run the `graphql-hooks` codegen below. Codegen validates against the public schema, so fix any unknown field or type errors it reports before using the generated hooks.
|
|
30
|
-
|
|
31
|
-
Never invent schema fields; look them up with one of the sources above, and treat codegen errors as the final check.
|
|
32
|
-
|
|
33
|
-
## Setup
|
|
34
|
-
|
|
35
|
-
### Install GraphQL Tools
|
|
20
|
+
## Set up
|
|
36
21
|
|
|
37
22
|
```bash
|
|
38
23
|
npm install @trackunit/react-graphql-tools
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### Set Up GraphQL Tooling
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
24
|
npx nx generate @trackunit/react-graphql-tools:add-graphql --project=[project-name]
|
|
45
25
|
```
|
|
46
26
|
|
|
47
|
-
|
|
27
|
+
Take `[project-name]` from the library's `project.json`. Extensions in subdirectories use `[subdir-name]-[extension-name]`.
|
|
48
28
|
|
|
49
|
-
|
|
29
|
+
## Write and generate
|
|
30
|
+
|
|
31
|
+
Put `.graphql` files in `libs/[feature-name]/[extension-name]/src/`, then generate hooks after every change:
|
|
50
32
|
|
|
51
33
|
```bash
|
|
52
34
|
npx nx run [feature-name]-[extension-name]:graphql-hooks
|
|
53
35
|
```
|
|
54
36
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
## GraphQL File Structure
|
|
58
|
-
|
|
59
|
-
Create `.graphql` files in `libs/[feature-name]/[extension-name]/src/` directory.
|
|
60
|
-
|
|
61
|
-
### Query Syntax
|
|
62
|
-
|
|
63
|
-
```graphql
|
|
64
|
-
query QueryName($variable: Type) {
|
|
65
|
-
fieldName {
|
|
66
|
-
subField
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### Mutation Syntax
|
|
72
|
-
|
|
73
|
-
```graphql
|
|
74
|
-
mutation MutationName($variable: Type!) {
|
|
75
|
-
mutationField(input: $variable) {
|
|
76
|
-
result
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
## React Integration
|
|
82
|
-
|
|
83
|
-
### Import Generated Hooks
|
|
84
|
-
|
|
85
|
-
```typescript
|
|
86
|
-
import { QueryNameDocument } from "./generated/graphql-api/graphql";
|
|
87
|
-
```
|
|
37
|
+
## Use the hooks
|
|
88
38
|
|
|
89
|
-
|
|
39
|
+
Import documents from `./generated/graphql-api/graphql`. Use `useQuery` from `@trackunit/react-graphql-hooks` and `useMutation` from `@apollo/client`; don't add other GraphQL libraries. Always handle `loading` and `error`.
|
|
90
40
|
|
|
91
41
|
```typescript
|
|
92
42
|
import { useQuery } from '@trackunit/react-graphql-hooks';
|
|
93
|
-
|
|
94
|
-
const { data, loading, error } = useQuery(QueryNameDocument, {
|
|
95
|
-
variables: { /* your variables */ }
|
|
96
|
-
});
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
### Use Mutations
|
|
100
|
-
|
|
101
|
-
```typescript
|
|
102
43
|
import { useMutation } from '@apollo/client';
|
|
44
|
+
import { GetAssetDocument, UpdateAssetDocument } from './generated/graphql-api/graphql';
|
|
103
45
|
|
|
104
|
-
const [mutationName, { data, loading, error }] = useMutation(MutationNameDocument);
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
## Common Patterns
|
|
108
|
-
|
|
109
|
-
### Query with Variables
|
|
110
|
-
|
|
111
|
-
```typescript
|
|
112
46
|
const { data, loading, error } = useQuery(GetAssetDocument, {
|
|
113
|
-
variables: { assetId
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if (loading) return <Spinner />;
|
|
117
|
-
if (error) return <ErrorMessage error={error} />;
|
|
118
|
-
|
|
119
|
-
return <AssetDisplay asset={data?.asset} />;
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### Mutation with Refetch
|
|
123
|
-
|
|
124
|
-
```typescript
|
|
125
|
-
import { useMutation } from '@apollo/client';
|
|
126
|
-
|
|
127
|
-
const [updateAsset, { loading }] = useMutation(UpdateAssetDocument, {
|
|
128
|
-
refetchQueries: [{ query: GetAssetDocument, variables: { assetId } }]
|
|
47
|
+
variables: { assetId },
|
|
48
|
+
pollInterval: 5000, // optional polling
|
|
129
49
|
});
|
|
130
50
|
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
};
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
### Polling
|
|
137
|
-
|
|
138
|
-
```typescript
|
|
139
|
-
const { data } = useQuery(GetAssetsDocument, {
|
|
140
|
-
pollInterval: 5000, // Poll every 5 seconds
|
|
51
|
+
const [updateAsset] = useMutation(UpdateAssetDocument, {
|
|
52
|
+
refetchQueries: [{ query: GetAssetDocument, variables: { assetId } }],
|
|
141
53
|
});
|
|
142
54
|
```
|
|
143
55
|
|
|
144
|
-
##
|
|
145
|
-
|
|
146
|
-
- [Calling Trackunit GraphQL API](https://developers.trackunit.com/docs/apps-and-extensions/overview/public-apis/graphql-api/)
|
|
147
|
-
- [Apollo useQuery documentation](https://www.apollographql.com/docs/react/data/queries)
|
|
148
|
-
- [Apollo useMutation documentation](https://www.apollographql.com/docs/react/data/mutations)
|
|
149
|
-
- [GraphQL Code Generator](https://the-guild.dev/graphql/codegen)
|
|
56
|
+
## Common mistakes
|
|
150
57
|
|
|
151
|
-
|
|
58
|
+
- **Hand-writing `gql` documents or result types.** Write a `.graphql` file, run `graphql-hooks`, and import the generated document and types.
|
|
59
|
+
- **Guessing schema fields.** Check the schema first, and fix every error codegen reports.
|
|
60
|
+
- **Adding another GraphQL client.** Use the hooks above.
|
|
61
|
+
- **Missing `loading` and `error` states.**
|
|
152
62
|
|
|
153
|
-
|
|
154
|
-
|---------|-----|
|
|
155
|
-
| Guessing schema fields | Introspect via Trackunit MCP; otherwise use the Developer Hub docs and fix any unknown field errors from `graphql-hooks` codegen |
|
|
156
|
-
| Using generic GraphQL libraries | Use `@trackunit/react-graphql-tools` only |
|
|
157
|
-
| Missing hook generation | Run `nx run [project]:graphql-hooks` after adding `.graphql` files |
|
|
158
|
-
| Wrong project name format | Use `[subdir-name]-[extension-name]` from `project.json` |
|
|
159
|
-
| No loading/error states | Always handle `loading` and `error` from hooks |
|
|
160
|
-
| Importing from wrong path | Import from `./generated/graphql-api/graphql` |
|
|
63
|
+
References: [Calling Trackunit GraphQL API](https://developers.trackunit.com/docs/apps-and-extensions/overview/public-apis/graphql-api/), [Apollo queries](https://www.apollographql.com/docs/react/data/queries), [Apollo mutations](https://www.apollographql.com/docs/react/data/mutations), and [GraphQL Code Generator](https://the-guild.dev/graphql/codegen).
|
|
@@ -3,24 +3,11 @@ name: graphql-timeseries
|
|
|
3
3
|
description: Use when querying machine insights, engine metrics, fuel data, operating hours, or building charts with historical time-based data.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# GraphQL
|
|
6
|
+
# GraphQL time series
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Query time series data through GraphQL with PromQL. Use `rangeQuery` for data over time and `instantQuery` for current values. For static entity data, use the `graphql` skill.
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
## When to Use
|
|
13
|
-
|
|
14
|
-
- Querying engine metrics (speed, temperature, fuel rate)
|
|
15
|
-
- Building historical data charts
|
|
16
|
-
- Calculating increases over time periods (daily fuel usage, operating hours)
|
|
17
|
-
- Getting current sensor values
|
|
18
|
-
|
|
19
|
-
**Not for:** Static entity data (use `graphql` skill).
|
|
20
|
-
|
|
21
|
-
## Query Structure
|
|
22
|
-
|
|
23
|
-
### Range Query (Time Series Data)
|
|
10
|
+
## Queries
|
|
24
11
|
|
|
25
12
|
```graphql
|
|
26
13
|
query GetTimeSeriesData($assetId: ID!, $start: DateTime!, $end: DateTime!, $step: Duration!) {
|
|
@@ -38,11 +25,7 @@ query GetTimeSeriesData($assetId: ID!, $start: DateTime!, $end: DateTime!, $step
|
|
|
38
25
|
}
|
|
39
26
|
}
|
|
40
27
|
}
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### Instant Query (Single Point in Time)
|
|
44
28
|
|
|
45
|
-
```graphql
|
|
46
29
|
query GetInstantData($assetId: ID!, $time: DateTime!) {
|
|
47
30
|
asset(id: $assetId) {
|
|
48
31
|
timeSeries {
|
|
@@ -58,136 +41,38 @@ query GetInstantData($assetId: ID!, $time: DateTime!) {
|
|
|
58
41
|
}
|
|
59
42
|
```
|
|
60
43
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
### Machine Insights
|
|
64
|
-
|
|
65
|
-
Not all assets have all insights. Common metrics include:
|
|
66
|
-
|
|
67
|
-
**Engine Metrics:**
|
|
68
|
-
- `machine_insight_engine_speed`
|
|
69
|
-
- `machine_insight_engine_coolant_temperature`
|
|
70
|
-
- `machine_insight_engine_oil_pressure`
|
|
71
|
-
- `machine_insight_engine_oil_temperature`
|
|
72
|
-
- `machine_insight_engine_fuel_rate`
|
|
73
|
-
- `machine_insight_engine_total_fuel_used`
|
|
74
|
-
- `machine_insight_engine_percent_load_at_current_speed`
|
|
75
|
-
- `machine_insight_cumulative_engine_hours`
|
|
76
|
-
|
|
77
|
-
**Fuel & Emissions:**
|
|
78
|
-
- `machine_insight_fuel_level`
|
|
79
|
-
- `machine_insight_fuel_tank_capacity`
|
|
80
|
-
- `machine_insight_fuel_used_last_24`
|
|
81
|
-
- `machine_insight_cumulative_co2_emissions`
|
|
82
|
-
|
|
83
|
-
**Operating Hours:**
|
|
84
|
-
- `machine_insight_cumulative_operating_hours`
|
|
85
|
-
- `machine_insight_cumulative_idle_hours`
|
|
86
|
-
- `machine_insight_cumulative_moving_hours`
|
|
87
|
-
- `machine_insight_cumulative_productive_hours`
|
|
44
|
+
Always include the fragment for the result type: `TimeSeriesMatrixData` for range queries, `TimeSeriesVectorData` for instant queries.
|
|
88
45
|
|
|
89
|
-
|
|
90
|
-
- `machine_insight_battery_state_of_charge_percent`
|
|
91
|
-
- `machine_insight_battery_state_of_health_percent`
|
|
92
|
-
- `machine_insight_battery_temperature`
|
|
93
|
-
- `machine_insight_battery_current`
|
|
94
|
-
- `machine_insight_battery_potential`
|
|
46
|
+
## PromQL
|
|
95
47
|
|
|
96
|
-
|
|
97
|
-
- `machine_insight_speed`
|
|
98
|
-
- `machine_insight_altitude`
|
|
99
|
-
- `machine_insight_total_vehicle_distance`
|
|
48
|
+
Pass any PromQL expression as `query`:
|
|
100
49
|
|
|
101
|
-
|
|
102
|
-
- `
|
|
103
|
-
- `
|
|
104
|
-
|
|
105
|
-
## PromQL Examples
|
|
106
|
-
|
|
107
|
-
### Calculate Daily Increases
|
|
108
|
-
|
|
109
|
-
```graphql
|
|
110
|
-
query IncreaseOperatingHours($assetId: ID!, $start: DateTime!, $end: DateTime!, $step: Duration!) {
|
|
111
|
-
asset(id: $assetId) {
|
|
112
|
-
timeSeries {
|
|
113
|
-
rangeQuery(
|
|
114
|
-
query: "increase(machine_insight_cumulative_operating_hours[1d])",
|
|
115
|
-
start: $start,
|
|
116
|
-
end: $end,
|
|
117
|
-
step: $step
|
|
118
|
-
) {
|
|
119
|
-
data {
|
|
120
|
-
... on TimeSeriesMatrixData {
|
|
121
|
-
result { values { timestamp value } }
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
```
|
|
50
|
+
- Daily increase: `increase(machine_insight_cumulative_operating_hours[1d])`
|
|
51
|
+
- Filter with `>`, `<`, `>=`, `<=`, `==`, `!=`: `increase(machine_insight_engine_total_fuel_used[1d]) > 13`
|
|
52
|
+
- Combine conditions: `(increase(machine_insight_engine_total_fuel_used[1d]) > 13) and (increase(machine_insight_cumulative_idle_hours[1d]) > 4)`
|
|
53
|
+
- Other functions include `rate()` and `avg_over_time()`. Time windows use brackets: `[15m]`, `[1h]`, `[1d]`.
|
|
129
54
|
|
|
130
|
-
|
|
55
|
+
Match `step` to the granularity the chart needs.
|
|
131
56
|
|
|
132
|
-
|
|
133
|
-
query HighFuelConsumption($assetId: ID!, $start: DateTime!, $end: DateTime!, $step: Duration!) {
|
|
134
|
-
asset(id: $assetId) {
|
|
135
|
-
timeSeries {
|
|
136
|
-
rangeQuery(
|
|
137
|
-
query: "increase(machine_insight_engine_total_fuel_used[1d]) > 13",
|
|
138
|
-
start: $start,
|
|
139
|
-
end: $end,
|
|
140
|
-
step: $step
|
|
141
|
-
) {
|
|
142
|
-
data {
|
|
143
|
-
... on TimeSeriesMatrixData {
|
|
144
|
-
result { values { timestamp value } }
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
```
|
|
57
|
+
## Results
|
|
152
58
|
|
|
153
|
-
|
|
59
|
+
- Timestamps are Unix timestamps in seconds.
|
|
60
|
+
- Values are strings; convert them with `parseFloat()`.
|
|
61
|
+
- Not every asset has every metric, so handle empty results.
|
|
154
62
|
|
|
155
|
-
|
|
156
|
-
query FuelWithHighIdle($assetId: ID!, $start: DateTime!, $end: DateTime!, $step: Duration!) {
|
|
157
|
-
asset(id: $assetId) {
|
|
158
|
-
timeSeries {
|
|
159
|
-
rangeQuery(
|
|
160
|
-
query: "(increase(machine_insight_engine_total_fuel_used[1d]) > 13) and (increase(machine_insight_cumulative_idle_hours[1d]) > 4)",
|
|
161
|
-
start: $start,
|
|
162
|
-
end: $end,
|
|
163
|
-
step: $step
|
|
164
|
-
) {
|
|
165
|
-
data {
|
|
166
|
-
... on TimeSeriesMatrixData {
|
|
167
|
-
result { values { timestamp value } }
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
```
|
|
63
|
+
## Cost
|
|
175
64
|
|
|
176
|
-
|
|
65
|
+
The API rejects a query above 50,000 complexity points and rate-limits each customer to 500,000 points per 10 minutes ([rate limits](https://developers.trackunit.com/docs/reference/graphql-api/graphql-api-rate-limits)). Time series under `assets` costs points for every asset in the page.
|
|
177
66
|
|
|
178
|
-
-
|
|
179
|
-
-
|
|
180
|
-
-
|
|
181
|
-
- **Time windows** use brackets: `[1d]`, `[1h]`, `[15m]`
|
|
182
|
-
- **Step intervals**: Choose based on data granularity needed
|
|
183
|
-
- **Timestamps** are Unix timestamps in seconds
|
|
184
|
-
- **Values** are returned as strings - convert to numbers as needed
|
|
67
|
+
- Don't load every page of assets to sum their time series. Use a field the API already aggregates, or query one page at a time.
|
|
68
|
+
- Keep `first` small when a list query includes time series, and poll slowly or not at all.
|
|
69
|
+
- Never drop a requirement because of cost. If no aggregate covers what was asked, cap the number of assets, say so in the UI, and note the trade-off in your report.
|
|
185
70
|
|
|
186
|
-
## Common
|
|
71
|
+
## Common metrics
|
|
187
72
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
73
|
+
- **Engine:** `machine_insight_engine_speed`, `machine_insight_engine_coolant_temperature`, `machine_insight_engine_oil_pressure`, `machine_insight_engine_oil_temperature`, `machine_insight_engine_fuel_rate`, `machine_insight_engine_total_fuel_used`, `machine_insight_engine_percent_load_at_current_speed`, `machine_insight_cumulative_engine_hours`
|
|
74
|
+
- **Fuel and emissions:** `machine_insight_fuel_level`, `machine_insight_fuel_tank_capacity`, `machine_insight_fuel_used_last_24`, `machine_insight_cumulative_co2_emissions`
|
|
75
|
+
- **Operating hours:** `machine_insight_cumulative_operating_hours`, `machine_insight_cumulative_idle_hours`, `machine_insight_cumulative_moving_hours`, `machine_insight_cumulative_productive_hours`
|
|
76
|
+
- **Battery:** `machine_insight_battery_state_of_charge_percent`, `machine_insight_battery_state_of_health_percent`, `machine_insight_battery_temperature`, `machine_insight_battery_current`, `machine_insight_battery_potential`
|
|
77
|
+
- **Location and movement:** `machine_insight_speed`, `machine_insight_altitude`, `machine_insight_total_vehicle_distance`
|
|
78
|
+
- **Environment:** `machine_insight_ambient_air_temperature`, `machine_insight_barometric_pressure`
|
|
@@ -3,70 +3,15 @@ name: irisx-app-sdk
|
|
|
3
3
|
description: Use when creating apps, adding extensions, configuring CSP/scopes, or needing SDK command reference. Core SDK documentation.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# IrisX App SDK
|
|
6
|
+
# IrisX App SDK
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
IrisX Apps are React applications that integrate into Trackunit Manager at extension points. `AGENTS.md` lists the SDK commands and extension types. Always use those commands, never `create-react-app`, `npm init`, or other generic React or Node.js tooling.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Guides: [creating a new app](https://developers.trackunit.com/docs/apps-and-extensions/overview/getting-started/creating-a-new-app), [creating a new extension](https://developers.trackunit.com/docs/apps-and-extensions/overview/getting-started/creating-a-new-extension), and [running the Iris App SDK](https://developers.trackunit.com/docs/apps-and-extensions/overview/getting-started/running-the-iris-app-sdk).
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## Security
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
- Configuring security (CSP headers, scopes)
|
|
16
|
-
- Looking up extension types or SDK commands
|
|
17
|
-
- Understanding runtime hooks availability
|
|
18
|
-
|
|
19
|
-
**Not for:** GraphQL setup (use `graphql` skill), browser testing (use `browser-testing` skill).
|
|
20
|
-
|
|
21
|
-
## Extension Points
|
|
22
|
-
|
|
23
|
-
Extensions are React applications that integrate into specific points in Trackunit Manager:
|
|
24
|
-
|
|
25
|
-
| Extension Type | Location |
|
|
26
|
-
|----------------|----------|
|
|
27
|
-
| `ASSET_HOME_EXTENSION` | New tabs in Assets Home screen |
|
|
28
|
-
| `SITE_HOME_EXTENSION` | New tabs in Site Home screen |
|
|
29
|
-
| `FLEET_EXTENSION` | Menu items in Main Menu |
|
|
30
|
-
| `REPORT_EXTENSION` | New reports in Reports screen |
|
|
31
|
-
| `WIDGET_EXTENSION` | Dashboard widgets |
|
|
32
|
-
| `IRIS_APP_SETTINGS_EXTENSION` | Configuration UI in App library |
|
|
33
|
-
| `ADMIN_EXTENSION` | Admin UI tabs (admin-only) |
|
|
34
|
-
| `CUSTOMER_HOME_EXTENSION` | UI within Customer Home |
|
|
35
|
-
| `ASSET_EVENTS_ACTIONS_EXTENSION` | UI in Asset Home Events |
|
|
36
|
-
| `LIFECYCLE_EXTENSION` | Handles app install/uninstall events |
|
|
37
|
-
| `SERVERSIDE_API_EXTENSION` | Serverside backend functions |
|
|
38
|
-
|
|
39
|
-
## Commands
|
|
40
|
-
|
|
41
|
-
### Create New App
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
npx nx generate @trackunit/iris-app:create [name-of-your-app]
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
See: [Creating a new app](https://developers.trackunit.com/docs/apps-and-extensions/overview/getting-started/creating-a-new-app)
|
|
48
|
-
|
|
49
|
-
### Create New Extension
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
npx nx g @trackunit/iris-app:extend --name=[my-extension-name] --app=[app-name] --directory=[feature] --type=[extension-type]
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
See: [Creating a new extension](https://developers.trackunit.com/docs/apps-and-extensions/overview/getting-started/creating-a-new-extension)
|
|
56
|
-
|
|
57
|
-
### Run App
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
npx nx run [name-of-your-app]:serve
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
See: [Running the Iris App SDK](https://developers.trackunit.com/docs/apps-and-extensions/overview/getting-started/running-the-iris-app-sdk)
|
|
64
|
-
|
|
65
|
-
## Security Configuration
|
|
66
|
-
|
|
67
|
-
IrisX Apps are locked down by default. External API requests and embedded content require proper Content Security Policy (CSP) configuration in the app manifest.
|
|
68
|
-
|
|
69
|
-
### CSP Headers Example
|
|
14
|
+
Apps are locked down by default. Allow external API requests and embedded content with `cspHeader` in the app manifest:
|
|
70
15
|
|
|
71
16
|
```typescript
|
|
72
17
|
cspHeader: {
|
|
@@ -76,7 +21,7 @@ cspHeader: {
|
|
|
76
21
|
},
|
|
77
22
|
```
|
|
78
23
|
|
|
79
|
-
|
|
24
|
+
Declare the scopes the app needs for API access:
|
|
80
25
|
|
|
81
26
|
```typescript
|
|
82
27
|
scopes: [
|
|
@@ -85,32 +30,10 @@ scopes: [
|
|
|
85
30
|
],
|
|
86
31
|
```
|
|
87
32
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
See: [Embedding IrisX Dashboards in Apps](https://developers.trackunit.com/docs/guides/analytics-and-insights/analytics-dashboards-in-apps#troubleshooting)
|
|
91
|
-
|
|
92
|
-
## Runtime Hooks
|
|
93
|
-
|
|
94
|
-
IrisX Apps have access to runtime hooks from `@trackunit/react-core-hooks`:
|
|
95
|
-
|
|
96
|
-
- `useAssetRuntime()` - Asset information in asset-scoped extensions
|
|
97
|
-
- `useCustomerRuntime()` - Customer data
|
|
98
|
-
- `useEventRuntime()` - Event details
|
|
99
|
-
- `useSiteRuntime()` - Site information
|
|
100
|
-
- Plus navigation, user context, and utility hooks
|
|
101
|
-
|
|
102
|
-
See the `react-core-hooks` skill for full details.
|
|
103
|
-
|
|
104
|
-
## Quality Assurance
|
|
105
|
-
|
|
106
|
-
Before completing any task: Always use `read_lints` to check for and fix all ESLint and TypeScript errors in modified files.
|
|
33
|
+
New scopes work locally only after the app is deployed with them. Never submit or deploy the app yourself; tell the user to do it. See [Embedding IrisX Dashboards in Apps](https://developers.trackunit.com/docs/guides/analytics-and-insights/analytics-dashboards-in-apps#troubleshooting).
|
|
107
34
|
|
|
108
|
-
##
|
|
35
|
+
## Related skills
|
|
109
36
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
| Mocking data without asking | Always use real GraphQL API |
|
|
114
|
-
| Missing scopes in manifest | Add required scopes; deploy to enable locally |
|
|
115
|
-
| External API blocked | Add domain to `cspHeader` in manifest |
|
|
116
|
-
| Auto-submitting app | Never auto-submit; instruct user to deploy |
|
|
37
|
+
- `react-core-hooks`: runtime context such as `useAssetRuntime()`, `useSiteRuntime()`, `useCustomerRuntime()`, and `useEventRuntime()`, plus navigation, user, and UI hooks.
|
|
38
|
+
- `graphql`: fetching data.
|
|
39
|
+
- `browser-testing`: verifying the app in Manager.
|