Skip to content

Commit

Permalink
fix(modules): re-export types, conform to *Schema convention (#795)
Browse files Browse the repository at this point in the history
Pre-typebox, we exported all interfaces & types, actually because this was
required for schema generation.  Now that we don't need that anymore,
whether or not we should do this in the longterm is a conversation that
deserves merit, however, since some users make sure of these exports, we
need to export them all to avoid it being a breaking change.

In `quoteSummmary-iface.ts`, renamed the schemas to have a *Schema suffix
and exported types without that suffix, like in other modules.  Similar
small change like that in `quoteSummary.ts` too.

cc: @eddie-atkinson
  • Loading branch information
gadicc committed Sep 17, 2024
1 parent 94430d8 commit 4269556
Show file tree
Hide file tree
Showing 13 changed files with 321 additions and 191 deletions.
10 changes: 5 additions & 5 deletions src/modules/chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,15 @@ const ChartOptionsWithReturnObjectSchema = Type.Composite(
},
);

type ChartOptions = Static<typeof ChartOptionsSchema>;
type ChartOptionsWithReturnObject = Static<
export type ChartOptions = Static<typeof ChartOptionsSchema>;
export type ChartOptionsWithReturnObject = Static<
typeof ChartOptionsWithReturnObjectSchema
>;
type ChartResultObject = Static<typeof ChartResultObjectSchema>;
type ChartOptionsWithReturnArray = Static<
export type ChartResultObject = Static<typeof ChartResultObjectSchema>;
export type ChartOptionsWithReturnArray = Static<
typeof ChartOptionsWithReturnArraySchema
>;
type ChartResultArray = Static<typeof ChartResultArraySchema>;
export type ChartResultArray = Static<typeof ChartResultArraySchema>;

const queryOptionsDefaults: Omit<ChartOptions, "period1"> = {
useYfid: true,
Expand Down
4 changes: 2 additions & 2 deletions src/modules/dailyGainers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ const DailyGainersResultSchema = Type.Object(
{ title: "DailyGainersResult" },
);

type DailyGainersResult = Static<typeof DailyGainersResultSchema>;
type DailyGainersOptions = Static<typeof DailyGainersOptionsSchema>;
export type DailyGainersResult = Static<typeof DailyGainersResultSchema>;
export type DailyGainersOptions = Static<typeof DailyGainersOptionsSchema>;

const queryOptionsDefaults = {
lang: "en-US",
Expand Down
4 changes: 2 additions & 2 deletions src/modules/fundamentalsTimeSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ const FundamentalsTimeSeriesOptionsSchema = Type.Object(
},
);

type FundamentalsTimeSeriesOptions = Static<
export type FundamentalsTimeSeriesOptions = Static<
typeof FundamentalsTimeSeriesOptionsSchema
>;

const FundamentalsTimeSeriesResultsSchema = Type.Array(
FundamentalsTimeSeriesResultSchema,
);

type FundamentalsTimeSeriesResult = Static<
export type FundamentalsTimeSeriesResult = Static<
typeof FundamentalsTimeSeriesResultSchema
>;

Expand Down
18 changes: 11 additions & 7 deletions src/modules/historical.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,24 @@ const HistoricalStockSplitsResultSchema = Type.Array(HistoricalRowStockSplit, {
title: "HistoricalRowStockSplit",
});

type HistoricalOptions = Static<typeof HistoricalOptionsSchema>;
type HistoricalOptionsEventsHistory = Static<
export type HistoricalOptions = Static<typeof HistoricalOptionsSchema>;
export type HistoricalOptionsEventsHistory = Static<
typeof HistoricalOptionsEventsHistorySchema
>;

type HistoricalHistoryResult = Static<typeof HistoricalHistoryResultSchema>;
type HistoricalDividendsResult = Static<typeof HistoricalDividendsResultSchema>;
type HistoricalOptionsEventsDividends = Static<
export type HistoricalHistoryResult = Static<
typeof HistoricalHistoryResultSchema
>;
export type HistoricalDividendsResult = Static<
typeof HistoricalDividendsResultSchema
>;
export type HistoricalOptionsEventsDividends = Static<
typeof HistoricalOptionsEventsDividendsSchema
>;
type HistoricalOptionsEventsSplit = Static<
export type HistoricalOptionsEventsSplit = Static<
typeof HistoricalOptionsEventsSplitSchema
>;
type HistoricalStockSplitsResult = Static<
export type HistoricalStockSplitsResult = Static<
typeof HistoricalStockSplitsResultSchema
>;

Expand Down
6 changes: 3 additions & 3 deletions src/modules/insights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ const InsightsResultSchema = Type.Object(
},
);

type InsightsResult = Static<typeof InsightsResultSchema>;
type InsightsOutlook = Static<typeof InsightsOutlookSchema>;
export type InsightsResult = Static<typeof InsightsResultSchema>;
export type InsightsOutlook = Static<typeof InsightsOutlookSchema>;

export interface InsightsInstrumentInfo {
[key: string]: any;
Expand Down Expand Up @@ -298,7 +298,7 @@ const InsightsOptionsSchema = Type.Object(
{ title: "InsightsOptions" },
);

type InsightsOptions = Static<typeof InsightsOptionsSchema>;
export type InsightsOptions = Static<typeof InsightsOptionsSchema>;

const queryOptionsDefaults = {
lang: "en-US",
Expand Down
4 changes: 2 additions & 2 deletions src/modules/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ const OptionsOptionsSchema = Type.Object(
},
);

type OptionsOptions = Static<typeof OptionsOptionsSchema>;
type OptionsResult = Static<typeof OptionsResultSchema>;
export type OptionsOptions = Static<typeof OptionsOptionsSchema>;
export type OptionsResult = Static<typeof OptionsResultSchema>;

const queryOptionsDefaults: OptionsOptions = {
formatted: false,
Expand Down
14 changes: 8 additions & 6 deletions src/modules/quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ const ResultType = Type.Union([

const QuoteResponseArraySchema = Type.Array(QuoteSchema);

type QuoteResponseArray = Quote[];
type QuoteResponseMap = Map<string, Quote>;
type QuoteResponseObject = { [key: string]: Quote };
export type QuoteResponseArray = Quote[];
export type QuoteResponseMap = Map<string, Quote>;
export type QuoteResponseObject = { [key: string]: Quote };

export const QuoteOptionsSchema = Type.Object({
fields: Type.Optional(Type.Array(QuoteField)),
Expand All @@ -270,13 +270,15 @@ const QuoteOptionsWithReturnObjectSchema = Type.Composite([
}),
]);

type QuoteOptionsWithReturnArray = Static<
export type QuoteOptionsWithReturnArray = Static<
typeof QuoteOptionsWithReturnArraySchema
>;

type QuoteOptionsWithReturnMap = Static<typeof QuoteOptionsWithReturnMapSchema>;
export type QuoteOptionsWithReturnMap = Static<
typeof QuoteOptionsWithReturnMapSchema
>;

type QuoteOptionsWithReturnObject = Static<
export type QuoteOptionsWithReturnObject = Static<
typeof QuoteOptionsWithReturnObjectSchema
>;

Expand Down
Loading

0 comments on commit 4269556

Please sign in to comment.