From cfcfc2dd047e85dc152a35279f9a52a2f29a59c2 Mon Sep 17 00:00:00 2001 From: "guillem.cordoba" Date: Mon, 19 Feb 2024 17:07:35 +0100 Subject: [PATCH] Fixed templates, tests working again --- .envrc | 1 + .gitignore | 1 + .../{{snake_case entry_type.name}}.rs.hbs | 19 ++- ...eferenceable.name)}}.rs{{\302\241if}}.hbs" | 6 +- ...nceable.name)}}.test.ts{{\302\241if}}.hbs" | 4 +- .../mocks.ts.hbs | 6 +- ...dinator_zome_manifest.name}}-client.ts.hbs | 2 +- ...rdinator_zome_manifest.name}}-store.ts.hbs | 6 +- .templates/app/web-app/.envrc.hbs | 1 + .templates/app/web-app/.gitignore.hbs | 2 + .templates/app/web-app/flake.nix.hbs | 1 + .../{{snake_case entry_type.name}}.rs.hbs | 2 +- ...nceable.name)}}.test.ts{{\302\241if}}.hbs" | 4 +- .../module/link-type/ui/src/mocks.ts.hbs | 6 +- ...dinator_zome_manifest.name}}-client.ts.hbs | 2 +- ...rdinator_zome_manifest.name}}-store.ts.hbs | 6 +- ...eferenceable.name)}}.rs{{\302\241if}}.hbs" | 4 +- .templates/module/web-app/.envrc.hbs | 1 + .templates/module/web-app/.gitignore.hbs | 2 + .templates/module/web-app/flake.nix.hbs | 1 + flake.lock | 147 +++++------------- run_test_app.sh | 8 +- run_test_module.sh | 8 +- 23 files changed, 98 insertions(+), 142 deletions(-) create mode 100644 .envrc create mode 100644 .templates/app/web-app/.envrc.hbs create mode 100644 .templates/module/web-app/.envrc.hbs diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..a5dbbcb --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake . diff --git a/.gitignore b/.gitignore index e2a9920..f350afb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .cargo target +.direnv diff --git a/.templates/app/entry-type/dnas/{{dna_role_name}}/zomes/coordinator/{{snake_case coordinator_zome_manifest.name}}/tests/{{snake_case entry_type.name}}.rs.hbs b/.templates/app/entry-type/dnas/{{dna_role_name}}/zomes/coordinator/{{snake_case coordinator_zome_manifest.name}}/tests/{{snake_case entry_type.name}}.rs.hbs index 38cf375..5beca6c 100644 --- a/.templates/app/entry-type/dnas/{{dna_role_name}}/zomes/coordinator/{{snake_case coordinator_zome_manifest.name}}/tests/{{snake_case entry_type.name}}.rs.hbs +++ b/.templates/app/entry-type/dnas/{{dna_role_name}}/zomes/coordinator/{{snake_case coordinator_zome_manifest.name}}/tests/{{snake_case entry_type.name}}.rs.hbs @@ -76,9 +76,15 @@ async fn create_and_read_{{snake_case entry_type.name}}() { consistency_10s([&alice, &bobbo]).await; + {{#if crud.update}} + let get_record: Option = conductors[1] + .call(&bob_zome, "get_original_{{snake_case entry_type.name}}", record.signed_action.action_address().clone()) + .await; + {{else}} let get_record: Option = conductors[1] .call(&bob_zome, "get_{{snake_case entry_type.name}}", {{#if entry_type.reference_entry_hash}}record.action().entry_hash().unwrap().clone(){{else}}record.signed_action.action_address().clone(){{/if}}) .await; + {{/if}} assert_eq!(record, get_record.unwrap()); } @@ -130,7 +136,7 @@ async fn create_and_update_{{snake_case entry_type.name}}() { consistency_10s([&alice, &bobbo]).await; let get_record: Option = conductors[1] - .call(&bob_zome, "get_{{snake_case entry_type.name}}", original_action_hash.clone()) + .call(&bob_zome, "get_latest_{{snake_case entry_type.name}}", original_action_hash.clone()) .await; assert_eq!(update_record, get_record.unwrap()); @@ -154,7 +160,7 @@ async fn create_and_update_{{snake_case entry_type.name}}() { consistency_10s([&alice, &bobbo]).await; let get_record: Option = conductors[1] - .call(&bob_zome, "get_{{snake_case entry_type.name}}", original_action_hash.clone()) + .call(&bob_zome, "get_latest_{{snake_case entry_type.name}}", original_action_hash.clone()) .await; assert_eq!(update_record, get_record.unwrap()); @@ -187,16 +193,17 @@ async fn create_and_delete_{{snake_case entry_type.name}}() { let original_action_hash = record.signed_action.hashed.hash; // Alice deletes the {{pascal_case entry_type.name}} - let _delete_action_hash: ActionHash = conductors[0] + let delete_action_hash: ActionHash = conductors[0] .call(&alice_zome, "delete_{{snake_case entry_type.name}}", original_action_hash.clone()) .await; consistency_10s([&alice, &bobbo]).await; - let get_record: Option = conductors[1] - .call(&bob_zome, "get_{{snake_case entry_type.name}}", original_action_hash.clone()) + let deletes: Vec = conductors[1] + .call(&bob_zome, "get_all_deletes_for_{{snake_case entry_type.name}}", original_action_hash.clone()) .await; - assert!(get_record.is_none()); + assert_eq!(deletes.len(), 1); + assert_eq!(deletes[0].hashed.hash, delete_action_hash); } {{/if}} diff --git "a/.templates/app/link-type/dnas/{{dna_role_name}}/zomes/coordinator/{{snake_case coordinator_zome_manifest.name}}/tests/{{#if to_referenceable}}{{snake_case from_referenceable.name}}_to_{{snake_case (plural to_referenceable.name)}}.rs{{\302\241if}}.hbs" "b/.templates/app/link-type/dnas/{{dna_role_name}}/zomes/coordinator/{{snake_case coordinator_zome_manifest.name}}/tests/{{#if to_referenceable}}{{snake_case from_referenceable.name}}_to_{{snake_case (plural to_referenceable.name)}}.rs{{\302\241if}}.hbs" index f59a60b..33116d6 100644 --- "a/.templates/app/link-type/dnas/{{dna_role_name}}/zomes/coordinator/{{snake_case coordinator_zome_manifest.name}}/tests/{{#if to_referenceable}}{{snake_case from_referenceable.name}}_to_{{snake_case (plural to_referenceable.name)}}.rs{{\302\241if}}.hbs" +++ "b/.templates/app/link-type/dnas/{{dna_role_name}}/zomes/coordinator/{{snake_case coordinator_zome_manifest.name}}/tests/{{#if to_referenceable}}{{snake_case from_referenceable.name}}_to_{{snake_case (plural to_referenceable.name)}}.rs{{\302\241if}}.hbs" @@ -6,7 +6,7 @@ use hdk::prelude::*; use holochain::test_utils::consistency_10s; use holochain::{conductor::config::ConductorConfig, sweettest::*}; -use hc_zome_{{snake_case coordinator_zome_manifest.name}}_coordinator::{{snake_case link_type_name}}::{{#if delete}}{Remove{{pascal_case to_referenceable.name}}For{{pascal_case from_referenceable.name}}Input, Add{{pascal_case to_referenceable.name}}For{{pascal_case from_referenceable.name}}Input }{{else}}Add{{pascal_case to_referenceable.name}}For{{pascal_case from_referenceable.name}}Input{{/if}}; +use {{snake_case coordinator_zome_manifest.name}}::{{snake_case link_type_name}}::{{#if delete}}{Remove{{pascal_case to_referenceable.name}}For{{pascal_case from_referenceable.name}}Input, Add{{pascal_case to_referenceable.name}}For{{pascal_case from_referenceable.name}}Input }{{else}}Add{{pascal_case to_referenceable.name}}For{{pascal_case from_referenceable.name}}Input{{/if}}; {{#if (or (ne from_referenceable.hash_type "AgentPubKey") (ne to_referenceable.hash_type "AgentPubKey"))}} mod common; @@ -80,7 +80,7 @@ async fn link_a_{{snake_case from_referenceable.name}}_to_a_{{snake_case to_refe assert_eq!(AnyLinkableHash::from(target_address.clone()), links_output[0].target); {{/if}} -{{#if bidireccional}} +{{#if bidirectional}} // Bob gets the links in the inverse let links_output: Vec = conductors[1] @@ -108,7 +108,7 @@ async fn link_a_{{snake_case from_referenceable.name}}_to_a_{{snake_case to_refe let deleted_links_output: Vec<(SignedActionHashed, Vec)> = conductors[1] .call(&bob_zome, "get_deleted_{{plural (snake_case to_referenceable.name)}}_for_{{snake_case from_referenceable.name}}", base_address.clone()).await; assert_eq!(deleted_links_output.len(), 1); - {{#if bidireccional}} + {{#if bidirectional}} // Bob gets the links in the inverse let links_output: Vec = conductors[1] diff --git "a/.templates/app/link-type/tests/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if to_referenceable}}{{kebab_case from_referenceable.name}}-to-{{kebab_case (plural to_referenceable.name)}}.test.ts{{\302\241if}}.hbs" "b/.templates/app/link-type/tests/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if to_referenceable}}{{kebab_case from_referenceable.name}}-to-{{kebab_case (plural to_referenceable.name)}}.test.ts{{\302\241if}}.hbs" index e04dcc8..a29bf9c 100644 --- "a/.templates/app/link-type/tests/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if to_referenceable}}{{kebab_case from_referenceable.name}}-to-{{kebab_case (plural to_referenceable.name)}}.test.ts{{\302\241if}}.hbs" +++ "b/.templates/app/link-type/tests/src/{{dna_role_name}}/{{coordinator_zome_manifest.name}}/{{#if to_referenceable}}{{kebab_case from_referenceable.name}}-to-{{kebab_case (plural to_referenceable.name)}}.test.ts{{\302\241if}}.hbs" @@ -65,7 +65,7 @@ test('link a {{pascal_case from_referenceable.name}} to a {{pascal_case to_refer assert.deepEqual(targetAddress, Array.from(linksOutput.keys())[0]); {{/if}} -{{#if bidireccional}} +{{#if bidirectional}} // Bob gets the links in the inverse direction let inverseLinksOutput = await toPromise(bob.store.{{#if (ne to_referenceable.hash_type "ActionHash")}}{{camel_case (plural from_referenceable.name)}}For{{pascal_case to_referenceable.name}}.get(targetAddress){{else}}{{camel_case (plural to_referenceable.name)}}.get(targetAddress).{{camel_case (plural from_referenceable.name)}}{{/if}}{{#if delete}}.live{{/if}}); {{#if (eq from_referenceable.hash_type "AgentPubKey")}} @@ -102,7 +102,7 @@ test('link a {{pascal_case from_referenceable.name}} to a {{pascal_case to_refer assert.equal(deletedLinksOutput.size, 1); {{/if}} - {{#if bidireccional}} + {{#if bidirectional}} // Bob gets the links in the inverse direction inverseLinksOutput = await toPromise(bob.store.{{#if (ne to_referenceable.hash_type "ActionHash")}}{{camel_case (plural from_referenceable.name)}}For{{pascal_case to_referenceable.name}}.get(targetAddress){{else}}{{camel_case (plural to_referenceable.name)}}.get(targetAddress).{{camel_case (plural from_referenceable.name)}}{{/if}}{{#if delete}}.live{{/if}}); {{#if (eq from_referenceable.hash_type "AgentPubKey")}} diff --git a/.templates/app/link-type/ui/src/{{dna_role_name}}/{{kebab_case coordinator_zome_manifest.name}}/mocks.ts.hbs b/.templates/app/link-type/ui/src/{{dna_role_name}}/{{kebab_case coordinator_zome_manifest.name}}/mocks.ts.hbs index eb838ce..e7ff2e0 100644 --- a/.templates/app/link-type/ui/src/{{dna_role_name}}/{{kebab_case coordinator_zome_manifest.name}}/mocks.ts.hbs +++ b/.templates/app/link-type/ui/src/{{dna_role_name}}/{{kebab_case coordinator_zome_manifest.name}}/mocks.ts.hbs @@ -4,7 +4,7 @@ /** {{title_case (plural to_referenceable.name)}} for {{title_case from_referenceable.name}} */ {{camel_case from_referenceable.name}}To{{pascal_case to_referenceable.name}} = new HoloHashMap<{{from_referenceable.hash_type}}, Link[]>(); - {{#if bidireccional}} + {{#if bidirectional}} {{camel_case to_referenceable.name}}To{{pascal_case from_referenceable.name}} = new HoloHashMap<{{to_referenceable.hash_type}}, Link[]>(); {{/if}} @@ -23,7 +23,7 @@ tag: new Uint8Array(), create_link_hash: await fakeActionHash() }]); - {{#if bidireccional}} + {{#if bidirectional}} const existingReverse = this.{{camel_case to_referenceable.name}}To{{pascal_case from_referenceable.name}}.get(input.{{snake_case to_referenceable.singular_arg}}) || []; this.{{camel_case to_referenceable.name}}To{{pascal_case from_referenceable.name}}.set(input.{{snake_case to_referenceable.singular_arg}}, [...existingReverse, { target: input.{{snake_case from_referenceable.singular_arg}}, @@ -37,7 +37,7 @@ {{/if}} } - {{#if bidireccional}} + {{#if bidirectional}} async get_{{snake_case (plural from_referenceable.name)}}_for_{{snake_case to_referenceable.name}}({{camel_case to_referenceable.singular_arg}}: {{to_referenceable.hash_type}}): Promise> { return this.{{camel_case to_referenceable.name}}To{{pascal_case from_referenceable.name}}.get({{camel_case to_referenceable.singular_arg}}) || []; } diff --git a/.templates/app/link-type/ui/src/{{dna_role_name}}/{{kebab_case coordinator_zome_manifest.name}}/{{kebab_case coordinator_zome_manifest.name}}-client.ts.hbs b/.templates/app/link-type/ui/src/{{dna_role_name}}/{{kebab_case coordinator_zome_manifest.name}}/{{kebab_case coordinator_zome_manifest.name}}-client.ts.hbs index f076386..e534fa4 100644 --- a/.templates/app/link-type/ui/src/{{dna_role_name}}/{{kebab_case coordinator_zome_manifest.name}}/{{kebab_case coordinator_zome_manifest.name}}-client.ts.hbs +++ b/.templates/app/link-type/ui/src/{{dna_role_name}}/{{kebab_case coordinator_zome_manifest.name}}/{{kebab_case coordinator_zome_manifest.name}}-client.ts.hbs @@ -30,7 +30,7 @@ } {{/if}} - {{#if bidireccional}} + {{#if bidirectional}} async get{{pascal_case (plural from_referenceable.name)}}For{{pascal_case to_referenceable.name}}({{camel_case to_referenceable.singular_arg}}: {{to_referenceable.hash_type}}): Promise> { return this.callZome('get_{{snake_case (plural from_referenceable.name)}}_for_{{snake_case to_referenceable.name}}', {{camel_case to_referenceable.singular_arg}}); } diff --git a/.templates/app/link-type/ui/src/{{dna_role_name}}/{{kebab_case coordinator_zome_manifest.name}}/{{kebab_case coordinator_zome_manifest.name}}-store.ts.hbs b/.templates/app/link-type/ui/src/{{dna_role_name}}/{{kebab_case coordinator_zome_manifest.name}}/{{kebab_case coordinator_zome_manifest.name}}-store.ts.hbs index 756539a..d387a91 100644 --- a/.templates/app/link-type/ui/src/{{dna_role_name}}/{{kebab_case coordinator_zome_manifest.name}}/{{kebab_case coordinator_zome_manifest.name}}-store.ts.hbs +++ b/.templates/app/link-type/ui/src/{{dna_role_name}}/{{kebab_case coordinator_zome_manifest.name}}/{{kebab_case coordinator_zome_manifest.name}}-store.ts.hbs @@ -49,7 +49,7 @@ ), {{/if}} {{/match_scope}} - {{#if bidireccional}} + {{#if bidirectional}} {{#if (includes previous_file_content (concat (camel_case (plural to_referenceable.name)) " = new LazyHoloHashMap((" (camel_case to_referenceable.name) "Hash: " to_referenceable.hash_type ") => ({" ) ) }} {{#match_scope (concat (camel_case (plural to_referenceable.name)) " = new LazyHoloHashMap((" (camel_case to_referenceable.name) "Hash: " to_referenceable.hash_type ") => ({" )}} {{previous_scope_content}} @@ -102,7 +102,7 @@ {{/if}} {{/merge}} {{else}} - {{#if (or (not bidireccional) (not (and (not (includes previous_file_content (concat (camel_case (plural from_referenceable.name)) " = new LazyHoloHashMap((" (camel_case from_referenceable.name) "Hash: " from_referenceable.hash_type ") => ({" ) )) (includes previous_file_content (concat (camel_case (plural to_referenceable.name)) " = new LazyHoloHashMap((" (camel_case to_referenceable.name) "Hash: " to_referenceable.hash_type ") => ({" ) ))))}} + {{#if (or (not bidirectional) (not (and (not (includes previous_file_content (concat (camel_case (plural from_referenceable.name)) " = new LazyHoloHashMap((" (camel_case from_referenceable.name) "Hash: " from_referenceable.hash_type ") => ({" ) )) (includes previous_file_content (concat (camel_case (plural to_referenceable.name)) " = new LazyHoloHashMap((" (camel_case to_referenceable.name) "Hash: " to_referenceable.hash_type ") => ({" ) ))))}} {{previous_scope_content}} {{/if}} @@ -150,7 +150,7 @@ ){{/if}}); {{/if}} - {{#if bidireccional}} + {{#if bidirectional}} {{#if (and (not (includes previous_file_content (concat (camel_case (plural from_referenceable.name)) " = new LazyHoloHashMap((" (camel_case from_referenceable.name) "Hash: " from_referenceable.hash_type ") => ({" ) )) (includes previous_file_content (concat (camel_case (plural to_referenceable.name)) " = new LazyHoloHashMap((" (camel_case to_referenceable.name) "Hash: " to_referenceable.hash_type ") => ({" ) )) }} {{#merge previous_scope_content}} {{#match_scope (concat (camel_case (plural to_referenceable.name)) " = new LazyHoloHashMap((" (camel_case to_referenceable.name) "Hash: " to_referenceable.hash_type ") => ({" )}} diff --git a/.templates/app/web-app/.envrc.hbs b/.templates/app/web-app/.envrc.hbs new file mode 100644 index 0000000..a5dbbcb --- /dev/null +++ b/.templates/app/web-app/.envrc.hbs @@ -0,0 +1 @@ +use flake . diff --git a/.templates/app/web-app/.gitignore.hbs b/.templates/app/web-app/.gitignore.hbs index c1a4033..89fa284 100644 --- a/.templates/app/web-app/.gitignore.hbs +++ b/.templates/app/web-app/.gitignore.hbs @@ -31,3 +31,5 @@ storybook-static # cargo /target/ /.cargo/ + +.direnv/ diff --git a/.templates/app/web-app/flake.nix.hbs b/.templates/app/web-app/flake.nix.hbs index c413830..0cce270 100644 --- a/.templates/app/web-app/flake.nix.hbs +++ b/.templates/app/web-app/flake.nix.hbs @@ -5,6 +5,7 @@ packages = with pkgs; [ nodejs-18_x cargo-nextest + binaryen ]; {{/match_scope}} {{/merge}} diff --git a/.templates/module/entry-type/zomes/coordinator/{{snake_case app_name}}/tests/{{snake_case entry_type.name}}.rs.hbs b/.templates/module/entry-type/zomes/coordinator/{{snake_case app_name}}/tests/{{snake_case entry_type.name}}.rs.hbs index 8112e55..d917711 100644 --- a/.templates/module/entry-type/zomes/coordinator/{{snake_case app_name}}/tests/{{snake_case entry_type.name}}.rs.hbs +++ b/.templates/module/entry-type/zomes/coordinator/{{snake_case app_name}}/tests/{{snake_case entry_type.name}}.rs.hbs @@ -9,7 +9,7 @@ use holochain::{conductor::config::ConductorConfig, sweettest::*}; use {{snake_case coordinator_zome_manifest.name}}_integrity::*; {{#if crud.update}} -use hc_zome_{{snake_case coordinator_zome_manifest.name}}_coordinator::{{snake_case entry_type.name}}::Update{{pascal_case entry_type.name}}Input; +use {{snake_case coordinator_zome_manifest.name}}::{{snake_case entry_type.name}}::Update{{pascal_case entry_type.name}}Input; {{/if}} mod common; diff --git "a/.templates/module/link-type/tests/src/{{#if to_referenceable}}{{kebab_case from_referenceable.name}}-to-{{kebab_case (plural to_referenceable.name)}}.test.ts{{\302\241if}}.hbs" "b/.templates/module/link-type/tests/src/{{#if to_referenceable}}{{kebab_case from_referenceable.name}}-to-{{kebab_case (plural to_referenceable.name)}}.test.ts{{\302\241if}}.hbs" index f344b50..7851034 100644 --- "a/.templates/module/link-type/tests/src/{{#if to_referenceable}}{{kebab_case from_referenceable.name}}-to-{{kebab_case (plural to_referenceable.name)}}.test.ts{{\302\241if}}.hbs" +++ "b/.templates/module/link-type/tests/src/{{#if to_referenceable}}{{kebab_case from_referenceable.name}}-to-{{kebab_case (plural to_referenceable.name)}}.test.ts{{\302\241if}}.hbs" @@ -65,7 +65,7 @@ test('link a {{pascal_case from_referenceable.name}} to a {{pascal_case to_refer assert.deepEqual(targetAddress, Array.from(linksOutput.keys())[0]); {{/if}} -{{#if bidireccional}} +{{#if bidirectional}} // Bob gets the links in the inverse direction let inverseLinksOutput = await toPromise(bob.store.{{#if (ne to_referenceable.hash_type "ActionHash")}}{{camel_case (plural from_referenceable.name)}}For{{pascal_case to_referenceable.name}}.get(targetAddress){{else}}{{camel_case (plural to_referenceable.name)}}.get(targetAddress).{{camel_case (plural from_referenceable.name)}}{{/if}}{{#if delete}}.live{{/if}}); {{#if (eq from_referenceable.hash_type "AgentPubKey")}} @@ -102,7 +102,7 @@ test('link a {{pascal_case from_referenceable.name}} to a {{pascal_case to_refer assert.equal(deletedLinksOutput.size, 1); {{/if}} - {{#if bidireccional}} + {{#if bidirectional}} // Bob gets the links in the inverse direction inverseLinksOutput = await toPromise(bob.store.{{#if (ne to_referenceable.hash_type "ActionHash")}}{{camel_case (plural from_referenceable.name)}}For{{pascal_case to_referenceable.name}}.get(targetAddress){{else}}{{camel_case (plural to_referenceable.name)}}.get(targetAddress).{{camel_case (plural from_referenceable.name)}}{{/if}}{{#if delete}}.live{{/if}}); {{#if (eq from_referenceable.hash_type "AgentPubKey")}} diff --git a/.templates/module/link-type/ui/src/mocks.ts.hbs b/.templates/module/link-type/ui/src/mocks.ts.hbs index eb838ce..e7ff2e0 100644 --- a/.templates/module/link-type/ui/src/mocks.ts.hbs +++ b/.templates/module/link-type/ui/src/mocks.ts.hbs @@ -4,7 +4,7 @@ /** {{title_case (plural to_referenceable.name)}} for {{title_case from_referenceable.name}} */ {{camel_case from_referenceable.name}}To{{pascal_case to_referenceable.name}} = new HoloHashMap<{{from_referenceable.hash_type}}, Link[]>(); - {{#if bidireccional}} + {{#if bidirectional}} {{camel_case to_referenceable.name}}To{{pascal_case from_referenceable.name}} = new HoloHashMap<{{to_referenceable.hash_type}}, Link[]>(); {{/if}} @@ -23,7 +23,7 @@ tag: new Uint8Array(), create_link_hash: await fakeActionHash() }]); - {{#if bidireccional}} + {{#if bidirectional}} const existingReverse = this.{{camel_case to_referenceable.name}}To{{pascal_case from_referenceable.name}}.get(input.{{snake_case to_referenceable.singular_arg}}) || []; this.{{camel_case to_referenceable.name}}To{{pascal_case from_referenceable.name}}.set(input.{{snake_case to_referenceable.singular_arg}}, [...existingReverse, { target: input.{{snake_case from_referenceable.singular_arg}}, @@ -37,7 +37,7 @@ {{/if}} } - {{#if bidireccional}} + {{#if bidirectional}} async get_{{snake_case (plural from_referenceable.name)}}_for_{{snake_case to_referenceable.name}}({{camel_case to_referenceable.singular_arg}}: {{to_referenceable.hash_type}}): Promise> { return this.{{camel_case to_referenceable.name}}To{{pascal_case from_referenceable.name}}.get({{camel_case to_referenceable.singular_arg}}) || []; } diff --git a/.templates/module/link-type/ui/src/{{kebab_case coordinator_zome_manifest.name}}-client.ts.hbs b/.templates/module/link-type/ui/src/{{kebab_case coordinator_zome_manifest.name}}-client.ts.hbs index f076386..e534fa4 100644 --- a/.templates/module/link-type/ui/src/{{kebab_case coordinator_zome_manifest.name}}-client.ts.hbs +++ b/.templates/module/link-type/ui/src/{{kebab_case coordinator_zome_manifest.name}}-client.ts.hbs @@ -30,7 +30,7 @@ } {{/if}} - {{#if bidireccional}} + {{#if bidirectional}} async get{{pascal_case (plural from_referenceable.name)}}For{{pascal_case to_referenceable.name}}({{camel_case to_referenceable.singular_arg}}: {{to_referenceable.hash_type}}): Promise> { return this.callZome('get_{{snake_case (plural from_referenceable.name)}}_for_{{snake_case to_referenceable.name}}', {{camel_case to_referenceable.singular_arg}}); } diff --git a/.templates/module/link-type/ui/src/{{kebab_case coordinator_zome_manifest.name}}-store.ts.hbs b/.templates/module/link-type/ui/src/{{kebab_case coordinator_zome_manifest.name}}-store.ts.hbs index 756539a..d387a91 100644 --- a/.templates/module/link-type/ui/src/{{kebab_case coordinator_zome_manifest.name}}-store.ts.hbs +++ b/.templates/module/link-type/ui/src/{{kebab_case coordinator_zome_manifest.name}}-store.ts.hbs @@ -49,7 +49,7 @@ ), {{/if}} {{/match_scope}} - {{#if bidireccional}} + {{#if bidirectional}} {{#if (includes previous_file_content (concat (camel_case (plural to_referenceable.name)) " = new LazyHoloHashMap((" (camel_case to_referenceable.name) "Hash: " to_referenceable.hash_type ") => ({" ) ) }} {{#match_scope (concat (camel_case (plural to_referenceable.name)) " = new LazyHoloHashMap((" (camel_case to_referenceable.name) "Hash: " to_referenceable.hash_type ") => ({" )}} {{previous_scope_content}} @@ -102,7 +102,7 @@ {{/if}} {{/merge}} {{else}} - {{#if (or (not bidireccional) (not (and (not (includes previous_file_content (concat (camel_case (plural from_referenceable.name)) " = new LazyHoloHashMap((" (camel_case from_referenceable.name) "Hash: " from_referenceable.hash_type ") => ({" ) )) (includes previous_file_content (concat (camel_case (plural to_referenceable.name)) " = new LazyHoloHashMap((" (camel_case to_referenceable.name) "Hash: " to_referenceable.hash_type ") => ({" ) ))))}} + {{#if (or (not bidirectional) (not (and (not (includes previous_file_content (concat (camel_case (plural from_referenceable.name)) " = new LazyHoloHashMap((" (camel_case from_referenceable.name) "Hash: " from_referenceable.hash_type ") => ({" ) )) (includes previous_file_content (concat (camel_case (plural to_referenceable.name)) " = new LazyHoloHashMap((" (camel_case to_referenceable.name) "Hash: " to_referenceable.hash_type ") => ({" ) ))))}} {{previous_scope_content}} {{/if}} @@ -150,7 +150,7 @@ ){{/if}}); {{/if}} - {{#if bidireccional}} + {{#if bidirectional}} {{#if (and (not (includes previous_file_content (concat (camel_case (plural from_referenceable.name)) " = new LazyHoloHashMap((" (camel_case from_referenceable.name) "Hash: " from_referenceable.hash_type ") => ({" ) )) (includes previous_file_content (concat (camel_case (plural to_referenceable.name)) " = new LazyHoloHashMap((" (camel_case to_referenceable.name) "Hash: " to_referenceable.hash_type ") => ({" ) )) }} {{#merge previous_scope_content}} {{#match_scope (concat (camel_case (plural to_referenceable.name)) " = new LazyHoloHashMap((" (camel_case to_referenceable.name) "Hash: " to_referenceable.hash_type ") => ({" )}} diff --git "a/.templates/module/link-type/zomes/coordinator/{{snake_case app_name}}/tests/{{#if to_referenceable}}{{snake_case from_referenceable.name}}_to_{{snake_case (plural to_referenceable.name)}}.rs{{\302\241if}}.hbs" "b/.templates/module/link-type/zomes/coordinator/{{snake_case app_name}}/tests/{{#if to_referenceable}}{{snake_case from_referenceable.name}}_to_{{snake_case (plural to_referenceable.name)}}.rs{{\302\241if}}.hbs" index f59a60b..8d6b16b 100644 --- "a/.templates/module/link-type/zomes/coordinator/{{snake_case app_name}}/tests/{{#if to_referenceable}}{{snake_case from_referenceable.name}}_to_{{snake_case (plural to_referenceable.name)}}.rs{{\302\241if}}.hbs" +++ "b/.templates/module/link-type/zomes/coordinator/{{snake_case app_name}}/tests/{{#if to_referenceable}}{{snake_case from_referenceable.name}}_to_{{snake_case (plural to_referenceable.name)}}.rs{{\302\241if}}.hbs" @@ -80,7 +80,7 @@ async fn link_a_{{snake_case from_referenceable.name}}_to_a_{{snake_case to_refe assert_eq!(AnyLinkableHash::from(target_address.clone()), links_output[0].target); {{/if}} -{{#if bidireccional}} +{{#if bidirectional}} // Bob gets the links in the inverse let links_output: Vec = conductors[1] @@ -108,7 +108,7 @@ async fn link_a_{{snake_case from_referenceable.name}}_to_a_{{snake_case to_refe let deleted_links_output: Vec<(SignedActionHashed, Vec)> = conductors[1] .call(&bob_zome, "get_deleted_{{plural (snake_case to_referenceable.name)}}_for_{{snake_case from_referenceable.name}}", base_address.clone()).await; assert_eq!(deleted_links_output.len(), 1); - {{#if bidireccional}} + {{#if bidirectional}} // Bob gets the links in the inverse let links_output: Vec = conductors[1] diff --git a/.templates/module/web-app/.envrc.hbs b/.templates/module/web-app/.envrc.hbs new file mode 100644 index 0000000..a5dbbcb --- /dev/null +++ b/.templates/module/web-app/.envrc.hbs @@ -0,0 +1 @@ +use flake . diff --git a/.templates/module/web-app/.gitignore.hbs b/.templates/module/web-app/.gitignore.hbs index c1a4033..e8c508d 100644 --- a/.templates/module/web-app/.gitignore.hbs +++ b/.templates/module/web-app/.gitignore.hbs @@ -31,3 +31,5 @@ storybook-static # cargo /target/ /.cargo/ + +/.direnv/ diff --git a/.templates/module/web-app/flake.nix.hbs b/.templates/module/web-app/flake.nix.hbs index bd210e2..1956006 100644 --- a/.templates/module/web-app/flake.nix.hbs +++ b/.templates/module/web-app/flake.nix.hbs @@ -5,6 +5,7 @@ packages = with pkgs; [ nodejs-18_x cargo-nextest + binaryen ]; {{/match_scope}} {{/merge}} diff --git a/flake.lock b/flake.lock index a693747..1f45a51 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "cargo-chef": { "flake": false, "locked": { - "lastModified": 1672901199, - "narHash": "sha256-MHTuR4aQ1rQaBKx1vWDy2wbvcT0ZAzpkVB2zylSC+k0=", + "lastModified": 1695999026, + "narHash": "sha256-UtLoZd7YBRSF9uXStfC3geEFqSqZXFh1rLHaP8hre0Y=", "owner": "LukeMathWalker", "repo": "cargo-chef", - "rev": "5c9f11578a2e0783cce27666737d50f84510b8b5", + "rev": "6e96ae5cd023b718ae40d608981e50a6e7d7facf", "type": "github" }, "original": { @@ -36,20 +36,17 @@ }, "crane": { "inputs": { - "flake-compat": "flake-compat", - "flake-utils": "flake-utils", "nixpkgs": [ "holochain-flake", "nixpkgs" - ], - "rust-overlay": "rust-overlay" + ] }, "locked": { - "lastModified": 1675475924, - "narHash": "sha256-KWdfV9a6+zG6Ij/7PZYLnomjBZZUu8gdRy+hfjGrrJQ=", + "lastModified": 1707363936, + "narHash": "sha256-QbqyvGFYt84QNOQLOOTWplZZkzkyDhYrAl/N/9H0vFM=", "owner": "ipetkov", "repo": "crane", - "rev": "1bde9c762ebf26de9f8ecf502357c92105bc4577", + "rev": "9107434eda6991e9388ad87b815dafa337446d16", "type": "github" }, "original": { @@ -61,11 +58,11 @@ "crate2nix": { "flake": false, "locked": { - "lastModified": 1693149153, - "narHash": "sha256-HUszQcnIal1FFRAWraODDbxTp0HECwczRTD+Zf0v9o0=", + "lastModified": 1706909251, + "narHash": "sha256-T7G9Uhh77P0kKri/u+Mwa/4YnXwdPsJSwYCiJCCW+fs=", "owner": "kolloch", "repo": "crate2nix", - "rev": "8749f46953b46d44fd181b002399e4a20371f323", + "rev": "15656bb6cb15f55ee3344bf4362e6489feb93db6", "type": "github" }, "original": { @@ -93,27 +90,11 @@ "flake-compat": { "flake": false, "locked": { - "lastModified": 1673956053, - "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-compat_2": { - "flake": false, - "locked": { - "lastModified": 1673956053, - "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", "owner": "edolstra", "repo": "flake-compat", - "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", "type": "github" }, "original": { @@ -127,11 +108,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1675295133, - "narHash": "sha256-dU8fuLL98WFXG0VnRgM00bqKX6CEPBLybhiIDIgO45o=", + "lastModified": 1706830856, + "narHash": "sha256-a0NYyp+h9hlb7ddVz4LUn1vT/PLwqfrWYcHMvFB1xYg=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "bf53492df08f3178ce85e0c9df8ed8d03c030c9f", + "rev": "b253292d9c0a5ead9bc98c4e9a26c6312e27d69f", "type": "github" }, "original": { @@ -140,21 +121,6 @@ } }, "flake-utils": { - "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_2": { "inputs": { "systems": "systems" }, @@ -196,7 +162,7 @@ "crane": "crane", "crate2nix": "crate2nix", "empty": "empty", - "flake-compat": "flake-compat_2", + "flake-compat": "flake-compat", "flake-parts": "flake-parts", "holochain": [ "holochain-flake", @@ -214,7 +180,7 @@ "nixpkgs": "nixpkgs", "pre-commit-hooks-nix": "pre-commit-hooks-nix", "repo-git": "repo-git", - "rust-overlay": "rust-overlay_2", + "rust-overlay": "rust-overlay", "scaffolding": [ "holochain-flake", "empty" @@ -224,11 +190,11 @@ ] }, "locked": { - "lastModified": 1707461628, - "narHash": "sha256-au2itjmk2is3msotjDzArkdkC6fCRUZBmSs7h8PQptk=", + "lastModified": 1708349140, + "narHash": "sha256-Xe5oCMV9UXzuBJUmEmwAPJSsMT6Q/orZQNfJPmxDNWk=", "owner": "holochain", "repo": "holochain", - "rev": "d877d2179cb0dc3d76c5fcf9d6f04c959ab87ed7", + "rev": "a762a69176d87db57960c62cfb28fe49c4381446", "type": "github" }, "original": { @@ -246,11 +212,11 @@ }, "locked": { "dir": "versions/0_2", - "lastModified": 1707461628, - "narHash": "sha256-au2itjmk2is3msotjDzArkdkC6fCRUZBmSs7h8PQptk=", + "lastModified": 1708349140, + "narHash": "sha256-Xe5oCMV9UXzuBJUmEmwAPJSsMT6Q/orZQNfJPmxDNWk=", "owner": "holochain", "repo": "holochain", - "rev": "d877d2179cb0dc3d76c5fcf9d6f04c959ab87ed7", + "rev": "a762a69176d87db57960c62cfb28fe49c4381446", "type": "github" }, "original": { @@ -296,11 +262,11 @@ }, "nix-filter": { "locked": { - "lastModified": 1675361037, - "narHash": "sha256-CTbDuDxFD3U3g/dWUB+r+B/snIe+qqP1R+1myuFGe2I=", + "lastModified": 1705332318, + "narHash": "sha256-kcw1yFeJe9N4PjQji9ZeX47jg0p9A0DuU4djKvg1a7I=", "owner": "numtide", "repo": "nix-filter", - "rev": "e1b2f96c2a31415f362268bc48c3fccf47dff6eb", + "rev": "3449dc925982ad46246cfc36469baf66e1b64f17", "type": "github" }, "original": { @@ -311,11 +277,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1707268954, - "narHash": "sha256-2en1kvde3cJVc3ZnTy8QeD2oKcseLFjYPLKhIGDanQ0=", + "lastModified": 1708118438, + "narHash": "sha256-kk9/0nuVgA220FcqH/D2xaN6uGyHp/zoxPNUmPCMmEE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "f8e2ebd66d097614d51a56a755450d4ae1632df1", + "rev": "5863c27340ba4de8f83e7e3c023b9599c3cb3c80", "type": "github" }, "original": { @@ -327,11 +293,11 @@ "nixpkgs-lib": { "locked": { "dir": "lib", - "lastModified": 1675183161, - "narHash": "sha256-Zq8sNgAxDckpn7tJo7V1afRSk2eoVbu3OjI1QklGLNg=", + "lastModified": 1706550542, + "narHash": "sha256-UcsnCG6wx++23yeER4Hg18CXWbgNpqNXcHIo5/1Y+hc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e1e1b192c1a5aab2960bf0a0bd53a2e8124fa18e", + "rev": "97b17f32362e475016f942bbdfda4a4a72a8a652", "type": "github" }, "original": { @@ -345,11 +311,11 @@ "pre-commit-hooks-nix": { "flake": false, "locked": { - "lastModified": 1676513100, - "narHash": "sha256-MK39nQV86L2ag4TmcK5/+r1ULpzRLPbbfvWbPvIoYJE=", + "lastModified": 1707297608, + "narHash": "sha256-ADjo/5VySGlvtCW3qR+vdFF4xM9kJFlRDqcC9ZGI8EA=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "5f0cba88ac4d6dd8cad5c6f6f1540b3d6a21a798", + "rev": "0db2e67ee49910adfa13010e7f012149660af7f0", "type": "github" }, "original": { @@ -386,45 +352,18 @@ }, "rust-overlay": { "inputs": { - "flake-utils": [ - "holochain-flake", - "crane", - "flake-utils" - ], - "nixpkgs": [ - "holochain-flake", - "crane", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1675391458, - "narHash": "sha256-ukDKZw922BnK5ohL9LhwtaDAdCsJL7L6ScNEyF1lO9w=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "383a4acfd11d778d5c2efcf28376cbd845eeaedf", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" - } - }, - "rust-overlay_2": { - "inputs": { - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils", "nixpkgs": [ "holochain-flake", "nixpkgs" ] }, "locked": { - "lastModified": 1707444620, - "narHash": "sha256-P8kRkiJLFttN+hbAOlm11wPxUrQZqKle+QtVCqFiGXY=", + "lastModified": 1708308739, + "narHash": "sha256-FtKWP6d51kz8282jfziNNcCBpAvEzv2TtKH6dYIXCuA=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "78503e9199010a4df714f29a4f9c00eb2ccae071", + "rev": "d45281ce1027a401255db01ea44972afbc569b7e", "type": "github" }, "original": { @@ -436,11 +375,11 @@ "scaffolding": { "flake": false, "locked": { - "lastModified": 1705076186, - "narHash": "sha256-O914XeBuFulky5RqTOvsog+fbO12v0ppW+mIdO6lvKU=", + "lastModified": 1708195684, + "narHash": "sha256-Z2ymdwC8mKr4pGRC+iMKpVR+kFCny1VwcCbtz7LuzeE=", "owner": "holochain", "repo": "scaffolding", - "rev": "42e025fe23ac0b4cd659d95e6752d2d300a8d076", + "rev": "ce2281438dd314d825860cd5942122ac164f1f1e", "type": "github" }, "original": { diff --git a/run_test_app.sh b/run_test_app.sh index f2a0aa8..7b97a42 100644 --- a/run_test_app.sh +++ b/run_test_app.sh @@ -26,10 +26,10 @@ hc-scaffold collection by-author posts_by_author post hc-scaffold collection global all_posts_entry_hash post:EntryHash hc-scaffold collection by-author posts_by_author_entry_hash post:EntryHash -hc-scaffold link-type post like --delete true --bidireccional false -hc-scaffold link-type comment like --delete true --bidireccional false -hc-scaffold link-type certificate like --delete false --bidireccional false -hc-scaffold link-type agent:creator post --delete false --bidireccional false +hc-scaffold link-type post like --delete true --bidirectional false +hc-scaffold link-type comment like --delete true --bidirectional false +hc-scaffold link-type certificate like --delete false --bidirectional false +hc-scaffold link-type agent:creator post --delete false --bidirectional false hc-scaffold zome profiles --coordinator dnas/forum/zomes/coordinator --integrity dnas/forum/zomes/integrity hc-scaffold zome file_storage --coordinator dnas/forum/zomes/coordinator --integrity dnas/forum/zomes/integrity diff --git a/run_test_module.sh b/run_test_module.sh index 8449d92..2f2fef6 100644 --- a/run_test_module.sh +++ b/run_test_module.sh @@ -23,10 +23,10 @@ hc-scaffold collection --zome posts_integrity by-author posts_by_author post hc-scaffold collection --zome posts_integrity global all_posts_entry_hash post:EntryHash hc-scaffold collection --zome posts_integrity by-author posts_by_author_entry_hash post:EntryHash -hc-scaffold link-type --zome posts_integrity post like --delete true --bidireccional false -hc-scaffold link-type --zome posts_integrity comment like --delete true --bidireccional false -hc-scaffold link-type --zome posts_integrity certificate like --delete false --bidireccional false -hc-scaffold link-type --zome posts_integrity agent:creator post --delete false --bidireccional false +hc-scaffold link-type --zome posts_integrity post like --delete true --bidirectional false +hc-scaffold link-type --zome posts_integrity comment like --delete true --bidirectional false +hc-scaffold link-type --zome posts_integrity certificate like --delete false --bidirectional false +hc-scaffold link-type --zome posts_integrity agent:creator post --delete false --bidirectional false npm i