diff --git a/.husky/post-checkout b/.husky/post-checkout new file mode 100755 index 000000000..cab40f264 --- /dev/null +++ b/.husky/post-checkout @@ -0,0 +1,3 @@ +#!/bin/sh +command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/post-checkout.\n"; exit 2; } +git lfs post-checkout "$@" diff --git a/.husky/post-commit b/.husky/post-commit new file mode 100755 index 000000000..9443f4161 --- /dev/null +++ b/.husky/post-commit @@ -0,0 +1,3 @@ +#!/bin/sh +command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/post-commit.\n"; exit 2; } +git lfs post-commit "$@" diff --git a/.husky/post-merge b/.husky/post-merge new file mode 100755 index 000000000..828b70891 --- /dev/null +++ b/.husky/post-merge @@ -0,0 +1,3 @@ +#!/bin/sh +command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/post-merge.\n"; exit 2; } +git lfs post-merge "$@" diff --git a/.husky/pre-push b/.husky/pre-push new file mode 100755 index 000000000..81a9cc639 --- /dev/null +++ b/.husky/pre-push @@ -0,0 +1,3 @@ +#!/bin/sh +command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/pre-push.\n"; exit 2; } +git lfs pre-push "$@" diff --git a/pkg/arvo/gen/hood/keen.hoon b/pkg/arvo/gen/hood/keen.hoon new file mode 100644 index 000000000..f57225d13 --- /dev/null +++ b/pkg/arvo/gen/hood/keen.hoon @@ -0,0 +1,8 @@ +:- %say +|= [^ [=ship pax=$@(~ [=path ~])] ~] +=/ =path + ?~ pax /cz/(scot %p ship)/kids/1/sys + ?> ?=([@ *] path.pax) + =, pax + [i.path (scot %p ship) t.path] +[%helm-pass %a %keen path] diff --git a/pkg/arvo/sys/vane/ames.hoon b/pkg/arvo/sys/vane/ames.hoon index 0c2e8440f..16b573617 100644 --- a/pkg/arvo/sys/vane/ames.hoon +++ b/pkg/arvo/sys/vane/ames.hoon @@ -284,6 +284,53 @@ [1 relayed=.?(origin)] == (mix header (lsh 5 body)) +:: +++ decode-request + |= =hoot + ^- twit + :- sig=(cut 3 [0 64] hoot) + -:(decode-request-info (rsh 3^64 hoot)) +:: +++ decode-request-info + |= =hoot + ^- [=peep =purr] + =+ num=(cut 3 [0 4] hoot) + =+ len=(cut 3 [4 2] hoot) + =+ pat=(cut 3 [6 len] hoot) + :- [(stab pat) num] + :: if there is data remaining, it's the response + (rsh [3 (add 6 len)] hoot) +:: +++ decode-response-packet + |= =purr + =; =rawr + ~? !=(wid.rawr (met 3 dat.rawr)) [%fine %unexpected-dat-size] + rawr + :* sig=(cut 3 [0 64] purr) + siz=(cut 3 [64 4] purr) + wid=(cut 3 [68 2] purr) + dat=(rsh 3^70 purr) + == +:: +++ verify-response-packet + |= rawr + !! +:: +++ decode-response-msg + |= partial-fine ::TODO maybe take @ instead + ^- roar + =/ mess=@ + %+ rep 13 + %+ turn (gulf 1 num-fragments) + |= num=@ud + =/ frag=byts (~(got by fragments) num) + dat.frag + =+ sig=(end 3^64 mess) + :- sig + ~| [%fine %response-not-cask] + ;;((cask) (cue (rsh 3^64 mess))) +:: + :: +decode-packet: deserialize packet from bytestream or crash :: ++ decode-packet @@ -483,6 +530,7 @@ :: 0b11: comet -- 16 bytes :: +$ rank ?(%0b0 %0b1 %0b10 %0b11) ++$ byuts [wid=@ud dat=@ux] :: +| %kinetics :: $channel: combined sender and receiver identifying data @@ -609,6 +657,26 @@ part=(map path partial-fine) ::TODO re-send request timers? == ++$ twit :: signed request + $: signature=@ + peep + == +:: ++$ peep :: request data + $: =path + num=@ud + == +:: ++$ rawr :: response packet ::TODO meow + $: sig=@ + siz=@ud + byts + == +:: ++$ roar :: response message + $: sig=@ + dat=(cask) + == :: $partial-fine: partial remote scry response :: +$ partial-fine @@ -1155,16 +1223,18 @@ :: =/ =path [i.t.t.tyl (scot %p our) t.t.t.tyl] + =* pax t.t.tyl ?~ nom=(de-omen path) ~ :: we only support scrying into clay, :: and only if the data is fully public. :: - ?. =(%c (end 3 (snag 0 path))) ~ - =+ pem=(rof lyc (need (de-omen %cp (slag 1 path)))) - ?> ?=(^ pem) - ?> ?=(^ u.pem) - =+ per=!<([r=dict:clay w=dict:clay] q.u.u.pem) - ?> =([%black ~ ~] rul.r.per) + :: ?. =(%c (end 3 (snag 0 path))) ~ + :: =/ perm-omen (need (de-omen %cp (slag 1 path))) + :: =+ pem=(rof lyc perm-omen) + :: ?> ?=(^ pem) + :: ?> ?=(^ u.pem) + :: =+ per=!<([r=dict:clay w=dict:clay] q.u.u.pem) + :: ?> =([%black ~ ~] rul.r.per) =+ res=(rof lyc u.nom) ::TODO suggests we need to factor differently =+ ven=(per-event [now 0v0 rof] *duct ames-state) @@ -2458,7 +2528,8 @@ ^+ event-core ?^ dud ::TODO handle - ~& [%fine %done-goofed u.dud] + ~& [%fine %done-goofed mote.u.dud] + %- (slog tang.u.dud) event-core ::NOTE we only send requests to ships we know, :: so we should only get responses from ships we know. @@ -2473,6 +2544,7 @@ (handle-response [from life.peer lane] peep rawr) -- |% +<<<<<<< HEAD +$ twit :: signed request $: signature=@ peep @@ -2508,7 +2580,7 @@ ^- byts ?> (lth num (bex 32)) =+ (spit path) - :- :(add 32 16 wid) + :- :(add 4 2 wid) %+ can 3 :~ 4^num :: fragment number 2^wid :: path size @@ -2544,7 +2616,12 @@ :: prepend a signature and split the data into 1024-byte fragments :: =/ frag=(list @) +<<<<<<< HEAD =/ sig=@ (full:keys path (fall data ~)) +======= + ::TODO should also sign the request path + =/ sig=@ ::(full:keys path (fall data ~)) + (fil 5 16 0xdead.beef) ?~ data [sig]~ %+ rip 13 ::NOTE 1024 bytes (cat 3 sig (jam u.data)) ::TODO should include life @@ -2565,7 +2642,8 @@ wid^dat :: response data fragment == =/ sig=byts - 64^(sign:keys (can 3 req bod ~)) + 64^(fil 5 16 0xcafe.face) + :: 64^(fil (sign:keys (can 3 req bod ~)) (can 3 req sig bod ~) :: ++ keys @@ -2611,18 +2689,16 @@ |= [who=ship lyf=life pax=path sig=@ dat=$@(~ (cask))] (veri who lyf sig (mess who lyf pax dat)) -- - :: + :: TODO: should not crash, + :: improve routing? ++ get-lane |= =ship ^- lane:ames - =; lanes - ::TODO should we send to all lanes? - ?^ lanes i.lanes - ~&(%fine-lane-stub &+~zod) ::TODO - !< (list lane:ames) - =< q %- need %- need - =/ =path /peers/(scot %p ship)/forward-lane + =/ =peer-state + (got-peer-state ship) + lane:(need route.peer-state) ::TODO get from state +<<<<<<< HEAD (rof `[our ~ ~] [%ames %x] [our %$ da+now] path) :: ++ decode-request @@ -2681,6 +2757,7 @@ |= [[from=ship =life] =path sig=@ data=$@(~ (cask))] ^+ event-core ?> (meri:keys from life path sig data) + ~& got-response/path =. event-core %- emil %+ turn ~(tap in (~(get ju want.state) path)) @@ -2692,19 +2769,24 @@ ++ handle-response |= [[from=ship =life =lane:ames] =peep =rawr] ^+ event-core - ?. (~(has by part.state) path.peep) + ?> ?=([@ *] path.peep) + =/ =path [i.path.peep (scot %p from) t.path.peep] + ?: =(0 siz.rawr) + ?> =(~ dat.rawr) + (process-response path.peep ~) + ?. (~(has by part.state) path) :: we did not initiate this request, or it's been cancelled :: !! =/ partial=partial-fine - (~(got by part.state) path.peep) + (~(got by part.state) path) =. partial ?: (~(has by fragments.partial) num.peep) partial =, partial :+ ~| [%fine %response-size-changed have=num-fragments new=siz.rawr] ?> |(=(0 num-fragments) =(num-fragments siz.rawr)) - num-fragments + siz.rawr +(num-received) ?> (veri:keys from life [sig dat]:rawr) (~(put by fragments) num.peep [wid dat]:rawr) @@ -2713,10 +2795,10 @@ :: we have all the parts now, construct the full response :: =/ =roar (decode-response-msg partial) - (process-response [from life] path.peep [sig dat]:roar) + (process-response [from life] path [sig dat]:roar) :: otherwise, store the part, and send out the next request :: - =. part.state (~(put by part.state) path.peep partial) + =. part.state (~(put by part.state) path partial) =/ next-num=@ud =/ next=@ud +(num.peep) :: we should receive responses in order, but in case we don't... diff --git a/pkg/arvo/tests/sys/vane/ames.hoon b/pkg/arvo/tests/sys/vane/ames.hoon index 16638ddc1..9352340f1 100644 --- a/pkg/arvo/tests/sys/vane/ames.hoon +++ b/pkg/arvo/tests/sys/vane/ames.hoon @@ -89,6 +89,11 @@ %+ snag index (skim moves is-move-send) :: +++ scry + |= [vane=_nec car=term bem=beam] + =/ vane-core (vane) + (scry:vane-core ~ car bem) +:: ++ call |= [vane=_nec =duct =task:ames] ^- [moves=(list move:ames) _nec] @@ -118,7 +123,7 @@ content=0xdead.beef == :: - =/ encoded (encode-packet:ames packet) + =/ encoded (encode-packet:ames & packet) =/ decoded (decode-packet:ames encoded) :: %+ expect-eq @@ -135,7 +140,7 @@ content=0xdead.beef == :: - =/ encoded (encode-packet:ames packet) + =/ encoded (encode-packet:ames & packet) =/ decoded (decode-packet:ames encoded) :: %+ expect-eq @@ -191,7 +196,7 @@ rcvr-life=3 == :: - =/ =blob:ames (encode-packet:ames packet) + =/ =blob:ames (encode-packet:ames & packet) =^ moves1 bud (call bud ~[//unix] %hear lane-foo blob) =^ moves2 bud =/ =point:ames @@ -236,7 +241,7 @@ =/ packet ~! ames (encode-open-packet:ames open-packet crypto-core.ames-state.comet) - =/ blob (encode-packet:ames packet) + =/ blob (encode-packet:ames & packet) :: =^ moves0 bud (call bud ~[//unix] %hear lane-foo blob) :: @@ -255,7 +260,7 @@ sndr-life=1 rcvr-life=3 == - =/ blob (encode-packet:ames packet) + =/ blob (encode-packet:ames & packet) =^ moves1 bud (call bud ~[//unix] %hear lane-foo blob) :: ;: weld @@ -330,4 +335,56 @@ %+ expect-eq !> [~[/g/talk] %give %done `error] !> (snag 1 `(list move:ames)`moves5) +:: +++ test-fine-request + ^- tang + =/ want=path /cz/~bud/kids/1/sys + =/ net=path /cz/kids/1/sys + =^ moves1 nec (call nec ~[/g/talk] %keen want) + =/ req=hoot:ames + %+ snag 0 + %+ murn ;;((list move:ames) moves1) + |= =move:ames + ^- (unit hoot:ames) + ?. ?=(%give -.card.move) ~ + ?. ?=(%send -.p.card.move) ~ + `;;(@uxhoot blob.p.card.move) + =/ [is-ames=? =packet:ames] (decode-packet:ames `@ux`req) + ?> ?=(%| is-ames) + =/ twit + (decode-request:ames `@ux`content.packet) + ~& twit + (expect-eq !>(1) !>(1)) +:: +++ test-fine-response + ^- tang + =/ want=path /cz/~bud/kids/1/sys + =/ net=path /cz/kids/1/sys + =/ =beam [[~bud %$ da+now:bud] (welp /fine/message net)] + =/ [=mark =vase] (need (need (scry bud %x beam))) + =+ !<(=song:ames vase) + =/ partial + %- ~(gas by *(map @ud byts)) + ^- (list [@ud byts]) + %- head + %^ spin song 1 + |= [blob=@ux num=@ud] + ^- [[_num byts] _num] + :_ +(num) + =/ [is-ames=? =packet:ames] (decode-packet:ames `@ux`blob) + ?> ?=(%| is-ames) + =/ [=peep:ames =purr:ames] (decode-request-info:ames `@ux`content.packet) + =/ rawr (decode-response-packet:ames `@ux`purr) + ~& rawr-sig/`@ux`sig.rawr + ~& rawr-siz/`@ux`siz.rawr + ~& rawr-wid/`@ux`wid.rawr + ~& rawr-dat/`@ux`dat.rawr + :- num + [wid dat]:rawr + =/ num-frag=@ud ~(wyt by partial) + =/ =roar:ames + (decode-response-msg:ames num-frag num-frag partial) + ~& roar + ~! . + (expect-eq !>(1) !>(1)) -- diff --git a/pkg/npm/api/tmp/contacts/index.d.ts b/pkg/npm/api/tmp/contacts/index.d.ts new file mode 100644 index 000000000..4a272fce5 --- /dev/null +++ b/pkg/npm/api/tmp/contacts/index.d.ts @@ -0,0 +1,2 @@ +export * from './types'; +export * from './lib'; diff --git a/pkg/npm/api/tmp/contacts/index.js b/pkg/npm/api/tmp/contacts/index.js new file mode 100644 index 000000000..5c8443c9d --- /dev/null +++ b/pkg/npm/api/tmp/contacts/index.js @@ -0,0 +1,3 @@ +export * from './types'; +export * from './lib'; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/contacts/index.js.map b/pkg/npm/api/tmp/contacts/index.js.map new file mode 100644 index 000000000..e8bec26c5 --- /dev/null +++ b/pkg/npm/api/tmp/contacts/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../contacts/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/contacts/lib.d.ts b/pkg/npm/api/tmp/contacts/lib.d.ts new file mode 100644 index 000000000..b81a69eae --- /dev/null +++ b/pkg/npm/api/tmp/contacts/lib.d.ts @@ -0,0 +1,26 @@ +import { Patp, Poke, Scry } from '../lib'; +import { Contact, ContactUpdateAdd, ContactUpdateEdit, ContactUpdateRemove, ContactEditField, ContactShare, ContactUpdate, ContactUpdateAllowShips, ContactUpdateAllowGroup, ContactUpdateSetPublic } from './types'; +export declare const CONTACT_UPDATE_VERSION = 0; +declare const storeAction: (data: T, version?: number) => Poke; +export { storeAction as contactStoreAction }; +export declare const addContact: (ship: Patp, contact: Contact) => Poke; +export declare const removeContact: (ship: Patp) => Poke; +export declare const share: (recipient: Patp, version?: number) => Poke; +export declare const editContact: (ship: Patp, editField: ContactEditField) => Poke; +export declare const allowShips: (ships: Patp[]) => Poke; +export declare const allowGroup: (ship: string, name: string) => Poke; +export declare const setPublic: (setPublic: any) => Poke; +export declare const retrieve: (ship: string) => { + app: string; + mark: string; + json: { + add: { + resource: { + ship: string; + name: string; + }; + ship: string; + }; + }; +}; +export declare const fetchIsAllowed: (entity: string, name: string, ship: string, personal: boolean) => Scry; diff --git a/pkg/npm/api/tmp/contacts/lib.js b/pkg/npm/api/tmp/contacts/lib.js new file mode 100644 index 000000000..e2177339f --- /dev/null +++ b/pkg/npm/api/tmp/contacts/lib.js @@ -0,0 +1,64 @@ +export const CONTACT_UPDATE_VERSION = 0; +const storeAction = (data, version = CONTACT_UPDATE_VERSION) => ({ + app: 'contact-store', + mark: `contact-update-${version}`, + json: data +}); +export { storeAction as contactStoreAction }; +export const addContact = (ship, contact) => { + contact['last-updated'] = Date.now(); + return storeAction({ + add: { ship, contact } + }); +}; +export const removeContact = (ship) => storeAction({ + remove: { ship } +}); +export const share = (recipient, version = CONTACT_UPDATE_VERSION) => ({ + app: 'contact-push-hook', + mark: 'contact-share', + json: { share: recipient } +}); +export const editContact = (ship, editField) => storeAction({ + edit: { + ship, + 'edit-field': editField, + timestamp: Date.now() + } +}); +export const allowShips = (ships) => storeAction({ + allow: { + ships + } +}); +export const allowGroup = (ship, name) => storeAction({ + allow: { + group: { ship, name } + } +}); +export const setPublic = (setPublic) => { + return storeAction({ + 'set-public': setPublic + }); +}; +export const retrieve = (ship) => { + const resource = { ship, name: '' }; + return { + app: 'contact-pull-hook', + mark: 'pull-hook-action', + json: { + add: { + resource, + ship + } + } + }; +}; +export const fetchIsAllowed = (entity, name, ship, personal) => { + const isPersonal = personal ? 'true' : 'false'; + return { + app: 'contact-store', + path: `/is-allowed/${entity}/${name}/${ship}/${isPersonal}` + }; +}; +//# sourceMappingURL=lib.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/contacts/lib.js.map b/pkg/npm/api/tmp/contacts/lib.js.map new file mode 100644 index 000000000..5c0b9b03e --- /dev/null +++ b/pkg/npm/api/tmp/contacts/lib.js.map @@ -0,0 +1 @@ +{"version":3,"file":"lib.js","sourceRoot":"","sources":["../../contacts/lib.ts"],"names":[],"mappings":"AAeA,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAExC,MAAM,WAAW,GAAG,CAA0B,IAAO,EAAE,UAAkB,sBAAsB,EAAW,EAAE,CAAC,CAAC;IAC5G,GAAG,EAAE,eAAe;IACpB,IAAI,EAAE,kBAAk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AC,MAAM,SAAS,GAAG,CACvB,SAAc,EACgB,EAAE;IAChC,OAAO,WAAW,CAAC;QACjB,YAAY,EAAE,SAAS;KACxB,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,IAAY,EACZ,EAAE;IACF,MAAM,QAAQ,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IACpC,OAAO;QACL,GAAG,EAAE,mBAAmB;QACxB,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE;YACJ,GAAG,EAAE;gBACH,QAAQ;gBACR,IAAI;aACL;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,MAAc,EACd,IAAY,EACZ,IAAY,EACZ,QAAiB,EACX,EAAE;IACR,MAAM,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IAC/C,OAAO;QACL,GAAG,EAAE,eAAe;QACpB,IAAI,EAAE,eAAe,MAAM,IAAI,IAAI,IAAI,IAAI,IAAI,UAAU,EAAE;KAC5D,CAAC;AACJ,CAAC,CAAC"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/contacts/types.d.ts b/pkg/npm/api/tmp/contacts/types.d.ts new file mode 100644 index 000000000..d002ebebf --- /dev/null +++ b/pkg/npm/api/tmp/contacts/types.d.ts @@ -0,0 +1,61 @@ +import { Path, Patp } from '../lib'; +import { Resource } from '../groups'; +export declare type ContactUpdate = ContactUpdateAdd | ContactUpdateRemove | ContactUpdateEdit | ContactUpdateInitial | ContactUpdateAllowGroup | ContactUpdateAllowShips | ContactUpdateSetPublic; +export interface ContactUpdateAdd { + add: { + ship: Patp; + contact: Contact; + }; +} +export interface ContactUpdateRemove { + remove: { + ship: Patp; + }; +} +export interface ContactUpdateEdit { + edit: { + ship: Patp; + 'edit-field': ContactEditField; + timestamp: number; + }; +} +export interface ContactUpdateAllowShips { + allow: { + ships: Patp[]; + }; +} +export interface ContactUpdateAllowGroup { + allow: { + group: Resource; + }; +} +export interface ContactUpdateSetPublic { + 'set-public': boolean; +} +export interface ContactShare { + share: Patp; +} +export interface ContactUpdateInitial { + initial: Rolodex; +} +export declare type Rolodex = { + [p in Patp]: Contact; +}; +export declare type Contacts = Rolodex; +export interface Contact { + nickname: string; + bio: string; + status: string; + color: string; + avatar: string | null; + cover: string | null; + groups: Path[]; + 'last-updated': number; +} +declare type ContactKeys = keyof Contact; +export declare type ContactEditFieldPrim = Exclude; +export declare type ContactEditField = Partial> & { + 'add-group'?: Resource; + 'remove-group'?: Resource; +}; +export {}; diff --git a/pkg/npm/api/tmp/contacts/types.js b/pkg/npm/api/tmp/contacts/types.js new file mode 100644 index 000000000..718fd38ae --- /dev/null +++ b/pkg/npm/api/tmp/contacts/types.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/contacts/types.js.map b/pkg/npm/api/tmp/contacts/types.js.map new file mode 100644 index 000000000..b27fd52b3 --- /dev/null +++ b/pkg/npm/api/tmp/contacts/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../../contacts/types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/pkg/npm/api/tmp/docket/index.d.ts b/pkg/npm/api/tmp/docket/index.d.ts new file mode 100644 index 000000000..e06143cf1 --- /dev/null +++ b/pkg/npm/api/tmp/docket/index.d.ts @@ -0,0 +1,2 @@ +export * from './lib'; +export * from './types'; diff --git a/pkg/npm/api/tmp/docket/index.js b/pkg/npm/api/tmp/docket/index.js new file mode 100644 index 000000000..872ee0de4 --- /dev/null +++ b/pkg/npm/api/tmp/docket/index.js @@ -0,0 +1,3 @@ +export * from './lib'; +export * from './types'; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/docket/index.js.map b/pkg/npm/api/tmp/docket/index.js.map new file mode 100644 index 000000000..ee11f934d --- /dev/null +++ b/pkg/npm/api/tmp/docket/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../docket/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/docket/lib.d.ts b/pkg/npm/api/tmp/docket/lib.d.ts new file mode 100644 index 000000000..540c66f53 --- /dev/null +++ b/pkg/npm/api/tmp/docket/lib.d.ts @@ -0,0 +1,15 @@ +import { Poke, Scry } from '../lib'; +import { Chad } from './types'; +export declare function chadIsRunning(chad: Chad): boolean; +export declare const scryCharges: Scry; +export declare const scryDockets: Scry; +export declare const scryTreaties: Scry; +export declare const scryDefaultAlly: Scry; +export declare const scryAllies: Scry; +export declare const scryAllyTreaties: (ship: string) => Scry; +/** + * Uninstall a desk, and remove docket + */ +export declare function docketUninstall(desk: string): Poke; +export declare function docketInstall(ship: string, desk: string): Poke; +export declare function allyShip(ship: string): Poke; diff --git a/pkg/npm/api/tmp/docket/lib.js b/pkg/npm/api/tmp/docket/lib.js new file mode 100644 index 000000000..a974be13a --- /dev/null +++ b/pkg/npm/api/tmp/docket/lib.js @@ -0,0 +1,54 @@ +export function chadIsRunning(chad) { + return 'glob' in chad || 'site' in chad; +} +export const scryCharges = { + app: 'docket', + path: '/charges' +}; +export const scryDockets = { + app: 'docket', + path: '/dockets' +}; +export const scryTreaties = { + app: 'treaty', + path: '/treaties' +}; +export const scryDefaultAlly = { + app: 'treaty', + path: '/default-ally' +}; +export const scryAllies = { + app: 'treaty', + path: '/allies' +}; +export const scryAllyTreaties = (ship) => ({ + app: 'treaty', + path: `/treaties/${ship}` +}); +/** + * Uninstall a desk, and remove docket + */ +export function docketUninstall(desk) { + return { + app: 'docket', + mark: 'docket-uninstall', + json: desk + }; +} +export function docketInstall(ship, desk) { + return { + app: 'docket', + mark: 'docket-install', + json: `${ship}/${desk}` + }; +} +export function allyShip(ship) { + return { + app: 'treaty', + mark: 'ally-update-0', + json: { + add: ship + } + }; +} +//# sourceMappingURL=lib.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/docket/lib.js.map b/pkg/npm/api/tmp/docket/lib.js.map new file mode 100644 index 000000000..7d7d1407c --- /dev/null +++ b/pkg/npm/api/tmp/docket/lib.js.map @@ -0,0 +1 @@ +{"version":3,"file":"lib.js","sourceRoot":"","sources":["../../docket/lib.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,aAAa,CAAC,IAAU;IACtC,OAAO,MAAM,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,CAAC;AAC1C,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAS;IAC/B,GAAG,EAAE,QAAQ;IACb,IAAI,EAAE,UAAU;CACjB,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAS;IAC/B,GAAG,EAAE,QAAQ;IACb,IAAI,EAAE,UAAU;CACjB,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAS;IAChC,GAAG,EAAE,QAAQ;IACb,IAAI,EAAE,WAAW;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAS;IACnC,GAAG,EAAE,QAAQ;IACb,IAAI,EAAE,eAAe;CACtB,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAS;IAC9B,GAAG,EAAE,QAAQ;IACb,IAAI,EAAE,SAAS;CAChB,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAY,EAAQ,EAAE,CAAC,CAAC;IACvD,GAAG,EAAE,QAAQ;IACb,IAAI,EAAE,aAAa,IAAI,EAAE;CAC1B,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO;QACL,GAAG,EAAE,QAAQ;QACb,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,IAAI;KACX,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,IAAY;IACtD,OAAO;QACL,GAAG,EAAE,QAAQ;QACb,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,GAAG,IAAI,IAAI,IAAI,EAAE;KACxB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,OAAO;QACL,GAAG,EAAE,QAAQ;QACb,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE;YACJ,GAAG,EAAE,IAAI;SACV;KACF,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/docket/types.d.ts b/pkg/npm/api/tmp/docket/types.d.ts new file mode 100644 index 000000000..594b0f310 --- /dev/null +++ b/pkg/npm/api/tmp/docket/types.d.ts @@ -0,0 +1,106 @@ +import { Cass } from '../hood'; +export declare type DeskStatus = 'active' | 'suspended'; +export declare type DocketHref = DocketHrefSite | DocketHrefGlob; +export interface DocketHrefGlob { + glob: { + base: string; + }; +} +export interface DocketHrefSite { + site: string; +} +export interface Docket { + title: string; + info?: string; + color: string; + href: DocketHref; + website: string; + license: string; + version: string; + image?: string; +} +export interface Charge extends Docket { + chad: Chad; +} +export declare type Chad = HungChad | GlobChad | SiteChad | InstallChad | SuspendChad; +export interface HungChad { + hung: string; +} +export interface GlobChad { + glob: null; +} +export interface SiteChad { + site: null; +} +export interface InstallChad { + install: null; +} +export interface SuspendChad { + suspend: null; +} +export interface Treaty extends Docket { + ship: string; + desk: string; + cass: Cass; + hash: string; +} +export interface Charges { + [desk: string]: Charge; +} +export interface Treaties { + [ref: string]: Treaty; +} +export declare type Charter = string[]; +export interface Allies { + [ship: string]: Charter; +} +export interface Provider { + shipName: string; + nickname?: string; + status?: string; +} +export declare type ChargeUpdate = ChargeUpdateInitial | ChargeUpdateAdd | ChargeUpdateDel; +export interface ChargeUpdateInitial { + initial: { + [desk: string]: Charge; + }; +} +export interface ChargeUpdateAdd { + 'add-charge': { + desk: string; + charge: Charge; + }; +} +export interface ChargeUpdateDel { + 'del-charge': string; +} +export declare type AllyUpdate = AllyUpdateIni | AllyUpdateAdd | AllyUpdateDel | AllyUpdateNew; +export interface AllyUpdateIni { + ini: { + [ship: string]: string[]; + }; +} +export interface AllyUpdateAdd { + add: string; +} +export interface AllyUpdateDel { + del: string; +} +export interface AllyUpdateNew { + new: { + ship: string; + alliance: string[]; + }; +} +export declare type TreatyUpdate = TreatyUpdateIni | TreatyUpdateAdd | TreatyUpdateDel; +export interface TreatyUpdateIni { + ini: { + [foreignDesk: string]: Treaty; + }; +} +export interface TreatyUpdateAdd { + add: Treaty; +} +export interface TreatyUpdateDel { + del: string; +} diff --git a/pkg/npm/api/tmp/docket/types.js b/pkg/npm/api/tmp/docket/types.js new file mode 100644 index 000000000..718fd38ae --- /dev/null +++ b/pkg/npm/api/tmp/docket/types.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/docket/types.js.map b/pkg/npm/api/tmp/docket/types.js.map new file mode 100644 index 000000000..0dffe4f69 --- /dev/null +++ b/pkg/npm/api/tmp/docket/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../../docket/types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/pkg/npm/api/tmp/graph/index.d.ts b/pkg/npm/api/tmp/graph/index.d.ts new file mode 100644 index 000000000..e06143cf1 --- /dev/null +++ b/pkg/npm/api/tmp/graph/index.d.ts @@ -0,0 +1,2 @@ +export * from './lib'; +export * from './types'; diff --git a/pkg/npm/api/tmp/graph/index.js b/pkg/npm/api/tmp/graph/index.js new file mode 100644 index 000000000..872ee0de4 --- /dev/null +++ b/pkg/npm/api/tmp/graph/index.js @@ -0,0 +1,3 @@ +export * from './lib'; +export * from './types'; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/graph/index.js.map b/pkg/npm/api/tmp/graph/index.js.map new file mode 100644 index 000000000..5db9fcbe9 --- /dev/null +++ b/pkg/npm/api/tmp/graph/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../graph/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/graph/lib.d.ts b/pkg/npm/api/tmp/graph/lib.d.ts new file mode 100644 index 000000000..1d8e9c69a --- /dev/null +++ b/pkg/npm/api/tmp/graph/lib.d.ts @@ -0,0 +1,148 @@ +import { GroupPolicy, Resource } from '../groups'; +import { Scry } from '../lib'; +import { Enc, Path, Patp, PatpNoSig, Poke, Thread } from '../lib/types'; +import { Content, GraphNodePoke, Post } from './types'; +export declare const GRAPH_UPDATE_VERSION = 3; +export declare const createBlankNodeWithChildPost: (ship: PatpNoSig, parentIndex: string, childIndex: string, contents: Content[]) => GraphNodePoke; +export declare const markPending: (nodes: any) => any; +export declare const createPost: (ship: PatpNoSig, contents: Content[], parentIndex?: string, childIndex?: string) => Post; +declare const storeAction: (data: T, version?: number) => Poke; +export { storeAction as graphStoreAction }; +declare const viewAction: (threadName: string, action: T) => Thread; +export { viewAction as graphViewAction }; +declare const hookAction: (data: T, version?: number) => Poke; +export { hookAction as graphHookAction }; +export declare const createManagedGraph: (ship: PatpNoSig, name: string, title: string, description: string, group: Path, mod: string) => Thread; +export declare const createUnmanagedGraph: (ship: PatpNoSig, name: string, title: string, description: string, policy: Enc, mod: string) => Thread; +export declare const joinGraph: (ship: Patp, name: string) => Thread; +export declare const deleteGraph: (ship: PatpNoSig, name: string) => Thread; +export declare const leaveGraph: (ship: Patp, name: string) => Thread; +export declare const groupifyGraph: (ship: Patp, name: string, toPath?: string) => Thread; +export declare const evalCord: (cord: string) => Thread; +export declare const addGraph: (ship: Patp, name: string, graph: any, mark: any) => Poke; +export declare const addNodes: (ship: Patp, name: string, nodes: Object) => Thread; +export declare const addPost: (ship: Patp, name: string, post: Post) => Thread; +export declare const addNode: (ship: Patp, name: string, node: GraphNodePoke) => Thread; +export declare const createGroupFeed: (group: Resource, vip?: any) => Thread; +export declare const disableGroupFeed: (group: Resource) => Thread; +/** + * Set dm-hook to screen new DMs or not + * + */ +export declare const setScreen: (screen: boolean) => Poke; +/** + * Accept a pending DM request + * + * @param ship the ship to accept + */ +export declare const acceptDm: (ship: string) => Poke<{ + accept: string; +}>; +/** + * Decline a pending DM request + * + * @param ship the ship to accept + */ +export declare const declineDm: (ship: string) => Poke<{ + decline: string; +}>; +/** + * Remove posts from a set of indices + * + */ +export declare const removePosts: (ship: Patp, name: string, indices: string[]) => Poke; +/** + * Remove a DM message from our inbox + * + * @remarks + * This does not remove the message from the recipients inbox + */ +export declare const removeDmMessage: (our: Patp, index: string) => Poke; +/** + * Send a DM to a ship + * + * @param our sender + * @param ship recipient + * @param contents contents of message + */ +export declare const addDmMessage: (our: PatpNoSig, ship: Patp, contents: Content[]) => Poke; +/** + * Fetch newest (larger keys) nodes in a graph under some index + * + * @param ship ship of graph + * @param name name of graph + * @param count number of nodes to load + * @param index index to query + */ +export declare const getNewest: (ship: string, name: string, count: number, index?: string) => Scry; +/** + * Fetch nodes in a graph that are older (key is smaller) and direct + * siblings of some index + * + * @param ship ship of graph + * @param name name of graph + * @param count number of nodes to load + * @param index index to query + */ +export declare const getOlderSiblings: (ship: string, name: string, count: number, index: string) => Scry; +/** + * Fetch nodes in a graph that are younger (key is larger) and direct + * siblings of some index + * + * @param ship ship of graph + * @param name name of graph + * @param count number of nodes to load + * @param index index to query + */ +export declare const getYoungerSiblings: (ship: string, name: string, count: number, index: string) => Scry; +/** + * Fetch all nodes in a graph under some index, without loading children + * + * @param ship ship of graph + * @param name name of graph + * @param index index to query + */ +export declare const getShallowChildren: (ship: string, name: string, index?: string) => { + app: string; + path: string; +}; +/** + * Fetch newest nodes in a graph as a flat map, including children, + * optionally starting at a specified key + * + * @param ship ship of graph + * @param name name of graph + * @param count number of nodes to load + * @param start key to start at + * + */ +export declare const getDeepOlderThan: (ship: string, name: string, count: number, start?: string) => { + app: string; + path: string; +}; +/** + * Fetch a flat map of a nodes ancestors and firstborn children + * + * @param ship ship of graph + * @param name name of graph + * @param index index to query + * + */ +export declare const getFirstborn: (ship: string, name: string, index: string) => Scry; +/** + * Fetch a single node, and all it's children + * + * @param ship ship of graph + * @param name name of graph + * @param index index to query + * + */ +export declare const getNode: (ship: string, name: string, index: string) => Scry; +/** + * Fetch entire graph + * + * @param ship ship of graph + * @param name name of graph + * + */ +export declare const getGraph: (ship: string, name: string) => Scry; diff --git a/pkg/npm/api/tmp/graph/lib.js b/pkg/npm/api/tmp/graph/lib.js new file mode 100644 index 000000000..af182a9db --- /dev/null +++ b/pkg/npm/api/tmp/graph/lib.js @@ -0,0 +1,380 @@ +import { makeResource, resourceFromPath } from '../groups'; +import { decToUd, deSig, unixToDa } from '../lib'; +import { patp2dec } from 'urbit-ob'; +export const GRAPH_UPDATE_VERSION = 3; +export const createBlankNodeWithChildPost = (ship, parentIndex = '', childIndex = '', contents) => { + const date = unixToDa(Date.now()).toString(); + const nodeIndex = parentIndex + '/' + date; + const childGraph = {}; + childGraph[childIndex] = { + post: { + author: `~${ship}`, + index: nodeIndex + '/' + childIndex, + 'time-sent': Date.now(), + contents, + hash: null, + signatures: [] + }, + children: null + }; + return { + post: { + author: `~${ship}`, + index: nodeIndex, + 'time-sent': Date.now(), + contents: [], + hash: null, + signatures: [] + }, + children: childGraph + }; +}; +export const markPending = (nodes) => { + Object.keys(nodes).forEach((key) => { + nodes[key].post.author = deSig(nodes[key].post.author); + nodes[key].post.pending = true; + if (nodes[key].children) { + nodes[key].children = markPending(nodes[key].children); + } + }); + return nodes; +}; +export const createPost = (ship, contents, parentIndex = '', childIndex = 'DATE_PLACEHOLDER') => { + if (childIndex === 'DATE_PLACEHOLDER') { + childIndex = unixToDa(Date.now()).toString(); + } + return { + author: `~${ship}`, + index: parentIndex + '/' + childIndex, + 'time-sent': Date.now(), + contents, + hash: null, + signatures: [] + }; +}; +function moduleToMark(mod) { + if (mod === 'link') { + return 'graph-validator-link'; + } + if (mod === 'publish') { + return 'graph-validator-publish'; + } + if (mod === 'chat') { + return 'graph-validator-chat'; + } + return undefined; +} +const storeAction = (data, version = GRAPH_UPDATE_VERSION) => ({ + app: 'graph-store', + mark: `graph-update-${version}`, + json: data +}); +export { storeAction as graphStoreAction }; +const viewAction = (threadName, action) => ({ + inputMark: 'graph-view-action', + outputMark: 'json', + threadName, + body: action +}); +export { viewAction as graphViewAction }; +const hookAction = (data, version = GRAPH_UPDATE_VERSION) => ({ + app: 'graph-push-hook', + mark: `graph-update-${version}`, + json: data +}); +const dmAction = (data) => ({ + app: 'dm-hook', + mark: 'dm-hook-action', + json: data +}); +export { hookAction as graphHookAction }; +export const createManagedGraph = (ship, name, title, description, group, mod) => { + const associated = { group: resourceFromPath(group) }; + const resource = makeResource(`~${ship}`, name); + return viewAction('graph-create', { + create: { + resource, + title, + description, + associated, + module: mod, + mark: moduleToMark(mod) + } + }); +}; +export const createUnmanagedGraph = (ship, name, title, description, policy, mod) => viewAction('graph-create', { + create: { + resource: makeResource(`~${ship}`, name), + title, + description, + associated: { policy }, + module: mod, + mark: moduleToMark(mod) + } +}); +export const joinGraph = (ship, name) => viewAction('graph-join', { + join: { + resource: makeResource(ship, name), + ship + } +}); +export const deleteGraph = (ship, name) => viewAction('graph-delete', { + 'delete': { + resource: makeResource(`~${ship}`, name) + } +}); +export const leaveGraph = (ship, name) => viewAction('graph-leave', { + 'leave': { + resource: makeResource(ship, name) + } +}); +export const groupifyGraph = (ship, name, toPath) => { + const resource = makeResource(ship, name); + const to = toPath && resourceFromPath(toPath); + return viewAction('graph-groupify', { + groupify: { + resource, + to + } + }); +}; +export const evalCord = (cord) => { + return ({ + inputMark: 'graph-view-action', + outputMark: 'tang', + threadName: 'graph-eval', + body: { + eval: cord + } + }); +}; +export const addGraph = (ship, name, graph, mark) => { + return storeAction({ + 'add-graph': { + resource: { ship, name }, + graph, + mark + } + }); +}; +export const addNodes = (ship, name, nodes) => ({ + inputMark: `graph-update-${GRAPH_UPDATE_VERSION}`, + outputMark: 'graph-view-action', + threadName: 'graph-add-nodes', + body: { + 'add-nodes': { + resource: { ship, name }, + nodes + } + } +}); +export const addPost = (ship, name, post) => { + const nodes = {}; + nodes[post.index] = { + post, + children: null + }; + return addNodes(ship, name, nodes); +}; +export const addNode = (ship, name, node) => { + const nodes = {}; + nodes[node.post.index] = node; + return addNodes(ship, name, nodes); +}; +export const createGroupFeed = (group, vip = '') => ({ + inputMark: 'graph-view-action', + outputMark: 'resource', + threadName: 'graph-create-group-feed', + body: { + 'create-group-feed': { + resource: group, + vip + } + } +}); +export const disableGroupFeed = (group) => ({ + inputMark: 'graph-view-action', + outputMark: 'json', + threadName: 'graph-disable-group-feed', + body: { + 'disable-group-feed': { + resource: group + } + } +}); +/** + * Set dm-hook to screen new DMs or not + * + */ +export const setScreen = (screen) => dmAction({ screen }); +/** + * Accept a pending DM request + * + * @param ship the ship to accept + */ +export const acceptDm = (ship) => dmAction({ + accept: ship +}); +/** + * Decline a pending DM request + * + * @param ship the ship to accept + */ +export const declineDm = (ship) => dmAction({ + decline: ship +}); +/** + * Remove posts from a set of indices + * + */ +export const removePosts = (ship, name, indices) => hookAction({ + 'remove-posts': { + resource: { ship, name }, + indices + } +}); +/** + * Remove a DM message from our inbox + * + * @remarks + * This does not remove the message from the recipients inbox + */ +export const removeDmMessage = (our, index) => ({ + app: 'graph-store', + mark: `graph-update-${GRAPH_UPDATE_VERSION}`, + json: { + 'remove-posts': { + resource: { ship: our, name: 'dm-inbox' }, + indices: [index] + } + } +}); +/** + * Send a DM to a ship + * + * @param our sender + * @param ship recipient + * @param contents contents of message + */ +export const addDmMessage = (our, ship, contents) => { + const post = createPost(our, contents, `/${patp2dec(ship)}`); + const node = { + post, + children: null + }; + return { + app: 'dm-hook', + mark: `graph-update-${GRAPH_UPDATE_VERSION}`, + json: { + 'add-nodes': { + resource: { ship: `~${our}`, name: 'dm-inbox' }, + nodes: { + [post.index]: node + } + } + } + }; +}; +const encodeIndex = (idx) => idx.split('/').map(decToUd).join('/'); +/** + * Fetch newest (larger keys) nodes in a graph under some index + * + * @param ship ship of graph + * @param name name of graph + * @param count number of nodes to load + * @param index index to query + */ +export const getNewest = (ship, name, count, index = '') => ({ + app: 'graph-store', + path: `/graph/${ship}/${name}/node/siblings` + + `/newest/lone/${count}${encodeIndex(index)}` +}); +/** + * Fetch nodes in a graph that are older (key is smaller) and direct + * siblings of some index + * + * @param ship ship of graph + * @param name name of graph + * @param count number of nodes to load + * @param index index to query + */ +export const getOlderSiblings = (ship, name, count, index) => ({ + app: 'graph-store', + path: `/graph/${ship}/${name}/node/siblings/older/lone/${count}${encodeIndex(index)}` +}); +/** + * Fetch nodes in a graph that are younger (key is larger) and direct + * siblings of some index + * + * @param ship ship of graph + * @param name name of graph + * @param count number of nodes to load + * @param index index to query + */ +export const getYoungerSiblings = (ship, name, count, index) => ({ + app: 'graph-store', + path: `/graph/${ship}/${name}/node/siblings/newer/lone/${count}${encodeIndex(index)}` +}); +/** + * Fetch all nodes in a graph under some index, without loading children + * + * @param ship ship of graph + * @param name name of graph + * @param index index to query + */ +export const getShallowChildren = (ship, name, index = '') => ({ + app: 'graph-store', + path: `/graph/${ship}/${name}/node/children/lone/~/~${encodeIndex(index)}` +}); +/** + * Fetch newest nodes in a graph as a flat map, including children, + * optionally starting at a specified key + * + * @param ship ship of graph + * @param name name of graph + * @param count number of nodes to load + * @param start key to start at + * + */ +export const getDeepOlderThan = (ship, name, count, start = '') => ({ + app: 'graph-store', + path: `/graph/${ship}/${name}/node/siblings` + + `/${start.length > 0 ? 'older' : 'newest'}` + + `/kith/${count}${encodeIndex(start)}` +}); +/** + * Fetch a flat map of a nodes ancestors and firstborn children + * + * @param ship ship of graph + * @param name name of graph + * @param index index to query + * + */ +export const getFirstborn = (ship, name, index) => ({ + app: 'graph-store', + path: `/graph/${ship}/${name}/node/firstborn${encodeIndex(index)}` +}); +/** + * Fetch a single node, and all it's children + * + * @param ship ship of graph + * @param name name of graph + * @param index index to query + * + */ +export const getNode = (ship, name, index) => ({ + app: 'graph-store', + path: `/graph/${ship}/${name}/node/index/kith${encodeIndex(index)}` +}); +/** + * Fetch entire graph + * + * @param ship ship of graph + * @param name name of graph + * + */ +export const getGraph = (ship, name) => ({ + app: 'graph-store', + path: `/graph/${ship}/${name}` +}); +//# sourceMappingURL=lib.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/graph/lib.js.map b/pkg/npm/api/tmp/graph/lib.js.map new file mode 100644 index 000000000..e62f9fff2 --- /dev/null +++ b/pkg/npm/api/tmp/graph/lib.js.map @@ -0,0 +1 @@ +{"version":3,"file":"lib.js","sourceRoot":"","sources":["../../graph/lib.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,YAAY,EAAY,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAElF,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAQ,MAAM,QAAQ,CAAC;AAGxD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAEtC,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,IAAe,EACf,WAAW,GAAG,EAAE,EAChB,UAAU,GAAG,EAAE,EACf,QAAmB,EACJ,EAAE;IACjB,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC7C,MAAM,SAAS,GAAG,WAAW,GAAG,GAAG,GAAG,IAAI,CAAC;IAE3C,MAAM,UAAU,GAAsB,EAAE,CAAC;IACzC,UAAU,CAAC,UAAU,CAAC,GAAG;QACvB,IAAI,EAAE;YACJ,MAAM,EAAE,IAAI,IAAI,EAAE;YAClB,KAAK,EAAE,SAAS,GAAG,GAAG,GAAG,UAAU;YACnC,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE;YACvB,QAAQ;YACR,IAAI,EAAE,IAAI;YACV,UA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MAAM,QAAQ,GAAG,CACtB,IAAY,EACZ,IAAY,EACN,EAAE,CAAC,CAAC;IACV,GAAG,EAAE,aAAa;IAClB,IAAI,EAAE,UAAU,IAAI,IAAI,IAAI,EAAE;CAC/B,CAAC,CAAC"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/graph/types.d.ts b/pkg/npm/api/tmp/graph/types.d.ts new file mode 100644 index 000000000..2c18e0103 --- /dev/null +++ b/pkg/npm/api/tmp/graph/types.d.ts @@ -0,0 +1,76 @@ +import { Patp } from '../lib'; +import { BigIntOrderedMap } from '../lib/BigIntOrderedMap'; +import { BigIntArrayOrderedMap } from '../lib/BigIntArrayOrderedMap'; +export interface TextContent { + text: string; +} +export interface UrlContent { + url: string; +} +export interface CodeContent { + code: { + expression: string; + output: string[] | undefined; + }; +} +export interface ReferenceContent { + reference: AppReference | GraphReference | GroupReference; +} +export interface GraphReference { + graph: { + graph: string; + group: string; + index: string; + }; +} +export interface GroupReference { + group: string; +} +export interface AppReference { + app: { + ship: string; + desk: string; + path: string; + }; +} +export interface MentionContent { + mention: string; +} +export declare type Content = TextContent | UrlContent | CodeContent | ReferenceContent | MentionContent; +export interface Post { + author: Patp; + contents: Content[]; + hash: string | null; + index: string; + pending?: boolean; + signatures: string[]; + 'time-sent': number; +} +export interface GraphNodePoke { + post: Post; + children: GraphChildrenPoke | null; +} +export interface GraphChildrenPoke { + [k: string]: GraphNodePoke; +} +export interface GraphNode { + children: Graph | null; + post: Post; +} +export interface FlatGraphNode { + children: null; + post: Post; +} +export declare type Graph = BigIntOrderedMap; +export declare type Graphs = { + [rid: string]: Graph; +}; +export declare type FlatGraph = BigIntArrayOrderedMap; +export declare type FlatGraphs = { + [rid: string]: FlatGraph; +}; +export declare type ThreadGraphs = { + [rid: string]: { + [index: string]: FlatGraph; + }; +}; diff --git a/pkg/npm/api/tmp/graph/types.js b/pkg/npm/api/tmp/graph/types.js new file mode 100644 index 000000000..718fd38ae --- /dev/null +++ b/pkg/npm/api/tmp/graph/types.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/graph/types.js.map b/pkg/npm/api/tmp/graph/types.js.map new file mode 100644 index 000000000..7a3e71902 --- /dev/null +++ b/pkg/npm/api/tmp/graph/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../../graph/types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/pkg/npm/api/tmp/groups/index.d.ts b/pkg/npm/api/tmp/groups/index.d.ts new file mode 100644 index 000000000..4a272fce5 --- /dev/null +++ b/pkg/npm/api/tmp/groups/index.d.ts @@ -0,0 +1,2 @@ +export * from './types'; +export * from './lib'; diff --git a/pkg/npm/api/tmp/groups/index.js b/pkg/npm/api/tmp/groups/index.js new file mode 100644 index 000000000..5c8443c9d --- /dev/null +++ b/pkg/npm/api/tmp/groups/index.js @@ -0,0 +1,3 @@ +export * from './types'; +export * from './lib'; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/groups/index.js.map b/pkg/npm/api/tmp/groups/index.js.map new file mode 100644 index 000000000..387cd9ddb --- /dev/null +++ b/pkg/npm/api/tmp/groups/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../groups/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/groups/lib.d.ts b/pkg/npm/api/tmp/groups/lib.d.ts new file mode 100644 index 000000000..a75a837a8 --- /dev/null +++ b/pkg/npm/api/tmp/groups/lib.d.ts @@ -0,0 +1,40 @@ +import { Enc, Path, Patp, PatpNoSig, Poke, Thread } from '../lib/types'; +import { Group, GroupPolicy, GroupPolicyDiff, GroupUpdateAddMembers, GroupUpdateAddTag, GroupUpdateChangePolicy, GroupUpdateRemoveGroup, GroupUpdateRemoveMembers, GroupUpdateRemoveTag, Resource, RoleTags, Tag } from './types'; +import { GroupUpdate } from './update'; +export declare const GROUP_UPDATE_VERSION = 0; +export declare const proxyAction: (data: T, version?: number) => Poke; +declare const storeAction: (data: T, version?: number) => Poke; +export { storeAction as groupStoreAction }; +declare const viewAction: (data: T) => Poke; +export { viewAction as groupViewAction }; +export declare const viewThread: (thread: string, action: T) => Thread; +export declare const removeMembers: (resource: Resource, ships: PatpNoSig[]) => Poke; +export declare const addTag: (resource: Resource, tag: Tag, ships: Patp[]) => Poke; +export declare const removeTag: (tag: Tag, resource: Resource, ships: PatpNoSig[]) => Poke; +export declare const addMembers: (resource: Resource, ships: PatpNoSig[]) => Poke; +export declare const removeGroup: (resource: Resource) => Poke; +export declare const changePolicy: (resource: Resource, diff: Enc) => Poke>; +export declare const makeResource: (ship: string, name: string) => { + ship: string; + name: string; +}; +export declare const join: (ship: string, name: string, app: "groups" | "graph", autojoin: boolean, share: boolean) => Poke; +export declare const createGroup: (name: string, policy: Enc, title: string, description: string) => Thread; +export declare const deleteGroup: (ship: string, name: string) => Thread; +export declare const leaveGroup: (ship: string, name: string) => Thread; +export declare const invite: (ship: string, name: string, ships: Patp[], description: string) => Thread; +export declare const abortJoin: (resource: string) => Poke; +export declare const roleTags: string[]; +export declare const groupBunts: { + group: () => Group; + policy: () => GroupPolicy; +}; +export declare const joinError: readonly ["no-perms", "strange", "abort"]; +export declare const joinResult: readonly ["done", "no-perms", "strange", "abort"]; +export declare const joinLoad: readonly ["start", "added", "metadata"]; +export declare const joinProgress: readonly ["start", "added", "metadata", "done", "no-perms", "strange", "abort"]; +export declare const roleForShip: (group: Group, ship: PatpNoSig) => RoleTags | undefined; +export declare const resourceFromPath: (path: Path) => Resource; +export declare const isWriter: (group: Group, resource: string, ship: string) => boolean; +export declare const isHost: (resource: string, ship: string) => boolean; +export declare const isChannelAdmin: (group: Group, resource: string, ship: string) => boolean; diff --git a/pkg/npm/api/tmp/groups/lib.js b/pkg/npm/api/tmp/groups/lib.js new file mode 100644 index 000000000..e2d572986 --- /dev/null +++ b/pkg/npm/api/tmp/groups/lib.js @@ -0,0 +1,139 @@ +export const GROUP_UPDATE_VERSION = 0; +export const proxyAction = (data, version = GROUP_UPDATE_VERSION) => ({ + app: 'group-push-hook', + mark: `group-update-${version}`, + json: data +}); +const storeAction = (data, version = GROUP_UPDATE_VERSION) => ({ + app: 'group-store', + mark: `group-update-${version}`, + json: data +}); +export { storeAction as groupStoreAction }; +const viewAction = (data) => ({ + app: 'group-view', + mark: 'group-view-action', + json: data +}); +export { viewAction as groupViewAction }; +export const viewThread = (thread, action) => ({ + inputMark: 'group-view-action', + outputMark: 'json', + threadName: thread, + body: action +}); +export const removeMembers = (resource, ships) => proxyAction({ + removeMembers: { + resource, + ships + } +}); +export const addTag = (resource, tag, ships) => proxyAction({ + addTag: { + resource, + tag, + ships + } +}); +export const removeTag = (tag, resource, ships) => proxyAction({ + removeTag: { + tag, + resource, + ships + } +}); +export const addMembers = (resource, ships) => proxyAction({ + addMembers: { + resource, + ships + } +}); +export const removeGroup = (resource) => storeAction({ + removeGroup: { + resource + } +}); +export const changePolicy = (resource, diff) => proxyAction({ + changePolicy: { + resource, + diff + } +}); +export const makeResource = (ship, name) => { + return { ship, name }; +}; +export const join = (ship, name, app, autojoin, share) => viewAction({ + join: { + resource: makeResource(ship, name), + ship, + shareContact: share || false, + app, + autojoin + } +}); +export const createGroup = (name, policy, title, description) => viewThread('group-create', { + create: { + name, + policy, + title, + description + } +}); +export const deleteGroup = (ship, name) => viewThread('group-delete', { + remove: makeResource(ship, name) +}); +export const leaveGroup = (ship, name) => viewThread('group-leave', { + leave: makeResource(ship, name) +}); +export const invite = (ship, name, ships, description) => viewThread('group-invite', { + invite: { + resource: makeResource(ship, name), + ships, + description + } +}); +export const abortJoin = (resource) => viewAction({ + abort: resource +}); +export const roleTags = ['janitor', 'moderator', 'admin']; +// TODO make this type better? +export const groupBunts = { + group: () => ({ members: new Set(), tags: { role: {} }, hidden: false, policy: groupBunts.policy() }), + policy: () => ({ open: { banned: new Set(), banRanks: new Set() } }) +}; +export const joinError = ['no-perms', 'strange', 'abort']; +export const joinResult = ['done', ...joinError]; +export const joinLoad = ['start', 'added', 'metadata']; +export const joinProgress = [...joinLoad, ...joinResult]; +export const roleForShip = (group, ship) => { + return roleTags.reduce((currRole, role) => { + const roleShips = group?.tags?.role?.[role]; + return roleShips && roleShips.has(ship) ? role : currRole; + }, undefined); +}; +export const resourceFromPath = (path) => { + const [, , ship, name] = path.split('/'); + return { ship, name }; +}; +export const isWriter = (group, resource, ship) => { + const graph = group.tags?.graph; + const writers = graph && graph[resource]?.writers; + const admins = group?.tags?.role?.admin ?? new Set(); + if (typeof writers === 'undefined') { + return true; + } + else { + return writers.has(ship) || admins.has(ship); + } +}; +export const isHost = (resource, ship) => { + const [, , host] = resource.split('/'); + return ship === host; +}; +export const isChannelAdmin = (group, resource, ship) => { + const role = roleForShip(group, ship.slice(1)); + return (isHost(resource, ship) || + role === 'admin' || + role === 'moderator'); +}; +//# sourceMappingURL=lib.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/groups/lib.js.map b/pkg/npm/api/tmp/groups/lib.js.map new file mode 100644 index 000000000..6c2d70922 --- /dev/null +++ b/pkg/npm/api/tmp/groups/lib.js.map @@ -0,0 +1 @@ +{"version":3,"file":"lib.js","sourceRoot":"","sources":["../../groups/lib.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAEtC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAI,IAAO,EAAE,UAAkB,oBAAoB,EAAW,EAAE,CAAC,CAAC;IAC3F,GAAG,EAAE,iBAAiB;IACtB,IAAI,EAAE,gBAAgB,OAAO,EAAE;IAC/B,IAAI,EAAE,IAAI;CACX,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,CAAwB,IAAO,EAAE,UAAkB,oBAAoB,EAAW,EAAE,CAAC,CAAC;IACxG,GAAG,EAAE,aAAa;IAClB,IAAI,EAAE,gB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AAAD,EAAG,IAAI,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAEvC,OAAO,IAAI,KAAK,IAAI,CAAC;AACvB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,KAAY,EACZ,QAAgB,EAChB,IAAY,EACH,EAAE;IACX,MAAM,IAAI,GAAG,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAE/C,OAAO,CACL,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC;QACtB,IAAI,KAAK,OAAO;QAChB,IAAI,KAAK,WAAW,CACrB,CAAC;AACJ,CAAC,CAAC"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/groups/types.d.ts b/pkg/npm/api/tmp/groups/types.d.ts new file mode 100644 index 000000000..b838383f1 --- /dev/null +++ b/pkg/npm/api/tmp/groups/types.d.ts @@ -0,0 +1,2 @@ +export * from './update'; +export * from './view'; diff --git a/pkg/npm/api/tmp/groups/types.js b/pkg/npm/api/tmp/groups/types.js new file mode 100644 index 000000000..fe3fba155 --- /dev/null +++ b/pkg/npm/api/tmp/groups/types.js @@ -0,0 +1,3 @@ +export * from './update'; +export * from './view'; +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/groups/types.js.map b/pkg/npm/api/tmp/groups/types.js.map new file mode 100644 index 000000000..e7f9f68e8 --- /dev/null +++ b/pkg/npm/api/tmp/groups/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../../groups/types.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/groups/update.d.ts b/pkg/npm/api/tmp/groups/update.d.ts new file mode 100644 index 000000000..a8e74a551 --- /dev/null +++ b/pkg/npm/api/tmp/groups/update.d.ts @@ -0,0 +1,133 @@ +import { PatpNoSig, Path, ShipRank, Enc } from '../lib'; +import { roleTags } from './index'; +export declare type RoleTags = typeof roleTags[number]; +interface RoleTag { + tag: 'admin' | 'moderator' | 'janitor'; +} +interface AppTag { + app: string; + resource: string; + tag: string; +} +export declare type Tag = AppTag | RoleTag; +export interface InvitePolicy { + invite: { + pending: Set; + }; +} +export interface OpenPolicy { + open: { + banned: Set; + banRanks: Set; + }; +} +export interface Resource { + name: string; + ship: PatpNoSig; +} +export declare type OpenPolicyDiff = AllowRanksDiff | BanRanksDiff | AllowShipsDiff | BanShipsDiff; +export interface AllowRanksDiff { + allowRanks: ShipRank[]; +} +export interface BanRanksDiff { + banRanks: ShipRank[]; +} +export interface AllowShipsDiff { + allowShips: PatpNoSig[]; +} +export interface BanShipsDiff { + banShips: PatpNoSig[]; +} +export declare type InvitePolicyDiff = AddInvitesDiff | RemoveInvitesDiff; +export interface AddInvitesDiff { + addInvites: PatpNoSig[]; +} +export interface RemoveInvitesDiff { + removeInvites: PatpNoSig[]; +} +export interface ReplacePolicyDiff { + replace: GroupPolicy; +} +export declare type GroupPolicyDiff = { + open: OpenPolicyDiff; +} | { + invite: InvitePolicyDiff; +} | ReplacePolicyDiff; +export declare type GroupPolicy = OpenPolicy | InvitePolicy; +export interface TaggedShips { + [tag: string]: Set; +} +export interface Tags { + role: TaggedShips; + [app: string]: TaggedShips; +} +export interface Group { + members: Set; + tags: Tags; + policy: GroupPolicy; + hidden: boolean; +} +export declare type Groups = { + [p in Path]: Group; +}; +export interface GroupUpdateInitial { + initial: Enc; +} +export interface GroupUpdateAddGroup { + addGroup: { + resource: Resource; + policy: Enc; + hidden: boolean; + }; +} +export interface GroupUpdateAddMembers { + addMembers: { + ships: PatpNoSig[]; + resource: Resource; + }; +} +export interface GroupUpdateRemoveMembers { + removeMembers: { + ships: PatpNoSig[]; + resource: Resource; + }; +} +export interface GroupUpdateAddTag { + addTag: { + tag: Tag; + resource: Resource; + ships: PatpNoSig[]; + }; +} +export interface GroupUpdateRemoveTag { + removeTag: { + tag: Tag; + resource: Resource; + ships: PatpNoSig[]; + }; +} +export interface GroupUpdateChangePolicy { + changePolicy: { + resource: Resource; + diff: GroupPolicyDiff; + }; +} +export interface GroupUpdateRemoveGroup { + removeGroup: { + resource: Resource; + }; +} +export interface GroupUpdateExpose { + expose: { + resource: Resource; + }; +} +export interface GroupUpdateInitialGroup { + initialGroup: { + resource: Resource; + group: Enc; + }; +} +export declare type GroupUpdate = GroupUpdateInitial | GroupUpdateAddGroup | GroupUpdateAddMembers | GroupUpdateRemoveMembers | GroupUpdateAddTag | GroupUpdateRemoveTag | GroupUpdateChangePolicy | GroupUpdateRemoveGroup | GroupUpdateExpose | GroupUpdateInitialGroup; +export declare type GroupAction = Omit; +export {}; diff --git a/pkg/npm/api/tmp/groups/update.js b/pkg/npm/api/tmp/groups/update.js new file mode 100644 index 000000000..3a8140041 --- /dev/null +++ b/pkg/npm/api/tmp/groups/update.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=update.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/groups/update.js.map b/pkg/npm/api/tmp/groups/update.js.map new file mode 100644 index 000000000..67c69672f --- /dev/null +++ b/pkg/npm/api/tmp/groups/update.js.map @@ -0,0 +1 @@ +{"version":3,"file":"update.js","sourceRoot":"","sources":["../../groups/update.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/pkg/npm/api/tmp/groups/view.d.ts b/pkg/npm/api/tmp/groups/view.d.ts new file mode 100644 index 000000000..9e8010ef7 --- /dev/null +++ b/pkg/npm/api/tmp/groups/view.d.ts @@ -0,0 +1,24 @@ +import { joinError, joinProgress, joinResult } from "."; +import { Patp } from "../lib"; +export declare type JoinError = typeof joinError[number]; +export declare type JoinResult = typeof joinResult[number]; +export declare type JoinProgress = typeof joinProgress[number]; +export interface JoinRequest { + /** + * Whether to display the join request or not + */ + hidden: boolean; + /** + * Timestamp of when the request started + */ + started: number; + ship: Patp; + progress: JoinProgress; + shareContact: boolean; + autojoin: boolean; + app: 'graph' | 'groups'; + invite: string[]; +} +export interface JoinRequests { + [rid: string]: JoinRequest; +} diff --git a/pkg/npm/api/tmp/groups/view.js b/pkg/npm/api/tmp/groups/view.js new file mode 100644 index 000000000..d8198797a --- /dev/null +++ b/pkg/npm/api/tmp/groups/view.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=view.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/groups/view.js.map b/pkg/npm/api/tmp/groups/view.js.map new file mode 100644 index 000000000..000c52048 --- /dev/null +++ b/pkg/npm/api/tmp/groups/view.js.map @@ -0,0 +1 @@ +{"version":3,"file":"view.js","sourceRoot":"","sources":["../../groups/view.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/pkg/npm/api/tmp/hark/index.d.ts b/pkg/npm/api/tmp/hark/index.d.ts new file mode 100644 index 000000000..4a272fce5 --- /dev/null +++ b/pkg/npm/api/tmp/hark/index.d.ts @@ -0,0 +1,2 @@ +export * from './types'; +export * from './lib'; diff --git a/pkg/npm/api/tmp/hark/index.js b/pkg/npm/api/tmp/hark/index.js new file mode 100644 index 000000000..5c8443c9d --- /dev/null +++ b/pkg/npm/api/tmp/hark/index.js @@ -0,0 +1,3 @@ +export * from './types'; +export * from './lib'; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/hark/index.js.map b/pkg/npm/api/tmp/hark/index.js.map new file mode 100644 index 000000000..8624fd26f --- /dev/null +++ b/pkg/npm/api/tmp/hark/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../hark/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/hark/lib.d.ts b/pkg/npm/api/tmp/hark/lib.d.ts new file mode 100644 index 000000000..3b75f25f2 --- /dev/null +++ b/pkg/npm/api/tmp/hark/lib.d.ts @@ -0,0 +1,46 @@ +import { BigInteger } from 'big-integer'; +import { Poke } from '../lib/types'; +import { HarkBin, HarkBinId, HarkLid, HarkPlace } from './types'; +export declare const harkAction: (data: T) => Poke; +declare const graphHookAction: (data: T) => Poke; +export { graphHookAction as harkGraphHookAction }; +declare const groupHookAction: (data: T) => Poke; +export { groupHookAction as harkGroupHookAction }; +export declare const actOnNotification: (frond: string, intTime: BigInteger, bin: HarkBin) => Poke; +export declare const setMentions: (mentions: boolean) => Poke; +export declare const setWatchOnSelf: (watchSelf: boolean) => Poke; +export declare const setDoNotDisturb: (dnd: boolean) => Poke; +export declare const archive: (bin: HarkBin, lid: HarkLid) => Poke; +export declare const opened: Poke<{ + opened: any; +}>; +export declare const markCountAsRead: (place: HarkPlace) => Poke; +export declare const markEachAsRead: (place: HarkPlace, path: string) => Poke; +export declare const seen: () => Poke<{ + seen: any; +}>; +export declare const readAll: Poke<{ + 'read-all': any; +}>; +export declare const archiveAll: Poke<{ + 'archive-all': any; +}>; +export declare const ignoreGroup: (group: string) => Poke; +export declare const ignoreGraph: (graph: string, index: string) => Poke; +export declare const listenGroup: (group: string) => Poke; +export declare const listenGraph: (graph: string, index: string) => Poke; +/** + * Read all graphs belonging to a particular group + */ +export declare const readGroup: (group: string) => Poke<{ + 'read-group': string; +}>; +/** + * Read all unreads in a graph + */ +export declare const readGraph: (graph: string) => Poke<{ + 'read-graph': string; +}>; +export declare function harkBinToId(bin: HarkBin): HarkBinId; +export declare function harkBinEq(a: HarkBin, b: HarkBin): boolean; +export declare function harkLidToId(lid: HarkLid): string; diff --git a/pkg/npm/api/tmp/hark/lib.js b/pkg/npm/api/tmp/hark/lib.js new file mode 100644 index 000000000..7ea20b407 --- /dev/null +++ b/pkg/npm/api/tmp/hark/lib.js @@ -0,0 +1,100 @@ +import { decToUd } from '../lib'; +export const harkAction = (data) => ({ + app: 'hark-store', + mark: 'hark-action', + json: data +}); +const graphHookAction = (data) => ({ + app: 'hark-graph-hook', + mark: 'hark-graph-hook-action', + json: data +}); +export { graphHookAction as harkGraphHookAction }; +const groupHookAction = (data) => ({ + app: 'hark-group-hook', + mark: 'hark-group-hook-action', + json: data +}); +export { groupHookAction as harkGroupHookAction }; +export const actOnNotification = (frond, intTime, bin) => harkAction({ + [frond]: { + time: decToUd(intTime.toString()), + bin + } +}); +export const setMentions = (mentions) => graphHookAction({ + 'set-mentions': mentions +}); +export const setWatchOnSelf = (watchSelf) => graphHookAction({ + 'set-watch-on-self': watchSelf +}); +export const setDoNotDisturb = (dnd) => harkAction({ + 'set-dnd': dnd +}); +export const archive = (bin, lid) => harkAction({ + archive: { + lid, + bin + } +}); +export const opened = harkAction({ + opened: null +}); +export const markCountAsRead = (place) => harkAction({ + 'read-count': place +}); +export const markEachAsRead = (place, path) => harkAction({ + 'read-each': { + place, + path + } +}); +export const seen = () => harkAction({ seen: null }); +export const readAll = harkAction({ 'read-all': null }); +export const archiveAll = harkAction({ 'archive-all': null }); +export const ignoreGroup = (group) => groupHookAction({ + ignore: group +}); +export const ignoreGraph = (graph, index) => graphHookAction({ + ignore: { + graph, + index + } +}); +export const listenGroup = (group) => groupHookAction({ + listen: group +}); +export const listenGraph = (graph, index) => graphHookAction({ + listen: { + graph, + index + } +}); +/** + * Read all graphs belonging to a particular group + */ +export const readGroup = (group) => harkAction({ + 'read-group': group +}); +/** + * Read all unreads in a graph + */ +export const readGraph = (graph) => harkAction({ + 'read-graph': graph +}); +export function harkBinToId(bin) { + const { place, path } = bin; + return `${place.desk}${place.path}${path}`; +} +export function harkBinEq(a, b) { + return (a.place.path === b.place.path && + a.place.desk === b.place.desk && + a.path === b.path); +} +export function harkLidToId(lid) { + if ('time' in lid) { + return `archive-${lid.time}`; + } + return Object.keys(lid)[0]; +} +//# sourceMappingURL=lib.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/hark/lib.js.map b/pkg/npm/api/tmp/hark/lib.js.map new file mode 100644 index 000000000..8915f9d06 --- /dev/null +++ b/pkg/npm/api/tmp/hark/lib.js.map @@ -0,0 +1 @@ +{"version":3,"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,CAAC;AAEL,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAa,EAAE,KAAa,EAAiB,EAAE,CACzE,eAAe,CAAC;IACd,MAAM,EAAE;QACN,KAAK;QACL,KAAK;KACN;CACF,CAAC,CAAC;AAEL;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAa,EAAE,EAAE,CACzC,UAAU,CAAC;IACT,YAAY,EAAE,KAAK;CACpB,CAAC,CAAC;AAEL;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAa,EAAE,EAAE,CACzC,UAAU,CAAC;IACT,YAAY,EAAE,KAAK;CACpB,CAAC,CAAC;AAEL,MAAM,UAAU,WAAW,CAAC,GAAY;IACtC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC;IAC5B,OAAO,GAAG,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,GAAG,IAAI,EAAE,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,CAAU,EAAE,CAAU;IAC9C,OAAO,CACL,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI;QAC7B,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI;QAC7B,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,CAClB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAY;IACtC,IAAG,MAAM,IAAI,GAAG,EAAE;QAChB,OAAO,WAAW,GAAG,CAAC,IAAI,EAAE,CAAC;KAC9B;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7B,CAAC"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/hark/types.d.ts b/pkg/npm/api/tmp/hark/types.d.ts new file mode 100644 index 000000000..475a0a62a --- /dev/null +++ b/pkg/npm/api/tmp/hark/types.d.ts @@ -0,0 +1,55 @@ +export interface HarkStats { + count: number; + each: string[]; + last: number; +} +export interface Timebox { + [binId: string]: Notification; +} +export declare type HarkContent = { + ship: string; +} | { + text: string; +}; +export interface HarkBody { + title: HarkContent[]; + time: string; + content: HarkContent[]; + link: string; + binned: string; +} +export interface HarkPlace { + desk: string; + path: string; +} +export interface HarkBin { + path: string; + place: HarkPlace; +} +export declare type HarkLid = { + unseen: null; +} | { + seen: null; +} | { + time: string; +}; +export declare type HarkBinId = string; +export interface Notification { + bin: HarkBin; + time: number; + body: HarkBody[]; +} +export interface NotificationGraphConfig { + watchOnSelf: boolean; + mentions: boolean; + watching: WatchedIndex[]; +} +export interface Unreads { + [path: string]: HarkStats; +} +interface WatchedIndex { + graph: string; + index: string; +} +export declare type GroupNotificationsConfig = string[]; +export {}; diff --git a/pkg/npm/api/tmp/hark/types.js b/pkg/npm/api/tmp/hark/types.js new file mode 100644 index 000000000..718fd38ae --- /dev/null +++ b/pkg/npm/api/tmp/hark/types.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/hark/types.js.map b/pkg/npm/api/tmp/hark/types.js.map new file mode 100644 index 000000000..cc26b3540 --- /dev/null +++ b/pkg/npm/api/tmp/hark/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../../hark/types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/pkg/npm/api/tmp/hood/index.d.ts b/pkg/npm/api/tmp/hood/index.d.ts new file mode 100644 index 000000000..e06143cf1 --- /dev/null +++ b/pkg/npm/api/tmp/hood/index.d.ts @@ -0,0 +1,2 @@ +export * from './lib'; +export * from './types'; diff --git a/pkg/npm/api/tmp/hood/index.js b/pkg/npm/api/tmp/hood/index.js new file mode 100644 index 000000000..872ee0de4 --- /dev/null +++ b/pkg/npm/api/tmp/hood/index.js @@ -0,0 +1,3 @@ +export * from './lib'; +export * from './types'; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/hood/index.js.map b/pkg/npm/api/tmp/hood/index.js.map new file mode 100644 index 000000000..deed8c74e --- /dev/null +++ b/pkg/npm/api/tmp/hood/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../hood/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/hood/lib.d.ts b/pkg/npm/api/tmp/hood/lib.d.ts new file mode 100644 index 000000000..3886ad812 --- /dev/null +++ b/pkg/npm/api/tmp/hood/lib.d.ts @@ -0,0 +1,34 @@ +import { Poke, Scry } from '../lib'; +import { Vats, Vat } from './types'; +export declare const getVats: Scry; +/** + * Install a foreign desk + */ +export declare function kilnInstall(ship: string, desk: string, local?: string): Poke; +/** + * Uninstall a desk + */ +export declare function kilnUninstall(desk: string): Poke; +export declare function kilnSuspend(desk: string): Poke; +export declare function kilnRevive(desk: string): Poke; +export declare function kilnBump(force?: boolean, except?: string[]): { + app: string; + mark: string; + json: { + force: boolean; + except: string[]; + }; +}; +export declare function kilnPause(desk: string): { + app: string; + mark: string; + json: string; +}; +export declare function kilnResume(desk: string): { + app: string; + mark: string; + json: string; +}; +export declare const scryLag: Scry; +export declare function getBlockers(vats: Vats): string[]; +export declare function getVatPublisher(vat: Vat): string | undefined; diff --git a/pkg/npm/api/tmp/hood/lib.js b/pkg/npm/api/tmp/hood/lib.js new file mode 100644 index 000000000..885f9395b --- /dev/null +++ b/pkg/npm/api/tmp/hood/lib.js @@ -0,0 +1,97 @@ +export const getVats = { + app: 'hood', + path: '/kiln/vats' +}; +/** + * Install a foreign desk + */ +export function kilnInstall(ship, desk, local) { + return { + app: 'hood', + mark: 'kiln-install', + json: { + ship, + desk, + local: local || desk + } + }; +} +/** + * Uninstall a desk + */ +export function kilnUninstall(desk) { + return { + app: 'hood', + mark: 'kiln-uninstall', + json: desk + }; +} +export function kilnSuspend(desk) { + return { + app: 'hood', + mark: 'kiln-suspend', + json: desk + }; +} +export function kilnRevive(desk) { + return { + app: 'hood', + mark: 'kiln-revive', + json: desk + }; +} +export function kilnBump(force = false, except = []) { + return { + app: 'hood', + mark: 'kiln-bump', + json: { + force, + except + } + }; +} +export function kilnPause(desk) { + return { + app: 'hood', + mark: 'kiln-pause', + json: desk + }; +} +export function kilnResume(desk) { + return { + app: 'hood', + mark: 'kiln-resume', + json: desk + }; +} +export const scryLag = ({ app: 'hood', path: '/kiln/lag' }); +export function getBlockers(vats) { + const blockers = []; + const base = vats?.base; + if (!base) { + return blockers; + } + const blockedOn = base.arak.rail?.next?.[0]?.weft?.kelvin; + if (!blockedOn) { + return blockers; + } + Object.entries(vats) + .filter(([desk]) => desk !== 'base') + .forEach(([desk, vat]) => { + // assuming only %zuse + const woofs = vat.arak.rail?.next || []; + const kelvins = woofs.map(n => n.weft.kelvin); + if (!(kelvins.includes(blockedOn))) { + blockers.push(desk); + } + }); + return blockers; +} +export function getVatPublisher(vat) { + if (vat.arak.rail) { + const { rail } = vat.arak; + return (rail?.publisher || rail?.ship || undefined); + } + return undefined; +} +//# sourceMappingURL=lib.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/hood/lib.js.map b/pkg/npm/api/tmp/hood/lib.js.map new file mode 100644 index 000000000..79f13c95f --- /dev/null +++ b/pkg/npm/api/tmp/hood/lib.js.map @@ -0,0 +1 @@ +{"version":3,"file":"lib.js","sourceRoot":"","sources":["../../hood/lib.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,OAAO,GAAS;IAC3B,GAAG,EAAE,MAAM;IACX,IAAI,EAAE,YAAY;CACnB,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,WAAW,CACzB,IAAY,EACZ,IAAY,EACZ,KAAc;IAEd,OAAO;QACL,GAAG,EAAE,MAAM;QACX,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE;YACJ,IAAI;YACJ,IAA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EAAE;QACR,OAAO,QAAQ,CAAC;KACjB;IACD,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC;IAC1D,IAAG,CAAC,SAAS,EAAE;QACb,OAAO,QAAQ,CAAC;KACjB;IAED,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;SACjB,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,MAAM,CAAC;SACnC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE;QACvB,sBAAsB;QACtB,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC;QACxC,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC9C,IAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE;YACjC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACrB;IACH,CAAC,CAAC,CAAC;IAEL,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAQ;IACtC,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE;QACjB,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC;QAC1B,OAAO,CAAC,IAAI,EAAE,SAAS,IAAI,IAAI,EAAE,IAAI,IAAI,SAAS,CAAC,CAAC;KACrD;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/hood/types.d.ts b/pkg/npm/api/tmp/hood/types.d.ts new file mode 100644 index 000000000..92ff9ed7c --- /dev/null +++ b/pkg/npm/api/tmp/hood/types.d.ts @@ -0,0 +1,145 @@ +/** + * A pending commit, awaiting a future kelvin version + */ +interface Woof { + aeon: number; + weft: Weft; +} +interface Rein { + /** + * Agents not in manifest that should be running + */ + add: string[]; + /** + * Agents in manifest that should not be running + */ + sub: string[]; +} +export interface Rail { + /** + * Original publisher of desk, if available + */ + publisher: string | null; + /** + * Ship of foreign vat + */ + ship: string; + /** + * Desk of foreign vat + */ + desk: string; + /** + * Aeon (version number) that we currently have synced + */ + aeon: number; + next: Woof[]; + paused: boolean; +} +/** + * A tracker of a foreign {@link Vat} + * + */ +export interface Arak { + rein: Rein; + rail: Rail | null; +} +/** + * A component's kelvin version + */ +export interface Weft { + /** + * Name of the component + * + * @remarks + * Usually %zuse, %hoon, or %lull + */ + name: string; + /** + * Kelvin version + * + */ + kelvin: number; +} +export interface KilnDiffBlock { + block: { + desk: string; + arak: Arak; + weft: Weft; + blockers: string[]; + }; +} +export interface KilnDiffReset { + reset: { + desk: string; + arak: Arak; + }; +} +export interface KilnDiffMerge { + merge: { + desk: string; + arak: Arak; + }; +} +export interface KilnDiffMergeSunk { + 'merge-sunk': { + desk: string; + arak: Arak; + tang: string; + }; +} +export interface KilnDiffMergeFail { + 'merge-fail': { + desk: string; + arak: Arak; + tang: string; + }; +} +export declare type KilnDiff = KilnDiffBlock | KilnDiffReset | KilnDiffMerge | KilnDiffMergeSunk | KilnDiffMergeFail; +/** + * Cases for revision + * + */ +export interface Cass { + /** + * Revision number + */ + ud: number; + /** + * Timestamp of revision, as stringifed `@da` + * + * @remarks + * If \@da is outside valid positive unix timestamp, value will be zero + */ + da: string; +} +/** + * A local desk installation + */ +export interface Vat { + /** + * Desk that this Vat describes + */ + desk: string; + /** + * Hash of the desk, rendered as `@uv` + * + * @remarks + * Equivalent to + * ```hoon + * .^(@uv %cz /=desk=) + * ``` + */ + hash: string; + /** + * Current revision + */ + cass: Cass; + /** + * Foreign sync + */ + arak: Arak; +} +export interface Vats { + [desk: string]: Vat; +} +export {}; diff --git a/pkg/npm/api/tmp/hood/types.js b/pkg/npm/api/tmp/hood/types.js new file mode 100644 index 000000000..718fd38ae --- /dev/null +++ b/pkg/npm/api/tmp/hood/types.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/hood/types.js.map b/pkg/npm/api/tmp/hood/types.js.map new file mode 100644 index 000000000..bbc8fe4cb --- /dev/null +++ b/pkg/npm/api/tmp/hood/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../../hood/types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/pkg/npm/api/tmp/index.d.ts b/pkg/npm/api/tmp/index.d.ts new file mode 100644 index 000000000..b0576ccfe --- /dev/null +++ b/pkg/npm/api/tmp/index.d.ts @@ -0,0 +1,22 @@ +export * from './contacts'; +export * as contacts from './contacts'; +export * from './graph'; +export * as graph from './graph'; +export * from './groups'; +export * as groups from './groups'; +export * from './hark'; +export * as hark from './hark'; +export * from './invite'; +export * from './metadata'; +export * as metadata from './metadata'; +export * from './settings'; +export * as settings from './settings'; +export * from './s3'; +export * as s3 from './s3'; +export * from './lib'; +export * from './lib/BigIntOrderedMap'; +export * from './lib/BigIntArrayOrderedMap'; +export * as hood from './hood'; +export * from './hood'; +export * as docket from './docket'; +export * from './docket'; diff --git a/pkg/npm/api/tmp/index.js b/pkg/npm/api/tmp/index.js new file mode 100644 index 000000000..75b48a634 --- /dev/null +++ b/pkg/npm/api/tmp/index.js @@ -0,0 +1,25 @@ +export * from './contacts'; +export * as contacts from './contacts'; +export * from './graph'; +export * as graph from './graph'; +export * from './groups'; +export * as groups from './groups'; +export * from './hark'; +export * as hark from './hark'; +export * from './invite'; +// this conflicts with /groups/lib invite +// export * as invite from './invite'; +export * from './metadata'; +export * as metadata from './metadata'; +export * from './settings'; +export * as settings from './settings'; +export * from './s3'; +export * as s3 from './s3'; +export * from './lib'; +export * from './lib/BigIntOrderedMap'; +export * from './lib/BigIntArrayOrderedMap'; +export * as hood from './hood'; +export * from './hood'; +export * as docket from './docket'; +export * from './docket'; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/index.js.map b/pkg/npm/api/tmp/index.js.map new file mode 100644 index 000000000..91d106aaf --- /dev/null +++ b/pkg/npm/api/tmp/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,cAAc,SAAS,CAAC;AACxB,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,cAAc,QAAQ,CAAC;AACvB,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,yCAAyC;AACzC,sCAAsC;AACtC,cAAc,YAAY,CAAC;AAC3B,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,cAAc,YAAY,CAAC;AAC3B,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,cAAc,MAAM,CAAC;AACrB,OAAO,KAAK,EAAE,MAAM,MAAM,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,cAAc,UAAU,CAAC"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/invite/index.d.ts b/pkg/npm/api/tmp/invite/index.d.ts new file mode 100644 index 000000000..4a272fce5 --- /dev/null +++ b/pkg/npm/api/tmp/invite/index.d.ts @@ -0,0 +1,2 @@ +export * from './types'; +export * from './lib'; diff --git a/pkg/npm/api/tmp/invite/index.js b/pkg/npm/api/tmp/invite/index.js new file mode 100644 index 000000000..5c8443c9d --- /dev/null +++ b/pkg/npm/api/tmp/invite/index.js @@ -0,0 +1,3 @@ +export * from './types'; +export * from './lib'; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/invite/index.js.map b/pkg/npm/api/tmp/invite/index.js.map new file mode 100644 index 000000000..ebd16bd59 --- /dev/null +++ b/pkg/npm/api/tmp/invite/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../invite/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/invite/lib.d.ts b/pkg/npm/api/tmp/invite/lib.d.ts new file mode 100644 index 000000000..e8c18e884 --- /dev/null +++ b/pkg/npm/api/tmp/invite/lib.d.ts @@ -0,0 +1,5 @@ +import { Poke, Serial } from "../lib"; +import { InviteUpdate, InviteUpdateAccept, InviteUpdateDecline } from "./types"; +export declare const inviteAction: (data: T) => Poke; +export declare const accept: (app: string, uid: Serial) => Poke; +export declare const decline: (app: string, uid: Serial) => Poke; diff --git a/pkg/npm/api/tmp/invite/lib.js b/pkg/npm/api/tmp/invite/lib.js new file mode 100644 index 000000000..db7195c3c --- /dev/null +++ b/pkg/npm/api/tmp/invite/lib.js @@ -0,0 +1,18 @@ +export const inviteAction = (data) => ({ + app: 'invite-store', + mark: 'invite-action', + json: data +}); +export const accept = (app, uid) => inviteAction({ + accept: { + term: app, + uid + } +}); +export const decline = (app, uid) => inviteAction({ + decline: { + term: app, + uid + } +}); +//# sourceMappingURL=lib.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/invite/lib.js.map b/pkg/npm/api/tmp/invite/lib.js.map new file mode 100644 index 000000000..8cfb7eaa2 --- /dev/null +++ b/pkg/npm/api/tmp/invite/lib.js.map @@ -0,0 +1 @@ +{"version":3,"file":"lib.js","sourceRoot":"","sources":["../../invite/lib.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,YAAY,GAAG,CAAyB,IAAO,EAAW,EAAE,CAAC,CAAC;IACzE,GAAG,EAAE,cAAc;IACnB,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE,IAAI;CACX,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,MAAM,GAAG,CACpB,GAAW,EACX,GAAW,EACe,EAAE,CAAC,YAAY,CAAC;IAC1C,MAAM,EAAE;QACN,IAAI,EAAE,GAAG;QACT,GAAG;KACJ;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,GAAW,EACX,GAAW,EACgB,EAAE,CAAC,YAAY,CAAC;IAC3C,OAAO,EAAE;QACP,IAAI,EAAE,GAAG;QACT,GAAG;KACJ;CACF,CAAC,CAAC"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/invite/types.d.ts b/pkg/npm/api/tmp/invite/types.d.ts new file mode 100644 index 000000000..d9418ba8f --- /dev/null +++ b/pkg/npm/api/tmp/invite/types.d.ts @@ -0,0 +1,54 @@ +import { Serial, PatpNoSig, Path } from '../lib'; +import { Resource } from "../groups"; +export declare type InviteUpdate = InviteUpdateInitial | InviteUpdateCreate | InviteUpdateDelete | InviteUpdateInvite | InviteUpdateAccept | InviteUpdateAccepted | InviteUpdateDecline; +export interface InviteUpdateAccept { + accept: { + term: string; + uid: Serial; + }; +} +export interface InviteUpdateInitial { + initial: Invites; +} +export interface InviteUpdateCreate { + create: { + term: string; + }; +} +export interface InviteUpdateDelete { + delete: { + term: string; + }; +} +export interface InviteUpdateInvite { + invite: { + term: string; + uid: Serial; + invite: Invite; + }; +} +export interface InviteUpdateAccepted { + accepted: { + term: string; + uid: Serial; + }; +} +export interface InviteUpdateDecline { + decline: { + term: string; + uid: Serial; + }; +} +export declare type Invites = { + [p in Path]: AppInvites; +}; +export declare type AppInvites = { + [s in Serial]: Invite; +}; +export interface Invite { + app: string; + recipient: PatpNoSig; + resource: Resource; + ship: PatpNoSig; + text: string; +} diff --git a/pkg/npm/api/tmp/invite/types.js b/pkg/npm/api/tmp/invite/types.js new file mode 100644 index 000000000..718fd38ae --- /dev/null +++ b/pkg/npm/api/tmp/invite/types.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/invite/types.js.map b/pkg/npm/api/tmp/invite/types.js.map new file mode 100644 index 000000000..e163d5eee --- /dev/null +++ b/pkg/npm/api/tmp/invite/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../../invite/types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/pkg/npm/api/tmp/lib/BigIntArrayOrderedMap.d.ts b/pkg/npm/api/tmp/lib/BigIntArrayOrderedMap.d.ts new file mode 100644 index 000000000..4dd317c53 --- /dev/null +++ b/pkg/npm/api/tmp/lib/BigIntArrayOrderedMap.d.ts @@ -0,0 +1,24 @@ +import { immerable } from 'immer'; +import bigInt, { BigInteger } from 'big-integer'; +export declare function stringToArr(str: string): bigInt.BigInteger[]; +export declare function arrToString(arr: BigInteger[]): string; +export declare function sortBigIntArr(a: BigInteger[], b: BigInteger[]): number; +export declare class BigIntArrayOrderedMap implements Iterable<[BigInteger[], V]> { + root: Record; + cachedIter: [BigInteger[], V][] | null; + [immerable]: boolean; + reversed: boolean; + constructor(items?: [BigInteger[], V][], reversed?: boolean); + get size(): number; + get(key: BigInteger[]): V; + gas(items: [BigInteger[], V][]): this; + set(key: BigInteger[], value: V): this; + clear(): this; + has(key: BigInteger[]): boolean; + delete(key: BigInteger[]): this; + [Symbol.iterator](): IterableIterator<[BigInteger[], V]>; + peekLargest(): [bigInt.BigInteger[], V]; + peekSmallest(): [bigInt.BigInteger[], V]; + keys(): bigInt.BigInteger[][]; + generateCachedIter(): [bigInt.BigInteger[], V][]; +} diff --git a/pkg/npm/api/tmp/lib/BigIntArrayOrderedMap.js b/pkg/npm/api/tmp/lib/BigIntArrayOrderedMap.js new file mode 100644 index 000000000..04e568ef3 --- /dev/null +++ b/pkg/npm/api/tmp/lib/BigIntArrayOrderedMap.js @@ -0,0 +1,131 @@ +import produce, { immerable, castDraft, setAutoFreeze, enablePatches } from 'immer'; +import bigInt from 'big-integer'; +setAutoFreeze(false); +enablePatches(); +export function stringToArr(str) { + return str.split('/').slice(1).map((ind) => { + return bigInt(ind); + }); +} +export function arrToString(arr) { + let string = ''; + arr.forEach((key) => { + string = string + `/${key.toString()}`; + }); + return string; +} +function sorted(a, b, reversed = false) { + const getSort = sortBigIntArr(a, b); + if (reversed) { + return getSort * -1; + } + else { + return getSort; + } +} +export function sortBigIntArr(a, b) { + const aLen = a.length; + const bLen = b.length; + const aCop = a.slice(0); + const bCop = b.slice(0); + aCop.reverse(); + bCop.reverse(); + let i = 0; + while (i < aLen && i < bLen) { + if (aCop[i].lt(bCop[i])) { + return 1; + } + else if (aCop[i].gt(bCop[i])) { + return -1; + } + else { + i++; + } + } + return bLen - aLen; +} +export class BigIntArrayOrderedMap { + root = {}; + cachedIter = null; + [immerable] = true; + reversed = false; + constructor(items = [], reversed = false) { + items.forEach(([key, val]) => { + this.set(key, val); + }); + this.reversed = reversed; + } + get size() { + return Object.keys(this.root).length; + } + get(key) { + return this.root[arrToString(key)] ?? null; + } + gas(items) { + return produce(this, (draft) => { + items.forEach(([key, value]) => { + draft.root[arrToString(key)] = castDraft(value); + }); + draft.generateCachedIter(); + }, (patches) => { + // console.log(`gassed with ${JSON.stringify(patches, null, 2)}`); + }); + } + set(key, value) { + return produce(this, (draft) => { + draft.root[arrToString(key)] = castDraft(value); + draft.cachedIter = null; + }); + } + clear() { + return produce(this, (draft) => { + draft.cachedIter = []; + draft.root = {}; + }); + } + has(key) { + return arrToString(key) in this.root; + } + delete(key) { + const result = produce(this, (draft) => { + delete draft.root[arrToString(key)]; + draft.cachedIter = null; + }); + return result; + } + [Symbol.iterator]() { + let idx = 0; + const result = this.generateCachedIter(); + return { + [Symbol.iterator]: this[Symbol.iterator], + next: () => { + if (idx < result.length) { + return { value: result[idx++], done: false }; + } + return { done: true, value: null }; + } + }; + } + peekLargest() { + const sorted = Array.from(this); + return sorted[0]; + } + peekSmallest() { + const sorted = Array.from(this); + return sorted[sorted.length - 1]; + } + keys() { + return Array.from(this).map(([k, v]) => k); + } + generateCachedIter() { + if (this.cachedIter) { + return [...this.cachedIter]; + } + const result = Object.keys(this.root).map((key) => { + return [stringToArr(key), this.root[key]]; + }).sort(([a], [b]) => sorted(a, b, this.reversed)); + this.cachedIter = result; + return [...result]; + } +} +//# sourceMappingURL=BigIntArrayOrderedMap.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/lib/BigIntArrayOrderedMap.js.map b/pkg/npm/api/tmp/lib/BigIntArrayOrderedMap.js.map new file mode 100644 index 000000000..81db34c03 --- /dev/null +++ b/pkg/npm/api/tmp/lib/BigIntArrayOrderedMap.js.map @@ -0,0 +1 @@ +{"version":3,"file":"BigIntArrayOrderedMap.js","sourceRoot":"","sources":["../../lib/BigIntArrayOrderedMap.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACpF,OAAO,MAAsB,MAAM,aAAa,CAAC;AAEjD,aAAa,CAAC,KAAK,CAAC,CAAC;AAErB,aAAa,EAAE,CAAC;AAEhB,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QACzC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAiB;IAC3C,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QAClB,MAAM,GAAG,MA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CAAC;IAED,YAAY;QACV,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChC,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAA6B,CAAC;IAC/D,CAAC;IAED,IAAI;QACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED,kBAAkB;QAChB,IAAG,IAAI,CAAC,UAAU,EAAE;YAClB,OAAO,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;SAC7B;QACD,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;YAChD,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAsB,CAAC;QACjE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;QACnD,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC;QACzB,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC;IACrB,CAAC;CACF"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/lib/BigIntOrderedMap.d.ts b/pkg/npm/api/tmp/lib/BigIntOrderedMap.d.ts new file mode 100644 index 000000000..bcbcbb0e7 --- /dev/null +++ b/pkg/npm/api/tmp/lib/BigIntOrderedMap.d.ts @@ -0,0 +1,20 @@ +import { immerable } from 'immer'; +import bigInt, { BigInteger } from 'big-integer'; +export declare class BigIntOrderedMap implements Iterable<[BigInteger, V]> { + root: Record; + cachedIter: [BigInteger, V][] | null; + [immerable]: boolean; + constructor(items?: [BigInteger, V][]); + get size(): number; + get(key: BigInteger): V; + gas(items: [BigInteger, V][]): this; + set(key: BigInteger, value: V): this; + clear(): this; + has(key: BigInteger): boolean; + delete(key: BigInteger): this; + [Symbol.iterator](): IterableIterator<[BigInteger, V]>; + peekLargest(): [bigInt.BigInteger, V]; + peekSmallest(): [bigInt.BigInteger, V]; + keys(): bigInt.BigInteger[]; + generateCachedIter(): [bigInt.BigInteger, V][]; +} diff --git a/pkg/npm/api/tmp/lib/BigIntOrderedMap.js b/pkg/npm/api/tmp/lib/BigIntOrderedMap.js new file mode 100644 index 000000000..ee37d9aef --- /dev/null +++ b/pkg/npm/api/tmp/lib/BigIntOrderedMap.js @@ -0,0 +1,102 @@ +import produce, { immerable, castDraft, setAutoFreeze, enablePatches } from 'immer'; +import bigInt from 'big-integer'; +setAutoFreeze(false); +enablePatches(); +function sortBigInt(a, b) { + if (a.lt(b)) { + return 1; + } + else if (a.eq(b)) { + return 0; + } + else { + return -1; + } +} +export class BigIntOrderedMap { + root = {}; + cachedIter = null; + [immerable] = true; + constructor(items = []) { + items.forEach(([key, val]) => { + this.set(key, val); + }); + } + get size() { + if (this.cachedIter) { + return this.cachedIter.length; + } + return this.generateCachedIter().length; + } + get(key) { + return this.root[key.toString()] ?? null; + } + gas(items) { + return produce(this, (draft) => { + items.forEach(([key, value]) => { + draft.root[key.toString()] = castDraft(value); + }); + draft.cachedIter = null; + }, (patches) => { + // console.log(`gassed with ${JSON.stringify(patches, null, 2)}`); + }); + } + set(key, value) { + return produce(this, (draft) => { + draft.root[key.toString()] = castDraft(value); + draft.cachedIter = null; + }); + } + clear() { + return produce(this, (draft) => { + draft.cachedIter = []; + draft.root = {}; + }); + } + has(key) { + return key.toString() in this.root; + } + delete(key) { + const result = produce(this, (draft) => { + delete draft.root[key.toString()]; + draft.cachedIter = null; + }); + return result; + } + [Symbol.iterator]() { + let idx = 0; + const result = this.generateCachedIter(); + return { + [Symbol.iterator]: this[Symbol.iterator], + next: () => { + if (idx < result.length) { + return { value: result[idx++], done: false }; + } + return { done: true, value: null }; + } + }; + } + peekLargest() { + const sorted = Array.from(this); + return sorted[0]; + } + peekSmallest() { + const sorted = Array.from(this); + return sorted[sorted.length - 1]; + } + keys() { + return Array.from(this).map(([k, v]) => k); + } + generateCachedIter() { + if (this.cachedIter) { + return [...this.cachedIter]; + } + const result = Object.keys(this.root).map((key) => { + const num = bigInt(key); + return [num, this.root[key]]; + }).sort(([a], [b]) => sortBigInt(a, b)); + this.cachedIter = result; + return [...result]; + } +} +//# sourceMappingURL=BigIntOrderedMap.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/lib/BigIntOrderedMap.js.map b/pkg/npm/api/tmp/lib/BigIntOrderedMap.js.map new file mode 100644 index 000000000..f907f6444 --- /dev/null +++ b/pkg/npm/api/tmp/lib/BigIntOrderedMap.js.map @@ -0,0 +1 @@ +{"version":3,"file":"BigIntOrderedMap.js","sourceRoot":"","sources":["../../lib/BigIntOrderedMap.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACpF,OAAO,MAAsB,MAAM,aAAa,CAAC;AAEjD,aAAa,CAAC,KAAK,CAAC,CAAC;AAErB,aAAa,EAAE,CAAC;AAEhB,SAAS,UAAU,CAAC,CAAa,EAAE,CAAa;IAC9C,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;QACX,OAAO,CAAC,CAAC;KACV;SAAM,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;QAClB,OAAO,CAAC,CAAC;KACV;SAAM;QACL,OAAO,CAAC,CAAC,CAAC;KACX;AACH,CAAC;AACD,MAAM,OAAO,gBAAgB;IAC3B,IAAI,GAAsB,EAAE,CAAA;IAC5B,UAAU,GAA6B,IAAI,CAAC;IAC5C,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC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AI,CAAC,CAAC;QAChC,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAA2B,CAAC;IAC7D,CAAC;IAED,IAAI;QACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED,kBAAkB;QAChB,IAAG,IAAI,CAAC,UAAU,EAAE;YAClB,OAAO,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;SAC7B;QACD,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;YAChD,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YACxB,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAoB,CAAC;QAClD,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC;QACvC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC;QACzB,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC;IACrB,CAAC;CACF"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/lib/index.d.ts b/pkg/npm/api/tmp/lib/index.d.ts new file mode 100644 index 000000000..e06143cf1 --- /dev/null +++ b/pkg/npm/api/tmp/lib/index.d.ts @@ -0,0 +1,2 @@ +export * from './lib'; +export * from './types'; diff --git a/pkg/npm/api/tmp/lib/index.js b/pkg/npm/api/tmp/lib/index.js new file mode 100644 index 000000000..872ee0de4 --- /dev/null +++ b/pkg/npm/api/tmp/lib/index.js @@ -0,0 +1,3 @@ +export * from './lib'; +export * from './types'; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/lib/index.js.map b/pkg/npm/api/tmp/lib/index.js.map new file mode 100644 index 000000000..f4062559b --- /dev/null +++ b/pkg/npm/api/tmp/lib/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/lib/lib.d.ts b/pkg/npm/api/tmp/lib/lib.d.ts new file mode 100644 index 000000000..2600d247a --- /dev/null +++ b/pkg/npm/api/tmp/lib/lib.d.ts @@ -0,0 +1,33 @@ +import { BigInteger } from "big-integer"; +import { Resource } from "../groups/types"; +import { Post, GraphNode } from "../graph/types"; +/** + * Given a bigint representing an urbit date, returns a unix timestamp. + * + * @param {BigInteger} da The urbit date + * + * @return {number} The unix timestamp + */ +export declare function daToUnix(da: BigInteger): number; +/** + * Given a unix timestamp, returns a bigint representing an urbit date + * + * @param {number} unix The unix timestamp + * + * @return {BigInteger} The urbit date + */ +export declare function unixToDa(unix: number): BigInteger; +export declare function makePatDa(patda: string): BigInteger; +export declare function udToDec(ud: string): string; +export declare function decToUd(str: string): string; +export declare function resourceAsPath(resource: Resource): string; +export declare function uuid(): string; +export declare function daToDate(st: string): Date; +export declare function dateToDa(d: Date, mil?: boolean): string; +export declare function deSig(ship: string): string | null; +export declare function cite(ship: string): string; +export declare function uxToHex(ux: string): string; +export declare const hexToUx: (hex: string) => string; +export declare function stringToTa(str: string): string; +export declare const buntPost: () => Post; +export declare function makeNodeMap(posts: Post[]): Record; diff --git a/pkg/npm/api/tmp/lib/lib.js b/pkg/npm/api/tmp/lib/lib.js new file mode 100644 index 000000000..6b52d21c0 --- /dev/null +++ b/pkg/npm/api/tmp/lib/lib.js @@ -0,0 +1,207 @@ +import bigInt from "big-integer"; +const DA_UNIX_EPOCH = bigInt("170141184475152167957503069145530368000"); // `@ud` ~1970.1.1 +const DA_SECOND = bigInt("18446744073709551616"); // `@ud` ~s1 +function chunk(arr, size) { + let chunk = []; + let newArray = [chunk]; + for (let i = 0; i < arr.length; i++) { + if (chunk.length < size) { + chunk.push(arr[i]); + } + else { + chunk = [arr[i]]; + newArray.push(chunk); + } + } + return newArray; +} +function dropWhile(arr, pred) { + const newArray = arr.slice(); + for (const item of arr) { + if (pred(item)) { + newArray.shift(); + } + else { + return newArray; + } + } + return newArray; +} +/** + * Given a bigint representing an urbit date, returns a unix timestamp. + * + * @param {BigInteger} da The urbit date + * + * @return {number} The unix timestamp + */ +export function daToUnix(da) { + // ported from +time:enjs:format in hoon.hoon + const offset = DA_SECOND.divide(bigInt(2000)); + const epochAdjusted = offset.add(da.subtract(DA_UNIX_EPOCH)); + return Math.round(epochAdjusted.multiply(bigInt(1000)).divide(DA_SECOND).toJSNumber()); +} +/** + * Given a unix timestamp, returns a bigint representing an urbit date + * + * @param {number} unix The unix timestamp + * + * @return {BigInteger} The urbit date + */ +export function unixToDa(unix) { + const timeSinceEpoch = bigInt(unix).multiply(DA_SECOND).divide(bigInt(1000)); + return DA_UNIX_EPOCH.add(timeSinceEpoch); +} +export function makePatDa(patda) { + return bigInt(udToDec(patda)); +} +export function udToDec(ud) { + return ud.replace(/\./g, ""); +} +export function decToUd(str) { + const transform = chunk(str.split('').reverse(), 3) + .map(group => group.reverse().join('')) + .reverse() + .join('.'); + return transform.replace(/^[0\.]+/g, ''); +} +export function resourceAsPath(resource) { + const { name, ship } = resource; + return `/ship/~${ship}/${name}`; +} +export function uuid() { + let str = "0v"; + str += Math.ceil(Math.random() * 8) + "."; + for (let i = 0; i < 5; i++) { + let _str = Math.ceil(Math.random() * 10000000).toString(32); + _str = ("00000" + _str).substr(-5, 5); + str += _str + "."; + } + return str.slice(0, -1); +} +/* + Goes from: + ~2018.7.17..23.15.09..5be5 // urbit @da + To: + (javascript Date object) +*/ +export function daToDate(st) { + const dub = function (n) { + return parseInt(n) < 10 ? "0" + parseInt(n) : n.toString(); + }; + const da = st.split(".."); + const bigEnd = da[0].split("."); + const lilEnd = da[1].split("."); + const ds = `${bigEnd[0].slice(1)}-${dub(bigEnd[1])}-${dub(bigEnd[2])}T${dub(lilEnd[0])}:${dub(lilEnd[1])}:${dub(lilEnd[2])}Z`; + return new Date(ds); +} +/* + Goes from: + (javascript Date object) + To: + ~2018.7.17..23.15.09..5be5 // urbit @da +*/ +export function dateToDa(d, mil = false) { + const fil = function (n) { + return n >= 10 ? n : "0" + n; + }; + return (`~${d.getUTCFullYear()}.` + + `${d.getUTCMonth() + 1}.` + + `${fil(d.getUTCDate())}..` + + `${fil(d.getUTCHours())}.` + + `${fil(d.getUTCMinutes())}.` + + `${fil(d.getUTCSeconds())}` + + `${mil ? "..0000" : ""}`); +} +export function deSig(ship) { + if (!ship) { + return null; + } + return ship.replace("~", ""); +} +// trim patps to match dojo, chat-cli +export function cite(ship) { + let patp = ship, shortened = ''; + if (patp === null || patp === '') { + return null; + } + if (patp.startsWith('~')) { + patp = patp.substr(1); + } + // comet + if (patp.length === 56) { + shortened = '~' + patp.slice(0, 6) + '_' + patp.slice(50, 56); + return shortened; + } + // moon + if (patp.length === 27) { + shortened = '~' + patp.slice(14, 20) + '^' + patp.slice(21, 27); + return shortened; + } + return `~${patp}`; +} +export function uxToHex(ux) { + if (ux.length > 2 && ux.substr(0, 2) === '0x') { + const value = ux.substr(2).replace('.', '').padStart(6, '0'); + return value; + } + const value = ux.replace('.', '').padStart(6, '0'); + return value; +} +export const hexToUx = (hex) => { + const nonZeroChars = dropWhile(hex.split(''), y => y === '0'); + const ux = chunk(nonZeroChars.reverse(), 4).map(x => { + return x.reverse().join(''); + }).reverse().join('.') || '0'; + return `0x${ux}`; +}; +// encode the string into @ta-safe format, using logic from +wood. +// for example, 'some Chars!' becomes '~.some.~43.hars~21.' +// +export function stringToTa(str) { + let out = ""; + for (let i = 0; i < str.length; i++) { + const char = str[i]; + let add = ""; + switch (char) { + case " ": + add = "."; + break; + case ".": + add = "~."; + break; + case "~": + add = "~~"; + break; + default: + const charCode = str.charCodeAt(i); + if ((charCode >= 97 && charCode <= 122) || // a-z + (charCode >= 48 && charCode <= 57) || // 0-9 + char === "-") { + add = char; + } + else { + // TODO behavior for unicode doesn't match +wood's, + // but we can probably get away with that for now. + add = "~" + charCode.toString(16) + "."; + } + } + out = out + add; + } + return "~." + out; +} +export const buntPost = () => ({ + author: '', + contents: [], + hash: null, + index: '', + signatures: [], + 'time-sent': 0 +}); +export function makeNodeMap(posts) { + const nodes = {}; + posts.forEach((p) => { + nodes[String(p.index)] = { children: null, post: p }; + }); + return nodes; +} +//# sourceMappingURL=lib.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/lib/lib.js.map b/pkg/npm/api/tmp/lib/lib.js.map new file mode 100644 index 000000000..8d263d786 --- /dev/null +++ b/pkg/npm/api/tmp/lib/lib.js.map @@ -0,0 +1 @@ +{"version":3,"file":"lib.js","sourceRoot":"","sources":["../../lib/lib.ts"],"names":[],"mappings":"AAAA,OAAO,MAAsB,MAAM,aAAa,CAAC;AAKjD,MAAM,aAAa,GAAG,MAAM,CAAC,yCAAyC,CAAC,CAAC,CAAC,kBAAkB;AAE3F,MAAM,SAAS,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,YAAY;AAE9D,SAAS,KAAK,CAAI,GAAQ,EAAE,IAAY;IACtC,IAAI,KAAK,GAAQ,EAAE,CAAC;IACpB,IAAI,QAAQ,GAAG,CAAC,KAAK,CAAC,CAAC;IAEvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAC,CAAC,GAAG,GAAG,CAAC,MAAM,EAAC,CAAC,EAAE,EAAE;QACjC,IAAI,KAAK,CAAC,MAAM,GAAG,IAAI,EAAE;YACvB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;SACnB;aAAM;YACL,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;YAChB,QAAQ,CAAC,IAAI,CAAC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AC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IACvD,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/lib/types.d.ts b/pkg/npm/api/tmp/lib/types.d.ts new file mode 100644 index 000000000..f35993cc3 --- /dev/null +++ b/pkg/npm/api/tmp/lib/types.d.ts @@ -0,0 +1,42 @@ +/** + * Martian embassy + */ +import { BigIntOrderedMap } from "./BigIntOrderedMap"; +export declare type Path = string; +export declare type Patp = string; +export declare type PatpNoSig = string; +export declare type Serial = string; +export declare type Jug = Map>; +export declare type AppName = 'chat' | 'link' | 'contacts' | 'publish' | 'graph' | 'groups'; +export declare type ShipRank = 'czar' | 'king' | 'duke' | 'earl' | 'pawn'; +export declare type Action = 'poke' | 'subscribe' | 'ack' | 'unsubscribe' | 'delete'; +export declare type SetElement = S extends Set<(infer T)> ? T : never; +export declare type MapKey = M extends Map<(infer K), any> ? K : never; +export declare type MapValue = M extends Map ? V : never; +/** + * Turns sets into arrays and maps into objects so we can send them over the wire + */ +export declare type Enc = S extends Set ? Enc>[] : S extends Map ? { + [s: string]: Enc>; +} : S extends object ? { + [K in keyof S]: Enc; +} : S extends BigIntOrderedMap ? { + [index: string]: T; +} : S; +export declare type Mark = string; +export interface Poke { + ship?: string; + app: string; + mark: Mark; + json: Action; +} +export interface Scry { + app: string; + path: string; +} +export interface Thread { + inputMark: string; + outputMark: string; + threadName: string; + body: Action; +} diff --git a/pkg/npm/api/tmp/lib/types.js b/pkg/npm/api/tmp/lib/types.js new file mode 100644 index 000000000..b5d0954fb --- /dev/null +++ b/pkg/npm/api/tmp/lib/types.js @@ -0,0 +1,5 @@ +/** + * Martian embassy + */ +export {}; +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/lib/types.js.map b/pkg/npm/api/tmp/lib/types.js.map new file mode 100644 index 000000000..212a6e318 --- /dev/null +++ b/pkg/npm/api/tmp/lib/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../../lib/types.ts"],"names":[],"mappings":"AAAA;;GAEG"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/metadata/index.d.ts b/pkg/npm/api/tmp/metadata/index.d.ts new file mode 100644 index 000000000..4a272fce5 --- /dev/null +++ b/pkg/npm/api/tmp/metadata/index.d.ts @@ -0,0 +1,2 @@ +export * from './types'; +export * from './lib'; diff --git a/pkg/npm/api/tmp/metadata/index.js b/pkg/npm/api/tmp/metadata/index.js new file mode 100644 index 000000000..5c8443c9d --- /dev/null +++ b/pkg/npm/api/tmp/metadata/index.js @@ -0,0 +1,3 @@ +export * from './types'; +export * from './lib'; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/metadata/index.js.map b/pkg/npm/api/tmp/metadata/index.js.map new file mode 100644 index 000000000..7be78af17 --- /dev/null +++ b/pkg/npm/api/tmp/metadata/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../metadata/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/metadata/lib.d.ts b/pkg/npm/api/tmp/metadata/lib.d.ts new file mode 100644 index 000000000..221a2d820 --- /dev/null +++ b/pkg/npm/api/tmp/metadata/lib.d.ts @@ -0,0 +1,15 @@ +import { Path, Poke, PatpNoSig } from '../lib'; +import { MdAppName, Association, Metadata, MetadataUpdate, MetadataUpdateAdd, MetadataUpdateRemove, MetadataEditField, MetadataUpdateEdit } from './types'; +export declare const METADATA_UPDATE_VERSION = 2; +export declare const metadataAction: (data: T, version?: number) => Poke; +export declare const add: (ship: PatpNoSig, appName: MdAppName, resource: Path, group: Path, title: string, description: string, dateCreated: string, color: string, moduleName: string) => Poke; +export { add as metadataAdd }; +export declare const remove: (appName: MdAppName, resource: string, group: string) => Poke; +export { remove as metadataRemove }; +export declare const edit: (association: Association, edit: MetadataEditField) => Poke; +export { edit as metadataEdit }; +/** + * @deprecated use {@link edit} instead + */ +export declare const update: (association: Association, newMetadata: Partial) => Poke; +export { update as metadataUpdate }; diff --git a/pkg/npm/api/tmp/metadata/lib.js b/pkg/npm/api/tmp/metadata/lib.js new file mode 100644 index 000000000..c6fed6976 --- /dev/null +++ b/pkg/npm/api/tmp/metadata/lib.js @@ -0,0 +1,69 @@ +import { uxToHex } from '../lib'; +export const METADATA_UPDATE_VERSION = 2; +export const metadataAction = (data, version = METADATA_UPDATE_VERSION) => ({ + app: 'metadata-push-hook', + mark: `metadata-update-${version}`, + json: data +}); +export const add = (ship, appName, resource, group, title, description, dateCreated, color, moduleName) => metadataAction({ + add: { + group, + resource: { + resource, + 'app-name': appName + }, + metadata: { + title, + description, + color, + 'date-created': dateCreated, + creator: `~${ship}`, + config: { graph: moduleName }, + picture: '', + hidden: false, + preview: false, + vip: '' + } + } +}); +export { add as metadataAdd }; +export const remove = (appName, resource, group) => metadataAction({ + remove: { + group, + resource: { + resource, + 'app-name': appName + } + } +}); +export { remove as metadataRemove }; +export const edit = (association, edit) => metadataAction({ + edit: { + group: association.group, + resource: { + resource: association.resource, + 'app-name': association['app-name'] + }, + edit + } +}); +export { edit as metadataEdit }; +/** + * @deprecated use {@link edit} instead + */ +export const update = (association, newMetadata) => { + const metadata = { ...association.metadata, ...newMetadata }; + metadata.color = uxToHex(metadata.color); + return metadataAction({ + add: { + group: association.group, + resource: { + resource: association.resource, + 'app-name': association['app-name'] + }, + metadata + } + }); +}; +export { update as metadataUpdate }; +//# sourceMappingURL=lib.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/metadata/lib.js.map b/pkg/npm/api/tmp/metadata/lib.js.map new file mode 100644 index 000000000..933172f52 --- /dev/null +++ b/pkg/npm/api/tmp/metadata/lib.js.map @@ -0,0 +1 @@ +{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AC,MAAM,IAAI,GAAG,CAClB,WAAwB,EACxB,IAAuB,EACG,EAAE,CAAC,cAAc,CAAqB;IAChE,IAAI,EAAE;QACJ,KAAK,EAAE,WAAW,CAAC,KAAK;QACxB,QAAQ,EAAE;YACR,QAAQ,EAAE,WAAW,CAAC,QAAQ;YAC9B,UAAU,EAAE,WAAW,CAAC,UAAU,CAAC;SACpC;QACD,IAAI;KACL;CACF,CAAC,CAAC;AAEH,OAAO,EAAE,IAAI,IAAI,YAAY,EAAE,CAAC;AAEhC;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CACpB,WAAwB,EACxB,WAA8B,EACL,EAAE;IAC3B,MAAM,QAAQ,GAAG,EAAE,GAAG,WAAW,CAAC,QAAQ,EAAE,GAAG,WAAW,EAAE,CAAC;IAC3D,QAAQ,CAAC,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACzC,OAAO,cAAc,CAAoB;QACvC,GAAG,EAAE;YACH,KAAK,EAAE,WAAW,CAAC,KAAK;YACxB,QAAQ,EAAE;gBACR,QAAQ,EAAE,WAAW,CAAC,QAAQ;gBAC9B,UAAU,EAAE,WAAW,CAAC,UAAU,CAAC;aACpC;YACD,QAAQ;SACT;KACF,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,CAAC"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/metadata/types.d.ts b/pkg/npm/api/tmp/metadata/types.d.ts new file mode 100644 index 000000000..7459689b8 --- /dev/null +++ b/pkg/npm/api/tmp/metadata/types.d.ts @@ -0,0 +1,76 @@ +import { Path, Patp } from '../lib'; +export declare type MdAppName = 'groups' | 'graph'; +export declare type MetadataUpdate = MetadataUpdateInitial | MetadataUpdateAdd | MetadataUpdateUpdate | MetadataUpdateRemove | MetadataUpdateEdit; +export interface MetadataUpdateInitial { + associations: ResourceAssociations; +} +export declare type ResourceAssociations = { + [p in Path]: Association; +}; +export declare type MetadataUpdateAdd = { + add: AssociationPoke; +}; +export declare type MetadataUpdateUpdate = { + update: AssociationPoke; +}; +export interface MetadataUpdateEdit { + edit: { + resource: MdResource; + group: string; + edit: MetadataEditField; + }; +} +export declare type MetadataEditField = Partial>; +export declare type MetadataUpdateRemove = { + remove: { + resource: MdResource; + group: string; + }; +}; +export interface MdResource { + resource: string; + 'app-name': MdAppName; +} +export interface MetadataUpdatePreview { + group: string; + channels: Associations; + 'channel-count': number; + members: number; + metadata: Metadata; +} +export declare type Associations = { + groups: AppAssociations; + graph: AppAssociations; +}; +export declare type AppAssociations = { + [p in Path]: Association; +}; +export declare type Association = MdResource & { + group: Path; + metadata: Metadata; +}; +export interface AssociationPoke { + group: Path; + resource: MdResource; + metadata: Metadata; +} +export interface Metadata { + color: string; + creator: Patp; + 'date-created': string; + description: string; + title: string; + config: C; + hidden: boolean; + picture: string; + preview: boolean; + vip: PermVariation; +} +export declare type MetadataConfig = GroupConfig | GraphConfig; +export interface GraphConfig { + graph: string; +} +export interface GroupConfig { + group: undefined | {} | MdResource; +} +export declare type PermVariation = '' | ' ' | 'reader-comments' | 'member-metadata' | 'host-feed' | 'admin-feed'; diff --git a/pkg/npm/api/tmp/metadata/types.js b/pkg/npm/api/tmp/metadata/types.js new file mode 100644 index 000000000..718fd38ae --- /dev/null +++ b/pkg/npm/api/tmp/metadata/types.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/metadata/types.js.map b/pkg/npm/api/tmp/metadata/types.js.map new file mode 100644 index 000000000..8a55fbd72 --- /dev/null +++ b/pkg/npm/api/tmp/metadata/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../../metadata/types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/pkg/npm/api/tmp/s3/index.d.ts b/pkg/npm/api/tmp/s3/index.d.ts new file mode 100644 index 000000000..e06143cf1 --- /dev/null +++ b/pkg/npm/api/tmp/s3/index.d.ts @@ -0,0 +1,2 @@ +export * from './lib'; +export * from './types'; diff --git a/pkg/npm/api/tmp/s3/index.js b/pkg/npm/api/tmp/s3/index.js new file mode 100644 index 000000000..872ee0de4 --- /dev/null +++ b/pkg/npm/api/tmp/s3/index.js @@ -0,0 +1,3 @@ +export * from './lib'; +export * from './types'; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/s3/index.js.map b/pkg/npm/api/tmp/s3/index.js.map new file mode 100644 index 000000000..c694f0ff7 --- /dev/null +++ b/pkg/npm/api/tmp/s3/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../s3/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/s3/lib.d.ts b/pkg/npm/api/tmp/s3/lib.d.ts new file mode 100644 index 000000000..edbfa465b --- /dev/null +++ b/pkg/npm/api/tmp/s3/lib.d.ts @@ -0,0 +1,8 @@ +import { Poke } from '../lib/types'; +import { S3UpdateAccessKeyId, S3UpdateAddBucket, S3UpdateCurrentBucket, S3UpdateEndpoint, S3UpdateRemoveBucket, S3UpdateSecretAccessKey } from './types'; +export declare const setCurrentBucket: (bucket: string) => Poke; +export declare const addBucket: (bucket: string) => Poke; +export declare const removeBucket: (bucket: string) => Poke; +export declare const setEndpoint: (endpoint: string) => Poke; +export declare const setAccessKeyId: (accessKeyId: string) => Poke; +export declare const setSecretAccessKey: (secretAccessKey: string) => Poke; diff --git a/pkg/npm/api/tmp/s3/lib.js b/pkg/npm/api/tmp/s3/lib.js new file mode 100644 index 000000000..4f363769d --- /dev/null +++ b/pkg/npm/api/tmp/s3/lib.js @@ -0,0 +1,24 @@ +const s3Action = (data) => ({ + app: 's3-store', + mark: 's3-action', + json: data +}); +export const setCurrentBucket = (bucket) => s3Action({ + 'set-current-bucket': bucket +}); +export const addBucket = (bucket) => s3Action({ + 'add-bucket': bucket +}); +export const removeBucket = (bucket) => s3Action({ + 'remove-bucket': bucket +}); +export const setEndpoint = (endpoint) => s3Action({ + 'set-endpoint': endpoint +}); +export const setAccessKeyId = (accessKeyId) => s3Action({ + 'set-access-key-id': accessKeyId +}); +export const setSecretAccessKey = (secretAccessKey) => s3Action({ + 'set-secret-access-key': secretAccessKey +}); +//# sourceMappingURL=lib.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/s3/lib.js.map b/pkg/npm/api/tmp/s3/lib.js.map new file mode 100644 index 000000000..769f49c50 --- /dev/null +++ b/pkg/npm/api/tmp/s3/lib.js.map @@ -0,0 +1 @@ +{"version":3,"file":"lib.js","sourceRoot":"","sources":["../../s3/lib.ts"],"names":[],"mappings":"AAGA,MAAM,QAAQ,GAAG,CACf,IAAS,EACA,EAAE,CAAC,CAAC;IACb,GAAG,EAAE,UAAU;IACf,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,IAAI;CACX,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,MAAc,EACe,EAAE,CAAC,QAAQ,CAAC;IACzC,oBAAoB,EAAE,MAAM;CAC7B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,MAAc,EACW,EAAE,CAAC,QAAQ,CAAC;IACrC,YAAY,EAAE,MAAM;CACrB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,MAAc,EACc,EAAE,CAAC,QAAQ,CAAC;IACxC,eAAe,EAAE,MAAM;CACxB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,QAAgB,EACQ,EAAE,CAAC,QAAQ,CAAC;IACpC,cAAc,EAAE,QAAQ;CACzB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,WAAmB,EACQ,EAAE,CAAC,QAAQ,CAAC;IACvC,mBAAmB,EAAE,WAAW;CACjC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,eAAuB,EACQ,EAAE,CAAC,QAAQ,CAAC;IAC3C,uBAAuB,EAAE,eAAe;CACzC,CAAC,CAAC"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/s3/types.d.ts b/pkg/npm/api/tmp/s3/types.d.ts new file mode 100644 index 000000000..924749718 --- /dev/null +++ b/pkg/npm/api/tmp/s3/types.d.ts @@ -0,0 +1,41 @@ +export interface S3Credentials { + endpoint: string; + accessKeyId: string; + secretAccessKey: string; +} +export interface S3Configuration { + buckets: Set; + currentBucket: string; +} +export interface S3State { + configuration: S3Configuration; + credentials: S3Credentials | null; +} +export interface S3UpdateCredentials { + credentials: S3Credentials; +} +export interface S3UpdateConfiguration { + configuration: { + buckets: string[]; + currentBucket: string; + }; +} +export interface S3UpdateCurrentBucket { + setCurrentBucket: string; +} +export interface S3UpdateAddBucket { + addBucket: string; +} +export interface S3UpdateRemoveBucket { + removeBucket: string; +} +export interface S3UpdateEndpoint { + setEndpoint: string; +} +export interface S3UpdateAccessKeyId { + setAccessKeyId: string; +} +export interface S3UpdateSecretAccessKey { + setSecretAccessKey: string; +} +export declare type S3Update = S3UpdateCredentials | S3UpdateConfiguration | S3UpdateCurrentBucket | S3UpdateAddBucket | S3UpdateRemoveBucket | S3UpdateEndpoint | S3UpdateAccessKeyId | S3UpdateSecretAccessKey; diff --git a/pkg/npm/api/tmp/s3/types.js b/pkg/npm/api/tmp/s3/types.js new file mode 100644 index 000000000..718fd38ae --- /dev/null +++ b/pkg/npm/api/tmp/s3/types.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/s3/types.js.map b/pkg/npm/api/tmp/s3/types.js.map new file mode 100644 index 000000000..651890e84 --- /dev/null +++ b/pkg/npm/api/tmp/s3/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../../s3/types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/pkg/npm/api/tmp/settings/index.d.ts b/pkg/npm/api/tmp/settings/index.d.ts new file mode 100644 index 000000000..4a272fce5 --- /dev/null +++ b/pkg/npm/api/tmp/settings/index.d.ts @@ -0,0 +1,2 @@ +export * from './types'; +export * from './lib'; diff --git a/pkg/npm/api/tmp/settings/index.js b/pkg/npm/api/tmp/settings/index.js new file mode 100644 index 000000000..5c8443c9d --- /dev/null +++ b/pkg/npm/api/tmp/settings/index.js @@ -0,0 +1,3 @@ +export * from './types'; +export * from './lib'; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/settings/index.js.map b/pkg/npm/api/tmp/settings/index.js.map new file mode 100644 index 000000000..06b65a2d7 --- /dev/null +++ b/pkg/npm/api/tmp/settings/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../settings/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/settings/lib.d.ts b/pkg/npm/api/tmp/settings/lib.d.ts new file mode 100644 index 000000000..8e2da9a75 --- /dev/null +++ b/pkg/npm/api/tmp/settings/lib.d.ts @@ -0,0 +1,21 @@ +import { Poke, Scry } from '../lib'; +import { PutBucket, Key, Bucket, DelBucket, Value, PutEntry, DelEntry, SettingsUpdate } from './types'; +export declare const action: (data: T) => Poke; +export declare const putBucket: (desk: string, key: Key, bucket: Bucket) => Poke; +export declare const delBucket: (desk: string, key: Key) => Poke; +export declare const putEntry: (desk: string, bucket: Key, key: Key, value: Value) => Poke; +export declare const delEntry: (desk: string, bucket: Key, key: Key) => Poke; +export declare const getAll: Scry; +export declare const getBucket: (desk: string, bucket: string) => { + app: string; + path: string; +}; +export declare const getEntry: (desk: string, bucket: string, entry: string) => { + app: string; + path: string; +}; +export declare const getDeskSettings: (desk: string) => { + app: string; + path: string; +}; +export * from './types'; diff --git a/pkg/npm/api/tmp/settings/lib.js b/pkg/npm/api/tmp/settings/lib.js new file mode 100644 index 000000000..c863ef963 --- /dev/null +++ b/pkg/npm/api/tmp/settings/lib.js @@ -0,0 +1,51 @@ +export const action = (data) => ({ + app: 'settings-store', + mark: 'settings-event', + json: data +}); +export const putBucket = (desk, key, bucket) => action({ + 'put-bucket': { + desk, + 'bucket-key': key, + 'bucket': bucket + } +}); +export const delBucket = (desk, key) => action({ + 'del-bucket': { + desk, + 'bucket-key': key + } +}); +export const putEntry = (desk, bucket, key, value) => action({ + 'put-entry': { + desk, + 'bucket-key': bucket, + 'entry-key': key, + value: value + } +}); +export const delEntry = (desk, bucket, key) => action({ + 'del-entry': { + desk, + 'bucket-key': bucket, + 'entry-key': key + } +}); +export const getAll = { + app: 'settings-store', + path: '/all' +}; +export const getBucket = (desk, bucket) => ({ + app: 'settings-store', + path: `/bucket/${bucket}` +}); +export const getEntry = (desk, bucket, entry) => ({ + app: 'settings-store', + path: `/entry/${desk}/${bucket}/${entry}` +}); +export const getDeskSettings = (desk) => ({ + app: 'settings-store', + path: `/desk/${desk}` +}); +export * from './types'; +//# sourceMappingURL=lib.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/settings/lib.js.map b/pkg/npm/api/tmp/settings/lib.js.map new file mode 100644 index 000000000..7c6f13886 --- /dev/null +++ b/pkg/npm/api/tmp/settings/lib.js.map @@ -0,0 +1 @@ +{"version":3,"file":"lib.js","sourceRoot":"","sources":["../../settings/lib.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,MAAM,GAAG,CAA2B,IAAO,EAAW,EAAE,CAAC,CAAC;IACrE,GAAG,EAAE,gBAAgB;IACrB,IAAI,EAAE,gBAAgB;IACtB,IAAI,EAAE,IAAI;CACX,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,IAAY,EACZ,GAAQ,EACR,MAAc,EACG,EAAE,CAAC,MAAM,CAAC;IAC3B,YAAY,EAAE;QACZ,IAAI;QACJ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AAE,gBAAgB;IACrB,IAAI,EAAE,SAAS,IAAI,EAAE;CACtB,CAAC,CAAC;AAEH,cAAc,SAAS,CAAC"} \ No newline at end of file diff --git a/pkg/npm/api/tmp/settings/types.d.ts b/pkg/npm/api/tmp/settings/types.d.ts new file mode 100644 index 000000000..9e58650d1 --- /dev/null +++ b/pkg/npm/api/tmp/settings/types.d.ts @@ -0,0 +1,52 @@ +export declare type Key = string; +export declare type Value = string | string[] | boolean | number; +export declare type Bucket = { + [key: string]: Value; +}; +export declare type DeskSettings = { + [bucket: string]: Bucket; +}; +export declare type Settings = { + [desk: string]: Settings; +}; +export interface PutBucket { + 'put-bucket': { + desk: string; + 'bucket-key': Key; + 'bucket': Bucket; + }; +} +export interface DelBucket { + 'del-bucket': { + desk: string; + 'bucket-key': Key; + }; +} +export interface PutEntry { + 'put-entry': { + 'bucket-key': Key; + 'entry-key': Key; + 'value'?: Value; + }; +} +export interface DelEntry { + 'del-entry': { + desk: string; + 'bucket-key': Key; + 'entry-key': Key; + }; +} +export interface AllData { + 'all': Settings; +} +export interface DeskData { + desk: DeskSettings; +} +export interface BucketData { + 'bucket': Bucket; +} +export interface EntryData { + 'entry': Value; +} +export declare type SettingsUpdate = PutBucket | DelBucket | PutEntry | DelEntry; +export declare type SettingsData = AllData | BucketData | EntryData | DeskData; diff --git a/pkg/npm/api/tmp/settings/types.js b/pkg/npm/api/tmp/settings/types.js new file mode 100644 index 000000000..718fd38ae --- /dev/null +++ b/pkg/npm/api/tmp/settings/types.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/pkg/npm/api/tmp/settings/types.js.map b/pkg/npm/api/tmp/settings/types.js.map new file mode 100644 index 000000000..e768750c4 --- /dev/null +++ b/pkg/npm/api/tmp/settings/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../../settings/types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/pkg/npm/http-api/tmp/Urbit.d.ts b/pkg/npm/http-api/tmp/Urbit.d.ts new file mode 100644 index 000000000..9b4570b1c --- /dev/null +++ b/pkg/npm/http-api/tmp/Urbit.d.ts @@ -0,0 +1,183 @@ +import { Scry, Thread, AuthenticationInterface, PokeInterface, SubscriptionRequestInterface } from './types'; +/** + * A class for interacting with an urbit ship, given its URL and code + */ +export declare class Urbit { + url: string; + code?: string; + desk?: string; + /** + * UID will be used for the channel: The current unix time plus a random hex string + */ + private uid; + /** + * Last Event ID is an auto-updated index of which events have been sent over this channel + */ + private lastEventId; + private lastAcknowledgedEventId; + /** + * SSE Client is null for now; we don't want to start polling until it the channel exists + */ + private sseClientInitialized; + /** + * Cookie gets set when we log in. + */ + cookie?: string | undefined; + /** + * A registry of requestId to successFunc/failureFunc + * + * These functions are registered during a +poke and are executed + * in the onServerEvent()/onServerError() callbacks. Only one of + * the functions will be called, and the outstanding poke will be + * removed after calling the success or failure function. + */ + private outstandingPokes; + /** + * A registry of requestId to subscription functions. + * + * These functions are registered during a +subscribe and are + * executed in the onServerEvent()/onServerError() callbacks. The + * event function will be called whenever a new piece of data on this + * subscription is available, which may be 0, 1, or many times. The + * disconnect function may be called exactly once. + */ + private outstandingSubscriptions; + /** + * Our abort controller, used to close the connection + */ + private abort; + /** + * Ship can be set, in which case we can do some magic stuff like send chats + */ + ship?: string | null; + /** + * If verbose, logs output eagerly. + */ + verbose?: boolean; + /** + * number of consecutive errors in connecting to the eventsource + */ + private errorCount; + onError?: (error: any) => void; + onRetry?: () => void; + onOpen?: () => void; + /** This is basic interpolation to get the channel URL of an instantiated Urbit connection. */ + private get channelUrl(); + private get fetchOptions(); + /** + * Constructs a new Urbit connection. + * + * @param url The URL (with protocol and port) of the ship to be accessed. If + * the airlock is running in a webpage served by the ship, this should just + * be the empty string. + * @param code The access code for the ship at that address + */ + constructor(url: string, code?: string, desk?: string); + /** + * All-in-one hook-me-up. + * + * Given a ship, url, and code, this returns an airlock connection + * that is ready to go. It `|hi`s itself to create the channel, + * then opens the channel via EventSource. + * + */ + static authenticate({ ship, url, code, verbose, }: AuthenticationInterface): Promise; + /** + * Connects to the Urbit ship. Nothing can be done until this is called. + * That's why we roll it into this.authenticate + */ + connect(): Promise; + /** + * Initializes the SSE pipe for the appropriate channel. + */ + eventSource(): Promise; + /** + * Reset airlock, abandoning current subscriptions and wiping state + * + */ + reset(): void; + /** + * Autoincrements the next event ID for the appropriate channel. + */ + private getEventId; + /** + * Acknowledges an event. + * + * @param eventId The event to acknowledge. + */ + private ack; + private sendJSONtoChannel; + /** + * Creates a subscription, waits for a fact and then unsubscribes + * + * @param app Name of gall agent to subscribe to + * @param path Path to subscribe to + * @param timeout Optional timeout before ending subscription + * + * @returns The first fact on the subcription + */ + subscribeOnce(app: string, path: string, timeout?: number): Promise; + /** + * Pokes a ship with data. + * + * @param app The app to poke + * @param mark The mark of the data being sent + * @param json The data to send + */ + poke(params: PokeInterface): Promise; + /** + * Subscribes to a path on an app on a ship. + * + * + * @param app The app to subsribe to + * @param path The path to which to subscribe + * @param handlers Handlers to deal with various events of the subscription + */ + subscribe(params: SubscriptionRequestInterface): Promise; + /** + * Unsubscribes to a given subscription. + * + * @param subscription + */ + unsubscribe(subscription: number): Promise; + /** + * Deletes the connection to a channel. + */ + delete(): void; + /** + * Scry into an gall agent at a path + * + * @typeParam T - Type of the scry result + * + * @remarks + * + * Equivalent to + * ```hoon + * .^(T %gx /(scot %p our)/[app]/(scot %da now)/[path]/json) + * ``` + * The returned cage must have a conversion to JSON for the scry to succeed + * + * @param params The scry request + * @returns The scry result + */ + scry(params: Scry): Promise; + /** + * Run a thread + * + * + * @param inputMark The mark of the data being sent + * @param outputMark The mark of the data being returned + * @param threadName The thread to run + * @param body The data to send to the thread + * @returns The return value of the thread + */ + thread(params: Thread): Promise; + /** + * Utility function to connect to a ship that has its *.arvo.network domain configured. + * + * @param name Name of the ship e.g. zod + * @param code Code to log in + */ + static onArvoNetwork(ship: string, code: string): Promise; +} +export default Urbit; diff --git a/pkg/npm/http-api/tmp/Urbit.js b/pkg/npm/http-api/tmp/Urbit.js new file mode 100644 index 000000000..4f38123cc --- /dev/null +++ b/pkg/npm/http-api/tmp/Urbit.js @@ -0,0 +1,497 @@ +import { isBrowser, isNode } from 'browser-or-node'; +import { fetchEventSource, } from '@microsoft/fetch-event-source'; +import { hexString } from './utils'; +/** + * A class for interacting with an urbit ship, given its URL and code + */ +export class Urbit { + /** + * Constructs a new Urbit connection. + * + * @param url The URL (with protocol and port) of the ship to be accessed. If + * the airlock is running in a webpage served by the ship, this should just + * be the empty string. + * @param code The access code for the ship at that address + */ + constructor(url, code, desk) { + this.url = url; + this.code = code; + this.desk = desk; + /** + * UID will be used for the channel: The current unix time plus a random hex string + */ + this.uid = `${Math.floor(Date.now() / 1000)}-${hexString(6)}`; + /** + * Last Event ID is an auto-updated index of which events have been sent over this channel + */ + this.lastEventId = 0; + this.lastAcknowledgedEventId = 0; + /** + * SSE Client is null for now; we don't want to start polling until it the channel exists + */ + this.sseClientInitialized = false; + /** + * A registry of requestId to successFunc/failureFunc + * + * These functions are registered during a +poke and are executed + * in the onServerEvent()/onServerError() callbacks. Only one of + * the functions will be called, and the outstanding poke will be + * removed after calling the success or failure function. + */ + this.outstandingPokes = new Map(); + /** + * A registry of requestId to subscription functions. + * + * These functions are registered during a +subscribe and are + * executed in the onServerEvent()/onServerError() callbacks. The + * event function will be called whenever a new piece of data on this + * subscription is available, which may be 0, 1, or many times. The + * disconnect function may be called exactly once. + */ + this.outstandingSubscriptions = new Map(); + /** + * Our abort controller, used to close the connection + */ + this.abort = new AbortController(); + /** + * number of consecutive errors in connecting to the eventsource + */ + this.errorCount = 0; + this.onError = null; + this.onRetry = null; + this.onOpen = null; + if (isBrowser) { + window.addEventListener('beforeunload', this.delete); + } + return this; + } + /** This is basic interpolation to get the channel URL of an instantiated Urbit connection. */ + get channelUrl() { + return `${this.url}/~/channel/${this.uid}`; + } + get fetchOptions() { + const headers = { + 'Content-Type': 'application/json', + }; + if (!isBrowser) { + headers.Cookie = this.cookie; + } + return { + credentials: 'include', + accept: '*', + headers, + signal: this.abort.signal, + }; + } + /** + * All-in-one hook-me-up. + * + * Given a ship, url, and code, this returns an airlock connection + * that is ready to go. It `|hi`s itself to create the channel, + * then opens the channel via EventSource. + * + */ + static async authenticate({ ship, url, code, verbose = false, }) { + const airlock = new Urbit(`http://${url}`, code); + airlock.verbose = verbose; + airlock.ship = ship; + await airlock.connect(); + await airlock.poke({ + app: 'hood', + mark: 'helm-hi', + json: 'opening airlock', + }); + await airlock.eventSource(); + return airlock; + } + /** + * Connects to the Urbit ship. Nothing can be done until this is called. + * That's why we roll it into this.authenticate + */ + async connect() { + if (this.verbose) { + console.log(`password=${this.code} `, isBrowser + ? 'Connecting in browser context at ' + `${this.url}/~/login` + : 'Connecting from node context'); + } + return fetch(`${this.url}/~/login`, { + method: 'post', + body: `password=${this.code}`, + credentials: 'include', + }).then((response) => { + if (this.verbose) { + console.log('Received authentication response', response); + } + const cookie = response.headers.get('set-cookie'); + if (!this.ship) { + this.ship = new RegExp(/urbauth-~([\w-]+)/).exec(cookie)[1]; + } + if (!isBrowser) { + this.cookie = cookie; + } + }); + } + /** + * Initializes the SSE pipe for the appropriate channel. + */ + async eventSource() { + if (this.sseClientInitialized) { + return Promise.resolve(); + } + if (this.lastEventId === 0) { + // Can't receive events until the channel is open, + // so poke and open then + await this.poke({ + app: 'hood', + mark: 'helm-hi', + json: 'Opening API channel', + }); + return; + } + this.sseClientInitialized = true; + return new Promise((resolve, reject) => { + const sseOptions = { + headers: {}, + }; + if (isBrowser) { + sseOptions.withCredentials = true; + } + else if (isNode) { + sseOptions.headers.Cookie = this.cookie; + } + fetchEventSource(this.channelUrl, { + ...this.fetchOptions, + openWhenHidden: true, + onopen: async (response) => { + if (this.verbose) { + console.log('Opened eventsource', response); + } + if (response.ok) { + this.errorCount = 0; + this.onOpen && this.onOpen(); + resolve(); + return; // everything's good + } + else { + const err = new Error('failed to open eventsource'); + reject(err); + } + }, + onmessage: (event) => { + if (this.verbose) { + console.log('Received SSE: ', event); + } + if (!event.id) + return; + this.lastEventId = parseInt(event.id, 10); + if (this.lastEventId - this.lastAcknowledgedEventId > 20) { + this.ack(this.lastEventId); + } + if (event.data && JSON.parse(event.data)) { + const data = JSON.parse(event.data); + if (data.response === 'poke' && + this.outstandingPokes.has(data.id)) { + const funcs = this.outstandingPokes.get(data.id); + if (data.hasOwnProperty('ok')) { + funcs.onSuccess(); + } + else if (data.hasOwnProperty('err')) { + console.error(data.err); + funcs.onError(data.err); + } + else { + console.error('Invalid poke response', data); + } + this.outstandingPokes.delete(data.id); + } + else if (data.response === 'subscribe' && + this.outstandingSubscriptions.has(data.id)) { + const funcs = this.outstandingSubscriptions.get(data.id); + if (data.hasOwnProperty('err')) { + console.error(data.err); + funcs.err(data.err, data.id); + this.outstandingSubscriptions.delete(data.id); + } + } + else if (data.response === 'diff' && + this.outstandingSubscriptions.has(data.id)) { + const funcs = this.outstandingSubscriptions.get(data.id); + try { + funcs.event(data.json); + } + catch (e) { + console.error('Failed to call subscription event callback', e); + } + } + else if (data.response === 'quit' && + this.outstandingSubscriptions.has(data.id)) { + const funcs = this.outstandingSubscriptions.get(data.id); + funcs.quit(data); + this.outstandingSubscriptions.delete(data.id); + } + else { + console.log([...this.outstandingSubscriptions.keys()]); + console.log('Unrecognized response', data); + } + } + }, + onerror: (error) => { + console.warn(error); + if (this.errorCount++ < 4) { + this.onRetry && this.onRetry(); + return Math.pow(2, this.errorCount - 1) * 750; + } + this.onError && this.onError(error); + throw error; + }, + onclose: () => { + console.log('e'); + throw new Error('Ship unexpectedly closed the connection'); + }, + }); + }); + } + /** + * Reset airlock, abandoning current subscriptions and wiping state + * + */ + reset() { + this.delete(); + this.abort.abort(); + this.abort = new AbortController(); + this.uid = `${Math.floor(Date.now() / 1000)}-${hexString(6)}`; + this.lastEventId = 0; + this.lastAcknowledgedEventId = 0; + this.outstandingSubscriptions = new Map(); + this.outstandingPokes = new Map(); + this.sseClientInitialized = false; + } + /** + * Autoincrements the next event ID for the appropriate channel. + */ + getEventId() { + this.lastEventId = Number(this.lastEventId) + 1; + return this.lastEventId; + } + /** + * Acknowledges an event. + * + * @param eventId The event to acknowledge. + */ + async ack(eventId) { + this.lastAcknowledgedEventId = eventId; + const message = { + action: 'ack', + 'event-id': eventId, + }; + await this.sendJSONtoChannel(message); + return eventId; + } + async sendJSONtoChannel(...json) { + const response = await fetch(this.channelUrl, { + ...this.fetchOptions, + method: 'PUT', + body: JSON.stringify(json), + }); + if (!response.ok) { + throw new Error('Failed to PUT channel'); + } + if (!this.sseClientInitialized) { + await this.eventSource(); + } + } + /** + * Creates a subscription, waits for a fact and then unsubscribes + * + * @param app Name of gall agent to subscribe to + * @param path Path to subscribe to + * @param timeout Optional timeout before ending subscription + * + * @returns The first fact on the subcription + */ + async subscribeOnce(app, path, timeout) { + return new Promise(async (resolve, reject) => { + let done = false; + let id = null; + const quit = () => { + if (!done) { + reject('quit'); + } + }; + const event = (e) => { + if (!done) { + resolve(e); + this.unsubscribe(id); + } + }; + const request = { app, path, event, err: reject, quit }; + id = await this.subscribe(request); + if (timeout) { + setTimeout(() => { + if (!done) { + done = true; + reject('timeout'); + this.unsubscribe(id); + } + }, timeout); + } + }); + } + /** + * Pokes a ship with data. + * + * @param app The app to poke + * @param mark The mark of the data being sent + * @param json The data to send + */ + async poke(params) { + const { app, mark, json, ship, onSuccess, onError } = { + onSuccess: () => { }, + onError: () => { }, + ship: this.ship, + ...params, + }; + const message = { + id: this.getEventId(), + action: 'poke', + ship, + app, + mark, + json, + }; + const [send, result] = await Promise.all([ + this.sendJSONtoChannel(message), + new Promise((resolve, reject) => { + this.outstandingPokes.set(message.id, { + onSuccess: () => { + onSuccess(); + resolve(message.id); + }, + onError: (event) => { + onError(event); + reject(event.err); + }, + }); + }), + ]); + return result; + } + /** + * Subscribes to a path on an app on a ship. + * + * + * @param app The app to subsribe to + * @param path The path to which to subscribe + * @param handlers Handlers to deal with various events of the subscription + */ + async subscribe(params) { + const { app, path, ship, err, event, quit } = { + err: () => { }, + event: () => { }, + quit: () => { }, + ship: this.ship, + ...params, + }; + const message = { + id: this.getEventId(), + action: 'subscribe', + ship, + app, + path, + }; + this.outstandingSubscriptions.set(message.id, { + app, + path, + err, + event, + quit, + }); + await this.sendJSONtoChannel(message); + return message.id; + } + /** + * Unsubscribes to a given subscription. + * + * @param subscription + */ + async unsubscribe(subscription) { + return this.sendJSONtoChannel({ + id: this.getEventId(), + action: 'unsubscribe', + subscription, + }).then(() => { + this.outstandingSubscriptions.delete(subscription); + }); + } + /** + * Deletes the connection to a channel. + */ + delete() { + if (isBrowser) { + navigator.sendBeacon(this.channelUrl, JSON.stringify([ + { + action: 'delete', + }, + ])); + } + else { + // TODO + // this.sendMessage('delete'); + } + } + /** + * Scry into an gall agent at a path + * + * @typeParam T - Type of the scry result + * + * @remarks + * + * Equivalent to + * ```hoon + * .^(T %gx /(scot %p our)/[app]/(scot %da now)/[path]/json) + * ``` + * The returned cage must have a conversion to JSON for the scry to succeed + * + * @param params The scry request + * @returns The scry result + */ + async scry(params) { + const { app, path } = params; + const response = await fetch(`${this.url}/~/scry/${app}${path}.json`, this.fetchOptions); + return await response.json(); + } + /** + * Run a thread + * + * + * @param inputMark The mark of the data being sent + * @param outputMark The mark of the data being returned + * @param threadName The thread to run + * @param body The data to send to the thread + * @returns The return value of the thread + */ + async thread(params) { + const { inputMark, outputMark, threadName, body, desk = this.desk, } = params; + if (!desk) { + throw new Error('Must supply desk to run thread from'); + } + const res = await fetch(`${this.url}/spider/${desk}/${inputMark}/${threadName}/${outputMark}.json`, { + ...this.fetchOptions, + method: 'POST', + body: JSON.stringify(body), + }); + return res.json(); + } + /** + * Utility function to connect to a ship that has its *.arvo.network domain configured. + * + * @param name Name of the ship e.g. zod + * @param code Code to log in + */ + static async onArvoNetwork(ship, code) { + const url = `https://${ship}.arvo.network`; + return await Urbit.authenticate({ ship, url, code }); + } +} +export default Urbit; +//# sourceMappingURL=Urbit.js.map \ No newline at end of file diff --git a/pkg/npm/http-api/tmp/Urbit.js.map b/pkg/npm/http-api/tmp/Urbit.js.map new file mode 100644 index 000000000..2ef2ed00d --- /dev/null +++ b/pkg/npm/http-api/tmp/Urbit.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Urbit.js","sourceRoot":"","sources":["../src/Urbit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EACL,gBAAgB,GAEjB,MAAM,+BAA+B,CAAC;AAavC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC;;GAEG;AACH,MAAM,OAAO,KAAK;IA4FhB;;;;;;;OAOG;IACH,YAAmB,GAAW,EAAS,IAAa,EAAS,IAAa;QAAvD,QAAG,GAAH,GAAG,CAAQ;QAAS,SAAI,GAAJ,IAAI,CAAS;QAAS,SAAI,GAAJ,IAAI,CAAS;QAnG1E;;WAEG;QACK,QAAG,GAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;QAEzE;;WAEG;QACK,gBAAW,GAAW,CAAC,CAAC;QAExB,4BAAuB,GAAW,CAAC,CAAC;QAE5C;;WAEG;QACK,yBAAoB,GAAY,KAAK,CAAC;QAO9C;;;;;;;WAOG;QAEK,qBAAgB,GAA8B,IAAI,GAAG,EAAE,CAAC;QAEhE;;;;;;;;WAQG;QACK,6BAAwB,GAC9B,IAAI,GAAG,EAAE,CAAC;QAEZ;;WAEG;QACK,UAAK,GAAG,IAAI,eAAe,EAAE,CAAC;QAYtC;;WAEG;QACK,eAAU,GAAG,CAAC,CAAC;QAEvB,YAAO,GAA0B,IAAI,CAAC;QAEtC,YAAO,GAAgB,IAAI,CAAC;QAE5B,WAAM,GAAgB,IAAI,CAAC;QA+BzB,IAAI,SAAS,EAAE;YACb,MAAM,CAAC,gBAAgB,CAA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,eAAe,CAAC;QAC3C,OAAO,MAAM,KAAK,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC;CACF;AAED,eAAe,KAAK,CAAC"} \ No newline at end of file diff --git a/pkg/npm/http-api/tmp/index.d.ts b/pkg/npm/http-api/tmp/index.d.ts new file mode 100644 index 000000000..5c39dfc41 --- /dev/null +++ b/pkg/npm/http-api/tmp/index.d.ts @@ -0,0 +1,3 @@ +export * from './types'; +import { Urbit } from './Urbit'; +export { Urbit as default, Urbit }; diff --git a/pkg/npm/http-api/tmp/index.js b/pkg/npm/http-api/tmp/index.js new file mode 100644 index 000000000..46ce972d6 --- /dev/null +++ b/pkg/npm/http-api/tmp/index.js @@ -0,0 +1,4 @@ +export * from './types'; +import { Urbit } from './Urbit'; +export { Urbit as default, Urbit }; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/pkg/npm/http-api/tmp/index.js.map b/pkg/npm/http-api/tmp/index.js.map new file mode 100644 index 000000000..011e99d58 --- /dev/null +++ b/pkg/npm/http-api/tmp/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,KAAK,EAAE,CAAC"} \ No newline at end of file diff --git a/pkg/npm/http-api/tmp/types.d.ts b/pkg/npm/http-api/tmp/types.d.ts new file mode 100644 index 000000000..361d94378 --- /dev/null +++ b/pkg/npm/http-api/tmp/types.d.ts @@ -0,0 +1,180 @@ +/** + * An urbit style path, rendered as a Javascript string + * @example + * `"/updates"` + */ +export declare type Path = string; +/** + * @p including leading sig, rendered as a string + * + * @example + * ```typescript + * "~sampel-palnet" + * ``` + * + */ +export declare type Patp = string; +/** + * @p not including leading sig, rendered as a string + * + * @example + * ```typescript + * "sampel-palnet" + * ``` + * + */ +export declare type PatpNoSig = string; +/** + * The name of a clay mark, as a string + * + * @example + * ```typescript + * "graph-update" + * ``` + */ +export declare type Mark = string; +/** + * The name of a gall agent, as a string + * + * @example + * + * ```typescript + * "graph-store" + * ``` + */ +export declare type GallAgent = string; +/** + * Description of an outgoing poke + * + * @typeParam Action - Typescript type of the data being poked + */ +export interface Poke { + /** + * Ship to poke. If left empty, the api lib will populate it with the ship that it is connected to. + * + * @remarks + * + * This should always be the ship that you are connected to + * + */ + ship?: PatpNoSig; + /** + */ + app: GallAgent; + /** + * Mark of the cage to be poked + * + */ + mark: Mark; + /** + * Vase of the cage of to be poked, as JSON + */ + json: Action; +} +/** + * Description of a scry request + */ +export interface Scry { + /** {@inheritDoc GallAgent} */ + app: GallAgent; + /** {@inheritDoc Path} */ + path: Path; +} +/** + * Description of a thread request + * + * @typeParam Action - Typescript type of the data being poked + */ +export interface Thread { + /** + * The mark of the input vase + */ + inputMark: Mark; + /** + * The mark of the output vase + */ + outputMark: Mark; + /** + * Name of the thread + * + * @example + * ```typescript + * "graph-add-nodes" + * ``` + */ + threadName: string; + /** + * Desk of thread + */ + desk?: string; + /** + * Data of the input vase + */ + body: Action; +} +export declare type Action = 'poke' | 'subscribe' | 'ack' | 'unsubscribe' | 'delete'; +export interface PokeHandlers { + onSuccess?: () => void; + onError?: (e: any) => void; +} +export declare type PokeInterface = PokeHandlers & Poke; +export interface AuthenticationInterface { + ship: string; + url: string; + code: string; + verbose?: boolean; +} +/** + * Subscription event handlers + * + */ +export interface SubscriptionInterface { + /** + * Handle negative %watch-ack + */ + err?(error: any, id: string): void; + /** + * Handle %fact + */ + event?(data: any): void; + /** + * Handle %kick + */ + quit?(data: any): void; +} +export declare type OnceSubscriptionErr = 'quit' | 'nack' | 'timeout'; +export interface SubscriptionRequestInterface extends SubscriptionInterface { + /** + * The app to subscribe to + * @example + * `"graph-store"` + */ + app: GallAgent; + /** + * The path to which to subscribe + * @example + * `"/keys"` + */ + path: Path; +} +export interface headers { + 'Content-Type': string; + Cookie?: string; +} +export interface CustomEventHandler { + (data: any, response: string): void; +} +export interface SSEOptions { + headers?: { + Cookie?: string; + }; + withCredentials?: boolean; +} +export interface Message extends Record { + action: Action; + id?: number; +} +export declare class ResumableError extends Error { +} +export declare class FatalError extends Error { +} diff --git a/pkg/npm/http-api/tmp/types.js b/pkg/npm/http-api/tmp/types.js new file mode 100644 index 000000000..3d3a607cf --- /dev/null +++ b/pkg/npm/http-api/tmp/types.js @@ -0,0 +1,5 @@ +export class ResumableError extends Error { +} +export class FatalError extends Error { +} +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/pkg/npm/http-api/tmp/types.js.map b/pkg/npm/http-api/tmp/types.js.map new file mode 100644 index 000000000..1c908503f --- /dev/null +++ b/pkg/npm/http-api/tmp/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAmMA,MAAM,OAAO,cAAe,SAAQ,KAAK;CAAG;AAE5C,MAAM,OAAO,UAAW,SAAQ,KAAK;CAAG"} \ No newline at end of file diff --git a/pkg/npm/http-api/tmp/utils.d.ts b/pkg/npm/http-api/tmp/utils.d.ts new file mode 100644 index 000000000..75bdaf067 --- /dev/null +++ b/pkg/npm/http-api/tmp/utils.d.ts @@ -0,0 +1,16 @@ +export declare function camelize(str: string): string; +export declare function uncamelize(str: string, separator?: string): string; +/** + * Returns a hex string of given length. + * + * Poached from StackOverflow. + * + * @param len Length of hex string to return. + */ +export declare function hexString(len: number): string; +/** + * Generates a random UID. + * + * Copied from https://github.com/urbit/urbit/blob/137e4428f617c13f28ed31e520eff98d251ed3e9/pkg/interface/src/lib/util.js#L3 + */ +export declare function uid(): string; diff --git a/pkg/npm/http-api/tmp/utils.js b/pkg/npm/http-api/tmp/utils.js new file mode 100644 index 000000000..4a99da707 --- /dev/null +++ b/pkg/npm/http-api/tmp/utils.js @@ -0,0 +1,51 @@ +export function camelize(str) { + return str + .replace(/\s(.)/g, function ($1) { + return $1.toUpperCase(); + }) + .replace(/\s/g, '') + .replace(/^(.)/, function ($1) { + return $1.toLowerCase(); + }); +} +export function uncamelize(str, separator = '-') { + // Replace all capital letters by separator followed by lowercase one + var str = str.replace(/[A-Z]/g, function (letter) { + return separator + letter.toLowerCase(); + }); + return str.replace(new RegExp('^' + separator), ''); +} +/** + * Returns a hex string of given length. + * + * Poached from StackOverflow. + * + * @param len Length of hex string to return. + */ +export function hexString(len) { + const maxlen = 8; + const min = Math.pow(16, Math.min(len, maxlen) - 1); + const max = Math.pow(16, Math.min(len, maxlen)) - 1; + const n = Math.floor(Math.random() * (max - min + 1)) + min; + let r = n.toString(16); + while (r.length < len) { + r = r + hexString(len - maxlen); + } + return r; +} +/** + * Generates a random UID. + * + * Copied from https://github.com/urbit/urbit/blob/137e4428f617c13f28ed31e520eff98d251ed3e9/pkg/interface/src/lib/util.js#L3 + */ +export function uid() { + let str = '0v'; + str += Math.ceil(Math.random() * 8) + '.'; + for (let i = 0; i < 5; i++) { + let _str = Math.ceil(Math.random() * 10000000).toString(32); + _str = ('00000' + _str).substr(-5, 5); + str += _str + '.'; + } + return str.slice(0, -1); +} +//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/pkg/npm/http-api/tmp/utils.js.map b/pkg/npm/http-api/tmp/utils.js.map new file mode 100644 index 000000000..a5238c348 --- /dev/null +++ b/pkg/npm/http-api/tmp/utils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ,CAAC,GAAW;IAClC,OAAO,GAAG;SACP,OAAO,CAAC,QAAQ,EAAE,UAAU,EAAU;QACrC,OAAO,EAAE,CAAC,WAAW,EAAE,CAAC;IAC1B,CAAC,CAAC;SACD,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;SAClB,OAAO,CAAC,MAAM,EAAE,UAAU,EAAU;QACnC,OAAO,EAAE,CAAC,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