diff --git a/modules/vf-graphql-holochain/queries/recipeFlow.ts b/modules/vf-graphql-holochain/queries/recipeFlow.ts index 144548b8..49681295 100644 --- a/modules/vf-graphql-holochain/queries/recipeFlow.ts +++ b/modules/vf-graphql-holochain/queries/recipeFlow.ts @@ -19,6 +19,7 @@ export default (dnaConfig: DNAIdMappings, conductorUri: string) => { return { recipeFlow: async (root, args): Promise => { + console.log("recipeFlow", args) return (await readOne({ address: args.id })).recipeFlow }, recipeFlows: async (root, args: PagingParams): Promise => { diff --git a/modules/vf-graphql-holochain/queries/recipeProcess.ts b/modules/vf-graphql-holochain/queries/recipeProcess.ts index 1d7ec8a5..770becfe 100644 --- a/modules/vf-graphql-holochain/queries/recipeProcess.ts +++ b/modules/vf-graphql-holochain/queries/recipeProcess.ts @@ -14,14 +14,16 @@ import { import { PagingParams } from '../resolvers/zomeSearchInputTypes.js' export default (dnaConfig: DNAIdMappings, conductorUri: string) => { - const readOne = mapZomeFn(dnaConfig, conductorUri, 'planning', 'recipe_process', 'get_recipe_process') - const readAll = mapZomeFn(dnaConfig, conductorUri, 'planning', 'recipe_process_index', 'read_all_recipe_processs') + const readOne = mapZomeFn(dnaConfig, conductorUri, 'recipe', 'recipe_process', 'get_recipe_process') + const readAll = mapZomeFn(dnaConfig, conductorUri, 'recipe', 'recipe_process_index', 'read_all_recipe_processes') return { recipeProcess: async (root, args): Promise => { + console.log("recipeProcess", args) return (await readOne({ address: args.id })).recipeProcess }, - recipeProcesss: async (root, args: PagingParams): Promise => { + recipeProcesses: async (root, args: PagingParams): Promise => { + console.log("recipeProcesses", args) return await readAll(args) }, } diff --git a/package.json b/package.json index 59f01819..6ffbfd4a 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,8 @@ "dev:graphql:explorer": "cd apps/hrea-graphql-explorer && npm start", "watch": "npm-watch", "test": "npm-run-all test:unit test:integration", - "t": "TRYORAMA_LOG_LEVEL=debug WASM_LOG=debug RUST_LOG=\"debug,wasmer_compiler_cranelift=error,holochain::core::workflow=error,holochain::conductor::entry_def_store=error\" RUST_BACKTRACE=1 GRAPHQL_DEBUG=1 npx tape test/recipe/test_recipe_flow_crud.js", + "t1": "TRYORAMA_LOG_LEVEL=debug WASM_LOG=debug RUST_LOG=\"debug,wasmer_compiler_cranelift=error,holochain::core::workflow=error,holochain::conductor::entry_def_store=error\" RUST_BACKTRACE=1 GRAPHQL_DEBUG=1 npx tape test/recipe/test_recipe_flow_crud.js", + "t2": "TRYORAMA_LOG_LEVEL=debug WASM_LOG=debug RUST_LOG=warn,debug,wasmer_compiler_cranelift=error,holochain::core::workflow=error,holochain::conductor::entry_def_store=error RUST_BACKTRACE=1 GRAPHQL_DEBUG=1 npx tape test/recipe/test_recipe_process_crud.js", "test:unit": "scripts/run-unit-tests.sh", "test:integration": "cd test && npm test", "clean": "npm-run-all --parallel clean:modules clean:build", diff --git a/test/recipe/test_recipe_flow_crud.js b/test/recipe/test_recipe_flow_crud.js index 805233e1..21f2f221 100644 --- a/test/recipe/test_recipe_flow_crud.js +++ b/test/recipe/test_recipe_flow_crud.js @@ -60,6 +60,60 @@ test('Plan record API', async (t) => { }) await pause(100) t.ok(createResp.data.rs.recipeFlow.id, 'recipe created') + + const recipeId = createResp.data.rs.recipeFlow.id + const recipeRev = createResp.data.rs.recipeFlow.revisionId + console.log("recipe id", recipeId) + + let getResp = await graphQL(` + query($id: ID!) { + res: recipeFlow(id: $id) { + id + revisionId + action { + id + } + note + } + } + `, { + id: recipeId, + }) + + console.log("get resp", JSON.stringify(getResp.data.res)) + console.log("other", JSON.stringify(exampleEntry)) + + t.ok(getResp, 'recipe read') + + t.deepLooseEqual(getResp.data.res, createResp.data.rs.recipeFlow, 'record read OK') + + const updateResp = await graphQL(` + mutation($rs: RecipeFlowUpdateParams!) { + res: updateRecipeFlow(recipeFlow: $rs) { + recipeFlow { + id + revisionId + } + } + } + `, { + rs: { revisionId: recipeRev, ...exampleEntry }, + }) + + await pause(100) + t.equal(updateResp.data.res.recipeFlow.id, recipeId, 'record ID consistent') + t.notEqual(updateResp.data.res.recipeFlow.revisionId, recipeRev, 'record updated') + + const deleteResult = await graphQL(` + mutation($revisionId: ID!) { + res: deleteRecipeFlow(revisionId: $revisionId) + } + `, { + revisionId: recipeRev, + }) + await pause(100) + + t.equal(deleteResult.data.res, true, "delete successful") } catch (e) { await alice.scenario.cleanUp() console.log(e) diff --git a/test/recipe/test_recipe_process_crud.js b/test/recipe/test_recipe_process_crud.js index 1f31f5f0..d5153f19 100644 --- a/test/recipe/test_recipe_process_crud.js +++ b/test/recipe/test_recipe_process_crud.js @@ -7,7 +7,7 @@ import { test('Plan record API', async (t) => { console.warn(`\n\n${import.meta.url}`) - const alice = await buildPlayer(['planning', 'specification']) + const alice = await buildPlayer(['recipe', 'specification']) try { const { graphQL } = alice @@ -33,9 +33,9 @@ test('Plan record API', async (t) => { const rsId = resp.data.rs.processSpecification.id const exampleEntry = { - name: "String!", - processClassifiedAs: rsId, - note: "String" + name: "lkasdf", + // processConformsTo: rsId, + note: "fffaa" } console.log(exampleEntry) @@ -49,7 +49,6 @@ test('Plan record API', async (t) => { id revisionId name - processClassifiedAs note } } @@ -59,6 +58,26 @@ test('Plan record API', async (t) => { }) await pause(100) t.ok(createResp.data.rs.recipeProcess.id, 'recipe created') + const recipeId = createResp.data.rs.recipeProcess.id + console.log("recipe id", recipeId) + + let readResp = await alice.graphQL(` + query($id: ID!) { + res: recipeProcess(id: $id) { + id + revisionId + name + note + } + } + `, { + id: recipeId, + }) + + console.log("response", JSON.stringify(readResp)) + + t.ok(readResp, 'recipe read') + } catch (e) { await alice.scenario.cleanUp() console.log(e) diff --git a/zomes/rea_recipe_process/lib/src/lib.rs b/zomes/rea_recipe_process/lib/src/lib.rs index 0c558432..09d800cd 100644 --- a/zomes/rea_recipe_process/lib/src/lib.rs +++ b/zomes/rea_recipe_process/lib/src/lib.rs @@ -157,8 +157,8 @@ pub fn construct_response<'a>( id: address.to_owned(), revision_id: meta.as_hash().to_owned(), meta: read_revision_metadata_abbreviated(meta)?, - name: e.note.to_owned(), - image: e.note.to_owned(), + name: e.name.to_owned(), + image: e.image.to_owned(), note: e.note.to_owned(), process_conforms_to: e.process_conforms_to.to_owned(), } diff --git a/zomes/rea_recipe_process/rpc/src/lib.rs b/zomes/rea_recipe_process/rpc/src/lib.rs index 48c4d1e2..4104e499 100644 --- a/zomes/rea_recipe_process/rpc/src/lib.rs +++ b/zomes/rea_recipe_process/rpc/src/lib.rs @@ -65,7 +65,7 @@ pub struct ResponseData { #[derive(Serialize, Deserialize, Debug, SerializedBytes, Clone)] #[serde(rename_all = "camelCase")] pub struct CreateRequest { - pub action: ActionId, + // pub action: ActionId, #[serde(default)] pub name: MaybeUndefined, #[serde(default)] diff --git a/zomes/rea_recipe_process/storage/src/lib.rs b/zomes/rea_recipe_process/storage/src/lib.rs index 009ec115..ad2ba3aa 100644 --- a/zomes/rea_recipe_process/storage/src/lib.rs +++ b/zomes/rea_recipe_process/storage/src/lib.rs @@ -18,7 +18,7 @@ use hdk_records::{ use vf_measurement::QuantityValue; pub use vf_attributes_hdk::{ - ActionId, + // ActionId, DateTime, FixedOffset, ExternalURL, RecipeProcessAddress, @@ -30,7 +30,7 @@ pub use vf_attributes_hdk::{ ProcessSpecificationAddress }; -use vf_actions::{ validate_flow_action }; +// use vf_actions::{ validate_flow_action }; use hc_zome_rea_recipe_process_rpc::{ CreateRequest, UpdateRequest }; @@ -113,8 +113,8 @@ impl TryFrom for EntryData { fn try_from(e: CreateRequest) -> RecordAPIResult { Ok(EntryData { - name: e.note.to_owned().into(), - image: e.note.to_owned().into(), + name: e.name.to_owned().into(), + image: e.image.to_owned().into(), note: e.note.to_owned().into(), process_conforms_to: e.process_conforms_to.to_owned().into(), _nonce: random_bytes(32)?, diff --git a/zomes/rea_recipe_process/zome/src/lib.rs b/zomes/rea_recipe_process/zome/src/lib.rs index 87dfcd4b..5e377650 100644 --- a/zomes/rea_recipe_process/zome/src/lib.rs +++ b/zomes/rea_recipe_process/zome/src/lib.rs @@ -34,6 +34,7 @@ struct ByAddress { #[hdk_extern] fn get_recipe_process(ByAddress { address }: ByAddress) -> ExternResult { + debug!("=====================================get_recipe_process({:?})+++++++++++++++++++++++++++++++++++", address); Ok(handle_get_recipe_process(address)?) }