Skip to content
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
.env.development.local
.env.test.local
.env.production.local
*.tsbuildinfo

npm-debug.log*
yarn-debug.log*
Expand Down
52 changes: 49 additions & 3 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"stream-browserify": "^3.0.0",
"style-loader": "^3.3.4",
"terser-webpack-plugin": "^5.3.14",
"tldts": "^6.1.86",
"ts-pnp": "1.2.0",
"typescript": "4.9.5",
"url": "^0.11.4",
Expand Down
4 changes: 2 additions & 2 deletions src/_shared/hooks/useRunMutation/useRunMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const useRunMutation = () => {
options: any,
message?: string,
successCallback?: (data?: any) => void,
errorCallback?: () => void,
errorCallback?: (error?: Error) => void,
refetch?: any,
): void => {
mutateFunction(options)
Expand All @@ -39,7 +39,7 @@ export const useRunMutation = () => {

// execute any additional actions, i.e. hiding the edit form
if (errorCallback) {
errorCallback();
errorCallback(error);
}
});
};
Expand Down
135 changes: 132 additions & 3 deletions src/api/generatedTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,13 @@ export type CreateApprovedCorpusItemInput = {
language: CorpusLanguage;
/** The GUID of the corresponding Prospect ID. Will be empty for manually added items. */
prospectId?: InputMaybe<Scalars['ID']>;
/** The name of the online publication that published this story. */
publisher: Scalars['String'];
/**
* The name of the online publication that published this story.
* If not provided, it will be derived from the PublisherDomain table
* (looking up by subdomain first, then registrable domain),
* falling back to the URL's hostname if no match is found.
*/
publisher?: InputMaybe<Scalars['String']>;
/** Optionally, specify the date this item should be appearing on a Scheduled Surface. Format: YYYY-MM-DD */
scheduledDate?: InputMaybe<Scalars['Date']>;
/** Optionally, specify the source of the Scheduled Item. Could be one of: MANUAL or ML */
Expand Down Expand Up @@ -637,6 +642,19 @@ export type CreateCustomSectionInput = {
title: Scalars['String'];
};

/** Input data for creating or updating a publisher domain mapping. */
export type CreateOrUpdatePublisherDomainInput = {
/**
* The domain name (hostname only, not a full URL).
* Will be sanitized: trimmed, lowercased, converted to ASCII (punycode), www. prefix stripped.
* Must be a registrable domain (e.g., "example.com") or subdomain (e.g., "news.example.com").
* Cannot be a public suffix (e.g., "co.uk"), IP address, or wildcard.
*/
domainName: Scalars['String'];
/** The display name for the publisher. Will be trimmed but case is preserved. */
publisher: Scalars['String'];
};

/** Input data for creating a Section */
export type CreateOrUpdateSectionInput = {
/** Indicates whether or not a Section is available for display. */
Expand Down Expand Up @@ -1212,6 +1230,14 @@ export type Mutation = {
createCustomSection: Section;
/** Creates a Label. */
createLabel: Label;
/**
* Creates or updates a publisher domain mapping.
* If a mapping for the domain already exists, updates the publisher name.
* Otherwise, creates a new mapping.
* Domain names are sanitized (trimmed, lowercased, converted to ASCII, www. stripped)
* and validated before storage.
*/
createOrUpdatePublisherDomain: PublisherDomain;
/**
* Creates a new Section entity. If a Section already exists, the existing
* Section gets updated, associated active SectionItems are set to in-active.
Expand Down Expand Up @@ -1356,6 +1382,10 @@ export type MutationCreateLabelArgs = {
name: Scalars['String'];
};

export type MutationCreateOrUpdatePublisherDomainArgs = {
data: CreateOrUpdatePublisherDomainInput;
};

export type MutationCreateOrUpdateSectionArgs = {
data: CreateOrUpdateSectionInput;
};
Expand Down Expand Up @@ -1660,6 +1690,30 @@ export enum ProspectType {
TopSaved = 'TOP_SAVED',
}

/**
* A mapping between a domain name and its publisher display name.
* Used to auto-populate the publisher field when creating corpus items.
*/
export type PublisherDomain = {
__typename?: 'PublisherDomain';
/** A Unix timestamp of when the entity was created. */
createdAt: Scalars['Int'];
/** A single sign-on user identifier of the user who created this entity. */
createdBy: Scalars['String'];
/**
* The domain name (hostname). This is the unique identifier.
* Stored normalized: lowercase, ASCII (punycode), without www. prefix.
* Can be a registrable domain (e.g., "example.com") or subdomain (e.g., "news.example.com").
*/
domainName: Scalars['String'];
/** The display name for the publisher. */
publisher: Scalars['String'];
/** A Unix timestamp of when the entity was last updated. */
updatedAt: Scalars['Int'];
/** A single sign-on user identifier of the user who last updated this entity. Null on creation. */
updatedBy?: Maybe<Scalars['String']>;
};

export type Query = {
__typename?: 'Query';
/** Retrieves an approved item with the given external ID. */
Expand Down Expand Up @@ -1710,7 +1764,7 @@ export type Query = {
getScheduledSurfacesForUser: Array<ScheduledSurface>;
/** Retrieves a list of active and enabled/disabled Sections with their corresponding active SectionItems for a scheduled surface. */
getSectionsWithSectionItems: Array<Section>;
/** returns parser meta data for a given url */
/** returns meta data for a given url */
getUrlMetadata: UrlMetadata;
/** Look up Item info by a url. */
itemByUrl?: Maybe<Item>;
Expand Down Expand Up @@ -3371,6 +3425,23 @@ export type CreateLabelMutation = {
createLabel: { __typename?: 'Label'; externalId: string; name: string };
};

export type CreateOrUpdatePublisherDomainMutationVariables = Exact<{
data: CreateOrUpdatePublisherDomainInput;
}>;

export type CreateOrUpdatePublisherDomainMutation = {
__typename?: 'Mutation';
createOrUpdatePublisherDomain: {
__typename?: 'PublisherDomain';
domainName: string;
publisher: string;
createdAt: number;
createdBy: string;
updatedAt: number;
updatedBy?: string | null;
};
};

export type CreateScheduledCorpusItemMutationVariables = Exact<{
approvedItemExternalId: Scalars['ID'];
scheduledSurfaceGuid: Scalars['ID'];
Expand Down Expand Up @@ -6170,6 +6241,64 @@ export type CreateLabelMutationOptions = Apollo.BaseMutationOptions<
CreateLabelMutation,
CreateLabelMutationVariables
>;
export const CreateOrUpdatePublisherDomainDocument = gql`
mutation createOrUpdatePublisherDomain(
$data: CreateOrUpdatePublisherDomainInput!
) {
createOrUpdatePublisherDomain(data: $data) {
domainName
publisher
createdAt
createdBy
updatedAt
updatedBy
}
}
`;
export type CreateOrUpdatePublisherDomainMutationFn = Apollo.MutationFunction<
CreateOrUpdatePublisherDomainMutation,
CreateOrUpdatePublisherDomainMutationVariables
>;

/**
* __useCreateOrUpdatePublisherDomainMutation__
*
* To run a mutation, you first call `useCreateOrUpdatePublisherDomainMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useCreateOrUpdatePublisherDomainMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
*
* @example
* const [createOrUpdatePublisherDomainMutation, { data, loading, error }] = useCreateOrUpdatePublisherDomainMutation({
* variables: {
* data: // value for 'data'
* },
* });
*/
export function useCreateOrUpdatePublisherDomainMutation(
baseOptions?: Apollo.MutationHookOptions<
CreateOrUpdatePublisherDomainMutation,
CreateOrUpdatePublisherDomainMutationVariables
>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useMutation<
CreateOrUpdatePublisherDomainMutation,
CreateOrUpdatePublisherDomainMutationVariables
>(CreateOrUpdatePublisherDomainDocument, options);
}
export type CreateOrUpdatePublisherDomainMutationHookResult = ReturnType<
typeof useCreateOrUpdatePublisherDomainMutation
>;
export type CreateOrUpdatePublisherDomainMutationResult =
Apollo.MutationResult<CreateOrUpdatePublisherDomainMutation>;
export type CreateOrUpdatePublisherDomainMutationOptions =
Apollo.BaseMutationOptions<
CreateOrUpdatePublisherDomainMutation,
CreateOrUpdatePublisherDomainMutationVariables
>;
export const CreateScheduledCorpusItemDocument = gql`
mutation createScheduledCorpusItem(
$approvedItemExternalId: ID!
Expand Down
19 changes: 19 additions & 0 deletions src/api/mutations/createOrUpdatePublisherDomain.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { gql } from '@apollo/client';

/**
* Create or update a publisher domain mapping
*/
export const createOrUpdatePublisherDomain = gql`
mutation createOrUpdatePublisherDomain(
$data: CreateOrUpdatePublisherDomainInput!
) {
createOrUpdatePublisherDomain(data: $data) {
domainName
publisher
createdAt
createdBy
updatedAt
updatedBy
}
}
`;
Loading