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

Export additional TypeScript types #27

Merged
merged 3 commits into from
Oct 16, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: ci
on: push

env:
NODE_VERSION: 20.12.2
NODE_VERSION: 22.9.0
PNPM_VERSION: 9

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nodejs 20.12.2
nodejs 22.9.0
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "parallelmarkets",
"private": true,
"version": "2.1.1",
"version": "2.1.2",
"description": "ParallelMarkets.com JavaScript SDK loading utility",
"scripts": {
"build": "pnpm --filter '@parallelmarkets/*' build",
Expand All @@ -16,13 +16,13 @@
"license": "MIT",
"homepage": "https://developer.parallelmarkets.com/docs/javascript",
"devDependencies": {
"globals": "^15.0.0",
"eslint": "^9.12.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-n": "^17.11.1",
"eslint-plugin-promise": "^7.1.0",
"globals": "^15.11.0",
"jest": "^29.7.0",
"rollup": "^4.16.2",
"eslint": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^17.2.1",
"eslint-plugin-promise": "^6.1.1",
"eslint-config-prettier": "^9.1.0"
"rollup": "^4.24.0"
}
}
6 changes: 6 additions & 0 deletions packages/react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v2.1.2 (2024-10-10)

### Changed

- Update dependency @parallelmarkets/vanilla to version 2.1.2

## v2.1.1 (2024-05-02)

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@parallelmarkets/react",
"version": "2.1.1",
"version": "2.1.2",
"description": "ParallelMarkets.com React SDK",
"author": "Parallel Markets (https://parallelmarkets.com)",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/react/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { babel } from '@rollup/plugin-babel'
import pkg from './package.json' assert { type: 'json' }
import pkg from './package.json' with { type: 'json' }
import image from '@rollup/plugin-image'
import typescript from '@rollup/plugin-typescript'
import replace from '@rollup/plugin-replace'
Expand Down
10 changes: 10 additions & 0 deletions packages/vanilla/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## v2.1.2 (2024-10-10)

### Fixed

- The `OAuthErrorCode` TypeScript type now includes a previously missing value 'access_denied'

### Enhancements

- Some previously unexported TypeScript types are now exported

## v2.1.1 (2024-05-02)

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion packages/vanilla/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@parallelmarkets/vanilla",
"version": "2.1.1",
"version": "2.1.2",
"description": "ParallelMarkets.com JavaScript SDK loading utility",
"author": "Parallel Markets (https://parallelmarkets.com)",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/vanilla/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { babel } from '@rollup/plugin-babel'
import pkg from './package.json' assert { type: 'json' }
import pkg from './package.json' with { type: 'json' }
import typescript from '@rollup/plugin-typescript'
import replace from '@rollup/plugin-replace'

Expand Down
2 changes: 2 additions & 0 deletions packages/vanilla/src/__tests__/index-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ global.window.Parallel = {
hideButton: () => null,
subscribeWithButton: () => null,
_appendLoadContext: () => null,
_codeVersion: 'test',
api: () => null,
get _config() {
return window.config
},
Expand Down
28 changes: 18 additions & 10 deletions packages/vanilla/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ export type BusinessType =
| 'Limited Liability Company'
| 'Limited Partnership'

/* eslint-disable @typescript-eslint/no-explicit-any */
type AuthResponse = {
export type AuthResponse = {
access_token: string
token_type: 'bearer'
expires_in: number
Expand Down Expand Up @@ -50,6 +49,7 @@ export type ParallelConfig = (EmbedParallelConfig | OverlayRedirectParallelConfi
identity_claim_override_id?: number
verbose?: boolean
on_init?: () => void
// eslint-disable-next-line @typescript-eslint/no-explicit-any
raw_config?: Record<string, any>
}

Expand Down Expand Up @@ -77,24 +77,25 @@ export type ProfileApiResponse = {
available_scopes: Array<ParallelScope>
}

type GetProfileSuccessCallbackFunc = (_result: ProfileApiResponse) => void
export type GetProfileSuccessCallbackFunc = (_result: ProfileApiResponse) => void

type GetProfileFailureCallbackFunc = (_result: { error: unknown }) => void
export type GetProfileFailureCallbackFunc = (_result: { error: unknown }) => void

type AuthSuccessCallbackFunc = (_result: AuthCallbackResult) => void
export type AuthSuccessCallbackFunc = (_result: AuthCallbackResult) => void

type AuthFailureCallbackFunc = (_result: { error: unknown }) => void
export type AuthFailureCallbackFunc = (_result: { error: unknown }) => void

type SubscribeEvents = 'auth.login' | 'auth.logout' | 'auth.statusChange' | 'auth.authResponseChange'
export type SubscribeEvents = 'auth.login' | 'auth.logout' | 'auth.statusChange' | 'auth.authResponseChange'

type OAuthErrorCode =
export type OAuthErrorCode =
| 'invalid_request'
| 'invalid_client'
| 'invalid_grant'
| 'unauthorized_client'
| 'unsupported_grant_type'
| 'access_denied'

type SubscriptionEvent = {
export type SubscriptionEvent = {
status: 'not_authorized' | 'unknown' | 'connected'
error?: OAuthErrorCode
errorDescription?: string
Expand All @@ -107,7 +108,7 @@ type SubscriptionEvent = {
}
}

type SubscriptionHandler = (_response: SubscriptionEvent) => void
export type SubscriptionHandler = (_response: SubscriptionEvent) => void

export interface LoginOptions {
email?: string
Expand All @@ -123,6 +124,11 @@ export interface LoginOptions {
required_entity_id?: string
}

// In this case, the object param should be the result of parsing JSON
export type RawApiCallback = (_json: object) => void

export type RawApiErrback = (_err: Error) => void

export interface Parallel {
init(_options: ParallelConfig): void
getLoginStatus: (_callback: AuthSuccessCallbackFunc) => void
Expand All @@ -134,6 +140,8 @@ export interface Parallel {
showButton: () => void
hideButton: () => void
subscribeWithButton: (_successFunc: AuthSuccessCallbackFunc, _errorFunc: AuthFailureCallbackFunc) => void
api: (_path: string, _successFunc: RawApiCallback, _errorFunc: RawApiErrback) => void
_codeVersion: string
_appendLoadContext: (_context: string) => void
_config: ParallelConfig
}
Expand Down
Loading