@aglyn/tenant-data-admin 1.0.0-beta.250 → 1.0.0-beta.253
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/package.json +7 -7
- package/src/lib/server/ad-audience-sync-run.d.ts +134 -0
- package/src/lib/server/ad-audience-sync-run.js +364 -0
- package/src/lib/server/ad-audience-sync-run.js.map +1 -0
- package/src/lib/server/ad-audience-sync.d.ts +250 -0
- package/src/lib/server/ad-audience-sync.js +446 -0
- package/src/lib/server/ad-audience-sync.js.map +1 -0
- package/src/lib/server/consent-by-address.d.ts +101 -0
- package/src/lib/server/consent-by-address.js +178 -0
- package/src/lib/server/consent-by-address.js.map +1 -0
- package/src/lib/server/notifications.d.ts +23 -0
- package/src/lib/server/notifications.js +35 -16
- package/src/lib/server/notifications.js.map +1 -1
- package/src/lib/server/serve-media-cdn.js +4 -1
- package/src/lib/server/serve-media-cdn.js.map +1 -1
- package/src/lib/server/storage-read-stream.d.ts +43 -0
- package/src/lib/server/storage-read-stream.js +77 -0
- package/src/lib/server/storage-read-stream.js.map +1 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* The listener limit for a Storage response body. The measured peak is 12
|
|
19
|
+
* (`error`). Room for a few more lets a library patch add one without
|
|
20
|
+
* bringing the warning back, but stays low enough that a per-chunk or
|
|
21
|
+
* per-request leak would still cross it within one read.
|
|
22
|
+
*/
|
|
23
|
+
export declare const STORAGE_READ_BODY_LISTENER_BUDGET = 16;
|
|
24
|
+
/** The slice of a Storage `File` a read needs. */
|
|
25
|
+
export interface StorageReadableFile {
|
|
26
|
+
createReadStream(options?: StorageReadOptions): NodeJS.ReadableStream;
|
|
27
|
+
}
|
|
28
|
+
/** The `createReadStream` options the platform uses. */
|
|
29
|
+
export interface StorageReadOptions {
|
|
30
|
+
start?: number;
|
|
31
|
+
end?: number;
|
|
32
|
+
validation?: 'crc32c' | 'md5' | boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* `file.createReadStream(options)`, with the response body's listener
|
|
36
|
+
* limit sized to Storage's fixed fan-out (see the module note).
|
|
37
|
+
*/
|
|
38
|
+
export declare function openStorageReadStream(file: StorageReadableFile, options?: StorageReadOptions): NodeJS.ReadableStream;
|
|
39
|
+
/**
|
|
40
|
+
* The whole object as one Buffer, like `file.download()`, read through
|
|
41
|
+
* {@link openStorageReadStream}. Rejects when the read fails.
|
|
42
|
+
*/
|
|
43
|
+
export declare function readStorageObject(file: StorageReadableFile, options?: StorageReadOptions): Promise<Buffer>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ /**
|
|
17
|
+
* Reading a Cloud Storage object without a false leak warning (AGL-3795).
|
|
18
|
+
*
|
|
19
|
+
* ## Why every Storage read used to warn
|
|
20
|
+
*
|
|
21
|
+
* `File#createReadStream` (and `File#download`, which is built on it) hands
|
|
22
|
+
* the HTTP response body, a node-fetch `PassThrough`, to three `pipeline`s at
|
|
23
|
+
* once:
|
|
24
|
+
*
|
|
25
|
+
* 1. node-fetch's own, from the socket into the body;
|
|
26
|
+
* 2. teeny-request's, from the body into the retry-request stream, which
|
|
27
|
+
* Storage only `resume()`s;
|
|
28
|
+
* 3. Storage's, from the body into the read stream it returns.
|
|
29
|
+
*
|
|
30
|
+
* On Node 24 those add 12 `error` listeners and 11 `close` listeners to the
|
|
31
|
+
* body. Node's limit is 10, so `MaxListenersExceededWarning` fired once per
|
|
32
|
+
* read on every route that touches Storage. The count is a fixed fan-out: it
|
|
33
|
+
* is the same for a 1-chunk and a 200-chunk object and for the first and the
|
|
34
|
+
* hundredth request, and the listeners go away with the body when the read
|
|
35
|
+
* ends. So nothing accumulates. The warning is a heuristic tripping on a
|
|
36
|
+
* library's wiring.
|
|
37
|
+
*
|
|
38
|
+
* ## What this does
|
|
39
|
+
*
|
|
40
|
+
* Storage re-emits the body as the read stream's `response` event before it
|
|
41
|
+
* or teeny-request attaches its `pipeline`. At that point, only on that one
|
|
42
|
+
* per-request body, the limit is raised to {@link STORAGE_READ_BODY_LISTENER_BUDGET}:
|
|
43
|
+
* the measured fan-out plus a little headroom. The process default stays at
|
|
44
|
+
* 10, so a real leak anywhere still warns, and so does a real leak on this
|
|
45
|
+
* body once it grows past the budget.
|
|
46
|
+
*/ import { buffer } from "node:stream/consumers";
|
|
47
|
+
/**
|
|
48
|
+
* The listener limit for a Storage response body. The measured peak is 12
|
|
49
|
+
* (`error`). Room for a few more lets a library patch add one without
|
|
50
|
+
* bringing the warning back, but stays low enough that a per-chunk or
|
|
51
|
+
* per-request leak would still cross it within one read.
|
|
52
|
+
*/ export const STORAGE_READ_BODY_LISTENER_BUDGET = 16;
|
|
53
|
+
/** Raises the limit on the response body Storage just received. */ function budgetResponseBody(body) {
|
|
54
|
+
var _ref;
|
|
55
|
+
const emitter = body;
|
|
56
|
+
if (typeof (emitter == null ? void 0 : emitter.setMaxListeners) !== 'function') return;
|
|
57
|
+
const current = (_ref = emitter.getMaxListeners == null ? void 0 : emitter.getMaxListeners.call(emitter)) != null ? _ref : 0;
|
|
58
|
+
// 0 means unlimited, and a higher limit was set on purpose by someone else.
|
|
59
|
+
if (current === 0 || current >= STORAGE_READ_BODY_LISTENER_BUDGET) return;
|
|
60
|
+
emitter.setMaxListeners(STORAGE_READ_BODY_LISTENER_BUDGET);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* `file.createReadStream(options)`, with the response body's listener
|
|
64
|
+
* limit sized to Storage's fixed fan-out (see the module note).
|
|
65
|
+
*/ export function openStorageReadStream(file, options = {}) {
|
|
66
|
+
const stream = file.createReadStream(options);
|
|
67
|
+
stream.once('response', budgetResponseBody);
|
|
68
|
+
return stream;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The whole object as one Buffer, like `file.download()`, read through
|
|
72
|
+
* {@link openStorageReadStream}. Rejects when the read fails.
|
|
73
|
+
*/ export async function readStorageObject(file, options = {}) {
|
|
74
|
+
return buffer(openStorageReadStream(file, options));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=storage-read-stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/tenant/data/admin/src/lib/server/storage-read-stream.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Reading a Cloud Storage object without a false leak warning (AGL-3795).\n *\n * ## Why every Storage read used to warn\n *\n * `File#createReadStream` (and `File#download`, which is built on it) hands\n * the HTTP response body, a node-fetch `PassThrough`, to three `pipeline`s at\n * once:\n *\n * 1. node-fetch's own, from the socket into the body;\n * 2. teeny-request's, from the body into the retry-request stream, which\n * Storage only `resume()`s;\n * 3. Storage's, from the body into the read stream it returns.\n *\n * On Node 24 those add 12 `error` listeners and 11 `close` listeners to the\n * body. Node's limit is 10, so `MaxListenersExceededWarning` fired once per\n * read on every route that touches Storage. The count is a fixed fan-out: it\n * is the same for a 1-chunk and a 200-chunk object and for the first and the\n * hundredth request, and the listeners go away with the body when the read\n * ends. So nothing accumulates. The warning is a heuristic tripping on a\n * library's wiring.\n *\n * ## What this does\n *\n * Storage re-emits the body as the read stream's `response` event before it\n * or teeny-request attaches its `pipeline`. At that point, only on that one\n * per-request body, the limit is raised to {@link STORAGE_READ_BODY_LISTENER_BUDGET}:\n * the measured fan-out plus a little headroom. The process default stays at\n * 10, so a real leak anywhere still warns, and so does a real leak on this\n * body once it grows past the budget.\n */\n\nimport type { Readable } from 'node:stream'\nimport { buffer } from 'node:stream/consumers'\n\n/**\n * The listener limit for a Storage response body. The measured peak is 12\n * (`error`). Room for a few more lets a library patch add one without\n * bringing the warning back, but stays low enough that a per-chunk or\n * per-request leak would still cross it within one read.\n */\nexport const STORAGE_READ_BODY_LISTENER_BUDGET = 16\n\n/** The slice of a Storage `File` a read needs. */\nexport interface StorageReadableFile {\n createReadStream(options?: StorageReadOptions): NodeJS.ReadableStream\n}\n\n/** The `createReadStream` options the platform uses. */\nexport interface StorageReadOptions {\n start?: number\n end?: number\n validation?: 'crc32c' | 'md5' | boolean\n}\n\n/** Raises the limit on the response body Storage just received. */\nfunction budgetResponseBody(body: unknown): void {\n const emitter = body as\n | { getMaxListeners?: () => number; setMaxListeners?: (n: number) => unknown }\n | null\n | undefined\n if (typeof emitter?.setMaxListeners !== 'function') return\n const current = emitter.getMaxListeners?.() ?? 0\n // 0 means unlimited, and a higher limit was set on purpose by someone else.\n if (current === 0 || current >= STORAGE_READ_BODY_LISTENER_BUDGET) return\n emitter.setMaxListeners(STORAGE_READ_BODY_LISTENER_BUDGET)\n}\n\n/**\n * `file.createReadStream(options)`, with the response body's listener\n * limit sized to Storage's fixed fan-out (see the module note).\n */\nexport function openStorageReadStream(\n file: StorageReadableFile,\n options: StorageReadOptions = {},\n): NodeJS.ReadableStream {\n const stream = file.createReadStream(options)\n stream.once('response', budgetResponseBody)\n return stream\n}\n\n/**\n * The whole object as one Buffer, like `file.download()`, read through\n * {@link openStorageReadStream}. Rejects when the read fails.\n */\nexport async function readStorageObject(\n file: StorageReadableFile,\n options: StorageReadOptions = {},\n): Promise<Buffer> {\n return buffer(openStorageReadStream(file, options) as Readable)\n}\n"],"names":["buffer","STORAGE_READ_BODY_LISTENER_BUDGET","budgetResponseBody","body","emitter","setMaxListeners","current","getMaxListeners","openStorageReadStream","file","options","stream","createReadStream","once","readStorageObject"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BC,GAGD,SAASA,MAAM,QAAQ,wBAAuB;AAE9C;;;;;CAKC,GACD,OAAO,MAAMC,oCAAoC,GAAE;AAcnD,iEAAiE,GACjE,SAASC,mBAAmBC,IAAa;;IACvC,MAAMC,UAAUD;IAIhB,IAAI,QAAOC,2BAAAA,QAASC,eAAe,MAAK,YAAY;IACpD,MAAMC,kBAAUF,QAAQG,eAAe,oBAAvBH,QAAQG,eAAe,MAAvBH,2BAA+B;IAC/C,4EAA4E;IAC5E,IAAIE,YAAY,KAAKA,WAAWL,mCAAmC;IACnEG,QAAQC,eAAe,CAACJ;AAC1B;AAEA;;;CAGC,GACD,OAAO,SAASO,sBACdC,IAAyB,EACzBC,UAA8B,CAAC,CAAC;IAEhC,MAAMC,SAASF,KAAKG,gBAAgB,CAACF;IACrCC,OAAOE,IAAI,CAAC,YAAYX;IACxB,OAAOS;AACT;AAEA;;;CAGC,GACD,OAAO,eAAeG,kBACpBL,IAAyB,EACzBC,UAA8B,CAAC,CAAC;IAEhC,OAAOV,OAAOQ,sBAAsBC,MAAMC;AAC5C"}
|