@tinycloud/operations 0.4.0-beta.9 → 0.5.0-beta.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/coverage.json +9 -0
- package/dist/artifacts.cjs +19 -4
- 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 +19 -4
- package/dist/artifacts.js.map +1 -1
- package/dist/cli-runtime.cjs +4353 -659
- 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 +4348 -654
- package/dist/cli-runtime.js.map +1 -1
- package/dist/{contract-CjuEjE-M.d.cts → contract-DfyrluLB.d.cts} +24 -2
- package/dist/{contract-CjuEjE-M.d.ts → contract-DfyrluLB.d.ts} +24 -2
- package/dist/delegation-binding.cjs +3797 -253
- package/dist/delegation-binding.cjs.map +1 -1
- package/dist/delegation-binding.d.cts +104 -60
- package/dist/delegation-binding.d.ts +104 -60
- package/dist/delegation-binding.js +3773 -238
- package/dist/delegation-binding.js.map +1 -1
- package/dist/index.cjs +4349 -658
- 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 +4343 -652
- package/dist/index.js.map +1 -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.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/generated/operations.json +2665 -8
- package/package.json +4 -4
package/coverage.json
CHANGED
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
{ "command": "enable", "status": "legacy" },
|
|
8
8
|
{ "command": "enable share", "status": "legacy" },
|
|
9
9
|
{ "command": "auth", "status": "legacy" },
|
|
10
|
+
{ "command": "auth grants", "status": "legacy" },
|
|
11
|
+
{ "command": "auth grants list", "status": "legacy" },
|
|
12
|
+
{ "command": "auth grants remove <cid>", "status": "legacy" },
|
|
10
13
|
{ "command": "auth login", "status": "legacy" },
|
|
11
14
|
{ "command": "auth logout", "status": "legacy" },
|
|
12
15
|
{ "command": "auth rotate", "status": "legacy" },
|
|
@@ -35,6 +38,12 @@
|
|
|
35
38
|
{ "command": "kv delete <key>", "status": "legacy" },
|
|
36
39
|
{ "command": "kv list", "status": "legacy" },
|
|
37
40
|
{ "command": "kv head <key>", "status": "legacy" },
|
|
41
|
+
{ "command": "replica", "status": "legacy" },
|
|
42
|
+
{ "command": "replica sync", "status": "legacy" },
|
|
43
|
+
{ "command": "replica get <key>", "status": "legacy" },
|
|
44
|
+
{ "command": "replica list [prefix]", "status": "legacy" },
|
|
45
|
+
{ "command": "replica status", "status": "legacy" },
|
|
46
|
+
{ "command": "replica reset", "status": "legacy" },
|
|
38
47
|
{ "command": "space", "status": "legacy" },
|
|
39
48
|
{ "command": "space list", "status": "legacy" },
|
|
40
49
|
{ "command": "space create <name>", "status": "legacy" },
|
package/dist/artifacts.cjs
CHANGED
|
@@ -278,8 +278,17 @@ function canonicalizeRecapCaveats(caveats) {
|
|
|
278
278
|
}
|
|
279
279
|
return `[${branches.join(",")}]`;
|
|
280
280
|
}
|
|
281
|
+
var EXPLICIT_ONLY_ACTIONS = {
|
|
282
|
+
"tinycloud.kv/sync": true,
|
|
283
|
+
"tinycloud.kv/retain": true
|
|
284
|
+
};
|
|
285
|
+
function isExplicitOnlyAction(action) {
|
|
286
|
+
return Object.prototype.hasOwnProperty.call(EXPLICIT_ONLY_ACTIONS, action);
|
|
287
|
+
}
|
|
281
288
|
function actionContains(grantedAction, requestedAction) {
|
|
282
|
-
if (grantedAction ===
|
|
289
|
+
if (grantedAction === requestedAction) return true;
|
|
290
|
+
if (isExplicitOnlyAction(requestedAction)) return false;
|
|
291
|
+
if (grantedAction === "*") return true;
|
|
283
292
|
if (!grantedAction.endsWith("/*")) return false;
|
|
284
293
|
const service = grantedAction.slice(0, -2);
|
|
285
294
|
return requestedAction === service || requestedAction.startsWith(`${service}/`);
|
|
@@ -580,7 +589,8 @@ async function acquireProfileLock(profile, options) {
|
|
|
580
589
|
const lockPath = profileLockPath(profile);
|
|
581
590
|
const turnDirectory = profileTurnLockPath(profile);
|
|
582
591
|
const directory = profilePath(profile);
|
|
583
|
-
|
|
592
|
+
if (options.requireProfile && !await exists(profileConfigPath(profile))) throw new ProfileDeletedError(profile);
|
|
593
|
+
if (!options.requireProfile) await (0, import_promises.mkdir)(directory, { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
584
594
|
await (0, import_promises.mkdir)((0, import_node_path.dirname)(turnDirectory), { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
585
595
|
for (const path of [tinycloudHomePath(), profilesPath(), directory]) {
|
|
586
596
|
await (0, import_promises.chmod)(path, PRIVATE_DIR_MODE).catch((error) => {
|
|
@@ -589,11 +599,15 @@ async function acquireProfileLock(profile, options) {
|
|
|
589
599
|
}
|
|
590
600
|
const { turn, firstWaitedTurn } = await acquireTurn(profile, turnDirectory, deadline);
|
|
591
601
|
try {
|
|
602
|
+
if (options.requireProfile && !await exists(profileConfigPath(profile))) {
|
|
603
|
+
await (0, import_promises.rmdir)(directory).catch(() => void 0);
|
|
604
|
+
throw new ProfileDeletedError(profile);
|
|
605
|
+
}
|
|
592
606
|
const deletion = await readJson((0, import_node_path.join)(turnDirectory, "deleted.json")).catch(() => null);
|
|
593
607
|
const deletedWhileWaiting = typeof deletion?.slot === "number" && deletion.slot >= firstWaitedTurn;
|
|
594
608
|
while (true) {
|
|
595
609
|
const token = (0, import_node_crypto.randomUUID)();
|
|
596
|
-
if (await publishProfileLock(profile, lockPath, token)) {
|
|
610
|
+
if (await publishProfileLock(profile, lockPath, token, options.requireProfile === true)) {
|
|
597
611
|
return {
|
|
598
612
|
deletedWhileWaiting,
|
|
599
613
|
turnSlot: turn.slot,
|
|
@@ -844,12 +858,13 @@ async function collectTurns(profile, turn) {
|
|
|
844
858
|
}
|
|
845
859
|
}
|
|
846
860
|
}
|
|
847
|
-
async function publishProfileLock(profile, lockPath, token) {
|
|
861
|
+
async function publishProfileLock(profile, lockPath, token, requireProfile) {
|
|
848
862
|
try {
|
|
849
863
|
await (0, import_promises.mkdir)(lockPath, { mode: PRIVATE_DIR_MODE });
|
|
850
864
|
} catch (error) {
|
|
851
865
|
if (isErrno(error, "EEXIST")) return false;
|
|
852
866
|
if (!isErrno(error, "ENOENT")) throw error;
|
|
867
|
+
if (requireProfile) throw new ProfileDeletedError(profile);
|
|
853
868
|
await (0, import_promises.mkdir)(profilePath(profile), { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
854
869
|
return false;
|
|
855
870
|
}
|