@spotsdev/sdk 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/api/client.d.ts +1 -1
  2. package/dist/api/client.js +7 -3
  3. package/dist/api/entities.d.ts +316 -0
  4. package/dist/api/entities.js +9 -0
  5. package/dist/api/mutations/clubs.d.ts +6 -6
  6. package/dist/api/mutations/clubs.js +12 -10
  7. package/dist/api/mutations/conversations.d.ts +7 -7
  8. package/dist/api/mutations/conversations.js +17 -13
  9. package/dist/api/mutations/index.js +1 -1
  10. package/dist/api/mutations/notifications.d.ts +4 -4
  11. package/dist/api/mutations/notifications.js +7 -7
  12. package/dist/api/mutations/orders.d.ts +7 -7
  13. package/dist/api/mutations/orders.js +11 -13
  14. package/dist/api/mutations/posts.d.ts +13 -13
  15. package/dist/api/mutations/posts.js +41 -29
  16. package/dist/api/mutations/products.d.ts +5 -5
  17. package/dist/api/mutations/products.js +9 -13
  18. package/dist/api/mutations/spots.d.ts +42 -8
  19. package/dist/api/mutations/spots.js +51 -13
  20. package/dist/api/mutations/users.d.ts +12 -10
  21. package/dist/api/mutations/users.js +20 -18
  22. package/dist/api/queries/auth.d.ts +5 -5
  23. package/dist/api/queries/auth.js +7 -7
  24. package/dist/api/queries/clubs.d.ts +7 -7
  25. package/dist/api/queries/clubs.js +11 -11
  26. package/dist/api/queries/conversations.d.ts +5 -5
  27. package/dist/api/queries/conversations.js +7 -7
  28. package/dist/api/queries/index.js +1 -1
  29. package/dist/api/queries/misc.d.ts +8 -32
  30. package/dist/api/queries/misc.js +28 -66
  31. package/dist/api/queries/notifications.d.ts +4 -4
  32. package/dist/api/queries/notifications.js +5 -5
  33. package/dist/api/queries/orders.d.ts +4 -4
  34. package/dist/api/queries/orders.js +7 -7
  35. package/dist/api/queries/posts.d.ts +44 -7
  36. package/dist/api/queries/posts.js +118 -15
  37. package/dist/api/queries/products.d.ts +6 -10
  38. package/dist/api/queries/products.js +7 -9
  39. package/dist/api/queries/spots.d.ts +31 -16
  40. package/dist/api/queries/spots.js +113 -31
  41. package/dist/api/queries/templates.d.ts +6 -9
  42. package/dist/api/queries/templates.js +8 -13
  43. package/dist/api/queries/users.d.ts +25 -11
  44. package/dist/api/queries/users.js +75 -27
  45. package/dist/api/types.d.ts +36 -33
  46. package/dist/api/types.js +6 -7
  47. package/dist/index.d.ts +1 -2
  48. package/dist/index.js +1 -8
  49. package/package.json +6 -21
  50. package/src/api/client.ts +45 -30
  51. package/src/api/entities.ts +420 -0
  52. package/src/api/mutations/clubs.ts +73 -40
  53. package/src/api/mutations/conversations.ts +91 -47
  54. package/src/api/mutations/index.ts +8 -8
  55. package/src/api/mutations/notifications.ts +48 -25
  56. package/src/api/mutations/orders.ts +101 -70
  57. package/src/api/mutations/posts.ts +229 -118
  58. package/src/api/mutations/products.ts +120 -81
  59. package/src/api/mutations/spots.ts +167 -55
  60. package/src/api/mutations/users.ts +109 -76
  61. package/src/api/queries/auth.ts +49 -24
  62. package/src/api/queries/clubs.ts +53 -38
  63. package/src/api/queries/conversations.ts +48 -30
  64. package/src/api/queries/index.ts +21 -21
  65. package/src/api/queries/misc.ts +53 -82
  66. package/src/api/queries/notifications.ts +32 -21
  67. package/src/api/queries/orders.ts +59 -42
  68. package/src/api/queries/posts.ts +203 -48
  69. package/src/api/queries/products.ts +51 -44
  70. package/src/api/queries/spots.ts +216 -85
  71. package/src/api/queries/templates.ts +39 -32
  72. package/src/api/queries/users.ts +157 -64
  73. package/src/api/types.ts +72 -118
  74. package/src/index.ts +5 -11
package/dist/index.d.ts CHANGED
@@ -30,9 +30,8 @@
30
30
  * }
31
31
  * ```
32
32
  */
33
- export { configureSDK, getApiClient, getConfig } from './api/client';
34
33
  export type { SDKConfig } from './api/client';
34
+ export { configureSDK, getApiClient, getConfig } from './api/client';
35
35
  export * from './api/types';
36
36
  export * from './api/queries';
37
37
  export * from './api/mutations';
38
- export * from './api/services';
package/dist/index.js CHANGED
@@ -47,9 +47,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
47
47
  };
48
48
  Object.defineProperty(exports, "__esModule", { value: true });
49
49
  exports.getConfig = exports.getApiClient = exports.configureSDK = void 0;
50
- // ============================================================================
51
- // API CLIENT
52
- // ============================================================================
53
50
  var client_1 = require("./api/client");
54
51
  Object.defineProperty(exports, "configureSDK", { enumerable: true, get: function () { return client_1.configureSDK; } });
55
52
  Object.defineProperty(exports, "getApiClient", { enumerable: true, get: function () { return client_1.getApiClient; } });
@@ -66,8 +63,4 @@ __exportStar(require("./api/queries"), exports);
66
63
  // MUTATION HOOKS
67
64
  // ============================================================================
68
65
  __exportStar(require("./api/mutations"), exports);
69
- // ============================================================================
70
- // SERVICES (Plain async functions for testing/non-React)
71
- // ============================================================================
72
- __exportStar(require("./api/services"), exports);
73
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBK0JHOzs7Ozs7Ozs7Ozs7Ozs7OztBQUVILCtFQUErRTtBQUMvRSxhQUFhO0FBQ2IsK0VBQStFO0FBRS9FLHVDQUFxRTtBQUE1RCxzR0FBQSxZQUFZLE9BQUE7QUFBRSxzR0FBQSxZQUFZLE9BQUE7QUFBRSxtR0FBQSxTQUFTLE9BQUE7QUFHOUMsK0VBQStFO0FBQy9FLFFBQVE7QUFDUiwrRUFBK0U7QUFFL0UsOENBQTRCO0FBRTVCLCtFQUErRTtBQUMvRSxjQUFjO0FBQ2QsK0VBQStFO0FBRS9FLGdEQUE4QjtBQUU5QiwrRUFBK0U7QUFDL0UsaUJBQWlCO0FBQ2pCLCtFQUErRTtBQUUvRSxrREFBZ0M7QUFFaEMsK0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3VycmVudFVzZXIoKTtcbiAqICAgY29uc3QgeyBkYXRhOiBzcG90cyB9ID0gdXNlU3BvdHMoKTtcbiAqICAgY29uc3QgeyBtdXRhdGU6IGNyZWF0ZVBvc3QgfSA9IHVzZUNyZWF0ZVBvc3QoKTtcbiAqICAgLy8gLi4uXG4gKiB9XG4gKiBgYGBcbiAqL1xuXG4vLyA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09XG4vLyBBUEkgQ0xJRU5UXG4vLyA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09XG5cbmV4cG9ydCB7IGNvbmZpZ3VyZVNESywgZ2V0QXBpQ2xpZW50LCBnZXRDb25maWcgfSBmcm9tICcuL2FwaS9jbGllbnQnO1xuZXhwb3J0IHR5cGUgeyBTREtDb25maWcgfSBmcm9tICcuL2FwaS9jbGllbnQnO1xuXG4vLyA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09XG4vLyBUWVBFU1xuLy8gPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PVxuXG5leHBvcnQgKiBmcm9tICcuL2FwaS90eXBlcyc7XG5cbi8vID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT1cbi8vIFFVRVJZIEhPT0tTXG4vLyA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09XG5cbmV4cG9ydCAqIGZyb20gJy4vYXBpL3F1ZXJpZXMnO1xuXG4vLyA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09XG4vLyBNVVRBVElPTiBIT09LU1xuLy8gPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PVxuXG5leHBvcnQgKiBmcm9tICcuL2FwaS9tdXRhdGlvbnMnO1xuXG4vLyA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09XG4vLyBTRVJWSUNFUyAoUGxhaW4gYXN5bmMgZnVuY3Rpb25zIGZvciB0ZXN0aW5nL25vbi1SZWFjdClcbi8vID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT1cblxuZXhwb3J0ICogZnJvbSAnLi9hcGkvc2VydmljZXMnO1xuIl19
66
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBK0JHOzs7Ozs7Ozs7Ozs7Ozs7OztBQU9ILHVDQUFrRTtBQUExRCxzR0FBQSxZQUFZLE9BQUE7QUFBRSxzR0FBQSxZQUFZLE9BQUE7QUFBRSxtR0FBQSxTQUFTLE9BQUE7QUFFN0MsK0VBQStFO0FBQy9FLFFBQVE7QUFDUiwrRUFBK0U7QUFFL0UsOENBQTJCO0FBRTNCLCtFQUErRTtBQUMvRSxjQUFjO0FBQ2QsK0VBQStFO0FBRS9FLGdEQUE2QjtBQUU3QiwrRUFBK0U7QUFDL0UsaUJBQWlCO0FBQ2pCLCtFQUErRTtBQUUvRSxrREFBK0IiL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TcG90cygpO1xuICogICBjb25zdCB7IG11dGF0ZTogY3JlYXRlUG9zdCB9ID0gdXNlQ3JlYXRlUG9zdCgpO1xuICogICAvLyAuLi5cbiAqIH1cbiAqIGBgYFxuICovXG5cbi8vID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT1cbi8vIEFQSSBDTElFTlRcbi8vID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT1cblxuZXhwb3J0IHR5cGUge1NES0NvbmZpZ30gZnJvbSAnLi9hcGkvY2xpZW50J1xuZXhwb3J0IHtjb25maWd1cmVTREssIGdldEFwaUNsaWVudCwgZ2V0Q29uZmlnfSBmcm9tICcuL2FwaS9jbGllbnQnXG5cbi8vID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT1cbi8vIFRZUEVTXG4vLyA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09XG5cbmV4cG9ydCAqIGZyb20gJy4vYXBpL3R5cGVzJ1xuXG4vLyA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09XG4vLyBRVUVSWSBIT09LU1xuLy8gPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PVxuXG5leHBvcnQgKiBmcm9tICcuL2FwaS9xdWVyaWVzJ1xuXG4vLyA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09XG4vLyBNVVRBVElPTiBIT09LU1xuLy8gPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PVxuXG5leHBvcnQgKiBmcm9tICcuL2FwaS9tdXRhdGlvbnMnXG4iXX0=
package/package.json CHANGED
@@ -1,15 +1,11 @@
1
1
  {
2
2
  "name": "@spotsdev/sdk",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Shared TypeScript SDK for Spots API - TanStack Query hooks, API client, and utilities",
5
5
  "main": "dist/index.js",
6
+ "source": "src/index.ts",
6
7
  "types": "dist/index.d.ts",
7
- "exports": {
8
- ".": {
9
- "types": "./dist/index.d.ts",
10
- "default": "./dist/index.js"
11
- }
12
- },
8
+ "react-native": "src/index.ts",
13
9
  "files": [
14
10
  "dist",
15
11
  "src"
@@ -18,8 +14,6 @@
18
14
  "build": "tsc",
19
15
  "build:watch": "tsc --watch",
20
16
  "type-check": "tsc --noEmit",
21
- "lint": "eslint src --ext .ts",
22
- "generate": "prisma generate --schema=../spots-api/prisma/schema.prisma",
23
17
  "prepublishOnly": "npm run build"
24
18
  },
25
19
  "keywords": [
@@ -31,27 +25,18 @@
31
25
  "typescript"
32
26
  ],
33
27
  "author": "SoulToSoul",
34
- "license": "MIT",
35
- "publishConfig": {
36
- "access": "public"
37
- },
28
+ "license": "UNLICENSED",
38
29
  "peerDependencies": {
39
30
  "@tanstack/react-query": "^5.0.0",
40
31
  "axios": "^1.6.0",
41
- "react": ">=18.0.0",
42
- "zod": "^3.0.0"
32
+ "react": ">=18.0.0"
43
33
  },
44
34
  "dependencies": {
45
35
  "@spotsdev/types": "^1.0.0"
46
36
  },
47
37
  "devDependencies": {
48
- "@spotsdev/types": "^1.0.0",
49
- "@tanstack/react-query": "^5.0.0",
50
38
  "@types/node": "^20.0.0",
51
39
  "@types/react": "^18.0.0",
52
- "axios": "^1.6.0",
53
- "react": "^18.0.0",
54
- "typescript": "^5.9.3",
55
- "zod": "^3.0.0"
40
+ "typescript": "^5.7.0"
56
41
  }
57
42
  }
package/src/api/client.ts CHANGED
@@ -1,32 +1,36 @@
1
- import axios, { AxiosInstance, AxiosError, InternalAxiosRequestConfig } from 'axios';
1
+ import axios, {
2
+ type AxiosError,
3
+ type AxiosInstance,
4
+ type InternalAxiosRequestConfig,
5
+ } from 'axios'
2
6
 
3
7
  export interface SDKConfig {
4
- baseURL: string;
5
- getAccessToken: () => string | null | Promise<string | null>;
6
- refreshAccessToken?: () => Promise<string>;
7
- onUnauthorized?: () => void;
8
+ baseURL: string
9
+ getAccessToken: () => string | null | Promise<string | null>
10
+ refreshAccessToken?: () => Promise<string>
11
+ onUnauthorized?: () => void
8
12
  }
9
13
 
10
- let config: SDKConfig | null = null;
11
- let apiClient: AxiosInstance | null = null;
14
+ let config: SDKConfig | null = null
15
+ let apiClient: AxiosInstance | null = null
12
16
 
13
17
  export function configureSDK(sdkConfig: SDKConfig): void {
14
- config = sdkConfig;
15
- apiClient = createApiClient(sdkConfig);
18
+ config = sdkConfig
19
+ apiClient = createApiClient(sdkConfig)
16
20
  }
17
21
 
18
22
  export function getApiClient(): AxiosInstance {
19
23
  if (!apiClient) {
20
- throw new Error('SDK not configured. Call configureSDK() first.');
24
+ throw new Error('SDK not configured. Call configureSDK() first.')
21
25
  }
22
- return apiClient;
26
+ return apiClient
23
27
  }
24
28
 
25
29
  export function getConfig(): SDKConfig {
26
30
  if (!config) {
27
- throw new Error('SDK not configured. Call configureSDK() first.');
31
+ throw new Error('SDK not configured. Call configureSDK() first.')
28
32
  }
29
- return config;
33
+ return config
30
34
  }
31
35
 
32
36
  function createApiClient(sdkConfig: SDKConfig): AxiosInstance {
@@ -35,44 +39,55 @@ function createApiClient(sdkConfig: SDKConfig): AxiosInstance {
35
39
  headers: {
36
40
  'Content-Type': 'application/json',
37
41
  },
38
- });
42
+ })
39
43
 
40
44
  // Request interceptor - add auth token
41
45
  client.interceptors.request.use(
42
46
  async (requestConfig: InternalAxiosRequestConfig) => {
43
- const token = await sdkConfig.getAccessToken();
47
+ const token = await sdkConfig.getAccessToken()
44
48
  if (token) {
45
- requestConfig.headers.Authorization = `Bearer ${token}`;
49
+ requestConfig.headers.Authorization = `Bearer ${token}`
46
50
  }
47
- return requestConfig;
51
+
52
+ // Debug logging
53
+ console.log(
54
+ `[SDK] ${requestConfig.method?.toUpperCase()} ${sdkConfig.baseURL}${requestConfig.url}`,
55
+ )
56
+ return requestConfig
48
57
  },
49
- (error) => Promise.reject(error)
50
- );
58
+ error => Promise.reject(error),
59
+ )
51
60
 
52
61
  // Response interceptor - handle 401
53
62
  client.interceptors.response.use(
54
- (response) => response,
63
+ response => response,
55
64
  async (error: AxiosError) => {
65
+ console.log(
66
+ `[SDK] Error: ${error.response?.status} ${error.config?.url}`,
67
+ error.message,
68
+ )
69
+
70
+ // Handle auth token expiration (401)
56
71
  if (error.response?.status === 401) {
57
72
  if (sdkConfig.refreshAccessToken) {
58
73
  try {
59
- const newToken = await sdkConfig.refreshAccessToken();
74
+ const newToken = await sdkConfig.refreshAccessToken()
60
75
  if (newToken && error.config) {
61
- error.config.headers.Authorization = `Bearer ${newToken}`;
62
- return client.request(error.config);
76
+ error.config.headers.Authorization = `Bearer ${newToken}`
77
+ return client.request(error.config)
63
78
  }
64
79
  } catch {
65
- sdkConfig.onUnauthorized?.();
80
+ sdkConfig.onUnauthorized?.()
66
81
  }
67
82
  } else {
68
- sdkConfig.onUnauthorized?.();
83
+ sdkConfig.onUnauthorized?.()
69
84
  }
70
85
  }
71
- return Promise.reject(error);
72
- }
73
- );
86
+ return Promise.reject(error)
87
+ },
88
+ )
74
89
 
75
- return client;
90
+ return client
76
91
  }
77
92
 
78
- export { apiClient };
93
+ export {apiClient}
@@ -0,0 +1,420 @@
1
+ /**
2
+ * Spots SDK Entity Types
3
+ *
4
+ * These types mirror the Prisma schema entities but without @prisma/client dependency.
5
+ * This allows the SDK to work in React Native where Prisma is not available.
6
+ */
7
+
8
+ // ============================================================================
9
+ // ENUMS
10
+ // ============================================================================
11
+
12
+ export type SpotType =
13
+ | 'CAFE'
14
+ | 'RESTAURANT'
15
+ | 'BAR'
16
+ | 'PARK'
17
+ | 'BEACH'
18
+ | 'COWORKING'
19
+ | 'LIBRARY'
20
+ | 'GYM'
21
+ | 'MUSEUM'
22
+ | 'GALLERY'
23
+ | 'THEATER'
24
+ | 'CINEMA'
25
+ | 'MALL'
26
+ | 'MARKET'
27
+ | 'HOTEL'
28
+ | 'HOSTEL'
29
+ | 'OTHER'
30
+
31
+ export type SpotPostType =
32
+ | 'CHECK_IN'
33
+ | 'LOOKING_FOR'
34
+ | 'OFFERING'
35
+ | 'QUESTION'
36
+ | 'EVENT'
37
+ | 'RECOMMENDATION'
38
+ | 'GENERAL'
39
+
40
+ export type AccountStatus = 'ACTIVE' | 'SUSPENDED' | 'DELETED' | 'PENDING'
41
+
42
+ export type ClaimStatus = 'PENDING' | 'APPROVED' | 'REJECTED'
43
+
44
+ export type ResponseStatus = 'PENDING' | 'ACCEPTED' | 'DECLINED'
45
+
46
+ export type ReportReason =
47
+ | 'SPAM'
48
+ | 'HARASSMENT'
49
+ | 'INAPPROPRIATE'
50
+ | 'SCAM'
51
+ | 'OTHER'
52
+
53
+ export type ReportStatus = 'PENDING' | 'REVIEWED' | 'RESOLVED' | 'DISMISSED'
54
+
55
+ export type NotificationType =
56
+ | 'POST_RESPONSE'
57
+ | 'POST_REPLY'
58
+ | 'POST_UPVOTE'
59
+ | 'RESPONSE_ACCEPTED'
60
+ | 'RESPONSE_DECLINED'
61
+ | 'NEW_MESSAGE'
62
+ | 'SYSTEM'
63
+
64
+ // ============================================================================
65
+ // ENTITY INTERFACES
66
+ // ============================================================================
67
+
68
+ export interface User {
69
+ id: string
70
+ phone: string | null
71
+ email: string | null
72
+ name: string | null
73
+ bio: string | null
74
+ avatarUrl: string | null
75
+ status: AccountStatus
76
+ onboardingCompleted: boolean
77
+ lastActiveAt: Date | null
78
+ createdAt: Date
79
+ updatedAt: Date
80
+ }
81
+
82
+ export interface Spot {
83
+ id: string
84
+ name: string
85
+ slug: string
86
+ description: string | null
87
+ address: string | null
88
+ city: string | null
89
+ country: string | null
90
+ latitude: number | null
91
+ longitude: number | null
92
+ type: SpotType
93
+ googlePlaceId: string | null
94
+ website: string | null
95
+ phone: string | null
96
+ imageUrl: string | null
97
+ ownerId: string | null
98
+ isVerified: boolean
99
+ createdAt: Date
100
+ updatedAt: Date
101
+ }
102
+
103
+ export interface SpotPost {
104
+ id: string
105
+ spotId: string
106
+ userId: string
107
+ postType: SpotPostType
108
+ title: string
109
+ content: string | null
110
+ emoji: string | null
111
+ expiresAt: Date | null
112
+ status: 'ACTIVE' | 'FULFILLED' | 'EXPIRED' | 'DELETED'
113
+ upvoteCount: number
114
+ responseCount: number
115
+ replyCount: number
116
+ createdAt: Date
117
+ updatedAt: Date
118
+ // Relations (optional, populated by API)
119
+ user?: User
120
+ spot?: Spot
121
+ }
122
+
123
+ export interface PostReply {
124
+ id: string
125
+ postId: string
126
+ userId: string
127
+ content: string
128
+ createdAt: Date
129
+ updatedAt: Date
130
+ user?: User
131
+ }
132
+
133
+ export interface PostResponse {
134
+ id: string
135
+ postId: string
136
+ userId: string
137
+ note: string | null
138
+ status: ResponseStatus
139
+ createdAt: Date
140
+ updatedAt: Date
141
+ user?: User
142
+ post?: SpotPost
143
+ }
144
+
145
+ export interface PostUpvote {
146
+ id: string
147
+ postId: string
148
+ userId: string
149
+ createdAt: Date
150
+ }
151
+
152
+ /**
153
+ * PostUpvoter - user who upvoted a post (from /posts/:id/upvotes endpoint)
154
+ */
155
+ export interface PostUpvoter {
156
+ id: string
157
+ userId: string
158
+ name: string | null
159
+ avatarUrl: string | null
160
+ createdAt: Date
161
+ }
162
+
163
+ /**
164
+ * PostUpvotesResponse - response from /posts/:id/upvotes endpoint
165
+ */
166
+ export interface PostUpvotesResponse {
167
+ data: PostUpvoter[]
168
+ meta: {
169
+ total: number
170
+ limit: number
171
+ offset: number
172
+ hasMore: boolean
173
+ currentUserUpvoted: boolean
174
+ isPostAuthor: boolean
175
+ }
176
+ }
177
+
178
+ export interface PostReport {
179
+ id: string
180
+ postId: string
181
+ userId: string
182
+ reason: ReportReason
183
+ details: string | null
184
+ status: ReportStatus
185
+ createdAt: Date
186
+ updatedAt: Date
187
+ }
188
+
189
+ export interface Club {
190
+ id: string
191
+ name: string
192
+ slug: string
193
+ description: string | null
194
+ imageUrl: string | null
195
+ isPrivate: boolean
196
+ createdById: string
197
+ createdAt: Date
198
+ updatedAt: Date
199
+ }
200
+
201
+ export interface ClubMember {
202
+ id: string
203
+ clubId: string
204
+ userId: string
205
+ role: 'MEMBER' | 'ADMIN' | 'OWNER'
206
+ joinedAt: Date
207
+ }
208
+
209
+ export interface Conversation {
210
+ id: string
211
+ createdAt: Date
212
+ updatedAt: Date
213
+ participants?: User[]
214
+ messages?: Message[]
215
+ }
216
+
217
+ export interface Message {
218
+ id: string
219
+ conversationId: string
220
+ senderId: string
221
+ content: string
222
+ createdAt: Date
223
+ sender?: User
224
+ }
225
+
226
+ export interface Notification {
227
+ id: string
228
+ userId: string
229
+ type: NotificationType
230
+ title: string
231
+ body: string | null
232
+ data: Record<string, unknown> | null
233
+ isRead: boolean
234
+ createdAt: Date
235
+ }
236
+
237
+ export interface PostTemplate {
238
+ id: string
239
+ postType: SpotPostType
240
+ emoji: string
241
+ title: string
242
+ placeholder: string | null
243
+ isActive: boolean
244
+ sortOrder: number
245
+ createdAt: Date
246
+ updatedAt: Date
247
+ }
248
+
249
+ export interface Vibe {
250
+ id: string
251
+ name: string
252
+ emoji: string | null
253
+ createdAt: Date
254
+ }
255
+
256
+ export interface Interest {
257
+ id: string
258
+ name: string
259
+ emoji: string | null
260
+ category: string | null
261
+ createdAt: Date
262
+ }
263
+
264
+ export interface Intention {
265
+ id: string
266
+ name: string
267
+ emoji: string | null
268
+ createdAt: Date
269
+ }
270
+
271
+ export interface LifeSituation {
272
+ id: string
273
+ name: string
274
+ emoji: string | null
275
+ createdAt: Date
276
+ }
277
+
278
+ export interface FavoriteSpot {
279
+ id: string
280
+ userId: string
281
+ spotId: string
282
+ createdAt: Date
283
+ spot?: Spot
284
+ }
285
+
286
+ export interface SpotImage {
287
+ id: string
288
+ spotId: string
289
+ url: string
290
+ caption: string | null
291
+ sortOrder: number
292
+ createdAt: Date
293
+ }
294
+
295
+ export interface SpotVibe {
296
+ id: string
297
+ spotId: string
298
+ vibeId: string
299
+ vibe?: Vibe
300
+ }
301
+
302
+ export interface SpotIntention {
303
+ id: string
304
+ spotId: string
305
+ intentionId: string
306
+ intention?: Intention
307
+ }
308
+
309
+ export interface SpotClaim {
310
+ id: string
311
+ spotId: string
312
+ userId: string
313
+ status: ClaimStatus
314
+ verificationMethod: string | null
315
+ createdAt: Date
316
+ updatedAt: Date
317
+ }
318
+
319
+ export interface SpotSubscription {
320
+ id: string
321
+ spotId: string
322
+ userId: string
323
+ createdAt: Date
324
+ spot?: Spot
325
+ }
326
+
327
+ export interface City {
328
+ id: string
329
+ name: string
330
+ country: string
331
+ latitude: number
332
+ longitude: number
333
+ timezone: string | null
334
+ createdAt: Date
335
+ }
336
+
337
+ // ============================================================================
338
+ // API RESPONSE TYPES
339
+ // ============================================================================
340
+
341
+ // NOTE: ApiResponse is re-exported from @spots/types in types.ts
342
+
343
+ /**
344
+ * Paginated response with meta information
345
+ */
346
+ export interface PaginatedResponse<T> {
347
+ data: T[]
348
+ meta: PaginationMeta
349
+ }
350
+
351
+ export interface PaginationMeta {
352
+ total: number
353
+ page: number
354
+ limit: number
355
+ totalPages: number
356
+ hasNextPage: boolean
357
+ hasPreviousPage: boolean
358
+ }
359
+
360
+ // ============================================================================
361
+ // MARKETPLACE TYPES
362
+ // ============================================================================
363
+
364
+ export type ProductType = 'PHYSICAL' | 'DIGITAL' | 'SERVICE' | 'BUNDLE'
365
+
366
+ export type ProductStatus = 'DRAFT' | 'ACTIVE' | 'SOLD_OUT' | 'ARCHIVED'
367
+
368
+ export type OrderStatus =
369
+ | 'PENDING'
370
+ | 'CONFIRMED'
371
+ | 'PREPARING'
372
+ | 'READY'
373
+ | 'COMPLETED'
374
+ | 'CANCELLED'
375
+ | 'REFUNDED'
376
+
377
+ export interface Product {
378
+ id: string
379
+ spotId: string
380
+ name: string
381
+ slug: string
382
+ description: string | null
383
+ type: ProductType
384
+ status: ProductStatus
385
+ price: number
386
+ currency: string
387
+ imageUrl: string | null
388
+ images: string[]
389
+ stock: number | null
390
+ maxQuantity: number
391
+ sortOrder: number
392
+ metadata: Record<string, unknown> | null
393
+ createdAt: Date
394
+ updatedAt: Date
395
+ }
396
+
397
+ export interface Order {
398
+ id: string
399
+ spotId: string
400
+ userId: string
401
+ status: OrderStatus
402
+ subtotal: number
403
+ tax: number
404
+ total: number
405
+ currency: string
406
+ notes: string | null
407
+ metadata: Record<string, unknown> | null
408
+ createdAt: Date
409
+ updatedAt: Date
410
+ }
411
+
412
+ export interface OrderItem {
413
+ id: string
414
+ orderId: string
415
+ productId: string
416
+ quantity: number
417
+ unitPrice: number
418
+ total: number
419
+ createdAt: Date
420
+ }