@spotsdev/sdk 1.0.0 → 1.2.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 +318 -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 +424 -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.2.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,424 @@
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
+ // Aliases for backwards compatibility
93
+ lat?: number | null
94
+ lng?: number | null
95
+ type: SpotType
96
+ googlePlaceId: string | null
97
+ website: string | null
98
+ phone: string | null
99
+ imageUrl: string | null
100
+ ownerId: string | null
101
+ isVerified: boolean
102
+ // Dates as strings for JSON serialization compatibility
103
+ createdAt: Date | string
104
+ updatedAt: Date | string
105
+ }
106
+
107
+ export interface SpotPost {
108
+ id: string
109
+ spotId: string
110
+ userId: string
111
+ postType: SpotPostType
112
+ title: string
113
+ content: string | null
114
+ emoji: string | null
115
+ expiresAt: Date | null
116
+ status: 'ACTIVE' | 'FULFILLED' | 'EXPIRED' | 'DELETED'
117
+ upvoteCount: number
118
+ responseCount: number
119
+ replyCount: number
120
+ createdAt: Date
121
+ updatedAt: Date
122
+ // Relations (optional, populated by API)
123
+ user?: User
124
+ spot?: Spot
125
+ }
126
+
127
+ export interface PostReply {
128
+ id: string
129
+ postId: string
130
+ userId: string
131
+ content: string
132
+ createdAt: Date
133
+ updatedAt: Date
134
+ user?: User
135
+ }
136
+
137
+ export interface PostResponse {
138
+ id: string
139
+ postId: string
140
+ userId: string
141
+ note: string | null
142
+ status: ResponseStatus
143
+ createdAt: Date
144
+ updatedAt: Date
145
+ user?: User
146
+ post?: SpotPost
147
+ }
148
+
149
+ export interface PostUpvote {
150
+ id: string
151
+ postId: string
152
+ userId: string
153
+ createdAt: Date
154
+ }
155
+
156
+ /**
157
+ * PostUpvoter - user who upvoted a post (from /posts/:id/upvotes endpoint)
158
+ */
159
+ export interface PostUpvoter {
160
+ id: string
161
+ userId: string
162
+ name: string | null
163
+ avatarUrl: string | null
164
+ createdAt: Date
165
+ }
166
+
167
+ /**
168
+ * PostUpvotesResponse - response from /posts/:id/upvotes endpoint
169
+ */
170
+ export interface PostUpvotesResponse {
171
+ data: PostUpvoter[]
172
+ meta: {
173
+ total: number
174
+ limit: number
175
+ offset: number
176
+ hasMore: boolean
177
+ currentUserUpvoted: boolean
178
+ isPostAuthor: boolean
179
+ }
180
+ }
181
+
182
+ export interface PostReport {
183
+ id: string
184
+ postId: string
185
+ userId: string
186
+ reason: ReportReason
187
+ details: string | null
188
+ status: ReportStatus
189
+ createdAt: Date
190
+ updatedAt: Date
191
+ }
192
+
193
+ export interface Club {
194
+ id: string
195
+ name: string
196
+ slug: string
197
+ description: string | null
198
+ imageUrl: string | null
199
+ isPrivate: boolean
200
+ createdById: string
201
+ createdAt: Date
202
+ updatedAt: Date
203
+ }
204
+
205
+ export interface ClubMember {
206
+ id: string
207
+ clubId: string
208
+ userId: string
209
+ role: 'MEMBER' | 'ADMIN' | 'OWNER'
210
+ joinedAt: Date
211
+ }
212
+
213
+ export interface Conversation {
214
+ id: string
215
+ createdAt: Date
216
+ updatedAt: Date
217
+ participants?: User[]
218
+ messages?: Message[]
219
+ }
220
+
221
+ export interface Message {
222
+ id: string
223
+ conversationId: string
224
+ senderId: string
225
+ content: string
226
+ createdAt: Date
227
+ sender?: User
228
+ }
229
+
230
+ export interface Notification {
231
+ id: string
232
+ userId: string
233
+ type: NotificationType
234
+ title: string
235
+ body: string | null
236
+ data: Record<string, unknown> | null
237
+ isRead: boolean
238
+ createdAt: Date
239
+ }
240
+
241
+ export interface PostTemplate {
242
+ id: string
243
+ postType: SpotPostType
244
+ emoji: string
245
+ title: string
246
+ placeholder: string | null
247
+ isActive: boolean
248
+ sortOrder: number
249
+ createdAt: Date
250
+ updatedAt: Date
251
+ }
252
+
253
+ export interface Vibe {
254
+ id: string
255
+ name: string
256
+ emoji: string | null
257
+ createdAt: Date
258
+ }
259
+
260
+ export interface Interest {
261
+ id: string
262
+ name: string
263
+ emoji: string | null
264
+ category: string | null
265
+ createdAt: Date
266
+ }
267
+
268
+ export interface Intention {
269
+ id: string
270
+ name: string
271
+ emoji: string | null
272
+ createdAt: Date
273
+ }
274
+
275
+ export interface LifeSituation {
276
+ id: string
277
+ name: string
278
+ emoji: string | null
279
+ createdAt: Date
280
+ }
281
+
282
+ export interface FavoriteSpot {
283
+ id: string
284
+ userId: string
285
+ spotId: string
286
+ createdAt: Date
287
+ spot?: Spot
288
+ }
289
+
290
+ export interface SpotImage {
291
+ id: string
292
+ spotId: string
293
+ url: string
294
+ caption: string | null
295
+ sortOrder: number
296
+ createdAt: Date
297
+ }
298
+
299
+ export interface SpotVibe {
300
+ id: string
301
+ spotId: string
302
+ vibeId: string
303
+ vibe?: Vibe
304
+ }
305
+
306
+ export interface SpotIntention {
307
+ id: string
308
+ spotId: string
309
+ intentionId: string
310
+ intention?: Intention
311
+ }
312
+
313
+ export interface SpotClaim {
314
+ id: string
315
+ spotId: string
316
+ userId: string
317
+ status: ClaimStatus
318
+ verificationMethod: string | null
319
+ createdAt: Date
320
+ updatedAt: Date
321
+ }
322
+
323
+ export interface SpotSubscription {
324
+ id: string
325
+ spotId: string
326
+ userId: string
327
+ createdAt: Date
328
+ spot?: Spot
329
+ }
330
+
331
+ export interface City {
332
+ id: string
333
+ name: string
334
+ country: string
335
+ latitude: number
336
+ longitude: number
337
+ timezone: string | null
338
+ createdAt: Date
339
+ }
340
+
341
+ // ============================================================================
342
+ // API RESPONSE TYPES
343
+ // ============================================================================
344
+
345
+ // NOTE: ApiResponse is re-exported from @spots/types in types.ts
346
+
347
+ /**
348
+ * Paginated response with meta information
349
+ */
350
+ export interface PaginatedResponse<T> {
351
+ data: T[]
352
+ meta: PaginationMeta
353
+ }
354
+
355
+ export interface PaginationMeta {
356
+ total: number
357
+ page: number
358
+ limit: number
359
+ totalPages: number
360
+ hasNextPage: boolean
361
+ hasPreviousPage: boolean
362
+ }
363
+
364
+ // ============================================================================
365
+ // MARKETPLACE TYPES
366
+ // ============================================================================
367
+
368
+ export type ProductType = 'PHYSICAL' | 'DIGITAL' | 'SERVICE' | 'BUNDLE'
369
+
370
+ export type ProductStatus = 'DRAFT' | 'ACTIVE' | 'SOLD_OUT' | 'ARCHIVED'
371
+
372
+ export type OrderStatus =
373
+ | 'PENDING'
374
+ | 'CONFIRMED'
375
+ | 'PREPARING'
376
+ | 'READY'
377
+ | 'COMPLETED'
378
+ | 'CANCELLED'
379
+ | 'REFUNDED'
380
+
381
+ export interface Product {
382
+ id: string
383
+ spotId: string
384
+ name: string
385
+ slug: string
386
+ description: string | null
387
+ type: ProductType
388
+ status: ProductStatus
389
+ price: number
390
+ currency: string
391
+ imageUrl: string | null
392
+ images: string[]
393
+ stock: number | null
394
+ maxQuantity: number
395
+ sortOrder: number
396
+ metadata: Record<string, unknown> | null
397
+ createdAt: Date
398
+ updatedAt: Date
399
+ }
400
+
401
+ export interface Order {
402
+ id: string
403
+ spotId: string
404
+ userId: string
405
+ status: OrderStatus
406
+ subtotal: number
407
+ tax: number
408
+ total: number
409
+ currency: string
410
+ notes: string | null
411
+ metadata: Record<string, unknown> | null
412
+ createdAt: Date
413
+ updatedAt: Date
414
+ }
415
+
416
+ export interface OrderItem {
417
+ id: string
418
+ orderId: string
419
+ productId: string
420
+ quantity: number
421
+ unitPrice: number
422
+ total: number
423
+ createdAt: Date
424
+ }