From 505ceb8afdd4413ffc6e292da005407dbdb0c0f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Paraniak?= Date: Fri, 25 Oct 2024 21:33:35 +0800 Subject: [PATCH 1/5] contacts: fix %contact-action-1 JSON conversion --- desk/lib/contacts/json-1.hoon | 2 +- desk/tests/lib/contacts-json-1.hoon | 168 +++++++++++++++++++++++----- 2 files changed, 142 insertions(+), 28 deletions(-) diff --git a/desk/lib/contacts/json-1.hoon b/desk/lib/contacts/json-1.hoon index 390f75b8..8837e4ba 100644 --- a/desk/lib/contacts/json-1.hoon +++ b/desk/lib/contacts/json-1.hoon @@ -115,7 +115,7 @@ :: =/ [type=@tas val=json] %. jon - (ot text+(se %tas) value+json ~) + (ot type+(se %tas) value+json ~) ?+ type !! %text %. val (ta %text so) %numb %. val (ta %numb ni) diff --git a/desk/tests/lib/contacts-json-1.hoon b/desk/tests/lib/contacts-json-1.hoon index 5b9cac72..155ec310 100644 --- a/desk/tests/lib/contacts-json-1.hoon +++ b/desk/tests/lib/contacts-json-1.hoon @@ -12,73 +12,187 @@ |= [a=vase b=vase] (expect-eq b a) :: -++ jen-equal +++ enjs-equal |= [jon=json txt=@t] %+ ex-equal !> (en:json:html jon) !> txt :: +++ dejs-equal + |* [saf=$-(json *) txt=@t data=*] + %+ ex-equal + !> (saf (need (de:json:html txt))) + !> data +:: ++ test-ship - %+ jen-equal - (ship:enjs:j ~sampel-palnet) - '"~sampel-palnet"' + ;: weld + %+ enjs-equal + (ship:enjs:j ~sampel-palnet) + '"~sampel-palnet"' + :: + %^ dejs-equal ship:dejs:j + '"~sampel-palnet"' + ~sampel-palnet + == ++ test-cid - %+ jen-equal - (cid:enjs:j 0v11abc) - '"0v11abc"' + ;: weld + %+ enjs-equal + (cid:enjs:j 0v11abc) + '"0v11abc"' + :: + %^ dejs-equal cid:dejs:j + '"0v11abc"' + 0v11abc + == ++ test-kip ;: weld - %+ jen-equal + %+ enjs-equal (kip:enjs:j ~sampel-palnet) '"~sampel-palnet"' :: - %+ jen-equal + %+ enjs-equal (kip:enjs:j id+0v11abc) '"0v11abc"' + :: + %^ dejs-equal kip:dejs:j + '"~sampel-palnet"' + ~sampel-palnet + :: + %^ dejs-equal kip:dejs:j + '"0v11abc"' + id+0v11abc == ++ test-value ;: weld :: - %+ jen-equal - (value:enjs:j text+'the lazy fox') + %+ enjs-equal + (value:enjs:j text+'the lazy fox') '{"type":"text","value":"the lazy fox"}' :: - %+ jen-equal - (value:enjs:j numb+42) + %^ dejs-equal value:dejs:j + '{"type":"text","value":"the lazy fox"}' + text+'the lazy fox' + :: + %+ enjs-equal + (value:enjs:j numb+42) '{"type":"numb","value":42}' :: - %+ jen-equal + %^ dejs-equal value:dejs:j + '{"type":"numb","value":42}' + numb+42 + :: + %+ enjs-equal (value:enjs:j date+~2024.9.11) '{"type":"date","value":"~2024.9.11"}' :: - %+ jen-equal - (value:enjs:j [%tint 0xcafe.babe]) + %^ dejs-equal value:dejs:j + '{"type":"date","value":"~2024.9.11"}' + date+~2024.9.11 + :: + %+ enjs-equal + (value:enjs:j tint+0xcafe.babe) '{"type":"tint","value":"cafe.babe"}' :: - %+ jen-equal - (value:enjs:j [%ship ~sampel-palnet]) + %^ dejs-equal value:dejs:j + '{"type":"tint","value":"cafe.babe"}' + tint+0xcafe.babe + :: + %+ enjs-equal + (value:enjs:j ship+~sampel-palnet) '{"type":"ship","value":"~sampel-palnet"}' :: - %+ jen-equal - (value:enjs:j [%look 'https://ship.io/avatar.png']) + %^ dejs-equal value:dejs:j + '{"type":"ship","value":"~sampel-palnet"}' + ship+~sampel-palnet + :: + %+ enjs-equal + (value:enjs:j look+'https://ship.io/avatar.png') '{"type":"look","value":"https://ship.io/avatar.png"}' :: - %+ jen-equal - (value:enjs:j [%flag [~sampel-palnet %circle]]) + %^ dejs-equal value:dejs:j + '{"type":"look","value":"https://ship.io/avatar.png"}' + look+'https://ship.io/avatar.png' + :: + %+ enjs-equal + (value:enjs:j flag+[~sampel-palnet %circle]) '{"type":"flag","value":"~sampel-palnet/circle"}' :: - %+ jen-equal + %^ dejs-equal value:dejs:j + '{"type":"flag","value":"~sampel-palnet/circle"}' + flag+[~sampel-palnet %circle] + :: + %+ enjs-equal %- value:enjs:j - [%set (silt `(list value)`~[flag/[~sampel-palnet %circle] flag/[~sampel-pardux %square]])] + set+(silt `(list value)`~[flag/[~sampel-palnet %circle] flag/[~sampel-pardux %square]]) '{"type":"set","value":[{"type":"flag","value":"~sampel-palnet/circle"},{"type":"flag","value":"~sampel-pardux/square"}]}' + :: + %^ dejs-equal value:dejs:j + '{"type":"set","value":[{"type":"flag","value":"~sampel-palnet/circle"},{"type":"flag","value":"~sampel-pardux/square"}]}' + set+(silt `(list value)`~[flag/[~sampel-palnet %circle] flag/[~sampel-pardux %square]]) == ++ test-contact - %+ jen-equal - %- contact:enjs:j + ;: weld + %+ enjs-equal + %- contact:enjs:j + %- malt + ^- (list [@tas value]) + :~ name+text/'Sampel' + surname+text/'Palnet' + == + '{"name":{"type":"text","value":"Sampel"},"surname":{"type":"text","value":"Palnet"}}' + :: + %^ dejs-equal contact:dejs:j + '{"name":{"type":"text","value":"Sampel"},"surname":{"type":"text","value":"Palnet"}}' + ^- contact:c %- malt ^- (list [@tas value]) :~ name+text/'Sampel' surname+text/'Palnet' == - '{"name":{"type":"text","value":"Sampel"},"surname":{"type":"text","value":"Palnet"}}' + == +++ test-action + =/ con=contact:c + %- malt + ^- (list [@tas value]) + :~ name+text/'Sampel' + == + =/ mod=contact:c + %- malt + ^- (list [@tas value]) + :~ surname+text/'Palnet' + == + :: + ;: weld + %^ dejs-equal action:dejs:j + '{"anon":null}' + [%anon ~] + :: + %^ dejs-equal action:dejs:j + '{"self":{"name":{"type":"text","value":"Sampel"}}}' + [%self con] + :: + %^ dejs-equal action:dejs:j + '{"page":{"kip":"0v1","contact":{"surname":{"type":"text","value":"Palnet"}}}}' + [%page id+0v1 mod] + :: + %^ dejs-equal action:dejs:j + '{"page":{"kip":"~sampel-palnet","contact":{"surname":{"type":"text","value":"Palnet"}}}}' + [%page ~sampel-palnet mod] + :: + %^ dejs-equal action:dejs:j + '{"wipe":["0v1", "0v2", "~sampel-palnet"]}' + [%wipe id+0v1 id+0v2 ~sampel-palnet ~] + :: + %^ dejs-equal action:dejs:j + '{"meet":["~sampel-palnet", "~master-botnet"]}' + [%meet ~sampel-palnet ~master-botnet ~] + :: + %^ dejs-equal action:dejs:j + '{"drop":["~sampel-palnet", "~master-botnet"]}' + [%drop ~sampel-palnet ~master-botnet ~] + :: + %^ dejs-equal action:dejs:j + '{"snub":["~sampel-palnet", "~master-botnet"]}' + [%snub ~sampel-palnet ~master-botnet ~] + == -- From 984ed9e9524b3be74eb7c02364e3d40081fb1846 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Paraniak?= Date: Fri, 25 Oct 2024 22:58:19 +0800 Subject: [PATCH 2/5] contacts: fix %response-0 JSON conversion --- desk/tests/lib/contacts-json-1.hoon | 49 +++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/desk/tests/lib/contacts-json-1.hoon b/desk/tests/lib/contacts-json-1.hoon index 155ec310..8ac7a507 100644 --- a/desk/tests/lib/contacts-json-1.hoon +++ b/desk/tests/lib/contacts-json-1.hoon @@ -195,4 +195,53 @@ '{"snub":["~sampel-palnet", "~master-botnet"]}' [%snub ~sampel-palnet ~master-botnet ~] == +++ test-response + =/ con=contact:c + %- malt + ^- (list [@tas value]) + :~ name+text/'Sampel' + == + =/ mod=contact:c + %- malt + ^- (list [@tas value]) + :~ surname+text/'Palnet' + == + ;: weld + %+ enjs-equal + (response:enjs:j [%self con]) + '{"self":{"contact":{"name":{"type":"text","value":"Sampel"}}}}' + :: + %+ enjs-equal + (response:enjs:j [%page id+0v1 con mod]) + ^~ %- en:json:html %- need %- de:json:html + ''' + { + "page": { + "mod":{"surname":{"type":"text","value":"Palnet"}}, + "kip":"0v1", + "contact":{"name":{"type":"text","value":"Sampel"}} + } + } + ''' + :: + %+ enjs-equal + (response:enjs:j [%wipe id+0v1]) + '{"wipe":{"kip":"0v1"}}' + :: + %+ enjs-equal + (response:enjs:j [%wipe ~sampel-palnet]) + '{"wipe":{"kip":"~sampel-palnet"}}' + :: + %+ enjs-equal + (response:enjs:j [%peer ~sampel-palnet con]) + ^~ %- en:json:html %- need %- de:json:html + ''' + { + "peer": { + "who":"~sampel-palnet", + "contact":{"name":{"type":"text","value":"Sampel"}} + } + } + ''' + == -- From 430d56d7d1e2de7ebc8acab676f57a23d9fa3a92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Paraniak?= Date: Tue, 29 Oct 2024 18:03:18 +0800 Subject: [PATCH 3/5] contacts: fix $response-0 JSON --- desk/lib/contacts/json-1.hoon | 7 ++++--- desk/tests/lib/contacts-json-1.hoon | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/desk/lib/contacts/json-1.hoon b/desk/lib/contacts/json-1.hoon index 8837e4ba..cbf368e0 100644 --- a/desk/lib/contacts/json-1.hoon +++ b/desk/lib/contacts/json-1.hoon @@ -67,17 +67,18 @@ ++ response |= n=response:c ^- json + %+ frond -.n ?- -.n - %self (frond self+(contact con.n)) + %self (frond contact+(contact con.n)) %page %- pairs :~ kip+(kip kip.n) - con+(contact con.n) + contact+(contact con.n) mod+(contact mod.n) == %wipe (frond kip+(kip kip.n)) %peer %- pairs :~ who+(ship who.n) - con+(contact con.n) + contact+(contact con.n) == == -- diff --git a/desk/tests/lib/contacts-json-1.hoon b/desk/tests/lib/contacts-json-1.hoon index 8ac7a507..6f72b062 100644 --- a/desk/tests/lib/contacts-json-1.hoon +++ b/desk/tests/lib/contacts-json-1.hoon @@ -122,7 +122,7 @@ flag+[~sampel-palnet %circle] :: %+ enjs-equal - %- value:enjs:j + %- value:enjs:j set+(silt `(list value)`~[flag/[~sampel-palnet %circle] flag/[~sampel-pardux %square]]) '{"type":"set","value":[{"type":"flag","value":"~sampel-palnet/circle"},{"type":"flag","value":"~sampel-pardux/square"}]}' :: @@ -207,7 +207,7 @@ :~ surname+text/'Palnet' == ;: weld - %+ enjs-equal + %+ enjs-equal (response:enjs:j [%self con]) '{"self":{"contact":{"name":{"type":"text","value":"Sampel"}}}}' :: @@ -224,15 +224,15 @@ } ''' :: - %+ enjs-equal + %+ enjs-equal (response:enjs:j [%wipe id+0v1]) '{"wipe":{"kip":"0v1"}}' :: - %+ enjs-equal + %+ enjs-equal (response:enjs:j [%wipe ~sampel-palnet]) '{"wipe":{"kip":"~sampel-palnet"}}' :: - %+ enjs-equal + %+ enjs-equal (response:enjs:j [%peer ~sampel-palnet con]) ^~ %- en:json:html %- need %- de:json:html ''' From d83e090d4ef86fa5db586abc4b3ab1d5ce27ff1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Paraniak?= Date: Wed, 30 Oct 2024 23:19:02 +0800 Subject: [PATCH 4/5] contacts: handle null value in $action %edit --- desk/lib/contacts/json-1.hoon | 3 +-- desk/tests/lib/contacts-json-1.hoon | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/desk/lib/contacts/json-1.hoon b/desk/lib/contacts/json-1.hoon index cbf368e0..a65fc33c 100644 --- a/desk/lib/contacts/json-1.hoon +++ b/desk/lib/contacts/json-1.hoon @@ -112,8 +112,7 @@ ++ value ^- $-(json value:c) |= jon=json - :: XX is there a way to do it in one go? - :: + ?~ jon ~ =/ [type=@tas val=json] %. jon (ot type+(se %tas) value+json ~) diff --git a/desk/tests/lib/contacts-json-1.hoon b/desk/tests/lib/contacts-json-1.hoon index 6f72b062..2c9766e3 100644 --- a/desk/tests/lib/contacts-json-1.hoon +++ b/desk/tests/lib/contacts-json-1.hoon @@ -64,6 +64,11 @@ == ++ test-value ;: weld + :: submit null value to delete entry in contacts + :: + %^ dejs-equal value:dejs:j + 'null' + ~ :: %+ enjs-equal (value:enjs:j text+'the lazy fox') From 4ef22d69b7b25d81ec631938b6830d68936bab2e Mon Sep 17 00:00:00 2001 From: Hunter Miller Date: Fri, 1 Nov 2024 11:22:26 -0500 Subject: [PATCH 5/5] ops: version bump --- desk/desk.docket-0 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desk/desk.docket-0 b/desk/desk.docket-0 index 631f0115..c7ce3bbb 100644 --- a/desk/desk.docket-0 +++ b/desk/desk.docket-0 @@ -4,7 +4,7 @@ glob-http+['https://bootstrap.urbit.org/glob-0v7.the2a.smdhg.89k09.6ar0t.gb5te.glob' 0v7.the2a.smdhg.89k09.6ar0t.gb5te] ::glob-ames+~zod^0v0 base+'landscape' - version+[1 27 1] + version+[1 28 0] website+'https://tlon.io' license+'MIT' ==