@sixb/client 0.1.18 → 0.1.20
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.
- package/README.md +13 -31
- package/dist/actions.d.ts +9 -50
- package/dist/actions.d.ts.map +1 -1
- package/dist/browser.d.ts +1 -4
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +2 -4
- package/dist/browser.js.map +3 -3
- package/dist/{chunk-pvmd5f18.js → chunk-g05ar78c.js} +13 -223
- package/dist/chunk-g05ar78c.js.map +17 -0
- package/dist/{chunk-jh4ts8mt.js → chunk-m2rmbshc.js} +3 -2
- package/dist/{chunk-jh4ts8mt.js.map → chunk-m2rmbshc.js.map} +3 -3
- package/dist/chunk-tkjkrcdt.js.map +2 -2
- package/dist/connectors/queries.d.ts.map +1 -1
- package/dist/events-builder.d.ts +1 -26
- package/dist/events-builder.d.ts.map +1 -1
- package/dist/events-transport.d.ts +1 -3
- package/dist/events-transport.d.ts.map +1 -1
- package/dist/file.d.ts +1 -3
- package/dist/file.d.ts.map +1 -1
- package/dist/generated/@tanstack/react-query.gen.d.ts +177 -200
- package/dist/generated/@tanstack/react-query.gen.d.ts.map +1 -1
- package/dist/generated/sdk.gen.d.ts +2 -0
- package/dist/generated/sdk.gen.d.ts.map +1 -1
- package/dist/generated/types.gen.d.ts +142 -78
- package/dist/generated/types.gen.d.ts.map +1 -1
- package/dist/hooks.js +15 -26
- package/dist/hooks.js.map +4 -4
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -12
- package/dist/index.js.map +1 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +1 -1
- package/dist/query-hooks.d.ts +5 -5
- package/dist/query-hooks.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/actions.ts +9 -288
- package/src/agent-streams.ts +1 -1
- package/src/browser.ts +1 -6
- package/src/events-builder.ts +2 -78
- package/src/events-transport.ts +2 -5
- package/src/file.ts +6 -6
- package/src/generated/@tanstack/react-query.gen.ts +2 -0
- package/src/generated/sdk.gen.ts +2 -0
- package/src/generated/types.gen.ts +207 -114
- package/src/index.ts +2 -1
- package/src/models.ts +5 -3
- package/src/query-hooks.ts +29 -44
- package/dist/chunk-pvmd5f18.js.map +0 -17
package/src/events-builder.ts
CHANGED
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import type {
|
|
15
|
-
ActionDefinition,
|
|
16
15
|
DatasetDefinition,
|
|
17
16
|
InferObjectReadProperties,
|
|
18
17
|
InferPropertyValue,
|
|
@@ -249,42 +248,6 @@ export interface EventsRunBuilder<TEvent extends SixbEvent> extends Subscribable
|
|
|
249
248
|
run(runId: string): EventsRunBuilder<TEvent>
|
|
250
249
|
}
|
|
251
250
|
|
|
252
|
-
/** Object-subject scope builder for action events: `events.actions().subject(Type).byId(id)`. */
|
|
253
|
-
export interface EventsActionSubjectBuilder<TEvent extends SixbEvent>
|
|
254
|
-
extends SubscribableEvents<TEvent> {
|
|
255
|
-
/** Scope to a single action subject object. */
|
|
256
|
-
byId(primaryId: string): EventsActionBuilder<TEvent>
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/** Action-scoped topic builder: `events.actions().run(runId).completed()`. */
|
|
260
|
-
export interface EventsActionBuilder<TEvent extends SixbEvent> extends SubscribableEvents<TEvent> {
|
|
261
|
-
/** Scope to a single action run id. */
|
|
262
|
-
run(runId: string): EventsActionBuilder<TEvent>
|
|
263
|
-
|
|
264
|
-
/** Scope to one action definition id. */
|
|
265
|
-
action(actionId: string): EventsActionBuilder<TEvent>
|
|
266
|
-
|
|
267
|
-
/** Scope to an object-bound action subject type. */
|
|
268
|
-
subject<TObjectType extends ObjectTypeWithTokens>(
|
|
269
|
-
objectType: TObjectType
|
|
270
|
-
): EventsActionSubjectBuilder<TEvent>
|
|
271
|
-
subject(objectTypeId: string): EventsActionSubjectBuilder<TEvent>
|
|
272
|
-
|
|
273
|
-
/** Action request events. */
|
|
274
|
-
requested(): EventsActionBuilder<SixbEventOfType<"action.requested">>
|
|
275
|
-
|
|
276
|
-
/** Successful terminal action events. */
|
|
277
|
-
completed(): EventsActionBuilder<SixbEventOfType<"action.completed">>
|
|
278
|
-
|
|
279
|
-
/** Failed or cancelled terminal action events. */
|
|
280
|
-
failed(): EventsActionBuilder<SixbEventOfType<"action.failed">>
|
|
281
|
-
|
|
282
|
-
/** All terminal action events. */
|
|
283
|
-
terminal(): EventsActionBuilder<
|
|
284
|
-
SixbEventOfType<"action.completed"> | SixbEventOfType<"action.failed">
|
|
285
|
-
>
|
|
286
|
-
}
|
|
287
|
-
|
|
288
251
|
/** Rule-scoped topic builder: `events.rule(rule).triggered()`. */
|
|
289
252
|
export interface EventsRuleBuilder<TEvent extends SixbEvent> extends SubscribableEvents<TEvent> {
|
|
290
253
|
triggered(): EventsRuleBuilder<SixbEventOfType<"rule.triggered">>
|
|
@@ -360,11 +323,10 @@ export function createWsSubscribeExecutor(options?: { client?: Client }): EventS
|
|
|
360
323
|
const socket = createEventSocket({
|
|
361
324
|
topic: filter.topic,
|
|
362
325
|
types: filter.types,
|
|
363
|
-
// Object/
|
|
326
|
+
// Object/run scope is filtered server-side; the client predicate
|
|
364
327
|
// still refines propertyId/linkId and guards correctness.
|
|
365
328
|
objectTypeId: filter.objectTypeId,
|
|
366
329
|
primaryId: filter.primaryId,
|
|
367
|
-
actionId: filter.actionId,
|
|
368
330
|
runId: filter.runId,
|
|
369
331
|
afterCursor: subscribeOptions?.afterCursor,
|
|
370
332
|
limit: subscribeOptions?.limit,
|
|
@@ -518,29 +480,12 @@ class EventsBuilderImpl {
|
|
|
518
480
|
return this.withFilter({ runId })
|
|
519
481
|
}
|
|
520
482
|
|
|
521
|
-
action(actionId: string): EventsBuilderImpl {
|
|
522
|
-
return this.withFilter({ actionId })
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
subject(objectType: ObjectTypeWithTokens | string): EventsBuilderImpl {
|
|
526
|
-
const objectTypeId = typeof objectType === "string" ? objectType : objectType.id
|
|
527
|
-
return this.withFilter({ objectTypeId })
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
requested(): EventsBuilderImpl {
|
|
531
|
-
return this.withFilter({ topic: "actions", types: ["action.requested"] })
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
completed(): EventsBuilderImpl {
|
|
535
|
-
return this.withFilter({ topic: "actions", types: ["action.completed"] })
|
|
536
|
-
}
|
|
537
|
-
|
|
538
483
|
failed(): EventsBuilderImpl {
|
|
539
484
|
const selector = this.params.selector
|
|
540
485
|
if (selector && "failed" in selector) {
|
|
541
486
|
return this.withSelectorSpec(selector.failed())
|
|
542
487
|
}
|
|
543
|
-
return this
|
|
488
|
+
return this
|
|
544
489
|
}
|
|
545
490
|
|
|
546
491
|
succeeded(): EventsBuilderImpl {
|
|
@@ -559,10 +504,6 @@ class EventsBuilderImpl {
|
|
|
559
504
|
return this
|
|
560
505
|
}
|
|
561
506
|
|
|
562
|
-
terminal(): EventsBuilderImpl {
|
|
563
|
-
return this.withFilter({ topic: "actions", types: ["action.completed", "action.failed"] })
|
|
564
|
-
}
|
|
565
|
-
|
|
566
507
|
triggered(): EventsBuilderImpl {
|
|
567
508
|
return this.withFilter({ topic: "rules", types: ["rule.triggered"] })
|
|
568
509
|
}
|
|
@@ -647,11 +588,6 @@ export interface SixbEventsApi {
|
|
|
647
588
|
objects(options?: SixbEventsClientOptions): EventsTopicBuilder<SixbEventOfTopic<"objects">>
|
|
648
589
|
telemetry(options?: SixbEventsClientOptions): EventsTopicBuilder<SixbEventOfTopic<"telemetry">>
|
|
649
590
|
links(options?: SixbEventsClientOptions): EventsTopicBuilder<SixbEventOfTopic<"links">>
|
|
650
|
-
actions(options?: SixbEventsClientOptions): EventsActionBuilder<SixbEventOfTopic<"actions">>
|
|
651
|
-
action<TAction extends ActionDefinition>(
|
|
652
|
-
action: TAction,
|
|
653
|
-
options?: SixbEventsClientOptions
|
|
654
|
-
): EventsActionBuilder<SixbEventOfTopic<"actions">>
|
|
655
591
|
rule<TRule extends RuleDefinition>(
|
|
656
592
|
rule: TRule,
|
|
657
593
|
options?: SixbEventsClientOptions
|
|
@@ -690,12 +626,6 @@ function runBuilder<TEvent extends SixbEvent>(
|
|
|
690
626
|
return createBuilder({ topic }, options) as unknown as EventsRunBuilder<TEvent>
|
|
691
627
|
}
|
|
692
628
|
|
|
693
|
-
function actionBuilder<TEvent extends SixbEvent>(
|
|
694
|
-
options?: SixbEventsClientOptions
|
|
695
|
-
): EventsActionBuilder<TEvent> {
|
|
696
|
-
return createBuilder({ topic: "actions" }, options) as unknown as EventsActionBuilder<TEvent>
|
|
697
|
-
}
|
|
698
|
-
|
|
699
629
|
const eventsApi = {} as SixbEventsApi
|
|
700
630
|
|
|
701
631
|
eventsApi.object = (objectType, options) => {
|
|
@@ -710,12 +640,6 @@ eventsApi.all = (options) => createBuilder({}, options) as unknown as EventsTopi
|
|
|
710
640
|
eventsApi.objects = (options) => topicBuilder("objects", options)
|
|
711
641
|
eventsApi.telemetry = (options) => topicBuilder("telemetry", options)
|
|
712
642
|
eventsApi.links = (options) => topicBuilder("links", options)
|
|
713
|
-
eventsApi.actions = (options) => actionBuilder(options)
|
|
714
|
-
eventsApi.action = (action, options) =>
|
|
715
|
-
createBuilder(
|
|
716
|
-
{ topic: "actions", actionId: action.id },
|
|
717
|
-
options
|
|
718
|
-
) as unknown as EventsActionBuilder<SixbEventOfTopic<"actions">>
|
|
719
643
|
eventsApi.rule = (rule, options) =>
|
|
720
644
|
createBuilder({ topic: "rules", ruleId: rule.id }, options) as unknown as EventsRuleBuilder<
|
|
721
645
|
SixbEventOfTopic<"rules">
|
package/src/events-transport.ts
CHANGED
|
@@ -31,9 +31,7 @@ export interface EventSocketOptions {
|
|
|
31
31
|
readonly objectTypeId?: string
|
|
32
32
|
/** Object-instance scope; the server narrows the stream when set. */
|
|
33
33
|
readonly primaryId?: string
|
|
34
|
-
/**
|
|
35
|
-
readonly actionId?: string
|
|
36
|
-
/** Run id scope; the server narrows run/action streams when set. */
|
|
34
|
+
/** Run id scope; the server narrows run streams when set. */
|
|
37
35
|
readonly runId?: string
|
|
38
36
|
readonly afterCursor?: string
|
|
39
37
|
readonly limit?: number
|
|
@@ -67,7 +65,7 @@ type EventStreamServerMessage =
|
|
|
67
65
|
* the same fields when they are sent on the subscribe message).
|
|
68
66
|
*/
|
|
69
67
|
export function createEventSocket(options: EventSocketOptions): EventSocket {
|
|
70
|
-
const { topic, types, objectTypeId, primaryId,
|
|
68
|
+
const { topic, types, objectTypeId, primaryId, runId, limit } = options
|
|
71
69
|
let latestCursor = options.afterCursor
|
|
72
70
|
let transportState: ReconnectingSocketState = {
|
|
73
71
|
connected: false,
|
|
@@ -103,7 +101,6 @@ export function createEventSocket(options: EventSocketOptions): EventSocket {
|
|
|
103
101
|
...(types && types.length > 0 ? { types } : {}),
|
|
104
102
|
...(objectTypeId ? { objectTypeId } : {}),
|
|
105
103
|
...(primaryId ? { primaryId } : {}),
|
|
106
|
-
...(actionId ? { actionId } : {}),
|
|
107
104
|
...(runId ? { runId } : {}),
|
|
108
105
|
...(latestCursor ? { afterCursor: latestCursor } : {}),
|
|
109
106
|
...(limit ? { limit } : {}),
|
package/src/file.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FileRef } from "@sixb/core"
|
|
2
2
|
import { DEFAULT_SIMPLE_FILE_UPLOAD_BYTES } from "@sixb/core/blob-storage"
|
|
3
3
|
import { isSixbApiError, type SixbClient } from "./api"
|
|
4
4
|
import { getClientSharedGrantId } from "./client-authority"
|
|
@@ -19,8 +19,6 @@ export interface ObjectFileContentUrlInput {
|
|
|
19
19
|
/** Property path segments, without the leading `properties` segment. */
|
|
20
20
|
readonly pathSegments: readonly string[]
|
|
21
21
|
readonly fileRef: FileRef
|
|
22
|
-
/** Session audience for browser file navigation, e.g. "app" in split-domain deployments. */
|
|
23
|
-
readonly audience?: AuthSessionAudience
|
|
24
22
|
readonly disposition?: "inline" | "attachment"
|
|
25
23
|
readonly client?: SixbClient
|
|
26
24
|
}
|
|
@@ -47,7 +45,6 @@ export function objectFileContentUrl(input: ObjectFileContentUrlInput): string {
|
|
|
47
45
|
.map((segment) => segment.replaceAll("~", "~0").replaceAll("/", "~1"))
|
|
48
46
|
.join("/")}`,
|
|
49
47
|
disposition: input.disposition,
|
|
50
|
-
audience: input.audience,
|
|
51
48
|
shareGrant: getClientSharedGrantId(client) ?? undefined,
|
|
52
49
|
// Opaque cache key, not a historical-file selector. Include per-reference metadata.
|
|
53
50
|
// Encode each field so Elysia won't interpret commas in filenames as an array.
|
|
@@ -207,9 +204,11 @@ async function putDirectUpload(input: {
|
|
|
207
204
|
readonly url: string
|
|
208
205
|
readonly signal?: AbortSignal
|
|
209
206
|
}): Promise<void> {
|
|
207
|
+
// Browser fetch rejects an arbitrary receiver; invoke it as a standalone function.
|
|
208
|
+
const fetch = input.fetch
|
|
210
209
|
let response: Response
|
|
211
210
|
try {
|
|
212
|
-
response = await
|
|
211
|
+
response = await fetch(input.url, {
|
|
213
212
|
method: input.method,
|
|
214
213
|
headers: input.headers,
|
|
215
214
|
body: input.file,
|
|
@@ -236,6 +235,7 @@ async function uploadMultipartFile(input: {
|
|
|
236
235
|
readonly uploadId: string
|
|
237
236
|
readonly signal?: AbortSignal
|
|
238
237
|
}): Promise<Array<{ partNumber: number; etag?: string }>> {
|
|
238
|
+
const fetch = input.fetch
|
|
239
239
|
const parts: Array<{ partNumber: number; etag?: string }> = []
|
|
240
240
|
let partNumber = 1
|
|
241
241
|
|
|
@@ -250,7 +250,7 @@ async function uploadMultipartFile(input: {
|
|
|
250
250
|
|
|
251
251
|
let response: Response
|
|
252
252
|
try {
|
|
253
|
-
response = await
|
|
253
|
+
response = await fetch(signedPart.url, {
|
|
254
254
|
method: signedPart.method,
|
|
255
255
|
headers: signedPart.headers,
|
|
256
256
|
body: input.file.slice(offset, Math.min(input.file.size, offset + input.partSizeBytes)),
|
|
@@ -3681,6 +3681,8 @@ export const getActionOptions = (options: Options<GetActionData>) =>
|
|
|
3681
3681
|
|
|
3682
3682
|
/**
|
|
3683
3683
|
* Request an action
|
|
3684
|
+
*
|
|
3685
|
+
* Runs the action and returns its terminal run. A run that fails is returned with status `failed`. Its effects run after the response, which does not wait for them. An error response usually means no run was requested, but a 500 can follow a run that started: request again with the same `runId` to get its record if it was written. A `runId` that was already recorded returns that run, and 409 while this server still runs it. 503 means the server is stopping and started nothing.
|
|
3684
3686
|
*/
|
|
3685
3687
|
export const requestActionMutation = (
|
|
3686
3688
|
options?: Partial<Options<RequestActionData>>
|
package/src/generated/sdk.gen.ts
CHANGED
|
@@ -2228,6 +2228,8 @@ export const getAction = <ThrowOnError extends boolean = false>(
|
|
|
2228
2228
|
|
|
2229
2229
|
/**
|
|
2230
2230
|
* Request an action
|
|
2231
|
+
*
|
|
2232
|
+
* Runs the action and returns its terminal run. A run that fails is returned with status `failed`. Its effects run after the response, which does not wait for them. An error response usually means no run was requested, but a 500 can follow a run that started: request again with the same `runId` to get its record if it was written. A `runId` that was already recorded returns that run, and 409 while this server still runs it. 503 means the server is stopping and started nothing.
|
|
2231
2233
|
*/
|
|
2232
2234
|
export const requestAction = <ThrowOnError extends boolean = false>(
|
|
2233
2235
|
options: Options<RequestActionData, ThrowOnError>
|