@adventurelabs/scout-core 1.5.4 → 2.0.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 (219) hide show
  1. package/README.md +47 -0
  2. package/dist/api_keys/actions.d.ts +0 -1
  3. package/dist/api_keys/actions.js +0 -14
  4. package/dist/client/index.d.ts +75 -0
  5. package/dist/client/index.js +82 -0
  6. package/dist/constants/index.d.ts +1 -0
  7. package/dist/constants/index.js +1 -0
  8. package/dist/helpers/analysis_usage/jobs_server.d.ts +25 -0
  9. package/dist/helpers/analysis_usage/jobs_server.js +10 -0
  10. package/dist/helpers/analysis_usage/tasks_server.d.ts +63 -0
  11. package/dist/helpers/analysis_usage/tasks_server.js +14 -0
  12. package/dist/helpers/artifacts.d.ts +0 -1
  13. package/dist/helpers/artifacts.js +10 -147
  14. package/dist/helpers/artifacts.queries.d.ts +26 -0
  15. package/dist/helpers/{artifacts.internal.js → artifacts.queries.js} +24 -41
  16. package/dist/helpers/auth.d.ts +1 -1
  17. package/dist/helpers/auth.js +2 -3
  18. package/dist/helpers/auth_server.d.ts +2 -0
  19. package/dist/helpers/auth_server.js +10 -0
  20. package/dist/helpers/certificates_server.d.ts +101 -0
  21. package/dist/helpers/certificates_server.js +42 -0
  22. package/dist/helpers/chat.d.ts +1 -2
  23. package/dist/helpers/chat.js +3 -38
  24. package/dist/helpers/chat.queries.d.ts +13 -0
  25. package/dist/helpers/chat.queries.js +39 -0
  26. package/dist/helpers/client_abilities_jwt_keys.js +0 -1
  27. package/dist/helpers/client_abilities_token_server.d.ts +1 -0
  28. package/dist/helpers/client_abilities_token_server.js +5 -2
  29. package/dist/helpers/connectivity.d.ts +1 -5
  30. package/dist/helpers/connectivity.js +7 -140
  31. package/dist/helpers/connectivity.queries.d.ts +18 -0
  32. package/dist/helpers/connectivity.queries.js +121 -0
  33. package/dist/helpers/contacts_server.d.ts +63 -0
  34. package/dist/helpers/contacts_server.js +18 -0
  35. package/dist/helpers/deviceTransfer.js +2 -11
  36. package/dist/helpers/deviceTransfer.queries.d.ts +4 -0
  37. package/dist/helpers/deviceTransfer.queries.js +11 -0
  38. package/dist/helpers/devices.js +4 -61
  39. package/dist/helpers/devices.queries.d.ts +4 -1
  40. package/dist/helpers/devices.queries.js +52 -0
  41. package/dist/helpers/document_templates.js +6 -52
  42. package/dist/helpers/document_templates.queries.d.ts +9 -0
  43. package/dist/helpers/document_templates.queries.js +56 -0
  44. package/dist/helpers/documents_server.d.ts +226 -0
  45. package/dist/helpers/documents_server.js +38 -0
  46. package/dist/helpers/email.d.ts +0 -6
  47. package/dist/helpers/email.js +1 -19
  48. package/dist/helpers/embeddings.d.ts +0 -5
  49. package/dist/helpers/embeddings.js +2 -19
  50. package/dist/helpers/embeddings.queries.d.ts +7 -0
  51. package/dist/helpers/{embeddings.internal.js → embeddings.queries.js} +2 -2
  52. package/dist/helpers/eventUtils.d.ts +3 -12
  53. package/dist/helpers/eventUtils.js +0 -10
  54. package/dist/helpers/events.d.ts +0 -1
  55. package/dist/helpers/events.js +7 -107
  56. package/dist/helpers/events.queries.d.ts +17 -0
  57. package/dist/helpers/{events.internal.js → events.queries.js} +24 -15
  58. package/dist/helpers/health_metrics.js +3 -38
  59. package/dist/helpers/health_metrics.queries.d.ts +12 -0
  60. package/dist/helpers/health_metrics.queries.js +39 -0
  61. package/dist/helpers/heartbeats.js +4 -83
  62. package/dist/helpers/heartbeats.queries.d.ts +11 -0
  63. package/dist/helpers/heartbeats.queries.js +76 -0
  64. package/dist/helpers/herd_allowed_domains.js +2 -12
  65. package/dist/helpers/{herd_allowed_domains_internal.d.ts → herd_allowed_domains.queries.d.ts} +1 -1
  66. package/dist/helpers/{herd_allowed_domains_internal.js → herd_allowed_domains.queries.js} +2 -2
  67. package/dist/helpers/herd_credentials_server.d.ts +76 -0
  68. package/dist/helpers/herd_credentials_server.js +22 -0
  69. package/dist/helpers/herd_modules.queries.js +10 -7
  70. package/dist/helpers/herd_roles.js +13 -148
  71. package/dist/helpers/herd_roles.queries.d.ts +18 -0
  72. package/dist/helpers/{herd_roles_internal.js → herd_roles.queries.js} +28 -28
  73. package/dist/helpers/herds.js +5 -47
  74. package/dist/helpers/herds.queries.d.ts +8 -1
  75. package/dist/helpers/herds.queries.js +48 -0
  76. package/dist/helpers/invitations.js +7 -58
  77. package/dist/helpers/invitations.queries.d.ts +10 -0
  78. package/dist/helpers/{invitations_internal.js → invitations.queries.js} +12 -12
  79. package/dist/helpers/issuers.js +6 -52
  80. package/dist/helpers/issuers.queries.d.ts +9 -0
  81. package/dist/helpers/issuers.queries.js +53 -0
  82. package/dist/helpers/layers.js +2 -20
  83. package/dist/helpers/layers.queries.d.ts +2 -1
  84. package/dist/helpers/layers.queries.js +9 -13
  85. package/dist/helpers/lifecycle_server.d.ts +175 -0
  86. package/dist/helpers/lifecycle_server.js +38 -0
  87. package/dist/helpers/localizations.js +5 -42
  88. package/dist/helpers/localizations.queries.d.ts +8 -0
  89. package/dist/helpers/localizations.queries.js +45 -0
  90. package/dist/helpers/maintenance_requests_server.d.ts +124 -0
  91. package/dist/helpers/maintenance_requests_server.js +34 -0
  92. package/dist/helpers/manufacturers.js +5 -43
  93. package/dist/helpers/manufacturers.queries.d.ts +10 -0
  94. package/dist/helpers/manufacturers.queries.js +46 -0
  95. package/dist/helpers/media_urls.d.ts +13 -0
  96. package/dist/helpers/media_urls.js +21 -0
  97. package/dist/helpers/models.js +8 -80
  98. package/dist/helpers/models.queries.d.ts +13 -0
  99. package/dist/helpers/models.queries.js +79 -0
  100. package/dist/helpers/observations_server.d.ts +51 -0
  101. package/dist/helpers/observations_server.js +22 -0
  102. package/dist/helpers/operating_contexts.js +39 -154
  103. package/dist/helpers/operating_contexts.queries.d.ts +48 -0
  104. package/dist/helpers/operating_contexts.queries.js +223 -0
  105. package/dist/helpers/operators.js +4 -57
  106. package/dist/helpers/operators.queries.d.ts +7 -0
  107. package/dist/helpers/operators.queries.js +55 -0
  108. package/dist/helpers/parts.d.ts +0 -87
  109. package/dist/helpers/parts.js +4 -90
  110. package/dist/helpers/parts_server.d.ts +260 -0
  111. package/dist/helpers/parts_server.js +71 -0
  112. package/dist/helpers/pins_server.d.ts +118 -0
  113. package/dist/helpers/pins_server.js +38 -0
  114. package/dist/helpers/plans.js +4 -56
  115. package/dist/helpers/plans.queries.d.ts +4 -1
  116. package/dist/helpers/plans.queries.js +39 -12
  117. package/dist/helpers/points_for_user_server.d.ts +9 -0
  118. package/dist/helpers/points_for_user_server.js +14 -0
  119. package/dist/helpers/product_compatibilities.js +6 -78
  120. package/dist/helpers/product_compatibilities.queries.d.ts +9 -0
  121. package/dist/helpers/product_compatibilities.queries.js +83 -0
  122. package/dist/helpers/product_numbers.js +6 -55
  123. package/dist/helpers/product_numbers.queries.d.ts +9 -0
  124. package/dist/helpers/product_numbers.queries.js +58 -0
  125. package/dist/helpers/products.js +6 -54
  126. package/dist/helpers/products.queries.d.ts +11 -0
  127. package/dist/helpers/products.queries.js +58 -0
  128. package/dist/helpers/providers.js +5 -71
  129. package/dist/helpers/providers.queries.d.ts +5 -1
  130. package/dist/helpers/providers.queries.js +52 -11
  131. package/dist/helpers/pubsub_token_server.d.ts +1 -0
  132. package/dist/helpers/pubsub_token_server.js +5 -2
  133. package/dist/helpers/segmentations_sam3.js +5 -78
  134. package/dist/helpers/segmentations_sam3.queries.d.ts +16 -0
  135. package/dist/helpers/segmentations_sam3.queries.js +81 -0
  136. package/dist/helpers/sensor_poses_server.d.ts +98 -0
  137. package/dist/helpers/sensor_poses_server.js +26 -0
  138. package/dist/helpers/session_incidents_server.d.ts +106 -0
  139. package/dist/helpers/session_incidents_server.js +22 -0
  140. package/dist/helpers/session_summaries.d.ts +2 -0
  141. package/dist/helpers/session_summaries.js +7 -23
  142. package/dist/helpers/session_summaries.queries.d.ts +6 -3
  143. package/dist/helpers/session_summaries.queries.js +27 -0
  144. package/dist/helpers/sessions.js +8 -122
  145. package/dist/helpers/sessions.queries.d.ts +14 -2
  146. package/dist/helpers/sessions.queries.js +88 -1
  147. package/dist/helpers/storage.js +0 -1
  148. package/dist/helpers/supabase_auth.d.ts +6 -0
  149. package/dist/helpers/supabase_auth.js +37 -0
  150. package/dist/helpers/tags.d.ts +0 -1
  151. package/dist/helpers/tags.js +13 -559
  152. package/dist/helpers/tags.queries.d.ts +33 -0
  153. package/dist/helpers/tags.queries.js +454 -0
  154. package/dist/helpers/user_credentials_server.d.ts +76 -0
  155. package/dist/helpers/user_credentials_server.js +22 -0
  156. package/dist/helpers/users.d.ts +2 -2
  157. package/dist/helpers/users.js +8 -107
  158. package/dist/helpers/users.queries.d.ts +9 -1
  159. package/dist/helpers/users.queries.js +107 -0
  160. package/dist/helpers/versions_software.d.ts +3 -1
  161. package/dist/helpers/versions_software.js +24 -0
  162. package/dist/helpers/versions_software_server.d.ts +83 -4
  163. package/dist/helpers/versions_software_server.js +23 -50
  164. package/dist/helpers/zones.d.ts +1 -16
  165. package/dist/helpers/zones.js +4 -104
  166. package/dist/helpers/zones.queries.d.ts +6 -0
  167. package/dist/helpers/zones.queries.js +78 -0
  168. package/dist/hooks/useAuthorizedRealtimeTopics.js +8 -2
  169. package/dist/hooks/useInfiniteQuery.js +18 -14
  170. package/dist/hooks/useScoutRealtimeBroadcast.js +8 -6
  171. package/dist/hooks/useScoutRealtimeDocuments.js +3 -2
  172. package/dist/hooks/useScoutRefresh.d.ts +9 -25
  173. package/dist/hooks/useScoutRefresh.js +33 -213
  174. package/dist/providers/ScoutRefreshProvider.d.ts +1 -1
  175. package/dist/providers/ScoutRefreshProvider.js +56 -13
  176. package/dist/server/index.d.ts +77 -0
  177. package/dist/server/index.js +79 -0
  178. package/dist/server/middleware.d.ts +2 -0
  179. package/dist/server/middleware.js +2 -0
  180. package/dist/server/supabase.d.ts +2 -0
  181. package/dist/server/supabase.js +2 -0
  182. package/dist/store/api.d.ts +40 -40
  183. package/dist/store/api.js +38 -109
  184. package/dist/store/configureStore.d.ts +0 -55
  185. package/dist/store/configureStore.js +1 -8
  186. package/dist/store/hooks.js +1 -0
  187. package/dist/supabase/client.d.ts +3 -0
  188. package/dist/supabase/client.js +10 -0
  189. package/dist/supabase/middleware.d.ts +1 -0
  190. package/dist/supabase/middleware.js +6 -20
  191. package/dist/supabase/server.d.ts +7 -2
  192. package/dist/supabase/server.js +13 -1
  193. package/dist/types/db.d.ts +2 -2
  194. package/dist/types/index.d.ts +5 -0
  195. package/dist/types/index.js +5 -0
  196. package/package.json +53 -4
  197. package/dist/api_keys/index.d.ts +0 -1
  198. package/dist/api_keys/index.js +0 -1
  199. package/dist/helpers/artifacts.internal.d.ts +0 -22
  200. package/dist/helpers/client_abilities_jwt_keys_internal.d.ts +0 -9
  201. package/dist/helpers/client_abilities_jwt_keys_internal.js +0 -20
  202. package/dist/helpers/connectivity.internal.d.ts +0 -10
  203. package/dist/helpers/connectivity.internal.js +0 -47
  204. package/dist/helpers/credentials.d.ts +0 -9
  205. package/dist/helpers/credentials.js +0 -92
  206. package/dist/helpers/embeddings.internal.d.ts +0 -5
  207. package/dist/helpers/events.internal.d.ts +0 -13
  208. package/dist/helpers/herd_roles_internal.d.ts +0 -18
  209. package/dist/helpers/index.d.ts +0 -56
  210. package/dist/helpers/index.js +0 -56
  211. package/dist/helpers/invitations_internal.d.ts +0 -10
  212. package/dist/helpers/versions_software_internal.d.ts +0 -6
  213. package/dist/helpers/versions_software_internal.js +0 -53
  214. package/dist/hooks/useDeviceDisplayName.d.ts +0 -8
  215. package/dist/hooks/useDeviceDisplayName.js +0 -49
  216. package/dist/index.d.ts +0 -108
  217. package/dist/index.js +0 -114
  218. package/dist/supabase/index.d.ts +0 -2
  219. package/dist/supabase/index.js +0 -2
@@ -1,8 +1,8 @@
1
+ "use client";
1
2
  import { configureStore } from "@reduxjs/toolkit";
2
3
  import { setupListeners } from "@reduxjs/toolkit/query";
3
4
  import scoutReducer from "./scout";
4
5
  import { scoutApi } from "./api";
5
- // Configure the Redux store
6
6
  export const configureScoutStore = () => {
7
7
  const store = configureStore({
8
8
  reducer: {
@@ -11,12 +11,10 @@ export const configureScoutStore = () => {
11
11
  },
12
12
  middleware: (getDefaultMiddleware) => getDefaultMiddleware({
13
13
  serializableCheck: {
14
- // Ignore these action types for serializable check
15
14
  ignoredActions: [
16
15
  "persist/PERSIST",
17
16
  "persist/REHYDRATE",
18
17
  "persist/REGISTER",
19
- // RTK Query actions
20
18
  "scoutApi/executeQuery/pending",
21
19
  "scoutApi/executeQuery/fulfilled",
22
20
  "scoutApi/executeQuery/rejected",
@@ -24,17 +22,12 @@ export const configureScoutStore = () => {
24
22
  "scoutApi/executeMutation/fulfilled",
25
23
  "scoutApi/executeMutation/rejected",
26
24
  ],
27
- // Ignore these field paths in all actions
28
25
  ignoredActionsPaths: ["meta.arg", "payload.timestamp"],
29
- // Ignore these paths in the state
30
26
  ignoredPaths: ["scoutApi.queries", "scoutApi.mutations"],
31
27
  },
32
28
  }).concat(scoutApi.middleware),
33
29
  devTools: process.env.NODE_ENV !== "production",
34
30
  });
35
- // Enable listener behavior for the store
36
31
  setupListeners(store.dispatch);
37
32
  return store;
38
33
  };
39
- // Create a default store instance
40
- export const store = configureScoutStore();
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { useDispatch, useSelector } from "react-redux";
2
3
  import { EnumHerdModulesLoadingState } from "../types/herd_module";
3
4
  // Simple wrapper for useDispatch to maintain compatibility
@@ -0,0 +1,3 @@
1
+ import type { SupabaseClient } from "@supabase/supabase-js";
2
+ import type { Database } from "../types/supabase";
3
+ export declare function createScoutBrowserClient(): SupabaseClient<Database>;
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { createBrowserClient } from "@supabase/ssr";
3
+ export function createScoutBrowserClient() {
4
+ const url = process.env.NEXT_PUBLIC_SUPABASE_URL;
5
+ const anonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
6
+ if (!url || !anonKey) {
7
+ throw new Error("Missing required Supabase environment variables");
8
+ }
9
+ return createBrowserClient(url, anonKey);
10
+ }
@@ -1,3 +1,4 @@
1
+ import "server-only";
1
2
  import { NextResponse, type NextRequest } from "next/server";
2
3
  export interface IOptionsMiddlewareAuth {
3
4
  allowed_email_domains?: string[];
@@ -1,7 +1,7 @@
1
+ import "server-only";
1
2
  import { createServerClient } from "@supabase/ssr";
2
3
  import { NextResponse } from "next/server";
3
4
  export async function updateSession(request, options) {
4
- // Validate environment variables
5
5
  const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
6
6
  const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
7
7
  if (!supabaseUrl || !supabaseAnonKey) {
@@ -20,37 +20,23 @@ export async function updateSession(request, options) {
20
20
  },
21
21
  },
22
22
  });
23
- // IMPORTANT: Avoid writing any logic between createServerClient and
24
- // supabase.auth.getClaims(). A simple mistake could make it very hard to debug
25
- // issues with users being randomly logged out.
26
23
  const { data: claims, error } = await supabase.auth.getClaims();
27
- // Check if current path is allowed without authentication
28
24
  const isPublicPath = options.allowed_page_paths_without_auth.some((page) => request.nextUrl.pathname.startsWith(page));
29
25
  if (isPublicPath) {
30
26
  return supabaseResponse;
31
27
  }
32
- // Check authentication requirements
33
28
  const hasValidClaims = !error && claims?.claims?.sub;
34
29
  const hasValidEmail = claims?.claims?.email &&
35
30
  (!options.allowed_email_domains ||
36
31
  options.allowed_email_domains.some((domain) => claims.claims.email.endsWith(`@${domain}`)));
37
32
  if (!hasValidClaims || (claims?.claims?.email && !hasValidEmail)) {
38
- // no valid claims - respond by redirecting the user to the login page
39
33
  const url = request.nextUrl.clone();
40
34
  url.pathname = options.login_page_path;
41
- return NextResponse.redirect(url);
35
+ const redirect = NextResponse.redirect(url);
36
+ supabaseResponse.cookies
37
+ .getAll()
38
+ .forEach((cookie) => redirect.cookies.set(cookie));
39
+ return redirect;
42
40
  }
43
- // IMPORTANT: You *must* return the supabaseResponse object as it is. If you're
44
- // creating a new response object with NextResponse.next() make sure to:
45
- // 1. Pass the request in it, like so:
46
- // const myNewResponse = NextResponse.next({ request })
47
- // 2. Copy over the cookies, like so:
48
- // myNewResponse.cookies.setAll(supabaseResponse.cookies.getAll())
49
- // 3. Change the myNewResponse object to fit your needs, but avoid changing
50
- // the cookies!
51
- // 4. Finally:
52
- // return myNewResponse
53
- // If this is not done, you may be causing the browser and server to go out
54
- // of sync and terminate the user's session prematurely!
55
41
  return supabaseResponse;
56
42
  }
@@ -1,6 +1,11 @@
1
- import { Database } from "../types/supabase";
2
- import { SupabaseClient } from "@supabase/supabase-js";
1
+ import "server-only";
2
+ import type { Database } from "../types/supabase";
3
+ import type { SupabaseClient } from "@supabase/supabase-js";
3
4
  export interface IServerClientOptions {
4
5
  persistSession?: boolean;
5
6
  }
7
+ /**
8
+ * Reuses one read client per RSC request. Cookie writes are opt-in for
9
+ * auth-mutating actions; middleware persists normal session refreshes.
10
+ */
6
11
  export declare function newServerClient(options?: IServerClientOptions): Promise<SupabaseClient<Database>>;
@@ -1,6 +1,8 @@
1
+ import "server-only";
1
2
  import { createServerClient } from "@supabase/ssr";
2
3
  import { cookies } from "next/headers";
3
- export async function newServerClient(options = {}) {
4
+ import { cache } from "react";
5
+ async function createRequestClient(options) {
4
6
  const cookieStore = await cookies();
5
7
  return createServerClient(process.env.NEXT_PUBLIC_SUPABASE_URL, process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY, {
6
8
  cookies: {
@@ -21,3 +23,13 @@ export async function newServerClient(options = {}) {
21
23
  },
22
24
  });
23
25
  }
26
+ const cachedRequestClient = cache(() => createRequestClient({}));
27
+ /**
28
+ * Reuses one read client per RSC request. Cookie writes are opt-in for
29
+ * auth-mutating actions; middleware persists normal session refreshes.
30
+ */
31
+ export function newServerClient(options = {}) {
32
+ return options.persistSession
33
+ ? createRequestClient(options)
34
+ : cachedRequestClient();
35
+ }
@@ -1,5 +1,5 @@
1
- import { SupabaseClient, User } from "@supabase/supabase-js";
2
- import { Database } from "./supabase";
1
+ import type { SupabaseClient, User } from "@supabase/supabase-js";
2
+ import type { Database } from "./supabase";
3
3
  export type ScoutDatabaseClient = SupabaseClient<Database, "public">;
4
4
  export type DeviceType = Database["public"]["Enums"]["device_type"];
5
5
  export type MediaType = Database["public"]["Enums"]["media_type"];
@@ -4,7 +4,12 @@ export * from "./ui";
4
4
  export * from "./requests";
5
5
  export * from "./gps";
6
6
  export * from "./supabase";
7
+ export * from "./bounding_boxes";
7
8
  export * from "./events";
8
9
  export * from "./data_source";
9
10
  export * from "./connectivity";
10
11
  export * from "./historical";
12
+ export * from "./realtime";
13
+ export * from "./pubsub_token";
14
+ export * from "./client_abilities_token";
15
+ export * from "./jwt_mint";
@@ -4,7 +4,12 @@ export * from "./ui";
4
4
  export * from "./requests";
5
5
  export * from "./gps";
6
6
  export * from "./supabase";
7
+ export * from "./bounding_boxes";
7
8
  export * from "./events";
8
9
  export * from "./data_source";
9
10
  export * from "./connectivity";
10
11
  export * from "./historical";
12
+ export * from "./realtime";
13
+ export * from "./pubsub_token";
14
+ export * from "./client_abilities_token";
15
+ export * from "./jwt_mint";
package/package.json CHANGED
@@ -1,9 +1,57 @@
1
1
  {
2
2
  "name": "@adventurelabs/scout-core",
3
- "version": "1.5.4",
3
+ "version": "2.0.0",
4
4
  "description": "Core utilities and helpers for Adventure Labs Scout applications",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
5
+ "exports": {
6
+ "./client": {
7
+ "types": "./dist/client/index.d.ts",
8
+ "import": "./dist/client/index.js",
9
+ "default": "./dist/client/index.js"
10
+ },
11
+ "./server": {
12
+ "types": "./dist/server/index.d.ts",
13
+ "react-server": "./dist/server/index.js",
14
+ "import": "./dist/server/index.js",
15
+ "default": "./dist/server/index.js"
16
+ },
17
+ "./server/middleware": {
18
+ "types": "./dist/server/middleware.d.ts",
19
+ "react-server": "./dist/server/middleware.js",
20
+ "import": "./dist/server/middleware.js",
21
+ "default": "./dist/server/middleware.js"
22
+ },
23
+ "./server/supabase": {
24
+ "types": "./dist/server/supabase.d.ts",
25
+ "react-server": "./dist/server/supabase.js",
26
+ "import": "./dist/server/supabase.js",
27
+ "default": "./dist/server/supabase.js"
28
+ },
29
+ "./types": {
30
+ "types": "./dist/types/index.d.ts",
31
+ "import": "./dist/types/index.js",
32
+ "default": "./dist/types/index.js"
33
+ },
34
+ "./package.json": "./package.json"
35
+ },
36
+ "typesVersions": {
37
+ "*": {
38
+ "client": [
39
+ "dist/client/index.d.ts"
40
+ ],
41
+ "server": [
42
+ "dist/server/index.d.ts"
43
+ ],
44
+ "server/middleware": [
45
+ "dist/server/middleware.d.ts"
46
+ ],
47
+ "server/supabase": [
48
+ "dist/server/supabase.d.ts"
49
+ ],
50
+ "types": [
51
+ "dist/types/index.d.ts"
52
+ ]
53
+ }
54
+ },
7
55
  "files": [
8
56
  "dist",
9
57
  "README.md"
@@ -57,6 +105,7 @@
57
105
  },
58
106
  "dependencies": {
59
107
  "dequal": "^2.0.3",
60
- "jose": "5"
108
+ "jose": "5",
109
+ "server-only": "^0.0.1"
61
110
  }
62
111
  }
@@ -1 +0,0 @@
1
- export * from "./actions";
@@ -1 +0,0 @@
1
- export * from "./actions";
@@ -1,22 +0,0 @@
1
- import { SupabaseClient } from "@supabase/supabase-js";
2
- import { IArtifact, IArtifactWithMediaUrl, ArtifactInsert, ArtifactUpdate } from "../types/db";
3
- import { IWebResponseCompatible } from "../types/requests";
4
- import type { Database } from "../types/supabase";
5
- export interface ArtifactTimeRangeOptions {
6
- start_timestamp?: string;
7
- end_timestamp?: string;
8
- }
9
- export declare function getArtifactByIdWithClient(client: SupabaseClient<Database>, id: number): Promise<IWebResponseCompatible<IArtifactWithMediaUrl | null>>;
10
- export declare function getArtifactsByHerdWithClient(client: SupabaseClient<Database>, herd_id: number, limit: number, offset: number, options: ArtifactTimeRangeOptions | undefined): Promise<IWebResponseCompatible<IArtifactWithMediaUrl[]>>;
11
- export declare function getArtifactsByDeviceIdWithClient(client: SupabaseClient<Database>, device_id: number, limit: number, offset: number): Promise<IWebResponseCompatible<IArtifactWithMediaUrl[]>>;
12
- export declare function getArtifactsByDeviceIdsBatchWithClient(client: SupabaseClient<Database>, device_ids: number[], limit_per_device: number, options: ArtifactTimeRangeOptions | undefined): Promise<{
13
- [device_id: number]: IArtifactWithMediaUrl[];
14
- }>;
15
- export declare function insertArtifactWithClient(client: SupabaseClient<Database>, artifact: ArtifactInsert | ArtifactInsert[]): Promise<IWebResponseCompatible<IArtifact[]>>;
16
- export declare function updateArtifactWithClient(client: SupabaseClient<Database>, artifact: (ArtifactUpdate & {
17
- id: number;
18
- }) | (ArtifactUpdate & {
19
- id: number;
20
- })[]): Promise<IWebResponseCompatible<IArtifact[]>>;
21
- export declare function deleteArtifactWithClient(client: SupabaseClient<Database>, id: number | number[]): Promise<IWebResponseCompatible<boolean>>;
22
- export declare function matchArtifactsByVertexEmbeddingWithClient(client: SupabaseClient<Database>, query_embedding: number[], match_threshold: number, match_count: number, herd_id: number | null | undefined): Promise<IWebResponseCompatible<IArtifact[]>>;
@@ -1,9 +0,0 @@
1
- import { SupabaseClient } from "@supabase/supabase-js";
2
- import { IWebResponseCompatible } from "../types/requests";
3
- import { Database, Json } from "../types/supabase";
4
- export type ClientAbilitiesPublicJwk = Record<string, Json | undefined> & {
5
- kty: string;
6
- kid?: string;
7
- };
8
- export declare function upsert_client_abilities_jwt_public_key(client: SupabaseClient<Database>, kid: string, publicJwk: ClientAbilitiesPublicJwk): Promise<IWebResponseCompatible<null>>;
9
- export declare function revoke_client_abilities_jwt_public_key(client: SupabaseClient<Database>, kid: string): Promise<IWebResponseCompatible<null>>;
@@ -1,20 +0,0 @@
1
- import { IWebResponse } from "../types/requests";
2
- export async function upsert_client_abilities_jwt_public_key(client, kid, publicJwk) {
3
- const { error } = await client.rpc("upsert_client_abilities_jwt_public_key", {
4
- p_kid: kid,
5
- p_public_jwk: publicJwk,
6
- });
7
- if (error) {
8
- return IWebResponse.error(error.message).to_compatible();
9
- }
10
- return IWebResponse.success(null).to_compatible();
11
- }
12
- export async function revoke_client_abilities_jwt_public_key(client, kid) {
13
- const { error } = await client.rpc("revoke_client_abilities_jwt_public_key", {
14
- p_kid: kid,
15
- });
16
- if (error) {
17
- return IWebResponse.error(error.message).to_compatible();
18
- }
19
- return IWebResponse.success(null).to_compatible();
20
- }
@@ -1,10 +0,0 @@
1
- import { SupabaseClient } from "@supabase/supabase-js";
2
- import { IConnectivity, ConnectivityInsert, ConnectivityUpdate } from "../types/db";
3
- import { IWebResponseCompatible } from "../types/requests";
4
- import type { Database } from "../types/supabase";
5
- export declare function insertConnectivityWithClient(client: SupabaseClient<Database>, connectivity: ConnectivityInsert | ConnectivityInsert[]): Promise<IWebResponseCompatible<IConnectivity[]>>;
6
- export declare function updateConnectivityWithClient(client: SupabaseClient<Database>, connectivity: (ConnectivityUpdate & {
7
- id: number;
8
- }) | (ConnectivityUpdate & {
9
- id: number;
10
- })[]): Promise<IWebResponseCompatible<IConnectivity[]>>;
@@ -1,47 +0,0 @@
1
- import { EnumWebResponse, IWebResponse, } from "../types/requests";
2
- export async function insertConnectivityWithClient(client, connectivity) {
3
- const connectivityArray = Array.isArray(connectivity)
4
- ? connectivity
5
- : [connectivity];
6
- const { data, error } = await client
7
- .from("connectivity")
8
- .insert(connectivityArray)
9
- .select("*");
10
- if (error) {
11
- console.warn("Error inserting connectivity:", error.message);
12
- return {
13
- status: EnumWebResponse.ERROR,
14
- msg: error.message,
15
- data: [],
16
- };
17
- }
18
- return IWebResponse.success(data || []).to_compatible();
19
- }
20
- export async function updateConnectivityWithClient(client, connectivity) {
21
- const connectivityArray = Array.isArray(connectivity)
22
- ? connectivity
23
- : [connectivity];
24
- const updatedConnectivity = [];
25
- for (const record of connectivityArray) {
26
- const { id, ...updateData } = record;
27
- delete updateData.inserted_at;
28
- const { data, error } = await client
29
- .from("connectivity")
30
- .update(updateData)
31
- .eq("id", id)
32
- .select("*")
33
- .single();
34
- if (error) {
35
- console.warn("Error updating connectivity:", error.message);
36
- return {
37
- status: EnumWebResponse.ERROR,
38
- msg: error.message,
39
- data: [],
40
- };
41
- }
42
- if (data) {
43
- updatedConnectivity.push(data);
44
- }
45
- }
46
- return IWebResponse.success(updatedConnectivity).to_compatible();
47
- }
@@ -1,9 +0,0 @@
1
- import { Database } from "../types/supabase";
2
- import { CredentialInsert, CredentialUpdate, ICredential } from "../types/db";
3
- import { IWebResponseCompatible } from "../types/requests";
4
- import { SupabaseClient } from "@supabase/supabase-js";
5
- export declare function get_credentials_by_user_id(client: SupabaseClient<Database>, user_id: string): Promise<IWebResponseCompatible<ICredential[]>>;
6
- export declare function get_credential_by_id(client: SupabaseClient<Database>, credential_id: number, user_id: string): Promise<IWebResponseCompatible<ICredential | null>>;
7
- export declare function create_credential(client: SupabaseClient<Database>, row: CredentialInsert): Promise<IWebResponseCompatible<ICredential | null>>;
8
- export declare function update_credential(client: SupabaseClient<Database>, credential_id: number, user_id: string, patch: CredentialUpdate): Promise<IWebResponseCompatible<ICredential | null>>;
9
- export declare function delete_credential(client: SupabaseClient<Database>, credential_id: number, user_id: string): Promise<IWebResponseCompatible<ICredential | null>>;
@@ -1,92 +0,0 @@
1
- import { IWebResponse } from "../types/requests";
2
- export async function get_credentials_by_user_id(client, user_id) {
3
- const { data, error } = await client
4
- .from("credentials")
5
- .select("*")
6
- .eq("user_id", user_id)
7
- .order("created_at", { ascending: false });
8
- if (error) {
9
- return IWebResponse.error(error.message).to_compatible();
10
- }
11
- return IWebResponse.success(data ?? []).to_compatible();
12
- }
13
- export async function get_credential_by_id(client, credential_id, user_id) {
14
- const { data, error } = await client
15
- .from("credentials")
16
- .select("*")
17
- .eq("id", credential_id)
18
- .eq("user_id", user_id)
19
- .single();
20
- if (error) {
21
- return IWebResponse.error(error.message).to_compatible();
22
- }
23
- if (!data) {
24
- return IWebResponse.error("Credential not found")
25
- .to_compatible();
26
- }
27
- return IWebResponse.success(data).to_compatible();
28
- }
29
- export async function create_credential(client, row) {
30
- if (!row.user_id) {
31
- return IWebResponse.error("user_id is required")
32
- .to_compatible();
33
- }
34
- if (!row.issuer?.trim()) {
35
- return IWebResponse.error("issuer is required")
36
- .to_compatible();
37
- }
38
- if (!row.type?.trim()) {
39
- return IWebResponse.error("type is required")
40
- .to_compatible();
41
- }
42
- const { data, error } = await client
43
- .from("credentials")
44
- .insert([row])
45
- .select("*")
46
- .single();
47
- if (error) {
48
- return IWebResponse.error(error.message).to_compatible();
49
- }
50
- if (!data) {
51
- return IWebResponse.error("Failed to create credential").to_compatible();
52
- }
53
- return IWebResponse.success(data).to_compatible();
54
- }
55
- export async function update_credential(client, credential_id, user_id, patch) {
56
- const { id: _id, user_id: _uid, created_at: _ca, ...updateData } = patch;
57
- if (Object.keys(updateData).length === 0) {
58
- return IWebResponse.error("No valid fields to update").to_compatible();
59
- }
60
- const { data, error } = await client
61
- .from("credentials")
62
- .update(updateData)
63
- .eq("id", credential_id)
64
- .eq("user_id", user_id)
65
- .select("*")
66
- .single();
67
- if (error) {
68
- return IWebResponse.error(error.message).to_compatible();
69
- }
70
- if (!data) {
71
- return IWebResponse.error("Credential not found")
72
- .to_compatible();
73
- }
74
- return IWebResponse.success(data).to_compatible();
75
- }
76
- export async function delete_credential(client, credential_id, user_id) {
77
- const { data, error } = await client
78
- .from("credentials")
79
- .delete()
80
- .eq("id", credential_id)
81
- .eq("user_id", user_id)
82
- .select("*")
83
- .single();
84
- if (error) {
85
- return IWebResponse.error(error.message).to_compatible();
86
- }
87
- if (!data) {
88
- return IWebResponse.error("Credential not found")
89
- .to_compatible();
90
- }
91
- return IWebResponse.success(data).to_compatible();
92
- }
@@ -1,5 +0,0 @@
1
- import { SupabaseClient } from "@supabase/supabase-js";
2
- import type { IEmbeddingSearchResult } from "../types/db";
3
- import { IWebResponseCompatible } from "../types/requests";
4
- import type { Database } from "../types/supabase";
5
- export declare function searchEmbeddingsVertexMultimodal001WithClient(client: SupabaseClient<Database>, query_embedding: number[], match_threshold: number, match_count: number, herd_id: number | null | undefined): Promise<IWebResponseCompatible<IEmbeddingSearchResult[]>>;
@@ -1,13 +0,0 @@
1
- import { SupabaseClient } from "@supabase/supabase-js";
2
- import { IEvent, IEventWithMediaUrl, EventInsert, EventUpdate } from "../types/db";
3
- import { IWebResponseCompatible } from "../types/requests";
4
- import type { Database } from "../types/supabase";
5
- export declare function getEventByIdWithClient(client: SupabaseClient<Database>, id: number): Promise<IWebResponseCompatible<IEventWithMediaUrl | null>>;
6
- export declare function insertEventWithClient(client: SupabaseClient<Database>, events: EventInsert | EventInsert[]): Promise<IWebResponseCompatible<IEvent[]>>;
7
- export declare function updateEventWithClient(client: SupabaseClient<Database>, events: (EventUpdate & {
8
- id: number;
9
- }) | (EventUpdate & {
10
- id: number;
11
- })[]): Promise<IWebResponseCompatible<IEvent[]>>;
12
- export declare function deleteEventWithClient(client: SupabaseClient<Database>, id: number | number[]): Promise<IWebResponseCompatible<boolean>>;
13
- export declare function matchEventsByVertexEmbeddingWithClient(client: SupabaseClient<Database>, query_embedding: number[], match_threshold: number, match_count: number, herd_id: number | null | undefined): Promise<IWebResponseCompatible<IEvent[]>>;
@@ -1,18 +0,0 @@
1
- import { SupabaseClient } from "@supabase/supabase-js";
2
- import { IAbility, IHerdRole, IHerdRoleAbilityRow, IHerdRoleWithAbilities, IPlatformDefaultRoleAbilitiesGroup } from "../types/db";
3
- import { IWebResponseCompatible } from "../types/requests";
4
- import { Database } from "../types/supabase";
5
- export declare function listAbilitiesWithClient(supabase: SupabaseClient<Database>): Promise<IWebResponseCompatible<IAbility[]>>;
6
- export declare function getAbilitiesByIdsWithClient(supabase: SupabaseClient<Database>, ids: number[]): Promise<IWebResponseCompatible<IAbility[]>>;
7
- export declare function getHerdRolesWithClient(supabase: SupabaseClient<Database>, herd_id: number): Promise<IWebResponseCompatible<IHerdRole[]>>;
8
- export declare function getHerdRolesWithAbilitiesWithClient(supabase: SupabaseClient<Database>, herd_id: number): Promise<IWebResponseCompatible<IHerdRoleWithAbilities[]>>;
9
- export declare function getHerdRoleBySystemNameWithClient(supabase: SupabaseClient<Database>, herd_id: number, system_name: string): Promise<IWebResponseCompatible<IHerdRole | null>>;
10
- export declare function createHerdRoleWithClient(supabase: SupabaseClient<Database>, herd_id: number, system_name: string, name: string): Promise<IWebResponseCompatible<IHerdRole | null>>;
11
- export declare function updateHerdRoleWithClient(supabase: SupabaseClient<Database>, herd_role_id: number, patch: {
12
- name?: string;
13
- }): Promise<IWebResponseCompatible<IHerdRole | null>>;
14
- export declare function deleteHerdRoleWithClient(supabase: SupabaseClient<Database>, herd_role_id: number): Promise<IWebResponseCompatible<null>>;
15
- export declare function setHerdRoleAbilitiesWithClient(supabase: SupabaseClient<Database>, herd_role_id: number, ability_ids: number[]): Promise<IWebResponseCompatible<IHerdRoleAbilityRow[]>>;
16
- export declare function getPlatformDefaultRoleAbilitiesWithClient(supabase: SupabaseClient<Database>): Promise<IWebResponseCompatible<IPlatformDefaultRoleAbilitiesGroup[]>>;
17
- export declare function setPlatformDefaultRoleAbilitiesWithClient(supabase: SupabaseClient<Database>, system_name: string, ability_keys: string[]): Promise<IWebResponseCompatible<null>>;
18
- export declare function resetHerdDefaultRoleAbilitiesWithClient(supabase: SupabaseClient<Database>, herd_id: number): Promise<IWebResponseCompatible<null>>;
@@ -1,56 +0,0 @@
1
- export * from "./analysis_usage";
2
- export * from "./auth";
3
- export * from "./bounding_boxes";
4
- export * from "./chat";
5
- export * from "./certificates";
6
- export * from "./user_credentials";
7
- export * from "./herd_credentials";
8
- export * from "./db";
9
- export * from "./devices";
10
- export * from "./email";
11
- export * from "./events";
12
- export * from "./gps";
13
- export * from "./health_metrics";
14
- export * from "./heartbeats";
15
- export * from "./herds";
16
- export * from "./location";
17
- export * from "./lifecycle";
18
- export * from "./models";
19
- export * from "./manufacturers";
20
- export * from "./products";
21
- export * from "./product_numbers";
22
- export * from "./product_compatibilities";
23
- export * from "./localizations";
24
- export * from "./issuers";
25
- export * from "./document_templates";
26
- export * from "./documents";
27
- export * from "./maintenance_requests";
28
- export * from "./session_incidents";
29
- export * from "./contacts";
30
- export * from "./operating_contexts";
31
- export * from "./plans";
32
- export * from "./sessions";
33
- export * from "./segmentations_sam3";
34
- export * from "./tags";
35
- export * from "./time";
36
- export * from "./ui";
37
- export * from "./users";
38
- export * from "./web";
39
- export * from "./zones";
40
- export * from "./cache";
41
- export * from "./observations";
42
- export * from "./operators";
43
- export * from "./parts";
44
- export * from "./sensor_poses";
45
- export * from "./versions_software";
46
- export * from "./versions_software_server";
47
- export * from "./artifacts";
48
- export * from "./pins";
49
- export * from "./points_for_user";
50
- export * from "./pubsub_token";
51
- export * from "./pubsub_token_server";
52
- export * from "./client_abilities_token";
53
- export * from "./client_abilities_token_server";
54
- export * from "./client_abilities_jwt_keys";
55
- export * from "./herd_roles";
56
- export * from "./storagePath";
@@ -1,56 +0,0 @@
1
- export * from "./analysis_usage";
2
- export * from "./auth";
3
- export * from "./bounding_boxes";
4
- export * from "./chat";
5
- export * from "./certificates";
6
- export * from "./user_credentials";
7
- export * from "./herd_credentials";
8
- export * from "./db";
9
- export * from "./devices";
10
- export * from "./email";
11
- export * from "./events";
12
- export * from "./gps";
13
- export * from "./health_metrics";
14
- export * from "./heartbeats";
15
- export * from "./herds";
16
- export * from "./location";
17
- export * from "./lifecycle";
18
- export * from "./models";
19
- export * from "./manufacturers";
20
- export * from "./products";
21
- export * from "./product_numbers";
22
- export * from "./product_compatibilities";
23
- export * from "./localizations";
24
- export * from "./issuers";
25
- export * from "./document_templates";
26
- export * from "./documents";
27
- export * from "./maintenance_requests";
28
- export * from "./session_incidents";
29
- export * from "./contacts";
30
- export * from "./operating_contexts";
31
- export * from "./plans";
32
- export * from "./sessions";
33
- export * from "./segmentations_sam3";
34
- export * from "./tags";
35
- export * from "./time";
36
- export * from "./ui";
37
- export * from "./users";
38
- export * from "./web";
39
- export * from "./zones";
40
- export * from "./cache";
41
- export * from "./observations";
42
- export * from "./operators";
43
- export * from "./parts";
44
- export * from "./sensor_poses";
45
- export * from "./versions_software";
46
- export * from "./versions_software_server";
47
- export * from "./artifacts";
48
- export * from "./pins";
49
- export * from "./points_for_user";
50
- export * from "./pubsub_token";
51
- export * from "./pubsub_token_server";
52
- export * from "./client_abilities_token";
53
- export * from "./client_abilities_token_server";
54
- export * from "./client_abilities_jwt_keys";
55
- export * from "./herd_roles";
56
- export * from "./storagePath";