twenty-client-sdk 2.33.0 → 2.35.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/core/generated/index.d.ts +2 -1
- package/dist/core.cjs +1 -1
- package/dist/core.mjs +1 -1
- package/dist/generate/twenty-client-template.d.ts +3 -3
- package/dist/generate.cjs +10 -16
- package/dist/generate.mjs +2 -2
- package/dist/metadata/generated/index.d.ts +2 -2
- package/dist/metadata/generated/schema.d.ts +102 -5
- package/dist/metadata/generated/types.d.ts +50 -1
- package/dist/metadata.cjs +2 -2
- package/dist/metadata.mjs +503 -450
- package/dist/rest/index.d.ts +2 -2
- package/dist/shared/twenty-client-options.type.d.ts +9 -0
- package/dist/shared/twenty-client-run-as.type.d.ts +1 -0
- package/package.json +1 -1
package/dist/core.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./chunk-DWNI8pZO.js");var t=class{constructor(){throw Error("CoreApiClient was not generated. Install this app on a Twenty instance or run `yarn twenty dev`.")}},n=e.t({});exports.CoreApiClient=t,Object.defineProperty(exports,"CoreSchema",{enumerable:!0,get:function(){return n}});
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./chunk-DWNI8pZO.js");var t=class{constructor(e){throw Error("CoreApiClient was not generated. Install this app on a Twenty instance or run `yarn twenty dev`.")}},n=e.t({});exports.CoreApiClient=t,Object.defineProperty(exports,"CoreSchema",{enumerable:!0,get:function(){return n}});
|
package/dist/core.mjs
CHANGED
|
@@ -7,7 +7,7 @@ var e = Object.defineProperty, t = (t, n) => {
|
|
|
7
7
|
});
|
|
8
8
|
return n || e(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
9
9
|
}, n = class {
|
|
10
|
-
constructor() {
|
|
10
|
+
constructor(e) {
|
|
11
11
|
throw Error("CoreApiClient was not generated. Install this app on a Twenty instance or run `yarn twenty dev`.");
|
|
12
12
|
}
|
|
13
13
|
}, r = /* @__PURE__ */ t({});
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import type { TwentyClientRunAs } from '../shared/twenty-client-run-as.type';
|
|
1
2
|
type QueryGenqlSelection = Record<string, unknown>;
|
|
2
3
|
type MutationGenqlSelection = Record<string, unknown>;
|
|
3
4
|
type GraphqlOperation = Record<string, unknown>;
|
|
4
|
-
type ClientOptions = {
|
|
5
|
+
type ClientOptions = Omit<RequestInit, 'body' | 'headers'> & {
|
|
5
6
|
url?: string;
|
|
6
7
|
headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
|
|
7
8
|
fetcher?: (operation: GraphqlOperation | GraphqlOperation[]) => Promise<unknown>;
|
|
8
9
|
fetch?: typeof globalThis.fetch;
|
|
9
10
|
batch?: unknown;
|
|
10
11
|
};
|
|
11
|
-
type
|
|
12
|
-
type TwentyGeneratedClientOptions = ClientOptions & {
|
|
12
|
+
export type TwentyGeneratedClientOptions = ClientOptions & {
|
|
13
13
|
runAs?: TwentyClientRunAs;
|
|
14
14
|
};
|
|
15
15
|
export declare class TwentyGeneratedClient {
|
package/dist/generate.cjs
CHANGED
|
@@ -1091,14 +1091,16 @@ export interface LinkedTypeMap {
|
|
|
1091
1091
|
`)+`
|
|
1092
1092
|
}
|
|
1093
1093
|
`).join(`
|
|
1094
|
-
`))}var Ie=async e=>{if(!e.schema)throw Error("`schema` must be defined in the config");let t=(0,a.buildSchema)(e.schema,{assumeValidSDL:!0}),n=e.sortProperties?(0,a.lexicographicSortSchema)(t):t;return n.getQueryType()&&(0,a.assertValidSchema)(n),n},Z=async e=>{if(!e.output)throw Error("`output` must be defined in the config");await Pe(e,await Ie(e))},Le={DateTime:`string`,JSON:`Record<string, unknown>`,UUID:`string`},Q=`core/generated`,$=async({schema:e,outputPath:i,clientWrapperTemplateSource:a})=>{let o=a
|
|
1094
|
+
`))}var Ie=async e=>{if(!e.schema)throw Error("`schema` must be defined in the config");let t=(0,a.buildSchema)(e.schema,{assumeValidSDL:!0}),n=e.sortProperties?(0,a.lexicographicSortSchema)(t):t;return n.getQueryType()&&(0,a.assertValidSchema)(n),n},Z=async e=>{if(!e.output)throw Error("`output` must be defined in the config");await Pe(e,await Ie(e))},Le={DateTime:`string`,JSON:`Record<string, unknown>`,UUID:`string`},Q=`core/generated`,$=async({schema:e,outputPath:i,clientWrapperTemplateSource:a})=>{let o=a??`import type { TwentyClientRunAs } from '../shared/twenty-client-run-as.type';
|
|
1095
|
+
|
|
1096
|
+
// Ambient type stubs for the genql-generated code this template gets
|
|
1095
1097
|
// injected into. They enable full typecheck/lint on this file.
|
|
1096
1098
|
// __STRIPPED_DURING_INJECTION_START__
|
|
1097
1099
|
type QueryGenqlSelection = Record<string, unknown>;
|
|
1098
1100
|
type MutationGenqlSelection = Record<string, unknown>;
|
|
1099
1101
|
type GraphqlOperation = Record<string, unknown>;
|
|
1100
1102
|
|
|
1101
|
-
type ClientOptions = {
|
|
1103
|
+
type ClientOptions = Omit<RequestInit, 'body' | 'headers'> & {
|
|
1102
1104
|
url?: string;
|
|
1103
1105
|
headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
|
|
1104
1106
|
fetcher?: (
|
|
@@ -1129,12 +1131,7 @@ const APP_APPLICATION_ACCESS_TOKEN_ENV_KEY =
|
|
|
1129
1131
|
'TWENTY_APP_APPLICATION_ACCESS_TOKEN';
|
|
1130
1132
|
const API_KEY_ENV_KEY = 'TWENTY_API_KEY';
|
|
1131
1133
|
|
|
1132
|
-
|
|
1133
|
-
// intersected with the application's, and as the application alone when nobody
|
|
1134
|
-
// triggered it. 'application' asks for the application's access either way.
|
|
1135
|
-
type TwentyClientRunAs = 'user' | 'application';
|
|
1136
|
-
|
|
1137
|
-
type TwentyGeneratedClientOptions = ClientOptions & {
|
|
1134
|
+
export type TwentyGeneratedClientOptions = ClientOptions & {
|
|
1138
1135
|
runAs?: TwentyClientRunAs;
|
|
1139
1136
|
};
|
|
1140
1137
|
|
|
@@ -1540,14 +1537,16 @@ export class TwentyGeneratedClient {
|
|
|
1540
1537
|
processEnvironment[APP_ACCESS_TOKEN_ENV_KEY] = token;
|
|
1541
1538
|
}
|
|
1542
1539
|
}
|
|
1543
|
-
`,s=`${i}.tmp`;await v(s),await y(s);try{await Z({schema:e,output:s,scalarTypes:Le});let a=_(o,{apiClientName:`CoreApiClient`,defaultUrl:`\`\${process.env.${t.r}}/graphql\``,includeUploadFile:!0});await(0,n.appendFile)((0,r.join)(s,`index.ts`),a),await x(i),await b(s,i),await ze(i)}catch(e){throw await x(s),e}},Re=async({packageRoot:e,schema:t})=>{let i=(0,r.join)(e,`dist`,Q);await $({schema:t,outputPath:i}),await(0,n.copyFile)((0,r.join)(i,`index.mjs`),(0,r.join)(e,`dist`,`core.mjs`)),await(0,n.copyFile)((0,r.join)(i,`index.cjs`),(0,r.join)(e,`dist`,`core.cjs`))},ze=async e=>{let t=(0,r.join)(e,`index.ts`),a=(0,r.join)(e,`index.mjs`);await(0,i.build)({entryPoints:[t],outfile:a,bundle:!0,format:`esm`,platform:`node`,target:`node18`,sourcemap:!1,minify:!1}),await(0,i.build)({entryPoints:[t],outfile:(0,r.join)(e,`index.cjs`),bundle:!0,format:`cjs`,platform:`node`,target:`node18`,sourcemap:!1,minify:!1}),await(0,n.writeFile)((0,r.join)(e,`package.json`),JSON.stringify({type:`module`,main:`index.mjs`,module:`index.mjs`},null,2))},Be={DateTime:`string`,JSON:`Record<string, unknown>`,UUID:`string`},Ve=async({schema:e,outputPath:i,clientWrapperTemplateSource:a})=>{let o=a
|
|
1540
|
+
`,s=`${i}.tmp`;await v(s),await y(s);try{await Z({schema:e,output:s,scalarTypes:Le});let a=_(o,{apiClientName:`CoreApiClient`,defaultUrl:`\`\${process.env.${t.r}}/graphql\``,includeUploadFile:!0});await(0,n.appendFile)((0,r.join)(s,`index.ts`),a),await x(i),await b(s,i),await ze(i)}catch(e){throw await x(s),e}},Re=async({packageRoot:e,schema:t})=>{let i=(0,r.join)(e,`dist`,Q);await $({schema:t,outputPath:i}),await(0,n.copyFile)((0,r.join)(i,`index.mjs`),(0,r.join)(e,`dist`,`core.mjs`)),await(0,n.copyFile)((0,r.join)(i,`index.cjs`),(0,r.join)(e,`dist`,`core.cjs`))},ze=async e=>{let t=(0,r.join)(e,`index.ts`),a=(0,r.join)(e,`index.mjs`);await(0,i.build)({entryPoints:[t],outfile:a,bundle:!0,format:`esm`,platform:`node`,target:`node18`,sourcemap:!1,minify:!1}),await(0,i.build)({entryPoints:[t],outfile:(0,r.join)(e,`index.cjs`),bundle:!0,format:`cjs`,platform:`node`,target:`node18`,sourcemap:!1,minify:!1}),await(0,n.writeFile)((0,r.join)(e,`package.json`),JSON.stringify({type:`module`,main:`index.mjs`,module:`index.mjs`},null,2))},Be={DateTime:`string`,JSON:`Record<string, unknown>`,UUID:`string`},Ve=async({schema:e,outputPath:i,clientWrapperTemplateSource:a})=>{let o=a??`import type { TwentyClientRunAs } from '../shared/twenty-client-run-as.type';
|
|
1541
|
+
|
|
1542
|
+
// Ambient type stubs for the genql-generated code this template gets
|
|
1544
1543
|
// injected into. They enable full typecheck/lint on this file.
|
|
1545
1544
|
// __STRIPPED_DURING_INJECTION_START__
|
|
1546
1545
|
type QueryGenqlSelection = Record<string, unknown>;
|
|
1547
1546
|
type MutationGenqlSelection = Record<string, unknown>;
|
|
1548
1547
|
type GraphqlOperation = Record<string, unknown>;
|
|
1549
1548
|
|
|
1550
|
-
type ClientOptions = {
|
|
1549
|
+
type ClientOptions = Omit<RequestInit, 'body' | 'headers'> & {
|
|
1551
1550
|
url?: string;
|
|
1552
1551
|
headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
|
|
1553
1552
|
fetcher?: (
|
|
@@ -1578,12 +1577,7 @@ const APP_APPLICATION_ACCESS_TOKEN_ENV_KEY =
|
|
|
1578
1577
|
'TWENTY_APP_APPLICATION_ACCESS_TOKEN';
|
|
1579
1578
|
const API_KEY_ENV_KEY = 'TWENTY_API_KEY';
|
|
1580
1579
|
|
|
1581
|
-
|
|
1582
|
-
// intersected with the application's, and as the application alone when nobody
|
|
1583
|
-
// triggered it. 'application' asks for the application's access either way.
|
|
1584
|
-
type TwentyClientRunAs = 'user' | 'application';
|
|
1585
|
-
|
|
1586
|
-
type TwentyGeneratedClientOptions = ClientOptions & {
|
|
1580
|
+
export type TwentyGeneratedClientOptions = ClientOptions & {
|
|
1587
1581
|
runAs?: TwentyClientRunAs;
|
|
1588
1582
|
};
|
|
1589
1583
|
|
package/dist/generate.mjs
CHANGED
|
@@ -522,7 +522,7 @@ var ot = async (e) => {
|
|
|
522
522
|
JSON: "Record<string, unknown>",
|
|
523
523
|
UUID: "string"
|
|
524
524
|
}, Q = "core/generated", $ = async ({ schema: n, outputPath: r, clientWrapperTemplateSource: i }) => {
|
|
525
|
-
let a = i ?? "// Ambient type stubs for the genql-generated code this template gets\n// injected into. They enable full typecheck/lint on this file.\n// __STRIPPED_DURING_INJECTION_START__\ntype QueryGenqlSelection = Record<string, unknown>;\ntype MutationGenqlSelection = Record<string, unknown>;\ntype GraphqlOperation = Record<string, unknown>;\n\ntype ClientOptions = {\n url?: string;\n headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);\n fetcher?: (\n operation: GraphqlOperation | GraphqlOperation[],\n ) => Promise<unknown>;\n fetch?: typeof globalThis.fetch;\n batch?: unknown;\n};\n\ntype Client = {\n query: (\n request: QueryGenqlSelection & { __name?: string },\n ) => Promise<unknown>;\n mutation: (\n request: MutationGenqlSelection & { __name?: string },\n ) => Promise<unknown>;\n};\n\ndeclare function createClient(options: ClientOptions): Client;\n\ndeclare class GenqlError extends Error {\n constructor(errors: unknown, data: unknown);\n}\n// __STRIPPED_DURING_INJECTION_END__\n\nconst APP_ACCESS_TOKEN_ENV_KEY = 'TWENTY_APP_ACCESS_TOKEN';\nconst APP_APPLICATION_ACCESS_TOKEN_ENV_KEY =\n 'TWENTY_APP_APPLICATION_ACCESS_TOKEN';\nconst API_KEY_ENV_KEY = 'TWENTY_API_KEY';\n\n// The default acts as the person who triggered the run, limited to their role\n// intersected with the application's, and as the application alone when nobody\n// triggered it. 'application' asks for the application's access either way.\ntype TwentyClientRunAs = 'user' | 'application';\n\ntype TwentyGeneratedClientOptions = ClientOptions & {\n runAs?: TwentyClientRunAs;\n};\n\ntype ProcessEnvironment = Record<string, string | undefined>;\n\ntype GraphqlErrorPayloadEntry = {\n message?: string;\n extensions?: { code?: string };\n};\n\ntype GraphqlResponsePayload = {\n data?: Record<string, unknown>;\n errors?: GraphqlErrorPayloadEntry[];\n};\n\ntype GraphqlResponse = {\n status: number;\n statusText: string;\n payload: GraphqlResponsePayload | null;\n rawBody: string;\n};\n\nconst getProcessEnvironment = (): ProcessEnvironment => {\n const processObject = (\n globalThis as { process?: { env?: ProcessEnvironment } }\n ).process;\n\n return processObject?.env ?? {};\n};\n\nconst getTokenFromAuthorizationHeader = (\n authorizationHeader: string | undefined,\n): string | null => {\n if (typeof authorizationHeader !== 'string') {\n return null;\n }\n\n const trimmedAuthorizationHeader = authorizationHeader.trim();\n\n if (trimmedAuthorizationHeader.length === 0) {\n return null;\n }\n\n if (trimmedAuthorizationHeader === 'Bearer') {\n return null;\n }\n\n if (trimmedAuthorizationHeader.startsWith('Bearer ')) {\n return trimmedAuthorizationHeader.slice('Bearer '.length).trim();\n }\n\n return trimmedAuthorizationHeader;\n};\n\nconst getTokenFromHeaders = (\n headers: HeadersInit | undefined,\n): string | null => {\n if (!headers) {\n return null;\n }\n\n if (headers instanceof Headers) {\n return getTokenFromAuthorizationHeader(\n headers.get('Authorization') ?? undefined,\n );\n }\n\n if (Array.isArray(headers)) {\n const matchedAuthorizationHeader = headers.find(\n ([headerName]) => headerName.toLowerCase() === 'authorization',\n );\n\n return getTokenFromAuthorizationHeader(matchedAuthorizationHeader?.[1]);\n }\n\n const headersRecord = headers as Record<string, string | undefined>;\n\n return getTokenFromAuthorizationHeader(\n headersRecord.Authorization ?? headersRecord.authorization,\n );\n};\n\nconst hasAuthenticationErrorInGraphqlPayload = (\n payload: GraphqlResponsePayload | null,\n): boolean => {\n if (!payload?.errors) {\n return false;\n }\n\n return payload.errors.some((graphqlError) => {\n return (\n graphqlError.extensions?.code === 'UNAUTHENTICATED' ||\n graphqlError.message?.toLowerCase() === 'unauthorized'\n );\n });\n};\n\nconst defaultOptions: TwentyGeneratedClientOptions = {\n url: '__TWENTY_DEFAULT_URL__',\n headers: {\n 'Content-Type': 'application/json',\n },\n};\n\nexport class TwentyGeneratedClient {\n private client: Client;\n private url: string;\n private requestOptions: RequestInit;\n private headers: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);\n private fetchImplementation: typeof globalThis.fetch | null;\n private authorizationToken: string | null;\n private refreshAccessTokenPromise: Promise<string | null> | null = null;\n\n constructor(options?: TwentyGeneratedClientOptions) {\n const merged: TwentyGeneratedClientOptions = {\n ...defaultOptions,\n ...options,\n };\n\n const {\n url,\n headers,\n fetch: customFetchImplementation,\n fetcher: _fetcher,\n batch: _batch,\n runAs,\n ...requestOptions\n } = merged;\n\n this.url = url ?? '';\n this.requestOptions = requestOptions;\n this.headers = headers ?? {};\n this.fetchImplementation =\n customFetchImplementation ?? globalThis.fetch ?? null;\n\n const processEnvironment = getProcessEnvironment();\n const tokenFromHeaders = getTokenFromHeaders(\n typeof headers === 'function' ? undefined : headers,\n );\n\n // Priority: explicit header > the token for the requested access > api key\n // (legacy).\n this.authorizationToken =\n tokenFromHeaders ??\n processEnvironment[\n runAs === 'application'\n ? APP_APPLICATION_ACCESS_TOKEN_ENV_KEY\n : APP_ACCESS_TOKEN_ENV_KEY\n ] ??\n processEnvironment[API_KEY_ENV_KEY] ??\n null;\n\n this.client = createClient({\n ...merged,\n headers: undefined,\n fetcher: async (operation) =>\n this.executeGraphqlRequestWithOptionalRefresh({\n operation,\n }),\n });\n }\n\n query<R extends QueryGenqlSelection>(request: R & { __name?: string }) {\n return this.client.query(request);\n }\n\n mutation<R extends MutationGenqlSelection>(request: R & { __name?: string }) {\n return this.client.mutation(request);\n }\n\n // __UPLOAD_FILE_START__\n async uploadFile(\n fileBuffer: Buffer,\n filename: string,\n contentType: string = 'application/octet-stream',\n fieldMetadataUniversalIdentifier: string,\n ): Promise<{\n id: string;\n path: string;\n size: number;\n createdAt: string;\n url: string;\n }> {\n const form = new FormData();\n\n form.append(\n 'operations',\n JSON.stringify({\n query: `mutation UploadFilesFieldFileByUniversalIdentifier($file: Upload!, $fieldMetadataUniversalIdentifier: String!) {\n uploadFilesFieldFileByUniversalIdentifier(file: $file, fieldMetadataUniversalIdentifier: $fieldMetadataUniversalIdentifier) { id path size createdAt url }\n }`,\n variables: {\n file: null,\n fieldMetadataUniversalIdentifier,\n },\n }),\n );\n form.append('map', JSON.stringify({ '0': ['variables.file'] }));\n form.append(\n '0',\n new Blob([fileBuffer as BlobPart], { type: contentType }),\n filename,\n );\n\n const result = await this.executeGraphqlRequestWithOptionalRefresh({\n operation: form,\n headers: {},\n requestInit: {\n method: 'POST',\n },\n });\n\n if (result.errors) {\n throw new GenqlError(result.errors, result.data);\n }\n\n const data = result.data as Record<string, unknown>;\n\n return data.uploadFilesFieldFileByUniversalIdentifier as {\n id: string;\n path: string;\n size: number;\n createdAt: string;\n url: string;\n };\n }\n // __UPLOAD_FILE_END__\n\n private async executeGraphqlRequestWithOptionalRefresh({\n operation,\n headers,\n requestInit,\n }: {\n operation: GraphqlOperation | GraphqlOperation[] | FormData;\n headers?: HeadersInit;\n requestInit?: RequestInit;\n }) {\n const firstResponse = await this.executeGraphqlRequest({\n operation,\n headers,\n requestInit,\n token: this.authorizationToken,\n });\n\n if (this.shouldRefreshToken(firstResponse)) {\n const refreshedAccessToken = await this.requestRefreshedAccessToken();\n\n if (refreshedAccessToken) {\n const retryResponse = await this.executeGraphqlRequest({\n operation,\n headers,\n requestInit,\n token: refreshedAccessToken,\n });\n\n return this.assertResponseIsSuccessful(retryResponse);\n }\n }\n\n return this.assertResponseIsSuccessful(firstResponse);\n }\n\n private async executeGraphqlRequest({\n operation,\n headers,\n requestInit,\n token,\n }: {\n operation: GraphqlOperation | GraphqlOperation[] | FormData;\n headers?: HeadersInit;\n requestInit?: RequestInit;\n token: string | null;\n }): Promise<GraphqlResponse> {\n if (!this.fetchImplementation) {\n throw new Error(\n 'Global `fetch` function is not available, ' +\n 'pass a fetch implementation to the Twenty client',\n );\n }\n\n const resolvedHeaders = await this.resolveHeaders();\n const requestHeaders = new Headers(resolvedHeaders);\n\n if (headers) {\n new Headers(headers).forEach((value, key) =>\n requestHeaders.set(key, value),\n );\n }\n\n if (operation instanceof FormData) {\n requestHeaders.delete('Content-Type');\n } else {\n requestHeaders.set('Content-Type', 'application/json');\n }\n\n if (token) {\n requestHeaders.set('Authorization', `Bearer ${token}`);\n } else {\n requestHeaders.delete('Authorization');\n }\n\n const response = await this.fetchImplementation.call(globalThis, this.url, {\n ...this.requestOptions,\n ...requestInit,\n method: requestInit?.method ?? 'POST',\n headers: requestHeaders,\n body:\n operation instanceof FormData ? operation : JSON.stringify(operation),\n });\n\n const rawBody = await response.text();\n let payload: GraphqlResponsePayload | null = null;\n\n if (rawBody.trim().length > 0) {\n try {\n payload = JSON.parse(rawBody) as GraphqlResponsePayload;\n } catch {\n payload = null;\n }\n }\n\n return {\n status: response.status,\n statusText: response.statusText,\n payload,\n rawBody,\n };\n }\n\n private async resolveHeaders(): Promise<HeadersInit> {\n if (typeof this.headers === 'function') {\n return (await this.headers()) ?? {};\n }\n\n return this.headers ?? {};\n }\n\n private shouldRefreshToken(response: GraphqlResponse): boolean {\n if (response.status === 401) {\n return true;\n }\n\n return hasAuthenticationErrorInGraphqlPayload(response.payload);\n }\n\n private assertResponseIsSuccessful(response: GraphqlResponse) {\n if (response.status < 200 || response.status >= 300) {\n throw new Error(`${response.statusText}: ${response.rawBody}`);\n }\n\n if (response.payload === null) {\n throw new Error('Invalid JSON response');\n }\n\n return response.payload;\n }\n\n private async requestRefreshedAccessToken(): Promise<string | null> {\n const refreshAccessTokenFunction = (\n globalThis as {\n frontComponentHostCommunicationApi?: {\n requestAccessTokenRefresh?: () => Promise<string>;\n };\n }\n ).frontComponentHostCommunicationApi?.requestAccessTokenRefresh;\n\n if (typeof refreshAccessTokenFunction !== 'function') {\n return null;\n }\n\n if (!this.refreshAccessTokenPromise) {\n this.refreshAccessTokenPromise = refreshAccessTokenFunction()\n .then((refreshedAccessToken) => {\n if (\n typeof refreshedAccessToken !== 'string' ||\n refreshedAccessToken.length === 0\n ) {\n return null;\n }\n\n this.setAuthorizationToken(refreshedAccessToken);\n\n return refreshedAccessToken;\n })\n .catch((refreshError: unknown) => {\n console.error('Twenty client: token refresh failed', refreshError);\n\n return null;\n })\n .finally(() => {\n this.refreshAccessTokenPromise = null;\n });\n }\n\n return this.refreshAccessTokenPromise;\n }\n\n private setAuthorizationToken(token: string) {\n this.authorizationToken = token;\n\n const processEnvironment = getProcessEnvironment();\n\n processEnvironment[APP_ACCESS_TOKEN_ENV_KEY] = token;\n }\n}\n", o = `${r}.tmp`;
|
|
525
|
+
let a = i ?? "import type { TwentyClientRunAs } from '../shared/twenty-client-run-as.type';\n\n// Ambient type stubs for the genql-generated code this template gets\n// injected into. They enable full typecheck/lint on this file.\n// __STRIPPED_DURING_INJECTION_START__\ntype QueryGenqlSelection = Record<string, unknown>;\ntype MutationGenqlSelection = Record<string, unknown>;\ntype GraphqlOperation = Record<string, unknown>;\n\ntype ClientOptions = Omit<RequestInit, 'body' | 'headers'> & {\n url?: string;\n headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);\n fetcher?: (\n operation: GraphqlOperation | GraphqlOperation[],\n ) => Promise<unknown>;\n fetch?: typeof globalThis.fetch;\n batch?: unknown;\n};\n\ntype Client = {\n query: (\n request: QueryGenqlSelection & { __name?: string },\n ) => Promise<unknown>;\n mutation: (\n request: MutationGenqlSelection & { __name?: string },\n ) => Promise<unknown>;\n};\n\ndeclare function createClient(options: ClientOptions): Client;\n\ndeclare class GenqlError extends Error {\n constructor(errors: unknown, data: unknown);\n}\n// __STRIPPED_DURING_INJECTION_END__\n\nconst APP_ACCESS_TOKEN_ENV_KEY = 'TWENTY_APP_ACCESS_TOKEN';\nconst APP_APPLICATION_ACCESS_TOKEN_ENV_KEY =\n 'TWENTY_APP_APPLICATION_ACCESS_TOKEN';\nconst API_KEY_ENV_KEY = 'TWENTY_API_KEY';\n\nexport type TwentyGeneratedClientOptions = ClientOptions & {\n runAs?: TwentyClientRunAs;\n};\n\ntype ProcessEnvironment = Record<string, string | undefined>;\n\ntype GraphqlErrorPayloadEntry = {\n message?: string;\n extensions?: { code?: string };\n};\n\ntype GraphqlResponsePayload = {\n data?: Record<string, unknown>;\n errors?: GraphqlErrorPayloadEntry[];\n};\n\ntype GraphqlResponse = {\n status: number;\n statusText: string;\n payload: GraphqlResponsePayload | null;\n rawBody: string;\n};\n\nconst getProcessEnvironment = (): ProcessEnvironment => {\n const processObject = (\n globalThis as { process?: { env?: ProcessEnvironment } }\n ).process;\n\n return processObject?.env ?? {};\n};\n\nconst getTokenFromAuthorizationHeader = (\n authorizationHeader: string | undefined,\n): string | null => {\n if (typeof authorizationHeader !== 'string') {\n return null;\n }\n\n const trimmedAuthorizationHeader = authorizationHeader.trim();\n\n if (trimmedAuthorizationHeader.length === 0) {\n return null;\n }\n\n if (trimmedAuthorizationHeader === 'Bearer') {\n return null;\n }\n\n if (trimmedAuthorizationHeader.startsWith('Bearer ')) {\n return trimmedAuthorizationHeader.slice('Bearer '.length).trim();\n }\n\n return trimmedAuthorizationHeader;\n};\n\nconst getTokenFromHeaders = (\n headers: HeadersInit | undefined,\n): string | null => {\n if (!headers) {\n return null;\n }\n\n if (headers instanceof Headers) {\n return getTokenFromAuthorizationHeader(\n headers.get('Authorization') ?? undefined,\n );\n }\n\n if (Array.isArray(headers)) {\n const matchedAuthorizationHeader = headers.find(\n ([headerName]) => headerName.toLowerCase() === 'authorization',\n );\n\n return getTokenFromAuthorizationHeader(matchedAuthorizationHeader?.[1]);\n }\n\n const headersRecord = headers as Record<string, string | undefined>;\n\n return getTokenFromAuthorizationHeader(\n headersRecord.Authorization ?? headersRecord.authorization,\n );\n};\n\nconst hasAuthenticationErrorInGraphqlPayload = (\n payload: GraphqlResponsePayload | null,\n): boolean => {\n if (!payload?.errors) {\n return false;\n }\n\n return payload.errors.some((graphqlError) => {\n return (\n graphqlError.extensions?.code === 'UNAUTHENTICATED' ||\n graphqlError.message?.toLowerCase() === 'unauthorized'\n );\n });\n};\n\nconst defaultOptions: TwentyGeneratedClientOptions = {\n url: '__TWENTY_DEFAULT_URL__',\n headers: {\n 'Content-Type': 'application/json',\n },\n};\n\nexport class TwentyGeneratedClient {\n private client: Client;\n private url: string;\n private requestOptions: RequestInit;\n private headers: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);\n private fetchImplementation: typeof globalThis.fetch | null;\n private authorizationToken: string | null;\n private refreshAccessTokenPromise: Promise<string | null> | null = null;\n\n constructor(options?: TwentyGeneratedClientOptions) {\n const merged: TwentyGeneratedClientOptions = {\n ...defaultOptions,\n ...options,\n };\n\n const {\n url,\n headers,\n fetch: customFetchImplementation,\n fetcher: _fetcher,\n batch: _batch,\n runAs,\n ...requestOptions\n } = merged;\n\n this.url = url ?? '';\n this.requestOptions = requestOptions;\n this.headers = headers ?? {};\n this.fetchImplementation =\n customFetchImplementation ?? globalThis.fetch ?? null;\n\n const processEnvironment = getProcessEnvironment();\n const tokenFromHeaders = getTokenFromHeaders(\n typeof headers === 'function' ? undefined : headers,\n );\n\n // Priority: explicit header > the token for the requested access > api key\n // (legacy).\n this.authorizationToken =\n tokenFromHeaders ??\n processEnvironment[\n runAs === 'application'\n ? APP_APPLICATION_ACCESS_TOKEN_ENV_KEY\n : APP_ACCESS_TOKEN_ENV_KEY\n ] ??\n processEnvironment[API_KEY_ENV_KEY] ??\n null;\n\n this.client = createClient({\n ...merged,\n headers: undefined,\n fetcher: async (operation) =>\n this.executeGraphqlRequestWithOptionalRefresh({\n operation,\n }),\n });\n }\n\n query<R extends QueryGenqlSelection>(request: R & { __name?: string }) {\n return this.client.query(request);\n }\n\n mutation<R extends MutationGenqlSelection>(request: R & { __name?: string }) {\n return this.client.mutation(request);\n }\n\n // __UPLOAD_FILE_START__\n async uploadFile(\n fileBuffer: Buffer,\n filename: string,\n contentType: string = 'application/octet-stream',\n fieldMetadataUniversalIdentifier: string,\n ): Promise<{\n id: string;\n path: string;\n size: number;\n createdAt: string;\n url: string;\n }> {\n const form = new FormData();\n\n form.append(\n 'operations',\n JSON.stringify({\n query: `mutation UploadFilesFieldFileByUniversalIdentifier($file: Upload!, $fieldMetadataUniversalIdentifier: String!) {\n uploadFilesFieldFileByUniversalIdentifier(file: $file, fieldMetadataUniversalIdentifier: $fieldMetadataUniversalIdentifier) { id path size createdAt url }\n }`,\n variables: {\n file: null,\n fieldMetadataUniversalIdentifier,\n },\n }),\n );\n form.append('map', JSON.stringify({ '0': ['variables.file'] }));\n form.append(\n '0',\n new Blob([fileBuffer as BlobPart], { type: contentType }),\n filename,\n );\n\n const result = await this.executeGraphqlRequestWithOptionalRefresh({\n operation: form,\n headers: {},\n requestInit: {\n method: 'POST',\n },\n });\n\n if (result.errors) {\n throw new GenqlError(result.errors, result.data);\n }\n\n const data = result.data as Record<string, unknown>;\n\n return data.uploadFilesFieldFileByUniversalIdentifier as {\n id: string;\n path: string;\n size: number;\n createdAt: string;\n url: string;\n };\n }\n // __UPLOAD_FILE_END__\n\n private async executeGraphqlRequestWithOptionalRefresh({\n operation,\n headers,\n requestInit,\n }: {\n operation: GraphqlOperation | GraphqlOperation[] | FormData;\n headers?: HeadersInit;\n requestInit?: RequestInit;\n }) {\n const firstResponse = await this.executeGraphqlRequest({\n operation,\n headers,\n requestInit,\n token: this.authorizationToken,\n });\n\n if (this.shouldRefreshToken(firstResponse)) {\n const refreshedAccessToken = await this.requestRefreshedAccessToken();\n\n if (refreshedAccessToken) {\n const retryResponse = await this.executeGraphqlRequest({\n operation,\n headers,\n requestInit,\n token: refreshedAccessToken,\n });\n\n return this.assertResponseIsSuccessful(retryResponse);\n }\n }\n\n return this.assertResponseIsSuccessful(firstResponse);\n }\n\n private async executeGraphqlRequest({\n operation,\n headers,\n requestInit,\n token,\n }: {\n operation: GraphqlOperation | GraphqlOperation[] | FormData;\n headers?: HeadersInit;\n requestInit?: RequestInit;\n token: string | null;\n }): Promise<GraphqlResponse> {\n if (!this.fetchImplementation) {\n throw new Error(\n 'Global `fetch` function is not available, ' +\n 'pass a fetch implementation to the Twenty client',\n );\n }\n\n const resolvedHeaders = await this.resolveHeaders();\n const requestHeaders = new Headers(resolvedHeaders);\n\n if (headers) {\n new Headers(headers).forEach((value, key) =>\n requestHeaders.set(key, value),\n );\n }\n\n if (operation instanceof FormData) {\n requestHeaders.delete('Content-Type');\n } else {\n requestHeaders.set('Content-Type', 'application/json');\n }\n\n if (token) {\n requestHeaders.set('Authorization', `Bearer ${token}`);\n } else {\n requestHeaders.delete('Authorization');\n }\n\n const response = await this.fetchImplementation.call(globalThis, this.url, {\n ...this.requestOptions,\n ...requestInit,\n method: requestInit?.method ?? 'POST',\n headers: requestHeaders,\n body:\n operation instanceof FormData ? operation : JSON.stringify(operation),\n });\n\n const rawBody = await response.text();\n let payload: GraphqlResponsePayload | null = null;\n\n if (rawBody.trim().length > 0) {\n try {\n payload = JSON.parse(rawBody) as GraphqlResponsePayload;\n } catch {\n payload = null;\n }\n }\n\n return {\n status: response.status,\n statusText: response.statusText,\n payload,\n rawBody,\n };\n }\n\n private async resolveHeaders(): Promise<HeadersInit> {\n if (typeof this.headers === 'function') {\n return (await this.headers()) ?? {};\n }\n\n return this.headers ?? {};\n }\n\n private shouldRefreshToken(response: GraphqlResponse): boolean {\n if (response.status === 401) {\n return true;\n }\n\n return hasAuthenticationErrorInGraphqlPayload(response.payload);\n }\n\n private assertResponseIsSuccessful(response: GraphqlResponse) {\n if (response.status < 200 || response.status >= 300) {\n throw new Error(`${response.statusText}: ${response.rawBody}`);\n }\n\n if (response.payload === null) {\n throw new Error('Invalid JSON response');\n }\n\n return response.payload;\n }\n\n private async requestRefreshedAccessToken(): Promise<string | null> {\n const refreshAccessTokenFunction = (\n globalThis as {\n frontComponentHostCommunicationApi?: {\n requestAccessTokenRefresh?: () => Promise<string>;\n };\n }\n ).frontComponentHostCommunicationApi?.requestAccessTokenRefresh;\n\n if (typeof refreshAccessTokenFunction !== 'function') {\n return null;\n }\n\n if (!this.refreshAccessTokenPromise) {\n this.refreshAccessTokenPromise = refreshAccessTokenFunction()\n .then((refreshedAccessToken) => {\n if (\n typeof refreshedAccessToken !== 'string' ||\n refreshedAccessToken.length === 0\n ) {\n return null;\n }\n\n this.setAuthorizationToken(refreshedAccessToken);\n\n return refreshedAccessToken;\n })\n .catch((refreshError: unknown) => {\n console.error('Twenty client: token refresh failed', refreshError);\n\n return null;\n })\n .finally(() => {\n this.refreshAccessTokenPromise = null;\n });\n }\n\n return this.refreshAccessTokenPromise;\n }\n\n private setAuthorizationToken(token: string) {\n this.authorizationToken = token;\n\n const processEnvironment = getProcessEnvironment();\n\n processEnvironment[APP_ACCESS_TOKEN_ENV_KEY] = token;\n }\n}\n", o = `${r}.tmp`;
|
|
526
526
|
await O(o), await k(o);
|
|
527
527
|
try {
|
|
528
528
|
await Z({
|
|
@@ -575,7 +575,7 @@ var ot = async (e) => {
|
|
|
575
575
|
JSON: "Record<string, unknown>",
|
|
576
576
|
UUID: "string"
|
|
577
577
|
}, dt = async ({ schema: n, outputPath: r, clientWrapperTemplateSource: i }) => {
|
|
578
|
-
let a = i ?? "// Ambient type stubs for the genql-generated code this template gets\n// injected into. They enable full typecheck/lint on this file.\n// __STRIPPED_DURING_INJECTION_START__\ntype QueryGenqlSelection = Record<string, unknown>;\ntype MutationGenqlSelection = Record<string, unknown>;\ntype GraphqlOperation = Record<string, unknown>;\n\ntype ClientOptions = {\n url?: string;\n headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);\n fetcher?: (\n operation: GraphqlOperation | GraphqlOperation[],\n ) => Promise<unknown>;\n fetch?: typeof globalThis.fetch;\n batch?: unknown;\n};\n\ntype Client = {\n query: (\n request: QueryGenqlSelection & { __name?: string },\n ) => Promise<unknown>;\n mutation: (\n request: MutationGenqlSelection & { __name?: string },\n ) => Promise<unknown>;\n};\n\ndeclare function createClient(options: ClientOptions): Client;\n\ndeclare class GenqlError extends Error {\n constructor(errors: unknown, data: unknown);\n}\n// __STRIPPED_DURING_INJECTION_END__\n\nconst APP_ACCESS_TOKEN_ENV_KEY = 'TWENTY_APP_ACCESS_TOKEN';\nconst APP_APPLICATION_ACCESS_TOKEN_ENV_KEY =\n 'TWENTY_APP_APPLICATION_ACCESS_TOKEN';\nconst API_KEY_ENV_KEY = 'TWENTY_API_KEY';\n\n// The default acts as the person who triggered the run, limited to their role\n// intersected with the application's, and as the application alone when nobody\n// triggered it. 'application' asks for the application's access either way.\ntype TwentyClientRunAs = 'user' | 'application';\n\ntype TwentyGeneratedClientOptions = ClientOptions & {\n runAs?: TwentyClientRunAs;\n};\n\ntype ProcessEnvironment = Record<string, string | undefined>;\n\ntype GraphqlErrorPayloadEntry = {\n message?: string;\n extensions?: { code?: string };\n};\n\ntype GraphqlResponsePayload = {\n data?: Record<string, unknown>;\n errors?: GraphqlErrorPayloadEntry[];\n};\n\ntype GraphqlResponse = {\n status: number;\n statusText: string;\n payload: GraphqlResponsePayload | null;\n rawBody: string;\n};\n\nconst getProcessEnvironment = (): ProcessEnvironment => {\n const processObject = (\n globalThis as { process?: { env?: ProcessEnvironment } }\n ).process;\n\n return processObject?.env ?? {};\n};\n\nconst getTokenFromAuthorizationHeader = (\n authorizationHeader: string | undefined,\n): string | null => {\n if (typeof authorizationHeader !== 'string') {\n return null;\n }\n\n const trimmedAuthorizationHeader = authorizationHeader.trim();\n\n if (trimmedAuthorizationHeader.length === 0) {\n return null;\n }\n\n if (trimmedAuthorizationHeader === 'Bearer') {\n return null;\n }\n\n if (trimmedAuthorizationHeader.startsWith('Bearer ')) {\n return trimmedAuthorizationHeader.slice('Bearer '.length).trim();\n }\n\n return trimmedAuthorizationHeader;\n};\n\nconst getTokenFromHeaders = (\n headers: HeadersInit | undefined,\n): string | null => {\n if (!headers) {\n return null;\n }\n\n if (headers instanceof Headers) {\n return getTokenFromAuthorizationHeader(\n headers.get('Authorization') ?? undefined,\n );\n }\n\n if (Array.isArray(headers)) {\n const matchedAuthorizationHeader = headers.find(\n ([headerName]) => headerName.toLowerCase() === 'authorization',\n );\n\n return getTokenFromAuthorizationHeader(matchedAuthorizationHeader?.[1]);\n }\n\n const headersRecord = headers as Record<string, string | undefined>;\n\n return getTokenFromAuthorizationHeader(\n headersRecord.Authorization ?? headersRecord.authorization,\n );\n};\n\nconst hasAuthenticationErrorInGraphqlPayload = (\n payload: GraphqlResponsePayload | null,\n): boolean => {\n if (!payload?.errors) {\n return false;\n }\n\n return payload.errors.some((graphqlError) => {\n return (\n graphqlError.extensions?.code === 'UNAUTHENTICATED' ||\n graphqlError.message?.toLowerCase() === 'unauthorized'\n );\n });\n};\n\nconst defaultOptions: TwentyGeneratedClientOptions = {\n url: '__TWENTY_DEFAULT_URL__',\n headers: {\n 'Content-Type': 'application/json',\n },\n};\n\nexport class TwentyGeneratedClient {\n private client: Client;\n private url: string;\n private requestOptions: RequestInit;\n private headers: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);\n private fetchImplementation: typeof globalThis.fetch | null;\n private authorizationToken: string | null;\n private refreshAccessTokenPromise: Promise<string | null> | null = null;\n\n constructor(options?: TwentyGeneratedClientOptions) {\n const merged: TwentyGeneratedClientOptions = {\n ...defaultOptions,\n ...options,\n };\n\n const {\n url,\n headers,\n fetch: customFetchImplementation,\n fetcher: _fetcher,\n batch: _batch,\n runAs,\n ...requestOptions\n } = merged;\n\n this.url = url ?? '';\n this.requestOptions = requestOptions;\n this.headers = headers ?? {};\n this.fetchImplementation =\n customFetchImplementation ?? globalThis.fetch ?? null;\n\n const processEnvironment = getProcessEnvironment();\n const tokenFromHeaders = getTokenFromHeaders(\n typeof headers === 'function' ? undefined : headers,\n );\n\n // Priority: explicit header > the token for the requested access > api key\n // (legacy).\n this.authorizationToken =\n tokenFromHeaders ??\n processEnvironment[\n runAs === 'application'\n ? APP_APPLICATION_ACCESS_TOKEN_ENV_KEY\n : APP_ACCESS_TOKEN_ENV_KEY\n ] ??\n processEnvironment[API_KEY_ENV_KEY] ??\n null;\n\n this.client = createClient({\n ...merged,\n headers: undefined,\n fetcher: async (operation) =>\n this.executeGraphqlRequestWithOptionalRefresh({\n operation,\n }),\n });\n }\n\n query<R extends QueryGenqlSelection>(request: R & { __name?: string }) {\n return this.client.query(request);\n }\n\n mutation<R extends MutationGenqlSelection>(request: R & { __name?: string }) {\n return this.client.mutation(request);\n }\n\n // __UPLOAD_FILE_START__\n async uploadFile(\n fileBuffer: Buffer,\n filename: string,\n contentType: string = 'application/octet-stream',\n fieldMetadataUniversalIdentifier: string,\n ): Promise<{\n id: string;\n path: string;\n size: number;\n createdAt: string;\n url: string;\n }> {\n const form = new FormData();\n\n form.append(\n 'operations',\n JSON.stringify({\n query: `mutation UploadFilesFieldFileByUniversalIdentifier($file: Upload!, $fieldMetadataUniversalIdentifier: String!) {\n uploadFilesFieldFileByUniversalIdentifier(file: $file, fieldMetadataUniversalIdentifier: $fieldMetadataUniversalIdentifier) { id path size createdAt url }\n }`,\n variables: {\n file: null,\n fieldMetadataUniversalIdentifier,\n },\n }),\n );\n form.append('map', JSON.stringify({ '0': ['variables.file'] }));\n form.append(\n '0',\n new Blob([fileBuffer as BlobPart], { type: contentType }),\n filename,\n );\n\n const result = await this.executeGraphqlRequestWithOptionalRefresh({\n operation: form,\n headers: {},\n requestInit: {\n method: 'POST',\n },\n });\n\n if (result.errors) {\n throw new GenqlError(result.errors, result.data);\n }\n\n const data = result.data as Record<string, unknown>;\n\n return data.uploadFilesFieldFileByUniversalIdentifier as {\n id: string;\n path: string;\n size: number;\n createdAt: string;\n url: string;\n };\n }\n // __UPLOAD_FILE_END__\n\n private async executeGraphqlRequestWithOptionalRefresh({\n operation,\n headers,\n requestInit,\n }: {\n operation: GraphqlOperation | GraphqlOperation[] | FormData;\n headers?: HeadersInit;\n requestInit?: RequestInit;\n }) {\n const firstResponse = await this.executeGraphqlRequest({\n operation,\n headers,\n requestInit,\n token: this.authorizationToken,\n });\n\n if (this.shouldRefreshToken(firstResponse)) {\n const refreshedAccessToken = await this.requestRefreshedAccessToken();\n\n if (refreshedAccessToken) {\n const retryResponse = await this.executeGraphqlRequest({\n operation,\n headers,\n requestInit,\n token: refreshedAccessToken,\n });\n\n return this.assertResponseIsSuccessful(retryResponse);\n }\n }\n\n return this.assertResponseIsSuccessful(firstResponse);\n }\n\n private async executeGraphqlRequest({\n operation,\n headers,\n requestInit,\n token,\n }: {\n operation: GraphqlOperation | GraphqlOperation[] | FormData;\n headers?: HeadersInit;\n requestInit?: RequestInit;\n token: string | null;\n }): Promise<GraphqlResponse> {\n if (!this.fetchImplementation) {\n throw new Error(\n 'Global `fetch` function is not available, ' +\n 'pass a fetch implementation to the Twenty client',\n );\n }\n\n const resolvedHeaders = await this.resolveHeaders();\n const requestHeaders = new Headers(resolvedHeaders);\n\n if (headers) {\n new Headers(headers).forEach((value, key) =>\n requestHeaders.set(key, value),\n );\n }\n\n if (operation instanceof FormData) {\n requestHeaders.delete('Content-Type');\n } else {\n requestHeaders.set('Content-Type', 'application/json');\n }\n\n if (token) {\n requestHeaders.set('Authorization', `Bearer ${token}`);\n } else {\n requestHeaders.delete('Authorization');\n }\n\n const response = await this.fetchImplementation.call(globalThis, this.url, {\n ...this.requestOptions,\n ...requestInit,\n method: requestInit?.method ?? 'POST',\n headers: requestHeaders,\n body:\n operation instanceof FormData ? operation : JSON.stringify(operation),\n });\n\n const rawBody = await response.text();\n let payload: GraphqlResponsePayload | null = null;\n\n if (rawBody.trim().length > 0) {\n try {\n payload = JSON.parse(rawBody) as GraphqlResponsePayload;\n } catch {\n payload = null;\n }\n }\n\n return {\n status: response.status,\n statusText: response.statusText,\n payload,\n rawBody,\n };\n }\n\n private async resolveHeaders(): Promise<HeadersInit> {\n if (typeof this.headers === 'function') {\n return (await this.headers()) ?? {};\n }\n\n return this.headers ?? {};\n }\n\n private shouldRefreshToken(response: GraphqlResponse): boolean {\n if (response.status === 401) {\n return true;\n }\n\n return hasAuthenticationErrorInGraphqlPayload(response.payload);\n }\n\n private assertResponseIsSuccessful(response: GraphqlResponse) {\n if (response.status < 200 || response.status >= 300) {\n throw new Error(`${response.statusText}: ${response.rawBody}`);\n }\n\n if (response.payload === null) {\n throw new Error('Invalid JSON response');\n }\n\n return response.payload;\n }\n\n private async requestRefreshedAccessToken(): Promise<string | null> {\n const refreshAccessTokenFunction = (\n globalThis as {\n frontComponentHostCommunicationApi?: {\n requestAccessTokenRefresh?: () => Promise<string>;\n };\n }\n ).frontComponentHostCommunicationApi?.requestAccessTokenRefresh;\n\n if (typeof refreshAccessTokenFunction !== 'function') {\n return null;\n }\n\n if (!this.refreshAccessTokenPromise) {\n this.refreshAccessTokenPromise = refreshAccessTokenFunction()\n .then((refreshedAccessToken) => {\n if (\n typeof refreshedAccessToken !== 'string' ||\n refreshedAccessToken.length === 0\n ) {\n return null;\n }\n\n this.setAuthorizationToken(refreshedAccessToken);\n\n return refreshedAccessToken;\n })\n .catch((refreshError: unknown) => {\n console.error('Twenty client: token refresh failed', refreshError);\n\n return null;\n })\n .finally(() => {\n this.refreshAccessTokenPromise = null;\n });\n }\n\n return this.refreshAccessTokenPromise;\n }\n\n private setAuthorizationToken(token: string) {\n this.authorizationToken = token;\n\n const processEnvironment = getProcessEnvironment();\n\n processEnvironment[APP_ACCESS_TOKEN_ENV_KEY] = token;\n }\n}\n";
|
|
578
|
+
let a = i ?? "import type { TwentyClientRunAs } from '../shared/twenty-client-run-as.type';\n\n// Ambient type stubs for the genql-generated code this template gets\n// injected into. They enable full typecheck/lint on this file.\n// __STRIPPED_DURING_INJECTION_START__\ntype QueryGenqlSelection = Record<string, unknown>;\ntype MutationGenqlSelection = Record<string, unknown>;\ntype GraphqlOperation = Record<string, unknown>;\n\ntype ClientOptions = Omit<RequestInit, 'body' | 'headers'> & {\n url?: string;\n headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);\n fetcher?: (\n operation: GraphqlOperation | GraphqlOperation[],\n ) => Promise<unknown>;\n fetch?: typeof globalThis.fetch;\n batch?: unknown;\n};\n\ntype Client = {\n query: (\n request: QueryGenqlSelection & { __name?: string },\n ) => Promise<unknown>;\n mutation: (\n request: MutationGenqlSelection & { __name?: string },\n ) => Promise<unknown>;\n};\n\ndeclare function createClient(options: ClientOptions): Client;\n\ndeclare class GenqlError extends Error {\n constructor(errors: unknown, data: unknown);\n}\n// __STRIPPED_DURING_INJECTION_END__\n\nconst APP_ACCESS_TOKEN_ENV_KEY = 'TWENTY_APP_ACCESS_TOKEN';\nconst APP_APPLICATION_ACCESS_TOKEN_ENV_KEY =\n 'TWENTY_APP_APPLICATION_ACCESS_TOKEN';\nconst API_KEY_ENV_KEY = 'TWENTY_API_KEY';\n\nexport type TwentyGeneratedClientOptions = ClientOptions & {\n runAs?: TwentyClientRunAs;\n};\n\ntype ProcessEnvironment = Record<string, string | undefined>;\n\ntype GraphqlErrorPayloadEntry = {\n message?: string;\n extensions?: { code?: string };\n};\n\ntype GraphqlResponsePayload = {\n data?: Record<string, unknown>;\n errors?: GraphqlErrorPayloadEntry[];\n};\n\ntype GraphqlResponse = {\n status: number;\n statusText: string;\n payload: GraphqlResponsePayload | null;\n rawBody: string;\n};\n\nconst getProcessEnvironment = (): ProcessEnvironment => {\n const processObject = (\n globalThis as { process?: { env?: ProcessEnvironment } }\n ).process;\n\n return processObject?.env ?? {};\n};\n\nconst getTokenFromAuthorizationHeader = (\n authorizationHeader: string | undefined,\n): string | null => {\n if (typeof authorizationHeader !== 'string') {\n return null;\n }\n\n const trimmedAuthorizationHeader = authorizationHeader.trim();\n\n if (trimmedAuthorizationHeader.length === 0) {\n return null;\n }\n\n if (trimmedAuthorizationHeader === 'Bearer') {\n return null;\n }\n\n if (trimmedAuthorizationHeader.startsWith('Bearer ')) {\n return trimmedAuthorizationHeader.slice('Bearer '.length).trim();\n }\n\n return trimmedAuthorizationHeader;\n};\n\nconst getTokenFromHeaders = (\n headers: HeadersInit | undefined,\n): string | null => {\n if (!headers) {\n return null;\n }\n\n if (headers instanceof Headers) {\n return getTokenFromAuthorizationHeader(\n headers.get('Authorization') ?? undefined,\n );\n }\n\n if (Array.isArray(headers)) {\n const matchedAuthorizationHeader = headers.find(\n ([headerName]) => headerName.toLowerCase() === 'authorization',\n );\n\n return getTokenFromAuthorizationHeader(matchedAuthorizationHeader?.[1]);\n }\n\n const headersRecord = headers as Record<string, string | undefined>;\n\n return getTokenFromAuthorizationHeader(\n headersRecord.Authorization ?? headersRecord.authorization,\n );\n};\n\nconst hasAuthenticationErrorInGraphqlPayload = (\n payload: GraphqlResponsePayload | null,\n): boolean => {\n if (!payload?.errors) {\n return false;\n }\n\n return payload.errors.some((graphqlError) => {\n return (\n graphqlError.extensions?.code === 'UNAUTHENTICATED' ||\n graphqlError.message?.toLowerCase() === 'unauthorized'\n );\n });\n};\n\nconst defaultOptions: TwentyGeneratedClientOptions = {\n url: '__TWENTY_DEFAULT_URL__',\n headers: {\n 'Content-Type': 'application/json',\n },\n};\n\nexport class TwentyGeneratedClient {\n private client: Client;\n private url: string;\n private requestOptions: RequestInit;\n private headers: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);\n private fetchImplementation: typeof globalThis.fetch | null;\n private authorizationToken: string | null;\n private refreshAccessTokenPromise: Promise<string | null> | null = null;\n\n constructor(options?: TwentyGeneratedClientOptions) {\n const merged: TwentyGeneratedClientOptions = {\n ...defaultOptions,\n ...options,\n };\n\n const {\n url,\n headers,\n fetch: customFetchImplementation,\n fetcher: _fetcher,\n batch: _batch,\n runAs,\n ...requestOptions\n } = merged;\n\n this.url = url ?? '';\n this.requestOptions = requestOptions;\n this.headers = headers ?? {};\n this.fetchImplementation =\n customFetchImplementation ?? globalThis.fetch ?? null;\n\n const processEnvironment = getProcessEnvironment();\n const tokenFromHeaders = getTokenFromHeaders(\n typeof headers === 'function' ? undefined : headers,\n );\n\n // Priority: explicit header > the token for the requested access > api key\n // (legacy).\n this.authorizationToken =\n tokenFromHeaders ??\n processEnvironment[\n runAs === 'application'\n ? APP_APPLICATION_ACCESS_TOKEN_ENV_KEY\n : APP_ACCESS_TOKEN_ENV_KEY\n ] ??\n processEnvironment[API_KEY_ENV_KEY] ??\n null;\n\n this.client = createClient({\n ...merged,\n headers: undefined,\n fetcher: async (operation) =>\n this.executeGraphqlRequestWithOptionalRefresh({\n operation,\n }),\n });\n }\n\n query<R extends QueryGenqlSelection>(request: R & { __name?: string }) {\n return this.client.query(request);\n }\n\n mutation<R extends MutationGenqlSelection>(request: R & { __name?: string }) {\n return this.client.mutation(request);\n }\n\n // __UPLOAD_FILE_START__\n async uploadFile(\n fileBuffer: Buffer,\n filename: string,\n contentType: string = 'application/octet-stream',\n fieldMetadataUniversalIdentifier: string,\n ): Promise<{\n id: string;\n path: string;\n size: number;\n createdAt: string;\n url: string;\n }> {\n const form = new FormData();\n\n form.append(\n 'operations',\n JSON.stringify({\n query: `mutation UploadFilesFieldFileByUniversalIdentifier($file: Upload!, $fieldMetadataUniversalIdentifier: String!) {\n uploadFilesFieldFileByUniversalIdentifier(file: $file, fieldMetadataUniversalIdentifier: $fieldMetadataUniversalIdentifier) { id path size createdAt url }\n }`,\n variables: {\n file: null,\n fieldMetadataUniversalIdentifier,\n },\n }),\n );\n form.append('map', JSON.stringify({ '0': ['variables.file'] }));\n form.append(\n '0',\n new Blob([fileBuffer as BlobPart], { type: contentType }),\n filename,\n );\n\n const result = await this.executeGraphqlRequestWithOptionalRefresh({\n operation: form,\n headers: {},\n requestInit: {\n method: 'POST',\n },\n });\n\n if (result.errors) {\n throw new GenqlError(result.errors, result.data);\n }\n\n const data = result.data as Record<string, unknown>;\n\n return data.uploadFilesFieldFileByUniversalIdentifier as {\n id: string;\n path: string;\n size: number;\n createdAt: string;\n url: string;\n };\n }\n // __UPLOAD_FILE_END__\n\n private async executeGraphqlRequestWithOptionalRefresh({\n operation,\n headers,\n requestInit,\n }: {\n operation: GraphqlOperation | GraphqlOperation[] | FormData;\n headers?: HeadersInit;\n requestInit?: RequestInit;\n }) {\n const firstResponse = await this.executeGraphqlRequest({\n operation,\n headers,\n requestInit,\n token: this.authorizationToken,\n });\n\n if (this.shouldRefreshToken(firstResponse)) {\n const refreshedAccessToken = await this.requestRefreshedAccessToken();\n\n if (refreshedAccessToken) {\n const retryResponse = await this.executeGraphqlRequest({\n operation,\n headers,\n requestInit,\n token: refreshedAccessToken,\n });\n\n return this.assertResponseIsSuccessful(retryResponse);\n }\n }\n\n return this.assertResponseIsSuccessful(firstResponse);\n }\n\n private async executeGraphqlRequest({\n operation,\n headers,\n requestInit,\n token,\n }: {\n operation: GraphqlOperation | GraphqlOperation[] | FormData;\n headers?: HeadersInit;\n requestInit?: RequestInit;\n token: string | null;\n }): Promise<GraphqlResponse> {\n if (!this.fetchImplementation) {\n throw new Error(\n 'Global `fetch` function is not available, ' +\n 'pass a fetch implementation to the Twenty client',\n );\n }\n\n const resolvedHeaders = await this.resolveHeaders();\n const requestHeaders = new Headers(resolvedHeaders);\n\n if (headers) {\n new Headers(headers).forEach((value, key) =>\n requestHeaders.set(key, value),\n );\n }\n\n if (operation instanceof FormData) {\n requestHeaders.delete('Content-Type');\n } else {\n requestHeaders.set('Content-Type', 'application/json');\n }\n\n if (token) {\n requestHeaders.set('Authorization', `Bearer ${token}`);\n } else {\n requestHeaders.delete('Authorization');\n }\n\n const response = await this.fetchImplementation.call(globalThis, this.url, {\n ...this.requestOptions,\n ...requestInit,\n method: requestInit?.method ?? 'POST',\n headers: requestHeaders,\n body:\n operation instanceof FormData ? operation : JSON.stringify(operation),\n });\n\n const rawBody = await response.text();\n let payload: GraphqlResponsePayload | null = null;\n\n if (rawBody.trim().length > 0) {\n try {\n payload = JSON.parse(rawBody) as GraphqlResponsePayload;\n } catch {\n payload = null;\n }\n }\n\n return {\n status: response.status,\n statusText: response.statusText,\n payload,\n rawBody,\n };\n }\n\n private async resolveHeaders(): Promise<HeadersInit> {\n if (typeof this.headers === 'function') {\n return (await this.headers()) ?? {};\n }\n\n return this.headers ?? {};\n }\n\n private shouldRefreshToken(response: GraphqlResponse): boolean {\n if (response.status === 401) {\n return true;\n }\n\n return hasAuthenticationErrorInGraphqlPayload(response.payload);\n }\n\n private assertResponseIsSuccessful(response: GraphqlResponse) {\n if (response.status < 200 || response.status >= 300) {\n throw new Error(`${response.statusText}: ${response.rawBody}`);\n }\n\n if (response.payload === null) {\n throw new Error('Invalid JSON response');\n }\n\n return response.payload;\n }\n\n private async requestRefreshedAccessToken(): Promise<string | null> {\n const refreshAccessTokenFunction = (\n globalThis as {\n frontComponentHostCommunicationApi?: {\n requestAccessTokenRefresh?: () => Promise<string>;\n };\n }\n ).frontComponentHostCommunicationApi?.requestAccessTokenRefresh;\n\n if (typeof refreshAccessTokenFunction !== 'function') {\n return null;\n }\n\n if (!this.refreshAccessTokenPromise) {\n this.refreshAccessTokenPromise = refreshAccessTokenFunction()\n .then((refreshedAccessToken) => {\n if (\n typeof refreshedAccessToken !== 'string' ||\n refreshedAccessToken.length === 0\n ) {\n return null;\n }\n\n this.setAuthorizationToken(refreshedAccessToken);\n\n return refreshedAccessToken;\n })\n .catch((refreshError: unknown) => {\n console.error('Twenty client: token refresh failed', refreshError);\n\n return null;\n })\n .finally(() => {\n this.refreshAccessTokenPromise = null;\n });\n }\n\n return this.refreshAccessTokenPromise;\n }\n\n private setAuthorizationToken(token: string) {\n this.authorizationToken = token;\n\n const processEnvironment = getProcessEnvironment();\n\n processEnvironment[APP_ACCESS_TOKEN_ENV_KEY] = token;\n }\n}\n";
|
|
579
579
|
await O(r), await k(r), await Z({
|
|
580
580
|
schema: n,
|
|
581
581
|
output: r,
|
|
@@ -27,8 +27,8 @@ export type SubscriptionResult<fields extends SubscriptionGenqlSelection> = Fiel
|
|
|
27
27
|
export declare const generateSubscriptionOp: (fields: SubscriptionGenqlSelection & {
|
|
28
28
|
__name?: string;
|
|
29
29
|
}) => GraphqlOperation;
|
|
30
|
-
type TwentyClientRunAs
|
|
31
|
-
type MetadataApiClientOptions = ClientOptions & {
|
|
30
|
+
import type { TwentyClientRunAs } from '../shared/twenty-client-run-as.type';
|
|
31
|
+
export type MetadataApiClientOptions = ClientOptions & {
|
|
32
32
|
runAs?: TwentyClientRunAs;
|
|
33
33
|
};
|
|
34
34
|
export declare class MetadataApiClient {
|
|
@@ -106,6 +106,7 @@ export interface CommandMenuItem {
|
|
|
106
106
|
hotKeys?: Scalars['String'][];
|
|
107
107
|
conditionalAvailabilityExpression?: Scalars['String'];
|
|
108
108
|
availabilityObjectMetadataId?: Scalars['UUID'];
|
|
109
|
+
navigationTargetObjectMetadataId?: Scalars['UUID'];
|
|
109
110
|
pageLayoutId?: Scalars['UUID'];
|
|
110
111
|
universalIdentifier?: Scalars['UUID'];
|
|
111
112
|
applicationId?: Scalars['UUID'];
|
|
@@ -124,6 +125,7 @@ export interface PathCommandMenuItemPayload {
|
|
|
124
125
|
__typename: 'PathCommandMenuItemPayload';
|
|
125
126
|
}
|
|
126
127
|
export interface ObjectMetadataCommandMenuItemPayload {
|
|
128
|
+
/** @deprecated Use CommandMenuItem.navigationTargetObjectMetadataId instead, which is the modelled relation. This variant is dual-written and kept for backward compatibility. */
|
|
127
129
|
objectMetadataItemId: Scalars['UUID'];
|
|
128
130
|
__typename: 'ObjectMetadataCommandMenuItemPayload';
|
|
129
131
|
}
|
|
@@ -796,6 +798,7 @@ export interface CalendarConfiguration {
|
|
|
796
798
|
export interface FrontComponentConfiguration {
|
|
797
799
|
configurationType: WidgetConfigurationType;
|
|
798
800
|
frontComponentId: Scalars['UUID'];
|
|
801
|
+
headerCommandMenuItemUniversalIdentifiers?: Scalars['UUID'][];
|
|
799
802
|
__typename: 'FrontComponentConfiguration';
|
|
800
803
|
}
|
|
801
804
|
export interface EmailsConfiguration {
|
|
@@ -1237,7 +1240,7 @@ export interface FeatureFlag {
|
|
|
1237
1240
|
value: Scalars['Boolean'];
|
|
1238
1241
|
__typename: 'FeatureFlag';
|
|
1239
1242
|
}
|
|
1240
|
-
export type FeatureFlagKey = 'IS_APP_CLAIMING_ENABLED' | 'IS_UNIQUE_INDEXES_ENABLED' | 'IS_JSON_FILTER_ENABLED' | 'IS_CALENDAR_WEEK_VIEW_ENABLED' | 'IS_EMAIL_GROUP_ENABLED' | 'IS_JUNCTION_RELATIONS_ENABLED' | 'IS_LIST_VIEW_ENABLED' | 'IS_REST_METADATA_API_NEW_FORMAT_DIRECT' | 'IS_LOGIC_FUNCTION_PREBUILT_MODE_ENABLED' | 'IS_WORKFLOW_VERSION_IN_CORE_ENABLED' | 'IS_WORKFLOW_CORE_INDEX_PAGE_ENABLED' | 'IS_WORKFLOW_DISPATCH_FROM_CORE_ENABLED'
|
|
1243
|
+
export type FeatureFlagKey = 'IS_APP_CLAIMING_ENABLED' | 'IS_UNIQUE_INDEXES_ENABLED' | 'IS_JSON_FILTER_ENABLED' | 'IS_CALENDAR_WEEK_VIEW_ENABLED' | 'IS_EMAIL_GROUP_ENABLED' | 'IS_JUNCTION_RELATIONS_ENABLED' | 'IS_LIST_VIEW_ENABLED' | 'IS_REST_METADATA_API_NEW_FORMAT_DIRECT' | 'IS_LOGIC_FUNCTION_PREBUILT_MODE_ENABLED' | 'IS_WORKFLOW_VERSION_IN_CORE_ENABLED' | 'IS_WORKFLOW_CORE_INDEX_PAGE_ENABLED' | 'IS_WORKFLOW_DISPATCH_FROM_CORE_ENABLED';
|
|
1241
1244
|
export interface WorkspaceUrls {
|
|
1242
1245
|
customUrl?: Scalars['String'];
|
|
1243
1246
|
subdomainUrl: Scalars['String'];
|
|
@@ -2418,6 +2421,12 @@ export interface EnqueueJobResult {
|
|
|
2418
2421
|
logicFunctionUniversalIdentifier: Scalars['String'];
|
|
2419
2422
|
__typename: 'EnqueueJobResult';
|
|
2420
2423
|
}
|
|
2424
|
+
export interface EnqueueJobsResult {
|
|
2425
|
+
enqueued: Scalars['Boolean'];
|
|
2426
|
+
logicFunctionUniversalIdentifier: Scalars['String'];
|
|
2427
|
+
enqueuedJobsCount: Scalars['Int'];
|
|
2428
|
+
__typename: 'EnqueueJobsResult';
|
|
2429
|
+
}
|
|
2421
2430
|
export interface AppKeyValue {
|
|
2422
2431
|
key: Scalars['String'];
|
|
2423
2432
|
value?: Scalars['JSON'];
|
|
@@ -2475,14 +2484,31 @@ export interface MetadataTranslation {
|
|
|
2475
2484
|
}
|
|
2476
2485
|
/** Where a resolved metadata label comes from: a workspace-authored translation, a shipped application catalog, or inheritance from the canonical value */
|
|
2477
2486
|
export type MetadataTranslationProvenance = 'WORKSPACE' | 'SHIPPED' | 'INHERITED';
|
|
2487
|
+
export interface TimelineActivityTypeEmitThrough {
|
|
2488
|
+
relationFieldUniversalIdentifier: Scalars['UUID'];
|
|
2489
|
+
triggerFieldUniversalIdentifiers?: Scalars['UUID'][];
|
|
2490
|
+
__typename: 'TimelineActivityTypeEmitThrough';
|
|
2491
|
+
}
|
|
2492
|
+
export interface TimelineActivityTypeEmit {
|
|
2493
|
+
on: Scalars['String'];
|
|
2494
|
+
objectUniversalIdentifier?: Scalars['UUID'];
|
|
2495
|
+
through?: TimelineActivityTypeEmitThrough;
|
|
2496
|
+
__typename: 'TimelineActivityTypeEmit';
|
|
2497
|
+
}
|
|
2478
2498
|
export interface TimelineActivityType {
|
|
2479
2499
|
id: Scalars['UUID'];
|
|
2500
|
+
universalIdentifier: Scalars['UUID'];
|
|
2480
2501
|
name: Scalars['String'];
|
|
2481
2502
|
label: Scalars['String'];
|
|
2503
|
+
emit?: TimelineActivityTypeEmit;
|
|
2504
|
+
/** @deprecated Use emit.on */
|
|
2482
2505
|
action?: Scalars['String'];
|
|
2483
2506
|
icon?: Scalars['String'];
|
|
2484
|
-
|
|
2507
|
+
frontComponentUniversalIdentifier?: Scalars['UUID'];
|
|
2508
|
+
/** @deprecated Use emit.objectUniversalIdentifier */
|
|
2485
2509
|
objectUniversalIdentifier?: Scalars['UUID'];
|
|
2510
|
+
replacesTimelineActivityTypeUniversalIdentifier?: Scalars['UUID'];
|
|
2511
|
+
isActive: Scalars['Boolean'];
|
|
2486
2512
|
applicationId?: Scalars['UUID'];
|
|
2487
2513
|
createdAt: Scalars['DateTime'];
|
|
2488
2514
|
updatedAt: Scalars['DateTime'];
|
|
@@ -2815,7 +2841,9 @@ export interface Mutation {
|
|
|
2815
2841
|
updateCalendarChannel: CalendarChannel;
|
|
2816
2842
|
setAppKeyValue: AppKeyValue;
|
|
2817
2843
|
deleteAppKeyValue: Scalars['Boolean'];
|
|
2844
|
+
/** @deprecated Use enqueueJobs instead. */
|
|
2818
2845
|
enqueueJob: EnqueueJobResult;
|
|
2846
|
+
enqueueJobs: EnqueueJobsResult;
|
|
2819
2847
|
createChatThread: AgentChatThread;
|
|
2820
2848
|
sendChatMessage: SendChatMessageResult;
|
|
2821
2849
|
retryChatMessage: SendChatMessageResult;
|
|
@@ -2834,6 +2862,8 @@ export interface Mutation {
|
|
|
2834
2862
|
deactivateSkill: Skill;
|
|
2835
2863
|
evaluateAgentTurn: AgentTurnEvaluation;
|
|
2836
2864
|
runEvaluationInput: AgentTurn;
|
|
2865
|
+
updateTimelineActivityType: TimelineActivityType;
|
|
2866
|
+
resetTimelineActivityType: TimelineActivityType;
|
|
2837
2867
|
getAuthorizationUrlForSSO: GetAuthorizationUrlForSSO;
|
|
2838
2868
|
getLoginTokenFromCredentials: LoginToken;
|
|
2839
2869
|
signIn: AvailableWorkspacesAndAccessTokens;
|
|
@@ -3006,6 +3036,7 @@ export interface CommandMenuItemGenqlSelection {
|
|
|
3006
3036
|
hotKeys?: boolean | number;
|
|
3007
3037
|
conditionalAvailabilityExpression?: boolean | number;
|
|
3008
3038
|
availabilityObjectMetadataId?: boolean | number;
|
|
3039
|
+
navigationTargetObjectMetadataId?: boolean | number;
|
|
3009
3040
|
pageLayoutId?: boolean | number;
|
|
3010
3041
|
universalIdentifier?: boolean | number;
|
|
3011
3042
|
applicationId?: boolean | number;
|
|
@@ -3026,6 +3057,7 @@ export interface PathCommandMenuItemPayloadGenqlSelection {
|
|
|
3026
3057
|
__scalar?: boolean | number;
|
|
3027
3058
|
}
|
|
3028
3059
|
export interface ObjectMetadataCommandMenuItemPayloadGenqlSelection {
|
|
3060
|
+
/** @deprecated Use CommandMenuItem.navigationTargetObjectMetadataId instead, which is the modelled relation. This variant is dual-written and kept for backward compatibility. */
|
|
3029
3061
|
objectMetadataItemId?: boolean | number;
|
|
3030
3062
|
__typename?: boolean | number;
|
|
3031
3063
|
__scalar?: boolean | number;
|
|
@@ -3787,6 +3819,7 @@ export interface CalendarConfigurationGenqlSelection {
|
|
|
3787
3819
|
export interface FrontComponentConfigurationGenqlSelection {
|
|
3788
3820
|
configurationType?: boolean | number;
|
|
3789
3821
|
frontComponentId?: boolean | number;
|
|
3822
|
+
headerCommandMenuItemUniversalIdentifiers?: boolean | number;
|
|
3790
3823
|
__typename?: boolean | number;
|
|
3791
3824
|
__scalar?: boolean | number;
|
|
3792
3825
|
}
|
|
@@ -5572,6 +5605,13 @@ export interface EnqueueJobResultGenqlSelection {
|
|
|
5572
5605
|
__typename?: boolean | number;
|
|
5573
5606
|
__scalar?: boolean | number;
|
|
5574
5607
|
}
|
|
5608
|
+
export interface EnqueueJobsResultGenqlSelection {
|
|
5609
|
+
enqueued?: boolean | number;
|
|
5610
|
+
logicFunctionUniversalIdentifier?: boolean | number;
|
|
5611
|
+
enqueuedJobsCount?: boolean | number;
|
|
5612
|
+
__typename?: boolean | number;
|
|
5613
|
+
__scalar?: boolean | number;
|
|
5614
|
+
}
|
|
5575
5615
|
export interface AppKeyValueGenqlSelection {
|
|
5576
5616
|
key?: boolean | number;
|
|
5577
5617
|
value?: boolean | number;
|
|
@@ -5624,14 +5664,33 @@ export interface MetadataTranslationGenqlSelection {
|
|
|
5624
5664
|
__typename?: boolean | number;
|
|
5625
5665
|
__scalar?: boolean | number;
|
|
5626
5666
|
}
|
|
5667
|
+
export interface TimelineActivityTypeEmitThroughGenqlSelection {
|
|
5668
|
+
relationFieldUniversalIdentifier?: boolean | number;
|
|
5669
|
+
triggerFieldUniversalIdentifiers?: boolean | number;
|
|
5670
|
+
__typename?: boolean | number;
|
|
5671
|
+
__scalar?: boolean | number;
|
|
5672
|
+
}
|
|
5673
|
+
export interface TimelineActivityTypeEmitGenqlSelection {
|
|
5674
|
+
on?: boolean | number;
|
|
5675
|
+
objectUniversalIdentifier?: boolean | number;
|
|
5676
|
+
through?: TimelineActivityTypeEmitThroughGenqlSelection;
|
|
5677
|
+
__typename?: boolean | number;
|
|
5678
|
+
__scalar?: boolean | number;
|
|
5679
|
+
}
|
|
5627
5680
|
export interface TimelineActivityTypeGenqlSelection {
|
|
5628
5681
|
id?: boolean | number;
|
|
5682
|
+
universalIdentifier?: boolean | number;
|
|
5629
5683
|
name?: boolean | number;
|
|
5630
5684
|
label?: boolean | number;
|
|
5685
|
+
emit?: TimelineActivityTypeEmitGenqlSelection;
|
|
5686
|
+
/** @deprecated Use emit.on */
|
|
5631
5687
|
action?: boolean | number;
|
|
5632
5688
|
icon?: boolean | number;
|
|
5633
|
-
|
|
5689
|
+
frontComponentUniversalIdentifier?: boolean | number;
|
|
5690
|
+
/** @deprecated Use emit.objectUniversalIdentifier */
|
|
5634
5691
|
objectUniversalIdentifier?: boolean | number;
|
|
5692
|
+
replacesTimelineActivityTypeUniversalIdentifier?: boolean | number;
|
|
5693
|
+
isActive?: boolean | number;
|
|
5635
5694
|
applicationId?: boolean | number;
|
|
5636
5695
|
createdAt?: boolean | number;
|
|
5637
5696
|
updatedAt?: boolean | number;
|
|
@@ -6157,6 +6216,7 @@ export interface ObjectFilter {
|
|
|
6157
6216
|
and?: (ObjectFilter[] | null);
|
|
6158
6217
|
or?: (ObjectFilter[] | null);
|
|
6159
6218
|
id?: (UUIDFilterComparison | null);
|
|
6219
|
+
universalIdentifier?: (UUIDFilterComparison | null);
|
|
6160
6220
|
isActive?: (BooleanFieldComparison | null);
|
|
6161
6221
|
isRemote?: (BooleanFieldComparison | null);
|
|
6162
6222
|
isSearchable?: (BooleanFieldComparison | null);
|
|
@@ -7051,11 +7111,17 @@ export interface MutationGenqlSelection {
|
|
|
7051
7111
|
scope?: (AppKeyValueScope | null);
|
|
7052
7112
|
};
|
|
7053
7113
|
};
|
|
7114
|
+
/** @deprecated Use enqueueJobs instead. */
|
|
7054
7115
|
enqueueJob?: (EnqueueJobResultGenqlSelection & {
|
|
7055
7116
|
__args: {
|
|
7056
7117
|
input: EnqueueJobInput;
|
|
7057
7118
|
};
|
|
7058
7119
|
});
|
|
7120
|
+
enqueueJobs?: (EnqueueJobsResultGenqlSelection & {
|
|
7121
|
+
__args: {
|
|
7122
|
+
input: EnqueueJobsInput;
|
|
7123
|
+
};
|
|
7124
|
+
});
|
|
7059
7125
|
createChatThread?: AgentChatThreadGenqlSelection;
|
|
7060
7126
|
sendChatMessage?: (SendChatMessageResultGenqlSelection & {
|
|
7061
7127
|
__args: {
|
|
@@ -7155,6 +7221,16 @@ export interface MutationGenqlSelection {
|
|
|
7155
7221
|
input: Scalars['String'];
|
|
7156
7222
|
};
|
|
7157
7223
|
});
|
|
7224
|
+
updateTimelineActivityType?: (TimelineActivityTypeGenqlSelection & {
|
|
7225
|
+
__args: {
|
|
7226
|
+
input: UpdateTimelineActivityTypeInput;
|
|
7227
|
+
};
|
|
7228
|
+
});
|
|
7229
|
+
resetTimelineActivityType?: (TimelineActivityTypeGenqlSelection & {
|
|
7230
|
+
__args: {
|
|
7231
|
+
id: Scalars['UUID'];
|
|
7232
|
+
};
|
|
7233
|
+
});
|
|
7158
7234
|
getAuthorizationUrlForSSO?: (GetAuthorizationUrlForSSOGenqlSelection & {
|
|
7159
7235
|
__args: {
|
|
7160
7236
|
input: GetAuthorizationUrlForSSOInput;
|
|
@@ -8377,6 +8453,12 @@ export interface EnqueueJobInput {
|
|
|
8377
8453
|
retryLimit?: (Scalars['Int'] | null);
|
|
8378
8454
|
delayMs?: (Scalars['Int'] | null);
|
|
8379
8455
|
}
|
|
8456
|
+
export interface EnqueueJobsInput {
|
|
8457
|
+
logicFunctionUniversalIdentifier: Scalars['String'];
|
|
8458
|
+
payloads: Scalars['JSON'][];
|
|
8459
|
+
retryLimit?: (Scalars['Int'] | null);
|
|
8460
|
+
delayMs?: (Scalars['Int'] | null);
|
|
8461
|
+
}
|
|
8380
8462
|
export interface FileAttachmentInput {
|
|
8381
8463
|
id: Scalars['UUID'];
|
|
8382
8464
|
filename: Scalars['String'];
|
|
@@ -8403,6 +8485,13 @@ export interface UpdateSkillInput {
|
|
|
8403
8485
|
content?: (Scalars['String'] | null);
|
|
8404
8486
|
isActive?: (Scalars['Boolean'] | null);
|
|
8405
8487
|
}
|
|
8488
|
+
export interface UpdateTimelineActivityTypeInput {
|
|
8489
|
+
id: Scalars['UUID'];
|
|
8490
|
+
label?: (Scalars['String'] | null);
|
|
8491
|
+
icon?: (Scalars['String'] | null);
|
|
8492
|
+
isActive?: (Scalars['Boolean'] | null);
|
|
8493
|
+
translations?: (MetadataTranslationOverrideInput[] | null);
|
|
8494
|
+
}
|
|
8406
8495
|
export interface GetAuthorizationUrlForSSOInput {
|
|
8407
8496
|
identityProviderId: Scalars['UUID'];
|
|
8408
8497
|
workspaceInviteHash?: (Scalars['String'] | null);
|
|
@@ -8451,6 +8540,7 @@ export interface CreateCalendarEventInput {
|
|
|
8451
8540
|
}
|
|
8452
8541
|
export interface SendEmailInput {
|
|
8453
8542
|
connectedAccountId: Scalars['String'];
|
|
8543
|
+
fromHandle?: (Scalars['String'] | null);
|
|
8454
8544
|
to: Scalars['String'];
|
|
8455
8545
|
cc?: (Scalars['String'] | null);
|
|
8456
8546
|
bcc?: (Scalars['String'] | null);
|
|
@@ -9295,6 +9385,9 @@ export declare const isWorkspaceAiStats: (obj?: {
|
|
|
9295
9385
|
export declare const isEnqueueJobResult: (obj?: {
|
|
9296
9386
|
__typename?: any;
|
|
9297
9387
|
} | null | undefined) => obj is EnqueueJobResult;
|
|
9388
|
+
export declare const isEnqueueJobsResult: (obj?: {
|
|
9389
|
+
__typename?: any;
|
|
9390
|
+
} | null | undefined) => obj is EnqueueJobsResult;
|
|
9298
9391
|
export declare const isAppKeyValue: (obj?: {
|
|
9299
9392
|
__typename?: any;
|
|
9300
9393
|
} | null | undefined) => obj is AppKeyValue;
|
|
@@ -9307,6 +9400,12 @@ export declare const isMessageFolder: (obj?: {
|
|
|
9307
9400
|
export declare const isMetadataTranslation: (obj?: {
|
|
9308
9401
|
__typename?: any;
|
|
9309
9402
|
} | null | undefined) => obj is MetadataTranslation;
|
|
9403
|
+
export declare const isTimelineActivityTypeEmitThrough: (obj?: {
|
|
9404
|
+
__typename?: any;
|
|
9405
|
+
} | null | undefined) => obj is TimelineActivityTypeEmitThrough;
|
|
9406
|
+
export declare const isTimelineActivityTypeEmit: (obj?: {
|
|
9407
|
+
__typename?: any;
|
|
9408
|
+
} | null | undefined) => obj is TimelineActivityTypeEmit;
|
|
9310
9409
|
export declare const isTimelineActivityType: (obj?: {
|
|
9311
9410
|
__typename?: any;
|
|
9312
9411
|
} | null | undefined) => obj is TimelineActivityType;
|
|
@@ -9762,8 +9861,6 @@ export declare const enumFeatureFlagKey: {
|
|
|
9762
9861
|
IS_WORKFLOW_VERSION_IN_CORE_ENABLED: "IS_WORKFLOW_VERSION_IN_CORE_ENABLED";
|
|
9763
9862
|
IS_WORKFLOW_CORE_INDEX_PAGE_ENABLED: "IS_WORKFLOW_CORE_INDEX_PAGE_ENABLED";
|
|
9764
9863
|
IS_WORKFLOW_DISPATCH_FROM_CORE_ENABLED: "IS_WORKFLOW_DISPATCH_FROM_CORE_ENABLED";
|
|
9765
|
-
IS_NATIVE_CALL_RECORDING_TABS_ENABLED: "IS_NATIVE_CALL_RECORDING_TABS_ENABLED";
|
|
9766
|
-
IS_ORM_V2_READ_PATH_ENABLED: "IS_ORM_V2_READ_PATH_ENABLED";
|
|
9767
9864
|
};
|
|
9768
9865
|
export declare const enumIdentityProviderType: {
|
|
9769
9866
|
OIDC: "OIDC";
|