@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.js
CHANGED
|
@@ -355,8 +355,13 @@ function canonicalizeRecapCaveats(caveats) {
|
|
|
355
355
|
}
|
|
356
356
|
return `[${branches.join(",")}]`;
|
|
357
357
|
}
|
|
358
|
+
function isExplicitOnlyAction(action) {
|
|
359
|
+
return Object.prototype.hasOwnProperty.call(EXPLICIT_ONLY_ACTIONS, action);
|
|
360
|
+
}
|
|
358
361
|
function actionContains(grantedAction, requestedAction) {
|
|
359
|
-
if (grantedAction ===
|
|
362
|
+
if (grantedAction === requestedAction) return true;
|
|
363
|
+
if (isExplicitOnlyAction(requestedAction)) return false;
|
|
364
|
+
if (grantedAction === "*") return true;
|
|
360
365
|
if (!grantedAction.endsWith("/*")) return false;
|
|
361
366
|
const service = grantedAction.slice(0, -2);
|
|
362
367
|
return requestedAction === service || requestedAction.startsWith(`${service}/`);
|
|
@@ -381,10 +386,15 @@ function cloneEntry(entry) {
|
|
|
381
386
|
...entry.expiry !== void 0 ? { expiry: entry.expiry } : {}
|
|
382
387
|
};
|
|
383
388
|
}
|
|
389
|
+
var EXPLICIT_ONLY_ACTIONS;
|
|
384
390
|
var init_capabilities = __esm({
|
|
385
391
|
"../sdk-core/src/capabilities.ts"() {
|
|
386
392
|
"use strict";
|
|
387
393
|
init_manifest();
|
|
394
|
+
EXPLICIT_ONLY_ACTIONS = {
|
|
395
|
+
"tinycloud.kv/sync": true,
|
|
396
|
+
"tinycloud.kv/retain": true
|
|
397
|
+
};
|
|
388
398
|
}
|
|
389
399
|
});
|
|
390
400
|
|
|
@@ -727,7 +737,8 @@ async function acquireProfileLock(profile, options) {
|
|
|
727
737
|
const lockPath = profileLockPath(profile);
|
|
728
738
|
const turnDirectory = profileTurnLockPath(profile);
|
|
729
739
|
const directory = profilePath(profile);
|
|
730
|
-
|
|
740
|
+
if (options.requireProfile && !await exists(profileConfigPath(profile))) throw new ProfileDeletedError(profile);
|
|
741
|
+
if (!options.requireProfile) await mkdir(directory, { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
731
742
|
await mkdir(dirname(turnDirectory), { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
732
743
|
for (const path of [tinycloudHomePath(), profilesPath(), directory]) {
|
|
733
744
|
await chmod(path, PRIVATE_DIR_MODE).catch((error) => {
|
|
@@ -736,11 +747,15 @@ async function acquireProfileLock(profile, options) {
|
|
|
736
747
|
}
|
|
737
748
|
const { turn, firstWaitedTurn } = await acquireTurn(profile, turnDirectory, deadline);
|
|
738
749
|
try {
|
|
750
|
+
if (options.requireProfile && !await exists(profileConfigPath(profile))) {
|
|
751
|
+
await rmdir(directory).catch(() => void 0);
|
|
752
|
+
throw new ProfileDeletedError(profile);
|
|
753
|
+
}
|
|
739
754
|
const deletion = await readJson(join(turnDirectory, "deleted.json")).catch(() => null);
|
|
740
755
|
const deletedWhileWaiting = typeof deletion?.slot === "number" && deletion.slot >= firstWaitedTurn;
|
|
741
756
|
while (true) {
|
|
742
757
|
const token = randomUUID();
|
|
743
|
-
if (await publishProfileLock(profile, lockPath, token)) {
|
|
758
|
+
if (await publishProfileLock(profile, lockPath, token, options.requireProfile === true)) {
|
|
744
759
|
return {
|
|
745
760
|
deletedWhileWaiting,
|
|
746
761
|
turnSlot: turn.slot,
|
|
@@ -985,12 +1000,13 @@ async function collectTurns(profile, turn) {
|
|
|
985
1000
|
}
|
|
986
1001
|
}
|
|
987
1002
|
}
|
|
988
|
-
async function publishProfileLock(profile, lockPath, token) {
|
|
1003
|
+
async function publishProfileLock(profile, lockPath, token, requireProfile) {
|
|
989
1004
|
try {
|
|
990
1005
|
await mkdir(lockPath, { mode: PRIVATE_DIR_MODE });
|
|
991
1006
|
} catch (error) {
|
|
992
1007
|
if (isErrno(error, "EEXIST")) return false;
|
|
993
1008
|
if (!isErrno(error, "ENOENT")) throw error;
|
|
1009
|
+
if (requireProfile) throw new ProfileDeletedError(profile);
|
|
994
1010
|
await mkdir(profilePath(profile), { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
995
1011
|
return false;
|
|
996
1012
|
}
|