jfrog-workers 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/event/AFTER_BUILD_INFO_SAVE.ts +62 -0
- package/event/AFTER_CREATE.ts +19 -0
- package/event/AFTER_DOWNLOAD.ts +19 -0
- package/event/AFTER_MOVE.ts +19 -0
- package/event/BEFORE_DOWNLOAD.ts +33 -0
- package/event/BEFORE_UPLOAD.ts +36 -0
- package/event/commons.ts +109 -0
- package/index.ts +86 -0
- package/package.json +29 -0
- package/test/login.sh +9 -0
- package/test/package.json +11 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Status } from './commons';
|
|
2
|
+
|
|
3
|
+
export interface AfterBuildInfoSaveRequest {
|
|
4
|
+
/** Various immutable build run details */
|
|
5
|
+
build: DetailedBuildRun | undefined;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface DetailedBuildRun {
|
|
9
|
+
name: string;
|
|
10
|
+
number: string;
|
|
11
|
+
started: string;
|
|
12
|
+
buildAgent: string;
|
|
13
|
+
agent: string;
|
|
14
|
+
durationMillis: number;
|
|
15
|
+
principal: string;
|
|
16
|
+
artifactoryPrincipal: string;
|
|
17
|
+
url: string;
|
|
18
|
+
parentName: string;
|
|
19
|
+
parentNumber: string;
|
|
20
|
+
buildRepo: string;
|
|
21
|
+
modules: Module[];
|
|
22
|
+
releaseStatus: string;
|
|
23
|
+
promotionStatuses: PromotionStatus[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface Module {
|
|
27
|
+
id: string;
|
|
28
|
+
artifacts: Artifact[];
|
|
29
|
+
dependencies: Dependency[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface Artifact {
|
|
33
|
+
name: string;
|
|
34
|
+
type: string;
|
|
35
|
+
sha1: string;
|
|
36
|
+
sha256: string;
|
|
37
|
+
md5: string;
|
|
38
|
+
remotePath: string;
|
|
39
|
+
properties: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface Dependency {
|
|
43
|
+
id: string;
|
|
44
|
+
scopes: string;
|
|
45
|
+
requestedBy: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface PromotionStatus {
|
|
49
|
+
status: string;
|
|
50
|
+
comment: string;
|
|
51
|
+
repository: string;
|
|
52
|
+
timestamp: string;
|
|
53
|
+
user: string;
|
|
54
|
+
ciUser: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface AfterBuildInfoSaveResponse {
|
|
58
|
+
/** Message to print to the log, in case of an error it will be printed as a warning */
|
|
59
|
+
message: string;
|
|
60
|
+
/** Indicates whether worker execution succeeded or failed */
|
|
61
|
+
executionStatus: Status;
|
|
62
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Header, UploadMetadata, Status, UserContext } from './commons';
|
|
2
|
+
|
|
3
|
+
export interface AfterCreateRequest {
|
|
4
|
+
/** Various immutable upload metadata */
|
|
5
|
+
metadata:
|
|
6
|
+
| UploadMetadata
|
|
7
|
+
| undefined;
|
|
8
|
+
/** The immutable request headers */
|
|
9
|
+
headers: { [key: string]: Header };
|
|
10
|
+
/** The user context which sends the request */
|
|
11
|
+
userContext: UserContext | undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface AfterCreateResponse {
|
|
15
|
+
/** Message to print to the log, in case of an error it will be printed as a warning */
|
|
16
|
+
message: string;
|
|
17
|
+
/** Indicates whether worker execution succeeded or failed */
|
|
18
|
+
executionStatus?: Status;
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Header, DownloadMetadata, Status, UserContext } from './commons';
|
|
2
|
+
|
|
3
|
+
export interface AfterDownloadRequest {
|
|
4
|
+
/** Various immutable download metadata */
|
|
5
|
+
metadata:
|
|
6
|
+
| DownloadMetadata
|
|
7
|
+
| undefined;
|
|
8
|
+
/** The immutable request headers */
|
|
9
|
+
headers: { [key: string]: Header };
|
|
10
|
+
/** The user context which sends the request */
|
|
11
|
+
userContext: UserContext | undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface AfterDownloadResponse {
|
|
15
|
+
/** Message to print to the log, in case of an error it will be printed as a warning */
|
|
16
|
+
message: string;
|
|
17
|
+
/** Indicates whether worker execution succeeded or failed */
|
|
18
|
+
executionStatus?: Status;
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ArtifactProperties, UploadMetadata, RepoPath, Status, UserContext } from './commons';
|
|
2
|
+
|
|
3
|
+
export interface AfterMoveRequest {
|
|
4
|
+
/** Various immutable upload metadata */
|
|
5
|
+
metadata: UploadMetadata | undefined;
|
|
6
|
+
/** The immutable target repository path */
|
|
7
|
+
targetRepoPath: RepoPath | undefined;
|
|
8
|
+
/** The user context which sends the request */
|
|
9
|
+
userContext: UserContext | undefined;
|
|
10
|
+
/** The moved artifacts properties */
|
|
11
|
+
artifactProperties: { [key: string]: ArtifactProperties };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface AfterMoveResponse {
|
|
15
|
+
/** Message to print to the log, in case of an error it will be printed as a warning */
|
|
16
|
+
message: string;
|
|
17
|
+
/** Indicates whether worker execution succeeded or failed */
|
|
18
|
+
executionStatus?: Status;
|
|
19
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Header, DownloadMetadata, RepoPath, Status, UserContext } from './commons';
|
|
2
|
+
|
|
3
|
+
export interface BeforeDownloadRequest {
|
|
4
|
+
/** Various immutable download metadata */
|
|
5
|
+
metadata:
|
|
6
|
+
| DownloadMetadata
|
|
7
|
+
| undefined;
|
|
8
|
+
/** The immutable request headers */
|
|
9
|
+
headers: { [key: string]: Header };
|
|
10
|
+
/** The user context which sends the request */
|
|
11
|
+
userContext:
|
|
12
|
+
| UserContext
|
|
13
|
+
| undefined;
|
|
14
|
+
/** The response repoPath */
|
|
15
|
+
repoPath: RepoPath | undefined;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface BeforeDownloadResponse {
|
|
19
|
+
/** The instruction of how to proceed */
|
|
20
|
+
status: DownloadStatus;
|
|
21
|
+
/** Message to print to the log, in case of an error it will be printed as a warning */
|
|
22
|
+
message: string;
|
|
23
|
+
/** Indicates whether worker execution succeeded or failed */
|
|
24
|
+
executionStatus?: Status;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export enum DownloadStatus {
|
|
28
|
+
DOWNLOAD_UNSPECIFIED = 0,
|
|
29
|
+
DOWNLOAD_PROCEED = 1,
|
|
30
|
+
DOWNLOAD_STOP = 2,
|
|
31
|
+
DOWNLOAD_WARN = 3,
|
|
32
|
+
UNRECOGNIZED = -1,
|
|
33
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Header, RepoType, RepoPath, Status, UserContext, ArtifactProperties, UploadMetadata } from './commons';
|
|
2
|
+
|
|
3
|
+
export interface BeforeUploadRequest {
|
|
4
|
+
/** Various immutable upload metadata */
|
|
5
|
+
metadata:
|
|
6
|
+
| UploadMetadata
|
|
7
|
+
| undefined;
|
|
8
|
+
/** The immutable request headers */
|
|
9
|
+
headers: { [key: string]: Header };
|
|
10
|
+
/** The user context which sends the request */
|
|
11
|
+
userContext:
|
|
12
|
+
| UserContext
|
|
13
|
+
| undefined;
|
|
14
|
+
/** The properties of the request */
|
|
15
|
+
artifactProperties: { [key: string]: ArtifactProperties };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface BeforeUploadResponse {
|
|
19
|
+
/** The instruction of how to proceed */
|
|
20
|
+
status: UploadStatus;
|
|
21
|
+
/** Message to print to the log, in case of an error it will be printed as a warning */
|
|
22
|
+
message: string;
|
|
23
|
+
/** The modified repo path from the worker */
|
|
24
|
+
modifiedRepoPath:
|
|
25
|
+
| RepoPath
|
|
26
|
+
| undefined;
|
|
27
|
+
/** Indicates whether worker execution succeeded or failed */
|
|
28
|
+
executionStatus?: Status;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export enum UploadStatus {
|
|
32
|
+
UPLOAD_UNSPECIFIED = 0,
|
|
33
|
+
UPLOAD_PROCEED = 1,
|
|
34
|
+
UPLOAD_STOP = 2,
|
|
35
|
+
UPLOAD_WARN = 3,
|
|
36
|
+
}
|
package/event/commons.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
export interface Header {
|
|
2
|
+
value: string[];
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface UserContext {
|
|
6
|
+
/** The username or subject */
|
|
7
|
+
id: string;
|
|
8
|
+
/** Is the context an accessToken */
|
|
9
|
+
isToken: boolean;
|
|
10
|
+
/** The realm of the user */
|
|
11
|
+
realm: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface RepoPath {
|
|
15
|
+
/** The repo key */
|
|
16
|
+
key: string;
|
|
17
|
+
/** The path itself */
|
|
18
|
+
path: string;
|
|
19
|
+
/** The key:path combination */
|
|
20
|
+
id: string;
|
|
21
|
+
/** Is the path the root */
|
|
22
|
+
isRoot: boolean;
|
|
23
|
+
/** Is the path a folder */
|
|
24
|
+
isFolder: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export enum RepoType {
|
|
28
|
+
REPO_TYPE_UNSPECIFIED = 0,
|
|
29
|
+
REPO_TYPE_LOCAL = 1,
|
|
30
|
+
REPO_TYPE_REMOTE = 2,
|
|
31
|
+
REPO_TYPE_FEDERATED = 3,
|
|
32
|
+
UNRECOGNIZED = -1,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export enum Status {
|
|
36
|
+
STATUS_UNSPECIFIED = 0,
|
|
37
|
+
STATUS_SUCCESS = 4,
|
|
38
|
+
STATUS_FAIL = 2,
|
|
39
|
+
UNRECOGNIZED = -1,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface ArtifactProperties {
|
|
43
|
+
/** The property values */
|
|
44
|
+
value: string[];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface DownloadMetadata {
|
|
48
|
+
/** The repoPath object of the request */
|
|
49
|
+
repoPath:
|
|
50
|
+
| RepoPath
|
|
51
|
+
| undefined;
|
|
52
|
+
/** The original repo path in case a virtual repo is involved */
|
|
53
|
+
originalRepoPath:
|
|
54
|
+
| RepoPath
|
|
55
|
+
| undefined;
|
|
56
|
+
/** The file name from path */
|
|
57
|
+
name: string;
|
|
58
|
+
/** Is it a head request */
|
|
59
|
+
headOnly: boolean;
|
|
60
|
+
/** Is it a checksum request */
|
|
61
|
+
checksum: boolean;
|
|
62
|
+
/** Is it a recursive request */
|
|
63
|
+
recursive: boolean;
|
|
64
|
+
/** When a modification has occurred */
|
|
65
|
+
modificationTime: number;
|
|
66
|
+
/** Is it a directory request */
|
|
67
|
+
directoryRequest: boolean;
|
|
68
|
+
/** Is it a metadata request */
|
|
69
|
+
metadata: boolean;
|
|
70
|
+
/** Last modification time that occurred */
|
|
71
|
+
lastModified: number;
|
|
72
|
+
/** If a modification happened since the last modification time */
|
|
73
|
+
ifModifiedSince: number;
|
|
74
|
+
/** The url that points to artifactory */
|
|
75
|
+
servletContextUrl: string;
|
|
76
|
+
/** The request URI */
|
|
77
|
+
uri: string;
|
|
78
|
+
/** The client address */
|
|
79
|
+
clientAddress: string;
|
|
80
|
+
/** The resource path of the requested zip */
|
|
81
|
+
zipResourcePath: string;
|
|
82
|
+
/** Is the request a zip resource request */
|
|
83
|
+
zipResourceRequest: boolean;
|
|
84
|
+
/** should replace the head request with get */
|
|
85
|
+
replaceHeadRequestWithGet: boolean;
|
|
86
|
+
/** Repository type */
|
|
87
|
+
repoType: RepoType;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface UploadMetadata {
|
|
91
|
+
/** The repoPath object of the request */
|
|
92
|
+
repoPath:
|
|
93
|
+
| RepoPath
|
|
94
|
+
| undefined;
|
|
95
|
+
/** The deploy request content length */
|
|
96
|
+
contentLength: number;
|
|
97
|
+
/** Last modification time that occurred */
|
|
98
|
+
lastModified: number;
|
|
99
|
+
/** Is the request trusting the server checksums */
|
|
100
|
+
trustServerChecksums: boolean;
|
|
101
|
+
/** The url that points to artifactory */
|
|
102
|
+
servletContextUrl: string;
|
|
103
|
+
/** Is it a request that skips jar indexing */
|
|
104
|
+
skipJarIndexing: boolean;
|
|
105
|
+
/** Is redirect disabled on this request */
|
|
106
|
+
disableRedirect: boolean;
|
|
107
|
+
/** Repository type */
|
|
108
|
+
repoType: RepoType;
|
|
109
|
+
}
|
package/index.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Response returned by JFrog platform API
|
|
5
|
+
*/
|
|
6
|
+
export interface IPlatformHttpResponse {
|
|
7
|
+
/**
|
|
8
|
+
* Http status
|
|
9
|
+
*/
|
|
10
|
+
status: number;
|
|
11
|
+
/**
|
|
12
|
+
* Response headers
|
|
13
|
+
*/
|
|
14
|
+
headers: Record<string, string>;
|
|
15
|
+
/**
|
|
16
|
+
* Parsed response body
|
|
17
|
+
*/
|
|
18
|
+
data: any;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* PlatformHttpClient allows performing REST requests to JFrog platform APIs.
|
|
23
|
+
* The client encapsulates platform scheme, hostname and port. Client can add Authorization header with
|
|
24
|
+
* admin token and other additional headers (E.g. X-Jfrog-Tenant-Id header with proper tenant id in multi-tenant
|
|
25
|
+
* environment). User provides only the path for the request, body, http method, additional headers.
|
|
26
|
+
*/
|
|
27
|
+
export interface PlatformHttpClient {
|
|
28
|
+
/**
|
|
29
|
+
* Perform http GET request to JFrog platform
|
|
30
|
+
* @param {string} endpoint - API endpoint. E.g. /artifactory/api/repositories
|
|
31
|
+
* @param {Record<string, string>} headers - additional headers used in the request
|
|
32
|
+
*/
|
|
33
|
+
get(endpoint: string, headers?: Record<string, string>): Promise<IPlatformHttpResponse>;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Perform http POST request to JFrog platform
|
|
37
|
+
* @param {string} endpoint - API endpoint. E.g. /artifactory/api/repositories
|
|
38
|
+
* @param {any} requestData - data sent in request body
|
|
39
|
+
* @param {Record<string, string>} headers - additional headers used in the request
|
|
40
|
+
*/
|
|
41
|
+
post(endpoint: string, requestData?: any, headers?: Record<string, string>): Promise<IPlatformHttpResponse>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Perform http PUT request to JFrog platform
|
|
45
|
+
* @param {string} endpoint - API endpoint. E.g. /artifactory/api/repositories
|
|
46
|
+
* @param {any} requestData - data sent in request body
|
|
47
|
+
* @param {Record<string, string>} headers - additional headers used in the request
|
|
48
|
+
*/
|
|
49
|
+
put(endpoint: string, requestData?: any, headers?: Record<string, string>): Promise<IPlatformHttpResponse>;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Perform http PATCH request to JFrog platform
|
|
53
|
+
* @param {string} endpoint - API endpoint. E.g. /artifactory/api/repositories
|
|
54
|
+
* @param {any} requestData - data sent in request body
|
|
55
|
+
* @param {Record<string, string>} headers - additional headers used in the request
|
|
56
|
+
*/
|
|
57
|
+
patch(endpoint: string, requestData?: any, headers?: Record<string, string>): Promise<IPlatformHttpResponse>;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Perform http DELETE request to JFrog platform
|
|
61
|
+
* @param {string} endpoint - API endpoint. E.g. /artifactory/api/repositories
|
|
62
|
+
* @param {Record<string, string>} headers - additional headers used in the request
|
|
63
|
+
*/
|
|
64
|
+
delete(endpoint: string, headers?: Record<string, string>): Promise<IPlatformHttpResponse>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface PlatformClients {
|
|
68
|
+
platformHttp: PlatformHttpClient;
|
|
69
|
+
axios: Pick<AxiosInstance, 'get'|'put'|'post'|'delete'|'head'|'patch'|'request'>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface PlatformContext {
|
|
73
|
+
platformToken: string
|
|
74
|
+
clients: PlatformClients
|
|
75
|
+
secrets: Record<string, string>
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export * from './event/commons';
|
|
79
|
+
export * from './event/AFTER_CREATE';
|
|
80
|
+
export * from './event/AFTER_BUILD_INFO_SAVE';
|
|
81
|
+
export * from './event/AFTER_DOWNLOAD';
|
|
82
|
+
export * from './event/AFTER_MOVE';
|
|
83
|
+
export * from './event/AFTER_DOWNLOAD';
|
|
84
|
+
export * from './event/BEFORE_DOWNLOAD';
|
|
85
|
+
export * from './event/BEFORE_UPLOAD';
|
|
86
|
+
export * from './event/AFTER_CREATE';
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "jfrog-workers",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "JFrog workers interfaces and stubs",
|
|
5
|
+
"homepage": "https://github.com/jfrog/workers-sample",
|
|
6
|
+
"contributors": [
|
|
7
|
+
{
|
|
8
|
+
"name": "HERVE ESTEGUET",
|
|
9
|
+
"githubUsername": "ehl-jf",
|
|
10
|
+
"url": "https://github.com/ehl-jf"
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"main": "index.ts",
|
|
14
|
+
"author": "JFrog",
|
|
15
|
+
"license": "ISC",
|
|
16
|
+
"exports": {
|
|
17
|
+
"./package.json": "./package.json"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/jfrog/workers-sample.git"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"axios": "1.6.7"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"typescript": "^5.4.2"
|
|
28
|
+
}
|
|
29
|
+
}
|
package/test/login.sh
ADDED
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "nodenext",
|
|
4
|
+
"moduleResolution": "nodenext",
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"target": "es2017",
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"forceConsistentCasingInFileNames": false,
|
|
9
|
+
"noFallthroughCasesInSwitch": false,
|
|
10
|
+
"lib": [
|
|
11
|
+
"ES2021.String"
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
"include": [
|
|
15
|
+
"**/*.ts",
|
|
16
|
+
"node_modules/@types/**/*.d.ts"
|
|
17
|
+
]
|
|
18
|
+
}
|