Skip to content

Commit

Permalink
feat: Migrate func endpoints to v2
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Bustamante <[email protected]>
  • Loading branch information
vbustamante committed Jul 29, 2024
1 parent 9a94986 commit 5c3dd6d
Show file tree
Hide file tree
Showing 29 changed files with 71 additions and 1,053 deletions.
32 changes: 16 additions & 16 deletions app/web/src/store/func/funcs.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export const useFuncStore = () => {

return new ApiRequest<{ summary: FuncSummary; code: FuncCode }>({
method: "post",
url: `${API_PREFIX}/create`,
url: `${API_PREFIX}`,
params: { ...createFuncRequest },
onSuccess: (response) => {
// summary coming through the WsEvent
Expand All @@ -208,7 +208,7 @@ export const useFuncStore = () => {
) {
return new ApiRequest<{ summary: FuncSummary; code: FuncCode }>({
method: "post",
url: `${API_PREFIX}/${funcId}/create_unlocked_copy`,
url: `${API_PREFIX}/${funcId}`,
params: {
schemaVariantId,
},
Expand All @@ -231,7 +231,7 @@ export const useFuncStore = () => {
async DELETE_UNLOCKED_FUNC(funcId: FuncId) {
return new ApiRequest<DeleteFuncResponse>({
method: "delete",
url: `${API_PREFIX}/${funcId}/delete`,
url: `${API_PREFIX}/${funcId}`,
});
},
async UPDATE_FUNC(func: FuncSummary) {
Expand All @@ -242,8 +242,8 @@ export const useFuncStore = () => {
const isHead = changeSetsStore.headSelected;

return new ApiRequest({
method: "post",
url: `${API_PREFIX}/${func.funcId}/update`,
method: "put",
url: `${API_PREFIX}/${func.funcId}`,
params: {
displayName: func.displayName,
description: func.description,
Expand Down Expand Up @@ -275,7 +275,7 @@ export const useFuncStore = () => {

return new ApiRequest<{ bindings: FuncBinding[] }>({
method: "post",
url: `${API_PREFIX}/${funcId}/bindings/create`,
url: `${API_PREFIX}/${funcId}/bindings`,
params: {
bindings,
},
Expand All @@ -291,8 +291,8 @@ export const useFuncStore = () => {
changeSetsStore.creatingChangeSet = true;

return new ApiRequest<null>({
method: "post",
url: `${API_PREFIX}/${funcId}/bindings/update`,
method: "put",
url: `${API_PREFIX}/${funcId}/bindings`,
params: {
funcId,
bindings,
Expand Down Expand Up @@ -328,8 +328,8 @@ export const useFuncStore = () => {
changeSetsStore.creatingChangeSet = true;

return new ApiRequest<null>({
method: "post",
url: `${API_PREFIX}/${funcId}/bindings/delete`,
method: "delete",
url: `${API_PREFIX}/${funcId}/bindings`,
params: {
bindings,
},
Expand All @@ -346,7 +346,7 @@ export const useFuncStore = () => {

return new ApiRequest<null>({
method: "post",
url: `${API_PREFIX}/${funcId}/create_argument`,
url: `${API_PREFIX}/${funcId}/arguments`,
params: {
...funcArg,
},
Expand All @@ -362,8 +362,8 @@ export const useFuncStore = () => {
changeSetsStore.creatingChangeSet = true;

return new ApiRequest<null>({
method: "post",
url: `${API_PREFIX}/${funcId}/${funcArg.id}/update`,
method: "put",
url: `${API_PREFIX}/${funcId}/arguments/${funcArg.id}`,
params: {
...funcArg,
},
Expand All @@ -382,8 +382,8 @@ export const useFuncStore = () => {
changeSetsStore.creatingChangeSet = true;

return new ApiRequest<null>({
method: "post",
url: `${API_PREFIX}/${funcId}/${funcArgumentId}/delete`,
method: "delete",
url: `${API_PREFIX}/${funcId}/arguments/${funcArgumentId}`,
onFail: () => {
changeSetsStore.creatingChangeSet = false;
},
Expand Down Expand Up @@ -484,7 +484,7 @@ export const useFuncStore = () => {
async SAVE_FUNC(func: FuncCode) {
return new ApiRequest<FuncCode>({
method: "post",
url: `${API_PREFIX}/${func.funcId}/save_code`,
url: `${API_PREFIX}/${func.funcId}/code`,
params: { code: func.code },
onFail: () => {
changeSetsStore.creatingChangeSet = false;
Expand Down
8 changes: 3 additions & 5 deletions app/web/src/store/func_runs.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ export const useFuncRunsStore = () => {
const changeSetsStore = useChangeSetsStore();
const changeSetId = changeSetsStore.selectedChangeSetId;

const API_PREFIX = `v2/workspaces/${workspaceId}/change-sets/${changeSetId}/funcs/runs`;

return addStoreHooks(
defineStore(`ws${workspaceId || "NONE"}/func_runs`, {
state: () => ({
Expand All @@ -143,12 +145,8 @@ export const useFuncRunsStore = () => {
async GET_FUNC_RUN(funcRunId: FuncRunId) {
// note: this lookup is not cached, always re-fetch, even though the payload is large. things may have changed since last load!
return new ApiRequest<GetFuncRunResponse>({
url: "/func/get_func_run",
url: `${API_PREFIX}/${funcRunId}`,
headers: { accept: "application/json" },
params: {
funcRunId,
visibility_change_set_pk: changeSetId,
},
onSuccess: (response) => {
if (response.funcRun) {
this.funcRuns[response.funcRun.id] = response.funcRun;
Expand Down
5 changes: 2 additions & 3 deletions lib/dal/src/func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -691,15 +691,14 @@ impl Func {
.await
.map_err(Box::new)?
{
dbg!(&arg);
// create new func args for the new func
FuncArgument::new(ctx, arg.name, arg.kind, arg.element_kind, new_func.id)
.await
.map_err(Box::new)?;
}
dbg!(FuncArgument::list_for_func(ctx, new_func.id)
FuncArgument::list_for_func(ctx, new_func.id)
.await
.map_err(Box::new)?);
.map_err(Box::new)?;
Ok(new_func)
}

Expand Down
1 change: 0 additions & 1 deletion lib/dal/src/func/binding/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ impl AttributeBinding {
WorkspaceSnapshotGraphError::NodeWithIdNotFound(raw_id),
),
) if raw_id == arg.func_argument_id.into() => {
dbg!("raw id == arg.func_arg.id.into");
continue;
}
err => return Err(err.into()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ async fn create_attribute_prototype_with_attribute_prototype_argument(ctx: &mut
.expect("could not perform find by name for func")
.expect("func argument not found");

dbg!(FuncArgument::list_for_func(ctx, func_id)
FuncArgument::list_for_func(ctx, func_id)
.await
.expect("could list"));
.expect("could list");
let prototype_arguments = vec![AttributeArgumentBinding {
func_argument_id: func_argument.id,
attribute_prototype_argument_id: None,
Expand Down Expand Up @@ -251,7 +251,6 @@ async fn detach_attribute_func(ctx: &mut DalContext) {
.await
.expect("unable to get the funcs for a schema variant");
let total_funcs = funcs.len();
dbg!(&funcs);

// Detach one attribute func to the schema variant and commit.
let func_id = Func::find_id_by_name(ctx, "test:falloutEntriesToGalaxies")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ async fn clone_variant(ctx: &mut DalContext) {

assert!(default_schema_variant.is_some());

let clone_name = format!("{}-clone", schema.name().to_string());
let (new_schema_variant, _) = VariantAuthoringClient::new_schema_with_cloned_variant(
ctx,
default_schema_variant.expect("unable to get the schema variant id from the option"),
schema.name().to_string(),
dbg!(clone_name),
)
.await
.expect("unable to clone the schema variant");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,14 +632,12 @@ async fn update_variant_with_leaf_func(ctx: &mut DalContext) {
.expect("could not commit and update snapshot");

// Check the qualifications for all components.
let component_one_qualifications =
dbg!(Component::list_qualifications(ctx, component_one.id())
.await
.expect("could not list qualifications"));
let component_two_qualifications =
dbg!(Component::list_qualifications(ctx, component_two.id())
.await
.expect("could not list qualifications"));
let component_one_qualifications = Component::list_qualifications(ctx, component_one.id())
.await
.expect("could not list qualifications");
let component_two_qualifications = Component::list_qualifications(ctx, component_two.id())
.await
.expect("could not list qualifications");

assert_eq!(
3, // expected
Expand Down
1 change: 0 additions & 1 deletion lib/sdf-server/src/server/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ pub fn routes(state: AppState) -> Router {
crate::server::service::component::routes(),
)
.nest("/api/diagram", crate::server::service::diagram::routes())
.nest("/api/func", crate::server::service::func::routes())
.nest("/api/graphviz", crate::server::service::graphviz::routes())
.nest(
"/api/qualification",
Expand Down
1 change: 0 additions & 1 deletion lib/sdf-server/src/server/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ pub mod attribute;
pub mod change_set;
pub mod component;
pub mod diagram;
pub mod func;
pub mod graphviz;
pub mod module;
pub mod node_debug;
Expand Down
4 changes: 0 additions & 4 deletions lib/sdf-server/src/server/service/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ use thiserror::Error;
// };

use crate::server::state::AppState;
// use crate::service::dev::author_single_schema_with_default_variant::author_single_schema_with_default_variant;
use crate::service::func;

#[remain::sorted]
#[derive(Debug, Error)]
Expand All @@ -34,8 +32,6 @@ pub enum DevError {
#[error(transparent)]
Pg(#[from] si_data_pg::PgError),
#[error(transparent)]
SdfFunc(#[from] func::FuncError),
#[error(transparent)]
StandardModel(#[from] StandardModelError),
#[error("user error: {0}")]
User(#[from] UserError),
Expand Down
139 changes: 0 additions & 139 deletions lib/sdf-server/src/server/service/func.rs

This file was deleted.

Loading

0 comments on commit 5c3dd6d

Please sign in to comment.