@thewhateverapp/platform 0.0.1 → 0.0.3
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.
- package/dist/client/auth/index.d.ts +76 -0
- package/dist/client/auth/index.d.ts.map +1 -0
- package/dist/client/auth/index.js +130 -0
- package/dist/client/auth/index.js.map +1 -0
- package/dist/client/auth/types.d.ts +52 -0
- package/dist/client/auth/types.d.ts.map +1 -0
- package/dist/client/auth/types.js +7 -0
- package/dist/client/auth/types.js.map +1 -0
- package/dist/client/index.d.ts +11 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +11 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/tile-state/index.d.ts +187 -0
- package/dist/client/tile-state/index.d.ts.map +1 -0
- package/dist/client/tile-state/index.js +264 -0
- package/dist/client/tile-state/index.js.map +1 -0
- package/dist/client/tile-state/types.d.ts +105 -0
- package/dist/client/tile-state/types.d.ts.map +1 -0
- package/dist/client/tile-state/types.js +7 -0
- package/dist/client/tile-state/types.js.map +1 -0
- package/dist/edge/index.d.ts +2 -0
- package/dist/edge/index.d.ts.map +1 -1
- package/dist/edge/index.js +2 -0
- package/dist/edge/index.js.map +1 -1
- package/dist/edge/tile-state/index.d.ts +26 -0
- package/dist/edge/tile-state/index.d.ts.map +1 -0
- package/dist/edge/tile-state/index.js +133 -0
- package/dist/edge/tile-state/index.js.map +1 -0
- package/dist/edge/tile-state/types.d.ts +89 -0
- package/dist/edge/tile-state/types.d.ts.map +1 -0
- package/dist/edge/tile-state/types.js +7 -0
- package/dist/edge/tile-state/types.js.map +1 -0
- package/package.json +5 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mobile Authentication Client
|
|
3
|
+
*
|
|
4
|
+
* Client for React Native apps to authenticate users with platform-api
|
|
5
|
+
*/
|
|
6
|
+
import type { AuthResponse, GoogleAuthRequest, TwitterAuthRequest, RefreshTokenResponse, DeviceRegistrationRequest, InviteValidationResult } from './types';
|
|
7
|
+
export interface MobileAuthClientConfig {
|
|
8
|
+
apiUrl?: string;
|
|
9
|
+
fetch?: typeof fetch;
|
|
10
|
+
timeout?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare class MobileAuthClient {
|
|
13
|
+
private apiUrl;
|
|
14
|
+
private fetchFn;
|
|
15
|
+
private timeout;
|
|
16
|
+
constructor(config?: MobileAuthClientConfig);
|
|
17
|
+
/**
|
|
18
|
+
* Make authenticated request with timeout
|
|
19
|
+
*/
|
|
20
|
+
private request;
|
|
21
|
+
/**
|
|
22
|
+
* Login with Google (supports both mobile and web tokens)
|
|
23
|
+
*/
|
|
24
|
+
loginWithGoogle(request: GoogleAuthRequest): Promise<AuthResponse>;
|
|
25
|
+
/**
|
|
26
|
+
* Login with Twitter
|
|
27
|
+
*/
|
|
28
|
+
loginWithTwitter(request: TwitterAuthRequest): Promise<AuthResponse>;
|
|
29
|
+
/**
|
|
30
|
+
* Refresh JWT token
|
|
31
|
+
* Call this periodically (e.g., on app launch) to keep session alive
|
|
32
|
+
*/
|
|
33
|
+
refreshToken(currentToken: string): Promise<RefreshTokenResponse>;
|
|
34
|
+
/**
|
|
35
|
+
* Register device for push notifications
|
|
36
|
+
*/
|
|
37
|
+
registerDevice(token: string, request: DeviceRegistrationRequest): Promise<{
|
|
38
|
+
success: boolean;
|
|
39
|
+
}>;
|
|
40
|
+
/**
|
|
41
|
+
* Remove device registration (call on logout)
|
|
42
|
+
*/
|
|
43
|
+
removeDevice(token: string, deviceId: string): Promise<{
|
|
44
|
+
success: boolean;
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* Validate invite code before signup
|
|
48
|
+
*/
|
|
49
|
+
validateInvite(code: string): Promise<InviteValidationResult>;
|
|
50
|
+
/**
|
|
51
|
+
* Get current user profile
|
|
52
|
+
*/
|
|
53
|
+
getCurrentUser(token: string): Promise<AuthResponse['user']>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Custom error class for authentication errors
|
|
57
|
+
*/
|
|
58
|
+
export declare class AuthError extends Error {
|
|
59
|
+
code: string;
|
|
60
|
+
status: number;
|
|
61
|
+
constructor(message: string, code: string, status: number);
|
|
62
|
+
/**
|
|
63
|
+
* Check if error is due to expired token
|
|
64
|
+
*/
|
|
65
|
+
isTokenExpired(): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Check if error is due to invalid invite code
|
|
68
|
+
*/
|
|
69
|
+
isInvalidInvite(): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Check if error is network-related (retry-able)
|
|
72
|
+
*/
|
|
73
|
+
isNetworkError(): boolean;
|
|
74
|
+
}
|
|
75
|
+
export type * from './types';
|
|
76
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/auth/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,yBAAyB,EACzB,sBAAsB,EAEvB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,sBAAsB;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,GAAE,sBAA2B;IAM/C;;OAEG;YACW,OAAO;IAuDrB;;OAEG;IACG,eAAe,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC;IAQxE;;OAEG;IACG,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC;IAQ1E;;;OAGG;IACG,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IASvE;;OAEG;IACG,cAAc,CAClB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAShC;;OAEG;IACG,YAAY,CAChB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAShC;;OAEG;IACG,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAQnE;;OAEG;IACG,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;CASnE;AAED;;GAEG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAGzB,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,MAAM;gBAFrB,OAAO,EAAE,MAAM,EACR,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM;IAMvB;;OAEG;IACH,cAAc,IAAI,OAAO;IAIzB;;OAEG;IACH,eAAe,IAAI,OAAO;IAI1B;;OAEG;IACH,cAAc,IAAI,OAAO;CAG1B;AAGD,mBAAmB,SAAS,CAAC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mobile Authentication Client
|
|
3
|
+
*
|
|
4
|
+
* Client for React Native apps to authenticate users with platform-api
|
|
5
|
+
*/
|
|
6
|
+
export class MobileAuthClient {
|
|
7
|
+
apiUrl;
|
|
8
|
+
fetchFn;
|
|
9
|
+
timeout;
|
|
10
|
+
constructor(config = {}) {
|
|
11
|
+
this.apiUrl = config.apiUrl || 'https://api.thewhatever.app';
|
|
12
|
+
this.fetchFn = config.fetch || globalThis.fetch;
|
|
13
|
+
this.timeout = config.timeout || 30000; // 30 seconds
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Make authenticated request with timeout
|
|
17
|
+
*/
|
|
18
|
+
async request(method, path, body, token) {
|
|
19
|
+
const controller = new AbortController();
|
|
20
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
21
|
+
try {
|
|
22
|
+
const headers = {
|
|
23
|
+
'Content-Type': 'application/json',
|
|
24
|
+
};
|
|
25
|
+
if (token) {
|
|
26
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
27
|
+
}
|
|
28
|
+
const response = await this.fetchFn(`${this.apiUrl}${path}`, {
|
|
29
|
+
method,
|
|
30
|
+
headers,
|
|
31
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
32
|
+
signal: controller.signal,
|
|
33
|
+
});
|
|
34
|
+
clearTimeout(timeoutId);
|
|
35
|
+
const data = await response.json();
|
|
36
|
+
if (!response.ok) {
|
|
37
|
+
// Structured error from platform-api
|
|
38
|
+
const error = data;
|
|
39
|
+
throw new AuthError(error.error, error.code, response.status);
|
|
40
|
+
}
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
clearTimeout(timeoutId);
|
|
45
|
+
if (error instanceof AuthError) {
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
if (error.name === 'AbortError') {
|
|
49
|
+
throw new AuthError('Request timeout', 'AUTH_INVALID_TOKEN', 408);
|
|
50
|
+
}
|
|
51
|
+
throw new AuthError(error.message || 'Network error', 'AUTH_INVALID_TOKEN', 500);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Login with Google (supports both mobile and web tokens)
|
|
56
|
+
*/
|
|
57
|
+
async loginWithGoogle(request) {
|
|
58
|
+
return this.request('POST', '/platform/auth/google', request);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Login with Twitter
|
|
62
|
+
*/
|
|
63
|
+
async loginWithTwitter(request) {
|
|
64
|
+
return this.request('POST', '/platform/auth/twitter', request);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Refresh JWT token
|
|
68
|
+
* Call this periodically (e.g., on app launch) to keep session alive
|
|
69
|
+
*/
|
|
70
|
+
async refreshToken(currentToken) {
|
|
71
|
+
return this.request('POST', '/platform/auth/refresh', undefined, currentToken);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Register device for push notifications
|
|
75
|
+
*/
|
|
76
|
+
async registerDevice(token, request) {
|
|
77
|
+
return this.request('POST', '/platform/auth/device', request, token);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Remove device registration (call on logout)
|
|
81
|
+
*/
|
|
82
|
+
async removeDevice(token, deviceId) {
|
|
83
|
+
return this.request('DELETE', `/platform/auth/device/${deviceId}`, undefined, token);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Validate invite code before signup
|
|
87
|
+
*/
|
|
88
|
+
async validateInvite(code) {
|
|
89
|
+
return this.request('POST', '/platform/auth/validate-invite', { code });
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Get current user profile
|
|
93
|
+
*/
|
|
94
|
+
async getCurrentUser(token) {
|
|
95
|
+
const response = await this.request('GET', '/platform/auth/me', undefined, token);
|
|
96
|
+
return response;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Custom error class for authentication errors
|
|
101
|
+
*/
|
|
102
|
+
export class AuthError extends Error {
|
|
103
|
+
code;
|
|
104
|
+
status;
|
|
105
|
+
constructor(message, code, status) {
|
|
106
|
+
super(message);
|
|
107
|
+
this.code = code;
|
|
108
|
+
this.status = status;
|
|
109
|
+
this.name = 'AuthError';
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Check if error is due to expired token
|
|
113
|
+
*/
|
|
114
|
+
isTokenExpired() {
|
|
115
|
+
return this.code === 'AUTH_TOKEN_EXPIRED';
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Check if error is due to invalid invite code
|
|
119
|
+
*/
|
|
120
|
+
isInvalidInvite() {
|
|
121
|
+
return this.code === 'AUTH_INVITE_INVALID' || this.code === 'AUTH_INVITE_REQUIRED';
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Check if error is network-related (retry-able)
|
|
125
|
+
*/
|
|
126
|
+
isNetworkError() {
|
|
127
|
+
return this.status >= 500 || this.status === 408;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/auth/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAkBH,MAAM,OAAO,gBAAgB;IACnB,MAAM,CAAS;IACf,OAAO,CAAe;IACtB,OAAO,CAAS;IAExB,YAAY,SAAiC,EAAE;QAC7C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,6BAA6B,CAAC;QAC7D,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC;QAChD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,KAAK,CAAC,CAAC,aAAa;IACvD,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,OAAO,CACnB,MAAc,EACd,IAAY,EACZ,IAAU,EACV,KAAc;QAEd,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,OAAO,GAA2B;gBACtC,cAAc,EAAE,kBAAkB;aACnC,CAAC;YAEF,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,KAAK,EAAE,CAAC;YAC/C,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CA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IAED;;OAEG;IACH,eAAe;QACb,OAAO,IAAI,CAAC,IAAI,KAAK,qBAAqB,IAAI,IAAI,CAAC,IAAI,KAAK,sBAAsB,CAAC;IACrF,CAAC;IAED;;OAEG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,KAAK,GAAG,CAAC;IACnD,CAAC;CACF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mobile Authentication Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for mobile app authentication with platform-api
|
|
5
|
+
*/
|
|
6
|
+
export type AuthErrorCode = 'AUTH_INVALID_TOKEN' | 'AUTH_TOKEN_EXPIRED' | 'AUTH_MISSING_TOKEN' | 'AUTH_INVITE_REQUIRED' | 'AUTH_INVITE_INVALID' | 'AUTH_USER_NOT_FOUND' | 'AUTH_REFRESH_FAILED' | 'AUTH_DEVICE_REGISTRATION_FAILED' | 'AUTH_INVALID_PLATFORM' | 'AUTH_INVALID_DEVICE_DATA' | 'AUTH_DEVICE_REMOVAL_FAILED';
|
|
7
|
+
export interface AuthErrorResponse {
|
|
8
|
+
error: string;
|
|
9
|
+
code: AuthErrorCode;
|
|
10
|
+
}
|
|
11
|
+
export interface AuthUser {
|
|
12
|
+
id: string;
|
|
13
|
+
email?: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
picture?: string;
|
|
16
|
+
role: 'user' | 'admin';
|
|
17
|
+
username?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface AuthResponse {
|
|
20
|
+
token: string;
|
|
21
|
+
user: AuthUser;
|
|
22
|
+
}
|
|
23
|
+
export interface GoogleAuthRequest {
|
|
24
|
+
idToken?: string;
|
|
25
|
+
accessToken?: string;
|
|
26
|
+
inviteCode?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface TwitterAuthRequest {
|
|
29
|
+
accessToken: string;
|
|
30
|
+
inviteCode?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface RefreshTokenResponse {
|
|
33
|
+
token: string;
|
|
34
|
+
user: AuthUser;
|
|
35
|
+
}
|
|
36
|
+
export interface DeviceRegistrationRequest {
|
|
37
|
+
deviceToken: string;
|
|
38
|
+
platform: 'ios' | 'android';
|
|
39
|
+
deviceId: string;
|
|
40
|
+
appVersion?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface InviteValidationResult {
|
|
43
|
+
valid: boolean;
|
|
44
|
+
error?: string;
|
|
45
|
+
invite?: {
|
|
46
|
+
code: string;
|
|
47
|
+
maxUses: number;
|
|
48
|
+
usedCount: number;
|
|
49
|
+
expiresAt?: string;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/client/auth/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,MAAM,MAAM,aAAa,GACrB,oBAAoB,GACpB,oBAAoB,GACpB,oBAAoB,GACpB,sBAAsB,GACtB,qBAAqB,GACrB,qBAAqB,GACrB,qBAAqB,GACrB,iCAAiC,GACjC,uBAAuB,GACvB,0BAA0B,GAC1B,4BAA4B,CAAC;AAGjC,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,aAAa,CAAC;CACrB;AAGD,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,QAAQ,CAAC;CAChB;AAGD,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,QAAQ,CAAC;CAChB;AAGD,MAAM,WAAW,yBAAyB;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,KAAK,GAAG,SAAS,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/client/auth/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
export { MobileAuthClient, AuthError } from './auth';
|
|
10
|
+
export type * from './auth/types';
|
|
11
|
+
//# 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;AAGxC,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACrD,mBAAmB,cAAc,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
// Mobile Authentication client
|
|
10
|
+
export { MobileAuthClient, AuthError } from './auth';
|
|
11
|
+
//# 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;AAG/C,+BAA+B;AAC/B,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,QAAQ,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;IAC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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,OAAO,GAAG,QAAQ,UAAU,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;YAE5E,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE;gBACrC,GAAG,OAAO;gBACV,MAAM,EAAE,UAAU,CAAC,MAAM;aAC1B,CAAC,CAAC;YAEH,YAAY,CAAC,SAAS,CAAC,CAAC;YAExB,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAA2B,EAAE,CAAC,CAA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,MAAM,CAAC;SAC7B,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,MAAM,CAAC;IACzB,CAAC;IAED,6DAA6D;IAE7D;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,QAAQ,CAAU,KAAa;QACnC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAsB,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC1E,OAAO,QAAQ,CAAC,KAAK,CAAC;IACxB,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,KAAK,CAAC,QAAQ,CAAC,KAAa,EAAE,KAA0B;QACtD,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE;YAClC,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;SAC5B,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,UAAU,CAAC,KAAa;QAC5B,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE;YAClC,MAAM,EAAE,QAAQ;SACjB,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tile State Client Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the TileState HTTP 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 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/client/tile-state/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
package/dist/edge/index.d.ts
CHANGED
|
@@ -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
|
package/dist/edge/index.d.ts.map
CHANGED
|
@@ -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"}
|
package/dist/edge/index.js
CHANGED
|
@@ -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
|
package/dist/edge/index.js.map
CHANGED
|
@@ -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,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IAED,oDAAoD;IACpD,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAEtC,OAAO,uBAAuB,CAAC,IAAI,CAAC,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,SAAS,uBAAuB,CAAC,IAAuB;IACtD,OAAO;QACL,KAAK,CAAC,WAAW;YACf,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;YACnD,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;YAC9B,OAAQ,IAAY,CAAC,QAAQ,CAAC;QAChC,CAAC;QAED,KAAK,CAAC,UAAU,CAAC,OAA0C;YACzD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE;gBACjD,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,EAAE,cAAc,E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,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;YAC9B,OAAQ,IAAY,CAAC,KAAU,CAAC;QAClC,CAAC;QAED,KAAK,CAAC,QAAQ,CAAC,KAA0B;YACvC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE;gBAC9C,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;gBAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;aAC5B,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,wBAAwB,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 @@
|
|
|
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.
|
|
3
|
+
"version": "0.0.3",
|
|
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": [
|