@uipath/solution-sdk 1.202.0-preview.159 → 1.203.0-preview.160
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/dist/THIRD-PARTY-NOTICES.md +12 -1
- package/dist/embedded-file-reader-xxqe8vs8.js +114 -0
- package/dist/first-party-service-sd8yaf73.js +27 -0
- package/dist/index-1de529jm.js +39 -0
- package/dist/index-4zqv4bn2.js +6922 -0
- package/dist/index-53w8skv5.js +262 -0
- package/dist/index-dqa169gp.js +25 -0
- package/dist/index-g0hcxnae.js +237 -0
- package/dist/index-gdtpsdn7.js +342 -0
- package/dist/index-sby22td6.js +634 -0
- package/dist/index-y8tgscfm.js +1381 -0
- package/dist/index.js +3660 -15829
- package/dist/jmespath-231m3hyn.js +1485 -0
- package/dist/js-yaml-88tdqrtd.js +3153 -0
- package/dist/resources/index.js +14311 -27794
- package/dist/solution-auth.js +6 -2320
- package/dist/src/index.d.ts +1 -1
- package/dist/src/resources/commands/project-utils.d.ts +5 -0
- package/dist/src/resources/index.d.ts +3 -0
- package/dist/src/resources/providers/artefact-pair-binding-provider.d.ts +21 -0
- package/dist/src/resources/providers/file-storage-provider.d.ts +2 -1
- package/dist/src/resources/providers/resource-builder-init.d.ts +12 -12
- package/dist/src/resources/providers/solution-access-provider.d.ts +2 -1
- package/dist/src/resources/services/entry-point-spec-enhancer.d.ts +21 -2
- package/dist/src/resources/services/local-resource-matcher.d.ts +1 -1
- package/dist/src/resources/services/project-template-types.d.ts +35 -0
- package/dist/src/resources/services/resource-casing.d.ts +24 -0
- package/dist/src/resources/services/resource-refresh-service.d.ts +7 -0
- package/dist/src/resources/services/resource-remote-sync.d.ts +67 -0
- package/dist/src/resources/services/solution-manifest.d.ts +20 -6
- package/dist/src/resources/services/sync-resources-from-bindings.d.ts +4 -3
- package/package.json +3 -2
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
// ../../node_modules/@uipath/resource-builder-sdk/dist/clients/generated/first-party-service.js
|
|
2
|
+
var first_party_service_DeploymentAction = /* @__PURE__ */ function(DeploymentAction) {
|
|
3
|
+
DeploymentAction["Install"] = "Install";
|
|
4
|
+
DeploymentAction["Link"] = "Link";
|
|
5
|
+
DeploymentAction["Uninstall"] = "Uninstall";
|
|
6
|
+
DeploymentAction["Unlink"] = "Unlink";
|
|
7
|
+
DeploymentAction["Merge"] = "Merge";
|
|
8
|
+
DeploymentAction["UseExisting"] = "UseExisting";
|
|
9
|
+
DeploymentAction["Activate"] = "Activate";
|
|
10
|
+
return DeploymentAction;
|
|
11
|
+
}({});
|
|
12
|
+
var first_party_service_SolutionDeploymentAction = /* @__PURE__ */ function(SolutionDeploymentAction) {
|
|
13
|
+
SolutionDeploymentAction["Install"] = "Install";
|
|
14
|
+
SolutionDeploymentAction["Uninstall"] = "Uninstall";
|
|
15
|
+
SolutionDeploymentAction["Upgrade"] = "Upgrade";
|
|
16
|
+
SolutionDeploymentAction["Rollback"] = "Rollback";
|
|
17
|
+
SolutionDeploymentAction["Activate"] = "Activate";
|
|
18
|
+
return SolutionDeploymentAction;
|
|
19
|
+
}({});
|
|
20
|
+
var first_party_service_SolutionStatus = /* @__PURE__ */ function(SolutionStatus) {
|
|
21
|
+
SolutionStatus["Installed"] = "Installed";
|
|
22
|
+
SolutionStatus["Uninstalled"] = "Uninstalled";
|
|
23
|
+
SolutionStatus["Installing"] = "Installing";
|
|
24
|
+
SolutionStatus["Uninstalling"] = "Uninstalling";
|
|
25
|
+
SolutionStatus["InstallError"] = "InstallError";
|
|
26
|
+
SolutionStatus["UninstallError"] = "UninstallError";
|
|
27
|
+
SolutionStatus["Unknown"] = "Unknown";
|
|
28
|
+
return SolutionStatus;
|
|
29
|
+
}({});
|
|
30
|
+
var first_party_service_QueryOptions = /* @__PURE__ */ function(QueryOptions) {
|
|
31
|
+
QueryOptions["Contains"] = "Contains";
|
|
32
|
+
QueryOptions["Equals"] = "Equals";
|
|
33
|
+
return QueryOptions;
|
|
34
|
+
}({});
|
|
35
|
+
var first_party_service_DeploymentResourceValidationErrorLevel = /* @__PURE__ */ function(DeploymentResourceValidationErrorLevel) {
|
|
36
|
+
DeploymentResourceValidationErrorLevel["Error"] = "Error";
|
|
37
|
+
DeploymentResourceValidationErrorLevel["Warning"] = "Warning";
|
|
38
|
+
DeploymentResourceValidationErrorLevel["Info"] = "Info";
|
|
39
|
+
return DeploymentResourceValidationErrorLevel;
|
|
40
|
+
}({});
|
|
41
|
+
var first_party_service_DeploymentResourceValidationErrorKind = /* @__PURE__ */ function(DeploymentResourceValidationErrorKind) {
|
|
42
|
+
DeploymentResourceValidationErrorKind["Conflict"] = "Conflict";
|
|
43
|
+
DeploymentResourceValidationErrorKind["ConfigurationError"] = "ConfigurationError";
|
|
44
|
+
return DeploymentResourceValidationErrorKind;
|
|
45
|
+
}({});
|
|
46
|
+
var first_party_service_DeploymentResourceValidationAction = /* @__PURE__ */ function(DeploymentResourceValidationAction) {
|
|
47
|
+
DeploymentResourceValidationAction["RenameExisting"] = "RenameExisting";
|
|
48
|
+
DeploymentResourceValidationAction["RenameInSolution"] = "RenameInSolution";
|
|
49
|
+
DeploymentResourceValidationAction["UseExisting"] = "UseExisting";
|
|
50
|
+
DeploymentResourceValidationAction["FixConfiguration"] = "FixConfiguration";
|
|
51
|
+
DeploymentResourceValidationAction["Delete"] = "Delete";
|
|
52
|
+
DeploymentResourceValidationAction["SkipDelete"] = "SkipDelete";
|
|
53
|
+
DeploymentResourceValidationAction["MergeConfiguration"] = "MergeConfiguration";
|
|
54
|
+
DeploymentResourceValidationAction["Replace"] = "Replace";
|
|
55
|
+
return DeploymentResourceValidationAction;
|
|
56
|
+
}({});
|
|
57
|
+
var first_party_service_ContentType = /* @__PURE__ */ function(ContentType) {
|
|
58
|
+
ContentType["Json"] = "application/json";
|
|
59
|
+
ContentType["JsonApi"] = "application/vnd.api+json";
|
|
60
|
+
ContentType["FormData"] = "multipart/form-data";
|
|
61
|
+
ContentType["UrlEncoded"] = "application/x-www-form-urlencoded";
|
|
62
|
+
ContentType["Text"] = "text/plain";
|
|
63
|
+
return ContentType;
|
|
64
|
+
}({});
|
|
65
|
+
|
|
66
|
+
class HttpClient {
|
|
67
|
+
encodeQueryParam(key, value) {
|
|
68
|
+
const encodedKey = encodeURIComponent(key);
|
|
69
|
+
return `${encodedKey}=${encodeURIComponent(typeof value == "number" ? value : `${value}`)}`;
|
|
70
|
+
}
|
|
71
|
+
addQueryParam(query, key) {
|
|
72
|
+
return this.encodeQueryParam(key, query[key]);
|
|
73
|
+
}
|
|
74
|
+
addArrayQueryParam(query, key) {
|
|
75
|
+
const value = query[key];
|
|
76
|
+
return value.map((v) => this.encodeQueryParam(key, v)).join("&");
|
|
77
|
+
}
|
|
78
|
+
toQueryString(rawQuery) {
|
|
79
|
+
const query = rawQuery || {};
|
|
80
|
+
const keys = Object.keys(query).filter((key) => query[key] !== undefined);
|
|
81
|
+
return keys.map((key) => Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key)).join("&");
|
|
82
|
+
}
|
|
83
|
+
addQueryParams(rawQuery) {
|
|
84
|
+
const queryString = this.toQueryString(rawQuery);
|
|
85
|
+
return queryString ? `?${queryString}` : "";
|
|
86
|
+
}
|
|
87
|
+
mergeRequestParams(params1, params2) {
|
|
88
|
+
return {
|
|
89
|
+
...this.baseApiParams,
|
|
90
|
+
...params1,
|
|
91
|
+
...params2 || {},
|
|
92
|
+
headers: {
|
|
93
|
+
...this.baseApiParams.headers || {},
|
|
94
|
+
...params1.headers || {},
|
|
95
|
+
...params2 && params2.headers || {}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
constructor(apiConfig = {}) {
|
|
100
|
+
this.baseUrl = "https://localhost:7008";
|
|
101
|
+
this.securityData = null;
|
|
102
|
+
this.abortControllers = new Map;
|
|
103
|
+
this.customFetch = (...fetchParams) => fetch(...fetchParams);
|
|
104
|
+
this.baseApiParams = {
|
|
105
|
+
credentials: "same-origin",
|
|
106
|
+
headers: {},
|
|
107
|
+
redirect: "follow",
|
|
108
|
+
referrerPolicy: "no-referrer"
|
|
109
|
+
};
|
|
110
|
+
this.setSecurityData = (data) => {
|
|
111
|
+
this.securityData = data;
|
|
112
|
+
};
|
|
113
|
+
this.contentFormatters = {
|
|
114
|
+
["application/json"]: (input) => input !== null && (typeof input == "object" || typeof input == "string") ? JSON.stringify(input) : input,
|
|
115
|
+
["application/vnd.api+json"]: (input) => input !== null && (typeof input == "object" || typeof input == "string") ? JSON.stringify(input) : input,
|
|
116
|
+
["text/plain"]: (input) => input !== null && typeof input != "string" ? JSON.stringify(input) : input,
|
|
117
|
+
["multipart/form-data"]: (input) => {
|
|
118
|
+
if (input instanceof FormData)
|
|
119
|
+
return input;
|
|
120
|
+
return Object.keys(input || {}).reduce((formData, key) => {
|
|
121
|
+
const property = input[key];
|
|
122
|
+
formData.append(key, property instanceof Blob ? property : typeof property == "object" && property !== null ? JSON.stringify(property) : `${property}`);
|
|
123
|
+
return formData;
|
|
124
|
+
}, new FormData);
|
|
125
|
+
},
|
|
126
|
+
["application/x-www-form-urlencoded"]: (input) => this.toQueryString(input)
|
|
127
|
+
};
|
|
128
|
+
this.createAbortSignal = (cancelToken) => {
|
|
129
|
+
if (this.abortControllers.has(cancelToken)) {
|
|
130
|
+
const abortController2 = this.abortControllers.get(cancelToken);
|
|
131
|
+
if (abortController2)
|
|
132
|
+
return abortController2.signal;
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const abortController = new AbortController;
|
|
136
|
+
this.abortControllers.set(cancelToken, abortController);
|
|
137
|
+
return abortController.signal;
|
|
138
|
+
};
|
|
139
|
+
this.abortRequest = (cancelToken) => {
|
|
140
|
+
const abortController = this.abortControllers.get(cancelToken);
|
|
141
|
+
if (abortController) {
|
|
142
|
+
abortController.abort();
|
|
143
|
+
this.abortControllers.delete(cancelToken);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
this.request = async ({ body, secure, path, type, query, format, baseUrl, cancelToken, ...params }) => {
|
|
147
|
+
const secureParams = (typeof secure == "boolean" ? secure : this.baseApiParams.secure) && this.securityWorker && await this.securityWorker(this.securityData) || {};
|
|
148
|
+
const requestParams = this.mergeRequestParams(params, secureParams);
|
|
149
|
+
const queryString = query && this.toQueryString(query);
|
|
150
|
+
const payloadFormatter = this.contentFormatters[type || "application/json"];
|
|
151
|
+
const responseFormat = format || requestParams.format;
|
|
152
|
+
return this.customFetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, {
|
|
153
|
+
...requestParams,
|
|
154
|
+
headers: {
|
|
155
|
+
...requestParams.headers || {},
|
|
156
|
+
...type && type !== "multipart/form-data" ? {
|
|
157
|
+
"Content-Type": type
|
|
158
|
+
} : {}
|
|
159
|
+
},
|
|
160
|
+
signal: (cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal) || null,
|
|
161
|
+
body: body == null ? null : payloadFormatter(body)
|
|
162
|
+
}).then(async (response) => {
|
|
163
|
+
const r = response;
|
|
164
|
+
r.data = null;
|
|
165
|
+
r.error = null;
|
|
166
|
+
const responseToParse = responseFormat ? response.clone() : response;
|
|
167
|
+
const data = responseFormat ? await responseToParse[responseFormat]().then((data2) => {
|
|
168
|
+
if (r.ok)
|
|
169
|
+
r.data = data2;
|
|
170
|
+
else
|
|
171
|
+
r.error = data2;
|
|
172
|
+
return r;
|
|
173
|
+
}).catch((e) => {
|
|
174
|
+
r.error = e;
|
|
175
|
+
return r;
|
|
176
|
+
}) : r;
|
|
177
|
+
if (cancelToken)
|
|
178
|
+
this.abortControllers.delete(cancelToken);
|
|
179
|
+
if (!response.ok)
|
|
180
|
+
throw data;
|
|
181
|
+
return data.data;
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
Object.assign(this, apiConfig);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
class FirstPartyServiceApi extends HttpClient {
|
|
189
|
+
constructor(...args) {
|
|
190
|
+
super(...args), this.v2 = {
|
|
191
|
+
automationSolutionsGetMetadata: (params = {}) => this.request({
|
|
192
|
+
path: "/v2/automationsolutions/metadata",
|
|
193
|
+
method: "GET",
|
|
194
|
+
...params
|
|
195
|
+
}),
|
|
196
|
+
automationSolutionsHeadMetadata: (params = {}) => this.request({
|
|
197
|
+
path: "/v2/automationsolutions/metadata",
|
|
198
|
+
method: "HEAD",
|
|
199
|
+
...params
|
|
200
|
+
}),
|
|
201
|
+
automationSolutionsSetState: (data, query, params = {}) => this.request({
|
|
202
|
+
path: "/v2/automationsolutions",
|
|
203
|
+
method: "PATCH",
|
|
204
|
+
query,
|
|
205
|
+
body: data,
|
|
206
|
+
type: "application/json",
|
|
207
|
+
...params
|
|
208
|
+
}),
|
|
209
|
+
automationSolutionsInstall: (data, query, params = {}) => this.request({
|
|
210
|
+
path: "/v2/automationsolutions",
|
|
211
|
+
method: "PUT",
|
|
212
|
+
query,
|
|
213
|
+
body: data,
|
|
214
|
+
format: "json",
|
|
215
|
+
...params
|
|
216
|
+
}),
|
|
217
|
+
automationSolutionsUninstall: (data, query, params = {}) => this.request({
|
|
218
|
+
path: "/v2/automationsolutions",
|
|
219
|
+
method: "DELETE",
|
|
220
|
+
query,
|
|
221
|
+
body: data,
|
|
222
|
+
type: "application/json",
|
|
223
|
+
format: "json",
|
|
224
|
+
...params
|
|
225
|
+
}),
|
|
226
|
+
automationSolutionsExport: (data, params = {}) => this.request({
|
|
227
|
+
path: "/v2/automationsolutions/export",
|
|
228
|
+
method: "POST",
|
|
229
|
+
body: data,
|
|
230
|
+
type: "application/json",
|
|
231
|
+
format: "json",
|
|
232
|
+
...params
|
|
233
|
+
}),
|
|
234
|
+
automationSolutionsGetTranslations: (query, params = {}) => this.request({
|
|
235
|
+
path: "/v2/automationsolutions/translations",
|
|
236
|
+
method: "GET",
|
|
237
|
+
query,
|
|
238
|
+
format: "json",
|
|
239
|
+
...params
|
|
240
|
+
}),
|
|
241
|
+
automationSolutionsValidate: (data, query, params = {}) => this.request({
|
|
242
|
+
path: "/v2/automationsolutions/validate",
|
|
243
|
+
method: "POST",
|
|
244
|
+
query,
|
|
245
|
+
body: data,
|
|
246
|
+
type: "application/json",
|
|
247
|
+
format: "json",
|
|
248
|
+
...params
|
|
249
|
+
}),
|
|
250
|
+
automationSolutionsLookup: (query, params = {}) => this.request({
|
|
251
|
+
path: "/v2/automationsolutions/lookup",
|
|
252
|
+
method: "GET",
|
|
253
|
+
query,
|
|
254
|
+
format: "json",
|
|
255
|
+
...params
|
|
256
|
+
})
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
export { first_party_service_DeploymentAction, first_party_service_SolutionDeploymentAction, first_party_service_SolutionStatus, first_party_service_QueryOptions, first_party_service_DeploymentResourceValidationErrorLevel, first_party_service_DeploymentResourceValidationErrorKind, first_party_service_DeploymentResourceValidationAction, first_party_service_ContentType, HttpClient, FirstPartyServiceApi };
|
|
261
|
+
|
|
262
|
+
//# debugId=AC88CC622210E15664756E2164756E21
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CAMEL_CASE_ENUM_PROPERTIES,
|
|
3
|
+
JsonSerializer,
|
|
4
|
+
JsonSerializerFactory,
|
|
5
|
+
JsonSerializerNames,
|
|
6
|
+
JsonSerializerProxy,
|
|
7
|
+
PASCAL_CASE_ENUM_PROPERTIES,
|
|
8
|
+
RESOURCE_BUILDER_PASCAL_CASE_PROPERTIES,
|
|
9
|
+
SHARED_CORE_ABSTRACTIONS_PASCAL_CASE_PROPERTIES,
|
|
10
|
+
StreamSerializer
|
|
11
|
+
} from "./index-gdtpsdn7.js";
|
|
12
|
+
import"./index-1de529jm.js";
|
|
13
|
+
export {
|
|
14
|
+
CAMEL_CASE_ENUM_PROPERTIES,
|
|
15
|
+
JsonSerializer,
|
|
16
|
+
JsonSerializerFactory,
|
|
17
|
+
JsonSerializerNames,
|
|
18
|
+
JsonSerializerProxy,
|
|
19
|
+
PASCAL_CASE_ENUM_PROPERTIES,
|
|
20
|
+
RESOURCE_BUILDER_PASCAL_CASE_PROPERTIES,
|
|
21
|
+
SHARED_CORE_ABSTRACTIONS_PASCAL_CASE_PROPERTIES,
|
|
22
|
+
StreamSerializer
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//# debugId=A79DD62A6A37B41864756E2164756E21
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__require
|
|
3
|
+
} from "./index-1de529jm.js";
|
|
4
|
+
|
|
5
|
+
// ../filesystem/src/node.ts
|
|
6
|
+
import { randomUUID } from "node:crypto";
|
|
7
|
+
import { existsSync } from "node:fs";
|
|
8
|
+
import * as fs from "node:fs/promises";
|
|
9
|
+
import * as os from "node:os";
|
|
10
|
+
import * as path from "node:path";
|
|
11
|
+
var LOCK_HEARTBEAT_MS = 5000;
|
|
12
|
+
var LOCK_STALE_MS = 15000;
|
|
13
|
+
var LOCK_MAX_WAIT_MS = 20000;
|
|
14
|
+
var LOCK_MAX_HOLD_MS = 60000;
|
|
15
|
+
var LOCK_RETRY_MIN_MS = 100;
|
|
16
|
+
var LOCK_RETRY_JITTER_MS = 200;
|
|
17
|
+
|
|
18
|
+
class NodeFileSystem {
|
|
19
|
+
path = {
|
|
20
|
+
join: path.join,
|
|
21
|
+
resolve: path.resolve,
|
|
22
|
+
relative: path.relative,
|
|
23
|
+
dirname: path.dirname,
|
|
24
|
+
isAbsolute: path.isAbsolute,
|
|
25
|
+
basename: path.basename
|
|
26
|
+
};
|
|
27
|
+
env = {
|
|
28
|
+
cwd: process.cwd,
|
|
29
|
+
homedir: os.homedir,
|
|
30
|
+
tmpdir: os.tmpdir,
|
|
31
|
+
getenv: (key) => process.env[key]
|
|
32
|
+
};
|
|
33
|
+
utils = {
|
|
34
|
+
open: async (url) => {
|
|
35
|
+
const { default: open } = await import("./index-sby22td6.js");
|
|
36
|
+
await open(url);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
async readFile(path2, options) {
|
|
40
|
+
try {
|
|
41
|
+
if (options) {
|
|
42
|
+
return await fs.readFile(path2, "utf-8");
|
|
43
|
+
}
|
|
44
|
+
return await fs.readFile(path2);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
if (this.isEnoent(error))
|
|
47
|
+
return null;
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async writeFile(filePath, data) {
|
|
52
|
+
const dir = path.dirname(filePath);
|
|
53
|
+
if (dir) {
|
|
54
|
+
await fs.mkdir(dir, { recursive: true });
|
|
55
|
+
}
|
|
56
|
+
await fs.writeFile(filePath, data);
|
|
57
|
+
}
|
|
58
|
+
async appendFile(filePath, data) {
|
|
59
|
+
const dir = path.dirname(filePath);
|
|
60
|
+
if (dir) {
|
|
61
|
+
await fs.mkdir(dir, { recursive: true });
|
|
62
|
+
}
|
|
63
|
+
await fs.appendFile(filePath, data);
|
|
64
|
+
}
|
|
65
|
+
async readdir(dirPath) {
|
|
66
|
+
try {
|
|
67
|
+
return await fs.readdir(dirPath);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
if (this.isEnoent(error))
|
|
70
|
+
return [];
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async stat(filePath) {
|
|
75
|
+
try {
|
|
76
|
+
const stats = await fs.stat(filePath);
|
|
77
|
+
return {
|
|
78
|
+
isFile: () => stats.isFile(),
|
|
79
|
+
isDirectory: () => stats.isDirectory(),
|
|
80
|
+
size: stats.size,
|
|
81
|
+
mtimeMs: stats.mtimeMs
|
|
82
|
+
};
|
|
83
|
+
} catch (error) {
|
|
84
|
+
if (this.isEnoent(error))
|
|
85
|
+
return null;
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async exists(filePath) {
|
|
90
|
+
return existsSync(filePath);
|
|
91
|
+
}
|
|
92
|
+
async mkdir(dirPath) {
|
|
93
|
+
await fs.mkdir(dirPath, { recursive: true });
|
|
94
|
+
}
|
|
95
|
+
async acquireLock(lockPath) {
|
|
96
|
+
const canonicalPath = await this.canonicalizeLockTarget(lockPath);
|
|
97
|
+
const lockFile = `${canonicalPath}.lock`;
|
|
98
|
+
const ownerId = randomUUID();
|
|
99
|
+
const start = Date.now();
|
|
100
|
+
while (true) {
|
|
101
|
+
try {
|
|
102
|
+
await fs.writeFile(lockFile, ownerId, { flag: "wx" });
|
|
103
|
+
return this.createLockRelease(lockFile, ownerId);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
if (!this.hasErrnoCode(error, "EEXIST")) {
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
const stats = await fs.stat(lockFile).catch(() => null);
|
|
109
|
+
if (stats && Date.now() - stats.mtimeMs > LOCK_STALE_MS) {
|
|
110
|
+
const reclaimed = await fs.rm(lockFile, { force: true }).then(() => true).catch(() => false);
|
|
111
|
+
if (reclaimed)
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (Date.now() - start > LOCK_MAX_WAIT_MS) {
|
|
115
|
+
throw new Error(`ELOCKED: timed out waiting for lock on ${canonicalPath}`);
|
|
116
|
+
}
|
|
117
|
+
await new Promise((resolve2) => setTimeout(resolve2, LOCK_RETRY_MIN_MS + Math.random() * LOCK_RETRY_JITTER_MS));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
async canonicalizeLockTarget(lockPath) {
|
|
122
|
+
const absolute = path.resolve(lockPath);
|
|
123
|
+
const fullReal = await fs.realpath(absolute).catch(() => null);
|
|
124
|
+
if (fullReal)
|
|
125
|
+
return fullReal;
|
|
126
|
+
const parent = path.dirname(absolute);
|
|
127
|
+
const base = path.basename(absolute);
|
|
128
|
+
const canonicalParent = await fs.realpath(parent).catch(() => parent);
|
|
129
|
+
return path.join(canonicalParent, base);
|
|
130
|
+
}
|
|
131
|
+
createLockRelease(lockFile, ownerId) {
|
|
132
|
+
const heartbeatStart = Date.now();
|
|
133
|
+
let heartbeatTimer;
|
|
134
|
+
let stopped = false;
|
|
135
|
+
const stopHeartbeat = () => {
|
|
136
|
+
stopped = true;
|
|
137
|
+
if (heartbeatTimer)
|
|
138
|
+
clearTimeout(heartbeatTimer);
|
|
139
|
+
};
|
|
140
|
+
const scheduleNextHeartbeat = () => {
|
|
141
|
+
if (stopped)
|
|
142
|
+
return;
|
|
143
|
+
if (Date.now() - heartbeatStart >= LOCK_MAX_HOLD_MS) {
|
|
144
|
+
stopped = true;
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
heartbeatTimer = setTimeout(() => {
|
|
148
|
+
runHeartbeat();
|
|
149
|
+
}, LOCK_HEARTBEAT_MS);
|
|
150
|
+
heartbeatTimer.unref?.();
|
|
151
|
+
};
|
|
152
|
+
const runHeartbeat = async () => {
|
|
153
|
+
if (stopped)
|
|
154
|
+
return;
|
|
155
|
+
const current = await fs.readFile(lockFile, "utf-8").catch(() => null);
|
|
156
|
+
if (stopped)
|
|
157
|
+
return;
|
|
158
|
+
if (current !== ownerId) {
|
|
159
|
+
stopped = true;
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const now = Date.now() / 1000;
|
|
163
|
+
await fs.utimes(lockFile, now, now).catch(() => {});
|
|
164
|
+
scheduleNextHeartbeat();
|
|
165
|
+
};
|
|
166
|
+
scheduleNextHeartbeat();
|
|
167
|
+
let released = false;
|
|
168
|
+
return async () => {
|
|
169
|
+
if (released)
|
|
170
|
+
return;
|
|
171
|
+
released = true;
|
|
172
|
+
stopHeartbeat();
|
|
173
|
+
const current = await fs.readFile(lockFile, "utf-8").catch(() => null);
|
|
174
|
+
if (current === ownerId) {
|
|
175
|
+
await fs.rm(lockFile, { force: true });
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
async rm(filePath) {
|
|
180
|
+
await fs.rm(filePath, { recursive: true, force: true });
|
|
181
|
+
}
|
|
182
|
+
async rename(oldPath, newPath) {
|
|
183
|
+
await fs.rename(oldPath, newPath);
|
|
184
|
+
}
|
|
185
|
+
async realpath(filePath) {
|
|
186
|
+
try {
|
|
187
|
+
return await fs.realpath(filePath);
|
|
188
|
+
} catch (error) {
|
|
189
|
+
if (this.isEnoent(error))
|
|
190
|
+
return filePath;
|
|
191
|
+
throw error;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
async getTempDir() {
|
|
195
|
+
return await fs.mkdtemp(path.join(os.tmpdir(), "uipath-fs-"));
|
|
196
|
+
}
|
|
197
|
+
async copyDirectory(sourcePath, destPath) {
|
|
198
|
+
const sourceStats = await this.stat(sourcePath);
|
|
199
|
+
if (!sourceStats) {
|
|
200
|
+
throw new Error(`Source directory does not exist: ${sourcePath}`);
|
|
201
|
+
}
|
|
202
|
+
if (!sourceStats.isDirectory()) {
|
|
203
|
+
throw new Error(`Source path is not a directory: ${sourcePath}`);
|
|
204
|
+
}
|
|
205
|
+
await this.mkdir(destPath);
|
|
206
|
+
const entries = await this.readdir(sourcePath);
|
|
207
|
+
for (const entry of entries) {
|
|
208
|
+
const srcEntry = path.join(sourcePath, entry);
|
|
209
|
+
const destEntry = path.join(destPath, entry);
|
|
210
|
+
const entryStats = await this.stat(srcEntry);
|
|
211
|
+
if (!entryStats)
|
|
212
|
+
continue;
|
|
213
|
+
if (entryStats.isDirectory()) {
|
|
214
|
+
await this.copyDirectory(srcEntry, destEntry);
|
|
215
|
+
} else if (entryStats.isFile()) {
|
|
216
|
+
const content = await this.readFile(srcEntry);
|
|
217
|
+
if (content !== null) {
|
|
218
|
+
await this.writeFile(destEntry, content);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
isEnoent(error) {
|
|
224
|
+
return this.hasErrnoCode(error, "ENOENT");
|
|
225
|
+
}
|
|
226
|
+
hasErrnoCode(error, code) {
|
|
227
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// ../filesystem/src/index.ts
|
|
232
|
+
var fsInstance = new NodeFileSystem;
|
|
233
|
+
var getFileSystem = () => fsInstance;
|
|
234
|
+
|
|
235
|
+
export { getFileSystem };
|
|
236
|
+
|
|
237
|
+
//# debugId=25EC9C9B4767723E64756E2164756E21
|