@tinycloud/operations 0.4.0-beta.9 → 0.4.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 +6 -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 +162 -27
- 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 +162 -26
- package/dist/cli-runtime.js.map +1 -1
- package/dist/{contract-CjuEjE-M.d.cts → contract-BRwWJpPs.d.cts} +24 -2
- package/dist/{contract-CjuEjE-M.d.ts → contract-BRwWJpPs.d.ts} +24 -2
- package/dist/delegation-binding.cjs +79 -16
- package/dist/delegation-binding.cjs.map +1 -1
- package/dist/delegation-binding.d.cts +43 -13
- package/dist/delegation-binding.d.ts +43 -13
- package/dist/delegation-binding.js +78 -16
- package/dist/delegation-binding.js.map +1 -1
- package/dist/index.cjs +160 -28
- 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 +160 -27
- 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 +2661 -4
- package/package.json +4 -4
package/dist/artifacts.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import { PermissionEntry } from '@tinycloud/sdk-core';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { O as OperationSpaceResolver } from './authority-ofwbEqmj.cjs';
|
|
4
4
|
export { e as evaluateAuthority } from './authority-ofwbEqmj.cjs';
|
|
5
|
-
import { T as TinyCloudPosture, O as OperationOperatorType } from './contract-
|
|
5
|
+
import { T as TinyCloudPosture, O as OperationOperatorType } from './contract-BRwWJpPs.cjs';
|
|
6
6
|
|
|
7
7
|
/** The shared wire schema for SDK PermissionEntry values, including signed ReCap caveats. */
|
|
8
8
|
declare const PermissionEntrySchema: z.ZodObject<{
|
package/dist/artifacts.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { PermissionEntry } from '@tinycloud/sdk-core';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { O as OperationSpaceResolver } from './authority-ofwbEqmj.js';
|
|
4
4
|
export { e as evaluateAuthority } from './authority-ofwbEqmj.js';
|
|
5
|
-
import { T as TinyCloudPosture, O as OperationOperatorType } from './contract-
|
|
5
|
+
import { T as TinyCloudPosture, O as OperationOperatorType } from './contract-BRwWJpPs.js';
|
|
6
6
|
|
|
7
7
|
/** The shared wire schema for SDK PermissionEntry values, including signed ReCap caveats. */
|
|
8
8
|
declare const PermissionEntrySchema: z.ZodObject<{
|
package/dist/artifacts.js
CHANGED
|
@@ -253,8 +253,17 @@ function canonicalizeRecapCaveats(caveats) {
|
|
|
253
253
|
}
|
|
254
254
|
return `[${branches.join(",")}]`;
|
|
255
255
|
}
|
|
256
|
+
var EXPLICIT_ONLY_ACTIONS = {
|
|
257
|
+
"tinycloud.kv/sync": true,
|
|
258
|
+
"tinycloud.kv/retain": true
|
|
259
|
+
};
|
|
260
|
+
function isExplicitOnlyAction(action) {
|
|
261
|
+
return Object.prototype.hasOwnProperty.call(EXPLICIT_ONLY_ACTIONS, action);
|
|
262
|
+
}
|
|
256
263
|
function actionContains(grantedAction, requestedAction) {
|
|
257
|
-
if (grantedAction ===
|
|
264
|
+
if (grantedAction === requestedAction) return true;
|
|
265
|
+
if (isExplicitOnlyAction(requestedAction)) return false;
|
|
266
|
+
if (grantedAction === "*") return true;
|
|
258
267
|
if (!grantedAction.endsWith("/*")) return false;
|
|
259
268
|
const service = grantedAction.slice(0, -2);
|
|
260
269
|
return requestedAction === service || requestedAction.startsWith(`${service}/`);
|
|
@@ -568,7 +577,8 @@ async function acquireProfileLock(profile, options) {
|
|
|
568
577
|
const lockPath = profileLockPath(profile);
|
|
569
578
|
const turnDirectory = profileTurnLockPath(profile);
|
|
570
579
|
const directory = profilePath(profile);
|
|
571
|
-
|
|
580
|
+
if (options.requireProfile && !await exists(profileConfigPath(profile))) throw new ProfileDeletedError(profile);
|
|
581
|
+
if (!options.requireProfile) await mkdir(directory, { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
572
582
|
await mkdir(dirname(turnDirectory), { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
573
583
|
for (const path of [tinycloudHomePath(), profilesPath(), directory]) {
|
|
574
584
|
await chmod(path, PRIVATE_DIR_MODE).catch((error) => {
|
|
@@ -577,11 +587,15 @@ async function acquireProfileLock(profile, options) {
|
|
|
577
587
|
}
|
|
578
588
|
const { turn, firstWaitedTurn } = await acquireTurn(profile, turnDirectory, deadline);
|
|
579
589
|
try {
|
|
590
|
+
if (options.requireProfile && !await exists(profileConfigPath(profile))) {
|
|
591
|
+
await rmdir(directory).catch(() => void 0);
|
|
592
|
+
throw new ProfileDeletedError(profile);
|
|
593
|
+
}
|
|
580
594
|
const deletion = await readJson(join(turnDirectory, "deleted.json")).catch(() => null);
|
|
581
595
|
const deletedWhileWaiting = typeof deletion?.slot === "number" && deletion.slot >= firstWaitedTurn;
|
|
582
596
|
while (true) {
|
|
583
597
|
const token = randomUUID();
|
|
584
|
-
if (await publishProfileLock(profile, lockPath, token)) {
|
|
598
|
+
if (await publishProfileLock(profile, lockPath, token, options.requireProfile === true)) {
|
|
585
599
|
return {
|
|
586
600
|
deletedWhileWaiting,
|
|
587
601
|
turnSlot: turn.slot,
|
|
@@ -832,12 +846,13 @@ async function collectTurns(profile, turn) {
|
|
|
832
846
|
}
|
|
833
847
|
}
|
|
834
848
|
}
|
|
835
|
-
async function publishProfileLock(profile, lockPath, token) {
|
|
849
|
+
async function publishProfileLock(profile, lockPath, token, requireProfile) {
|
|
836
850
|
try {
|
|
837
851
|
await mkdir(lockPath, { mode: PRIVATE_DIR_MODE });
|
|
838
852
|
} catch (error) {
|
|
839
853
|
if (isErrno(error, "EEXIST")) return false;
|
|
840
854
|
if (!isErrno(error, "ENOENT")) throw error;
|
|
855
|
+
if (requireProfile) throw new ProfileDeletedError(profile);
|
|
841
856
|
await mkdir(profilePath(profile), { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
842
857
|
return false;
|
|
843
858
|
}
|