@contello/client 3.1.2 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -1
- package/dist/generate-Db8wmmzJ.js +3 -0
- package/dist/index.cjs +57 -28
- package/dist/index.d.cts +19 -8
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +19 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +57 -28
- package/dist/index.js.map +1 -1
- package/package.json +6 -3
- package/dist/generate-CqlYWWhF.js +0 -1338
- package/dist/generate-CqlYWWhF.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const command = process.argv[2];
|
|
4
4
|
switch (command) {
|
|
5
5
|
case "generate":
|
|
6
|
-
await import("./generate-
|
|
6
|
+
await import("./generate-Db8wmmzJ.js");
|
|
7
7
|
break;
|
|
8
8
|
default:
|
|
9
9
|
console.error(command ? `unknown command: ${command}` : "usage: contello-client <command>");
|
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)) {
|
|
@@ -606,12 +637,11 @@ function upload(url, project, token, data, meta, options) {
|
|
|
606
637
|
else sendStream(data);
|
|
607
638
|
return;
|
|
608
639
|
}
|
|
609
|
-
if (message.type
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
}
|
|
640
|
+
if (message.type !== "done") return;
|
|
641
|
+
done = true;
|
|
642
|
+
cleanup();
|
|
643
|
+
ws.close();
|
|
644
|
+
resolve(message.id);
|
|
615
645
|
});
|
|
616
646
|
ws.addEventListener("error", () => {
|
|
617
647
|
cleanup();
|
|
@@ -644,17 +674,15 @@ var ContelloClient = class {
|
|
|
644
674
|
let connectedCount = 0;
|
|
645
675
|
const onConnectionUp = () => {
|
|
646
676
|
connectedCount++;
|
|
647
|
-
if (connectedCount
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
}
|
|
677
|
+
if (connectedCount !== connections || state === "connected") return;
|
|
678
|
+
state = "connected";
|
|
679
|
+
options.onConnected?.();
|
|
651
680
|
};
|
|
652
681
|
const onConnectionDown = () => {
|
|
653
682
|
if (connectedCount > 0) connectedCount--;
|
|
654
|
-
if (state
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
}
|
|
683
|
+
if (state !== "connected") return;
|
|
684
|
+
state = "reconnecting";
|
|
685
|
+
options.onReconnecting?.();
|
|
658
686
|
};
|
|
659
687
|
this._pool = new ConnectionPool((id) => {
|
|
660
688
|
const context = Object.freeze({
|
|
@@ -746,22 +774,20 @@ var ContelloClient = class {
|
|
|
746
774
|
error(err) {
|
|
747
775
|
done = true;
|
|
748
776
|
error = err;
|
|
749
|
-
if (pending)
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
}
|
|
777
|
+
if (!pending) return;
|
|
778
|
+
const p = pending;
|
|
779
|
+
pending = void 0;
|
|
780
|
+
p.reject(err);
|
|
754
781
|
},
|
|
755
782
|
complete() {
|
|
756
783
|
done = true;
|
|
757
|
-
if (pending)
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
}
|
|
784
|
+
if (!pending) return;
|
|
785
|
+
const p = pending;
|
|
786
|
+
pending = void 0;
|
|
787
|
+
p.resolve({
|
|
788
|
+
value: void 0,
|
|
789
|
+
done: true
|
|
790
|
+
});
|
|
765
791
|
}
|
|
766
792
|
});
|
|
767
793
|
return {
|
|
@@ -802,6 +828,9 @@ var ContelloClient = class {
|
|
|
802
828
|
proxyHls(path, signal) {
|
|
803
829
|
return wrap("@contello/client:proxyHls", () => proxyHls(this._agent, this._url, this._token, path, signal));
|
|
804
830
|
}
|
|
831
|
+
proxySitemap(sitemapId, options, signal) {
|
|
832
|
+
return wrap("@contello/client:proxySitemap", () => proxySitemap(this._agent, this._url, this._token, this._project, sitemapId, options, signal));
|
|
833
|
+
}
|
|
805
834
|
upload(data, meta, options) {
|
|
806
835
|
return wrap("@contello/client:upload", () => upload(this._url, this._project, this._token, data, meta, options));
|
|
807
836
|
}
|
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';
|
|
@@ -201,7 +211,7 @@ type ContelloClientOptions<TSchema extends Schema | undefined = undefined> = {
|
|
|
201
211
|
onError?: ((error: unknown) => void) | undefined;
|
|
202
212
|
connectionEvents?: ConnectionEvents | undefined;
|
|
203
213
|
};
|
|
204
|
-
declare class ContelloClient<TSchema extends Schema | undefined = undefined> {
|
|
214
|
+
export declare class ContelloClient<TSchema extends Schema | undefined = undefined> {
|
|
205
215
|
private _pool;
|
|
206
216
|
private _rpc;
|
|
207
217
|
private _sources;
|
|
@@ -223,10 +233,11 @@ 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
|
}
|
|
229
|
-
declare function createContelloClient<TSchema extends Schema | undefined = undefined>(options: ContelloClientOptions<TSchema>): ContelloClient<TSchema>;
|
|
240
|
+
export declare function createContelloClient<TSchema extends Schema | undefined = undefined>(options: ContelloClientOptions<TSchema>): ContelloClient<TSchema>;
|
|
230
241
|
//#endregion
|
|
231
242
|
//#region src/scalars.d.ts
|
|
232
243
|
type LocalDateTime = {
|
|
@@ -244,7 +255,7 @@ type LocalDate = {
|
|
|
244
255
|
};
|
|
245
256
|
//#endregion
|
|
246
257
|
//#region src/source-subscription.d.ts
|
|
247
|
-
declare function createSourceSubscription(source: SourceDef): string;
|
|
258
|
+
export declare function createSourceSubscription(source: SourceDef): string;
|
|
248
259
|
//#endregion
|
|
249
260
|
//#region src/source-mutation.d.ts
|
|
250
261
|
type SourceMutationKind = keyof SourceMutations;
|
|
@@ -254,16 +265,16 @@ type SourceMutationValues = {
|
|
|
254
265
|
id?: string | undefined;
|
|
255
266
|
};
|
|
256
267
|
/** The mutation document for one write operation of a source. Cached per source + kind. */
|
|
257
|
-
declare function createSourceMutation(source: SourceDef, kind: SourceMutationKind): string;
|
|
268
|
+
export declare function createSourceMutation(source: SourceDef, kind: SourceMutationKind): string;
|
|
258
269
|
/**
|
|
259
270
|
* Variables for a write: one per bound argument, the input nested under the envelope field when
|
|
260
271
|
* the argument is a one-field wrapper, and everything encoded on the way out (LocalDate /
|
|
261
272
|
* LocalDateTime structs become wire strings) — every caller goes through here, so no write path
|
|
262
273
|
* can skip the encoding.
|
|
263
274
|
*/
|
|
264
|
-
declare function createSourceMutationVariables(binding: SourceMutationBinding, values: SourceMutationValues): Record<string, unknown>;
|
|
275
|
+
export declare function createSourceMutationVariables(binding: SourceMutationBinding, values: SourceMutationValues): Record<string, unknown>;
|
|
265
276
|
/** Pulls the id out of whatever shape the mutation answered with. */
|
|
266
|
-
declare function readSourceMutationId(binding: SourceMutationBinding, result: unknown): string;
|
|
277
|
+
export declare function readSourceMutationId(binding: SourceMutationBinding, result: unknown): string;
|
|
267
278
|
//#endregion
|
|
268
279
|
//#region src/built-in-mutations.d.ts
|
|
269
280
|
/**
|
|
@@ -278,7 +289,7 @@ declare function readSourceMutationId(binding: SourceMutationBinding, result: un
|
|
|
278
289
|
*
|
|
279
290
|
* Assets have no `create` — an asset comes into being through `client.upload()`, not a mutation.
|
|
280
291
|
*/
|
|
281
|
-
declare const BUILT_IN_MUTATIONS: Partial<Record<SourceCardinality, SourceMutations>>;
|
|
292
|
+
export declare const BUILT_IN_MUTATIONS: Partial<Record<SourceCardinality, SourceMutations>>;
|
|
282
293
|
//#endregion
|
|
283
|
-
export {
|
|
294
|
+
export type { ConnectionContext, ConnectionEvents, ContelloClientOptions, DownloadResult, HttpAgentOptions, LocalDate, LocalDateTime, OperationDef, OperationKind, OperationMap, ProxyResult, Rpc, Schema, SitemapProxyOptions, SourceAccessors, SourceCardinality, SourceDef, SourceMap, SourceMutationArgument, SourceMutationBinding, SourceMutationKind, SourceMutationResult, SourceMutationValues, SourceMutations, SourceWrites, UploadData, UploadMetadata, UploadOptions };
|
|
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":["NodeReadableStream"],"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;;;;;;KAOA;;EAEV;;EAEA;;EAEA;;;;;EAKA;;;;;;;;KASU;;;;;KAMA;;EAEV;EACA,WAAW;EACX,QAAQ;;;KAIE;EACV,SAAS;EACT,SAAS;EACT,SAAS;;;;;;;KAQC;EACV;EACA;EACA;;KAGU,UACV,gCACA,qBAAqB,oBAAoB,mBACzC,mBACA;;EAGA;;EAEA;;EAEA;;EAEA,YAAY;EACZ,SAAS;EACT,eAAe;;EAEf,WAAW;;EAEX,WAAW;;KAGD,YAAY,eAAe;;;;;;;KAQ3B,OACV,aAAa,eAAe,cAC5B,iBAAiB,YAAY,WAC7B;EAEA,YAAY;EACZ,SAAS;EACT,QAAQ,OAAO;;KAGZ,iBAAiB,KACpB,UAAU,qCAAqC,WACrC,QAAQ,KACd,UAAU,kCAAkC,MACzC;EAAS;MAAqB,QAAQ,OACvC,UAAU,iCAAiC,MACxC;EAAS;EAA4B;kB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,0BACR,QAAQ;EAOX,OAAO,MAAM,YAAY,MAAM,gBAAgB,UAAU,4BAA4B;EAOrF,QAAQ,OAAO,eAAe,YAAY,sCAAsC,QAAQ;;wBAS1E,qBAAqB,gBAAgB,gCACnD,SAAS,sBAAsB,WAC9B,eAAe;;;KCtTN;EACV;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;;;;wBCcc,yBAAyB,QAAQ;;;KCvBrC,2BAA2B;;KAG3B;EACV;EACA;;;wBAwBc,qBAAqB,QAAQ,WAAW,MAAM;;;;;;;wBA+B9C,8BACd,SAAS,uBACT,QAAQ,uBACP;;wBAYa,qBAAqB,SAAS,uBAAuB;;;;;;;;;;;;;;;qBChExD,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';
|
|
@@ -201,7 +211,7 @@ type ContelloClientOptions<TSchema extends Schema | undefined = undefined> = {
|
|
|
201
211
|
onError?: ((error: unknown) => void) | undefined;
|
|
202
212
|
connectionEvents?: ConnectionEvents | undefined;
|
|
203
213
|
};
|
|
204
|
-
declare class ContelloClient<TSchema extends Schema | undefined = undefined> {
|
|
214
|
+
export declare class ContelloClient<TSchema extends Schema | undefined = undefined> {
|
|
205
215
|
private _pool;
|
|
206
216
|
private _rpc;
|
|
207
217
|
private _sources;
|
|
@@ -223,10 +233,11 @@ 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
|
}
|
|
229
|
-
declare function createContelloClient<TSchema extends Schema | undefined = undefined>(options: ContelloClientOptions<TSchema>): ContelloClient<TSchema>;
|
|
240
|
+
export declare function createContelloClient<TSchema extends Schema | undefined = undefined>(options: ContelloClientOptions<TSchema>): ContelloClient<TSchema>;
|
|
230
241
|
//#endregion
|
|
231
242
|
//#region src/scalars.d.ts
|
|
232
243
|
type LocalDateTime = {
|
|
@@ -244,7 +255,7 @@ type LocalDate = {
|
|
|
244
255
|
};
|
|
245
256
|
//#endregion
|
|
246
257
|
//#region src/source-subscription.d.ts
|
|
247
|
-
declare function createSourceSubscription(source: SourceDef): string;
|
|
258
|
+
export declare function createSourceSubscription(source: SourceDef): string;
|
|
248
259
|
//#endregion
|
|
249
260
|
//#region src/source-mutation.d.ts
|
|
250
261
|
type SourceMutationKind = keyof SourceMutations;
|
|
@@ -254,16 +265,16 @@ type SourceMutationValues = {
|
|
|
254
265
|
id?: string | undefined;
|
|
255
266
|
};
|
|
256
267
|
/** The mutation document for one write operation of a source. Cached per source + kind. */
|
|
257
|
-
declare function createSourceMutation(source: SourceDef, kind: SourceMutationKind): string;
|
|
268
|
+
export declare function createSourceMutation(source: SourceDef, kind: SourceMutationKind): string;
|
|
258
269
|
/**
|
|
259
270
|
* Variables for a write: one per bound argument, the input nested under the envelope field when
|
|
260
271
|
* the argument is a one-field wrapper, and everything encoded on the way out (LocalDate /
|
|
261
272
|
* LocalDateTime structs become wire strings) — every caller goes through here, so no write path
|
|
262
273
|
* can skip the encoding.
|
|
263
274
|
*/
|
|
264
|
-
declare function createSourceMutationVariables(binding: SourceMutationBinding, values: SourceMutationValues): Record<string, unknown>;
|
|
275
|
+
export declare function createSourceMutationVariables(binding: SourceMutationBinding, values: SourceMutationValues): Record<string, unknown>;
|
|
265
276
|
/** Pulls the id out of whatever shape the mutation answered with. */
|
|
266
|
-
declare function readSourceMutationId(binding: SourceMutationBinding, result: unknown): string;
|
|
277
|
+
export declare function readSourceMutationId(binding: SourceMutationBinding, result: unknown): string;
|
|
267
278
|
//#endregion
|
|
268
279
|
//#region src/built-in-mutations.d.ts
|
|
269
280
|
/**
|
|
@@ -278,7 +289,7 @@ declare function readSourceMutationId(binding: SourceMutationBinding, result: un
|
|
|
278
289
|
*
|
|
279
290
|
* Assets have no `create` — an asset comes into being through `client.upload()`, not a mutation.
|
|
280
291
|
*/
|
|
281
|
-
declare const BUILT_IN_MUTATIONS: Partial<Record<SourceCardinality, SourceMutations>>;
|
|
292
|
+
export declare const BUILT_IN_MUTATIONS: Partial<Record<SourceCardinality, SourceMutations>>;
|
|
282
293
|
//#endregion
|
|
283
|
-
export {
|
|
294
|
+
export type { ConnectionContext, ConnectionEvents, ContelloClientOptions, DownloadResult, HttpAgentOptions, LocalDate, LocalDateTime, OperationDef, OperationKind, OperationMap, ProxyResult, Rpc, Schema, SitemapProxyOptions, SourceAccessors, SourceCardinality, SourceDef, SourceMap, SourceMutationArgument, SourceMutationBinding, SourceMutationKind, SourceMutationResult, SourceMutationValues, SourceMutations, SourceWrites, UploadData, UploadMetadata, UploadOptions };
|
|
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":["NodeReadableStream"],"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;;;;;;KAOA;;EAEV;;EAEA;;EAEA;;;;;EAKA;;;;;;;;KASU;;;;;KAMA;;EAEV;EACA,WAAW;EACX,QAAQ;;;KAIE;EACV,SAAS;EACT,SAAS;EACT,SAAS;;;;;;;KAQC;EACV;EACA;EACA;;KAGU,UACV,gCACA,qBAAqB,oBAAoB,mBACzC,mBACA;;EAGA;;EAEA;;EAEA;;EAEA,YAAY;EACZ,SAAS;EACT,eAAe;;EAEf,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OAAO,gBAAgB,aAAa,kBAAkB,IAAI;MAQ1D,WAAW,gBAAgB,kBAAkB,iBAAiB,gBAAgB;EAQ5E,QAAQ;EAIR,WAAW;EAKX,QAAQ;;;;;;EAUd,UAAU,OAAO,eAAe,YAAY,sCAAsC,cAAc;EA2FhG,SAAS,iBAAiB,QAAQ;EAIlC,SAAS,cAAc,SAAS,0BAA0B,QAAQ;EAIlE,aACE,mBACA,SAAS,qBACT,SAAS,0BACR,QAAQ;EAOX,OAAO,MAAM,YAAY,MAAM,gBAAgB,UAAU,4BAA4B;EAOrF,QAAQ,OAAO,eAAe,YAAY,sCAAsC,QAAQ;;wBAS1E,qBAAqB,gBAAgB,gCACnD,SAAS,sBAAsB,WAC9B,eAAe;;;KCtTN;EACV;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;;;;wBCcc,yBAAyB,QAAQ;;;KCvBrC,2BAA2B;;KAG3B;EACV;EACA;;;wBAwBc,qBAAqB,QAAQ,WAAW,MAAM;;;;;;;wBA+B9C,8BACd,SAAS,uBACT,QAAQ,uBACP;;wBAYa,qBAAqB,SAAS,uBAAuB;;;;;;;;;;;;;;;qBChExD,oBAAoB,QAAQ,OAAO,mBAAmB"}
|
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)) {
|
|
@@ -605,12 +636,11 @@ function upload(url, project, token, data, meta, options) {
|
|
|
605
636
|
else sendStream(data);
|
|
606
637
|
return;
|
|
607
638
|
}
|
|
608
|
-
if (message.type
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
}
|
|
639
|
+
if (message.type !== "done") return;
|
|
640
|
+
done = true;
|
|
641
|
+
cleanup();
|
|
642
|
+
ws.close();
|
|
643
|
+
resolve(message.id);
|
|
614
644
|
});
|
|
615
645
|
ws.addEventListener("error", () => {
|
|
616
646
|
cleanup();
|
|
@@ -643,17 +673,15 @@ var ContelloClient = class {
|
|
|
643
673
|
let connectedCount = 0;
|
|
644
674
|
const onConnectionUp = () => {
|
|
645
675
|
connectedCount++;
|
|
646
|
-
if (connectedCount
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
}
|
|
676
|
+
if (connectedCount !== connections || state === "connected") return;
|
|
677
|
+
state = "connected";
|
|
678
|
+
options.onConnected?.();
|
|
650
679
|
};
|
|
651
680
|
const onConnectionDown = () => {
|
|
652
681
|
if (connectedCount > 0) connectedCount--;
|
|
653
|
-
if (state
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
}
|
|
682
|
+
if (state !== "connected") return;
|
|
683
|
+
state = "reconnecting";
|
|
684
|
+
options.onReconnecting?.();
|
|
657
685
|
};
|
|
658
686
|
this._pool = new ConnectionPool((id) => {
|
|
659
687
|
const context = Object.freeze({
|
|
@@ -745,22 +773,20 @@ var ContelloClient = class {
|
|
|
745
773
|
error(err) {
|
|
746
774
|
done = true;
|
|
747
775
|
error = err;
|
|
748
|
-
if (pending)
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
}
|
|
776
|
+
if (!pending) return;
|
|
777
|
+
const p = pending;
|
|
778
|
+
pending = void 0;
|
|
779
|
+
p.reject(err);
|
|
753
780
|
},
|
|
754
781
|
complete() {
|
|
755
782
|
done = true;
|
|
756
|
-
if (pending)
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
}
|
|
783
|
+
if (!pending) return;
|
|
784
|
+
const p = pending;
|
|
785
|
+
pending = void 0;
|
|
786
|
+
p.resolve({
|
|
787
|
+
value: void 0,
|
|
788
|
+
done: true
|
|
789
|
+
});
|
|
764
790
|
}
|
|
765
791
|
});
|
|
766
792
|
return {
|
|
@@ -801,6 +827,9 @@ var ContelloClient = class {
|
|
|
801
827
|
proxyHls(path, signal) {
|
|
802
828
|
return wrap("@contello/client:proxyHls", () => proxyHls(this._agent, this._url, this._token, path, signal));
|
|
803
829
|
}
|
|
830
|
+
proxySitemap(sitemapId, options, signal) {
|
|
831
|
+
return wrap("@contello/client:proxySitemap", () => proxySitemap(this._agent, this._url, this._token, this._project, sitemapId, options, signal));
|
|
832
|
+
}
|
|
804
833
|
upload(data, meta, options) {
|
|
805
834
|
return wrap("@contello/client:upload", () => upload(this._url, this._project, this._token, data, meta, options));
|
|
806
835
|
}
|