Skip to content

Commit

Permalink
More vaults to spaces (#8394)
Browse files Browse the repository at this point in the history
  • Loading branch information
flvndvd authored Oct 31, 2024
1 parent 6fda99a commit 65a207b
Show file tree
Hide file tree
Showing 40 changed files with 153 additions and 152 deletions.
2 changes: 1 addition & 1 deletion front/admin/init_dust_apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function main() {
});

const group = await GroupResource.makeNew({
name: `Group for vault Public Dust Apps`,
name: `Group for space Public Dust Apps`,
workspaceId: w.id,
kind: "regular",
});
Expand Down
4 changes: 2 additions & 2 deletions front/components/ViewFolderAPIModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ export function ViewFolderAPIModal({
const cURLRequest = (type: "upsert" | "search") => {
switch (type) {
case "upsert":
return `curl "${process.env.NEXT_PUBLIC_DUST_CLIENT_FACING_URL}/api/v1/w/${owner.sId}/vaults/${space.sId}/data_sources/${dataSource.sId}/documents/YOUR_DOCUMENT_ID" \\
return `curl "${process.env.NEXT_PUBLIC_DUST_CLIENT_FACING_URL}/api/v1/w/${owner.sId}/spaces/${space.sId}/data_sources/${dataSource.sId}/documents/YOUR_DOCUMENT_ID" \\
-H "Authorization: Bearer YOUR_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{
"text": "Lorem ipsum dolor sit amet...",
"source_url": "https://acme.com"
}'`;
case "search":
return `curl "${process.env.NEXT_PUBLIC_DUST_CLIENT_FACING_URL}/api/v1/w/${owner.sId}/vaults/${space.sId}/data_sources/${dataSource.sId}/search?query=foo+bar&top_k=16&full_text=false" \\
return `curl "${process.env.NEXT_PUBLIC_DUST_CLIENT_FACING_URL}/api/v1/w/${owner.sId}/spaces/${space.sId}/data_sources/${dataSource.sId}/search?query=foo+bar&top_k=16&full_text=false" \\
-H "Authorization: Bearer YOUR_API_KEY"`;
default:
assertNever(type);
Expand Down
4 changes: 2 additions & 2 deletions front/components/app/Deploy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function ViewAppAPIModal({
const cURLRequest = (type: "run") => {
switch (type) {
case "run":
return `curl ${process.env.NEXT_PUBLIC_DUST_CLIENT_FACING_URL}/api/v1/w/${owner.sId}/vaults/${app.space.sId}/apps/${app.sId}/runs \\
return `curl ${process.env.NEXT_PUBLIC_DUST_CLIENT_FACING_URL}/api/v1/w/${owner.sId}/spaces/${app.space.sId}/apps/${app.sId}/runs \\
-H "Authorization: Bearer YOUR_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{
Expand Down Expand Up @@ -103,7 +103,7 @@ export function ViewAppAPIModal({
<Page.P>
<ul className="text-gray-500">
<li>
vaultId: <span className="font-bold">{app.space.sId}</span>{" "}
spaceId: <span className="font-bold">{app.space.sId}</span>{" "}
</li>
<li>
appId: <span className="font-bold">{app.sId}</span>
Expand Down
2 changes: 1 addition & 1 deletion front/components/poke/plans/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export const PLAN_FIELDS = {
maxVaults: {
type: "number",
width: "small",
title: "# Vaults",
title: "# Spaces",
error: (plan: EditingPlanType) => errorCheckNumber(plan.maxVaults),
},
trialPeriodDays: {
Expand Down
2 changes: 1 addition & 1 deletion front/lib/api/assistant/actions/dust_app_run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ export class DustAppRunConfigurationServerRunner extends BaseActionConfiguration
{
workspaceId: actionConfiguration.appWorkspaceId,
appId: actionConfiguration.appId,
appVaultId: app.space.sId,
appSpaceId: app.space.sId,
appHash: "latest",
},
appConfig,
Expand Down
2 changes: 1 addition & 1 deletion front/lib/api/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const config = {
"DEVELOPMENT_DUST_APPS_WORKSPACE_ID"
);
},
getDevelopmentDustAppsVaultId: (): string | undefined => {
getDevelopmentDustAppsSpaceId: (): string | undefined => {
return EnvironmentConfig.getOptionalEnvVariable(
"DEVELOPMENT_DUST_APPS_VAULT_ID"
);
Expand Down
8 changes: 4 additions & 4 deletions front/lib/api/spaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { DataSourceViewResource } from "@app/lib/resources/data_source_view_reso
import { KeyResource } from "@app/lib/resources/key_resource";
import type { SpaceResource } from "@app/lib/resources/space_resource";
import { frontSequelize } from "@app/lib/resources/storage";
import { launchScrubVaultWorkflow } from "@app/poke/temporal/client";
import { launchScrubSpaceWorkflow } from "@app/poke/temporal/client";

export async function softDeleteSpaceAndLaunchScrubWorkflow(
auth: Authenticator,
Expand Down Expand Up @@ -90,7 +90,7 @@ export async function softDeleteSpaceAndLaunchScrubWorkflow(
throw res.error;
}

await launchScrubVaultWorkflow(auth, space);
await launchScrubSpaceWorkflow(auth, space);
});

return new Ok(undefined);
Expand All @@ -105,9 +105,9 @@ export async function hardDeleteSpace(
): Promise<Result<void, Error>> {
assert(auth.isAdmin(), "Only admins can delete spaces.");

const isDeletableVault =
const isDeletableSpace =
space.isDeleted() || space.isGlobal() || space.isSystem();
assert(isDeletableVault, "Vault is not soft deleted.");
assert(isDeletableSpace, "Space is not soft deleted.");

const dataSourceViews = await DataSourceViewResource.listBySpace(
auth,
Expand Down
42 changes: 21 additions & 21 deletions front/lib/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import config from "@app/lib/api/config";

export const PRODUCTION_DUST_WORKSPACE_ID = "0ec9852c2f";
export const PRODUCTION_DUST_APPS_WORKSPACE_ID = "78bda07b39";
export const PRODUCTION_DUST_APPS_VAULT_ID = "vlt_rICtlrSEpWqX";
export const PRODUCTION_DUST_APPS_SPACE_ID = "vlt_rICtlrSEpWqX";
export const PRODUCTION_DUST_APPS_HELPER_DATASOURCE_VIEW_ID =
"dsv_artLN7ZRrKWB";
export type Action = {
app: {
workspaceId: string;
appId: string;
appHash: string;
appVaultId: string;
appSpaceId: string;
};
config: { [key: string]: unknown };
};
Expand All @@ -21,18 +21,18 @@ const createActionRegistry = <K extends string, R extends Record<K, Action>>(
registry: R
) => {
const developmentWorkspaceId = config.getDevelopmentDustAppsWorkspaceId();
const developmentVaultId = config.getDevelopmentDustAppsVaultId();
const developmentSpaceId = config.getDevelopmentDustAppsSpaceId();

if (isDevelopment() && developmentWorkspaceId) {
if (!developmentVaultId) {
if (!developmentSpaceId) {
throw new Error(
"DEVELOPMENT_DUST_APPS_VAULT_ID must be set in development if DEVELOPMENT_DUST_APPS_WORKSPACE_ID is set"
);
}
const actions: Action[] = Object.values(registry);
actions.forEach((action) => {
action.app.workspaceId = developmentWorkspaceId;
action.app.appVaultId = developmentVaultId;
action.app.appSpaceId = developmentSpaceId;
});
}

Expand All @@ -46,7 +46,7 @@ export const DustProdActionRegistry = createActionRegistry({
appId: "0e9889c787",
appHash:
"4e896f08ef6c2c69c97610c861cd444e3d34c839eab44f9b4fd7dd1d166c40a2",
appVaultId: PRODUCTION_DUST_APPS_VAULT_ID,
appSpaceId: PRODUCTION_DUST_APPS_SPACE_ID,
},
config: {
MODEL: {
Expand All @@ -63,7 +63,7 @@ export const DustProdActionRegistry = createActionRegistry({
appId: "84dfc1d4f7",
appHash:
"6ea231add2ae690ee959c5d8d5d06420ea2feae7dd32ac13a4e655910087e313",
appVaultId: PRODUCTION_DUST_APPS_VAULT_ID,
appSpaceId: PRODUCTION_DUST_APPS_SPACE_ID,
},
config: {
MODEL: {
Expand All @@ -79,7 +79,7 @@ export const DustProdActionRegistry = createActionRegistry({
appId: "471b6aa923",
appHash:
"3b634a84930020a7a18d3b32f4c5f5cd85690bf4958127ba51061fb101edea33",
appVaultId: PRODUCTION_DUST_APPS_VAULT_ID,
appSpaceId: PRODUCTION_DUST_APPS_SPACE_ID,
},
config: {
DATASOURCE: {
Expand All @@ -96,7 +96,7 @@ export const DustProdActionRegistry = createActionRegistry({
appId: "953b79fe89",
appHash:
"06e0af3c215ee205d2eff01826f763e36f5694c0650bf645ab156ee189e50b3a",
appVaultId: PRODUCTION_DUST_APPS_VAULT_ID,
appSpaceId: PRODUCTION_DUST_APPS_SPACE_ID,
},
config: {
DATASOURCE: {
Expand All @@ -119,7 +119,7 @@ export const DustProdActionRegistry = createActionRegistry({
appId: "4180309c80",
appHash:
"8adcc9ae33a63cc735c9a23a97d7bffe658c6ef2400fc997e61e8817f611a1f8",
appVaultId: PRODUCTION_DUST_APPS_VAULT_ID,
appSpaceId: PRODUCTION_DUST_APPS_SPACE_ID,
},
config: {
SEMANTIC_SEARCH: {
Expand All @@ -143,7 +143,7 @@ export const DustProdActionRegistry = createActionRegistry({
appId: "76b40f14fb",
appHash:
"d06ec19c9196fdecda4c37f0f96c00343fcf401e0e9d206c1b12618292c6462a",
appVaultId: PRODUCTION_DUST_APPS_VAULT_ID,
appSpaceId: PRODUCTION_DUST_APPS_SPACE_ID,
},
config: {
SUGGEST_CHANGES: {
Expand All @@ -159,7 +159,7 @@ export const DustProdActionRegistry = createActionRegistry({
appId: "b4f205e453",
appHash:
"59b0d9aa49ed9232f88f3ac1cd260ae25e0cd68e0622058c87cd4a42edce18da",
appVaultId: PRODUCTION_DUST_APPS_VAULT_ID,
appSpaceId: PRODUCTION_DUST_APPS_SPACE_ID,
},
config: {
MODEL: {
Expand All @@ -175,7 +175,7 @@ export const DustProdActionRegistry = createActionRegistry({
appId: "098b515f8e",
appHash:
"514d54c0967638656b437417228efec26de465796b5ab67ae0480d6976250768",
appVaultId: PRODUCTION_DUST_APPS_VAULT_ID,
appSpaceId: PRODUCTION_DUST_APPS_SPACE_ID,
},
config: { SEARCH: { provider_id: "serpapi", use_cache: false } },
},
Expand All @@ -185,7 +185,7 @@ export const DustProdActionRegistry = createActionRegistry({
appId: "21092925b9",
appHash:
"766618e57ff6600cac27d170395c74f4067e8671ef5bf36db5a820fb411f044b",
appVaultId: PRODUCTION_DUST_APPS_VAULT_ID,
appSpaceId: PRODUCTION_DUST_APPS_SPACE_ID,
},
config: {
WEBCONTENT: {
Expand All @@ -201,7 +201,7 @@ export const DustProdActionRegistry = createActionRegistry({
appId: "d995d868a8",
appHash:
"7fb9c826d9de74c98de2a675093f66eab9da93a1a2cb9bc0bcc919fd074cd7eb",
appVaultId: PRODUCTION_DUST_APPS_VAULT_ID,
appSpaceId: PRODUCTION_DUST_APPS_SPACE_ID,
},
config: {
CREATE_SUGGESTIONS: {
Expand All @@ -217,7 +217,7 @@ export const DustProdActionRegistry = createActionRegistry({
appId: "34a8c4a2aa",
appHash:
"65020161030b555f4d2efc9d1ce3a6d0020dcf76e663f746bd98213c90a0675f",
appVaultId: PRODUCTION_DUST_APPS_VAULT_ID,
appSpaceId: PRODUCTION_DUST_APPS_SPACE_ID,
},
config: {
CREATE_SUGGESTIONS: {
Expand All @@ -233,7 +233,7 @@ export const DustProdActionRegistry = createActionRegistry({
appId: "b69YdlJ3PJ",
appHash:
"0b6b63def0224321f2bece0751bad632baca33f6d5bb596bbeb3f95b6bea5966",
appVaultId: PRODUCTION_DUST_APPS_VAULT_ID,
appSpaceId: PRODUCTION_DUST_APPS_SPACE_ID,
},
config: {
CREATE_SUGGESTIONS: {
Expand All @@ -249,7 +249,7 @@ export const DustProdActionRegistry = createActionRegistry({
appId: "aba0057f4c",
appHash:
"e4bda2ba50f160712c08309628b4a6bf2b68dd7e9709669cc29ac43e36d663f7",
appVaultId: PRODUCTION_DUST_APPS_VAULT_ID,
appSpaceId: PRODUCTION_DUST_APPS_SPACE_ID,
},
config: {
CREATE_SUGGESTIONS: {
Expand All @@ -265,7 +265,7 @@ export const DustProdActionRegistry = createActionRegistry({
appId: "b36c7416bd",
appHash:
"1ca7b9568681b06ef6cc0830239a479644a3ecc203c812983f3386a72e214d48",
appVaultId: PRODUCTION_DUST_APPS_VAULT_ID,
appSpaceId: PRODUCTION_DUST_APPS_SPACE_ID,
},
config: {
MODEL: {
Expand All @@ -281,7 +281,7 @@ export const DustProdActionRegistry = createActionRegistry({
appId: "tWcuYDj1OE",
appHash:
"8298c6543759d1d11db0e360a8b7aa7b8ec0fa71ed274f2667678302073e4f8d",
appVaultId: PRODUCTION_DUST_APPS_VAULT_ID,
appSpaceId: PRODUCTION_DUST_APPS_SPACE_ID,
},
config: {
MODEL: {
Expand All @@ -297,7 +297,7 @@ export const DustProdActionRegistry = createActionRegistry({
appId: "Hllp6rDlNo",
appHash:
"99f72c76477abd761f33d693b13c8d98750b2e80a68d24eb8963de777a77ebdc",
appVaultId: PRODUCTION_DUST_APPS_VAULT_ID,
appSpaceId: PRODUCTION_DUST_APPS_SPACE_ID,
},
config: {
MODEL: {
Expand Down
20 changes: 10 additions & 10 deletions front/lib/resources/data_source_view_resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class DataSourceViewResource extends ResourceWithSpace<DataSourceViewMode
space,
transaction
);
return this.createDefaultViewInVaultFromDataSourceIncludingAllDocuments(
return this.createDefaultViewInSpaceFromDataSourceIncludingAllDocuments(
auth,
dataSource.space,
dataSource,
Expand All @@ -137,9 +137,9 @@ export class DataSourceViewResource extends ResourceWithSpace<DataSourceViewMode
});
}

static async createViewInVaultFromDataSource(
static async createViewInSpaceFromDataSource(
auth: Authenticator,
vault: SpaceResource,
space: SpaceResource,
dataSource: DataSourceResource,
parentsIn: string[]
) {
Expand All @@ -148,18 +148,18 @@ export class DataSourceViewResource extends ResourceWithSpace<DataSourceViewMode
{
dataSourceId: dataSource.id,
parentsIn,
workspaceId: vault.workspaceId,
workspaceId: space.workspaceId,
kind: "custom",
},
vault,
space,
dataSource
);
}

// This view has access to all documents, which is represented by null.
private static async createDefaultViewInVaultFromDataSourceIncludingAllDocuments(
private static async createDefaultViewInSpaceFromDataSourceIncludingAllDocuments(
auth: Authenticator,
vault: SpaceResource,
space: SpaceResource,
dataSource: DataSourceResource,
transaction?: Transaction
) {
Expand All @@ -168,10 +168,10 @@ export class DataSourceViewResource extends ResourceWithSpace<DataSourceViewMode
{
dataSourceId: dataSource.id,
parentsIn: null,
workspaceId: vault.workspaceId,
workspaceId: space.workspaceId,
kind: "default",
},
vault,
space,
dataSource,
transaction
);
Expand Down Expand Up @@ -273,7 +273,7 @@ export class DataSourceViewResource extends ResourceWithSpace<DataSourceViewMode
});
}

static async listForDataSourcesInVault(
static async listForDataSourcesInSpace(
auth: Authenticator,
dataSources: DataSourceResource[],
space: SpaceResource,
Expand Down
2 changes: 1 addition & 1 deletion front/lib/resources/space_resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class SpaceResource extends BaseResource<SpaceModel> {
id: ModelId;
workspaceId: ModelId;
}): string {
return makeSId("vault", {
return makeSId("space", {
id,
workspaceId,
});
Expand Down
3 changes: 2 additions & 1 deletion front/lib/resources/string_ids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const REGION = 1; // US.
const RESOURCES_PREFIX = {
file: "fil",
group: "grp",
vault: "vlt",
// TODO(2024-10-31 flav) Add new prefix for space.
space: "vlt",
data_source: "dts",
data_source_view: "dsv",
};
Expand Down
Loading

0 comments on commit 65a207b

Please sign in to comment.