@tinycloud/operations 0.2.1 → 0.3.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/dist/artifacts.cjs +3 -1
- package/dist/artifacts.cjs.map +1 -1
- package/dist/artifacts.d.cts +1 -1
- package/dist/artifacts.d.ts +1 -1
- package/dist/artifacts.js +4 -2
- package/dist/artifacts.js.map +1 -1
- package/dist/cli-runtime.cjs +27 -3
- package/dist/cli-runtime.cjs.map +1 -1
- package/dist/cli-runtime.d.cts +1 -1
- package/dist/cli-runtime.d.ts +1 -1
- package/dist/cli-runtime.js +28 -4
- package/dist/cli-runtime.js.map +1 -1
- package/dist/{contract-OnWT3OXa.d.cts → contract-xMIIMtpF.d.cts} +6 -0
- package/dist/{contract-OnWT3OXa.d.ts → contract-xMIIMtpF.d.ts} +6 -0
- package/dist/index.cjs +34 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +35 -12
- package/dist/index.js.map +1 -1
- package/dist/profile.cjs +3 -1
- package/dist/profile.cjs.map +1 -1
- package/dist/profile.d.cts +1 -1
- package/dist/profile.d.ts +1 -1
- package/dist/profile.js +4 -2
- package/dist/profile.js.map +1 -1
- package/dist/state.cjs +12 -1
- package/dist/state.cjs.map +1 -1
- package/dist/state.d.cts +3 -1
- package/dist/state.d.ts +3 -1
- package/dist/state.js +12 -2
- package/dist/state.js.map +1 -1
- package/package.json +1 -1
package/dist/cli-runtime.cjs
CHANGED
|
@@ -6754,9 +6754,16 @@ var init_authority = __esm({
|
|
|
6754
6754
|
|
|
6755
6755
|
// src/state.ts
|
|
6756
6756
|
function tinycloudHomePath() {
|
|
6757
|
-
const home = process.env.TC_HOME ?? process.env.HOME ?? process.env.USERPROFILE ?? (0, import_node_os.homedir)();
|
|
6757
|
+
const home = invocationStateRoot.getStore() ?? process.env.TC_HOME ?? process.env.HOME ?? process.env.USERPROFILE ?? (0, import_node_os.homedir)();
|
|
6758
6758
|
return (0, import_node_path.join)(home, ".tinycloud");
|
|
6759
6759
|
}
|
|
6760
|
+
function withTinyCloudStateRoot(stateRoot, action) {
|
|
6761
|
+
if (stateRoot === void 0) return action();
|
|
6762
|
+
if (!(0, import_node_path.isAbsolute)(stateRoot) || stateRoot.includes("\0")) {
|
|
6763
|
+
throw new TypeError("The TinyCloud state root must be an absolute path.");
|
|
6764
|
+
}
|
|
6765
|
+
return invocationStateRoot.run((0, import_node_path.resolve)(stateRoot), action);
|
|
6766
|
+
}
|
|
6760
6767
|
function tinycloudConfigPath() {
|
|
6761
6768
|
return (0, import_node_path.join)(tinycloudHomePath(), "config.json");
|
|
6762
6769
|
}
|
|
@@ -7008,11 +7015,12 @@ function isErrno(error, code) {
|
|
|
7008
7015
|
function sleep(milliseconds) {
|
|
7009
7016
|
return new Promise((resolve2) => setTimeout(resolve2, milliseconds));
|
|
7010
7017
|
}
|
|
7011
|
-
var import_node_crypto, import_promises, import_node_os, import_node_path, DEFAULT_PROFILE, DEFAULT_LOCK_TIMEOUT_MS, DEFAULT_LOCK_RETRY_MS, DEFAULT_STALE_LOCK_MS, TEST_LOCK_CONTENTION_SIGNAL_PATH, TEST_LOCK_RECOVERY_BARRIER_DIR, ProfileLockTimeoutError;
|
|
7018
|
+
var import_node_crypto, import_node_async_hooks, import_promises, import_node_os, import_node_path, DEFAULT_PROFILE, DEFAULT_LOCK_TIMEOUT_MS, DEFAULT_LOCK_RETRY_MS, DEFAULT_STALE_LOCK_MS, TEST_LOCK_CONTENTION_SIGNAL_PATH, TEST_LOCK_RECOVERY_BARRIER_DIR, invocationStateRoot, ProfileLockTimeoutError;
|
|
7012
7019
|
var init_state = __esm({
|
|
7013
7020
|
"src/state.ts"() {
|
|
7014
7021
|
"use strict";
|
|
7015
7022
|
import_node_crypto = require("crypto");
|
|
7023
|
+
import_node_async_hooks = require("async_hooks");
|
|
7016
7024
|
import_promises = require("fs/promises");
|
|
7017
7025
|
import_node_os = require("os");
|
|
7018
7026
|
import_node_path = require("path");
|
|
@@ -7022,6 +7030,7 @@ var init_state = __esm({
|
|
|
7022
7030
|
DEFAULT_STALE_LOCK_MS = 3e4;
|
|
7023
7031
|
TEST_LOCK_CONTENTION_SIGNAL_PATH = "TC_TEST_PROFILE_LOCK_CONTENTION_SIGNAL_PATH";
|
|
7024
7032
|
TEST_LOCK_RECOVERY_BARRIER_DIR = "TC_TEST_PROFILE_LOCK_RECOVERY_BARRIER_DIR";
|
|
7033
|
+
invocationStateRoot = new import_node_async_hooks.AsyncLocalStorage();
|
|
7025
7034
|
ProfileLockTimeoutError = class extends Error {
|
|
7026
7035
|
constructor(profile, timeoutMs) {
|
|
7027
7036
|
super(`Timed out waiting for the profile lock for "${profile}" after ${timeoutMs}ms.`);
|
|
@@ -9908,6 +9917,7 @@ module.exports = __toCommonJS(cli_runtime_exports);
|
|
|
9908
9917
|
|
|
9909
9918
|
// src/invoke.ts
|
|
9910
9919
|
var import_node_crypto3 = require("crypto");
|
|
9920
|
+
var import_node_path2 = require("path");
|
|
9911
9921
|
var import_node_sdk2 = require("@tinycloud/node-sdk");
|
|
9912
9922
|
|
|
9913
9923
|
// ../sdk-core/src/policy/errors.ts
|
|
@@ -10247,6 +10257,7 @@ function isRecord(value) {
|
|
|
10247
10257
|
}
|
|
10248
10258
|
|
|
10249
10259
|
// src/invoke.ts
|
|
10260
|
+
init_state();
|
|
10250
10261
|
init_secrets();
|
|
10251
10262
|
async function invokeOperationWithLocalAuthorityRetry(operationId, operationVersion, invocationTarget, unknownInput) {
|
|
10252
10263
|
const target = normalizeInvocationTarget(invocationTarget);
|
|
@@ -10267,6 +10278,17 @@ async function invokeOperationWithLocalAuthorityRetry(operationId, operationVers
|
|
|
10267
10278
|
)
|
|
10268
10279
|
);
|
|
10269
10280
|
}
|
|
10281
|
+
return withTinyCloudStateRoot(
|
|
10282
|
+
target.stateRoot,
|
|
10283
|
+
() => invokeLocalAuthorityRetry(
|
|
10284
|
+
operationId,
|
|
10285
|
+
operationVersion,
|
|
10286
|
+
target,
|
|
10287
|
+
unknownInput
|
|
10288
|
+
)
|
|
10289
|
+
);
|
|
10290
|
+
}
|
|
10291
|
+
async function invokeLocalAuthorityRetry(operationId, operationVersion, target, unknownInput) {
|
|
10270
10292
|
const prepared = await prepareInvocation(
|
|
10271
10293
|
operationId,
|
|
10272
10294
|
operationVersion,
|
|
@@ -10713,14 +10735,16 @@ function normalizeInvocationTarget(target) {
|
|
|
10713
10735
|
const candidate = target;
|
|
10714
10736
|
const profile = candidate.profile;
|
|
10715
10737
|
const host = candidate.host;
|
|
10738
|
+
const stateRoot = candidate.stateRoot;
|
|
10716
10739
|
const allowOwnerProfile = candidate.allowOwnerProfile;
|
|
10717
10740
|
const privateKey = candidate.privateKey;
|
|
10718
|
-
if (profile !== void 0 && typeof profile !== "string" || host !== void 0 && typeof host !== "string" || allowOwnerProfile !== void 0 && typeof allowOwnerProfile !== "boolean" || privateKey !== void 0 && typeof privateKey !== "string") {
|
|
10741
|
+
if (profile !== void 0 && typeof profile !== "string" || host !== void 0 && typeof host !== "string" || stateRoot !== void 0 && (typeof stateRoot !== "string" || !(0, import_node_path2.isAbsolute)(stateRoot)) || allowOwnerProfile !== void 0 && typeof allowOwnerProfile !== "boolean" || privateKey !== void 0 && typeof privateKey !== "string") {
|
|
10719
10742
|
return void 0;
|
|
10720
10743
|
}
|
|
10721
10744
|
return {
|
|
10722
10745
|
...profile === void 0 ? {} : { profile },
|
|
10723
10746
|
...host === void 0 ? {} : { host },
|
|
10747
|
+
...stateRoot === void 0 ? {} : { stateRoot },
|
|
10724
10748
|
...allowOwnerProfile === true ? { allowOwnerProfile: true } : {},
|
|
10725
10749
|
...privateKey === void 0 ? {} : { privateKey }
|
|
10726
10750
|
};
|