Skip to content
Draft
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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
136 changes: 136 additions & 0 deletions built-types/genericLenses.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
export type ScSLike<TEventSeriesFields, TSessionSeriesFields> = {
type: 'ScheduledSession';
superEvent: {
superEvent: TEventSeriesFields;
} & TSessionSeriesFields;
};
export type SlotNoIfuLike<TFacilityUseFields> = {
type: 'Slot';
facilityUse: {
type: 'FacilityUse';
} & TFacilityUseFields;
};
export type SlotIfuLike<TFacilityUseFields> = {
type: 'Slot';
facilityUse: {
type: 'IndividualFacilityUse';
facilityUse: {
type: 'FacilityUse';
} & TFacilityUseFields;
};
};
export type SlotLike<TFacilityUseFields> = SlotNoIfuLike<TFacilityUseFields> | SlotIfuLike<TFacilityUseFields>;
/**
* @template TEventSeriesFields
* @template TSessionSeriesFields
* @typedef {{
* type: 'ScheduledSession',
* superEvent: {
* superEvent: TEventSeriesFields
* } & TSessionSeriesFields,
* }} ScSLike
*/
/**
* @template TFacilityUseFields
* @typedef {{
* type: 'Slot',
* facilityUse: {
* type: 'FacilityUse',
* } & TFacilityUseFields,
* }} SlotNoIfuLike
*/
/**
* @template TFacilityUseFields
* @typedef {{
* type: 'Slot',
* facilityUse: {
* type: 'IndividualFacilityUse',
* facilityUse: {
* type: 'FacilityUse',
* } & TFacilityUseFields,
* }
* }} SlotIfuLike
*/
/**
* @template TFacilityUseFields
* @typedef {SlotNoIfuLike<TFacilityUseFields> | SlotIfuLike<TFacilityUseFields>} SlotLike
*/
/**
* @template {SlotLike<any>} TSlot
* @param {string[]} propertyPath
* @returns {import('ramda').Lens<TSlot, any>}
*/
export function createSlotLensForFacilityUseProperty<TSlot extends SlotLike<any>>(propertyPath: string[]): R.Lens<TSlot, any>;
/**
* @template {ScSLike<any, any>} TScS
* @template {SlotLike<any>} TSlot
* @param {{
* scs?: import('ramda').Lens<TScS, any>,
* slot?: import('ramda').Lens<TSlot, any>
* }} lensByOpportunityType
*/
export function opportunityTypeLens<TScS extends ScSLike<any, any>, TSlot extends SlotLike<any>>(lensByOpportunityType: {
scs?: R.Lens<TScS, any> | undefined;
slot?: R.Lens<TSlot, any> | undefined;
}): R.Lens<TScS | TSlot, any>;
export namespace genericLenses {
export { createSellerLens };
export { createNameLens };
export { createLocationSummaryLens };
export { createLocationLens };
}
import R = require("ramda");
/**
* @template TSeller
* @template {ScSLike<{ organizer?: TSeller }, any> | SlotLike<{ provider?: TSeller }>} TOpportunity
* @returns {import('ramda').Lens<TOpportunity, TSeller>}
*/
declare function createSellerLens<TSeller, TOpportunity extends ScSLike<{
organizer?: TSeller | undefined;
}, any> | SlotLike<{
provider?: TSeller | undefined;
}>>(): R.Lens<TOpportunity, TSeller>;
/**
* @template {string | null | undefined} TName
* @template {ScSLike<{ name?: TName }, any> | SlotLike<{ name?: TName }>} TOpportunity
* @returns {import('ramda').Lens<TOpportunity, TName>}
*/
declare function createNameLens<TName extends string | null | undefined, TOpportunity extends ScSLike<{
name?: TName | undefined;
}, any> | SlotLike<{
name?: TName | undefined;
}>>(): R.Lens<TOpportunity, TName>;
/**
* Lens for the Opportunity's Place. For ScheduledSessions, this searches imin:locationSummary.
* Therefore, this is the function to use when dealing with Opportunities that have come from imin
* Search.
*
* Pre-condition:
* - The EventSeries, if it has a location summary, only has one item which has
* the same location as the ScheduledSession's SessionSeries.
* I believe this is how the Search ScS by-id endpoint works.
*
* @template TPlace
* @template {ScSLike<{ 'imin:locationSummary'?: TPlace[] }, any> | SlotLike<{ location?: TPlace }>} TOpportunity
* @returns {import('ramda').Lens<TOpportunity, TPlace>}
*/
declare function createLocationSummaryLens<TPlace, TOpportunity extends ScSLike<{
'imin:locationSummary'?: TPlace[] | undefined;
}, any> | SlotLike<{
location?: TPlace | undefined;
}>>(): R.Lens<TOpportunity, TPlace>;
/**
* Lens for the Opportunity's Place. For ScheduledSessions, this searches SessionSeries location.
* Therefore, this is the function to use when dealing with Opportunities that have come from an
* OpenActive Data Source.
*
* @template TPlace
* @template {ScSLike<any, { location?: TPlace }> | SlotLike<{ location?: TPlace }>} TOpportunity
* @returns {import('ramda').Lens<TOpportunity, TPlace>}
*/
declare function createLocationLens<TPlace, TOpportunity extends ScSLike<any, {
location?: TPlace | undefined;
}> | SlotLike<{
location?: TPlace | undefined;
}>>(): R.Lens<TOpportunity, TPlace>;
export {};
3 changes: 2 additions & 1 deletion built-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import { validateReq } from "./expressUtils";
import { validateReqQuery } from "./expressUtils";
import { getHerokuReleaseInfo } from "./herokuUtils";
import { Lenses } from "./lenses";
import { genericLenses } from "./genericLenses";
export declare namespace expressUtils {
export { validateReq };
export { validateReqQuery };
}
export declare namespace herokuUtils {
export { getHerokuReleaseInfo };
}
export { logger, kongSecretMiddleware, postgres, syncDbMigrations, Lenses };
export { logger, kongSecretMiddleware, postgres, syncDbMigrations, Lenses, genericLenses };
20 changes: 10 additions & 10 deletions built-types/lenses.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export type SearchIsBookingRequestFacilityUseSlotType = import('@imin/shared-data-types/src/search/SearchIsBookingRequestFacilityUseSlot').SearchIsBookingRequestFacilityUseSlotType;
export type BsBookableScheduledSessionType = import('@imin/shared-data-types/src/booking/BsBookableScheduledSession').BsBookableScheduledSessionType;
export type GetSlotByIdResponseType = import('@imin/shared-data-types/src/booking/GetSlotByIdResponse').GetSlotByIdResponseType;
export type TOpportunity = SearchIsBookingRequestFacilityUseSlotType | BsBookableScheduledSessionType | GetSlotByIdResponseType;
export type Opportunity = SearchIsBookingRequestFacilityUseSlotType | BsBookableScheduledSessionType | GetSlotByIdResponseType;
/**
* // even though this is from the ScS, the FacilityUsePlace is exactly the same model
*/
Expand All @@ -10,15 +10,15 @@ export type Organizer = import('@imin/shared-data-types/src/modellingSpec/common
export type OfferType = import('@imin/shared-data-types/src/modellingSpec/common').OfferType;
export type SearchIsBookingRequestFacilityUseType = import('@imin/shared-data-types/src/search/SearchIsBookingRequestFacilityUseSlot').SearchIsBookingRequestFacilityUseType;
export namespace Lenses {
const seller: import('ramda').Lens<TOpportunity, Organizer>;
const providerId: import('ramda').Lens<TOpportunity, string>;
const name: import('ramda').Lens<TOpportunity, string>;
const place: import('ramda').Lens<TOpportunity, PlaceType>;
const facilityUse: import('ramda').Lens<TOpportunity, SearchIsBookingRequestFacilityUseType>;
const offers: import('ramda').Lens<TOpportunity, OfferType[]>;
const aggregateOffer: R.Lens<TOpportunity, any>;
const remainingCapacity: import('ramda').Lens<TOpportunity, number>;
const maxCapacity: import('ramda').Lens<TOpportunity, number>;
const seller: R.Lens<Opportunity, import("@imin/shared-data-types/src/modellingSpec/common").OrganizerType>;
const providerId: import('ramda').Lens<Opportunity, string>;
const name: R.Lens<Opportunity, string>;
const place: R.Lens<Opportunity, import("@imin/shared-data-types/src/booking/BsBookableScheduledSession").LocationSummaryLocationType>;
const facilityUse: import('ramda').Lens<Opportunity, SearchIsBookingRequestFacilityUseType>;
const offers: import('ramda').Lens<Opportunity, OfferType[]>;
const aggregateOffer: R.Lens<import("@imin/shared-data-types/src/search/SearchIsBookingRequestFacilityUseSlot").SearchIsBookingRequestFacilityUseSlotType | import("@imin/shared-data-types/src/booking/BsBookableScheduledSession").BsBookableScheduledSessionType | import("@imin/shared-data-types/src/booking/GetSlotByIdResponse").GetSlotByIdResponseType, any>;
const remainingCapacity: import('ramda').Lens<Opportunity, number>;
const maxCapacity: import('ramda').Lens<Opportunity, number>;
namespace util {
const throwErrorIfUsed: import('ramda').Lens<any, any>;
}
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@types/node": "^14.14.19",
"@types/pg": "^7.14.7",
"axios": "^0.25.0",
"typescript": "^4.2.4"
"typescript": "^4.7.4"
},
"engines": {
"node": ">=14.15.0",
Expand Down
Loading