Skip to content

Commit

Permalink
Merge pull request #9 from ClicknClear/event-sync
Browse files Browse the repository at this point in the history
Event sync
  • Loading branch information
TristanBarlow authored Oct 21, 2024
2 parents dd63eeb + 52ce8bc commit 77595a0
Show file tree
Hide file tree
Showing 10 changed files with 1,147 additions and 14 deletions.
8 changes: 8 additions & 0 deletions docs/apis/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [1.0.4](https://github.com/clicknclear/API-Documentation/compare/@clicknclear/[email protected]...@clicknclear/[email protected]) (2024-10-21)

**Note:** Version bump only for package @clicknclear/apis





## [1.0.3](https://github.com/ClicknClear/Public-Resources/compare/@clicknclear/[email protected]...@clicknclear/[email protected]) (2024-10-10)

**Note:** Version bump only for package @clicknclear/apis
Expand Down
316 changes: 313 additions & 3 deletions docs/apis/Main.postman_collection.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/apis/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@clicknclear/apis",
"version": "1.0.3",
"version": "1.0.4",
"description": "",
"private": true,
"scripts": {
Expand Down
760 changes: 759 additions & 1 deletion docs/apis/swagger-docs.yml

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions packages/lvs-types/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [1.0.4](https://github.com/ClicknClear/Public-Resources/compare/@clicknclear/[email protected]...@clicknclear/[email protected]) (2024-10-21)

**Note:** Version bump only for package @clicknclear/lvs-types-public





## [1.0.3](https://github.com/ClicknClear/Public-Resources/compare/@clicknclear/[email protected]...@clicknclear/[email protected]) (2024-10-10)

**Note:** Version bump only for package @clicknclear/lvs-types-public
Expand Down
2 changes: 1 addition & 1 deletion packages/lvs-types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@clicknclear/lvs-types-public",
"version": "1.0.3",
"version": "1.0.4",
"description": "A collection of shared public types for the License Verification Platform",
"main": "build/lib",
"module": "build/es",
Expand Down
36 changes: 33 additions & 3 deletions packages/lvs-types/src/v1/event.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,38 @@
import { z } from 'zod';
import { paginationBaseV1 } from './pagination';
import { ISignupFieldV1 } from './signupField';
import { zParsedNumber } from './zodHelpers';

export interface IEventV1 {
id: number
name: string
title: string
/**
* ISO Date String.
*/
startDate: string
inviteURL: string | null
/**
* ISO Date String.
*/
endDate: string
territories: string[]
inviteURL: string | null
/**
* ISO Territory codes to check licenses against in this event. https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
* null if the event venue address has not been set
*/
territory: string | null
/**
* if isLocked is true Team/Athletes will no longer be able to signup
*/
isLocked: boolean
organisationId: number
signupFields: ISignupFieldV1[]
}

export type GetEventsQueryV1 = z.infer<typeof getEventsQuerySchemaV1>
/**
* Used to query events via the GET Events API endpoint
*/
export const getEventsQuerySchemaV1 = paginationBaseV1.extend({
//If undefined, all events will be fetched
organisationId: zParsedNumber().optional()
});
7 changes: 7 additions & 0 deletions packages/lvs-types/src/v1/pagination.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { z } from 'zod';
import { zParsedNumber } from './zodHelpers';

export const paginationBaseV1 = z.object({
limit: zParsedNumber(z.number().max(100)).default(25).optional(),
offset: zParsedNumber().default(0).optional()
});
5 changes: 2 additions & 3 deletions packages/lvs-types/src/v1/verificationJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { z } from 'zod';
import { zParsedDate } from './zodHelpers';
import { ISoundRecordingVerificationV1 } from './soundRecording';
import { LicenseSourceV1 } from './license';
import { paginationBaseV1 } from './pagination';

/**
* The current status of the verification job.
Expand Down Expand Up @@ -132,11 +133,9 @@ export interface IVerificationJobStatusUpdateV1 {
* @param offset Paginiation offset. Optional. If specified, 'limit' must also be passed.
*/
export type VerificationJobTagSearchV1 = z.infer<typeof verificationJobTagSearchSchemaV1>
export const verificationJobTagSearchSchemaV1 = z.object({
export const verificationJobTagSearchSchemaV1 = paginationBaseV1.extend({
tags: z.string().array().min(1).max(100),
statuses: z.nativeEnum(VerificationJobStatusV1).array().optional(),
limit: z.number().max(100).default(25).optional(),
offset: z.number().default(0).optional()
});

export interface VerificationJobTagSearchResultsV1 {
Expand Down
17 changes: 15 additions & 2 deletions packages/lvs-types/src/v1/zodHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isDate, isString } from 'lodash';
import { z, ZodDate } from 'zod';
import { isDate, isNumber, isString } from 'lodash';
import { z, ZodDate, ZodNumber } from 'zod';

export const zParsedDate = (dateSchema: ZodDate = z.date()) => z.union([ z.string(), z.date() ])
.superRefine((val: string | Date, ctx) => {
Expand All @@ -13,3 +13,16 @@ export const zParsedDate = (dateSchema: ZodDate = z.date()) => z.union([ z.strin
validationResult.error.issues.forEach(issue => ctx.addIssue(issue));
}
}).transform((val: string | Date) => isString(val) ? new Date(val) : val);

export const zParsedNumber = (numberSchema: ZodNumber = z.number()) => z.union([ numberSchema, z.string() ])
.superRefine((val: string | number, ctx) => {
if (isNumber(val)) return;

const numericalVal = parseFloat(val);
const validationResult = numberSchema.safeParse(numericalVal);

// Must be === false for type narrowing purposes
if (validationResult.success === false) {
validationResult.error.issues.forEach((issue) => ctx.addIssue(issue));
}
}).transform((val: string | number) => isString(val) ? parseFloat(val) : val);

0 comments on commit 77595a0

Please sign in to comment.