@indiciaosint/sdk 1.1.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 (191) hide show
  1. package/FUNCTIONS.md +1 -1
  2. package/README.md +53 -13
  3. package/esm/funcs/activity-delete-activity.js +3 -3
  4. package/esm/funcs/activity-delete-activity.js.map +1 -1
  5. package/esm/funcs/activity-get-activity.js +3 -3
  6. package/esm/funcs/activity-get-activity.js.map +1 -1
  7. package/esm/funcs/activity-list-activities.js +3 -3
  8. package/esm/funcs/activity-list-activities.js.map +1 -1
  9. package/esm/funcs/infrastructure-scan-ports.d.ts +2 -127
  10. package/esm/funcs/infrastructure-scan-ports.d.ts.map +1 -1
  11. package/esm/funcs/infrastructure-scan-ports.js +12 -131
  12. package/esm/funcs/infrastructure-scan-ports.js.map +1 -1
  13. package/esm/funcs/infrastructure-search-certificates.js +3 -3
  14. package/esm/funcs/infrastructure-search-certificates.js.map +1 -1
  15. package/esm/funcs/infrastructure-search-dns.js +3 -3
  16. package/esm/funcs/infrastructure-search-dns.js.map +1 -1
  17. package/esm/funcs/infrastructure-search-ip-info.js +3 -3
  18. package/esm/funcs/infrastructure-search-ip-info.js.map +1 -1
  19. package/esm/funcs/infrastructure-search-shodan.js +3 -3
  20. package/esm/funcs/infrastructure-search-shodan.js.map +1 -1
  21. package/esm/funcs/infrastructure-search-whois.js +3 -3
  22. package/esm/funcs/infrastructure-search-whois.js.map +1 -1
  23. package/esm/funcs/intelligence-geolocate-media.d.ts +2 -13
  24. package/esm/funcs/intelligence-geolocate-media.d.ts.map +1 -1
  25. package/esm/funcs/intelligence-geolocate-media.js +12 -17
  26. package/esm/funcs/intelligence-geolocate-media.js.map +1 -1
  27. package/esm/funcs/intelligence-search-address.js +3 -3
  28. package/esm/funcs/intelligence-search-address.js.map +1 -1
  29. package/esm/funcs/intelligence-search-email.js +3 -3
  30. package/esm/funcs/intelligence-search-email.js.map +1 -1
  31. package/esm/funcs/intelligence-search-face.d.ts +2 -1
  32. package/esm/funcs/intelligence-search-face.d.ts.map +1 -1
  33. package/esm/funcs/intelligence-search-face.js +12 -5
  34. package/esm/funcs/intelligence-search-face.js.map +1 -1
  35. package/esm/funcs/intelligence-search-gmail.js +3 -3
  36. package/esm/funcs/intelligence-search-gmail.js.map +1 -1
  37. package/esm/funcs/intelligence-search-hudson-rock.js +3 -3
  38. package/esm/funcs/intelligence-search-hudson-rock.js.map +1 -1
  39. package/esm/funcs/intelligence-search-person.js +3 -3
  40. package/esm/funcs/intelligence-search-person.js.map +1 -1
  41. package/esm/funcs/intelligence-search-phone.js +3 -3
  42. package/esm/funcs/intelligence-search-phone.js.map +1 -1
  43. package/esm/funcs/intelligence-search-seon.js +3 -3
  44. package/esm/funcs/intelligence-search-seon.js.map +1 -1
  45. package/esm/funcs/intelligence-search-web-databases.js +3 -3
  46. package/esm/funcs/intelligence-search-web-databases.js.map +1 -1
  47. package/esm/funcs/organizations-get-organization-audit-log.js +3 -3
  48. package/esm/funcs/organizations-get-organization-audit-log.js.map +1 -1
  49. package/esm/funcs/organizations-get-organization.js +3 -3
  50. package/esm/funcs/organizations-get-organization.js.map +1 -1
  51. package/esm/funcs/organizations-list-organization-cases.js +3 -3
  52. package/esm/funcs/organizations-list-organization-cases.js.map +1 -1
  53. package/esm/funcs/organizations-list-organization-members.js +3 -3
  54. package/esm/funcs/organizations-list-organization-members.js.map +1 -1
  55. package/esm/funcs/organizations-list-organizations.js +3 -3
  56. package/esm/funcs/organizations-list-organizations.js.map +1 -1
  57. package/esm/funcs/organizations-send-organization-credits.js +3 -3
  58. package/esm/funcs/organizations-send-organization-credits.js.map +1 -1
  59. package/esm/funcs/pricing-get-pricing.js +3 -3
  60. package/esm/funcs/pricing-get-pricing.js.map +1 -1
  61. package/esm/funcs/socials-search-discord.js +3 -3
  62. package/esm/funcs/socials-search-discord.js.map +1 -1
  63. package/esm/funcs/socials-search-github.js +3 -3
  64. package/esm/funcs/socials-search-github.js.map +1 -1
  65. package/esm/funcs/socials-search-roblox.js +3 -3
  66. package/esm/funcs/socials-search-roblox.js.map +1 -1
  67. package/esm/funcs/socials-search-tiktok.js +3 -3
  68. package/esm/funcs/socials-search-tiktok.js.map +1 -1
  69. package/esm/funcs/socials-search-username.js +3 -3
  70. package/esm/funcs/socials-search-username.js.map +1 -1
  71. package/esm/funcs/tools-bypass-double-counter.js +3 -3
  72. package/esm/funcs/tools-bypass-double-counter.js.map +1 -1
  73. package/esm/funcs/tools-download-intelx-file.js +3 -3
  74. package/esm/funcs/tools-download-intelx-file.js.map +1 -1
  75. package/esm/funcs/tools-lookup-discord-alt.js +3 -3
  76. package/esm/funcs/tools-lookup-discord-alt.js.map +1 -1
  77. package/esm/funcs/users-get-info.js +3 -3
  78. package/esm/funcs/users-get-info.js.map +1 -1
  79. package/esm/hooks/hooks.d.ts.map +1 -1
  80. package/esm/hooks/hooks.js +2 -0
  81. package/esm/hooks/hooks.js.map +1 -1
  82. package/esm/hooks/registration.d.ts +3 -0
  83. package/esm/hooks/registration.d.ts.map +1 -0
  84. package/esm/hooks/registration.js +12 -0
  85. package/esm/hooks/registration.js.map +1 -0
  86. package/esm/lib/config.d.ts +4 -4
  87. package/esm/lib/config.d.ts.map +1 -1
  88. package/esm/lib/config.js +3 -3
  89. package/esm/lib/env.d.ts +1 -1
  90. package/esm/lib/env.d.ts.map +1 -1
  91. package/esm/lib/env.js +1 -1
  92. package/esm/lib/env.js.map +1 -1
  93. package/esm/lib/event-streams.d.ts +23 -0
  94. package/esm/lib/event-streams.d.ts.map +1 -0
  95. package/esm/lib/event-streams.js +163 -0
  96. package/esm/lib/event-streams.js.map +1 -0
  97. package/esm/lib/security.js +1 -1
  98. package/esm/lib/security.js.map +1 -1
  99. package/esm/models/operations/geolocate-media.d.ts +91 -0
  100. package/esm/models/operations/geolocate-media.d.ts.map +1 -1
  101. package/esm/models/operations/geolocate-media.js +74 -0
  102. package/esm/models/operations/geolocate-media.js.map +1 -1
  103. package/esm/models/operations/scan-ports.d.ts +355 -0
  104. package/esm/models/operations/scan-ports.d.ts.map +1 -1
  105. package/esm/models/operations/scan-ports.js +473 -0
  106. package/esm/models/operations/scan-ports.js.map +1 -1
  107. package/esm/models/operations/search-face.d.ts +95 -0
  108. package/esm/models/operations/search-face.d.ts.map +1 -1
  109. package/esm/models/operations/search-face.js +98 -0
  110. package/esm/models/operations/search-face.js.map +1 -1
  111. package/esm/models/operations/search-username.d.ts +6 -6
  112. package/esm/models/operations/search-username.d.ts.map +1 -1
  113. package/esm/models/operations/search-username.js +13 -7
  114. package/esm/models/operations/search-username.js.map +1 -1
  115. package/esm/models/operations/search-web-databases.d.ts +4 -5
  116. package/esm/models/operations/search-web-databases.d.ts.map +1 -1
  117. package/esm/models/operations/search-web-databases.js +3 -4
  118. package/esm/models/operations/search-web-databases.js.map +1 -1
  119. package/esm/models/security.d.ts +2 -2
  120. package/esm/models/security.d.ts.map +1 -1
  121. package/esm/models/security.js +2 -2
  122. package/esm/models/security.js.map +1 -1
  123. package/esm/sdk/infrastructure.d.ts +2 -127
  124. package/esm/sdk/infrastructure.d.ts.map +1 -1
  125. package/esm/sdk/infrastructure.js +0 -126
  126. package/esm/sdk/infrastructure.js.map +1 -1
  127. package/esm/sdk/intelligence.d.ts +3 -14
  128. package/esm/sdk/intelligence.d.ts.map +1 -1
  129. package/esm/sdk/intelligence.js +0 -12
  130. package/esm/sdk/intelligence.js.map +1 -1
  131. package/esm/types/discriminated-union.d.ts +25 -0
  132. package/esm/types/discriminated-union.d.ts.map +1 -0
  133. package/esm/types/discriminated-union.js +61 -0
  134. package/esm/types/discriminated-union.js.map +1 -0
  135. package/esm/types/smart-union.d.ts.map +1 -1
  136. package/esm/types/smart-union.js +2 -1
  137. package/esm/types/smart-union.js.map +1 -1
  138. package/examples/usersGetInfo.example.ts +1 -1
  139. package/jsr.json +2 -1
  140. package/package.json +1 -1
  141. package/src/funcs/activity-delete-activity.ts +3 -3
  142. package/src/funcs/activity-get-activity.ts +3 -3
  143. package/src/funcs/activity-list-activities.ts +3 -3
  144. package/src/funcs/infrastructure-scan-ports.ts +21 -134
  145. package/src/funcs/infrastructure-search-certificates.ts +3 -3
  146. package/src/funcs/infrastructure-search-dns.ts +3 -3
  147. package/src/funcs/infrastructure-search-ip-info.ts +3 -3
  148. package/src/funcs/infrastructure-search-shodan.ts +3 -3
  149. package/src/funcs/infrastructure-search-whois.ts +3 -3
  150. package/src/funcs/intelligence-geolocate-media.ts +21 -20
  151. package/src/funcs/intelligence-search-address.ts +3 -3
  152. package/src/funcs/intelligence-search-email.ts +3 -3
  153. package/src/funcs/intelligence-search-face.ts +21 -8
  154. package/src/funcs/intelligence-search-gmail.ts +3 -3
  155. package/src/funcs/intelligence-search-hudson-rock.ts +3 -3
  156. package/src/funcs/intelligence-search-person.ts +3 -3
  157. package/src/funcs/intelligence-search-phone.ts +3 -3
  158. package/src/funcs/intelligence-search-seon.ts +3 -3
  159. package/src/funcs/intelligence-search-web-databases.ts +3 -3
  160. package/src/funcs/organizations-get-organization-audit-log.ts +3 -3
  161. package/src/funcs/organizations-get-organization.ts +3 -3
  162. package/src/funcs/organizations-list-organization-cases.ts +3 -3
  163. package/src/funcs/organizations-list-organization-members.ts +3 -3
  164. package/src/funcs/organizations-list-organizations.ts +3 -3
  165. package/src/funcs/organizations-send-organization-credits.ts +3 -3
  166. package/src/funcs/pricing-get-pricing.ts +3 -3
  167. package/src/funcs/socials-search-discord.ts +3 -3
  168. package/src/funcs/socials-search-github.ts +3 -3
  169. package/src/funcs/socials-search-roblox.ts +3 -3
  170. package/src/funcs/socials-search-tiktok.ts +3 -3
  171. package/src/funcs/socials-search-username.ts +3 -3
  172. package/src/funcs/tools-bypass-double-counter.ts +3 -3
  173. package/src/funcs/tools-download-intelx-file.ts +3 -3
  174. package/src/funcs/tools-lookup-discord-alt.ts +3 -3
  175. package/src/funcs/users-get-info.ts +3 -3
  176. package/src/hooks/hooks.ts +3 -0
  177. package/src/hooks/registration.ts +14 -0
  178. package/src/lib/config.ts +4 -4
  179. package/src/lib/env.ts +2 -2
  180. package/src/lib/event-streams.ts +191 -0
  181. package/src/lib/security.ts +1 -1
  182. package/src/models/operations/geolocate-media.ts +231 -0
  183. package/src/models/operations/scan-ports.ts +1223 -0
  184. package/src/models/operations/search-face.ts +259 -0
  185. package/src/models/operations/search-username.ts +23 -15
  186. package/src/models/operations/search-web-databases.ts +9 -8
  187. package/src/models/security.ts +4 -4
  188. package/src/sdk/infrastructure.ts +2 -127
  189. package/src/sdk/intelligence.ts +3 -14
  190. package/src/types/discriminated-union.ts +101 -0
  191. package/src/types/smart-union.ts +2 -1
@@ -0,0 +1,191 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ // Some environments' type definitions do not include ReadableStream's async
6
+ // iterator, even though the runtime supports it or this class polyfills it.
7
+ // Declare the method here so Stream can override it and preserve T in for-await.
8
+ declare global {
9
+ interface ReadableStream<R = any> {
10
+ [Symbol.asyncIterator](): {
11
+ next(): Promise<IteratorResult<R, undefined>>;
12
+ throw?(e?: unknown): Promise<IteratorResult<R, undefined>>;
13
+ return?(): Promise<IteratorResult<R, undefined>>;
14
+ [Symbol.asyncIterator](): any;
15
+ };
16
+ }
17
+ }
18
+
19
+ export type SseMessage<T> = {
20
+ data?: T | undefined;
21
+ event?: string | null | undefined;
22
+ id?: string | null | undefined;
23
+ retry?: number | null | undefined;
24
+ };
25
+ export class EventStream<T extends SseMessage<unknown>>
26
+ extends ReadableStream<T>
27
+ {
28
+ constructor(
29
+ responseBody: ReadableStream<Uint8Array>,
30
+ parse: (x: SseMessage<string>) => IteratorResult<T, undefined>,
31
+ opts?: { dataRequired?: boolean },
32
+ ) {
33
+ const upstream = responseBody.getReader();
34
+ let buffer: Uint8Array = new Uint8Array(4096);
35
+ let bufferLen = 0;
36
+ let searchStart = 0;
37
+ const state = { eventId: undefined as string | undefined };
38
+ const dataRequired = opts?.dataRequired ?? true;
39
+ super({
40
+ async pull(downstream) {
41
+ try {
42
+ while (true) {
43
+ const match = findBoundary(buffer, bufferLen, searchStart);
44
+ if (!match) {
45
+ // Bytes before the trailing MAX_BOUNDARY_LEN-1 were already
46
+ // scanned with full lookahead and cannot start a boundary even
47
+ // once more data arrives, so the next scan can skip them.
48
+ searchStart = Math.max(0, bufferLen - MAX_BOUNDARY_LEN + 1);
49
+ const chunk = await upstream.read();
50
+ if (chunk.done) return downstream.close();
51
+ if (bufferLen + chunk.value.length > buffer.length) {
52
+ const grown = new Uint8Array(
53
+ Math.max(buffer.length * 2, bufferLen + chunk.value.length),
54
+ );
55
+ grown.set(buffer.subarray(0, bufferLen));
56
+ buffer = grown;
57
+ }
58
+ buffer.set(chunk.value, bufferLen);
59
+ bufferLen += chunk.value.length;
60
+ continue;
61
+ }
62
+ const message = buffer.slice(0, match.index);
63
+ buffer.copyWithin(0, match.index + match.length, bufferLen);
64
+ bufferLen -= match.index + match.length;
65
+ if (buffer.length > 4096 && bufferLen <= buffer.length >> 2) {
66
+ // Release oversized capacity retained after an unusually large
67
+ // event so long-lived streams do not hold peak memory.
68
+ const shrunk = new Uint8Array(Math.max(4096, bufferLen * 2));
69
+ shrunk.set(buffer.subarray(0, bufferLen));
70
+ buffer = shrunk;
71
+ }
72
+ searchStart = 0;
73
+ const item = parseMessage(message, parse, state, dataRequired);
74
+ if (item && !item.done) return downstream.enqueue(item.value);
75
+ if (item?.done) {
76
+ await upstream.cancel("done");
77
+ return downstream.close();
78
+ }
79
+ }
80
+ } catch (e) {
81
+ downstream.error(e);
82
+ await upstream.cancel(e);
83
+ }
84
+ },
85
+ cancel: reason => upstream.cancel(reason),
86
+ });
87
+ }
88
+
89
+ // Use ReadableStream's iterator return type instead of `any` so stream events
90
+ // keep their generated type in for-await loops.
91
+ override [Symbol.asyncIterator](): ReturnType<
92
+ ReadableStream<T>[typeof Symbol.asyncIterator]
93
+ > {
94
+ const fn = (ReadableStream.prototype as any)[Symbol.asyncIterator];
95
+ if (typeof fn === "function") return fn.call(this);
96
+ const reader = this.getReader();
97
+ return {
98
+ next: async () => {
99
+ const r = await reader.read();
100
+ if (r.done) {
101
+ reader.releaseLock();
102
+ return { done: true, value: undefined };
103
+ }
104
+ return { done: false, value: r.value };
105
+ },
106
+ throw: async (e) => {
107
+ await reader.cancel(e);
108
+ reader.releaseLock();
109
+ return { done: true, value: undefined };
110
+ },
111
+ return: async () => {
112
+ await reader.cancel("done");
113
+ reader.releaseLock();
114
+ return { done: true, value: undefined };
115
+ },
116
+ [Symbol.asyncIterator]() {
117
+ return this;
118
+ },
119
+ } as ReturnType<ReadableStream<T>[typeof Symbol.asyncIterator]>;
120
+ }
121
+ }
122
+
123
+ const CR = 13;
124
+ const LF = 10;
125
+ const BOUNDARIES = [
126
+ [CR, LF, CR, LF], // \r\n\r\n
127
+ [CR, LF, CR], // \r\n\r
128
+ [CR, LF, LF], // \r\n\n
129
+ [CR, CR, LF], // \r\r\n
130
+ [LF, CR, LF], // \n\r\n
131
+ [CR, CR], // \r\r
132
+ [LF, CR], // \n\r
133
+ [LF, LF], // \n\n
134
+ ];
135
+ const MAX_BOUNDARY_LEN = BOUNDARIES.reduce((m, b) => Math.max(m, b.length), 0);
136
+
137
+ function findBoundary(
138
+ buf: Uint8Array,
139
+ len: number,
140
+ from: number,
141
+ ): { index: number; length: number } | null {
142
+ for (let i = from; i < len; i++) {
143
+ if (buf[i] !== CR && buf[i] !== LF) continue;
144
+ for (const boundary of BOUNDARIES) {
145
+ if (i + boundary.length > len) continue;
146
+ let match = true;
147
+ for (let j = 0; j < boundary.length; j++) {
148
+ if (buf[i + j] !== boundary[j]) {
149
+ match = false;
150
+ break;
151
+ }
152
+ }
153
+ if (match) return { index: i, length: boundary.length };
154
+ }
155
+ }
156
+ return null;
157
+ }
158
+ function parseMessage<T extends SseMessage<unknown>>(
159
+ chunk: Uint8Array,
160
+ parse: (x: SseMessage<string>) => IteratorResult<T, undefined>,
161
+ state: { eventId: string | undefined },
162
+ dataRequired: boolean,
163
+ ) {
164
+ const text = new TextDecoder().decode(chunk);
165
+ const lines = text.split(/\r\n|\r|\n/);
166
+ const dataLines: string[] = [];
167
+ const ret: SseMessage<string> = {};
168
+ let ignore = true;
169
+ for (const line of lines) {
170
+ if (!line || line.startsWith(":")) continue;
171
+ ignore = false;
172
+ const i = line.indexOf(":");
173
+ let field = line;
174
+ let value = "";
175
+ if (i > 0) {
176
+ field = line.slice(0, i);
177
+ value = line[i + 1] === " " ? line.slice(i + 2) : line.slice(i + 1);
178
+ }
179
+ if (field === "data") dataLines.push(value);
180
+ else if (field === "event") ret.event = value;
181
+ else if (field === "id" && !value.includes("\0")) state.eventId = value;
182
+ else if (field === "retry" && /^\d+$/.test(value)) {
183
+ ret.retry = Number(value);
184
+ }
185
+ }
186
+ if (ignore) return;
187
+ ret.id = state.eventId;
188
+ if (dataLines.length) ret.data = dataLines.join("\n");
189
+ else if (dataRequired) return; // skip data-less events when data is required
190
+ return parse(ret);
191
+ }
@@ -247,7 +247,7 @@ export function resolveGlobalSecurity(
247
247
  {
248
248
  fieldName: "x-api-key",
249
249
  type: "apiKey:header",
250
- value: security?.apiKeyAuth ?? env().INDICIA_API_KEY_AUTH,
250
+ value: security?.apiKey ?? env().INDICIA_API_KEY,
251
251
  },
252
252
  ],
253
253
  ];
@@ -3,8 +3,14 @@
3
3
  */
4
4
 
5
5
  import * as z from "zod/v4-mini";
6
+ import { safeParse } from "../../lib/schemas.js";
6
7
  import { blobLikeSchema } from "../../types/blobs.js";
8
+ import * as discriminatedUnionTypes from "../../types/discriminated-union.js";
9
+ import { discriminatedUnion } from "../../types/discriminated-union.js";
7
10
  import { ClosedEnum } from "../../types/enums.js";
11
+ import { Result as SafeParseResult } from "../../types/fp.js";
12
+ import * as types from "../../types/primitives.js";
13
+ import { SDKValidationError } from "../errors/sdk-validation-error.js";
8
14
 
9
15
  export type GeolocateMediaMedia = {
10
16
  fileName: string;
@@ -38,6 +44,90 @@ export type GeolocateMediaRequest = {
38
44
  model?: Model | undefined;
39
45
  };
40
46
 
47
+ /**
48
+ * Terminal event indicating the analysis failed.
49
+ */
50
+ export type GeolocateMediaErrorEvent = {
51
+ status: "error";
52
+ success: false;
53
+ /**
54
+ * Human-readable error message.
55
+ */
56
+ error: string;
57
+ };
58
+
59
+ /**
60
+ * Geolocation analysis result.
61
+ */
62
+ export type GeolocateMediaData = {
63
+ /**
64
+ * Human-readable location name, or null if undetermined.
65
+ */
66
+ location: string | null;
67
+ /**
68
+ * Comma-separated "latitude,longitude" pair, or null if undetermined.
69
+ */
70
+ coordinates: string | null;
71
+ /**
72
+ * Confidence level of the geolocation result.
73
+ */
74
+ certainty: string;
75
+ /**
76
+ * Explanation of how the location was determined.
77
+ */
78
+ reasoning: string;
79
+ /**
80
+ * Google Maps URL for the determined coordinates.
81
+ */
82
+ mapsUrl?: string | undefined;
83
+ };
84
+
85
+ /**
86
+ * Terminal event containing the geolocation result.
87
+ */
88
+ export type GeolocateMediaCompleteEvent = {
89
+ status: "complete";
90
+ success: true;
91
+ /**
92
+ * Geolocation analysis result.
93
+ */
94
+ data: GeolocateMediaData;
95
+ };
96
+
97
+ /**
98
+ * Progress heartbeat emitted while analysis is in progress. Sent immediately on connection and then roughly every 10 seconds to keep the connection alive.
99
+ */
100
+ export type AnalyzingEvent = {
101
+ status: "analyzing";
102
+ /**
103
+ * Unix epoch milliseconds of the heartbeat.
104
+ */
105
+ timestamp?: number | undefined;
106
+ };
107
+
108
+ /**
109
+ * JSON `data` payload of a geolocation Server-Sent Event. Discriminated by `status`.
110
+ */
111
+ export type GeolocationEventData =
112
+ | AnalyzingEvent
113
+ | GeolocateMediaCompleteEvent
114
+ | GeolocateMediaErrorEvent
115
+ | discriminatedUnionTypes.Unknown<"status">;
116
+
117
+ /**
118
+ * A Server-Sent Event whose `data` field carries the event payload.
119
+ */
120
+ export type GeolocationEvent = {
121
+ /**
122
+ * JSON `data` payload of a geolocation Server-Sent Event. Discriminated by `status`.
123
+ */
124
+ data:
125
+ | AnalyzingEvent
126
+ | GeolocateMediaCompleteEvent
127
+ | GeolocateMediaErrorEvent
128
+ | discriminatedUnionTypes.Unknown<"status">;
129
+ };
130
+
41
131
  /** @internal */
42
132
  export type GeolocateMediaMedia$Outbound = {
43
133
  fileName: string;
@@ -96,3 +186,144 @@ export function geolocateMediaRequestToJSON(
96
186
  GeolocateMediaRequest$outboundSchema.parse(geolocateMediaRequest),
97
187
  );
98
188
  }
189
+
190
+ /** @internal */
191
+ export const GeolocateMediaErrorEvent$inboundSchema: z.ZodMiniType<
192
+ GeolocateMediaErrorEvent,
193
+ unknown
194
+ > = z.object({
195
+ status: types.literal("error"),
196
+ success: types.literal(false),
197
+ error: types.string(),
198
+ });
199
+
200
+ export function geolocateMediaErrorEventFromJSON(
201
+ jsonString: string,
202
+ ): SafeParseResult<GeolocateMediaErrorEvent, SDKValidationError> {
203
+ return safeParse(
204
+ jsonString,
205
+ (x) => GeolocateMediaErrorEvent$inboundSchema.parse(JSON.parse(x)),
206
+ `Failed to parse 'GeolocateMediaErrorEvent' from JSON`,
207
+ );
208
+ }
209
+
210
+ /** @internal */
211
+ export const GeolocateMediaData$inboundSchema: z.ZodMiniType<
212
+ GeolocateMediaData,
213
+ unknown
214
+ > = z.object({
215
+ location: types.nullable(types.string()),
216
+ coordinates: types.nullable(types.string()),
217
+ certainty: types.string(),
218
+ reasoning: types.string(),
219
+ mapsUrl: types.optional(types.string()),
220
+ });
221
+
222
+ export function geolocateMediaDataFromJSON(
223
+ jsonString: string,
224
+ ): SafeParseResult<GeolocateMediaData, SDKValidationError> {
225
+ return safeParse(
226
+ jsonString,
227
+ (x) => GeolocateMediaData$inboundSchema.parse(JSON.parse(x)),
228
+ `Failed to parse 'GeolocateMediaData' from JSON`,
229
+ );
230
+ }
231
+
232
+ /** @internal */
233
+ export const GeolocateMediaCompleteEvent$inboundSchema: z.ZodMiniType<
234
+ GeolocateMediaCompleteEvent,
235
+ unknown
236
+ > = z.object({
237
+ status: types.literal("complete"),
238
+ success: types.literal(true),
239
+ data: z.lazy(() => GeolocateMediaData$inboundSchema),
240
+ });
241
+
242
+ export function geolocateMediaCompleteEventFromJSON(
243
+ jsonString: string,
244
+ ): SafeParseResult<GeolocateMediaCompleteEvent, SDKValidationError> {
245
+ return safeParse(
246
+ jsonString,
247
+ (x) => GeolocateMediaCompleteEvent$inboundSchema.parse(JSON.parse(x)),
248
+ `Failed to parse 'GeolocateMediaCompleteEvent' from JSON`,
249
+ );
250
+ }
251
+
252
+ /** @internal */
253
+ export const AnalyzingEvent$inboundSchema: z.ZodMiniType<
254
+ AnalyzingEvent,
255
+ unknown
256
+ > = z.object({
257
+ status: types.literal("analyzing"),
258
+ timestamp: types.optional(types.number()),
259
+ });
260
+
261
+ export function analyzingEventFromJSON(
262
+ jsonString: string,
263
+ ): SafeParseResult<AnalyzingEvent, SDKValidationError> {
264
+ return safeParse(
265
+ jsonString,
266
+ (x) => AnalyzingEvent$inboundSchema.parse(JSON.parse(x)),
267
+ `Failed to parse 'AnalyzingEvent' from JSON`,
268
+ );
269
+ }
270
+
271
+ /** @internal */
272
+ export const GeolocationEventData$inboundSchema: z.ZodMiniType<
273
+ GeolocationEventData,
274
+ unknown
275
+ > = discriminatedUnion("status", {
276
+ analyzing: z.lazy(() => AnalyzingEvent$inboundSchema),
277
+ complete: z.lazy(() => GeolocateMediaCompleteEvent$inboundSchema),
278
+ error: z.lazy(() => GeolocateMediaErrorEvent$inboundSchema),
279
+ });
280
+
281
+ export function geolocationEventDataFromJSON(
282
+ jsonString: string,
283
+ ): SafeParseResult<GeolocationEventData, SDKValidationError> {
284
+ return safeParse(
285
+ jsonString,
286
+ (x) => GeolocationEventData$inboundSchema.parse(JSON.parse(x)),
287
+ `Failed to parse 'GeolocationEventData' from JSON`,
288
+ );
289
+ }
290
+
291
+ /** @internal */
292
+ export const GeolocationEvent$inboundSchema: z.ZodMiniType<
293
+ GeolocationEvent,
294
+ unknown
295
+ > = z.object({
296
+ data: z.pipe(
297
+ z.pipe(
298
+ z.unknown(),
299
+ z.transform((v, ctx) => {
300
+ if (typeof v !== "string") return v;
301
+ try {
302
+ return JSON.parse(v);
303
+ } catch (err) {
304
+ ctx.issues.push({
305
+ input: v,
306
+ code: "custom",
307
+ message: `malformed json: ${err}`,
308
+ });
309
+ return z.NEVER;
310
+ }
311
+ }),
312
+ ),
313
+ discriminatedUnion("status", {
314
+ analyzing: z.lazy(() => AnalyzingEvent$inboundSchema),
315
+ complete: z.lazy(() => GeolocateMediaCompleteEvent$inboundSchema),
316
+ error: z.lazy(() => GeolocateMediaErrorEvent$inboundSchema),
317
+ }),
318
+ ),
319
+ });
320
+
321
+ export function geolocationEventFromJSON(
322
+ jsonString: string,
323
+ ): SafeParseResult<GeolocationEvent, SDKValidationError> {
324
+ return safeParse(
325
+ jsonString,
326
+ (x) => GeolocationEvent$inboundSchema.parse(JSON.parse(x)),
327
+ `Failed to parse 'GeolocationEvent' from JSON`,
328
+ );
329
+ }