-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(@jcoreio/clarity-feature-api): move package into this monorepo
- Loading branch information
1 parent
883c96f
commit 8644d0f
Showing
31 changed files
with
700 additions
and
1 deletion.
There are no files selected for viewing
Submodule clarity-feature-api
deleted from
bdc359
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* eslint-env node, es2018 */ | ||
module.exports = function (api) { | ||
const base = require('@jcoreio/toolchain-esnext/.babelrc.cjs')(api) | ||
return { | ||
...base, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# created by @jcoreio/toolchain-circle | ||
|
||
version: 2.1 | ||
jobs: | ||
build: | ||
docker: | ||
- image: cimg/node:20.10.0 | ||
|
||
steps: | ||
- checkout | ||
- run: | ||
name: Setup NPM Token | ||
command: | | ||
npm config set \ | ||
"//registry.npmjs.org/:_authToken=$NPM_TOKEN" \ | ||
"registry=https://registry.npmjs.org/" | ||
- run: | ||
name: Corepack enable | ||
command: sudo corepack enable | ||
- run: | ||
name: Install Dependencies | ||
command: pnpm install --frozen-lockfile | ||
- run: | ||
name: Prepublish | ||
command: | | ||
[[ $(netstat -tnlp | grep -F 'circleci-agent') ]] || pnpm run tc prepublish | ||
- run: | ||
name: Release | ||
command: | | ||
[[ $(netstat -tnlp | grep -F 'circleci-agent') ]] || pnpm run tc release | ||
workflows: | ||
build: | ||
jobs: | ||
- build: | ||
context: | ||
- npm-release | ||
- github-release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* eslint-env node, es2018 */ | ||
module.exports = { | ||
extends: [require.resolve('@jcoreio/toolchain/eslintConfig.cjs')], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/dist | ||
.nyc_output | ||
node_modules | ||
/coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* eslint-env node, es2018 */ | ||
const base = require('@jcoreio/toolchain-mocha/.mocharc.cjs') | ||
module.exports = { | ||
...base, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "test:debug <file>", | ||
"port": 9229, | ||
"request": "attach", | ||
"skipFiles": ["<node_internals>/**"], | ||
"type": "node", | ||
"preLaunchTask": "test:debug <file>" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"type": "shell", | ||
"options": { | ||
"shell": { | ||
"executable": "bash", | ||
"args": ["-c", "-l"] | ||
} | ||
}, | ||
"command": "pnpm", | ||
"isBackground": false, | ||
"group": "test", | ||
"presentation": { | ||
"panel": "dedicated", | ||
"clear": true | ||
}, | ||
"label": "test <file>", | ||
"args": ["tc", "test", "${file}"] | ||
}, | ||
{ | ||
"type": "shell", | ||
"options": { | ||
"shell": { | ||
"executable": "bash", | ||
"args": ["-c", "-l"] | ||
} | ||
}, | ||
"command": "pnpm", | ||
"isBackground": false, | ||
"group": "test", | ||
"presentation": { | ||
"panel": "dedicated", | ||
"clear": true | ||
}, | ||
"label": "test:watch <file>", | ||
"args": ["tc", "test", "--watch", "${file}"] | ||
}, | ||
{ | ||
"type": "shell", | ||
"options": { | ||
"shell": { | ||
"executable": "bash", | ||
"args": ["-c", "-l"] | ||
} | ||
}, | ||
"command": "pnpm", | ||
"isBackground": false, | ||
"group": "test", | ||
"presentation": { | ||
"panel": "dedicated", | ||
"clear": true | ||
}, | ||
"label": "test:debug <file>", | ||
"args": ["tc", "test", "-n", "inspect-brk", "${file}"] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2024-present JCore Systems | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# `@jcoreio/clarity-feature-api` | ||
|
||
This package provides a mock environment for developing custom features for Clarity. | ||
|
||
## Client API | ||
|
||
### `useTagState(tag: string)` | ||
|
||
```ts | ||
import { useTagState } from '@jcoreio/clarity-feature-api/client' | ||
``` | ||
|
||
React hook that subscribes to the realtime value, metadata, and alarm state of a tag. | ||
|
||
#### Example | ||
|
||
```tsx | ||
import * as React from 'react' | ||
import { | ||
useTagState, | ||
CustomDashboardWidgetProps, | ||
} from '@jcoreio/clarity-feature-api/client' | ||
|
||
export function MyWidget({ | ||
config, | ||
}: CustomDashboardWidgetProps<{ tag: string } | undefined>) { | ||
const { loading, error, data } = useTagState(config?.tag) | ||
|
||
if (loading) return <div>Loading...</div> | ||
if (error) return <div>Error: {error.message}</div> | ||
|
||
const t = data?.t | ||
const v = data?.v | ||
const metadata = data?.metadata | ||
const notification = data?.notification | ||
const name = metadata?.fullName?.join('/') || tag | ||
return <div> | ||
Most recent data for {name}: | ||
<p>Time: {t != null ? new Date(t).toLocaleString()}</p> | ||
<p>Value: {v}</p> | ||
<p>Notification: {notification?.severity}</p> | ||
</div> | ||
} | ||
``` | ||
### `useDrop(spec)` | ||
```ts | ||
import { useDrop } from '@jcoreio/clarity-feature-api/client' | ||
``` | ||
React hook for connecting a drop target to Clarity | ||
#### Example | ||
```tsx | ||
import * as React from 'react' | ||
import { | ||
useTagState, | ||
CustomDashboardWidgetProps, | ||
} from '@jcoreio/clarity-feature-api/client' | ||
|
||
export function MyWidget({ | ||
config, | ||
setConfig, | ||
}: CustomDashboardWidgetProps<{ tag?: string } | undefined>) { | ||
const [{ isOver, canDrop, tag, MetadataItem }, connectDropTarget] = useDrop( | ||
{ | ||
canDrop: ({ tag, MetadataItem }) => tag != null, | ||
drop: ({ tag, MetadataItem }): undefined => { | ||
if (tag != null) setConfig({ tag }) | ||
}, | ||
}, | ||
[setConfig] | ||
) | ||
|
||
return ( | ||
<div ref={connectDropTarget}> | ||
{tag != null ? ( | ||
<p>Drop to set tag to {tag}</p> | ||
) : ( | ||
<p>Tag: {config?.tag}</p> | ||
)} | ||
</div> | ||
) | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* eslint-env node, es2018 */ | ||
const base = require('@jcoreio/toolchain/lint-staged.config.cjs') | ||
module.exports = { | ||
...base, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* eslint-env node, es2018 */ | ||
const base = require('@jcoreio/toolchain-mocha/nyc.config.cjs') | ||
module.exports = { | ||
...base, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{ | ||
"name": "@jcoreio/clarity-feature-api", | ||
"version": "0.0.0-development", | ||
"description": "Clarity Feature API mocks for developing custom features", | ||
"scripts": { | ||
"tc": "toolchain", | ||
"toolchain": "toolchain", | ||
"test": "toolchain test", | ||
"prepublishOnly": "echo This package is meant to be published by semantic-release from the dist build directory. && exit 1" | ||
}, | ||
"keywords": [ | ||
"jcore", | ||
"jcoreio", | ||
"jcore systems", | ||
"clarity" | ||
], | ||
"author": "Andy Edwards", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/jcoreio/clarity-feature-api.git", | ||
"directory": "packages/clarity-feature-api" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/jcoreio/clarity-feature-toolkit/issues" | ||
}, | ||
"homepage": "https://github.com/jcoreio/clarity-feature-toolkit/tree/master/packages/clarity-feature-api", | ||
"devDependencies": { | ||
"@jcoreio/eslint-plugin-implicit-dependencies": "^1.1.1", | ||
"@jcoreio/toolchain": "^3.11.1", | ||
"@jcoreio/toolchain-circle": "^3.11.1", | ||
"@jcoreio/toolchain-esnext": "^3.11.1", | ||
"@jcoreio/toolchain-mocha": "^3.11.1", | ||
"@jcoreio/toolchain-react": "^3.11.1", | ||
"@jcoreio/toolchain-semantic-release": "^3.11.1", | ||
"@jcoreio/toolchain-typescript": "^3.11.1", | ||
"@semantic-release/npm": "12.0.0", | ||
"@types/chai": "^4.0.0", | ||
"@types/mocha": "^10.0.0", | ||
"@typescript-eslint/eslint-plugin": "^7.6.0", | ||
"@typescript-eslint/parser": "^7.6.0", | ||
"chai": "^4.0.0", | ||
"eslint": "^8.56.0", | ||
"eslint-plugin-no-only-tests": "^3.1.0", | ||
"eslint-plugin-react": "^7.32.2", | ||
"mocha": "^10.4.0", | ||
"typescript": "^5.1.0" | ||
}, | ||
"sideEffects": false, | ||
"engines": { | ||
"node": ">=16" | ||
}, | ||
"packageManager": "pnpm@8.11.0", | ||
"dependencies": { | ||
"@babel/runtime": "^7.18.6", | ||
"@types/react": "^18.3.0", | ||
"@types/semver": "^7.5.8", | ||
"react": "^18.3.1", | ||
"react-dnd": "^14.0.5", | ||
"semver": "^7.6.0", | ||
"zod": "^3.23.5", | ||
"zod-route-schemas": "^1.0.0" | ||
}, | ||
"exports": { | ||
"./package.json": "./dist/package.json", | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.mjs", | ||
"default": "./dist/index.js" | ||
}, | ||
"./client": { | ||
"types": "./dist/client/index.d.ts", | ||
"import": "./dist/client/index.mjs", | ||
"default": "./dist/client/index.js" | ||
}, | ||
"./client/test": { | ||
"types": "./dist/client/test.d.ts", | ||
"import": "./dist/client/test.mjs", | ||
"default": "./dist/client/test.js" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* eslint-env node, es2018 */ | ||
const base = require('@jcoreio/toolchain/prettier.config.cjs') | ||
module.exports = { | ||
...base, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* eslint-env node, es2018 */ | ||
const { name: pkg } = require('./package.json') | ||
const makeReleaseConfig = require('../../makeReleaseConfig.cjs') | ||
module.exports = makeReleaseConfig(pkg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import z from 'zod' | ||
|
||
export const ContributesSchema = z.strictObject({ | ||
client: z | ||
.strictObject({ | ||
dashboardWidgets: z.record( | ||
z.strictObject({ | ||
displayName: z.string(), | ||
component: z.string(), | ||
}) | ||
), | ||
}) | ||
.optional(), | ||
}) | ||
|
||
export type Contributes = z.output<typeof ContributesSchema> |
7 changes: 7 additions & 0 deletions
7
packages/clarity-feature-api/src/client/CustomDashboardWidgetProps.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export type CustomDashboardWidgetProps<Config = any> = { | ||
config: Config | ||
setConfig: (config: Config) => void | ||
hideTagPrefixLevels: number | ||
editMode: boolean | ||
saving: boolean | ||
} |
Oops, something went wrong.