@agent-native/dispatch 0.7.0 → 0.8.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/README.md +37 -0
- package/dist/actions/apply-dream-proposal.d.ts +3 -0
- package/dist/actions/apply-dream-proposal.d.ts.map +1 -0
- package/dist/actions/apply-dream-proposal.js +11 -0
- package/dist/actions/apply-dream-proposal.js.map +1 -0
- package/dist/actions/create-dream-report.d.ts +3 -0
- package/dist/actions/create-dream-report.d.ts.map +1 -0
- package/dist/actions/create-dream-report.js +67 -0
- package/dist/actions/create-dream-report.js.map +1 -0
- package/dist/actions/create-workspace-resource.js +3 -3
- package/dist/actions/create-workspace-resource.js.map +1 -1
- package/dist/actions/delete-workspace-resource.js +1 -1
- package/dist/actions/delete-workspace-resource.js.map +1 -1
- package/dist/actions/ensure-dream-job.d.ts +3 -0
- package/dist/actions/ensure-dream-job.d.ts.map +1 -0
- package/dist/actions/ensure-dream-job.js +73 -0
- package/dist/actions/ensure-dream-job.js.map +1 -0
- package/dist/actions/get-dream-settings.d.ts +3 -0
- package/dist/actions/get-dream-settings.d.ts.map +1 -0
- package/dist/actions/get-dream-settings.js +11 -0
- package/dist/actions/get-dream-settings.js.map +1 -0
- package/dist/actions/get-dream.d.ts +3 -0
- package/dist/actions/get-dream.d.ts.map +1 -0
- package/dist/actions/get-dream.js +13 -0
- package/dist/actions/get-dream.js.map +1 -0
- package/dist/actions/get-workspace-resource-effective-context.d.ts +3 -0
- package/dist/actions/get-workspace-resource-effective-context.d.ts.map +1 -0
- package/dist/actions/get-workspace-resource-effective-context.js +27 -0
- package/dist/actions/get-workspace-resource-effective-context.js.map +1 -0
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/index.js +30 -4
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/list-dream-candidates.d.ts +3 -0
- package/dist/actions/list-dream-candidates.d.ts.map +1 -0
- package/dist/actions/list-dream-candidates.js +68 -0
- package/dist/actions/list-dream-candidates.js.map +1 -0
- package/dist/actions/list-dreams.d.ts +3 -0
- package/dist/actions/list-dreams.d.ts.map +1 -0
- package/dist/actions/list-dreams.js +17 -0
- package/dist/actions/list-dreams.js.map +1 -0
- package/dist/actions/list-workspace-resources-for-app.d.ts +3 -0
- package/dist/actions/list-workspace-resources-for-app.d.ts.map +1 -0
- package/dist/actions/list-workspace-resources-for-app.js +12 -0
- package/dist/actions/list-workspace-resources-for-app.js.map +1 -0
- package/dist/actions/list-workspace-resources.js +1 -1
- package/dist/actions/list-workspace-resources.js.map +1 -1
- package/dist/actions/navigate.d.ts +1 -0
- package/dist/actions/navigate.d.ts.map +1 -1
- package/dist/actions/navigate.js +2 -1
- package/dist/actions/navigate.js.map +1 -1
- package/dist/actions/preview-dream-proposal.d.ts +3 -0
- package/dist/actions/preview-dream-proposal.d.ts.map +1 -0
- package/dist/actions/preview-dream-proposal.js +13 -0
- package/dist/actions/preview-dream-proposal.js.map +1 -0
- package/dist/actions/preview-workspace-resource-change.d.ts +3 -0
- package/dist/actions/preview-workspace-resource-change.d.ts.map +1 -0
- package/dist/actions/preview-workspace-resource-change.js +24 -0
- package/dist/actions/preview-workspace-resource-change.js.map +1 -0
- package/dist/actions/reject-dream-proposal.d.ts +3 -0
- package/dist/actions/reject-dream-proposal.d.ts.map +1 -0
- package/dist/actions/reject-dream-proposal.js +12 -0
- package/dist/actions/reject-dream-proposal.js.map +1 -0
- package/dist/actions/restore-starter-workspace-resources.d.ts +3 -0
- package/dist/actions/restore-starter-workspace-resources.d.ts.map +1 -0
- package/dist/actions/restore-starter-workspace-resources.js +14 -0
- package/dist/actions/restore-starter-workspace-resources.js.map +1 -0
- package/dist/actions/send-code-agent-remote-command.d.ts +3 -0
- package/dist/actions/send-code-agent-remote-command.d.ts.map +1 -0
- package/dist/actions/send-code-agent-remote-command.js +53 -0
- package/dist/actions/send-code-agent-remote-command.js.map +1 -0
- package/dist/actions/set-dream-settings.d.ts +3 -0
- package/dist/actions/set-dream-settings.d.ts.map +1 -0
- package/dist/actions/set-dream-settings.js +41 -0
- package/dist/actions/set-dream-settings.js.map +1 -0
- package/dist/actions/update-workspace-resource.js +1 -1
- package/dist/actions/update-workspace-resource.js.map +1 -1
- package/dist/actions/view-screen.d.ts.map +1 -1
- package/dist/actions/view-screen.js +73 -2
- package/dist/actions/view-screen.js.map +1 -1
- package/dist/components/approval-value-block.d.ts +7 -0
- package/dist/components/approval-value-block.d.ts.map +1 -0
- package/dist/components/approval-value-block.js +22 -0
- package/dist/components/approval-value-block.js.map +1 -0
- package/dist/components/create-app-popover.d.ts.map +1 -1
- package/dist/components/create-app-popover.js +3 -2
- package/dist/components/create-app-popover.js.map +1 -1
- package/dist/components/layout/Layout.d.ts.map +1 -1
- package/dist/components/layout/Layout.js +8 -1
- package/dist/components/layout/Layout.js.map +1 -1
- package/dist/components/ui/chart.d.ts +1 -1
- package/dist/components/workspace-app-card.d.ts.map +1 -1
- package/dist/components/workspace-app-card.js +25 -4
- package/dist/components/workspace-app-card.js.map +1 -1
- package/dist/components/workspace-resource-effective-stack.d.ts +11 -0
- package/dist/components/workspace-resource-effective-stack.d.ts.map +1 -0
- package/dist/components/workspace-resource-effective-stack.js +59 -0
- package/dist/components/workspace-resource-effective-stack.js.map +1 -0
- package/dist/components/workspace-resource-impact-preview.d.ts +9 -0
- package/dist/components/workspace-resource-impact-preview.d.ts.map +1 -0
- package/dist/components/workspace-resource-impact-preview.js +39 -0
- package/dist/components/workspace-resource-impact-preview.js.map +1 -0
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/migrations.js +59 -0
- package/dist/db/migrations.js.map +1 -1
- package/dist/db/schema.d.ts +714 -0
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +44 -2
- package/dist/db/schema.js.map +1 -1
- package/dist/hooks/use-navigation-state.d.ts +3 -0
- package/dist/hooks/use-navigation-state.d.ts.map +1 -1
- package/dist/hooks/use-navigation-state.js +23 -3
- package/dist/hooks/use-navigation-state.js.map +1 -1
- package/dist/lib/utils.d.ts +2 -1
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +5 -1
- package/dist/lib/utils.js.map +1 -1
- package/dist/routes/index.d.ts.map +1 -1
- package/dist/routes/index.js +1 -0
- package/dist/routes/index.js.map +1 -1
- package/dist/routes/pages/approval.d.ts.map +1 -1
- package/dist/routes/pages/approval.js +4 -1
- package/dist/routes/pages/approval.js.map +1 -1
- package/dist/routes/pages/approvals.js +1 -1
- package/dist/routes/pages/approvals.js.map +1 -1
- package/dist/routes/pages/dream-settings.d.ts +34 -0
- package/dist/routes/pages/dream-settings.d.ts.map +1 -0
- package/dist/routes/pages/dream-settings.js +68 -0
- package/dist/routes/pages/dream-settings.js.map +1 -0
- package/dist/routes/pages/dreams.d.ts +5 -0
- package/dist/routes/pages/dreams.d.ts.map +1 -0
- package/dist/routes/pages/dreams.js +435 -0
- package/dist/routes/pages/dreams.js.map +1 -0
- package/dist/routes/pages/workspace.d.ts.map +1 -1
- package/dist/routes/pages/workspace.js +187 -35
- package/dist/routes/pages/workspace.js.map +1 -1
- package/dist/server/lib/app-creation-store.d.ts.map +1 -1
- package/dist/server/lib/app-creation-store.js +3 -2
- package/dist/server/lib/app-creation-store.js.map +1 -1
- package/dist/server/lib/dispatch-integrations.d.ts +1 -1
- package/dist/server/lib/dispatch-integrations.d.ts.map +1 -1
- package/dist/server/lib/dispatch-integrations.js +9 -4
- package/dist/server/lib/dispatch-integrations.js.map +1 -1
- package/dist/server/lib/dispatch-remote-commands.d.ts +83 -0
- package/dist/server/lib/dispatch-remote-commands.d.ts.map +1 -0
- package/dist/server/lib/dispatch-remote-commands.js +256 -0
- package/dist/server/lib/dispatch-remote-commands.js.map +1 -0
- package/dist/server/lib/dispatch-store.d.ts +26 -0
- package/dist/server/lib/dispatch-store.d.ts.map +1 -1
- package/dist/server/lib/dispatch-store.js +17 -1
- package/dist/server/lib/dispatch-store.js.map +1 -1
- package/dist/server/lib/dreams-store.d.ts +398 -0
- package/dist/server/lib/dreams-store.d.ts.map +1 -0
- package/dist/server/lib/dreams-store.js +2330 -0
- package/dist/server/lib/dreams-store.js.map +1 -0
- package/dist/server/lib/thread-debug-store.d.ts +2 -2
- package/dist/server/lib/vault-store.d.ts +1 -1
- package/dist/server/lib/workspace-resources-store.d.ts +181 -17
- package/dist/server/lib/workspace-resources-store.d.ts.map +1 -1
- package/dist/server/lib/workspace-resources-store.js +737 -108
- package/dist/server/lib/workspace-resources-store.js.map +1 -1
- package/package.json +4 -2
- package/src/actions/apply-dream-proposal.ts +12 -0
- package/src/actions/create-dream-report.ts +76 -0
- package/src/actions/create-workspace-resource.ts +3 -3
- package/src/actions/delete-workspace-resource.ts +1 -1
- package/src/actions/ensure-dream-job.ts +76 -0
- package/src/actions/get-dream-settings.ts +12 -0
- package/src/actions/get-dream.ts +14 -0
- package/src/actions/get-workspace-resource-effective-context.ts +34 -0
- package/src/actions/index.spec.ts +26 -0
- package/src/actions/index.ts +31 -4
- package/src/actions/list-dream-candidates.ts +77 -0
- package/src/actions/list-dreams.ts +17 -0
- package/src/actions/list-workspace-resources-for-app.ts +13 -0
- package/src/actions/list-workspace-resources.ts +1 -1
- package/src/actions/navigate.ts +2 -1
- package/src/actions/preview-dream-proposal.ts +14 -0
- package/src/actions/preview-workspace-resource-change.ts +25 -0
- package/src/actions/reject-dream-proposal.ts +12 -0
- package/src/actions/restore-starter-workspace-resources.ts +17 -0
- package/src/actions/send-code-agent-remote-command.ts +59 -0
- package/src/actions/set-dream-settings.spec.ts +81 -0
- package/src/actions/set-dream-settings.ts +44 -0
- package/src/actions/update-workspace-resource.ts +1 -1
- package/src/actions/view-screen.ts +90 -2
- package/src/components/approval-value-block.spec.tsx +59 -0
- package/src/components/approval-value-block.tsx +33 -0
- package/src/components/create-app-popover.tsx +3 -2
- package/src/components/layout/Layout.tsx +8 -0
- package/src/components/workspace-app-card.tsx +166 -1
- package/src/components/workspace-resource-effective-stack.spec.tsx +125 -0
- package/src/components/workspace-resource-effective-stack.tsx +141 -0
- package/src/components/workspace-resource-impact-preview.spec.tsx +147 -0
- package/src/components/workspace-resource-impact-preview.tsx +116 -0
- package/src/db/migrations.ts +59 -0
- package/src/db/schema.ts +46 -2
- package/src/hooks/use-navigation-state.ts +24 -5
- package/src/lib/utils.ts +6 -1
- package/src/routes/index.ts +1 -0
- package/src/routes/pages/approval.tsx +14 -1
- package/src/routes/pages/approvals.tsx +1 -1
- package/src/routes/pages/dream-settings.spec.ts +130 -0
- package/src/routes/pages/dream-settings.ts +103 -0
- package/src/routes/pages/dreams.tsx +1828 -0
- package/src/routes/pages/workspace.tsx +577 -97
- package/src/server/lib/app-creation-store.ts +3 -2
- package/src/server/lib/dispatch-integrations.ts +10 -3
- package/src/server/lib/dispatch-remote-commands.spec.ts +167 -0
- package/src/server/lib/dispatch-remote-commands.ts +375 -0
- package/src/server/lib/dispatch-store.ts +37 -1
- package/src/server/lib/dreams-store.spec.ts +1492 -0
- package/src/server/lib/dreams-store.ts +3168 -0
- package/src/server/lib/workspace-resource-approval-lifecycle.spec.ts +236 -0
- package/src/server/lib/workspace-resources-store.spec.ts +1106 -0
- package/src/server/lib/workspace-resources-store.ts +1001 -134
- package/dist/actions/sync-workspace-resources-to-all.d.ts +0 -3
- package/dist/actions/sync-workspace-resources-to-all.d.ts.map +0 -1
- package/dist/actions/sync-workspace-resources-to-all.js +0 -9
- package/dist/actions/sync-workspace-resources-to-all.js.map +0 -1
- package/dist/actions/sync-workspace-resources-to-app.d.ts +0 -3
- package/dist/actions/sync-workspace-resources-to-app.d.ts.map +0 -1
- package/dist/actions/sync-workspace-resources-to-app.js +0 -11
- package/dist/actions/sync-workspace-resources-to-app.js.map +0 -1
- package/src/actions/sync-workspace-resources-to-all.ts +0 -10
- package/src/actions/sync-workspace-resources-to-app.ts +0 -12
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
|
+
|
|
6
|
+
const ownerEmail = "owner+resource-lifecycle@example.test";
|
|
7
|
+
const approverEmail = "approver+resource-lifecycle@example.test";
|
|
8
|
+
const userEmail = "person+resource-lifecycle@example.test";
|
|
9
|
+
const orgId = "org_resource_lifecycle";
|
|
10
|
+
const resourcePath = "context/lifecycle-smoke.md";
|
|
11
|
+
|
|
12
|
+
const originalEnv = {
|
|
13
|
+
APP_NAME: process.env.APP_NAME,
|
|
14
|
+
DATABASE_URL: process.env.DATABASE_URL,
|
|
15
|
+
DATABASE_AUTH_TOKEN: process.env.DATABASE_AUTH_TOKEN,
|
|
16
|
+
DISPATCH_DATABASE_URL: process.env.DISPATCH_DATABASE_URL,
|
|
17
|
+
DISPATCH_DATABASE_AUTH_TOKEN: process.env.DISPATCH_DATABASE_AUTH_TOKEN,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
let tempDir: string | null = null;
|
|
21
|
+
|
|
22
|
+
function restoreEnv() {
|
|
23
|
+
for (const [key, value] of Object.entries(originalEnv)) {
|
|
24
|
+
if (value === undefined) delete process.env[key];
|
|
25
|
+
else process.env[key] = value;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function statementList(sql: string) {
|
|
30
|
+
return sql
|
|
31
|
+
.split(";")
|
|
32
|
+
.map((statement) => statement.trim())
|
|
33
|
+
.filter(Boolean);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
beforeEach(async () => {
|
|
37
|
+
tempDir = fs.mkdtempSync(
|
|
38
|
+
path.join(os.tmpdir(), "dispatch-resource-lifecycle-"),
|
|
39
|
+
);
|
|
40
|
+
process.env.DATABASE_URL = `file:${path.join(tempDir, "app.db")}`;
|
|
41
|
+
delete process.env.APP_NAME;
|
|
42
|
+
delete process.env.DATABASE_AUTH_TOKEN;
|
|
43
|
+
delete process.env.DISPATCH_DATABASE_URL;
|
|
44
|
+
delete process.env.DISPATCH_DATABASE_AUTH_TOKEN;
|
|
45
|
+
vi.resetModules();
|
|
46
|
+
|
|
47
|
+
const [{ getDbExec }, { dispatchMigrations }] = await Promise.all([
|
|
48
|
+
import("@agent-native/core/db"),
|
|
49
|
+
import("../../db/migrations.js"),
|
|
50
|
+
]);
|
|
51
|
+
const exec = getDbExec();
|
|
52
|
+
for (const migration of dispatchMigrations) {
|
|
53
|
+
for (const statement of statementList(migration.sql)) {
|
|
54
|
+
await exec.execute(statement);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
afterEach(async () => {
|
|
60
|
+
try {
|
|
61
|
+
const { closeDbExec } = await import("@agent-native/core/db");
|
|
62
|
+
await closeDbExec();
|
|
63
|
+
} catch {}
|
|
64
|
+
restoreEnv();
|
|
65
|
+
if (tempDir) {
|
|
66
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
67
|
+
tempDir = null;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe("workspace resource approval lifecycle", () => {
|
|
72
|
+
it("queues, approves, materializes, and explains inherited All-app context", async () => {
|
|
73
|
+
const [
|
|
74
|
+
{ getDbExec },
|
|
75
|
+
{ runWithRequestContext },
|
|
76
|
+
{ resourceGetByPath, resourcePut, SHARED_OWNER, WORKSPACE_OWNER },
|
|
77
|
+
{ putOrgSetting },
|
|
78
|
+
{
|
|
79
|
+
approveRequest,
|
|
80
|
+
createWorkspaceResource,
|
|
81
|
+
getWorkspaceResourceEffectiveContext,
|
|
82
|
+
listWorkspaceResourcesForApp,
|
|
83
|
+
},
|
|
84
|
+
] = await Promise.all([
|
|
85
|
+
import("@agent-native/core/db"),
|
|
86
|
+
import("@agent-native/core/server"),
|
|
87
|
+
import("@agent-native/core/resources/store"),
|
|
88
|
+
import("@agent-native/core/settings"),
|
|
89
|
+
import("./workspace-resources-store.js").then(async (resourcesStore) => {
|
|
90
|
+
const dispatchStore = await import("./dispatch-store.js");
|
|
91
|
+
return {
|
|
92
|
+
approveRequest: dispatchStore.approveRequest,
|
|
93
|
+
createWorkspaceResource: resourcesStore.createWorkspaceResource,
|
|
94
|
+
getWorkspaceResourceEffectiveContext:
|
|
95
|
+
resourcesStore.getWorkspaceResourceEffectiveContext,
|
|
96
|
+
listWorkspaceResourcesForApp:
|
|
97
|
+
resourcesStore.listWorkspaceResourcesForApp,
|
|
98
|
+
};
|
|
99
|
+
}),
|
|
100
|
+
]);
|
|
101
|
+
|
|
102
|
+
const exec = getDbExec();
|
|
103
|
+
|
|
104
|
+
await runWithRequestContext({ userEmail: ownerEmail, orgId }, async () => {
|
|
105
|
+
await putOrgSetting(orgId, "dispatch-approval-policy", {
|
|
106
|
+
enabled: true,
|
|
107
|
+
approverEmails: [approverEmail],
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const queued = await createWorkspaceResource({
|
|
111
|
+
kind: "knowledge",
|
|
112
|
+
name: "Lifecycle Smoke Context",
|
|
113
|
+
description: "A smoke-test resource for global inheritance.",
|
|
114
|
+
path: resourcePath,
|
|
115
|
+
content: "# Workspace lifecycle context",
|
|
116
|
+
scope: "all",
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
expect(queued).toEqual(
|
|
120
|
+
expect.objectContaining({
|
|
121
|
+
status: "pending",
|
|
122
|
+
changeType: "workspace-resource.create",
|
|
123
|
+
targetType: "workspace-knowledge",
|
|
124
|
+
}),
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
const beforeRows = await exec.execute({
|
|
128
|
+
sql: "SELECT * FROM workspace_resources WHERE path = ?",
|
|
129
|
+
args: [resourcePath],
|
|
130
|
+
});
|
|
131
|
+
expect(beforeRows.rows).toHaveLength(0);
|
|
132
|
+
await expect(
|
|
133
|
+
resourceGetByPath(WORKSPACE_OWNER, resourcePath),
|
|
134
|
+
).resolves.toBeNull();
|
|
135
|
+
|
|
136
|
+
await approveRequest((queued as any).id);
|
|
137
|
+
|
|
138
|
+
const approvalRows = await exec.execute({
|
|
139
|
+
sql: "SELECT status, reviewed_by FROM dispatch_approval_requests WHERE id = ?",
|
|
140
|
+
args: [(queued as any).id],
|
|
141
|
+
});
|
|
142
|
+
expect(approvalRows.rows[0]).toMatchObject({
|
|
143
|
+
status: "approved",
|
|
144
|
+
reviewed_by: ownerEmail,
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
const afterRows = await exec.execute({
|
|
148
|
+
sql: "SELECT path, scope, content FROM workspace_resources WHERE path = ?",
|
|
149
|
+
args: [resourcePath],
|
|
150
|
+
});
|
|
151
|
+
expect(afterRows.rows).toEqual([
|
|
152
|
+
expect.objectContaining({
|
|
153
|
+
path: resourcePath,
|
|
154
|
+
scope: "all",
|
|
155
|
+
content: "# Workspace lifecycle context",
|
|
156
|
+
}),
|
|
157
|
+
]);
|
|
158
|
+
|
|
159
|
+
const materialized = await resourceGetByPath(
|
|
160
|
+
WORKSPACE_OWNER,
|
|
161
|
+
resourcePath,
|
|
162
|
+
);
|
|
163
|
+
expect(materialized).toEqual(
|
|
164
|
+
expect.objectContaining({
|
|
165
|
+
owner: WORKSPACE_OWNER,
|
|
166
|
+
path: resourcePath,
|
|
167
|
+
content: "# Workspace lifecycle context",
|
|
168
|
+
}),
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
const appResources = await listWorkspaceResourcesForApp("analytics");
|
|
172
|
+
expect(appResources.resources).toEqual(
|
|
173
|
+
expect.arrayContaining([
|
|
174
|
+
expect.objectContaining({
|
|
175
|
+
path: resourcePath,
|
|
176
|
+
source: "workspace",
|
|
177
|
+
scope: "all",
|
|
178
|
+
grantId: null,
|
|
179
|
+
}),
|
|
180
|
+
]),
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
const inherited = await getWorkspaceResourceEffectiveContext({
|
|
184
|
+
path: resourcePath,
|
|
185
|
+
appId: "analytics",
|
|
186
|
+
userEmail,
|
|
187
|
+
});
|
|
188
|
+
expect(inherited).toMatchObject({
|
|
189
|
+
availability: "all-apps",
|
|
190
|
+
availableToApp: true,
|
|
191
|
+
effectiveScope: "workspace",
|
|
192
|
+
});
|
|
193
|
+
expect(inherited.layers.map((layer) => layer.scope)).toEqual([
|
|
194
|
+
"workspace",
|
|
195
|
+
"shared",
|
|
196
|
+
"personal",
|
|
197
|
+
]);
|
|
198
|
+
|
|
199
|
+
await resourcePut(SHARED_OWNER, resourcePath, "# Organization override");
|
|
200
|
+
|
|
201
|
+
const sharedOverride = await getWorkspaceResourceEffectiveContext({
|
|
202
|
+
path: resourcePath,
|
|
203
|
+
appId: "analytics",
|
|
204
|
+
userEmail,
|
|
205
|
+
});
|
|
206
|
+
expect(sharedOverride.effectiveScope).toBe("shared");
|
|
207
|
+
expect(
|
|
208
|
+
sharedOverride.layers.find((layer) => layer.scope === "workspace"),
|
|
209
|
+
).toMatchObject({ exists: true, overridden: true });
|
|
210
|
+
expect(
|
|
211
|
+
sharedOverride.layers.find((layer) => layer.scope === "shared"),
|
|
212
|
+
).toMatchObject({ exists: true, effective: true });
|
|
213
|
+
|
|
214
|
+
await resourcePut(userEmail, resourcePath, "# Personal override");
|
|
215
|
+
|
|
216
|
+
const personalOverride = await getWorkspaceResourceEffectiveContext({
|
|
217
|
+
path: resourcePath,
|
|
218
|
+
appId: "analytics",
|
|
219
|
+
userEmail,
|
|
220
|
+
});
|
|
221
|
+
expect(personalOverride.effectiveScope).toBe("personal");
|
|
222
|
+
expect(personalOverride.effectiveResource).toEqual(
|
|
223
|
+
expect.objectContaining({
|
|
224
|
+
owner: userEmail,
|
|
225
|
+
path: resourcePath,
|
|
226
|
+
}),
|
|
227
|
+
);
|
|
228
|
+
expect(
|
|
229
|
+
personalOverride.layers.find((layer) => layer.scope === "shared"),
|
|
230
|
+
).toMatchObject({ exists: true, overridden: true });
|
|
231
|
+
expect(
|
|
232
|
+
personalOverride.layers.find((layer) => layer.scope === "personal"),
|
|
233
|
+
).toMatchObject({ exists: true, effective: true });
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
});
|