@sixb/client 0.1.7 → 0.1.8

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 (59) hide show
  1. package/dist/api.d.ts +5 -0
  2. package/dist/api.d.ts.map +1 -1
  3. package/dist/browser.d.ts +18 -1
  4. package/dist/browser.d.ts.map +1 -1
  5. package/dist/browser.js +180 -35
  6. package/dist/browser.js.map +3 -3
  7. package/dist/{chunk-dcebhkmz.js → chunk-0g4bg41z.js} +25 -5
  8. package/dist/chunk-0g4bg41z.js.map +17 -0
  9. package/dist/chunk-3gvmb0w6.js +23 -0
  10. package/dist/chunk-3gvmb0w6.js.map +10 -0
  11. package/dist/{chunk-h80qj1f8.js → chunk-cmfd585n.js} +17 -2
  12. package/dist/chunk-cmfd585n.js.map +10 -0
  13. package/dist/{chunk-r8p88mbg.js → chunk-n4160ht2.js} +103 -21
  14. package/dist/chunk-n4160ht2.js.map +19 -0
  15. package/dist/{chunk-p0xrjaz6.js → chunk-se1tydhh.js} +2 -2
  16. package/dist/{chunk-b3bfdm80.js → chunk-v8q8185t.js} +61 -6
  17. package/dist/chunk-v8q8185t.js.map +10 -0
  18. package/dist/{chunk-m4by7m5r.js → chunk-x6pk2xhn.js} +21 -4
  19. package/dist/chunk-x6pk2xhn.js.map +12 -0
  20. package/dist/client-authority.d.ts +6 -0
  21. package/dist/client-authority.d.ts.map +1 -0
  22. package/dist/events-builder.d.ts.map +1 -1
  23. package/dist/generated/@tanstack/react-query.gen.d.ts +395 -126
  24. package/dist/generated/@tanstack/react-query.gen.d.ts.map +1 -1
  25. package/dist/generated/index.d.ts +2 -2
  26. package/dist/generated/index.d.ts.map +1 -1
  27. package/dist/generated/sdk.gen.d.ts +25 -1
  28. package/dist/generated/sdk.gen.d.ts.map +1 -1
  29. package/dist/generated/types.gen.d.ts +362 -3
  30. package/dist/generated/types.gen.d.ts.map +1 -1
  31. package/dist/hooks.js +120 -6
  32. package/dist/hooks.js.map +3 -3
  33. package/dist/index.js +21 -6
  34. package/dist/index.js.map +1 -1
  35. package/dist/logs-builder.d.ts.map +1 -1
  36. package/dist/logs.js +5 -4
  37. package/dist/logs.js.map +1 -1
  38. package/dist/models.js +14 -2
  39. package/dist/models.js.map +1 -1
  40. package/dist/query.js +5 -4
  41. package/dist/query.js.map +1 -1
  42. package/dist/ws-socket.d.ts.map +1 -1
  43. package/package.json +2 -2
  44. package/src/api.ts +92 -3
  45. package/src/browser.ts +257 -48
  46. package/src/client-authority.ts +31 -0
  47. package/src/events-builder.ts +18 -1
  48. package/src/generated/@tanstack/react-query.gen.ts +229 -0
  49. package/src/generated/index.ts +36 -0
  50. package/src/generated/sdk.gen.ts +178 -12
  51. package/src/generated/types.gen.ts +402 -3
  52. package/src/logs-builder.ts +14 -1
  53. package/src/ws-socket.ts +11 -0
  54. package/dist/chunk-b3bfdm80.js.map +0 -10
  55. package/dist/chunk-dcebhkmz.js.map +0 -17
  56. package/dist/chunk-h80qj1f8.js.map +0 -10
  57. package/dist/chunk-m4by7m5r.js.map +0 -12
  58. package/dist/chunk-r8p88mbg.js.map +0 -19
  59. /package/dist/{chunk-p0xrjaz6.js.map → chunk-se1tydhh.js.map} +0 -0
@@ -4134,6 +4134,7 @@ export type ListDatasetsResponses = {
4134
4134
  id: string
4135
4135
  description?: string
4136
4136
  primaryKey?: string | Array<string>
4137
+ sequenceBy?: string
4137
4138
  partitionBy?: Array<string>
4138
4139
  schema: {
4139
4140
  columns: Array<{
@@ -4207,6 +4208,7 @@ export type GetDatasetResponses = {
4207
4208
  id: string
4208
4209
  description?: string
4209
4210
  primaryKey?: string | Array<string>
4211
+ sequenceBy?: string
4210
4212
  partitionBy?: Array<string>
4211
4213
  schema: {
4212
4214
  columns: Array<{
@@ -4302,7 +4304,7 @@ export type ListDatasetVersionsResponses = {
4302
4304
  }>
4303
4305
  }
4304
4306
  producer?: {
4305
- kind: "sync" | "pipeline"
4307
+ kind: "sync" | "pipeline" | "ingest"
4306
4308
  id?: string
4307
4309
  runId?: string
4308
4310
  }
@@ -4378,7 +4380,7 @@ export type GetDatasetVersionResponses = {
4378
4380
  }>
4379
4381
  }
4380
4382
  producer?: {
4381
- kind: "sync" | "pipeline"
4383
+ kind: "sync" | "pipeline" | "ingest"
4382
4384
  id?: string
4383
4385
  runId?: string
4384
4386
  }
@@ -4458,7 +4460,7 @@ export type ListDatasetRowsResponses = {
4458
4460
  }>
4459
4461
  }
4460
4462
  producer?: {
4461
- kind: "sync" | "pipeline"
4463
+ kind: "sync" | "pipeline" | "ingest"
4462
4464
  id?: string
4463
4465
  runId?: string
4464
4466
  }
@@ -4507,6 +4509,7 @@ export type ListSyncsResponses = {
4507
4509
  id: string
4508
4510
  description?: string
4509
4511
  primaryKey?: string | Array<string>
4512
+ sequenceBy?: string
4510
4513
  partitionBy?: Array<string>
4511
4514
  schema: {
4512
4515
  columns: Array<{
@@ -4613,6 +4616,7 @@ export type GetSyncResponses = {
4613
4616
  id: string
4614
4617
  description?: string
4615
4618
  primaryKey?: string | Array<string>
4619
+ sequenceBy?: string
4616
4620
  partitionBy?: Array<string>
4617
4621
  schema: {
4618
4622
  columns: Array<{
@@ -4855,6 +4859,7 @@ export type ListPipelinesResponses = {
4855
4859
  id: string
4856
4860
  description?: string
4857
4861
  primaryKey?: string | Array<string>
4862
+ sequenceBy?: string
4858
4863
  partitionBy?: Array<string>
4859
4864
  schema: {
4860
4865
  columns: Array<{
@@ -4878,6 +4883,7 @@ export type ListPipelinesResponses = {
4878
4883
  id: string
4879
4884
  description?: string
4880
4885
  primaryKey?: string | Array<string>
4886
+ sequenceBy?: string
4881
4887
  partitionBy?: Array<string>
4882
4888
  schema: {
4883
4889
  columns: Array<{
@@ -4991,6 +4997,7 @@ export type GetPipelineResponses = {
4991
4997
  id: string
4992
4998
  description?: string
4993
4999
  primaryKey?: string | Array<string>
5000
+ sequenceBy?: string
4994
5001
  partitionBy?: Array<string>
4995
5002
  schema: {
4996
5003
  columns: Array<{
@@ -5014,6 +5021,7 @@ export type GetPipelineResponses = {
5014
5021
  id: string
5015
5022
  description?: string
5016
5023
  primaryKey?: string | Array<string>
5024
+ sequenceBy?: string
5017
5025
  partitionBy?: Array<string>
5018
5026
  schema: {
5019
5027
  columns: Array<{
@@ -7452,6 +7460,397 @@ export type ListRuleStatesResponses = {
7452
7460
 
7453
7461
  export type ListRuleStatesResponse = ListRuleStatesResponses[keyof ListRuleStatesResponses]
7454
7462
 
7463
+ export type ListSharedAccessGrantsData = {
7464
+ body?: never
7465
+ path?: never
7466
+ query: {
7467
+ definitionId: string
7468
+ primaryId?: string
7469
+ includeRevoked?: boolean
7470
+ includeExpired?: boolean
7471
+ limit?: number
7472
+ offset?: number
7473
+ }
7474
+ url: "/api/share-grants"
7475
+ }
7476
+
7477
+ export type ListSharedAccessGrantsErrors = {
7478
+ /**
7479
+ * Response for status 400
7480
+ */
7481
+ 400: {
7482
+ error: string
7483
+ }
7484
+ /**
7485
+ * Response for status 401
7486
+ */
7487
+ 401: {
7488
+ error: string
7489
+ }
7490
+ /**
7491
+ * Response for status 403
7492
+ */
7493
+ 403: {
7494
+ error: string
7495
+ }
7496
+ /**
7497
+ * Response for status 404
7498
+ */
7499
+ 404: {
7500
+ error: string
7501
+ }
7502
+ /**
7503
+ * Response for status 500
7504
+ */
7505
+ 500: {
7506
+ error: string
7507
+ }
7508
+ /**
7509
+ * Response for status 501
7510
+ */
7511
+ 501: {
7512
+ error: string
7513
+ }
7514
+ }
7515
+
7516
+ export type ListSharedAccessGrantsError =
7517
+ ListSharedAccessGrantsErrors[keyof ListSharedAccessGrantsErrors]
7518
+
7519
+ export type ListSharedAccessGrantsResponses = {
7520
+ /**
7521
+ * Response for status 200
7522
+ */
7523
+ 200: {
7524
+ grants: Array<{
7525
+ id: string
7526
+ definitionId: string
7527
+ target: {
7528
+ objectTypeId: string
7529
+ primaryId: string
7530
+ }
7531
+ issuedBy: {
7532
+ type: "user" | "serviceAccount"
7533
+ id: string
7534
+ }
7535
+ destinationPath: string
7536
+ createdAt: string
7537
+ expiresAt: string
7538
+ revokedAt?: string
7539
+ revokedBy?: {
7540
+ type: "user" | "serviceAccount" | "system"
7541
+ id: string
7542
+ }
7543
+ }>
7544
+ hasMore: boolean
7545
+ total: number
7546
+ }
7547
+ }
7548
+
7549
+ export type ListSharedAccessGrantsResponse =
7550
+ ListSharedAccessGrantsResponses[keyof ListSharedAccessGrantsResponses]
7551
+
7552
+ export type IssueSharedAccessGrantData = {
7553
+ body: {
7554
+ definitionId: string
7555
+ target: {
7556
+ objectTypeId: string
7557
+ primaryId: string
7558
+ }
7559
+ destinationPath: string
7560
+ expiresAt: string
7561
+ }
7562
+ path?: never
7563
+ query?: never
7564
+ url: "/api/share-grants"
7565
+ }
7566
+
7567
+ export type IssueSharedAccessGrantErrors = {
7568
+ /**
7569
+ * Response for status 400
7570
+ */
7571
+ 400: {
7572
+ error: string
7573
+ }
7574
+ /**
7575
+ * Response for status 401
7576
+ */
7577
+ 401: {
7578
+ error: string
7579
+ }
7580
+ /**
7581
+ * Response for status 403
7582
+ */
7583
+ 403: {
7584
+ error: string
7585
+ }
7586
+ /**
7587
+ * Response for status 404
7588
+ */
7589
+ 404: {
7590
+ error: string
7591
+ }
7592
+ /**
7593
+ * Response for status 500
7594
+ */
7595
+ 500: {
7596
+ error: string
7597
+ }
7598
+ /**
7599
+ * Response for status 501
7600
+ */
7601
+ 501: {
7602
+ error: string
7603
+ }
7604
+ }
7605
+
7606
+ export type IssueSharedAccessGrantError =
7607
+ IssueSharedAccessGrantErrors[keyof IssueSharedAccessGrantErrors]
7608
+
7609
+ export type IssueSharedAccessGrantResponses = {
7610
+ /**
7611
+ * Response for status 201
7612
+ */
7613
+ 201: {
7614
+ grant: {
7615
+ id: string
7616
+ definitionId: string
7617
+ target: {
7618
+ objectTypeId: string
7619
+ primaryId: string
7620
+ }
7621
+ issuedBy: {
7622
+ type: "user" | "serviceAccount"
7623
+ id: string
7624
+ }
7625
+ destinationPath: string
7626
+ createdAt: string
7627
+ expiresAt: string
7628
+ revokedAt?: string
7629
+ revokedBy?: {
7630
+ type: "user" | "serviceAccount" | "system"
7631
+ id: string
7632
+ }
7633
+ }
7634
+ url: string
7635
+ }
7636
+ }
7637
+
7638
+ export type IssueSharedAccessGrantResponse =
7639
+ IssueSharedAccessGrantResponses[keyof IssueSharedAccessGrantResponses]
7640
+
7641
+ export type RevokeSharedAccessGrantData = {
7642
+ body?: never
7643
+ path: {
7644
+ grantId: string
7645
+ }
7646
+ query?: never
7647
+ url: "/api/share-grants/{grantId}"
7648
+ }
7649
+
7650
+ export type RevokeSharedAccessGrantErrors = {
7651
+ /**
7652
+ * Response for status 400
7653
+ */
7654
+ 400: {
7655
+ error: string
7656
+ }
7657
+ /**
7658
+ * Response for status 401
7659
+ */
7660
+ 401: {
7661
+ error: string
7662
+ }
7663
+ /**
7664
+ * Response for status 403
7665
+ */
7666
+ 403: {
7667
+ error: string
7668
+ }
7669
+ /**
7670
+ * Response for status 404
7671
+ */
7672
+ 404: {
7673
+ error: string
7674
+ }
7675
+ /**
7676
+ * Response for status 500
7677
+ */
7678
+ 500: {
7679
+ error: string
7680
+ }
7681
+ /**
7682
+ * Response for status 501
7683
+ */
7684
+ 501: {
7685
+ error: string
7686
+ }
7687
+ }
7688
+
7689
+ export type RevokeSharedAccessGrantError =
7690
+ RevokeSharedAccessGrantErrors[keyof RevokeSharedAccessGrantErrors]
7691
+
7692
+ export type RevokeSharedAccessGrantResponses = {
7693
+ /**
7694
+ * Response for status 200
7695
+ */
7696
+ 200: {
7697
+ grant: {
7698
+ id: string
7699
+ definitionId: string
7700
+ target: {
7701
+ objectTypeId: string
7702
+ primaryId: string
7703
+ }
7704
+ issuedBy: {
7705
+ type: "user" | "serviceAccount"
7706
+ id: string
7707
+ }
7708
+ destinationPath: string
7709
+ createdAt: string
7710
+ expiresAt: string
7711
+ revokedAt?: string
7712
+ revokedBy?: {
7713
+ type: "user" | "serviceAccount" | "system"
7714
+ id: string
7715
+ }
7716
+ }
7717
+ }
7718
+ }
7719
+
7720
+ export type RevokeSharedAccessGrantResponse =
7721
+ RevokeSharedAccessGrantResponses[keyof RevokeSharedAccessGrantResponses]
7722
+
7723
+ export type ExchangeSharedAccessData = {
7724
+ body: {
7725
+ secret: string
7726
+ }
7727
+ path: {
7728
+ grantId: string
7729
+ }
7730
+ query?: never
7731
+ url: "/api/shared-access/{grantId}/exchange"
7732
+ }
7733
+
7734
+ export type ExchangeSharedAccessErrors = {
7735
+ /**
7736
+ * Response for status 401
7737
+ */
7738
+ 401: {
7739
+ error: string
7740
+ }
7741
+ /**
7742
+ * Response for status 503
7743
+ */
7744
+ 503: {
7745
+ error: string
7746
+ }
7747
+ }
7748
+
7749
+ export type ExchangeSharedAccessError = ExchangeSharedAccessErrors[keyof ExchangeSharedAccessErrors]
7750
+
7751
+ export type ExchangeSharedAccessResponses = {
7752
+ /**
7753
+ * Response for status 200
7754
+ */
7755
+ 200: {
7756
+ grantId: string
7757
+ destinationPath: string
7758
+ expiresAt: string
7759
+ absoluteExpiresAt: string
7760
+ csrfToken: string
7761
+ }
7762
+ }
7763
+
7764
+ export type ExchangeSharedAccessResponse =
7765
+ ExchangeSharedAccessResponses[keyof ExchangeSharedAccessResponses]
7766
+
7767
+ export type GetSharedAccessSessionData = {
7768
+ body?: never
7769
+ path: {
7770
+ grantId: string
7771
+ }
7772
+ query?: never
7773
+ url: "/api/shared-access/{grantId}/session"
7774
+ }
7775
+
7776
+ export type GetSharedAccessSessionErrors = {
7777
+ /**
7778
+ * Response for status 401
7779
+ */
7780
+ 401: {
7781
+ error: string
7782
+ }
7783
+ /**
7784
+ * Response for status 503
7785
+ */
7786
+ 503: {
7787
+ error: string
7788
+ }
7789
+ }
7790
+
7791
+ export type GetSharedAccessSessionError =
7792
+ GetSharedAccessSessionErrors[keyof GetSharedAccessSessionErrors]
7793
+
7794
+ export type GetSharedAccessSessionResponses = {
7795
+ /**
7796
+ * Response for status 200
7797
+ */
7798
+ 200: {
7799
+ grantId: string
7800
+ destinationPath: string
7801
+ expiresAt: string
7802
+ absoluteExpiresAt: string
7803
+ csrfToken: string
7804
+ }
7805
+ }
7806
+
7807
+ export type GetSharedAccessSessionResponse =
7808
+ GetSharedAccessSessionResponses[keyof GetSharedAccessSessionResponses]
7809
+
7810
+ export type SignOutSharedAccessData = {
7811
+ body?: never
7812
+ path: {
7813
+ grantId: string
7814
+ }
7815
+ query?: never
7816
+ url: "/api/shared-access/{grantId}/sign-out"
7817
+ }
7818
+
7819
+ export type SignOutSharedAccessErrors = {
7820
+ /**
7821
+ * Response for status 401
7822
+ */
7823
+ 401: {
7824
+ error: string
7825
+ }
7826
+ /**
7827
+ * Response for status 403
7828
+ */
7829
+ 403: {
7830
+ error: string
7831
+ }
7832
+ /**
7833
+ * Response for status 503
7834
+ */
7835
+ 503: {
7836
+ error: string
7837
+ }
7838
+ }
7839
+
7840
+ export type SignOutSharedAccessError = SignOutSharedAccessErrors[keyof SignOutSharedAccessErrors]
7841
+
7842
+ export type SignOutSharedAccessResponses = {
7843
+ /**
7844
+ * Response for status 200
7845
+ */
7846
+ 200: {
7847
+ signedOut: true
7848
+ }
7849
+ }
7850
+
7851
+ export type SignOutSharedAccessResponse =
7852
+ SignOutSharedAccessResponses[keyof SignOutSharedAccessResponses]
7853
+
7455
7854
  export type ListObjectTypesData = {
7456
7855
  body?: never
7457
7856
  path?: never
@@ -5,8 +5,10 @@ import {
5
5
  type SixbRunKind,
6
6
  type StoredLogLine,
7
7
  } from "@sixb/core/logging"
8
+ import { hasClientSharedAuthority, SHARED_ACCESS_REALTIME_UNAVAILABLE } from "./client-authority"
8
9
  import { listLogs } from "./generated"
9
10
  import type { Client } from "./generated/client"
11
+ import { client as generatedClient } from "./generated/client.gen"
10
12
  import { createLogSocket, type LogSocketState } from "./logs-transport"
11
13
 
12
14
  export interface LogsFilterIR {
@@ -80,6 +82,17 @@ class LogsBuilderImpl implements RunScopedLogsBuilder {
80
82
  }
81
83
 
82
84
  subscribe(handler: (line: StoredLogLine) => void, options?: LogSubscribeOptions): () => void {
85
+ const transportClient = this.options?.client ?? generatedClient
86
+ if (hasClientSharedAuthority(transportClient)) {
87
+ options?.onError?.(SHARED_ACCESS_REALTIME_UNAVAILABLE)
88
+ options?.onStateChange?.({
89
+ connected: false,
90
+ reconnecting: false,
91
+ error: SHARED_ACCESS_REALTIME_UNAVAILABLE,
92
+ })
93
+ return () => undefined
94
+ }
95
+
83
96
  const socket = createLogSocket({
84
97
  kinds: this.ir.kinds,
85
98
  run: this.ir.run,
@@ -87,7 +100,7 @@ class LogsBuilderImpl implements RunScopedLogsBuilder {
87
100
  afterCursor: options?.afterCursor,
88
101
  reconnect: options?.reconnect,
89
102
  reconnectDelayMs: options?.reconnectDelayMs,
90
- baseUrl: this.options?.client?.getConfig().baseUrl,
103
+ baseUrl: transportClient.getConfig().baseUrl,
91
104
  onLog: handler,
92
105
  onError: options?.onError,
93
106
  onReset: options?.onReset,
package/src/ws-socket.ts CHANGED
@@ -7,6 +7,7 @@
7
7
  * protocol while sharing one reconnection loop. React is an optional peer of `@sixb/client`;
8
8
  * nothing here may import it.
9
9
  */
10
+ import { hasClientSharedAuthority, SHARED_ACCESS_REALTIME_UNAVAILABLE } from "./client-authority"
10
11
  import { client } from "./generated/client.gen"
11
12
 
12
13
  const DEFAULT_SIXB_API_BASE_URL = "http://localhost:3002"
@@ -65,6 +66,16 @@ const INITIAL_STATE: ReconnectingSocketState = {
65
66
  }
66
67
 
67
68
  export function createReconnectingSocket(options: ReconnectingSocketOptions): ReconnectingSocket {
69
+ if (hasClientSharedAuthority(client)) {
70
+ options.onError?.(SHARED_ACCESS_REALTIME_UNAVAILABLE)
71
+ options.onStateChange?.({
72
+ connected: false,
73
+ reconnecting: false,
74
+ error: SHARED_ACCESS_REALTIME_UNAVAILABLE,
75
+ })
76
+ return { close: () => undefined }
77
+ }
78
+
68
79
  const { reconnect = true, reconnectDelayMs = DEFAULT_RECONNECT_DELAY_MS } = options
69
80
 
70
81
  let state = INITIAL_STATE
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/api.ts"],
4
- "sourcesContent": [
5
- "import type { SixbErrorCode } from \"@sixb/core\"\nimport { type Auth, type Client, type Config, createClient, createConfig } from \"./generated/client\"\nimport { client as sharedClient } from \"./generated/client.gen\"\n\nexport const SIXB_CSRF_HEADER_NAME = \"x-sixb-csrf\"\nexport const SIXB_CSRF_TOKEN_RESPONSE_HEADER_NAME = \"x-sixb-csrf-token\"\n\nexport type SixbClient = Client\n\nexport type SixbClientAuth =\n | {\n readonly kind: \"bearer\"\n readonly token: string\n }\n | {\n readonly kind: \"cookie\"\n readonly csrfToken?: () => string | null | undefined\n }\n | {\n readonly kind: \"none\"\n }\n\nexport interface SixbClientOptions {\n readonly baseUrl?: string\n readonly auth?: SixbClientAuth\n readonly fetch?: typeof fetch\n readonly headers?: Config[\"headers\"]\n readonly credentials?: RequestCredentials\n}\n\nexport interface SixbApiErrorInit {\n readonly status: number\n readonly statusText?: string\n readonly url?: string\n readonly method?: string\n readonly body?: unknown\n}\n\n/** Known Sixb codes with a forward-compatible escape hatch for newer servers. */\nexport type SixbApiErrorCode = SixbErrorCode | (string & Record<never, never>)\n\n/**\n * A structured HTTP error thrown by the Sixb client. The raw generated client\n * throws the bare response body (a string, or parsed JSON) with no status code\n * or identity, which makes failures impossible to branch on and prints as\n * cryptic quoted text in dev tooling. `SixbApiError` carries the status, the\n * parsed `body`, an optional stable `code`, and a readable `message`, so callers\n * and error boundaries can branch without parsing prose.\n */\nexport class SixbApiError extends Error {\n readonly status: number\n readonly statusText: string\n readonly url: string\n readonly method: string\n readonly body: unknown\n readonly code?: SixbApiErrorCode\n\n constructor(message: string, init: SixbApiErrorInit) {\n super(message)\n this.name = \"SixbApiError\"\n this.status = init.status\n this.statusText = init.statusText ?? \"\"\n this.url = init.url ?? \"\"\n this.method = init.method ?? \"\"\n this.body = init.body\n this.code = extractErrorCode(init.body)\n }\n}\n\n/**\n * Identifies a `SixbApiError` across bundle boundaries. The custom app and the\n * client are bundled separately, so a plain `instanceof` would miss errors that\n * crossed packages; the structural fallback recognizes them by shape.\n */\nexport function isSixbApiError(value: unknown): value is SixbApiError {\n if (value instanceof SixbApiError) {\n return true\n }\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as { name?: unknown }).name === \"SixbApiError\" &&\n typeof (value as { status?: unknown }).status === \"number\"\n )\n}\n\nexport function createSixbClient(options: SixbClientOptions = {}): SixbClient {\n const client = createClient(createSixbClientConfig(options))\n installSixbErrorInterceptor(client)\n return client\n}\n\nexport function configureSixbClient(\n client: SixbClient,\n options: SixbClientOptions = {}\n): SixbClient {\n client.setConfig(createSixbClientConfig(options))\n installSixbErrorInterceptor(client)\n return client\n}\n\nexport function createSixbClientConfig(options: SixbClientOptions = {}): Config {\n const auth = options.auth ?? { kind: \"none\" as const }\n if (auth.kind === \"bearer\" && !auth.token.trim()) {\n throw new Error(\"[SixbClient] Bearer token cannot be empty.\")\n }\n\n return createConfig({\n ...(options.baseUrl === undefined ? {} : { baseUrl: normalizeSixbApiBaseUrl(options.baseUrl) }),\n ...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n ...(options.headers === undefined ? {} : { headers: options.headers }),\n credentials: auth.kind === \"cookie\" ? \"include\" : options.credentials,\n auth: auth.kind === \"none\" ? undefined : createSixbAuthResolver(auth),\n })\n}\n\nexport function normalizeSixbApiBaseUrl(value: string): string {\n const absolute = /^[a-z][a-z\\d+.-]*:\\/\\//i.test(value)\n let url: URL\n\n try {\n url = new URL(value, absolute ? undefined : \"http://sixb.local\")\n } catch {\n throw new Error(`[SixbClient] Invalid API base URL '${value}'.`)\n }\n\n const pathname = stripTrailingApiPath(url.pathname)\n if (!absolute) {\n return pathname\n }\n\n return `${url.origin}${pathname === \"/\" ? \"\" : pathname}`\n}\n\nfunction createSixbAuthResolver(auth: SixbClientAuth): Config[\"auth\"] {\n return (scheme: Auth) => {\n if (auth.kind === \"bearer\") {\n return isBearerAuth(scheme) ? auth.token : undefined\n }\n\n if (auth.kind === \"cookie\") {\n return isCsrfAuth(scheme) ? (auth.csrfToken?.() ?? undefined) : undefined\n }\n\n return undefined\n }\n}\n\nfunction isBearerAuth(auth: Auth): boolean {\n return auth.type === \"http\" && auth.scheme === \"bearer\"\n}\n\nfunction isCsrfAuth(auth: Auth): boolean {\n return auth.type === \"apiKey\" && auth.in !== \"query\" && auth.name === SIXB_CSRF_HEADER_NAME\n}\n\nfunction stripTrailingApiPath(pathname: string): string {\n const trimmed = pathname.replace(/\\/+$/, \"\")\n if (!trimmed || trimmed === \"/api\") {\n return \"\"\n }\n\n if (trimmed.endsWith(\"/api\")) {\n return trimmed.slice(0, -4) || \"\"\n }\n\n return trimmed\n}\n\n/**\n * Maps the generated client's raw error (bare body) into a `SixbApiError`.\n * Runs for every failed response regardless of `throwOnError`, so both thrown\n * errors and the `{ error }` result field carry the structured type. Network\n * failures (no `response`) are already native `Error`s and pass through.\n */\nfunction sixbErrorInterceptor(\n error: unknown,\n response: Response | undefined,\n request: Request | undefined\n): unknown {\n if (isSixbApiError(error) || !response) {\n return error\n }\n\n const method = request?.method ?? \"\"\n const url = response.url || request?.url || \"\"\n return new SixbApiError(buildSixbApiErrorMessage(method, url, response, error), {\n status: response.status,\n statusText: response.statusText,\n url,\n method,\n body: error,\n })\n}\n\nfunction buildSixbApiErrorMessage(\n method: string,\n url: string,\n response: Response,\n body: unknown\n): string {\n const status = response.statusText\n ? `${response.status} ${response.statusText}`\n : String(response.status)\n const target = [method, safeRequestPath(url)].filter(Boolean).join(\" \")\n const head = target ? `[SixbClient] ${target} → ${status}` : `[SixbClient] request → ${status}`\n const detail = extractErrorDetail(body)\n return detail ? `${head}: ${detail}` : head\n}\n\nfunction extractErrorDetail(body: unknown): string | undefined {\n if (typeof body === \"string\") {\n return body.trim() || undefined\n }\n if (body && typeof body === \"object\" && \"error\" in body) {\n const message = (body as { error: unknown }).error\n if (typeof message === \"string\" && message.trim()) {\n return message\n }\n }\n return undefined\n}\n\nfunction extractErrorCode(body: unknown): SixbApiErrorCode | undefined {\n if (!body || typeof body !== \"object\") {\n return undefined\n }\n\n try {\n const code = Reflect.get(body, \"code\")\n return typeof code === \"string\" && code.trim() === code && code.length > 0 ? code : undefined\n } catch {\n return undefined\n }\n}\n\nfunction safeRequestPath(url: string): string {\n try {\n return new URL(url).pathname\n } catch {\n return url\n }\n}\n\nfunction installSixbErrorInterceptor(client: SixbClient): void {\n if (!client.interceptors.error.exists(sixbErrorInterceptor)) {\n client.interceptors.error.use(sixbErrorInterceptor)\n }\n}\n\n// Package-level SDK functions use the generated singleton. Initialize it once at the transport\n// boundary so the shared client and `createSixbClient()` expose the same HTTP error contract.\ninstallSixbErrorInterceptor(sharedClient)\n"
6
- ],
7
- "mappings": ";;;;;;;;AAIO,IAAM,wBAAwB;AAC9B,IAAM,uCAAuC;AAAA;AA4C7C,MAAM,qBAAqB,MAAM;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAET,WAAW,CAAC,SAAiB,MAAwB;AAAA,IACnD,MAAM,OAAO;AAAA,IACb,KAAK,OAAO;AAAA,IACZ,KAAK,SAAS,KAAK;AAAA,IACnB,KAAK,aAAa,KAAK,cAAc;AAAA,IACrC,KAAK,MAAM,KAAK,OAAO;AAAA,IACvB,KAAK,SAAS,KAAK,UAAU;AAAA,IAC7B,KAAK,OAAO,KAAK;AAAA,IACjB,KAAK,OAAO,iBAAiB,KAAK,IAAI;AAAA;AAE1C;AAOO,SAAS,cAAc,CAAC,OAAuC;AAAA,EACpE,IAAI,iBAAiB,cAAc;AAAA,IACjC,OAAO;AAAA,EACT;AAAA,EACA,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAA6B,SAAS,kBACvC,OAAQ,MAA+B,WAAW;AAAA;AAI/C,SAAS,gBAAgB,CAAC,UAA6B,CAAC,GAAe;AAAA,EAC5E,MAAM,UAAS,aAAa,uBAAuB,OAAO,CAAC;AAAA,EAC3D,4BAA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