@contello/client 3.1.2 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +35 -1
- package/dist/index.d.cts +12 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +35 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -15,7 +15,8 @@ const FORWARDED_PROXY_HEADERS = /* @__PURE__ */ new Set([
|
|
|
15
15
|
"etag",
|
|
16
16
|
"last-modified",
|
|
17
17
|
"expires",
|
|
18
|
-
"age"
|
|
18
|
+
"age",
|
|
19
|
+
"vary"
|
|
19
20
|
]);
|
|
20
21
|
function assertSafeSegment(segment, kind) {
|
|
21
22
|
if (segment === "." || segment === ".." || !SAFE_SEGMENT.test(segment)) throw new Error(`invalid ${kind}`);
|
|
@@ -59,6 +60,36 @@ async function proxyHls(agent, url, token, path, signal) {
|
|
|
59
60
|
signal: signal ?? null
|
|
60
61
|
}), signal);
|
|
61
62
|
}
|
|
63
|
+
async function proxySitemap(agent, url, token, projectRef, sitemapId, options, signal) {
|
|
64
|
+
assertSafeSegment(projectRef, "project ref");
|
|
65
|
+
assertSafeSegment(sitemapId, "sitemap id");
|
|
66
|
+
const search = new URLSearchParams();
|
|
67
|
+
if (options.source !== void 0) search.set("source", options.source);
|
|
68
|
+
if (options.page !== void 0) search.set("page", options.page);
|
|
69
|
+
const query = search.size > 0 ? `?${search}` : "";
|
|
70
|
+
const headers = { token };
|
|
71
|
+
if (options.acceptEncoding) headers["accept-encoding"] = options.acceptEncoding;
|
|
72
|
+
if (options.ifNoneMatch) headers["if-none-match"] = options.ifNoneMatch;
|
|
73
|
+
const response = await (0, undici.request)(`${url}/api/v1/projects/${projectRef}/sitemaps/${sitemapId}${query}`, {
|
|
74
|
+
headers,
|
|
75
|
+
dispatcher: agent,
|
|
76
|
+
signal: signal ?? null
|
|
77
|
+
});
|
|
78
|
+
const result = buildProxyResult(response, signal);
|
|
79
|
+
if (response.statusCode === 304) {
|
|
80
|
+
safeDestroyBody(response.body);
|
|
81
|
+
return {
|
|
82
|
+
...result,
|
|
83
|
+
stream: emptyStream
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
function emptyStream() {
|
|
89
|
+
return new ReadableStream({ start(controller) {
|
|
90
|
+
controller.close();
|
|
91
|
+
} });
|
|
92
|
+
}
|
|
62
93
|
function buildProxyResult(response, signal) {
|
|
63
94
|
const headers = new Headers();
|
|
64
95
|
for (const [key, value] of Object.entries(response.headers)) {
|
|
@@ -802,6 +833,9 @@ var ContelloClient = class {
|
|
|
802
833
|
proxyHls(path, signal) {
|
|
803
834
|
return wrap("@contello/client:proxyHls", () => proxyHls(this._agent, this._url, this._token, path, signal));
|
|
804
835
|
}
|
|
836
|
+
proxySitemap(sitemapId, options, signal) {
|
|
837
|
+
return wrap("@contello/client:proxySitemap", () => proxySitemap(this._agent, this._url, this._token, this._project, sitemapId, options, signal));
|
|
838
|
+
}
|
|
805
839
|
upload(data, meta, options) {
|
|
806
840
|
return wrap("@contello/client:upload", () => upload(this._url, this._project, this._token, data, meta, options));
|
|
807
841
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -18,6 +18,16 @@ type ProxyResult = {
|
|
|
18
18
|
headers: Headers;
|
|
19
19
|
stream(): ReadableStream<Uint8Array>;
|
|
20
20
|
};
|
|
21
|
+
type SitemapProxyOptions = {
|
|
22
|
+
/** chunk source as received from the query string; core decides whether the source/page pair is valid */
|
|
23
|
+
source?: string | undefined;
|
|
24
|
+
/** chunk page as received from the query string */
|
|
25
|
+
page?: string | undefined;
|
|
26
|
+
/** the incoming request's Accept-Encoding, so stored gzip bytes pass through untouched */
|
|
27
|
+
acceptEncoding?: string | undefined;
|
|
28
|
+
/** the incoming request's If-None-Match, so core can answer 304 */
|
|
29
|
+
ifNoneMatch?: string | undefined;
|
|
30
|
+
};
|
|
21
31
|
//#endregion
|
|
22
32
|
//#region src/types.d.ts
|
|
23
33
|
type OperationKind = 'query' | 'mutation' | 'subscription';
|
|
@@ -223,6 +233,7 @@ declare class ContelloClient<TSchema extends Schema | undefined = undefined> {
|
|
|
223
233
|
subscribe<TData>(query: string, variables?: Record<string, unknown> | undefined): AsyncIterable<TData>;
|
|
224
234
|
download(fileId: string): Promise<DownloadResult>;
|
|
225
235
|
proxyHls(path: string, signal?: AbortSignal | undefined): Promise<ProxyResult>;
|
|
236
|
+
proxySitemap(sitemapId: string, options: SitemapProxyOptions, signal?: AbortSignal | undefined): Promise<ProxyResult>;
|
|
226
237
|
upload(data: UploadData, meta: UploadMetadata, options?: UploadOptions | undefined): Promise<string>;
|
|
227
238
|
execute<TData>(query: string, variables?: Record<string, unknown> | undefined): Promise<TData>;
|
|
228
239
|
}
|
|
@@ -280,5 +291,5 @@ declare function readSourceMutationId(binding: SourceMutationBinding, result: un
|
|
|
280
291
|
*/
|
|
281
292
|
declare const BUILT_IN_MUTATIONS: Partial<Record<SourceCardinality, SourceMutations>>;
|
|
282
293
|
//#endregion
|
|
283
|
-
export { BUILT_IN_MUTATIONS, type ConnectionContext, type ConnectionEvents, ContelloClient, type ContelloClientOptions, type DownloadResult, type HttpAgentOptions, type LocalDate, type LocalDateTime, type OperationDef, type OperationKind, type OperationMap, type ProxyResult, type Rpc, type Schema, type SourceAccessors, type SourceCardinality, type SourceDef, type SourceMap, type SourceMutationArgument, type SourceMutationBinding, type SourceMutationKind, type SourceMutationResult, type SourceMutationValues, type SourceMutations, type SourceWrites, type UploadData, type UploadMetadata, type UploadOptions, createContelloClient, createSourceMutation, createSourceMutationVariables, createSourceSubscription, readSourceMutationId };
|
|
294
|
+
export { BUILT_IN_MUTATIONS, type ConnectionContext, type ConnectionEvents, ContelloClient, type ContelloClientOptions, type DownloadResult, type HttpAgentOptions, type LocalDate, type LocalDateTime, type OperationDef, type OperationKind, type OperationMap, type ProxyResult, type Rpc, type Schema, type SitemapProxyOptions, type SourceAccessors, type SourceCardinality, type SourceDef, type SourceMap, type SourceMutationArgument, type SourceMutationBinding, type SourceMutationKind, type SourceMutationResult, type SourceMutationValues, type SourceMutations, type SourceWrites, type UploadData, type UploadMetadata, type UploadOptions, createContelloClient, createSourceMutation, createSourceMutationVariables, createSourceSubscription, readSourceMutationId };
|
|
284
295
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/http.ts","../src/types.ts","../src/upload.ts","../src/client.ts","../src/scalars.ts","../src/source-subscription.ts","../src/source-mutation.ts","../src/built-in-mutations.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/http.ts","../src/types.ts","../src/upload.ts","../src/client.ts","../src/scalars.ts","../src/source-subscription.ts","../src/source-mutation.ts","../src/built-in-mutations.ts"],"mappings":";;;KAkCY;EACV;EACA;EACA;EACA;;KAcU;EACV;EACA;EACA,SAAS,QAAQ;EACjB,UAAU,eAAe;;KAiCf;EACV;EACA,SAAS;EACT,UAAU,eAAe;;KAqBf;;EAEV;;EAEA;;EAEA;;EAEA;;;;KCzHU;KAEA,aACV,mBACA,aAAa,yBACb,cAAc,gBAAgB;EAE9B;EACA,MAAM;;EAEN,WAAW;;EAEX,cAAc;;KAGJ,eAAe,eAAe;KAE9B,YAAY,UAAU,gBAAgB,YAAY;KAClD,eAAe,UAAU,gBAAgB,YAAY;KAErD,UAAU,UAAU,gBAAgB,mCAC5C,eAAe,WAAW,8BAClB,cAAc,YAAY,OAC/B,WAAW,eAAe,OAAO,cAAc,YAAY,MAC9D,eAAe,WAAW,8BAClB,QAAQ,YAAY,OACzB,WAAW,eAAe,OAAO,QAAQ,YAAY;KAEhD,IAAI,UAAU,mBACvB,WAAW,IAAI,UAAU,EAAE;;;;;;;;;KAWlB;;;;;;K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AgB,SAAS;EACzB,iBAAiB,SAAS;EAC1B,aAAa,SAAS;EACtB,YAAY,SAAS,mBAAmB;;KAG9B,sBAAsB,gBAAgB;EAChD;EACA;EACA;EACA,SAAS;EACT;EACA,OAAO;EACP;EACA;EACA,YAAY;EACZ,mBAAmB;;cAKR,eAAe,gBAAgB;UAClC;UACA;UACA;UACA;UACA;UACA;UACA;EAEI,YAAA,SAAS,sBAAsB;MAmFvC,OAAO,gBAAgB,aAAa,kBAAkB,IAAI;MAQ1D,WAAW,gBAAgB,kBAAkB,iBAAiB,gBAAgB;EAQ5E,QAAQ;EAIR,WAAW;EAKX,QAAQ;;;;;;EAUd,UAAU,OAAO,eAAe,YAAY,sCAAsC,cAAc;EAuFhG,SAAS,iBAAiB,QAAQ;EAIlC,SAAS,cAAc,SAAS,0BAA0B,QAAQ;EAIlE,aACE,mBACA,SAAS,qBACT,SAAS,0BACR,QAAQ;EAMX,OAAO,MAAM,YAAY,MAAM,gBAAgB,UAAU,4BAA4B;EAMrF,QAAQ,OAAO,eAAe,YAAY,sCAAsC,QAAQ;;iBAS1E,qBAAqB,gBAAgB,gCACnD,SAAS,sBAAsB,WAC9B,eAAe;;;KC5SN;EACV;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;;;;iBCcc,yBAAyB,QAAQ;;;KCvBrC,2BAA2B;;KAG3B;EACV;EACA;;;iBAwBc,qBAAqB,QAAQ,WAAW,MAAM;;;;;;;iBA+B9C,8BACd,SAAS,uBACT,QAAQ,uBACP;;iBAYa,qBAAqB,SAAS,uBAAuB;;;;;;;;;;;;;;;cChExD,oBAAoB,QAAQ,OAAO,mBAAmB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,16 @@ type ProxyResult = {
|
|
|
18
18
|
headers: Headers;
|
|
19
19
|
stream(): ReadableStream<Uint8Array>;
|
|
20
20
|
};
|
|
21
|
+
type SitemapProxyOptions = {
|
|
22
|
+
/** chunk source as received from the query string; core decides whether the source/page pair is valid */
|
|
23
|
+
source?: string | undefined;
|
|
24
|
+
/** chunk page as received from the query string */
|
|
25
|
+
page?: string | undefined;
|
|
26
|
+
/** the incoming request's Accept-Encoding, so stored gzip bytes pass through untouched */
|
|
27
|
+
acceptEncoding?: string | undefined;
|
|
28
|
+
/** the incoming request's If-None-Match, so core can answer 304 */
|
|
29
|
+
ifNoneMatch?: string | undefined;
|
|
30
|
+
};
|
|
21
31
|
//#endregion
|
|
22
32
|
//#region src/types.d.ts
|
|
23
33
|
type OperationKind = 'query' | 'mutation' | 'subscription';
|
|
@@ -223,6 +233,7 @@ declare class ContelloClient<TSchema extends Schema | undefined = undefined> {
|
|
|
223
233
|
subscribe<TData>(query: string, variables?: Record<string, unknown> | undefined): AsyncIterable<TData>;
|
|
224
234
|
download(fileId: string): Promise<DownloadResult>;
|
|
225
235
|
proxyHls(path: string, signal?: AbortSignal | undefined): Promise<ProxyResult>;
|
|
236
|
+
proxySitemap(sitemapId: string, options: SitemapProxyOptions, signal?: AbortSignal | undefined): Promise<ProxyResult>;
|
|
226
237
|
upload(data: UploadData, meta: UploadMetadata, options?: UploadOptions | undefined): Promise<string>;
|
|
227
238
|
execute<TData>(query: string, variables?: Record<string, unknown> | undefined): Promise<TData>;
|
|
228
239
|
}
|
|
@@ -280,5 +291,5 @@ declare function readSourceMutationId(binding: SourceMutationBinding, result: un
|
|
|
280
291
|
*/
|
|
281
292
|
declare const BUILT_IN_MUTATIONS: Partial<Record<SourceCardinality, SourceMutations>>;
|
|
282
293
|
//#endregion
|
|
283
|
-
export { BUILT_IN_MUTATIONS, type ConnectionContext, type ConnectionEvents, ContelloClient, type ContelloClientOptions, type DownloadResult, type HttpAgentOptions, type LocalDate, type LocalDateTime, type OperationDef, type OperationKind, type OperationMap, type ProxyResult, type Rpc, type Schema, type SourceAccessors, type SourceCardinality, type SourceDef, type SourceMap, type SourceMutationArgument, type SourceMutationBinding, type SourceMutationKind, type SourceMutationResult, type SourceMutationValues, type SourceMutations, type SourceWrites, type UploadData, type UploadMetadata, type UploadOptions, createContelloClient, createSourceMutation, createSourceMutationVariables, createSourceSubscription, readSourceMutationId };
|
|
294
|
+
export { BUILT_IN_MUTATIONS, type ConnectionContext, type ConnectionEvents, ContelloClient, type ContelloClientOptions, type DownloadResult, type HttpAgentOptions, type LocalDate, type LocalDateTime, type OperationDef, type OperationKind, type OperationMap, type ProxyResult, type Rpc, type Schema, type SitemapProxyOptions, type SourceAccessors, type SourceCardinality, type SourceDef, type SourceMap, type SourceMutationArgument, type SourceMutationBinding, type SourceMutationKind, type SourceMutationResult, type SourceMutationValues, type SourceMutations, type SourceWrites, type UploadData, type UploadMetadata, type UploadOptions, createContelloClient, createSourceMutation, createSourceMutationVariables, createSourceSubscription, readSourceMutationId };
|
|
284
295
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/http.ts","../src/types.ts","../src/upload.ts","../src/client.ts","../src/scalars.ts","../src/source-subscription.ts","../src/source-mutation.ts","../src/built-in-mutations.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/http.ts","../src/types.ts","../src/upload.ts","../src/client.ts","../src/scalars.ts","../src/source-subscription.ts","../src/source-mutation.ts","../src/built-in-mutations.ts"],"mappings":";;;KAkCY;EACV;EACA;EACA;EACA;;KAcU;EACV;EACA;EACA,SAAS,QAAQ;EACjB,UAAU,eAAe;;KAiCf;EACV;EACA,SAAS;EACT,UAAU,eAAe;;KAqBf;;EAEV;;EAEA;;EAEA;;EAEA;;;;KCzHU;KAEA,aACV,mBACA,aAAa,yBACb,cAAc,gBAAgB;EAE9B;EACA,MAAM;;EAEN,WAAW;;EAEX,cAAc;;KAGJ,eAAe,eAAe;KAE9B,YAAY,UAAU,gBAAgB,YAAY;KAClD,eAAe,UAAU,gBAAgB,YAAY;KAErD,UAAU,UAAU,gBAAgB,mCAC5C,eAAe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AAmB"}
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,8 @@ const FORWARDED_PROXY_HEADERS = /* @__PURE__ */ new Set([
|
|
|
14
14
|
"etag",
|
|
15
15
|
"last-modified",
|
|
16
16
|
"expires",
|
|
17
|
-
"age"
|
|
17
|
+
"age",
|
|
18
|
+
"vary"
|
|
18
19
|
]);
|
|
19
20
|
function assertSafeSegment(segment, kind) {
|
|
20
21
|
if (segment === "." || segment === ".." || !SAFE_SEGMENT.test(segment)) throw new Error(`invalid ${kind}`);
|
|
@@ -58,6 +59,36 @@ async function proxyHls(agent, url, token, path, signal) {
|
|
|
58
59
|
signal: signal ?? null
|
|
59
60
|
}), signal);
|
|
60
61
|
}
|
|
62
|
+
async function proxySitemap(agent, url, token, projectRef, sitemapId, options, signal) {
|
|
63
|
+
assertSafeSegment(projectRef, "project ref");
|
|
64
|
+
assertSafeSegment(sitemapId, "sitemap id");
|
|
65
|
+
const search = new URLSearchParams();
|
|
66
|
+
if (options.source !== void 0) search.set("source", options.source);
|
|
67
|
+
if (options.page !== void 0) search.set("page", options.page);
|
|
68
|
+
const query = search.size > 0 ? `?${search}` : "";
|
|
69
|
+
const headers = { token };
|
|
70
|
+
if (options.acceptEncoding) headers["accept-encoding"] = options.acceptEncoding;
|
|
71
|
+
if (options.ifNoneMatch) headers["if-none-match"] = options.ifNoneMatch;
|
|
72
|
+
const response = await request(`${url}/api/v1/projects/${projectRef}/sitemaps/${sitemapId}${query}`, {
|
|
73
|
+
headers,
|
|
74
|
+
dispatcher: agent,
|
|
75
|
+
signal: signal ?? null
|
|
76
|
+
});
|
|
77
|
+
const result = buildProxyResult(response, signal);
|
|
78
|
+
if (response.statusCode === 304) {
|
|
79
|
+
safeDestroyBody(response.body);
|
|
80
|
+
return {
|
|
81
|
+
...result,
|
|
82
|
+
stream: emptyStream
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
function emptyStream() {
|
|
88
|
+
return new ReadableStream({ start(controller) {
|
|
89
|
+
controller.close();
|
|
90
|
+
} });
|
|
91
|
+
}
|
|
61
92
|
function buildProxyResult(response, signal) {
|
|
62
93
|
const headers = new Headers();
|
|
63
94
|
for (const [key, value] of Object.entries(response.headers)) {
|
|
@@ -801,6 +832,9 @@ var ContelloClient = class {
|
|
|
801
832
|
proxyHls(path, signal) {
|
|
802
833
|
return wrap("@contello/client:proxyHls", () => proxyHls(this._agent, this._url, this._token, path, signal));
|
|
803
834
|
}
|
|
835
|
+
proxySitemap(sitemapId, options, signal) {
|
|
836
|
+
return wrap("@contello/client:proxySitemap", () => proxySitemap(this._agent, this._url, this._token, this._project, sitemapId, options, signal));
|
|
837
|
+
}
|
|
804
838
|
upload(data, meta, options) {
|
|
805
839
|
return wrap("@contello/client:upload", () => upload(this._url, this._project, this._token, data, meta, options));
|
|
806
840
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["undiciRequest","cache","createSelection","uploadAsset"],"sources":["../src/http.ts","../src/ping.ts","../src/pool.ts","../src/telemetry.ts","../src/scalars.ts","../src/transform-variables.ts","../src/rpc.ts","../src/source-mutation.ts","../src/source-subscription.ts","../src/sources.ts","../src/transform-response.ts","../src/upload.ts","../src/client.ts","../src/built-in-mutations.ts"],"sourcesContent":["import { Agent, type Dispatcher, request as undiciRequest } from 'undici';\n\nconst SAFE_SEGMENT = /^[A-Za-z0-9._-]+$/;\n\nconst FORWARDED_PROXY_HEADERS = new Set([\n 'content-type',\n 'content-length',\n 'content-range',\n 'content-encoding',\n 'accept-ranges',\n 'cache-control',\n 'etag',\n 'last-modified',\n 'expires',\n 'age',\n]);\n\nfunction assertSafeSegment(segment: string, kind: string): void {\n if (segment === '.' || segment === '..' || !SAFE_SEGMENT.test(segment)) {\n throw new Error(`invalid ${kind}`);\n }\n}\n\nfunction assertSafeAssetPath(path: string, kind: string): void {\n if (path === '') {\n throw new Error(`invalid ${kind}`);\n }\n\n for (const segment of path.split('/')) {\n assertSafeSegment(segment, kind);\n }\n}\n\nexport type HttpAgentOptions = {\n pipelining?: number | undefined;\n allowH2?: boolean | undefined;\n maxConcurrentStreams?: number | undefined;\n keepAliveTimeout?: number | undefined;\n};\n\nexport function createHttpAgent(options?: HttpAgentOptions | undefined): Agent {\n return new Agent({\n pipelining: options?.pipelining ?? 10,\n allowH2: options?.allowH2 ?? true,\n maxConcurrentStreams: options?.maxConcurrentStreams ?? 128,\n keepAliveTimeout: options?.keepAliveTimeout ?? 60_000,\n autoSelectFamily: true,\n autoSelectFamilyAttemptTimeout: 25,\n });\n}\n\nexport type DownloadResult = {\n mimeType: string;\n size: number;\n bytes(): Promise<Uint8Array>;\n stream(): ReadableStream<Uint8Array>;\n};\n\nexport async function downloadFile(\n agent: Dispatcher,\n url: string,\n token: string,\n fileId: string,\n): Promise<DownloadResult> {\n assertSafeSegment(fileId, 'file id');\n\n const response = await undiciRequest(`${url}/api/v1/assets/files/${fileId}`, {\n headers: { token },\n dispatcher: agent,\n });\n\n if (response.statusCode < 200 || response.statusCode >= 300) {\n safeDestroyBody(response.body);\n\n throw new Error(`download failed: ${response.statusCode}`);\n }\n\n const mimeType = firstHeader(response.headers, 'content-type') ?? 'application/octet-stream';\n const size = Number(firstHeader(response.headers, 'content-length') ?? 0);\n\n return {\n mimeType,\n size,\n bytes: async () => new Uint8Array(await response.body.arrayBuffer()),\n stream: () => toWebStream(response.body),\n };\n}\n\nexport type ProxyResult = {\n status: number;\n headers: Headers;\n stream(): ReadableStream<Uint8Array>;\n};\n\nexport async function proxyHls(\n agent: Dispatcher,\n url: string,\n token: string,\n path: string,\n signal?: AbortSignal | undefined,\n): Promise<ProxyResult> {\n assertSafeAssetPath(path, 'hls path');\n\n const response = await undiciRequest(`${url}/api/v1/assets/video/hls/${path}`, {\n headers: { token },\n dispatcher: agent,\n signal: signal ?? null,\n });\n\n return buildProxyResult(response, signal);\n}\n\nfunction buildProxyResult(response: Dispatcher.ResponseData, signal: AbortSignal | undefined): ProxyResult {\n const headers = new Headers();\n\n for (const [key, value] of Object.entries(response.headers)) {\n if (!FORWARDED_PROXY_HEADERS.has(key.toLowerCase())) {\n continue;\n }\n\n if (Array.isArray(value)) {\n for (const v of value) headers.append(key, v);\n } else if (value !== null && value !== undefined) {\n headers.set(key, value);\n }\n }\n\n return {\n status: response.statusCode,\n headers,\n stream: () => toWebStream(response.body, signal),\n };\n}\n\nfunction firstHeader(headers: Record<string, string | string[] | undefined>, key: string): string | undefined {\n const v = headers[key];\n\n return Array.isArray(v) ? v[0] : v;\n}\n\nfunction safeDestroyBody(body: Dispatcher.ResponseData['body']): void {\n try {\n body.on('error', () => {});\n body.destroy();\n } catch {\n // already destroyed\n }\n}\n\nfunction toWebStream(\n body: Dispatcher.ResponseData['body'],\n signal?: AbortSignal | undefined,\n): ReadableStream<Uint8Array> {\n let closed = false;\n\n const cleanup = () => {\n if (closed) {\n return;\n }\n\n closed = true;\n signal?.removeEventListener('abort', cleanup);\n safeDestroyBody(body);\n };\n\n return new ReadableStream<Uint8Array>({\n start(controller) {\n signal?.addEventListener('abort', cleanup);\n\n body.on('data', (chunk: Uint8Array) => {\n if (closed || signal?.aborted) {\n return;\n }\n\n try {\n controller.enqueue(chunk);\n } catch {\n cleanup();\n }\n });\n\n body.on('end', () => {\n if (closed || signal?.aborted) {\n return;\n }\n\n closed = true;\n signal?.removeEventListener('abort', cleanup);\n\n try {\n controller.close();\n } catch {\n // already closed\n }\n });\n\n body.on('error', (err: Error) => {\n cleanup();\n\n if (err.name === 'AbortError') {\n try {\n controller.close();\n } catch {\n // already closed\n }\n\n return;\n }\n\n try {\n controller.error(err);\n } catch {\n // already closed\n }\n });\n },\n cancel() {\n cleanup();\n },\n });\n}\n","const PING_QUERY = `query ContelloPing { contelloPing { response } }`;\n\ntype PingResult = { contelloPing: { response: string } };\n\nexport async function ping(execute: <T>(query: string) => Promise<T>): Promise<void> {\n const data = await execute<PingResult>(PING_QUERY);\n\n if (data.contelloPing.response !== 'pong') {\n throw new Error(`unexpected ping response: ${data.contelloPing.response}`);\n }\n}\n","import type { Client } from 'graphql-ws';\n\n// how long connect() waits for an individual client's first `connected` event\n// before resolving optimistically. without this a single unreachable endpoint\n// (graphql-ws retries forever) would make init() hang indefinitely; the client\n// keeps retrying in the background and get() routes around it via failover.\nconst DEFAULT_CONNECT_TIMEOUT = 10_000;\n\nexport class ConnectionPool {\n private _clients: Client[] = [];\n private _connected: boolean[] = [];\n private _currentIndex = 0;\n\n constructor(\n private _createClient: (id: string) => Client,\n private _poolSize: number,\n private _connectTimeout = DEFAULT_CONNECT_TIMEOUT,\n ) {}\n\n async connect() {\n const ready: Promise<void>[] = [];\n\n for (let i = 0; i < this._poolSize; i++) {\n const index = i;\n const client = this._createClient(String(i + 1));\n\n this._clients.push(client);\n this._connected.push(false);\n\n client.on('connected', () => {\n this._connected[index] = true;\n });\n client.on('closed', () => {\n this._connected[index] = false;\n });\n\n ready.push(\n new Promise<void>((resolve) => {\n let settled = false;\n\n const done = () => {\n if (settled) {\n return;\n }\n\n settled = true;\n offConnected();\n clearTimeout(timer);\n resolve();\n };\n\n const offConnected = client.on('connected', done);\n const timer = setTimeout(done, this._connectTimeout);\n\n timer.unref?.();\n }),\n );\n }\n\n await Promise.all(ready);\n }\n\n get() {\n if (this._clients.length === 0) {\n throw new Error('@contello/client: connection pool is empty — call client.init() first');\n }\n\n // prefer a currently-connected client, scanning round-robin from the cursor\n for (let i = 0; i < this._clients.length; i++) {\n const index = (this._currentIndex + i) % this._clients.length;\n\n if (this._connected[index] === true) {\n this._currentIndex = (index + 1) % this._clients.length;\n\n return this._clients[index]!;\n }\n }\n\n // none known-connected — fall back to plain round-robin; graphql-ws buffers\n // the operation until the chosen socket reconnects\n const client = this._clients[this._currentIndex]!;\n\n this._currentIndex = (this._currentIndex + 1) % this._clients.length;\n\n return client;\n }\n\n async disconnect() {\n const closed = this._clients.map(\n (client) =>\n new Promise<void>((resolve) => {\n const unsubscribe = client.on('closed', () => {\n unsubscribe();\n resolve();\n });\n\n client.dispose();\n }),\n );\n\n this._clients = [];\n this._connected = [];\n this._currentIndex = 0;\n\n await Promise.all(closed);\n }\n}\n","import { createOperationTelemetry } from '@contello/opentelemetry';\n\nexport const { wrap } = createOperationTelemetry('@contello/client');\n","export type LocalDateTime = {\n year: number;\n month: number;\n day: number;\n hour: number;\n minute: number;\n second: number;\n};\n\nexport type LocalDate = {\n year: number;\n month: number;\n day: number;\n};\n\nconst LOCAL_DATE_TIME_KEYS = ['year', 'month', 'day', 'hour', 'minute', 'second'] as const;\nconst LOCAL_DATE_KEYS = ['year', 'month', 'day'] as const;\n\nconst DATE_TIME_REGEX = /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})/;\nconst DATE_REGEX = /^(\\d{4})-(\\d{2})-(\\d{2})/;\n\nfunction pad2(n: number): string {\n return n.toString().padStart(2, '0');\n}\n\nfunction pad4(n: number): string {\n return n.toString().padStart(4, '0');\n}\n\nfunction hasExactKeys(value: object, keys: readonly string[]): boolean {\n const ownKeys = Object.keys(value);\n\n if (ownKeys.length !== keys.length) {\n return false;\n }\n\n for (const key of keys) {\n if (!Object.prototype.hasOwnProperty.call(value, key)) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction allNumbers(value: Record<string, unknown>, keys: readonly string[]): boolean {\n for (const key of keys) {\n if (typeof value[key] !== 'number') {\n return false;\n }\n }\n\n return true;\n}\n\nexport function isLocalDateTime(value: unknown): value is LocalDateTime {\n return (\n !!value &&\n typeof value === 'object' &&\n !Array.isArray(value) &&\n hasExactKeys(value, LOCAL_DATE_TIME_KEYS) &&\n allNumbers(value as Record<string, unknown>, LOCAL_DATE_TIME_KEYS)\n );\n}\n\nexport function isLocalDate(value: unknown): value is LocalDate {\n return (\n !!value &&\n typeof value === 'object' &&\n !Array.isArray(value) &&\n hasExactKeys(value, LOCAL_DATE_KEYS) &&\n allNumbers(value as Record<string, unknown>, LOCAL_DATE_KEYS)\n );\n}\n\nexport function decodeLocalDateTime(value: string): LocalDateTime {\n const match = DATE_TIME_REGEX.exec(value);\n\n if (!match) {\n throw new Error(`@contello/client: cannot decode LocalDateTime from \"${value}\"`);\n }\n\n return {\n year: Number(match[1]),\n month: Number(match[2]),\n day: Number(match[3]),\n hour: Number(match[4]),\n minute: Number(match[5]),\n second: Number(match[6]),\n };\n}\n\nexport function decodeLocalDate(value: string): LocalDate {\n const match = DATE_REGEX.exec(value);\n\n if (!match) {\n throw new Error(`@contello/client: cannot decode LocalDate from \"${value}\"`);\n }\n\n return {\n year: Number(match[1]),\n month: Number(match[2]),\n day: Number(match[3]),\n };\n}\n\nexport function encodeLocalDateTime(value: LocalDateTime): string {\n return (\n `${pad4(value.year)}-${pad2(value.month)}-${pad2(value.day)}` +\n `T${pad2(value.hour)}:${pad2(value.minute)}:${pad2(value.second)}Z`\n );\n}\n\nexport function encodeLocalDate(value: LocalDate): string {\n return `${pad4(value.year)}-${pad2(value.month)}-${pad2(value.day)}T00:00:00Z`;\n}\n","import { encodeLocalDate, encodeLocalDateTime, isLocalDate, isLocalDateTime } from './scalars';\n\n/**\n * encodes outgoing variables: LocalDateTime / LocalDate POJOs become wire strings.\n * detection is by shape — generated input types use the struct types, so consumers\n * pass structs in the right places, and stray objects with the same shape would be\n * an extremely unusual coincidence.\n */\nexport function transformVariables<T>(value: T): T {\n if (value === null || value === undefined) {\n return value;\n }\n\n if (Array.isArray(value)) {\n return value.map((item) => transformVariables(item)) as unknown as T;\n }\n\n if (typeof value !== 'object') {\n return value;\n }\n\n if (isLocalDateTime(value)) {\n return encodeLocalDateTime(value) as unknown as T;\n }\n\n if (isLocalDate(value)) {\n return encodeLocalDate(value) as unknown as T;\n }\n\n const obj = value as Record<string, unknown>;\n const out: Record<string, unknown> = {};\n\n for (const [key, val] of Object.entries(obj)) {\n out[key] = transformVariables(val);\n }\n\n return out as unknown as T;\n}\n","import { graphqlOperationAttributes } from '@contello/opentelemetry';\nimport { firstAsync } from '@entwico/dash/async';\nimport { wrap } from './telemetry';\nimport { transformVariables } from './transform-variables';\nimport type { OperationMap, Rpc } from './types';\n\ntype Subscribe = <TData>(query: string, variables?: Record<string, unknown> | undefined) => AsyncIterable<TData>;\n\nexport function buildRpc<T extends OperationMap>(operations: T, subscribe: Subscribe): Rpc<T> {\n const rpc = {} as Record<string, (...args: any[]) => any>;\n\n for (const [name, def] of Object.entries(operations)) {\n rpc[name] = def.kind === 'subscription' ? (variables?: Record<string, unknown>) =>\n subscribe<unknown>(def.document, transformVariables(variables)) : (variables?: Record<string, unknown>) => {\n const vars = transformVariables(variables);\n\n return wrap(\n `rpc:${name}`,\n () => firstAsync(subscribe<unknown>(def.document, vars)),\n graphqlOperationAttributes(def.document, vars),\n );\n };\n }\n\n return rpc as Rpc<T>;\n}\n","import { transformVariables } from './transform-variables';\nimport type { SourceDef, SourceMutationBinding, SourceMutations } from './types';\n\nexport type SourceMutationKind = keyof SourceMutations;\n\n/** What a write takes: the caller's input, and the id for a delete. */\nexport type SourceMutationValues = {\n input?: unknown;\n id?: string | undefined;\n};\n\nconst cache = new WeakMap<SourceDef, Partial<Record<SourceMutationKind, string>>>();\n\n/**\n * A create/update answers with the entity itself, so it selects the source's own fragment — the\n * write comes back in the same shape a read does and needs no follow-up fetch. A delete answers\n * with an id, either wrapped in a response object or, for routes, as a bare scalar.\n */\nfunction createSelection(source: SourceDef, binding: SourceMutationBinding): string {\n const declarations = binding.arguments.map((argument) => `$${argument.name}: ${argument.type}`).join(', ');\n const args = binding.arguments.map((argument) => `${argument.name}: $${argument.name}`).join(', ');\n const selection = { entity: ` { ...${source.fragment} }`, idObject: ' { id }', idScalar: '' }[binding.result];\n const operation = `mutation(${declarations}) { result: ${binding.field}(${args})${selection} }`;\n\n return binding.result === 'entity' ? `${source.document}\\n${operation}` : operation;\n}\n\nexport function getSourceMutation(source: SourceDef, kind: SourceMutationKind): SourceMutationBinding | undefined {\n return source.mutations?.[kind];\n}\n\n/** The mutation document for one write operation of a source. Cached per source + kind. */\nexport function createSourceMutation(source: SourceDef, kind: SourceMutationKind): string {\n const binding = getSourceMutation(source, kind);\n\n if (!binding) {\n throw new Error(\n `@contello/client: source \"${source.__model}\" has no ${kind} mutation — ` +\n `the schema exposes none for this model`,\n );\n }\n\n const cached = cache.get(source);\n\n if (cached?.[kind] !== undefined) {\n return cached[kind];\n }\n\n const doc = createSelection(source, binding);\n const entry = cached ?? {};\n\n entry[kind] = doc;\n cache.set(source, entry);\n\n return doc;\n}\n\n/**\n * Variables for a write: one per bound argument, the input nested under the envelope field when\n * the argument is a one-field wrapper, and everything encoded on the way out (LocalDate /\n * LocalDateTime structs become wire strings) — every caller goes through here, so no write path\n * can skip the encoding.\n */\nexport function createSourceMutationVariables(\n binding: SourceMutationBinding,\n values: SourceMutationValues,\n): Record<string, unknown> {\n const variables: Record<string, unknown> = {};\n\n for (const argument of binding.arguments) {\n variables[argument.name] =\n argument.from === 'id' ? values.id : (argument.envelope ? { [argument.envelope]: values.input } : values.input);\n }\n\n return transformVariables(variables);\n}\n\n/** Pulls the id out of whatever shape the mutation answered with. */\nexport function readSourceMutationId(binding: SourceMutationBinding, result: unknown): string {\n return binding.result === 'idScalar' ? (result as string) : (result as { id: string }).id;\n}\n","import type { SourceDef } from './types';\n\nconst cache = new WeakMap<SourceDef, string>();\n\nfunction createSelection(source: SourceDef): string {\n const spread = `{ ...${source.fragment} }`;\n\n switch (source.__cardinality) {\n case 'singleton': {\n return `subscription { source: ${source.subscription} ${spread} }`;\n }\n case 'entity': {\n return `subscription($ids: [ID!]) { source: ${source.subscription}(request: { filter: { ids: $ids } }) ${spread} }`;\n }\n case 'route': {\n return `subscription($ids: [ID!], $paths: [String!]) { source: ${source.subscription}(request: { ids: $ids, paths: $paths }) ${spread} }`;\n }\n case 'asset': {\n return `subscription($ids: [ID!]) { source: ${source.subscription}(filter: { ids: $ids }) ${spread} }`;\n }\n case 'i18nMessage': {\n return `subscription($collection: String!, $ids: [ID!]) { source: ${source.subscription}(collectionReferenceName: $collection, ids: $ids) ${spread} }`;\n }\n }\n}\n\nexport function createSourceSubscription(source: SourceDef): string {\n const cached = cache.get(source);\n\n if (cached !== undefined) {\n return cached;\n }\n\n const doc = `${source.document}\\n${createSelection(source)}`;\n\n cache.set(source, doc);\n\n return doc;\n}\n","import { graphqlOperationAttributes } from '@contello/opentelemetry';\nimport { concatAsync, firstAsync, mapAsync } from '@entwico/dash/async';\nimport {\n type SourceMutationKind,\n createSourceMutation,\n createSourceMutationVariables,\n readSourceMutationId,\n} from './source-mutation';\nimport { createSourceSubscription } from './source-subscription';\nimport { wrap } from './telemetry';\nimport { transformVariables } from './transform-variables';\nimport type { SourceAccessors, SourceDef, SourceMap } from './types';\n\ntype Subscribe = <TData>(query: string, variables?: Record<string, unknown> | undefined) => AsyncIterable<TData>;\n\nconst WRITE_KINDS: SourceMutationKind[] = ['create', 'update', 'delete'];\n\nexport function createSources<TSources extends SourceMap>(\n sources: TSources,\n subscribe: Subscribe,\n): SourceAccessors<TSources> {\n const out = {} as Record<string, Record<string, (...args: any[]) => Promise<unknown>>>;\n\n for (const [name, source] of Object.entries(sources)) {\n const def = source as SourceDef;\n const doc = createSourceSubscription(def);\n const accessor = createSourceAccessor(name, def, doc, subscribe);\n\n if (accessor) {\n out[name] = { ...accessor, ...createSourceWriters(name, def, subscribe) };\n }\n }\n\n return out as SourceAccessors<TSources>;\n}\n\n/**\n * Write accessors for the mutations the generator bound to this source. A create/update answers\n * with the entity in the source's fragment shape, a delete with the id it removed. Nothing is\n * cached here — `@contello/store` collections take the same payload into their cache.\n */\nfunction createSourceWriters(\n name: string,\n def: SourceDef,\n subscribe: Subscribe,\n): Record<string, (input: unknown) => Promise<unknown>> {\n const out: Record<string, (input: unknown) => Promise<unknown>> = {};\n\n for (const kind of WRITE_KINDS) {\n const binding = def.mutations?.[kind];\n\n if (!binding) {\n continue;\n }\n\n const doc = createSourceMutation(def, kind);\n\n out[kind] = (input: unknown) => {\n // a delete is addressed by id: bindings that take a bare `id:` argument read it off the input\n const variables = createSourceMutationVariables(\n binding,\n kind === 'delete' ? { input, id: (input as { id: string }).id } : { input },\n );\n\n return wrap(\n `source:${name}:${kind}`,\n async () => {\n const response = await firstAsync(subscribe<{ result: unknown }>(doc, variables));\n\n if (response?.result === undefined || response.result === null) {\n throw new Error(`@contello/client: ${kind} on source \"${name}\" returned no entity`);\n }\n\n return kind === 'delete' ? readSourceMutationId(binding, response.result) : response.result;\n },\n graphqlOperationAttributes(doc, variables),\n );\n };\n }\n\n return out;\n}\n\nfunction createSourceAccessor(\n name: string,\n def: SourceDef,\n doc: string,\n subscribe: Subscribe,\n): { fetch: (...args: any[]) => Promise<unknown> } | undefined {\n switch (def.__cardinality) {\n case 'singleton': {\n return {\n fetch: () =>\n wrap(\n `source:${name}`,\n () => firstAsync(mapAsync(subscribe<{ source: unknown }>(doc), (r) => r.source)),\n graphqlOperationAttributes(doc),\n ),\n };\n }\n case 'entity': {\n return {\n fetch: (vars?: { ids?: string[] }) => {\n const variables = transformVariables({ ids: vars?.ids });\n\n return wrap(\n `source:${name}`,\n () => concatAsync(mapAsync(subscribe<{ source: unknown[] }>(doc, variables), (r) => r.source)),\n graphqlOperationAttributes(doc, variables),\n );\n },\n };\n }\n case 'route': {\n return {\n fetch: (vars?: { ids?: string[] | undefined; paths?: string[] | undefined } | undefined) => {\n const variables = transformVariables({ ids: vars?.ids, paths: vars?.paths });\n\n return wrap(\n `source:${name}`,\n () => concatAsync(mapAsync(subscribe<{ source: unknown[] }>(doc, variables), (r) => r.source)),\n graphqlOperationAttributes(doc, variables),\n );\n },\n };\n }\n case 'asset': {\n return {\n fetch: (vars?: { ids?: string[] | undefined } | undefined) => {\n const variables = transformVariables({ ids: vars?.ids });\n\n return wrap(\n `source:${name}`,\n () => concatAsync(mapAsync(subscribe<{ source: unknown[] }>(doc, variables), (r) => r.source)),\n graphqlOperationAttributes(doc, variables),\n );\n },\n };\n }\n case 'i18nMessage': {\n return {\n fetch: (vars: { collection: string; ids?: string[] | undefined }) => {\n const variables = transformVariables({ collection: vars.collection, ids: vars.ids });\n\n return wrap(\n `source:${name}`,\n () => concatAsync(mapAsync(subscribe<{ source: unknown[] }>(doc, variables), (r) => r.source)),\n graphqlOperationAttributes(doc, variables),\n );\n },\n };\n }\n }\n}\n","import { decodeLocalDate, decodeLocalDateTime } from './scalars';\n\nconst FLAT_PREFIX = '_flat_';\nconst LDT_PREFIX = '_ldt_';\nconst LD_PREFIX = '_ld_';\n\nconst MODEL_SUFFIXES = ['Entity', 'Component'];\n\nfunction decodeValue(value: unknown, decoder: (s: string) => unknown): unknown {\n if (value === null || value === undefined) {\n return value;\n }\n\n if (Array.isArray(value)) {\n return value.map((item) => decodeValue(item, decoder));\n }\n\n if (typeof value === 'string') {\n return decoder(value);\n }\n\n return value;\n}\n\ntype FlatRef = { _flatId?: string | undefined };\ntype FlatComponent = FlatRef & { __typename?: string | undefined };\n\nfunction deriveModel(typename: string): string | undefined {\n for (const suffix of MODEL_SUFFIXES) {\n if (typename.endsWith(suffix)) {\n const stripped = typename.slice(0, -suffix.length);\n\n return stripped.charAt(0).toLowerCase() + stripped.slice(1);\n }\n }\n\n return undefined;\n}\n\n/**\n * transforms a GraphQL response in a single depth-first pass:\n * - resolves `_flat_{field}` companions into nested component arrays (refs are\n * matched against the companion map by `_flatId`, at any nesting depth — the\n * companion lists the whole subtree, so one map serves every ref below it)\n * - injects `__model` on objects with entity/component `__typename`\n * - decodes managed scalar aliases (`_ldt_` / `_ld_`) into structured values\n *\n * a `seen` set guards against shared or cyclic references so every object is\n * visited exactly once.\n */\nexport function transformResponse<T>(data: T): T {\n transformNode(data, undefined, new WeakSet());\n\n return data;\n}\n\nfunction transformNode(\n value: unknown,\n flatMap: Map<string, FlatComponent> | undefined,\n seen: WeakSet<object>,\n): void {\n if (!value || typeof value !== 'object') {\n return;\n }\n\n if (seen.has(value)) {\n return;\n }\n\n seen.add(value);\n\n if (Array.isArray(value)) {\n for (const item of value) {\n transformNode(item, flatMap, seen);\n }\n\n return;\n }\n\n const obj = value as Record<string, unknown>;\n\n // inject __model from __typename\n const typename = obj['__typename'];\n\n if (typeof typename === 'string') {\n const model = deriveModel(typename);\n\n if (model) {\n obj['__model'] = model;\n }\n }\n\n // collect `_flat_*` companions into this scope's resolution map, extending any\n // map inherited from an ancestor so refs nested below resolve against the same\n // companion set\n let ownMap: Map<string, FlatComponent> | undefined;\n\n for (const key of Object.keys(obj)) {\n if (!key.startsWith(FLAT_PREFIX)) {\n continue;\n }\n\n const flatArray = obj[key] as FlatComponent[] | undefined;\n\n delete obj[key];\n\n if (!flatArray) {\n continue;\n }\n\n if (!ownMap) {\n ownMap = flatMap ? new Map(flatMap) : new Map();\n }\n\n for (const component of flatArray) {\n if (component._flatId) {\n ownMap.set(component._flatId, component);\n }\n }\n }\n\n // decode scalar aliases, resolve ref arrays, and recurse — one pass over keys.\n // refs resolve against this object's own companion map if it had `_flat_*`\n // siblings, otherwise against the inherited ancestor map\n const resolveMap = ownMap ?? flatMap;\n\n for (const key of Object.keys(obj)) {\n if (key.startsWith(LDT_PREFIX)) {\n obj[key.slice(LDT_PREFIX.length)] = decodeValue(obj[key], decodeLocalDateTime);\n delete obj[key];\n\n continue;\n }\n\n if (key.startsWith(LD_PREFIX)) {\n obj[key.slice(LD_PREFIX.length)] = decodeValue(obj[key], decodeLocalDate);\n delete obj[key];\n\n continue;\n }\n\n const inner = obj[key];\n\n if (\n resolveMap &&\n Array.isArray(inner) &&\n inner.length > 0 &&\n (inner[0] as FlatRef | undefined)?._flatId !== undefined\n ) {\n obj[key] = resolveRefs(inner as FlatRef[], resolveMap);\n }\n\n transformNode(obj[key], resolveMap, seen);\n }\n}\n\nfunction resolveRefs(refs: readonly FlatRef[], flatMap: Map<string, FlatComponent>): FlatComponent[] {\n const resolved: FlatComponent[] = [];\n\n for (const ref of refs) {\n if (!ref._flatId) {\n continue;\n }\n\n const component = flatMap.get(ref._flatId);\n\n if (component) {\n resolved.push(component);\n }\n }\n\n return resolved;\n}\n","import type { ReadableStream as NodeReadableStream } from 'node:stream/web';\n\nexport type UploadMetadata = {\n name: string;\n mimeType?: string | undefined;\n size?: number | undefined;\n annotations?: { key: string; value: string }[] | undefined;\n collectionRefs?: string[] | undefined;\n};\n\nexport type UploadData = Uint8Array | NodeReadableStream<Uint8Array> | ReadableStream<Uint8Array>;\n\ntype InitFrame = { type: 'init'; metadata: UploadMetadata & { projectRef: string }; token: string };\ntype ServerMessage = { type: 'ack' } | { type: 'progress'; bytesReceived: number } | { type: 'done'; id: string };\n\nexport type UploadOptions = {\n chunkSize?: number | undefined;\n abort?: AbortSignal | undefined;\n};\n\nconst DEFAULT_CHUNK_SIZE = 4 * 1024 * 1024;\n\nfunction isUint8Array(data: UploadData): data is Uint8Array {\n return data instanceof Uint8Array;\n}\n\nexport function upload(\n url: string,\n project: string,\n token: string,\n data: UploadData,\n meta: UploadMetadata,\n options?: UploadOptions | undefined,\n): Promise<string> {\n const chunkSize = options?.chunkSize ?? DEFAULT_CHUNK_SIZE;\n const wsUrl = `${url.replace(/^http/i, 'ws')}/api/v1/assets/ws`;\n\n const size = isUint8Array(data) ? data.length : meta.size;\n\n return new Promise<string>((resolve, reject) => {\n const ws = new WebSocket(wsUrl, 'contello-file-upload-v1');\n\n let done = false;\n\n const cleanup = () => {\n options?.abort?.removeEventListener('abort', abortHandler);\n };\n\n const abortHandler = () => {\n if (done) {\n return;\n }\n\n ws.close();\n reject(new Error('upload aborted'));\n };\n\n options?.abort?.addEventListener('abort', abortHandler);\n\n function sendBuffer(buf: Uint8Array) {\n let offset = 0;\n\n while (offset < buf.length) {\n const chunk = buf.subarray(offset, offset + chunkSize);\n\n ws.send(chunk);\n offset += chunk.length;\n }\n\n ws.send(JSON.stringify({ type: 'done' }));\n }\n\n const MAX_BUFFER_SIZE = 8 * 1024 * 1024;\n\n function waitForBufferedDrain(): Promise<void> {\n return new Promise((resolveDrain, rejectDrain) => {\n const check = () => {\n if (options?.abort?.aborted) {\n rejectDrain(new Error('upload aborted'));\n\n return;\n }\n\n if (ws.bufferedAmount <= MAX_BUFFER_SIZE) {\n resolveDrain();\n\n return;\n }\n\n setTimeout(check, 50);\n };\n\n check();\n });\n }\n\n async function sendStream(stream: UploadData) {\n const reader = (stream as ReadableStream<Uint8Array>).getReader();\n\n try {\n while (true) {\n const { done: streamDone, value } = await reader.read();\n\n if (streamDone) break;\n\n await waitForBufferedDrain();\n ws.send(value);\n }\n\n ws.send(JSON.stringify({ type: 'done' }));\n } catch (error) {\n reject(error);\n ws.close();\n }\n }\n\n ws.addEventListener('open', () => {\n const initFrame: InitFrame = {\n type: 'init',\n metadata: { ...meta, ...(size !== undefined && { size }), projectRef: project },\n token,\n };\n\n ws.send(JSON.stringify(initFrame));\n });\n\n ws.addEventListener('message', (event) => {\n const message: ServerMessage = JSON.parse(String(event.data));\n\n if (message.type === 'ack') {\n if (isUint8Array(data)) {\n sendBuffer(data);\n } else {\n sendStream(data);\n }\n\n return;\n }\n\n if (message.type === 'done') {\n done = true;\n cleanup();\n ws.close();\n resolve(message.id);\n }\n });\n\n ws.addEventListener('error', () => {\n cleanup();\n reject(new Error('upload websocket error'));\n });\n\n ws.addEventListener('close', () => {\n cleanup();\n\n if (!done) {\n reject(new Error('connection closed before upload completed'));\n }\n });\n });\n}\n","import { graphqlOperationAttributes, injectTraceContext } from '@contello/opentelemetry';\nimport { exponentialBackoff, firstAsync } from '@entwico/dash/async';\nimport { createClient } from 'graphql-ws';\nimport type { Agent } from 'undici';\n\nimport {\n type DownloadResult,\n type HttpAgentOptions,\n type ProxyResult,\n createHttpAgent,\n downloadFile,\n proxyHls,\n} from './http';\nimport { ping } from './ping';\nimport { ConnectionPool } from './pool';\nimport { buildRpc } from './rpc';\nimport { createSources } from './sources';\nimport { wrap } from './telemetry';\nimport { transformResponse } from './transform-response';\nimport type { Rpc, Schema, SourceAccessors } from './types';\nimport { type UploadData, type UploadMetadata, type UploadOptions, upload as uploadAsset } from './upload';\n\nexport type ConnectionContext = {\n connectionId: string;\n websocketUrl: string;\n};\n\nexport type ConnectionEvents = {\n onConnected?: ((context: ConnectionContext) => void) | undefined;\n onConnecting?: ((context: ConnectionContext) => void) | undefined;\n onClosed?: ((context: ConnectionContext) => void) | undefined;\n onError?: ((context: ConnectionContext, error: unknown) => void) | undefined;\n};\n\nexport type ContelloClientOptions<TSchema extends Schema | undefined = undefined> = {\n url: string;\n project: string;\n token: string;\n schema?: TSchema | undefined;\n connections?: number | undefined;\n http?: HttpAgentOptions | undefined;\n onConnected?: (() => void) | undefined;\n onReconnecting?: (() => void) | undefined;\n onError?: ((error: unknown) => void) | undefined;\n connectionEvents?: ConnectionEvents | undefined;\n};\n\ntype PoolState = 'disconnected' | 'connected' | 'reconnecting';\n\nexport class ContelloClient<TSchema extends Schema | undefined = undefined> {\n private _pool: ConnectionPool;\n private _rpc: TSchema extends Schema<infer TOps, any, any> ? Rpc<TOps> : undefined;\n private _sources: TSchema extends Schema<any, infer TSources, any> ? SourceAccessors<TSources> : undefined;\n private _url: string;\n private _project: string;\n private _token: string;\n private _agent: Agent;\n\n constructor(options: ContelloClientOptions<TSchema>) {\n const { url, project, token, schema, connections = 1, connectionEvents } = options;\n\n this._url = url;\n this._project = project;\n this._token = token;\n this._agent = createHttpAgent(options.http);\n\n const websocketUrl = `${url}/graphql/projects/${project}`.replace(/^http/i, 'ws');\n\n let state: PoolState = 'disconnected';\n let connectedCount = 0;\n\n const onConnectionUp = () => {\n connectedCount++;\n\n if (connectedCount === connections && state !== 'connected') {\n state = 'connected';\n options.onConnected?.();\n }\n };\n\n const onConnectionDown = () => {\n if (connectedCount > 0) {\n connectedCount--;\n }\n\n if (state === 'connected') {\n state = 'reconnecting';\n options.onReconnecting?.();\n }\n };\n\n this._pool = new ConnectionPool((id: string) => {\n const context: ConnectionContext = Object.freeze({ connectionId: id, websocketUrl });\n\n return createClient({\n url: websocketUrl,\n connectionParams: { token },\n lazy: false,\n keepAlive: 30_000,\n retryAttempts: Infinity,\n retryWait: exponentialBackoff,\n shouldRetry: () => true,\n jsonMessageReplacer: (key, value) => {\n if (!key) {\n return injectTraceContext(value);\n }\n\n return value;\n },\n ...(options.onError && { onNonLazyError: (e) => options.onError!(e) }),\n on: {\n connected: () => {\n onConnectionUp();\n connectionEvents?.onConnected?.(context);\n },\n connecting: () => {\n connectionEvents?.onConnecting?.(context);\n },\n closed: () => {\n onConnectionDown();\n connectionEvents?.onClosed?.(context);\n },\n ...((options.onError || connectionEvents?.onError) && {\n error: (e) => {\n options.onError?.(e);\n connectionEvents?.onError?.(context, e);\n },\n }),\n },\n });\n }, connections);\n\n this._rpc = (\n schema?.operations ? buildRpc(schema.operations, (q, v) => this.subscribe(q, v)) : undefined\n ) as typeof this._rpc;\n\n this._sources = (\n schema?.sources ? createSources(schema.sources, (q, v) => this.subscribe(q, v)) : undefined\n ) as typeof this._sources;\n }\n\n get rpc(): TSchema extends Schema<infer TOps, any, any> ? Rpc<TOps> : never {\n if (!this._rpc) {\n throw new Error('@contello/client: .rpc accessed without a schema containing operations');\n }\n\n return this._rpc as any;\n }\n\n get sources(): TSchema extends Schema<any, infer TSources, any> ? SourceAccessors<TSources> : never {\n if (!this._sources) {\n throw new Error('@contello/client: .sources accessed without a schema containing sources');\n }\n\n return this._sources as any;\n }\n\n async init(): Promise<void> {\n await this._pool.connect();\n }\n\n async destroy(): Promise<void> {\n await this._pool.disconnect();\n await this._agent.close();\n }\n\n async ping(): Promise<void> {\n // excluded from telemetry to avoid noise\n return ping((query) => firstAsync(this.subscribe(query)));\n }\n\n /**\n * Open a subscription on the websocket. Each `[Symbol.asyncIterator]()` call (the implicit one\n * from `for await`, or via `rxjs.from(this)`) starts a fresh server subscription and tears it\n * down when the iterator is returned (`break`, error, or explicit stop).\n */\n subscribe<TData>(query: string, variables?: Record<string, unknown> | undefined): AsyncIterable<TData> {\n const pool = this._pool;\n\n return {\n [Symbol.asyncIterator](): AsyncIterator<TData> {\n const wsClient = pool.get();\n const queue: TData[] = [];\n let pending: { resolve: (r: IteratorResult<TData>) => void; reject: (e: unknown) => void } | undefined;\n let done = false;\n let error: unknown;\n\n const unsubscribe = wsClient.subscribe<TData>(\n { query, variables },\n {\n next(msg) {\n const value = transformResponse(msg.data);\n\n if (value === undefined || value === null) {\n return;\n }\n\n if (pending) {\n const p = pending;\n\n pending = undefined;\n p.resolve({ value: value as TData, done: false });\n } else {\n queue.push(value as TData);\n }\n },\n error(err) {\n done = true;\n error = err;\n\n if (pending) {\n const p = pending;\n\n pending = undefined;\n p.reject(err);\n }\n },\n complete() {\n done = true;\n\n if (pending) {\n const p = pending;\n\n pending = undefined;\n p.resolve({ value: undefined as unknown as TData, done: true });\n }\n },\n },\n );\n\n return {\n next(): Promise<IteratorResult<TData>> {\n if (queue.length > 0) {\n return Promise.resolve({ value: queue.shift()!, done: false });\n }\n\n if (error !== undefined) {\n return Promise.reject(error);\n }\n\n if (done) {\n return Promise.resolve({ value: undefined as unknown as TData, done: true });\n }\n\n return new Promise<IteratorResult<TData>>((resolve, reject) => {\n pending = { resolve, reject };\n });\n },\n return(): Promise<IteratorResult<TData>> {\n unsubscribe();\n\n return Promise.resolve({ value: undefined as unknown as TData, done: true });\n },\n throw(err): Promise<IteratorResult<TData>> {\n unsubscribe();\n\n return Promise.reject(err);\n },\n };\n },\n };\n }\n\n download(fileId: string): Promise<DownloadResult> {\n return wrap('@contello/client:download', () => downloadFile(this._agent, this._url, this._token, fileId));\n }\n\n proxyHls(path: string, signal?: AbortSignal | undefined): Promise<ProxyResult> {\n return wrap('@contello/client:proxyHls', () => proxyHls(this._agent, this._url, this._token, path, signal));\n }\n\n upload(data: UploadData, meta: UploadMetadata, options?: UploadOptions | undefined): Promise<string> {\n return wrap('@contello/client:upload', () =>\n uploadAsset(this._url, this._project, this._token, data, meta, options),\n );\n }\n\n execute<TData>(query: string, variables?: Record<string, unknown> | undefined): Promise<TData> {\n return wrap(\n '@contello/client:execute',\n () => firstAsync(this.subscribe<TData>(query, variables)),\n graphqlOperationAttributes(query, variables),\n );\n }\n}\n\nexport function createContelloClient<TSchema extends Schema | undefined = undefined>(\n options: ContelloClientOptions<TSchema>,\n): ContelloClient<TSchema> {\n return new ContelloClient(options);\n}\n","import type { SourceCardinality, SourceMutations } from './types';\n\n/**\n * Write bindings for the built-in sources. Unlike entity mutations these are not derived — their\n * field and argument names are fixed parts of every Contello schema — but the generator still\n * checks each one against the introspected schema before emitting it, so a server without them\n * (or with a different shape) simply yields a read-only source.\n *\n * Routes are the odd ones: `updateContelloRoute` is keyed by the `path` inside its input rather\n * than by an id, and it replaces the route rather than patching it. `deleteContelloRoute` takes a\n * bare `id` and answers with a bare id string.\n *\n * Assets have no `create` — an asset comes into being through `client.upload()`, not a mutation.\n */\nexport const BUILT_IN_MUTATIONS: Partial<Record<SourceCardinality, SourceMutations>> = {\n route: {\n create: {\n field: 'createContelloRoute',\n arguments: [{ name: 'route', type: 'ContelloRouteInput!', from: 'input' }],\n result: 'entity',\n },\n update: {\n field: 'updateContelloRoute',\n arguments: [{ name: 'route', type: 'ContelloRouteInput!', from: 'input' }],\n result: 'entity',\n },\n delete: {\n field: 'deleteContelloRoute',\n arguments: [{ name: 'id', type: 'String', from: 'id' }],\n result: 'idScalar',\n },\n },\n asset: {\n update: {\n field: 'updateContelloAsset',\n arguments: [{ name: 'request', type: 'ContelloAssetUpdateInput!', from: 'input' }],\n result: 'entity',\n },\n delete: {\n field: 'deleteContelloAsset',\n arguments: [{ name: 'id', type: 'String!', from: 'id' }],\n result: 'idObject',\n },\n },\n};\n"],"mappings":";;;;;AAEA,MAAM,eAAe;AAErB,MAAM,0CAA0B,IAAI,IAAI;CACtC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,kBAAkB,SAAiB,MAAoB;CAC9D,IAAI,YAAY,OAAO,YAAY,QAAQ,CAAC,aAAa,KAAK,OAAO,GACnE,MAAM,IAAI,MAAM,WAAW,MAAM;AAErC;AAEA,SAAS,oBAAoB,MAAc,MAAoB;CAC7D,I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QAAQ;EACV;CACF;CACA,OAAO;EACL,QAAQ;GACN,OAAO;GACP,WAAW,CAAC;IAAE,MAAM;IAAW,MAAM;IAA6B,MAAM;GAAQ,CAAC;GACjF,QAAQ;EACV;EACA,QAAQ;GACN,OAAO;GACP,WAAW,CAAC;IAAE,MAAM;IAAM,MAAM;IAAW,MAAM;GAAK,CAAC;GACvD,QAAQ;EACV;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["undiciRequest","cache","createSelection","uploadAsset"],"sources":["../src/http.ts","../src/ping.ts","../src/pool.ts","../src/telemetry.ts","../src/scalars.ts","../src/transform-variables.ts","../src/rpc.ts","../src/source-mutation.ts","../src/source-subscription.ts","../src/sources.ts","../src/transform-response.ts","../src/upload.ts","../src/client.ts","../src/built-in-mutations.ts"],"sourcesContent":["import { Agent, type Dispatcher, request as undiciRequest } from 'undici';\n\nconst SAFE_SEGMENT = /^[A-Za-z0-9._-]+$/;\n\nconst FORWARDED_PROXY_HEADERS = new Set([\n 'content-type',\n 'content-length',\n 'content-range',\n 'content-encoding',\n 'accept-ranges',\n 'cache-control',\n 'etag',\n 'last-modified',\n 'expires',\n 'age',\n 'vary',\n]);\n\nfunction assertSafeSegment(segment: string, kind: string): void {\n if (segment === '.' || segment === '..' || !SAFE_SEGMENT.test(segment)) {\n throw new Error(`invalid ${kind}`);\n }\n}\n\nfunction assertSafeAssetPath(path: string, kind: string): void {\n if (path === '') {\n throw new Error(`invalid ${kind}`);\n }\n\n for (const segment of path.split('/')) {\n assertSafeSegment(segment, kind);\n }\n}\n\nexport type HttpAgentOptions = {\n pipelining?: number | undefined;\n allowH2?: boolean | undefined;\n maxConcurrentStreams?: number | undefined;\n keepAliveTimeout?: number | undefined;\n};\n\nexport function createHttpAgent(options?: HttpAgentOptions | undefined): Agent {\n return new Agent({\n pipelining: options?.pipelining ?? 10,\n allowH2: options?.allowH2 ?? true,\n maxConcurrentStreams: options?.maxConcurrentStreams ?? 128,\n keepAliveTimeout: options?.keepAliveTimeout ?? 60_000,\n autoSelectFamily: true,\n autoSelectFamilyAttemptTimeout: 25,\n });\n}\n\nexport type DownloadResult = {\n mimeType: string;\n size: number;\n bytes(): Promise<Uint8Array>;\n stream(): ReadableStream<Uint8Array>;\n};\n\nexport async function downloadFile(\n agent: Dispatcher,\n url: string,\n token: string,\n fileId: string,\n): Promise<DownloadResult> {\n assertSafeSegment(fileId, 'file id');\n\n const response = await undiciRequest(`${url}/api/v1/assets/files/${fileId}`, {\n headers: { token },\n dispatcher: agent,\n });\n\n if (response.statusCode < 200 || response.statusCode >= 300) {\n safeDestroyBody(response.body);\n\n throw new Error(`download failed: ${response.statusCode}`);\n }\n\n const mimeType = firstHeader(response.headers, 'content-type') ?? 'application/octet-stream';\n const size = Number(firstHeader(response.headers, 'content-length') ?? 0);\n\n return {\n mimeType,\n size,\n bytes: async () => new Uint8Array(await response.body.arrayBuffer()),\n stream: () => toWebStream(response.body),\n };\n}\n\nexport type ProxyResult = {\n status: number;\n headers: Headers;\n stream(): ReadableStream<Uint8Array>;\n};\n\nexport async function proxyHls(\n agent: Dispatcher,\n url: string,\n token: string,\n path: string,\n signal?: AbortSignal | undefined,\n): Promise<ProxyResult> {\n assertSafeAssetPath(path, 'hls path');\n\n const response = await undiciRequest(`${url}/api/v1/assets/video/hls/${path}`, {\n headers: { token },\n dispatcher: agent,\n signal: signal ?? null,\n });\n\n return buildProxyResult(response, signal);\n}\n\nexport type SitemapProxyOptions = {\n /** chunk source as received from the query string; core decides whether the source/page pair is valid */\n source?: string | undefined;\n /** chunk page as received from the query string */\n page?: string | undefined;\n /** the incoming request's Accept-Encoding, so stored gzip bytes pass through untouched */\n acceptEncoding?: string | undefined;\n /** the incoming request's If-None-Match, so core can answer 304 */\n ifNoneMatch?: string | undefined;\n};\n\nexport async function proxySitemap(\n agent: Dispatcher,\n url: string,\n token: string,\n projectRef: string,\n sitemapId: string,\n options: SitemapProxyOptions,\n signal?: AbortSignal | undefined,\n): Promise<ProxyResult> {\n assertSafeSegment(projectRef, 'project ref');\n assertSafeSegment(sitemapId, 'sitemap id');\n\n const search = new URLSearchParams();\n\n if (options.source !== undefined) {\n search.set('source', options.source);\n }\n\n if (options.page !== undefined) {\n search.set('page', options.page);\n }\n\n const query = search.size > 0 ? `?${search}` : '';\n const headers: Record<string, string> = { token };\n\n if (options.acceptEncoding) {\n headers['accept-encoding'] = options.acceptEncoding;\n }\n\n if (options.ifNoneMatch) {\n headers['if-none-match'] = options.ifNoneMatch;\n }\n\n const response = await undiciRequest(`${url}/api/v1/projects/${projectRef}/sitemaps/${sitemapId}${query}`, {\n headers,\n dispatcher: agent,\n signal: signal ?? null,\n });\n\n const result = buildProxyResult(response, signal);\n\n if (response.statusCode === 304) {\n safeDestroyBody(response.body);\n\n return { ...result, stream: emptyStream };\n }\n\n return result;\n}\n\nfunction emptyStream(): ReadableStream<Uint8Array> {\n return new ReadableStream<Uint8Array>({\n start(controller) {\n controller.close();\n },\n });\n}\n\nfunction buildProxyResult(response: Dispatcher.ResponseData, signal: AbortSignal | undefined): ProxyResult {\n const headers = new Headers();\n\n for (const [key, value] of Object.entries(response.headers)) {\n if (!FORWARDED_PROXY_HEADERS.has(key.toLowerCase())) {\n continue;\n }\n\n if (Array.isArray(value)) {\n for (const v of value) headers.append(key, v);\n } else if (value !== null && value !== undefined) {\n headers.set(key, value);\n }\n }\n\n return {\n status: response.statusCode,\n headers,\n stream: () => toWebStream(response.body, signal),\n };\n}\n\nfunction firstHeader(headers: Record<string, string | string[] | undefined>, key: string): string | undefined {\n const v = headers[key];\n\n return Array.isArray(v) ? v[0] : v;\n}\n\nfunction safeDestroyBody(body: Dispatcher.ResponseData['body']): void {\n try {\n body.on('error', () => {});\n body.destroy();\n } catch {\n // already destroyed\n }\n}\n\nfunction toWebStream(\n body: Dispatcher.ResponseData['body'],\n signal?: AbortSignal | undefined,\n): ReadableStream<Uint8Array> {\n let closed = false;\n\n const cleanup = () => {\n if (closed) {\n return;\n }\n\n closed = true;\n signal?.removeEventListener('abort', cleanup);\n safeDestroyBody(body);\n };\n\n return new ReadableStream<Uint8Array>({\n start(controller) {\n signal?.addEventListener('abort', cleanup);\n\n body.on('data', (chunk: Uint8Array) => {\n if (closed || signal?.aborted) {\n return;\n }\n\n try {\n controller.enqueue(chunk);\n } catch {\n cleanup();\n }\n });\n\n body.on('end', () => {\n if (closed || signal?.aborted) {\n return;\n }\n\n closed = true;\n signal?.removeEventListener('abort', cleanup);\n\n try {\n controller.close();\n } catch {\n // already closed\n }\n });\n\n body.on('error', (err: Error) => {\n cleanup();\n\n if (err.name === 'AbortError') {\n try {\n controller.close();\n } catch {\n // already closed\n }\n\n return;\n }\n\n try {\n controller.error(err);\n } catch {\n // already closed\n }\n });\n },\n cancel() {\n cleanup();\n },\n });\n}\n","const PING_QUERY = `query ContelloPing { contelloPing { response } }`;\n\ntype PingResult = { contelloPing: { response: string } };\n\nexport async function ping(execute: <T>(query: string) => Promise<T>): Promise<void> {\n const data = await execute<PingResult>(PING_QUERY);\n\n if (data.contelloPing.response !== 'pong') {\n throw new Error(`unexpected ping response: ${data.contelloPing.response}`);\n }\n}\n","import type { Client } from 'graphql-ws';\n\n// how long connect() waits for an individual client's first `connected` event\n// before resolving optimistically. without this a single unreachable endpoint\n// (graphql-ws retries forever) would make init() hang indefinitely; the client\n// keeps retrying in the background and get() routes around it via failover.\nconst DEFAULT_CONNECT_TIMEOUT = 10_000;\n\nexport class ConnectionPool {\n private _clients: Client[] = [];\n private _connected: boolean[] = [];\n private _currentIndex = 0;\n\n constructor(\n private _createClient: (id: string) => Client,\n private _poolSize: number,\n private _connectTimeout = DEFAULT_CONNECT_TIMEOUT,\n ) {}\n\n async connect() {\n const ready: Promise<void>[] = [];\n\n for (let i = 0; i < this._poolSize; i++) {\n const index = i;\n const client = this._createClient(String(i + 1));\n\n this._clients.push(client);\n this._connected.push(false);\n\n client.on('connected', () => {\n this._connected[index] = true;\n });\n client.on('closed', () => {\n this._connected[index] = false;\n });\n\n ready.push(\n new Promise<void>((resolve) => {\n let settled = false;\n\n const done = () => {\n if (settled) {\n return;\n }\n\n settled = true;\n offConnected();\n clearTimeout(timer);\n resolve();\n };\n\n const offConnected = client.on('connected', done);\n const timer = setTimeout(done, this._connectTimeout);\n\n timer.unref?.();\n }),\n );\n }\n\n await Promise.all(ready);\n }\n\n get() {\n if (this._clients.length === 0) {\n throw new Error('@contello/client: connection pool is empty — call client.init() first');\n }\n\n // prefer a currently-connected client, scanning round-robin from the cursor\n for (let i = 0; i < this._clients.length; i++) {\n const index = (this._currentIndex + i) % this._clients.length;\n\n if (this._connected[index] === true) {\n this._currentIndex = (index + 1) % this._clients.length;\n\n return this._clients[index]!;\n }\n }\n\n // none known-connected — fall back to plain round-robin; graphql-ws buffers\n // the operation until the chosen socket reconnects\n const client = this._clients[this._currentIndex]!;\n\n this._currentIndex = (this._currentIndex + 1) % this._clients.length;\n\n return client;\n }\n\n async disconnect() {\n const closed = this._clients.map(\n (client) =>\n new Promise<void>((resolve) => {\n const unsubscribe = client.on('closed', () => {\n unsubscribe();\n resolve();\n });\n\n client.dispose();\n }),\n );\n\n this._clients = [];\n this._connected = [];\n this._currentIndex = 0;\n\n await Promise.all(closed);\n }\n}\n","import { createOperationTelemetry } from '@contello/opentelemetry';\n\nexport const { wrap } = createOperationTelemetry('@contello/client');\n","export type LocalDateTime = {\n year: number;\n month: number;\n day: number;\n hour: number;\n minute: number;\n second: number;\n};\n\nexport type LocalDate = {\n year: number;\n month: number;\n day: number;\n};\n\nconst LOCAL_DATE_TIME_KEYS = ['year', 'month', 'day', 'hour', 'minute', 'second'] as const;\nconst LOCAL_DATE_KEYS = ['year', 'month', 'day'] as const;\n\nconst DATE_TIME_REGEX = /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})/;\nconst DATE_REGEX = /^(\\d{4})-(\\d{2})-(\\d{2})/;\n\nfunction pad2(n: number): string {\n return n.toString().padStart(2, '0');\n}\n\nfunction pad4(n: number): string {\n return n.toString().padStart(4, '0');\n}\n\nfunction hasExactKeys(value: object, keys: readonly string[]): boolean {\n const ownKeys = Object.keys(value);\n\n if (ownKeys.length !== keys.length) {\n return false;\n }\n\n for (const key of keys) {\n if (!Object.prototype.hasOwnProperty.call(value, key)) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction allNumbers(value: Record<string, unknown>, keys: readonly string[]): boolean {\n for (const key of keys) {\n if (typeof value[key] !== 'number') {\n return false;\n }\n }\n\n return true;\n}\n\nexport function isLocalDateTime(value: unknown): value is LocalDateTime {\n return (\n !!value &&\n typeof value === 'object' &&\n !Array.isArray(value) &&\n hasExactKeys(value, LOCAL_DATE_TIME_KEYS) &&\n allNumbers(value as Record<string, unknown>, LOCAL_DATE_TIME_KEYS)\n );\n}\n\nexport function isLocalDate(value: unknown): value is LocalDate {\n return (\n !!value &&\n typeof value === 'object' &&\n !Array.isArray(value) &&\n hasExactKeys(value, LOCAL_DATE_KEYS) &&\n allNumbers(value as Record<string, unknown>, LOCAL_DATE_KEYS)\n );\n}\n\nexport function decodeLocalDateTime(value: string): LocalDateTime {\n const match = DATE_TIME_REGEX.exec(value);\n\n if (!match) {\n throw new Error(`@contello/client: cannot decode LocalDateTime from \"${value}\"`);\n }\n\n return {\n year: Number(match[1]),\n month: Number(match[2]),\n day: Number(match[3]),\n hour: Number(match[4]),\n minute: Number(match[5]),\n second: Number(match[6]),\n };\n}\n\nexport function decodeLocalDate(value: string): LocalDate {\n const match = DATE_REGEX.exec(value);\n\n if (!match) {\n throw new Error(`@contello/client: cannot decode LocalDate from \"${value}\"`);\n }\n\n return {\n year: Number(match[1]),\n month: Number(match[2]),\n day: Number(match[3]),\n };\n}\n\nexport function encodeLocalDateTime(value: LocalDateTime): string {\n return (\n `${pad4(value.year)}-${pad2(value.month)}-${pad2(value.day)}` +\n `T${pad2(value.hour)}:${pad2(value.minute)}:${pad2(value.second)}Z`\n );\n}\n\nexport function encodeLocalDate(value: LocalDate): string {\n return `${pad4(value.year)}-${pad2(value.month)}-${pad2(value.day)}T00:00:00Z`;\n}\n","import { encodeLocalDate, encodeLocalDateTime, isLocalDate, isLocalDateTime } from './scalars';\n\n/**\n * encodes outgoing variables: LocalDateTime / LocalDate POJOs become wire strings.\n * detection is by shape — generated input types use the struct types, so consumers\n * pass structs in the right places, and stray objects with the same shape would be\n * an extremely unusual coincidence.\n */\nexport function transformVariables<T>(value: T): T {\n if (value === null || value === undefined) {\n return value;\n }\n\n if (Array.isArray(value)) {\n return value.map((item) => transformVariables(item)) as unknown as T;\n }\n\n if (typeof value !== 'object') {\n return value;\n }\n\n if (isLocalDateTime(value)) {\n return encodeLocalDateTime(value) as unknown as T;\n }\n\n if (isLocalDate(value)) {\n return encodeLocalDate(value) as unknown as T;\n }\n\n const obj = value as Record<string, unknown>;\n const out: Record<string, unknown> = {};\n\n for (const [key, val] of Object.entries(obj)) {\n out[key] = transformVariables(val);\n }\n\n return out as unknown as T;\n}\n","import { graphqlOperationAttributes } from '@contello/opentelemetry';\nimport { firstAsync } from '@entwico/dash/async';\nimport { wrap } from './telemetry';\nimport { transformVariables } from './transform-variables';\nimport type { OperationMap, Rpc } from './types';\n\ntype Subscribe = <TData>(query: string, variables?: Record<string, unknown> | undefined) => AsyncIterable<TData>;\n\nexport function buildRpc<T extends OperationMap>(operations: T, subscribe: Subscribe): Rpc<T> {\n const rpc = {} as Record<string, (...args: any[]) => any>;\n\n for (const [name, def] of Object.entries(operations)) {\n rpc[name] = def.kind === 'subscription' ? (variables?: Record<string, unknown>) =>\n subscribe<unknown>(def.document, transformVariables(variables)) : (variables?: Record<string, unknown>) => {\n const vars = transformVariables(variables);\n\n return wrap(\n `rpc:${name}`,\n () => firstAsync(subscribe<unknown>(def.document, vars)),\n graphqlOperationAttributes(def.document, vars),\n );\n };\n }\n\n return rpc as Rpc<T>;\n}\n","import { transformVariables } from './transform-variables';\nimport type { SourceDef, SourceMutationBinding, SourceMutations } from './types';\n\nexport type SourceMutationKind = keyof SourceMutations;\n\n/** What a write takes: the caller's input, and the id for a delete. */\nexport type SourceMutationValues = {\n input?: unknown;\n id?: string | undefined;\n};\n\nconst cache = new WeakMap<SourceDef, Partial<Record<SourceMutationKind, string>>>();\n\n/**\n * A create/update answers with the entity itself, so it selects the source's own fragment — the\n * write comes back in the same shape a read does and needs no follow-up fetch. A delete answers\n * with an id, either wrapped in a response object or, for routes, as a bare scalar.\n */\nfunction createSelection(source: SourceDef, binding: SourceMutationBinding): string {\n const declarations = binding.arguments.map((argument) => `$${argument.name}: ${argument.type}`).join(', ');\n const args = binding.arguments.map((argument) => `${argument.name}: $${argument.name}`).join(', ');\n const selection = { entity: ` { ...${source.fragment} }`, idObject: ' { id }', idScalar: '' }[binding.result];\n const operation = `mutation(${declarations}) { result: ${binding.field}(${args})${selection} }`;\n\n return binding.result === 'entity' ? `${source.document}\\n${operation}` : operation;\n}\n\nexport function getSourceMutation(source: SourceDef, kind: SourceMutationKind): SourceMutationBinding | undefined {\n return source.mutations?.[kind];\n}\n\n/** The mutation document for one write operation of a source. Cached per source + kind. */\nexport function createSourceMutation(source: SourceDef, kind: SourceMutationKind): string {\n const binding = getSourceMutation(source, kind);\n\n if (!binding) {\n throw new Error(\n `@contello/client: source \"${source.__model}\" has no ${kind} mutation — ` +\n `the schema exposes none for this model`,\n );\n }\n\n const cached = cache.get(source);\n\n if (cached?.[kind] !== undefined) {\n return cached[kind];\n }\n\n const doc = createSelection(source, binding);\n const entry = cached ?? {};\n\n entry[kind] = doc;\n cache.set(source, entry);\n\n return doc;\n}\n\n/**\n * Variables for a write: one per bound argument, the input nested under the envelope field when\n * the argument is a one-field wrapper, and everything encoded on the way out (LocalDate /\n * LocalDateTime structs become wire strings) — every caller goes through here, so no write path\n * can skip the encoding.\n */\nexport function createSourceMutationVariables(\n binding: SourceMutationBinding,\n values: SourceMutationValues,\n): Record<string, unknown> {\n const variables: Record<string, unknown> = {};\n\n for (const argument of binding.arguments) {\n variables[argument.name] =\n argument.from === 'id' ? values.id : (argument.envelope ? { [argument.envelope]: values.input } : values.input);\n }\n\n return transformVariables(variables);\n}\n\n/** Pulls the id out of whatever shape the mutation answered with. */\nexport function readSourceMutationId(binding: SourceMutationBinding, result: unknown): string {\n return binding.result === 'idScalar' ? (result as string) : (result as { id: string }).id;\n}\n","import type { SourceDef } from './types';\n\nconst cache = new WeakMap<SourceDef, string>();\n\nfunction createSelection(source: SourceDef): string {\n const spread = `{ ...${source.fragment} }`;\n\n switch (source.__cardinality) {\n case 'singleton': {\n return `subscription { source: ${source.subscription} ${spread} }`;\n }\n case 'entity': {\n return `subscription($ids: [ID!]) { source: ${source.subscription}(request: { filter: { ids: $ids } }) ${spread} }`;\n }\n case 'route': {\n return `subscription($ids: [ID!], $paths: [String!]) { source: ${source.subscription}(request: { ids: $ids, paths: $paths }) ${spread} }`;\n }\n case 'asset': {\n return `subscription($ids: [ID!]) { source: ${source.subscription}(filter: { ids: $ids }) ${spread} }`;\n }\n case 'i18nMessage': {\n return `subscription($collection: String!, $ids: [ID!]) { source: ${source.subscription}(collectionReferenceName: $collection, ids: $ids) ${spread} }`;\n }\n }\n}\n\nexport function createSourceSubscription(source: SourceDef): string {\n const cached = cache.get(source);\n\n if (cached !== undefined) {\n return cached;\n }\n\n const doc = `${source.document}\\n${createSelection(source)}`;\n\n cache.set(source, doc);\n\n return doc;\n}\n","import { graphqlOperationAttributes } from '@contello/opentelemetry';\nimport { concatAsync, firstAsync, mapAsync } from '@entwico/dash/async';\nimport {\n type SourceMutationKind,\n createSourceMutation,\n createSourceMutationVariables,\n readSourceMutationId,\n} from './source-mutation';\nimport { createSourceSubscription } from './source-subscription';\nimport { wrap } from './telemetry';\nimport { transformVariables } from './transform-variables';\nimport type { SourceAccessors, SourceDef, SourceMap } from './types';\n\ntype Subscribe = <TData>(query: string, variables?: Record<string, unknown> | undefined) => AsyncIterable<TData>;\n\nconst WRITE_KINDS: SourceMutationKind[] = ['create', 'update', 'delete'];\n\nexport function createSources<TSources extends SourceMap>(\n sources: TSources,\n subscribe: Subscribe,\n): SourceAccessors<TSources> {\n const out = {} as Record<string, Record<string, (...args: any[]) => Promise<unknown>>>;\n\n for (const [name, source] of Object.entries(sources)) {\n const def = source as SourceDef;\n const doc = createSourceSubscription(def);\n const accessor = createSourceAccessor(name, def, doc, subscribe);\n\n if (accessor) {\n out[name] = { ...accessor, ...createSourceWriters(name, def, subscribe) };\n }\n }\n\n return out as SourceAccessors<TSources>;\n}\n\n/**\n * Write accessors for the mutations the generator bound to this source. A create/update answers\n * with the entity in the source's fragment shape, a delete with the id it removed. Nothing is\n * cached here — `@contello/store` collections take the same payload into their cache.\n */\nfunction createSourceWriters(\n name: string,\n def: SourceDef,\n subscribe: Subscribe,\n): Record<string, (input: unknown) => Promise<unknown>> {\n const out: Record<string, (input: unknown) => Promise<unknown>> = {};\n\n for (const kind of WRITE_KINDS) {\n const binding = def.mutations?.[kind];\n\n if (!binding) {\n continue;\n }\n\n const doc = createSourceMutation(def, kind);\n\n out[kind] = (input: unknown) => {\n // a delete is addressed by id: bindings that take a bare `id:` argument read it off the input\n const variables = createSourceMutationVariables(\n binding,\n kind === 'delete' ? { input, id: (input as { id: string }).id } : { input },\n );\n\n return wrap(\n `source:${name}:${kind}`,\n async () => {\n const response = await firstAsync(subscribe<{ result: unknown }>(doc, variables));\n\n if (response?.result === undefined || response.result === null) {\n throw new Error(`@contello/client: ${kind} on source \"${name}\" returned no entity`);\n }\n\n return kind === 'delete' ? readSourceMutationId(binding, response.result) : response.result;\n },\n graphqlOperationAttributes(doc, variables),\n );\n };\n }\n\n return out;\n}\n\nfunction createSourceAccessor(\n name: string,\n def: SourceDef,\n doc: string,\n subscribe: Subscribe,\n): { fetch: (...args: any[]) => Promise<unknown> } | undefined {\n switch (def.__cardinality) {\n case 'singleton': {\n return {\n fetch: () =>\n wrap(\n `source:${name}`,\n () => firstAsync(mapAsync(subscribe<{ source: unknown }>(doc), (r) => r.source)),\n graphqlOperationAttributes(doc),\n ),\n };\n }\n case 'entity': {\n return {\n fetch: (vars?: { ids?: string[] }) => {\n const variables = transformVariables({ ids: vars?.ids });\n\n return wrap(\n `source:${name}`,\n () => concatAsync(mapAsync(subscribe<{ source: unknown[] }>(doc, variables), (r) => r.source)),\n graphqlOperationAttributes(doc, variables),\n );\n },\n };\n }\n case 'route': {\n return {\n fetch: (vars?: { ids?: string[] | undefined; paths?: string[] | undefined } | undefined) => {\n const variables = transformVariables({ ids: vars?.ids, paths: vars?.paths });\n\n return wrap(\n `source:${name}`,\n () => concatAsync(mapAsync(subscribe<{ source: unknown[] }>(doc, variables), (r) => r.source)),\n graphqlOperationAttributes(doc, variables),\n );\n },\n };\n }\n case 'asset': {\n return {\n fetch: (vars?: { ids?: string[] | undefined } | undefined) => {\n const variables = transformVariables({ ids: vars?.ids });\n\n return wrap(\n `source:${name}`,\n () => concatAsync(mapAsync(subscribe<{ source: unknown[] }>(doc, variables), (r) => r.source)),\n graphqlOperationAttributes(doc, variables),\n );\n },\n };\n }\n case 'i18nMessage': {\n return {\n fetch: (vars: { collection: string; ids?: string[] | undefined }) => {\n const variables = transformVariables({ collection: vars.collection, ids: vars.ids });\n\n return wrap(\n `source:${name}`,\n () => concatAsync(mapAsync(subscribe<{ source: unknown[] }>(doc, variables), (r) => r.source)),\n graphqlOperationAttributes(doc, variables),\n );\n },\n };\n }\n }\n}\n","import { decodeLocalDate, decodeLocalDateTime } from './scalars';\n\nconst FLAT_PREFIX = '_flat_';\nconst LDT_PREFIX = '_ldt_';\nconst LD_PREFIX = '_ld_';\n\nconst MODEL_SUFFIXES = ['Entity', 'Component'];\n\nfunction decodeValue(value: unknown, decoder: (s: string) => unknown): unknown {\n if (value === null || value === undefined) {\n return value;\n }\n\n if (Array.isArray(value)) {\n return value.map((item) => decodeValue(item, decoder));\n }\n\n if (typeof value === 'string') {\n return decoder(value);\n }\n\n return value;\n}\n\ntype FlatRef = { _flatId?: string | undefined };\ntype FlatComponent = FlatRef & { __typename?: string | undefined };\n\nfunction deriveModel(typename: string): string | undefined {\n for (const suffix of MODEL_SUFFIXES) {\n if (typename.endsWith(suffix)) {\n const stripped = typename.slice(0, -suffix.length);\n\n return stripped.charAt(0).toLowerCase() + stripped.slice(1);\n }\n }\n\n return undefined;\n}\n\n/**\n * transforms a GraphQL response in a single depth-first pass:\n * - resolves `_flat_{field}` companions into nested component arrays (refs are\n * matched against the companion map by `_flatId`, at any nesting depth — the\n * companion lists the whole subtree, so one map serves every ref below it)\n * - injects `__model` on objects with entity/component `__typename`\n * - decodes managed scalar aliases (`_ldt_` / `_ld_`) into structured values\n *\n * a `seen` set guards against shared or cyclic references so every object is\n * visited exactly once.\n */\nexport function transformResponse<T>(data: T): T {\n transformNode(data, undefined, new WeakSet());\n\n return data;\n}\n\nfunction transformNode(\n value: unknown,\n flatMap: Map<string, FlatComponent> | undefined,\n seen: WeakSet<object>,\n): void {\n if (!value || typeof value !== 'object') {\n return;\n }\n\n if (seen.has(value)) {\n return;\n }\n\n seen.add(value);\n\n if (Array.isArray(value)) {\n for (const item of value) {\n transformNode(item, flatMap, seen);\n }\n\n return;\n }\n\n const obj = value as Record<string, unknown>;\n\n // inject __model from __typename\n const typename = obj['__typename'];\n\n if (typeof typename === 'string') {\n const model = deriveModel(typename);\n\n if (model) {\n obj['__model'] = model;\n }\n }\n\n // collect `_flat_*` companions into this scope's resolution map, extending any\n // map inherited from an ancestor so refs nested below resolve against the same\n // companion set\n let ownMap: Map<string, FlatComponent> | undefined;\n\n for (const key of Object.keys(obj)) {\n if (!key.startsWith(FLAT_PREFIX)) {\n continue;\n }\n\n const flatArray = obj[key] as FlatComponent[] | undefined;\n\n delete obj[key];\n\n if (!flatArray) {\n continue;\n }\n\n if (!ownMap) {\n ownMap = flatMap ? new Map(flatMap) : new Map();\n }\n\n for (const component of flatArray) {\n if (component._flatId) {\n ownMap.set(component._flatId, component);\n }\n }\n }\n\n // decode scalar aliases, resolve ref arrays, and recurse — one pass over keys.\n // refs resolve against this object's own companion map if it had `_flat_*`\n // siblings, otherwise against the inherited ancestor map\n const resolveMap = ownMap ?? flatMap;\n\n for (const key of Object.keys(obj)) {\n if (key.startsWith(LDT_PREFIX)) {\n obj[key.slice(LDT_PREFIX.length)] = decodeValue(obj[key], decodeLocalDateTime);\n delete obj[key];\n\n continue;\n }\n\n if (key.startsWith(LD_PREFIX)) {\n obj[key.slice(LD_PREFIX.length)] = decodeValue(obj[key], decodeLocalDate);\n delete obj[key];\n\n continue;\n }\n\n const inner = obj[key];\n\n if (\n resolveMap &&\n Array.isArray(inner) &&\n inner.length > 0 &&\n (inner[0] as FlatRef | undefined)?._flatId !== undefined\n ) {\n obj[key] = resolveRefs(inner as FlatRef[], resolveMap);\n }\n\n transformNode(obj[key], resolveMap, seen);\n }\n}\n\nfunction resolveRefs(refs: readonly FlatRef[], flatMap: Map<string, FlatComponent>): FlatComponent[] {\n const resolved: FlatComponent[] = [];\n\n for (const ref of refs) {\n if (!ref._flatId) {\n continue;\n }\n\n const component = flatMap.get(ref._flatId);\n\n if (component) {\n resolved.push(component);\n }\n }\n\n return resolved;\n}\n","import type { ReadableStream as NodeReadableStream } from 'node:stream/web';\n\nexport type UploadMetadata = {\n name: string;\n mimeType?: string | undefined;\n size?: number | undefined;\n annotations?: { key: string; value: string }[] | undefined;\n collectionRefs?: string[] | undefined;\n};\n\nexport type UploadData = Uint8Array | NodeReadableStream<Uint8Array> | ReadableStream<Uint8Array>;\n\ntype InitFrame = { type: 'init'; metadata: UploadMetadata & { projectRef: string }; token: string };\ntype ServerMessage = { type: 'ack' } | { type: 'progress'; bytesReceived: number } | { type: 'done'; id: string };\n\nexport type UploadOptions = {\n chunkSize?: number | undefined;\n abort?: AbortSignal | undefined;\n};\n\nconst DEFAULT_CHUNK_SIZE = 4 * 1024 * 1024;\n\nfunction isUint8Array(data: UploadData): data is Uint8Array {\n return data instanceof Uint8Array;\n}\n\nexport function upload(\n url: string,\n project: string,\n token: string,\n data: UploadData,\n meta: UploadMetadata,\n options?: UploadOptions | undefined,\n): Promise<string> {\n const chunkSize = options?.chunkSize ?? DEFAULT_CHUNK_SIZE;\n const wsUrl = `${url.replace(/^http/i, 'ws')}/api/v1/assets/ws`;\n\n const size = isUint8Array(data) ? data.length : meta.size;\n\n return new Promise<string>((resolve, reject) => {\n const ws = new WebSocket(wsUrl, 'contello-file-upload-v1');\n\n let done = false;\n\n const cleanup = () => {\n options?.abort?.removeEventListener('abort', abortHandler);\n };\n\n const abortHandler = () => {\n if (done) {\n return;\n }\n\n ws.close();\n reject(new Error('upload aborted'));\n };\n\n options?.abort?.addEventListener('abort', abortHandler);\n\n function sendBuffer(buf: Uint8Array) {\n let offset = 0;\n\n while (offset < buf.length) {\n const chunk = buf.subarray(offset, offset + chunkSize);\n\n ws.send(chunk);\n offset += chunk.length;\n }\n\n ws.send(JSON.stringify({ type: 'done' }));\n }\n\n const MAX_BUFFER_SIZE = 8 * 1024 * 1024;\n\n function waitForBufferedDrain(): Promise<void> {\n return new Promise((resolveDrain, rejectDrain) => {\n const check = () => {\n if (options?.abort?.aborted) {\n rejectDrain(new Error('upload aborted'));\n\n return;\n }\n\n if (ws.bufferedAmount <= MAX_BUFFER_SIZE) {\n resolveDrain();\n\n return;\n }\n\n setTimeout(check, 50);\n };\n\n check();\n });\n }\n\n async function sendStream(stream: UploadData) {\n const reader = (stream as ReadableStream<Uint8Array>).getReader();\n\n try {\n while (true) {\n const { done: streamDone, value } = await reader.read();\n\n if (streamDone) break;\n\n await waitForBufferedDrain();\n ws.send(value);\n }\n\n ws.send(JSON.stringify({ type: 'done' }));\n } catch (error) {\n reject(error);\n ws.close();\n }\n }\n\n ws.addEventListener('open', () => {\n const initFrame: InitFrame = {\n type: 'init',\n metadata: { ...meta, ...(size !== undefined && { size }), projectRef: project },\n token,\n };\n\n ws.send(JSON.stringify(initFrame));\n });\n\n ws.addEventListener('message', (event) => {\n const message: ServerMessage = JSON.parse(String(event.data));\n\n if (message.type === 'ack') {\n if (isUint8Array(data)) {\n sendBuffer(data);\n } else {\n sendStream(data);\n }\n\n return;\n }\n\n if (message.type === 'done') {\n done = true;\n cleanup();\n ws.close();\n resolve(message.id);\n }\n });\n\n ws.addEventListener('error', () => {\n cleanup();\n reject(new Error('upload websocket error'));\n });\n\n ws.addEventListener('close', () => {\n cleanup();\n\n if (!done) {\n reject(new Error('connection closed before upload completed'));\n }\n });\n });\n}\n","import { graphqlOperationAttributes, injectTraceContext } from '@contello/opentelemetry';\nimport { exponentialBackoff, firstAsync } from '@entwico/dash/async';\nimport { createClient } from 'graphql-ws';\nimport type { Agent } from 'undici';\n\nimport {\n type DownloadResult,\n type HttpAgentOptions,\n type ProxyResult,\n type SitemapProxyOptions,\n createHttpAgent,\n downloadFile,\n proxyHls,\n proxySitemap,\n} from './http';\nimport { ping } from './ping';\nimport { ConnectionPool } from './pool';\nimport { buildRpc } from './rpc';\nimport { createSources } from './sources';\nimport { wrap } from './telemetry';\nimport { transformResponse } from './transform-response';\nimport type { Rpc, Schema, SourceAccessors } from './types';\nimport { type UploadData, type UploadMetadata, type UploadOptions, upload as uploadAsset } from './upload';\n\nexport type ConnectionContext = {\n connectionId: string;\n websocketUrl: string;\n};\n\nexport type ConnectionEvents = {\n onConnected?: ((context: ConnectionContext) => void) | undefined;\n onConnecting?: ((context: ConnectionContext) => void) | undefined;\n onClosed?: ((context: ConnectionContext) => void) | undefined;\n onError?: ((context: ConnectionContext, error: unknown) => void) | undefined;\n};\n\nexport type ContelloClientOptions<TSchema extends Schema | undefined = undefined> = {\n url: string;\n project: string;\n token: string;\n schema?: TSchema | undefined;\n connections?: number | undefined;\n http?: HttpAgentOptions | undefined;\n onConnected?: (() => void) | undefined;\n onReconnecting?: (() => void) | undefined;\n onError?: ((error: unknown) => void) | undefined;\n connectionEvents?: ConnectionEvents | undefined;\n};\n\ntype PoolState = 'disconnected' | 'connected' | 'reconnecting';\n\nexport class ContelloClient<TSchema extends Schema | undefined = undefined> {\n private _pool: ConnectionPool;\n private _rpc: TSchema extends Schema<infer TOps, any, any> ? Rpc<TOps> : undefined;\n private _sources: TSchema extends Schema<any, infer TSources, any> ? SourceAccessors<TSources> : undefined;\n private _url: string;\n private _project: string;\n private _token: string;\n private _agent: Agent;\n\n constructor(options: ContelloClientOptions<TSchema>) {\n const { url, project, token, schema, connections = 1, connectionEvents } = options;\n\n this._url = url;\n this._project = project;\n this._token = token;\n this._agent = createHttpAgent(options.http);\n\n const websocketUrl = `${url}/graphql/projects/${project}`.replace(/^http/i, 'ws');\n\n let state: PoolState = 'disconnected';\n let connectedCount = 0;\n\n const onConnectionUp = () => {\n connectedCount++;\n\n if (connectedCount === connections && state !== 'connected') {\n state = 'connected';\n options.onConnected?.();\n }\n };\n\n const onConnectionDown = () => {\n if (connectedCount > 0) {\n connectedCount--;\n }\n\n if (state === 'connected') {\n state = 'reconnecting';\n options.onReconnecting?.();\n }\n };\n\n this._pool = new ConnectionPool((id: string) => {\n const context: ConnectionContext = Object.freeze({ connectionId: id, websocketUrl });\n\n return createClient({\n url: websocketUrl,\n connectionParams: { token },\n lazy: false,\n keepAlive: 30_000,\n retryAttempts: Infinity,\n retryWait: exponentialBackoff,\n shouldRetry: () => true,\n jsonMessageReplacer: (key, value) => {\n if (!key) {\n return injectTraceContext(value);\n }\n\n return value;\n },\n ...(options.onError && { onNonLazyError: (e) => options.onError!(e) }),\n on: {\n connected: () => {\n onConnectionUp();\n connectionEvents?.onConnected?.(context);\n },\n connecting: () => {\n connectionEvents?.onConnecting?.(context);\n },\n closed: () => {\n onConnectionDown();\n connectionEvents?.onClosed?.(context);\n },\n ...((options.onError || connectionEvents?.onError) && {\n error: (e) => {\n options.onError?.(e);\n connectionEvents?.onError?.(context, e);\n },\n }),\n },\n });\n }, connections);\n\n this._rpc = (\n schema?.operations ? buildRpc(schema.operations, (q, v) => this.subscribe(q, v)) : undefined\n ) as typeof this._rpc;\n\n this._sources = (\n schema?.sources ? createSources(schema.sources, (q, v) => this.subscribe(q, v)) : undefined\n ) as typeof this._sources;\n }\n\n get rpc(): TSchema extends Schema<infer TOps, any, any> ? Rpc<TOps> : never {\n if (!this._rpc) {\n throw new Error('@contello/client: .rpc accessed without a schema containing operations');\n }\n\n return this._rpc as any;\n }\n\n get sources(): TSchema extends Schema<any, infer TSources, any> ? SourceAccessors<TSources> : never {\n if (!this._sources) {\n throw new Error('@contello/client: .sources accessed without a schema containing sources');\n }\n\n return this._sources as any;\n }\n\n async init(): Promise<void> {\n await this._pool.connect();\n }\n\n async destroy(): Promise<void> {\n await this._pool.disconnect();\n await this._agent.close();\n }\n\n async ping(): Promise<void> {\n // excluded from telemetry to avoid noise\n return ping((query) => firstAsync(this.subscribe(query)));\n }\n\n /**\n * Open a subscription on the websocket. Each `[Symbol.asyncIterator]()` call (the implicit one\n * from `for await`, or via `rxjs.from(this)`) starts a fresh server subscription and tears it\n * down when the iterator is returned (`break`, error, or explicit stop).\n */\n subscribe<TData>(query: string, variables?: Record<string, unknown> | undefined): AsyncIterable<TData> {\n const pool = this._pool;\n\n return {\n [Symbol.asyncIterator](): AsyncIterator<TData> {\n const wsClient = pool.get();\n const queue: TData[] = [];\n let pending: { resolve: (r: IteratorResult<TData>) => void; reject: (e: unknown) => void } | undefined;\n let done = false;\n let error: unknown;\n\n const unsubscribe = wsClient.subscribe<TData>(\n { query, variables },\n {\n next(msg) {\n const value = transformResponse(msg.data);\n\n if (value === undefined || value === null) {\n return;\n }\n\n if (pending) {\n const p = pending;\n\n pending = undefined;\n p.resolve({ value: value as TData, done: false });\n } else {\n queue.push(value as TData);\n }\n },\n error(err) {\n done = true;\n error = err;\n\n if (pending) {\n const p = pending;\n\n pending = undefined;\n p.reject(err);\n }\n },\n complete() {\n done = true;\n\n if (pending) {\n const p = pending;\n\n pending = undefined;\n p.resolve({ value: undefined as unknown as TData, done: true });\n }\n },\n },\n );\n\n return {\n next(): Promise<IteratorResult<TData>> {\n if (queue.length > 0) {\n return Promise.resolve({ value: queue.shift()!, done: false });\n }\n\n if (error !== undefined) {\n return Promise.reject(error);\n }\n\n if (done) {\n return Promise.resolve({ value: undefined as unknown as TData, done: true });\n }\n\n return new Promise<IteratorResult<TData>>((resolve, reject) => {\n pending = { resolve, reject };\n });\n },\n return(): Promise<IteratorResult<TData>> {\n unsubscribe();\n\n return Promise.resolve({ value: undefined as unknown as TData, done: true });\n },\n throw(err): Promise<IteratorResult<TData>> {\n unsubscribe();\n\n return Promise.reject(err);\n },\n };\n },\n };\n }\n\n download(fileId: string): Promise<DownloadResult> {\n return wrap('@contello/client:download', () => downloadFile(this._agent, this._url, this._token, fileId));\n }\n\n proxyHls(path: string, signal?: AbortSignal | undefined): Promise<ProxyResult> {\n return wrap('@contello/client:proxyHls', () => proxyHls(this._agent, this._url, this._token, path, signal));\n }\n\n proxySitemap(\n sitemapId: string,\n options: SitemapProxyOptions,\n signal?: AbortSignal | undefined,\n ): Promise<ProxyResult> {\n return wrap('@contello/client:proxySitemap', () =>\n proxySitemap(this._agent, this._url, this._token, this._project, sitemapId, options, signal),\n );\n }\n\n upload(data: UploadData, meta: UploadMetadata, options?: UploadOptions | undefined): Promise<string> {\n return wrap('@contello/client:upload', () =>\n uploadAsset(this._url, this._project, this._token, data, meta, options),\n );\n }\n\n execute<TData>(query: string, variables?: Record<string, unknown> | undefined): Promise<TData> {\n return wrap(\n '@contello/client:execute',\n () => firstAsync(this.subscribe<TData>(query, variables)),\n graphqlOperationAttributes(query, variables),\n );\n }\n}\n\nexport function createContelloClient<TSchema extends Schema | undefined = undefined>(\n options: ContelloClientOptions<TSchema>,\n): ContelloClient<TSchema> {\n return new ContelloClient(options);\n}\n","import type { SourceCardinality, SourceMutations } from './types';\n\n/**\n * Write bindings for the built-in sources. Unlike entity mutations these are not derived — their\n * field and argument names are fixed parts of every Contello schema — but the generator still\n * checks each one against the introspected schema before emitting it, so a server without them\n * (or with a different shape) simply yields a read-only source.\n *\n * Routes are the odd ones: `updateContelloRoute` is keyed by the `path` inside its input rather\n * than by an id, and it replaces the route rather than patching it. `deleteContelloRoute` takes a\n * bare `id` and answers with a bare id string.\n *\n * Assets have no `create` — an asset comes into being through `client.upload()`, not a mutation.\n */\nexport const BUILT_IN_MUTATIONS: Partial<Record<SourceCardinality, SourceMutations>> = {\n route: {\n create: {\n field: 'createContelloRoute',\n arguments: [{ name: 'route', type: 'ContelloRouteInput!', from: 'input' }],\n result: 'entity',\n },\n update: {\n field: 'updateContelloRoute',\n arguments: [{ name: 'route', type: 'ContelloRouteInput!', from: 'input' }],\n result: 'entity',\n },\n delete: {\n field: 'deleteContelloRoute',\n arguments: [{ name: 'id', type: 'String', from: 'id' }],\n result: 'idScalar',\n },\n },\n asset: {\n update: {\n field: 'updateContelloAsset',\n arguments: [{ name: 'request', type: 'ContelloAssetUpdateInput!', from: 'input' }],\n result: 'entity',\n },\n delete: {\n field: 'deleteContelloAsset',\n arguments: [{ name: 'id', type: 'String!', from: 'id' }],\n result: 'idObject',\n },\n },\n};\n"],"mappings":";;;;;AAEA,MAAM,eAAe;AAErB,MAAM,0CAA0B,IAAI,IAAI;CACtC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,kBAAkB,SAAiB,MAAoB;CAC9D,IAAI,YAAY,OAAO,YAAY,QAAQ,CAAC,aAAa,KAAK,OAAO,GACnE,MAAM,IAAI,MAAM,WAAW,MAAM;AAErC;AAEA,SAAS,oBAAoB,MAAc,MAAoB;CAC7D,IAAI,SAAS,IACX,MAAM,IAAI,MAAM,WAAW,MAAM;CAGnC,KAAK,MAAM,WAAW,KAAK,MAAM,GAAG,GAClC,kBAAkB,SAAS,IAAI;AAEnC;AASA,SAAgB,gBAAgB,SAA+C;CAC7E,OAAO,IAAI,MAAM;EACf,YAAY,SAAS,cAAc;EACnC,SAAS,SAAS,WAAW;EAC7B,sBAAsB,SAAS,wBAAwB;EACvD,kBAAkB,SAAS,oBAAoB;EAC/C,kBAAkB;EAClB,gCAAgC;CAClC,CAAC;AACH;AASA,eAAsB,aACpB,OACA,KACA,OACA,QACyB;CACzB,kBAAkB,QAAQ,SAAS;CAEnC,MAAM,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