@flow-industries/id 0.21.1 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/sdk/client/create-flow.js +3 -5
  2. package/dist/sdk/client/dialog-host.js +13 -1
  3. package/dist/sdk/client/flow-widget.js +6 -1
  4. package/dist/sdk/client/focus-session.d.ts +18 -0
  5. package/dist/sdk/client/focus-session.js +140 -0
  6. package/dist/sdk/client/focus.d.ts +11 -0
  7. package/dist/sdk/client/focus.js +30 -0
  8. package/dist/sdk/client/iframe-host.d.ts +5 -3
  9. package/dist/sdk/client/iframe-host.js +6 -3
  10. package/dist/sdk/client/index.d.ts +2 -1
  11. package/dist/sdk/client/index.js +1 -0
  12. package/dist/sdk/client/json-api.d.ts +1 -1
  13. package/dist/sdk/client/json-api.js +3 -1
  14. package/dist/sdk/client/open-profile.js +7 -3
  15. package/dist/sdk/client/overlay-focus.d.ts +1 -0
  16. package/dist/sdk/client/overlay-focus.js +24 -0
  17. package/dist/sdk/client/profile-button.js +9 -4
  18. package/dist/sdk/client/rooms.js +7 -26
  19. package/dist/sdk/client/study-search.d.ts +20 -0
  20. package/dist/sdk/client/study-search.js +116 -0
  21. package/dist/sdk/react/use-cooldown.d.ts +1 -0
  22. package/dist/sdk/react/use-cooldown.js +12 -0
  23. package/dist/sdk/types/account-data.d.ts +269 -0
  24. package/dist/sdk/types/account-data.js +0 -0
  25. package/dist/sdk/types/auth.d.ts +12 -0
  26. package/dist/sdk/types/dialog.d.ts +25 -0
  27. package/dist/sdk/types/events.d.ts +5 -1
  28. package/dist/sdk/types/focus.d.ts +109 -0
  29. package/dist/sdk/types/focus.js +0 -0
  30. package/dist/sdk/types/index.d.ts +8 -3
  31. package/dist/sdk/types/landing.d.ts +9 -0
  32. package/dist/sdk/types/landing.js +0 -0
  33. package/dist/sdk/types/otp.d.ts +20 -0
  34. package/dist/sdk/types/otp.js +0 -0
  35. package/dist/sdk/types/sdk.d.ts +1 -0
  36. package/dist/sdk/types/settings.d.ts +162 -0
  37. package/dist/sdk/types/settings.js +0 -0
  38. package/dist/sdk/types/xp.d.ts +8 -0
  39. package/package.json +6 -2
@@ -0,0 +1,162 @@
1
+ import type { RawValue } from "../json";
2
+ import type { CosmeticItem, CosmeticMaterial, CosmeticSlot, EquipRegion, SettingsConflict } from "./cosmetics";
3
+ export interface PaintDescriptor {
4
+ key: string;
5
+ group: string;
6
+ label: string;
7
+ description?: string;
8
+ type: "paint";
9
+ default: string;
10
+ options: {
11
+ value: string;
12
+ label: string;
13
+ }[];
14
+ /**
15
+ * The item this colour lands on, and the material on it that is recoloured.
16
+ * Both travel on the descriptor rather than being read back out of the key: a
17
+ * form grouping its pickers by item, and a renderer deciding which surface a
18
+ * colour applies to, each want one of them, and neither should be taking a
19
+ * key apart to get it.
20
+ */
21
+ cosmetic: string;
22
+ material: CosmeticMaterial;
23
+ }
24
+ export interface CosmeticOffer extends CosmeticItem {
25
+ /**
26
+ * Every equip region this item cannot share a body with — its own, plus
27
+ * everything they overlap. Another item is blocked by this one exactly when
28
+ * its `regions` intersect this list, so a client tests a set instead of
29
+ * re-implementing the rule.
30
+ */
31
+ conflicts: readonly EquipRegion[];
32
+ /**
33
+ * The colour pickers this item brings once it is worn: the SAME descriptors
34
+ * {@link SurfaceRegistry.derived} emits for it, from the same builder, so a
35
+ * client rendering its draft and a client reading the derived list for a
36
+ * saved loadout draw the same rows.
37
+ *
38
+ * An offer, not a setting. A colour is a setting the player HAS only while
39
+ * its item is equipped — that is what {@link sanitize} prunes on — and
40
+ * nothing here widens the stored blob or the write path.
41
+ */
42
+ paint: readonly PaintDescriptor[];
43
+ }
44
+ export type SettingDescriptor = {
45
+ key: string;
46
+ group: string;
47
+ label: string;
48
+ description?: string;
49
+ type: "number";
50
+ default: number;
51
+ min: number;
52
+ max: number;
53
+ step: number;
54
+ } | {
55
+ key: string;
56
+ group: string;
57
+ label: string;
58
+ description?: string;
59
+ type: "boolean";
60
+ default: boolean;
61
+ } | {
62
+ key: string;
63
+ group: string;
64
+ label: string;
65
+ description?: string;
66
+ type: "enum";
67
+ default: string;
68
+ options: {
69
+ value: string;
70
+ label: string;
71
+ }[];
72
+ } | {
73
+ key: string;
74
+ group: string;
75
+ label: string;
76
+ description?: string;
77
+ /** Free text with a shape, for values no fixed option list can cover —
78
+ * a Discord snowflake, a channel id. `pattern` is a source string (not a
79
+ * RegExp) so the descriptor stays JSON-serializable for the schema
80
+ * endpoint the settings form reads. */
81
+ type: "text";
82
+ default: string;
83
+ maxLength: number;
84
+ pattern?: string;
85
+ } | {
86
+ key: string;
87
+ group: string;
88
+ label: string;
89
+ description?: string;
90
+ /** One cosmetic slot: the stored value is a catalog cosmetic id, or ""
91
+ * for nothing equipped. `items` is the catalog projection the customizer
92
+ * reads off the schema endpoint so it can render a draft loadout with no
93
+ * catalog data of its own — which picks would collide, and which colour
94
+ * pickers a pick brings with it. UX only; the conflict rule is enforced
95
+ * on save, and a draft is never a claim about what may be saved.
96
+ *
97
+ * The default is an item id, not "": a player who has never dressed is
98
+ * wearing the starting outfit, and saying so here is what lets "" mean
99
+ * the one thing it should — a player who chose to wear nothing there. */
100
+ type: "cosmetic";
101
+ default: string;
102
+ slot: CosmeticSlot;
103
+ /**
104
+ * Whether an avatar may go with this slot empty. False is the slot a
105
+ * client offers a "None" chip for; true is one where `""` is refused on
106
+ * save. Projected here rather than restated in the customizer for the
107
+ * reason {@link CosmeticOffer.conflicts} is: the rule belongs to the
108
+ * slot, and a second hand-maintained copy of it goes quiet (AUTH-222).
109
+ */
110
+ required: boolean;
111
+ items: readonly CosmeticOffer[];
112
+ } | PaintDescriptor;
113
+ export type StoredSettings = Record<string, RawValue>;
114
+ export type Settings = Record<string, number | boolean | string>;
115
+ export interface SettingsMigration {
116
+ to: number;
117
+ up: (stored: StoredSettings) => StoredSettings;
118
+ }
119
+ export interface SurfaceRegistry {
120
+ /**
121
+ * Bumped only when a setting in this surface is renamed or retyped. A stored
122
+ * blob stamps the version it was last normalized to; {@link normalize} walks
123
+ * an old blob up to this version on read, preserving the user's chosen value
124
+ * instead of dropping it. Adding or removing a setting does NOT bump it.
125
+ */
126
+ version: number;
127
+ settings: readonly SettingDescriptor[];
128
+ /**
129
+ * The steps {@link normalize} walks an out-of-date blob up through, in
130
+ * ascending {@link SettingsMigration.to} order. A surface that has never
131
+ * renamed anything has none, and its blobs need no walk.
132
+ */
133
+ migrations?: readonly SettingsMigration[];
134
+ /**
135
+ * Enum defaults are drawn from the option list seeded by the user id instead
136
+ * of the descriptor default, so every unsaved user gets their own stable
137
+ * random pick — identical on every read and on every surface that reads it.
138
+ */
139
+ randomDefaults?: boolean;
140
+ /**
141
+ * Cross-field rule for the whole surface, evaluated on the MERGED blob by
142
+ * the one settings write path. Per-descriptor {@link sanitize} cannot
143
+ * express it: an equip-region collision is a relation between two keys, not
144
+ * a property of either. Living on the surface rather than in a route is what
145
+ * makes it impossible for a second write path to skip.
146
+ */
147
+ validate?: (settings: Settings) => SettingsConflict | null;
148
+ /**
149
+ * The settings this surface has only because of what is stored in it — the
150
+ * appearance surface's colour pickers for the cosmetics a player is
151
+ * currently wearing.
152
+ *
153
+ * Derived rather than fixed is the whole mechanism: a setting that exists
154
+ * only while its cosmetic is equipped is dropped by {@link sanitize} the
155
+ * moment the cosmetic is not, so unequipping an item takes its colour with
156
+ * it and re-equipping cannot resurrect a colour the player never chose.
157
+ *
158
+ * Reads the surface's FIXED settings only, never its own output, so the
159
+ * descriptor list is resolved in one pass and cannot recurse.
160
+ */
161
+ derived?: (settings: Settings) => readonly SettingDescriptor[];
162
+ }
File without changes
@@ -212,3 +212,11 @@ export interface CurrentAction {
212
212
  since: string;
213
213
  subject?: string;
214
214
  }
215
+ export interface ActionTimelineEvent {
216
+ kind: ActionEventKind;
217
+ at: Date;
218
+ }
219
+ export interface ActionDurations {
220
+ accruedSeconds: number;
221
+ focusedSeconds: number;
222
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flow-industries/id",
3
- "version": "0.21.1",
3
+ "version": "0.22.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -50,6 +50,10 @@
50
50
  "./start/server": {
51
51
  "types": "./dist/sdk/start/server.d.ts",
52
52
  "import": "./dist/sdk/start/server.js"
53
+ },
54
+ "./focus": {
55
+ "types": "./dist/sdk/client/focus.d.ts",
56
+ "import": "./dist/sdk/client/focus.js"
53
57
  }
54
58
  },
55
59
  "files": [
@@ -126,7 +130,7 @@
126
130
  ],
127
131
  "dependencies": {
128
132
  "@aws-sdk/client-s3": "^3.1073.0",
129
- "@flow-industries/ui": "^0.19.0",
133
+ "@flow-industries/ui": "^0.21.1",
130
134
  "@hono/otel": "^1.1.2",
131
135
  "@openobserve/browser-logs": "^0.3.1",
132
136
  "@openobserve/browser-rum": "^0.3.1",