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

Support field type #3

Merged
merged 10 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from 7 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
5 changes: 5 additions & 0 deletions .changeset/brave-pears-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@forgerock/davinci-client': minor
---

adding support for fields in DROPDOWN, CHECKBOX, COMBOBOX, RADIO, FLOW_LINK.
5 changes: 3 additions & 2 deletions .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
}
],
"commit": false,
"fixed": [],
"fixed": [["@forgerock/*"]],
"privatePackages": false,
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": [
"@forgerock/*",
"@forgerock/mock-api-v2",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryanbas21 I'm sure you didn't intend to change this to something else?

"@forgerock/davinci-app",
"@forgerock/davinci-suites",
"@forgerock/mock-api-v2"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}

- name: Send GitHub Action data to a Slack workflow
if: steps.changesets.outputs.published === 'true'
if: steps.changesets.outputs.published == 'true'
uses: slackapi/[email protected]
with:
payload-delimiter: '_'
Expand Down
17 changes: 17 additions & 0 deletions contributing_docs/testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Testing

## Testing Types

You can test types using vitest. It's important to note that testing types does not actually _run_ a test file.

When you test types, these are statically analyzed by the compiler.

Vitest defaults state that all files matching `*.test-d.ts` are considered type-tests

From the vitest docs:

```
Under the hood Vitest calls tsc or vue-tsc, depending on your config, and parses results. Vitest will also print out type errors in your source code, if it finds any. You can disable it with typecheck.ignoreSourceErrors config option.

Keep in mind that Vitest doesn't run these files, they are only statically analyzed by the compiler. Meaning, that if you use a dynamic name or test.each or test.for, the test name will not be evaluated - it will be displayed as is.
```
2 changes: 1 addition & 1 deletion e2e/davinci-app/components/flow-link.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FlowCollector, InitFlow } from '@forgerock/davinci-client/types';
import type { FlowCollector, InitFlow } from '@forgerock/davinci-client/types';

export default function flowLinkComponent(
formEl: HTMLFormElement,
Expand Down
2 changes: 1 addition & 1 deletion e2e/davinci-app/components/password.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PasswordCollector, Updater } from '@forgerock/davinci-client/types';
import type { PasswordCollector, Updater } from '@forgerock/davinci-client/types';

export default function passwordComponent(
formEl: HTMLFormElement,
Expand Down
2 changes: 1 addition & 1 deletion e2e/davinci-app/components/protect.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TextCollector, Updater } from '@forgerock/davinci-client/types';
import type { TextCollector, Updater } from '@forgerock/davinci-client/types';

export default function (formEl: HTMLFormElement, collector: TextCollector, updater: Updater) {
// create paragraph element with text of "Loading ... "
Expand Down
2 changes: 1 addition & 1 deletion e2e/davinci-app/components/social-login-button.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SocialLoginCollector } from '@forgerock/davinci-client/types';
import type { SocialLoginCollector } from '@forgerock/davinci-client/types';

export default function submitButtonComponent(
formEl: HTMLFormElement,
Expand Down
2 changes: 1 addition & 1 deletion e2e/davinci-app/components/submit-button.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SubmitCollector } from '@forgerock/davinci-client/types';
import type { SubmitCollector } from '@forgerock/davinci-client/types';

export default function submitButtonComponent(formEl: HTMLFormElement, collector: SubmitCollector) {
const button = document.createElement('button');
Expand Down
2 changes: 1 addition & 1 deletion e2e/davinci-app/components/text.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TextCollector, Updater } from '@forgerock/davinci-client/types';
import type { TextCollector, Updater } from '@forgerock/davinci-client/types';

export default function usernameComponent(
formEl: HTMLFormElement,
Expand Down
5 changes: 4 additions & 1 deletion e2e/davinci-app/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
{
"name": "@forgerock/davinci-app",
"version": "0.0.0",
"description": "Ping DaVinci Client Test App",
"type": "module",
"private": true,
"nx": {
"tags": ["scope:app"]
},
"dependencies": {
"@forgerock/davinci-client": "workspace:*",
"@forgerock/javascript-sdk": "4.6.0"
},
"devDependencies": {},
"version": "0.0.0",
"scripts": {
"build": "nx exec -- vite build --watch false",
"serve": "vite dev",
Expand Down
4 changes: 2 additions & 2 deletions e2e/davinci-app/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"outDir": "../../dist/out-tsc",
"moduleResolution": "Bundler"
},
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts"],
"include": ["src/**/*.ts"]
"exclude": ["**/*.spec.ts", "**/*.test.ts"],
"include": ["./main.ts", "components/**/*.ts"]
}
2 changes: 2 additions & 0 deletions e2e/davinci-app/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"lib": ["ESNext", "DOM"],
"strict": true,
"resolveJsonModule": true,
"moduleDetection": "force",
"verbatimModuleSyntax": true,
"isolatedModules": true,
"esModuleInterop": true,
"noUnusedLocals": true,
Expand Down
3 changes: 3 additions & 0 deletions e2e/davinci-suites/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"main": "src/index.js",
"author": "",
"license": "ISC",
"nx": {
"implicitDependencies": ["@forgerock/davinci-app", "@forgerock/mock-api-v2"]
},
"repository": {
"type": "git",
"url": "git+https://github.com/ForgeRock/ping-javascript-sdk.git"
Expand Down
1 change: 1 addition & 0 deletions e2e/mock-api-v2/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "@forgerock/mock-api-v2",
"private": true,
"version": "1.0.0",
"description": "",
"main": "./dist/index.js",
Expand Down
8 changes: 7 additions & 1 deletion e2e/mock-api-v2/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
"types": ["node"],
"exactOptionalPropertyTypes": true,
"strictNullChecks": true,
"noErrorTruncation": true
"noErrorTruncation": true,
"skipLibCheck": true,
"plugins": [
{
"name": "@effect/language-service"
}
]
},
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts"],
"include": ["src/**/*.ts"]
Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
"@commitlint/cli": "^19.1.0",
"@commitlint/config-conventional": "^19.1.0",
"@commitlint/prompt": "^19.1.0",
"@effect/language-service": "^0.1.0",
"@effect/platform": "^0.58.27",
"@effect/platform-node": "^0.53.26",
"@effect/schema": "^0.68.23",
"@effect/vitest": "^0.6.7",
"@effect/language-service": "^0.2.0",
"@effect/platform": "^0.72.1",
"@effect/platform-node": "^0.68.1",
"@effect/schema": "^0.75.5",
"@effect/vitest": "^0.16.1",
"@forgerock/create-package": "workspace:*",
"@nx/devkit": "20.2.2",
"@nx/eslint": "20.2.2",
Expand All @@ -69,14 +69,14 @@
"@typescript-eslint/parser": "7.16.1",
"@typescript-eslint/typescript-estree": "5.59.5",
"@typescript-eslint/utils": "^8.13.0",
"@vitest/coverage-v8": "^1.5.0",
"@vitest/ui": "^1.4.0",
"@vitest/coverage-v8": "^2.1.8",
"@vitest/ui": "^2.1.8",
"conventional-changelog-conventionalcommits": "^7.0.2",
"cz-conventional-changelog": "^3.3.0",
"cz-git": "^1.6.1",
"effect": "^3.5.3",
"effect-http": "^0.73.0",
"effect-http-node": "^0.16.1",
"effect-http": "0.73.0",
"effect-http-node": "0.24.0",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-import": "2.27.5",
Expand Down Expand Up @@ -107,7 +107,7 @@
"vite-plugin-eslint": "^1.8.1",
"vite-plugin-externalize-deps": "^0.8.0",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.4.0",
"vitest": "^2.1.8",
"vitest-canvas-mock": "^0.3.3"
},
"config": {
Expand Down
8 changes: 5 additions & 3 deletions packages/davinci-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"typings": "./dist/index.d.ts",
"type": "module",
"files": ["dist"],
"sideEffects": ["./src/types.js"],
"nx": {
"tags": ["scope:package"]
},
"repository": {
"type": "git",
"url": "git+https://github.com:ForgeRock/forgerock-javascript-sdk.git",
Expand All @@ -19,9 +23,6 @@
"@reduxjs/toolkit": "catalog:",
"immer": "catalog:"
},
"devDependencies": {
"vitest": "^1.4.0"
},
"exports": {
".": {
"import": "./dist/index.js",
Expand All @@ -31,6 +32,7 @@
},
"scripts": {
"build": "nx exec -- vite build",
"serve": "nx exec -- vite dev",
"test": "vitest",
"test:watch": "vitest --watch",
"test:coverage": "vitest --coverage",
Expand Down
13 changes: 11 additions & 2 deletions packages/davinci-client/src/lib/client.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ export async function davinci({ config }: { config: DaVinciConfig }) {
if (!action.action) {
console.error('Missing `argument.action`');
return async function () {
return { error: { message: 'Missing argument.action', type: 'argument_error' } };
return {
error: { message: 'Missing argument.action', type: 'argument_error' },
type: 'internal_error',
};
};
}

Expand Down Expand Up @@ -107,6 +110,7 @@ export async function davinci({ config }: { config: DaVinciConfig }) {
return function () {
return {
error: { message: 'Argument for `collector` has no ID', type: 'argument_error' },
type: 'internal_error',
};
};
}
Expand All @@ -118,6 +122,7 @@ export async function davinci({ config }: { config: DaVinciConfig }) {
return function () {
console.error('Collector not found');
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obviously this was here, just want to make sure we want a console.error

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we should probably talk about this. Ultimately, I think it's good we log errors when they happen, but we probably need to add a control for this sometime soon (like logLevel). And, we should be consistent with it. I think some instances of errors we don't log with error.

return {
type: 'internal_error',
error: { message: 'Collector not found', type: 'state_error' },
};
};
Expand All @@ -127,6 +132,7 @@ export async function davinci({ config }: { config: DaVinciConfig }) {
console.error('Collector is not a SingleValueCollector and cannot be updated');
return function () {
return {
type: 'internal_error',
error: {
message: 'Collector is not a SingleValueCollector and cannot be updated',
type: 'state_error',
Expand All @@ -141,7 +147,10 @@ export async function davinci({ config }: { config: DaVinciConfig }) {
return null;
} catch (err) {
const error = err as Error;
return { error: { message: error.message, type: 'internal_error' } };
return {
type: 'internal_error',
error: { message: error.message, type: 'internal_error' },
};
}
};
},
Expand Down
Loading
Loading