@tinycloud/operations 0.4.0-beta.12 → 0.4.0-beta.14
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/coverage.json +6 -0
- package/dist/artifacts.cjs +19 -4
- package/dist/artifacts.cjs.map +1 -1
- package/dist/artifacts.js +19 -4
- package/dist/artifacts.js.map +1 -1
- package/dist/cli-runtime.cjs +20 -4
- package/dist/cli-runtime.cjs.map +1 -1
- package/dist/cli-runtime.js +20 -4
- package/dist/cli-runtime.js.map +1 -1
- package/dist/delegation-binding.cjs +19 -4
- package/dist/delegation-binding.cjs.map +1 -1
- package/dist/delegation-binding.js +19 -4
- package/dist/delegation-binding.js.map +1 -1
- package/dist/index.cjs +20 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -4
- package/dist/index.js.map +1 -1
- package/dist/profile.cjs.map +1 -1
- package/dist/profile.js.map +1 -1
- package/dist/state.cjs +9 -3
- package/dist/state.cjs.map +1 -1
- package/dist/state.d.cts +7 -0
- package/dist/state.d.ts +7 -0
- package/dist/state.js +9 -3
- package/dist/state.js.map +1 -1
- package/package.json +4 -4
package/dist/cli-runtime.cjs
CHANGED
|
@@ -357,8 +357,13 @@ function canonicalizeRecapCaveats(caveats) {
|
|
|
357
357
|
}
|
|
358
358
|
return `[${branches.join(",")}]`;
|
|
359
359
|
}
|
|
360
|
+
function isExplicitOnlyAction(action) {
|
|
361
|
+
return Object.prototype.hasOwnProperty.call(EXPLICIT_ONLY_ACTIONS, action);
|
|
362
|
+
}
|
|
360
363
|
function actionContains(grantedAction, requestedAction) {
|
|
361
|
-
if (grantedAction ===
|
|
364
|
+
if (grantedAction === requestedAction) return true;
|
|
365
|
+
if (isExplicitOnlyAction(requestedAction)) return false;
|
|
366
|
+
if (grantedAction === "*") return true;
|
|
362
367
|
if (!grantedAction.endsWith("/*")) return false;
|
|
363
368
|
const service = grantedAction.slice(0, -2);
|
|
364
369
|
return requestedAction === service || requestedAction.startsWith(`${service}/`);
|
|
@@ -383,10 +388,15 @@ function cloneEntry(entry) {
|
|
|
383
388
|
...entry.expiry !== void 0 ? { expiry: entry.expiry } : {}
|
|
384
389
|
};
|
|
385
390
|
}
|
|
391
|
+
var EXPLICIT_ONLY_ACTIONS;
|
|
386
392
|
var init_capabilities = __esm({
|
|
387
393
|
"../sdk-core/src/capabilities.ts"() {
|
|
388
394
|
"use strict";
|
|
389
395
|
init_manifest();
|
|
396
|
+
EXPLICIT_ONLY_ACTIONS = {
|
|
397
|
+
"tinycloud.kv/sync": true,
|
|
398
|
+
"tinycloud.kv/retain": true
|
|
399
|
+
};
|
|
390
400
|
}
|
|
391
401
|
});
|
|
392
402
|
|
|
@@ -711,7 +721,8 @@ async function acquireProfileLock(profile, options) {
|
|
|
711
721
|
const lockPath = profileLockPath(profile);
|
|
712
722
|
const turnDirectory = profileTurnLockPath(profile);
|
|
713
723
|
const directory = profilePath(profile);
|
|
714
|
-
|
|
724
|
+
if (options.requireProfile && !await exists(profileConfigPath(profile))) throw new ProfileDeletedError(profile);
|
|
725
|
+
if (!options.requireProfile) await (0, import_promises.mkdir)(directory, { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
715
726
|
await (0, import_promises.mkdir)((0, import_node_path.dirname)(turnDirectory), { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
716
727
|
for (const path of [tinycloudHomePath(), profilesPath(), directory]) {
|
|
717
728
|
await (0, import_promises.chmod)(path, PRIVATE_DIR_MODE).catch((error) => {
|
|
@@ -720,11 +731,15 @@ async function acquireProfileLock(profile, options) {
|
|
|
720
731
|
}
|
|
721
732
|
const { turn, firstWaitedTurn } = await acquireTurn(profile, turnDirectory, deadline);
|
|
722
733
|
try {
|
|
734
|
+
if (options.requireProfile && !await exists(profileConfigPath(profile))) {
|
|
735
|
+
await (0, import_promises.rmdir)(directory).catch(() => void 0);
|
|
736
|
+
throw new ProfileDeletedError(profile);
|
|
737
|
+
}
|
|
723
738
|
const deletion = await readJson((0, import_node_path.join)(turnDirectory, "deleted.json")).catch(() => null);
|
|
724
739
|
const deletedWhileWaiting = typeof deletion?.slot === "number" && deletion.slot >= firstWaitedTurn;
|
|
725
740
|
while (true) {
|
|
726
741
|
const token = (0, import_node_crypto.randomUUID)();
|
|
727
|
-
if (await publishProfileLock(profile, lockPath, token)) {
|
|
742
|
+
if (await publishProfileLock(profile, lockPath, token, options.requireProfile === true)) {
|
|
728
743
|
return {
|
|
729
744
|
deletedWhileWaiting,
|
|
730
745
|
turnSlot: turn.slot,
|
|
@@ -969,12 +984,13 @@ async function collectTurns(profile, turn) {
|
|
|
969
984
|
}
|
|
970
985
|
}
|
|
971
986
|
}
|
|
972
|
-
async function publishProfileLock(profile, lockPath, token) {
|
|
987
|
+
async function publishProfileLock(profile, lockPath, token, requireProfile) {
|
|
973
988
|
try {
|
|
974
989
|
await (0, import_promises.mkdir)(lockPath, { mode: PRIVATE_DIR_MODE });
|
|
975
990
|
} catch (error) {
|
|
976
991
|
if (isErrno(error, "EEXIST")) return false;
|
|
977
992
|
if (!isErrno(error, "ENOENT")) throw error;
|
|
993
|
+
if (requireProfile) throw new ProfileDeletedError(profile);
|
|
978
994
|
await (0, import_promises.mkdir)(profilePath(profile), { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
979
995
|
return false;
|
|
980
996
|
}
|