oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package wire
2
3import "time"
4
5// Push (native slice 2, plan 2026-11-20-equipo-native-slice-2.md): a
6// paired device registers its APNs token; the engine writes pushes to an
7// outbox in the transaction of the change; a sender delivers them.
8
9// Push environments: the APNs gateway a token belongs to.
10const (
11 APNsProduction = "production"
12 APNsDevelopment = "development"
13)
14
15// Device platforms. Only iOS starts Live Activities (macOS shows the
16// iPhone's in its menu bar).
17const (
18 PlatformIOS = "ios"
19 PlatformMacOS = "macos"
20)
21
22// MaxPushToken bounds an APNs token in hex: Apple's are 32 bytes today
23// and may grow.
24const MaxPushToken = 400
25
26// RegisterPush is the body of POST /api/v1/push-registrations: the
27// device's APNs token, its environment and platform, and on iPhone the
28// Live Activity push-to-start token. It is bound to the paired device
29// credential that sends it and replaces that credential's earlier one.
30type RegisterPush struct {
31 ActionsVersion int `json:"actions_version,omitempty"`
32 BindingID string `json:"binding_id,omitempty"`
33 Token string `json:"token"`
34 Environment string `json:"environment"`
35 Platform string `json:"platform"`
36 StartToken string `json:"start_token,omitempty"`
37}
38
39// PushRegistration is what the server keeps for the device, without its
40// tokens (which are never echoed). LiveActivities is whether a
41// push-to-start token is on file.
42type PushRegistration struct {
43 Environment string `json:"environment"`
44 Platform string `json:"platform"`
45 LiveActivities bool `json:"live_activities"`
46 UpdatedAt time.Time `json:"updated_at"`
47}
48
49// RegisterActivity is the body of POST
50// /api/v1/push-registrations/activities: a running Live Activity's own
51// update token, for the task it follows. The server forgets it when the
52// activity ends.
53type RegisterActivity struct {
54 TaskID string `json:"task_id"`
55 Token string `json:"token"`
56}
57
58// LiveActivityAttributesType is the app's ActivityAttributes type, named in a
59// push-to-start payload ("attributes-type").
60const LiveActivityAttributesType = "EquipoTaskAttributes"
61
62// LiveActivityAttributes are a task Live Activity's fixed attributes.
63type LiveActivityAttributes struct {
64 TaskID string `json:"task_id"`
65 // Origin is the instance's origin: a device sends this activity's
66 // token only to the account it names.
67 Origin string `json:"origin"`
68}
69
70// Live Activity tones, as Roster's stage track: amber waits on you, red
71// only for a failure.
72const (
73 TonePositive = "positive"
74 ToneWarning = "warning"
75 ToneNegative = "negative"
76)
77
78// Live Activity and task outcomes.
79const (
80 PushOutcomeDone = "done"
81 PushOutcomeCancelled = "cancelled"
82 PushOutcomeFailed = "failed"
83 // PushOutcomeReplaced ends an activity to make room for a newer
84 // task's (at most MaxLiveActivities a person).
85 PushOutcomeReplaced = "replaced"
86)
87
88// MaxLiveActivities is how many task Live Activities a person has at
89// once: the most recently started tasks'.
90const MaxLiveActivities = 3
91
92// LiveActivityState is a task Live Activity's content state, the app's
93// Codable ContentState: the task, its stage (Task.stage), the specialist
94// working on it (Step.specialist, or its maker's category: design), the
95// newest activity line, what it
96// needs from you (Task.needs_you, "" when nothing), the tone, and once it
97// ended, the outcome.
98type LiveActivityState struct {
99 TaskID string `json:"task_id"`
100 Title string `json:"title"`
101 Stage string `json:"stage"`
102 Specialist string `json:"specialist"`
103 Activity string `json:"activity"`
104 NeedsYou string `json:"needs_you"`
105 Tone string `json:"tone"`
106 Outcome string `json:"outcome,omitempty"`
107}
108
109// PushData is what an alert carries beside aps, under "equipo", for the
110// app to open the right place when it is tapped: a card, a task, or the
111// conversation (a reply).
112// PushActions is routing and revision metadata only, never authority or text.
113type PushActions struct {
114 Version int `json:"version"`
115 BindingID string `json:"binding_id"`
116 NotificationID string `json:"notification_id"`
117 CardKind string `json:"card_kind,omitempty"`
118 CardRevision int64 `json:"card_revision,omitempty"`
119 TaskRevision int64 `json:"task_revision,omitempty"`
120 StepID string `json:"step_id,omitempty"`
121 StepRevision int64 `json:"step_revision,omitempty"`
122 Attempt int64 `json:"attempt,omitempty"`
123}
124type PushData struct {
125 Actions *PushActions `json:"actions,omitempty"`
126 Kind string `json:"kind"`
127 CardID string `json:"card_id,omitempty"`
128 TaskID string `json:"task_id,omitempty"`
129 TurnID string `json:"turn_id,omitempty"`
130}
131
132// PushData kinds.
133const (
134 PushCard = "card"
135 PushReply = "reply"
136 PushTask = "task"
137 PushBadge = "badge"
138)
139
140// SetCardVisibility is the body of POST /api/v1/cards/{id}/visibility:
141// set the card aside (or bring it back) for the person, at the card's
142// current revision. It never answers, cancels or starts anything; the
143// card stays in Needs you.
144type SetCardVisibility struct {
145 Aside bool `json:"aside"`
146 Revision int64 `json:"revision"`
147}
148
149// RetryTask binds notification retry to the exact failed attempt shown.
150type RetryTask struct {
151 Revision int64 `json:"revision"`
152 StepID string `json:"step_id"`
153 StepRevision int64 `json:"step_revision"`
154 Attempt int64 `json:"attempt"`
155 IdempotencyKey string `json:"idempotency_key"`
156}
157