@canonry/canonry 7.57.0 → 7.57.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{backfill-4LAL4IIT.js → backfill-WHQ5PRQY.js} +2 -2
- package/dist/{chunk-NUHCDBKR.js → chunk-72GHLLA5.js} +1 -1
- package/dist/{chunk-SHUTA74W.js → chunk-AMN7DC25.js} +5 -5
- package/dist/{chunk-FHYOQI26.js → chunk-FC2JA3FN.js} +1487 -1428
- package/dist/{chunk-OAA7RHMG.js → chunk-HFMRK3V3.js} +1 -1
- package/dist/{chunk-JQS2H65K.js → chunk-N6P3NLEI.js} +14 -14
- package/dist/{chunk-3OTH3ABK.js → chunk-RNDQREJC.js} +1 -1
- package/dist/{chunk-J4YFSAAY.js → chunk-SLN2KNEE.js} +2 -2
- package/dist/{chunk-BJN7FNIB.js → chunk-W7EX6AYN.js} +1 -1
- package/dist/{cli-commands-NUXQWIKA.js → cli-commands-5O54JBVV.js} +1 -1
- package/dist/cli.js +2 -2
- package/dist/{dashboard-55IRUB73.js → dashboard-TERSQLOV.js} +1 -1
- package/dist/{demo-KEFXTKRQ.js → demo-UT5Y2RFF.js} +1 -1
- package/dist/{demo-server-BDQDPUWN.js → demo-server-5D6QLZOA.js} +2 -2
- package/dist/index.d.ts +9 -9
- package/dist/index.js +5 -5
- package/dist/{init-542CZBNS.js → init-ONIDATRC.js} +1 -1
- package/dist/{intelligence-service-6IVSAF2X.js → intelligence-service-KRIDKJH2.js} +2 -2
- package/dist/{serve-R2OR4ZF2.js → serve-VG52MHRC.js} +6 -6
- package/dist/{session-CSYHALIE.js → session-IQKGJYKH.js} +3 -3
- package/dist/{tools-HIRCGFM2.js → tools-KKSEFA25.js} +2 -2
- package/package.json +1 -1
|
@@ -41910,20 +41910,28 @@ async function gbpFetchGet(url, accessToken, opts = {}) {
|
|
|
41910
41910
|
}
|
|
41911
41911
|
|
|
41912
41912
|
// ../integration-google-business-profile/src/local-posts-client.ts
|
|
41913
|
+
var GbpLocalPostResponseError = class extends Error {
|
|
41914
|
+
constructor(reason) {
|
|
41915
|
+
super(reason === "UNSUPPORTED_MEDIA" ? "Unsupported or incomplete Google Local Post media" : reason === "WRONG_IDENTITY" ? "Wrong Google Local Post identity" : "Invalid Google Local Post response");
|
|
41916
|
+
this.reason = reason;
|
|
41917
|
+
this.name = "GbpLocalPostResponseError";
|
|
41918
|
+
}
|
|
41919
|
+
reason;
|
|
41920
|
+
};
|
|
41913
41921
|
function parent(account, location) {
|
|
41914
41922
|
return `${gbpAccountNameSchema.parse(account)}/${gbpLocationNameSchema.parse(location)}`;
|
|
41915
41923
|
}
|
|
41916
41924
|
function post(value) {
|
|
41917
41925
|
if (!value || typeof value !== "object")
|
|
41918
|
-
throw new
|
|
41926
|
+
throw new GbpLocalPostResponseError("INVALID_RESPONSE");
|
|
41919
41927
|
const raw = value;
|
|
41920
41928
|
const action = raw.callToAction;
|
|
41921
41929
|
const media = Array.isArray(raw.media) ? raw.media : [];
|
|
41922
41930
|
if (media.some(
|
|
41923
41931
|
(item2) => !item2 || item2.mediaFormat !== "PHOTO" || typeof item2.sourceUrl !== "string"
|
|
41924
41932
|
))
|
|
41925
|
-
throw new
|
|
41926
|
-
|
|
41933
|
+
throw new GbpLocalPostResponseError("UNSUPPORTED_MEDIA");
|
|
41934
|
+
const parsed = gbpLocalPostDtoSchema.safeParse({
|
|
41927
41935
|
name: raw.name,
|
|
41928
41936
|
languageCode: raw.languageCode ?? "",
|
|
41929
41937
|
summary: raw.summary ?? "",
|
|
@@ -41936,6 +41944,8 @@ function post(value) {
|
|
|
41936
41944
|
updateTime: raw.updateTime,
|
|
41937
41945
|
searchUrl: raw.searchUrl ?? null
|
|
41938
41946
|
});
|
|
41947
|
+
if (!parsed.success) throw new GbpLocalPostResponseError("INVALID_RESPONSE");
|
|
41948
|
+
return parsed.data;
|
|
41939
41949
|
}
|
|
41940
41950
|
async function listLocalPosts(token, account, location, pageToken, options = {}) {
|
|
41941
41951
|
const scope = parent(account, location);
|
|
@@ -41943,9 +41953,11 @@ async function listLocalPosts(token, account, location, pageToken, options = {})
|
|
|
41943
41953
|
url.searchParams.set("pageSize", "100");
|
|
41944
41954
|
if (pageToken) url.searchParams.set("pageToken", pageToken);
|
|
41945
41955
|
const raw = await gbpFetchGet(url.toString(), token, options);
|
|
41956
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw) || raw.localPosts !== void 0 && !Array.isArray(raw.localPosts))
|
|
41957
|
+
throw new GbpLocalPostResponseError("INVALID_RESPONSE");
|
|
41946
41958
|
const posts = (raw.localPosts ?? []).map(post);
|
|
41947
41959
|
if (posts.some((item2) => !item2.name.startsWith(`${scope}/localPosts/`)))
|
|
41948
|
-
throw new
|
|
41960
|
+
throw new GbpLocalPostResponseError("WRONG_IDENTITY");
|
|
41949
41961
|
return { posts, nextPageToken: raw.nextPageToken ?? null };
|
|
41950
41962
|
}
|
|
41951
41963
|
async function getLocalPost(token, name, options = {}) {
|
|
@@ -41953,7 +41965,7 @@ async function getLocalPost(token, name, options = {}) {
|
|
|
41953
41965
|
const result = post(
|
|
41954
41966
|
await gbpFetchGet(`${GBP_LEGACY_V4_BASE}/${name}`, token, options)
|
|
41955
41967
|
);
|
|
41956
|
-
if (result.name !== name) throw new
|
|
41968
|
+
if (result.name !== name) throw new GbpLocalPostResponseError("WRONG_IDENTITY");
|
|
41957
41969
|
return result;
|
|
41958
41970
|
}
|
|
41959
41971
|
async function createLocalPost(token, account, location, content) {
|
|
@@ -42299,1549 +42311,1596 @@ function classifyReviewsError(err) {
|
|
|
42299
42311
|
return { access: "error", reason: "NETWORK", projectWide: false };
|
|
42300
42312
|
}
|
|
42301
42313
|
|
|
42302
|
-
//
|
|
42303
|
-
var
|
|
42304
|
-
|
|
42305
|
-
|
|
42306
|
-
|
|
42307
|
-
|
|
42308
|
-
|
|
42309
|
-
|
|
42310
|
-
|
|
42311
|
-
|
|
42312
|
-
|
|
42313
|
-
|
|
42314
|
-
|
|
42315
|
-
|
|
42316
|
-
|
|
42317
|
-
|
|
42318
|
-
|
|
42319
|
-
|
|
42320
|
-
|
|
42321
|
-
|
|
42322
|
-
|
|
42323
|
-
|
|
42324
|
-
|
|
42325
|
-
8226,
|
|
42326
|
-
8211,
|
|
42327
|
-
8212,
|
|
42328
|
-
732,
|
|
42329
|
-
8482,
|
|
42330
|
-
353,
|
|
42331
|
-
8250,
|
|
42332
|
-
339,
|
|
42333
|
-
0,
|
|
42334
|
-
382,
|
|
42335
|
-
376
|
|
42336
|
-
];
|
|
42337
|
-
function isInvalidCodePoint(codePoint) {
|
|
42338
|
-
return codePoint === 0 || codePoint >= 55296 && codePoint <= 57343 || codePoint > 1114111;
|
|
42339
|
-
}
|
|
42340
|
-
function replaceCodePoint(codePoint) {
|
|
42341
|
-
if (isInvalidCodePoint(codePoint)) {
|
|
42342
|
-
return 65533;
|
|
42314
|
+
// ../integration-google/src/constants.ts
|
|
42315
|
+
var GOOGLE_AUTH_URL = "https://accounts.google.com/o/oauth2/v2/auth";
|
|
42316
|
+
var GOOGLE_TOKEN_URL = "https://oauth2.googleapis.com/token";
|
|
42317
|
+
var GSC_SCOPE = "https://www.googleapis.com/auth/webmasters";
|
|
42318
|
+
var GSC_READONLY_SCOPE = "https://www.googleapis.com/auth/webmasters.readonly";
|
|
42319
|
+
var INDEXING_SCOPE = "https://www.googleapis.com/auth/indexing";
|
|
42320
|
+
var GSC_API_BASE = "https://www.googleapis.com/webmasters/v3";
|
|
42321
|
+
var URL_INSPECTION_API = "https://searchconsole.googleapis.com/v1/urlInspection/index:inspect";
|
|
42322
|
+
var GSC_MAX_ROWS_PER_REQUEST = 25e3;
|
|
42323
|
+
var GSC_REPORTING_TIME_ZONE = "America/Los_Angeles";
|
|
42324
|
+
var GSC_DATA_LAG_DAYS = 3;
|
|
42325
|
+
var INDEXING_API_BASE = "https://indexing.googleapis.com/v3";
|
|
42326
|
+
var INDEXING_API_DAILY_LIMIT = 200;
|
|
42327
|
+
var GOOGLE_REQUEST_TIMEOUT_MS = 3e4;
|
|
42328
|
+
var GSC_MAX_PAGES = 40;
|
|
42329
|
+
|
|
42330
|
+
// ../integration-google/src/types.ts
|
|
42331
|
+
var GoogleAuthError = class extends Error {
|
|
42332
|
+
statusCode;
|
|
42333
|
+
constructor(message, statusCode) {
|
|
42334
|
+
super(message);
|
|
42335
|
+
this.name = "GoogleAuthError";
|
|
42336
|
+
this.statusCode = statusCode;
|
|
42343
42337
|
}
|
|
42344
|
-
|
|
42345
|
-
|
|
42338
|
+
};
|
|
42339
|
+
var GoogleApiError = class extends Error {
|
|
42340
|
+
status;
|
|
42341
|
+
constructor(message, status) {
|
|
42342
|
+
super(message);
|
|
42343
|
+
this.name = "GoogleApiError";
|
|
42344
|
+
this.status = status;
|
|
42345
|
+
}
|
|
42346
|
+
};
|
|
42347
|
+
|
|
42348
|
+
// ../integration-google/src/oauth.ts
|
|
42349
|
+
function validateClientId(clientId) {
|
|
42350
|
+
if (!clientId || typeof clientId !== "string" || clientId.trim().length === 0) {
|
|
42351
|
+
throw new GoogleAuthError("Client ID is required and must be a non-empty string");
|
|
42346
42352
|
}
|
|
42347
|
-
return codePoint;
|
|
42348
42353
|
}
|
|
42349
|
-
function
|
|
42350
|
-
|
|
42354
|
+
function validateClientSecret(clientSecret) {
|
|
42355
|
+
if (!clientSecret || typeof clientSecret !== "string" || clientSecret.trim().length === 0) {
|
|
42356
|
+
throw new GoogleAuthError("Client secret is required and must be a non-empty string");
|
|
42357
|
+
}
|
|
42351
42358
|
}
|
|
42352
|
-
|
|
42353
|
-
|
|
42354
|
-
|
|
42355
|
-
const table = new Uint8Array(127);
|
|
42356
|
-
let code = 0;
|
|
42357
|
-
for (let char = 33; char <= 126; char++) {
|
|
42358
|
-
if (char !== 34 && char !== 36 && char !== 92) {
|
|
42359
|
-
table[char] = code++;
|
|
42360
|
-
}
|
|
42359
|
+
function validateRedirectUri(redirectUri) {
|
|
42360
|
+
if (!redirectUri || typeof redirectUri !== "string" || redirectUri.trim().length === 0) {
|
|
42361
|
+
throw new GoogleAuthError("Redirect URI is required and must be a non-empty string");
|
|
42361
42362
|
}
|
|
42362
|
-
|
|
42363
|
-
|
|
42364
|
-
|
|
42365
|
-
|
|
42366
|
-
const inputLength = input.length;
|
|
42367
|
-
const twoCharBias = dictSize * (base - 1);
|
|
42368
|
-
let pos = 0;
|
|
42369
|
-
const readSlotCode = () => {
|
|
42370
|
-
const c12 = BASE91_INVERSE[input.charCodeAt(pos++)];
|
|
42371
|
-
return c12 < dictSize ? c12 : c12 * base - twoCharBias + BASE91_INVERSE[input.charCodeAt(pos++)];
|
|
42372
|
-
};
|
|
42373
|
-
const dict2AtomCount = atomCount - dict1AtomCount;
|
|
42374
|
-
const slotCount = atomCount + ngramCount;
|
|
42375
|
-
const single = new Int32Array(slotCount);
|
|
42376
|
-
single.fill(-1, dict1AtomCount, dictSize);
|
|
42377
|
-
single.fill(-1, dictSize + dict2AtomCount, slotCount);
|
|
42378
|
-
const start = new Int32Array(slotCount);
|
|
42379
|
-
const length = new Int32Array(slotCount);
|
|
42380
|
-
function decodeDelta(count9, off) {
|
|
42381
|
-
let previous = 0;
|
|
42382
|
-
let slot = off;
|
|
42383
|
-
const end = off + count9;
|
|
42384
|
-
while (slot < end) {
|
|
42385
|
-
const code = BASE91_INVERSE[input.charCodeAt(pos++)];
|
|
42386
|
-
if (code < 89) {
|
|
42387
|
-
previous += code;
|
|
42388
|
-
single[slot++] = previous;
|
|
42389
|
-
} else if (code === 89) {
|
|
42390
|
-
let runLength = BASE91_INVERSE[input.charCodeAt(pos++)] + 2;
|
|
42391
|
-
while (runLength--)
|
|
42392
|
-
single[slot++] = ++previous;
|
|
42393
|
-
} else {
|
|
42394
|
-
const next = BASE91_INVERSE[input.charCodeAt(pos++)];
|
|
42395
|
-
previous += 89 + // eslint-disable-next-line unicorn/prefer-minimal-ternary -- branches read a different number of side-effecting input bytes
|
|
42396
|
-
(next < 90 ? next * base + BASE91_INVERSE[input.charCodeAt(pos++)] : BASE91_INVERSE[input.charCodeAt(pos++)] * 8281 + BASE91_INVERSE[input.charCodeAt(pos++)] * base + BASE91_INVERSE[input.charCodeAt(pos++)]);
|
|
42397
|
-
single[slot++] = previous;
|
|
42398
|
-
}
|
|
42363
|
+
try {
|
|
42364
|
+
const url = new URL(redirectUri);
|
|
42365
|
+
if (!url.protocol.startsWith("http")) {
|
|
42366
|
+
throw new GoogleAuthError("Redirect URI must be an HTTP or HTTPS URL");
|
|
42399
42367
|
}
|
|
42368
|
+
} catch {
|
|
42369
|
+
throw new GoogleAuthError("Redirect URI must be a valid URL");
|
|
42400
42370
|
}
|
|
42401
|
-
|
|
42402
|
-
|
|
42403
|
-
|
|
42404
|
-
|
|
42405
|
-
let ngramIndex = 0;
|
|
42406
|
-
function readNgramReferences(count9, startSlot) {
|
|
42407
|
-
for (let index = 0; index < count9; index++) {
|
|
42408
|
-
const slot = startSlot + index;
|
|
42409
|
-
const a = readSlotCode();
|
|
42410
|
-
const b = readSlotCode();
|
|
42411
|
-
references[ngramIndex * 2] = a;
|
|
42412
|
-
references[ngramIndex * 2 + 1] = b;
|
|
42413
|
-
ngramIndex += 1;
|
|
42414
|
-
start[slot] = poolSize;
|
|
42415
|
-
const entryLength = (single[a] < 0 ? length[a] : 1) + (single[b] < 0 ? length[b] : 1);
|
|
42416
|
-
length[slot] = entryLength;
|
|
42417
|
-
poolSize += entryLength;
|
|
42418
|
-
}
|
|
42371
|
+
}
|
|
42372
|
+
function validateCode(code) {
|
|
42373
|
+
if (!code || typeof code !== "string" || code.trim().length === 0) {
|
|
42374
|
+
throw new GoogleAuthError("Authorization code is required and must be a non-empty string");
|
|
42419
42375
|
}
|
|
42420
|
-
|
|
42421
|
-
|
|
42422
|
-
|
|
42423
|
-
|
|
42424
|
-
for (let index = 0; index < ngramIndex; index++) {
|
|
42425
|
-
for (let half = 0; half < 2; half++) {
|
|
42426
|
-
const source = references[index * 2 + half];
|
|
42427
|
-
const value = single[source];
|
|
42428
|
-
if (value < 0) {
|
|
42429
|
-
let read = start[source];
|
|
42430
|
-
const readEnd = read + length[source];
|
|
42431
|
-
while (read < readEnd)
|
|
42432
|
-
pool[write++] = pool[read++];
|
|
42433
|
-
} else {
|
|
42434
|
-
pool[write++] = value;
|
|
42435
|
-
}
|
|
42436
|
-
}
|
|
42376
|
+
}
|
|
42377
|
+
function validateScopes(scopes) {
|
|
42378
|
+
if (!Array.isArray(scopes) || scopes.length === 0) {
|
|
42379
|
+
throw new GoogleAuthError("At least one scope is required");
|
|
42437
42380
|
}
|
|
42438
|
-
const
|
|
42439
|
-
|
|
42440
|
-
|
|
42441
|
-
let slot = BASE91_INVERSE[input.charCodeAt(pos++)];
|
|
42442
|
-
if (slot >= dictSize) {
|
|
42443
|
-
slot = slot * base - twoCharBias + BASE91_INVERSE[input.charCodeAt(pos++)];
|
|
42444
|
-
}
|
|
42445
|
-
const value = single[slot];
|
|
42446
|
-
if (value < 0) {
|
|
42447
|
-
let read = start[slot];
|
|
42448
|
-
const readEnd = read + length[slot];
|
|
42449
|
-
while (read < readEnd)
|
|
42450
|
-
out[outIndex++] = pool[read++];
|
|
42451
|
-
} else {
|
|
42452
|
-
out[outIndex++] = value;
|
|
42381
|
+
for (const scope of scopes) {
|
|
42382
|
+
if (!scope || typeof scope !== "string" || scope.trim().length === 0) {
|
|
42383
|
+
throw new GoogleAuthError("Scope must be a non-empty string");
|
|
42453
42384
|
}
|
|
42454
42385
|
}
|
|
42455
|
-
return out;
|
|
42456
|
-
}
|
|
42457
|
-
|
|
42458
|
-
// ../../node_modules/.pnpm/entities@8.1.0/node_modules/entities/dist/generated/decode-data-html.js
|
|
42459
|
-
var htmlDecodeTree = /* @__PURE__ */ decodeTrieDict("!}.&u%}'&}*'~!6*)%&,~!J~!J~%L~y<~!R,~~%Lu~~#GD~~#|)1#%}^%}2%+#.##%##%}&%##%'#%##&%#%#'%#&#%#&#'#%%#&#%##%#)%''%&%#%#'%#%%#%%}%%%#%#&(23#%%#&-%0%('1#(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, 61);
|
|
42460
|
-
|
|
42461
|
-
// ../../node_modules/.pnpm/entities@8.1.0/node_modules/entities/dist/internal/bin-trie-flags.js
|
|
42462
|
-
var BinTrieFlags;
|
|
42463
|
-
(function(BinTrieFlags2) {
|
|
42464
|
-
BinTrieFlags2[BinTrieFlags2["VALUE_LENGTH"] = 49152] = "VALUE_LENGTH";
|
|
42465
|
-
BinTrieFlags2[BinTrieFlags2["FLAG13"] = 8192] = "FLAG13";
|
|
42466
|
-
BinTrieFlags2[BinTrieFlags2["BRANCH_LENGTH"] = 8064] = "BRANCH_LENGTH";
|
|
42467
|
-
BinTrieFlags2[BinTrieFlags2["JUMP_TABLE"] = 127] = "JUMP_TABLE";
|
|
42468
|
-
BinTrieFlags2[BinTrieFlags2["VALUE_MASK"] = 8191] = "VALUE_MASK";
|
|
42469
|
-
})(BinTrieFlags || (BinTrieFlags = {}));
|
|
42470
|
-
|
|
42471
|
-
// ../../node_modules/.pnpm/entities@8.1.0/node_modules/entities/dist/decode.js
|
|
42472
|
-
var CharCodes;
|
|
42473
|
-
(function(CharCodes2) {
|
|
42474
|
-
CharCodes2[CharCodes2["AMP"] = 38] = "AMP";
|
|
42475
|
-
CharCodes2[CharCodes2["NUM"] = 35] = "NUM";
|
|
42476
|
-
CharCodes2[CharCodes2["SEMI"] = 59] = "SEMI";
|
|
42477
|
-
CharCodes2[CharCodes2["EQUALS"] = 61] = "EQUALS";
|
|
42478
|
-
CharCodes2[CharCodes2["ZERO"] = 48] = "ZERO";
|
|
42479
|
-
CharCodes2[CharCodes2["NINE"] = 57] = "NINE";
|
|
42480
|
-
CharCodes2[CharCodes2["LOWER_A"] = 97] = "LOWER_A";
|
|
42481
|
-
CharCodes2[CharCodes2["LOWER_X"] = 120] = "LOWER_X";
|
|
42482
|
-
})(CharCodes || (CharCodes = {}));
|
|
42483
|
-
var TO_LOWER_BIT = 32;
|
|
42484
|
-
var CONSUMED_SHIFT = 21;
|
|
42485
|
-
var CODE_POINT_MASK = 2097151;
|
|
42486
|
-
var CONSUMED_OVERFLOW = 2047;
|
|
42487
|
-
var longNumericConsumed = 0;
|
|
42488
|
-
function unpackConsumed(packed) {
|
|
42489
|
-
const consumed = packed >>> CONSUMED_SHIFT;
|
|
42490
|
-
return consumed === CONSUMED_OVERFLOW ? longNumericConsumed : consumed;
|
|
42491
|
-
}
|
|
42492
|
-
function isNumber(code) {
|
|
42493
|
-
return code - CharCodes.ZERO >>> 0 <= 9;
|
|
42494
42386
|
}
|
|
42495
|
-
function
|
|
42496
|
-
|
|
42387
|
+
function validateRefreshToken(refreshToken) {
|
|
42388
|
+
if (!refreshToken || typeof refreshToken !== "string" || refreshToken.trim().length === 0) {
|
|
42389
|
+
throw new GoogleAuthError("Refresh token is required and must be a non-empty string");
|
|
42390
|
+
}
|
|
42497
42391
|
}
|
|
42498
|
-
function
|
|
42499
|
-
|
|
42500
|
-
|
|
42501
|
-
|
|
42502
|
-
|
|
42392
|
+
function getAuthUrl(clientId, redirectUri, scopes, state) {
|
|
42393
|
+
validateClientId(clientId);
|
|
42394
|
+
validateRedirectUri(redirectUri);
|
|
42395
|
+
validateScopes(scopes);
|
|
42396
|
+
if (state && (typeof state !== "string" || state.trim().length === 0)) {
|
|
42397
|
+
throw new GoogleAuthError("State must be a non-empty string if provided");
|
|
42398
|
+
}
|
|
42399
|
+
const params = new URLSearchParams({
|
|
42400
|
+
client_id: clientId,
|
|
42401
|
+
redirect_uri: redirectUri,
|
|
42402
|
+
response_type: "code",
|
|
42403
|
+
scope: scopes.join(" "),
|
|
42404
|
+
access_type: "offline",
|
|
42405
|
+
prompt: "consent"
|
|
42406
|
+
});
|
|
42407
|
+
if (state) params.set("state", state);
|
|
42408
|
+
return `${GOOGLE_AUTH_URL}?${params.toString()}`;
|
|
42503
42409
|
}
|
|
42504
|
-
|
|
42505
|
-
(
|
|
42506
|
-
|
|
42507
|
-
|
|
42508
|
-
|
|
42509
|
-
|
|
42510
|
-
|
|
42511
|
-
|
|
42512
|
-
|
|
42513
|
-
|
|
42514
|
-
|
|
42515
|
-
|
|
42516
|
-
|
|
42517
|
-
|
|
42518
|
-
|
|
42519
|
-
|
|
42520
|
-
|
|
42521
|
-
if (
|
|
42522
|
-
|
|
42523
|
-
return char === jumpOffset ? nodeIndex : -1;
|
|
42524
|
-
}
|
|
42525
|
-
const slot = char - jumpOffset;
|
|
42526
|
-
if (slot >>> 0 >= branchCount)
|
|
42527
|
-
return -1;
|
|
42528
|
-
const stored = decodeTree[nodeIndex + slot];
|
|
42529
|
-
return stored === 0 ? -1 : nodeIndex + branchCount + stored - 1 & 65535;
|
|
42410
|
+
async function exchangeCode(clientId, clientSecret, code, redirectUri) {
|
|
42411
|
+
validateClientId(clientId);
|
|
42412
|
+
validateClientSecret(clientSecret);
|
|
42413
|
+
validateCode(code);
|
|
42414
|
+
validateRedirectUri(redirectUri);
|
|
42415
|
+
const res = await fetch(GOOGLE_TOKEN_URL, {
|
|
42416
|
+
method: "POST",
|
|
42417
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
42418
|
+
body: new URLSearchParams({
|
|
42419
|
+
client_id: clientId,
|
|
42420
|
+
client_secret: clientSecret,
|
|
42421
|
+
code,
|
|
42422
|
+
redirect_uri: redirectUri,
|
|
42423
|
+
grant_type: "authorization_code"
|
|
42424
|
+
}),
|
|
42425
|
+
signal: AbortSignal.timeout(GOOGLE_REQUEST_TIMEOUT_MS)
|
|
42426
|
+
});
|
|
42427
|
+
if (res.status === 429) {
|
|
42428
|
+
throw new GoogleAuthError("Google OAuth rate limit exceeded", 429);
|
|
42530
42429
|
}
|
|
42531
|
-
if (
|
|
42532
|
-
|
|
42533
|
-
|
|
42534
|
-
|
|
42535
|
-
|
|
42536
|
-
|
|
42537
|
-
|
|
42538
|
-
|
|
42539
|
-
|
|
42540
|
-
|
|
42430
|
+
if (!res.ok) {
|
|
42431
|
+
const body = await res.text();
|
|
42432
|
+
let detail = "";
|
|
42433
|
+
try {
|
|
42434
|
+
const parsed = JSON.parse(body);
|
|
42435
|
+
if (parsed.error) detail = parsed.error;
|
|
42436
|
+
if (parsed.error_description) {
|
|
42437
|
+
const sanitized = parsed.error_description.replace(new RegExp(escapeRegExp2(clientId), "g"), "***").replace(new RegExp(escapeRegExp2(clientSecret), "g"), "***").replace(new RegExp(escapeRegExp2(code), "g"), "***");
|
|
42438
|
+
detail += detail ? `: ${sanitized}` : sanitized;
|
|
42439
|
+
}
|
|
42440
|
+
} catch {
|
|
42441
|
+
const truncated = body.length <= 120 ? body : `${body.slice(0, 120)}...`;
|
|
42442
|
+
detail = truncated.replace(new RegExp(escapeRegExp2(clientId), "g"), "***").replace(new RegExp(escapeRegExp2(clientSecret), "g"), "***").replace(new RegExp(escapeRegExp2(code), "g"), "***");
|
|
42541
42443
|
}
|
|
42542
|
-
|
|
42543
|
-
return -1;
|
|
42444
|
+
throw new GoogleAuthError(`Token exchange failed (${res.status}): ${detail}`);
|
|
42544
42445
|
}
|
|
42545
|
-
return
|
|
42446
|
+
return await res.json();
|
|
42546
42447
|
}
|
|
42547
|
-
function
|
|
42548
|
-
|
|
42549
|
-
|
|
42448
|
+
function escapeRegExp2(str) {
|
|
42449
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
42450
|
+
}
|
|
42451
|
+
async function refreshAccessToken(clientId, clientSecret, currentRefreshToken) {
|
|
42452
|
+
validateClientId(clientId);
|
|
42453
|
+
validateClientSecret(clientSecret);
|
|
42454
|
+
validateRefreshToken(currentRefreshToken);
|
|
42455
|
+
const res = await fetch(GOOGLE_TOKEN_URL, {
|
|
42456
|
+
method: "POST",
|
|
42457
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
42458
|
+
body: new URLSearchParams({
|
|
42459
|
+
client_id: clientId,
|
|
42460
|
+
client_secret: clientSecret,
|
|
42461
|
+
refresh_token: currentRefreshToken,
|
|
42462
|
+
grant_type: "refresh_token"
|
|
42463
|
+
}),
|
|
42464
|
+
signal: AbortSignal.timeout(GOOGLE_REQUEST_TIMEOUT_MS)
|
|
42465
|
+
});
|
|
42466
|
+
if (res.status === 429) {
|
|
42467
|
+
throw new GoogleAuthError("Google OAuth rate limit exceeded", 429);
|
|
42550
42468
|
}
|
|
42551
|
-
if (
|
|
42552
|
-
|
|
42469
|
+
if (!res.ok) {
|
|
42470
|
+
const body = await res.text();
|
|
42471
|
+
let detail = "";
|
|
42472
|
+
try {
|
|
42473
|
+
const parsed = JSON.parse(body);
|
|
42474
|
+
if (parsed.error) detail = parsed.error;
|
|
42475
|
+
if (parsed.error_description) {
|
|
42476
|
+
const sanitized = parsed.error_description.replace(new RegExp(escapeRegExp2(clientId), "g"), "***").replace(new RegExp(escapeRegExp2(clientSecret), "g"), "***").replace(new RegExp(escapeRegExp2(currentRefreshToken), "g"), "***");
|
|
42477
|
+
detail += detail ? `: ${sanitized}` : sanitized;
|
|
42478
|
+
}
|
|
42479
|
+
} catch {
|
|
42480
|
+
const truncated = body.length <= 120 ? body : `${body.slice(0, 120)}...`;
|
|
42481
|
+
detail = truncated.replace(new RegExp(escapeRegExp2(clientId), "g"), "***").replace(new RegExp(escapeRegExp2(clientSecret), "g"), "***").replace(new RegExp(escapeRegExp2(currentRefreshToken), "g"), "***");
|
|
42482
|
+
}
|
|
42483
|
+
throw new GoogleAuthError(`Token refresh failed (${res.status}): ${detail}`);
|
|
42553
42484
|
}
|
|
42554
|
-
return
|
|
42485
|
+
return await res.json();
|
|
42555
42486
|
}
|
|
42556
|
-
|
|
42557
|
-
|
|
42558
|
-
|
|
42559
|
-
|
|
42560
|
-
|
|
42561
|
-
|
|
42562
|
-
|
|
42563
|
-
|
|
42564
|
-
|
|
42565
|
-
|
|
42566
|
-
|
|
42567
|
-
|
|
42568
|
-
|
|
42569
|
-
|
|
42570
|
-
|
|
42571
|
-
|
|
42572
|
-
|
|
42487
|
+
|
|
42488
|
+
// ../integration-google/src/gsc-client.ts
|
|
42489
|
+
function validateAccessToken(accessToken) {
|
|
42490
|
+
if (!accessToken || typeof accessToken !== "string" || accessToken.trim().length === 0) {
|
|
42491
|
+
throw new GoogleApiError("Access token is required and must be a non-empty string", 400);
|
|
42492
|
+
}
|
|
42493
|
+
}
|
|
42494
|
+
function validateSiteUrl(siteUrl) {
|
|
42495
|
+
if (!siteUrl || typeof siteUrl !== "string" || siteUrl.trim().length === 0) {
|
|
42496
|
+
throw new GoogleApiError("Site URL is required and must be a non-empty string", 400);
|
|
42497
|
+
}
|
|
42498
|
+
if (/^\d+$/.test(siteUrl)) {
|
|
42499
|
+
return;
|
|
42500
|
+
}
|
|
42501
|
+
if (siteUrl.startsWith("sc-domain:")) {
|
|
42502
|
+
const domain = siteUrl.slice("sc-domain:".length);
|
|
42503
|
+
if (!domain) {
|
|
42504
|
+
throw new GoogleApiError("Site URL sc-domain must include a domain", 400);
|
|
42505
|
+
}
|
|
42506
|
+
if (!domain.includes(".")) {
|
|
42507
|
+
throw new GoogleApiError("Site URL sc-domain must be a valid domain", 400);
|
|
42573
42508
|
}
|
|
42574
42509
|
} else {
|
|
42575
|
-
|
|
42576
|
-
const
|
|
42577
|
-
if (
|
|
42578
|
-
|
|
42579
|
-
|
|
42580
|
-
|
|
42510
|
+
try {
|
|
42511
|
+
const url = new URL(siteUrl);
|
|
42512
|
+
if (!url.protocol.startsWith("http")) {
|
|
42513
|
+
throw new GoogleApiError("Site URL must be an HTTP or HTTPS URL", 400);
|
|
42514
|
+
}
|
|
42515
|
+
} catch {
|
|
42516
|
+
throw new GoogleApiError("Site URL must be a valid URL", 400);
|
|
42581
42517
|
}
|
|
42582
42518
|
}
|
|
42583
|
-
|
|
42584
|
-
|
|
42585
|
-
if (
|
|
42586
|
-
|
|
42519
|
+
}
|
|
42520
|
+
function validateUrl(urlParam) {
|
|
42521
|
+
if (!urlParam || typeof urlParam !== "string" || urlParam.trim().length === 0) {
|
|
42522
|
+
throw new GoogleApiError("URL is required and must be a non-empty string", 400);
|
|
42587
42523
|
}
|
|
42588
|
-
|
|
42589
|
-
|
|
42590
|
-
|
|
42591
|
-
|
|
42592
|
-
|
|
42593
|
-
|
|
42524
|
+
try {
|
|
42525
|
+
const url = new URL(urlParam);
|
|
42526
|
+
if (!url.protocol.startsWith("http")) {
|
|
42527
|
+
throw new GoogleApiError("URL must be an HTTP or HTTPS URL", 400);
|
|
42528
|
+
}
|
|
42529
|
+
} catch {
|
|
42530
|
+
throw new GoogleApiError("URL must be a valid URL", 400);
|
|
42594
42531
|
}
|
|
42595
|
-
return consumed << CONSUMED_SHIFT | cp;
|
|
42596
42532
|
}
|
|
42597
|
-
function
|
|
42598
|
-
|
|
42599
|
-
|
|
42600
|
-
|
|
42601
|
-
|
|
42602
|
-
|
|
42603
|
-
|
|
42604
|
-
|
|
42605
|
-
|
|
42606
|
-
|
|
42607
|
-
|
|
42608
|
-
|
|
42609
|
-
|
|
42610
|
-
|
|
42611
|
-
|
|
42612
|
-
|
|
42613
|
-
|
|
42614
|
-
|
|
42615
|
-
|
|
42616
|
-
|
|
42617
|
-
|
|
42618
|
-
|
|
42619
|
-
|
|
42620
|
-
|
|
42621
|
-
|
|
42622
|
-
|
|
42623
|
-
|
|
42624
|
-
|
|
42625
|
-
if (rootSlotIndex >>> 0 < rootBranchCount) {
|
|
42626
|
-
const stored = decodeTree[1 + rootSlotIndex];
|
|
42627
|
-
nodeIndex = stored === 0 ? -1 : rootBranchCount + stored & 65535;
|
|
42628
|
-
} else {
|
|
42629
|
-
nodeIndex = -1;
|
|
42630
|
-
}
|
|
42631
|
-
let bestNodeIndex = 0;
|
|
42632
|
-
let bestValueLength = 0;
|
|
42633
|
-
let current = nodeIndex < 0 ? 0 : decodeTree[nodeIndex];
|
|
42634
|
-
let index = entityStart + 1;
|
|
42635
|
-
trie: while (index < inputLength) {
|
|
42636
|
-
while (
|
|
42637
|
-
// Value-less, non-run node with a nonzero jump offset.
|
|
42638
|
-
(current & (BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13)) === 0 && (current & BinTrieFlags.JUMP_TABLE) !== 0
|
|
42639
|
-
) {
|
|
42640
|
-
const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
|
|
42641
|
-
const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
|
|
42642
|
-
if (branchCount === 0) {
|
|
42643
|
-
if (input.charCodeAt(index) !== jumpOffset)
|
|
42644
|
-
break trie;
|
|
42645
|
-
nodeIndex += 1;
|
|
42646
|
-
} else {
|
|
42647
|
-
const slot = input.charCodeAt(index) - jumpOffset;
|
|
42648
|
-
if (slot >>> 0 >= branchCount)
|
|
42649
|
-
break trie;
|
|
42650
|
-
const stored = decodeTree[nodeIndex + 1 + slot];
|
|
42651
|
-
if (stored === 0)
|
|
42652
|
-
break trie;
|
|
42653
|
-
nodeIndex = nodeIndex + branchCount + stored & 65535;
|
|
42654
|
-
}
|
|
42655
|
-
current = decodeTree[nodeIndex];
|
|
42656
|
-
index += 1;
|
|
42657
|
-
if (index >= inputLength)
|
|
42658
|
-
break trie;
|
|
42659
|
-
}
|
|
42660
|
-
if ((current & (BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13)) === BinTrieFlags.FLAG13) {
|
|
42661
|
-
const runLength = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
|
|
42662
|
-
if (input.charCodeAt(index) !== (current & BinTrieFlags.JUMP_TABLE)) {
|
|
42663
|
-
break;
|
|
42664
|
-
}
|
|
42665
|
-
index += 1;
|
|
42666
|
-
const remaining = runLength - 1;
|
|
42667
|
-
let wordIndex = nodeIndex + 1;
|
|
42668
|
-
let charIndexInPacked = 0;
|
|
42669
|
-
for (; charIndexInPacked + 1 < remaining; charIndexInPacked += 2) {
|
|
42670
|
-
const packed = decodeTree[wordIndex];
|
|
42671
|
-
if (input.charCodeAt(index) !== (packed & 255))
|
|
42672
|
-
break trie;
|
|
42673
|
-
index += 1;
|
|
42674
|
-
if (input.charCodeAt(index) !== (packed >> 8 & 255))
|
|
42675
|
-
break trie;
|
|
42676
|
-
index += 1;
|
|
42677
|
-
wordIndex += 1;
|
|
42678
|
-
}
|
|
42679
|
-
if (charIndexInPacked < remaining) {
|
|
42680
|
-
if (input.charCodeAt(index) !== (decodeTree[wordIndex] & 255))
|
|
42681
|
-
break;
|
|
42682
|
-
index += 1;
|
|
42683
|
-
}
|
|
42684
|
-
nodeIndex += 1 + (runLength >> 1);
|
|
42685
|
-
current = decodeTree[nodeIndex];
|
|
42686
|
-
continue;
|
|
42687
|
-
}
|
|
42688
|
-
const valueLength = current >>> 14;
|
|
42689
|
-
const char = input.charCodeAt(index);
|
|
42690
|
-
if (valueLength !== 0) {
|
|
42691
|
-
if (char === CharCodes.SEMI) {
|
|
42692
|
-
consumed = index - entityStart + 1;
|
|
42693
|
-
value = valueLength === 1 ? String.fromCharCode(current & BinTrieFlags.VALUE_MASK) : readTrieValue(decodeTree, nodeIndex, valueLength);
|
|
42694
|
-
break;
|
|
42695
|
-
}
|
|
42696
|
-
if (!isStrict && (current & BinTrieFlags.FLAG13) === 0) {
|
|
42697
|
-
consumed = index - entityStart;
|
|
42698
|
-
bestNodeIndex = nodeIndex;
|
|
42699
|
-
bestValueLength = valueLength;
|
|
42533
|
+
function validateDate(date, label) {
|
|
42534
|
+
if (!date || typeof date !== "string" || date.trim().length === 0) {
|
|
42535
|
+
throw new GoogleApiError(`${label} is required and must be a non-empty string`, 400);
|
|
42536
|
+
}
|
|
42537
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) {
|
|
42538
|
+
throw new GoogleApiError(`${label} must be in YYYY-MM-DD format, got "${date}"`, 400);
|
|
42539
|
+
}
|
|
42540
|
+
const parsed = /* @__PURE__ */ new Date(`${date}T00:00:00Z`);
|
|
42541
|
+
if (Number.isNaN(parsed.getTime())) {
|
|
42542
|
+
throw new GoogleApiError(`${label} is not a valid date, got "${date}"`, 400);
|
|
42543
|
+
}
|
|
42544
|
+
}
|
|
42545
|
+
function gscClientLog(level, action, ctx) {
|
|
42546
|
+
const entry = {
|
|
42547
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
42548
|
+
level,
|
|
42549
|
+
module: "GscClient",
|
|
42550
|
+
action,
|
|
42551
|
+
...ctx
|
|
42552
|
+
};
|
|
42553
|
+
if (entry.accessToken) entry.accessToken = "***";
|
|
42554
|
+
if (typeof entry.siteUrl === "string") {
|
|
42555
|
+
try {
|
|
42556
|
+
const url = new URL(entry.siteUrl);
|
|
42557
|
+
if (url.search) {
|
|
42558
|
+
url.searchParams.forEach((_, key) => {
|
|
42559
|
+
if (key.toLowerCase().includes("token") || key.toLowerCase().includes("key") || key.toLowerCase().includes("auth")) {
|
|
42560
|
+
url.searchParams.set(key, "***");
|
|
42700
42561
|
}
|
|
42701
|
-
|
|
42702
|
-
|
|
42703
|
-
}
|
|
42704
|
-
const next = determineBranch(decodeTree, current, nodeIndex + (valueLength || 1), char);
|
|
42705
|
-
if (next < 0)
|
|
42706
|
-
break;
|
|
42707
|
-
nodeIndex = next;
|
|
42708
|
-
current = decodeTree[nodeIndex];
|
|
42709
|
-
index += 1;
|
|
42710
|
-
}
|
|
42711
|
-
if (value === "") {
|
|
42712
|
-
const finalVL = current >>> 14;
|
|
42713
|
-
if (finalVL !== 0 && !isStrict && (current & BinTrieFlags.FLAG13) === 0) {
|
|
42714
|
-
consumed = index - entityStart;
|
|
42715
|
-
bestNodeIndex = nodeIndex;
|
|
42716
|
-
bestValueLength = finalVL;
|
|
42717
|
-
}
|
|
42718
|
-
if (consumed > 0) {
|
|
42719
|
-
value = readTrieValue(decodeTree, bestNodeIndex, bestValueLength);
|
|
42720
|
-
}
|
|
42721
|
-
}
|
|
42722
|
-
} else {
|
|
42723
|
-
consumed = 0;
|
|
42724
|
-
value = "";
|
|
42725
|
-
}
|
|
42726
|
-
if (consumed === 0 || isAttribute && firstChar !== CharCodes.NUM && input.charCodeAt(entityStart + consumed - 1) !== CharCodes.SEMI && entityStart + consumed < inputLength && isEntityInAttributeInvalidEnd(input.charCodeAt(entityStart + consumed))) {
|
|
42727
|
-
offset = entityStart;
|
|
42728
|
-
} else {
|
|
42729
|
-
if (chunkStart < offset) {
|
|
42730
|
-
result += input.slice(chunkStart, offset);
|
|
42562
|
+
});
|
|
42563
|
+
entry.siteUrl = url.toString();
|
|
42731
42564
|
}
|
|
42732
|
-
|
|
42733
|
-
offset = chunkStart = entityStart + consumed;
|
|
42734
|
-
}
|
|
42735
|
-
if (input.charCodeAt(offset) !== CharCodes.AMP) {
|
|
42736
|
-
offset = input.indexOf("&", offset);
|
|
42565
|
+
} catch {
|
|
42737
42566
|
}
|
|
42738
|
-
}
|
|
42739
|
-
|
|
42567
|
+
}
|
|
42568
|
+
const stream = level === "error" ? process.stderr : process.stdout;
|
|
42569
|
+
stream.write(JSON.stringify(entry) + "\n");
|
|
42740
42570
|
}
|
|
42741
|
-
function
|
|
42742
|
-
return
|
|
42571
|
+
function escapeRegExp3(str) {
|
|
42572
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
42743
42573
|
}
|
|
42744
|
-
|
|
42745
|
-
|
|
42746
|
-
|
|
42747
|
-
|
|
42748
|
-
|
|
42749
|
-
|
|
42750
|
-
|
|
42751
|
-
|
|
42752
|
-
(
|
|
42753
|
-
|
|
42754
|
-
|
|
42755
|
-
|
|
42756
|
-
|
|
42757
|
-
|
|
42758
|
-
}
|
|
42759
|
-
|
|
42760
|
-
// ../api-routes/src/guarded-fetch.ts
|
|
42761
|
-
import { Agent, fetch as undiciFetch } from "undici";
|
|
42762
|
-
var GUARDED_FETCH_MAX_REDIRECTS = 5;
|
|
42763
|
-
var MAX_POOLED_AGENTS = 16;
|
|
42764
|
-
var EgressRefusedError = class extends Error {
|
|
42765
|
-
/**
|
|
42766
|
-
* True when the refused target is a redirect the site chose rather than the
|
|
42767
|
-
* URL the caller asked for. Refusing the caller's URL is a verdict on the
|
|
42768
|
-
* caller's input; refusing a redirect is the site's failure.
|
|
42769
|
-
*/
|
|
42770
|
-
redirected;
|
|
42771
|
-
constructor(message, redirected) {
|
|
42772
|
-
super(message);
|
|
42773
|
-
this.name = "EgressRefusedError";
|
|
42774
|
-
this.redirected = redirected;
|
|
42574
|
+
async function gscFetchResponse(accessToken, url, opts) {
|
|
42575
|
+
const method = opts?.method ?? "GET";
|
|
42576
|
+
const headers = {
|
|
42577
|
+
Authorization: `Bearer ${accessToken}`,
|
|
42578
|
+
"Content-Type": "application/json"
|
|
42579
|
+
};
|
|
42580
|
+
let res;
|
|
42581
|
+
try {
|
|
42582
|
+
res = await fetch(url, {
|
|
42583
|
+
method,
|
|
42584
|
+
headers,
|
|
42585
|
+
body: opts?.body != null ? JSON.stringify(opts.body) : void 0,
|
|
42586
|
+
signal: AbortSignal.timeout(GOOGLE_REQUEST_TIMEOUT_MS)
|
|
42587
|
+
});
|
|
42588
|
+
} catch (error) {
|
|
42589
|
+
throw new Error(describeFetchError(error, url), { cause: error });
|
|
42775
42590
|
}
|
|
42776
|
-
|
|
42777
|
-
|
|
42778
|
-
|
|
42779
|
-
super(message);
|
|
42780
|
-
this.name = "EgressFailedError";
|
|
42591
|
+
if (res.status === 401) {
|
|
42592
|
+
gscClientLog("error", "http.auth-expired", { url, method, httpStatus: 401 });
|
|
42593
|
+
throw new GoogleApiError("Access token expired or revoked", 401);
|
|
42781
42594
|
}
|
|
42782
|
-
|
|
42783
|
-
|
|
42784
|
-
|
|
42785
|
-
|
|
42786
|
-
|
|
42787
|
-
|
|
42788
|
-
|
|
42789
|
-
const
|
|
42790
|
-
|
|
42791
|
-
|
|
42792
|
-
|
|
42793
|
-
agents.set(key, agent);
|
|
42794
|
-
if (agents.size > MAX_POOLED_AGENTS) {
|
|
42795
|
-
const [oldestKey, oldest] = agents.entries().next().value;
|
|
42796
|
-
agents.delete(oldestKey);
|
|
42797
|
-
oldest.close().catch(() => {
|
|
42798
|
-
});
|
|
42595
|
+
if (res.status === 429) {
|
|
42596
|
+
gscClientLog("error", "http.rate-limited", { url, method, httpStatus: 429 });
|
|
42597
|
+
throw new GoogleApiError("Google API rate limit exceeded", 429);
|
|
42598
|
+
}
|
|
42599
|
+
if (!res.ok) {
|
|
42600
|
+
const body = await res.text();
|
|
42601
|
+
gscClientLog("error", "http.error", { url, method, httpStatus: res.status });
|
|
42602
|
+
const detail = body.length <= 500 ? body : `${body.slice(0, 500)}... [truncated]`;
|
|
42603
|
+
let sanitizedDetail = detail;
|
|
42604
|
+
if (accessToken) {
|
|
42605
|
+
sanitizedDetail = sanitizedDetail.replace(new RegExp(escapeRegExp3(accessToken), "g"), "***");
|
|
42799
42606
|
}
|
|
42800
|
-
|
|
42607
|
+
throw new GoogleApiError(`GSC API error (${res.status}): ${sanitizedDetail}`, res.status);
|
|
42801
42608
|
}
|
|
42802
|
-
return
|
|
42803
|
-
let href = String(input);
|
|
42804
|
-
let method = (init.method ?? "GET").toUpperCase();
|
|
42805
|
-
let body = init.body ?? null;
|
|
42806
|
-
const headers = new Headers(init.headers);
|
|
42807
|
-
const signal = init.signal ?? void 0;
|
|
42808
|
-
let mayRedirectToLoopback = true;
|
|
42809
|
-
for (let redirects = 0; ; redirects += 1) {
|
|
42810
|
-
signal?.throwIfAborted();
|
|
42811
|
-
const check = await untilAborted(resolveTarget(href), signal);
|
|
42812
|
-
if (!check.ok) {
|
|
42813
|
-
const parsed = URL.canParse(href) ? new URL(href) : null;
|
|
42814
|
-
if (check.unresolved) throw new EgressFailedError(`Could not resolve ${parsed?.hostname || href}`);
|
|
42815
|
-
throw new EgressRefusedError(`Refused to connect to ${parsed?.host || href}: ${check.message.replace(/^"url" /, "")}`, redirects > 0);
|
|
42816
|
-
}
|
|
42817
|
-
const url = check.target.url;
|
|
42818
|
-
const onLoopback = checkedAddresses(check.target).map(({ address }) => isLoopbackAddress(address));
|
|
42819
|
-
if (!mayRedirectToLoopback && onLoopback.includes(true)) {
|
|
42820
|
-
throw new EgressRefusedError(`Refused to connect to ${url.host}: a redirect from a site that is not on loopback must not lead to loopback`, true);
|
|
42821
|
-
}
|
|
42822
|
-
mayRedirectToLoopback = !onLoopback.includes(false);
|
|
42823
|
-
const response = await requestPinned(check.target, agentFor(check.target), { method, headers, body, signal });
|
|
42824
|
-
const location = isLocationRedirectStatus(response.status) ? response.headers.get("location") : null;
|
|
42825
|
-
if (location === null) return response;
|
|
42826
|
-
await response.body?.cancel();
|
|
42827
|
-
if (redirects >= GUARDED_FETCH_MAX_REDIRECTS) {
|
|
42828
|
-
throw new EgressFailedError(`${url.host} redirected more than ${GUARDED_FETCH_MAX_REDIRECTS} times`);
|
|
42829
|
-
}
|
|
42830
|
-
let next;
|
|
42831
|
-
try {
|
|
42832
|
-
next = new URL(location, url);
|
|
42833
|
-
} catch {
|
|
42834
|
-
throw new EgressFailedError(`${url.host} redirected to an invalid Location`);
|
|
42835
|
-
}
|
|
42836
|
-
const status = response.status;
|
|
42837
|
-
if (status === 303 && method !== "GET" && method !== "HEAD" || (status === 301 || status === 302) && method === "POST") {
|
|
42838
|
-
method = "GET";
|
|
42839
|
-
body = null;
|
|
42840
|
-
for (const name of BODY_HEADERS) headers.delete(name);
|
|
42841
|
-
}
|
|
42842
|
-
if (next.origin !== url.origin) {
|
|
42843
|
-
for (const name of CROSS_ORIGIN_DROPPED_HEADERS) headers.delete(name);
|
|
42844
|
-
}
|
|
42845
|
-
href = next.href;
|
|
42846
|
-
}
|
|
42847
|
-
};
|
|
42609
|
+
return res;
|
|
42848
42610
|
}
|
|
42849
|
-
async function
|
|
42850
|
-
|
|
42851
|
-
|
|
42611
|
+
async function gscFetchJson(accessToken, url, opts) {
|
|
42612
|
+
const res = await gscFetchResponse(accessToken, url, opts);
|
|
42613
|
+
const text = await res.text();
|
|
42614
|
+
if (!text) {
|
|
42615
|
+
throw new GoogleApiError("GSC API returned an empty response where JSON was expected", res.status);
|
|
42616
|
+
}
|
|
42852
42617
|
try {
|
|
42853
|
-
return
|
|
42854
|
-
|
|
42855
|
-
|
|
42856
|
-
onAbort = () => reject(signal.reason instanceof Error ? signal.reason : new DOMException("This operation was aborted", "AbortError"));
|
|
42857
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
42858
|
-
})
|
|
42859
|
-
]);
|
|
42860
|
-
} finally {
|
|
42861
|
-
if (onAbort) signal.removeEventListener("abort", onAbort);
|
|
42618
|
+
return JSON.parse(text);
|
|
42619
|
+
} catch {
|
|
42620
|
+
throw new GoogleApiError("GSC API returned invalid JSON", res.status);
|
|
42862
42621
|
}
|
|
42863
42622
|
}
|
|
42864
|
-
async function
|
|
42865
|
-
|
|
42866
|
-
|
|
42867
|
-
|
|
42868
|
-
|
|
42869
|
-
|
|
42870
|
-
|
|
42871
|
-
dispatcher
|
|
42872
|
-
});
|
|
42873
|
-
return response;
|
|
42623
|
+
async function listSites(accessToken) {
|
|
42624
|
+
validateAccessToken(accessToken);
|
|
42625
|
+
const data = await gscFetchJson(
|
|
42626
|
+
accessToken,
|
|
42627
|
+
`${GSC_API_BASE}/sites`
|
|
42628
|
+
);
|
|
42629
|
+
return data.siteEntry ?? [];
|
|
42874
42630
|
}
|
|
42875
|
-
function
|
|
42876
|
-
|
|
42877
|
-
|
|
42878
|
-
|
|
42879
|
-
|
|
42880
|
-
|
|
42881
|
-
|
|
42882
|
-
|
|
42883
|
-
|
|
42631
|
+
async function listSitemaps(accessToken, siteUrl, sitemapIndex) {
|
|
42632
|
+
validateAccessToken(accessToken);
|
|
42633
|
+
validateSiteUrl(siteUrl);
|
|
42634
|
+
if (sitemapIndex != null) validateUrl(sitemapIndex);
|
|
42635
|
+
const encodedSiteUrl = encodeURIComponent(siteUrl);
|
|
42636
|
+
const sitemapIndexQuery = sitemapIndex == null ? "" : `?sitemapIndex=${encodeURIComponent(sitemapIndex)}`;
|
|
42637
|
+
const data = await gscFetchJson(
|
|
42638
|
+
accessToken,
|
|
42639
|
+
`${GSC_API_BASE}/sites/${encodedSiteUrl}/sitemaps${sitemapIndexQuery}`
|
|
42640
|
+
);
|
|
42641
|
+
return data.sitemap ?? [];
|
|
42884
42642
|
}
|
|
42885
|
-
|
|
42886
|
-
|
|
42887
|
-
|
|
42888
|
-
|
|
42889
|
-
|
|
42890
|
-
|
|
42643
|
+
async function submitSitemap(accessToken, siteUrl, sitemapUrl) {
|
|
42644
|
+
validateAccessToken(accessToken);
|
|
42645
|
+
validateSiteUrl(siteUrl);
|
|
42646
|
+
validateUrl(sitemapUrl);
|
|
42647
|
+
await gscFetchResponse(
|
|
42648
|
+
accessToken,
|
|
42649
|
+
`${GSC_API_BASE}/sites/${encodeURIComponent(siteUrl)}/sitemaps/${encodeURIComponent(sitemapUrl)}`,
|
|
42650
|
+
{ method: "PUT" }
|
|
42891
42651
|
);
|
|
42892
42652
|
}
|
|
42893
|
-
|
|
42894
|
-
|
|
42895
|
-
|
|
42896
|
-
|
|
42897
|
-
|
|
42898
|
-
|
|
42899
|
-
|
|
42653
|
+
async function fetchSearchAnalytics(accessToken, siteUrl, opts) {
|
|
42654
|
+
validateAccessToken(accessToken);
|
|
42655
|
+
validateSiteUrl(siteUrl);
|
|
42656
|
+
validateDate(opts.startDate, "startDate");
|
|
42657
|
+
validateDate(opts.endDate, "endDate");
|
|
42658
|
+
const allRows = [];
|
|
42659
|
+
let startRow = 0;
|
|
42660
|
+
const dimensions = opts.dimensions ?? ["query", "page", "country", "device", "date"];
|
|
42661
|
+
for (; ; ) {
|
|
42662
|
+
if (startRow >= GSC_MAX_ROWS_PER_REQUEST * GSC_MAX_PAGES) {
|
|
42663
|
+
gscClientLog("error", "pagination.safety-limit", { siteUrl, startRow, maxRows: GSC_MAX_ROWS_PER_REQUEST * GSC_MAX_PAGES });
|
|
42664
|
+
break;
|
|
42900
42665
|
}
|
|
42901
|
-
|
|
42902
|
-
|
|
42903
|
-
|
|
42904
|
-
|
|
42905
|
-
|
|
42906
|
-
|
|
42907
|
-
|
|
42908
|
-
if (
|
|
42909
|
-
|
|
42910
|
-
|
|
42911
|
-
(
|
|
42912
|
-
|
|
42913
|
-
|
|
42914
|
-
|
|
42915
|
-
let visited = 0;
|
|
42916
|
-
while (pending.length > 0) {
|
|
42917
|
-
const { value, depth } = pending.pop();
|
|
42918
|
-
if (depth > 32 || ++visited > 1e4) return null;
|
|
42919
|
-
if (value === null || typeof value !== "object") continue;
|
|
42920
|
-
if (Array.isArray(value)) {
|
|
42921
|
-
pending.push(
|
|
42922
|
-
...value.map((item2) => ({ value: item2, depth: depth + 1 }))
|
|
42923
|
-
);
|
|
42924
|
-
continue;
|
|
42925
|
-
}
|
|
42926
|
-
const row = value;
|
|
42927
|
-
if (depth === 0 || Object.hasOwn(row, "@context")) {
|
|
42928
|
-
const context = row["@context"];
|
|
42929
|
-
if (typeof context !== "string" || !SCHEMA_CONTEXT.test(context))
|
|
42930
|
-
return null;
|
|
42931
|
-
}
|
|
42932
|
-
pending.push(
|
|
42933
|
-
...Object.values(row).map((item2) => ({
|
|
42934
|
-
value: item2,
|
|
42935
|
-
depth: depth + 1
|
|
42936
|
-
}))
|
|
42937
|
-
);
|
|
42666
|
+
const requestBody = {
|
|
42667
|
+
startDate: opts.startDate,
|
|
42668
|
+
endDate: opts.endDate,
|
|
42669
|
+
dimensions,
|
|
42670
|
+
rowLimit: GSC_MAX_ROWS_PER_REQUEST,
|
|
42671
|
+
startRow
|
|
42672
|
+
};
|
|
42673
|
+
if (opts.query || opts.page) {
|
|
42674
|
+
const filters = [];
|
|
42675
|
+
const filterList = [];
|
|
42676
|
+
if (opts.query) filterList.push({ dimension: "query", operator: "contains", expression: opts.query });
|
|
42677
|
+
if (opts.page) filterList.push({ dimension: "page", operator: "contains", expression: opts.page });
|
|
42678
|
+
filters.push({ filters: filterList });
|
|
42679
|
+
requestBody.dimensionFilterGroups = filters;
|
|
42938
42680
|
}
|
|
42939
|
-
const
|
|
42940
|
-
|
|
42941
|
-
|
|
42942
|
-
|
|
42943
|
-
|
|
42681
|
+
const encodedSiteUrl = encodeURIComponent(siteUrl);
|
|
42682
|
+
const data = await gscFetchJson(
|
|
42683
|
+
accessToken,
|
|
42684
|
+
`${GSC_API_BASE}/sites/${encodedSiteUrl}/searchAnalytics/query`,
|
|
42685
|
+
{ method: "POST", body: requestBody }
|
|
42944
42686
|
);
|
|
42945
|
-
|
|
42946
|
-
|
|
42947
|
-
)
|
|
42948
|
-
|
|
42949
|
-
if (/discount|coupon|promo|specialrate|saleprice|strikethroughprice/u.test(
|
|
42950
|
-
key
|
|
42951
|
-
))
|
|
42952
|
-
return null;
|
|
42953
|
-
}
|
|
42954
|
-
for (const match of canonical.matchAll(JSON_STRING)) {
|
|
42955
|
-
if (/^(?:https?:\/\/schema\.org\/)?(?:SalePrice|StrikethroughPrice)$/u.test(
|
|
42956
|
-
String(JSON.parse(match[0]))
|
|
42957
|
-
))
|
|
42958
|
-
return null;
|
|
42687
|
+
const rows = data.rows ?? [];
|
|
42688
|
+
allRows.push(...rows);
|
|
42689
|
+
if (rows.length < GSC_MAX_ROWS_PER_REQUEST) {
|
|
42690
|
+
break;
|
|
42959
42691
|
}
|
|
42960
|
-
|
|
42961
|
-
/([,{]\s*"@type"\s*:\s*)("(?:\\.|[^"\\])*"|\[\s*\]|\[\s*"(?:\\.|[^"\\])*"(?:\s*,\s*"(?:\\.|[^"\\])*")*\s*\])/gu,
|
|
42962
|
-
(_whole, prefix, raw) => {
|
|
42963
|
-
const types = JSON.parse(raw);
|
|
42964
|
-
const mask = (type) => typeof type === "string" && SCHEMA_TYPE.test(type) ? "SchemaType" : type;
|
|
42965
|
-
return prefix + JSON.stringify(Array.isArray(types) ? types.map(mask) : mask(types));
|
|
42966
|
-
}
|
|
42967
|
-
).replace(/([,{]\s*)"offers"(\s*:)/gu, '$1"schemaOffers"$2');
|
|
42968
|
-
} catch {
|
|
42969
|
-
return null;
|
|
42692
|
+
startRow += rows.length;
|
|
42970
42693
|
}
|
|
42694
|
+
return allRows;
|
|
42971
42695
|
}
|
|
42972
|
-
function
|
|
42973
|
-
|
|
42974
|
-
|
|
42975
|
-
|
|
42976
|
-
|
|
42977
|
-
|
|
42978
|
-
|
|
42979
|
-
|
|
42980
|
-
|
|
42981
|
-
const normalized = editorialJsonLd(body);
|
|
42982
|
-
if (normalized === null) {
|
|
42983
|
-
valid = false;
|
|
42984
|
-
return whole;
|
|
42985
|
-
}
|
|
42986
|
-
return `<script${attributes}>${normalized}</script>`;
|
|
42696
|
+
async function publishUrlNotification(accessToken, url, type = "URL_UPDATED") {
|
|
42697
|
+
validateAccessToken(accessToken);
|
|
42698
|
+
validateUrl(url);
|
|
42699
|
+
return gscFetchJson(
|
|
42700
|
+
accessToken,
|
|
42701
|
+
`${INDEXING_API_BASE}/urlNotifications:publish`,
|
|
42702
|
+
{
|
|
42703
|
+
method: "POST",
|
|
42704
|
+
body: { url, type }
|
|
42987
42705
|
}
|
|
42988
42706
|
);
|
|
42989
|
-
return valid && hotelEditorialText(text) && hotelEditorialText(decodePercentRuns(text));
|
|
42990
42707
|
}
|
|
42991
|
-
async function
|
|
42992
|
-
|
|
42993
|
-
|
|
42994
|
-
|
|
42995
|
-
|
|
42996
|
-
|
|
42997
|
-
|
|
42998
|
-
|
|
42999
|
-
|
|
43000
|
-
|
|
43001
|
-
|
|
43002
|
-
|
|
43003
|
-
return false;
|
|
43004
|
-
const reader = response.body.getReader();
|
|
43005
|
-
const chunks = [];
|
|
43006
|
-
let size = 0;
|
|
43007
|
-
for (; ; ) {
|
|
43008
|
-
const part = await reader.read();
|
|
43009
|
-
if (part.done) break;
|
|
43010
|
-
size += part.value.byteLength;
|
|
43011
|
-
if (size > 512 * 1024) {
|
|
43012
|
-
await reader.cancel();
|
|
43013
|
-
return false;
|
|
42708
|
+
async function inspectUrl(accessToken, inspectionUrl, siteUrl) {
|
|
42709
|
+
validateAccessToken(accessToken);
|
|
42710
|
+
validateUrl(inspectionUrl);
|
|
42711
|
+
validateSiteUrl(siteUrl);
|
|
42712
|
+
return gscFetchJson(
|
|
42713
|
+
accessToken,
|
|
42714
|
+
URL_INSPECTION_API,
|
|
42715
|
+
{
|
|
42716
|
+
method: "POST",
|
|
42717
|
+
body: {
|
|
42718
|
+
inspectionUrl,
|
|
42719
|
+
siteUrl
|
|
43014
42720
|
}
|
|
43015
|
-
chunks.push(part.value);
|
|
43016
42721
|
}
|
|
43017
|
-
|
|
43018
|
-
Buffer.concat(chunks)
|
|
43019
|
-
);
|
|
43020
|
-
return editorialHtml(html);
|
|
43021
|
-
} catch {
|
|
43022
|
-
return false;
|
|
43023
|
-
}
|
|
42722
|
+
);
|
|
43024
42723
|
}
|
|
43025
42724
|
|
|
43026
|
-
//
|
|
43027
|
-
var
|
|
43028
|
-
|
|
43029
|
-
|
|
43030
|
-
|
|
43031
|
-
|
|
43032
|
-
|
|
43033
|
-
|
|
43034
|
-
|
|
43035
|
-
|
|
42725
|
+
// ../../node_modules/.pnpm/entities@8.1.0/node_modules/entities/dist/decode-codepoint.js
|
|
42726
|
+
var c1 = [
|
|
42727
|
+
8364,
|
|
42728
|
+
0,
|
|
42729
|
+
8218,
|
|
42730
|
+
402,
|
|
42731
|
+
8222,
|
|
42732
|
+
8230,
|
|
42733
|
+
8224,
|
|
42734
|
+
8225,
|
|
42735
|
+
710,
|
|
42736
|
+
8240,
|
|
42737
|
+
352,
|
|
42738
|
+
8249,
|
|
42739
|
+
338,
|
|
42740
|
+
0,
|
|
42741
|
+
381,
|
|
42742
|
+
0,
|
|
42743
|
+
0,
|
|
42744
|
+
8216,
|
|
42745
|
+
8217,
|
|
42746
|
+
8220,
|
|
42747
|
+
8221,
|
|
42748
|
+
8226,
|
|
42749
|
+
8211,
|
|
42750
|
+
8212,
|
|
42751
|
+
732,
|
|
42752
|
+
8482,
|
|
42753
|
+
353,
|
|
42754
|
+
8250,
|
|
42755
|
+
339,
|
|
42756
|
+
0,
|
|
42757
|
+
382,
|
|
42758
|
+
376
|
|
42759
|
+
];
|
|
42760
|
+
function isInvalidCodePoint(codePoint) {
|
|
42761
|
+
return codePoint === 0 || codePoint >= 55296 && codePoint <= 57343 || codePoint > 1114111;
|
|
43036
42762
|
}
|
|
43037
|
-
|
|
43038
|
-
|
|
43039
|
-
|
|
43040
|
-
const l = gbpLocationNameSchema.safeParse(location);
|
|
43041
|
-
if (!a.success || !l.success)
|
|
43042
|
-
throw validationError(
|
|
43043
|
-
"Exact GBP account and location names are required."
|
|
43044
|
-
);
|
|
43045
|
-
const row = app.db.select().from(gbpLocations).where(
|
|
43046
|
-
and51(
|
|
43047
|
-
eq62(gbpLocations.projectId, projectId),
|
|
43048
|
-
eq62(gbpLocations.accountName, a.data),
|
|
43049
|
-
eq62(gbpLocations.locationName, l.data),
|
|
43050
|
-
eq62(gbpLocations.selected, true)
|
|
43051
|
-
)
|
|
43052
|
-
).get();
|
|
43053
|
-
if (!row)
|
|
43054
|
-
throw forbidden(
|
|
43055
|
-
"This account/location is not selected on the requested project."
|
|
43056
|
-
);
|
|
43057
|
-
return row;
|
|
42763
|
+
function replaceCodePoint(codePoint) {
|
|
42764
|
+
if (isInvalidCodePoint(codePoint)) {
|
|
42765
|
+
return 65533;
|
|
43058
42766
|
}
|
|
43059
|
-
|
|
43060
|
-
|
|
43061
|
-
|
|
43062
|
-
|
|
43063
|
-
|
|
43064
|
-
|
|
43065
|
-
|
|
43066
|
-
|
|
43067
|
-
|
|
43068
|
-
|
|
43069
|
-
|
|
43070
|
-
|
|
43071
|
-
|
|
43072
|
-
|
|
43073
|
-
|
|
43074
|
-
|
|
43075
|
-
page3
|
|
43076
|
-
);
|
|
43077
|
-
} catch {
|
|
43078
|
-
throw providerError(
|
|
43079
|
-
"Google Local Posts could not be read; coverage is unknown."
|
|
43080
|
-
);
|
|
42767
|
+
if (codePoint >= 128 && codePoint <= 159) {
|
|
42768
|
+
return c1[codePoint - 128] || codePoint;
|
|
42769
|
+
}
|
|
42770
|
+
return codePoint;
|
|
42771
|
+
}
|
|
42772
|
+
function codePointToString(codePoint) {
|
|
42773
|
+
return codePoint - 1 >>> 0 < 127 || codePoint - 160 >>> 0 < 55136 ? String.fromCharCode(codePoint) : String.fromCodePoint(replaceCodePoint(codePoint));
|
|
42774
|
+
}
|
|
42775
|
+
|
|
42776
|
+
// ../../node_modules/.pnpm/entities@8.1.0/node_modules/entities/dist/internal/decode-shared.js
|
|
42777
|
+
var BASE91_INVERSE = /* @__PURE__ */ (() => {
|
|
42778
|
+
const table = new Uint8Array(127);
|
|
42779
|
+
let code = 0;
|
|
42780
|
+
for (let char = 33; char <= 126; char++) {
|
|
42781
|
+
if (char !== 34 && char !== 36 && char !== 92) {
|
|
42782
|
+
table[char] = code++;
|
|
43081
42783
|
}
|
|
43082
|
-
}
|
|
43083
|
-
|
|
43084
|
-
|
|
43085
|
-
|
|
43086
|
-
|
|
43087
|
-
|
|
43088
|
-
|
|
43089
|
-
|
|
43090
|
-
|
|
43091
|
-
|
|
43092
|
-
|
|
43093
|
-
|
|
43094
|
-
|
|
43095
|
-
|
|
43096
|
-
|
|
43097
|
-
|
|
43098
|
-
|
|
43099
|
-
|
|
43100
|
-
|
|
43101
|
-
|
|
43102
|
-
|
|
43103
|
-
|
|
43104
|
-
|
|
43105
|
-
|
|
42784
|
+
}
|
|
42785
|
+
return table;
|
|
42786
|
+
})();
|
|
42787
|
+
function decodeTrieDict(input, resultLength, atomCount, dict1AtomCount, ngramCount, dictSize) {
|
|
42788
|
+
const base = 91;
|
|
42789
|
+
const inputLength = input.length;
|
|
42790
|
+
const twoCharBias = dictSize * (base - 1);
|
|
42791
|
+
let pos = 0;
|
|
42792
|
+
const readSlotCode = () => {
|
|
42793
|
+
const c12 = BASE91_INVERSE[input.charCodeAt(pos++)];
|
|
42794
|
+
return c12 < dictSize ? c12 : c12 * base - twoCharBias + BASE91_INVERSE[input.charCodeAt(pos++)];
|
|
42795
|
+
};
|
|
42796
|
+
const dict2AtomCount = atomCount - dict1AtomCount;
|
|
42797
|
+
const slotCount = atomCount + ngramCount;
|
|
42798
|
+
const single = new Int32Array(slotCount);
|
|
42799
|
+
single.fill(-1, dict1AtomCount, dictSize);
|
|
42800
|
+
single.fill(-1, dictSize + dict2AtomCount, slotCount);
|
|
42801
|
+
const start = new Int32Array(slotCount);
|
|
42802
|
+
const length = new Int32Array(slotCount);
|
|
42803
|
+
function decodeDelta(count9, off) {
|
|
42804
|
+
let previous = 0;
|
|
42805
|
+
let slot = off;
|
|
42806
|
+
const end = off + count9;
|
|
42807
|
+
while (slot < end) {
|
|
42808
|
+
const code = BASE91_INVERSE[input.charCodeAt(pos++)];
|
|
42809
|
+
if (code < 89) {
|
|
42810
|
+
previous += code;
|
|
42811
|
+
single[slot++] = previous;
|
|
42812
|
+
} else if (code === 89) {
|
|
42813
|
+
let runLength = BASE91_INVERSE[input.charCodeAt(pos++)] + 2;
|
|
42814
|
+
while (runLength--)
|
|
42815
|
+
single[slot++] = ++previous;
|
|
42816
|
+
} else {
|
|
42817
|
+
const next = BASE91_INVERSE[input.charCodeAt(pos++)];
|
|
42818
|
+
previous += 89 + // eslint-disable-next-line unicorn/prefer-minimal-ternary -- branches read a different number of side-effecting input bytes
|
|
42819
|
+
(next < 90 ? next * base + BASE91_INVERSE[input.charCodeAt(pos++)] : BASE91_INVERSE[input.charCodeAt(pos++)] * 8281 + BASE91_INVERSE[input.charCodeAt(pos++)] * base + BASE91_INVERSE[input.charCodeAt(pos++)]);
|
|
42820
|
+
single[slot++] = previous;
|
|
43106
42821
|
}
|
|
43107
42822
|
}
|
|
43108
|
-
|
|
43109
|
-
|
|
43110
|
-
|
|
43111
|
-
|
|
43112
|
-
|
|
43113
|
-
|
|
43114
|
-
|
|
43115
|
-
|
|
43116
|
-
|
|
43117
|
-
|
|
43118
|
-
const
|
|
43119
|
-
|
|
43120
|
-
|
|
43121
|
-
|
|
43122
|
-
|
|
43123
|
-
);
|
|
43124
|
-
|
|
43125
|
-
|
|
43126
|
-
return {
|
|
43127
|
-
accountName: location.accountName,
|
|
43128
|
-
locationName: location.locationName,
|
|
43129
|
-
profileUrl,
|
|
43130
|
-
complete: true,
|
|
43131
|
-
checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
43132
|
-
reviews: listing.reviews.map(
|
|
43133
|
-
({ replyComment: _reply, replyUpdateTime: _time, ...review }) => review
|
|
43134
|
-
)
|
|
43135
|
-
};
|
|
43136
|
-
} catch {
|
|
43137
|
-
throw providerError(
|
|
43138
|
-
"Google reviews could not be read completely; keep the previous baseline."
|
|
43139
|
-
);
|
|
42823
|
+
}
|
|
42824
|
+
decodeDelta(dict1AtomCount, 0);
|
|
42825
|
+
decodeDelta(dict2AtomCount, dictSize);
|
|
42826
|
+
const references = new Int32Array(ngramCount * 2);
|
|
42827
|
+
let poolSize = 0;
|
|
42828
|
+
let ngramIndex = 0;
|
|
42829
|
+
function readNgramReferences(count9, startSlot) {
|
|
42830
|
+
for (let index = 0; index < count9; index++) {
|
|
42831
|
+
const slot = startSlot + index;
|
|
42832
|
+
const a = readSlotCode();
|
|
42833
|
+
const b = readSlotCode();
|
|
42834
|
+
references[ngramIndex * 2] = a;
|
|
42835
|
+
references[ngramIndex * 2 + 1] = b;
|
|
42836
|
+
ngramIndex += 1;
|
|
42837
|
+
start[slot] = poolSize;
|
|
42838
|
+
const entryLength = (single[a] < 0 ? length[a] : 1) + (single[b] < 0 ? length[b] : 1);
|
|
42839
|
+
length[slot] = entryLength;
|
|
42840
|
+
poolSize += entryLength;
|
|
43140
42841
|
}
|
|
43141
|
-
}
|
|
43142
|
-
|
|
43143
|
-
|
|
43144
|
-
|
|
43145
|
-
|
|
43146
|
-
|
|
43147
|
-
|
|
43148
|
-
|
|
43149
|
-
|
|
43150
|
-
)
|
|
43151
|
-
|
|
43152
|
-
|
|
43153
|
-
|
|
43154
|
-
|
|
43155
|
-
|
|
43156
|
-
|
|
43157
|
-
const binding = JSON.parse(claim.diff);
|
|
43158
|
-
if (binding.packageId !== packageId)
|
|
43159
|
-
throw validationError("GBP attempt package mismatch.");
|
|
43160
|
-
const result = app.db.select().from(auditLog).where(eq62(auditLog.id, `${key}:result`)).get();
|
|
43161
|
-
return result?.diff ? gbpLocalPostAttemptSchema.parse(JSON.parse(result.diff)) : { attemptId, packageId, status: "uncertain", post: null };
|
|
43162
|
-
});
|
|
43163
|
-
app.post(
|
|
43164
|
-
"/projects/:name/gbp/local-posts",
|
|
43165
|
-
{ config: { writeScope: GBP_POSTS_WRITE_SCOPE } },
|
|
43166
|
-
async (request) => {
|
|
43167
|
-
requireAdminSession(request);
|
|
43168
|
-
requireScope(request, GBP_POSTS_WRITE_SCOPE);
|
|
43169
|
-
const project = resolveProject(app.db, request.params.name);
|
|
43170
|
-
const parsed = gbpLocalPostCreateSchema.safeParse(request.body);
|
|
43171
|
-
if (!parsed.success)
|
|
43172
|
-
throw validationError(
|
|
43173
|
-
"A bounded STANDARD article post and exact attempt/package binding are required."
|
|
43174
|
-
);
|
|
43175
|
-
const body = parsed.data;
|
|
43176
|
-
selected(project.id, body.accountName, body.locationName);
|
|
43177
|
-
if (!await hotelEditorialDestination(
|
|
43178
|
-
project.canonicalDomain,
|
|
43179
|
-
body.content.summary,
|
|
43180
|
-
body.content.callToAction.url
|
|
43181
|
-
))
|
|
43182
|
-
throw forbidden(
|
|
43183
|
-
"Updates and their linked page must be editorial, without offers, deals or promotions. Unavailable checks do not authorize a post."
|
|
43184
|
-
);
|
|
43185
|
-
const key = `gbp-post:${digest([project.id, body.attemptId])}`;
|
|
43186
|
-
const payload = digest(body);
|
|
43187
|
-
const existing = app.db.select().from(auditLog).where(eq62(auditLog.id, key)).get();
|
|
43188
|
-
const readResult = () => {
|
|
43189
|
-
const result2 = app.db.select().from(auditLog).where(eq62(auditLog.id, `${key}:result`)).get();
|
|
43190
|
-
return result2?.diff ? gbpLocalPostAttemptSchema.parse(JSON.parse(result2.diff)) : {
|
|
43191
|
-
attemptId: body.attemptId,
|
|
43192
|
-
packageId: body.packageId,
|
|
43193
|
-
status: "uncertain",
|
|
43194
|
-
post: null
|
|
43195
|
-
};
|
|
43196
|
-
};
|
|
43197
|
-
const answerExisting = (claimed) => {
|
|
43198
|
-
const binding = JSON.parse(claimed.diff ?? "null");
|
|
43199
|
-
if (claimed.projectId !== project.id || binding?.requestDigest !== payload)
|
|
43200
|
-
throw validationError(
|
|
43201
|
-
"GBP attempt identity was already used with different content."
|
|
43202
|
-
);
|
|
43203
|
-
return readResult();
|
|
43204
|
-
};
|
|
43205
|
-
if (existing) return answerExisting(existing);
|
|
43206
|
-
const token = await options.token(project.canonicalDomain);
|
|
43207
|
-
const currentProject = resolveProject(app.db, request.params.name);
|
|
43208
|
-
if (currentProject.id !== project.id || currentProject.canonicalDomain !== project.canonicalDomain)
|
|
43209
|
-
throw forbidden("GBP project changed during preflight; prepare a new request.");
|
|
43210
|
-
selected(currentProject.id, body.accountName, body.locationName);
|
|
43211
|
-
const claim = claimAuditLog(app.db, key, {
|
|
43212
|
-
projectId: project.id,
|
|
43213
|
-
actor: "api",
|
|
43214
|
-
action: "gbp.local-post-claimed",
|
|
43215
|
-
entityType: "gbp-local-post",
|
|
43216
|
-
entityId: body.attemptId,
|
|
43217
|
-
diff: {
|
|
43218
|
-
requestDigest: payload,
|
|
43219
|
-
packageId: body.packageId,
|
|
43220
|
-
accountName: body.accountName,
|
|
43221
|
-
locationName: body.locationName
|
|
43222
|
-
}
|
|
43223
|
-
});
|
|
43224
|
-
if (!claim) {
|
|
43225
|
-
const winner = app.db.select().from(auditLog).where(eq62(auditLog.id, key)).get();
|
|
43226
|
-
if (!winner) return readResult();
|
|
43227
|
-
return answerExisting(winner);
|
|
43228
|
-
}
|
|
43229
|
-
let post2 = null;
|
|
43230
|
-
let status = "uncertain";
|
|
43231
|
-
try {
|
|
43232
|
-
post2 = await createLocalPost(
|
|
43233
|
-
token,
|
|
43234
|
-
body.accountName,
|
|
43235
|
-
body.locationName,
|
|
43236
|
-
body.content
|
|
43237
|
-
);
|
|
43238
|
-
status = "accepted";
|
|
43239
|
-
} catch (error) {
|
|
43240
|
-
if (error instanceof GbpApiError && [400, 401, 403, 404, 422].includes(error.status))
|
|
43241
|
-
status = "rejected";
|
|
42842
|
+
}
|
|
42843
|
+
readNgramReferences(ngramCount - dictSize + dict1AtomCount, dictSize + dict2AtomCount);
|
|
42844
|
+
readNgramReferences(dictSize - dict1AtomCount, dict1AtomCount);
|
|
42845
|
+
const pool = new Uint16Array(poolSize);
|
|
42846
|
+
let write = 0;
|
|
42847
|
+
for (let index = 0; index < ngramIndex; index++) {
|
|
42848
|
+
for (let half = 0; half < 2; half++) {
|
|
42849
|
+
const source = references[index * 2 + half];
|
|
42850
|
+
const value = single[source];
|
|
42851
|
+
if (value < 0) {
|
|
42852
|
+
let read = start[source];
|
|
42853
|
+
const readEnd = read + length[source];
|
|
42854
|
+
while (read < readEnd)
|
|
42855
|
+
pool[write++] = pool[read++];
|
|
42856
|
+
} else {
|
|
42857
|
+
pool[write++] = value;
|
|
43242
42858
|
}
|
|
43243
|
-
const result = {
|
|
43244
|
-
attemptId: body.attemptId,
|
|
43245
|
-
packageId: body.packageId,
|
|
43246
|
-
status,
|
|
43247
|
-
post: post2
|
|
43248
|
-
};
|
|
43249
|
-
claimAuditLog(app.db, `${key}:result`, {
|
|
43250
|
-
projectId: project.id,
|
|
43251
|
-
actor: "api",
|
|
43252
|
-
action: "gbp.local-post-result",
|
|
43253
|
-
entityType: "gbp-local-post",
|
|
43254
|
-
entityId: body.attemptId,
|
|
43255
|
-
diff: result
|
|
43256
|
-
});
|
|
43257
|
-
return result;
|
|
43258
42859
|
}
|
|
43259
|
-
|
|
42860
|
+
}
|
|
42861
|
+
const out = new Uint16Array(resultLength);
|
|
42862
|
+
let outIndex = 0;
|
|
42863
|
+
while (pos < inputLength) {
|
|
42864
|
+
let slot = BASE91_INVERSE[input.charCodeAt(pos++)];
|
|
42865
|
+
if (slot >= dictSize) {
|
|
42866
|
+
slot = slot * base - twoCharBias + BASE91_INVERSE[input.charCodeAt(pos++)];
|
|
42867
|
+
}
|
|
42868
|
+
const value = single[slot];
|
|
42869
|
+
if (value < 0) {
|
|
42870
|
+
let read = start[slot];
|
|
42871
|
+
const readEnd = read + length[slot];
|
|
42872
|
+
while (read < readEnd)
|
|
42873
|
+
out[outIndex++] = pool[read++];
|
|
42874
|
+
} else {
|
|
42875
|
+
out[outIndex++] = value;
|
|
42876
|
+
}
|
|
42877
|
+
}
|
|
42878
|
+
return out;
|
|
43260
42879
|
}
|
|
43261
42880
|
|
|
43262
|
-
//
|
|
43263
|
-
import { eq as eq64, and as and52, desc as desc29, sql as sql19, inArray as inArray30 } from "drizzle-orm";
|
|
42881
|
+
// ../../node_modules/.pnpm/entities@8.1.0/node_modules/entities/dist/generated/decode-data-html.js
|
|
42882
|
+
var htmlDecodeTree = /* @__PURE__ */ decodeTrieDict("!}.&u%}'&}*'~!6*)%&,~!J~!J~%L~y<~!R,~~%Lu~~#GD~~#|)1#%}^%}2%+#.##%##%}&%##%'#%##&%#%#'%#&#%#&#'#%%#&#%##%#)%''%&%#%#'%#%%#%%}%%%#%#&(23#%%#&-%0%('1#(##%#'##+%'*.:1}#%#6-+(%'%%#%%%}#L'2351&('%}&/N'(0(/*-%(%%}#'+&T%7.2}#&%&#%#36/5##%&%%#&#%%#))2%%##%&&'0~!#*+&'%1~!%).'3q?&%'1~!.##%6(~!+%%%(Gw'rT~!E#<nA%#jZ~!H%(~!42##~!*31&~!G%U~#)5~#`3~!J~!Z~%]~%Y~%C~!q~!u~#kz~%#~!6'~!D~!U~!?~#T~!c%~!G#'~%7|~!G~!J~!G&~#pb~(Df}#%}*&}#%##%##%##&#-}&'#'&%#.++}%mI,#,@&(}*%}*'%&##&#%##%}&0}#.},U},%}+%}&%}#%##&}B%(}(%}+%)})%##%#&}&%##%&}<%}>%#%&}*%}(%}9%}/%})%}*%}*%}?&}&%}3%}&*#%})%#%#)}#&#-#+*%E%%'%'#%}#*V##&##I}#&&##%&%#&&Qf%%))w/0+&%#(#.%-''''++++7}>%4'',##1,#%#&%##&#'##&#*#9)%&%}#*}%,#+P(%A&%#'&##wSD',9E00#y#@}(+}&%&>~!#~!X}#*}(&&}(&}(,%}%&#+&}#&}I%#%}%)#(},'%#*}4%%#%}(''}#/##(##),%-##%%)#&}(.}&%#&}%%}*&#%},&&}&%}#%*'#%})%}D&}&%}-&}6&#&}-,%}#%})-(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Sn~Mkfrmu9p}u7vwv]So!McW#Xa!ax5@A5aY:5;5<H|>kJv~vYrquJu3x4ib#T)2@SmZM?C2F|Bj:rmu9@xPhI(a*a#U#`a3-5Abb|L~@:RhK9:4E|0@52B5G|#C::aY?C2F|-:2<BaY?C2F|.5Jvk!a)javYrquJu3x4ia#T)2@SmYM?C2F|HAxPhH(!a#U#`a*-5Abb|4~@:RhJ9:4E|R@52B5G|F:2<BaY?C2F|Sc^#Xa2j=Qq5CJvB!-g<v{z;hhM?C2F|Zi[vrv{z;hiM?C2F|XKsA>!a)-g<v{z;h[eb?C2F|]i[vrv{z;h]eb?C2F|^iZu.vix,hZq3ah!.(?C2F|QOu!5ShXM:2<BaY?C2F|P", 13494, 2713, 49, 25, 61);
|
|
43264
42883
|
|
|
43265
|
-
//
|
|
43266
|
-
var
|
|
43267
|
-
function
|
|
43268
|
-
|
|
43269
|
-
|
|
43270
|
-
|
|
43271
|
-
|
|
42884
|
+
// ../../node_modules/.pnpm/entities@8.1.0/node_modules/entities/dist/internal/bin-trie-flags.js
|
|
42885
|
+
var BinTrieFlags;
|
|
42886
|
+
(function(BinTrieFlags2) {
|
|
42887
|
+
BinTrieFlags2[BinTrieFlags2["VALUE_LENGTH"] = 49152] = "VALUE_LENGTH";
|
|
42888
|
+
BinTrieFlags2[BinTrieFlags2["FLAG13"] = 8192] = "FLAG13";
|
|
42889
|
+
BinTrieFlags2[BinTrieFlags2["BRANCH_LENGTH"] = 8064] = "BRANCH_LENGTH";
|
|
42890
|
+
BinTrieFlags2[BinTrieFlags2["JUMP_TABLE"] = 127] = "JUMP_TABLE";
|
|
42891
|
+
BinTrieFlags2[BinTrieFlags2["VALUE_MASK"] = 8191] = "VALUE_MASK";
|
|
42892
|
+
})(BinTrieFlags || (BinTrieFlags = {}));
|
|
42893
|
+
|
|
42894
|
+
// ../../node_modules/.pnpm/entities@8.1.0/node_modules/entities/dist/decode.js
|
|
42895
|
+
var CharCodes;
|
|
42896
|
+
(function(CharCodes2) {
|
|
42897
|
+
CharCodes2[CharCodes2["AMP"] = 38] = "AMP";
|
|
42898
|
+
CharCodes2[CharCodes2["NUM"] = 35] = "NUM";
|
|
42899
|
+
CharCodes2[CharCodes2["SEMI"] = 59] = "SEMI";
|
|
42900
|
+
CharCodes2[CharCodes2["EQUALS"] = 61] = "EQUALS";
|
|
42901
|
+
CharCodes2[CharCodes2["ZERO"] = 48] = "ZERO";
|
|
42902
|
+
CharCodes2[CharCodes2["NINE"] = 57] = "NINE";
|
|
42903
|
+
CharCodes2[CharCodes2["LOWER_A"] = 97] = "LOWER_A";
|
|
42904
|
+
CharCodes2[CharCodes2["LOWER_X"] = 120] = "LOWER_X";
|
|
42905
|
+
})(CharCodes || (CharCodes = {}));
|
|
42906
|
+
var TO_LOWER_BIT = 32;
|
|
42907
|
+
var CONSUMED_SHIFT = 21;
|
|
42908
|
+
var CODE_POINT_MASK = 2097151;
|
|
42909
|
+
var CONSUMED_OVERFLOW = 2047;
|
|
42910
|
+
var longNumericConsumed = 0;
|
|
42911
|
+
function unpackConsumed(packed) {
|
|
42912
|
+
const consumed = packed >>> CONSUMED_SHIFT;
|
|
42913
|
+
return consumed === CONSUMED_OVERFLOW ? longNumericConsumed : consumed;
|
|
43272
42914
|
}
|
|
43273
|
-
function
|
|
43274
|
-
return
|
|
42915
|
+
function isNumber(code) {
|
|
42916
|
+
return code - CharCodes.ZERO >>> 0 <= 9;
|
|
43275
42917
|
}
|
|
43276
|
-
function
|
|
43277
|
-
|
|
43278
|
-
if (!Number.isFinite(trailing) || !Number.isFinite(prior)) return null;
|
|
43279
|
-
if (prior <= 0) return null;
|
|
43280
|
-
return (trailing - prior) / prior;
|
|
42918
|
+
function isHexadecimalCharacter(code) {
|
|
42919
|
+
return (code | TO_LOWER_BIT) - CharCodes.LOWER_A >>> 0 <= 5;
|
|
43281
42920
|
}
|
|
43282
|
-
function
|
|
43283
|
-
|
|
43284
|
-
|
|
43285
|
-
|
|
43286
|
-
|
|
43287
|
-
|
|
43288
|
-
|
|
43289
|
-
|
|
43290
|
-
|
|
43291
|
-
|
|
43292
|
-
|
|
43293
|
-
|
|
43294
|
-
|
|
43295
|
-
|
|
43296
|
-
|
|
43297
|
-
|
|
42921
|
+
function isAlpha(code) {
|
|
42922
|
+
return (code | TO_LOWER_BIT) - CharCodes.LOWER_A >>> 0 <= 25;
|
|
42923
|
+
}
|
|
42924
|
+
function isEntityInAttributeInvalidEnd(code) {
|
|
42925
|
+
return code === CharCodes.EQUALS || isAlpha(code) || isNumber(code);
|
|
42926
|
+
}
|
|
42927
|
+
var EntityDecoderState;
|
|
42928
|
+
(function(EntityDecoderState2) {
|
|
42929
|
+
EntityDecoderState2[EntityDecoderState2["EntityStart"] = 0] = "EntityStart";
|
|
42930
|
+
EntityDecoderState2[EntityDecoderState2["NumericStart"] = 1] = "NumericStart";
|
|
42931
|
+
EntityDecoderState2[EntityDecoderState2["NumericDecimal"] = 2] = "NumericDecimal";
|
|
42932
|
+
EntityDecoderState2[EntityDecoderState2["NumericHex"] = 3] = "NumericHex";
|
|
42933
|
+
EntityDecoderState2[EntityDecoderState2["NamedEntity"] = 4] = "NamedEntity";
|
|
42934
|
+
})(EntityDecoderState || (EntityDecoderState = {}));
|
|
42935
|
+
var DecodingMode;
|
|
42936
|
+
(function(DecodingMode2) {
|
|
42937
|
+
DecodingMode2[DecodingMode2["Legacy"] = 0] = "Legacy";
|
|
42938
|
+
DecodingMode2[DecodingMode2["Strict"] = 1] = "Strict";
|
|
42939
|
+
DecodingMode2[DecodingMode2["Attribute"] = 2] = "Attribute";
|
|
42940
|
+
})(DecodingMode || (DecodingMode = {}));
|
|
42941
|
+
function determineBranch(decodeTree, current, nodeIndex, char) {
|
|
42942
|
+
const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
|
|
42943
|
+
const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
|
|
42944
|
+
if (jumpOffset) {
|
|
42945
|
+
if (branchCount === 0) {
|
|
42946
|
+
return char === jumpOffset ? nodeIndex : -1;
|
|
43298
42947
|
}
|
|
42948
|
+
const slot = char - jumpOffset;
|
|
42949
|
+
if (slot >>> 0 >= branchCount)
|
|
42950
|
+
return -1;
|
|
42951
|
+
const stored = decodeTree[nodeIndex + slot];
|
|
42952
|
+
return stored === 0 ? -1 : nodeIndex + branchCount + stored - 1 & 65535;
|
|
43299
42953
|
}
|
|
43300
|
-
|
|
43301
|
-
|
|
43302
|
-
|
|
43303
|
-
|
|
43304
|
-
|
|
43305
|
-
|
|
43306
|
-
|
|
43307
|
-
|
|
43308
|
-
|
|
43309
|
-
|
|
43310
|
-
|
|
43311
|
-
|
|
43312
|
-
|
|
43313
|
-
}
|
|
42954
|
+
if (branchCount === 0)
|
|
42955
|
+
return -1;
|
|
42956
|
+
const packedKeySlots = branchCount + 1 >> 1;
|
|
42957
|
+
const branchEnd = nodeIndex + packedKeySlots + branchCount;
|
|
42958
|
+
for (let index = 0; index < branchCount; index++) {
|
|
42959
|
+
const packed = decodeTree[nodeIndex + (index >> 1)];
|
|
42960
|
+
const key = packed >> ((index & 1) << 3) & 255;
|
|
42961
|
+
if (key === char) {
|
|
42962
|
+
const pointerIndex = nodeIndex + packedKeySlots + index;
|
|
42963
|
+
return branchEnd + decodeTree[pointerIndex] & 65535;
|
|
42964
|
+
}
|
|
42965
|
+
if (key > char)
|
|
42966
|
+
return -1;
|
|
42967
|
+
}
|
|
42968
|
+
return -1;
|
|
43314
42969
|
}
|
|
43315
|
-
function
|
|
43316
|
-
|
|
43317
|
-
|
|
43318
|
-
if (!first || !last) return null;
|
|
43319
|
-
const firstMs = calendarDateMs(first);
|
|
43320
|
-
const lastMs = calendarDateMs(last);
|
|
43321
|
-
if (firstMs === null || lastMs === null || firstMs > lastMs) return null;
|
|
43322
|
-
const spanDays = Math.floor((lastMs - firstMs) / DAY_MS) + 1;
|
|
43323
|
-
const periodDays = Math.floor(spanDays / 2);
|
|
43324
|
-
if (periodDays < 1) return null;
|
|
43325
|
-
const byDate = new Map(daily.map((row) => [row.date, row]));
|
|
43326
|
-
const trailingStart = calendarDateAt(lastMs - (periodDays - 1) * DAY_MS);
|
|
43327
|
-
const priorEnd = calendarDateAt(lastMs - periodDays * DAY_MS);
|
|
43328
|
-
const priorStart = calendarDateAt(lastMs - (periodDays * 2 - 1) * DAY_MS);
|
|
43329
|
-
const prior = aggregate(priorStart, priorEnd, byDate);
|
|
43330
|
-
const trailing = aggregate(trailingStart, last, byDate);
|
|
43331
|
-
if (prior.source === "empty" && trailing.source === "empty") return null;
|
|
43332
|
-
const comparable = prior.source !== "dimensioned" && prior.source !== "mixed" && trailing.source !== "dimensioned" && trailing.source !== "mixed";
|
|
43333
|
-
return {
|
|
43334
|
-
days: periodDays,
|
|
43335
|
-
basis: bounds?.basis ?? "split-window",
|
|
43336
|
-
prior,
|
|
43337
|
-
trailing,
|
|
43338
|
-
comparable,
|
|
43339
|
-
change: {
|
|
43340
|
-
clicks: comparable ? relativeChange(trailing.clicks, prior.clicks) : null,
|
|
43341
|
-
impressions: comparable ? relativeChange(trailing.impressions, prior.impressions) : null,
|
|
43342
|
-
ctr: comparable ? relativeChange(trailing.ctr, prior.ctr) : null,
|
|
43343
|
-
position: comparable ? relativeChange(trailing.position, prior.position) : null
|
|
43344
|
-
}
|
|
43345
|
-
};
|
|
43346
|
-
}
|
|
43347
|
-
|
|
43348
|
-
// ../api-routes/src/ga-property-data.ts
|
|
43349
|
-
import { eq as eq63 } from "drizzle-orm";
|
|
43350
|
-
function resolveCurrentGa4PropertyId(stores, projectName, canonicalDomain) {
|
|
43351
|
-
const serviceAccount = stores.ga4CredentialStore?.getConnection(projectName);
|
|
43352
|
-
if (serviceAccount?.propertyId) return serviceAccount.propertyId;
|
|
43353
|
-
return stores.googleConnectionStore?.getConnection(canonicalDomain, "ga4")?.propertyId ?? null;
|
|
43354
|
-
}
|
|
43355
|
-
var GA_PROPERTY_TABLES = [
|
|
43356
|
-
gaTrafficSnapshots,
|
|
43357
|
-
gaTrafficSummaries,
|
|
43358
|
-
gaTrafficWindowSummaries,
|
|
43359
|
-
gaWindowMetrics,
|
|
43360
|
-
gaDailyTotals,
|
|
43361
|
-
gaAiReferrals,
|
|
43362
|
-
gaSocialReferrals,
|
|
43363
|
-
gaAcquisitionDaily,
|
|
43364
|
-
gaLeadEventsDaily,
|
|
43365
|
-
gaSearchLandingPages,
|
|
43366
|
-
gaSearchLandingWindows,
|
|
43367
|
-
gaMeasurementSyncStates
|
|
43368
|
-
];
|
|
43369
|
-
function clearGaPropertyData(tx, projectId) {
|
|
43370
|
-
let deleted = 0;
|
|
43371
|
-
for (const table of GA_PROPERTY_TABLES) {
|
|
43372
|
-
deleted += tx.delete(table).where(eq63(table.projectId, projectId)).run().changes;
|
|
42970
|
+
function readTrieValue(decodeTree, nodeIndex, valueLength) {
|
|
42971
|
+
if (valueLength === 1) {
|
|
42972
|
+
return String.fromCharCode(decodeTree[nodeIndex] & BinTrieFlags.VALUE_MASK);
|
|
43373
42973
|
}
|
|
43374
|
-
|
|
43375
|
-
|
|
43376
|
-
function projectsSharingGa4Connection(db, canonicalDomain) {
|
|
43377
|
-
return db.select({ id: projects.id, name: projects.name, canonicalDomain: projects.canonicalDomain }).from(projects).where(eq63(projects.canonicalDomain, canonicalDomain)).all();
|
|
43378
|
-
}
|
|
43379
|
-
function readGa4Properties(stores, gaProjects) {
|
|
43380
|
-
return gaProjects.map((project) => ({
|
|
43381
|
-
project,
|
|
43382
|
-
propertyId: resolveCurrentGa4PropertyId(stores, project.name, project.canonicalDomain)
|
|
43383
|
-
}));
|
|
43384
|
-
}
|
|
43385
|
-
function clearGaDataOnPropertyChange(tx, stores, before, actor = "api") {
|
|
43386
|
-
for (const { project, propertyId: previousPropertyId } of before) {
|
|
43387
|
-
const propertyId = resolveCurrentGa4PropertyId(stores, project.name, project.canonicalDomain);
|
|
43388
|
-
const moved = previousPropertyId !== null && previousPropertyId !== propertyId;
|
|
43389
|
-
const snapshotOfAnotherProperty = !moved && tx.selectDistinct({ propertyId: gaSearchLandingWindows.propertyId }).from(gaSearchLandingWindows).where(eq63(gaSearchLandingWindows.projectId, project.id)).all().some((stored) => stored.propertyId !== propertyId);
|
|
43390
|
-
if (!moved && !snapshotOfAnotherProperty) continue;
|
|
43391
|
-
if (clearGaPropertyData(tx, project.id) === 0) continue;
|
|
43392
|
-
writeAuditLog(tx, {
|
|
43393
|
-
projectId: project.id,
|
|
43394
|
-
actor,
|
|
43395
|
-
action: "ga4.data-cleared",
|
|
43396
|
-
entityType: "ga_connection",
|
|
43397
|
-
entityId: propertyId,
|
|
43398
|
-
diff: { previousPropertyId, propertyId }
|
|
43399
|
-
});
|
|
42974
|
+
if (valueLength === 2) {
|
|
42975
|
+
return String.fromCharCode(decodeTree[nodeIndex + 1]);
|
|
43400
42976
|
}
|
|
42977
|
+
return String.fromCharCode(decodeTree[nodeIndex + 1], decodeTree[nodeIndex + 2]);
|
|
43401
42978
|
}
|
|
43402
|
-
|
|
43403
|
-
|
|
43404
|
-
|
|
43405
|
-
|
|
43406
|
-
|
|
43407
|
-
|
|
43408
|
-
|
|
43409
|
-
|
|
43410
|
-
|
|
43411
|
-
|
|
43412
|
-
|
|
43413
|
-
}
|
|
43414
|
-
|
|
43415
|
-
|
|
43416
|
-
|
|
43417
|
-
|
|
43418
|
-
|
|
43419
|
-
|
|
43420
|
-
|
|
43421
|
-
|
|
43422
|
-
|
|
43423
|
-
|
|
43424
|
-
|
|
43425
|
-
|
|
43426
|
-
|
|
43427
|
-
|
|
43428
|
-
const issuedAt = typeof parsed.issuedAt === "number" ? parsed.issuedAt : null;
|
|
43429
|
-
if (issuedAt === null || issuedAt > nowMs || nowMs - issuedAt > GOOGLE_OAUTH_STATE_MAX_AGE_MS) return null;
|
|
43430
|
-
return parsed;
|
|
43431
|
-
} catch {
|
|
43432
|
-
return null;
|
|
42979
|
+
function parseNumericEntity(input, numberStart, inputLength) {
|
|
42980
|
+
let offset = numberStart + 1;
|
|
42981
|
+
let cp = 0;
|
|
42982
|
+
let digitStart = offset;
|
|
42983
|
+
if (offset < inputLength && (input.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X) {
|
|
42984
|
+
offset += 1;
|
|
42985
|
+
digitStart = offset;
|
|
42986
|
+
while (offset < inputLength) {
|
|
42987
|
+
const char = input.charCodeAt(offset);
|
|
42988
|
+
if (isNumber(char)) {
|
|
42989
|
+
cp = cp * 16 + (char - CharCodes.ZERO);
|
|
42990
|
+
} else if (isHexadecimalCharacter(char)) {
|
|
42991
|
+
cp = cp * 16 + ((char | TO_LOWER_BIT) - CharCodes.LOWER_A + 10);
|
|
42992
|
+
} else {
|
|
42993
|
+
break;
|
|
42994
|
+
}
|
|
42995
|
+
offset += 1;
|
|
42996
|
+
}
|
|
42997
|
+
} else {
|
|
42998
|
+
while (offset < inputLength) {
|
|
42999
|
+
const digit = input.charCodeAt(offset) - CharCodes.ZERO;
|
|
43000
|
+
if (digit >>> 0 > 9)
|
|
43001
|
+
break;
|
|
43002
|
+
cp = cp * 10 + digit;
|
|
43003
|
+
offset += 1;
|
|
43004
|
+
}
|
|
43433
43005
|
}
|
|
43006
|
+
if (offset === digitStart)
|
|
43007
|
+
return 0;
|
|
43008
|
+
if (offset < inputLength && input.charCodeAt(offset) === CharCodes.SEMI) {
|
|
43009
|
+
offset += 1;
|
|
43010
|
+
}
|
|
43011
|
+
if (cp > 1114111)
|
|
43012
|
+
cp = 1114112;
|
|
43013
|
+
let consumed = offset - numberStart;
|
|
43014
|
+
if (consumed >= CONSUMED_OVERFLOW) {
|
|
43015
|
+
longNumericConsumed = consumed;
|
|
43016
|
+
consumed = CONSUMED_OVERFLOW;
|
|
43017
|
+
}
|
|
43018
|
+
return consumed << CONSUMED_SHIFT | cp;
|
|
43019
|
+
}
|
|
43020
|
+
function decodeWithTrie(input, isStrict, isAttribute) {
|
|
43021
|
+
const decodeTree = htmlDecodeTree;
|
|
43022
|
+
let offset = input.indexOf("&");
|
|
43023
|
+
if (offset < 0)
|
|
43024
|
+
return input;
|
|
43025
|
+
const inputLength = input.length;
|
|
43026
|
+
let chunkStart = 0;
|
|
43027
|
+
let result = "";
|
|
43028
|
+
const root = decodeTree[0];
|
|
43029
|
+
const rootJumpOffset = root & BinTrieFlags.JUMP_TABLE;
|
|
43030
|
+
const rootBranchCount = (root & BinTrieFlags.BRANCH_LENGTH) >> 7;
|
|
43031
|
+
do {
|
|
43032
|
+
const entityStart = offset + 1;
|
|
43033
|
+
const firstChar = input.charCodeAt(entityStart);
|
|
43034
|
+
let consumed;
|
|
43035
|
+
let value;
|
|
43036
|
+
if (firstChar === CharCodes.NUM) {
|
|
43037
|
+
const packed = parseNumericEntity(input, entityStart, inputLength);
|
|
43038
|
+
consumed = unpackConsumed(packed);
|
|
43039
|
+
if (isStrict && consumed > 0 && input.charCodeAt(entityStart + consumed - 1) !== CharCodes.SEMI) {
|
|
43040
|
+
consumed = 0;
|
|
43041
|
+
}
|
|
43042
|
+
value = consumed === 0 ? "" : codePointToString(packed & CODE_POINT_MASK);
|
|
43043
|
+
} else if (isAlpha(firstChar)) {
|
|
43044
|
+
consumed = 0;
|
|
43045
|
+
value = "";
|
|
43046
|
+
const rootSlotIndex = firstChar - rootJumpOffset;
|
|
43047
|
+
let nodeIndex;
|
|
43048
|
+
if (rootSlotIndex >>> 0 < rootBranchCount) {
|
|
43049
|
+
const stored = decodeTree[1 + rootSlotIndex];
|
|
43050
|
+
nodeIndex = stored === 0 ? -1 : rootBranchCount + stored & 65535;
|
|
43051
|
+
} else {
|
|
43052
|
+
nodeIndex = -1;
|
|
43053
|
+
}
|
|
43054
|
+
let bestNodeIndex = 0;
|
|
43055
|
+
let bestValueLength = 0;
|
|
43056
|
+
let current = nodeIndex < 0 ? 0 : decodeTree[nodeIndex];
|
|
43057
|
+
let index = entityStart + 1;
|
|
43058
|
+
trie: while (index < inputLength) {
|
|
43059
|
+
while (
|
|
43060
|
+
// Value-less, non-run node with a nonzero jump offset.
|
|
43061
|
+
(current & (BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13)) === 0 && (current & BinTrieFlags.JUMP_TABLE) !== 0
|
|
43062
|
+
) {
|
|
43063
|
+
const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
|
|
43064
|
+
const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
|
|
43065
|
+
if (branchCount === 0) {
|
|
43066
|
+
if (input.charCodeAt(index) !== jumpOffset)
|
|
43067
|
+
break trie;
|
|
43068
|
+
nodeIndex += 1;
|
|
43069
|
+
} else {
|
|
43070
|
+
const slot = input.charCodeAt(index) - jumpOffset;
|
|
43071
|
+
if (slot >>> 0 >= branchCount)
|
|
43072
|
+
break trie;
|
|
43073
|
+
const stored = decodeTree[nodeIndex + 1 + slot];
|
|
43074
|
+
if (stored === 0)
|
|
43075
|
+
break trie;
|
|
43076
|
+
nodeIndex = nodeIndex + branchCount + stored & 65535;
|
|
43077
|
+
}
|
|
43078
|
+
current = decodeTree[nodeIndex];
|
|
43079
|
+
index += 1;
|
|
43080
|
+
if (index >= inputLength)
|
|
43081
|
+
break trie;
|
|
43082
|
+
}
|
|
43083
|
+
if ((current & (BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13)) === BinTrieFlags.FLAG13) {
|
|
43084
|
+
const runLength = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
|
|
43085
|
+
if (input.charCodeAt(index) !== (current & BinTrieFlags.JUMP_TABLE)) {
|
|
43086
|
+
break;
|
|
43087
|
+
}
|
|
43088
|
+
index += 1;
|
|
43089
|
+
const remaining = runLength - 1;
|
|
43090
|
+
let wordIndex = nodeIndex + 1;
|
|
43091
|
+
let charIndexInPacked = 0;
|
|
43092
|
+
for (; charIndexInPacked + 1 < remaining; charIndexInPacked += 2) {
|
|
43093
|
+
const packed = decodeTree[wordIndex];
|
|
43094
|
+
if (input.charCodeAt(index) !== (packed & 255))
|
|
43095
|
+
break trie;
|
|
43096
|
+
index += 1;
|
|
43097
|
+
if (input.charCodeAt(index) !== (packed >> 8 & 255))
|
|
43098
|
+
break trie;
|
|
43099
|
+
index += 1;
|
|
43100
|
+
wordIndex += 1;
|
|
43101
|
+
}
|
|
43102
|
+
if (charIndexInPacked < remaining) {
|
|
43103
|
+
if (input.charCodeAt(index) !== (decodeTree[wordIndex] & 255))
|
|
43104
|
+
break;
|
|
43105
|
+
index += 1;
|
|
43106
|
+
}
|
|
43107
|
+
nodeIndex += 1 + (runLength >> 1);
|
|
43108
|
+
current = decodeTree[nodeIndex];
|
|
43109
|
+
continue;
|
|
43110
|
+
}
|
|
43111
|
+
const valueLength = current >>> 14;
|
|
43112
|
+
const char = input.charCodeAt(index);
|
|
43113
|
+
if (valueLength !== 0) {
|
|
43114
|
+
if (char === CharCodes.SEMI) {
|
|
43115
|
+
consumed = index - entityStart + 1;
|
|
43116
|
+
value = valueLength === 1 ? String.fromCharCode(current & BinTrieFlags.VALUE_MASK) : readTrieValue(decodeTree, nodeIndex, valueLength);
|
|
43117
|
+
break;
|
|
43118
|
+
}
|
|
43119
|
+
if (!isStrict && (current & BinTrieFlags.FLAG13) === 0) {
|
|
43120
|
+
consumed = index - entityStart;
|
|
43121
|
+
bestNodeIndex = nodeIndex;
|
|
43122
|
+
bestValueLength = valueLength;
|
|
43123
|
+
}
|
|
43124
|
+
if (valueLength === 1)
|
|
43125
|
+
break;
|
|
43126
|
+
}
|
|
43127
|
+
const next = determineBranch(decodeTree, current, nodeIndex + (valueLength || 1), char);
|
|
43128
|
+
if (next < 0)
|
|
43129
|
+
break;
|
|
43130
|
+
nodeIndex = next;
|
|
43131
|
+
current = decodeTree[nodeIndex];
|
|
43132
|
+
index += 1;
|
|
43133
|
+
}
|
|
43134
|
+
if (value === "") {
|
|
43135
|
+
const finalVL = current >>> 14;
|
|
43136
|
+
if (finalVL !== 0 && !isStrict && (current & BinTrieFlags.FLAG13) === 0) {
|
|
43137
|
+
consumed = index - entityStart;
|
|
43138
|
+
bestNodeIndex = nodeIndex;
|
|
43139
|
+
bestValueLength = finalVL;
|
|
43140
|
+
}
|
|
43141
|
+
if (consumed > 0) {
|
|
43142
|
+
value = readTrieValue(decodeTree, bestNodeIndex, bestValueLength);
|
|
43143
|
+
}
|
|
43144
|
+
}
|
|
43145
|
+
} else {
|
|
43146
|
+
consumed = 0;
|
|
43147
|
+
value = "";
|
|
43148
|
+
}
|
|
43149
|
+
if (consumed === 0 || isAttribute && firstChar !== CharCodes.NUM && input.charCodeAt(entityStart + consumed - 1) !== CharCodes.SEMI && entityStart + consumed < inputLength && isEntityInAttributeInvalidEnd(input.charCodeAt(entityStart + consumed))) {
|
|
43150
|
+
offset = entityStart;
|
|
43151
|
+
} else {
|
|
43152
|
+
if (chunkStart < offset) {
|
|
43153
|
+
result += input.slice(chunkStart, offset);
|
|
43154
|
+
}
|
|
43155
|
+
result += value;
|
|
43156
|
+
offset = chunkStart = entityStart + consumed;
|
|
43157
|
+
}
|
|
43158
|
+
if (input.charCodeAt(offset) !== CharCodes.AMP) {
|
|
43159
|
+
offset = input.indexOf("&", offset);
|
|
43160
|
+
}
|
|
43161
|
+
} while (offset >= 0);
|
|
43162
|
+
return result + input.slice(chunkStart);
|
|
43163
|
+
}
|
|
43164
|
+
function decodeHTML(htmlString, mode = DecodingMode.Legacy) {
|
|
43165
|
+
return decodeWithTrie(htmlString, mode === DecodingMode.Strict, mode === DecodingMode.Attribute);
|
|
43434
43166
|
}
|
|
43435
43167
|
|
|
43436
|
-
//
|
|
43437
|
-
var
|
|
43438
|
-
|
|
43439
|
-
|
|
43440
|
-
|
|
43441
|
-
|
|
43442
|
-
var
|
|
43443
|
-
|
|
43444
|
-
|
|
43445
|
-
|
|
43446
|
-
|
|
43447
|
-
|
|
43448
|
-
|
|
43449
|
-
|
|
43450
|
-
var GSC_MAX_PAGES = 40;
|
|
43168
|
+
// ../../node_modules/.pnpm/entities@8.1.0/node_modules/entities/dist/index.js
|
|
43169
|
+
var EntityLevel;
|
|
43170
|
+
(function(EntityLevel2) {
|
|
43171
|
+
EntityLevel2[EntityLevel2["XML"] = 0] = "XML";
|
|
43172
|
+
EntityLevel2[EntityLevel2["HTML"] = 1] = "HTML";
|
|
43173
|
+
})(EntityLevel || (EntityLevel = {}));
|
|
43174
|
+
var EncodingMode;
|
|
43175
|
+
(function(EncodingMode2) {
|
|
43176
|
+
EncodingMode2[EncodingMode2["UTF8"] = 0] = "UTF8";
|
|
43177
|
+
EncodingMode2[EncodingMode2["ASCII"] = 1] = "ASCII";
|
|
43178
|
+
EncodingMode2[EncodingMode2["Extensive"] = 2] = "Extensive";
|
|
43179
|
+
EncodingMode2[EncodingMode2["Attribute"] = 3] = "Attribute";
|
|
43180
|
+
EncodingMode2[EncodingMode2["Text"] = 4] = "Text";
|
|
43181
|
+
})(EncodingMode || (EncodingMode = {}));
|
|
43451
43182
|
|
|
43452
|
-
// ../
|
|
43453
|
-
|
|
43454
|
-
|
|
43455
|
-
|
|
43183
|
+
// ../api-routes/src/guarded-fetch.ts
|
|
43184
|
+
import { Agent, fetch as undiciFetch } from "undici";
|
|
43185
|
+
var GUARDED_FETCH_MAX_REDIRECTS = 5;
|
|
43186
|
+
var MAX_POOLED_AGENTS = 16;
|
|
43187
|
+
var EgressRefusedError = class extends Error {
|
|
43188
|
+
/**
|
|
43189
|
+
* True when the refused target is a redirect the site chose rather than the
|
|
43190
|
+
* URL the caller asked for. Refusing the caller's URL is a verdict on the
|
|
43191
|
+
* caller's input; refusing a redirect is the site's failure.
|
|
43192
|
+
*/
|
|
43193
|
+
redirected;
|
|
43194
|
+
constructor(message, redirected) {
|
|
43456
43195
|
super(message);
|
|
43457
|
-
this.name = "
|
|
43458
|
-
this.
|
|
43196
|
+
this.name = "EgressRefusedError";
|
|
43197
|
+
this.redirected = redirected;
|
|
43459
43198
|
}
|
|
43460
43199
|
};
|
|
43461
|
-
var
|
|
43462
|
-
|
|
43463
|
-
constructor(message, status) {
|
|
43200
|
+
var EgressFailedError = class extends Error {
|
|
43201
|
+
constructor(message) {
|
|
43464
43202
|
super(message);
|
|
43465
|
-
this.name = "
|
|
43466
|
-
this.status = status;
|
|
43203
|
+
this.name = "EgressFailedError";
|
|
43467
43204
|
}
|
|
43468
43205
|
};
|
|
43469
|
-
|
|
43470
|
-
|
|
43471
|
-
function
|
|
43472
|
-
|
|
43473
|
-
|
|
43206
|
+
var CROSS_ORIGIN_DROPPED_HEADERS = ["authorization", "cookie", "proxy-authorization"];
|
|
43207
|
+
var BODY_HEADERS = ["content-encoding", "content-language", "content-length", "content-location", "content-type"];
|
|
43208
|
+
function createGuardedFetch(options = {}) {
|
|
43209
|
+
const resolveTarget = options.resolveTarget ?? ((url) => resolveWebhookTarget(url, { allowLoopback: options.allowLoopback }));
|
|
43210
|
+
const agents = /* @__PURE__ */ new Map();
|
|
43211
|
+
function agentFor(target) {
|
|
43212
|
+
const addresses = checkedAddresses(target);
|
|
43213
|
+
const key = `${target.url.origin} ${addresses.map(({ address }) => address).sort().join(" ")}`;
|
|
43214
|
+
const agent = agents.get(key) ?? pinnedAgent(addresses);
|
|
43215
|
+
agents.delete(key);
|
|
43216
|
+
agents.set(key, agent);
|
|
43217
|
+
if (agents.size > MAX_POOLED_AGENTS) {
|
|
43218
|
+
const [oldestKey, oldest] = agents.entries().next().value;
|
|
43219
|
+
agents.delete(oldestKey);
|
|
43220
|
+
oldest.close().catch(() => {
|
|
43221
|
+
});
|
|
43222
|
+
}
|
|
43223
|
+
return agent;
|
|
43474
43224
|
}
|
|
43225
|
+
return async (input, init = {}) => {
|
|
43226
|
+
let href = String(input);
|
|
43227
|
+
let method = (init.method ?? "GET").toUpperCase();
|
|
43228
|
+
let body = init.body ?? null;
|
|
43229
|
+
const headers = new Headers(init.headers);
|
|
43230
|
+
const signal = init.signal ?? void 0;
|
|
43231
|
+
let mayRedirectToLoopback = true;
|
|
43232
|
+
for (let redirects = 0; ; redirects += 1) {
|
|
43233
|
+
signal?.throwIfAborted();
|
|
43234
|
+
const check = await untilAborted(resolveTarget(href), signal);
|
|
43235
|
+
if (!check.ok) {
|
|
43236
|
+
const parsed = URL.canParse(href) ? new URL(href) : null;
|
|
43237
|
+
if (check.unresolved) throw new EgressFailedError(`Could not resolve ${parsed?.hostname || href}`);
|
|
43238
|
+
throw new EgressRefusedError(`Refused to connect to ${parsed?.host || href}: ${check.message.replace(/^"url" /, "")}`, redirects > 0);
|
|
43239
|
+
}
|
|
43240
|
+
const url = check.target.url;
|
|
43241
|
+
const onLoopback = checkedAddresses(check.target).map(({ address }) => isLoopbackAddress(address));
|
|
43242
|
+
if (!mayRedirectToLoopback && onLoopback.includes(true)) {
|
|
43243
|
+
throw new EgressRefusedError(`Refused to connect to ${url.host}: a redirect from a site that is not on loopback must not lead to loopback`, true);
|
|
43244
|
+
}
|
|
43245
|
+
mayRedirectToLoopback = !onLoopback.includes(false);
|
|
43246
|
+
const response = await requestPinned(check.target, agentFor(check.target), { method, headers, body, signal });
|
|
43247
|
+
const location = isLocationRedirectStatus(response.status) ? response.headers.get("location") : null;
|
|
43248
|
+
if (location === null) return response;
|
|
43249
|
+
await response.body?.cancel();
|
|
43250
|
+
if (redirects >= GUARDED_FETCH_MAX_REDIRECTS) {
|
|
43251
|
+
throw new EgressFailedError(`${url.host} redirected more than ${GUARDED_FETCH_MAX_REDIRECTS} times`);
|
|
43252
|
+
}
|
|
43253
|
+
let next;
|
|
43254
|
+
try {
|
|
43255
|
+
next = new URL(location, url);
|
|
43256
|
+
} catch {
|
|
43257
|
+
throw new EgressFailedError(`${url.host} redirected to an invalid Location`);
|
|
43258
|
+
}
|
|
43259
|
+
const status = response.status;
|
|
43260
|
+
if (status === 303 && method !== "GET" && method !== "HEAD" || (status === 301 || status === 302) && method === "POST") {
|
|
43261
|
+
method = "GET";
|
|
43262
|
+
body = null;
|
|
43263
|
+
for (const name of BODY_HEADERS) headers.delete(name);
|
|
43264
|
+
}
|
|
43265
|
+
if (next.origin !== url.origin) {
|
|
43266
|
+
for (const name of CROSS_ORIGIN_DROPPED_HEADERS) headers.delete(name);
|
|
43267
|
+
}
|
|
43268
|
+
href = next.href;
|
|
43269
|
+
}
|
|
43270
|
+
};
|
|
43475
43271
|
}
|
|
43476
|
-
function
|
|
43477
|
-
if (!
|
|
43478
|
-
|
|
43272
|
+
async function untilAborted(operation, signal) {
|
|
43273
|
+
if (!signal) return await operation;
|
|
43274
|
+
let onAbort;
|
|
43275
|
+
try {
|
|
43276
|
+
return await Promise.race([
|
|
43277
|
+
operation,
|
|
43278
|
+
new Promise((_resolve, reject) => {
|
|
43279
|
+
onAbort = () => reject(signal.reason instanceof Error ? signal.reason : new DOMException("This operation was aborted", "AbortError"));
|
|
43280
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
43281
|
+
})
|
|
43282
|
+
]);
|
|
43283
|
+
} finally {
|
|
43284
|
+
if (onAbort) signal.removeEventListener("abort", onAbort);
|
|
43479
43285
|
}
|
|
43480
43286
|
}
|
|
43481
|
-
function
|
|
43482
|
-
|
|
43483
|
-
|
|
43484
|
-
|
|
43287
|
+
async function requestPinned(target, dispatcher, init) {
|
|
43288
|
+
const response = await undiciFetch(target.url, {
|
|
43289
|
+
method: init.method,
|
|
43290
|
+
headers: [...init.headers],
|
|
43291
|
+
body: init.body,
|
|
43292
|
+
signal: init.signal,
|
|
43293
|
+
redirect: "manual",
|
|
43294
|
+
dispatcher
|
|
43295
|
+
});
|
|
43296
|
+
return response;
|
|
43297
|
+
}
|
|
43298
|
+
function pinnedAgent(addresses) {
|
|
43299
|
+
return new Agent({
|
|
43300
|
+
// Try the next checked address when one does not answer, so a dual-stack
|
|
43301
|
+
// site whose first address is unreachable (an IPv6-only network, a dead A
|
|
43302
|
+
// record) still loads, as it does through global `fetch`. Every address
|
|
43303
|
+
// passed the policy, so falling back reaches nothing it refused.
|
|
43304
|
+
autoSelectFamily: true,
|
|
43305
|
+
connect: { lookup: pinnedLookup(addresses) }
|
|
43306
|
+
});
|
|
43307
|
+
}
|
|
43308
|
+
|
|
43309
|
+
// ../api-routes/src/gbp-hotel-policy.ts
|
|
43310
|
+
function hotelEditorialText(value) {
|
|
43311
|
+
const text = decodeHTML(value).normalize("NFKC").toLowerCase();
|
|
43312
|
+
return text.trim().length > 0 && !/\b(?:offers?|deals?|promotions?|discounts?|coupons?|promo\s*codes?|special\s+rates?|book\s+now|save\s+\d+)\b|\d+\s*%\s*off/iu.test(
|
|
43313
|
+
text
|
|
43314
|
+
);
|
|
43315
|
+
}
|
|
43316
|
+
var JSON_STRING = /"(?:\\.|[^"\\])*"/gu;
|
|
43317
|
+
function decodePercentRuns(value) {
|
|
43318
|
+
return value.replace(/(?:%[0-9a-f]{2})+/giu, (part) => {
|
|
43319
|
+
try {
|
|
43320
|
+
return decodeURIComponent(part);
|
|
43321
|
+
} catch {
|
|
43322
|
+
return " ";
|
|
43323
|
+
}
|
|
43324
|
+
});
|
|
43325
|
+
}
|
|
43326
|
+
var SCHEMA_TYPE = /^(?:https?:\/\/schema\.org\/)?(?:Offer|AggregateOffer|OfferCatalog)$/u;
|
|
43327
|
+
var SCHEMA_CONTEXT = /^https?:\/\/schema\.org\/?$/u;
|
|
43328
|
+
function editorialJsonLd(source) {
|
|
43485
43329
|
try {
|
|
43486
|
-
const
|
|
43487
|
-
if (
|
|
43488
|
-
|
|
43330
|
+
const parsed = JSON.parse(source);
|
|
43331
|
+
if (parsed === null || typeof parsed !== "object") return null;
|
|
43332
|
+
const roots = Array.isArray(parsed) ? parsed : [parsed];
|
|
43333
|
+
if (roots.length === 0 || roots.some(
|
|
43334
|
+
(value) => value === null || typeof value !== "object" || Array.isArray(value)
|
|
43335
|
+
))
|
|
43336
|
+
return null;
|
|
43337
|
+
const pending = roots.map((value) => ({ value, depth: 0 }));
|
|
43338
|
+
let visited = 0;
|
|
43339
|
+
while (pending.length > 0) {
|
|
43340
|
+
const { value, depth } = pending.pop();
|
|
43341
|
+
if (depth > 32 || ++visited > 1e4) return null;
|
|
43342
|
+
if (value === null || typeof value !== "object") continue;
|
|
43343
|
+
if (Array.isArray(value)) {
|
|
43344
|
+
pending.push(
|
|
43345
|
+
...value.map((item2) => ({ value: item2, depth: depth + 1 }))
|
|
43346
|
+
);
|
|
43347
|
+
continue;
|
|
43348
|
+
}
|
|
43349
|
+
const row = value;
|
|
43350
|
+
if (depth === 0 || Object.hasOwn(row, "@context")) {
|
|
43351
|
+
const context = row["@context"];
|
|
43352
|
+
if (typeof context !== "string" || !SCHEMA_CONTEXT.test(context))
|
|
43353
|
+
return null;
|
|
43354
|
+
}
|
|
43355
|
+
pending.push(
|
|
43356
|
+
...Object.values(row).map((item2) => ({
|
|
43357
|
+
value: item2,
|
|
43358
|
+
depth: depth + 1
|
|
43359
|
+
}))
|
|
43360
|
+
);
|
|
43361
|
+
}
|
|
43362
|
+
const canonical = source.replace(
|
|
43363
|
+
JSON_STRING,
|
|
43364
|
+
(token) => JSON.stringify(
|
|
43365
|
+
decodePercentRuns(decodeHTML(String(JSON.parse(token))).normalize("NFKC")).replace(/\s+/gu, " ")
|
|
43366
|
+
)
|
|
43367
|
+
);
|
|
43368
|
+
for (const match of canonical.matchAll(
|
|
43369
|
+
/(?:\{|,)\s*("(?:\\.|[^"\\])*")\s*:/gu
|
|
43370
|
+
)) {
|
|
43371
|
+
const key = String(JSON.parse(match[1])).replace(/[^a-z]/giu, "").toLowerCase();
|
|
43372
|
+
if (/discount|coupon|promo|specialrate|saleprice|strikethroughprice/u.test(
|
|
43373
|
+
key
|
|
43374
|
+
))
|
|
43375
|
+
return null;
|
|
43376
|
+
}
|
|
43377
|
+
for (const match of canonical.matchAll(JSON_STRING)) {
|
|
43378
|
+
if (/^(?:https?:\/\/schema\.org\/)?(?:SalePrice|StrikethroughPrice)$/u.test(
|
|
43379
|
+
String(JSON.parse(match[0]))
|
|
43380
|
+
))
|
|
43381
|
+
return null;
|
|
43489
43382
|
}
|
|
43383
|
+
return canonical.replace(
|
|
43384
|
+
/([,{]\s*"@type"\s*:\s*)("(?:\\.|[^"\\])*"|\[\s*\]|\[\s*"(?:\\.|[^"\\])*"(?:\s*,\s*"(?:\\.|[^"\\])*")*\s*\])/gu,
|
|
43385
|
+
(_whole, prefix, raw) => {
|
|
43386
|
+
const types = JSON.parse(raw);
|
|
43387
|
+
const mask = (type) => typeof type === "string" && SCHEMA_TYPE.test(type) ? "SchemaType" : type;
|
|
43388
|
+
return prefix + JSON.stringify(Array.isArray(types) ? types.map(mask) : mask(types));
|
|
43389
|
+
}
|
|
43390
|
+
).replace(/([,{]\s*)"offers"(\s*:)/gu, '$1"schemaOffers"$2');
|
|
43490
43391
|
} catch {
|
|
43491
|
-
|
|
43492
|
-
}
|
|
43493
|
-
}
|
|
43494
|
-
function validateCode(code) {
|
|
43495
|
-
if (!code || typeof code !== "string" || code.trim().length === 0) {
|
|
43496
|
-
throw new GoogleAuthError("Authorization code is required and must be a non-empty string");
|
|
43392
|
+
return null;
|
|
43497
43393
|
}
|
|
43498
43394
|
}
|
|
43499
|
-
function
|
|
43500
|
-
|
|
43501
|
-
|
|
43502
|
-
|
|
43503
|
-
|
|
43504
|
-
|
|
43505
|
-
|
|
43395
|
+
function editorialHtml(html) {
|
|
43396
|
+
let valid = true;
|
|
43397
|
+
const text = html.replace(
|
|
43398
|
+
/<script\b((?:[^"'<>]|"[^"]*"|'[^']*')*)>([\s\S]*?)<\/script\s*>/giu,
|
|
43399
|
+
(whole, attributes, body) => {
|
|
43400
|
+
if (!/(?:^|\s)type\s*=\s*(?:"application\/ld\+json"|'application\/ld\+json'|application\/ld\+json(?=\s|$))/iu.test(
|
|
43401
|
+
attributes
|
|
43402
|
+
))
|
|
43403
|
+
return whole;
|
|
43404
|
+
const normalized = editorialJsonLd(body);
|
|
43405
|
+
if (normalized === null) {
|
|
43406
|
+
valid = false;
|
|
43407
|
+
return whole;
|
|
43408
|
+
}
|
|
43409
|
+
return `<script${attributes}>${normalized}</script>`;
|
|
43506
43410
|
}
|
|
43507
|
-
|
|
43411
|
+
);
|
|
43412
|
+
return valid && hotelEditorialText(text) && hotelEditorialText(decodePercentRuns(text));
|
|
43508
43413
|
}
|
|
43509
|
-
function
|
|
43510
|
-
|
|
43511
|
-
|
|
43414
|
+
async function hotelEditorialDestination(domain, summary3, articleUrl, fetchImpl = createGuardedFetch()) {
|
|
43415
|
+
try {
|
|
43416
|
+
const host = hostOf(domain);
|
|
43417
|
+
const target = new URL(articleUrl);
|
|
43418
|
+
if (!host || target.protocol !== "https:" || target.username || target.password || target.port || target.hash || target.search || ![host, `www.${host}`].includes(target.hostname) || !hotelEditorialText(summary3 + " " + decodePercentRuns(target.pathname)))
|
|
43419
|
+
return false;
|
|
43420
|
+
const response = await fetchImpl(target, {
|
|
43421
|
+
method: "GET",
|
|
43422
|
+
headers: { accept: "text/html" },
|
|
43423
|
+
signal: AbortSignal.timeout(2e4)
|
|
43424
|
+
});
|
|
43425
|
+
if (response.status !== 200 || !response.headers.get("content-type")?.toLowerCase().startsWith("text/html") || new URL(response.url || target.href).origin !== target.origin || !response.body)
|
|
43426
|
+
return false;
|
|
43427
|
+
const reader = response.body.getReader();
|
|
43428
|
+
const chunks = [];
|
|
43429
|
+
let size = 0;
|
|
43430
|
+
for (; ; ) {
|
|
43431
|
+
const part = await reader.read();
|
|
43432
|
+
if (part.done) break;
|
|
43433
|
+
size += part.value.byteLength;
|
|
43434
|
+
if (size > 512 * 1024) {
|
|
43435
|
+
await reader.cancel();
|
|
43436
|
+
return false;
|
|
43437
|
+
}
|
|
43438
|
+
chunks.push(part.value);
|
|
43439
|
+
}
|
|
43440
|
+
const html = new TextDecoder("utf-8", { fatal: true }).decode(
|
|
43441
|
+
Buffer.concat(chunks)
|
|
43442
|
+
);
|
|
43443
|
+
return editorialHtml(html);
|
|
43444
|
+
} catch {
|
|
43445
|
+
return false;
|
|
43512
43446
|
}
|
|
43513
43447
|
}
|
|
43514
|
-
|
|
43515
|
-
|
|
43516
|
-
|
|
43517
|
-
|
|
43518
|
-
|
|
43519
|
-
|
|
43520
|
-
|
|
43521
|
-
|
|
43522
|
-
|
|
43523
|
-
|
|
43524
|
-
|
|
43525
|
-
|
|
43526
|
-
|
|
43527
|
-
|
|
43448
|
+
|
|
43449
|
+
// ../api-routes/src/gbp-local-posts.ts
|
|
43450
|
+
var digest = (value) => createHash8("sha256").update(JSON.stringify(value)).digest("hex");
|
|
43451
|
+
var READ_REASONS = /* @__PURE__ */ new Set([
|
|
43452
|
+
"ACCESS_TOKEN_SCOPE_INSUFFICIENT",
|
|
43453
|
+
"RATE_LIMIT_EXCEEDED",
|
|
43454
|
+
"SERVICE_DISABLED",
|
|
43455
|
+
"API_DISABLED",
|
|
43456
|
+
"CONSUMER_INVALID",
|
|
43457
|
+
"IAM_PERMISSION_DENIED",
|
|
43458
|
+
"ACCESS_DENIED",
|
|
43459
|
+
"UNAUTHENTICATED",
|
|
43460
|
+
"NOT_FOUND",
|
|
43461
|
+
"INVALID_ARGUMENT",
|
|
43462
|
+
"QUOTA_EXCEEDED",
|
|
43463
|
+
"PERMISSION_DENIED",
|
|
43464
|
+
"FAILED_PRECONDITION",
|
|
43465
|
+
"INTERNAL",
|
|
43466
|
+
"UNAVAILABLE",
|
|
43467
|
+
"RESOURCE_EXHAUSTED"
|
|
43468
|
+
]);
|
|
43469
|
+
function localPostReadError(error, stage, message) {
|
|
43470
|
+
let category = stage === "token" ? "token" : "unclassified";
|
|
43471
|
+
let reason = "UNCLASSIFIED";
|
|
43472
|
+
let upstreamStatus;
|
|
43473
|
+
if (stage === "token") {
|
|
43474
|
+
if (error instanceof GoogleAuthError) {
|
|
43475
|
+
reason = "REFRESH_FAILED";
|
|
43476
|
+
upstreamStatus = error.statusCode ?? Number(error.message.match(/^Token refresh failed \((\d{3})\):/u)?.[1]);
|
|
43477
|
+
} else if (error instanceof AppError) {
|
|
43478
|
+
if (error.code === "NOT_FOUND") reason = "NOT_CONNECTED";
|
|
43479
|
+
if (error.code === "VALIDATION_ERROR") reason = "NOT_CONFIGURED";
|
|
43480
|
+
}
|
|
43481
|
+
} else if (error instanceof GbpApiError) {
|
|
43482
|
+
category = "google_api";
|
|
43483
|
+
const body = error.body;
|
|
43484
|
+
const code = body?.error?.status;
|
|
43485
|
+
reason = error.reason !== null && READ_REASONS.has(error.reason) ? error.reason : typeof code === "string" && READ_REASONS.has(code) ? code : reason;
|
|
43486
|
+
upstreamStatus = error.status;
|
|
43487
|
+
} else if (error instanceof GbpLocalPostResponseError) {
|
|
43488
|
+
category = "response";
|
|
43489
|
+
reason = error.reason;
|
|
43490
|
+
}
|
|
43491
|
+
return providerError(message, {
|
|
43492
|
+
category,
|
|
43493
|
+
reason,
|
|
43494
|
+
...typeof upstreamStatus === "number" && Number.isInteger(upstreamStatus) && upstreamStatus >= 100 && upstreamStatus <= 599 ? { upstreamStatus } : {}
|
|
43528
43495
|
});
|
|
43529
|
-
if (state) params.set("state", state);
|
|
43530
|
-
return `${GOOGLE_AUTH_URL}?${params.toString()}`;
|
|
43531
43496
|
}
|
|
43532
|
-
|
|
43533
|
-
|
|
43534
|
-
|
|
43535
|
-
|
|
43536
|
-
|
|
43537
|
-
|
|
43538
|
-
|
|
43539
|
-
|
|
43540
|
-
|
|
43541
|
-
|
|
43542
|
-
|
|
43543
|
-
|
|
43544
|
-
redirect_uri: redirectUri,
|
|
43545
|
-
grant_type: "authorization_code"
|
|
43546
|
-
}),
|
|
43547
|
-
signal: AbortSignal.timeout(GOOGLE_REQUEST_TIMEOUT_MS)
|
|
43548
|
-
});
|
|
43549
|
-
if (res.status === 429) {
|
|
43550
|
-
throw new GoogleAuthError("Google OAuth rate limit exceeded", 429);
|
|
43551
|
-
}
|
|
43552
|
-
if (!res.ok) {
|
|
43553
|
-
const body = await res.text();
|
|
43554
|
-
let detail = "";
|
|
43497
|
+
function readGrant(request) {
|
|
43498
|
+
requireAdminSession(request);
|
|
43499
|
+
requirePaidReadScope(
|
|
43500
|
+
request,
|
|
43501
|
+
[GBP_LIVE_READ_SCOPE, GBP_POSTS_WRITE_SCOPE],
|
|
43502
|
+
"This API key was not granted live Google Business Profile reads."
|
|
43503
|
+
);
|
|
43504
|
+
requireScope(request, GBP_LIVE_READ_SCOPE);
|
|
43505
|
+
}
|
|
43506
|
+
async function gbpLocalPostsRoutes(app, options) {
|
|
43507
|
+
async function readPostResource(domain, read, message) {
|
|
43508
|
+
let token;
|
|
43555
43509
|
try {
|
|
43556
|
-
|
|
43557
|
-
|
|
43558
|
-
|
|
43559
|
-
const sanitized = parsed.error_description.replace(new RegExp(escapeRegExp2(clientId), "g"), "***").replace(new RegExp(escapeRegExp2(clientSecret), "g"), "***").replace(new RegExp(escapeRegExp2(code), "g"), "***");
|
|
43560
|
-
detail += detail ? `: ${sanitized}` : sanitized;
|
|
43561
|
-
}
|
|
43562
|
-
} catch {
|
|
43563
|
-
const truncated = body.length <= 120 ? body : `${body.slice(0, 120)}...`;
|
|
43564
|
-
detail = truncated.replace(new RegExp(escapeRegExp2(clientId), "g"), "***").replace(new RegExp(escapeRegExp2(clientSecret), "g"), "***").replace(new RegExp(escapeRegExp2(code), "g"), "***");
|
|
43510
|
+
token = await options.token(domain);
|
|
43511
|
+
} catch (error) {
|
|
43512
|
+
throw localPostReadError(error, "token", message);
|
|
43565
43513
|
}
|
|
43566
|
-
throw new GoogleAuthError(`Token exchange failed (${res.status}): ${detail}`);
|
|
43567
|
-
}
|
|
43568
|
-
return await res.json();
|
|
43569
|
-
}
|
|
43570
|
-
function escapeRegExp2(str) {
|
|
43571
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
43572
|
-
}
|
|
43573
|
-
async function refreshAccessToken(clientId, clientSecret, currentRefreshToken) {
|
|
43574
|
-
validateClientId(clientId);
|
|
43575
|
-
validateClientSecret(clientSecret);
|
|
43576
|
-
validateRefreshToken(currentRefreshToken);
|
|
43577
|
-
const res = await fetch(GOOGLE_TOKEN_URL, {
|
|
43578
|
-
method: "POST",
|
|
43579
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
43580
|
-
body: new URLSearchParams({
|
|
43581
|
-
client_id: clientId,
|
|
43582
|
-
client_secret: clientSecret,
|
|
43583
|
-
refresh_token: currentRefreshToken,
|
|
43584
|
-
grant_type: "refresh_token"
|
|
43585
|
-
}),
|
|
43586
|
-
signal: AbortSignal.timeout(GOOGLE_REQUEST_TIMEOUT_MS)
|
|
43587
|
-
});
|
|
43588
|
-
if (res.status === 429) {
|
|
43589
|
-
throw new GoogleAuthError("Google OAuth rate limit exceeded", 429);
|
|
43590
|
-
}
|
|
43591
|
-
if (!res.ok) {
|
|
43592
|
-
const body = await res.text();
|
|
43593
|
-
let detail = "";
|
|
43594
43514
|
try {
|
|
43595
|
-
|
|
43596
|
-
|
|
43597
|
-
|
|
43598
|
-
const sanitized = parsed.error_description.replace(new RegExp(escapeRegExp2(clientId), "g"), "***").replace(new RegExp(escapeRegExp2(clientSecret), "g"), "***").replace(new RegExp(escapeRegExp2(currentRefreshToken), "g"), "***");
|
|
43599
|
-
detail += detail ? `: ${sanitized}` : sanitized;
|
|
43600
|
-
}
|
|
43601
|
-
} catch {
|
|
43602
|
-
const truncated = body.length <= 120 ? body : `${body.slice(0, 120)}...`;
|
|
43603
|
-
detail = truncated.replace(new RegExp(escapeRegExp2(clientId), "g"), "***").replace(new RegExp(escapeRegExp2(clientSecret), "g"), "***").replace(new RegExp(escapeRegExp2(currentRefreshToken), "g"), "***");
|
|
43515
|
+
return await read(token);
|
|
43516
|
+
} catch (error) {
|
|
43517
|
+
throw localPostReadError(error, "read", message);
|
|
43604
43518
|
}
|
|
43605
|
-
throw new GoogleAuthError(`Token refresh failed (${res.status}): ${detail}`);
|
|
43606
43519
|
}
|
|
43607
|
-
|
|
43608
|
-
|
|
43609
|
-
|
|
43610
|
-
|
|
43611
|
-
|
|
43612
|
-
|
|
43613
|
-
|
|
43614
|
-
|
|
43615
|
-
|
|
43616
|
-
|
|
43617
|
-
|
|
43618
|
-
|
|
43619
|
-
|
|
43620
|
-
|
|
43621
|
-
|
|
43520
|
+
function selected(projectId, account, location) {
|
|
43521
|
+
const a = gbpAccountNameSchema.safeParse(account);
|
|
43522
|
+
const l = gbpLocationNameSchema.safeParse(location);
|
|
43523
|
+
if (!a.success || !l.success)
|
|
43524
|
+
throw validationError(
|
|
43525
|
+
"Exact GBP account and location names are required."
|
|
43526
|
+
);
|
|
43527
|
+
const row = app.db.select().from(gbpLocations).where(
|
|
43528
|
+
and51(
|
|
43529
|
+
eq62(gbpLocations.projectId, projectId),
|
|
43530
|
+
eq62(gbpLocations.accountName, a.data),
|
|
43531
|
+
eq62(gbpLocations.locationName, l.data),
|
|
43532
|
+
eq62(gbpLocations.selected, true)
|
|
43533
|
+
)
|
|
43534
|
+
).get();
|
|
43535
|
+
if (!row)
|
|
43536
|
+
throw forbidden(
|
|
43537
|
+
"This account/location is not selected on the requested project."
|
|
43538
|
+
);
|
|
43539
|
+
return row;
|
|
43622
43540
|
}
|
|
43623
|
-
|
|
43624
|
-
|
|
43625
|
-
|
|
43626
|
-
|
|
43627
|
-
|
|
43628
|
-
|
|
43629
|
-
|
|
43541
|
+
app.get("/projects/:name/gbp/local-posts", async (request) => {
|
|
43542
|
+
readGrant(request);
|
|
43543
|
+
const project = resolveProject(app.db, request.params.name);
|
|
43544
|
+
const location = selected(
|
|
43545
|
+
project.id,
|
|
43546
|
+
request.query.accountName,
|
|
43547
|
+
request.query.locationName
|
|
43548
|
+
);
|
|
43549
|
+
const page3 = request.query.pageToken;
|
|
43550
|
+
if (page3 !== void 0 && (page3.length > 2e3 || /[\p{Cc}\p{Cf}]/u.test(page3)))
|
|
43551
|
+
throw validationError("Invalid GBP page token.");
|
|
43552
|
+
return readPostResource(
|
|
43553
|
+
project.canonicalDomain,
|
|
43554
|
+
(token) => listLocalPosts(token, location.accountName, location.locationName, page3),
|
|
43555
|
+
"Google Local Posts could not be read; coverage is unknown."
|
|
43556
|
+
);
|
|
43557
|
+
});
|
|
43558
|
+
app.get(
|
|
43559
|
+
"/projects/:name/gbp/local-post",
|
|
43560
|
+
async (request) => {
|
|
43561
|
+
readGrant(request);
|
|
43562
|
+
const project = resolveProject(app.db, request.params.name);
|
|
43563
|
+
const parsed = gbpLocalPostNameSchema.safeParse(request.query.postName);
|
|
43564
|
+
if (!parsed.success)
|
|
43565
|
+
throw validationError("An exact GBP post resource name is required.");
|
|
43566
|
+
const parts = parsed.data.split("/");
|
|
43567
|
+
selected(
|
|
43568
|
+
project.id,
|
|
43569
|
+
parts.slice(0, 2).join("/"),
|
|
43570
|
+
parts.slice(2, 4).join("/")
|
|
43571
|
+
);
|
|
43572
|
+
return readPostResource(
|
|
43573
|
+
project.canonicalDomain,
|
|
43574
|
+
(token) => getLocalPost(token, parsed.data),
|
|
43575
|
+
"Google Local Post could not be verified; do not resubmit it."
|
|
43576
|
+
);
|
|
43630
43577
|
}
|
|
43631
|
-
|
|
43578
|
+
);
|
|
43579
|
+
app.get("/projects/:name/gbp/reviews/live", async (request) => {
|
|
43580
|
+
readGrant(request);
|
|
43581
|
+
const project = resolveProject(app.db, request.params.name);
|
|
43582
|
+
const location = selected(
|
|
43583
|
+
project.id,
|
|
43584
|
+
request.query.accountName,
|
|
43585
|
+
request.query.locationName
|
|
43586
|
+
);
|
|
43632
43587
|
try {
|
|
43633
|
-
const
|
|
43634
|
-
|
|
43635
|
-
|
|
43636
|
-
|
|
43588
|
+
const listing = await listReviews(
|
|
43589
|
+
await options.token(project.canonicalDomain),
|
|
43590
|
+
location.accountName,
|
|
43591
|
+
location.locationName,
|
|
43592
|
+
{ maxPages: 20, strict: true }
|
|
43593
|
+
);
|
|
43594
|
+
const url = location.mapsUri;
|
|
43595
|
+
const profileUrl = url && /^https:\/\/(?:www\.)?google\.com\/maps\//u.test(url) ? url : location.placeId ? `https://www.google.com/maps/search/?api=1&query=Google&query_place_id=${encodeURIComponent(location.placeId)}` : null;
|
|
43596
|
+
return {
|
|
43597
|
+
accountName: location.accountName,
|
|
43598
|
+
locationName: location.locationName,
|
|
43599
|
+
profileUrl,
|
|
43600
|
+
complete: true,
|
|
43601
|
+
checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
43602
|
+
reviews: listing.reviews.map(
|
|
43603
|
+
({ replyComment: _reply, replyUpdateTime: _time, ...review }) => review
|
|
43604
|
+
)
|
|
43605
|
+
};
|
|
43637
43606
|
} catch {
|
|
43638
|
-
throw
|
|
43607
|
+
throw providerError(
|
|
43608
|
+
"Google reviews could not be read completely; keep the previous baseline."
|
|
43609
|
+
);
|
|
43639
43610
|
}
|
|
43640
|
-
}
|
|
43641
|
-
|
|
43642
|
-
|
|
43643
|
-
|
|
43644
|
-
|
|
43645
|
-
|
|
43646
|
-
|
|
43647
|
-
|
|
43648
|
-
|
|
43649
|
-
|
|
43611
|
+
});
|
|
43612
|
+
app.get("/projects/:name/gbp/local-post-attempt", async (request) => {
|
|
43613
|
+
requireAdminSession(request);
|
|
43614
|
+
requireScope(request, GBP_LIVE_READ_SCOPE);
|
|
43615
|
+
const project = resolveProject(app.db, request.params.name);
|
|
43616
|
+
const { attemptId, packageId } = request.query;
|
|
43617
|
+
if (!attemptId || !/^[a-f0-9-]{36}$/u.test(attemptId) || !packageId || !/^[a-f0-9]{64}$/u.test(packageId))
|
|
43618
|
+
throw validationError(
|
|
43619
|
+
"Exact attempt and package identities are required."
|
|
43620
|
+
);
|
|
43621
|
+
const key = `gbp-post:${digest([project.id, attemptId])}`;
|
|
43622
|
+
const claim = app.db.select().from(auditLog).where(and51(eq62(auditLog.id, key), eq62(auditLog.projectId, project.id))).get();
|
|
43623
|
+
if (!claim?.diff)
|
|
43624
|
+
throw validationError(
|
|
43625
|
+
"No saved GBP attempt is available; do not resubmit."
|
|
43626
|
+
);
|
|
43627
|
+
const binding = JSON.parse(claim.diff);
|
|
43628
|
+
if (binding.packageId !== packageId)
|
|
43629
|
+
throw validationError("GBP attempt package mismatch.");
|
|
43630
|
+
const result = app.db.select().from(auditLog).where(eq62(auditLog.id, `${key}:result`)).get();
|
|
43631
|
+
return result?.diff ? gbpLocalPostAttemptSchema.parse(JSON.parse(result.diff)) : { attemptId, packageId, status: "uncertain", post: null };
|
|
43632
|
+
});
|
|
43633
|
+
app.post(
|
|
43634
|
+
"/projects/:name/gbp/local-posts",
|
|
43635
|
+
{ config: { writeScope: GBP_POSTS_WRITE_SCOPE } },
|
|
43636
|
+
async (request) => {
|
|
43637
|
+
requireAdminSession(request);
|
|
43638
|
+
requireScope(request, GBP_POSTS_WRITE_SCOPE);
|
|
43639
|
+
const project = resolveProject(app.db, request.params.name);
|
|
43640
|
+
const parsed = gbpLocalPostCreateSchema.safeParse(request.body);
|
|
43641
|
+
if (!parsed.success)
|
|
43642
|
+
throw validationError(
|
|
43643
|
+
"A bounded STANDARD article post and exact attempt/package binding are required."
|
|
43644
|
+
);
|
|
43645
|
+
const body = parsed.data;
|
|
43646
|
+
selected(project.id, body.accountName, body.locationName);
|
|
43647
|
+
if (!await hotelEditorialDestination(
|
|
43648
|
+
project.canonicalDomain,
|
|
43649
|
+
body.content.summary,
|
|
43650
|
+
body.content.callToAction.url
|
|
43651
|
+
))
|
|
43652
|
+
throw forbidden(
|
|
43653
|
+
"Updates and their linked page must be editorial, without offers, deals or promotions. Unavailable checks do not authorize a post."
|
|
43654
|
+
);
|
|
43655
|
+
const key = `gbp-post:${digest([project.id, body.attemptId])}`;
|
|
43656
|
+
const payload = digest(body);
|
|
43657
|
+
const existing = app.db.select().from(auditLog).where(eq62(auditLog.id, key)).get();
|
|
43658
|
+
const readResult = () => {
|
|
43659
|
+
const result2 = app.db.select().from(auditLog).where(eq62(auditLog.id, `${key}:result`)).get();
|
|
43660
|
+
return result2?.diff ? gbpLocalPostAttemptSchema.parse(JSON.parse(result2.diff)) : {
|
|
43661
|
+
attemptId: body.attemptId,
|
|
43662
|
+
packageId: body.packageId,
|
|
43663
|
+
status: "uncertain",
|
|
43664
|
+
post: null
|
|
43665
|
+
};
|
|
43666
|
+
};
|
|
43667
|
+
const answerExisting = (claimed) => {
|
|
43668
|
+
const binding = JSON.parse(claimed.diff ?? "null");
|
|
43669
|
+
if (claimed.projectId !== project.id || binding?.requestDigest !== payload)
|
|
43670
|
+
throw validationError(
|
|
43671
|
+
"GBP attempt identity was already used with different content."
|
|
43672
|
+
);
|
|
43673
|
+
return readResult();
|
|
43674
|
+
};
|
|
43675
|
+
if (existing) return answerExisting(existing);
|
|
43676
|
+
const token = await options.token(project.canonicalDomain);
|
|
43677
|
+
const currentProject = resolveProject(app.db, request.params.name);
|
|
43678
|
+
if (currentProject.id !== project.id || currentProject.canonicalDomain !== project.canonicalDomain)
|
|
43679
|
+
throw forbidden("GBP project changed during preflight; prepare a new request.");
|
|
43680
|
+
selected(currentProject.id, body.accountName, body.locationName);
|
|
43681
|
+
const claim = claimAuditLog(app.db, key, {
|
|
43682
|
+
projectId: project.id,
|
|
43683
|
+
actor: "api",
|
|
43684
|
+
action: "gbp.local-post-claimed",
|
|
43685
|
+
entityType: "gbp-local-post",
|
|
43686
|
+
entityId: body.attemptId,
|
|
43687
|
+
diff: {
|
|
43688
|
+
requestDigest: payload,
|
|
43689
|
+
packageId: body.packageId,
|
|
43690
|
+
accountName: body.accountName,
|
|
43691
|
+
locationName: body.locationName
|
|
43692
|
+
}
|
|
43693
|
+
});
|
|
43694
|
+
if (!claim) {
|
|
43695
|
+
const winner = app.db.select().from(auditLog).where(eq62(auditLog.id, key)).get();
|
|
43696
|
+
if (!winner) return readResult();
|
|
43697
|
+
return answerExisting(winner);
|
|
43698
|
+
}
|
|
43699
|
+
let post2 = null;
|
|
43700
|
+
let status = "uncertain";
|
|
43701
|
+
try {
|
|
43702
|
+
post2 = await createLocalPost(
|
|
43703
|
+
token,
|
|
43704
|
+
body.accountName,
|
|
43705
|
+
body.locationName,
|
|
43706
|
+
body.content
|
|
43707
|
+
);
|
|
43708
|
+
status = "accepted";
|
|
43709
|
+
} catch (error) {
|
|
43710
|
+
if (error instanceof GbpApiError && [400, 401, 403, 404, 422].includes(error.status))
|
|
43711
|
+
status = "rejected";
|
|
43712
|
+
}
|
|
43713
|
+
const result = {
|
|
43714
|
+
attemptId: body.attemptId,
|
|
43715
|
+
packageId: body.packageId,
|
|
43716
|
+
status,
|
|
43717
|
+
post: post2
|
|
43718
|
+
};
|
|
43719
|
+
claimAuditLog(app.db, `${key}:result`, {
|
|
43720
|
+
projectId: project.id,
|
|
43721
|
+
actor: "api",
|
|
43722
|
+
action: "gbp.local-post-result",
|
|
43723
|
+
entityType: "gbp-local-post",
|
|
43724
|
+
entityId: body.attemptId,
|
|
43725
|
+
diff: result
|
|
43726
|
+
});
|
|
43727
|
+
return result;
|
|
43650
43728
|
}
|
|
43651
|
-
|
|
43652
|
-
throw new GoogleApiError("URL must be a valid URL", 400);
|
|
43653
|
-
}
|
|
43729
|
+
);
|
|
43654
43730
|
}
|
|
43655
|
-
|
|
43656
|
-
|
|
43657
|
-
|
|
43658
|
-
|
|
43659
|
-
|
|
43660
|
-
|
|
43661
|
-
|
|
43662
|
-
|
|
43663
|
-
|
|
43664
|
-
|
|
43665
|
-
|
|
43731
|
+
|
|
43732
|
+
// ../api-routes/src/google.ts
|
|
43733
|
+
import { eq as eq64, and as and52, desc as desc29, sql as sql19, inArray as inArray30 } from "drizzle-orm";
|
|
43734
|
+
|
|
43735
|
+
// ../api-routes/src/gsc-period-comparison.ts
|
|
43736
|
+
var DAY_MS = 864e5;
|
|
43737
|
+
function calendarDateMs(value) {
|
|
43738
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) return null;
|
|
43739
|
+
const parsed = /* @__PURE__ */ new Date(`${value}T00:00:00Z`);
|
|
43740
|
+
if (Number.isNaN(parsed.getTime()) || parsed.toISOString().slice(0, 10) !== value) return null;
|
|
43741
|
+
return parsed.getTime();
|
|
43666
43742
|
}
|
|
43667
|
-
function
|
|
43668
|
-
|
|
43669
|
-
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
43670
|
-
level,
|
|
43671
|
-
module: "GscClient",
|
|
43672
|
-
action,
|
|
43673
|
-
...ctx
|
|
43674
|
-
};
|
|
43675
|
-
if (entry.accessToken) entry.accessToken = "***";
|
|
43676
|
-
if (typeof entry.siteUrl === "string") {
|
|
43677
|
-
try {
|
|
43678
|
-
const url = new URL(entry.siteUrl);
|
|
43679
|
-
if (url.search) {
|
|
43680
|
-
url.searchParams.forEach((_, key) => {
|
|
43681
|
-
if (key.toLowerCase().includes("token") || key.toLowerCase().includes("key") || key.toLowerCase().includes("auth")) {
|
|
43682
|
-
url.searchParams.set(key, "***");
|
|
43683
|
-
}
|
|
43684
|
-
});
|
|
43685
|
-
entry.siteUrl = url.toString();
|
|
43686
|
-
}
|
|
43687
|
-
} catch {
|
|
43688
|
-
}
|
|
43689
|
-
}
|
|
43690
|
-
const stream = level === "error" ? process.stderr : process.stdout;
|
|
43691
|
-
stream.write(JSON.stringify(entry) + "\n");
|
|
43743
|
+
function calendarDateAt(ms) {
|
|
43744
|
+
return new Date(ms).toISOString().slice(0, 10);
|
|
43692
43745
|
}
|
|
43693
|
-
function
|
|
43694
|
-
|
|
43746
|
+
function relativeChange(trailing, prior) {
|
|
43747
|
+
if (trailing === null || prior === null) return null;
|
|
43748
|
+
if (!Number.isFinite(trailing) || !Number.isFinite(prior)) return null;
|
|
43749
|
+
if (prior <= 0) return null;
|
|
43750
|
+
return (trailing - prior) / prior;
|
|
43695
43751
|
}
|
|
43696
|
-
|
|
43697
|
-
|
|
43698
|
-
|
|
43699
|
-
|
|
43700
|
-
|
|
43701
|
-
|
|
43702
|
-
let
|
|
43703
|
-
|
|
43704
|
-
|
|
43705
|
-
|
|
43706
|
-
|
|
43707
|
-
|
|
43708
|
-
|
|
43709
|
-
|
|
43710
|
-
|
|
43711
|
-
|
|
43712
|
-
}
|
|
43713
|
-
if (res.status === 401) {
|
|
43714
|
-
gscClientLog("error", "http.auth-expired", { url, method, httpStatus: 401 });
|
|
43715
|
-
throw new GoogleApiError("Access token expired or revoked", 401);
|
|
43716
|
-
}
|
|
43717
|
-
if (res.status === 429) {
|
|
43718
|
-
gscClientLog("error", "http.rate-limited", { url, method, httpStatus: 429 });
|
|
43719
|
-
throw new GoogleApiError("Google API rate limit exceeded", 429);
|
|
43720
|
-
}
|
|
43721
|
-
if (!res.ok) {
|
|
43722
|
-
const body = await res.text();
|
|
43723
|
-
gscClientLog("error", "http.error", { url, method, httpStatus: res.status });
|
|
43724
|
-
const detail = body.length <= 500 ? body : `${body.slice(0, 500)}... [truncated]`;
|
|
43725
|
-
let sanitizedDetail = detail;
|
|
43726
|
-
if (accessToken) {
|
|
43727
|
-
sanitizedDetail = sanitizedDetail.replace(new RegExp(escapeRegExp3(accessToken), "g"), "***");
|
|
43752
|
+
function aggregate(startDate, endDate, byDate) {
|
|
43753
|
+
let clicks = 0;
|
|
43754
|
+
let impressions = 0;
|
|
43755
|
+
let positionWeight = 0;
|
|
43756
|
+
let positionWeighted = 0;
|
|
43757
|
+
let propertyDays = 0;
|
|
43758
|
+
let dimensionedDays = 0;
|
|
43759
|
+
for (const row of byDate.values()) {
|
|
43760
|
+
if (row.date < startDate || row.date > endDate) continue;
|
|
43761
|
+
if (row.fromPropertyTotals) propertyDays += 1;
|
|
43762
|
+
else dimensionedDays += 1;
|
|
43763
|
+
clicks += row.clicks;
|
|
43764
|
+
impressions += row.impressions;
|
|
43765
|
+
if (row.position !== null && row.impressions > 0) {
|
|
43766
|
+
positionWeight += row.impressions;
|
|
43767
|
+
positionWeighted += row.position * row.impressions;
|
|
43728
43768
|
}
|
|
43729
|
-
throw new GoogleApiError(`GSC API error (${res.status}): ${sanitizedDetail}`, res.status);
|
|
43730
43769
|
}
|
|
43731
|
-
return
|
|
43770
|
+
return {
|
|
43771
|
+
startDate,
|
|
43772
|
+
endDate,
|
|
43773
|
+
clicks,
|
|
43774
|
+
impressions,
|
|
43775
|
+
// CTR is a ratio of the period's own totals. Averaging the daily ratios
|
|
43776
|
+
// instead would weight a 1-impression day equally with a 1000-impression
|
|
43777
|
+
// one and would not reconcile with the clicks and impressions beside it.
|
|
43778
|
+
ctr: impressions > 0 ? clicks / impressions : null,
|
|
43779
|
+
position: positionWeight > 0 ? positionWeighted / positionWeight : null,
|
|
43780
|
+
// Empty is its own provenance. It is a real zero-count period, not evidence
|
|
43781
|
+
// from the invalid-for-totals dimensioned table.
|
|
43782
|
+
source: propertyDays > 0 && dimensionedDays > 0 ? "mixed" : propertyDays > 0 ? "property-daily" : dimensionedDays > 0 ? "dimensioned" : "empty"
|
|
43783
|
+
};
|
|
43732
43784
|
}
|
|
43733
|
-
|
|
43734
|
-
const
|
|
43735
|
-
const
|
|
43736
|
-
if (!
|
|
43737
|
-
|
|
43738
|
-
|
|
43739
|
-
|
|
43740
|
-
|
|
43741
|
-
|
|
43742
|
-
|
|
43743
|
-
|
|
43785
|
+
function computeGscPeriodComparison(daily, bounds) {
|
|
43786
|
+
const first = bounds?.startDate ?? daily[0]?.date;
|
|
43787
|
+
const last = bounds?.endDate ?? daily[daily.length - 1]?.date;
|
|
43788
|
+
if (!first || !last) return null;
|
|
43789
|
+
const firstMs = calendarDateMs(first);
|
|
43790
|
+
const lastMs = calendarDateMs(last);
|
|
43791
|
+
if (firstMs === null || lastMs === null || firstMs > lastMs) return null;
|
|
43792
|
+
const spanDays = Math.floor((lastMs - firstMs) / DAY_MS) + 1;
|
|
43793
|
+
const periodDays = Math.floor(spanDays / 2);
|
|
43794
|
+
if (periodDays < 1) return null;
|
|
43795
|
+
const byDate = new Map(daily.map((row) => [row.date, row]));
|
|
43796
|
+
const trailingStart = calendarDateAt(lastMs - (periodDays - 1) * DAY_MS);
|
|
43797
|
+
const priorEnd = calendarDateAt(lastMs - periodDays * DAY_MS);
|
|
43798
|
+
const priorStart = calendarDateAt(lastMs - (periodDays * 2 - 1) * DAY_MS);
|
|
43799
|
+
const prior = aggregate(priorStart, priorEnd, byDate);
|
|
43800
|
+
const trailing = aggregate(trailingStart, last, byDate);
|
|
43801
|
+
if (prior.source === "empty" && trailing.source === "empty") return null;
|
|
43802
|
+
const comparable = prior.source !== "dimensioned" && prior.source !== "mixed" && trailing.source !== "dimensioned" && trailing.source !== "mixed";
|
|
43803
|
+
return {
|
|
43804
|
+
days: periodDays,
|
|
43805
|
+
basis: bounds?.basis ?? "split-window",
|
|
43806
|
+
prior,
|
|
43807
|
+
trailing,
|
|
43808
|
+
comparable,
|
|
43809
|
+
change: {
|
|
43810
|
+
clicks: comparable ? relativeChange(trailing.clicks, prior.clicks) : null,
|
|
43811
|
+
impressions: comparable ? relativeChange(trailing.impressions, prior.impressions) : null,
|
|
43812
|
+
ctr: comparable ? relativeChange(trailing.ctr, prior.ctr) : null,
|
|
43813
|
+
position: comparable ? relativeChange(trailing.position, prior.position) : null
|
|
43814
|
+
}
|
|
43815
|
+
};
|
|
43744
43816
|
}
|
|
43745
|
-
|
|
43746
|
-
|
|
43747
|
-
|
|
43748
|
-
|
|
43749
|
-
|
|
43750
|
-
);
|
|
43751
|
-
return
|
|
43817
|
+
|
|
43818
|
+
// ../api-routes/src/ga-property-data.ts
|
|
43819
|
+
import { eq as eq63 } from "drizzle-orm";
|
|
43820
|
+
function resolveCurrentGa4PropertyId(stores, projectName, canonicalDomain) {
|
|
43821
|
+
const serviceAccount = stores.ga4CredentialStore?.getConnection(projectName);
|
|
43822
|
+
if (serviceAccount?.propertyId) return serviceAccount.propertyId;
|
|
43823
|
+
return stores.googleConnectionStore?.getConnection(canonicalDomain, "ga4")?.propertyId ?? null;
|
|
43752
43824
|
}
|
|
43753
|
-
|
|
43754
|
-
|
|
43755
|
-
|
|
43756
|
-
|
|
43757
|
-
|
|
43758
|
-
|
|
43759
|
-
|
|
43760
|
-
|
|
43761
|
-
|
|
43762
|
-
|
|
43763
|
-
|
|
43825
|
+
var GA_PROPERTY_TABLES = [
|
|
43826
|
+
gaTrafficSnapshots,
|
|
43827
|
+
gaTrafficSummaries,
|
|
43828
|
+
gaTrafficWindowSummaries,
|
|
43829
|
+
gaWindowMetrics,
|
|
43830
|
+
gaDailyTotals,
|
|
43831
|
+
gaAiReferrals,
|
|
43832
|
+
gaSocialReferrals,
|
|
43833
|
+
gaAcquisitionDaily,
|
|
43834
|
+
gaLeadEventsDaily,
|
|
43835
|
+
gaSearchLandingPages,
|
|
43836
|
+
gaSearchLandingWindows,
|
|
43837
|
+
gaMeasurementSyncStates
|
|
43838
|
+
];
|
|
43839
|
+
function clearGaPropertyData(tx, projectId) {
|
|
43840
|
+
let deleted = 0;
|
|
43841
|
+
for (const table of GA_PROPERTY_TABLES) {
|
|
43842
|
+
deleted += tx.delete(table).where(eq63(table.projectId, projectId)).run().changes;
|
|
43843
|
+
}
|
|
43844
|
+
return deleted;
|
|
43764
43845
|
}
|
|
43765
|
-
|
|
43766
|
-
|
|
43767
|
-
validateSiteUrl(siteUrl);
|
|
43768
|
-
validateUrl(sitemapUrl);
|
|
43769
|
-
await gscFetchResponse(
|
|
43770
|
-
accessToken,
|
|
43771
|
-
`${GSC_API_BASE}/sites/${encodeURIComponent(siteUrl)}/sitemaps/${encodeURIComponent(sitemapUrl)}`,
|
|
43772
|
-
{ method: "PUT" }
|
|
43773
|
-
);
|
|
43846
|
+
function projectsSharingGa4Connection(db, canonicalDomain) {
|
|
43847
|
+
return db.select({ id: projects.id, name: projects.name, canonicalDomain: projects.canonicalDomain }).from(projects).where(eq63(projects.canonicalDomain, canonicalDomain)).all();
|
|
43774
43848
|
}
|
|
43775
|
-
|
|
43776
|
-
|
|
43777
|
-
|
|
43778
|
-
|
|
43779
|
-
|
|
43780
|
-
|
|
43781
|
-
|
|
43782
|
-
const
|
|
43783
|
-
|
|
43784
|
-
|
|
43785
|
-
|
|
43786
|
-
|
|
43787
|
-
|
|
43788
|
-
|
|
43789
|
-
|
|
43790
|
-
|
|
43791
|
-
|
|
43792
|
-
|
|
43793
|
-
|
|
43794
|
-
|
|
43795
|
-
|
|
43796
|
-
const filters = [];
|
|
43797
|
-
const filterList = [];
|
|
43798
|
-
if (opts.query) filterList.push({ dimension: "query", operator: "contains", expression: opts.query });
|
|
43799
|
-
if (opts.page) filterList.push({ dimension: "page", operator: "contains", expression: opts.page });
|
|
43800
|
-
filters.push({ filters: filterList });
|
|
43801
|
-
requestBody.dimensionFilterGroups = filters;
|
|
43802
|
-
}
|
|
43803
|
-
const encodedSiteUrl = encodeURIComponent(siteUrl);
|
|
43804
|
-
const data = await gscFetchJson(
|
|
43805
|
-
accessToken,
|
|
43806
|
-
`${GSC_API_BASE}/sites/${encodedSiteUrl}/searchAnalytics/query`,
|
|
43807
|
-
{ method: "POST", body: requestBody }
|
|
43808
|
-
);
|
|
43809
|
-
const rows = data.rows ?? [];
|
|
43810
|
-
allRows.push(...rows);
|
|
43811
|
-
if (rows.length < GSC_MAX_ROWS_PER_REQUEST) {
|
|
43812
|
-
break;
|
|
43813
|
-
}
|
|
43814
|
-
startRow += rows.length;
|
|
43849
|
+
function readGa4Properties(stores, gaProjects) {
|
|
43850
|
+
return gaProjects.map((project) => ({
|
|
43851
|
+
project,
|
|
43852
|
+
propertyId: resolveCurrentGa4PropertyId(stores, project.name, project.canonicalDomain)
|
|
43853
|
+
}));
|
|
43854
|
+
}
|
|
43855
|
+
function clearGaDataOnPropertyChange(tx, stores, before, actor = "api") {
|
|
43856
|
+
for (const { project, propertyId: previousPropertyId } of before) {
|
|
43857
|
+
const propertyId = resolveCurrentGa4PropertyId(stores, project.name, project.canonicalDomain);
|
|
43858
|
+
const moved = previousPropertyId !== null && previousPropertyId !== propertyId;
|
|
43859
|
+
const snapshotOfAnotherProperty = !moved && tx.selectDistinct({ propertyId: gaSearchLandingWindows.propertyId }).from(gaSearchLandingWindows).where(eq63(gaSearchLandingWindows.projectId, project.id)).all().some((stored) => stored.propertyId !== propertyId);
|
|
43860
|
+
if (!moved && !snapshotOfAnotherProperty) continue;
|
|
43861
|
+
if (clearGaPropertyData(tx, project.id) === 0) continue;
|
|
43862
|
+
writeAuditLog(tx, {
|
|
43863
|
+
projectId: project.id,
|
|
43864
|
+
actor,
|
|
43865
|
+
action: "ga4.data-cleared",
|
|
43866
|
+
entityType: "ga_connection",
|
|
43867
|
+
entityId: propertyId,
|
|
43868
|
+
diff: { previousPropertyId, propertyId }
|
|
43869
|
+
});
|
|
43815
43870
|
}
|
|
43816
|
-
return allRows;
|
|
43817
43871
|
}
|
|
43818
|
-
|
|
43819
|
-
|
|
43820
|
-
|
|
43821
|
-
|
|
43822
|
-
|
|
43823
|
-
|
|
43824
|
-
{
|
|
43825
|
-
method: "POST",
|
|
43826
|
-
body: { url, type }
|
|
43827
|
-
}
|
|
43828
|
-
);
|
|
43872
|
+
|
|
43873
|
+
// ../api-routes/src/google-oauth-state.ts
|
|
43874
|
+
import crypto34 from "crypto";
|
|
43875
|
+
var GOOGLE_OAUTH_STATE_MAX_AGE_MS = 15 * 60 * 1e3;
|
|
43876
|
+
function signState(payload, secret) {
|
|
43877
|
+
return crypto34.createHmac("sha256", secret).update(payload).digest("hex");
|
|
43829
43878
|
}
|
|
43830
|
-
|
|
43831
|
-
|
|
43832
|
-
|
|
43833
|
-
|
|
43834
|
-
|
|
43835
|
-
|
|
43836
|
-
|
|
43837
|
-
|
|
43838
|
-
|
|
43839
|
-
|
|
43840
|
-
|
|
43841
|
-
|
|
43842
|
-
|
|
43843
|
-
|
|
43844
|
-
|
|
43879
|
+
function buildSignedGoogleOAuthState(data, secret, nowMs = Date.now()) {
|
|
43880
|
+
const payload = JSON.stringify({ ...data, issuedAt: nowMs });
|
|
43881
|
+
const sig = signState(payload, secret);
|
|
43882
|
+
return Buffer.from(JSON.stringify({ payload, sig })).toString("base64url");
|
|
43883
|
+
}
|
|
43884
|
+
function verifySignedGoogleOAuthState(encoded, secret, nowMs = Date.now()) {
|
|
43885
|
+
try {
|
|
43886
|
+
if (!/^[\w-]+$/.test(encoded)) return null;
|
|
43887
|
+
const decoded = Buffer.from(encoded, "base64url");
|
|
43888
|
+
if (decoded.toString("base64url") !== encoded) return null;
|
|
43889
|
+
const parsedEnvelope = JSON.parse(decoded.toString());
|
|
43890
|
+
if (typeof parsedEnvelope.payload !== "string" || typeof parsedEnvelope.sig !== "string") return null;
|
|
43891
|
+
if (!/^[a-f0-9]{64}$/.test(parsedEnvelope.sig)) return null;
|
|
43892
|
+
const expected = signState(parsedEnvelope.payload, secret);
|
|
43893
|
+
const actualBuffer = Buffer.from(parsedEnvelope.sig, "hex");
|
|
43894
|
+
const expectedBuffer = Buffer.from(expected, "hex");
|
|
43895
|
+
if (actualBuffer.length !== expectedBuffer.length) return null;
|
|
43896
|
+
if (!crypto34.timingSafeEqual(actualBuffer, expectedBuffer)) return null;
|
|
43897
|
+
const parsed = JSON.parse(parsedEnvelope.payload);
|
|
43898
|
+
const issuedAt = typeof parsed.issuedAt === "number" ? parsed.issuedAt : null;
|
|
43899
|
+
if (issuedAt === null || issuedAt > nowMs || nowMs - issuedAt > GOOGLE_OAUTH_STATE_MAX_AGE_MS) return null;
|
|
43900
|
+
return parsed;
|
|
43901
|
+
} catch {
|
|
43902
|
+
return null;
|
|
43903
|
+
}
|
|
43845
43904
|
}
|
|
43846
43905
|
|
|
43847
43906
|
// ../integration-google-analytics/src/ga4-client.ts
|
|
@@ -72974,14 +73033,6 @@ export {
|
|
|
72974
73033
|
hashAttributes,
|
|
72975
73034
|
listReviews,
|
|
72976
73035
|
classifyReviewsError,
|
|
72977
|
-
EgressRefusedError,
|
|
72978
|
-
EgressFailedError,
|
|
72979
|
-
createGuardedFetch,
|
|
72980
|
-
getPlaceDetails,
|
|
72981
|
-
hashPlaceDetails,
|
|
72982
|
-
extractPlaceAmenities,
|
|
72983
|
-
getPlaceReviewSignals,
|
|
72984
|
-
buildGbpSummary,
|
|
72985
73036
|
GSC_REPORTING_TIME_ZONE,
|
|
72986
73037
|
GSC_DATA_LAG_DAYS,
|
|
72987
73038
|
GoogleAuthError,
|
|
@@ -72991,6 +73042,14 @@ export {
|
|
|
72991
73042
|
refreshAccessToken,
|
|
72992
73043
|
fetchSearchAnalytics,
|
|
72993
73044
|
inspectUrl,
|
|
73045
|
+
EgressRefusedError,
|
|
73046
|
+
EgressFailedError,
|
|
73047
|
+
createGuardedFetch,
|
|
73048
|
+
getPlaceDetails,
|
|
73049
|
+
hashPlaceDetails,
|
|
73050
|
+
extractPlaceAmenities,
|
|
73051
|
+
getPlaceReviewSignals,
|
|
73052
|
+
buildGbpSummary,
|
|
72994
73053
|
BingApiError,
|
|
72995
73054
|
getUrlInfo,
|
|
72996
73055
|
getCrawlIssues,
|