@sanity/client 6.29.0-generate.2 → 6.29.0-generate.3
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/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +82 -34
- package/dist/index.browser.d.ts +82 -34
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +82 -34
- package/dist/index.d.ts +82 -34
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +82 -34
- package/dist/stega.browser.d.ts +82 -34
- package/dist/stega.d.cts +82 -34
- package/dist/stega.d.ts +82 -34
- package/package.json +1 -1
- package/src/agent/actions/AgentActionsClient.ts +33 -73
- package/src/agent/actions/generate.ts +5 -6
- package/src/agent/actions/transform.ts +12 -8
- package/src/agent/actions/translate.ts +12 -8
|
@@ -2,19 +2,9 @@ import {lastValueFrom, type Observable} from 'rxjs'
|
|
|
2
2
|
|
|
3
3
|
import type {ObservableSanityClient, SanityClient} from '../../SanityClient'
|
|
4
4
|
import type {Any, HttpRequest, IdentifiedSanityDocumentStub, TranslateDocument} from '../../types'
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
type GenerateInstruction,
|
|
9
|
-
type GenerateSyncInstruction,
|
|
10
|
-
} from './generate'
|
|
11
|
-
import {
|
|
12
|
-
_transform,
|
|
13
|
-
type TransformDocument,
|
|
14
|
-
type TransformDocumentAsync,
|
|
15
|
-
type TransformDocumentSync,
|
|
16
|
-
} from './transform'
|
|
17
|
-
import {_translate, type TranslateDocumentAsync, type TranslateDocumentSync} from './translate'
|
|
5
|
+
import {_generate, type GenerateInstruction} from './generate'
|
|
6
|
+
import {_transform, type TransformDocument} from './transform'
|
|
7
|
+
import {_translate} from './translate'
|
|
18
8
|
|
|
19
9
|
/** @public */
|
|
20
10
|
export class ObservableAgentsActionClient {
|
|
@@ -25,59 +15,44 @@ export class ObservableAgentsActionClient {
|
|
|
25
15
|
this.#httpRequest = httpRequest
|
|
26
16
|
}
|
|
27
17
|
|
|
28
|
-
generate(request: GenerateAsyncInstruction): Observable<{_id: string}>
|
|
29
|
-
|
|
30
|
-
generate<DocumentShape extends Record<string, Any>>(
|
|
31
|
-
request: GenerateSyncInstruction<DocumentShape>,
|
|
32
|
-
): Observable<IdentifiedSanityDocumentStub & DocumentShape>
|
|
33
|
-
|
|
34
18
|
/**
|
|
35
19
|
* Run an instruction to generate content in a target document.
|
|
36
20
|
* @param request instruction request
|
|
37
21
|
*/
|
|
38
|
-
generate<
|
|
39
|
-
|
|
40
|
-
Req extends GenerateInstruction<DocumentShape>,
|
|
41
|
-
>(
|
|
42
|
-
request: Req,
|
|
22
|
+
generate<DocumentShape extends Record<string, Any>>(
|
|
23
|
+
request: GenerateInstruction<DocumentShape>,
|
|
43
24
|
): Observable<
|
|
44
|
-
|
|
25
|
+
(typeof request)['async'] extends true
|
|
26
|
+
? {_id: string}
|
|
27
|
+
: IdentifiedSanityDocumentStub & DocumentShape
|
|
45
28
|
> {
|
|
46
29
|
return _generate(this.#client, this.#httpRequest, request)
|
|
47
30
|
}
|
|
48
31
|
|
|
49
|
-
transform(request: TransformDocumentAsync): Observable<{_id: string}>
|
|
50
|
-
|
|
51
|
-
transform<DocumentShape extends Record<string, Any>>(
|
|
52
|
-
request: TransformDocumentSync,
|
|
53
|
-
): Observable<IdentifiedSanityDocumentStub & DocumentShape>
|
|
54
|
-
|
|
55
32
|
/**
|
|
56
33
|
* Transform a target document based on a source.
|
|
57
34
|
* @param request translation request
|
|
58
35
|
*/
|
|
59
|
-
transform<DocumentShape extends Record<string, Any
|
|
60
|
-
request:
|
|
36
|
+
transform<DocumentShape extends Record<string, Any>>(
|
|
37
|
+
request: TransformDocument<DocumentShape>,
|
|
61
38
|
): Observable<
|
|
62
|
-
|
|
39
|
+
(typeof request)['async'] extends true
|
|
40
|
+
? {_id: string}
|
|
41
|
+
: IdentifiedSanityDocumentStub & DocumentShape
|
|
63
42
|
> {
|
|
64
43
|
return _transform(this.#client, this.#httpRequest, request)
|
|
65
44
|
}
|
|
66
45
|
|
|
67
|
-
translate(request: TranslateDocumentAsync): Observable<{_id: string}>
|
|
68
|
-
|
|
69
|
-
translate<DocumentShape extends Record<string, Any>>(
|
|
70
|
-
request: TranslateDocumentSync,
|
|
71
|
-
): Observable<IdentifiedSanityDocumentStub & DocumentShape>
|
|
72
|
-
|
|
73
46
|
/**
|
|
74
47
|
* Translate a target document based on a source.
|
|
75
48
|
* @param request translation request
|
|
76
49
|
*/
|
|
77
|
-
translate<DocumentShape extends Record<string, Any
|
|
78
|
-
request:
|
|
50
|
+
translate<DocumentShape extends Record<string, Any>>(
|
|
51
|
+
request: TranslateDocument<DocumentShape>,
|
|
79
52
|
): Observable<
|
|
80
|
-
|
|
53
|
+
(typeof request)['async'] extends true
|
|
54
|
+
? {_id: string}
|
|
55
|
+
: IdentifiedSanityDocumentStub & DocumentShape
|
|
81
56
|
> {
|
|
82
57
|
return _translate(this.#client, this.#httpRequest, request)
|
|
83
58
|
}
|
|
@@ -92,59 +67,44 @@ export class AgentActionsClient {
|
|
|
92
67
|
this.#httpRequest = httpRequest
|
|
93
68
|
}
|
|
94
69
|
|
|
95
|
-
generate(request: GenerateAsyncInstruction): Promise<{_id: string}>
|
|
96
|
-
|
|
97
|
-
generate<DocumentShape extends Record<string, Any>>(
|
|
98
|
-
request: GenerateSyncInstruction<DocumentShape>,
|
|
99
|
-
): Promise<IdentifiedSanityDocumentStub & DocumentShape>
|
|
100
|
-
|
|
101
70
|
/**
|
|
102
71
|
* Run an instruction to generate content in a target document.
|
|
103
72
|
* @param request instruction request
|
|
104
73
|
*/
|
|
105
|
-
generate<
|
|
106
|
-
|
|
107
|
-
Req extends GenerateInstruction<DocumentShape>,
|
|
108
|
-
>(
|
|
109
|
-
request: Req,
|
|
74
|
+
generate<DocumentShape extends Record<string, Any>>(
|
|
75
|
+
request: GenerateInstruction<DocumentShape>,
|
|
110
76
|
): Promise<
|
|
111
|
-
|
|
77
|
+
(typeof request)['async'] extends true
|
|
78
|
+
? {_id: string}
|
|
79
|
+
: IdentifiedSanityDocumentStub & DocumentShape
|
|
112
80
|
> {
|
|
113
81
|
return lastValueFrom(_generate(this.#client, this.#httpRequest, request))
|
|
114
82
|
}
|
|
115
83
|
|
|
116
|
-
transform(request: TransformDocumentAsync): Promise<{_id: string}>
|
|
117
|
-
|
|
118
|
-
transform<DocumentShape extends Record<string, Any>>(
|
|
119
|
-
request: TransformDocumentSync,
|
|
120
|
-
): Promise<IdentifiedSanityDocumentStub & DocumentShape>
|
|
121
|
-
|
|
122
84
|
/**
|
|
123
85
|
* Transform a target document based on a source.
|
|
124
86
|
* @param request translation request
|
|
125
87
|
*/
|
|
126
|
-
transform<DocumentShape extends Record<string, Any
|
|
127
|
-
request:
|
|
88
|
+
transform<DocumentShape extends Record<string, Any>>(
|
|
89
|
+
request: TransformDocument<DocumentShape>,
|
|
128
90
|
): Promise<
|
|
129
|
-
|
|
91
|
+
(typeof request)['async'] extends true
|
|
92
|
+
? {_id: string}
|
|
93
|
+
: IdentifiedSanityDocumentStub & DocumentShape
|
|
130
94
|
> {
|
|
131
95
|
return lastValueFrom(_transform(this.#client, this.#httpRequest, request))
|
|
132
96
|
}
|
|
133
97
|
|
|
134
|
-
translate(request: TranslateDocumentAsync): Promise<{_id: string}>
|
|
135
|
-
|
|
136
|
-
translate<DocumentShape extends Record<string, Any>>(
|
|
137
|
-
request: TranslateDocumentSync,
|
|
138
|
-
): Promise<IdentifiedSanityDocumentStub & DocumentShape>
|
|
139
|
-
|
|
140
98
|
/**
|
|
141
99
|
* Translate a target document based on a source.
|
|
142
100
|
* @param request translation request
|
|
143
101
|
*/
|
|
144
|
-
translate<DocumentShape extends Record<string, Any
|
|
145
|
-
request:
|
|
102
|
+
translate<DocumentShape extends Record<string, Any>>(
|
|
103
|
+
request: TranslateDocument<DocumentShape>,
|
|
146
104
|
): Promise<
|
|
147
|
-
|
|
105
|
+
(typeof request)['async'] extends true
|
|
106
|
+
? {_id: string}
|
|
107
|
+
: IdentifiedSanityDocumentStub & DocumentShape
|
|
148
108
|
> {
|
|
149
109
|
return lastValueFrom(_translate(this.#client, this.#httpRequest, request))
|
|
150
110
|
}
|
|
@@ -156,15 +156,14 @@ export type GenerateInstruction<T extends Record<string, Any> = Record<string, A
|
|
|
156
156
|
| GenerateSyncInstruction<T>
|
|
157
157
|
| GenerateAsyncInstruction<T>
|
|
158
158
|
|
|
159
|
-
export function _generate<
|
|
160
|
-
DocumentShape extends Record<string, Any>,
|
|
161
|
-
Req extends GenerateInstruction<DocumentShape>,
|
|
162
|
-
>(
|
|
159
|
+
export function _generate<DocumentShape extends Record<string, Any>>(
|
|
163
160
|
client: SanityClient | ObservableSanityClient,
|
|
164
161
|
httpRequest: HttpRequest,
|
|
165
|
-
request:
|
|
162
|
+
request: GenerateInstruction<DocumentShape>,
|
|
166
163
|
): Observable<
|
|
167
|
-
|
|
164
|
+
(typeof request)['async'] extends true
|
|
165
|
+
? {_id: string}
|
|
166
|
+
: IdentifiedSanityDocumentStub & DocumentShape
|
|
168
167
|
> {
|
|
169
168
|
const dataset = hasDataset(client.config())
|
|
170
169
|
return _request(client, httpRequest, {
|
|
@@ -80,23 +80,27 @@ export interface TransformTarget extends AgentActionTarget {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/** @beta */
|
|
83
|
-
|
|
83
|
+
// need the generics to hold optional call-site response generics
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
85
|
+
export type TransformDocumentSync<T extends Record<string, Any> = Record<string, Any>> =
|
|
86
|
+
TransformRequestBase & AgentActionSync
|
|
84
87
|
|
|
85
88
|
/** @beta */
|
|
86
89
|
export type TransformDocumentAsync = TransformRequestBase & AgentActionAsync
|
|
87
90
|
|
|
88
91
|
/** @beta */
|
|
89
|
-
export type TransformDocument =
|
|
92
|
+
export type TransformDocument<T extends Record<string, Any> = Record<string, Any>> =
|
|
93
|
+
| TransformDocumentSync<T>
|
|
94
|
+
| TransformDocumentAsync
|
|
90
95
|
|
|
91
|
-
export function _transform<
|
|
92
|
-
DocumentShape extends Record<string, Any>,
|
|
93
|
-
Req extends TransformDocument,
|
|
94
|
-
>(
|
|
96
|
+
export function _transform<DocumentShape extends Record<string, Any>>(
|
|
95
97
|
client: SanityClient | ObservableSanityClient,
|
|
96
98
|
httpRequest: HttpRequest,
|
|
97
|
-
request:
|
|
99
|
+
request: TransformDocument<DocumentShape>,
|
|
98
100
|
): Observable<
|
|
99
|
-
|
|
101
|
+
(typeof request)['async'] extends true
|
|
102
|
+
? {_id: string}
|
|
103
|
+
: IdentifiedSanityDocumentStub & DocumentShape
|
|
100
104
|
> {
|
|
101
105
|
const dataset = hasDataset(client.config())
|
|
102
106
|
return _request(client, httpRequest, {
|
|
@@ -93,23 +93,27 @@ export interface TranslateTarget extends AgentActionTarget {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
/** @beta */
|
|
96
|
-
|
|
96
|
+
// need the generics to hold optional call-site response generics
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
98
|
+
export type TranslateDocumentSync<T extends Record<string, Any> = Record<string, Any>> =
|
|
99
|
+
TranslateRequestBase & AgentActionSync
|
|
97
100
|
|
|
98
101
|
/** @beta */
|
|
99
102
|
export type TranslateDocumentAsync = TranslateRequestBase & AgentActionAsync
|
|
100
103
|
|
|
101
104
|
/** @beta */
|
|
102
|
-
export type TranslateDocument =
|
|
105
|
+
export type TranslateDocument<T extends Record<string, Any> = Record<string, Any>> =
|
|
106
|
+
| TranslateDocumentSync<T>
|
|
107
|
+
| TranslateDocumentAsync
|
|
103
108
|
|
|
104
|
-
export function _translate<
|
|
105
|
-
DocumentShape extends Record<string, Any>,
|
|
106
|
-
Req extends TranslateDocument,
|
|
107
|
-
>(
|
|
109
|
+
export function _translate<DocumentShape extends Record<string, Any>>(
|
|
108
110
|
client: SanityClient | ObservableSanityClient,
|
|
109
111
|
httpRequest: HttpRequest,
|
|
110
|
-
request:
|
|
112
|
+
request: TranslateDocument<DocumentShape>,
|
|
111
113
|
): Observable<
|
|
112
|
-
|
|
114
|
+
(typeof request)['async'] extends true
|
|
115
|
+
? {_id: string}
|
|
116
|
+
: IdentifiedSanityDocumentStub & DocumentShape
|
|
113
117
|
> {
|
|
114
118
|
const dataset = hasDataset(client.config())
|
|
115
119
|
return _request(client, httpRequest, {
|