Skip to content

Commit

Permalink
refactor: use monorepo tools
Browse files Browse the repository at this point in the history
  • Loading branch information
hazimoarafa committed Nov 16, 2024
1 parent 69820fc commit d7bdfa5
Show file tree
Hide file tree
Showing 16 changed files with 7,345 additions and 7,480 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ui-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: actions/setup-node@v4
with:
cache: npm
cache-dependency-path: ui/package-lock.json
cache-dependency-path: package-lock.json
node-version: 20

- name: Installing Dependencies
Expand Down
13 changes: 7 additions & 6 deletions ui/.gitignore → .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
node_modules/
.pnp/
.pnp.js
.yarn/install-state.gz

# testing
/coverage
coverage/

# next.js
/.next/
/out/
.next/
out/

# production
/build
build/
dist/

# misc
.DS_Store
Expand Down
2 changes: 0 additions & 2 deletions api-client/.gitignore

This file was deleted.

51 changes: 25 additions & 26 deletions api-client/LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Apache License
==============
# Apache License

_Version 2.0, January 2004_
_&lt;<http://www.apache.org/licenses/>&gt;_
Expand Down Expand Up @@ -89,27 +88,27 @@ You may reproduce and distribute copies of the Work or Derivative Works thereof
in any medium, with or without modifications, and in Source or Object form,
provided that You meet the following conditions:

* **(a)** You must give any other recipients of the Work or Derivative Works a copy of
this License; and
* **(b)** You must cause any modified files to carry prominent notices stating that You
changed the files; and
* **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
all copyright, patent, trademark, and attribution notices from the Source form
of the Work, excluding those notices that do not pertain to any part of the
Derivative Works; and
* **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
Derivative Works that You distribute must include a readable copy of the
attribution notices contained within such NOTICE file, excluding those notices
that do not pertain to any part of the Derivative Works, in at least one of the
following places: within a NOTICE text file distributed as part of the
Derivative Works; within the Source form or documentation, if provided along
with the Derivative Works; or, within a display generated by the Derivative
Works, if and wherever such third-party notices normally appear. The contents of
the NOTICE file are for informational purposes only and do not modify the
License. You may add Your own attribution notices within Derivative Works that
You distribute, alongside or as an addendum to the NOTICE text from the Work,
provided that such additional attribution notices cannot be construed as
modifying the License.
- **(a)** You must give any other recipients of the Work or Derivative Works a copy of
this License; and
- **(b)** You must cause any modified files to carry prominent notices stating that You
changed the files; and
- **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
all copyright, patent, trademark, and attribution notices from the Source form
of the Work, excluding those notices that do not pertain to any part of the
Derivative Works; and
- **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
Derivative Works that You distribute must include a readable copy of the
attribution notices contained within such NOTICE file, excluding those notices
that do not pertain to any part of the Derivative Works, in at least one of the
following places: within a NOTICE text file distributed as part of the
Derivative Works; within the Source form or documentation, if provided along
with the Derivative Works; or, within a display generated by the Derivative
Works, if and wherever such third-party notices normally appear. The contents of
the NOTICE file are for informational purposes only and do not modify the
License. You may add Your own attribution notices within Derivative Works that
You distribute, alongside or as an addendum to the NOTICE text from the Work,
provided that such additional attribution notices cannot be construed as
modifying the License.

You may add Your own copyright statement to Your modifications and may provide
additional or different license terms and conditions for use, reproduction, or
Expand Down Expand Up @@ -180,13 +179,13 @@ the same “printed page” as the copyright notice for easier identification wi
third-party archives.

Copyright 2024 Little Horse Enterprises LLC.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down
4 changes: 2 additions & 2 deletions api-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { LittleHorseUserTasksApiClient } from "@littlehorse-enterprises/user-tas
const client = new LittleHorseUserTasksApiClient({
baseUrl: "http://localhost:8089",
tenantId: "default",
accessToken: "your-oauth-access-token",
accessToken: "your-oauth-access-token",
});

// List user tasks with pagination
Expand Down Expand Up @@ -88,7 +88,7 @@ type ListUserTasksResponse = {
user?: User;
}>;
bookmark: string | null;
}
};
```

## API Methods
Expand Down
48 changes: 0 additions & 48 deletions api-client/package-lock.json

This file was deleted.

50 changes: 30 additions & 20 deletions api-client/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
{
"name": "@littlehorse-enterprises/user-tasks-api-client",
"version": "0.11.7",
"description": "Node.js client for LittleHorse User Tasks API",
"license": "Apache-2.0",
"author": "LittleHorse Enterprises",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsc",
"prepublishOnly": "npm run build"
},
"keywords": [
"littlehorse",
"workflow",
"user-tasks"
],
"devDependencies": {
"@types/node": "^22.9.0",
"typescript": "^5.6.3"
}
"name": "@littlehorse-enterprises/user-tasks-api-client",
"homepage": "https://github.com/littlehorse-enterprises/lh-user-tasks",
"bugs": "https://github.com/littlehorse-enterprises/lh-user-tasks/issues",
"version": "0.11.2",
"description": "Node.js client for LittleHorse User Tasks API",
"license": "Apache-2.0",
"author": "LittleHorse Enterprises",
"repository": {
"type": "git",
"url": "https://github.com/littlehorse-enterprises/lh-user-tasks.git"
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"dev": "tsc --watch",
"build": "tsc",
"lint": "prettier --check .",
"lint:fix": "prettier --write .",
"prepublishOnly": "npm run build"
},
"keywords": [
"littlehorse",
"workflow",
"user-tasks"
],
"devDependencies": {
"@types/node": "^22.9.0",
"prettier": "^3.3.3",
"typescript": "^5.6.3"
}
}
40 changes: 24 additions & 16 deletions api-client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,33 @@ export class LittleHorseUserTasksApiClient {
throw new UnauthorizedError(errorMessage);
case 403:
// Check if error is related to task state
if (errorMessage.includes('DONE')) {
throw new TaskStateError("Cannot modify a task that is already completed");
} else if (errorMessage.includes('CANCELLED')) {
throw new TaskStateError("Cannot modify a task that has been cancelled");
if (errorMessage.includes("DONE")) {
throw new TaskStateError(
"Cannot modify a task that is already completed",
);
} else if (errorMessage.includes("CANCELLED")) {
throw new TaskStateError(
"Cannot modify a task that has been cancelled",
);
}
throw new ForbiddenError(errorMessage);
case 404:
throw new NotFoundError(errorMessage);
case 412:
// Check if error is related to assignment
if (errorMessage.includes('assign') || errorMessage.includes('claim')) {
if (
errorMessage.includes("assign") ||
errorMessage.includes("claim")
) {
throw new AssignmentError(errorMessage);
}
throw new PreconditionFailedError(errorMessage);
case 400:
throw new ValidationError(errorMessage);
default:
throw new LHUserTasksError(`HTTP error ${response.status}: ${response}`);
throw new LHUserTasksError(
`HTTP error ${response.status}: ${response}`,
);
}
}

Expand All @@ -97,7 +106,7 @@ export class LittleHorseUserTasksApiClient {
} else if (!contentType && response.status === 204) {
// Handle no-content responses explicitly
return undefined as T;
}
}
return response as T;
}

Expand All @@ -106,11 +115,11 @@ export class LittleHorseUserTasksApiClient {
const contentType = response.headers.get("content-type");
if (contentType && contentType.includes("application/json")) {
const errorData = await response.json();
return errorData.detail || errorData.message || 'Unknown error';
return errorData.detail || errorData.message || "Unknown error";
}
return await response.text();
} catch {
return 'Unknown error';
return "Unknown error";
}
}

Expand Down Expand Up @@ -149,8 +158,8 @@ export class LittleHorseUserTasksApiClient {
.map(([key, value]) => [
key,
// Ensure value is properly encoded for URLs
encodeURIComponent(value.toString().trim())
])
encodeURIComponent(value.toString().trim()),
]),
);
const searchParams = new URLSearchParams(filteredSearch);

Expand Down Expand Up @@ -254,14 +263,13 @@ export class LittleHorseUserTasksApiClient {
.map(([key, value]) => [
key,
// Ensure value is properly encoded for URLs
encodeURIComponent(value.toString().trim())
])
encodeURIComponent(value.toString().trim()),
]),
);
const searchParams = new URLSearchParams(filteredSearch);
return await this.fetch(`/admin/taskTypes?${searchParams.toString()}`);
}


/**
* Administrative method to get a user task
* @param userTask The user task to get the details of
Expand All @@ -287,8 +295,8 @@ export class LittleHorseUserTasksApiClient {
.map(([key, value]) => [
key,
// Ensure value is properly encoded for URLs
encodeURIComponent(value.toString().trim())
])
encodeURIComponent(value.toString().trim()),
]),
);
const searchParams = new URLSearchParams(filteredSearch);

Expand Down
Loading

0 comments on commit d7bdfa5

Please sign in to comment.