@hot-updater/aws 1.0.0-rc.0 → 1.0.0-rc.2
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/iac/index.cjs +523 -242
- package/dist/iac/index.d.cts +1 -5
- package/dist/iac/index.d.mts +1 -5
- package/dist/iac/index.mjs +519 -238
- package/dist/index.cjs +324 -100
- package/dist/index.d.cts +5 -7
- package/dist/index.d.mts +3 -6
- package/dist/index.mjs +325 -101
- package/dist/lambda/index.cjs +1436 -931
- package/dist/lambda/index.d.cts +0 -1
- package/package.json +6 -6
package/dist/iac/index.mjs
CHANGED
|
@@ -17,15 +17,15 @@ import { appendFileSync, createReadStream, createWriteStream, readFileSync, stat
|
|
|
17
17
|
import { finished } from "node:stream/promises";
|
|
18
18
|
import { Duplex, PassThrough, Readable, Transform, Writable, getDefaultHighWaterMark } from "node:stream";
|
|
19
19
|
import { Buffer as Buffer$1 } from "node:buffer";
|
|
20
|
+
import { createHash } from "node:crypto";
|
|
20
21
|
import { CloudFront, CloudFrontClient, CreateInvalidationCommand, GetInvalidationCommand } from "@aws-sdk/client-cloudfront";
|
|
21
22
|
import { DynamoDB, DynamoDBClient, waitUntilTableExists } from "@aws-sdk/client-dynamodb";
|
|
22
23
|
import { BatchGetCommand, DynamoDBDocumentClient, GetCommand, PutCommand, QueryCommand, ScanCommand, TransactWriteCommand } from "@aws-sdk/lib-dynamodb";
|
|
23
|
-
import { createDatabasePlugin, isDatabaseMetadataObject } from "@hot-updater/plugin-core";
|
|
24
|
+
import { createDatabasePlugin, isDatabaseMetadataObject, isInsightsMovementEvent } from "@hot-updater/plugin-core";
|
|
24
25
|
import { createDatabasePluginAdapter } from "@hot-updater/plugin-core/internal";
|
|
25
26
|
import { fromIni, fromNodeProviderChain, fromSSO } from "@aws-sdk/credential-providers";
|
|
26
27
|
import { Lambda } from "@aws-sdk/client-lambda";
|
|
27
28
|
import crypto from "crypto";
|
|
28
|
-
import { createHash } from "node:crypto";
|
|
29
29
|
import { IAM } from "@aws-sdk/client-iam";
|
|
30
30
|
import { STS } from "@aws-sdk/client-sts";
|
|
31
31
|
import fs from "fs/promises";
|
|
@@ -38,7 +38,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
38
38
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
39
39
|
var __getProtoOf = Object.getPrototypeOf;
|
|
40
40
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
41
|
-
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
41
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
42
42
|
var __copyProps = (to, from, except, desc) => {
|
|
43
43
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
44
44
|
key = keys[i];
|
|
@@ -49,11 +49,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
49
49
|
}
|
|
50
50
|
return to;
|
|
51
51
|
};
|
|
52
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
52
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
53
53
|
value: mod,
|
|
54
54
|
enumerable: true
|
|
55
55
|
}) : target, mod));
|
|
56
|
-
var __require = /*
|
|
56
|
+
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
57
57
|
//#endregion
|
|
58
58
|
//#region ../../node_modules/.pnpm/is-plain-obj@4.1.0/node_modules/is-plain-obj/index.js
|
|
59
59
|
function isPlainObject(value) {
|
|
@@ -153,7 +153,8 @@ const parseTemplate = ({ templates, expressions, tokens, index, template }) => {
|
|
|
153
153
|
const newTokens = concatTokens(tokens, nextTokens, leadingWhitespaces);
|
|
154
154
|
if (index === expressions.length) return newTokens;
|
|
155
155
|
const expression = expressions[index];
|
|
156
|
-
|
|
156
|
+
const expressionTokens = Array.isArray(expression) ? expression.map((expression) => parseExpression(expression)) : [parseExpression(expression)];
|
|
157
|
+
return concatTokens(newTokens, expressionTokens, trailingWhitespaces);
|
|
157
158
|
};
|
|
158
159
|
const splitByWhitespaces = (template, rawTemplate) => {
|
|
159
160
|
if (rawTemplate.length === 0) return {
|
|
@@ -186,7 +187,7 @@ const splitByWhitespaces = (template, rawTemplate) => {
|
|
|
186
187
|
trailingWhitespaces
|
|
187
188
|
};
|
|
188
189
|
};
|
|
189
|
-
const DELIMITERS = new Set([
|
|
190
|
+
const DELIMITERS = /* @__PURE__ */ new Set([
|
|
190
191
|
" ",
|
|
191
192
|
" ",
|
|
192
193
|
"\r",
|
|
@@ -238,7 +239,8 @@ const normalizeFdSpecificOptions = (options) => {
|
|
|
238
239
|
};
|
|
239
240
|
const normalizeFdSpecificOption = (options, optionName) => {
|
|
240
241
|
const optionBaseArray = Array.from({ length: getStdioLength(options) + 1 });
|
|
241
|
-
|
|
242
|
+
const optionArray = normalizeFdSpecificValue(options[optionName], optionBaseArray, optionName);
|
|
243
|
+
return addDefaultValue$1(optionArray, optionName);
|
|
242
244
|
};
|
|
243
245
|
const getStdioLength = ({ stdio }) => Array.isArray(stdio) ? Math.max(stdio.length, STANDARD_STREAMS_ALIASES.length) : STANDARD_STREAMS_ALIASES.length;
|
|
244
246
|
const normalizeFdSpecificValue = (optionValue, optionArray, optionName) => isPlainObject(optionValue) ? normalizeOptionObject(optionValue, optionArray, optionName) : optionArray.fill(optionValue);
|
|
@@ -271,7 +273,7 @@ const addDefaultValue$1 = (optionArray, optionName) => optionArray.map((optionVa
|
|
|
271
273
|
const DEFAULT_OPTIONS = {
|
|
272
274
|
lines: false,
|
|
273
275
|
buffer: true,
|
|
274
|
-
maxBuffer:
|
|
276
|
+
maxBuffer: 1e8,
|
|
275
277
|
verbose: debuglog("execa").enabled ? "full" : "none",
|
|
276
278
|
stripFinalNewline: true
|
|
277
279
|
};
|
|
@@ -319,7 +321,7 @@ const escapeControlCharacter = (character) => {
|
|
|
319
321
|
};
|
|
320
322
|
const getSpecialCharRegExp = () => {
|
|
321
323
|
try {
|
|
322
|
-
return
|
|
324
|
+
return new RegExp("\\p{Separator}|\\p{Other}", "gu");
|
|
323
325
|
} catch {
|
|
324
326
|
return /[\s\u0000-\u001F\u007F-\u009F\u00AD]/g;
|
|
325
327
|
}
|
|
@@ -739,11 +741,13 @@ const appendNewline = (printedLine) => printedLine.endsWith("\n") ? printedLine
|
|
|
739
741
|
//#endregion
|
|
740
742
|
//#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/verbose/log.js
|
|
741
743
|
const verboseLog = ({ type, verboseMessage, fdNumber, verboseInfo, result }) => {
|
|
742
|
-
const
|
|
744
|
+
const verboseObject = getVerboseObject({
|
|
743
745
|
type,
|
|
744
746
|
result,
|
|
745
747
|
verboseInfo
|
|
746
|
-
})
|
|
748
|
+
});
|
|
749
|
+
const printedLines = getPrintedLines(verboseMessage, verboseObject);
|
|
750
|
+
const finalLines = applyVerboseOnLines(printedLines, verboseInfo, fdNumber);
|
|
747
751
|
if (finalLines !== "") console.warn(finalLines.slice(0, -1));
|
|
748
752
|
};
|
|
749
753
|
const getVerboseObject = ({ type, result, verboseInfo: { escapedCommand, commandId, rawOptions: { piped = false, ...options } } }) => ({
|
|
@@ -766,7 +770,8 @@ const getPrintedLine = (verboseObject) => {
|
|
|
766
770
|
};
|
|
767
771
|
};
|
|
768
772
|
const serializeVerboseMessage = (message) => {
|
|
769
|
-
|
|
773
|
+
const messageString = typeof message === "string" ? message : inspect(message);
|
|
774
|
+
return escapeLines(messageString).replaceAll(" ", " ".repeat(TAB_SIZE));
|
|
770
775
|
};
|
|
771
776
|
const TAB_SIZE = 2;
|
|
772
777
|
//#endregion
|
|
@@ -811,7 +816,8 @@ const getDurationMs = (startTime) => Number(hrtime.bigint() - startTime) / 1e6;
|
|
|
811
816
|
const handleCommand = (filePath, rawArguments, rawOptions) => {
|
|
812
817
|
const startTime = getStartTime();
|
|
813
818
|
const { command, escapedCommand } = joinCommand(filePath, rawArguments);
|
|
814
|
-
const
|
|
819
|
+
const verbose = normalizeFdSpecificOption(rawOptions, "verbose");
|
|
820
|
+
const verboseInfo = getVerboseInfo(verbose, escapedCommand, { ...rawOptions });
|
|
815
821
|
logCommand(escapedCommand, verboseInfo);
|
|
816
822
|
return {
|
|
817
823
|
command,
|
|
@@ -932,7 +938,8 @@ var require_which = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
932
938
|
const getNotFoundError = (cmd) => Object.assign(/* @__PURE__ */ new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
933
939
|
const getPathInfo = (cmd, opt) => {
|
|
934
940
|
const colon = opt.colon || COLON;
|
|
935
|
-
const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [...isWindows ? [process.cwd()] : [], ...(opt.path || process.env.PATH ||
|
|
941
|
+
const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [...isWindows ? [process.cwd()] : [], ...(opt.path || process.env.PATH ||
|
|
942
|
+
/* istanbul ignore next: very unusual */ "").split(colon)];
|
|
936
943
|
const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
|
|
937
944
|
const pathExt = isWindows ? pathExtExe.split(colon) : [""];
|
|
938
945
|
if (isWindows) {
|
|
@@ -957,14 +964,17 @@ var require_which = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
957
964
|
const ppRaw = pathEnv[i];
|
|
958
965
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
959
966
|
const pCmd = path$4.join(pathPart, cmd);
|
|
960
|
-
|
|
967
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
968
|
+
resolve(subStep(p, i, 0));
|
|
961
969
|
});
|
|
962
970
|
const subStep = (p, i, ii) => new Promise((resolve, reject) => {
|
|
963
971
|
if (ii === pathExt.length) return resolve(step(i + 1));
|
|
964
972
|
const ext = pathExt[ii];
|
|
965
973
|
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
966
|
-
if (!er && is)
|
|
967
|
-
|
|
974
|
+
if (!er && is) {
|
|
975
|
+
if (opt.all) found.push(p + ext);
|
|
976
|
+
else return resolve(p + ext);
|
|
977
|
+
}
|
|
968
978
|
return resolve(subStep(p, i, ii + 1));
|
|
969
979
|
});
|
|
970
980
|
});
|
|
@@ -982,8 +992,10 @@ var require_which = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
982
992
|
for (let j = 0; j < pathExt.length; j++) {
|
|
983
993
|
const cur = p + pathExt[j];
|
|
984
994
|
try {
|
|
985
|
-
if (isexe.sync(cur, { pathExt: pathExtExe }))
|
|
986
|
-
|
|
995
|
+
if (isexe.sync(cur, { pathExt: pathExtExe })) {
|
|
996
|
+
if (opt.all) found.push(cur);
|
|
997
|
+
else return cur;
|
|
998
|
+
}
|
|
987
999
|
} catch (ex) {}
|
|
988
1000
|
}
|
|
989
1001
|
}
|
|
@@ -1674,7 +1686,7 @@ const normalizeForceKillAfterDelay = (forceKillAfterDelay) => {
|
|
|
1674
1686
|
if (!Number.isFinite(forceKillAfterDelay) || forceKillAfterDelay < 0) throw new TypeError(`Expected the \`forceKillAfterDelay\` option to be a non-negative integer, got \`${forceKillAfterDelay}\` (${typeof forceKillAfterDelay})`);
|
|
1675
1687
|
return forceKillAfterDelay;
|
|
1676
1688
|
};
|
|
1677
|
-
const DEFAULT_FORCE_KILL_TIMEOUT =
|
|
1689
|
+
const DEFAULT_FORCE_KILL_TIMEOUT = 5e3;
|
|
1678
1690
|
const subprocessKill = ({ kill, options: { forceKillAfterDelay, killSignal }, onInternalError, context, controller }, signalOrError, errorArgument) => {
|
|
1679
1691
|
const { signal, error } = parseKillArguments(signalOrError, errorArgument, killSignal);
|
|
1680
1692
|
emitKillError(error, onInternalError);
|
|
@@ -1776,7 +1788,7 @@ const handleSerializationError = ({ error, methodName, isSubprocess, message })
|
|
|
1776
1788
|
if (isSerializationError(error)) throw new Error(`${getMethodName(methodName, isSubprocess)}'s argument type is invalid: the message cannot be serialized: ${String(message)}.`, { cause: error });
|
|
1777
1789
|
};
|
|
1778
1790
|
const isSerializationError = ({ code, message }) => SERIALIZATION_ERROR_CODES.has(code) || SERIALIZATION_ERROR_MESSAGES.some((serializationErrorMessage) => message.includes(serializationErrorMessage));
|
|
1779
|
-
const SERIALIZATION_ERROR_CODES = new Set(["ERR_MISSING_ARGS", "ERR_INVALID_ARG_TYPE"]);
|
|
1791
|
+
const SERIALIZATION_ERROR_CODES = /* @__PURE__ */ new Set(["ERR_MISSING_ARGS", "ERR_INVALID_ARG_TYPE"]);
|
|
1780
1792
|
const SERIALIZATION_ERROR_MESSAGES = [
|
|
1781
1793
|
"could not be cloned",
|
|
1782
1794
|
"circular structure",
|
|
@@ -1986,7 +1998,8 @@ const isConnected = (anyProcess) => {
|
|
|
1986
1998
|
//#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/ipc/strict.js
|
|
1987
1999
|
const handleSendStrict = ({ anyProcess, channel, isSubprocess, message, strict }) => {
|
|
1988
2000
|
if (!strict) return message;
|
|
1989
|
-
const
|
|
2001
|
+
const ipcEmitter = getIpcEmitter(anyProcess, channel, isSubprocess);
|
|
2002
|
+
const hasListeners = hasMessageListeners(anyProcess, ipcEmitter);
|
|
1990
2003
|
return {
|
|
1991
2004
|
id: count++,
|
|
1992
2005
|
type: REQUEST_TYPE,
|
|
@@ -2218,7 +2231,8 @@ const throwOnGracefulCancel = ({ subprocess, cancelSignal, gracefulCancel, force
|
|
|
2218
2231
|
})] : [];
|
|
2219
2232
|
const sendOnAbort = async ({ subprocess, cancelSignal, forceKillAfterDelay, context, controller: { signal } }) => {
|
|
2220
2233
|
await onAbortedSignal(cancelSignal, signal);
|
|
2221
|
-
|
|
2234
|
+
const reason = getReason(cancelSignal);
|
|
2235
|
+
await sendAbort(subprocess, reason);
|
|
2222
2236
|
killOnTimeout({
|
|
2223
2237
|
kill: subprocess.kill,
|
|
2224
2238
|
forceKillAfterDelay,
|
|
@@ -2330,8 +2344,8 @@ Please rename it to ${serializeEncoding(correctEncoding)}.`);
|
|
|
2330
2344
|
throw new TypeError(`Invalid option \`encoding: ${serializeEncoding(encoding)}\`.
|
|
2331
2345
|
Please rename it to one of: ${correctEncodings}.`);
|
|
2332
2346
|
};
|
|
2333
|
-
const TEXT_ENCODINGS = new Set(["utf8", "utf16le"]);
|
|
2334
|
-
const BINARY_ENCODINGS = new Set([
|
|
2347
|
+
const TEXT_ENCODINGS = /* @__PURE__ */ new Set(["utf8", "utf16le"]);
|
|
2348
|
+
const BINARY_ENCODINGS = /* @__PURE__ */ new Set([
|
|
2335
2349
|
"buffer",
|
|
2336
2350
|
"hex",
|
|
2337
2351
|
"base64",
|
|
@@ -2339,7 +2353,7 @@ const BINARY_ENCODINGS = new Set([
|
|
|
2339
2353
|
"latin1",
|
|
2340
2354
|
"ascii"
|
|
2341
2355
|
]);
|
|
2342
|
-
const ENCODINGS = new Set([...TEXT_ENCODINGS, ...BINARY_ENCODINGS]);
|
|
2356
|
+
const ENCODINGS = /* @__PURE__ */ new Set([...TEXT_ENCODINGS, ...BINARY_ENCODINGS]);
|
|
2343
2357
|
const getCorrectEncoding = (encoding) => {
|
|
2344
2358
|
if (encoding === null) return "buffer";
|
|
2345
2359
|
if (typeof encoding !== "string") return;
|
|
@@ -2386,7 +2400,8 @@ const normalizeOptions = (filePath, rawArguments, rawOptions) => {
|
|
|
2386
2400
|
rawOptions.cwd = normalizeCwd(rawOptions.cwd);
|
|
2387
2401
|
const [processedFile, processedArguments, processedOptions] = handleNodeOption(filePath, rawArguments, rawOptions);
|
|
2388
2402
|
const { command: file, args: commandArguments, options: initialOptions } = import_cross_spawn.default._parse(processedFile, processedArguments, processedOptions);
|
|
2389
|
-
const
|
|
2403
|
+
const fdOptions = normalizeFdSpecificOptions(initialOptions);
|
|
2404
|
+
const options = addDefaultOptions(fdOptions);
|
|
2390
2405
|
validateTimeout(options);
|
|
2391
2406
|
validateEncoding(options);
|
|
2392
2407
|
validateIpcInputOption(options);
|
|
@@ -2587,14 +2602,17 @@ const getStreamContents$1 = async (stream, { init, convertChunk, getSize, trunca
|
|
|
2587
2602
|
const state = init();
|
|
2588
2603
|
state.length = 0;
|
|
2589
2604
|
try {
|
|
2590
|
-
for await (const chunk of asyncIterable)
|
|
2591
|
-
convertedChunk
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2605
|
+
for await (const chunk of asyncIterable) {
|
|
2606
|
+
const convertedChunk = convertChunk[getChunkType(chunk)](chunk, state);
|
|
2607
|
+
appendChunk({
|
|
2608
|
+
convertedChunk,
|
|
2609
|
+
state,
|
|
2610
|
+
getSize,
|
|
2611
|
+
truncateChunk,
|
|
2612
|
+
addChunk,
|
|
2613
|
+
maxBuffer
|
|
2614
|
+
});
|
|
2615
|
+
}
|
|
2598
2616
|
appendFinalChunk({
|
|
2599
2617
|
state,
|
|
2600
2618
|
convertChunk,
|
|
@@ -2880,7 +2898,8 @@ const getErrorPrefix = ({ originalError, timedOut, timeout, isMaxBuffer, maxBuff
|
|
|
2880
2898
|
const getForcefulSuffix = (isForcefullyTerminated, forceKillAfterDelay) => isForcefullyTerminated ? ` and was forcefully terminated after ${forceKillAfterDelay} milliseconds` : "";
|
|
2881
2899
|
const getOriginalMessage = (originalError, cwd) => {
|
|
2882
2900
|
if (originalError instanceof DiscardedError) return;
|
|
2883
|
-
const
|
|
2901
|
+
const originalMessage = isExecaError(originalError) ? originalError.originalMessage : String(originalError?.message ?? originalError);
|
|
2902
|
+
const escapedOriginalMessage = escapeLines(fixCwdError(originalMessage, cwd));
|
|
2884
2903
|
return escapedOriginalMessage === "" ? void 0 : escapedOriginalMessage;
|
|
2885
2904
|
};
|
|
2886
2905
|
const serializeIpcMessage = (ipcMessage) => typeof ipcMessage === "string" ? ipcMessage : inspect(ipcMessage);
|
|
@@ -3091,26 +3110,28 @@ function prettyMilliseconds(milliseconds, options) {
|
|
|
3091
3110
|
add(Number(parsed.hours), "hour", "h");
|
|
3092
3111
|
}
|
|
3093
3112
|
add(Number(parsed.minutes), "minute", "m");
|
|
3094
|
-
if (!options.hideSeconds)
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3113
|
+
if (!options.hideSeconds) {
|
|
3114
|
+
if (options.separateMilliseconds || options.formatSubMilliseconds || !options.colonNotation && milliseconds < 1e3 && !options.subSecondsAsDecimals) {
|
|
3115
|
+
const seconds = Number(parsed.seconds);
|
|
3116
|
+
const milliseconds = Number(parsed.milliseconds);
|
|
3117
|
+
const microseconds = Number(parsed.microseconds);
|
|
3118
|
+
const nanoseconds = Number(parsed.nanoseconds);
|
|
3119
|
+
add(seconds, "second", "s");
|
|
3120
|
+
if (options.formatSubMilliseconds) {
|
|
3121
|
+
add(milliseconds, "millisecond", "ms");
|
|
3122
|
+
add(microseconds, "microsecond", "µs");
|
|
3123
|
+
add(nanoseconds, "nanosecond", "ns");
|
|
3124
|
+
} else {
|
|
3125
|
+
const millisecondsAndBelow = milliseconds + microseconds / 1e3 + nanoseconds / 1e6;
|
|
3126
|
+
const millisecondsDecimalDigits = typeof options.millisecondsDecimalDigits === "number" ? options.millisecondsDecimalDigits : 0;
|
|
3127
|
+
const millisecondsString = millisecondsDecimalDigits ? millisecondsAndBelow.toFixed(millisecondsDecimalDigits) : millisecondsAndBelow >= 1 ? Math.round(millisecondsAndBelow) : Math.ceil(millisecondsAndBelow);
|
|
3128
|
+
add(Number.parseFloat(millisecondsString), "millisecond", "ms", millisecondsString);
|
|
3129
|
+
}
|
|
3104
3130
|
} else {
|
|
3105
|
-
const
|
|
3106
|
-
const
|
|
3107
|
-
|
|
3108
|
-
add(Number.parseFloat(millisecondsString), "millisecond", "ms", millisecondsString);
|
|
3131
|
+
const secondsFixed = floorDecimals((isBigInt ? Number(milliseconds % ONE_DAY_IN_MILLISECONDS) : milliseconds) / 1e3 % 60, typeof options.secondsDecimalDigits === "number" ? options.secondsDecimalDigits : 1);
|
|
3132
|
+
const secondsString = options.keepDecimalsOnWholeSeconds ? secondsFixed : secondsFixed.replace(/\.0+$/, "");
|
|
3133
|
+
add(Number.parseFloat(secondsString), "second", "s", secondsString);
|
|
3109
3134
|
}
|
|
3110
|
-
} else {
|
|
3111
|
-
const secondsFixed = floorDecimals((isBigInt ? Number(milliseconds % ONE_DAY_IN_MILLISECONDS) : milliseconds) / 1e3 % 60, typeof options.secondsDecimalDigits === "number" ? options.secondsDecimalDigits : 1);
|
|
3112
|
-
const secondsString = options.keepDecimalsOnWholeSeconds ? secondsFixed : secondsFixed.replace(/\.0+$/, "");
|
|
3113
|
-
add(Number.parseFloat(secondsString), "second", "s", secondsString);
|
|
3114
3135
|
}
|
|
3115
3136
|
if (result.length === 0) return sign + "0" + (options.verbose ? " milliseconds" : "ms");
|
|
3116
3137
|
const separator = options.colonNotation ? ":" : " ";
|
|
@@ -3135,9 +3156,10 @@ const logResult = (result, verboseInfo) => {
|
|
|
3135
3156
|
logDuration(result, verboseInfo);
|
|
3136
3157
|
};
|
|
3137
3158
|
const logDuration = (result, verboseInfo) => {
|
|
3159
|
+
const verboseMessage = `(done in ${prettyMilliseconds(result.durationMs)})`;
|
|
3138
3160
|
verboseLog({
|
|
3139
3161
|
type: "duration",
|
|
3140
|
-
verboseMessage
|
|
3162
|
+
verboseMessage,
|
|
3141
3163
|
verboseInfo,
|
|
3142
3164
|
result
|
|
3143
3165
|
});
|
|
@@ -3205,10 +3227,10 @@ const isTransformOptions = (value) => isPlainObject(value) && (value.transform !
|
|
|
3205
3227
|
const isUrl = (value) => Object.prototype.toString.call(value) === "[object URL]";
|
|
3206
3228
|
const isRegularUrl = (value) => isUrl(value) && value.protocol !== "file:";
|
|
3207
3229
|
const isFilePathObject = (value) => isPlainObject(value) && Object.keys(value).length > 0 && Object.keys(value).every((key) => FILE_PATH_KEYS.has(key)) && isFilePathString(value.file);
|
|
3208
|
-
const FILE_PATH_KEYS = new Set(["file", "append"]);
|
|
3230
|
+
const FILE_PATH_KEYS = /* @__PURE__ */ new Set(["file", "append"]);
|
|
3209
3231
|
const isFilePathString = (file) => typeof file === "string";
|
|
3210
3232
|
const isUnknownStdioString = (type, value) => type === "native" && typeof value === "string" && !KNOWN_STDIO_STRINGS.has(value);
|
|
3211
|
-
const KNOWN_STDIO_STRINGS = new Set([
|
|
3233
|
+
const KNOWN_STDIO_STRINGS = /* @__PURE__ */ new Set([
|
|
3212
3234
|
"ipc",
|
|
3213
3235
|
"ignore",
|
|
3214
3236
|
"inherit",
|
|
@@ -3222,24 +3244,24 @@ const isTransformStream = (value) => isReadableStream(value?.readable) && isWrit
|
|
|
3222
3244
|
const isAsyncIterableObject = (value) => isObject(value) && typeof value[Symbol.asyncIterator] === "function";
|
|
3223
3245
|
const isIterableObject = (value) => isObject(value) && typeof value[Symbol.iterator] === "function";
|
|
3224
3246
|
const isObject = (value) => typeof value === "object" && value !== null;
|
|
3225
|
-
const TRANSFORM_TYPES = new Set([
|
|
3247
|
+
const TRANSFORM_TYPES = /* @__PURE__ */ new Set([
|
|
3226
3248
|
"generator",
|
|
3227
3249
|
"asyncGenerator",
|
|
3228
3250
|
"duplex",
|
|
3229
3251
|
"webTransform"
|
|
3230
3252
|
]);
|
|
3231
|
-
const FILE_TYPES = new Set([
|
|
3253
|
+
const FILE_TYPES = /* @__PURE__ */ new Set([
|
|
3232
3254
|
"fileUrl",
|
|
3233
3255
|
"filePath",
|
|
3234
3256
|
"fileNumber"
|
|
3235
3257
|
]);
|
|
3236
|
-
const SPECIAL_DUPLICATE_TYPES_SYNC = new Set(["fileUrl", "filePath"]);
|
|
3237
|
-
const SPECIAL_DUPLICATE_TYPES = new Set([
|
|
3258
|
+
const SPECIAL_DUPLICATE_TYPES_SYNC = /* @__PURE__ */ new Set(["fileUrl", "filePath"]);
|
|
3259
|
+
const SPECIAL_DUPLICATE_TYPES = /* @__PURE__ */ new Set([
|
|
3238
3260
|
...SPECIAL_DUPLICATE_TYPES_SYNC,
|
|
3239
3261
|
"webStream",
|
|
3240
3262
|
"nodeStream"
|
|
3241
3263
|
]);
|
|
3242
|
-
const FORBID_DUPLICATE_TYPES = new Set(["webTransform", "duplex"]);
|
|
3264
|
+
const FORBID_DUPLICATE_TYPES = /* @__PURE__ */ new Set(["webTransform", "duplex"]);
|
|
3243
3265
|
const TYPE_TO_MESSAGE = {
|
|
3244
3266
|
generator: "a generator",
|
|
3245
3267
|
asyncGenerator: "an async generator",
|
|
@@ -3572,7 +3594,8 @@ const validateDuplicateStreamSync = ({ otherStdioItems, type, value, optionName,
|
|
|
3572
3594
|
const getDuplicateStreamInstance = ({ otherStdioItems, type, value, optionName, direction }) => {
|
|
3573
3595
|
const duplicateStdioItems = otherStdioItems.filter((stdioItem) => hasSameValue(stdioItem, value));
|
|
3574
3596
|
if (duplicateStdioItems.length === 0) return;
|
|
3575
|
-
|
|
3597
|
+
const differentStdioItem = duplicateStdioItems.find((stdioItem) => stdioItem.direction !== direction);
|
|
3598
|
+
throwOnDuplicateStream(differentStdioItem, optionName, type);
|
|
3576
3599
|
return direction === "output" ? duplicateStdioItems[0].stream : void 0;
|
|
3577
3600
|
};
|
|
3578
3601
|
const hasSameValue = ({ type, value }, secondValue) => {
|
|
@@ -3581,7 +3604,8 @@ const hasSameValue = ({ type, value }, secondValue) => {
|
|
|
3581
3604
|
return value === secondValue;
|
|
3582
3605
|
};
|
|
3583
3606
|
const validateDuplicateTransform = ({ otherStdioItems, type, value, optionName }) => {
|
|
3584
|
-
|
|
3607
|
+
const duplicateStdioItem = otherStdioItems.find(({ value: { transform } }) => transform === value.transform);
|
|
3608
|
+
throwOnDuplicateStream(duplicateStdioItem, optionName, type);
|
|
3585
3609
|
};
|
|
3586
3610
|
const throwOnDuplicateStream = (stdioItem, optionName, type) => {
|
|
3587
3611
|
if (stdioItem !== void 0) throw new TypeError(`The \`${stdioItem.optionName}\` and \`${optionName}\` options must not target ${TYPE_TO_MESSAGE[type]} that is the same.`);
|
|
@@ -3589,13 +3613,14 @@ const throwOnDuplicateStream = (stdioItem, optionName, type) => {
|
|
|
3589
3613
|
//#endregion
|
|
3590
3614
|
//#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/stdio/handle.js
|
|
3591
3615
|
const handleStdio = (addProperties, options, verboseInfo, isSync) => {
|
|
3616
|
+
const initialFileDescriptors = normalizeStdioOption(options, verboseInfo, isSync).map((stdioOption, fdNumber) => getFileDescriptor({
|
|
3617
|
+
stdioOption,
|
|
3618
|
+
fdNumber,
|
|
3619
|
+
options,
|
|
3620
|
+
isSync
|
|
3621
|
+
}));
|
|
3592
3622
|
const fileDescriptors = getFinalFileDescriptors({
|
|
3593
|
-
initialFileDescriptors
|
|
3594
|
-
stdioOption,
|
|
3595
|
-
fdNumber,
|
|
3596
|
-
options,
|
|
3597
|
-
isSync
|
|
3598
|
-
})),
|
|
3623
|
+
initialFileDescriptors,
|
|
3599
3624
|
addProperties,
|
|
3600
3625
|
options,
|
|
3601
3626
|
isSync
|
|
@@ -3612,13 +3637,14 @@ const getFileDescriptor = ({ stdioOption, fdNumber, options, isSync }) => {
|
|
|
3612
3637
|
optionName
|
|
3613
3638
|
});
|
|
3614
3639
|
const direction = getStreamDirection(initialStdioItems, fdNumber, optionName);
|
|
3615
|
-
const
|
|
3640
|
+
const stdioItems = initialStdioItems.map((stdioItem) => handleNativeStream({
|
|
3616
3641
|
stdioItem,
|
|
3617
3642
|
isStdioArray,
|
|
3618
3643
|
fdNumber,
|
|
3619
3644
|
direction,
|
|
3620
3645
|
isSync
|
|
3621
|
-
}))
|
|
3646
|
+
}));
|
|
3647
|
+
const normalizedStdioItems = normalizeTransforms(stdioItems, optionName, direction, options);
|
|
3622
3648
|
const objectMode = getFdObjectMode(normalizedStdioItems, direction);
|
|
3623
3649
|
validateFileObjectMode(normalizedStdioItems, objectMode);
|
|
3624
3650
|
return {
|
|
@@ -3628,7 +3654,8 @@ const getFileDescriptor = ({ stdioOption, fdNumber, options, isSync }) => {
|
|
|
3628
3654
|
};
|
|
3629
3655
|
};
|
|
3630
3656
|
const initializeStdioItems = ({ stdioOption, fdNumber, options, optionName }) => {
|
|
3631
|
-
const
|
|
3657
|
+
const initialStdioItems = [...(Array.isArray(stdioOption) ? stdioOption : [stdioOption]).map((value) => initializeStdioItem(value, optionName)), ...handleInputOptions(options, fdNumber)];
|
|
3658
|
+
const stdioItems = filterDuplicates(initialStdioItems);
|
|
3632
3659
|
const isStdioArray = stdioItems.length > 1;
|
|
3633
3660
|
validateStdioArray(stdioItems, isStdioArray, optionName);
|
|
3634
3661
|
validateStreams(stdioItems);
|
|
@@ -3647,7 +3674,7 @@ const validateStdioArray = (stdioItems, isStdioArray, optionName) => {
|
|
|
3647
3674
|
if (!isStdioArray) return;
|
|
3648
3675
|
for (const { value, optionName } of stdioItems) if (INVALID_STDIO_ARRAY_OPTIONS.has(value)) throw new Error(`The \`${optionName}\` option must not include \`${value}\`.`);
|
|
3649
3676
|
};
|
|
3650
|
-
const INVALID_STDIO_ARRAY_OPTIONS = new Set(["ignore", "ipc"]);
|
|
3677
|
+
const INVALID_STDIO_ARRAY_OPTIONS = /* @__PURE__ */ new Set(["ignore", "ipc"]);
|
|
3651
3678
|
const validateStreams = (stdioItems) => {
|
|
3652
3679
|
for (const stdioItem of stdioItems) validateFileStdio(stdioItem);
|
|
3653
3680
|
};
|
|
@@ -3976,7 +4003,10 @@ const generatorToStream = ({ value, value: { transform, final, writableObjectMod
|
|
|
3976
4003
|
const runGeneratorsSync = (chunks, stdioItems, encoding, isInput) => {
|
|
3977
4004
|
const generators = stdioItems.filter(({ type }) => type === "generator");
|
|
3978
4005
|
const reversedGenerators = isInput ? generators.reverse() : generators;
|
|
3979
|
-
for (const { value, optionName } of reversedGenerators)
|
|
4006
|
+
for (const { value, optionName } of reversedGenerators) {
|
|
4007
|
+
const generators = addInternalGenerators(value, encoding, optionName);
|
|
4008
|
+
chunks = runTransformSync(generators, chunks);
|
|
4009
|
+
}
|
|
3980
4010
|
return chunks;
|
|
3981
4011
|
};
|
|
3982
4012
|
const addInternalGenerators = ({ transform, final, binary, writableObjectMode, readableObjectMode, preserveNewlines }, encoding, optionName) => {
|
|
@@ -4012,7 +4042,8 @@ const addInputOptionSync = (fileDescriptors, fdNumber, options) => {
|
|
|
4012
4042
|
const [{ type, optionName }] = allStdioItems;
|
|
4013
4043
|
throw new TypeError(`Only the \`stdin\` option, not \`${optionName}\`, can be ${TYPE_TO_MESSAGE[type]} with synchronous methods.`);
|
|
4014
4044
|
}
|
|
4015
|
-
|
|
4045
|
+
const transformedContents = allStdioItems.map(({ contents }) => contents).map((contents) => applySingleInputGeneratorsSync(contents, stdioItems));
|
|
4046
|
+
options.input = joinToUint8Array(transformedContents);
|
|
4016
4047
|
};
|
|
4017
4048
|
const applySingleInputGeneratorsSync = (contents, stdioItems) => {
|
|
4018
4049
|
const newContents = runGeneratorsSync(contents, stdioItems, "utf8", true);
|
|
@@ -4027,7 +4058,7 @@ const validateSerializable = (newContents) => {
|
|
|
4027
4058
|
//#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/verbose/output.js
|
|
4028
4059
|
const shouldLogOutput = ({ stdioItems, encoding, verboseInfo, fdNumber }) => fdNumber !== "all" && isFullVerbose(verboseInfo, fdNumber) && !BINARY_ENCODINGS.has(encoding) && fdUsesVerbose(fdNumber) && (stdioItems.some(({ type, value }) => type === "native" && PIPED_STDIO_VALUES.has(value)) || stdioItems.every(({ type }) => TRANSFORM_TYPES.has(type)));
|
|
4029
4060
|
const fdUsesVerbose = (fdNumber) => fdNumber === 1 || fdNumber === 2;
|
|
4030
|
-
const PIPED_STDIO_VALUES = new Set(["pipe", "overlapped"]);
|
|
4061
|
+
const PIPED_STDIO_VALUES = /* @__PURE__ */ new Set(["pipe", "overlapped"]);
|
|
4031
4062
|
const logLines = async (linesIterable, stream, fdNumber, verboseInfo) => {
|
|
4032
4063
|
for await (const line of linesIterable) if (!isPipingStream(stream)) logLine(line, fdNumber, verboseInfo);
|
|
4033
4064
|
};
|
|
@@ -4036,9 +4067,10 @@ const logLinesSync = (linesArray, fdNumber, verboseInfo) => {
|
|
|
4036
4067
|
};
|
|
4037
4068
|
const isPipingStream = (stream) => stream._readableState.pipes.length > 0;
|
|
4038
4069
|
const logLine = (line, fdNumber, verboseInfo) => {
|
|
4070
|
+
const verboseMessage = serializeVerboseMessage(line);
|
|
4039
4071
|
verboseLog({
|
|
4040
4072
|
type: "output",
|
|
4041
|
-
verboseMessage
|
|
4073
|
+
verboseMessage,
|
|
4042
4074
|
fdNumber,
|
|
4043
4075
|
verboseInfo
|
|
4044
4076
|
});
|
|
@@ -4064,10 +4096,12 @@ const transformOutputSync = ({ fileDescriptors, syncResult: { output }, options,
|
|
|
4064
4096
|
};
|
|
4065
4097
|
const transformOutputResultSync = ({ result, fileDescriptors, fdNumber, state, outputFiles, isMaxBuffer, verboseInfo }, { buffer, encoding, lines, stripFinalNewline, maxBuffer }) => {
|
|
4066
4098
|
if (result === null) return;
|
|
4067
|
-
const
|
|
4099
|
+
const truncatedResult = truncateMaxBufferSync(result, isMaxBuffer, maxBuffer);
|
|
4100
|
+
const uint8ArrayResult = bufferToUint8Array(truncatedResult);
|
|
4068
4101
|
const { stdioItems, objectMode } = fileDescriptors[fdNumber];
|
|
4102
|
+
const chunks = runOutputGeneratorsSync([uint8ArrayResult], stdioItems, encoding, state);
|
|
4069
4103
|
const { serializedResult, finalResult = serializedResult } = serializeChunks({
|
|
4070
|
-
chunks
|
|
4104
|
+
chunks,
|
|
4071
4105
|
objectMode,
|
|
4072
4106
|
encoding,
|
|
4073
4107
|
lines,
|
|
@@ -4191,7 +4225,7 @@ const getResultError = (error, exitCode, signal) => {
|
|
|
4191
4225
|
//#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/methods/main-sync.js
|
|
4192
4226
|
const execaCoreSync = (rawFile, rawArguments, rawOptions) => {
|
|
4193
4227
|
const { file, commandArguments, command, escapedCommand, startTime, verboseInfo, options, fileDescriptors } = handleSyncArguments(rawFile, rawArguments, rawOptions);
|
|
4194
|
-
|
|
4228
|
+
const result = spawnSubprocessSync({
|
|
4195
4229
|
file,
|
|
4196
4230
|
commandArguments,
|
|
4197
4231
|
options,
|
|
@@ -4200,11 +4234,13 @@ const execaCoreSync = (rawFile, rawArguments, rawOptions) => {
|
|
|
4200
4234
|
verboseInfo,
|
|
4201
4235
|
fileDescriptors,
|
|
4202
4236
|
startTime
|
|
4203
|
-
})
|
|
4237
|
+
});
|
|
4238
|
+
return handleResult(result, verboseInfo, options);
|
|
4204
4239
|
};
|
|
4205
4240
|
const handleSyncArguments = (rawFile, rawArguments, rawOptions) => {
|
|
4206
4241
|
const { command, escapedCommand, startTime, verboseInfo } = handleCommand(rawFile, rawArguments, rawOptions);
|
|
4207
|
-
const
|
|
4242
|
+
const syncOptions = normalizeSyncOptions(rawOptions);
|
|
4243
|
+
const { file, commandArguments, options } = normalizeOptions(rawFile, rawArguments, syncOptions);
|
|
4208
4244
|
validateSyncOptions(options);
|
|
4209
4245
|
return {
|
|
4210
4246
|
file,
|
|
@@ -4249,14 +4285,16 @@ const spawnSubprocessSync = ({ file, commandArguments, options, command, escaped
|
|
|
4249
4285
|
isMaxBuffer,
|
|
4250
4286
|
verboseInfo
|
|
4251
4287
|
});
|
|
4288
|
+
const stdio = output.map((stdioOutput, fdNumber) => stripNewline(stdioOutput, options, fdNumber));
|
|
4289
|
+
const all = stripNewline(getAllSync(output, options), options, "all");
|
|
4252
4290
|
return getSyncResult({
|
|
4253
4291
|
error,
|
|
4254
4292
|
exitCode,
|
|
4255
4293
|
signal,
|
|
4256
4294
|
timedOut,
|
|
4257
4295
|
isMaxBuffer,
|
|
4258
|
-
stdio
|
|
4259
|
-
all
|
|
4296
|
+
stdio,
|
|
4297
|
+
all,
|
|
4260
4298
|
options,
|
|
4261
4299
|
command,
|
|
4262
4300
|
escapedCommand,
|
|
@@ -4266,7 +4304,8 @@ const spawnSubprocessSync = ({ file, commandArguments, options, command, escaped
|
|
|
4266
4304
|
const runSubprocessSync = ({ file, commandArguments, options, command, escapedCommand, fileDescriptors, startTime }) => {
|
|
4267
4305
|
try {
|
|
4268
4306
|
addInputOptionsSync(fileDescriptors, options);
|
|
4269
|
-
|
|
4307
|
+
const normalizedOptions = normalizeSpawnSyncOptions(options);
|
|
4308
|
+
return spawnSync(file, commandArguments, normalizedOptions);
|
|
4270
4309
|
} catch (error) {
|
|
4271
4310
|
return makeEarlyError({
|
|
4272
4311
|
error,
|
|
@@ -4480,17 +4519,18 @@ const handleEarlyError = ({ error, command, escapedCommand, fileDescriptors, opt
|
|
|
4480
4519
|
writable,
|
|
4481
4520
|
duplex
|
|
4482
4521
|
});
|
|
4522
|
+
const earlyError = makeEarlyError({
|
|
4523
|
+
error,
|
|
4524
|
+
command,
|
|
4525
|
+
escapedCommand,
|
|
4526
|
+
fileDescriptors,
|
|
4527
|
+
options,
|
|
4528
|
+
startTime,
|
|
4529
|
+
isSync: false
|
|
4530
|
+
});
|
|
4483
4531
|
return {
|
|
4484
4532
|
subprocess,
|
|
4485
|
-
promise: handleDummyPromise(
|
|
4486
|
-
error,
|
|
4487
|
-
command,
|
|
4488
|
-
escapedCommand,
|
|
4489
|
-
fileDescriptors,
|
|
4490
|
-
options,
|
|
4491
|
-
startTime,
|
|
4492
|
-
isSync: false
|
|
4493
|
-
}), verboseInfo, options)
|
|
4533
|
+
promise: handleDummyPromise(earlyError, verboseInfo, options)
|
|
4494
4534
|
};
|
|
4495
4535
|
};
|
|
4496
4536
|
const createDummyStreams = (subprocess, fileDescriptors) => {
|
|
@@ -4674,8 +4714,10 @@ const endWhenStreamsDone = async ({ passThroughStream, stream, streams, ended, a
|
|
|
4674
4714
|
controller.abort();
|
|
4675
4715
|
updateMaxListeners(passThroughStream, -PASSTHROUGH_LISTENERS_PER_STREAM);
|
|
4676
4716
|
}
|
|
4677
|
-
if (streams.size > 0 && streams.size === ended.size + aborted.size)
|
|
4678
|
-
|
|
4717
|
+
if (streams.size > 0 && streams.size === ended.size + aborted.size) {
|
|
4718
|
+
if (ended.size === 0 && aborted.size > 0) abortStream(passThroughStream);
|
|
4719
|
+
else endStream(passThroughStream);
|
|
4720
|
+
}
|
|
4679
4721
|
};
|
|
4680
4722
|
const afterMergedStreamFinished = async (onFinished, stream, { signal }) => {
|
|
4681
4723
|
try {
|
|
@@ -4781,7 +4823,10 @@ const pipeOutputAsync = (subprocess, fileDescriptors, controller) => {
|
|
|
4781
4823
|
controller
|
|
4782
4824
|
});
|
|
4783
4825
|
}
|
|
4784
|
-
for (const [outputStream, inputStreams] of pipeGroups.entries())
|
|
4826
|
+
for (const [outputStream, inputStreams] of pipeGroups.entries()) {
|
|
4827
|
+
const inputStream = inputStreams.length === 1 ? inputStreams[0] : mergeStreams(inputStreams);
|
|
4828
|
+
pipeStreams(inputStream, outputStream);
|
|
4829
|
+
}
|
|
4785
4830
|
};
|
|
4786
4831
|
const pipeTransform = (subprocess, stream, direction, fdNumber) => {
|
|
4787
4832
|
if (direction === "output") pipeStreams(subprocess.stdio[fdNumber], stream);
|
|
@@ -5270,12 +5315,13 @@ const stopReadingOnStreamEnd = async (onStreamEnd, controller, stream) => {
|
|
|
5270
5315
|
}
|
|
5271
5316
|
};
|
|
5272
5317
|
const iterateOnStream = ({ stream, controller, binary, shouldEncode, encoding, shouldSplit, preserveNewlines }) => {
|
|
5318
|
+
const onStdoutChunk = on(stream, "data", {
|
|
5319
|
+
signal: controller.signal,
|
|
5320
|
+
highWaterMark: HIGH_WATER_MARK,
|
|
5321
|
+
highWatermark: HIGH_WATER_MARK
|
|
5322
|
+
});
|
|
5273
5323
|
return iterateOnData({
|
|
5274
|
-
onStdoutChunk
|
|
5275
|
-
signal: controller.signal,
|
|
5276
|
-
highWaterMark: HIGH_WATER_MARK,
|
|
5277
|
-
highWatermark: HIGH_WATER_MARK
|
|
5278
|
-
}),
|
|
5324
|
+
onStdoutChunk,
|
|
5279
5325
|
controller,
|
|
5280
5326
|
binary,
|
|
5281
5327
|
shouldEncode,
|
|
@@ -5319,12 +5365,13 @@ const getStreamOutput = async ({ stream, onStreamEnd, fdNumber, encoding, buffer
|
|
|
5319
5365
|
await Promise.all([resumeStream(stream), logPromise]);
|
|
5320
5366
|
return;
|
|
5321
5367
|
}
|
|
5368
|
+
const stripFinalNewlineValue = getStripFinalNewline(stripFinalNewline, fdNumber);
|
|
5322
5369
|
const iterable = iterateForResult({
|
|
5323
5370
|
stream,
|
|
5324
5371
|
onStreamEnd,
|
|
5325
5372
|
lines,
|
|
5326
5373
|
encoding,
|
|
5327
|
-
stripFinalNewline:
|
|
5374
|
+
stripFinalNewline: stripFinalNewlineValue,
|
|
5328
5375
|
allMixed
|
|
5329
5376
|
});
|
|
5330
5377
|
const [output] = await Promise.all([getStreamContents({
|
|
@@ -5344,14 +5391,15 @@ const logOutputAsync = async ({ stream, onStreamEnd, fdNumber, encoding, allMixe
|
|
|
5344
5391
|
verboseInfo,
|
|
5345
5392
|
fdNumber
|
|
5346
5393
|
})) return;
|
|
5347
|
-
|
|
5394
|
+
const linesIterable = iterateForResult({
|
|
5348
5395
|
stream,
|
|
5349
5396
|
onStreamEnd,
|
|
5350
5397
|
lines: true,
|
|
5351
5398
|
encoding,
|
|
5352
5399
|
stripFinalNewline: true,
|
|
5353
5400
|
allMixed
|
|
5354
|
-
})
|
|
5401
|
+
});
|
|
5402
|
+
await logLines(linesIterable, stream, fdNumber, verboseInfo);
|
|
5355
5403
|
};
|
|
5356
5404
|
const resumeStream = async (stream) => {
|
|
5357
5405
|
await setImmediate();
|
|
@@ -5497,9 +5545,10 @@ const getAllMixed = ({ all, stdout, stderr }) => all && stdout && stderr && stdo
|
|
|
5497
5545
|
//#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/verbose/ipc.js
|
|
5498
5546
|
const shouldLogIpc = (verboseInfo) => isFullVerbose(verboseInfo, "ipc");
|
|
5499
5547
|
const logIpcOutput = (message, verboseInfo) => {
|
|
5548
|
+
const verboseMessage = serializeVerboseMessage(message);
|
|
5500
5549
|
verboseLog({
|
|
5501
5550
|
type: "ipc",
|
|
5502
|
-
verboseMessage
|
|
5551
|
+
verboseMessage,
|
|
5503
5552
|
fdNumber: "ipc",
|
|
5504
5553
|
verboseInfo
|
|
5505
5554
|
});
|
|
@@ -5895,14 +5944,15 @@ const onDuplexDestroy = async ({ subprocessStdout, subprocessStdin, subprocess,
|
|
|
5895
5944
|
const createIterable = (subprocess, encoding, { from, binary: binaryOption = false, preserveNewlines = false } = {}) => {
|
|
5896
5945
|
const binary = binaryOption || BINARY_ENCODINGS.has(encoding);
|
|
5897
5946
|
const subprocessStdout = getFromStream(subprocess, from);
|
|
5898
|
-
|
|
5947
|
+
const onStdoutData = iterateOnSubprocessStream({
|
|
5899
5948
|
subprocessStdout,
|
|
5900
5949
|
subprocess,
|
|
5901
5950
|
binary,
|
|
5902
5951
|
shouldEncode: true,
|
|
5903
5952
|
encoding,
|
|
5904
5953
|
preserveNewlines
|
|
5905
|
-
})
|
|
5954
|
+
});
|
|
5955
|
+
return iterateOnStdoutData(onStdoutData, subprocessStdout, subprocess);
|
|
5906
5956
|
};
|
|
5907
5957
|
const iterateOnStdoutData = async function* (onStdoutData, subprocessStdout, subprocess) {
|
|
5908
5958
|
try {
|
|
@@ -6062,19 +6112,22 @@ const handlePromise = async ({ subprocess, options, startTime, verboseInfo, file
|
|
|
6062
6112
|
});
|
|
6063
6113
|
controller.abort();
|
|
6064
6114
|
onInternalError.resolve();
|
|
6065
|
-
|
|
6115
|
+
const stdio = stdioResults.map((stdioResult, fdNumber) => stripNewline(stdioResult, options, fdNumber));
|
|
6116
|
+
const all = stripNewline(allResult, options, "all");
|
|
6117
|
+
const result = getAsyncResult({
|
|
6066
6118
|
errorInfo,
|
|
6067
6119
|
exitCode,
|
|
6068
6120
|
signal,
|
|
6069
|
-
stdio
|
|
6070
|
-
all
|
|
6121
|
+
stdio,
|
|
6122
|
+
all,
|
|
6071
6123
|
ipcOutput,
|
|
6072
6124
|
context,
|
|
6073
6125
|
options,
|
|
6074
6126
|
command,
|
|
6075
6127
|
escapedCommand,
|
|
6076
6128
|
startTime
|
|
6077
|
-
})
|
|
6129
|
+
});
|
|
6130
|
+
return handleResult(result, verboseInfo, options);
|
|
6078
6131
|
};
|
|
6079
6132
|
const getAsyncResult = ({ errorInfo, exitCode, signal, stdio, all, ipcOutput, context, options, command, escapedCommand, startTime }) => "error" in errorInfo ? makeError({
|
|
6080
6133
|
error: errorInfo.error,
|
|
@@ -6118,7 +6171,7 @@ const mergeOption = (optionName, boundOptionValue, optionValue) => {
|
|
|
6118
6171
|
};
|
|
6119
6172
|
return optionValue;
|
|
6120
6173
|
};
|
|
6121
|
-
const DEEP_OPTIONS = new Set(["env", ...FD_SPECIFIC_OPTIONS]);
|
|
6174
|
+
const DEEP_OPTIONS = /* @__PURE__ */ new Set(["env", ...FD_SPECIFIC_OPTIONS]);
|
|
6122
6175
|
//#endregion
|
|
6123
6176
|
//#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/methods/create.js
|
|
6124
6177
|
const createExeca = (mapArguments, boundOptions, deepOptions, setBoundExeca) => {
|
|
@@ -6145,7 +6198,8 @@ const callBoundExeca = ({ mapArguments, deepOptions = {}, boundOptions = {}, set
|
|
|
6145
6198
|
return isSync ? execaCoreSync(file, commandArguments, options) : execaCoreAsync(file, commandArguments, options, createNested);
|
|
6146
6199
|
};
|
|
6147
6200
|
const parseArguments = ({ mapArguments, firstArgument, nextArguments, deepOptions, boundOptions }) => {
|
|
6148
|
-
const
|
|
6201
|
+
const callArguments = isTemplateString(firstArgument) ? parseTemplates(firstArgument, nextArguments) : [firstArgument, ...nextArguments];
|
|
6202
|
+
const [initialFile, initialArguments, initialOptions] = normalizeParameters(...callArguments);
|
|
6149
6203
|
const mergedOptions = mergeOptions(mergeOptions(deepOptions, boundOptions), initialOptions);
|
|
6150
6204
|
const { file = initialFile, commandArguments = initialArguments, options = mergedOptions, isSync = false } = mapArguments({
|
|
6151
6205
|
file: initialFile,
|
|
@@ -6216,7 +6270,7 @@ const { sendMessage, getOneMessage, getEachMessage, getCancelSignal } = getIpcEx
|
|
|
6216
6270
|
//#endregion
|
|
6217
6271
|
//#region src/cloudFrontInvalidation.ts
|
|
6218
6272
|
const DEFAULT_POLL_INTERVAL_MS = 2e3;
|
|
6219
|
-
const DEFAULT_TIMEOUT_MS =
|
|
6273
|
+
const DEFAULT_TIMEOUT_MS = 3e5;
|
|
6220
6274
|
const sleep = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
6221
6275
|
const invalidateCloudFront = async (client, distributionId, paths, options) => {
|
|
6222
6276
|
if (paths.length === 0) return;
|
|
@@ -6245,9 +6299,10 @@ const invalidateCloudFront = async (client, distributionId, paths, options) => {
|
|
|
6245
6299
|
};
|
|
6246
6300
|
//#endregion
|
|
6247
6301
|
//#region src/dynamoDB.ts
|
|
6248
|
-
const DYNAMODB_MAX_METADATA_ITEM_BYTES =
|
|
6249
|
-
const DYNAMODB_MAX_CATALOG_ITEM_BYTES =
|
|
6302
|
+
const DYNAMODB_MAX_METADATA_ITEM_BYTES = 8192;
|
|
6303
|
+
const DYNAMODB_MAX_CATALOG_ITEM_BYTES = 409600;
|
|
6250
6304
|
var DynamoDBMetadataItemSizeError = class extends Error {
|
|
6305
|
+
byteLength;
|
|
6251
6306
|
name = "DynamoDBMetadataItemSizeError";
|
|
6252
6307
|
constructor(byteLength) {
|
|
6253
6308
|
super(`DynamoDB metadata item is ${byteLength} bytes; maximum is ${DYNAMODB_MAX_METADATA_ITEM_BYTES}`);
|
|
@@ -6260,6 +6315,7 @@ const boundedDynamoDBMetadataItem = (item) => {
|
|
|
6260
6315
|
return item;
|
|
6261
6316
|
};
|
|
6262
6317
|
var DynamoDBCatalogItemSizeError = class extends Error {
|
|
6318
|
+
byteLength;
|
|
6263
6319
|
name = "DynamoDBCatalogItemSizeError";
|
|
6264
6320
|
constructor(byteLength) {
|
|
6265
6321
|
super(`DynamoDB catalog item is ${byteLength} bytes; maximum is ${DYNAMODB_MAX_CATALOG_ITEM_BYTES}`);
|
|
@@ -6320,7 +6376,6 @@ const parseDynamoDBItem = (value) => {
|
|
|
6320
6376
|
version,
|
|
6321
6377
|
row
|
|
6322
6378
|
};
|
|
6323
|
-
if (typeof gsi1pk !== "string" || typeof gsi1sk !== "string") throw new DynamoDBStoredItemError();
|
|
6324
6379
|
if (pk === "bundles" && isBundleRow(row)) {
|
|
6325
6380
|
if (typeof relationCount !== "number" || typeof ownedPatchCount !== "number") throw new DynamoDBStoredItemError();
|
|
6326
6381
|
return {
|
|
@@ -6329,12 +6384,10 @@ const parseDynamoDBItem = (value) => {
|
|
|
6329
6384
|
version,
|
|
6330
6385
|
relation_count: relationCount,
|
|
6331
6386
|
owned_patch_count: ownedPatchCount,
|
|
6332
|
-
gsi1pk,
|
|
6333
|
-
gsi1sk,
|
|
6334
6387
|
row
|
|
6335
6388
|
};
|
|
6336
6389
|
}
|
|
6337
|
-
if (pk === "bundle_patches" && isPatchRow(row)) return {
|
|
6390
|
+
if (pk === "bundle_patches" && typeof gsi1pk === "string" && typeof gsi1sk === "string" && isPatchRow(row)) return {
|
|
6338
6391
|
pk,
|
|
6339
6392
|
sk,
|
|
6340
6393
|
version,
|
|
@@ -6344,7 +6397,6 @@ const parseDynamoDBItem = (value) => {
|
|
|
6344
6397
|
};
|
|
6345
6398
|
throw new DynamoDBStoredItemError();
|
|
6346
6399
|
};
|
|
6347
|
-
const bundlePlatformPartition = (row) => `bundle#${row.platform}`;
|
|
6348
6400
|
const patchOwnerPartition = (bundleId) => `patch-owner#${bundleId}`;
|
|
6349
6401
|
const patchOrderKey = (row) => `${row.order_index.toString().padStart(10, "0")}#${row.id}`;
|
|
6350
6402
|
const toDynamoDBBundleItem = (row, version = 1, relationCount = 0, ownedPatchCount = 0) => ({
|
|
@@ -6353,8 +6405,6 @@ const toDynamoDBBundleItem = (row, version = 1, relationCount = 0, ownedPatchCou
|
|
|
6353
6405
|
version,
|
|
6354
6406
|
relation_count: relationCount,
|
|
6355
6407
|
owned_patch_count: ownedPatchCount,
|
|
6356
|
-
gsi1pk: bundlePlatformPartition(row),
|
|
6357
|
-
gsi1sk: row.id,
|
|
6358
6408
|
row
|
|
6359
6409
|
});
|
|
6360
6410
|
const toDynamoDBPatchItem = (row, version = 1) => {
|
|
@@ -6711,6 +6761,7 @@ const queryOwnerPatchIds = async (store, indexName, bundleId) => {
|
|
|
6711
6761
|
})).filter((item) => item.pk === "bundle_patches").map(({ sk }) => sk);
|
|
6712
6762
|
};
|
|
6713
6763
|
var DynamoDBTransactionLimitError = class extends Error {
|
|
6764
|
+
actionCount;
|
|
6714
6765
|
name = "DynamoDBTransactionLimitError";
|
|
6715
6766
|
constructor(actionCount) {
|
|
6716
6767
|
super(`DynamoDB transaction requires ${actionCount} actions; maximum is 100`);
|
|
@@ -6791,6 +6842,7 @@ const commitDynamoDBTransaction = async (store, actions) => {
|
|
|
6791
6842
|
const DYNAMODB_BATCH_GET_ATTEMPTS = 5;
|
|
6792
6843
|
const DYNAMODB_BATCH_GET_BASE_DELAY_MS = 25;
|
|
6793
6844
|
var DynamoDBBatchGetExhaustedError = class extends Error {
|
|
6845
|
+
unprocessedKeyCount;
|
|
6794
6846
|
name = "DynamoDBBatchGetExhaustedError";
|
|
6795
6847
|
constructor(unprocessedKeyCount) {
|
|
6796
6848
|
super(`DynamoDB did not process ${unprocessedKeyCount} batch-get keys after ${DYNAMODB_BATCH_GET_ATTEMPTS} attempts`);
|
|
@@ -6843,6 +6895,8 @@ const loadMetadataCount = async (store, model) => {
|
|
|
6843
6895
|
return typeof count === "number" && Number.isSafeInteger(count) && count >= 0 ? count : void 0;
|
|
6844
6896
|
};
|
|
6845
6897
|
var DynamoDBPatchIndexConsistencyError = class extends Error {
|
|
6898
|
+
bundleId;
|
|
6899
|
+
expectedCount;
|
|
6846
6900
|
name = "DynamoDBPatchIndexConsistencyError";
|
|
6847
6901
|
constructor(bundleId, expectedCount) {
|
|
6848
6902
|
super(`DynamoDB patch index did not converge to ${expectedCount} rows for bundle "${bundleId}"`);
|
|
@@ -6870,7 +6924,8 @@ const queryCompleteOwnersPatches = async (store, indexName, bundleIds) => {
|
|
|
6870
6924
|
let failedOwner = firstOwner;
|
|
6871
6925
|
for (let attempt = 0; attempt < 3; attempt++) {
|
|
6872
6926
|
const candidateIdsByOwner = await Promise.all(owners.map(({ sk }) => queryOwnerPatchIds(store, indexName, sk)));
|
|
6873
|
-
const
|
|
6927
|
+
const candidateIds = candidateIdsByOwner.flat();
|
|
6928
|
+
const patches = await loadPatchItemsById(store, candidateIds);
|
|
6874
6929
|
const patchesById = new Map(patches.map((patch) => [patch.sk, patch]));
|
|
6875
6930
|
const mismatchedOwner = owners.find((owner, ownerIndex) => {
|
|
6876
6931
|
const ids = candidateIdsByOwner[ownerIndex] ?? [];
|
|
@@ -6971,7 +7026,7 @@ const createDynamoDBBundle = async (store, row) => {
|
|
|
6971
7026
|
} }]);
|
|
6972
7027
|
};
|
|
6973
7028
|
const createDynamoDBPatch = async (store, row) => {
|
|
6974
|
-
const bundleIds = [
|
|
7029
|
+
const bundleIds = [.../* @__PURE__ */ new Set([row.bundle_id, row.base_bundle_id])];
|
|
6975
7030
|
const counter = metadataUpdate(store, { bundle_patches: 1 });
|
|
6976
7031
|
if (!counter) return;
|
|
6977
7032
|
await commitDynamoDBTransaction(store, [
|
|
@@ -7007,9 +7062,10 @@ const deleteAction = (store, item) => ({ Delete: {
|
|
|
7007
7062
|
const deleteDynamoDBPatch = async (store, item) => {
|
|
7008
7063
|
const counter = metadataUpdate(store, { bundle_patches: -1 });
|
|
7009
7064
|
if (!counter) return;
|
|
7065
|
+
const bundleIds = [.../* @__PURE__ */ new Set([item.row.bundle_id, item.row.base_bundle_id])];
|
|
7010
7066
|
await commitDynamoDBTransaction(store, [
|
|
7011
7067
|
counter,
|
|
7012
|
-
...
|
|
7068
|
+
...bundleIds.map((id) => updateBundleRelation(store, id, -1, id === item.row.bundle_id ? -1 : 0)),
|
|
7013
7069
|
deleteAction(store, item)
|
|
7014
7070
|
]);
|
|
7015
7071
|
};
|
|
@@ -7020,7 +7076,7 @@ const deleteBundle = async (store, bundle, patches) => {
|
|
|
7020
7076
|
});
|
|
7021
7077
|
if (!counter) return;
|
|
7022
7078
|
const otherEndpointCounts = /* @__PURE__ */ new Map();
|
|
7023
|
-
for (const { row } of patches) for (const id of new Set([row.bundle_id, row.base_bundle_id])) {
|
|
7079
|
+
for (const { row } of patches) for (const id of /* @__PURE__ */ new Set([row.bundle_id, row.base_bundle_id])) {
|
|
7024
7080
|
if (id === bundle.sk) continue;
|
|
7025
7081
|
const current = otherEndpointCounts.get(id) ?? {
|
|
7026
7082
|
owned: 0,
|
|
@@ -7071,6 +7127,7 @@ const exactDynamoDBField = (where, fieldName) => {
|
|
|
7071
7127
|
return typeof value === "string" ? value : void 0;
|
|
7072
7128
|
};
|
|
7073
7129
|
const createDynamoDBCrud = (store, updateIndexName) => ({
|
|
7130
|
+
recordInsights: (input) => recordDynamoDBInsightsEvent(store, input),
|
|
7074
7131
|
async create(input) {
|
|
7075
7132
|
switch (input.model) {
|
|
7076
7133
|
case "bundles":
|
|
@@ -7227,14 +7284,19 @@ const createDynamoDBCrud = (store, updateIndexName) => ({
|
|
|
7227
7284
|
if (count !== void 0) return count;
|
|
7228
7285
|
}
|
|
7229
7286
|
switch (input.model) {
|
|
7230
|
-
case "bundles":
|
|
7287
|
+
case "bundles": {
|
|
7288
|
+
const rows = (await loadBundleItems(store)).map(({ row }) => row).filter((row) => matchesDynamoDBWhere(row, input.where));
|
|
7289
|
+
return countDistinctDynamoDBRows(rows, distinctFields(input.distinct));
|
|
7290
|
+
}
|
|
7231
7291
|
case "bundle_patches": {
|
|
7232
7292
|
const ownerId = exactDynamoDBPatchOwner(input.where);
|
|
7233
|
-
|
|
7293
|
+
const rows = (ownerId ? await queryCompleteOwnerPatches(store, updateIndexName, ownerId) : (await loadPatchItems(store)).map(({ row }) => row)).filter((row) => matchesDynamoDBWhere(row, input.where));
|
|
7294
|
+
return countDistinctDynamoDBRows(rows, distinctFields(input.distinct));
|
|
7234
7295
|
}
|
|
7235
7296
|
case "releases": {
|
|
7236
7297
|
const scopeKey = exactDynamoDBField(input.where, "scope_key");
|
|
7237
|
-
|
|
7298
|
+
const rows = (scopeKey === void 0 ? await loadReleaseItems(store) : await loadReleaseItemsByScope(store, scopeKey)).map(({ row }) => row).filter((row) => matchesDynamoDBWhere(row, input.where));
|
|
7299
|
+
return countDistinctDynamoDBRows(rows, distinctFields(input.distinct));
|
|
7238
7300
|
}
|
|
7239
7301
|
}
|
|
7240
7302
|
throw new DynamoDBUnsupportedModelError();
|
|
@@ -7252,7 +7314,6 @@ const createDynamoDBCrud = (store, updateIndexName) => ({
|
|
|
7252
7314
|
if (ownerId === void 0) break;
|
|
7253
7315
|
return (await queryCompleteOwnerPatches(store, updateIndexName, ownerId)).find((row) => matchesDynamoDBWhere(row, input.where)) ?? null;
|
|
7254
7316
|
}
|
|
7255
|
-
break;
|
|
7256
7317
|
case "channels":
|
|
7257
7318
|
if (id !== void 0) return (await loadChannelItem(store, id))?.row ?? null;
|
|
7258
7319
|
return (await loadChannelItems(store)).map(({ row }) => row).find((row) => matchesDynamoDBWhere(row, input.where)) ?? null;
|
|
@@ -7308,6 +7369,7 @@ const createDynamoDBCrud = (store, updateIndexName) => ({
|
|
|
7308
7369
|
deleteChannel: (input) => deleteDynamoDBChannel(store, input)
|
|
7309
7370
|
});
|
|
7310
7371
|
var DynamoDBDuplicatePatchError = class extends Error {
|
|
7372
|
+
patchId;
|
|
7311
7373
|
name = "DynamoDBDuplicatePatchError";
|
|
7312
7374
|
constructor(patchId) {
|
|
7313
7375
|
super(`DynamoDB bundle mutation contains duplicate patch "${patchId}"`);
|
|
@@ -7420,7 +7482,6 @@ const compileAndCommitDynamoDBChanges = async (store, input) => {
|
|
|
7420
7482
|
const originalApiKeys = /* @__PURE__ */ new Map();
|
|
7421
7483
|
const apiKeys = /* @__PURE__ */ new Map();
|
|
7422
7484
|
const apiKeyHashes = /* @__PURE__ */ new Map();
|
|
7423
|
-
const analytics = /* @__PURE__ */ new Map();
|
|
7424
7485
|
const rememberApiKey = (value) => {
|
|
7425
7486
|
if (value === null || apiKeys.has(value.row.id)) return;
|
|
7426
7487
|
originalApiKeys.set(value.row.id, value);
|
|
@@ -7543,48 +7604,40 @@ const compileAndCommitDynamoDBChanges = async (store, input) => {
|
|
|
7543
7604
|
patches.set(change.row.id, change.row);
|
|
7544
7605
|
} else for (const [id, patch] of patches) if (patch.bundle_id === change.where.bundleId) patches.delete(id);
|
|
7545
7606
|
break;
|
|
7546
|
-
case "
|
|
7547
|
-
|
|
7548
|
-
if (
|
|
7549
|
-
|
|
7550
|
-
|
|
7607
|
+
case "apiKeys": if (change.operation === "insert") {
|
|
7608
|
+
rememberApiKey(await loadApiKeyByHash(store, change.row.hash));
|
|
7609
|
+
if (apiKeyHashes.has(change.row.hash)) break;
|
|
7610
|
+
rememberApiKey(await loadApiKey(store, change.row.id));
|
|
7611
|
+
if (apiKeys.has(change.row.id)) throw new DynamoDBCommitStateError(`API key id "${change.row.id}" already exists`);
|
|
7612
|
+
const inserted = {
|
|
7613
|
+
row: change.row,
|
|
7614
|
+
version: 1
|
|
7615
|
+
};
|
|
7616
|
+
apiKeys.set(change.row.id, inserted);
|
|
7617
|
+
apiKeyHashes.set(change.row.hash, change.row.id);
|
|
7618
|
+
} else {
|
|
7619
|
+
rememberApiKey(await loadApiKey(store, change.where.id));
|
|
7620
|
+
const current = apiKeys.get(change.where.id);
|
|
7621
|
+
if (current === void 0) return {
|
|
7622
|
+
committed: false,
|
|
7623
|
+
conflict: {
|
|
7624
|
+
changeIndex,
|
|
7625
|
+
reason: "not_found"
|
|
7626
|
+
}
|
|
7627
|
+
};
|
|
7628
|
+
apiKeys.set(change.where.id, {
|
|
7629
|
+
row: {
|
|
7630
|
+
...current.row,
|
|
7631
|
+
revoked_at_ms: change.update.revokedAtMs
|
|
7632
|
+
},
|
|
7633
|
+
version: current.version
|
|
7634
|
+
});
|
|
7551
7635
|
}
|
|
7552
|
-
case "apiKeys":
|
|
7553
|
-
if (change.operation === "insert") {
|
|
7554
|
-
rememberApiKey(await loadApiKeyByHash(store, change.row.hash));
|
|
7555
|
-
if (apiKeyHashes.has(change.row.hash)) break;
|
|
7556
|
-
rememberApiKey(await loadApiKey(store, change.row.id));
|
|
7557
|
-
if (apiKeys.has(change.row.id)) throw new DynamoDBCommitStateError(`API key id "${change.row.id}" already exists`);
|
|
7558
|
-
const inserted = {
|
|
7559
|
-
row: change.row,
|
|
7560
|
-
version: 1
|
|
7561
|
-
};
|
|
7562
|
-
apiKeys.set(change.row.id, inserted);
|
|
7563
|
-
apiKeyHashes.set(change.row.hash, change.row.id);
|
|
7564
|
-
} else {
|
|
7565
|
-
rememberApiKey(await loadApiKey(store, change.where.id));
|
|
7566
|
-
const current = apiKeys.get(change.where.id);
|
|
7567
|
-
if (current === void 0) return {
|
|
7568
|
-
committed: false,
|
|
7569
|
-
conflict: {
|
|
7570
|
-
changeIndex,
|
|
7571
|
-
reason: "not_found"
|
|
7572
|
-
}
|
|
7573
|
-
};
|
|
7574
|
-
apiKeys.set(change.where.id, {
|
|
7575
|
-
row: {
|
|
7576
|
-
...current.row,
|
|
7577
|
-
revoked_at_ms: change.update.revokedAtMs
|
|
7578
|
-
},
|
|
7579
|
-
version: current.version
|
|
7580
|
-
});
|
|
7581
|
-
}
|
|
7582
|
-
break;
|
|
7583
7636
|
}
|
|
7584
7637
|
const relationCounts = /* @__PURE__ */ new Map();
|
|
7585
7638
|
const ownedPatchCounts = /* @__PURE__ */ new Map();
|
|
7586
7639
|
for (const patch of patches.values()) {
|
|
7587
|
-
for (const id of new Set([patch.bundle_id, patch.base_bundle_id])) relationCounts.set(id, (relationCounts.get(id) ?? 0) + 1);
|
|
7640
|
+
for (const id of /* @__PURE__ */ new Set([patch.bundle_id, patch.base_bundle_id])) relationCounts.set(id, (relationCounts.get(id) ?? 0) + 1);
|
|
7588
7641
|
ownedPatchCounts.set(patch.bundle_id, (ownedPatchCounts.get(patch.bundle_id) ?? 0) + 1);
|
|
7589
7642
|
}
|
|
7590
7643
|
const channelReferenceCounts = /* @__PURE__ */ new Map();
|
|
@@ -7693,7 +7746,7 @@ const compileAndCommitDynamoDBChanges = async (store, input) => {
|
|
|
7693
7746
|
...original ? { ExpressionAttributeValues: { ":version": original.version } } : {}
|
|
7694
7747
|
} });
|
|
7695
7748
|
}
|
|
7696
|
-
const changedReleaseIds = new Set([
|
|
7749
|
+
const changedReleaseIds = new Set([.../* @__PURE__ */ new Set([...originalReleases.keys(), ...releases.keys()])].filter((id) => {
|
|
7697
7750
|
const original = originalReleases.get(id)?.row;
|
|
7698
7751
|
const next = releases.get(id);
|
|
7699
7752
|
return original === void 0 || next === void 0 || !rowsEqual(original, next);
|
|
@@ -7735,17 +7788,6 @@ const compileAndCommitDynamoDBChanges = async (store, input) => {
|
|
|
7735
7788
|
bundle_patches: patches.size - originalPatches.size
|
|
7736
7789
|
});
|
|
7737
7790
|
if (counter !== void 0) actions.push(counter);
|
|
7738
|
-
for (const [key, row] of analytics) actions.push({ Put: {
|
|
7739
|
-
TableName: store.tableName,
|
|
7740
|
-
Item: boundedDynamoDBMetadataItem({
|
|
7741
|
-
pk: DYNAMODB_ANALYTICS_PARTITION,
|
|
7742
|
-
sk: key,
|
|
7743
|
-
version: 1,
|
|
7744
|
-
row
|
|
7745
|
-
}),
|
|
7746
|
-
ConditionExpression: "attribute_not_exists(#pk)",
|
|
7747
|
-
ExpressionAttributeNames: { "#pk": "pk" }
|
|
7748
|
-
} });
|
|
7749
7791
|
for (const [id, current] of apiKeys) {
|
|
7750
7792
|
const original = originalApiKeys.get(id);
|
|
7751
7793
|
if (original !== void 0 && rowsEqual(original.row, current.row)) continue;
|
|
@@ -7779,9 +7821,15 @@ const createDynamoDBCommit = (store) => async (input) => {
|
|
|
7779
7821
|
return compileAndCommitDynamoDBChanges(store, input);
|
|
7780
7822
|
}
|
|
7781
7823
|
};
|
|
7782
|
-
const
|
|
7824
|
+
const DYNAMODB_INSIGHTS_PARTITION = "bundle_events";
|
|
7825
|
+
const DYNAMODB_INSIGHTS_INSTALLATIONS_PARTITION = "_hot-updater#insights-installations";
|
|
7826
|
+
const DYNAMODB_INSIGHTS_EVENT_IDS_PARTITION = "_hot-updater#insights-event-ids";
|
|
7827
|
+
const DYNAMODB_INSIGHTS_BUNDLE_PREFIX = "_hot-updater#insights-bundle#";
|
|
7783
7828
|
const DYNAMODB_API_KEY_PARTITION = "api_keys";
|
|
7784
7829
|
const DYNAMODB_API_KEY_HASH_PARTITION = "_hot-updater#api-key-hashes";
|
|
7830
|
+
const DYNAMODB_INSIGHTS_MOVEMENT_PREFIX = "_hot-updater#insights-movement#";
|
|
7831
|
+
const DYNAMODB_INSIGHTS_USER_PREFIX = "_hot-updater#insights-user#";
|
|
7832
|
+
const DYNAMODB_INSIGHTS_RECORD_ATTEMPTS = 3;
|
|
7785
7833
|
const hasValidBundleEventShape = (value) => {
|
|
7786
7834
|
const type = field(value, "type");
|
|
7787
7835
|
const fromBundleId = field(value, "from_bundle_id");
|
|
@@ -7789,6 +7837,7 @@ const hasValidBundleEventShape = (value) => {
|
|
|
7789
7837
|
return (type === "UPDATE_APPLIED" || type === "RECOVERED" || type === "RELEASE_ADOPTED") && typeof fromBundleId === "string" && (updateStrategy === "fingerprint" || updateStrategy === "appVersion") || type === "UNCHANGED" && fromBundleId === null && updateStrategy === null;
|
|
7790
7838
|
};
|
|
7791
7839
|
const isBundleEventRow = (value) => typeof value === "object" && value !== null && typeof field(value, "id") === "string" && typeof field(value, "install_id") === "string" && isNullableString(field(value, "from_release_id")) && isNullableString(field(value, "to_release_id")) && typeof field(value, "to_bundle_id") === "string" && (field(value, "platform") === "ios" || field(value, "platform") === "android") && typeof field(value, "received_at_ms") === "number" && hasValidBundleEventShape(value);
|
|
7840
|
+
const isInsightsInstallationRow = (value) => typeof value === "object" && value !== null && typeof field(value, "id") === "string" && typeof field(value, "install_id") === "string" && isNullableString(field(value, "user_id")) && isNullableString(field(value, "username")) && typeof field(value, "to_bundle_id") === "string" && (field(value, "type") === "UPDATE_APPLIED" || field(value, "type") === "RECOVERED" || field(value, "type") === "RELEASE_ADOPTED" || field(value, "type") === "UNCHANGED") && (field(value, "platform") === "ios" || field(value, "platform") === "android") && typeof field(value, "app_version") === "string" && typeof field(value, "channel") === "string" && typeof field(value, "cohort") === "string" && typeof field(value, "received_at_ms") === "number";
|
|
7792
7841
|
const isApiKeyRow = (value) => typeof value === "object" && value !== null && typeof field(value, "id") === "string" && typeof field(value, "hash") === "string" && typeof field(value, "name") === "string" && typeof field(value, "prefix") === "string" && field(value, "role") === "client" && typeof field(value, "created_at_ms") === "number" && (field(value, "revoked_at_ms") === null || typeof field(value, "revoked_at_ms") === "number");
|
|
7793
7842
|
const parseOfficialRowItem = (value, partition, isRow) => {
|
|
7794
7843
|
if (value.pk !== partition || typeof value.sk !== "string" || typeof value.version !== "number" || !isRow(value.row)) throw new DynamoDBStoredItemError();
|
|
@@ -7798,52 +7847,279 @@ const parseOfficialRowItem = (value, partition, isRow) => {
|
|
|
7798
7847
|
};
|
|
7799
7848
|
};
|
|
7800
7849
|
const timestampSortKey = (timestampMs) => Math.trunc(timestampMs).toString().padStart(16, "0");
|
|
7801
|
-
const
|
|
7802
|
-
const
|
|
7803
|
-
|
|
7804
|
-
|
|
7850
|
+
const insightsSortKey = (row) => `${timestampSortKey(row.received_at_ms)}#${row.id}`;
|
|
7851
|
+
const insightsMovementPartition = (installId) => `${DYNAMODB_INSIGHTS_MOVEMENT_PREFIX}${installId}`;
|
|
7852
|
+
const insightsUserPartition = (userId) => `${DYNAMODB_INSIGHTS_USER_PREFIX}${userId}`;
|
|
7853
|
+
const insightsBundlePartition = (filter) => {
|
|
7854
|
+
const scope = JSON.stringify([
|
|
7855
|
+
filter.platform,
|
|
7856
|
+
filter.channel,
|
|
7857
|
+
filter.type,
|
|
7858
|
+
filter.type === "RECOVERED" ? filter.fromBundleId : filter.toBundleId
|
|
7859
|
+
]);
|
|
7860
|
+
return `${DYNAMODB_INSIGHTS_BUNDLE_PREFIX}${createHash("sha256").update(scope, "utf8").digest("hex")}`;
|
|
7861
|
+
};
|
|
7862
|
+
const toInsightsBundleItem = (row) => row.type === "UNCHANGED" ? null : boundedDynamoDBMetadataItem({
|
|
7863
|
+
pk: insightsBundlePartition({
|
|
7864
|
+
platform: row.platform,
|
|
7865
|
+
channel: row.channel,
|
|
7866
|
+
...row.type === "RECOVERED" ? {
|
|
7867
|
+
type: row.type,
|
|
7868
|
+
fromBundleId: row.from_bundle_id
|
|
7869
|
+
} : {
|
|
7870
|
+
type: row.type,
|
|
7871
|
+
toBundleId: row.to_bundle_id
|
|
7872
|
+
}
|
|
7873
|
+
}),
|
|
7874
|
+
sk: insightsSortKey(row),
|
|
7875
|
+
version: 1,
|
|
7876
|
+
row
|
|
7877
|
+
});
|
|
7878
|
+
const toInsightsEventItem = (row) => {
|
|
7879
|
+
const orderKey = insightsSortKey(row);
|
|
7880
|
+
return boundedDynamoDBMetadataItem({
|
|
7881
|
+
pk: DYNAMODB_INSIGHTS_PARTITION,
|
|
7882
|
+
sk: orderKey,
|
|
7883
|
+
version: 1,
|
|
7884
|
+
row,
|
|
7885
|
+
...isInsightsMovementEvent(row) ? {
|
|
7886
|
+
gsi1pk: insightsMovementPartition(row.install_id),
|
|
7887
|
+
gsi1sk: orderKey
|
|
7888
|
+
} : {}
|
|
7889
|
+
});
|
|
7890
|
+
};
|
|
7891
|
+
const toInsightsInstallationItem = (row) => boundedDynamoDBMetadataItem({
|
|
7892
|
+
pk: DYNAMODB_INSIGHTS_INSTALLATIONS_PARTITION,
|
|
7893
|
+
sk: row.install_id,
|
|
7894
|
+
order_key: insightsSortKey(row),
|
|
7895
|
+
version: 1,
|
|
7896
|
+
row
|
|
7897
|
+
});
|
|
7898
|
+
const toInsightsUserItem = (row) => boundedDynamoDBMetadataItem({
|
|
7899
|
+
pk: insightsUserPartition(row.user_id),
|
|
7900
|
+
sk: row.install_id,
|
|
7901
|
+
order_key: insightsSortKey(row),
|
|
7902
|
+
version: 1,
|
|
7903
|
+
row
|
|
7904
|
+
});
|
|
7905
|
+
const parseInsightsInstallationItem = (value, partition) => {
|
|
7906
|
+
const row = value.row;
|
|
7907
|
+
if (value.pk !== partition || typeof value.sk !== "string" || typeof value.order_key !== "string" || value.version !== 1 || !isInsightsInstallationRow(row) || value.sk !== row.install_id || value.order_key !== insightsSortKey(row)) throw new DynamoDBStoredItemError();
|
|
7908
|
+
return value;
|
|
7909
|
+
};
|
|
7910
|
+
const loadInsightsInstallationItem = async (store, installId) => {
|
|
7911
|
+
const { Item } = await store.client.send(new GetCommand({
|
|
7912
|
+
TableName: store.tableName,
|
|
7913
|
+
Key: {
|
|
7914
|
+
pk: DYNAMODB_INSIGHTS_INSTALLATIONS_PARTITION,
|
|
7915
|
+
sk: installId
|
|
7916
|
+
},
|
|
7917
|
+
ConsistentRead: true
|
|
7918
|
+
}));
|
|
7919
|
+
return Item === void 0 ? null : parseInsightsInstallationItem(Item, DYNAMODB_INSIGHTS_INSTALLATIONS_PARTITION);
|
|
7920
|
+
};
|
|
7921
|
+
const advancesInsightsInstallation = (row, current) => row.received_at_ms > current.received_at_ms || row.received_at_ms === current.received_at_ms && row.id > current.id;
|
|
7922
|
+
const recordDynamoDBInsightsEvent = async (store, { event: row, installation: next }) => {
|
|
7923
|
+
const eventItem = toInsightsEventItem(row);
|
|
7924
|
+
const bundleItem = toInsightsBundleItem(row);
|
|
7925
|
+
const identityKey = {
|
|
7926
|
+
pk: DYNAMODB_INSIGHTS_EVENT_IDS_PARTITION,
|
|
7927
|
+
sk: row.id
|
|
7928
|
+
};
|
|
7929
|
+
for (let attempt = 0; attempt < DYNAMODB_INSIGHTS_RECORD_ATTEMPTS; attempt++) {
|
|
7930
|
+
const { Item: accepted } = await store.client.send(new GetCommand({
|
|
7805
7931
|
TableName: store.tableName,
|
|
7806
|
-
|
|
7807
|
-
|
|
7808
|
-
sk: analyticsSortKey(row),
|
|
7809
|
-
version: 1,
|
|
7810
|
-
row
|
|
7811
|
-
}),
|
|
7812
|
-
ConditionExpression: "attribute_not_exists(#pk)",
|
|
7813
|
-
ExpressionAttributeNames: { "#pk": "pk" }
|
|
7932
|
+
Key: identityKey,
|
|
7933
|
+
ConsistentRead: true
|
|
7814
7934
|
}));
|
|
7935
|
+
if (accepted !== void 0) return;
|
|
7936
|
+
const current = await loadInsightsInstallationItem(store, row.install_id);
|
|
7937
|
+
const actions = [
|
|
7938
|
+
{ Put: {
|
|
7939
|
+
TableName: store.tableName,
|
|
7940
|
+
Item: identityKey,
|
|
7941
|
+
ConditionExpression: "attribute_not_exists(#pk)",
|
|
7942
|
+
ExpressionAttributeNames: { "#pk": "pk" }
|
|
7943
|
+
} },
|
|
7944
|
+
{ Put: {
|
|
7945
|
+
TableName: store.tableName,
|
|
7946
|
+
Item: eventItem
|
|
7947
|
+
} },
|
|
7948
|
+
...bundleItem === null ? [] : [{ Put: {
|
|
7949
|
+
TableName: store.tableName,
|
|
7950
|
+
Item: bundleItem
|
|
7951
|
+
} }]
|
|
7952
|
+
];
|
|
7953
|
+
if (current === null || advancesInsightsInstallation(next, current.row)) {
|
|
7954
|
+
actions.push({ Put: {
|
|
7955
|
+
TableName: store.tableName,
|
|
7956
|
+
Item: toInsightsInstallationItem(next),
|
|
7957
|
+
ConditionExpression: current === null ? "attribute_not_exists(#pk)" : "#orderKey = :currentOrderKey",
|
|
7958
|
+
ExpressionAttributeNames: current === null ? { "#pk": "pk" } : { "#orderKey": "order_key" },
|
|
7959
|
+
...current === null ? {} : { ExpressionAttributeValues: { ":currentOrderKey": current.order_key } }
|
|
7960
|
+
} });
|
|
7961
|
+
if (current !== null && current.row.user_id !== null && current.row.user_id !== next.user_id) actions.push({ Delete: {
|
|
7962
|
+
TableName: store.tableName,
|
|
7963
|
+
Key: {
|
|
7964
|
+
pk: insightsUserPartition(current.row.user_id),
|
|
7965
|
+
sk: current.row.install_id
|
|
7966
|
+
}
|
|
7967
|
+
} });
|
|
7968
|
+
if (next.user_id !== null) actions.push({ Put: {
|
|
7969
|
+
TableName: store.tableName,
|
|
7970
|
+
Item: toInsightsUserItem({
|
|
7971
|
+
...next,
|
|
7972
|
+
user_id: next.user_id
|
|
7973
|
+
})
|
|
7974
|
+
} });
|
|
7975
|
+
}
|
|
7976
|
+
try {
|
|
7977
|
+
await commitDynamoDBTransaction(store, actions);
|
|
7978
|
+
return;
|
|
7979
|
+
} catch (error) {
|
|
7980
|
+
if (!isDynamoDBTransactionConflict(error)) throw error;
|
|
7981
|
+
const { Item } = await store.client.send(new GetCommand({
|
|
7982
|
+
TableName: store.tableName,
|
|
7983
|
+
Key: identityKey,
|
|
7984
|
+
ConsistentRead: true
|
|
7985
|
+
}));
|
|
7986
|
+
if (Item !== void 0) return;
|
|
7987
|
+
if (attempt === 2) throw error;
|
|
7988
|
+
}
|
|
7989
|
+
}
|
|
7990
|
+
};
|
|
7991
|
+
const insightsEventRange = (input) => {
|
|
7992
|
+
const upperExclusive = input.after ? `${timestampSortKey(input.after.receivedAtMs)}#${input.after.id}` : `${timestampSortKey(input.beforeReceivedAtMs)}#`;
|
|
7993
|
+
const upper = `${upperExclusive.slice(0, -1)}${String.fromCharCode(upperExclusive.charCodeAt(upperExclusive.length - 1) - 1)}~`;
|
|
7994
|
+
const movement = input.filter.kind === "installationMovement";
|
|
7995
|
+
const partition = movement ? insightsMovementPartition(input.filter.installId) : input.filter.kind === "bundle" ? insightsBundlePartition(input.filter) : DYNAMODB_INSIGHTS_PARTITION;
|
|
7996
|
+
return {
|
|
7997
|
+
partition,
|
|
7998
|
+
query: {
|
|
7999
|
+
...movement ? { IndexName: DYNAMODB_UPDATE_INDEX_NAME } : { ConsistentRead: true },
|
|
8000
|
+
KeyConditionExpression: "#partition = :partition AND #order BETWEEN :since AND :upper",
|
|
8001
|
+
ExpressionAttributeNames: {
|
|
8002
|
+
"#partition": movement ? "gsi1pk" : "pk",
|
|
8003
|
+
"#order": movement ? "gsi1sk" : "sk"
|
|
8004
|
+
},
|
|
8005
|
+
ExpressionAttributeValues: {
|
|
8006
|
+
":partition": partition,
|
|
8007
|
+
":since": `${timestampSortKey(input.sinceMs ?? 0)}#`,
|
|
8008
|
+
":upper": upper
|
|
8009
|
+
}
|
|
8010
|
+
}
|
|
8011
|
+
};
|
|
8012
|
+
};
|
|
8013
|
+
const createDynamoDBInsightsTable = (store) => ({
|
|
8014
|
+
record: (input) => recordDynamoDBInsightsEvent(store, input),
|
|
8015
|
+
async listEvents(input) {
|
|
8016
|
+
if ((input.sinceMs ?? 0) === input.beforeReceivedAtMs) return [];
|
|
8017
|
+
const range = insightsEventRange(input);
|
|
8018
|
+
const rows = [];
|
|
8019
|
+
let exclusiveStartKey;
|
|
8020
|
+
do {
|
|
8021
|
+
const page = await store.client.send(new QueryCommand({
|
|
8022
|
+
TableName: store.tableName,
|
|
8023
|
+
...range.query,
|
|
8024
|
+
ExclusiveStartKey: exclusiveStartKey,
|
|
8025
|
+
Limit: input.limit - rows.length,
|
|
8026
|
+
ScanIndexForward: false
|
|
8027
|
+
}));
|
|
8028
|
+
rows.push(...(page.Items ?? []).slice(0, input.limit - rows.length).map((item) => parseOfficialRowItem(item, input.filter.kind === "bundle" ? range.partition : DYNAMODB_INSIGHTS_PARTITION, isBundleEventRow).row));
|
|
8029
|
+
exclusiveStartKey = page.LastEvaluatedKey;
|
|
8030
|
+
} while (rows.length < input.limit && exclusiveStartKey !== void 0);
|
|
8031
|
+
return rows;
|
|
7815
8032
|
},
|
|
7816
|
-
async
|
|
7817
|
-
if (
|
|
7818
|
-
|
|
8033
|
+
async findInstallations(input) {
|
|
8034
|
+
if ("installId" in input) {
|
|
8035
|
+
const stored = await loadInsightsInstallationItem(store, input.installId);
|
|
8036
|
+
return stored === null ? [] : [stored.row];
|
|
8037
|
+
}
|
|
8038
|
+
const partition = insightsUserPartition(input.userId);
|
|
7819
8039
|
const rows = [];
|
|
7820
|
-
const afterKey = input.after === void 0 ? void 0 : `${timestampSortKey(input.after.receivedAtMs)}#${input.after.id}`;
|
|
7821
8040
|
let exclusiveStartKey;
|
|
7822
8041
|
do {
|
|
7823
8042
|
const page = await store.client.send(new QueryCommand({
|
|
7824
8043
|
TableName: store.tableName,
|
|
8044
|
+
ConsistentRead: true,
|
|
7825
8045
|
ExclusiveStartKey: exclusiveStartKey,
|
|
7826
|
-
KeyConditionExpression:
|
|
8046
|
+
KeyConditionExpression: input.afterInstallId === void 0 ? "#pk = :pk" : "#pk = :pk AND #sk > :after",
|
|
7827
8047
|
ExpressionAttributeNames: {
|
|
7828
8048
|
"#pk": "pk",
|
|
7829
|
-
"#sk": "sk"
|
|
8049
|
+
...input.afterInstallId === void 0 ? {} : { "#sk": "sk" }
|
|
7830
8050
|
},
|
|
7831
8051
|
ExpressionAttributeValues: {
|
|
7832
|
-
":
|
|
7833
|
-
":
|
|
7834
|
-
...afterKey === void 0 ? {} : { ":after": afterKey }
|
|
8052
|
+
":pk": partition,
|
|
8053
|
+
...input.afterInstallId === void 0 ? {} : { ":after": input.afterInstallId }
|
|
7835
8054
|
},
|
|
7836
|
-
Limit: input.limit - rows.length
|
|
8055
|
+
Limit: input.limit - rows.length,
|
|
7837
8056
|
ScanIndexForward: true
|
|
7838
8057
|
}));
|
|
7839
|
-
for (const item of page.Items ?? []) {
|
|
7840
|
-
|
|
7841
|
-
|
|
7842
|
-
if (
|
|
8058
|
+
for (const item of (page.Items ?? []).slice(0, input.limit - rows.length)) {
|
|
8059
|
+
const stored = parseInsightsInstallationItem(item, partition);
|
|
8060
|
+
const current = await loadInsightsInstallationItem(store, stored.row.install_id);
|
|
8061
|
+
if (current?.row.user_id === input.userId) rows.push(current.row);
|
|
7843
8062
|
}
|
|
7844
8063
|
exclusiveStartKey = page.LastEvaluatedKey;
|
|
7845
|
-
} while (exclusiveStartKey !== void 0);
|
|
8064
|
+
} while (rows.length < input.limit && exclusiveStartKey !== void 0);
|
|
7846
8065
|
return rows;
|
|
8066
|
+
},
|
|
8067
|
+
async countInstallations(input) {
|
|
8068
|
+
let count = 0;
|
|
8069
|
+
let exclusiveStartKey;
|
|
8070
|
+
do {
|
|
8071
|
+
const page = await store.client.send(new QueryCommand({
|
|
8072
|
+
TableName: store.tableName,
|
|
8073
|
+
ConsistentRead: true,
|
|
8074
|
+
ExclusiveStartKey: exclusiveStartKey,
|
|
8075
|
+
KeyConditionExpression: "#pk = :pk",
|
|
8076
|
+
FilterExpression: "#row.#platform = :platform AND #row.#channel = :channel AND #row.#received >= :since" + (input.bundleId === void 0 ? "" : " AND #row.#bundle = :bundle"),
|
|
8077
|
+
ExpressionAttributeNames: {
|
|
8078
|
+
"#pk": "pk",
|
|
8079
|
+
"#row": "row",
|
|
8080
|
+
"#platform": "platform",
|
|
8081
|
+
"#channel": "channel",
|
|
8082
|
+
"#received": "received_at_ms",
|
|
8083
|
+
...input.bundleId === void 0 ? {} : { "#bundle": "to_bundle_id" }
|
|
8084
|
+
},
|
|
8085
|
+
ExpressionAttributeValues: {
|
|
8086
|
+
":pk": DYNAMODB_INSIGHTS_INSTALLATIONS_PARTITION,
|
|
8087
|
+
":platform": input.platform,
|
|
8088
|
+
":channel": input.channel,
|
|
8089
|
+
":since": input.sinceMs,
|
|
8090
|
+
...input.bundleId === void 0 ? {} : { ":bundle": input.bundleId }
|
|
8091
|
+
},
|
|
8092
|
+
Select: "COUNT",
|
|
8093
|
+
ScanIndexForward: true
|
|
8094
|
+
}));
|
|
8095
|
+
count += page.Count ?? 0;
|
|
8096
|
+
exclusiveStartKey = page.LastEvaluatedKey;
|
|
8097
|
+
} while (exclusiveStartKey !== void 0);
|
|
8098
|
+
return count;
|
|
8099
|
+
},
|
|
8100
|
+
async countEvents(input) {
|
|
8101
|
+
if (input.sinceMs === input.beforeReceivedAtMs) return 0;
|
|
8102
|
+
const { query } = insightsEventRange({
|
|
8103
|
+
...input,
|
|
8104
|
+
filter: {
|
|
8105
|
+
kind: "bundle",
|
|
8106
|
+
...input.filter
|
|
8107
|
+
},
|
|
8108
|
+
limit: 1
|
|
8109
|
+
});
|
|
8110
|
+
let count = 0;
|
|
8111
|
+
let exclusiveStartKey;
|
|
8112
|
+
do {
|
|
8113
|
+
const page = await store.client.send(new QueryCommand({
|
|
8114
|
+
TableName: store.tableName,
|
|
8115
|
+
...query,
|
|
8116
|
+
ExclusiveStartKey: exclusiveStartKey,
|
|
8117
|
+
Select: "COUNT"
|
|
8118
|
+
}));
|
|
8119
|
+
count += page.Count ?? 0;
|
|
8120
|
+
exclusiveStartKey = page.LastEvaluatedKey;
|
|
8121
|
+
} while (exclusiveStartKey !== void 0);
|
|
8122
|
+
return count;
|
|
7847
8123
|
}
|
|
7848
8124
|
});
|
|
7849
8125
|
const apiKeyItem = (row, version) => ({
|
|
@@ -7976,7 +8252,7 @@ const dynamoDB = (config) => {
|
|
|
7976
8252
|
models: {
|
|
7977
8253
|
...adapter.models,
|
|
7978
8254
|
bundlePatches: createDynamoDBBundlePatchTable(store, DYNAMODB_UPDATE_INDEX_NAME),
|
|
7979
|
-
|
|
8255
|
+
insights: createDynamoDBInsightsTable(store),
|
|
7980
8256
|
apiKeys: createDynamoDBApiKeyTable(store)
|
|
7981
8257
|
},
|
|
7982
8258
|
async commit(input) {
|
|
@@ -9101,6 +9377,7 @@ var CloudFrontManager = class {
|
|
|
9101
9377
|
//#region iac/dynamodb.ts
|
|
9102
9378
|
const DYNAMODB_DESCRIBE_TABLE_ACTION = "dynamodb:DescribeTable";
|
|
9103
9379
|
var DynamoDBTableSchemaError = class extends Error {
|
|
9380
|
+
tableName;
|
|
9104
9381
|
name = "DynamoDBTableSchemaError";
|
|
9105
9382
|
constructor(tableName) {
|
|
9106
9383
|
super(`DynamoDB table "${tableName}" does not match the Hot Updater key and index schema`);
|
|
@@ -9108,6 +9385,8 @@ var DynamoDBTableSchemaError = class extends Error {
|
|
|
9108
9385
|
}
|
|
9109
9386
|
};
|
|
9110
9387
|
var DynamoDBPermissionError = class extends InitError {
|
|
9388
|
+
tableName;
|
|
9389
|
+
region;
|
|
9111
9390
|
name = "DynamoDBPermissionError";
|
|
9112
9391
|
requiredAction = DYNAMODB_DESCRIBE_TABLE_ACTION;
|
|
9113
9392
|
constructor(tableName, region, cause) {
|
|
@@ -9154,6 +9433,7 @@ const hasExpectedSchema = (table) => {
|
|
|
9154
9433
|
};
|
|
9155
9434
|
const isResourceNotFound = (error) => typeof error === "object" && error !== null && Reflect.get(error, "name") === "ResourceNotFoundException";
|
|
9156
9435
|
var DynamoDBManager = class {
|
|
9436
|
+
region;
|
|
9157
9437
|
client;
|
|
9158
9438
|
constructor(region, credentials) {
|
|
9159
9439
|
this.region = region;
|
|
@@ -9254,13 +9534,17 @@ var IAMManager = class {
|
|
|
9254
9534
|
"dynamodb:TransactWriteItems",
|
|
9255
9535
|
"dynamodb:UpdateItem"
|
|
9256
9536
|
],
|
|
9257
|
-
Condition: { "ForAllValues:
|
|
9537
|
+
Condition: { "ForAllValues:StringLike": { "dynamodb:LeadingKeys": [
|
|
9258
9538
|
"_hot-updater",
|
|
9259
9539
|
"bundles",
|
|
9260
9540
|
"bundle_patches",
|
|
9261
9541
|
DYNAMODB_CHANNEL_PARTITION,
|
|
9262
9542
|
DYNAMODB_CHANNEL_NAME_PARTITION,
|
|
9263
|
-
|
|
9543
|
+
DYNAMODB_INSIGHTS_PARTITION,
|
|
9544
|
+
DYNAMODB_INSIGHTS_INSTALLATIONS_PARTITION,
|
|
9545
|
+
DYNAMODB_INSIGHTS_EVENT_IDS_PARTITION,
|
|
9546
|
+
`${DYNAMODB_INSIGHTS_BUNDLE_PREFIX}*`,
|
|
9547
|
+
"_hot-updater#insights-user#*",
|
|
9264
9548
|
DYNAMODB_API_KEY_PARTITION,
|
|
9265
9549
|
DYNAMODB_API_KEY_HASH_PARTITION
|
|
9266
9550
|
] } },
|
|
@@ -9398,7 +9682,8 @@ var LambdaEdgeDeployer = class {
|
|
|
9398
9682
|
async deploy(lambdaRoleArn, lambdaName, config) {
|
|
9399
9683
|
const cwd = getCwd();
|
|
9400
9684
|
const lambdaPath = __require.resolve("@hot-updater/aws/lambda");
|
|
9401
|
-
const
|
|
9685
|
+
const lambdaDir = path$1.dirname(lambdaPath);
|
|
9686
|
+
const { tmpDir, removeTmpDir } = await copyDirToTmp(lambdaDir);
|
|
9402
9687
|
const indexPath = path$1.join(tmpDir, "index.cjs");
|
|
9403
9688
|
const code = transformEnv(indexPath, {
|
|
9404
9689
|
CLOUDFRONT_KEY_PAIR_ID: config.publicKeyId,
|
|
@@ -9706,12 +9991,11 @@ const awsOptions = {
|
|
|
9706
9991
|
};`.trim()
|
|
9707
9992
|
}];
|
|
9708
9993
|
break;
|
|
9709
|
-
case "account":
|
|
9710
|
-
|
|
9711
|
-
|
|
9712
|
-
|
|
9713
|
-
|
|
9714
|
-
code: `
|
|
9994
|
+
case "account": helperStatements = [{
|
|
9995
|
+
name: "awsOptions",
|
|
9996
|
+
strategy: "merge-object",
|
|
9997
|
+
replaceIncompatibleProperties: ["credentials"],
|
|
9998
|
+
code: `
|
|
9715
9999
|
const awsOptions = {
|
|
9716
10000
|
region: process.env.HOT_UPDATER_S3_REGION!,
|
|
9717
10001
|
credentials: {
|
|
@@ -9719,8 +10003,7 @@ const awsOptions = {
|
|
|
9719
10003
|
secretAccessKey: process.env.HOT_UPDATER_S3_SECRET_ACCESS_KEY!,
|
|
9720
10004
|
},
|
|
9721
10005
|
};`.trim()
|
|
9722
|
-
|
|
9723
|
-
break;
|
|
10006
|
+
}];
|
|
9724
10007
|
}
|
|
9725
10008
|
const builder = new ConfigBuilder().setBuildType(build).setStorage(storageConfig).setDatabase(databaseConfig).setIntermediateCode(helperStatements.map((statement) => statement.code.trim()).join("\n\n"));
|
|
9726
10009
|
switch (authMode.mode) {
|
|
@@ -9730,13 +10013,10 @@ const awsOptions = {
|
|
|
9730
10013
|
named: ["fromSSO"]
|
|
9731
10014
|
});
|
|
9732
10015
|
break;
|
|
9733
|
-
case "local":
|
|
9734
|
-
|
|
9735
|
-
|
|
9736
|
-
|
|
9737
|
-
});
|
|
9738
|
-
break;
|
|
9739
|
-
case "account": break;
|
|
10016
|
+
case "local": builder.addImport({
|
|
10017
|
+
pkg: "@aws-sdk/credential-providers",
|
|
10018
|
+
named: [authMode.profile ? "fromIni" : "fromNodeProviderChain"]
|
|
10019
|
+
});
|
|
9740
10020
|
}
|
|
9741
10021
|
return createHotUpdaterConfigScaffoldFromBuilder(builder, { helperStatements });
|
|
9742
10022
|
};
|
|
@@ -9771,7 +10051,7 @@ const isAwsRegion = (value) => {
|
|
|
9771
10051
|
return value !== void 0 && Object.hasOwn(regionLocationMap, value);
|
|
9772
10052
|
};
|
|
9773
10053
|
const prepareDynamoDBDeployment = async (input) => {
|
|
9774
|
-
|
|
10054
|
+
await new DynamoDBManager(input.region, input.credentials).ensureTable(input.tableName);
|
|
9775
10055
|
};
|
|
9776
10056
|
const prepareDynamoDBApiKey = async (input) => {
|
|
9777
10057
|
return (await provisionApiKey({
|
|
@@ -9900,13 +10180,14 @@ const runInit = async ({ build, envFile }) => {
|
|
|
9900
10180
|
dynamodbTableName: resolvedDynamoDBTableName,
|
|
9901
10181
|
lambdaName
|
|
9902
10182
|
};
|
|
10183
|
+
const persistCredentialInputs = await confirmInitInputPersistence({
|
|
10184
|
+
existingEnv: managedEnv,
|
|
10185
|
+
inputs: resolvedInputs,
|
|
10186
|
+
nonInteractive,
|
|
10187
|
+
provider: initProvider
|
|
10188
|
+
});
|
|
9903
10189
|
const initEnv = getInitProviderEnvVars({
|
|
9904
|
-
includeConsentInputs:
|
|
9905
|
-
existingEnv: managedEnv,
|
|
9906
|
-
inputs: resolvedInputs,
|
|
9907
|
-
nonInteractive,
|
|
9908
|
-
provider: initProvider
|
|
9909
|
-
}),
|
|
10190
|
+
includeConsentInputs: persistCredentialInputs,
|
|
9910
10191
|
inputs: resolvedInputs,
|
|
9911
10192
|
provider: initProvider
|
|
9912
10193
|
});
|