Skip to content

Commit

Permalink
fix indexing for recipe flow and recipe process
Browse files Browse the repository at this point in the history
  • Loading branch information
LeosPrograms committed Dec 14, 2023
1 parent cb458b7 commit 551b33a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 55 deletions.
14 changes: 7 additions & 7 deletions modules/vf-graphql-holochain/resolvers/recipeFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ const extractProposedIntent = (data): ProposedIntent => data.proposedIntent
export default (enabledVFModules: VfModule[] = DEFAULT_VF_MODULES, dnaConfig: DNAIdMappings, conductorUri: string) => {
const hasResourceSpecification = -1 !== enabledVFModules.indexOf(VfModule.ResourceSpecification)
// const hasProcessSpecification = -1 !== enabledVFModules.indexOf(VfModule.ProcessSpecification)
// const hasAction = -1 !== enabledVFModules.indexOf(VfModule.Action)
const hasAction = -1 !== enabledVFModules.indexOf(VfModule.Action)
const hasHistory = -1 !== enabledVFModules.indexOf(VfModule.History)

const readResourceSpecification = mapZomeFn<ReadParams, ResourceSpecificationResponse>(dnaConfig, conductorUri, 'specification', 'resource_specification', 'get_resource_specification')
// const readProcessSpecification = mapZomeFn<ReadParams, ProcessSpecificationResponse>(dnaConfig, conductorUri, 'specification', 'process_specification', 'get_process_specification')
// const readAction = mapZomeFn<ById, Action>(dnaConfig, conductorUri, 'specification', 'action', 'get_action')
const readAction = mapZomeFn<ById, Action>(dnaConfig, conductorUri, 'specification', 'action', 'get_action')
const readRecipeProcess = mapZomeFn<ReadParams, RecipeProcessResponse>(dnaConfig, conductorUri, 'recipe', 'recipe_process', 'get_recipe_process')
const readRevision = mapZomeFn<ByRevision, RecipeFlowResponse>(dnaConfig, conductorUri, 'recipe', 'recipe_flow', 'get_revision')

Expand All @@ -60,11 +60,11 @@ export default (enabledVFModules: VfModule[] = DEFAULT_VF_MODULES, dnaConfig: DN
return (await readResourceSpecification({ address: record.resourceConformsTo })).resourceSpecification
},
} : {}),
// (hasAction ? {
// action: async (record: { action: AddressableIdentifier }): Promise<Action> => {
// return (await readAction({ id: record.action }))
// },
// } : {}),
(hasAction ? {
action: async (record: { action: AddressableIdentifier }): Promise<Action> => {
return (await readAction({ id: record.action }))
},
} : {}),
(hasHistory ? {
revision: async (record: RecipeFlow, args: { revisionId: AddressableIdentifier }): Promise<RecipeFlow> => {
return (await readRevision(args)).recipeFlow
Expand Down
2 changes: 1 addition & 1 deletion test/recipe/test_recipe_flow_crud.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test('Plan record API', async (t) => {
const exampleEntry = {
note: 'just testing',
action: 'raise',
recipeFlowResource: rsId,
resourceConformsTo: rsId,
}

console.log(exampleEntry)
Expand Down
24 changes: 1 addition & 23 deletions zomes/rea_recipe_flow/lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,7 @@ pub fn handle_delete_recipe_flow(revision_id: ActionHash) -> RecordAPIResult<boo
/// Create response from input DHT primitives
pub fn construct_response<'a>(
address: &RecipeFlowAddress, meta: &SignedActionHashed, e: &EntryData, (
satisfactions,
// published_in,
): (
Vec<SatisfactionAddress>,
// Vec<ProposedRecipeFlowAddress>
)
) -> RecordAPIResult<ResponseData> {
Ok(ResponseData {
Expand All @@ -180,26 +176,8 @@ pub fn construct_response<'a>(

//---------------- READ ----------------

/// Properties accessor for zome config
fn read_recipe_flow_index_zome(conf: DnaConfigSlice) -> Option<String> {
Some(conf.recipe_flow.index_zome)
}

/// Properties accessor for zome config
fn read_process_index_zome(conf: DnaConfigSlice) -> Option<String> {
conf.recipe_flow.process_index_zome
}

/// Properties accessor for zome config
fn read_agent_index_zome(conf: DnaConfigSlice) -> Option<String> {
conf.recipe_flow.agent_index_zome
}

// @see construct_response
pub fn get_link_fields(recipe_flow: &RecipeFlowAddress) -> RecordAPIResult<(
Vec<SatisfactionAddress>,
)> {
Ok((
read_index!(recipe_flow(recipe_flow).satisfied_by)?,
))
Ok(())
}
25 changes: 1 addition & 24 deletions zomes/rea_recipe_process/lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,7 @@ pub fn handle_delete_recipe_process(revision_id: ActionHash) -> RecordAPIResult<
/// Create response from input DHT primitives
pub fn construct_response<'a>(
address: &RecipeProcessAddress, meta: &SignedActionHashed, e: &EntryData, (
satisfactions,
// published_in,
): (
Vec<SatisfactionAddress>,
// Vec<ProposedRecipeProcessAddress>
)
) -> RecordAPIResult<ResponseData> {
Ok(ResponseData {
Expand All @@ -171,26 +167,7 @@ pub fn construct_response<'a>(

//---------------- READ ----------------

/// Properties accessor for zome config
fn read_recipe_process_index_zome(conf: DnaConfigSlice) -> Option<String> {
Some(conf.recipe_process.index_zome)
}

/// Properties accessor for zome config
fn read_process_index_zome(conf: DnaConfigSlice) -> Option<String> {
conf.recipe_process.process_index_zome
}

/// Properties accessor for zome config
fn read_agent_index_zome(conf: DnaConfigSlice) -> Option<String> {
conf.recipe_process.agent_index_zome
}

// @see construct_response
pub fn get_link_fields(recipe_process: &RecipeProcessAddress) -> RecordAPIResult<(
Vec<SatisfactionAddress>,
)> {
Ok((
read_index!(recipe_process(recipe_process).satisfied_by)?,
))
Ok(())
}

0 comments on commit 551b33a

Please sign in to comment.