@the-seeker/feedback-react-native 0.0.0-stage → 0.2.1

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 (80) hide show
  1. package/README.md +266 -2
  2. package/dist/core/author-token.d.ts +16 -0
  3. package/dist/core/author-token.js +96 -0
  4. package/dist/core/client.d.ts +55 -0
  5. package/dist/core/client.js +98 -0
  6. package/dist/core/config.d.ts +59 -0
  7. package/dist/core/config.js +112 -0
  8. package/dist/core/posts-schema.d.ts +306 -0
  9. package/dist/core/posts-schema.js +131 -0
  10. package/dist/core/posts.d.ts +67 -0
  11. package/dist/core/posts.js +113 -0
  12. package/dist/core/request.d.ts +53 -0
  13. package/dist/core/request.js +88 -0
  14. package/dist/core/survey.d.ts +12 -0
  15. package/dist/core/survey.js +26 -0
  16. package/dist/core/texts.d.ts +196 -0
  17. package/dist/core/texts.js +232 -0
  18. package/dist/core/theme.d.ts +6 -0
  19. package/dist/core/theme.js +55 -0
  20. package/dist/core/transport.d.ts +9 -0
  21. package/dist/core/transport.js +37 -0
  22. package/dist/index.d.ts +16 -0
  23. package/dist/index.js +34 -0
  24. package/dist/ui/Attachments.d.ts +9 -0
  25. package/dist/ui/Attachments.js +27 -0
  26. package/dist/ui/FeedbackForm.d.ts +8 -0
  27. package/dist/ui/FeedbackForm.js +92 -0
  28. package/dist/ui/FeedbackPostScreen.d.ts +8 -0
  29. package/dist/ui/FeedbackPostScreen.js +74 -0
  30. package/dist/ui/FeedbackSheet.d.ts +2 -0
  31. package/dist/ui/FeedbackSheet.js +14 -0
  32. package/dist/ui/FollowUpSheet.d.ts +17 -0
  33. package/dist/ui/FollowUpSheet.js +50 -0
  34. package/dist/ui/Inline.d.ts +6 -0
  35. package/dist/ui/Inline.js +16 -0
  36. package/dist/ui/Launcher.d.ts +1 -0
  37. package/dist/ui/Launcher.js +16 -0
  38. package/dist/ui/MyFeedbackModal.d.ts +10 -0
  39. package/dist/ui/MyFeedbackModal.js +45 -0
  40. package/dist/ui/MyFeedbackScreen.d.ts +9 -0
  41. package/dist/ui/MyFeedbackScreen.js +88 -0
  42. package/dist/ui/PostThread.d.ts +17 -0
  43. package/dist/ui/PostThread.js +57 -0
  44. package/dist/ui/Provider.d.ts +24 -0
  45. package/dist/ui/Provider.js +186 -0
  46. package/dist/ui/SurveyPrompt.d.ts +2 -0
  47. package/dist/ui/SurveyPrompt.js +52 -0
  48. package/dist/ui/context.d.ts +122 -0
  49. package/dist/ui/context.js +28 -0
  50. package/dist/ui/device.d.ts +10 -0
  51. package/dist/ui/device.js +22 -0
  52. package/dist/ui/forms.d.ts +32 -0
  53. package/dist/ui/forms.js +62 -0
  54. package/dist/ui/motion.d.ts +1 -0
  55. package/dist/ui/motion.js +23 -0
  56. package/dist/ui/post-format.d.ts +19 -0
  57. package/dist/ui/post-format.js +79 -0
  58. package/dist/ui/post-pieces.d.ts +24 -0
  59. package/dist/ui/post-pieces.js +60 -0
  60. package/dist/ui/post-styles.d.ts +317 -0
  61. package/dist/ui/post-styles.js +103 -0
  62. package/dist/ui/post-view-model.d.ts +52 -0
  63. package/dist/ui/post-view-model.js +181 -0
  64. package/dist/ui/primitives.d.ts +33 -0
  65. package/dist/ui/primitives.js +55 -0
  66. package/dist/ui/prop-state.d.ts +9 -0
  67. package/dist/ui/prop-state.js +27 -0
  68. package/dist/ui/storage.d.ts +15 -0
  69. package/dist/ui/storage.js +35 -0
  70. package/dist/ui/styles.d.ts +774 -0
  71. package/dist/ui/styles.js +185 -0
  72. package/dist/ui/surfaces.d.ts +13 -0
  73. package/dist/ui/surfaces.js +41 -0
  74. package/dist/ui/tokens.d.ts +16 -0
  75. package/dist/ui/tokens.js +62 -0
  76. package/dist/ui/useMyPosts.d.ts +35 -0
  77. package/dist/ui/useMyPosts.js +124 -0
  78. package/dist/ui/useSurvey.d.ts +12 -0
  79. package/dist/ui/useSurvey.js +52 -0
  80. package/package.json +32 -3
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RADII = exports.ACCENTS = void 0;
4
+ exports.parseWidgetConfig = parseWidgetConfig;
5
+ const zod_1 = require("zod");
6
+ const texts_1 = require("./texts");
7
+ exports.ACCENTS = {
8
+ neutral: "#111827",
9
+ blue: "#2563eb",
10
+ green: "#16a34a",
11
+ violet: "#7c3aed",
12
+ orange: "#ea580c",
13
+ rose: "#e11d48",
14
+ };
15
+ exports.RADII = { panel: 14, field: 10, button: 24 };
16
+ const nonNegative = zod_1.z.number().finite().nonnegative().catch(0);
17
+ const surveySchema = zod_1.z
18
+ .object({
19
+ id: zod_1.z.string(),
20
+ type: zod_1.z.enum(["nps", "csat"]),
21
+ question: zod_1.z.string(),
22
+ followUpQuestion: zod_1.z.string().catch(""),
23
+ pathPattern: zod_1.z.string().catch(""),
24
+ delaySeconds: nonNegative,
25
+ sampleRate: nonNegative,
26
+ cooldownDays: nonNegative,
27
+ })
28
+ .nullable()
29
+ .catch(null);
30
+ const color = zod_1.z
31
+ .string()
32
+ .regex(/^#[0-9a-f]{6}$/i)
33
+ .optional()
34
+ .catch(undefined);
35
+ const paletteSchema = zod_1.z
36
+ .object({ accent: color, accentText: color, background: color, text: color, mutedText: color, border: color })
37
+ .catch({});
38
+ const radiusSchema = zod_1.z
39
+ .object({
40
+ panel: zod_1.z.number().int().min(0).max(32).catch(exports.RADII.panel),
41
+ field: zod_1.z.number().int().min(0).max(24).catch(exports.RADII.field),
42
+ button: zod_1.z.number().int().min(0).max(24).catch(exports.RADII.button),
43
+ })
44
+ .catch(exports.RADII);
45
+ const appearanceSchema = zod_1.z
46
+ .object({
47
+ light: paletteSchema,
48
+ dark: paletteSchema,
49
+ radius: radiusSchema,
50
+ font: zod_1.z.enum(["default", "inherit"]).catch("default"),
51
+ })
52
+ .catch({ light: {}, dark: {}, radius: exports.RADII, font: "default" });
53
+ const label = zod_1.z.string().trim().catch("");
54
+ const rawSchema = zod_1.z.object({
55
+ enabled: zod_1.z.literal(true),
56
+ position: zod_1.z.enum(["bottom-right", "bottom-left"]).catch("bottom-right"),
57
+ accent: zod_1.z.enum(["neutral", "blue", "green", "violet", "orange", "rose"]).catch("neutral"),
58
+ appearance: appearanceSchema,
59
+ theme: zod_1.z.enum(["light", "dark", "system", "auto"]).catch("light"),
60
+ contactMode: zod_1.z.enum(["email", "text", "hidden"]).catch("email"),
61
+ texts: zod_1.z.unknown().optional(),
62
+ localizedTexts: zod_1.z
63
+ .object({ en: zod_1.z.object({ buttonLabel: label }).passthrough().catch({ buttonLabel: "" }) })
64
+ .catch({ en: { buttonLabel: "" } }),
65
+ buttonLabel: label,
66
+ displayMode: zod_1.z.enum(["launcher", "inline", "manual"]).catch("launcher"),
67
+ imageUploadEnabled: zod_1.z.unknown().optional(),
68
+ survey: surveySchema,
69
+ });
70
+ function parsePalette(raw) {
71
+ return Object.fromEntries(Object.entries(raw).filter((entry) => typeof entry[1] === "string"));
72
+ }
73
+ function parseWidgetConfig(input) {
74
+ const parsed = rawSchema.safeParse(input);
75
+ if (!parsed.success)
76
+ return null;
77
+ const raw = parsed.data;
78
+ const survey = raw.survey;
79
+ return {
80
+ position: raw.position,
81
+ labels: {
82
+ ko: raw.buttonLabel || texts_1.DEFAULT_TEXTS.ko.launcher,
83
+ en: raw.localizedTexts.en.buttonLabel || texts_1.DEFAULT_TEXTS.en.launcher,
84
+ },
85
+ accentName: raw.accent,
86
+ appearance: {
87
+ ...raw.appearance,
88
+ light: parsePalette(raw.appearance.light),
89
+ dark: parsePalette(raw.appearance.dark),
90
+ },
91
+ theme: raw.theme,
92
+ contactMode: raw.contactMode,
93
+ texts: {
94
+ ko: (0, texts_1.parseTexts)(raw.texts, raw.contactMode, "ko"),
95
+ en: (0, texts_1.parseTexts)(raw.localizedTexts.en, raw.contactMode, "en"),
96
+ },
97
+ mode: raw.displayMode,
98
+ images: raw.imageUploadEnabled !== false,
99
+ survey: survey === null
100
+ ? null
101
+ : {
102
+ id: survey.id,
103
+ type: survey.type,
104
+ question: survey.question,
105
+ followUp: survey.followUpQuestion.trim() ? survey.followUpQuestion : null,
106
+ delaySeconds: survey.delaySeconds,
107
+ pathPattern: survey.pathPattern || null,
108
+ sampleRate: survey.sampleRate,
109
+ cooldownDays: survey.cooldownDays,
110
+ },
111
+ };
112
+ }
@@ -0,0 +1,306 @@
1
+ import { z } from "zod";
2
+ export declare const FEEDBACK_STATUSES: readonly ["new", "in_progress", "resolved", "closed"];
3
+ export declare const BOARD_STATUSES: readonly ["review", "planned", "in_progress", "done"];
4
+ declare const ENTRY_KINDS: readonly ["answer", "followup", "comment", "status", "roadmap_link", "release_link", "merge", "auto_reply", "visibility"];
5
+ export type FeedbackStatus = (typeof FEEDBACK_STATUSES)[number];
6
+ export type BoardStatus = (typeof BOARD_STATUSES)[number];
7
+ export type EntryKind = (typeof ENTRY_KINDS)[number] | "other";
8
+ export type PostVisibility = "private" | "public";
9
+ export declare const siteSchema: z.ZodObject<{
10
+ name: z.ZodCatch<z.ZodString>;
11
+ iconUrl: z.ZodCatch<z.ZodNullable<z.ZodString>>;
12
+ accentColor: z.ZodCatch<z.ZodNullable<z.ZodString>>;
13
+ mode: z.ZodCatch<z.ZodEnum<{
14
+ one_way: "one_way";
15
+ two_way: "two_way";
16
+ }>>;
17
+ eligibility: z.ZodCatch<z.ZodEnum<{
18
+ email: "email";
19
+ anyone: "anyone";
20
+ app_user: "app_user";
21
+ }>>;
22
+ anonymity: z.ZodCatch<z.ZodEnum<{
23
+ off: "off";
24
+ others: "others";
25
+ full: "full";
26
+ }>>;
27
+ boards: z.ZodCatch<z.ZodPipe<z.ZodArray<z.ZodCatch<z.ZodNullable<z.ZodObject<{
28
+ key: z.ZodString;
29
+ name: z.ZodString;
30
+ }, z.core.$strip>>>>, z.ZodTransform<{
31
+ key: string;
32
+ name: string;
33
+ }[], ({
34
+ key: string;
35
+ name: string;
36
+ } | null)[]>>>;
37
+ statusLabels: z.ZodCatch<z.ZodObject<{
38
+ review: z.ZodCatch<z.ZodNullable<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodObject<{
39
+ label: z.ZodString;
40
+ }, z.core.$strip>, z.ZodTransform<string, {
41
+ label: string;
42
+ }>>]>, z.ZodString>>>;
43
+ planned: z.ZodCatch<z.ZodNullable<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodObject<{
44
+ label: z.ZodString;
45
+ }, z.core.$strip>, z.ZodTransform<string, {
46
+ label: string;
47
+ }>>]>, z.ZodString>>>;
48
+ in_progress: z.ZodCatch<z.ZodNullable<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodObject<{
49
+ label: z.ZodString;
50
+ }, z.core.$strip>, z.ZodTransform<string, {
51
+ label: string;
52
+ }>>]>, z.ZodString>>>;
53
+ done: z.ZodCatch<z.ZodNullable<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodObject<{
54
+ label: z.ZodString;
55
+ }, z.core.$strip>, z.ZodTransform<string, {
56
+ label: string;
57
+ }>>]>, z.ZodString>>>;
58
+ }, z.core.$strip>>;
59
+ autoReplyText: z.ZodCatch<z.ZodNullable<z.ZodString>>;
60
+ myPostsEnabled: z.ZodCatch<z.ZodBoolean>;
61
+ }, z.core.$strip>;
62
+ export declare const summarySchema: z.ZodObject<{
63
+ number: z.ZodNumber;
64
+ title: z.ZodCatch<z.ZodNullable<z.ZodString>>;
65
+ excerpt: z.ZodCatch<z.ZodNullable<z.ZodString>>;
66
+ status: z.ZodCatch<z.ZodEnum<{
67
+ new: "new";
68
+ in_progress: "in_progress";
69
+ resolved: "resolved";
70
+ closed: "closed";
71
+ }>>;
72
+ boardStatus: z.ZodCatch<z.ZodNullable<z.ZodEnum<{
73
+ in_progress: "in_progress";
74
+ review: "review";
75
+ planned: "planned";
76
+ done: "done";
77
+ }>>>;
78
+ visibility: z.ZodPipe<z.ZodUnknown, z.ZodTransform<"private" | "public", unknown>>;
79
+ answered: z.ZodCatch<z.ZodBoolean>;
80
+ awaitingReply: z.ZodCatch<z.ZodBoolean>;
81
+ unread: z.ZodCatch<z.ZodBoolean>;
82
+ createdAt: z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>;
83
+ lastActivityAt: z.ZodCatch<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>>>;
84
+ }, z.core.$strip>;
85
+ export declare const entrySchema: z.ZodObject<{
86
+ id: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodNumber, z.ZodTransform<string, number>>]>;
87
+ kind: z.ZodPipe<z.ZodString, z.ZodTransform<"status" | "answer" | "followup" | "comment" | "roadmap_link" | "release_link" | "merge" | "auto_reply" | "visibility" | "other", string>>;
88
+ body: z.ZodCatch<z.ZodString>;
89
+ createdAt: z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>;
90
+ author: z.ZodEnum<{
91
+ other: "other";
92
+ team: "team";
93
+ me: "me";
94
+ }>;
95
+ meta: z.ZodCatch<z.ZodObject<{
96
+ status: z.ZodCatch<z.ZodNullable<z.ZodEnum<{
97
+ new: "new";
98
+ in_progress: "in_progress";
99
+ resolved: "resolved";
100
+ closed: "closed";
101
+ }>>>;
102
+ boardStatus: z.ZodCatch<z.ZodNullable<z.ZodEnum<{
103
+ in_progress: "in_progress";
104
+ review: "review";
105
+ planned: "planned";
106
+ done: "done";
107
+ }>>>;
108
+ title: z.ZodCatch<z.ZodNullable<z.ZodString>>;
109
+ }, z.core.$strip>>;
110
+ }, z.core.$strip>;
111
+ export declare const detailSchema: z.ZodObject<{
112
+ content: z.ZodCatch<z.ZodString>;
113
+ board: z.ZodCatch<z.ZodNullable<z.ZodString>>;
114
+ anonymous: z.ZodCatch<z.ZodBoolean>;
115
+ images: z.ZodCatch<z.ZodPipe<z.ZodArray<z.ZodCatch<z.ZodNullable<z.ZodObject<{
116
+ id: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodNumber, z.ZodTransform<string, number>>]>;
117
+ width: z.ZodCatch<z.ZodNullable<z.ZodNumber>>;
118
+ height: z.ZodCatch<z.ZodNullable<z.ZodNumber>>;
119
+ }, z.core.$strip>>>>, z.ZodTransform<{
120
+ id: string;
121
+ width: number | null;
122
+ height: number | null;
123
+ }[], ({
124
+ id: string;
125
+ width: number | null;
126
+ height: number | null;
127
+ } | null)[]>>>;
128
+ mode: z.ZodCatch<z.ZodEnum<{
129
+ one_way: "one_way";
130
+ two_way: "two_way";
131
+ }>>;
132
+ entries: z.ZodCatch<z.ZodPipe<z.ZodArray<z.ZodCatch<z.ZodNullable<z.ZodObject<{
133
+ id: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodNumber, z.ZodTransform<string, number>>]>;
134
+ kind: z.ZodPipe<z.ZodString, z.ZodTransform<"status" | "answer" | "followup" | "comment" | "roadmap_link" | "release_link" | "merge" | "auto_reply" | "visibility" | "other", string>>;
135
+ body: z.ZodCatch<z.ZodString>;
136
+ createdAt: z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>;
137
+ author: z.ZodEnum<{
138
+ other: "other";
139
+ team: "team";
140
+ me: "me";
141
+ }>;
142
+ meta: z.ZodCatch<z.ZodObject<{
143
+ status: z.ZodCatch<z.ZodNullable<z.ZodEnum<{
144
+ new: "new";
145
+ in_progress: "in_progress";
146
+ resolved: "resolved";
147
+ closed: "closed";
148
+ }>>>;
149
+ boardStatus: z.ZodCatch<z.ZodNullable<z.ZodEnum<{
150
+ in_progress: "in_progress";
151
+ review: "review";
152
+ planned: "planned";
153
+ done: "done";
154
+ }>>>;
155
+ title: z.ZodCatch<z.ZodNullable<z.ZodString>>;
156
+ }, z.core.$strip>>;
157
+ }, z.core.$strip>>>>, z.ZodTransform<{
158
+ id: string;
159
+ kind: "status" | "answer" | "followup" | "comment" | "roadmap_link" | "release_link" | "merge" | "auto_reply" | "visibility" | "other";
160
+ body: string;
161
+ createdAt: Date;
162
+ author: "other" | "team" | "me";
163
+ meta: {
164
+ status: "new" | "in_progress" | "resolved" | "closed" | null;
165
+ boardStatus: "in_progress" | "review" | "planned" | "done" | null;
166
+ title: string | null;
167
+ };
168
+ }[], ({
169
+ id: string;
170
+ kind: "status" | "answer" | "followup" | "comment" | "roadmap_link" | "release_link" | "merge" | "auto_reply" | "visibility" | "other";
171
+ body: string;
172
+ createdAt: Date;
173
+ author: "other" | "team" | "me";
174
+ meta: {
175
+ status: "new" | "in_progress" | "resolved" | "closed" | null;
176
+ boardStatus: "in_progress" | "review" | "planned" | "done" | null;
177
+ title: string | null;
178
+ };
179
+ } | null)[]>>>;
180
+ roadmap: z.ZodCatch<z.ZodNullable<z.ZodObject<{
181
+ title: z.ZodCatch<z.ZodNullable<z.ZodString>>;
182
+ stage: z.ZodCatch<z.ZodNullable<z.ZodString>>;
183
+ }, z.core.$strip>>>;
184
+ release: z.ZodCatch<z.ZodNullable<z.ZodObject<{
185
+ title: z.ZodCatch<z.ZodNullable<z.ZodString>>;
186
+ version: z.ZodCatch<z.ZodNullable<z.ZodString>>;
187
+ }, z.core.$strip>>>;
188
+ canFollowUp: z.ZodCatch<z.ZodBoolean>;
189
+ number: z.ZodNumber;
190
+ title: z.ZodCatch<z.ZodNullable<z.ZodString>>;
191
+ excerpt: z.ZodCatch<z.ZodNullable<z.ZodString>>;
192
+ status: z.ZodCatch<z.ZodEnum<{
193
+ new: "new";
194
+ in_progress: "in_progress";
195
+ resolved: "resolved";
196
+ closed: "closed";
197
+ }>>;
198
+ boardStatus: z.ZodCatch<z.ZodNullable<z.ZodEnum<{
199
+ in_progress: "in_progress";
200
+ review: "review";
201
+ planned: "planned";
202
+ done: "done";
203
+ }>>>;
204
+ visibility: z.ZodPipe<z.ZodUnknown, z.ZodTransform<"private" | "public", unknown>>;
205
+ answered: z.ZodCatch<z.ZodBoolean>;
206
+ awaitingReply: z.ZodCatch<z.ZodBoolean>;
207
+ unread: z.ZodCatch<z.ZodBoolean>;
208
+ createdAt: z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>;
209
+ lastActivityAt: z.ZodCatch<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>>>;
210
+ }, z.core.$strip>;
211
+ export declare const createdSchema: z.ZodObject<{
212
+ id: z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodNumber, z.ZodTransform<string, number>>]>;
213
+ number: z.ZodNumber;
214
+ title: z.ZodCatch<z.ZodNullable<z.ZodString>>;
215
+ status: z.ZodCatch<z.ZodEnum<{
216
+ new: "new";
217
+ in_progress: "in_progress";
218
+ resolved: "resolved";
219
+ closed: "closed";
220
+ }>>;
221
+ boardStatus: z.ZodCatch<z.ZodNullable<z.ZodEnum<{
222
+ in_progress: "in_progress";
223
+ review: "review";
224
+ planned: "planned";
225
+ done: "done";
226
+ }>>>;
227
+ visibility: z.ZodPipe<z.ZodUnknown, z.ZodTransform<"private" | "public", unknown>>;
228
+ createdAt: z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>;
229
+ receipt: z.ZodCatch<z.ZodObject<{
230
+ autoReplyText: z.ZodCatch<z.ZodNullable<z.ZodString>>;
231
+ }, z.core.$strip>>;
232
+ }, z.core.$strip>;
233
+ export declare const listSchema: z.ZodObject<{
234
+ posts: z.ZodCatch<z.ZodPipe<z.ZodArray<z.ZodCatch<z.ZodNullable<z.ZodObject<{
235
+ number: z.ZodNumber;
236
+ title: z.ZodCatch<z.ZodNullable<z.ZodString>>;
237
+ excerpt: z.ZodCatch<z.ZodNullable<z.ZodString>>;
238
+ status: z.ZodCatch<z.ZodEnum<{
239
+ new: "new";
240
+ in_progress: "in_progress";
241
+ resolved: "resolved";
242
+ closed: "closed";
243
+ }>>;
244
+ boardStatus: z.ZodCatch<z.ZodNullable<z.ZodEnum<{
245
+ in_progress: "in_progress";
246
+ review: "review";
247
+ planned: "planned";
248
+ done: "done";
249
+ }>>>;
250
+ visibility: z.ZodPipe<z.ZodUnknown, z.ZodTransform<"private" | "public", unknown>>;
251
+ answered: z.ZodCatch<z.ZodBoolean>;
252
+ awaitingReply: z.ZodCatch<z.ZodBoolean>;
253
+ unread: z.ZodCatch<z.ZodBoolean>;
254
+ createdAt: z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>;
255
+ lastActivityAt: z.ZodCatch<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>>>;
256
+ }, z.core.$strip>>>>, z.ZodTransform<{
257
+ number: number;
258
+ title: string | null;
259
+ excerpt: string | null;
260
+ status: "new" | "in_progress" | "resolved" | "closed";
261
+ boardStatus: "in_progress" | "review" | "planned" | "done" | null;
262
+ visibility: "private" | "public";
263
+ answered: boolean;
264
+ awaitingReply: boolean;
265
+ unread: boolean;
266
+ createdAt: Date;
267
+ lastActivityAt: Date | null;
268
+ }[], ({
269
+ number: number;
270
+ title: string | null;
271
+ excerpt: string | null;
272
+ status: "new" | "in_progress" | "resolved" | "closed";
273
+ boardStatus: "in_progress" | "review" | "planned" | "done" | null;
274
+ visibility: "private" | "public";
275
+ answered: boolean;
276
+ awaitingReply: boolean;
277
+ unread: boolean;
278
+ createdAt: Date;
279
+ lastActivityAt: Date | null;
280
+ } | null)[]>>>;
281
+ nextCursor: z.ZodCatch<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodNumber, z.ZodTransform<string, number>>]>>>;
282
+ }, z.core.$strip>;
283
+ export declare const unreadSchema: z.ZodObject<{
284
+ count: z.ZodNumber;
285
+ posts: z.ZodCatch<z.ZodPipe<z.ZodArray<z.ZodCatch<z.ZodNullable<z.ZodObject<{
286
+ number: z.ZodNumber;
287
+ title: z.ZodCatch<z.ZodNullable<z.ZodString>>;
288
+ lastAnswerAt: z.ZodCatch<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>>>;
289
+ }, z.core.$strip>>>>, z.ZodTransform<{
290
+ number: number;
291
+ title: string | null;
292
+ lastAnswerAt: Date | null;
293
+ }[], ({
294
+ number: number;
295
+ title: string | null;
296
+ lastAnswerAt: Date | null;
297
+ } | null)[]>>>;
298
+ }, z.core.$strip>;
299
+ export declare const errorSchema: z.ZodObject<{
300
+ error: z.ZodUnion<readonly [z.ZodPipe<z.ZodObject<{
301
+ code: z.ZodString;
302
+ }, z.core.$strip>, z.ZodTransform<string, {
303
+ code: string;
304
+ }>>, z.ZodString]>;
305
+ }, z.core.$strip>;
306
+ export {};
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.errorSchema = exports.unreadSchema = exports.listSchema = exports.createdSchema = exports.detailSchema = exports.entrySchema = exports.summarySchema = exports.siteSchema = exports.BOARD_STATUSES = exports.FEEDBACK_STATUSES = void 0;
4
+ const zod_1 = require("zod");
5
+ // Response schemas for /api/feedback/app/*. Objects strip unknown keys; fields the contract leaves
6
+ // open (meta, roadmap, release) are optional so a richer server never breaks an older app.
7
+ exports.FEEDBACK_STATUSES = ["new", "in_progress", "resolved", "closed"];
8
+ exports.BOARD_STATUSES = ["review", "planned", "in_progress", "done"];
9
+ const ENTRY_KINDS = [
10
+ "answer",
11
+ "followup",
12
+ "comment",
13
+ "status",
14
+ "roadmap_link",
15
+ "release_link",
16
+ "merge",
17
+ "auto_reply",
18
+ "visibility",
19
+ ];
20
+ function compact(items) {
21
+ return items.filter((item) => item !== null);
22
+ }
23
+ /** Keeps the well-formed items of an array and drops the rest instead of failing the response. */
24
+ function lenientList(item) {
25
+ return zod_1.z
26
+ .array(item.nullable().catch(null))
27
+ .transform((items) => compact(items))
28
+ .catch([]);
29
+ }
30
+ const text = zod_1.z.string().trim().min(1);
31
+ const nullableText = text.nullable().catch(null);
32
+ const id = zod_1.z.union([text, zod_1.z.number().transform(String)]);
33
+ const date = zod_1.z.string().transform((value, ctx) => {
34
+ const ms = Date.parse(value);
35
+ if (Number.isFinite(ms))
36
+ return new Date(ms);
37
+ ctx.addIssue({ code: "custom", message: "Invalid date" });
38
+ return zod_1.z.NEVER;
39
+ });
40
+ const nullableDate = date.nullable().catch(null);
41
+ const flag = zod_1.z.boolean().catch(false);
42
+ const status = zod_1.z.enum(exports.FEEDBACK_STATUSES).catch("new");
43
+ const boardStatus = zod_1.z.enum(exports.BOARD_STATUSES).nullable().catch(null);
44
+ const visibility = zod_1.z
45
+ .unknown()
46
+ .transform((value) => (value === "public" || value === "public_board" ? "public" : "private"));
47
+ const mode = zod_1.z.enum(["one_way", "two_way"]).catch("one_way");
48
+ const label = zod_1.z
49
+ .union([zod_1.z.string(), zod_1.z.object({ label: zod_1.z.string() }).transform((value) => value.label)])
50
+ .pipe(zod_1.z.string().trim().min(1).max(40))
51
+ .nullable()
52
+ .catch(null);
53
+ const NO_LABELS = { review: null, planned: null, in_progress: null, done: null };
54
+ exports.siteSchema = zod_1.z.object({
55
+ name: zod_1.z.string().catch(""),
56
+ iconUrl: nullableText,
57
+ accentColor: nullableText,
58
+ mode,
59
+ eligibility: zod_1.z.enum(["anyone", "email", "app_user"]).catch("email"),
60
+ anonymity: zod_1.z.enum(["off", "others", "full"]).catch("others"),
61
+ boards: lenientList(zod_1.z.object({ key: text, name: text })),
62
+ statusLabels: zod_1.z.object({ review: label, planned: label, in_progress: label, done: label }).catch(NO_LABELS),
63
+ autoReplyText: nullableText,
64
+ myPostsEnabled: flag,
65
+ });
66
+ const summaryShape = {
67
+ number: zod_1.z.number().int().positive(),
68
+ title: nullableText,
69
+ excerpt: nullableText,
70
+ status,
71
+ boardStatus,
72
+ visibility,
73
+ answered: flag,
74
+ awaitingReply: flag,
75
+ unread: flag,
76
+ createdAt: date,
77
+ lastActivityAt: nullableDate,
78
+ };
79
+ exports.summarySchema = zod_1.z.object(summaryShape);
80
+ const NO_META = { status: null, boardStatus: null, title: null };
81
+ exports.entrySchema = zod_1.z.object({
82
+ id,
83
+ kind: zod_1.z.string().transform((value) => ENTRY_KINDS.find((kind) => kind === value) ?? "other"),
84
+ body: zod_1.z.string().catch(""),
85
+ createdAt: date,
86
+ author: zod_1.z.enum(["team", "me", "other"]),
87
+ meta: zod_1.z
88
+ .object({
89
+ status: zod_1.z.enum(exports.FEEDBACK_STATUSES).nullable().catch(null),
90
+ boardStatus,
91
+ title: nullableText,
92
+ })
93
+ .catch(NO_META),
94
+ });
95
+ exports.detailSchema = zod_1.z.object({
96
+ ...summaryShape,
97
+ content: zod_1.z.string().catch(""),
98
+ board: nullableText,
99
+ anonymous: flag,
100
+ images: lenientList(zod_1.z.object({
101
+ id,
102
+ width: zod_1.z.number().positive().nullable().catch(null),
103
+ height: zod_1.z.number().positive().nullable().catch(null),
104
+ })),
105
+ mode,
106
+ entries: lenientList(exports.entrySchema),
107
+ roadmap: zod_1.z.object({ title: nullableText, stage: nullableText }).nullable().catch(null),
108
+ release: zod_1.z.object({ title: nullableText, version: nullableText }).nullable().catch(null),
109
+ canFollowUp: flag,
110
+ });
111
+ exports.createdSchema = zod_1.z.object({
112
+ id,
113
+ number: zod_1.z.number().int().positive(),
114
+ title: nullableText,
115
+ status,
116
+ boardStatus,
117
+ visibility,
118
+ createdAt: date,
119
+ receipt: zod_1.z.object({ autoReplyText: nullableText }).catch({ autoReplyText: null }),
120
+ });
121
+ exports.listSchema = zod_1.z.object({
122
+ posts: lenientList(exports.summarySchema),
123
+ nextCursor: id.nullable().catch(null),
124
+ });
125
+ exports.unreadSchema = zod_1.z.object({
126
+ count: zod_1.z.number().int().nonnegative(),
127
+ posts: lenientList(zod_1.z.object({ number: zod_1.z.number().int().positive(), title: nullableText, lastAnswerAt: nullableDate })),
128
+ });
129
+ exports.errorSchema = zod_1.z.object({
130
+ error: zod_1.z.union([zod_1.z.object({ code: zod_1.z.string() }).transform((value) => value.code), zod_1.z.string()]),
131
+ });
@@ -0,0 +1,67 @@
1
+ import { z } from "zod";
2
+ import type { FetchImpl, FormDataLike, XhrLike } from "./client";
3
+ import { createdSchema, detailSchema, entrySchema, listSchema, siteSchema, summarySchema, unreadSchema } from "./posts-schema";
4
+ import type { PostVisibility } from "./posts-schema";
5
+ import type { ClientMetadata, ImageAsset } from "./request";
6
+ export type { BoardStatus, EntryKind, FeedbackStatus, PostVisibility } from "./posts-schema";
7
+ export type AppSite = z.output<typeof siteSchema>;
8
+ export type PostSummary = z.output<typeof summarySchema>;
9
+ export type PostDetail = z.output<typeof detailSchema>;
10
+ export type PostEntry = z.output<typeof entrySchema>;
11
+ export type CreatedPost = z.output<typeof createdSchema>;
12
+ export type PostPage = z.output<typeof listSchema>;
13
+ export type UnreadSummary = z.output<typeof unreadSchema>;
14
+ declare const ERROR_CODES: readonly ["SITE_NOT_FOUND", "VALIDATION_ERROR", "ELIGIBILITY", "ONE_WAY", "CLOSED", "NOT_FOUND", "RATE_LIMITED", "APP_NOT_ALLOWED", "IMAGES_DISABLED", "TOO_MANY_IMAGES", "IMAGE_TOO_LARGE", "INVALID_IMAGE"];
15
+ /** Server codes, plus `REQUEST_FAILED` (other statuses), `INVALID_RESPONSE` and `NETWORK_ERROR`. */
16
+ export type PostsErrorCode = (typeof ERROR_CODES)[number] | "REQUEST_FAILED" | "INVALID_RESPONSE" | "NETWORK_ERROR";
17
+ export type PostsResult<T> = Readonly<{
18
+ ok: true;
19
+ value: T;
20
+ }> | Readonly<{
21
+ ok: false;
22
+ code: PostsErrorCode;
23
+ }>;
24
+ export type CreatePostInput = Readonly<{
25
+ content: string;
26
+ board?: string;
27
+ title?: string;
28
+ visibility?: PostVisibility;
29
+ anonymous?: boolean;
30
+ uid?: string;
31
+ authorName?: string;
32
+ /** `email` for widgets that ask for an email, `text` for a free-text contact (e.g. a Telegram handle). */
33
+ contact?: Readonly<{
34
+ email?: string;
35
+ text?: string;
36
+ }>;
37
+ client?: ClientMetadata;
38
+ screen?: string;
39
+ }>;
40
+ export type ImageSource = Readonly<{
41
+ uri: string;
42
+ headers: Readonly<Record<string, string>>;
43
+ }>;
44
+ export type PostsClientOptions = Readonly<{
45
+ baseUrl?: string;
46
+ /** The `fbw_` widget key. */
47
+ publicKey: string;
48
+ appId: string;
49
+ /** Per-install bearer secret from `getOrCreateAuthorToken`, sent as `X-Devstage-Author`. */
50
+ authorToken: string;
51
+ fetch?: FetchImpl;
52
+ FormDataImpl?: new () => FormDataLike;
53
+ XMLHttpRequestImpl?: (new () => XhrLike) | undefined;
54
+ }>;
55
+ export interface PostsClient {
56
+ getSite(): Promise<PostsResult<AppSite>>;
57
+ createPost(input: CreatePostInput, images?: readonly ImageAsset[]): Promise<PostsResult<CreatedPost>>;
58
+ listMyPosts(cursor?: string): Promise<PostsResult<PostPage>>;
59
+ getPost(number: number): Promise<PostsResult<PostDetail>>;
60
+ addFollowUp(number: number, body: string): Promise<PostsResult<PostEntry>>;
61
+ getUnread(): Promise<PostsResult<UnreadSummary>>;
62
+ /** `Image` source for an attachment of my post; the image route needs the author header too. */
63
+ imageSource(number: number, imageId: string): ImageSource;
64
+ }
65
+ export declare const AUTHOR_HEADER = "X-Devstage-Author";
66
+ export declare const MAX_FOLLOW_UP = 2000;
67
+ export declare function createPostsClient(options: PostsClientOptions): PostsClient;