Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TM-1531] add job service url and script #734

Merged
merged 7 commits into from
Dec 19, 2024
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
4 changes: 2 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ const userSentryWebpackPluginOptions = {
// Suppresses source map uploading logs during build
silent: true,

org: process.env.SENTRY_ORG || "3-sided-cube",
project: process.env.SENTRY_PROJECT || "wri-web-platform-version-2",
org: process.env.SENTRY_ORG ?? "wri-terramatch",
project: process.env.SENTRY_PROJECT ?? "terramatch-frontend",
authToken: process.env.SENTRY_AUTH_TOKEN
};

Expand Down
8 changes: 8 additions & 0 deletions openapi-codegen.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,39 @@ type EnvironmentName = (typeof ENVIRONMENT_NAMES)[number];
type Environment = {
apiBaseUrl: string;
userServiceUrl: string;
jobServiceUrl: string;
entityServiceUrl: string;
};

const ENVIRONMENTS: { [Property in EnvironmentName]: Environment } = {
local: {
apiBaseUrl: "http://localhost:8080",
userServiceUrl: "http://localhost:4010",
jobServiceUrl: "http://localhost:4020",
entityServiceUrl: "http://localhost:4050"
},
dev: {
apiBaseUrl: "https://api-dev.terramatch.org",
userServiceUrl: "https://api-dev.terramatch.org",
jobServiceUrl: "https://api-dev.terramatch.org",
entityServiceUrl: "https://api-dev.terramatch.org"
},
test: {
apiBaseUrl: "https://api-test.terramatch.org",
userServiceUrl: "https://api-test.terramatch.org",
jobServiceUrl: "https://api-test.terramatch.org",
entityServiceUrl: "https://api-test.terramatch.org"
},
staging: {
apiBaseUrl: "https://api-staging.terramatch.org",
userServiceUrl: "https://api-staging.terramatch.org",
jobServiceUrl: "https://api-staging.terramatch.org",
entityServiceUrl: "https://api-staging.terramatch.org"
},
prod: {
apiBaseUrl: "https://api.terramatch.org",
userServiceUrl: "https://api.terramatch.org",
jobServiceUrl: "https://api.terramatch.org",
entityServiceUrl: "https://api.terramatch.org"
}
};
Expand All @@ -66,6 +72,7 @@ if (!ENVIRONMENT_NAMES.includes(declaredEnv as EnvironmentName)) {
const DEFAULTS = ENVIRONMENTS[declaredEnv];
const apiBaseUrl = process.env.NEXT_PUBLIC_API_BASE_URL ?? DEFAULTS.apiBaseUrl;
const userServiceUrl = process.env.NEXT_PUBLIC_USER_SERVICE_URL ?? DEFAULTS.userServiceUrl;
const jobServiceUrl = process.env.NEXT_PUBLIC_JOB_SERVICE_URL ?? DEFAULTS.jobServiceUrl;
const entityServiceUrl = process.env.NEXT_PUBLIC_ENTITY_SERVICE_URL ?? DEFAULTS.entityServiceUrl;

// The services defined in the v3 Node BE codebase. Although the URL path for APIs in the v3 space
Expand All @@ -74,6 +81,7 @@ const entityServiceUrl = process.env.NEXT_PUBLIC_ENTITY_SERVICE_URL ?? DEFAULTS.
// the associated BE code is for a given FE API integration.
const SERVICES = {
"user-service": userServiceUrl,
"job-service": jobServiceUrl,
"entity-service": entityServiceUrl
};

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"generate:api": "openapi-codegen gen api",
"generate:jobService": "openapi-codegen gen jobService",
"generate:userService": "openapi-codegen gen userService",
"generate:entityService": "openapi-codegen gen entityService",
"generate:services": "yarn generate:userService && yarn generate:entityService",
"generate:services": "yarn generate:userService && yarn generate:entityService && yarn generate:jobService",
"tx:push": "eval $(grep '^TRANSIFEX_TOKEN' .env) && eval $(grep '^TRANSIFEX_SECRET' .env) && txjs-cli push --key-generator=hash src/ --token=$TRANSIFEX_TOKEN --secret=$TRANSIFEX_SECRET",
"tx:pull": "eval $(grep '^TRANSIFEX_TOKEN' .env) && eval $(grep '^TRANSIFEX_SECRET' .env) && txjs-cli pull --token=$TRANSIFEX_TOKEN --secret=$TRANSIFEX_SECRET"
},
Expand Down
203 changes: 203 additions & 0 deletions src/generated/v3/jobService/jobServiceComponents.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
/**
* Generated by @openapi-codegen
*
* @version 1.0
*/
import type * as Fetcher from "./jobServiceFetcher";
import { jobServiceFetch } from "./jobServiceFetcher";
import type * as Schemas from "./jobServiceSchemas";

export type ListDelayedJobsError = Fetcher.ErrorWrapper<{
status: 401;
payload: {
/**
* @example 401
*/
statusCode: number;
/**
* @example Unauthorized
*/
message: string;
/**
* @example Unauthorized
*/
error?: string;
};
}>;

export type ListDelayedJobsResponse = {
data?: {
/**
* @example delayedJobs
*/
type?: string;
/**
* @format uuid
*/
id?: string;
attributes?: Schemas.DelayedJobDto;
};
};

/**
* Retrieve a list of all delayed jobs.
*/
export const listDelayedJobs = (signal?: AbortSignal) =>
jobServiceFetch<ListDelayedJobsResponse, ListDelayedJobsError, undefined, {}, {}, {}>({
url: "/jobs/v3/delayedJobs",
method: "get",
signal
});

export type DelayedJobsFindPathParams = {
uuid: string;
};

export type DelayedJobsFindError = Fetcher.ErrorWrapper<
| {
status: 401;
payload: {
/**
* @example 401
*/
statusCode: number;
/**
* @example Unauthorized
*/
message: string;
/**
* @example Unauthorized
*/
error?: string;
};
}
| {
status: 404;
payload: {
/**
* @example 404
*/
statusCode: number;
/**
* @example Not Found
*/
message: string;
/**
* @example Not Found
*/
error?: string;
};
}
>;

export type DelayedJobsFindResponse = {
data?: {
/**
* @example delayedJobs
*/
type?: string;
/**
* @format uuid
*/
id?: string;
attributes?: Schemas.DelayedJobDto;
};
};

export type DelayedJobsFindVariables = {
pathParams: DelayedJobsFindPathParams;
};

/**
* Get the current status and potentially payload or error from a delayed job.
*/
export const delayedJobsFind = (variables: DelayedJobsFindVariables, signal?: AbortSignal) =>
jobServiceFetch<DelayedJobsFindResponse, DelayedJobsFindError, undefined, {}, {}, DelayedJobsFindPathParams>({
url: "/jobs/v3/delayedJobs/{uuid}",
method: "get",
...variables,
signal
});

export type BulkUpdateJobsError = Fetcher.ErrorWrapper<
| {
status: 400;
payload: {
/**
* @example 400
*/
statusCode: number;
/**
* @example Bad Request
*/
message: string;
/**
* @example Bad Request
*/
error?: string;
};
}
| {
status: 401;
payload: {
/**
* @example 401
*/
statusCode: number;
/**
* @example Unauthorized
*/
message: string;
/**
* @example Unauthorized
*/
error?: string;
};
}
| {
status: 404;
payload: {
/**
* @example 404
*/
statusCode: number;
/**
* @example Not Found
*/
message: string;
/**
* @example Not Found
*/
error?: string;
};
}
>;

export type BulkUpdateJobsResponse = {
data?: {
/**
* @example delayedJobs
*/
type?: string;
/**
* @format uuid
*/
id?: string;
attributes?: Schemas.DelayedJobDto;
};
};

export type BulkUpdateJobsVariables = {
body: Schemas.DelayedJobBulkUpdateBodyDto;
};

/**
* Accepts a JSON:API-compliant payload to bulk update jobs, allowing each job's isAcknowledged attribute to be set to true or false.
*/
export const bulkUpdateJobs = (variables: BulkUpdateJobsVariables, signal?: AbortSignal) =>
jobServiceFetch<BulkUpdateJobsResponse, BulkUpdateJobsError, Schemas.DelayedJobBulkUpdateBodyDto, {}, {}, {}>({
url: "/jobs/v3/delayedJobs/bulk-update",
method: "patch",
...variables,
signal
});
6 changes: 6 additions & 0 deletions src/generated/v3/jobService/jobServiceFetcher.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This type is imported in the auto generated `jobServiceComponents` file, so it needs to be
// exported from this file.
export type { ErrorWrapper } from "../utils";

// The serviceFetch method is the shared fetch method for all service fetchers.
export { serviceFetch as jobServiceFetch } from "../utils";
26 changes: 26 additions & 0 deletions src/generated/v3/jobService/jobServicePredicates.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { isFetching, fetchFailed } from "../utils";
import { ApiDataStore } from "@/store/apiSlice";
import { DelayedJobsFindPathParams, DelayedJobsFindVariables } from "./jobServiceComponents";

export const listDelayedJobsIsFetching = (store: ApiDataStore) =>
isFetching<{}, {}>({ store, url: "/jobs/v3/delayedJobs", method: "get" });

export const listDelayedJobsFetchFailed = (store: ApiDataStore) =>
fetchFailed<{}, {}>({ store, url: "/jobs/v3/delayedJobs", method: "get" });

export const delayedJobsFindIsFetching = (variables: DelayedJobsFindVariables) => (store: ApiDataStore) =>
isFetching<{}, DelayedJobsFindPathParams>({ store, url: "/jobs/v3/delayedJobs/{uuid}", method: "get", ...variables });

export const delayedJobsFindFetchFailed = (variables: DelayedJobsFindVariables) => (store: ApiDataStore) =>
fetchFailed<{}, DelayedJobsFindPathParams>({
store,
url: "/jobs/v3/delayedJobs/{uuid}",
method: "get",
...variables
});

export const bulkUpdateJobsIsFetching = (store: ApiDataStore) =>
isFetching<{}, {}>({ store, url: "/jobs/v3/delayedJobs/bulk-update", method: "patch" });

export const bulkUpdateJobsFetchFailed = (store: ApiDataStore) =>
fetchFailed<{}, {}>({ store, url: "/jobs/v3/delayedJobs/bulk-update", method: "patch" });
71 changes: 71 additions & 0 deletions src/generated/v3/jobService/jobServiceSchemas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* Generated by @openapi-codegen
*
* @version 1.0
*/
export type DelayedJobDto = {
/**
* The current status of the job. If the status is not pending, the payload and statusCode will be provided.
*/
status: "pending" | "failed" | "succeeded";
/**
* If the job is out of pending state, this is the HTTP status code for the completed process
*/
statusCode: number | null;
/**
* If the job is out of pending state, this is the JSON payload for the completed process
*/
payload: Record<string, any> | null;
/**
* If the job is in progress, this is the total content to process
*/
totalContent: number | null;
/**
* If the job is in progress, this is the total content processed
*/
processedContent: number | null;
/**
* If the job is in progress, this is the progress message
*/
progressMessage: string | null;
/**
* Indicates whether the jobs have been acknowledged (cleared)
*/
isAcknowledged: boolean | null;
};

export type DelayedJobAttributes = {
/**
* Value to set for isAcknowledged
*
* @example true
*/
isAcknowledged: boolean;
};

export type DelayedJobData = {
/**
* Type of the resource
*
* @example delayedJobs
*/
type: "delayedJobs";
/**
* UUID of the job
*
* @format uuid
* @example uuid-1
*/
uuid: string;
/**
* Attributes to update for the job
*/
attributes: DelayedJobAttributes;
};

export type DelayedJobBulkUpdateBodyDto = {
/**
* List of jobs to update isAcknowledged
*/
data: DelayedJobData[];
};
Loading
Loading