Skip to content

William/v2 prototype#40

Open
swansontec wants to merge 6 commits into
masterfrom
william/v2-prototype
Open

William/v2 prototype#40
swansontec wants to merge 6 commits into
masterfrom
william/v2-prototype

Conversation

@swansontec
Copy link
Copy Markdown
Contributor

@swansontec swansontec commented Aug 1, 2022

Almost everything should be here now from the server point of view, but it needs to be tested, and we need the publisher, rates checker, and blockchain checkers still.

@swansontec swansontec force-pushed the william/v2-prototype branch from d89f1fc to e030330 Compare August 3, 2022 10:35
@swansontec swansontec force-pushed the william/v2-prototype branch from e030330 to 615dddd Compare August 5, 2022 22:43
@swansontec swansontec mentioned this pull request Aug 9, 2022
Comment thread src/types/pushCleaners.ts
export const asPushMessage: Cleaner<PushMessage> = asObject({
title: asOptional(asString),
body: asOptional(asString),
data: asObject(asString)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't data optional?

Copy link
Copy Markdown
Contributor

@samholmes samholmes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some feedback to discuss

Comment thread src/types/pushTypes.ts
Comment on lines +106 to +111
export type PushEventState =
| 'waiting' // Waiting for the trigger
| 'cancelled' // Removed before the trigger happened
| 'triggered' // The trigger happened, but not the effects
| 'complete' // The trigger and effects are done
| 'hidden' // Removed after being triggered
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are cancelled and hidden internal states? If a client removes a push event it is not returned by the public API, but it remains in the DB with either of these states?

If I understand correctly, triggered is the state just before completing the event (so this is also an internally-concerned state). I think we should word this as // The trigger and event is done, because at least on the client-side, the word "effect" is the derived state(s) from the action/event; and the action/event is the cause of the effect.

Comment thread src/types/pushTypes.ts
Comment on lines +138 to +144
export interface NewPushEvent {
readonly eventId: string
readonly broadcastTxs?: BroadcastTx[]
readonly pushMessage?: PushMessage
readonly recurring: boolean
readonly trigger: PushTrigger
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this belong in the pushApiTypes.ts?

Comment thread docs/demo.ts

const apiKey = 'demo-api-key'
const deviceId = 'example-device'
const loginId = base64.parse('EE+tBb5wM63qwCDVidzwUQThH9ekCSfpUuTQYujSmY8=')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this loginId a test loginId?

Comment thread docs/demo.ts
/**
* All push server HTTP methods use "POST" with JSON.
*/
async function postJson(uri: string, body: unknown): Promise<unknown> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish I had noticed this function early. I like it and would prefer to use it in the GUI (if not now, then later).

Comment thread docs/demo.ts
Comment on lines +53 to +60
await postJson(
'http://127.0.0.1:8001/v2/device/update/',
wasPushRequestBody({
apiKey,
deviceId,
data: wasDeviceUpdatePayload({ loginIds: [loginId] })
})
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be the isomorphic dream:

import pushServer from 'https://push.edge.app/api'

pushServer.device.update({ apiKey, deviceId, data: { loginIds: [loginId] } })

This magic would be enabled with URL imports in our client-side environments (something Deno or Bun enables) and using a special HTTP server framework (ala serverlet) which could syndicate a public API derived from the defined routes at the /api route.

TL;DR: Another thing to add to the side-project/experiment list.

Comment thread src/db/couchPushEvents.ts
)
} catch (error) {
if (asMaybeConflictError(error) == null) throw error
await addEvent(connection, event, new Date(created.valueOf() + 1))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this recursion thrash? The created date param wont prevent the recursive call to no longer conflict. We may want a delay here?

Comment thread src/util/triggerEvent.ts
/**
* Handles all the effects once a row has been triggered.
*/
export async function triggerEvent(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this used? Or is it used in a later PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants