Skip to content

Commit

Permalink
Export additional TypeScript types (#27)
Browse files Browse the repository at this point in the history
* Export additional TypeScript types

* import json in rollup via with statement

* Update packages/react/CHANGELOG.md

Co-authored-by: Cameron Kurth <[email protected]>

---------

Co-authored-by: Cameron Kurth <[email protected]>
  • Loading branch information
bmuller and Cameron-Kurth authored Oct 16, 2024
1 parent 63f95c1 commit 6fc2e9e
Show file tree
Hide file tree
Showing 12 changed files with 838 additions and 262 deletions.
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

0 comments on commit 6fc2e9e

Please sign in to comment.