@thewhateverapp/platform 0.0.1 → 0.0.2

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.
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Client runtime exports
3
+ *
4
+ * Services and utilities for client-side applications (mobile, web, etc.)
5
+ * These do not require Cloudflare Workers edge runtime.
6
+ */
7
+ export { TileStateClient } from './tile-state';
8
+ export type * from './tile-state/types';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,mBAAmB,oBAAoB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Client runtime exports
3
+ *
4
+ * Services and utilities for client-side applications (mobile, web, etc.)
5
+ * These do not require Cloudflare Workers edge runtime.
6
+ */
7
+ // Tile State (Durable Objects) client
8
+ export { TileStateClient } from './tile-state';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,sCAAsC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,187 @@
1
+ /**
2
+ * Tile State HTTP REST Client
3
+ *
4
+ * Client library for interacting with TileState Durable Objects via HTTP from mobile/web apps
5
+ */
6
+ import type { Comment, Report, TileStateClientConfig } from './types';
7
+ /**
8
+ * TileState REST Client
9
+ *
10
+ * HTTP client for calling TileState Durable Objects from mobile/web applications.
11
+ * This client uses the REST API and does not require Cloudflare Workers edge runtime.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * import { TileStateClient } from '@thewhateverapp/platform/client';
16
+ *
17
+ * const client = new TileStateClient();
18
+ *
19
+ * // Get comments for a tile app
20
+ * const comments = await client.getComments('app-123');
21
+ *
22
+ * // Add a comment
23
+ * const comment = await client.addComment('app-123', {
24
+ * userId: 'user-456',
25
+ * userName: 'Alice',
26
+ * text: 'Great app!'
27
+ * });
28
+ * ```
29
+ */
30
+ export declare class TileStateClient {
31
+ private baseUrl;
32
+ private fetch;
33
+ private timeout;
34
+ constructor(config?: TileStateClientConfig);
35
+ /**
36
+ * Make an HTTP request with timeout and error handling
37
+ */
38
+ private request;
39
+ /**
40
+ * Get all comments for a tile app
41
+ *
42
+ * @param appId - The unique ID of the tile app
43
+ * @returns Array of comments
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * const comments = await client.getComments('app-123');
48
+ * console.log(comments); // [{ id, userId, userName, text, timestamp }, ...]
49
+ * ```
50
+ */
51
+ getComments(appId: string): Promise<Comment[]>;
52
+ /**
53
+ * Add a comment to a tile app
54
+ *
55
+ * @param appId - The unique ID of the tile app
56
+ * @param comment - Comment data (without id and timestamp)
57
+ * @returns The created comment with id and timestamp
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * const comment = await client.addComment('app-123', {
62
+ * userId: 'user-456',
63
+ * userName: 'Alice',
64
+ * text: 'Great app!'
65
+ * });
66
+ * ```
67
+ */
68
+ addComment(appId: string, comment: Omit<Comment, 'id' | 'timestamp'>): Promise<Comment>;
69
+ /**
70
+ * Delete a comment from a tile app
71
+ *
72
+ * @param appId - The unique ID of the tile app
73
+ * @param commentId - The ID of the comment to delete
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * await client.deleteComment('app-123', 'comment-789');
78
+ * ```
79
+ */
80
+ deleteComment(appId: string, commentId: string): Promise<void>;
81
+ /**
82
+ * Get the total number of likes for a tile app
83
+ *
84
+ * @param appId - The unique ID of the tile app
85
+ * @returns The total like count
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * const count = await client.getLikes('app-123');
90
+ * console.log(count); // 42
91
+ * ```
92
+ */
93
+ getLikes(appId: string): Promise<number>;
94
+ /**
95
+ * Toggle like for a user on a tile app
96
+ *
97
+ * If the user has already liked, this will unlike.
98
+ * If the user hasn't liked, this will like.
99
+ *
100
+ * @param appId - The unique ID of the tile app
101
+ * @param userId - The ID of the user toggling the like
102
+ * @returns Object with total count and whether user liked or unliked
103
+ *
104
+ * @example
105
+ * ```typescript
106
+ * const result = await client.toggleLike('app-123', 'user-456');
107
+ * console.log(result); // { count: 43, liked: true }
108
+ * ```
109
+ */
110
+ toggleLike(appId: string, userId: string): Promise<{
111
+ count: number;
112
+ liked: boolean;
113
+ }>;
114
+ /**
115
+ * Get all reports for a tile app (moderators only in production)
116
+ *
117
+ * @param appId - The unique ID of the tile app
118
+ * @returns Array of reports
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * const reports = await client.getReports('app-123');
123
+ * console.log(reports); // [{ id, reportedBy, reason, details, timestamp }, ...]
124
+ * ```
125
+ */
126
+ getReports(appId: string): Promise<Report[]>;
127
+ /**
128
+ * Report content for moderation
129
+ *
130
+ * @param appId - The unique ID of the tile app
131
+ * @param report - Report data (without id and timestamp)
132
+ * @returns The created report with id and timestamp
133
+ *
134
+ * @example
135
+ * ```typescript
136
+ * const report = await client.reportContent('app-123', {
137
+ * reportedBy: 'user-456',
138
+ * reason: 'Inappropriate content',
139
+ * details: 'Contains spam links'
140
+ * });
141
+ * ```
142
+ */
143
+ reportContent(appId: string, report: Omit<Report, 'id' | 'timestamp'>): Promise<Report>;
144
+ /**
145
+ * Get custom app-specific state
146
+ *
147
+ * @param appId - The unique ID of the tile app
148
+ * @returns The custom state object
149
+ *
150
+ * @example
151
+ * ```typescript
152
+ * const state = await client.getState<{ score: number }>('app-123');
153
+ * console.log(state); // { score: 1000 }
154
+ * ```
155
+ */
156
+ getState<T = any>(appId: string): Promise<T>;
157
+ /**
158
+ * Update custom app-specific state
159
+ *
160
+ * This will merge with existing state, not replace it entirely.
161
+ *
162
+ * @param appId - The unique ID of the tile app
163
+ * @param state - State object to merge
164
+ *
165
+ * @example
166
+ * ```typescript
167
+ * await client.setState('app-123', {
168
+ * score: 1000,
169
+ * level: 5
170
+ * });
171
+ * ```
172
+ */
173
+ setState(appId: string, state: Record<string, any>): Promise<void>;
174
+ /**
175
+ * Clear all custom state for a tile app
176
+ *
177
+ * @param appId - The unique ID of the tile app
178
+ *
179
+ * @example
180
+ * ```typescript
181
+ * await client.clearState('app-123');
182
+ * ```
183
+ */
184
+ clearState(appId: string): Promise<void>;
185
+ }
186
+ export type { Comment, Report, TileStateClientConfig, AddCommentResponse, GetCommentsResponse, GetLikesResponse, ToggleLikeResponse, AddReportResponse, GetReportsResponse, GetStateResponse, SetStateResponse, TileStateErrorResponse, } from './types';
187
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/tile-state/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,OAAO,EACP,MAAM,EACN,qBAAqB,EAUtB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,GAAE,qBAA0B;IAM9C;;OAEG;YACW,OAAO;IAwCrB;;;;;;;;;;;OAWG;IACG,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAKpD;;;;;;;;;;;;;;;OAeG;IACG,UAAU,CACd,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,GAAG,WAAW,CAAC,GACzC,OAAO,CAAC,OAAO,CAAC;IASnB;;;;;;;;;;OAUG;IACG,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUpE;;;;;;;;;;;OAWG;IACG,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAK9C;;;;;;;;;;;;;;;OAeG;IACG,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;IAU3F;;;;;;;;;;;OAWG;IACG,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAKlD;;;;;;;;;;;;;;;OAeG;IACG,aAAa,CACjB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,WAAW,CAAC,GACvC,OAAO,CAAC,MAAM,CAAC;IAWlB;;;;;;;;;;;OAWG;IACG,QAAQ,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAKlD;;;;;;;;;;;;;;;OAeG;IACG,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAQxE;;;;;;;;;OASG;IACG,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAK/C;AAGD,YAAY,EACV,OAAO,EACP,MAAM,EACN,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,264 @@
1
+ /**
2
+ * Tile State HTTP REST Client
3
+ *
4
+ * Client library for interacting with TileState Durable Objects via HTTP from mobile/web apps
5
+ */
6
+ /**
7
+ * TileState REST Client
8
+ *
9
+ * HTTP client for calling TileState Durable Objects from mobile/web applications.
10
+ * This client uses the REST API and does not require Cloudflare Workers edge runtime.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { TileStateClient } from '@thewhateverapp/platform/client';
15
+ *
16
+ * const client = new TileStateClient();
17
+ *
18
+ * // Get comments for a tile app
19
+ * const comments = await client.getComments('app-123');
20
+ *
21
+ * // Add a comment
22
+ * const comment = await client.addComment('app-123', {
23
+ * userId: 'user-456',
24
+ * userName: 'Alice',
25
+ * text: 'Great app!'
26
+ * });
27
+ * ```
28
+ */
29
+ export class TileStateClient {
30
+ baseUrl;
31
+ fetch;
32
+ timeout;
33
+ constructor(config = {}) {
34
+ this.baseUrl = config.baseUrl || 'https://state.thewhatever.app';
35
+ this.fetch = config.fetch || globalThis.fetch;
36
+ this.timeout = config.timeout || 10000;
37
+ }
38
+ /**
39
+ * Make an HTTP request with timeout and error handling
40
+ */
41
+ async request(endpoint, appId, options = {}) {
42
+ const controller = new AbortController();
43
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
44
+ try {
45
+ const url = `${this.baseUrl}${endpoint}?appId=${encodeURIComponent(appId)}`;
46
+ const response = await this.fetch(url, {
47
+ ...options,
48
+ signal: controller.signal,
49
+ });
50
+ clearTimeout(timeoutId);
51
+ if (!response.ok) {
52
+ const error = await response.json().catch(() => ({
53
+ error: 'Unknown error',
54
+ message: response.statusText,
55
+ }));
56
+ throw new Error(error.message || error.error || `HTTP ${response.status}`);
57
+ }
58
+ return await response.json();
59
+ }
60
+ catch (error) {
61
+ clearTimeout(timeoutId);
62
+ if (error instanceof Error && error.name === 'AbortError') {
63
+ throw new Error(`Request timeout after ${this.timeout}ms`);
64
+ }
65
+ throw error;
66
+ }
67
+ }
68
+ // ==================== Comments API ====================
69
+ /**
70
+ * Get all comments for a tile app
71
+ *
72
+ * @param appId - The unique ID of the tile app
73
+ * @returns Array of comments
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * const comments = await client.getComments('app-123');
78
+ * console.log(comments); // [{ id, userId, userName, text, timestamp }, ...]
79
+ * ```
80
+ */
81
+ async getComments(appId) {
82
+ const response = await this.request('/comments', appId);
83
+ return response.comments;
84
+ }
85
+ /**
86
+ * Add a comment to a tile app
87
+ *
88
+ * @param appId - The unique ID of the tile app
89
+ * @param comment - Comment data (without id and timestamp)
90
+ * @returns The created comment with id and timestamp
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * const comment = await client.addComment('app-123', {
95
+ * userId: 'user-456',
96
+ * userName: 'Alice',
97
+ * text: 'Great app!'
98
+ * });
99
+ * ```
100
+ */
101
+ async addComment(appId, comment) {
102
+ const response = await this.request('/comments', appId, {
103
+ method: 'POST',
104
+ headers: { 'Content-Type': 'application/json' },
105
+ body: JSON.stringify(comment),
106
+ });
107
+ return response.comment;
108
+ }
109
+ /**
110
+ * Delete a comment from a tile app
111
+ *
112
+ * @param appId - The unique ID of the tile app
113
+ * @param commentId - The ID of the comment to delete
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * await client.deleteComment('app-123', 'comment-789');
118
+ * ```
119
+ */
120
+ async deleteComment(appId, commentId) {
121
+ await this.request('/comments', appId, {
122
+ method: 'DELETE',
123
+ headers: { 'Content-Type': 'application/json' },
124
+ body: JSON.stringify({ id: commentId }),
125
+ });
126
+ }
127
+ // ==================== Likes API ====================
128
+ /**
129
+ * Get the total number of likes for a tile app
130
+ *
131
+ * @param appId - The unique ID of the tile app
132
+ * @returns The total like count
133
+ *
134
+ * @example
135
+ * ```typescript
136
+ * const count = await client.getLikes('app-123');
137
+ * console.log(count); // 42
138
+ * ```
139
+ */
140
+ async getLikes(appId) {
141
+ const response = await this.request('/likes', appId);
142
+ return response.count;
143
+ }
144
+ /**
145
+ * Toggle like for a user on a tile app
146
+ *
147
+ * If the user has already liked, this will unlike.
148
+ * If the user hasn't liked, this will like.
149
+ *
150
+ * @param appId - The unique ID of the tile app
151
+ * @param userId - The ID of the user toggling the like
152
+ * @returns Object with total count and whether user liked or unliked
153
+ *
154
+ * @example
155
+ * ```typescript
156
+ * const result = await client.toggleLike('app-123', 'user-456');
157
+ * console.log(result); // { count: 43, liked: true }
158
+ * ```
159
+ */
160
+ async toggleLike(appId, userId) {
161
+ return await this.request('/likes', appId, {
162
+ method: 'POST',
163
+ headers: { 'Content-Type': 'application/json' },
164
+ body: JSON.stringify({ userId }),
165
+ });
166
+ }
167
+ // ==================== Reports API ====================
168
+ /**
169
+ * Get all reports for a tile app (moderators only in production)
170
+ *
171
+ * @param appId - The unique ID of the tile app
172
+ * @returns Array of reports
173
+ *
174
+ * @example
175
+ * ```typescript
176
+ * const reports = await client.getReports('app-123');
177
+ * console.log(reports); // [{ id, reportedBy, reason, details, timestamp }, ...]
178
+ * ```
179
+ */
180
+ async getReports(appId) {
181
+ const response = await this.request('/reports', appId);
182
+ return response.reports;
183
+ }
184
+ /**
185
+ * Report content for moderation
186
+ *
187
+ * @param appId - The unique ID of the tile app
188
+ * @param report - Report data (without id and timestamp)
189
+ * @returns The created report with id and timestamp
190
+ *
191
+ * @example
192
+ * ```typescript
193
+ * const report = await client.reportContent('app-123', {
194
+ * reportedBy: 'user-456',
195
+ * reason: 'Inappropriate content',
196
+ * details: 'Contains spam links'
197
+ * });
198
+ * ```
199
+ */
200
+ async reportContent(appId, report) {
201
+ const response = await this.request('/reports', appId, {
202
+ method: 'POST',
203
+ headers: { 'Content-Type': 'application/json' },
204
+ body: JSON.stringify(report),
205
+ });
206
+ return response.report;
207
+ }
208
+ // ==================== Custom State API ====================
209
+ /**
210
+ * Get custom app-specific state
211
+ *
212
+ * @param appId - The unique ID of the tile app
213
+ * @returns The custom state object
214
+ *
215
+ * @example
216
+ * ```typescript
217
+ * const state = await client.getState<{ score: number }>('app-123');
218
+ * console.log(state); // { score: 1000 }
219
+ * ```
220
+ */
221
+ async getState(appId) {
222
+ const response = await this.request('/state', appId);
223
+ return response.state;
224
+ }
225
+ /**
226
+ * Update custom app-specific state
227
+ *
228
+ * This will merge with existing state, not replace it entirely.
229
+ *
230
+ * @param appId - The unique ID of the tile app
231
+ * @param state - State object to merge
232
+ *
233
+ * @example
234
+ * ```typescript
235
+ * await client.setState('app-123', {
236
+ * score: 1000,
237
+ * level: 5
238
+ * });
239
+ * ```
240
+ */
241
+ async setState(appId, state) {
242
+ await this.request('/state', appId, {
243
+ method: 'PUT',
244
+ headers: { 'Content-Type': 'application/json' },
245
+ body: JSON.stringify(state),
246
+ });
247
+ }
248
+ /**
249
+ * Clear all custom state for a tile app
250
+ *
251
+ * @param appId - The unique ID of the tile app
252
+ *
253
+ * @example
254
+ * ```typescript
255
+ * await client.clearState('app-123');
256
+ * ```
257
+ */
258
+ async clearState(appId) {
259
+ await this.request('/state', appId, {
260
+ method: 'DELETE',
261
+ });
262
+ }
263
+ }
264
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/tile-state/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiBH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,eAAe;IAClB,OAAO,CAAS;IAChB,KAAK,CAAe;IACpB,OAAO,CAAS;IAExB,YAAY,SAAgC,EAAE;QAC5C,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,+BAA+B,CAAC;QACjE,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC;QAC9C,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,KAAK,CAAC;IACzC,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,OAAO,CACnB,QAAgB,EAChB,KAAa,EACb,UAAuB,EAAE;QAEzB,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;QACzC,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAErE,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,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P REST client
5
+ */
6
+ /**
7
+ * Comment data structure
8
+ */
9
+ export interface Comment {
10
+ id: string;
11
+ userId: string;
12
+ userName: string;
13
+ text: string;
14
+ timestamp: number;
15
+ }
16
+ /**
17
+ * Report data structure
18
+ */
19
+ export interface Report {
20
+ id: string;
21
+ reportedBy: string;
22
+ reason: string;
23
+ details?: string;
24
+ timestamp: number;
25
+ }
26
+ /**
27
+ * Configuration options for TileStateClient
28
+ */
29
+ export interface TileStateClientConfig {
30
+ /**
31
+ * Base URL for the TileState Durable Object worker
32
+ * @default 'https://state.thewhatever.app'
33
+ */
34
+ baseUrl?: string;
35
+ /**
36
+ * Custom fetch implementation (useful for React Native, testing, etc.)
37
+ * @default global fetch
38
+ */
39
+ fetch?: typeof fetch;
40
+ /**
41
+ * Request timeout in milliseconds
42
+ * @default 10000 (10 seconds)
43
+ */
44
+ timeout?: number;
45
+ }
46
+ /**
47
+ * Response from adding a comment
48
+ */
49
+ export interface AddCommentResponse {
50
+ success: true;
51
+ comment: Comment;
52
+ }
53
+ /**
54
+ * Response from getting comments
55
+ */
56
+ export interface GetCommentsResponse {
57
+ comments: Comment[];
58
+ }
59
+ /**
60
+ * Response from getting likes
61
+ */
62
+ export interface GetLikesResponse {
63
+ count: number;
64
+ }
65
+ /**
66
+ * Response from toggling a like
67
+ */
68
+ export interface ToggleLikeResponse {
69
+ count: number;
70
+ liked: boolean;
71
+ }
72
+ /**
73
+ * Response from adding a report
74
+ */
75
+ export interface AddReportResponse {
76
+ success: true;
77
+ report: Report;
78
+ }
79
+ /**
80
+ * Response from getting reports
81
+ */
82
+ export interface GetReportsResponse {
83
+ reports: Report[];
84
+ }
85
+ /**
86
+ * Response from getting custom state
87
+ */
88
+ export interface GetStateResponse<T = any> {
89
+ state: T;
90
+ }
91
+ /**
92
+ * Response from setting custom state
93
+ */
94
+ export interface SetStateResponse<T = any> {
95
+ success: true;
96
+ state: T;
97
+ }
98
+ /**
99
+ * Error response from TileState API
100
+ */
101
+ export interface TileStateErrorResponse {
102
+ error: string;
103
+ message?: string;
104
+ }
105
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/client/tile-state/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IAErB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,IAAI,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,IAAI,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,GAAG;IACvC,KAAK,EAAE,CAAC,CAAC;CACV;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,GAAG;IACvC,OAAO,EAAE,IAAI,CAAC;IACd,KAAK,EAAE,CAAC,CAAC;CACV;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Tile State Client Types
3
+ *
4
+ * Type definitions for the TileState HTTP REST client
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/client/tile-state/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -9,4 +9,6 @@ export { getKV, createKV } from './kv';
9
9
  export type * from './kv/types';
10
10
  export { getStorage, createStorage } from './storage';
11
11
  export type * from './storage/types';
12
+ export { getTileState } from './tile-state';
13
+ export type * from './tile-state/types';
12
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/edge/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACzD,mBAAmB,kBAAkB,CAAC;AAGtC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACvC,mBAAmB,YAAY,CAAC;AAGhC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACtD,mBAAmB,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/edge/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACzD,mBAAmB,kBAAkB,CAAC;AAGtC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACvC,mBAAmB,YAAY,CAAC;AAGhC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACtD,mBAAmB,iBAAiB,CAAC;AAGrC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,mBAAmB,oBAAoB,CAAC"}
@@ -9,4 +9,6 @@ export { getDatabase, createDatabase } from './database';
9
9
  export { getKV, createKV } from './kv';
10
10
  // Storage (Object Storage / R2) exports
11
11
  export { getStorage, createStorage } from './storage';
12
+ // Tile State (Durable Objects) exports
13
+ export { getTileState } from './tile-state';
12
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/edge/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,mBAAmB;AACnB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGzD,yBAAyB;AACzB,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAGvC,wCAAwC;AACxC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/edge/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,mBAAmB;AACnB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGzD,yBAAyB;AACzB,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAGvC,wCAAwC;AACxC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAGtD,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Tile State SDK
3
+ *
4
+ * Client library for interacting with TileState Durable Objects from user apps
5
+ */
6
+ import type { TileStateProvider, TileStateRequest } from './types';
7
+ /**
8
+ * Get TileState provider instance for the current app
9
+ *
10
+ * @param req - NextRequest or request with env binding
11
+ * @returns TileStateProvider instance
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * import { getTileState } from '@thewhateverapp/platform/edge';
16
+ *
17
+ * export async function GET(req: NextRequest) {
18
+ * const tileState = await getTileState(req);
19
+ * const comments = await tileState.getComments();
20
+ * return NextResponse.json({ comments });
21
+ * }
22
+ * ```
23
+ */
24
+ export declare function getTileState(req: TileStateRequest | any): Promise<TileStateProvider>;
25
+ export type { TileStateProvider, TileStateRequest, TileStateEnv, Comment, Report, } from './types';
26
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/edge/tile-state/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAGjB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,gBAAgB,GAAG,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAkB1F;AAsHD,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,MAAM,GACP,MAAM,SAAS,CAAC"}
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Tile State SDK
3
+ *
4
+ * Client library for interacting with TileState Durable Objects from user apps
5
+ */
6
+ /**
7
+ * Get TileState provider instance for the current app
8
+ *
9
+ * @param req - NextRequest or request with env binding
10
+ * @returns TileStateProvider instance
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { getTileState } from '@thewhateverapp/platform/edge';
15
+ *
16
+ * export async function GET(req: NextRequest) {
17
+ * const tileState = await getTileState(req);
18
+ * const comments = await tileState.getComments();
19
+ * return NextResponse.json({ comments });
20
+ * }
21
+ * ```
22
+ */
23
+ export async function getTileState(req) {
24
+ const env = req.env;
25
+ if (!env || !env.TILE_STATE) {
26
+ throw new Error('TILE_STATE binding not found in environment');
27
+ }
28
+ const appId = env.APP_ID;
29
+ if (!appId) {
30
+ throw new Error('APP_ID not found in environment');
31
+ }
32
+ // Get Durable Object ID from app ID (deterministic)
33
+ const doId = env.TILE_STATE.idFromName(appId);
34
+ const stub = env.TILE_STATE.get(doId);
35
+ return createTileStateProvider(stub);
36
+ }
37
+ /**
38
+ * Create a TileStateProvider instance from a DO stub
39
+ */
40
+ function createTileStateProvider(stub) {
41
+ return {
42
+ async getComments() {
43
+ const res = await stub.fetch('http://do/comments');
44
+ const data = await res.json();
45
+ return data.comments;
46
+ },
47
+ async addComment(comment) {
48
+ const res = await stub.fetch('http://do/comments', {
49
+ method: 'POST',
50
+ headers: { 'Content-Type': 'application/json' },
51
+ body: JSON.stringify(comment),
52
+ });
53
+ if (!res.ok) {
54
+ const error = await res.text();
55
+ throw new Error(`Failed to add comment: ${error}`);
56
+ }
57
+ const data = await res.json();
58
+ return data.comment;
59
+ },
60
+ async deleteComment(id) {
61
+ const res = await stub.fetch('http://do/comments', {
62
+ method: 'DELETE',
63
+ headers: { 'Content-Type': 'application/json' },
64
+ body: JSON.stringify({ id }),
65
+ });
66
+ if (!res.ok) {
67
+ const error = await res.text();
68
+ throw new Error(`Failed to delete comment: ${error}`);
69
+ }
70
+ },
71
+ async getLikes() {
72
+ const res = await stub.fetch('http://do/likes');
73
+ const data = await res.json();
74
+ return data.count;
75
+ },
76
+ async toggleLike(userId) {
77
+ const res = await stub.fetch('http://do/likes', {
78
+ method: 'POST',
79
+ headers: { 'Content-Type': 'application/json' },
80
+ body: JSON.stringify({ userId }),
81
+ });
82
+ if (!res.ok) {
83
+ const error = await res.text();
84
+ throw new Error(`Failed to toggle like: ${error}`);
85
+ }
86
+ return await res.json();
87
+ },
88
+ async getReports() {
89
+ const res = await stub.fetch('http://do/reports');
90
+ const data = await res.json();
91
+ return data.reports;
92
+ },
93
+ async reportContent(report) {
94
+ const res = await stub.fetch('http://do/reports', {
95
+ method: 'POST',
96
+ headers: { 'Content-Type': 'application/json' },
97
+ body: JSON.stringify(report),
98
+ });
99
+ if (!res.ok) {
100
+ const error = await res.text();
101
+ throw new Error(`Failed to report content: ${error}`);
102
+ }
103
+ const data = await res.json();
104
+ return data.report;
105
+ },
106
+ async getState() {
107
+ const res = await stub.fetch('http://do/state');
108
+ const data = await res.json();
109
+ return data.state;
110
+ },
111
+ async setState(state) {
112
+ const res = await stub.fetch('http://do/state', {
113
+ method: 'PUT',
114
+ headers: { 'Content-Type': 'application/json' },
115
+ body: JSON.stringify(state),
116
+ });
117
+ if (!res.ok) {
118
+ const error = await res.text();
119
+ throw new Error(`Failed to set state: ${error}`);
120
+ }
121
+ },
122
+ async clearState() {
123
+ const res = await stub.fetch('http://do/state', {
124
+ method: 'DELETE',
125
+ });
126
+ if (!res.ok) {
127
+ const error = await res.text();
128
+ throw new Error(`Failed to clear state: ${error}`);
129
+ }
130
+ },
131
+ };
132
+ }
133
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/edge/tile-state/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAA2B;IAC5D,MAAM,GAAG,GAAI,GAAW,CAAC,GAAG,CAAC;IAE7B,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACjE,CAAC;IAED,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC;IAEzB,IAAI,CAAC,KAAK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KAAK,EAAE,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;QAED,KAAK,CAAC,UAAU;YACd,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE;gBAC9C,MAAM,EAAE,QAAQ;aACjB,CAAC,CAAC;YAEH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;gBACZ,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;gBAC/B,MAAM,IAAI,KAAK,CAAC,0BAA0B,KAAK,EAAE,CAAC,CAAC;YACrD,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Tile State types and interfaces
3
+ *
4
+ * Type definitions for interacting with TileState Durable Objects
5
+ */
6
+ /**
7
+ * Comment data structure
8
+ */
9
+ export interface Comment {
10
+ id: string;
11
+ userId: string;
12
+ userName: string;
13
+ text: string;
14
+ timestamp: number;
15
+ }
16
+ /**
17
+ * Report data structure
18
+ */
19
+ export interface Report {
20
+ id: string;
21
+ reportedBy: string;
22
+ reason: string;
23
+ details?: string;
24
+ timestamp: number;
25
+ }
26
+ /**
27
+ * TileState provider interface
28
+ *
29
+ * Provides methods for interacting with the TileState Durable Object
30
+ */
31
+ export interface TileStateProvider {
32
+ /**
33
+ * Get all comments for this tile
34
+ */
35
+ getComments(): Promise<Comment[]>;
36
+ /**
37
+ * Add a new comment
38
+ */
39
+ addComment(comment: Omit<Comment, 'id' | 'timestamp'>): Promise<Comment>;
40
+ /**
41
+ * Delete a comment by ID
42
+ */
43
+ deleteComment(id: string): Promise<void>;
44
+ /**
45
+ * Get the total number of likes
46
+ */
47
+ getLikes(): Promise<number>;
48
+ /**
49
+ * Toggle like for a user (like if not liked, unlike if already liked)
50
+ */
51
+ toggleLike(userId: string): Promise<{
52
+ count: number;
53
+ liked: boolean;
54
+ }>;
55
+ /**
56
+ * Get all reports (moderators only in production)
57
+ */
58
+ getReports(): Promise<Report[]>;
59
+ /**
60
+ * Report content for moderation
61
+ */
62
+ reportContent(report: Omit<Report, 'id' | 'timestamp'>): Promise<Report>;
63
+ /**
64
+ * Get custom app-specific state
65
+ */
66
+ getState<T = any>(): Promise<T>;
67
+ /**
68
+ * Update custom app-specific state
69
+ */
70
+ setState(state: Record<string, any>): Promise<void>;
71
+ /**
72
+ * Clear all custom state
73
+ */
74
+ clearState(): Promise<void>;
75
+ }
76
+ /**
77
+ * Cloudflare environment interface for TileState
78
+ */
79
+ export interface TileStateEnv {
80
+ TILE_STATE: DurableObjectNamespace;
81
+ APP_ID?: string;
82
+ }
83
+ /**
84
+ * Request wrapper for NextRequest compatibility
85
+ */
86
+ export interface TileStateRequest {
87
+ env: TileStateEnv;
88
+ }
89
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/edge/tile-state/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,WAAW,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAElC;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,GAAG,WAAW,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEzE;;OAEG;IACH,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzC;;OAEG;IACH,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAE5B;;OAEG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAEvE;;OAEG;IACH,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAEhC;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,WAAW,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEzE;;OAEG;IACH,QAAQ,CAAC,CAAC,GAAG,GAAG,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IAEhC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpD;;OAEG;IACH,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,sBAAsB,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,YAAY,CAAC;CACnB"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Tile State types and interfaces
3
+ *
4
+ * Type definitions for interacting with TileState Durable Objects
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/edge/tile-state/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thewhateverapp/platform",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Universal SDK for The Whatever App platform services",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -13,6 +13,10 @@
13
13
  "./edge": {
14
14
  "types": "./dist/edge/index.d.ts",
15
15
  "import": "./dist/edge/index.js"
16
+ },
17
+ "./client": {
18
+ "types": "./dist/client/index.d.ts",
19
+ "import": "./dist/client/index.js"
16
20
  }
17
21
  },
18
22
  "files": [