@sanity/client 6.28.3-instruct.0 → 6.28.3-instruct.1
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/_chunks-cjs/config.cjs +6 -13
- package/dist/_chunks-cjs/config.cjs.map +1 -1
- package/dist/_chunks-es/config.js +6 -13
- package/dist/_chunks-es/config.js.map +1 -1
- package/dist/index.browser.cjs +48 -55
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +157 -153
- package/dist/index.browser.d.ts +157 -153
- package/dist/index.browser.js +48 -55
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +43 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +157 -153
- package/dist/index.d.ts +157 -153
- package/dist/index.js +43 -43
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +159 -160
- package/dist/stega.browser.d.ts +159 -160
- package/dist/stega.d.cts +159 -160
- package/dist/stega.d.ts +159 -160
- package/package.json +20 -20
- package/src/SanityClient.ts +5 -5
- package/src/{assist/AssistClient.ts → ai/AiClient.ts} +18 -12
- package/src/{assist → ai}/types.ts +30 -27
- package/src/config.ts +9 -18
- package/src/data/listen.ts +1 -1
- package/src/http/requestOptions.ts +1 -1
- package/src/types.ts +9 -9
- package/src/warnings.ts +5 -0
- package/umd/sanityClient.js +55 -60
- package/umd/sanityClient.min.js +2 -2
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import type {Any, SanityDocumentStub} from '@sanity/client'
|
|
4
4
|
|
|
5
5
|
/** @beta */
|
|
6
|
-
export interface
|
|
6
|
+
export interface InstructConstantInstructionParam {
|
|
7
7
|
type: 'constant'
|
|
8
8
|
value: string
|
|
9
9
|
}
|
|
@@ -13,10 +13,10 @@ export interface ConstantInstructionParam {
|
|
|
13
13
|
* Includes a LLM-friendly version of the field value in the instruction
|
|
14
14
|
* @beta
|
|
15
15
|
* */
|
|
16
|
-
export interface
|
|
16
|
+
export interface InstructFieldInstructionParam {
|
|
17
17
|
type: 'field'
|
|
18
18
|
/**
|
|
19
|
-
* Examples: 'title', 'array[_key=="key"].field
|
|
19
|
+
* Examples: 'title', 'array[_key=="key"].field'
|
|
20
20
|
*/
|
|
21
21
|
path: string
|
|
22
22
|
/**
|
|
@@ -38,31 +38,34 @@ export interface DocumentInstructionParam {
|
|
|
38
38
|
documentId?: string
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
/**
|
|
42
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Includes a LLM-friendly version of GROQ query result in the instruction
|
|
43
|
+
* @beta
|
|
44
|
+
* */
|
|
45
|
+
export interface InstructGroqInstructionParam {
|
|
43
46
|
type: 'groq'
|
|
44
47
|
query: string
|
|
45
48
|
params?: Record<string, string>
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
/** @beta */
|
|
49
|
-
export type
|
|
52
|
+
export type InstructInstructionParam =
|
|
50
53
|
| string
|
|
51
|
-
|
|
|
52
|
-
|
|
|
54
|
+
| InstructConstantInstructionParam
|
|
55
|
+
| InstructFieldInstructionParam
|
|
53
56
|
| DocumentInstructionParam
|
|
54
|
-
|
|
|
57
|
+
| InstructGroqInstructionParam
|
|
55
58
|
|
|
56
59
|
/** @beta */
|
|
57
|
-
export type
|
|
60
|
+
export type InstructInstructionParams = Record<string, InstructInstructionParam>
|
|
58
61
|
|
|
59
|
-
interface
|
|
62
|
+
interface InstructRequestBase {
|
|
60
63
|
/** schemaId as reported by sanity deploy / sanity schema store */
|
|
61
64
|
schemaId: string
|
|
62
65
|
/** string template using $variable – more on this below under "Dynamic instruction" */
|
|
63
66
|
instruction: string
|
|
64
67
|
/** param values for the string template, keys are the variable name, ie if the template has "$variable", one key must be "variable" */
|
|
65
|
-
instructionParams?:
|
|
68
|
+
instructionParams?: InstructInstructionParams
|
|
66
69
|
/**
|
|
67
70
|
* Optional document path output target for the instruction.
|
|
68
71
|
* When provided, the instruction will apply to this path in the document and its children.
|
|
@@ -81,23 +84,23 @@ interface AssistRequestBase {
|
|
|
81
84
|
* Note: these path strings are less strictly validated than the `path` param itself:
|
|
82
85
|
* if an relative-path does not exist or is invalid, it will be silently ignored.
|
|
83
86
|
*
|
|
84
|
-
* @see
|
|
85
|
-
* @see
|
|
87
|
+
* @see InstructRequestBase#conditionalPaths
|
|
88
|
+
* @see InstructRequestBase#outputTypes
|
|
86
89
|
*/
|
|
87
90
|
relativeOutputPaths?: {include: string[]} | {exclude: string[]}
|
|
88
91
|
|
|
89
92
|
/**
|
|
90
93
|
* Controls which types the instruction is allowed to output to.
|
|
91
94
|
*
|
|
92
|
-
* @see
|
|
93
|
-
* @see
|
|
95
|
+
* @see InstructRequestBase#relativeOutputPaths
|
|
96
|
+
* @see InstructRequestBase#conditionalPaths
|
|
94
97
|
*/
|
|
95
98
|
outputTypes?: {include: string[]} | {exclude: string[]}
|
|
96
99
|
|
|
97
100
|
/**
|
|
98
101
|
* When a type or field in the schema has a function set for `hidden` or `readOnly`, it is conditional.
|
|
99
102
|
*
|
|
100
|
-
* By default, AI
|
|
103
|
+
* By default, AI Instruct will not output to conditional `readOnly` and `hidden` fields,
|
|
101
104
|
* ie, they are considered to resolve to `readOnly: true` / `hidden: true`.
|
|
102
105
|
*
|
|
103
106
|
* `conditionalPaths` param allows setting the default conditional value for
|
|
@@ -105,13 +108,13 @@ interface AssistRequestBase {
|
|
|
105
108
|
* or individually set `hidden` and `readOnly` state for individual document paths.
|
|
106
109
|
*
|
|
107
110
|
*
|
|
108
|
-
* Note: fields and types with explicit readOnly: true or hidden: true in the schema, are not available to AI
|
|
111
|
+
* Note: fields and types with explicit readOnly: true or hidden: true in the schema, are not available to AI Instruct,
|
|
109
112
|
* and cannot be changed via conditionalPaths.
|
|
110
113
|
*
|
|
111
114
|
* conditionalPaths state only apply to fields and types that have conditional `hidden` or `readOnly` in their schema definition.
|
|
112
115
|
*
|
|
113
|
-
* @see
|
|
114
|
-
* @see
|
|
116
|
+
* @see InstructRequestBase#relativeOutputPaths
|
|
117
|
+
* @see InstructRequestBase#outputTypes
|
|
115
118
|
*/
|
|
116
119
|
conditionalPaths?: {
|
|
117
120
|
defaultReadOnly?: boolean
|
|
@@ -182,22 +185,22 @@ interface CreateDocumentRequest<T extends Record<string, Any> = Record<string, A
|
|
|
182
185
|
}
|
|
183
186
|
|
|
184
187
|
/** @beta */
|
|
185
|
-
export type
|
|
188
|
+
export type InstructSyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
|
|
186
189
|
| ExistingDocumentRequest
|
|
187
190
|
| CreateDocumentRequest<T>
|
|
188
191
|
) &
|
|
189
|
-
|
|
192
|
+
InstructRequestBase &
|
|
190
193
|
Sync
|
|
191
194
|
|
|
192
195
|
/** @beta */
|
|
193
|
-
export type
|
|
196
|
+
export type InstructAsyncInstruction<T extends Record<string, Any> = Record<string, Any>> = (
|
|
194
197
|
| ExistingDocumentRequest
|
|
195
198
|
| CreateDocumentRequest<T>
|
|
196
199
|
) &
|
|
197
|
-
|
|
200
|
+
InstructRequestBase &
|
|
198
201
|
Async
|
|
199
202
|
|
|
200
203
|
/** @beta */
|
|
201
|
-
export type
|
|
202
|
-
|
|
|
203
|
-
|
|
|
204
|
+
export type InstructInstruction<T extends Record<string, Any> = Record<string, Any>> =
|
|
205
|
+
| InstructSyncInstruction<T>
|
|
206
|
+
| InstructAsyncInstruction<T>
|
package/src/config.ts
CHANGED
|
@@ -28,30 +28,15 @@ function validateApiVersion(apiVersion: string) {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
const VALID_PERSPECTIVE = /^[a-z0-9_]+$/i
|
|
32
|
-
|
|
33
31
|
/**
|
|
34
32
|
* @internal - it may have breaking changes in any release
|
|
35
33
|
*/
|
|
36
34
|
export function validateApiPerspective(
|
|
37
35
|
perspective: unknown,
|
|
38
36
|
): asserts perspective is ClientPerspective {
|
|
39
|
-
if (Array.isArray(perspective)) {
|
|
40
|
-
if (perspective.includes('raw')) {
|
|
41
|
-
throw new TypeError(
|
|
42
|
-
`Invalid API perspective value: "raw". The raw-perspective can not be combined with other perspectives`,
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const invalid = (Array.isArray(perspective) ? perspective : [perspective]).filter(
|
|
48
|
-
(perspectiveName) =>
|
|
49
|
-
typeof perspectiveName !== 'string' || !VALID_PERSPECTIVE.test(perspectiveName),
|
|
50
|
-
)
|
|
51
|
-
if (invalid.length > 0) {
|
|
52
|
-
const formatted = invalid.map((v) => JSON.stringify(v))
|
|
37
|
+
if (Array.isArray(perspective) && perspective.length > 1 && perspective.includes('raw')) {
|
|
53
38
|
throw new TypeError(
|
|
54
|
-
`Invalid API perspective value
|
|
39
|
+
`Invalid API perspective value: "raw". The raw-perspective can not be combined with other perspectives`,
|
|
55
40
|
)
|
|
56
41
|
}
|
|
57
42
|
}
|
|
@@ -122,7 +107,13 @@ export const initConfig = (
|
|
|
122
107
|
const isBrowser = typeof window !== 'undefined' && window.location && window.location.hostname
|
|
123
108
|
const isLocalhost = isBrowser && isLocal(window.location.hostname)
|
|
124
109
|
|
|
125
|
-
|
|
110
|
+
const hasToken = Boolean(newConfig.token)
|
|
111
|
+
if (newConfig.withCredentials && hasToken) {
|
|
112
|
+
warnings.printCredentialedTokenWarning()
|
|
113
|
+
newConfig.withCredentials = false
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (isBrowser && isLocalhost && hasToken && newConfig.ignoreBrowserTokenWarning !== true) {
|
|
126
117
|
warnings.printBrowserTokenWarning()
|
|
127
118
|
} else if (typeof newConfig.useCdn === 'undefined') {
|
|
128
119
|
warnings.printCdnWarning()
|
package/src/data/listen.ts
CHANGED
|
@@ -84,7 +84,7 @@ export function _listen<R extends Record<string, Any> = Record<string, Any>>(
|
|
|
84
84
|
const listenFor = options.events ? options.events : ['mutation']
|
|
85
85
|
|
|
86
86
|
const esOptions: EventSourceInit & {headers?: Record<string, string>} = {}
|
|
87
|
-
if (
|
|
87
|
+
if (withCredentials) {
|
|
88
88
|
esOptions.withCredentials = true
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -18,7 +18,7 @@ export function requestOptions(config: Any, overrides: Any = {}): Omit<RequestOp
|
|
|
18
18
|
|
|
19
19
|
const withCredentials = Boolean(
|
|
20
20
|
typeof overrides.withCredentials === 'undefined'
|
|
21
|
-
? config.
|
|
21
|
+
? config.withCredentials
|
|
22
22
|
: overrides.withCredentials,
|
|
23
23
|
)
|
|
24
24
|
|
package/src/types.ts
CHANGED
|
@@ -1337,15 +1337,15 @@ export type ClientReturn<
|
|
|
1337
1337
|
> = GroqString extends keyof SanityQueries ? SanityQueries[GroqString] : Fallback
|
|
1338
1338
|
|
|
1339
1339
|
export type {
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
} from './
|
|
1340
|
+
InstructAsyncInstruction,
|
|
1341
|
+
InstructConstantInstructionParam,
|
|
1342
|
+
InstructFieldInstructionParam,
|
|
1343
|
+
InstructGroqInstructionParam,
|
|
1344
|
+
InstructInstruction,
|
|
1345
|
+
InstructInstructionParam,
|
|
1346
|
+
InstructInstructionParams,
|
|
1347
|
+
InstructSyncInstruction,
|
|
1348
|
+
} from './ai/types'
|
|
1349
1349
|
export type {
|
|
1350
1350
|
ContentSourceMapParsedPath,
|
|
1351
1351
|
ContentSourceMapParsedPathKeyedSegment,
|
package/src/warnings.ts
CHANGED
|
@@ -33,6 +33,11 @@ export const printBrowserTokenWarning = createWarningPrinter([
|
|
|
33
33
|
)} for more information and how to hide this warning.`,
|
|
34
34
|
])
|
|
35
35
|
|
|
36
|
+
export const printCredentialedTokenWarning = createWarningPrinter([
|
|
37
|
+
'You have configured Sanity client to use a token, but also provided `withCredentials: true`.',
|
|
38
|
+
'This is no longer supported - only token will be used - remove `withCredentials: true`.',
|
|
39
|
+
])
|
|
40
|
+
|
|
36
41
|
export const printNoApiVersionSpecifiedWarning = createWarningPrinter([
|
|
37
42
|
'Using the Sanity client without specifying an API version is deprecated.',
|
|
38
43
|
`See ${generateHelpUrl('js-client-api-version')}`,
|
package/umd/sanityClient.js
CHANGED
|
@@ -1465,11 +1465,13 @@
|
|
|
1465
1465
|
return !!obj && (obj instanceof Observable || (isFunction(obj.lift) && isFunction(obj.subscribe)));
|
|
1466
1466
|
}
|
|
1467
1467
|
|
|
1468
|
-
var EmptyError = createErrorClass(function (_super) {
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1468
|
+
var EmptyError = createErrorClass(function (_super) {
|
|
1469
|
+
return function EmptyErrorImpl() {
|
|
1470
|
+
_super(this);
|
|
1471
|
+
this.name = 'EmptyError';
|
|
1472
|
+
this.message = 'no elements in sequence';
|
|
1473
|
+
};
|
|
1474
|
+
});
|
|
1473
1475
|
|
|
1474
1476
|
function lastValueFrom(source, config) {
|
|
1475
1477
|
return new Promise(function (resolve, reject) {
|
|
@@ -2086,6 +2088,9 @@
|
|
|
2086
2088
|
`See ${generateHelpUrl(
|
|
2087
2089
|
"js-client-browser-token"
|
|
2088
2090
|
)} for more information and how to hide this warning.`
|
|
2091
|
+
]), printCredentialedTokenWarning = createWarningPrinter([
|
|
2092
|
+
"You have configured Sanity client to use a token, but also provided `withCredentials: true`.",
|
|
2093
|
+
"This is no longer supported - only token will be used - remove `withCredentials: true`."
|
|
2089
2094
|
]), printNoApiVersionSpecifiedWarning = createWarningPrinter([
|
|
2090
2095
|
"Using the Sanity client without specifying an API version is deprecated.",
|
|
2091
2096
|
`See ${generateHelpUrl("js-client-api-version")}`
|
|
@@ -2104,21 +2109,11 @@
|
|
|
2104
2109
|
if (!(/^\d{4}-\d{2}-\d{2}$/.test(apiVersion) && apiDate instanceof Date && apiDate.getTime() > 0))
|
|
2105
2110
|
throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`");
|
|
2106
2111
|
}
|
|
2107
|
-
const VALID_PERSPECTIVE = /^[a-z0-9_]+$/i;
|
|
2108
2112
|
function validateApiPerspective(perspective) {
|
|
2109
|
-
if (Array.isArray(perspective) && perspective.includes("raw"))
|
|
2113
|
+
if (Array.isArray(perspective) && perspective.length > 1 && perspective.includes("raw"))
|
|
2110
2114
|
throw new TypeError(
|
|
2111
2115
|
'Invalid API perspective value: "raw". The raw-perspective can not be combined with other perspectives'
|
|
2112
2116
|
);
|
|
2113
|
-
const invalid = (Array.isArray(perspective) ? perspective : [perspective]).filter(
|
|
2114
|
-
(perspectiveName) => typeof perspectiveName != "string" || !VALID_PERSPECTIVE.test(perspectiveName)
|
|
2115
|
-
);
|
|
2116
|
-
if (invalid.length > 0) {
|
|
2117
|
-
const formatted = invalid.map((v) => JSON.stringify(v));
|
|
2118
|
-
throw new TypeError(
|
|
2119
|
-
`Invalid API perspective value${invalid.length === 1 ? "" : "s"}: ${formatted.join(", ")}, expected \`published\`, \`drafts\`, \`raw\` or a release identifier string`
|
|
2120
|
-
);
|
|
2121
|
-
}
|
|
2122
2117
|
}
|
|
2123
2118
|
const initConfig = (config, prevConfig) => {
|
|
2124
2119
|
const specifiedConfig = {
|
|
@@ -2156,8 +2151,8 @@
|
|
|
2156
2151
|
throw new Error(
|
|
2157
2152
|
`stega.studioUrl must be a string or a function, received ${newConfig.stega.studioUrl}`
|
|
2158
2153
|
);
|
|
2159
|
-
const isBrowser = typeof window < "u" && window.location && window.location.hostname, isLocalhost = isBrowser && isLocal(window.location.hostname);
|
|
2160
|
-
|
|
2154
|
+
const isBrowser = typeof window < "u" && window.location && window.location.hostname, isLocalhost = isBrowser && isLocal(window.location.hostname), hasToken = !!newConfig.token;
|
|
2155
|
+
newConfig.withCredentials && hasToken && (printCredentialedTokenWarning(), newConfig.withCredentials = false), isBrowser && isLocalhost && hasToken && newConfig.ignoreBrowserTokenWarning !== true ? printBrowserTokenWarning() : typeof newConfig.useCdn > "u" && printCdnWarning(), projectBased && projectId(newConfig.projectId), newConfig.dataset && dataset(newConfig.dataset), "requestTagPrefix" in newConfig && (newConfig.requestTagPrefix = newConfig.requestTagPrefix ? requestTag(newConfig.requestTagPrefix).replace(/\.+$/, "") : void 0), newConfig.apiVersion = `${newConfig.apiVersion}`.replace(/^v/, ""), newConfig.isDefaultApi = newConfig.apiHost === defaultConfig.apiHost, newConfig.useCdn === true && newConfig.withCredentials && printCdnAndWithCredentialsWarning(), newConfig.useCdn = newConfig.useCdn !== false && !newConfig.withCredentials, validateApiVersion(newConfig.apiVersion);
|
|
2161
2156
|
const hostParts = newConfig.apiHost.split("://", 2), protocol = hostParts[0], host = hostParts[1], cdnHost = newConfig.isDefaultApi ? defaultCdnHost : host;
|
|
2162
2157
|
return newConfig.useProjectHostname ? (newConfig.url = `${protocol}://${newConfig.projectId}.${host}/v${newConfig.apiVersion}`, newConfig.cdnUrl = `${protocol}://${newConfig.projectId}.${cdnHost}/v${newConfig.apiVersion}`) : (newConfig.url = `${newConfig.apiHost}/v${newConfig.apiVersion}`, newConfig.cdnUrl = newConfig.url), newConfig;
|
|
2163
2158
|
};
|
|
@@ -2605,7 +2600,7 @@ ${selectionOpts}`);
|
|
|
2605
2600
|
function requestOptions(config, overrides = {}) {
|
|
2606
2601
|
const headers = {}, token = overrides.token || config.token;
|
|
2607
2602
|
token && (headers.Authorization = `Bearer ${token}`), !overrides.useGlobalApi && !config.useProjectHostname && config.projectId && (headers[projectHeader] = config.projectId);
|
|
2608
|
-
const withCredentials = !!(typeof overrides.withCredentials > "u" ? config.
|
|
2603
|
+
const withCredentials = !!(typeof overrides.withCredentials > "u" ? config.withCredentials : overrides.withCredentials), timeout = typeof overrides.timeout > "u" ? config.timeout : overrides.timeout;
|
|
2609
2604
|
return Object.assign({}, overrides, {
|
|
2610
2605
|
headers: Object.assign({}, headers, overrides.headers || {}),
|
|
2611
2606
|
timeout: typeof timeout > "u" ? 5 * 60 * 1e3 : timeout,
|
|
@@ -2828,6 +2823,42 @@ ${selectionOpts}`);
|
|
|
2828
2823
|
const error = new Error(signal?.reason ?? "The operation was aborted.");
|
|
2829
2824
|
return error.name = "AbortError", error;
|
|
2830
2825
|
}
|
|
2826
|
+
function _instruct(client, httpRequest, request) {
|
|
2827
|
+
const dataset2 = hasDataset(client.config());
|
|
2828
|
+
return _request(client, httpRequest, {
|
|
2829
|
+
method: "POST",
|
|
2830
|
+
uri: `/assist/tasks/instruct/${dataset2}`,
|
|
2831
|
+
body: request
|
|
2832
|
+
});
|
|
2833
|
+
}
|
|
2834
|
+
class ObservableAiClient {
|
|
2835
|
+
#client;
|
|
2836
|
+
#httpRequest;
|
|
2837
|
+
constructor(client, httpRequest) {
|
|
2838
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
2839
|
+
}
|
|
2840
|
+
/**
|
|
2841
|
+
* Run an ad-hoc instruction for a target document.
|
|
2842
|
+
* @param request instruction request
|
|
2843
|
+
*/
|
|
2844
|
+
instruct(request) {
|
|
2845
|
+
return _instruct(this.#client, this.#httpRequest, request);
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
class AiClient {
|
|
2849
|
+
#client;
|
|
2850
|
+
#httpRequest;
|
|
2851
|
+
constructor(client, httpRequest) {
|
|
2852
|
+
this.#client = client, this.#httpRequest = httpRequest;
|
|
2853
|
+
}
|
|
2854
|
+
/**
|
|
2855
|
+
* Run an ad-hoc instruction for a target document.
|
|
2856
|
+
* @param request instruction request
|
|
2857
|
+
*/
|
|
2858
|
+
instruct(request) {
|
|
2859
|
+
return lastValueFrom(_instruct(this.#client, this.#httpRequest, request));
|
|
2860
|
+
}
|
|
2861
|
+
}
|
|
2831
2862
|
class ObservableAssetsClient {
|
|
2832
2863
|
#client;
|
|
2833
2864
|
#httpRequest;
|
|
@@ -2887,42 +2918,6 @@ ${selectionOpts}`);
|
|
|
2887
2918
|
opts
|
|
2888
2919
|
);
|
|
2889
2920
|
}
|
|
2890
|
-
function _instruct(client, httpRequest, request) {
|
|
2891
|
-
const dataset2 = hasDataset(client.config());
|
|
2892
|
-
return _request(client, httpRequest, {
|
|
2893
|
-
method: "POST",
|
|
2894
|
-
uri: `/assist/tasks/instruct/${dataset2}`,
|
|
2895
|
-
body: request
|
|
2896
|
-
});
|
|
2897
|
-
}
|
|
2898
|
-
class ObservableAssistClient {
|
|
2899
|
-
#client;
|
|
2900
|
-
#httpRequest;
|
|
2901
|
-
constructor(client, httpRequest) {
|
|
2902
|
-
this.#client = client, this.#httpRequest = httpRequest;
|
|
2903
|
-
}
|
|
2904
|
-
/**
|
|
2905
|
-
* Run an ad-hoc instruction for a target document.
|
|
2906
|
-
* @param request instruction request
|
|
2907
|
-
*/
|
|
2908
|
-
instruct(request) {
|
|
2909
|
-
return _instruct(this.#client, this.#httpRequest, request);
|
|
2910
|
-
}
|
|
2911
|
-
}
|
|
2912
|
-
class AssistClient {
|
|
2913
|
-
#client;
|
|
2914
|
-
#httpRequest;
|
|
2915
|
-
constructor(client, httpRequest) {
|
|
2916
|
-
this.#client = client, this.#httpRequest = httpRequest;
|
|
2917
|
-
}
|
|
2918
|
-
/**
|
|
2919
|
-
* Run an ad-hoc instruction for a target document.
|
|
2920
|
-
* @param request instruction request
|
|
2921
|
-
*/
|
|
2922
|
-
instruct(request) {
|
|
2923
|
-
return lastValueFrom(_instruct(this.#client, this.#httpRequest, request));
|
|
2924
|
-
}
|
|
2925
|
-
}
|
|
2926
2921
|
var defaults = (obj, defaults2) => Object.keys(defaults2).concat(Object.keys(obj)).reduce((target, prop) => (target[prop] = typeof obj[prop] > "u" ? defaults2[prop] : obj[prop], target), {});
|
|
2927
2922
|
const pick = (obj, props) => props.reduce((selection, prop) => (typeof obj[prop] > "u" || (selection[prop] = obj[prop]), selection), {}), eventSourcePolyfill = defer(() => Promise.resolve().then(function () { return browser$1; })).pipe(
|
|
2928
2923
|
map(({ default: EventSource2 }) => EventSource2),
|
|
@@ -2951,7 +2946,7 @@ ${selectionOpts}`);
|
|
|
2951
2946
|
if (uri.length > MAX_URL_LENGTH)
|
|
2952
2947
|
return throwError(() => new Error("Query too large for listener"));
|
|
2953
2948
|
const listenFor = options.events ? options.events : ["mutation"], esOptions = {};
|
|
2954
|
-
return
|
|
2949
|
+
return withCredentials && (esOptions.withCredentials = true), token && (esOptions.headers = {
|
|
2955
2950
|
Authorization: `Bearer ${token}`
|
|
2956
2951
|
}), connectEventSource(() => (
|
|
2957
2952
|
// use polyfill if there is no global EventSource or if we need to set headers
|
|
@@ -3258,7 +3253,7 @@ ${selectionOpts}`);
|
|
|
3258
3253
|
live;
|
|
3259
3254
|
projects;
|
|
3260
3255
|
users;
|
|
3261
|
-
|
|
3256
|
+
ai;
|
|
3262
3257
|
/**
|
|
3263
3258
|
* Private properties
|
|
3264
3259
|
*/
|
|
@@ -3269,7 +3264,7 @@ ${selectionOpts}`);
|
|
|
3269
3264
|
*/
|
|
3270
3265
|
listen = _listen;
|
|
3271
3266
|
constructor(httpRequest, config = defaultConfig) {
|
|
3272
|
-
this.config(config), this.#httpRequest = httpRequest, this.assets = new ObservableAssetsClient(this, this.#httpRequest), this.datasets = new ObservableDatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.projects = new ObservableProjectsClient(this, this.#httpRequest), this.users = new ObservableUsersClient(this, this.#httpRequest), this.
|
|
3267
|
+
this.config(config), this.#httpRequest = httpRequest, this.assets = new ObservableAssetsClient(this, this.#httpRequest), this.datasets = new ObservableDatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.projects = new ObservableProjectsClient(this, this.#httpRequest), this.users = new ObservableUsersClient(this, this.#httpRequest), this.ai = new ObservableAiClient(this, this.#httpRequest);
|
|
3273
3268
|
}
|
|
3274
3269
|
/**
|
|
3275
3270
|
* Clone the client - returns a new instance
|
|
@@ -3408,7 +3403,7 @@ ${selectionOpts}`);
|
|
|
3408
3403
|
live;
|
|
3409
3404
|
projects;
|
|
3410
3405
|
users;
|
|
3411
|
-
|
|
3406
|
+
ai;
|
|
3412
3407
|
/**
|
|
3413
3408
|
* Observable version of the Sanity client, with the same configuration as the promise-based one
|
|
3414
3409
|
*/
|
|
@@ -3423,7 +3418,7 @@ ${selectionOpts}`);
|
|
|
3423
3418
|
*/
|
|
3424
3419
|
listen = _listen;
|
|
3425
3420
|
constructor(httpRequest, config = defaultConfig) {
|
|
3426
|
-
this.config(config), this.#httpRequest = httpRequest, this.assets = new AssetsClient(this, this.#httpRequest), this.datasets = new DatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.projects = new ProjectsClient(this, this.#httpRequest), this.users = new UsersClient(this, this.#httpRequest), this.
|
|
3421
|
+
this.config(config), this.#httpRequest = httpRequest, this.assets = new AssetsClient(this, this.#httpRequest), this.datasets = new DatasetsClient(this, this.#httpRequest), this.live = new LiveClient(this), this.projects = new ProjectsClient(this, this.#httpRequest), this.users = new UsersClient(this, this.#httpRequest), this.ai = new AiClient(this, this.#httpRequest), this.observable = new ObservableSanityClient(httpRequest, config);
|
|
3427
3422
|
}
|
|
3428
3423
|
/**
|
|
3429
3424
|
* Clone the client - returns a new instance
|