@sixb/client 0.1.11 → 0.1.12

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 (38) hide show
  1. package/dist/browser.js +2 -2
  2. package/dist/{chunk-f4qeqxz2.js → chunk-bsy1hg20.js} +1 -1
  3. package/dist/{chunk-7bv57jcq.js → chunk-e8qjsvha.js} +11 -2
  4. package/dist/{chunk-7bv57jcq.js.map → chunk-e8qjsvha.js.map} +3 -3
  5. package/dist/{chunk-65mmaq7r.js → chunk-hx3n4fer.js} +3 -3
  6. package/dist/{chunk-qaacaq2e.js → chunk-kh20z2mt.js} +6 -4
  7. package/dist/chunk-kh20z2mt.js.map +10 -0
  8. package/dist/{chunk-y4g6jrvs.js → chunk-sjb188se.js} +1 -1
  9. package/dist/{chunk-65bdf9vw.js → chunk-t50n91tk.js} +2 -2
  10. package/dist/connectors/queries.d.ts.map +1 -1
  11. package/dist/generated/@tanstack/react-query.gen.d.ts +617 -82
  12. package/dist/generated/@tanstack/react-query.gen.d.ts.map +1 -1
  13. package/dist/generated/index.d.ts +2 -2
  14. package/dist/generated/index.d.ts.map +1 -1
  15. package/dist/generated/sdk.gen.d.ts +5 -1
  16. package/dist/generated/sdk.gen.d.ts.map +1 -1
  17. package/dist/generated/types.gen.d.ts +262 -12
  18. package/dist/generated/types.gen.d.ts.map +1 -1
  19. package/dist/hooks.js +21 -6
  20. package/dist/hooks.js.map +3 -3
  21. package/dist/index.js +8 -6
  22. package/dist/index.js.map +1 -1
  23. package/dist/logs.js +3 -3
  24. package/dist/models.js +4 -2
  25. package/dist/models.js.map +1 -1
  26. package/dist/query.d.ts.map +1 -1
  27. package/dist/query.js +3 -3
  28. package/package.json +2 -2
  29. package/src/generated/@tanstack/react-query.gen.ts +31 -0
  30. package/src/generated/index.ts +7 -0
  31. package/src/generated/sdk.gen.ts +23 -0
  32. package/src/generated/types.gen.ts +306 -12
  33. package/src/query.ts +3 -1
  34. package/dist/chunk-qaacaq2e.js.map +0 -10
  35. /package/dist/{chunk-f4qeqxz2.js.map → chunk-bsy1hg20.js.map} +0 -0
  36. /package/dist/{chunk-65mmaq7r.js.map → chunk-hx3n4fer.js.map} +0 -0
  37. /package/dist/{chunk-y4g6jrvs.js.map → chunk-sjb188se.js.map} +0 -0
  38. /package/dist/{chunk-65bdf9vw.js.map → chunk-t50n91tk.js.map} +0 -0
@@ -9,6 +9,7 @@ export type ErrorResponse = {
9
9
  }
10
10
 
11
11
  export type ObjectQueryObject = {
12
+ score?: number
12
13
  primaryId: string
13
14
  objectTypeId: string
14
15
  properties: {
@@ -100,6 +101,26 @@ export type ObjectQueryLinksResponse = {
100
101
  nextPageToken?: string
101
102
  }
102
103
 
104
+ export type AiUsageLimitErrorResponse = {
105
+ error: string
106
+ /**
107
+ * Stable machine-readable failure code for programmatic handling.
108
+ */
109
+ code: "ai.usage_limit_exceeded" | "ai.usage_limit_unavailable"
110
+ /**
111
+ * Any JSON-compatible value.
112
+ */
113
+ details?:
114
+ | string
115
+ | number
116
+ | boolean
117
+ | Array<unknown>
118
+ | {
119
+ [key: string]: unknown
120
+ }
121
+ | null
122
+ }
123
+
103
124
  export type ObjectQueryErrorResponse = {
104
125
  error: string
105
126
  issues?: Array<ObjectQueryIssue>
@@ -175,8 +196,8 @@ export type ObjectQuery =
175
196
  | {
176
197
  kind: "vector"
177
198
  input: ObjectQuery
178
- vector: Array<number>
179
- propertyId: string
199
+ vector: string
200
+ profile: string
180
201
  k: number
181
202
  }
182
203
  | {
@@ -1761,6 +1782,9 @@ export type GetAiAccountingOverviewResponses = {
1761
1782
  bucket: "hour" | "day" | "week"
1762
1783
  totals: {
1763
1784
  modelCallCount: number
1785
+ /**
1786
+ * Sums of reported meters; unreported meters are absent. totalTokens sums available input and output counts and is a lower bound when coverage is incomplete.
1787
+ */
1764
1788
  usage: {
1765
1789
  inputTokens?: number
1766
1790
  outputTokens?: number
@@ -1772,6 +1796,21 @@ export type GetAiAccountingOverviewResponses = {
1772
1796
  reasoningOutputTokens?: number
1773
1797
  reportingStatus: "complete" | "partial" | "unavailable"
1774
1798
  }
1799
+ usageCoverage: {
1800
+ /**
1801
+ * Calls reporting both inputTokens and outputTokens.
1802
+ */
1803
+ completeCallCount: number
1804
+ fieldCallCounts: {
1805
+ inputTokens: number
1806
+ outputTokens: number
1807
+ uncachedInputTokens: number
1808
+ cacheReadInputTokens: number
1809
+ cacheWriteInputTokens: number
1810
+ textOutputTokens: number
1811
+ reasoningOutputTokens: number
1812
+ }
1813
+ }
1775
1814
  costs: {
1776
1815
  amounts: Array<{
1777
1816
  currency: string
@@ -1784,6 +1823,9 @@ export type GetAiAccountingOverviewResponses = {
1784
1823
  }
1785
1824
  series: Array<{
1786
1825
  modelCallCount: number
1826
+ /**
1827
+ * Sums of reported meters; unreported meters are absent. totalTokens sums available input and output counts and is a lower bound when coverage is incomplete.
1828
+ */
1787
1829
  usage: {
1788
1830
  inputTokens?: number
1789
1831
  outputTokens?: number
@@ -1795,6 +1837,21 @@ export type GetAiAccountingOverviewResponses = {
1795
1837
  reasoningOutputTokens?: number
1796
1838
  reportingStatus: "complete" | "partial" | "unavailable"
1797
1839
  }
1840
+ usageCoverage: {
1841
+ /**
1842
+ * Calls reporting both inputTokens and outputTokens.
1843
+ */
1844
+ completeCallCount: number
1845
+ fieldCallCounts: {
1846
+ inputTokens: number
1847
+ outputTokens: number
1848
+ uncachedInputTokens: number
1849
+ cacheReadInputTokens: number
1850
+ cacheWriteInputTokens: number
1851
+ textOutputTokens: number
1852
+ reasoningOutputTokens: number
1853
+ }
1854
+ }
1798
1855
  costs: {
1799
1856
  amounts: Array<{
1800
1857
  currency: string
@@ -1809,6 +1866,9 @@ export type GetAiAccountingOverviewResponses = {
1809
1866
  }>
1810
1867
  models: Array<{
1811
1868
  modelCallCount: number
1869
+ /**
1870
+ * Sums of reported meters; unreported meters are absent. totalTokens sums available input and output counts and is a lower bound when coverage is incomplete.
1871
+ */
1812
1872
  usage: {
1813
1873
  inputTokens?: number
1814
1874
  outputTokens?: number
@@ -1820,6 +1880,21 @@ export type GetAiAccountingOverviewResponses = {
1820
1880
  reasoningOutputTokens?: number
1821
1881
  reportingStatus: "complete" | "partial" | "unavailable"
1822
1882
  }
1883
+ usageCoverage: {
1884
+ /**
1885
+ * Calls reporting both inputTokens and outputTokens.
1886
+ */
1887
+ completeCallCount: number
1888
+ fieldCallCounts: {
1889
+ inputTokens: number
1890
+ outputTokens: number
1891
+ uncachedInputTokens: number
1892
+ cacheReadInputTokens: number
1893
+ cacheWriteInputTokens: number
1894
+ textOutputTokens: number
1895
+ reasoningOutputTokens: number
1896
+ }
1897
+ }
1823
1898
  costs: {
1824
1899
  amounts: Array<{
1825
1900
  currency: string
@@ -1835,6 +1910,9 @@ export type GetAiAccountingOverviewResponses = {
1835
1910
  agents: Array<
1836
1911
  | {
1837
1912
  modelCallCount: number
1913
+ /**
1914
+ * Sums of reported meters; unreported meters are absent. totalTokens sums available input and output counts and is a lower bound when coverage is incomplete.
1915
+ */
1838
1916
  usage: {
1839
1917
  inputTokens?: number
1840
1918
  outputTokens?: number
@@ -1846,6 +1924,21 @@ export type GetAiAccountingOverviewResponses = {
1846
1924
  reasoningOutputTokens?: number
1847
1925
  reportingStatus: "complete" | "partial" | "unavailable"
1848
1926
  }
1927
+ usageCoverage: {
1928
+ /**
1929
+ * Calls reporting both inputTokens and outputTokens.
1930
+ */
1931
+ completeCallCount: number
1932
+ fieldCallCounts: {
1933
+ inputTokens: number
1934
+ outputTokens: number
1935
+ uncachedInputTokens: number
1936
+ cacheReadInputTokens: number
1937
+ cacheWriteInputTokens: number
1938
+ textOutputTokens: number
1939
+ reasoningOutputTokens: number
1940
+ }
1941
+ }
1849
1942
  costs: {
1850
1943
  amounts: Array<{
1851
1944
  currency: string
@@ -1859,6 +1952,9 @@ export type GetAiAccountingOverviewResponses = {
1859
1952
  }
1860
1953
  | {
1861
1954
  modelCallCount: number
1955
+ /**
1956
+ * Sums of reported meters; unreported meters are absent. totalTokens sums available input and output counts and is a lower bound when coverage is incomplete.
1957
+ */
1862
1958
  usage: {
1863
1959
  inputTokens?: number
1864
1960
  outputTokens?: number
@@ -1870,6 +1966,21 @@ export type GetAiAccountingOverviewResponses = {
1870
1966
  reasoningOutputTokens?: number
1871
1967
  reportingStatus: "complete" | "partial" | "unavailable"
1872
1968
  }
1969
+ usageCoverage: {
1970
+ /**
1971
+ * Calls reporting both inputTokens and outputTokens.
1972
+ */
1973
+ completeCallCount: number
1974
+ fieldCallCounts: {
1975
+ inputTokens: number
1976
+ outputTokens: number
1977
+ uncachedInputTokens: number
1978
+ cacheReadInputTokens: number
1979
+ cacheWriteInputTokens: number
1980
+ textOutputTokens: number
1981
+ reasoningOutputTokens: number
1982
+ }
1983
+ }
1873
1984
  costs: {
1874
1985
  amounts: Array<{
1875
1986
  currency: string
@@ -1886,6 +1997,9 @@ export type GetAiAccountingOverviewResponses = {
1886
1997
  >
1887
1998
  workflows: Array<{
1888
1999
  modelCallCount: number
2000
+ /**
2001
+ * Sums of reported meters; unreported meters are absent. totalTokens sums available input and output counts and is a lower bound when coverage is incomplete.
2002
+ */
1889
2003
  usage: {
1890
2004
  inputTokens?: number
1891
2005
  outputTokens?: number
@@ -1897,6 +2011,21 @@ export type GetAiAccountingOverviewResponses = {
1897
2011
  reasoningOutputTokens?: number
1898
2012
  reportingStatus: "complete" | "partial" | "unavailable"
1899
2013
  }
2014
+ usageCoverage: {
2015
+ /**
2016
+ * Calls reporting both inputTokens and outputTokens.
2017
+ */
2018
+ completeCallCount: number
2019
+ fieldCallCounts: {
2020
+ inputTokens: number
2021
+ outputTokens: number
2022
+ uncachedInputTokens: number
2023
+ cacheReadInputTokens: number
2024
+ cacheWriteInputTokens: number
2025
+ textOutputTokens: number
2026
+ reasoningOutputTokens: number
2027
+ }
2028
+ }
1900
2029
  costs: {
1901
2030
  amounts: Array<{
1902
2031
  currency: string
@@ -8170,7 +8299,6 @@ export type ListObjectTypesResponses = {
8170
8299
  text?: boolean
8171
8300
  exact?: boolean
8172
8301
  facet?: boolean
8173
- vector?: boolean
8174
8302
  weight?: number
8175
8303
  }
8176
8304
  }>
@@ -8178,9 +8306,19 @@ export type ListObjectTypesResponses = {
8178
8306
  title?: string
8179
8307
  defaultText?: Array<string>
8180
8308
  exact?: Array<string>
8181
- vector?: {
8182
- property: string
8183
- source: Array<string>
8309
+ vectors?: {
8310
+ [key: string]: {
8311
+ source: Array<string>
8312
+ model: {
8313
+ providerId: string
8314
+ modelId: string
8315
+ dimensions: number
8316
+ representation?: {
8317
+ name: string
8318
+ version?: string
8319
+ }
8320
+ }
8321
+ }
8184
8322
  }
8185
8323
  }
8186
8324
  links: Array<{
@@ -8206,7 +8344,6 @@ export type ListObjectTypesResponses = {
8206
8344
  text?: boolean
8207
8345
  exact?: boolean
8208
8346
  facet?: boolean
8209
- vector?: boolean
8210
8347
  weight?: number
8211
8348
  }
8212
8349
  }>
@@ -8277,7 +8414,6 @@ export type GetObjectTypeResponses = {
8277
8414
  text?: boolean
8278
8415
  exact?: boolean
8279
8416
  facet?: boolean
8280
- vector?: boolean
8281
8417
  weight?: number
8282
8418
  }
8283
8419
  }>
@@ -8285,9 +8421,19 @@ export type GetObjectTypeResponses = {
8285
8421
  title?: string
8286
8422
  defaultText?: Array<string>
8287
8423
  exact?: Array<string>
8288
- vector?: {
8289
- property: string
8290
- source: Array<string>
8424
+ vectors?: {
8425
+ [key: string]: {
8426
+ source: Array<string>
8427
+ model: {
8428
+ providerId: string
8429
+ modelId: string
8430
+ dimensions: number
8431
+ representation?: {
8432
+ name: string
8433
+ version?: string
8434
+ }
8435
+ }
8436
+ }
8291
8437
  }
8292
8438
  }
8293
8439
  links: Array<{
@@ -8313,7 +8459,6 @@ export type GetObjectTypeResponses = {
8313
8459
  text?: boolean
8314
8460
  exact?: boolean
8315
8461
  facet?: boolean
8316
- vector?: boolean
8317
8462
  weight?: number
8318
8463
  }
8319
8464
  }>
@@ -8423,6 +8568,7 @@ export type ListObjectsResponses = {
8423
8568
  */
8424
8569
  200: {
8425
8570
  objects: Array<{
8571
+ score?: number
8426
8572
  primaryId: string
8427
8573
  objectTypeId: string
8428
8574
  properties: {
@@ -8454,6 +8600,10 @@ export type QueryObjectsErrors = {
8454
8600
  * Response for status 403
8455
8601
  */
8456
8602
  403: ErrorResponse
8603
+ /**
8604
+ * AI usage limit exceeded or unavailable
8605
+ */
8606
+ 429: AiUsageLimitErrorResponse
8457
8607
  /**
8458
8608
  * Response for status 500
8459
8609
  */
@@ -8520,6 +8670,10 @@ export type CountObjectsErrors = {
8520
8670
  * Response for status 403
8521
8671
  */
8522
8672
  403: ErrorResponse
8673
+ /**
8674
+ * AI usage limit exceeded or unavailable
8675
+ */
8676
+ 429: AiUsageLimitErrorResponse
8523
8677
  /**
8524
8678
  * Response for status 500
8525
8679
  */
@@ -8553,6 +8707,10 @@ export type ExistsObjectsErrors = {
8553
8707
  * Response for status 403
8554
8708
  */
8555
8709
  403: ErrorResponse
8710
+ /**
8711
+ * AI usage limit exceeded or unavailable
8712
+ */
8713
+ 429: AiUsageLimitErrorResponse
8556
8714
  /**
8557
8715
  * Response for status 500
8558
8716
  */
@@ -8731,6 +8889,7 @@ export type GetObjectResponses = {
8731
8889
  * Response for status 200
8732
8890
  */
8733
8891
  200: {
8892
+ score?: number
8734
8893
  primaryId: string
8735
8894
  objectTypeId: string
8736
8895
  properties: {
@@ -8785,6 +8944,7 @@ export type UpsertObjectResponses = {
8785
8944
  * Response for status 200
8786
8945
  */
8787
8946
  200: {
8947
+ score?: number
8788
8948
  primaryId: string
8789
8949
  objectTypeId: string
8790
8950
  properties: {
@@ -9700,6 +9860,11 @@ export type ListAgentThreadsResponses = {
9700
9860
  */
9701
9861
  200: {
9702
9862
  threads: Array<{
9863
+ sandboxState?: {
9864
+ name: string
9865
+ status: "new" | "busy" | "ready" | "blocked" | "unavailable"
9866
+ initialized: boolean
9867
+ }
9703
9868
  id: string
9704
9869
  projectId: string
9705
9870
  ownerPrincipal: {
@@ -9707,6 +9872,17 @@ export type ListAgentThreadsResponses = {
9707
9872
  id: string
9708
9873
  }
9709
9874
  title?: string
9875
+ sandboxParams?: {
9876
+ [key: string]:
9877
+ | string
9878
+ | number
9879
+ | boolean
9880
+ | Array<unknown>
9881
+ | {
9882
+ [key: string]: unknown
9883
+ }
9884
+ | null
9885
+ }
9710
9886
  status: "active" | "archived"
9711
9887
  activeRunId: string | null
9712
9888
  lastMessageAt?: string
@@ -9725,6 +9901,17 @@ export type CreateAgentThreadData = {
9725
9901
  body: {
9726
9902
  title?: string
9727
9903
  threadId?: string
9904
+ sandbox?: {
9905
+ [key: string]:
9906
+ | string
9907
+ | number
9908
+ | boolean
9909
+ | Array<unknown>
9910
+ | {
9911
+ [key: string]: unknown
9912
+ }
9913
+ | null
9914
+ }
9728
9915
  }
9729
9916
  path?: never
9730
9917
  query?: never
@@ -9766,6 +9953,11 @@ export type CreateAgentThreadResponses = {
9766
9953
  */
9767
9954
  201: {
9768
9955
  thread: {
9956
+ sandboxState?: {
9957
+ name: string
9958
+ status: "new" | "busy" | "ready" | "blocked" | "unavailable"
9959
+ initialized: boolean
9960
+ }
9769
9961
  id: string
9770
9962
  projectId: string
9771
9963
  ownerPrincipal: {
@@ -9773,6 +9965,17 @@ export type CreateAgentThreadResponses = {
9773
9965
  id: string
9774
9966
  }
9775
9967
  title?: string
9968
+ sandboxParams?: {
9969
+ [key: string]:
9970
+ | string
9971
+ | number
9972
+ | boolean
9973
+ | Array<unknown>
9974
+ | {
9975
+ [key: string]: unknown
9976
+ }
9977
+ | null
9978
+ }
9776
9979
  status: "active" | "archived"
9777
9980
  activeRunId: string | null
9778
9981
  lastMessageAt?: string
@@ -9822,6 +10025,11 @@ export type GetAgentThreadResponses = {
9822
10025
  * Response for status 200
9823
10026
  */
9824
10027
  200: {
10028
+ sandboxState?: {
10029
+ name: string
10030
+ status: "new" | "busy" | "ready" | "blocked" | "unavailable"
10031
+ initialized: boolean
10032
+ }
9825
10033
  id: string
9826
10034
  projectId: string
9827
10035
  ownerPrincipal: {
@@ -9829,6 +10037,17 @@ export type GetAgentThreadResponses = {
9829
10037
  id: string
9830
10038
  }
9831
10039
  title?: string
10040
+ sandboxParams?: {
10041
+ [key: string]:
10042
+ | string
10043
+ | number
10044
+ | boolean
10045
+ | Array<unknown>
10046
+ | {
10047
+ [key: string]: unknown
10048
+ }
10049
+ | null
10050
+ }
9832
10051
  status: "active" | "archived"
9833
10052
  activeRunId: string | null
9834
10053
  lastMessageAt?: string
@@ -9840,6 +10059,81 @@ export type GetAgentThreadResponses = {
9840
10059
 
9841
10060
  export type GetAgentThreadResponse = GetAgentThreadResponses[keyof GetAgentThreadResponses]
9842
10061
 
10062
+ export type RecreateAgentThreadSandboxData = {
10063
+ body: {
10064
+ expectedSandboxName: string
10065
+ }
10066
+ path: {
10067
+ threadId: string
10068
+ }
10069
+ query?: never
10070
+ url: "/api/agent-threads/{threadId}/sandbox/recreate"
10071
+ }
10072
+
10073
+ export type RecreateAgentThreadSandboxErrors = {
10074
+ /**
10075
+ * Response for status 400
10076
+ */
10077
+ 400: {
10078
+ error: string
10079
+ }
10080
+ /**
10081
+ * Response for status 404
10082
+ */
10083
+ 404: {
10084
+ error: string
10085
+ }
10086
+ /**
10087
+ * Response for status 409
10088
+ */
10089
+ 409: {
10090
+ error: string
10091
+ }
10092
+ }
10093
+
10094
+ export type RecreateAgentThreadSandboxError =
10095
+ RecreateAgentThreadSandboxErrors[keyof RecreateAgentThreadSandboxErrors]
10096
+
10097
+ export type RecreateAgentThreadSandboxResponses = {
10098
+ /**
10099
+ * Response for status 200
10100
+ */
10101
+ 200: {
10102
+ sandboxState?: {
10103
+ name: string
10104
+ status: "new" | "busy" | "ready" | "blocked" | "unavailable"
10105
+ initialized: boolean
10106
+ }
10107
+ id: string
10108
+ projectId: string
10109
+ ownerPrincipal: {
10110
+ type: "user" | "serviceAccount" | "system"
10111
+ id: string
10112
+ }
10113
+ title?: string
10114
+ sandboxParams?: {
10115
+ [key: string]:
10116
+ | string
10117
+ | number
10118
+ | boolean
10119
+ | Array<unknown>
10120
+ | {
10121
+ [key: string]: unknown
10122
+ }
10123
+ | null
10124
+ }
10125
+ status: "active" | "archived"
10126
+ activeRunId: string | null
10127
+ lastMessageAt?: string
10128
+ messageCount: number
10129
+ createdAt: string
10130
+ updatedAt: string
10131
+ }
10132
+ }
10133
+
10134
+ export type RecreateAgentThreadSandboxResponse =
10135
+ RecreateAgentThreadSandboxResponses[keyof RecreateAgentThreadSandboxResponses]
10136
+
9843
10137
  export type ListAgentThreadMessagesData = {
9844
10138
  body?: never
9845
10139
  path: {
package/src/query.ts CHANGED
@@ -75,10 +75,11 @@ export function createHttpQueryExecutor(client?: Client): ObjectQueryExecutor {
75
75
  const callOptions = { client, responseStyle: "fields", throwOnError: false } as const
76
76
 
77
77
  return {
78
- async list(query: ObjectQuery, options?: { includeTotal?: boolean }) {
78
+ async list(query: ObjectQuery, options?: { includeTotal?: boolean; signal?: AbortSignal }) {
79
79
  const { data, error } = await queryObjects({
80
80
  ...callOptions,
81
81
  body: { query: toWireQuery(query), includeTotal: options?.includeTotal },
82
+ signal: options?.signal,
82
83
  })
83
84
  if (error || !data) throw toSixbQueryError(error)
84
85
  return {
@@ -126,6 +127,7 @@ export function createHttpQueryExecutor(client?: Client): ObjectQueryExecutor {
126
127
  // builder types `links` precisely; here it flows through as runtime data.
127
128
  function reviveQueryRow(row: ObjectQueryObject): ObjectQueryExecutorRow {
128
129
  const revived: ObjectQueryExecutorRow = {
130
+ ...(row.score === undefined ? {} : { score: row.score }),
129
131
  primaryId: row.primaryId,
130
132
  objectTypeId: row.objectTypeId,
131
133
  properties: row.properties,
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/query.ts"],
4
- "sourcesContent": [
5
- "/**\n * Typed object queries over HTTP (`@sixb/client/query`).\n *\n * `objects(Type)` returns the same fluent query builder the server runtime\n * uses, wired to the object query routes through the generated SDK. Queries\n * are validated server-side; failures surface as `SixbQueryError`.\n */\n\nimport type { SixbObjectTypeMap } from \"@sixb/core/ontology\"\nimport type {\n ObjectQuery,\n ObjectQueryBuilder,\n ObjectQueryExecutor,\n ObjectQueryExecutorExpandedRow,\n ObjectQueryExecutorFacetRequest,\n ObjectQueryExecutorLinkValue,\n ObjectQueryExecutorRow,\n ObjectTypeWithPropertyTokens,\n} from \"@sixb/core/query\"\nimport { createObjectQueryBuilder } from \"@sixb/core/query\"\nimport { isSixbApiError } from \"./api\"\nimport type { Client } from \"./generated/client\"\nimport { countObjects, existsObjects, facetObjects, queryObjects } from \"./generated/sdk.gen\"\nimport type {\n ObjectQueryIssue,\n ObjectQueryObject,\n ObjectQuery as WireObjectQuery,\n} from \"./generated/types.gen\"\n\nexport type { ObjectQueryIssue }\n\nexport class SixbQueryError extends Error {\n readonly issues: readonly ObjectQueryIssue[]\n\n constructor(message: string, issues: readonly ObjectQueryIssue[] = []) {\n super(message)\n this.name = \"SixbQueryError\"\n this.issues = issues\n }\n}\n\nexport interface SixbQueryClientOptions {\n /** hey-api client override (base url, auth, fetch). Defaults to the global client. */\n client?: Client\n}\n\n// Value types are typed as \"none registered\": custom value-type refs resolve\n// like a runtime without them, and the empty tuple keeps property-value\n// inference shallow enough for TypeScript's recursion limits.\ntype ClientRegisteredObjectTypes<TObjectType extends ObjectTypeWithPropertyTokens> =\n | TObjectType\n | Extract<SixbObjectTypeMap[keyof SixbObjectTypeMap], ObjectTypeWithPropertyTokens>\n\nexport type ClientObjectQueryBuilder<TObjectType extends ObjectTypeWithPropertyTokens> =\n ObjectQueryBuilder<TObjectType, ClientRegisteredObjectTypes<TObjectType>, readonly []>\n\nexport function objects<TObjectType extends ObjectTypeWithPropertyTokens>(\n objectType: TObjectType,\n options?: SixbQueryClientOptions\n): { query: () => ClientObjectQueryBuilder<TObjectType> } {\n return {\n query: () =>\n createObjectQueryBuilder<TObjectType, ClientRegisteredObjectTypes<TObjectType>, readonly []>({\n query: { kind: \"start\", objectTypeId: objectType.id },\n executor: createHttpQueryExecutor(options?.client),\n }),\n }\n}\n\nexport function createHttpQueryExecutor(client?: Client): ObjectQueryExecutor {\n // Pin the SDK call shape regardless of client-level config: with\n // `responseStyle: \"data\"` the call would return the bare body (breaking the\n // `{ data, error }` destructuring below), and with `throwOnError: true`\n // failures would throw raw SDK errors instead of mapping to SixbQueryError.\n const callOptions = { client, responseStyle: \"fields\", throwOnError: false } as const\n\n return {\n async list(query: ObjectQuery, options?: { includeTotal?: boolean }) {\n const { data, error } = await queryObjects({\n ...callOptions,\n body: { query: toWireQuery(query), includeTotal: options?.includeTotal },\n })\n if (error || !data) throw toSixbQueryError(error)\n return {\n objects: data.objects.map(reviveQueryRow),\n hasMore: data.hasMore,\n total: data.total,\n nextPageToken: data.nextPageToken,\n }\n },\n\n async count(query: ObjectQuery) {\n const { data, error } = await countObjects({\n ...callOptions,\n body: { query: toWireQuery(query) },\n })\n if (error || !data) throw toSixbQueryError(error)\n return data.count\n },\n\n async exists(query: ObjectQuery) {\n const { data, error } = await existsObjects({\n ...callOptions,\n body: { query: toWireQuery(query) },\n })\n if (error || !data) throw toSixbQueryError(error)\n return data.exists\n },\n\n async facets(query: ObjectQuery, facets: readonly ObjectQueryExecutorFacetRequest[]) {\n const { data, error } = await facetObjects({\n ...callOptions,\n body: { query: toWireQuery(query), facets: [...facets] },\n })\n if (error || !data) throw toSixbQueryError(error)\n return data.facets.map((facet) => ({\n propertyId: facet.propertyId,\n buckets: [...facet.buckets],\n }))\n },\n }\n}\n\n// Revive a query row tree: parse ISO timestamps to Date at every hop and carry\n// the `links` attached by `expand` nodes (with edge `linkProperties`). The\n// builder types `links` precisely; here it flows through as runtime data.\nfunction reviveQueryRow(row: ObjectQueryObject): ObjectQueryExecutorRow {\n const revived: ObjectQueryExecutorRow = {\n primaryId: row.primaryId,\n objectTypeId: row.objectTypeId,\n properties: row.properties,\n createdAt: new Date(row.createdAt),\n updatedAt: new Date(row.updatedAt),\n }\n if (row.links) {\n const links: Record<string, ObjectQueryExecutorLinkValue> = {}\n for (const [linkId, value] of Object.entries(row.links)) {\n links[linkId] = reviveLinkValue(value)\n }\n revived.links = links\n }\n return revived\n}\n\nfunction reviveLinkValue(\n value: ObjectQueryObject | ObjectQueryObject[] | null\n): ObjectQueryExecutorLinkValue {\n if (value === null) return null\n if (Array.isArray(value)) return value.map(reviveExpandedRow)\n return reviveExpandedRow(value)\n}\n\nfunction reviveExpandedRow(row: ObjectQueryObject): ObjectQueryExecutorExpandedRow {\n const revived: ObjectQueryExecutorExpandedRow = reviveQueryRow(row)\n if (row.linkProperties !== undefined) revived.linkProperties = row.linkProperties\n return revived\n}\n\n// The generated wire type mirrors the core IR JSON schema; they differ only in\n// readonly-ness, which a structural cast cannot bridge.\nfunction toWireQuery(query: ObjectQuery): WireObjectQuery {\n return query as unknown as WireObjectQuery\n}\n\nfunction toSixbQueryError(error: unknown): SixbQueryError {\n // The browser client wraps failures in `SixbApiError`; tests and bare clients\n // surface the raw response body. Unwrap to the body either way so server-sent\n // query issues survive.\n const body = isSixbApiError(error) ? error.body : error\n if (body && typeof body === \"object\" && \"error\" in body) {\n const payload = body as { error: unknown; issues?: ObjectQueryIssue[] }\n return new SixbQueryError(`[SixbClient] ${String(payload.error)}`, payload.issues ?? [])\n }\n return new SixbQueryError(\"[SixbClient] Object query request failed\")\n}\n"
6
- ],
7
- "mappings": ";;;;;;;;;;;;AAmBA;AAYO,MAAM,wBAAuB,MAAM;AAAA,EAC/B;AAAA,EAET,WAAW,CAAC,SAAiB,SAAsC,CAAC,GAAG;AAAA,IACrE,MAAM,OAAO;AAAA,IACb,KAAK,OAAO;AAAA,IACZ,KAAK,SAAS;AAAA;AAElB;AAiBO,SAAS,QAAyD,CACvE,YACA,SACwD;AAAA,EACxD,OAAO;AAAA,IACL,OAAO,MACL,yBAA6F;AAAA,MAC3F,OAAO,EAAE,MAAM,SAAS,cAAc,WAAW,GAAG;AAAA,MACpD,UAAU,yBAAwB,SAAS,MAAM;AAAA,IACnD,CAAC;AAAA,EACL;AAAA;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