Skip to content

Commit

Permalink
Merge branch 'master' into feature/toggleable-shape-expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
lukehesluke authored Feb 21, 2024
2 parents 8ed19ec + 691f78f commit 611cbf0
Show file tree
Hide file tree
Showing 62 changed files with 5,375 additions and 1,289 deletions.
13 changes: 13 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@
"NODE_APP_INSTANCE": "dev"
},
},
{
"name": "test-interface-criteria - unit tests",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}/packages/test-interface-criteria/",
"runtimeArgs": [
"--inspect-brk",
"node_modules/.bin/jest",
"--runInBand"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
{
"name": "validate-feeds",
"type": "node",
Expand Down
6 changes: 6 additions & 0 deletions packages/openactive-broker-microservice/package-lock.json

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

6 changes: 6 additions & 0 deletions packages/openactive-integration-tests/package-lock.json

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

2 changes: 2 additions & 0 deletions packages/test-interface-criteria/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
module.exports = {
extends: 'airbnb-base',
plugins: ['jest'],
env: {
node: true,
'jest/globals': true,
},
globals: {
expectAsync: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export type DateTime = any;
export type Opportunity = import('../types/Opportunity').Opportunity;
export type Offer = import('../types/Offer').Offer;
export type Options = import('../types/Options').Options;
Expand Down Expand Up @@ -76,7 +75,7 @@ export function remainingCapacityMustBeAtLeastTwo(opportunity: import("../types/
export function mustRequireAttendeeDetails(offer: import("../types/Offer").Offer, opportunity?: import("../types/Opportunity").Opportunity, options?: import("../types/Options").Options): boolean;
export function mustNotRequireAttendeeDetails(offer: import("../types/Offer").Offer, opportunity?: import("../types/Opportunity").Opportunity, options?: import("../types/Options").Options): boolean;
export function mustAllowProposalAmendment(offer: import("../types/Offer").Offer, opportunity?: import("../types/Opportunity").Opportunity, options?: import("../types/Options").Options): boolean;
export function startDateMustBe2HrsInAdvance(opportunity: import("../types/Opportunity").Opportunity, options?: import("../types/Options").Options): boolean;
export function startDateMustBeOver2HrsInAdvance(opportunity: import("../types/Opportunity").Opportunity, options?: import("../types/Options").Options): boolean;
export function endDateMustBeInThePast(opportunity: import("../types/Opportunity").Opportunity, options?: import("../types/Options").Options): boolean;
export function eventStatusMustNotBeCancelledOrPostponed(opportunity: import("../types/Opportunity").Opportunity, options?: import("../types/Options").Options): boolean;
export function mustNotBeOpenBookingInAdvanceUnavailable(offer: import("../types/Offer").Offer, opportunity?: import("../types/Opportunity").Opportunity, options?: import("../types/Options").Options): boolean;
Expand Down Expand Up @@ -112,3 +111,4 @@ export function extendTestDataShape(baseTestDataShape: TestDataShape, extraTestD
* @returns {Criteria['offerConstraints'][number]}
*/
export function createCriteriaOfferConstraint(name: string, constraint: OfferConstraint): Criteria['offerConstraints'][number];
import { DateTime } from "luxon/src/datetime";
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,10 @@ export namespace shapeConstraintRecipes {
'schema:price': import("./types/TestDataShape").NumericNodeConstraint;
'oa:openBookingPrepayment': import("./types/TestDataShape").OptionNodeConstraint<import("./types/TestDataShape").RequiredStatusType, "oa:RequiredStatusType">;
};
function startDateMustBe2HrsInAdvance(options: import("./types/Options").Options): {
'schema:startDate': import("./types/TestDataShape").DateRangeNodeConstraint;
};
function eventStatusMustNotBeCancelledOrPostponed(): {
'schema:eventStatus': import("./types/TestDataShape").OptionNodeConstraint<import("./types/TestDataShape").EventStatusType, "schema:EventStatusType">;
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ export type ValueType =
| 'schema:EventStatusType'
| 'schema:EventAttendanceModeEnumeration';

/**
* Specifies a value that must be one of a set of options.
* For example, an `eventStatus` field would be set up to only have
* one of the `schema:EventStatusType` options (e.g.
* `https://schema.org/EventCancelled`, etc)
*/
export interface OptionNodeConstraint<
/** TypeScript union of the types that this option can take */
TOptionType,
Expand All @@ -70,6 +76,10 @@ export interface OptionNodeConstraint<
allowNull?: true;
}

/**
* Similar to OptionNodeConstraint, but where the value must be an
* array. Each item in the array must be from the same set of options.
*/
export interface ArrayConstraint<
TArrayOf,
TValueType extends ValueType
Expand Down Expand Up @@ -106,6 +116,7 @@ export type TestDataNodeConstraint =

export type TestDataShapeOpportunityConstraints = {
'schema:startDate'?: DateRangeNodeConstraint;
'schema:endDate'?: DateRangeNodeConstraint;
/**
* "placeholder:remainingCapacity" is a stand-in for either remainingAttendeeCapacity (sessions)
* or remainingUses (facilities)
Expand All @@ -120,6 +131,9 @@ export type TestDataShapeOpportunityConstraints = {
'oa:taxMode'?: OptionNodeConstraint<TaxMode, 'oa:TaxMode'>;
'oa:isOpenBookingAllowed'?: BooleanNodeConstraint;
'schema:eventAttendanceMode'?: OptionNodeConstraint<EventAttendanceMode, 'schema:EventAttendanceModeEnumeration'>;
// note that the type isn't specified yet (it's a '@type': 'Terms' object) as
// we don't use includes/excludes rules for this field, so it's irrelevant.
'schema:termsOfService'?: ArrayConstraint<unknown, 'oa:Terms'>;
};

/**
Expand All @@ -138,12 +152,20 @@ export type TestDataShape = {
* can be null.
*/
'oa:validFromBeforeStartDate'?: DateRangeNodeConstraint;
/**
* Refers to the date calculated as `startDate - validThroughBeforeStartDate`.
* For this particular DateRangeNodeConstraint, `allowNull` refers to whether `validThroughBeforeStartDate`
* can be null.
*/
'oa:validThroughBeforeStartDate'?: DateRangeNodeConstraint;
'oa:openBookingInAdvance'?: OptionNodeConstraint<RequiredStatusType, 'oa:RequiredStatusType'>;
'oa:openBookingFlowRequirement'?: ArrayConstraint<OpenBookingFlowRequirement, 'oa:OpenBookingFlowRequirement'>;
/**
* Refers to the date calculated as `startDate - latestCancellationBeforeStartDate`.
* For this particular DateRangeNodeConstraint, `allowNull` refers to whether `latestCancellationBeforeStartDate`
* can be null.
*/
'oa:latestCancellationBeforeStartDate'?: NullNodeConstraint | DateRangeNodeConstraint;
'oa:allowCustomerCancellationFullRefund'?: BooleanNodeConstraint;
// note that the type isn't specified yet (it's a '@type': 'Terms' object) as
// we don't use includes/excludes rules for this field, so it's irrelevant.
'schema:termsOfService'?: ArrayConstraint<unknown, 'oa:Terms'>;
};
}
10 changes: 0 additions & 10 deletions packages/test-interface-criteria/built-types/utils/objUtils.d.ts

This file was deleted.

5 changes: 5 additions & 0 deletions packages/test-interface-criteria/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
testMatch: [
"**/test/**/*.js"
]
};
Loading

0 comments on commit 611cbf0

Please sign in to comment.