@exabugs/dynamodb-client 1.3.29 → 1.3.31
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/CHANGELOG.md +14 -1076
- package/dist/integrations/react-admin/components/ReferenceManyToManyField.d.ts.map +1 -1
- package/dist/integrations/react-admin/components/ReferenceManyToManyField.js +3 -1
- package/dist/integrations/react-admin/components/ReferenceManyToManyField.js.map +1 -1
- package/dist/server/handler.cjs +2644 -1323
- package/dist/server/handler.cjs.map +4 -4
- package/dist/server/handler.d.ts +1 -1
- package/dist/server/handler.js +1 -1
- package/dist/server/operations/deleteMany.d.ts +6 -5
- package/dist/server/operations/deleteMany.d.ts.map +1 -1
- package/dist/server/operations/deleteMany.js +34 -11
- package/dist/server/operations/deleteMany.js.map +1 -1
- package/dist/server/operations/deleteOne.d.ts +4 -3
- package/dist/server/operations/deleteOne.d.ts.map +1 -1
- package/dist/server/operations/deleteOne.js +38 -13
- package/dist/server/operations/deleteOne.js.map +1 -1
- package/dist/server/operations/updateMany.d.ts +8 -7
- package/dist/server/operations/updateMany.d.ts.map +1 -1
- package/dist/server/operations/updateMany.js +37 -13
- package/dist/server/operations/updateMany.js.map +1 -1
- package/dist/server/operations/updateOne.d.ts +1 -1
- package/dist/server/operations/updateOne.d.ts.map +1 -1
- package/dist/server/operations/updateOne.js +73 -24
- package/dist/server/operations/updateOne.js.map +1 -1
- package/dist/server/types.d.ts +26 -16
- package/dist/server/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/server/handler.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// @exabugs/dynamodb-client v1.3.
|
|
2
|
-
// Built: 2026-01-
|
|
1
|
+
// @exabugs/dynamodb-client v1.3.31
|
|
2
|
+
// Built: 2026-01-08T06:32:12.170Z
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
@@ -36,6 +36,446 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
36
36
|
));
|
|
37
37
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
38
|
|
|
39
|
+
// src/shared/constants/http.ts
|
|
40
|
+
var DEFAULT_HTTP_TIMEOUT_MS, HTTP_STATUS, HTTP_METHOD;
|
|
41
|
+
var init_http = __esm({
|
|
42
|
+
"src/shared/constants/http.ts"() {
|
|
43
|
+
"use strict";
|
|
44
|
+
DEFAULT_HTTP_TIMEOUT_MS = 3e4;
|
|
45
|
+
HTTP_STATUS = {
|
|
46
|
+
OK: 200,
|
|
47
|
+
BAD_REQUEST: 400,
|
|
48
|
+
UNAUTHORIZED: 401,
|
|
49
|
+
FORBIDDEN: 403,
|
|
50
|
+
NOT_FOUND: 404,
|
|
51
|
+
METHOD_NOT_ALLOWED: 405,
|
|
52
|
+
INTERNAL_SERVER_ERROR: 500,
|
|
53
|
+
NOT_IMPLEMENTED: 501
|
|
54
|
+
};
|
|
55
|
+
HTTP_METHOD = {
|
|
56
|
+
GET: "GET",
|
|
57
|
+
POST: "POST",
|
|
58
|
+
PUT: "PUT",
|
|
59
|
+
DELETE: "DELETE",
|
|
60
|
+
OPTIONS: "OPTIONS"
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// src/shared/types/index.ts
|
|
66
|
+
var init_types = __esm({
|
|
67
|
+
"src/shared/types/index.ts"() {
|
|
68
|
+
"use strict";
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// src/shared/errors/index.ts
|
|
73
|
+
function isAppError(error2) {
|
|
74
|
+
return error2 instanceof AppError;
|
|
75
|
+
}
|
|
76
|
+
function getErrorClass(code) {
|
|
77
|
+
switch (code) {
|
|
78
|
+
case "AUTH_ERROR" /* AUTH_ERROR */:
|
|
79
|
+
return AuthError;
|
|
80
|
+
case "CONFIG_ERROR" /* CONFIG_ERROR */:
|
|
81
|
+
return ConfigError;
|
|
82
|
+
case "INVALID_FILTER" /* INVALID_FILTER */:
|
|
83
|
+
return InvalidFilterError;
|
|
84
|
+
case "INVALID_TOKEN" /* INVALID_TOKEN */:
|
|
85
|
+
return InvalidTokenError;
|
|
86
|
+
case "ITEM_NOT_FOUND" /* ITEM_NOT_FOUND */:
|
|
87
|
+
return ItemNotFoundError;
|
|
88
|
+
case "VERSION_CONFLICT" /* VERSION_CONFLICT */:
|
|
89
|
+
return VersionConflictError;
|
|
90
|
+
default:
|
|
91
|
+
return AppError;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
var ErrorCode, AppError, AuthError, ConfigError, InvalidFilterError, InvalidTokenError, ItemNotFoundError, PartialFailureError, VersionConflictError;
|
|
95
|
+
var init_errors = __esm({
|
|
96
|
+
"src/shared/errors/index.ts"() {
|
|
97
|
+
"use strict";
|
|
98
|
+
ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
|
|
99
|
+
ErrorCode2["AUTH_ERROR"] = "AUTH_ERROR";
|
|
100
|
+
ErrorCode2["CONFIG_ERROR"] = "CONFIG_ERROR";
|
|
101
|
+
ErrorCode2["INVALID_FILTER"] = "INVALID_FILTER";
|
|
102
|
+
ErrorCode2["INVALID_TOKEN"] = "INVALID_TOKEN";
|
|
103
|
+
ErrorCode2["ITEM_NOT_FOUND"] = "ITEM_NOT_FOUND";
|
|
104
|
+
ErrorCode2["PARTIAL_FAILURE"] = "PARTIAL_FAILURE";
|
|
105
|
+
ErrorCode2["VERSION_CONFLICT"] = "VERSION_CONFLICT";
|
|
106
|
+
ErrorCode2["VALIDATION_ERROR"] = "VALIDATION_ERROR";
|
|
107
|
+
ErrorCode2["INTERNAL_ERROR"] = "INTERNAL_ERROR";
|
|
108
|
+
ErrorCode2["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED";
|
|
109
|
+
ErrorCode2["INVALID_OPERATION"] = "INVALID_OPERATION";
|
|
110
|
+
ErrorCode2["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
|
111
|
+
return ErrorCode2;
|
|
112
|
+
})(ErrorCode || {});
|
|
113
|
+
AppError = class extends Error {
|
|
114
|
+
constructor(code, message, statusCode = 500, details) {
|
|
115
|
+
super(message);
|
|
116
|
+
this.code = code;
|
|
117
|
+
this.statusCode = statusCode;
|
|
118
|
+
this.details = details;
|
|
119
|
+
this.name = this.constructor.name;
|
|
120
|
+
Error.captureStackTrace(this, this.constructor);
|
|
121
|
+
}
|
|
122
|
+
static {
|
|
123
|
+
__name(this, "AppError");
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* エラーをJSON形式に変換
|
|
127
|
+
*/
|
|
128
|
+
toJSON() {
|
|
129
|
+
return {
|
|
130
|
+
code: this.code,
|
|
131
|
+
message: this.message,
|
|
132
|
+
statusCode: this.statusCode,
|
|
133
|
+
...this.details && { details: this.details }
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
AuthError = class extends AppError {
|
|
138
|
+
static {
|
|
139
|
+
__name(this, "AuthError");
|
|
140
|
+
}
|
|
141
|
+
constructor(message, details) {
|
|
142
|
+
super("AUTH_ERROR" /* AUTH_ERROR */, message, 401, details);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
ConfigError = class extends AppError {
|
|
146
|
+
static {
|
|
147
|
+
__name(this, "ConfigError");
|
|
148
|
+
}
|
|
149
|
+
constructor(message, details) {
|
|
150
|
+
super("CONFIG_ERROR" /* CONFIG_ERROR */, message, 500, details);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
InvalidFilterError = class extends AppError {
|
|
154
|
+
static {
|
|
155
|
+
__name(this, "InvalidFilterError");
|
|
156
|
+
}
|
|
157
|
+
constructor(message, details) {
|
|
158
|
+
super("INVALID_FILTER" /* INVALID_FILTER */, message, 400, details);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
InvalidTokenError = class extends AppError {
|
|
162
|
+
static {
|
|
163
|
+
__name(this, "InvalidTokenError");
|
|
164
|
+
}
|
|
165
|
+
constructor(message, details) {
|
|
166
|
+
super("INVALID_TOKEN" /* INVALID_TOKEN */, message, 400, details);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
ItemNotFoundError = class extends AppError {
|
|
170
|
+
static {
|
|
171
|
+
__name(this, "ItemNotFoundError");
|
|
172
|
+
}
|
|
173
|
+
constructor(message, details) {
|
|
174
|
+
super("ITEM_NOT_FOUND" /* ITEM_NOT_FOUND */, message, 404, details);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
PartialFailureError = class extends AppError {
|
|
178
|
+
constructor(message, failedIds, errors, details) {
|
|
179
|
+
super("PARTIAL_FAILURE" /* PARTIAL_FAILURE */, message, 207, {
|
|
180
|
+
...details,
|
|
181
|
+
failedIds,
|
|
182
|
+
errors
|
|
183
|
+
});
|
|
184
|
+
this.failedIds = failedIds;
|
|
185
|
+
this.errors = errors;
|
|
186
|
+
}
|
|
187
|
+
static {
|
|
188
|
+
__name(this, "PartialFailureError");
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
VersionConflictError = class extends AppError {
|
|
192
|
+
static {
|
|
193
|
+
__name(this, "VersionConflictError");
|
|
194
|
+
}
|
|
195
|
+
constructor(message, details) {
|
|
196
|
+
super("VERSION_CONFLICT" /* VERSION_CONFLICT */, message, 409, details);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
__name(isAppError, "isAppError");
|
|
200
|
+
__name(getErrorClass, "getErrorClass");
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
// src/shared/utils/logger.ts
|
|
205
|
+
function createLogger(config = {}) {
|
|
206
|
+
const {
|
|
207
|
+
level = process.env.LOG_LEVEL || "info",
|
|
208
|
+
service = process.env.SERVICE_NAME,
|
|
209
|
+
env = process.env.ENV
|
|
210
|
+
} = config;
|
|
211
|
+
const minLevel = LOG_LEVELS[level];
|
|
212
|
+
function log(logLevel, message, metadata) {
|
|
213
|
+
if (LOG_LEVELS[logLevel] < minLevel) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const logEntry = {
|
|
217
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
218
|
+
level: logLevel,
|
|
219
|
+
message
|
|
220
|
+
};
|
|
221
|
+
if (service) {
|
|
222
|
+
logEntry.service = service;
|
|
223
|
+
}
|
|
224
|
+
if (env) {
|
|
225
|
+
logEntry.env = env;
|
|
226
|
+
}
|
|
227
|
+
if (metadata) {
|
|
228
|
+
Object.assign(logEntry, metadata);
|
|
229
|
+
}
|
|
230
|
+
const output = JSON.stringify(logEntry);
|
|
231
|
+
if (logLevel === "error") {
|
|
232
|
+
console.error(output);
|
|
233
|
+
} else {
|
|
234
|
+
console.log(output);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
__name(log, "log");
|
|
238
|
+
return {
|
|
239
|
+
debug(message, metadata) {
|
|
240
|
+
log("debug", message, metadata);
|
|
241
|
+
},
|
|
242
|
+
info(message, metadata) {
|
|
243
|
+
log("info", message, metadata);
|
|
244
|
+
},
|
|
245
|
+
warn(message, metadata) {
|
|
246
|
+
log("warn", message, metadata);
|
|
247
|
+
},
|
|
248
|
+
error(message, metadata) {
|
|
249
|
+
log("error", message, metadata);
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
var LOG_LEVELS;
|
|
254
|
+
var init_logger = __esm({
|
|
255
|
+
"src/shared/utils/logger.ts"() {
|
|
256
|
+
"use strict";
|
|
257
|
+
LOG_LEVELS = {
|
|
258
|
+
debug: 0,
|
|
259
|
+
info: 1,
|
|
260
|
+
warn: 2,
|
|
261
|
+
error: 3
|
|
262
|
+
};
|
|
263
|
+
__name(createLogger, "createLogger");
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
// node_modules/ulid/dist/node/index.js
|
|
268
|
+
function randomChar(prng) {
|
|
269
|
+
const randomPosition = Math.floor(prng() * ENCODING_LEN) % ENCODING_LEN;
|
|
270
|
+
return ENCODING.charAt(randomPosition);
|
|
271
|
+
}
|
|
272
|
+
function detectPRNG(root) {
|
|
273
|
+
const rootLookup = detectRoot();
|
|
274
|
+
const globalCrypto = rootLookup && (rootLookup.crypto || rootLookup.msCrypto) || (typeof import_node_crypto.default !== "undefined" ? import_node_crypto.default : null);
|
|
275
|
+
if (typeof globalCrypto?.getRandomValues === "function") {
|
|
276
|
+
return () => {
|
|
277
|
+
const buffer = new Uint8Array(1);
|
|
278
|
+
globalCrypto.getRandomValues(buffer);
|
|
279
|
+
return buffer[0] / 256;
|
|
280
|
+
};
|
|
281
|
+
} else if (typeof globalCrypto?.randomBytes === "function") {
|
|
282
|
+
return () => globalCrypto.randomBytes(1).readUInt8() / 256;
|
|
283
|
+
} else if (import_node_crypto.default?.randomBytes) {
|
|
284
|
+
return () => import_node_crypto.default.randomBytes(1).readUInt8() / 256;
|
|
285
|
+
}
|
|
286
|
+
throw new ULIDError(ULIDErrorCode.PRNGDetectFailure, "Failed to find a reliable PRNG");
|
|
287
|
+
}
|
|
288
|
+
function detectRoot() {
|
|
289
|
+
if (inWebWorker())
|
|
290
|
+
return self;
|
|
291
|
+
if (typeof window !== "undefined") {
|
|
292
|
+
return window;
|
|
293
|
+
}
|
|
294
|
+
if (typeof global !== "undefined") {
|
|
295
|
+
return global;
|
|
296
|
+
}
|
|
297
|
+
if (typeof globalThis !== "undefined") {
|
|
298
|
+
return globalThis;
|
|
299
|
+
}
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
function encodeRandom(len, prng) {
|
|
303
|
+
let str = "";
|
|
304
|
+
for (; len > 0; len--) {
|
|
305
|
+
str = randomChar(prng) + str;
|
|
306
|
+
}
|
|
307
|
+
return str;
|
|
308
|
+
}
|
|
309
|
+
function encodeTime(now, len = TIME_LEN) {
|
|
310
|
+
if (isNaN(now)) {
|
|
311
|
+
throw new ULIDError(ULIDErrorCode.EncodeTimeValueMalformed, `Time must be a number: ${now}`);
|
|
312
|
+
} else if (now > TIME_MAX) {
|
|
313
|
+
throw new ULIDError(ULIDErrorCode.EncodeTimeSizeExceeded, `Cannot encode a time larger than ${TIME_MAX}: ${now}`);
|
|
314
|
+
} else if (now < 0) {
|
|
315
|
+
throw new ULIDError(ULIDErrorCode.EncodeTimeNegative, `Time must be positive: ${now}`);
|
|
316
|
+
} else if (Number.isInteger(now) === false) {
|
|
317
|
+
throw new ULIDError(ULIDErrorCode.EncodeTimeValueMalformed, `Time must be an integer: ${now}`);
|
|
318
|
+
}
|
|
319
|
+
let mod, str = "";
|
|
320
|
+
for (let currentLen = len; currentLen > 0; currentLen--) {
|
|
321
|
+
mod = now % ENCODING_LEN;
|
|
322
|
+
str = ENCODING.charAt(mod) + str;
|
|
323
|
+
now = (now - mod) / ENCODING_LEN;
|
|
324
|
+
}
|
|
325
|
+
return str;
|
|
326
|
+
}
|
|
327
|
+
function inWebWorker() {
|
|
328
|
+
return typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope;
|
|
329
|
+
}
|
|
330
|
+
function ulid(seedTime, prng) {
|
|
331
|
+
const currentPRNG = prng || detectPRNG();
|
|
332
|
+
const seed = !seedTime || isNaN(seedTime) ? Date.now() : seedTime;
|
|
333
|
+
return encodeTime(seed, TIME_LEN) + encodeRandom(RANDOM_LEN, currentPRNG);
|
|
334
|
+
}
|
|
335
|
+
var import_node_crypto, ENCODING, ENCODING_LEN, RANDOM_LEN, TIME_LEN, TIME_MAX, ULIDErrorCode, ULIDError;
|
|
336
|
+
var init_node = __esm({
|
|
337
|
+
"node_modules/ulid/dist/node/index.js"() {
|
|
338
|
+
import_node_crypto = __toESM(require("node:crypto"), 1);
|
|
339
|
+
ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
340
|
+
ENCODING_LEN = 32;
|
|
341
|
+
RANDOM_LEN = 16;
|
|
342
|
+
TIME_LEN = 10;
|
|
343
|
+
TIME_MAX = 281474976710655;
|
|
344
|
+
(function(ULIDErrorCode2) {
|
|
345
|
+
ULIDErrorCode2["Base32IncorrectEncoding"] = "B32_ENC_INVALID";
|
|
346
|
+
ULIDErrorCode2["DecodeTimeInvalidCharacter"] = "DEC_TIME_CHAR";
|
|
347
|
+
ULIDErrorCode2["DecodeTimeValueMalformed"] = "DEC_TIME_MALFORMED";
|
|
348
|
+
ULIDErrorCode2["EncodeTimeNegative"] = "ENC_TIME_NEG";
|
|
349
|
+
ULIDErrorCode2["EncodeTimeSizeExceeded"] = "ENC_TIME_SIZE_EXCEED";
|
|
350
|
+
ULIDErrorCode2["EncodeTimeValueMalformed"] = "ENC_TIME_MALFORMED";
|
|
351
|
+
ULIDErrorCode2["PRNGDetectFailure"] = "PRNG_DETECT";
|
|
352
|
+
ULIDErrorCode2["ULIDInvalid"] = "ULID_INVALID";
|
|
353
|
+
ULIDErrorCode2["Unexpected"] = "UNEXPECTED";
|
|
354
|
+
ULIDErrorCode2["UUIDInvalid"] = "UUID_INVALID";
|
|
355
|
+
})(ULIDErrorCode || (ULIDErrorCode = {}));
|
|
356
|
+
ULIDError = class extends Error {
|
|
357
|
+
static {
|
|
358
|
+
__name(this, "ULIDError");
|
|
359
|
+
}
|
|
360
|
+
constructor(errorCode, message) {
|
|
361
|
+
super(`${message} (${errorCode})`);
|
|
362
|
+
this.name = "ULIDError";
|
|
363
|
+
this.code = errorCode;
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
__name(randomChar, "randomChar");
|
|
367
|
+
__name(detectPRNG, "detectPRNG");
|
|
368
|
+
__name(detectRoot, "detectRoot");
|
|
369
|
+
__name(encodeRandom, "encodeRandom");
|
|
370
|
+
__name(encodeTime, "encodeTime");
|
|
371
|
+
__name(inWebWorker, "inWebWorker");
|
|
372
|
+
__name(ulid, "ulid");
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
// src/shared/utils/ulid.ts
|
|
377
|
+
function ulid2() {
|
|
378
|
+
return ulid();
|
|
379
|
+
}
|
|
380
|
+
function ulidWithTime(seedTime) {
|
|
381
|
+
return ulid(seedTime);
|
|
382
|
+
}
|
|
383
|
+
function decodeTime(id) {
|
|
384
|
+
const timeChars = id.substring(0, 10);
|
|
385
|
+
const ENCODING2 = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
386
|
+
let time2 = 0;
|
|
387
|
+
for (let i4 = 0; i4 < timeChars.length; i4++) {
|
|
388
|
+
const char = timeChars[i4];
|
|
389
|
+
const value = ENCODING2.indexOf(char);
|
|
390
|
+
if (value === -1) {
|
|
391
|
+
throw new Error(`Invalid ULID character: ${char}`);
|
|
392
|
+
}
|
|
393
|
+
time2 = time2 * 32 + value;
|
|
394
|
+
}
|
|
395
|
+
return time2;
|
|
396
|
+
}
|
|
397
|
+
var init_ulid = __esm({
|
|
398
|
+
"src/shared/utils/ulid.ts"() {
|
|
399
|
+
"use strict";
|
|
400
|
+
init_node();
|
|
401
|
+
__name(ulid2, "ulid");
|
|
402
|
+
__name(ulidWithTime, "ulidWithTime");
|
|
403
|
+
__name(decodeTime, "decodeTime");
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
// src/shared/utils/validation.ts
|
|
408
|
+
function validateRequiredFields(obj, fields) {
|
|
409
|
+
const missingFields = fields.filter((field) => obj[field] === void 0 || obj[field] === null);
|
|
410
|
+
if (missingFields.length > 0) {
|
|
411
|
+
throw new Error(`Missing required fields: ${missingFields.join(", ")}`);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
function validateNonEmptyString(value, fieldName) {
|
|
415
|
+
if (typeof value !== "string" || value.trim() === "") {
|
|
416
|
+
throw new Error(`${fieldName} must be a non-empty string`);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
function validateNumberRange(value, fieldName, min, max) {
|
|
420
|
+
if (typeof value !== "number" || isNaN(value)) {
|
|
421
|
+
throw new Error(`${fieldName} must be a valid number`);
|
|
422
|
+
}
|
|
423
|
+
if (min !== void 0 && value < min) {
|
|
424
|
+
throw new Error(`${fieldName} must be at least ${min}`);
|
|
425
|
+
}
|
|
426
|
+
if (max !== void 0 && value > max) {
|
|
427
|
+
throw new Error(`${fieldName} must be at most ${max}`);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
function validateNonEmptyArray(value, fieldName) {
|
|
431
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
432
|
+
throw new Error(`${fieldName} must be a non-empty array`);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
function validateSortField(sortField, validFields) {
|
|
436
|
+
if (!validFields.includes(sortField)) {
|
|
437
|
+
throw new InvalidFilterError(
|
|
438
|
+
`Invalid sort field: ${sortField}. Valid fields are: ${validFields.join(", ")}`,
|
|
439
|
+
{ sortField, validFields }
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
function validateULID(value, fieldName) {
|
|
444
|
+
if (typeof value !== "string") {
|
|
445
|
+
throw new Error(`${fieldName} must be a string`);
|
|
446
|
+
}
|
|
447
|
+
const ulidPattern = /^[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}$/;
|
|
448
|
+
if (!ulidPattern.test(value)) {
|
|
449
|
+
throw new Error(`${fieldName} must be a valid ULID format (26 characters, Crockford's Base32)`);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
function validateISO8601DateTime(value, fieldName) {
|
|
453
|
+
if (typeof value !== "string") {
|
|
454
|
+
throw new Error(`${fieldName} must be a string`);
|
|
455
|
+
}
|
|
456
|
+
const date2 = new Date(value);
|
|
457
|
+
if (isNaN(date2.getTime())) {
|
|
458
|
+
throw new Error(`${fieldName} must be a valid ISO 8601 datetime string`);
|
|
459
|
+
}
|
|
460
|
+
const iso8601Pattern = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?$/;
|
|
461
|
+
if (!iso8601Pattern.test(value)) {
|
|
462
|
+
throw new Error(`${fieldName} must be in ISO 8601 format (YYYY-MM-DDTHH:mm:ss.sssZ)`);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
var init_validation = __esm({
|
|
466
|
+
"src/shared/utils/validation.ts"() {
|
|
467
|
+
"use strict";
|
|
468
|
+
init_errors();
|
|
469
|
+
__name(validateRequiredFields, "validateRequiredFields");
|
|
470
|
+
__name(validateNonEmptyString, "validateNonEmptyString");
|
|
471
|
+
__name(validateNumberRange, "validateNumberRange");
|
|
472
|
+
__name(validateNonEmptyArray, "validateNonEmptyArray");
|
|
473
|
+
__name(validateSortField, "validateSortField");
|
|
474
|
+
__name(validateULID, "validateULID");
|
|
475
|
+
__name(validateISO8601DateTime, "validateISO8601DateTime");
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
|
|
39
479
|
// node_modules/@smithy/types/dist-cjs/index.js
|
|
40
480
|
var require_dist_cjs = __commonJS({
|
|
41
481
|
"node_modules/@smithy/types/dist-cjs/index.js"(exports2) {
|
|
@@ -18712,7 +19152,7 @@ var init_SSOOIDCServiceException = __esm({
|
|
|
18712
19152
|
|
|
18713
19153
|
// node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso-oidc/models/errors.js
|
|
18714
19154
|
var AccessDeniedException, AuthorizationPendingException, ExpiredTokenException, InternalServerException, InvalidClientException, InvalidGrantException, InvalidRequestException, InvalidScopeException, SlowDownException, UnauthorizedClientException, UnsupportedGrantTypeException;
|
|
18715
|
-
var
|
|
19155
|
+
var init_errors2 = __esm({
|
|
18716
19156
|
"node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso-oidc/models/errors.js"() {
|
|
18717
19157
|
init_SSOOIDCServiceException();
|
|
18718
19158
|
AccessDeniedException = class _AccessDeniedException extends SSOOIDCServiceException {
|
|
@@ -18936,7 +19376,7 @@ var _ADE, _APE, _AT, _CS, _CT, _CTR, _CTRr, _CV, _ETE, _ICE, _IGE, _IRE, _ISE, _
|
|
|
18936
19376
|
var init_schemas_0 = __esm({
|
|
18937
19377
|
"node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso-oidc/schemas/schemas_0.js"() {
|
|
18938
19378
|
init_schema();
|
|
18939
|
-
|
|
19379
|
+
init_errors2();
|
|
18940
19380
|
init_SSOOIDCServiceException();
|
|
18941
19381
|
_ADE = "AccessDeniedException";
|
|
18942
19382
|
_APE = "AuthorizationPendingException";
|
|
@@ -19153,7 +19593,7 @@ var init_sso_oidc = __esm({
|
|
|
19153
19593
|
init_SSOOIDC();
|
|
19154
19594
|
init_commands();
|
|
19155
19595
|
init_enums();
|
|
19156
|
-
|
|
19596
|
+
init_errors2();
|
|
19157
19597
|
init_SSOOIDCServiceException();
|
|
19158
19598
|
}
|
|
19159
19599
|
});
|
|
@@ -20620,7 +21060,7 @@ var init_SigninServiceException = __esm({
|
|
|
20620
21060
|
|
|
20621
21061
|
// node_modules/@aws-sdk/nested-clients/dist-es/submodules/signin/models/errors.js
|
|
20622
21062
|
var AccessDeniedException3, InternalServerException3, TooManyRequestsError, ValidationException;
|
|
20623
|
-
var
|
|
21063
|
+
var init_errors3 = __esm({
|
|
20624
21064
|
"node_modules/@aws-sdk/nested-clients/dist-es/submodules/signin/models/errors.js"() {
|
|
20625
21065
|
init_SigninServiceException();
|
|
20626
21066
|
AccessDeniedException3 = class _AccessDeniedException extends SigninServiceException {
|
|
@@ -20699,7 +21139,7 @@ var _ADE2, _AT2, _COAT, _COATR, _COATRB, _COATRBr, _COATRr, _ISE2, _RT2, _TMRE,
|
|
|
20699
21139
|
var init_schemas_02 = __esm({
|
|
20700
21140
|
"node_modules/@aws-sdk/nested-clients/dist-es/submodules/signin/schemas/schemas_0.js"() {
|
|
20701
21141
|
init_schema();
|
|
20702
|
-
|
|
21142
|
+
init_errors3();
|
|
20703
21143
|
init_SigninServiceException();
|
|
20704
21144
|
_ADE2 = "AccessDeniedException";
|
|
20705
21145
|
_AT2 = "AccessToken";
|
|
@@ -20895,7 +21335,7 @@ var init_signin = __esm({
|
|
|
20895
21335
|
init_Signin();
|
|
20896
21336
|
init_commands2();
|
|
20897
21337
|
init_enums2();
|
|
20898
|
-
|
|
21338
|
+
init_errors3();
|
|
20899
21339
|
init_SigninServiceException();
|
|
20900
21340
|
}
|
|
20901
21341
|
});
|
|
@@ -21585,7 +22025,7 @@ var init_STSServiceException = __esm({
|
|
|
21585
22025
|
|
|
21586
22026
|
// node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/models/errors.js
|
|
21587
22027
|
var ExpiredTokenException3, MalformedPolicyDocumentException, PackedPolicyTooLargeException, RegionDisabledException, IDPRejectedClaimException, InvalidIdentityTokenException, IDPCommunicationErrorException;
|
|
21588
|
-
var
|
|
22028
|
+
var init_errors4 = __esm({
|
|
21589
22029
|
"node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/models/errors.js"() {
|
|
21590
22030
|
init_STSServiceException();
|
|
21591
22031
|
ExpiredTokenException3 = class _ExpiredTokenException extends STSServiceException {
|
|
@@ -21701,7 +22141,7 @@ var _A, _AKI, _AR, _ARI, _ARR, _ARRs, _ARU, _ARWWI, _ARWWIR, _ARWWIRs, _Au, _C,
|
|
|
21701
22141
|
var init_schemas_03 = __esm({
|
|
21702
22142
|
"node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/schemas/schemas_0.js"() {
|
|
21703
22143
|
init_schema();
|
|
21704
|
-
|
|
22144
|
+
init_errors4();
|
|
21705
22145
|
init_STSServiceException();
|
|
21706
22146
|
_A = "Arn";
|
|
21707
22147
|
_AKI = "AccessKeyId";
|
|
@@ -22119,7 +22559,7 @@ var init_sts = __esm({
|
|
|
22119
22559
|
init_STSClient();
|
|
22120
22560
|
init_STS();
|
|
22121
22561
|
init_commands3();
|
|
22122
|
-
|
|
22562
|
+
init_errors4();
|
|
22123
22563
|
init_defaultRoleAssumers();
|
|
22124
22564
|
init_STSServiceException();
|
|
22125
22565
|
}
|
|
@@ -28605,6 +29045,685 @@ var require_dist_cjs66 = __commonJS({
|
|
|
28605
29045
|
}
|
|
28606
29046
|
});
|
|
28607
29047
|
|
|
29048
|
+
// src/shared/utils/dynamodb.ts
|
|
29049
|
+
function createDynamoDBClient(config = {}) {
|
|
29050
|
+
const { region = process.env.AWS_REGION || "us-east-1", endpoint } = config;
|
|
29051
|
+
const client = new import_client_dynamodb.DynamoDBClient({
|
|
29052
|
+
region,
|
|
29053
|
+
...endpoint && { endpoint }
|
|
29054
|
+
});
|
|
29055
|
+
const docClient = import_lib_dynamodb.DynamoDBDocumentClient.from(client, {
|
|
29056
|
+
marshallOptions: {
|
|
29057
|
+
removeUndefinedValues: true,
|
|
29058
|
+
convertEmptyValues: false
|
|
29059
|
+
},
|
|
29060
|
+
unmarshallOptions: {
|
|
29061
|
+
wrapNumbers: false
|
|
29062
|
+
}
|
|
29063
|
+
});
|
|
29064
|
+
return docClient;
|
|
29065
|
+
}
|
|
29066
|
+
var import_client_dynamodb, import_lib_dynamodb;
|
|
29067
|
+
var init_dynamodb = __esm({
|
|
29068
|
+
"src/shared/utils/dynamodb.ts"() {
|
|
29069
|
+
"use strict";
|
|
29070
|
+
import_client_dynamodb = __toESM(require_dist_cjs64(), 1);
|
|
29071
|
+
import_lib_dynamodb = __toESM(require_dist_cjs66(), 1);
|
|
29072
|
+
__name(createDynamoDBClient, "createDynamoDBClient");
|
|
29073
|
+
}
|
|
29074
|
+
});
|
|
29075
|
+
|
|
29076
|
+
// src/shared/utils/index.ts
|
|
29077
|
+
var init_utils2 = __esm({
|
|
29078
|
+
"src/shared/utils/index.ts"() {
|
|
29079
|
+
"use strict";
|
|
29080
|
+
init_logger();
|
|
29081
|
+
init_ulid();
|
|
29082
|
+
init_validation();
|
|
29083
|
+
init_dynamodb();
|
|
29084
|
+
}
|
|
29085
|
+
});
|
|
29086
|
+
|
|
29087
|
+
// src/shared/constants/dynamodb.ts
|
|
29088
|
+
var DYNAMODB_TRANSACT_WRITE_MAX_ITEMS, DYNAMODB_BATCH_GET_MAX_ITEMS, DYNAMODB_BATCH_WRITE_MAX_ITEMS, DYNAMODB_QUERY_MAX_SIZE_BYTES, DYNAMODB_SCAN_MAX_SIZE_BYTES, DYNAMODB_RESERVED_WORDS;
|
|
29089
|
+
var init_dynamodb2 = __esm({
|
|
29090
|
+
"src/shared/constants/dynamodb.ts"() {
|
|
29091
|
+
"use strict";
|
|
29092
|
+
DYNAMODB_TRANSACT_WRITE_MAX_ITEMS = 100;
|
|
29093
|
+
DYNAMODB_BATCH_GET_MAX_ITEMS = 100;
|
|
29094
|
+
DYNAMODB_BATCH_WRITE_MAX_ITEMS = 25;
|
|
29095
|
+
DYNAMODB_QUERY_MAX_SIZE_BYTES = 1024 * 1024;
|
|
29096
|
+
DYNAMODB_SCAN_MAX_SIZE_BYTES = 1024 * 1024;
|
|
29097
|
+
DYNAMODB_RESERVED_WORDS = [
|
|
29098
|
+
"ABORT",
|
|
29099
|
+
"ABSOLUTE",
|
|
29100
|
+
"ACTION",
|
|
29101
|
+
"ADD",
|
|
29102
|
+
"AFTER",
|
|
29103
|
+
"AGENT",
|
|
29104
|
+
"AGGREGATE",
|
|
29105
|
+
"ALL",
|
|
29106
|
+
"ALLOCATE",
|
|
29107
|
+
"ALTER",
|
|
29108
|
+
"ANALYZE",
|
|
29109
|
+
"AND",
|
|
29110
|
+
"ANY",
|
|
29111
|
+
"ARCHIVE",
|
|
29112
|
+
"ARE",
|
|
29113
|
+
"ARRAY",
|
|
29114
|
+
"AS",
|
|
29115
|
+
"ASC",
|
|
29116
|
+
"ASCII",
|
|
29117
|
+
"ASENSITIVE",
|
|
29118
|
+
"ASSERTION",
|
|
29119
|
+
"ASYMMETRIC",
|
|
29120
|
+
"AT",
|
|
29121
|
+
"ATOMIC",
|
|
29122
|
+
"ATTACH",
|
|
29123
|
+
"ATTRIBUTE",
|
|
29124
|
+
"AUTH",
|
|
29125
|
+
"AUTHORIZATION",
|
|
29126
|
+
"AUTHORIZE",
|
|
29127
|
+
"AUTO",
|
|
29128
|
+
"AVG",
|
|
29129
|
+
"BACK",
|
|
29130
|
+
"BACKUP",
|
|
29131
|
+
"BASE",
|
|
29132
|
+
"BATCH",
|
|
29133
|
+
"BEFORE",
|
|
29134
|
+
"BEGIN",
|
|
29135
|
+
"BETWEEN",
|
|
29136
|
+
"BIGINT",
|
|
29137
|
+
"BINARY",
|
|
29138
|
+
"BIT",
|
|
29139
|
+
"BLOB",
|
|
29140
|
+
"BLOCK",
|
|
29141
|
+
"BOOLEAN",
|
|
29142
|
+
"BOTH",
|
|
29143
|
+
"BREADTH",
|
|
29144
|
+
"BUCKET",
|
|
29145
|
+
"BULK",
|
|
29146
|
+
"BY",
|
|
29147
|
+
"BYTE",
|
|
29148
|
+
"CALL",
|
|
29149
|
+
"CALLED",
|
|
29150
|
+
"CALLING",
|
|
29151
|
+
"CAPACITY",
|
|
29152
|
+
"CASCADE",
|
|
29153
|
+
"CASCADED",
|
|
29154
|
+
"CASE",
|
|
29155
|
+
"CAST",
|
|
29156
|
+
"CATALOG",
|
|
29157
|
+
"CHAR",
|
|
29158
|
+
"CHARACTER",
|
|
29159
|
+
"CHECK",
|
|
29160
|
+
"CLASS",
|
|
29161
|
+
"CLOB",
|
|
29162
|
+
"CLOSE",
|
|
29163
|
+
"CLUSTER",
|
|
29164
|
+
"CLUSTERED",
|
|
29165
|
+
"CLUSTERING",
|
|
29166
|
+
"CLUSTERS",
|
|
29167
|
+
"COALESCE",
|
|
29168
|
+
"COLLATE",
|
|
29169
|
+
"COLLATION",
|
|
29170
|
+
"COLLECTION",
|
|
29171
|
+
"COLUMN",
|
|
29172
|
+
"COLUMNS",
|
|
29173
|
+
"COMBINE",
|
|
29174
|
+
"COMMENT",
|
|
29175
|
+
"COMMIT",
|
|
29176
|
+
"COMPACT",
|
|
29177
|
+
"COMPILE",
|
|
29178
|
+
"COMPRESS",
|
|
29179
|
+
"CONDITION",
|
|
29180
|
+
"CONFLICT",
|
|
29181
|
+
"CONNECT",
|
|
29182
|
+
"CONNECTION",
|
|
29183
|
+
"CONSISTENCY",
|
|
29184
|
+
"CONSISTENT",
|
|
29185
|
+
"CONSTRAINT",
|
|
29186
|
+
"CONSTRAINTS",
|
|
29187
|
+
"CONSTRUCTOR",
|
|
29188
|
+
"CONSUMED",
|
|
29189
|
+
"CONTAINS",
|
|
29190
|
+
"CONTINUE",
|
|
29191
|
+
"CONVERT",
|
|
29192
|
+
"COPY",
|
|
29193
|
+
"CORRESPONDING",
|
|
29194
|
+
"COUNT",
|
|
29195
|
+
"COUNTER",
|
|
29196
|
+
"CREATE",
|
|
29197
|
+
"CROSS",
|
|
29198
|
+
"CUBE",
|
|
29199
|
+
"CURRENT",
|
|
29200
|
+
"CURSOR",
|
|
29201
|
+
"CYCLE",
|
|
29202
|
+
"DATA",
|
|
29203
|
+
"DATABASE",
|
|
29204
|
+
"DATE",
|
|
29205
|
+
"DATETIME",
|
|
29206
|
+
"DAY",
|
|
29207
|
+
"DEALLOCATE",
|
|
29208
|
+
"DEC",
|
|
29209
|
+
"DECIMAL",
|
|
29210
|
+
"DECLARE",
|
|
29211
|
+
"DEFAULT",
|
|
29212
|
+
"DEFERRABLE",
|
|
29213
|
+
"DEFERRED",
|
|
29214
|
+
"DEFINE",
|
|
29215
|
+
"DEFINED",
|
|
29216
|
+
"DEFINITION",
|
|
29217
|
+
"DELETE",
|
|
29218
|
+
"DELIMITED",
|
|
29219
|
+
"DEPTH",
|
|
29220
|
+
"DEREF",
|
|
29221
|
+
"DESC",
|
|
29222
|
+
"DESCRIBE",
|
|
29223
|
+
"DESCRIPTOR",
|
|
29224
|
+
"DETACH",
|
|
29225
|
+
"DETERMINISTIC",
|
|
29226
|
+
"DIAGNOSTICS",
|
|
29227
|
+
"DIRECTORIES",
|
|
29228
|
+
"DISABLE",
|
|
29229
|
+
"DISCONNECT",
|
|
29230
|
+
"DISTINCT",
|
|
29231
|
+
"DISTRIBUTE",
|
|
29232
|
+
"DO",
|
|
29233
|
+
"DOMAIN",
|
|
29234
|
+
"DOUBLE",
|
|
29235
|
+
"DROP",
|
|
29236
|
+
"DUMP",
|
|
29237
|
+
"DURATION",
|
|
29238
|
+
"DYNAMIC",
|
|
29239
|
+
"EACH",
|
|
29240
|
+
"ELEMENT",
|
|
29241
|
+
"ELSE",
|
|
29242
|
+
"ELSEIF",
|
|
29243
|
+
"EMPTY",
|
|
29244
|
+
"ENABLE",
|
|
29245
|
+
"END",
|
|
29246
|
+
"EQUAL",
|
|
29247
|
+
"EQUALS",
|
|
29248
|
+
"ERROR",
|
|
29249
|
+
"ESCAPE",
|
|
29250
|
+
"ESCAPED",
|
|
29251
|
+
"EVAL",
|
|
29252
|
+
"EVALUATE",
|
|
29253
|
+
"EXCEEDED",
|
|
29254
|
+
"EXCEPT",
|
|
29255
|
+
"EXCEPTION",
|
|
29256
|
+
"EXCEPTIONS",
|
|
29257
|
+
"EXCLUSIVE",
|
|
29258
|
+
"EXEC",
|
|
29259
|
+
"EXECUTE",
|
|
29260
|
+
"EXISTS",
|
|
29261
|
+
"EXIT",
|
|
29262
|
+
"EXPLAIN",
|
|
29263
|
+
"EXPLODE",
|
|
29264
|
+
"EXPORT",
|
|
29265
|
+
"EXPRESSION",
|
|
29266
|
+
"EXPRESSIONS",
|
|
29267
|
+
"EXTERNAL",
|
|
29268
|
+
"EXTRACT",
|
|
29269
|
+
"FAIL",
|
|
29270
|
+
"FALSE",
|
|
29271
|
+
"FAMILY",
|
|
29272
|
+
"FETCH",
|
|
29273
|
+
"FIELDS",
|
|
29274
|
+
"FILE",
|
|
29275
|
+
"FILTER",
|
|
29276
|
+
"FILTERING",
|
|
29277
|
+
"FINAL",
|
|
29278
|
+
"FINISH",
|
|
29279
|
+
"FIRST",
|
|
29280
|
+
"FIXED",
|
|
29281
|
+
"FLATTERN",
|
|
29282
|
+
"FLOAT",
|
|
29283
|
+
"FOR",
|
|
29284
|
+
"FORCE",
|
|
29285
|
+
"FOREIGN",
|
|
29286
|
+
"FORMAT",
|
|
29287
|
+
"FORWARD",
|
|
29288
|
+
"FOUND",
|
|
29289
|
+
"FREE",
|
|
29290
|
+
"FROM",
|
|
29291
|
+
"FULL",
|
|
29292
|
+
"FUNCTION",
|
|
29293
|
+
"FUNCTIONS",
|
|
29294
|
+
"GENERAL",
|
|
29295
|
+
"GENERATE",
|
|
29296
|
+
"GET",
|
|
29297
|
+
"GLOB",
|
|
29298
|
+
"GLOBAL",
|
|
29299
|
+
"GO",
|
|
29300
|
+
"GOTO",
|
|
29301
|
+
"GRANT",
|
|
29302
|
+
"GREATER",
|
|
29303
|
+
"GROUP",
|
|
29304
|
+
"GROUPING",
|
|
29305
|
+
"HANDLER",
|
|
29306
|
+
"HASH",
|
|
29307
|
+
"HAVE",
|
|
29308
|
+
"HAVING",
|
|
29309
|
+
"HEAP",
|
|
29310
|
+
"HIDDEN",
|
|
29311
|
+
"HOLD",
|
|
29312
|
+
"HOUR",
|
|
29313
|
+
"IDENTIFIED",
|
|
29314
|
+
"IDENTITY",
|
|
29315
|
+
"IF",
|
|
29316
|
+
"IGNORE",
|
|
29317
|
+
"IMMEDIATE",
|
|
29318
|
+
"IMPORT",
|
|
29319
|
+
"IN",
|
|
29320
|
+
"INCLUDING",
|
|
29321
|
+
"INCLUSIVE",
|
|
29322
|
+
"INCREMENT",
|
|
29323
|
+
"INCREMENTAL",
|
|
29324
|
+
"INDEX",
|
|
29325
|
+
"INDEXED",
|
|
29326
|
+
"INDEXES",
|
|
29327
|
+
"INDICATOR",
|
|
29328
|
+
"INFINITE",
|
|
29329
|
+
"INITIALLY",
|
|
29330
|
+
"INLINE",
|
|
29331
|
+
"INNER",
|
|
29332
|
+
"INNTER",
|
|
29333
|
+
"INOUT",
|
|
29334
|
+
"INPUT",
|
|
29335
|
+
"INSENSITIVE",
|
|
29336
|
+
"INSERT",
|
|
29337
|
+
"INSTEAD",
|
|
29338
|
+
"INT",
|
|
29339
|
+
"INTEGER",
|
|
29340
|
+
"INTERSECT",
|
|
29341
|
+
"INTERVAL",
|
|
29342
|
+
"INTO",
|
|
29343
|
+
"INVALIDATE",
|
|
29344
|
+
"IS",
|
|
29345
|
+
"ISOLATION",
|
|
29346
|
+
"ITEM",
|
|
29347
|
+
"ITEMS",
|
|
29348
|
+
"ITERATE",
|
|
29349
|
+
"JOIN",
|
|
29350
|
+
"KEY",
|
|
29351
|
+
"KEYS",
|
|
29352
|
+
"LAG",
|
|
29353
|
+
"LANGUAGE",
|
|
29354
|
+
"LARGE",
|
|
29355
|
+
"LAST",
|
|
29356
|
+
"LATERAL",
|
|
29357
|
+
"LEAD",
|
|
29358
|
+
"LEADING",
|
|
29359
|
+
"LEAVE",
|
|
29360
|
+
"LEFT",
|
|
29361
|
+
"LENGTH",
|
|
29362
|
+
"LESS",
|
|
29363
|
+
"LEVEL",
|
|
29364
|
+
"LIKE",
|
|
29365
|
+
"LIMIT",
|
|
29366
|
+
"LIMITED",
|
|
29367
|
+
"LINES",
|
|
29368
|
+
"LIST",
|
|
29369
|
+
"LOAD",
|
|
29370
|
+
"LOCAL",
|
|
29371
|
+
"LOCALTIME",
|
|
29372
|
+
"LOCALTIMESTAMP",
|
|
29373
|
+
"LOCATION",
|
|
29374
|
+
"LOCATOR",
|
|
29375
|
+
"LOCK",
|
|
29376
|
+
"LOCKS",
|
|
29377
|
+
"LOG",
|
|
29378
|
+
"LOGED",
|
|
29379
|
+
"LONG",
|
|
29380
|
+
"LOOP",
|
|
29381
|
+
"LOWER",
|
|
29382
|
+
"MAP",
|
|
29383
|
+
"MATCH",
|
|
29384
|
+
"MATERIALIZED",
|
|
29385
|
+
"MAX",
|
|
29386
|
+
"MAXLEN",
|
|
29387
|
+
"MEMBER",
|
|
29388
|
+
"MERGE",
|
|
29389
|
+
"METHOD",
|
|
29390
|
+
"METRICS",
|
|
29391
|
+
"MIN",
|
|
29392
|
+
"MINUS",
|
|
29393
|
+
"MINUTE",
|
|
29394
|
+
"MISSING",
|
|
29395
|
+
"MOD",
|
|
29396
|
+
"MODE",
|
|
29397
|
+
"MODIFIES",
|
|
29398
|
+
"MODIFY",
|
|
29399
|
+
"MODULE",
|
|
29400
|
+
"MONTH",
|
|
29401
|
+
"MULTI",
|
|
29402
|
+
"MULTISET",
|
|
29403
|
+
"NAME",
|
|
29404
|
+
"NAMES",
|
|
29405
|
+
"NATIONAL",
|
|
29406
|
+
"NATURAL",
|
|
29407
|
+
"NCHAR",
|
|
29408
|
+
"NCLOB",
|
|
29409
|
+
"NEW",
|
|
29410
|
+
"NEXT",
|
|
29411
|
+
"NO",
|
|
29412
|
+
"NONE",
|
|
29413
|
+
"NOT",
|
|
29414
|
+
"NULL",
|
|
29415
|
+
"NULLIF",
|
|
29416
|
+
"NUMBER",
|
|
29417
|
+
"NUMERIC",
|
|
29418
|
+
"OBJECT",
|
|
29419
|
+
"OF",
|
|
29420
|
+
"OFFLINE",
|
|
29421
|
+
"OFFSET",
|
|
29422
|
+
"OLD",
|
|
29423
|
+
"ON",
|
|
29424
|
+
"ONLINE",
|
|
29425
|
+
"ONLY",
|
|
29426
|
+
"OPAQUE",
|
|
29427
|
+
"OPEN",
|
|
29428
|
+
"OPERATOR",
|
|
29429
|
+
"OPTION",
|
|
29430
|
+
"OR",
|
|
29431
|
+
"ORDER",
|
|
29432
|
+
"ORDINALITY",
|
|
29433
|
+
"OTHER",
|
|
29434
|
+
"OTHERS",
|
|
29435
|
+
"OUT",
|
|
29436
|
+
"OUTER",
|
|
29437
|
+
"OUTPUT",
|
|
29438
|
+
"OVER",
|
|
29439
|
+
"OVERLAPS",
|
|
29440
|
+
"OVERRIDE",
|
|
29441
|
+
"OWNER",
|
|
29442
|
+
"PAD",
|
|
29443
|
+
"PARALLEL",
|
|
29444
|
+
"PARAMETER",
|
|
29445
|
+
"PARAMETERS",
|
|
29446
|
+
"PARTIAL",
|
|
29447
|
+
"PARTITION",
|
|
29448
|
+
"PARTITIONED",
|
|
29449
|
+
"PARTITIONS",
|
|
29450
|
+
"PATH",
|
|
29451
|
+
"PERCENT",
|
|
29452
|
+
"PERCENTILE",
|
|
29453
|
+
"PERMISSION",
|
|
29454
|
+
"PERMISSIONS",
|
|
29455
|
+
"PIPE",
|
|
29456
|
+
"PIPELINED",
|
|
29457
|
+
"PLAN",
|
|
29458
|
+
"POOL",
|
|
29459
|
+
"POSITION",
|
|
29460
|
+
"PRECISION",
|
|
29461
|
+
"PREPARE",
|
|
29462
|
+
"PRESERVE",
|
|
29463
|
+
"PRIMARY",
|
|
29464
|
+
"PRIOR",
|
|
29465
|
+
"PRIVATE",
|
|
29466
|
+
"PRIVILEGES",
|
|
29467
|
+
"PROCEDURE",
|
|
29468
|
+
"PROCESSED",
|
|
29469
|
+
"PROJECT",
|
|
29470
|
+
"PROJECTION",
|
|
29471
|
+
"PROPERTY",
|
|
29472
|
+
"PROVISIONING",
|
|
29473
|
+
"PUBLIC",
|
|
29474
|
+
"PUT",
|
|
29475
|
+
"QUERY",
|
|
29476
|
+
"QUIT",
|
|
29477
|
+
"QUORUM",
|
|
29478
|
+
"RAISE",
|
|
29479
|
+
"RANDOM",
|
|
29480
|
+
"RANGE",
|
|
29481
|
+
"RANK",
|
|
29482
|
+
"RAW",
|
|
29483
|
+
"READ",
|
|
29484
|
+
"READS",
|
|
29485
|
+
"REAL",
|
|
29486
|
+
"REBUILD",
|
|
29487
|
+
"RECORD",
|
|
29488
|
+
"RECURSIVE",
|
|
29489
|
+
"REDUCE",
|
|
29490
|
+
"REF",
|
|
29491
|
+
"REFERENCE",
|
|
29492
|
+
"REFERENCES",
|
|
29493
|
+
"REFERENCING",
|
|
29494
|
+
"REGEXP",
|
|
29495
|
+
"REGION",
|
|
29496
|
+
"REINDEX",
|
|
29497
|
+
"RELATIVE",
|
|
29498
|
+
"RELEASE",
|
|
29499
|
+
"REMAINDER",
|
|
29500
|
+
"RENAME",
|
|
29501
|
+
"REPEAT",
|
|
29502
|
+
"REPLACE",
|
|
29503
|
+
"REQUEST",
|
|
29504
|
+
"RESET",
|
|
29505
|
+
"RESIGNAL",
|
|
29506
|
+
"RESOURCE",
|
|
29507
|
+
"RESPONSE",
|
|
29508
|
+
"RESTORE",
|
|
29509
|
+
"RESTRICT",
|
|
29510
|
+
"RESULT",
|
|
29511
|
+
"RETURN",
|
|
29512
|
+
"RETURNING",
|
|
29513
|
+
"RETURNS",
|
|
29514
|
+
"REVERSE",
|
|
29515
|
+
"REVOKE",
|
|
29516
|
+
"RIGHT",
|
|
29517
|
+
"ROLE",
|
|
29518
|
+
"ROLES",
|
|
29519
|
+
"ROLLBACK",
|
|
29520
|
+
"ROLLUP",
|
|
29521
|
+
"ROUTINE",
|
|
29522
|
+
"ROW",
|
|
29523
|
+
"ROWS",
|
|
29524
|
+
"RULE",
|
|
29525
|
+
"RULES",
|
|
29526
|
+
"SAMPLE",
|
|
29527
|
+
"SATISFIES",
|
|
29528
|
+
"SAVE",
|
|
29529
|
+
"SAVEPOINT",
|
|
29530
|
+
"SCAN",
|
|
29531
|
+
"SCHEMA",
|
|
29532
|
+
"SCOPE",
|
|
29533
|
+
"SCROLL",
|
|
29534
|
+
"SEARCH",
|
|
29535
|
+
"SECOND",
|
|
29536
|
+
"SECTION",
|
|
29537
|
+
"SEGMENT",
|
|
29538
|
+
"SEGMENTS",
|
|
29539
|
+
"SELECT",
|
|
29540
|
+
"SELF",
|
|
29541
|
+
"SEMI",
|
|
29542
|
+
"SENSITIVE",
|
|
29543
|
+
"SEPARATE",
|
|
29544
|
+
"SEQUENCE",
|
|
29545
|
+
"SERIALIZABLE",
|
|
29546
|
+
"SESSION",
|
|
29547
|
+
"SET",
|
|
29548
|
+
"SETS",
|
|
29549
|
+
"SHARD",
|
|
29550
|
+
"SHARE",
|
|
29551
|
+
"SHARED",
|
|
29552
|
+
"SHORT",
|
|
29553
|
+
"SHOW",
|
|
29554
|
+
"SIGNAL",
|
|
29555
|
+
"SIMILAR",
|
|
29556
|
+
"SIZE",
|
|
29557
|
+
"SKEWED",
|
|
29558
|
+
"SMALLINT",
|
|
29559
|
+
"SNAPSHOT",
|
|
29560
|
+
"SOME",
|
|
29561
|
+
"SOURCE",
|
|
29562
|
+
"SPACE",
|
|
29563
|
+
"SPACES",
|
|
29564
|
+
"SPARSE",
|
|
29565
|
+
"SPECIFIC",
|
|
29566
|
+
"SPECIFICTYPE",
|
|
29567
|
+
"SPLIT",
|
|
29568
|
+
"SQL",
|
|
29569
|
+
"SQLCODE",
|
|
29570
|
+
"SQLERROR",
|
|
29571
|
+
"SQLEXCEPTION",
|
|
29572
|
+
"SQLSTATE",
|
|
29573
|
+
"SQLWARNING",
|
|
29574
|
+
"START",
|
|
29575
|
+
"STATE",
|
|
29576
|
+
"STATIC",
|
|
29577
|
+
"STATUS",
|
|
29578
|
+
"STORAGE",
|
|
29579
|
+
"STORE",
|
|
29580
|
+
"STORED",
|
|
29581
|
+
"STREAM",
|
|
29582
|
+
"STRING",
|
|
29583
|
+
"STRUCTURE",
|
|
29584
|
+
"STYLE",
|
|
29585
|
+
"SUB",
|
|
29586
|
+
"SUBMULTISET",
|
|
29587
|
+
"SUBPARTITION",
|
|
29588
|
+
"SUBSTRING",
|
|
29589
|
+
"SUBTYPE",
|
|
29590
|
+
"SUM",
|
|
29591
|
+
"SUPER",
|
|
29592
|
+
"SYMMETRIC",
|
|
29593
|
+
"SYNONYM",
|
|
29594
|
+
"SYSTEM",
|
|
29595
|
+
"TABLE",
|
|
29596
|
+
"TABLESAMPLE",
|
|
29597
|
+
"TEMP",
|
|
29598
|
+
"TEMPORARY",
|
|
29599
|
+
"TERMINATED",
|
|
29600
|
+
"TEXT",
|
|
29601
|
+
"THAN",
|
|
29602
|
+
"THEN",
|
|
29603
|
+
"THROUGHPUT",
|
|
29604
|
+
"TIME",
|
|
29605
|
+
"TIMESTAMP",
|
|
29606
|
+
"TIMEZONE",
|
|
29607
|
+
"TINYINT",
|
|
29608
|
+
"TO",
|
|
29609
|
+
"TOKEN",
|
|
29610
|
+
"TOTAL",
|
|
29611
|
+
"TOUCH",
|
|
29612
|
+
"TRAILING",
|
|
29613
|
+
"TRANSACTION",
|
|
29614
|
+
"TRANSFORM",
|
|
29615
|
+
"TRANSLATE",
|
|
29616
|
+
"TRANSLATION",
|
|
29617
|
+
"TREAT",
|
|
29618
|
+
"TRIGGER",
|
|
29619
|
+
"TRIM",
|
|
29620
|
+
"TRUE",
|
|
29621
|
+
"TRUNCATE",
|
|
29622
|
+
"TTL",
|
|
29623
|
+
"TUPLE",
|
|
29624
|
+
"TYPE",
|
|
29625
|
+
"UNDER",
|
|
29626
|
+
"UNDO",
|
|
29627
|
+
"UNION",
|
|
29628
|
+
"UNIQUE",
|
|
29629
|
+
"UNIT",
|
|
29630
|
+
"UNKNOWN",
|
|
29631
|
+
"UNLOGGED",
|
|
29632
|
+
"UNNEST",
|
|
29633
|
+
"UNPROCESSED",
|
|
29634
|
+
"UNSIGNED",
|
|
29635
|
+
"UNTIL",
|
|
29636
|
+
"UPDATE",
|
|
29637
|
+
"UPPER",
|
|
29638
|
+
"URL",
|
|
29639
|
+
"USAGE",
|
|
29640
|
+
"USE",
|
|
29641
|
+
"USER",
|
|
29642
|
+
"USERS",
|
|
29643
|
+
"USING",
|
|
29644
|
+
"UUID",
|
|
29645
|
+
"VACUUM",
|
|
29646
|
+
"VALUE",
|
|
29647
|
+
"VALUED",
|
|
29648
|
+
"VALUES",
|
|
29649
|
+
"VARCHAR",
|
|
29650
|
+
"VARIABLE",
|
|
29651
|
+
"VARIANCE",
|
|
29652
|
+
"VARINT",
|
|
29653
|
+
"VARYING",
|
|
29654
|
+
"VIEW",
|
|
29655
|
+
"VIEWS",
|
|
29656
|
+
"VIRTUAL",
|
|
29657
|
+
"VOID",
|
|
29658
|
+
"WAIT",
|
|
29659
|
+
"WHEN",
|
|
29660
|
+
"WHENEVER",
|
|
29661
|
+
"WHERE",
|
|
29662
|
+
"WHILE",
|
|
29663
|
+
"WINDOW",
|
|
29664
|
+
"WITH",
|
|
29665
|
+
"WITHIN",
|
|
29666
|
+
"WITHOUT",
|
|
29667
|
+
"WORK",
|
|
29668
|
+
"WRAPPED",
|
|
29669
|
+
"WRITE",
|
|
29670
|
+
"YEAR",
|
|
29671
|
+
"ZONE"
|
|
29672
|
+
];
|
|
29673
|
+
}
|
|
29674
|
+
});
|
|
29675
|
+
|
|
29676
|
+
// src/shared/constants/lambda.ts
|
|
29677
|
+
var LAMBDA_TIMEOUT_MS, LARGE_BATCH_WARNING_THRESHOLD, TIMEOUT_RISK_THRESHOLD, LAMBDA_MAX_PAYLOAD_SIZE_SYNC, LAMBDA_MAX_PAYLOAD_SIZE_ASYNC, LAMBDA_MAX_RESPONSE_SIZE, LAMBDA_MAX_ENV_VARS_SIZE;
|
|
29678
|
+
var init_lambda = __esm({
|
|
29679
|
+
"src/shared/constants/lambda.ts"() {
|
|
29680
|
+
"use strict";
|
|
29681
|
+
LAMBDA_TIMEOUT_MS = 15 * 60 * 1e3;
|
|
29682
|
+
LARGE_BATCH_WARNING_THRESHOLD = 1e3;
|
|
29683
|
+
TIMEOUT_RISK_THRESHOLD = 0.2;
|
|
29684
|
+
LAMBDA_MAX_PAYLOAD_SIZE_SYNC = 6 * 1024 * 1024;
|
|
29685
|
+
LAMBDA_MAX_PAYLOAD_SIZE_ASYNC = 256 * 1024;
|
|
29686
|
+
LAMBDA_MAX_RESPONSE_SIZE = 6 * 1024 * 1024;
|
|
29687
|
+
LAMBDA_MAX_ENV_VARS_SIZE = 4 * 1024;
|
|
29688
|
+
}
|
|
29689
|
+
});
|
|
29690
|
+
|
|
29691
|
+
// src/shared/constants/index.ts
|
|
29692
|
+
var init_constants = __esm({
|
|
29693
|
+
"src/shared/constants/index.ts"() {
|
|
29694
|
+
"use strict";
|
|
29695
|
+
init_http();
|
|
29696
|
+
init_dynamodb2();
|
|
29697
|
+
init_lambda();
|
|
29698
|
+
}
|
|
29699
|
+
});
|
|
29700
|
+
|
|
29701
|
+
// src/shared/geohash/types.ts
|
|
29702
|
+
var GEOHASH_PRECISION_TABLE, DEFAULT_GEOHASH_CONFIG;
|
|
29703
|
+
var init_types2 = __esm({
|
|
29704
|
+
"src/shared/geohash/types.ts"() {
|
|
29705
|
+
"use strict";
|
|
29706
|
+
GEOHASH_PRECISION_TABLE = {
|
|
29707
|
+
1: { error: 25e5, description: "\u5927\u9678\u30EC\u30D9\u30EB" },
|
|
29708
|
+
4: { error: 2e4, description: "\u5927\u90FD\u5E02\u30EC\u30D9\u30EB" },
|
|
29709
|
+
6: { error: 610, description: "\u8FD1\u96A3\u30EC\u30D9\u30EB" },
|
|
29710
|
+
7: { error: 76, description: "\u8857\u533A\u30EC\u30D9\u30EB" },
|
|
29711
|
+
8: { error: 19, description: "\u5EFA\u7269\u30EC\u30D9\u30EB" },
|
|
29712
|
+
10: { error: 0.6, description: "\u9AD8\u7CBE\u5EA6" }
|
|
29713
|
+
};
|
|
29714
|
+
DEFAULT_GEOHASH_CONFIG = {
|
|
29715
|
+
shadowPrecision: 8,
|
|
29716
|
+
// ±19m(建物レベル)
|
|
29717
|
+
searchPrecision: 6,
|
|
29718
|
+
// ±610m(近隣レベル)
|
|
29719
|
+
minPrecision: 4,
|
|
29720
|
+
// ±20km(大都市レベル)
|
|
29721
|
+
maxIterations: 5,
|
|
29722
|
+
candidateMultiplier: 3
|
|
29723
|
+
};
|
|
29724
|
+
}
|
|
29725
|
+
});
|
|
29726
|
+
|
|
28608
29727
|
// node_modules/ngeohash/main.js
|
|
28609
29728
|
var require_main = __commonJS({
|
|
28610
29729
|
"node_modules/ngeohash/main.js"(exports2, module2) {
|
|
@@ -28919,313 +30038,16 @@ var require_main = __commonJS({
|
|
|
28919
30038
|
}
|
|
28920
30039
|
});
|
|
28921
30040
|
|
|
28922
|
-
// src/server/handler.ts
|
|
28923
|
-
var handler_exports = {};
|
|
28924
|
-
__export(handler_exports, {
|
|
28925
|
-
handler: () => handler
|
|
28926
|
-
});
|
|
28927
|
-
module.exports = __toCommonJS(handler_exports);
|
|
28928
|
-
|
|
28929
|
-
// src/shared/constants/http.ts
|
|
28930
|
-
var HTTP_STATUS = {
|
|
28931
|
-
OK: 200,
|
|
28932
|
-
BAD_REQUEST: 400,
|
|
28933
|
-
UNAUTHORIZED: 401,
|
|
28934
|
-
FORBIDDEN: 403,
|
|
28935
|
-
NOT_FOUND: 404,
|
|
28936
|
-
METHOD_NOT_ALLOWED: 405,
|
|
28937
|
-
INTERNAL_SERVER_ERROR: 500,
|
|
28938
|
-
NOT_IMPLEMENTED: 501
|
|
28939
|
-
};
|
|
28940
|
-
|
|
28941
|
-
// src/shared/errors/index.ts
|
|
28942
|
-
var AppError = class extends Error {
|
|
28943
|
-
constructor(code, message, statusCode = 500, details) {
|
|
28944
|
-
super(message);
|
|
28945
|
-
this.code = code;
|
|
28946
|
-
this.statusCode = statusCode;
|
|
28947
|
-
this.details = details;
|
|
28948
|
-
this.name = this.constructor.name;
|
|
28949
|
-
Error.captureStackTrace(this, this.constructor);
|
|
28950
|
-
}
|
|
28951
|
-
static {
|
|
28952
|
-
__name(this, "AppError");
|
|
28953
|
-
}
|
|
28954
|
-
/**
|
|
28955
|
-
* エラーをJSON形式に変換
|
|
28956
|
-
*/
|
|
28957
|
-
toJSON() {
|
|
28958
|
-
return {
|
|
28959
|
-
code: this.code,
|
|
28960
|
-
message: this.message,
|
|
28961
|
-
statusCode: this.statusCode,
|
|
28962
|
-
...this.details && { details: this.details }
|
|
28963
|
-
};
|
|
28964
|
-
}
|
|
28965
|
-
};
|
|
28966
|
-
var AuthError = class extends AppError {
|
|
28967
|
-
static {
|
|
28968
|
-
__name(this, "AuthError");
|
|
28969
|
-
}
|
|
28970
|
-
constructor(message, details) {
|
|
28971
|
-
super("AUTH_ERROR" /* AUTH_ERROR */, message, 401, details);
|
|
28972
|
-
}
|
|
28973
|
-
};
|
|
28974
|
-
var ConfigError = class extends AppError {
|
|
28975
|
-
static {
|
|
28976
|
-
__name(this, "ConfigError");
|
|
28977
|
-
}
|
|
28978
|
-
constructor(message, details) {
|
|
28979
|
-
super("CONFIG_ERROR" /* CONFIG_ERROR */, message, 500, details);
|
|
28980
|
-
}
|
|
28981
|
-
};
|
|
28982
|
-
var InvalidTokenError = class extends AppError {
|
|
28983
|
-
static {
|
|
28984
|
-
__name(this, "InvalidTokenError");
|
|
28985
|
-
}
|
|
28986
|
-
constructor(message, details) {
|
|
28987
|
-
super("INVALID_TOKEN" /* INVALID_TOKEN */, message, 400, details);
|
|
28988
|
-
}
|
|
28989
|
-
};
|
|
28990
|
-
var ItemNotFoundError = class extends AppError {
|
|
28991
|
-
static {
|
|
28992
|
-
__name(this, "ItemNotFoundError");
|
|
28993
|
-
}
|
|
28994
|
-
constructor(message, details) {
|
|
28995
|
-
super("ITEM_NOT_FOUND" /* ITEM_NOT_FOUND */, message, 404, details);
|
|
28996
|
-
}
|
|
28997
|
-
};
|
|
28998
|
-
function isAppError(error2) {
|
|
28999
|
-
return error2 instanceof AppError;
|
|
29000
|
-
}
|
|
29001
|
-
__name(isAppError, "isAppError");
|
|
29002
|
-
|
|
29003
|
-
// src/shared/utils/logger.ts
|
|
29004
|
-
var LOG_LEVELS = {
|
|
29005
|
-
debug: 0,
|
|
29006
|
-
info: 1,
|
|
29007
|
-
warn: 2,
|
|
29008
|
-
error: 3
|
|
29009
|
-
};
|
|
29010
|
-
function createLogger(config = {}) {
|
|
29011
|
-
const {
|
|
29012
|
-
level = process.env.LOG_LEVEL || "info",
|
|
29013
|
-
service = process.env.SERVICE_NAME,
|
|
29014
|
-
env = process.env.ENV
|
|
29015
|
-
} = config;
|
|
29016
|
-
const minLevel = LOG_LEVELS[level];
|
|
29017
|
-
function log(logLevel, message, metadata) {
|
|
29018
|
-
if (LOG_LEVELS[logLevel] < minLevel) {
|
|
29019
|
-
return;
|
|
29020
|
-
}
|
|
29021
|
-
const logEntry = {
|
|
29022
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
29023
|
-
level: logLevel,
|
|
29024
|
-
message
|
|
29025
|
-
};
|
|
29026
|
-
if (service) {
|
|
29027
|
-
logEntry.service = service;
|
|
29028
|
-
}
|
|
29029
|
-
if (env) {
|
|
29030
|
-
logEntry.env = env;
|
|
29031
|
-
}
|
|
29032
|
-
if (metadata) {
|
|
29033
|
-
Object.assign(logEntry, metadata);
|
|
29034
|
-
}
|
|
29035
|
-
const output = JSON.stringify(logEntry);
|
|
29036
|
-
if (logLevel === "error") {
|
|
29037
|
-
console.error(output);
|
|
29038
|
-
} else {
|
|
29039
|
-
console.log(output);
|
|
29040
|
-
}
|
|
29041
|
-
}
|
|
29042
|
-
__name(log, "log");
|
|
29043
|
-
return {
|
|
29044
|
-
debug(message, metadata) {
|
|
29045
|
-
log("debug", message, metadata);
|
|
29046
|
-
},
|
|
29047
|
-
info(message, metadata) {
|
|
29048
|
-
log("info", message, metadata);
|
|
29049
|
-
},
|
|
29050
|
-
warn(message, metadata) {
|
|
29051
|
-
log("warn", message, metadata);
|
|
29052
|
-
},
|
|
29053
|
-
error(message, metadata) {
|
|
29054
|
-
log("error", message, metadata);
|
|
29055
|
-
}
|
|
29056
|
-
};
|
|
29057
|
-
}
|
|
29058
|
-
__name(createLogger, "createLogger");
|
|
29059
|
-
|
|
29060
|
-
// node_modules/ulid/dist/node/index.js
|
|
29061
|
-
var import_node_crypto = __toESM(require("node:crypto"), 1);
|
|
29062
|
-
var ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
29063
|
-
var ENCODING_LEN = 32;
|
|
29064
|
-
var RANDOM_LEN = 16;
|
|
29065
|
-
var TIME_LEN = 10;
|
|
29066
|
-
var TIME_MAX = 281474976710655;
|
|
29067
|
-
var ULIDErrorCode;
|
|
29068
|
-
(function(ULIDErrorCode2) {
|
|
29069
|
-
ULIDErrorCode2["Base32IncorrectEncoding"] = "B32_ENC_INVALID";
|
|
29070
|
-
ULIDErrorCode2["DecodeTimeInvalidCharacter"] = "DEC_TIME_CHAR";
|
|
29071
|
-
ULIDErrorCode2["DecodeTimeValueMalformed"] = "DEC_TIME_MALFORMED";
|
|
29072
|
-
ULIDErrorCode2["EncodeTimeNegative"] = "ENC_TIME_NEG";
|
|
29073
|
-
ULIDErrorCode2["EncodeTimeSizeExceeded"] = "ENC_TIME_SIZE_EXCEED";
|
|
29074
|
-
ULIDErrorCode2["EncodeTimeValueMalformed"] = "ENC_TIME_MALFORMED";
|
|
29075
|
-
ULIDErrorCode2["PRNGDetectFailure"] = "PRNG_DETECT";
|
|
29076
|
-
ULIDErrorCode2["ULIDInvalid"] = "ULID_INVALID";
|
|
29077
|
-
ULIDErrorCode2["Unexpected"] = "UNEXPECTED";
|
|
29078
|
-
ULIDErrorCode2["UUIDInvalid"] = "UUID_INVALID";
|
|
29079
|
-
})(ULIDErrorCode || (ULIDErrorCode = {}));
|
|
29080
|
-
var ULIDError = class extends Error {
|
|
29081
|
-
static {
|
|
29082
|
-
__name(this, "ULIDError");
|
|
29083
|
-
}
|
|
29084
|
-
constructor(errorCode, message) {
|
|
29085
|
-
super(`${message} (${errorCode})`);
|
|
29086
|
-
this.name = "ULIDError";
|
|
29087
|
-
this.code = errorCode;
|
|
29088
|
-
}
|
|
29089
|
-
};
|
|
29090
|
-
function randomChar(prng) {
|
|
29091
|
-
const randomPosition = Math.floor(prng() * ENCODING_LEN) % ENCODING_LEN;
|
|
29092
|
-
return ENCODING.charAt(randomPosition);
|
|
29093
|
-
}
|
|
29094
|
-
__name(randomChar, "randomChar");
|
|
29095
|
-
function detectPRNG(root) {
|
|
29096
|
-
const rootLookup = detectRoot();
|
|
29097
|
-
const globalCrypto = rootLookup && (rootLookup.crypto || rootLookup.msCrypto) || (typeof import_node_crypto.default !== "undefined" ? import_node_crypto.default : null);
|
|
29098
|
-
if (typeof globalCrypto?.getRandomValues === "function") {
|
|
29099
|
-
return () => {
|
|
29100
|
-
const buffer = new Uint8Array(1);
|
|
29101
|
-
globalCrypto.getRandomValues(buffer);
|
|
29102
|
-
return buffer[0] / 256;
|
|
29103
|
-
};
|
|
29104
|
-
} else if (typeof globalCrypto?.randomBytes === "function") {
|
|
29105
|
-
return () => globalCrypto.randomBytes(1).readUInt8() / 256;
|
|
29106
|
-
} else if (import_node_crypto.default?.randomBytes) {
|
|
29107
|
-
return () => import_node_crypto.default.randomBytes(1).readUInt8() / 256;
|
|
29108
|
-
}
|
|
29109
|
-
throw new ULIDError(ULIDErrorCode.PRNGDetectFailure, "Failed to find a reliable PRNG");
|
|
29110
|
-
}
|
|
29111
|
-
__name(detectPRNG, "detectPRNG");
|
|
29112
|
-
function detectRoot() {
|
|
29113
|
-
if (inWebWorker())
|
|
29114
|
-
return self;
|
|
29115
|
-
if (typeof window !== "undefined") {
|
|
29116
|
-
return window;
|
|
29117
|
-
}
|
|
29118
|
-
if (typeof global !== "undefined") {
|
|
29119
|
-
return global;
|
|
29120
|
-
}
|
|
29121
|
-
if (typeof globalThis !== "undefined") {
|
|
29122
|
-
return globalThis;
|
|
29123
|
-
}
|
|
29124
|
-
return null;
|
|
29125
|
-
}
|
|
29126
|
-
__name(detectRoot, "detectRoot");
|
|
29127
|
-
function encodeRandom(len, prng) {
|
|
29128
|
-
let str = "";
|
|
29129
|
-
for (; len > 0; len--) {
|
|
29130
|
-
str = randomChar(prng) + str;
|
|
29131
|
-
}
|
|
29132
|
-
return str;
|
|
29133
|
-
}
|
|
29134
|
-
__name(encodeRandom, "encodeRandom");
|
|
29135
|
-
function encodeTime(now, len = TIME_LEN) {
|
|
29136
|
-
if (isNaN(now)) {
|
|
29137
|
-
throw new ULIDError(ULIDErrorCode.EncodeTimeValueMalformed, `Time must be a number: ${now}`);
|
|
29138
|
-
} else if (now > TIME_MAX) {
|
|
29139
|
-
throw new ULIDError(ULIDErrorCode.EncodeTimeSizeExceeded, `Cannot encode a time larger than ${TIME_MAX}: ${now}`);
|
|
29140
|
-
} else if (now < 0) {
|
|
29141
|
-
throw new ULIDError(ULIDErrorCode.EncodeTimeNegative, `Time must be positive: ${now}`);
|
|
29142
|
-
} else if (Number.isInteger(now) === false) {
|
|
29143
|
-
throw new ULIDError(ULIDErrorCode.EncodeTimeValueMalformed, `Time must be an integer: ${now}`);
|
|
29144
|
-
}
|
|
29145
|
-
let mod, str = "";
|
|
29146
|
-
for (let currentLen = len; currentLen > 0; currentLen--) {
|
|
29147
|
-
mod = now % ENCODING_LEN;
|
|
29148
|
-
str = ENCODING.charAt(mod) + str;
|
|
29149
|
-
now = (now - mod) / ENCODING_LEN;
|
|
29150
|
-
}
|
|
29151
|
-
return str;
|
|
29152
|
-
}
|
|
29153
|
-
__name(encodeTime, "encodeTime");
|
|
29154
|
-
function inWebWorker() {
|
|
29155
|
-
return typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope;
|
|
29156
|
-
}
|
|
29157
|
-
__name(inWebWorker, "inWebWorker");
|
|
29158
|
-
function ulid(seedTime, prng) {
|
|
29159
|
-
const currentPRNG = prng || detectPRNG();
|
|
29160
|
-
const seed = !seedTime || isNaN(seedTime) ? Date.now() : seedTime;
|
|
29161
|
-
return encodeTime(seed, TIME_LEN) + encodeRandom(RANDOM_LEN, currentPRNG);
|
|
29162
|
-
}
|
|
29163
|
-
__name(ulid, "ulid");
|
|
29164
|
-
|
|
29165
|
-
// src/shared/utils/ulid.ts
|
|
29166
|
-
function ulid2() {
|
|
29167
|
-
return ulid();
|
|
29168
|
-
}
|
|
29169
|
-
__name(ulid2, "ulid");
|
|
29170
|
-
|
|
29171
|
-
// src/shared/utils/dynamodb.ts
|
|
29172
|
-
var import_client_dynamodb = __toESM(require_dist_cjs64(), 1);
|
|
29173
|
-
var import_lib_dynamodb = __toESM(require_dist_cjs66(), 1);
|
|
29174
|
-
function createDynamoDBClient(config = {}) {
|
|
29175
|
-
const { region = process.env.AWS_REGION || "us-east-1", endpoint } = config;
|
|
29176
|
-
const client = new import_client_dynamodb.DynamoDBClient({
|
|
29177
|
-
region,
|
|
29178
|
-
...endpoint && { endpoint }
|
|
29179
|
-
});
|
|
29180
|
-
const docClient = import_lib_dynamodb.DynamoDBDocumentClient.from(client, {
|
|
29181
|
-
marshallOptions: {
|
|
29182
|
-
removeUndefinedValues: true,
|
|
29183
|
-
convertEmptyValues: false
|
|
29184
|
-
},
|
|
29185
|
-
unmarshallOptions: {
|
|
29186
|
-
wrapNumbers: false
|
|
29187
|
-
}
|
|
29188
|
-
});
|
|
29189
|
-
return docClient;
|
|
29190
|
-
}
|
|
29191
|
-
__name(createDynamoDBClient, "createDynamoDBClient");
|
|
29192
|
-
|
|
29193
|
-
// src/shared/constants/dynamodb.ts
|
|
29194
|
-
var DYNAMODB_TRANSACT_WRITE_MAX_ITEMS = 100;
|
|
29195
|
-
var DYNAMODB_QUERY_MAX_SIZE_BYTES = 1024 * 1024;
|
|
29196
|
-
var DYNAMODB_SCAN_MAX_SIZE_BYTES = 1024 * 1024;
|
|
29197
|
-
|
|
29198
|
-
// src/shared/constants/lambda.ts
|
|
29199
|
-
var LAMBDA_TIMEOUT_MS = 15 * 60 * 1e3;
|
|
29200
|
-
var LARGE_BATCH_WARNING_THRESHOLD = 1e3;
|
|
29201
|
-
var TIMEOUT_RISK_THRESHOLD = 0.2;
|
|
29202
|
-
var LAMBDA_MAX_PAYLOAD_SIZE_SYNC = 6 * 1024 * 1024;
|
|
29203
|
-
var LAMBDA_MAX_PAYLOAD_SIZE_ASYNC = 256 * 1024;
|
|
29204
|
-
var LAMBDA_MAX_RESPONSE_SIZE = 6 * 1024 * 1024;
|
|
29205
|
-
var LAMBDA_MAX_ENV_VARS_SIZE = 4 * 1024;
|
|
29206
|
-
|
|
29207
|
-
// src/shared/geohash/types.ts
|
|
29208
|
-
var DEFAULT_GEOHASH_CONFIG = {
|
|
29209
|
-
shadowPrecision: 8,
|
|
29210
|
-
// ±19m(建物レベル)
|
|
29211
|
-
searchPrecision: 6,
|
|
29212
|
-
// ±610m(近隣レベル)
|
|
29213
|
-
minPrecision: 4,
|
|
29214
|
-
// ±20km(大都市レベル)
|
|
29215
|
-
maxIterations: 5,
|
|
29216
|
-
candidateMultiplier: 3
|
|
29217
|
-
};
|
|
29218
|
-
|
|
29219
30041
|
// src/shared/geohash/utils.ts
|
|
29220
|
-
var import_ngeohash = __toESM(require_main(), 1);
|
|
29221
30042
|
function isGeoCoordinates(value) {
|
|
29222
30043
|
return typeof value === "object" && value !== null && "latitude" in value && "longitude" in value && typeof value.latitude === "number" && typeof value.longitude === "number" && value.latitude >= -90 && value.latitude <= 90 && value.longitude >= -180 && value.longitude <= 180;
|
|
29223
30044
|
}
|
|
29224
|
-
__name(isGeoCoordinates, "isGeoCoordinates");
|
|
29225
30045
|
function encodeGeoHash(latitude, longitude, precision = 6) {
|
|
29226
30046
|
return import_ngeohash.default.encode(latitude, longitude, precision);
|
|
29227
30047
|
}
|
|
29228
|
-
|
|
30048
|
+
function decodeGeoHash(geohash) {
|
|
30049
|
+
return import_ngeohash.default.decode(geohash);
|
|
30050
|
+
}
|
|
29229
30051
|
function getNeighborGeoHashes(geohash) {
|
|
29230
30052
|
const neighbors = [
|
|
29231
30053
|
geohash,
|
|
@@ -29249,7 +30071,6 @@ function getNeighborGeoHashes(geohash) {
|
|
|
29249
30071
|
];
|
|
29250
30072
|
return Array.from(new Set(neighbors));
|
|
29251
30073
|
}
|
|
29252
|
-
__name(getNeighborGeoHashes, "getNeighborGeoHashes");
|
|
29253
30074
|
function calculateDistance(lat1, lon1, lat2, lon2) {
|
|
29254
30075
|
const R = 6371e3;
|
|
29255
30076
|
const \u03C61 = lat1 * Math.PI / 180;
|
|
@@ -29260,11 +30081,9 @@ function calculateDistance(lat1, lon1, lat2, lon2) {
|
|
|
29260
30081
|
const c4 = 2 * Math.atan2(Math.sqrt(a4), Math.sqrt(1 - a4));
|
|
29261
30082
|
return R * c4;
|
|
29262
30083
|
}
|
|
29263
|
-
__name(calculateDistance, "calculateDistance");
|
|
29264
30084
|
function isNearQueryGeoJSON(query) {
|
|
29265
30085
|
return "$geometry" in query && query.$geometry.type === "Point";
|
|
29266
30086
|
}
|
|
29267
|
-
__name(isNearQueryGeoJSON, "isNearQueryGeoJSON");
|
|
29268
30087
|
function extractCoordinatesFromNearQuery(query) {
|
|
29269
30088
|
if (isNearQueryGeoJSON(query)) {
|
|
29270
30089
|
return {
|
|
@@ -29278,7 +30097,6 @@ function extractCoordinatesFromNearQuery(query) {
|
|
|
29278
30097
|
};
|
|
29279
30098
|
}
|
|
29280
30099
|
}
|
|
29281
|
-
__name(extractCoordinatesFromNearQuery, "extractCoordinatesFromNearQuery");
|
|
29282
30100
|
function extractMaxDistanceFromNearQuery(query) {
|
|
29283
30101
|
if (isNearQueryGeoJSON(query)) {
|
|
29284
30102
|
return query.$maxDistance;
|
|
@@ -29286,7 +30104,6 @@ function extractMaxDistanceFromNearQuery(query) {
|
|
|
29286
30104
|
return query.maxDistance;
|
|
29287
30105
|
}
|
|
29288
30106
|
}
|
|
29289
|
-
__name(extractMaxDistanceFromNearQuery, "extractMaxDistanceFromNearQuery");
|
|
29290
30107
|
function extractMinDistanceFromNearQuery(query) {
|
|
29291
30108
|
if (isNearQueryGeoJSON(query)) {
|
|
29292
30109
|
return query.$minDistance;
|
|
@@ -29294,24 +30111,125 @@ function extractMinDistanceFromNearQuery(query) {
|
|
|
29294
30111
|
return query.minDistance;
|
|
29295
30112
|
}
|
|
29296
30113
|
}
|
|
29297
|
-
|
|
29298
|
-
|
|
29299
|
-
|
|
29300
|
-
|
|
30114
|
+
function validateLocation(latitude, longitude) {
|
|
30115
|
+
if (latitude < -90 || latitude > 90) {
|
|
30116
|
+
throw new Error("Latitude must be between -90 and 90");
|
|
30117
|
+
}
|
|
30118
|
+
if (longitude < -180 || longitude > 180) {
|
|
30119
|
+
throw new Error("Longitude must be between -180 and 180");
|
|
30120
|
+
}
|
|
30121
|
+
}
|
|
30122
|
+
var import_ngeohash;
|
|
30123
|
+
var init_utils3 = __esm({
|
|
30124
|
+
"src/shared/geohash/utils.ts"() {
|
|
30125
|
+
"use strict";
|
|
30126
|
+
import_ngeohash = __toESM(require_main(), 1);
|
|
30127
|
+
__name(isGeoCoordinates, "isGeoCoordinates");
|
|
30128
|
+
__name(encodeGeoHash, "encodeGeoHash");
|
|
30129
|
+
__name(decodeGeoHash, "decodeGeoHash");
|
|
30130
|
+
__name(getNeighborGeoHashes, "getNeighborGeoHashes");
|
|
30131
|
+
__name(calculateDistance, "calculateDistance");
|
|
30132
|
+
__name(isNearQueryGeoJSON, "isNearQueryGeoJSON");
|
|
30133
|
+
__name(extractCoordinatesFromNearQuery, "extractCoordinatesFromNearQuery");
|
|
30134
|
+
__name(extractMaxDistanceFromNearQuery, "extractMaxDistanceFromNearQuery");
|
|
30135
|
+
__name(extractMinDistanceFromNearQuery, "extractMinDistanceFromNearQuery");
|
|
30136
|
+
__name(validateLocation, "validateLocation");
|
|
30137
|
+
}
|
|
30138
|
+
});
|
|
30139
|
+
|
|
30140
|
+
// src/shared/geohash/index.ts
|
|
30141
|
+
var init_geohash = __esm({
|
|
30142
|
+
"src/shared/geohash/index.ts"() {
|
|
30143
|
+
"use strict";
|
|
30144
|
+
init_types2();
|
|
30145
|
+
init_utils3();
|
|
30146
|
+
}
|
|
30147
|
+
});
|
|
30148
|
+
|
|
30149
|
+
// src/shared/index.ts
|
|
30150
|
+
var shared_exports = {};
|
|
30151
|
+
__export(shared_exports, {
|
|
30152
|
+
AppError: () => AppError,
|
|
30153
|
+
AuthError: () => AuthError,
|
|
30154
|
+
ConfigError: () => ConfigError,
|
|
30155
|
+
DEFAULT_GEOHASH_CONFIG: () => DEFAULT_GEOHASH_CONFIG,
|
|
30156
|
+
DEFAULT_HTTP_TIMEOUT_MS: () => DEFAULT_HTTP_TIMEOUT_MS,
|
|
30157
|
+
DYNAMODB_BATCH_GET_MAX_ITEMS: () => DYNAMODB_BATCH_GET_MAX_ITEMS,
|
|
30158
|
+
DYNAMODB_BATCH_WRITE_MAX_ITEMS: () => DYNAMODB_BATCH_WRITE_MAX_ITEMS,
|
|
30159
|
+
DYNAMODB_QUERY_MAX_SIZE_BYTES: () => DYNAMODB_QUERY_MAX_SIZE_BYTES,
|
|
30160
|
+
DYNAMODB_RESERVED_WORDS: () => DYNAMODB_RESERVED_WORDS,
|
|
30161
|
+
DYNAMODB_SCAN_MAX_SIZE_BYTES: () => DYNAMODB_SCAN_MAX_SIZE_BYTES,
|
|
30162
|
+
DYNAMODB_TRANSACT_WRITE_MAX_ITEMS: () => DYNAMODB_TRANSACT_WRITE_MAX_ITEMS,
|
|
30163
|
+
ErrorCode: () => ErrorCode,
|
|
30164
|
+
GEOHASH_PRECISION_TABLE: () => GEOHASH_PRECISION_TABLE,
|
|
30165
|
+
HTTP_METHOD: () => HTTP_METHOD,
|
|
30166
|
+
HTTP_STATUS: () => HTTP_STATUS,
|
|
30167
|
+
InvalidFilterError: () => InvalidFilterError,
|
|
30168
|
+
InvalidTokenError: () => InvalidTokenError,
|
|
30169
|
+
ItemNotFoundError: () => ItemNotFoundError,
|
|
30170
|
+
LAMBDA_MAX_ENV_VARS_SIZE: () => LAMBDA_MAX_ENV_VARS_SIZE,
|
|
30171
|
+
LAMBDA_MAX_PAYLOAD_SIZE_ASYNC: () => LAMBDA_MAX_PAYLOAD_SIZE_ASYNC,
|
|
30172
|
+
LAMBDA_MAX_PAYLOAD_SIZE_SYNC: () => LAMBDA_MAX_PAYLOAD_SIZE_SYNC,
|
|
30173
|
+
LAMBDA_MAX_RESPONSE_SIZE: () => LAMBDA_MAX_RESPONSE_SIZE,
|
|
30174
|
+
LAMBDA_TIMEOUT_MS: () => LAMBDA_TIMEOUT_MS,
|
|
30175
|
+
LARGE_BATCH_WARNING_THRESHOLD: () => LARGE_BATCH_WARNING_THRESHOLD,
|
|
30176
|
+
PartialFailureError: () => PartialFailureError,
|
|
30177
|
+
TIMEOUT_RISK_THRESHOLD: () => TIMEOUT_RISK_THRESHOLD,
|
|
30178
|
+
VersionConflictError: () => VersionConflictError,
|
|
30179
|
+
calculateDistance: () => calculateDistance,
|
|
30180
|
+
createDynamoDBClient: () => createDynamoDBClient,
|
|
30181
|
+
createLogger: () => createLogger,
|
|
30182
|
+
decodeGeoHash: () => decodeGeoHash,
|
|
30183
|
+
decodeTime: () => decodeTime,
|
|
30184
|
+
encodeGeoHash: () => encodeGeoHash,
|
|
30185
|
+
extractCoordinatesFromNearQuery: () => extractCoordinatesFromNearQuery,
|
|
30186
|
+
extractMaxDistanceFromNearQuery: () => extractMaxDistanceFromNearQuery,
|
|
30187
|
+
extractMinDistanceFromNearQuery: () => extractMinDistanceFromNearQuery,
|
|
30188
|
+
getErrorClass: () => getErrorClass,
|
|
30189
|
+
getNeighborGeoHashes: () => getNeighborGeoHashes,
|
|
30190
|
+
isAppError: () => isAppError,
|
|
30191
|
+
isGeoCoordinates: () => isGeoCoordinates,
|
|
30192
|
+
isNearQueryGeoJSON: () => isNearQueryGeoJSON,
|
|
30193
|
+
ulid: () => ulid2,
|
|
30194
|
+
ulidWithTime: () => ulidWithTime,
|
|
30195
|
+
validateISO8601DateTime: () => validateISO8601DateTime,
|
|
30196
|
+
validateLocation: () => validateLocation,
|
|
30197
|
+
validateNonEmptyArray: () => validateNonEmptyArray,
|
|
30198
|
+
validateNonEmptyString: () => validateNonEmptyString,
|
|
30199
|
+
validateNumberRange: () => validateNumberRange,
|
|
30200
|
+
validateRequiredFields: () => validateRequiredFields,
|
|
30201
|
+
validateSortField: () => validateSortField,
|
|
30202
|
+
validateULID: () => validateULID
|
|
30203
|
+
});
|
|
30204
|
+
var init_shared = __esm({
|
|
30205
|
+
"src/shared/index.ts"() {
|
|
30206
|
+
"use strict";
|
|
30207
|
+
init_types();
|
|
30208
|
+
init_errors();
|
|
30209
|
+
init_utils2();
|
|
30210
|
+
init_constants();
|
|
30211
|
+
init_geohash();
|
|
30212
|
+
}
|
|
30213
|
+
});
|
|
29301
30214
|
|
|
29302
30215
|
// src/shared/constants/formatting.ts
|
|
29303
|
-
var NUMBER_FORMAT
|
|
29304
|
-
|
|
29305
|
-
|
|
29306
|
-
|
|
29307
|
-
|
|
29308
|
-
|
|
30216
|
+
var NUMBER_FORMAT;
|
|
30217
|
+
var init_formatting = __esm({
|
|
30218
|
+
"src/shared/constants/formatting.ts"() {
|
|
30219
|
+
"use strict";
|
|
30220
|
+
NUMBER_FORMAT = {
|
|
30221
|
+
/** シャドウSKで使用する数値の桁数(20桁ゼロ埋め) */
|
|
30222
|
+
SHADOW_SK_DIGITS: 20,
|
|
30223
|
+
/** ゼロ埋め文字 */
|
|
30224
|
+
ZERO_PAD_CHAR: "0"
|
|
30225
|
+
};
|
|
30226
|
+
}
|
|
30227
|
+
});
|
|
29309
30228
|
|
|
29310
30229
|
// src/shadows/generator.ts
|
|
29311
30230
|
function escapeString(value) {
|
|
29312
30231
|
return value.replace(/#/g, "##").replace(/ /g, "#");
|
|
29313
30232
|
}
|
|
29314
|
-
__name(escapeString, "escapeString");
|
|
29315
30233
|
function formatDatetime(value) {
|
|
29316
30234
|
if (value === null || value === void 0) {
|
|
29317
30235
|
return "";
|
|
@@ -29322,18 +30240,25 @@ function formatDatetime(value) {
|
|
|
29322
30240
|
}
|
|
29323
30241
|
return date2.toISOString();
|
|
29324
30242
|
}
|
|
29325
|
-
__name(formatDatetime, "formatDatetime");
|
|
29326
30243
|
function formatBoolean(value) {
|
|
29327
30244
|
if (value === null || value === void 0) {
|
|
29328
30245
|
return "";
|
|
29329
30246
|
}
|
|
29330
30247
|
return value ? "true" : "false";
|
|
29331
30248
|
}
|
|
29332
|
-
__name(formatBoolean, "formatBoolean");
|
|
29333
30249
|
function generateMainRecordSK(recordId) {
|
|
29334
30250
|
return `id#${recordId}`;
|
|
29335
30251
|
}
|
|
29336
|
-
|
|
30252
|
+
var init_generator = __esm({
|
|
30253
|
+
"src/shadows/generator.ts"() {
|
|
30254
|
+
"use strict";
|
|
30255
|
+
init_formatting();
|
|
30256
|
+
__name(escapeString, "escapeString");
|
|
30257
|
+
__name(formatDatetime, "formatDatetime");
|
|
30258
|
+
__name(formatBoolean, "formatBoolean");
|
|
30259
|
+
__name(generateMainRecordSK, "generateMainRecordSK");
|
|
30260
|
+
}
|
|
30261
|
+
});
|
|
29337
30262
|
|
|
29338
30263
|
// src/shadows/differ.ts
|
|
29339
30264
|
function calculateShadowDiff(oldShadowKeys, newShadowKeys) {
|
|
@@ -29346,11 +30271,25 @@ function calculateShadowDiff(oldShadowKeys, newShadowKeys) {
|
|
|
29346
30271
|
toAdd
|
|
29347
30272
|
};
|
|
29348
30273
|
}
|
|
29349
|
-
__name(calculateShadowDiff, "calculateShadowDiff");
|
|
29350
30274
|
function isDiffEmpty(diff) {
|
|
29351
30275
|
return diff.toDelete.length === 0 && diff.toAdd.length === 0;
|
|
29352
30276
|
}
|
|
29353
|
-
|
|
30277
|
+
var init_differ = __esm({
|
|
30278
|
+
"src/shadows/differ.ts"() {
|
|
30279
|
+
"use strict";
|
|
30280
|
+
__name(calculateShadowDiff, "calculateShadowDiff");
|
|
30281
|
+
__name(isDiffEmpty, "isDiffEmpty");
|
|
30282
|
+
}
|
|
30283
|
+
});
|
|
30284
|
+
|
|
30285
|
+
// src/shadows/index.ts
|
|
30286
|
+
var init_shadows = __esm({
|
|
30287
|
+
"src/shadows/index.ts"() {
|
|
30288
|
+
"use strict";
|
|
30289
|
+
init_generator();
|
|
30290
|
+
init_differ();
|
|
30291
|
+
}
|
|
30292
|
+
});
|
|
29354
30293
|
|
|
29355
30294
|
// src/server/shadow/typeInference.ts
|
|
29356
30295
|
function inferFieldType(value) {
|
|
@@ -29377,7 +30316,12 @@ function inferFieldType(value) {
|
|
|
29377
30316
|
}
|
|
29378
30317
|
return null;
|
|
29379
30318
|
}
|
|
29380
|
-
|
|
30319
|
+
var init_typeInference = __esm({
|
|
30320
|
+
"src/server/shadow/typeInference.ts"() {
|
|
30321
|
+
"use strict";
|
|
30322
|
+
__name(inferFieldType, "inferFieldType");
|
|
30323
|
+
}
|
|
30324
|
+
});
|
|
29381
30325
|
|
|
29382
30326
|
// src/server/shadow/generator.ts
|
|
29383
30327
|
function normalizeJson(value) {
|
|
@@ -29397,7 +30341,6 @@ function normalizeJson(value) {
|
|
|
29397
30341
|
}
|
|
29398
30342
|
return value;
|
|
29399
30343
|
}
|
|
29400
|
-
__name(normalizeJson, "normalizeJson");
|
|
29401
30344
|
function truncateString(value, maxBytes) {
|
|
29402
30345
|
const encoder = new TextEncoder();
|
|
29403
30346
|
const bytes = encoder.encode(value);
|
|
@@ -29409,11 +30352,9 @@ function truncateString(value, maxBytes) {
|
|
|
29409
30352
|
truncated = truncated.replace(/[\uFFFD]$/, "");
|
|
29410
30353
|
return truncated;
|
|
29411
30354
|
}
|
|
29412
|
-
__name(truncateString, "truncateString");
|
|
29413
30355
|
function escapeString2(value) {
|
|
29414
30356
|
return escapeString(value);
|
|
29415
30357
|
}
|
|
29416
|
-
__name(escapeString2, "escapeString");
|
|
29417
30358
|
function formatNumberWithOffset(value, padding) {
|
|
29418
30359
|
if (!Number.isFinite(value)) {
|
|
29419
30360
|
throw new Error(`Invalid number value: ${value}`);
|
|
@@ -29426,15 +30367,12 @@ function formatNumberWithOffset(value, padding) {
|
|
|
29426
30367
|
const adjusted = Math.floor(value) + offset;
|
|
29427
30368
|
return adjusted.toString().padStart(padding + 1, "0");
|
|
29428
30369
|
}
|
|
29429
|
-
__name(formatNumberWithOffset, "formatNumberWithOffset");
|
|
29430
30370
|
function formatDatetime2(value) {
|
|
29431
30371
|
return formatDatetime(value);
|
|
29432
30372
|
}
|
|
29433
|
-
__name(formatDatetime2, "formatDatetime");
|
|
29434
30373
|
function formatBoolean2(value) {
|
|
29435
30374
|
return formatBoolean(value);
|
|
29436
30375
|
}
|
|
29437
|
-
__name(formatBoolean2, "formatBoolean");
|
|
29438
30376
|
function formatFieldValue2(type, value, config) {
|
|
29439
30377
|
switch (type) {
|
|
29440
30378
|
case "string": {
|
|
@@ -29462,11 +30400,9 @@ function formatFieldValue2(type, value, config) {
|
|
|
29462
30400
|
throw new Error(`Unknown shadow field type: ${type}`);
|
|
29463
30401
|
}
|
|
29464
30402
|
}
|
|
29465
|
-
__name(formatFieldValue2, "formatFieldValue");
|
|
29466
30403
|
function generateMainRecordSK2(recordId) {
|
|
29467
30404
|
return generateMainRecordSK(recordId);
|
|
29468
30405
|
}
|
|
29469
|
-
__name(generateMainRecordSK2, "generateMainRecordSK");
|
|
29470
30406
|
function generateShadowRecords(record, resourceName, config) {
|
|
29471
30407
|
const shadows = [];
|
|
29472
30408
|
for (const [fieldName, value] of Object.entries(record)) {
|
|
@@ -29507,10 +30443,33 @@ function generateShadowRecords(record, resourceName, config) {
|
|
|
29507
30443
|
}
|
|
29508
30444
|
return shadows;
|
|
29509
30445
|
}
|
|
29510
|
-
|
|
30446
|
+
var init_generator2 = __esm({
|
|
30447
|
+
"src/server/shadow/generator.ts"() {
|
|
30448
|
+
"use strict";
|
|
30449
|
+
init_shadows();
|
|
30450
|
+
init_geohash();
|
|
30451
|
+
init_typeInference();
|
|
30452
|
+
__name(normalizeJson, "normalizeJson");
|
|
30453
|
+
__name(truncateString, "truncateString");
|
|
30454
|
+
__name(escapeString2, "escapeString");
|
|
30455
|
+
__name(formatNumberWithOffset, "formatNumberWithOffset");
|
|
30456
|
+
__name(formatDatetime2, "formatDatetime");
|
|
30457
|
+
__name(formatBoolean2, "formatBoolean");
|
|
30458
|
+
__name(formatFieldValue2, "formatFieldValue");
|
|
30459
|
+
__name(generateMainRecordSK2, "generateMainRecordSK");
|
|
30460
|
+
__name(generateShadowRecords, "generateShadowRecords");
|
|
30461
|
+
}
|
|
30462
|
+
});
|
|
30463
|
+
|
|
30464
|
+
// src/server/shadow/differ.ts
|
|
30465
|
+
var init_differ2 = __esm({
|
|
30466
|
+
"src/server/shadow/differ.ts"() {
|
|
30467
|
+
"use strict";
|
|
30468
|
+
init_shadows();
|
|
30469
|
+
}
|
|
30470
|
+
});
|
|
29511
30471
|
|
|
29512
30472
|
// src/server/shadow/config.ts
|
|
29513
|
-
var cachedShadowConfig = null;
|
|
29514
30473
|
function getShadowConfig() {
|
|
29515
30474
|
if (!cachedShadowConfig) {
|
|
29516
30475
|
cachedShadowConfig = {
|
|
@@ -29528,229 +30487,27 @@ function getShadowConfig() {
|
|
|
29528
30487
|
}
|
|
29529
30488
|
return cachedShadowConfig;
|
|
29530
30489
|
}
|
|
29531
|
-
|
|
29532
|
-
|
|
29533
|
-
|
|
29534
|
-
|
|
29535
|
-
|
|
29536
|
-
|
|
29537
|
-
logger2.warn(`Large batch ${operation2} operation detected`, {
|
|
29538
|
-
requestId,
|
|
29539
|
-
resource,
|
|
29540
|
-
recordCount,
|
|
29541
|
-
warningThreshold: LARGE_BATCH_WARNING_THRESHOLD,
|
|
29542
|
-
estimatedTimeoutRisk: "high",
|
|
29543
|
-
recommendation: "Consider splitting the batch into smaller requests to avoid Lambda timeout (15 min limit)"
|
|
29544
|
-
});
|
|
29545
|
-
}
|
|
29546
|
-
}
|
|
29547
|
-
__name(logLargeBatchWarning, "logLargeBatchWarning");
|
|
29548
|
-
function calculateTimeoutRisk(startTime) {
|
|
29549
|
-
const elapsedMs = Date.now() - startTime;
|
|
29550
|
-
const remainingMs = LAMBDA_TIMEOUT_MS - elapsedMs;
|
|
29551
|
-
const utilizationPercent = Math.round(elapsedMs / LAMBDA_TIMEOUT_MS * 100);
|
|
29552
|
-
const risk = remainingMs < LAMBDA_TIMEOUT_MS * TIMEOUT_RISK_THRESHOLD ? "high" : "low";
|
|
29553
|
-
return {
|
|
29554
|
-
elapsedMs,
|
|
29555
|
-
remainingMs,
|
|
29556
|
-
risk,
|
|
29557
|
-
utilizationPercent
|
|
29558
|
-
};
|
|
29559
|
-
}
|
|
29560
|
-
__name(calculateTimeoutRisk, "calculateTimeoutRisk");
|
|
29561
|
-
function logPreparationTimeoutRisk(requestId, resource, totalRecords, chunkCount, riskInfo) {
|
|
29562
|
-
logger2.info("Records prepared for chunk execution", {
|
|
29563
|
-
requestId,
|
|
29564
|
-
resource,
|
|
29565
|
-
totalRecords,
|
|
29566
|
-
chunkCount,
|
|
29567
|
-
preparationTimeMs: riskInfo.elapsedMs,
|
|
29568
|
-
remainingTimeMs: riskInfo.remainingMs,
|
|
29569
|
-
timeoutRisk: riskInfo.risk
|
|
29570
|
-
});
|
|
29571
|
-
if (riskInfo.risk === "high") {
|
|
29572
|
-
logger2.warn("High timeout risk detected during preparation phase", {
|
|
29573
|
-
requestId,
|
|
29574
|
-
resource,
|
|
29575
|
-
preparationElapsedMs: riskInfo.elapsedMs,
|
|
29576
|
-
remainingTimeMs: riskInfo.remainingMs,
|
|
29577
|
-
lambdaTimeoutMs: LAMBDA_TIMEOUT_MS,
|
|
29578
|
-
recommendation: "Consider reducing batch size or optimizing preparation logic"
|
|
29579
|
-
});
|
|
30490
|
+
var cachedShadowConfig;
|
|
30491
|
+
var init_config = __esm({
|
|
30492
|
+
"src/server/shadow/config.ts"() {
|
|
30493
|
+
"use strict";
|
|
30494
|
+
cachedShadowConfig = null;
|
|
30495
|
+
__name(getShadowConfig, "getShadowConfig");
|
|
29580
30496
|
}
|
|
29581
|
-
}
|
|
29582
|
-
__name(logPreparationTimeoutRisk, "logPreparationTimeoutRisk");
|
|
29583
|
-
function logBulkOperationComplete(operation2, requestId, resource, requested, succeeded, failed, riskInfo, additionalInfo) {
|
|
29584
|
-
const totalElapsedSeconds = Math.round(riskInfo.elapsedMs / 1e3);
|
|
29585
|
-
logger2.info(`${operation2} completed`, {
|
|
29586
|
-
requestId,
|
|
29587
|
-
resource,
|
|
29588
|
-
requested,
|
|
29589
|
-
succeeded,
|
|
29590
|
-
totalFailed: failed,
|
|
29591
|
-
totalExecutionTimeMs: riskInfo.elapsedMs,
|
|
29592
|
-
totalExecutionTimeSeconds: totalElapsedSeconds,
|
|
29593
|
-
lambdaTimeoutMs: LAMBDA_TIMEOUT_MS,
|
|
29594
|
-
timeoutUtilization: `${riskInfo.utilizationPercent}%`,
|
|
29595
|
-
...additionalInfo
|
|
29596
|
-
});
|
|
29597
|
-
}
|
|
29598
|
-
__name(logBulkOperationComplete, "logBulkOperationComplete");
|
|
29599
|
-
function logPartialFailure(operation2, requestId, resource, requested, succeeded, failed, errorCodes, additionalInfo) {
|
|
29600
|
-
const failureRate = Math.round(failed / requested * 100);
|
|
29601
|
-
logger2.warn(`Partial failure in ${operation2} operation`, {
|
|
29602
|
-
requestId,
|
|
29603
|
-
resource,
|
|
29604
|
-
totalRequested: requested,
|
|
29605
|
-
successCount: succeeded,
|
|
29606
|
-
failedCount: failed,
|
|
29607
|
-
failureRate: `${failureRate}%`,
|
|
29608
|
-
errorCodes: [...new Set(errorCodes)],
|
|
29609
|
-
...additionalInfo
|
|
29610
|
-
});
|
|
29611
|
-
}
|
|
29612
|
-
__name(logPartialFailure, "logPartialFailure");
|
|
30497
|
+
});
|
|
29613
30498
|
|
|
29614
|
-
// src/server/
|
|
29615
|
-
var
|
|
29616
|
-
|
|
29617
|
-
|
|
29618
|
-
|
|
29619
|
-
|
|
29620
|
-
|
|
29621
|
-
|
|
29622
|
-
const itemCount = getItemCount(record);
|
|
29623
|
-
if (itemCount > DYNAMODB_TRANSACT_WRITE_MAX_ITEMS) {
|
|
29624
|
-
const errorMsg = `Single record exceeds ${DYNAMODB_TRANSACT_WRITE_MAX_ITEMS} items limit: ${itemCount} items`;
|
|
29625
|
-
logger3.error("Chunk validation failed", {
|
|
29626
|
-
itemCount,
|
|
29627
|
-
limit: DYNAMODB_TRANSACT_WRITE_MAX_ITEMS
|
|
29628
|
-
});
|
|
29629
|
-
throw new Error(errorMsg);
|
|
29630
|
-
}
|
|
29631
|
-
if (currentItemCount + itemCount > DYNAMODB_TRANSACT_WRITE_MAX_ITEMS) {
|
|
29632
|
-
if (currentChunk.length > 0) {
|
|
29633
|
-
chunks.push(currentChunk);
|
|
29634
|
-
itemCounts.push(currentItemCount);
|
|
29635
|
-
}
|
|
29636
|
-
currentChunk = [record];
|
|
29637
|
-
currentItemCount = itemCount;
|
|
29638
|
-
} else {
|
|
29639
|
-
currentChunk.push(record);
|
|
29640
|
-
currentItemCount += itemCount;
|
|
29641
|
-
}
|
|
29642
|
-
}
|
|
29643
|
-
if (currentChunk.length > 0) {
|
|
29644
|
-
chunks.push(currentChunk);
|
|
29645
|
-
itemCounts.push(currentItemCount);
|
|
29646
|
-
}
|
|
29647
|
-
logger3.info("Chunk calculation completed", {
|
|
29648
|
-
totalRecords: records.length,
|
|
29649
|
-
chunkCount: chunks.length,
|
|
29650
|
-
itemCounts,
|
|
29651
|
-
minItemsPerChunk: itemCounts.length > 0 ? Math.min(...itemCounts) : 0,
|
|
29652
|
-
maxItemsPerChunk: itemCounts.length > 0 ? Math.max(...itemCounts) : 0,
|
|
29653
|
-
avgItemsPerChunk: itemCounts.length > 0 ? Math.round(itemCounts.reduce((sum, count) => sum + count, 0) / itemCounts.length) : 0
|
|
29654
|
-
});
|
|
29655
|
-
return { chunks, itemCounts };
|
|
29656
|
-
}
|
|
29657
|
-
__name(calculateChunks, "calculateChunks");
|
|
29658
|
-
async function executeChunks(chunks, executeChunk, getRecordId) {
|
|
29659
|
-
const successRecords = [];
|
|
29660
|
-
const failedIds = [];
|
|
29661
|
-
const errors = [];
|
|
29662
|
-
const totalRecords = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
29663
|
-
const executionStartTime = Date.now();
|
|
29664
|
-
logger3.info("Starting chunk execution", {
|
|
29665
|
-
totalChunks: chunks.length,
|
|
29666
|
-
totalRecords
|
|
29667
|
-
});
|
|
29668
|
-
for (let i4 = 0; i4 < chunks.length; i4++) {
|
|
29669
|
-
const chunk = chunks[i4];
|
|
29670
|
-
const chunkStartTime = Date.now();
|
|
29671
|
-
try {
|
|
29672
|
-
logger3.debug(`Executing chunk ${i4 + 1}/${chunks.length}`, {
|
|
29673
|
-
chunkIndex: i4,
|
|
29674
|
-
recordCount: chunk.length
|
|
29675
|
-
});
|
|
29676
|
-
const successfulRecords = await executeChunk(chunk);
|
|
29677
|
-
successRecords.push(...successfulRecords);
|
|
29678
|
-
const chunkDuration = Date.now() - chunkStartTime;
|
|
29679
|
-
logger3.info(`Chunk ${i4 + 1}/${chunks.length} succeeded`, {
|
|
29680
|
-
chunkIndex: i4,
|
|
29681
|
-
recordCount: chunk.length,
|
|
29682
|
-
durationMs: chunkDuration
|
|
29683
|
-
});
|
|
29684
|
-
} catch (error2) {
|
|
29685
|
-
const chunkDuration = Date.now() - chunkStartTime;
|
|
29686
|
-
const errorMessage = error2 instanceof Error ? error2.message : "Unknown error";
|
|
29687
|
-
const errorCode = getErrorCode(error2);
|
|
29688
|
-
logger3.error(`Chunk ${i4 + 1}/${chunks.length} failed`, {
|
|
29689
|
-
chunkIndex: i4,
|
|
29690
|
-
recordCount: chunk.length,
|
|
29691
|
-
durationMs: chunkDuration,
|
|
29692
|
-
error: errorMessage,
|
|
29693
|
-
errorCode
|
|
29694
|
-
});
|
|
29695
|
-
for (const record of chunk) {
|
|
29696
|
-
const recordId = getRecordId(record);
|
|
29697
|
-
failedIds.push(recordId);
|
|
29698
|
-
errors.push({
|
|
29699
|
-
id: recordId,
|
|
29700
|
-
code: errorCode,
|
|
29701
|
-
message: errorMessage
|
|
29702
|
-
});
|
|
29703
|
-
}
|
|
29704
|
-
}
|
|
29705
|
-
}
|
|
29706
|
-
const totalExecutionTime = Date.now() - executionStartTime;
|
|
29707
|
-
logger3.info("Chunk execution completed", {
|
|
29708
|
-
totalChunks: chunks.length,
|
|
29709
|
-
totalRecords,
|
|
29710
|
-
successCount: successRecords.length,
|
|
29711
|
-
failedCount: failedIds.length,
|
|
29712
|
-
totalExecutionTimeMs: totalExecutionTime,
|
|
29713
|
-
avgTimePerChunkMs: chunks.length > 0 ? Math.round(totalExecutionTime / chunks.length) : 0
|
|
29714
|
-
});
|
|
29715
|
-
if (failedIds.length > 0) {
|
|
29716
|
-
logger3.warn("Partial failure detected in chunk execution", {
|
|
29717
|
-
totalRecords,
|
|
29718
|
-
successCount: successRecords.length,
|
|
29719
|
-
failedCount: failedIds.length,
|
|
29720
|
-
failureRate: `${Math.round(failedIds.length / totalRecords * 100)}%`,
|
|
29721
|
-
failedIds: failedIds.slice(0, 10),
|
|
29722
|
-
// 最初の10件のみログ出力
|
|
29723
|
-
errorSummary: errors.slice(0, 5).map((e4) => ({
|
|
29724
|
-
id: e4.id,
|
|
29725
|
-
code: e4.code,
|
|
29726
|
-
message: e4.message.substring(0, 100)
|
|
29727
|
-
// メッセージを100文字に制限
|
|
29728
|
-
}))
|
|
29729
|
-
});
|
|
29730
|
-
}
|
|
29731
|
-
return {
|
|
29732
|
-
successRecords,
|
|
29733
|
-
failedIds,
|
|
29734
|
-
errors
|
|
29735
|
-
};
|
|
29736
|
-
}
|
|
29737
|
-
__name(executeChunks, "executeChunks");
|
|
29738
|
-
function getErrorCode(error2) {
|
|
29739
|
-
if (error2 && typeof error2 === "object") {
|
|
29740
|
-
if ("name" in error2 && typeof error2.name === "string") {
|
|
29741
|
-
return error2.name;
|
|
29742
|
-
}
|
|
29743
|
-
if ("code" in error2 && typeof error2.code === "string") {
|
|
29744
|
-
return error2.code;
|
|
29745
|
-
}
|
|
30499
|
+
// src/server/shadow/index.ts
|
|
30500
|
+
var init_shadow = __esm({
|
|
30501
|
+
"src/server/shadow/index.ts"() {
|
|
30502
|
+
"use strict";
|
|
30503
|
+
init_generator2();
|
|
30504
|
+
init_differ2();
|
|
30505
|
+
init_config();
|
|
30506
|
+
init_typeInference();
|
|
29746
30507
|
}
|
|
29747
|
-
|
|
29748
|
-
}
|
|
29749
|
-
__name(getErrorCode, "getErrorCode");
|
|
30508
|
+
});
|
|
29750
30509
|
|
|
29751
30510
|
// src/server/utils/dynamodb.ts
|
|
29752
|
-
var logger4 = createLogger({ service: "records-lambda" });
|
|
29753
|
-
var dbClient = null;
|
|
29754
30511
|
function getDBClient() {
|
|
29755
30512
|
if (!dbClient) {
|
|
29756
30513
|
dbClient = createDynamoDBClient({
|
|
@@ -29759,7 +30516,6 @@ function getDBClient() {
|
|
|
29759
30516
|
}
|
|
29760
30517
|
return dbClient;
|
|
29761
30518
|
}
|
|
29762
|
-
__name(getDBClient, "getDBClient");
|
|
29763
30519
|
function getTableName() {
|
|
29764
30520
|
const tableName = process.env.TABLE_NAME;
|
|
29765
30521
|
if (!tableName) {
|
|
@@ -29767,17 +30523,14 @@ function getTableName() {
|
|
|
29767
30523
|
}
|
|
29768
30524
|
return tableName;
|
|
29769
30525
|
}
|
|
29770
|
-
__name(getTableName, "getTableName");
|
|
29771
30526
|
function removeShadowKeys(record) {
|
|
29772
30527
|
const { __shadowKeys, ...rest } = record;
|
|
29773
30528
|
return rest;
|
|
29774
30529
|
}
|
|
29775
|
-
__name(removeShadowKeys, "removeShadowKeys");
|
|
29776
30530
|
function extractCleanRecord(item) {
|
|
29777
30531
|
const data2 = item.data || item;
|
|
29778
30532
|
return removeShadowKeys(data2);
|
|
29779
30533
|
}
|
|
29780
|
-
__name(extractCleanRecord, "extractCleanRecord");
|
|
29781
30534
|
async function executeDynamoDBOperation(operation2, operationName) {
|
|
29782
30535
|
try {
|
|
29783
30536
|
return await operation2();
|
|
@@ -29795,312 +30548,89 @@ async function executeDynamoDBOperation(operation2, operationName) {
|
|
|
29795
30548
|
throw error2;
|
|
29796
30549
|
}
|
|
29797
30550
|
}
|
|
29798
|
-
|
|
29799
|
-
|
|
29800
|
-
|
|
29801
|
-
|
|
29802
|
-
|
|
29803
|
-
|
|
29804
|
-
|
|
29805
|
-
|
|
29806
|
-
|
|
29807
|
-
|
|
29808
|
-
|
|
29809
|
-
|
|
29810
|
-
if (ids.length === 0) {
|
|
29811
|
-
return {
|
|
29812
|
-
count: 0,
|
|
29813
|
-
successIds: {},
|
|
29814
|
-
failedIds: {},
|
|
29815
|
-
errors: {}
|
|
29816
|
-
};
|
|
30551
|
+
var logger4, dbClient;
|
|
30552
|
+
var init_dynamodb3 = __esm({
|
|
30553
|
+
"src/server/utils/dynamodb.ts"() {
|
|
30554
|
+
"use strict";
|
|
30555
|
+
init_shared();
|
|
30556
|
+
logger4 = createLogger({ service: "records-lambda" });
|
|
30557
|
+
dbClient = null;
|
|
30558
|
+
__name(getDBClient, "getDBClient");
|
|
30559
|
+
__name(getTableName, "getTableName");
|
|
30560
|
+
__name(removeShadowKeys, "removeShadowKeys");
|
|
30561
|
+
__name(extractCleanRecord, "extractCleanRecord");
|
|
30562
|
+
__name(executeDynamoDBOperation, "executeDynamoDBOperation");
|
|
29817
30563
|
}
|
|
29818
|
-
|
|
29819
|
-
|
|
29820
|
-
|
|
29821
|
-
|
|
29822
|
-
|
|
29823
|
-
|
|
29824
|
-
|
|
29825
|
-
const
|
|
29826
|
-
|
|
29827
|
-
|
|
29828
|
-
|
|
29829
|
-
|
|
29830
|
-
|
|
29831
|
-
|
|
29832
|
-
}
|
|
29833
|
-
}
|
|
29834
|
-
})
|
|
29835
|
-
),
|
|
29836
|
-
"BatchGetItem"
|
|
29837
|
-
);
|
|
29838
|
-
const existingItems = batchGetResult.Responses?.[tableName] || [];
|
|
29839
|
-
const existingIds = /* @__PURE__ */ new Set();
|
|
29840
|
-
const preparedRecords = [];
|
|
29841
|
-
for (const item of existingItems) {
|
|
29842
|
-
const existingData = item.data;
|
|
29843
|
-
const id = existingData.id;
|
|
29844
|
-
const shadowKeys = existingData.__shadowKeys || [];
|
|
29845
|
-
existingIds.add(id);
|
|
29846
|
-
preparedRecords.push({
|
|
29847
|
-
id,
|
|
29848
|
-
mainSK: generateMainRecordSK2(id),
|
|
29849
|
-
shadowKeys
|
|
29850
|
-
});
|
|
29851
|
-
}
|
|
29852
|
-
const notFoundIds = ids.filter((id) => !existingIds.has(id));
|
|
29853
|
-
const notFoundErrors = notFoundIds.map((id) => ({
|
|
29854
|
-
id,
|
|
29855
|
-
code: "ITEM_NOT_FOUND",
|
|
29856
|
-
message: `Record not found: ${id}`
|
|
29857
|
-
}));
|
|
29858
|
-
if (preparedRecords.length === 0) {
|
|
29859
|
-
logger5.info("deleteMany completed - no records found", {
|
|
29860
|
-
requestId,
|
|
29861
|
-
resource,
|
|
29862
|
-
requested: ids.length,
|
|
29863
|
-
notFound: notFoundIds.length
|
|
29864
|
-
});
|
|
29865
|
-
const failedIdsMap2 = {};
|
|
29866
|
-
const errorsMap2 = {};
|
|
29867
|
-
for (let i4 = 0; i4 < ids.length; i4++) {
|
|
29868
|
-
const id = ids[i4];
|
|
29869
|
-
if (notFoundIds.includes(id)) {
|
|
29870
|
-
failedIdsMap2[i4] = id;
|
|
29871
|
-
const error2 = notFoundErrors.find((e4) => e4.id === id);
|
|
29872
|
-
if (error2) {
|
|
29873
|
-
errorsMap2[i4] = error2;
|
|
29874
|
-
}
|
|
29875
|
-
}
|
|
29876
|
-
}
|
|
29877
|
-
return {
|
|
29878
|
-
count: 0,
|
|
29879
|
-
successIds: {},
|
|
29880
|
-
failedIds: failedIdsMap2,
|
|
29881
|
-
errors: errorsMap2
|
|
29882
|
-
};
|
|
29883
|
-
}
|
|
29884
|
-
const getItemCount = /* @__PURE__ */ __name((record) => {
|
|
29885
|
-
return 1 + record.shadowKeys.length;
|
|
29886
|
-
}, "getItemCount");
|
|
29887
|
-
const { chunks } = calculateChunks(preparedRecords, getItemCount);
|
|
29888
|
-
const preparationRiskInfo = calculateTimeoutRisk(startTime);
|
|
29889
|
-
logPreparationTimeoutRisk(
|
|
29890
|
-
requestId,
|
|
29891
|
-
resource,
|
|
29892
|
-
preparedRecords.length,
|
|
29893
|
-
chunks.length,
|
|
29894
|
-
preparationRiskInfo
|
|
29895
|
-
);
|
|
29896
|
-
const executeChunk = /* @__PURE__ */ __name(async (chunk) => {
|
|
29897
|
-
const transactItems = [];
|
|
29898
|
-
for (const record of chunk) {
|
|
29899
|
-
transactItems.push({
|
|
29900
|
-
Delete: {
|
|
29901
|
-
TableName: tableName,
|
|
29902
|
-
Key: {
|
|
29903
|
-
PK: resource,
|
|
29904
|
-
SK: record.mainSK
|
|
29905
|
-
}
|
|
29906
|
-
}
|
|
29907
|
-
});
|
|
29908
|
-
for (const shadowSK of record.shadowKeys) {
|
|
29909
|
-
transactItems.push({
|
|
29910
|
-
Delete: {
|
|
29911
|
-
TableName: tableName,
|
|
29912
|
-
Key: {
|
|
29913
|
-
PK: resource,
|
|
29914
|
-
SK: shadowSK
|
|
29915
|
-
}
|
|
29916
|
-
}
|
|
29917
|
-
});
|
|
29918
|
-
}
|
|
29919
|
-
}
|
|
29920
|
-
await executeDynamoDBOperation(
|
|
29921
|
-
() => dbClient2.send(
|
|
29922
|
-
new import_lib_dynamodb2.TransactWriteCommand({
|
|
29923
|
-
TransactItems: transactItems
|
|
29924
|
-
})
|
|
29925
|
-
),
|
|
29926
|
-
"TransactWriteItems"
|
|
29927
|
-
);
|
|
29928
|
-
return chunk;
|
|
29929
|
-
}, "executeChunk");
|
|
29930
|
-
const {
|
|
29931
|
-
successRecords,
|
|
29932
|
-
failedIds: chunkFailedIds,
|
|
29933
|
-
errors: chunkErrors
|
|
29934
|
-
} = await executeChunks(chunks, executeChunk, (record) => record.id);
|
|
29935
|
-
const successIds = {};
|
|
29936
|
-
const failedIdsMap = {};
|
|
29937
|
-
const errorsMap = {};
|
|
29938
|
-
const successIdSet = new Set(successRecords.map((r4) => r4.id));
|
|
29939
|
-
for (let i4 = 0; i4 < ids.length; i4++) {
|
|
29940
|
-
const id = ids[i4];
|
|
29941
|
-
if (successIdSet.has(id)) {
|
|
29942
|
-
successIds[i4] = id;
|
|
29943
|
-
}
|
|
29944
|
-
}
|
|
29945
|
-
for (let i4 = 0; i4 < ids.length; i4++) {
|
|
29946
|
-
const id = ids[i4];
|
|
29947
|
-
if (notFoundIds.includes(id)) {
|
|
29948
|
-
failedIdsMap[i4] = id;
|
|
29949
|
-
const error2 = notFoundErrors.find((e4) => e4.id === id);
|
|
29950
|
-
if (error2) {
|
|
29951
|
-
errorsMap[i4] = error2;
|
|
29952
|
-
}
|
|
29953
|
-
}
|
|
29954
|
-
}
|
|
29955
|
-
for (let i4 = 0; i4 < ids.length; i4++) {
|
|
29956
|
-
const id = ids[i4];
|
|
29957
|
-
if (chunkFailedIds.includes(id)) {
|
|
29958
|
-
failedIdsMap[i4] = id;
|
|
29959
|
-
const error2 = chunkErrors.find((e4) => e4.id === id);
|
|
29960
|
-
if (error2) {
|
|
29961
|
-
errorsMap[i4] = {
|
|
29962
|
-
id: error2.id,
|
|
29963
|
-
code: error2.code,
|
|
29964
|
-
message: error2.message
|
|
29965
|
-
};
|
|
29966
|
-
}
|
|
29967
|
-
}
|
|
29968
|
-
}
|
|
29969
|
-
const count = Object.keys(successIds).length;
|
|
29970
|
-
const allFailedIds = Object.values(failedIdsMap);
|
|
29971
|
-
const completionRiskInfo = calculateTimeoutRisk(startTime);
|
|
29972
|
-
logBulkOperationComplete(
|
|
29973
|
-
"deleteMany",
|
|
29974
|
-
requestId,
|
|
29975
|
-
resource,
|
|
29976
|
-
ids.length,
|
|
29977
|
-
count,
|
|
29978
|
-
allFailedIds.length,
|
|
29979
|
-
completionRiskInfo,
|
|
29980
|
-
{
|
|
29981
|
-
deleted: count,
|
|
29982
|
-
notFound: notFoundIds.length,
|
|
29983
|
-
chunkExecutionFailed: chunkFailedIds.length
|
|
29984
|
-
}
|
|
29985
|
-
);
|
|
29986
|
-
if (allFailedIds.length > 0) {
|
|
29987
|
-
logPartialFailure(
|
|
29988
|
-
"deleteMany",
|
|
29989
|
-
requestId,
|
|
29990
|
-
resource,
|
|
29991
|
-
ids.length,
|
|
29992
|
-
count,
|
|
29993
|
-
allFailedIds.length,
|
|
29994
|
-
Object.values(errorsMap).map((e4) => e4.code),
|
|
29995
|
-
{
|
|
29996
|
-
notFoundFailures: notFoundIds.length,
|
|
29997
|
-
chunkExecutionFailures: chunkFailedIds.length
|
|
29998
|
-
}
|
|
29999
|
-
);
|
|
30564
|
+
});
|
|
30565
|
+
|
|
30566
|
+
// src/server/utils/validation.ts
|
|
30567
|
+
function validateSortField2(_config, _resource, _sort) {
|
|
30568
|
+
return;
|
|
30569
|
+
}
|
|
30570
|
+
function normalizePagination(pagination) {
|
|
30571
|
+
const perPage = Math.min(pagination?.perPage || 50, 50);
|
|
30572
|
+
const nextToken = pagination?.nextToken;
|
|
30573
|
+
return { perPage, nextToken };
|
|
30574
|
+
}
|
|
30575
|
+
function normalizeSort(config, _resource, sort) {
|
|
30576
|
+
if (sort) {
|
|
30577
|
+
return sort;
|
|
30000
30578
|
}
|
|
30001
30579
|
return {
|
|
30002
|
-
|
|
30003
|
-
|
|
30004
|
-
failedIds: failedIdsMap,
|
|
30005
|
-
errors: errorsMap
|
|
30580
|
+
field: config.updatedAtField,
|
|
30581
|
+
order: "DESC"
|
|
30006
30582
|
};
|
|
30007
30583
|
}
|
|
30008
|
-
|
|
30584
|
+
var init_validation2 = __esm({
|
|
30585
|
+
"src/server/utils/validation.ts"() {
|
|
30586
|
+
"use strict";
|
|
30587
|
+
__name(validateSortField2, "validateSortField");
|
|
30588
|
+
__name(normalizePagination, "normalizePagination");
|
|
30589
|
+
__name(normalizeSort, "normalizeSort");
|
|
30590
|
+
}
|
|
30591
|
+
});
|
|
30009
30592
|
|
|
30010
|
-
// src/
|
|
30011
|
-
var
|
|
30012
|
-
|
|
30013
|
-
|
|
30014
|
-
|
|
30015
|
-
logger6.debug("Executing deleteOne", {
|
|
30016
|
-
requestId,
|
|
30017
|
-
resource,
|
|
30018
|
-
id
|
|
30019
|
-
});
|
|
30020
|
-
const dbClient2 = getDBClient();
|
|
30021
|
-
const tableName = getTableName();
|
|
30022
|
-
const mainSK = generateMainRecordSK2(id);
|
|
30023
|
-
const getResult = await executeDynamoDBOperation(
|
|
30024
|
-
() => dbClient2.send(
|
|
30025
|
-
new import_lib_dynamodb3.GetCommand({
|
|
30026
|
-
TableName: tableName,
|
|
30027
|
-
Key: {
|
|
30028
|
-
PK: resource,
|
|
30029
|
-
SK: mainSK
|
|
30030
|
-
},
|
|
30031
|
-
ConsistentRead: true
|
|
30032
|
-
})
|
|
30033
|
-
),
|
|
30034
|
-
"GetItem"
|
|
30035
|
-
);
|
|
30036
|
-
if (!getResult.Item) {
|
|
30037
|
-
throw new ItemNotFoundError(`Record not found: ${id}`, { resource, id });
|
|
30593
|
+
// src/client/FindCursor.ts
|
|
30594
|
+
var init_FindCursor = __esm({
|
|
30595
|
+
"src/client/FindCursor.ts"() {
|
|
30596
|
+
"use strict";
|
|
30597
|
+
init_http();
|
|
30038
30598
|
}
|
|
30039
|
-
|
|
30040
|
-
|
|
30041
|
-
|
|
30042
|
-
|
|
30043
|
-
|
|
30044
|
-
|
|
30045
|
-
|
|
30046
|
-
|
|
30047
|
-
SK: mainSK
|
|
30048
|
-
}
|
|
30049
|
-
}
|
|
30050
|
-
});
|
|
30051
|
-
for (const shadowSK of shadowKeys) {
|
|
30052
|
-
transactItems.push({
|
|
30053
|
-
Delete: {
|
|
30054
|
-
TableName: tableName,
|
|
30055
|
-
Key: {
|
|
30056
|
-
PK: resource,
|
|
30057
|
-
SK: shadowSK
|
|
30058
|
-
}
|
|
30059
|
-
}
|
|
30060
|
-
});
|
|
30599
|
+
});
|
|
30600
|
+
|
|
30601
|
+
// src/client/Collection.ts
|
|
30602
|
+
var init_Collection = __esm({
|
|
30603
|
+
"src/client/Collection.ts"() {
|
|
30604
|
+
"use strict";
|
|
30605
|
+
init_http();
|
|
30606
|
+
init_FindCursor();
|
|
30061
30607
|
}
|
|
30062
|
-
|
|
30063
|
-
() => dbClient2.send(
|
|
30064
|
-
new import_lib_dynamodb3.TransactWriteCommand({
|
|
30065
|
-
TransactItems: transactItems
|
|
30066
|
-
})
|
|
30067
|
-
),
|
|
30068
|
-
"TransactWriteItems"
|
|
30069
|
-
);
|
|
30070
|
-
logger6.info("deleteOne succeeded", {
|
|
30071
|
-
requestId,
|
|
30072
|
-
resource,
|
|
30073
|
-
id,
|
|
30074
|
-
shadowCount: shadowKeys.length
|
|
30075
|
-
});
|
|
30076
|
-
return { id };
|
|
30077
|
-
}
|
|
30078
|
-
__name(handleDeleteOne, "handleDeleteOne");
|
|
30608
|
+
});
|
|
30079
30609
|
|
|
30080
|
-
// src/
|
|
30081
|
-
|
|
30082
|
-
|
|
30083
|
-
|
|
30084
|
-
|
|
30085
|
-
function normalizePagination(pagination) {
|
|
30086
|
-
const perPage = Math.min(pagination?.perPage || 50, 50);
|
|
30087
|
-
const nextToken = pagination?.nextToken;
|
|
30088
|
-
return { perPage, nextToken };
|
|
30089
|
-
}
|
|
30090
|
-
__name(normalizePagination, "normalizePagination");
|
|
30091
|
-
function normalizeSort(config, _resource, sort) {
|
|
30092
|
-
if (sort) {
|
|
30093
|
-
return sort;
|
|
30610
|
+
// src/client/Database.ts
|
|
30611
|
+
var init_Database = __esm({
|
|
30612
|
+
"src/client/Database.ts"() {
|
|
30613
|
+
"use strict";
|
|
30614
|
+
init_Collection();
|
|
30094
30615
|
}
|
|
30095
|
-
|
|
30096
|
-
field: config.updatedAtField,
|
|
30097
|
-
order: "DESC"
|
|
30098
|
-
};
|
|
30099
|
-
}
|
|
30100
|
-
__name(normalizeSort, "normalizeSort");
|
|
30616
|
+
});
|
|
30101
30617
|
|
|
30102
|
-
// src/
|
|
30103
|
-
var
|
|
30618
|
+
// src/client/index.ts
|
|
30619
|
+
var init_client2 = __esm({
|
|
30620
|
+
"src/client/index.ts"() {
|
|
30621
|
+
"use strict";
|
|
30622
|
+
init_Database();
|
|
30623
|
+
init_Collection();
|
|
30624
|
+
init_FindCursor();
|
|
30625
|
+
}
|
|
30626
|
+
});
|
|
30627
|
+
|
|
30628
|
+
// src/server/query/converter.ts
|
|
30629
|
+
var init_converter = __esm({
|
|
30630
|
+
"src/server/query/converter.ts"() {
|
|
30631
|
+
"use strict";
|
|
30632
|
+
}
|
|
30633
|
+
});
|
|
30104
30634
|
|
|
30105
30635
|
// src/server/query/nearSearch.ts
|
|
30106
30636
|
async function executeNearSearch(nearQuery, fieldName, limit, searchFunction, config = DEFAULT_GEOHASH_CONFIG) {
|
|
@@ -30170,25 +30700,65 @@ async function executeNearSearch(nearQuery, fieldName, limit, searchFunction, co
|
|
|
30170
30700
|
}
|
|
30171
30701
|
};
|
|
30172
30702
|
}
|
|
30173
|
-
|
|
30703
|
+
var init_nearSearch = __esm({
|
|
30704
|
+
"src/server/query/nearSearch.ts"() {
|
|
30705
|
+
"use strict";
|
|
30706
|
+
init_geohash();
|
|
30707
|
+
__name(executeNearSearch, "executeNearSearch");
|
|
30708
|
+
}
|
|
30709
|
+
});
|
|
30710
|
+
|
|
30711
|
+
// src/server/query/index.ts
|
|
30712
|
+
var init_query = __esm({
|
|
30713
|
+
"src/server/query/index.ts"() {
|
|
30714
|
+
"use strict";
|
|
30715
|
+
init_converter();
|
|
30716
|
+
init_nearSearch();
|
|
30717
|
+
}
|
|
30718
|
+
});
|
|
30719
|
+
|
|
30720
|
+
// src/server/index.ts
|
|
30721
|
+
var init_index = __esm({
|
|
30722
|
+
"src/server/index.ts"() {
|
|
30723
|
+
"use strict";
|
|
30724
|
+
init_query();
|
|
30725
|
+
init_shadow();
|
|
30726
|
+
}
|
|
30727
|
+
});
|
|
30728
|
+
|
|
30729
|
+
// src/index.ts
|
|
30730
|
+
var init_index2 = __esm({
|
|
30731
|
+
"src/index.ts"() {
|
|
30732
|
+
"use strict";
|
|
30733
|
+
init_shared();
|
|
30734
|
+
init_client2();
|
|
30735
|
+
init_index();
|
|
30736
|
+
}
|
|
30737
|
+
});
|
|
30174
30738
|
|
|
30175
30739
|
// src/shared/constants/validation.ts
|
|
30176
|
-
var VALIDATION_ERROR_MESSAGES
|
|
30177
|
-
|
|
30178
|
-
|
|
30179
|
-
|
|
30180
|
-
|
|
30181
|
-
|
|
30182
|
-
|
|
30183
|
-
|
|
30184
|
-
|
|
30185
|
-
|
|
30186
|
-
|
|
30187
|
-
|
|
30188
|
-
|
|
30189
|
-
|
|
30190
|
-
|
|
30191
|
-
|
|
30740
|
+
var VALIDATION_ERROR_MESSAGES, VALIDATION_ERROR_PATTERNS;
|
|
30741
|
+
var init_validation3 = __esm({
|
|
30742
|
+
"src/shared/constants/validation.ts"() {
|
|
30743
|
+
"use strict";
|
|
30744
|
+
VALIDATION_ERROR_MESSAGES = {
|
|
30745
|
+
REQUEST_BODY_REQUIRED: "Request body is required",
|
|
30746
|
+
INVALID_JSON: "Invalid JSON in request body",
|
|
30747
|
+
MISSING_OPERATION: "Missing required field: operation",
|
|
30748
|
+
MISSING_COLLECTION: "Missing required field: collection",
|
|
30749
|
+
MISSING_PARAMS: "Missing required field: params",
|
|
30750
|
+
MISSING_TOKEN_FIELDS: "Missing required fields in token payload"
|
|
30751
|
+
};
|
|
30752
|
+
VALIDATION_ERROR_PATTERNS = [
|
|
30753
|
+
"Missing required field",
|
|
30754
|
+
"Invalid JSON",
|
|
30755
|
+
"Request body is required",
|
|
30756
|
+
"requires filter.id",
|
|
30757
|
+
"requires document",
|
|
30758
|
+
"requires documents"
|
|
30759
|
+
];
|
|
30760
|
+
}
|
|
30761
|
+
});
|
|
30192
30762
|
|
|
30193
30763
|
// src/server/utils/pagination.ts
|
|
30194
30764
|
function encodeNextToken(pk, sk) {
|
|
@@ -30198,7 +30768,6 @@ function encodeNextToken(pk, sk) {
|
|
|
30198
30768
|
const base64url = base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
30199
30769
|
return base64url;
|
|
30200
30770
|
}
|
|
30201
|
-
__name(encodeNextToken, "encodeNextToken");
|
|
30202
30771
|
function decodeNextToken(token) {
|
|
30203
30772
|
try {
|
|
30204
30773
|
let base64 = token.replace(/-/g, "+").replace(/_/g, "/");
|
|
@@ -30218,7 +30787,15 @@ function decodeNextToken(token) {
|
|
|
30218
30787
|
});
|
|
30219
30788
|
}
|
|
30220
30789
|
}
|
|
30221
|
-
|
|
30790
|
+
var init_pagination = __esm({
|
|
30791
|
+
"src/server/utils/pagination.ts"() {
|
|
30792
|
+
"use strict";
|
|
30793
|
+
init_index2();
|
|
30794
|
+
init_validation3();
|
|
30795
|
+
__name(encodeNextToken, "encodeNextToken");
|
|
30796
|
+
__name(decodeNextToken, "decodeNextToken");
|
|
30797
|
+
}
|
|
30798
|
+
});
|
|
30222
30799
|
|
|
30223
30800
|
// src/server/utils/filter.ts
|
|
30224
30801
|
function parseFilterField(fieldKey) {
|
|
@@ -30246,7 +30823,6 @@ function parseFilterField(fieldKey) {
|
|
|
30246
30823
|
}
|
|
30247
30824
|
throw new Error(`Invalid filter field syntax: ${fieldKey}`);
|
|
30248
30825
|
}
|
|
30249
|
-
__name(parseFilterField, "parseFilterField");
|
|
30250
30826
|
function isValidOperator(operator) {
|
|
30251
30827
|
return [
|
|
30252
30828
|
"$eq",
|
|
@@ -30265,21 +30841,22 @@ function isValidOperator(operator) {
|
|
|
30265
30841
|
"$near"
|
|
30266
30842
|
].includes(operator);
|
|
30267
30843
|
}
|
|
30268
|
-
__name(isValidOperator, "isValidOperator");
|
|
30269
30844
|
function isValidType(type) {
|
|
30270
30845
|
return ["string", "number", "date", "boolean"].includes(type);
|
|
30271
30846
|
}
|
|
30272
|
-
|
|
30847
|
+
var init_filter = __esm({
|
|
30848
|
+
"src/server/utils/filter.ts"() {
|
|
30849
|
+
"use strict";
|
|
30850
|
+
__name(parseFilterField, "parseFilterField");
|
|
30851
|
+
__name(isValidOperator, "isValidOperator");
|
|
30852
|
+
__name(isValidType, "isValidType");
|
|
30853
|
+
}
|
|
30854
|
+
});
|
|
30273
30855
|
|
|
30274
30856
|
// src/server/operations/find/utils.ts
|
|
30275
|
-
var logger7 = createLogger({
|
|
30276
|
-
service: "find-utils",
|
|
30277
|
-
level: process.env.LOG_LEVEL || "info"
|
|
30278
|
-
});
|
|
30279
30857
|
function initializeFindConfig() {
|
|
30280
30858
|
return getShadowConfig();
|
|
30281
30859
|
}
|
|
30282
|
-
__name(initializeFindConfig, "initializeFindConfig");
|
|
30283
30860
|
function normalizeFindParams(config, resource, params) {
|
|
30284
30861
|
const sort = normalizeSort(config, resource, params.sort);
|
|
30285
30862
|
const pagination = normalizePagination(params.pagination);
|
|
@@ -30290,7 +30867,6 @@ function normalizeFindParams(config, resource, params) {
|
|
|
30290
30867
|
parsedFilters
|
|
30291
30868
|
};
|
|
30292
30869
|
}
|
|
30293
|
-
__name(normalizeFindParams, "normalizeFindParams");
|
|
30294
30870
|
function parseFilters(filter) {
|
|
30295
30871
|
const parsedFilters = [];
|
|
30296
30872
|
if (!filter || Object.keys(filter).length === 0) {
|
|
@@ -30308,7 +30884,7 @@ function parseFilters(filter) {
|
|
|
30308
30884
|
parsedFilters.push({ parsed, value });
|
|
30309
30885
|
}
|
|
30310
30886
|
} catch (error2) {
|
|
30311
|
-
|
|
30887
|
+
logger5.error("Invalid filter field syntax", {
|
|
30312
30888
|
fieldKey,
|
|
30313
30889
|
error: error2 instanceof Error ? error2.message : String(error2)
|
|
30314
30890
|
});
|
|
@@ -30320,11 +30896,9 @@ function parseFilters(filter) {
|
|
|
30320
30896
|
}
|
|
30321
30897
|
return parsedFilters;
|
|
30322
30898
|
}
|
|
30323
|
-
__name(parseFilters, "parseFilters");
|
|
30324
30899
|
function findOptimizableFilter(sortField, parsedFilters) {
|
|
30325
30900
|
return parsedFilters.find((filter) => filter.parsed.field === sortField);
|
|
30326
30901
|
}
|
|
30327
|
-
__name(findOptimizableFilter, "findOptimizableFilter");
|
|
30328
30902
|
function matchesAllFilters(record, parsedFilters) {
|
|
30329
30903
|
return parsedFilters.every((filter) => {
|
|
30330
30904
|
const { field, operator } = filter.parsed;
|
|
@@ -30362,7 +30936,6 @@ function matchesAllFilters(record, parsedFilters) {
|
|
|
30362
30936
|
}
|
|
30363
30937
|
});
|
|
30364
30938
|
}
|
|
30365
|
-
__name(matchesAllFilters, "matchesAllFilters");
|
|
30366
30939
|
function detectNearQuery(filter) {
|
|
30367
30940
|
if (!filter || Object.keys(filter).length === 0) {
|
|
30368
30941
|
return null;
|
|
@@ -30380,17 +30953,33 @@ function detectNearQuery(filter) {
|
|
|
30380
30953
|
}
|
|
30381
30954
|
return null;
|
|
30382
30955
|
}
|
|
30383
|
-
|
|
30956
|
+
var logger5;
|
|
30957
|
+
var init_utils4 = __esm({
|
|
30958
|
+
"src/server/operations/find/utils.ts"() {
|
|
30959
|
+
"use strict";
|
|
30960
|
+
init_errors();
|
|
30961
|
+
init_shared();
|
|
30962
|
+
init_shadow();
|
|
30963
|
+
init_filter();
|
|
30964
|
+
init_validation2();
|
|
30965
|
+
logger5 = createLogger({
|
|
30966
|
+
service: "find-utils",
|
|
30967
|
+
level: process.env.LOG_LEVEL || "info"
|
|
30968
|
+
});
|
|
30969
|
+
__name(initializeFindConfig, "initializeFindConfig");
|
|
30970
|
+
__name(normalizeFindParams, "normalizeFindParams");
|
|
30971
|
+
__name(parseFilters, "parseFilters");
|
|
30972
|
+
__name(findOptimizableFilter, "findOptimizableFilter");
|
|
30973
|
+
__name(matchesAllFilters, "matchesAllFilters");
|
|
30974
|
+
__name(detectNearQuery, "detectNearQuery");
|
|
30975
|
+
}
|
|
30976
|
+
});
|
|
30384
30977
|
|
|
30385
30978
|
// src/server/operations/find/idQuery.ts
|
|
30386
|
-
var logger8 = createLogger({
|
|
30387
|
-
service: "id-query",
|
|
30388
|
-
level: process.env.LOG_LEVEL || "info"
|
|
30389
|
-
});
|
|
30390
30979
|
async function executeIdQuery(resource, normalizedParams, requestId) {
|
|
30391
30980
|
const { sort, pagination, parsedFilters } = normalizedParams;
|
|
30392
30981
|
const { perPage, nextToken } = pagination;
|
|
30393
|
-
|
|
30982
|
+
logger6.debug("Executing ID optimized query", {
|
|
30394
30983
|
requestId,
|
|
30395
30984
|
resource,
|
|
30396
30985
|
sort,
|
|
@@ -30402,13 +30991,12 @@ async function executeIdQuery(resource, normalizedParams, requestId) {
|
|
|
30402
30991
|
}
|
|
30403
30992
|
return await executeAllRecordsQuery(resource, sort, perPage, nextToken, parsedFilters, requestId);
|
|
30404
30993
|
}
|
|
30405
|
-
__name(executeIdQuery, "executeIdQuery");
|
|
30406
30994
|
async function executeSpecificIdQuery(resource, targetId, requestId) {
|
|
30407
30995
|
const dbClient2 = getDBClient();
|
|
30408
30996
|
const tableName = getTableName();
|
|
30409
30997
|
const queryResult = await executeDynamoDBOperation(
|
|
30410
30998
|
() => dbClient2.send(
|
|
30411
|
-
new
|
|
30999
|
+
new import_lib_dynamodb2.QueryCommand({
|
|
30412
31000
|
TableName: tableName,
|
|
30413
31001
|
KeyConditionExpression: "PK = :pk AND SK = :sk",
|
|
30414
31002
|
ExpressionAttributeValues: {
|
|
@@ -30422,7 +31010,7 @@ async function executeSpecificIdQuery(resource, targetId, requestId) {
|
|
|
30422
31010
|
);
|
|
30423
31011
|
const mainRecords = queryResult.Items || [];
|
|
30424
31012
|
const items = mainRecords.map((item) => extractCleanRecord(item));
|
|
30425
|
-
|
|
31013
|
+
logger6.info("ID specific query succeeded", {
|
|
30426
31014
|
requestId,
|
|
30427
31015
|
resource,
|
|
30428
31016
|
targetId,
|
|
@@ -30436,7 +31024,6 @@ async function executeSpecificIdQuery(resource, targetId, requestId) {
|
|
|
30436
31024
|
}
|
|
30437
31025
|
};
|
|
30438
31026
|
}
|
|
30439
|
-
__name(executeSpecificIdQuery, "executeSpecificIdQuery");
|
|
30440
31027
|
async function executeAllRecordsQuery(resource, sort, perPage, nextToken, parsedFilters, requestId) {
|
|
30441
31028
|
const dbClient2 = getDBClient();
|
|
30442
31029
|
const tableName = getTableName();
|
|
@@ -30450,7 +31037,7 @@ async function executeAllRecordsQuery(resource, sort, perPage, nextToken, parsed
|
|
|
30450
31037
|
}
|
|
30451
31038
|
const queryResult = await executeDynamoDBOperation(
|
|
30452
31039
|
() => dbClient2.send(
|
|
30453
|
-
new
|
|
31040
|
+
new import_lib_dynamodb2.QueryCommand({
|
|
30454
31041
|
TableName: tableName,
|
|
30455
31042
|
KeyConditionExpression: "PK = :pk AND begins_with(SK, :skPrefix)",
|
|
30456
31043
|
ExpressionAttributeValues: {
|
|
@@ -30473,432 +31060,1061 @@ async function executeAllRecordsQuery(resource, sort, perPage, nextToken, parsed
|
|
|
30473
31060
|
hasNextPage: false,
|
|
30474
31061
|
hasPreviousPage: false
|
|
30475
31062
|
}
|
|
30476
|
-
};
|
|
31063
|
+
};
|
|
31064
|
+
}
|
|
31065
|
+
let items = mainRecords.map((item) => extractCleanRecord(item));
|
|
31066
|
+
if (parsedFilters.length > 0) {
|
|
31067
|
+
items = items.filter((record) => matchesAllFilters(record, parsedFilters));
|
|
31068
|
+
}
|
|
31069
|
+
const hasNextPage = mainRecords.length < perPage ? false : queryResult.LastEvaluatedKey !== void 0;
|
|
31070
|
+
const nextTokenValue = hasNextPage && queryResult.LastEvaluatedKey ? encodeNextToken(
|
|
31071
|
+
queryResult.LastEvaluatedKey.PK,
|
|
31072
|
+
queryResult.LastEvaluatedKey.SK
|
|
31073
|
+
) : void 0;
|
|
31074
|
+
logger6.info("ID all records query succeeded", {
|
|
31075
|
+
requestId,
|
|
31076
|
+
resource,
|
|
31077
|
+
count: items.length,
|
|
31078
|
+
hasNextPage
|
|
31079
|
+
});
|
|
31080
|
+
return {
|
|
31081
|
+
items,
|
|
31082
|
+
pageInfo: {
|
|
31083
|
+
hasNextPage,
|
|
31084
|
+
hasPreviousPage: !!nextToken
|
|
31085
|
+
},
|
|
31086
|
+
...nextTokenValue && { nextToken: nextTokenValue }
|
|
31087
|
+
};
|
|
31088
|
+
}
|
|
31089
|
+
var import_lib_dynamodb2, logger6;
|
|
31090
|
+
var init_idQuery = __esm({
|
|
31091
|
+
"src/server/operations/find/idQuery.ts"() {
|
|
31092
|
+
"use strict";
|
|
31093
|
+
import_lib_dynamodb2 = __toESM(require_dist_cjs66(), 1);
|
|
31094
|
+
init_shared();
|
|
31095
|
+
init_dynamodb3();
|
|
31096
|
+
init_pagination();
|
|
31097
|
+
init_utils4();
|
|
31098
|
+
logger6 = createLogger({
|
|
31099
|
+
service: "id-query",
|
|
31100
|
+
level: process.env.LOG_LEVEL || "info"
|
|
31101
|
+
});
|
|
31102
|
+
__name(executeIdQuery, "executeIdQuery");
|
|
31103
|
+
__name(executeSpecificIdQuery, "executeSpecificIdQuery");
|
|
31104
|
+
__name(executeAllRecordsQuery, "executeAllRecordsQuery");
|
|
31105
|
+
}
|
|
31106
|
+
});
|
|
31107
|
+
|
|
31108
|
+
// src/server/operations/find/nearQuery.ts
|
|
31109
|
+
async function executeNearQuery(resource, fieldName, nearQuery, limit, requestId) {
|
|
31110
|
+
logger7.debug("Executing $near query", {
|
|
31111
|
+
requestId,
|
|
31112
|
+
resource,
|
|
31113
|
+
fieldName,
|
|
31114
|
+
nearQuery,
|
|
31115
|
+
limit
|
|
31116
|
+
});
|
|
31117
|
+
const searchFunction = /* @__PURE__ */ __name(async (geohashPrefix) => {
|
|
31118
|
+
const dbClient2 = getDBClient();
|
|
31119
|
+
const tableName = getTableName();
|
|
31120
|
+
logger7.debug("Searching shadow records", {
|
|
31121
|
+
requestId,
|
|
31122
|
+
resource,
|
|
31123
|
+
fieldName,
|
|
31124
|
+
geohashPrefix,
|
|
31125
|
+
skPrefix: `${fieldName}#${geohashPrefix}`
|
|
31126
|
+
});
|
|
31127
|
+
const queryResult = await executeDynamoDBOperation(
|
|
31128
|
+
() => dbClient2.send(
|
|
31129
|
+
new import_lib_dynamodb3.QueryCommand({
|
|
31130
|
+
TableName: tableName,
|
|
31131
|
+
KeyConditionExpression: "PK = :pk AND begins_with(SK, :skPrefix)",
|
|
31132
|
+
ExpressionAttributeValues: {
|
|
31133
|
+
":pk": resource,
|
|
31134
|
+
":skPrefix": `${fieldName}#${geohashPrefix}`
|
|
31135
|
+
},
|
|
31136
|
+
ConsistentRead: false
|
|
31137
|
+
// シャドウレコードは結果整合性で十分
|
|
31138
|
+
})
|
|
31139
|
+
),
|
|
31140
|
+
"Query"
|
|
31141
|
+
);
|
|
31142
|
+
const shadowRecords = queryResult.Items || [];
|
|
31143
|
+
logger7.debug("Shadow records found", {
|
|
31144
|
+
requestId,
|
|
31145
|
+
resource,
|
|
31146
|
+
geohashPrefix,
|
|
31147
|
+
count: shadowRecords.length
|
|
31148
|
+
});
|
|
31149
|
+
const mainRecordIds = shadowRecords.map((item) => {
|
|
31150
|
+
const sk = item.SK;
|
|
31151
|
+
const parts = sk.split("#id#");
|
|
31152
|
+
return parts.length === 2 ? parts[1] : null;
|
|
31153
|
+
}).filter((id) => id !== null);
|
|
31154
|
+
logger7.debug("Main record IDs extracted", {
|
|
31155
|
+
requestId,
|
|
31156
|
+
resource,
|
|
31157
|
+
geohashPrefix,
|
|
31158
|
+
ids: mainRecordIds
|
|
31159
|
+
});
|
|
31160
|
+
const mainRecords = await Promise.all(
|
|
31161
|
+
mainRecordIds.map(async (id) => {
|
|
31162
|
+
const result2 = await executeDynamoDBOperation(
|
|
31163
|
+
() => dbClient2.send(
|
|
31164
|
+
new import_lib_dynamodb3.QueryCommand({
|
|
31165
|
+
TableName: tableName,
|
|
31166
|
+
KeyConditionExpression: "PK = :pk AND SK = :sk",
|
|
31167
|
+
ExpressionAttributeValues: {
|
|
31168
|
+
":pk": resource,
|
|
31169
|
+
// venues
|
|
31170
|
+
":sk": `id#${id}`
|
|
31171
|
+
},
|
|
31172
|
+
ConsistentRead: true
|
|
31173
|
+
})
|
|
31174
|
+
),
|
|
31175
|
+
"Query"
|
|
31176
|
+
);
|
|
31177
|
+
return result2.Items?.[0];
|
|
31178
|
+
})
|
|
31179
|
+
);
|
|
31180
|
+
const validRecords = mainRecords.filter(
|
|
31181
|
+
(item) => item !== void 0
|
|
31182
|
+
);
|
|
31183
|
+
logger7.debug("Main records retrieved", {
|
|
31184
|
+
requestId,
|
|
31185
|
+
resource,
|
|
31186
|
+
geohashPrefix,
|
|
31187
|
+
count: validRecords.length
|
|
31188
|
+
});
|
|
31189
|
+
const cleanRecords = validRecords.map((record) => extractCleanRecord(record));
|
|
31190
|
+
logger7.debug("Clean records extracted", {
|
|
31191
|
+
requestId,
|
|
31192
|
+
resource,
|
|
31193
|
+
geohashPrefix,
|
|
31194
|
+
count: cleanRecords.length,
|
|
31195
|
+
sampleKeys: cleanRecords[0] ? Object.keys(cleanRecords[0]) : []
|
|
31196
|
+
});
|
|
31197
|
+
return cleanRecords;
|
|
31198
|
+
}, "searchFunction");
|
|
31199
|
+
const result = await executeNearSearch(
|
|
31200
|
+
nearQuery,
|
|
31201
|
+
fieldName,
|
|
31202
|
+
limit,
|
|
31203
|
+
searchFunction,
|
|
31204
|
+
DEFAULT_GEOHASH_CONFIG
|
|
31205
|
+
);
|
|
31206
|
+
const items = result.documents;
|
|
31207
|
+
logger7.info("$near query succeeded", {
|
|
31208
|
+
requestId,
|
|
31209
|
+
resource,
|
|
31210
|
+
fieldName,
|
|
31211
|
+
count: items.length,
|
|
31212
|
+
iterations: result.metadata.iterations,
|
|
31213
|
+
candidatesFound: result.metadata.candidatesFound
|
|
31214
|
+
});
|
|
31215
|
+
return {
|
|
31216
|
+
items,
|
|
31217
|
+
pageInfo: {
|
|
31218
|
+
hasNextPage: false,
|
|
31219
|
+
// $near検索はページネーション非対応
|
|
31220
|
+
hasPreviousPage: false
|
|
31221
|
+
}
|
|
31222
|
+
};
|
|
31223
|
+
}
|
|
31224
|
+
var import_lib_dynamodb3, logger7;
|
|
31225
|
+
var init_nearQuery = __esm({
|
|
31226
|
+
"src/server/operations/find/nearQuery.ts"() {
|
|
31227
|
+
"use strict";
|
|
31228
|
+
import_lib_dynamodb3 = __toESM(require_dist_cjs66(), 1);
|
|
31229
|
+
init_geohash();
|
|
31230
|
+
init_shared();
|
|
31231
|
+
init_nearSearch();
|
|
31232
|
+
init_dynamodb3();
|
|
31233
|
+
logger7 = createLogger({
|
|
31234
|
+
service: "near-query",
|
|
31235
|
+
level: process.env.LOG_LEVEL || "info"
|
|
31236
|
+
});
|
|
31237
|
+
__name(executeNearQuery, "executeNearQuery");
|
|
31238
|
+
}
|
|
31239
|
+
});
|
|
31240
|
+
|
|
31241
|
+
// src/server/operations/find/shadowQuery.ts
|
|
31242
|
+
async function executeShadowQuery(resource, normalizedParams, requestId) {
|
|
31243
|
+
const { sort, pagination, parsedFilters } = normalizedParams;
|
|
31244
|
+
const { perPage, nextToken } = pagination;
|
|
31245
|
+
logger8.debug("Executing shadow query", {
|
|
31246
|
+
requestId,
|
|
31247
|
+
resource,
|
|
31248
|
+
sortField: sort.field,
|
|
31249
|
+
hasFilters: parsedFilters.length > 0
|
|
31250
|
+
});
|
|
31251
|
+
const optimizableFilter = findOptimizableFilter(sort.field, parsedFilters);
|
|
31252
|
+
const shadowRecords = await executeShadowRecordQuery(
|
|
31253
|
+
resource,
|
|
31254
|
+
sort,
|
|
31255
|
+
perPage,
|
|
31256
|
+
nextToken,
|
|
31257
|
+
optimizableFilter,
|
|
31258
|
+
requestId
|
|
31259
|
+
);
|
|
31260
|
+
const recordIds = extractRecordIds(shadowRecords.Items || []);
|
|
31261
|
+
if (recordIds.length === 0) {
|
|
31262
|
+
return {
|
|
31263
|
+
items: [],
|
|
31264
|
+
pageInfo: {
|
|
31265
|
+
hasNextPage: false,
|
|
31266
|
+
hasPreviousPage: false
|
|
31267
|
+
}
|
|
31268
|
+
};
|
|
31269
|
+
}
|
|
31270
|
+
const mainRecords = await fetchMainRecords(resource, recordIds, requestId);
|
|
31271
|
+
const recordMap = new Map(
|
|
31272
|
+
mainRecords.map((item) => {
|
|
31273
|
+
const data2 = item.data;
|
|
31274
|
+
return [data2.id, extractCleanRecord(item)];
|
|
31275
|
+
})
|
|
31276
|
+
);
|
|
31277
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
31278
|
+
let items = recordIds.filter((id) => {
|
|
31279
|
+
if (seenIds.has(id)) {
|
|
31280
|
+
return false;
|
|
31281
|
+
}
|
|
31282
|
+
seenIds.add(id);
|
|
31283
|
+
return true;
|
|
31284
|
+
}).map((id) => recordMap.get(id)).filter((record) => record !== void 0);
|
|
31285
|
+
if (parsedFilters.length > 0) {
|
|
31286
|
+
items = items.filter((record) => matchesAllFilters(record, parsedFilters));
|
|
31287
|
+
}
|
|
31288
|
+
const hasNextPage = (shadowRecords.Items?.length || 0) < perPage ? false : shadowRecords.LastEvaluatedKey !== void 0;
|
|
31289
|
+
const nextTokenValue = hasNextPage && shadowRecords.LastEvaluatedKey ? encodeNextToken(
|
|
31290
|
+
shadowRecords.LastEvaluatedKey.PK,
|
|
31291
|
+
shadowRecords.LastEvaluatedKey.SK
|
|
31292
|
+
) : void 0;
|
|
31293
|
+
logger8.info("Shadow query succeeded", {
|
|
31294
|
+
requestId,
|
|
31295
|
+
resource,
|
|
31296
|
+
sortField: sort.field,
|
|
31297
|
+
shadowCount: shadowRecords.Items?.length || 0,
|
|
31298
|
+
mainCount: items.length,
|
|
31299
|
+
hasNextPage
|
|
31300
|
+
});
|
|
31301
|
+
return {
|
|
31302
|
+
items,
|
|
31303
|
+
pageInfo: {
|
|
31304
|
+
hasNextPage,
|
|
31305
|
+
hasPreviousPage: !!nextToken
|
|
31306
|
+
},
|
|
31307
|
+
...nextTokenValue && { nextToken: nextTokenValue }
|
|
31308
|
+
};
|
|
31309
|
+
}
|
|
31310
|
+
async function executeShadowRecordQuery(resource, sort, perPage, nextToken, optimizableFilter, _requestId) {
|
|
31311
|
+
const dbClient2 = getDBClient();
|
|
31312
|
+
const tableName = getTableName();
|
|
31313
|
+
let exclusiveStartKey;
|
|
31314
|
+
if (nextToken) {
|
|
31315
|
+
const decoded = decodeNextToken(nextToken);
|
|
31316
|
+
exclusiveStartKey = {
|
|
31317
|
+
PK: decoded.PK,
|
|
31318
|
+
SK: decoded.SK
|
|
31319
|
+
};
|
|
31320
|
+
}
|
|
31321
|
+
const { keyConditionExpression, expressionAttributeValues } = buildKeyCondition(
|
|
31322
|
+
resource,
|
|
31323
|
+
sort.field,
|
|
31324
|
+
optimizableFilter
|
|
31325
|
+
);
|
|
31326
|
+
return await executeDynamoDBOperation(
|
|
31327
|
+
() => dbClient2.send(
|
|
31328
|
+
new import_lib_dynamodb4.QueryCommand({
|
|
31329
|
+
TableName: tableName,
|
|
31330
|
+
KeyConditionExpression: keyConditionExpression,
|
|
31331
|
+
ExpressionAttributeValues: expressionAttributeValues,
|
|
31332
|
+
ScanIndexForward: sort.order === "ASC",
|
|
31333
|
+
Limit: perPage,
|
|
31334
|
+
ExclusiveStartKey: exclusiveStartKey,
|
|
31335
|
+
ConsistentRead: true
|
|
31336
|
+
})
|
|
31337
|
+
),
|
|
31338
|
+
"Query"
|
|
31339
|
+
);
|
|
31340
|
+
}
|
|
31341
|
+
function buildKeyCondition(resource, sortField, optimizableFilter) {
|
|
31342
|
+
const expressionAttributeValues = {
|
|
31343
|
+
":pk": resource
|
|
31344
|
+
};
|
|
31345
|
+
if (!optimizableFilter) {
|
|
31346
|
+
return {
|
|
31347
|
+
keyConditionExpression: "PK = :pk AND begins_with(SK, :skPrefix)",
|
|
31348
|
+
expressionAttributeValues: {
|
|
31349
|
+
...expressionAttributeValues,
|
|
31350
|
+
":skPrefix": `${sortField}#`
|
|
31351
|
+
}
|
|
31352
|
+
};
|
|
31353
|
+
}
|
|
31354
|
+
const { operator, type } = optimizableFilter.parsed;
|
|
31355
|
+
const value = optimizableFilter.value;
|
|
31356
|
+
const encodedValue = encodeValueForShadowSK(value, type);
|
|
31357
|
+
const skValue = `${sortField}#${encodedValue}`;
|
|
31358
|
+
switch (operator) {
|
|
31359
|
+
case "$eq":
|
|
31360
|
+
return {
|
|
31361
|
+
keyConditionExpression: "PK = :pk AND begins_with(SK, :skValue)",
|
|
31362
|
+
expressionAttributeValues: {
|
|
31363
|
+
...expressionAttributeValues,
|
|
31364
|
+
":skValue": `${skValue}#id#`
|
|
31365
|
+
}
|
|
31366
|
+
};
|
|
31367
|
+
case "$gt":
|
|
31368
|
+
return {
|
|
31369
|
+
keyConditionExpression: "PK = :pk AND SK > :skValue",
|
|
31370
|
+
expressionAttributeValues: {
|
|
31371
|
+
...expressionAttributeValues,
|
|
31372
|
+
":skValue": `${skValue}#id#~`
|
|
31373
|
+
}
|
|
31374
|
+
};
|
|
31375
|
+
case "$gte":
|
|
31376
|
+
return {
|
|
31377
|
+
keyConditionExpression: "PK = :pk AND SK >= :skValue",
|
|
31378
|
+
expressionAttributeValues: {
|
|
31379
|
+
...expressionAttributeValues,
|
|
31380
|
+
":skValue": `${skValue}#id#`
|
|
31381
|
+
}
|
|
31382
|
+
};
|
|
31383
|
+
case "$lt":
|
|
31384
|
+
return {
|
|
31385
|
+
keyConditionExpression: "PK = :pk AND begins_with(SK, :skPrefix) AND SK < :skValue",
|
|
31386
|
+
expressionAttributeValues: {
|
|
31387
|
+
...expressionAttributeValues,
|
|
31388
|
+
":skPrefix": `${sortField}#`,
|
|
31389
|
+
":skValue": `${skValue}#id#`
|
|
31390
|
+
}
|
|
31391
|
+
};
|
|
31392
|
+
case "$lte":
|
|
31393
|
+
return {
|
|
31394
|
+
keyConditionExpression: "PK = :pk AND begins_with(SK, :skPrefix) AND SK <= :skValue",
|
|
31395
|
+
expressionAttributeValues: {
|
|
31396
|
+
...expressionAttributeValues,
|
|
31397
|
+
":skPrefix": `${sortField}#`,
|
|
31398
|
+
":skValue": `${skValue}#id#~`
|
|
31399
|
+
}
|
|
31400
|
+
};
|
|
31401
|
+
default:
|
|
31402
|
+
return {
|
|
31403
|
+
keyConditionExpression: "PK = :pk AND begins_with(SK, :skPrefix)",
|
|
31404
|
+
expressionAttributeValues: {
|
|
31405
|
+
...expressionAttributeValues,
|
|
31406
|
+
":skPrefix": `${sortField}#`
|
|
31407
|
+
}
|
|
31408
|
+
};
|
|
31409
|
+
}
|
|
31410
|
+
}
|
|
31411
|
+
function encodeValueForShadowSK(value, type) {
|
|
31412
|
+
if (type === "number") {
|
|
31413
|
+
return String(value).padStart(NUMBER_FORMAT.SHADOW_SK_DIGITS, NUMBER_FORMAT.ZERO_PAD_CHAR);
|
|
31414
|
+
} else if (type === "date") {
|
|
31415
|
+
return new Date(String(value)).toISOString();
|
|
31416
|
+
} else if (type === "boolean") {
|
|
31417
|
+
return String(value);
|
|
31418
|
+
} else {
|
|
31419
|
+
return String(value).replace(/#/g, "##").replace(/ /g, "#");
|
|
31420
|
+
}
|
|
31421
|
+
}
|
|
31422
|
+
function extractRecordIds(shadowRecords) {
|
|
31423
|
+
return shadowRecords.map((record) => {
|
|
31424
|
+
const sk = record.SK;
|
|
31425
|
+
const parts = sk.split("#id#");
|
|
31426
|
+
return parts.length > 1 ? parts[1] : null;
|
|
31427
|
+
}).filter((id) => id !== null);
|
|
31428
|
+
}
|
|
31429
|
+
async function fetchMainRecords(resource, recordIds, requestId) {
|
|
31430
|
+
const dbClient2 = getDBClient();
|
|
31431
|
+
const tableName = getTableName();
|
|
31432
|
+
const uniqueRecordIds = Array.from(new Set(recordIds));
|
|
31433
|
+
const batchGetResult = await executeDynamoDBOperation(
|
|
31434
|
+
() => dbClient2.send(
|
|
31435
|
+
new import_lib_dynamodb4.BatchGetCommand({
|
|
31436
|
+
RequestItems: {
|
|
31437
|
+
[tableName]: {
|
|
31438
|
+
Keys: uniqueRecordIds.map((id) => ({
|
|
31439
|
+
PK: resource,
|
|
31440
|
+
SK: `id#${id}`
|
|
31441
|
+
})),
|
|
31442
|
+
ConsistentRead: true
|
|
31443
|
+
}
|
|
31444
|
+
}
|
|
31445
|
+
})
|
|
31446
|
+
),
|
|
31447
|
+
"BatchGetItem"
|
|
31448
|
+
);
|
|
31449
|
+
const mainRecords = batchGetResult.Responses?.[tableName] || [];
|
|
31450
|
+
logger8.debug("Main records fetched", {
|
|
31451
|
+
requestId,
|
|
31452
|
+
resource,
|
|
31453
|
+
requestedCount: uniqueRecordIds.length,
|
|
31454
|
+
fetchedCount: mainRecords.length
|
|
31455
|
+
});
|
|
31456
|
+
return mainRecords;
|
|
31457
|
+
}
|
|
31458
|
+
var import_lib_dynamodb4, logger8;
|
|
31459
|
+
var init_shadowQuery = __esm({
|
|
31460
|
+
"src/server/operations/find/shadowQuery.ts"() {
|
|
31461
|
+
"use strict";
|
|
31462
|
+
import_lib_dynamodb4 = __toESM(require_dist_cjs66(), 1);
|
|
31463
|
+
init_formatting();
|
|
31464
|
+
init_shared();
|
|
31465
|
+
init_dynamodb3();
|
|
31466
|
+
init_pagination();
|
|
31467
|
+
init_utils4();
|
|
31468
|
+
logger8 = createLogger({
|
|
31469
|
+
service: "shadow-query",
|
|
31470
|
+
level: process.env.LOG_LEVEL || "info"
|
|
31471
|
+
});
|
|
31472
|
+
__name(executeShadowQuery, "executeShadowQuery");
|
|
31473
|
+
__name(executeShadowRecordQuery, "executeShadowRecordQuery");
|
|
31474
|
+
__name(buildKeyCondition, "buildKeyCondition");
|
|
31475
|
+
__name(encodeValueForShadowSK, "encodeValueForShadowSK");
|
|
31476
|
+
__name(extractRecordIds, "extractRecordIds");
|
|
31477
|
+
__name(fetchMainRecords, "fetchMainRecords");
|
|
31478
|
+
}
|
|
31479
|
+
});
|
|
31480
|
+
|
|
31481
|
+
// src/server/operations/find/handler.ts
|
|
31482
|
+
async function handleFind(resource, params, requestId) {
|
|
31483
|
+
logger9.debug("Executing find", {
|
|
31484
|
+
requestId,
|
|
31485
|
+
resource,
|
|
31486
|
+
params
|
|
31487
|
+
});
|
|
31488
|
+
const nearDetection = detectNearQuery(params.filter);
|
|
31489
|
+
if (nearDetection) {
|
|
31490
|
+
logger9.debug("$near operator detected, executing near search", {
|
|
31491
|
+
requestId,
|
|
31492
|
+
resource,
|
|
31493
|
+
fieldName: nearDetection.fieldName
|
|
31494
|
+
});
|
|
31495
|
+
const limit = params.pagination?.perPage || 10;
|
|
31496
|
+
return executeNearQuery(
|
|
31497
|
+
resource,
|
|
31498
|
+
nearDetection.fieldName,
|
|
31499
|
+
nearDetection.nearQuery,
|
|
31500
|
+
limit,
|
|
31501
|
+
requestId
|
|
31502
|
+
);
|
|
31503
|
+
}
|
|
31504
|
+
const config = initializeFindConfig();
|
|
31505
|
+
const normalizedParams = normalizeFindParams(config, resource, params);
|
|
31506
|
+
validateSortField2(config, resource, normalizedParams.sort);
|
|
31507
|
+
logger9.debug("Find parameters normalized", {
|
|
31508
|
+
requestId,
|
|
31509
|
+
resource,
|
|
31510
|
+
sort: normalizedParams.sort,
|
|
31511
|
+
pagination: normalizedParams.pagination,
|
|
31512
|
+
filterCount: normalizedParams.parsedFilters.length
|
|
31513
|
+
});
|
|
31514
|
+
if (normalizedParams.sort.field === "id") {
|
|
31515
|
+
return executeIdQuery(resource, normalizedParams, requestId);
|
|
31516
|
+
}
|
|
31517
|
+
return executeShadowQuery(resource, normalizedParams, requestId);
|
|
31518
|
+
}
|
|
31519
|
+
var logger9;
|
|
31520
|
+
var init_handler = __esm({
|
|
31521
|
+
"src/server/operations/find/handler.ts"() {
|
|
31522
|
+
"use strict";
|
|
31523
|
+
init_shared();
|
|
31524
|
+
init_validation2();
|
|
31525
|
+
init_idQuery();
|
|
31526
|
+
init_nearQuery();
|
|
31527
|
+
init_shadowQuery();
|
|
31528
|
+
init_utils4();
|
|
31529
|
+
logger9 = createLogger({
|
|
31530
|
+
service: "find-handler",
|
|
31531
|
+
level: process.env.LOG_LEVEL || "info"
|
|
31532
|
+
});
|
|
31533
|
+
__name(handleFind, "handleFind");
|
|
31534
|
+
}
|
|
31535
|
+
});
|
|
31536
|
+
|
|
31537
|
+
// src/server/operations/find.ts
|
|
31538
|
+
var find_exports = {};
|
|
31539
|
+
__export(find_exports, {
|
|
31540
|
+
handleFind: () => handleFind
|
|
31541
|
+
});
|
|
31542
|
+
var init_find = __esm({
|
|
31543
|
+
"src/server/operations/find.ts"() {
|
|
31544
|
+
"use strict";
|
|
31545
|
+
init_handler();
|
|
31546
|
+
}
|
|
31547
|
+
});
|
|
31548
|
+
|
|
31549
|
+
// src/server/handler.ts
|
|
31550
|
+
var handler_exports = {};
|
|
31551
|
+
__export(handler_exports, {
|
|
31552
|
+
handler: () => handler
|
|
31553
|
+
});
|
|
31554
|
+
module.exports = __toCommonJS(handler_exports);
|
|
31555
|
+
init_http();
|
|
31556
|
+
init_shared();
|
|
31557
|
+
|
|
31558
|
+
// src/server/operations/operationDispatcher.ts
|
|
31559
|
+
init_shared();
|
|
31560
|
+
|
|
31561
|
+
// src/server/operations/deleteMany.ts
|
|
31562
|
+
var import_lib_dynamodb5 = __toESM(require_dist_cjs66(), 1);
|
|
31563
|
+
init_shared();
|
|
31564
|
+
init_shadow();
|
|
31565
|
+
|
|
31566
|
+
// src/server/utils/bulkOperations.ts
|
|
31567
|
+
init_shared();
|
|
31568
|
+
var logger2 = createLogger({ service: "records-lambda" });
|
|
31569
|
+
function logLargeBatchWarning(operation2, recordCount, requestId, resource) {
|
|
31570
|
+
if (recordCount > LARGE_BATCH_WARNING_THRESHOLD) {
|
|
31571
|
+
logger2.warn(`Large batch ${operation2} operation detected`, {
|
|
31572
|
+
requestId,
|
|
31573
|
+
resource,
|
|
31574
|
+
recordCount,
|
|
31575
|
+
warningThreshold: LARGE_BATCH_WARNING_THRESHOLD,
|
|
31576
|
+
estimatedTimeoutRisk: "high",
|
|
31577
|
+
recommendation: "Consider splitting the batch into smaller requests to avoid Lambda timeout (15 min limit)"
|
|
31578
|
+
});
|
|
31579
|
+
}
|
|
31580
|
+
}
|
|
31581
|
+
__name(logLargeBatchWarning, "logLargeBatchWarning");
|
|
31582
|
+
function calculateTimeoutRisk(startTime) {
|
|
31583
|
+
const elapsedMs = Date.now() - startTime;
|
|
31584
|
+
const remainingMs = LAMBDA_TIMEOUT_MS - elapsedMs;
|
|
31585
|
+
const utilizationPercent = Math.round(elapsedMs / LAMBDA_TIMEOUT_MS * 100);
|
|
31586
|
+
const risk = remainingMs < LAMBDA_TIMEOUT_MS * TIMEOUT_RISK_THRESHOLD ? "high" : "low";
|
|
31587
|
+
return {
|
|
31588
|
+
elapsedMs,
|
|
31589
|
+
remainingMs,
|
|
31590
|
+
risk,
|
|
31591
|
+
utilizationPercent
|
|
31592
|
+
};
|
|
31593
|
+
}
|
|
31594
|
+
__name(calculateTimeoutRisk, "calculateTimeoutRisk");
|
|
31595
|
+
function logPreparationTimeoutRisk(requestId, resource, totalRecords, chunkCount, riskInfo) {
|
|
31596
|
+
logger2.info("Records prepared for chunk execution", {
|
|
31597
|
+
requestId,
|
|
31598
|
+
resource,
|
|
31599
|
+
totalRecords,
|
|
31600
|
+
chunkCount,
|
|
31601
|
+
preparationTimeMs: riskInfo.elapsedMs,
|
|
31602
|
+
remainingTimeMs: riskInfo.remainingMs,
|
|
31603
|
+
timeoutRisk: riskInfo.risk
|
|
31604
|
+
});
|
|
31605
|
+
if (riskInfo.risk === "high") {
|
|
31606
|
+
logger2.warn("High timeout risk detected during preparation phase", {
|
|
31607
|
+
requestId,
|
|
31608
|
+
resource,
|
|
31609
|
+
preparationElapsedMs: riskInfo.elapsedMs,
|
|
31610
|
+
remainingTimeMs: riskInfo.remainingMs,
|
|
31611
|
+
lambdaTimeoutMs: LAMBDA_TIMEOUT_MS,
|
|
31612
|
+
recommendation: "Consider reducing batch size or optimizing preparation logic"
|
|
31613
|
+
});
|
|
31614
|
+
}
|
|
31615
|
+
}
|
|
31616
|
+
__name(logPreparationTimeoutRisk, "logPreparationTimeoutRisk");
|
|
31617
|
+
function logBulkOperationComplete(operation2, requestId, resource, requested, succeeded, failed, riskInfo, additionalInfo) {
|
|
31618
|
+
const totalElapsedSeconds = Math.round(riskInfo.elapsedMs / 1e3);
|
|
31619
|
+
logger2.info(`${operation2} completed`, {
|
|
31620
|
+
requestId,
|
|
31621
|
+
resource,
|
|
31622
|
+
requested,
|
|
31623
|
+
succeeded,
|
|
31624
|
+
totalFailed: failed,
|
|
31625
|
+
totalExecutionTimeMs: riskInfo.elapsedMs,
|
|
31626
|
+
totalExecutionTimeSeconds: totalElapsedSeconds,
|
|
31627
|
+
lambdaTimeoutMs: LAMBDA_TIMEOUT_MS,
|
|
31628
|
+
timeoutUtilization: `${riskInfo.utilizationPercent}%`,
|
|
31629
|
+
...additionalInfo
|
|
31630
|
+
});
|
|
31631
|
+
}
|
|
31632
|
+
__name(logBulkOperationComplete, "logBulkOperationComplete");
|
|
31633
|
+
function logPartialFailure(operation2, requestId, resource, requested, succeeded, failed, errorCodes, additionalInfo) {
|
|
31634
|
+
const failureRate = Math.round(failed / requested * 100);
|
|
31635
|
+
logger2.warn(`Partial failure in ${operation2} operation`, {
|
|
31636
|
+
requestId,
|
|
31637
|
+
resource,
|
|
31638
|
+
totalRequested: requested,
|
|
31639
|
+
successCount: succeeded,
|
|
31640
|
+
failedCount: failed,
|
|
31641
|
+
failureRate: `${failureRate}%`,
|
|
31642
|
+
errorCodes: [...new Set(errorCodes)],
|
|
31643
|
+
...additionalInfo
|
|
31644
|
+
});
|
|
31645
|
+
}
|
|
31646
|
+
__name(logPartialFailure, "logPartialFailure");
|
|
31647
|
+
|
|
31648
|
+
// src/server/utils/chunking.ts
|
|
31649
|
+
init_shared();
|
|
31650
|
+
var logger3 = createLogger({ service: "records-lambda" });
|
|
31651
|
+
function calculateChunks(records, getItemCount) {
|
|
31652
|
+
const chunks = [];
|
|
31653
|
+
const itemCounts = [];
|
|
31654
|
+
let currentChunk = [];
|
|
31655
|
+
let currentItemCount = 0;
|
|
31656
|
+
for (const record of records) {
|
|
31657
|
+
const itemCount = getItemCount(record);
|
|
31658
|
+
if (itemCount > DYNAMODB_TRANSACT_WRITE_MAX_ITEMS) {
|
|
31659
|
+
const errorMsg = `Single record exceeds ${DYNAMODB_TRANSACT_WRITE_MAX_ITEMS} items limit: ${itemCount} items`;
|
|
31660
|
+
logger3.error("Chunk validation failed", {
|
|
31661
|
+
itemCount,
|
|
31662
|
+
limit: DYNAMODB_TRANSACT_WRITE_MAX_ITEMS
|
|
31663
|
+
});
|
|
31664
|
+
throw new Error(errorMsg);
|
|
31665
|
+
}
|
|
31666
|
+
if (currentItemCount + itemCount > DYNAMODB_TRANSACT_WRITE_MAX_ITEMS) {
|
|
31667
|
+
if (currentChunk.length > 0) {
|
|
31668
|
+
chunks.push(currentChunk);
|
|
31669
|
+
itemCounts.push(currentItemCount);
|
|
31670
|
+
}
|
|
31671
|
+
currentChunk = [record];
|
|
31672
|
+
currentItemCount = itemCount;
|
|
31673
|
+
} else {
|
|
31674
|
+
currentChunk.push(record);
|
|
31675
|
+
currentItemCount += itemCount;
|
|
31676
|
+
}
|
|
31677
|
+
}
|
|
31678
|
+
if (currentChunk.length > 0) {
|
|
31679
|
+
chunks.push(currentChunk);
|
|
31680
|
+
itemCounts.push(currentItemCount);
|
|
31681
|
+
}
|
|
31682
|
+
logger3.info("Chunk calculation completed", {
|
|
31683
|
+
totalRecords: records.length,
|
|
31684
|
+
chunkCount: chunks.length,
|
|
31685
|
+
itemCounts,
|
|
31686
|
+
minItemsPerChunk: itemCounts.length > 0 ? Math.min(...itemCounts) : 0,
|
|
31687
|
+
maxItemsPerChunk: itemCounts.length > 0 ? Math.max(...itemCounts) : 0,
|
|
31688
|
+
avgItemsPerChunk: itemCounts.length > 0 ? Math.round(itemCounts.reduce((sum, count) => sum + count, 0) / itemCounts.length) : 0
|
|
31689
|
+
});
|
|
31690
|
+
return { chunks, itemCounts };
|
|
31691
|
+
}
|
|
31692
|
+
__name(calculateChunks, "calculateChunks");
|
|
31693
|
+
async function executeChunks(chunks, executeChunk, getRecordId) {
|
|
31694
|
+
const successRecords = [];
|
|
31695
|
+
const failedIds = [];
|
|
31696
|
+
const errors = [];
|
|
31697
|
+
const totalRecords = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
31698
|
+
const executionStartTime = Date.now();
|
|
31699
|
+
logger3.info("Starting chunk execution", {
|
|
31700
|
+
totalChunks: chunks.length,
|
|
31701
|
+
totalRecords
|
|
31702
|
+
});
|
|
31703
|
+
for (let i4 = 0; i4 < chunks.length; i4++) {
|
|
31704
|
+
const chunk = chunks[i4];
|
|
31705
|
+
const chunkStartTime = Date.now();
|
|
31706
|
+
try {
|
|
31707
|
+
logger3.debug(`Executing chunk ${i4 + 1}/${chunks.length}`, {
|
|
31708
|
+
chunkIndex: i4,
|
|
31709
|
+
recordCount: chunk.length
|
|
31710
|
+
});
|
|
31711
|
+
const successfulRecords = await executeChunk(chunk);
|
|
31712
|
+
successRecords.push(...successfulRecords);
|
|
31713
|
+
const chunkDuration = Date.now() - chunkStartTime;
|
|
31714
|
+
logger3.info(`Chunk ${i4 + 1}/${chunks.length} succeeded`, {
|
|
31715
|
+
chunkIndex: i4,
|
|
31716
|
+
recordCount: chunk.length,
|
|
31717
|
+
durationMs: chunkDuration
|
|
31718
|
+
});
|
|
31719
|
+
} catch (error2) {
|
|
31720
|
+
const chunkDuration = Date.now() - chunkStartTime;
|
|
31721
|
+
const errorMessage = error2 instanceof Error ? error2.message : "Unknown error";
|
|
31722
|
+
const errorCode = getErrorCode(error2);
|
|
31723
|
+
logger3.error(`Chunk ${i4 + 1}/${chunks.length} failed`, {
|
|
31724
|
+
chunkIndex: i4,
|
|
31725
|
+
recordCount: chunk.length,
|
|
31726
|
+
durationMs: chunkDuration,
|
|
31727
|
+
error: errorMessage,
|
|
31728
|
+
errorCode
|
|
31729
|
+
});
|
|
31730
|
+
for (const record of chunk) {
|
|
31731
|
+
const recordId = getRecordId(record);
|
|
31732
|
+
failedIds.push(recordId);
|
|
31733
|
+
errors.push({
|
|
31734
|
+
id: recordId,
|
|
31735
|
+
code: errorCode,
|
|
31736
|
+
message: errorMessage
|
|
31737
|
+
});
|
|
31738
|
+
}
|
|
31739
|
+
}
|
|
31740
|
+
}
|
|
31741
|
+
const totalExecutionTime = Date.now() - executionStartTime;
|
|
31742
|
+
logger3.info("Chunk execution completed", {
|
|
31743
|
+
totalChunks: chunks.length,
|
|
31744
|
+
totalRecords,
|
|
31745
|
+
successCount: successRecords.length,
|
|
31746
|
+
failedCount: failedIds.length,
|
|
31747
|
+
totalExecutionTimeMs: totalExecutionTime,
|
|
31748
|
+
avgTimePerChunkMs: chunks.length > 0 ? Math.round(totalExecutionTime / chunks.length) : 0
|
|
31749
|
+
});
|
|
31750
|
+
if (failedIds.length > 0) {
|
|
31751
|
+
logger3.warn("Partial failure detected in chunk execution", {
|
|
31752
|
+
totalRecords,
|
|
31753
|
+
successCount: successRecords.length,
|
|
31754
|
+
failedCount: failedIds.length,
|
|
31755
|
+
failureRate: `${Math.round(failedIds.length / totalRecords * 100)}%`,
|
|
31756
|
+
failedIds: failedIds.slice(0, 10),
|
|
31757
|
+
// 最初の10件のみログ出力
|
|
31758
|
+
errorSummary: errors.slice(0, 5).map((e4) => ({
|
|
31759
|
+
id: e4.id,
|
|
31760
|
+
code: e4.code,
|
|
31761
|
+
message: e4.message.substring(0, 100)
|
|
31762
|
+
// メッセージを100文字に制限
|
|
31763
|
+
}))
|
|
31764
|
+
});
|
|
31765
|
+
}
|
|
31766
|
+
return {
|
|
31767
|
+
successRecords,
|
|
31768
|
+
failedIds,
|
|
31769
|
+
errors
|
|
31770
|
+
};
|
|
31771
|
+
}
|
|
31772
|
+
__name(executeChunks, "executeChunks");
|
|
31773
|
+
function getErrorCode(error2) {
|
|
31774
|
+
if (error2 && typeof error2 === "object") {
|
|
31775
|
+
if ("name" in error2 && typeof error2.name === "string") {
|
|
31776
|
+
return error2.name;
|
|
31777
|
+
}
|
|
31778
|
+
if ("code" in error2 && typeof error2.code === "string") {
|
|
31779
|
+
return error2.code;
|
|
31780
|
+
}
|
|
31781
|
+
}
|
|
31782
|
+
return "TRANSACTION_FAILED";
|
|
31783
|
+
}
|
|
31784
|
+
__name(getErrorCode, "getErrorCode");
|
|
31785
|
+
|
|
31786
|
+
// src/server/operations/deleteMany.ts
|
|
31787
|
+
init_dynamodb3();
|
|
31788
|
+
var logger10 = createLogger({ service: "records-lambda" });
|
|
31789
|
+
async function handleDeleteMany(resource, params, requestId) {
|
|
31790
|
+
const startTime = Date.now();
|
|
31791
|
+
let ids;
|
|
31792
|
+
if ("ids" in params) {
|
|
31793
|
+
ids = params.ids;
|
|
31794
|
+
logger10.debug("Executing deleteMany with ids", {
|
|
31795
|
+
requestId,
|
|
31796
|
+
resource,
|
|
31797
|
+
count: ids.length
|
|
31798
|
+
});
|
|
31799
|
+
} else {
|
|
31800
|
+
logger10.debug("Executing deleteMany with filter", {
|
|
31801
|
+
requestId,
|
|
31802
|
+
resource,
|
|
31803
|
+
filter: params.filter
|
|
31804
|
+
});
|
|
31805
|
+
const { handleFind: handleFind2 } = await Promise.resolve().then(() => (init_find(), find_exports));
|
|
31806
|
+
const findResult = await handleFind2(resource, { filter: params.filter }, requestId);
|
|
31807
|
+
ids = findResult.items.map((item) => item.id);
|
|
31808
|
+
logger10.debug("Found records with filter", {
|
|
31809
|
+
requestId,
|
|
31810
|
+
resource,
|
|
31811
|
+
count: ids.length
|
|
31812
|
+
});
|
|
31813
|
+
}
|
|
31814
|
+
if (ids.length === 0) {
|
|
31815
|
+
return {
|
|
31816
|
+
count: 0,
|
|
31817
|
+
successIds: {},
|
|
31818
|
+
failedIds: {},
|
|
31819
|
+
errors: {}
|
|
31820
|
+
};
|
|
31821
|
+
}
|
|
31822
|
+
logLargeBatchWarning("deleteMany", ids.length, requestId, resource);
|
|
31823
|
+
const dbClient2 = getDBClient();
|
|
31824
|
+
const tableName = getTableName();
|
|
31825
|
+
const keys = ids.map((id) => ({
|
|
31826
|
+
PK: resource,
|
|
31827
|
+
SK: generateMainRecordSK2(id)
|
|
31828
|
+
}));
|
|
31829
|
+
const batchGetResult = await executeDynamoDBOperation(
|
|
31830
|
+
() => dbClient2.send(
|
|
31831
|
+
new import_lib_dynamodb5.BatchGetCommand({
|
|
31832
|
+
RequestItems: {
|
|
31833
|
+
[tableName]: {
|
|
31834
|
+
Keys: keys,
|
|
31835
|
+
ConsistentRead: true
|
|
31836
|
+
}
|
|
31837
|
+
}
|
|
31838
|
+
})
|
|
31839
|
+
),
|
|
31840
|
+
"BatchGetItem"
|
|
31841
|
+
);
|
|
31842
|
+
const existingItems = batchGetResult.Responses?.[tableName] || [];
|
|
31843
|
+
const existingIds = /* @__PURE__ */ new Set();
|
|
31844
|
+
const preparedRecords = [];
|
|
31845
|
+
for (const item of existingItems) {
|
|
31846
|
+
const existingData = item.data;
|
|
31847
|
+
const id = existingData.id;
|
|
31848
|
+
const shadowKeys = existingData.__shadowKeys || [];
|
|
31849
|
+
existingIds.add(id);
|
|
31850
|
+
preparedRecords.push({
|
|
31851
|
+
id,
|
|
31852
|
+
mainSK: generateMainRecordSK2(id),
|
|
31853
|
+
shadowKeys
|
|
31854
|
+
});
|
|
31855
|
+
}
|
|
31856
|
+
const notFoundIds = ids.filter((id) => !existingIds.has(id));
|
|
31857
|
+
const notFoundErrors = notFoundIds.map((id) => ({
|
|
31858
|
+
id,
|
|
31859
|
+
code: "ITEM_NOT_FOUND",
|
|
31860
|
+
message: `Record not found: ${id}`
|
|
31861
|
+
}));
|
|
31862
|
+
if (preparedRecords.length === 0) {
|
|
31863
|
+
logger10.info("deleteMany completed - no records found", {
|
|
31864
|
+
requestId,
|
|
31865
|
+
resource,
|
|
31866
|
+
requested: ids.length,
|
|
31867
|
+
notFound: notFoundIds.length
|
|
31868
|
+
});
|
|
31869
|
+
const failedIdsMap2 = {};
|
|
31870
|
+
const errorsMap2 = {};
|
|
31871
|
+
for (let i4 = 0; i4 < ids.length; i4++) {
|
|
31872
|
+
const id = ids[i4];
|
|
31873
|
+
if (notFoundIds.includes(id)) {
|
|
31874
|
+
failedIdsMap2[i4] = id;
|
|
31875
|
+
const error2 = notFoundErrors.find((e4) => e4.id === id);
|
|
31876
|
+
if (error2) {
|
|
31877
|
+
errorsMap2[i4] = error2;
|
|
31878
|
+
}
|
|
31879
|
+
}
|
|
31880
|
+
}
|
|
31881
|
+
return {
|
|
31882
|
+
count: 0,
|
|
31883
|
+
successIds: {},
|
|
31884
|
+
failedIds: failedIdsMap2,
|
|
31885
|
+
errors: errorsMap2
|
|
31886
|
+
};
|
|
31887
|
+
}
|
|
31888
|
+
const getItemCount = /* @__PURE__ */ __name((record) => {
|
|
31889
|
+
return 1 + record.shadowKeys.length;
|
|
31890
|
+
}, "getItemCount");
|
|
31891
|
+
const { chunks } = calculateChunks(preparedRecords, getItemCount);
|
|
31892
|
+
const preparationRiskInfo = calculateTimeoutRisk(startTime);
|
|
31893
|
+
logPreparationTimeoutRisk(
|
|
31894
|
+
requestId,
|
|
31895
|
+
resource,
|
|
31896
|
+
preparedRecords.length,
|
|
31897
|
+
chunks.length,
|
|
31898
|
+
preparationRiskInfo
|
|
31899
|
+
);
|
|
31900
|
+
const executeChunk = /* @__PURE__ */ __name(async (chunk) => {
|
|
31901
|
+
const transactItems = [];
|
|
31902
|
+
for (const record of chunk) {
|
|
31903
|
+
transactItems.push({
|
|
31904
|
+
Delete: {
|
|
31905
|
+
TableName: tableName,
|
|
31906
|
+
Key: {
|
|
31907
|
+
PK: resource,
|
|
31908
|
+
SK: record.mainSK
|
|
31909
|
+
}
|
|
31910
|
+
}
|
|
31911
|
+
});
|
|
31912
|
+
for (const shadowSK of record.shadowKeys) {
|
|
31913
|
+
transactItems.push({
|
|
31914
|
+
Delete: {
|
|
31915
|
+
TableName: tableName,
|
|
31916
|
+
Key: {
|
|
31917
|
+
PK: resource,
|
|
31918
|
+
SK: shadowSK
|
|
31919
|
+
}
|
|
31920
|
+
}
|
|
31921
|
+
});
|
|
31922
|
+
}
|
|
31923
|
+
}
|
|
31924
|
+
await executeDynamoDBOperation(
|
|
31925
|
+
() => dbClient2.send(
|
|
31926
|
+
new import_lib_dynamodb5.TransactWriteCommand({
|
|
31927
|
+
TransactItems: transactItems
|
|
31928
|
+
})
|
|
31929
|
+
),
|
|
31930
|
+
"TransactWriteItems"
|
|
31931
|
+
);
|
|
31932
|
+
return chunk;
|
|
31933
|
+
}, "executeChunk");
|
|
31934
|
+
const {
|
|
31935
|
+
successRecords,
|
|
31936
|
+
failedIds: chunkFailedIds,
|
|
31937
|
+
errors: chunkErrors
|
|
31938
|
+
} = await executeChunks(chunks, executeChunk, (record) => record.id);
|
|
31939
|
+
const successIds = {};
|
|
31940
|
+
const failedIdsMap = {};
|
|
31941
|
+
const errorsMap = {};
|
|
31942
|
+
const successIdSet = new Set(successRecords.map((r4) => r4.id));
|
|
31943
|
+
for (let i4 = 0; i4 < ids.length; i4++) {
|
|
31944
|
+
const id = ids[i4];
|
|
31945
|
+
if (successIdSet.has(id)) {
|
|
31946
|
+
successIds[i4] = id;
|
|
31947
|
+
}
|
|
31948
|
+
}
|
|
31949
|
+
for (let i4 = 0; i4 < ids.length; i4++) {
|
|
31950
|
+
const id = ids[i4];
|
|
31951
|
+
if (notFoundIds.includes(id)) {
|
|
31952
|
+
failedIdsMap[i4] = id;
|
|
31953
|
+
const error2 = notFoundErrors.find((e4) => e4.id === id);
|
|
31954
|
+
if (error2) {
|
|
31955
|
+
errorsMap[i4] = error2;
|
|
31956
|
+
}
|
|
31957
|
+
}
|
|
30477
31958
|
}
|
|
30478
|
-
let
|
|
30479
|
-
|
|
30480
|
-
|
|
31959
|
+
for (let i4 = 0; i4 < ids.length; i4++) {
|
|
31960
|
+
const id = ids[i4];
|
|
31961
|
+
if (chunkFailedIds.includes(id)) {
|
|
31962
|
+
failedIdsMap[i4] = id;
|
|
31963
|
+
const error2 = chunkErrors.find((e4) => e4.id === id);
|
|
31964
|
+
if (error2) {
|
|
31965
|
+
errorsMap[i4] = {
|
|
31966
|
+
id: error2.id,
|
|
31967
|
+
code: error2.code,
|
|
31968
|
+
message: error2.message
|
|
31969
|
+
};
|
|
31970
|
+
}
|
|
31971
|
+
}
|
|
30481
31972
|
}
|
|
30482
|
-
const
|
|
30483
|
-
const
|
|
30484
|
-
|
|
30485
|
-
|
|
30486
|
-
|
|
30487
|
-
logger8.info("ID all records query succeeded", {
|
|
31973
|
+
const count = Object.keys(successIds).length;
|
|
31974
|
+
const allFailedIds = Object.values(failedIdsMap);
|
|
31975
|
+
const completionRiskInfo = calculateTimeoutRisk(startTime);
|
|
31976
|
+
logBulkOperationComplete(
|
|
31977
|
+
"deleteMany",
|
|
30488
31978
|
requestId,
|
|
30489
31979
|
resource,
|
|
30490
|
-
|
|
30491
|
-
|
|
30492
|
-
|
|
31980
|
+
ids.length,
|
|
31981
|
+
count,
|
|
31982
|
+
allFailedIds.length,
|
|
31983
|
+
completionRiskInfo,
|
|
31984
|
+
{
|
|
31985
|
+
deleted: count,
|
|
31986
|
+
notFound: notFoundIds.length,
|
|
31987
|
+
chunkExecutionFailed: chunkFailedIds.length
|
|
31988
|
+
}
|
|
31989
|
+
);
|
|
31990
|
+
if (allFailedIds.length > 0) {
|
|
31991
|
+
logPartialFailure(
|
|
31992
|
+
"deleteMany",
|
|
31993
|
+
requestId,
|
|
31994
|
+
resource,
|
|
31995
|
+
ids.length,
|
|
31996
|
+
count,
|
|
31997
|
+
allFailedIds.length,
|
|
31998
|
+
Object.values(errorsMap).map((e4) => e4.code),
|
|
31999
|
+
{
|
|
32000
|
+
notFoundFailures: notFoundIds.length,
|
|
32001
|
+
chunkExecutionFailures: chunkFailedIds.length
|
|
32002
|
+
}
|
|
32003
|
+
);
|
|
32004
|
+
}
|
|
30493
32005
|
return {
|
|
30494
|
-
|
|
30495
|
-
|
|
30496
|
-
|
|
30497
|
-
|
|
30498
|
-
},
|
|
30499
|
-
...nextTokenValue && { nextToken: nextTokenValue }
|
|
32006
|
+
count,
|
|
32007
|
+
successIds,
|
|
32008
|
+
failedIds: failedIdsMap,
|
|
32009
|
+
errors: errorsMap
|
|
30500
32010
|
};
|
|
30501
32011
|
}
|
|
30502
|
-
__name(
|
|
32012
|
+
__name(handleDeleteMany, "handleDeleteMany");
|
|
30503
32013
|
|
|
30504
|
-
// src/server/operations/
|
|
30505
|
-
var
|
|
30506
|
-
|
|
30507
|
-
|
|
30508
|
-
|
|
30509
|
-
});
|
|
30510
|
-
async function
|
|
30511
|
-
|
|
30512
|
-
|
|
30513
|
-
|
|
30514
|
-
|
|
30515
|
-
nearQuery,
|
|
30516
|
-
limit
|
|
30517
|
-
});
|
|
30518
|
-
const searchFunction = /* @__PURE__ */ __name(async (geohashPrefix) => {
|
|
30519
|
-
const dbClient2 = getDBClient();
|
|
30520
|
-
const tableName = getTableName();
|
|
30521
|
-
logger9.debug("Searching shadow records", {
|
|
32014
|
+
// src/server/operations/deleteOne.ts
|
|
32015
|
+
var import_lib_dynamodb6 = __toESM(require_dist_cjs66(), 1);
|
|
32016
|
+
init_shared();
|
|
32017
|
+
init_shadow();
|
|
32018
|
+
init_dynamodb3();
|
|
32019
|
+
var logger11 = createLogger({ service: "records-lambda" });
|
|
32020
|
+
async function handleDeleteOne(resource, params, requestId) {
|
|
32021
|
+
let targetId;
|
|
32022
|
+
if ("id" in params) {
|
|
32023
|
+
targetId = params.id;
|
|
32024
|
+
logger11.debug("Executing deleteOne with id", {
|
|
30522
32025
|
requestId,
|
|
30523
32026
|
resource,
|
|
30524
|
-
|
|
30525
|
-
geohashPrefix,
|
|
30526
|
-
skPrefix: `${fieldName}#${geohashPrefix}`
|
|
32027
|
+
id: targetId
|
|
30527
32028
|
});
|
|
30528
|
-
|
|
30529
|
-
|
|
30530
|
-
new import_lib_dynamodb5.QueryCommand({
|
|
30531
|
-
TableName: tableName,
|
|
30532
|
-
KeyConditionExpression: "PK = :pk AND begins_with(SK, :skPrefix)",
|
|
30533
|
-
ExpressionAttributeValues: {
|
|
30534
|
-
":pk": resource,
|
|
30535
|
-
":skPrefix": `${fieldName}#${geohashPrefix}`
|
|
30536
|
-
},
|
|
30537
|
-
ConsistentRead: false
|
|
30538
|
-
// シャドウレコードは結果整合性で十分
|
|
30539
|
-
})
|
|
30540
|
-
),
|
|
30541
|
-
"Query"
|
|
30542
|
-
);
|
|
30543
|
-
const shadowRecords = queryResult.Items || [];
|
|
30544
|
-
logger9.debug("Shadow records found", {
|
|
32029
|
+
} else {
|
|
32030
|
+
logger11.debug("Executing deleteOne with filter", {
|
|
30545
32031
|
requestId,
|
|
30546
32032
|
resource,
|
|
30547
|
-
|
|
30548
|
-
count: shadowRecords.length
|
|
32033
|
+
filter: params.filter
|
|
30549
32034
|
});
|
|
30550
|
-
const
|
|
30551
|
-
|
|
30552
|
-
const parts = sk.split("#id#");
|
|
30553
|
-
return parts.length === 2 ? parts[1] : null;
|
|
30554
|
-
}).filter((id) => id !== null);
|
|
30555
|
-
logger9.debug("Main record IDs extracted", {
|
|
30556
|
-
requestId,
|
|
32035
|
+
const { handleFind: handleFind2 } = await Promise.resolve().then(() => (init_find(), find_exports));
|
|
32036
|
+
const findResult = await handleFind2(
|
|
30557
32037
|
resource,
|
|
30558
|
-
|
|
30559
|
-
|
|
30560
|
-
});
|
|
30561
|
-
const mainRecords = await Promise.all(
|
|
30562
|
-
mainRecordIds.map(async (id) => {
|
|
30563
|
-
const result2 = await executeDynamoDBOperation(
|
|
30564
|
-
() => dbClient2.send(
|
|
30565
|
-
new import_lib_dynamodb5.QueryCommand({
|
|
30566
|
-
TableName: tableName,
|
|
30567
|
-
KeyConditionExpression: "PK = :pk AND SK = :sk",
|
|
30568
|
-
ExpressionAttributeValues: {
|
|
30569
|
-
":pk": resource,
|
|
30570
|
-
// venues
|
|
30571
|
-
":sk": `id#${id}`
|
|
30572
|
-
},
|
|
30573
|
-
ConsistentRead: true
|
|
30574
|
-
})
|
|
30575
|
-
),
|
|
30576
|
-
"Query"
|
|
30577
|
-
);
|
|
30578
|
-
return result2.Items?.[0];
|
|
30579
|
-
})
|
|
30580
|
-
);
|
|
30581
|
-
const validRecords = mainRecords.filter(
|
|
30582
|
-
(item) => item !== void 0
|
|
32038
|
+
{ filter: params.filter, pagination: { perPage: 1 } },
|
|
32039
|
+
requestId
|
|
30583
32040
|
);
|
|
30584
|
-
|
|
30585
|
-
|
|
30586
|
-
|
|
30587
|
-
|
|
30588
|
-
|
|
30589
|
-
});
|
|
30590
|
-
const cleanRecords = validRecords.map((record) => extractCleanRecord(record));
|
|
30591
|
-
logger9.debug("Clean records extracted", {
|
|
30592
|
-
requestId,
|
|
30593
|
-
resource,
|
|
30594
|
-
geohashPrefix,
|
|
30595
|
-
count: cleanRecords.length,
|
|
30596
|
-
sampleKeys: cleanRecords[0] ? Object.keys(cleanRecords[0]) : []
|
|
30597
|
-
});
|
|
30598
|
-
return cleanRecords;
|
|
30599
|
-
}, "searchFunction");
|
|
30600
|
-
const result = await executeNearSearch(
|
|
30601
|
-
nearQuery,
|
|
30602
|
-
fieldName,
|
|
30603
|
-
limit,
|
|
30604
|
-
searchFunction,
|
|
30605
|
-
DEFAULT_GEOHASH_CONFIG
|
|
30606
|
-
);
|
|
30607
|
-
const items = result.documents;
|
|
30608
|
-
logger9.info("$near query succeeded", {
|
|
30609
|
-
requestId,
|
|
30610
|
-
resource,
|
|
30611
|
-
fieldName,
|
|
30612
|
-
count: items.length,
|
|
30613
|
-
iterations: result.metadata.iterations,
|
|
30614
|
-
candidatesFound: result.metadata.candidatesFound
|
|
30615
|
-
});
|
|
30616
|
-
return {
|
|
30617
|
-
items,
|
|
30618
|
-
pageInfo: {
|
|
30619
|
-
hasNextPage: false,
|
|
30620
|
-
// $near検索はページネーション非対応
|
|
30621
|
-
hasPreviousPage: false
|
|
30622
|
-
}
|
|
30623
|
-
};
|
|
30624
|
-
}
|
|
30625
|
-
__name(executeNearQuery, "executeNearQuery");
|
|
30626
|
-
|
|
30627
|
-
// src/server/operations/find/shadowQuery.ts
|
|
30628
|
-
var import_lib_dynamodb6 = __toESM(require_dist_cjs66(), 1);
|
|
30629
|
-
var logger10 = createLogger({
|
|
30630
|
-
service: "shadow-query",
|
|
30631
|
-
level: process.env.LOG_LEVEL || "info"
|
|
30632
|
-
});
|
|
30633
|
-
async function executeShadowQuery(resource, normalizedParams, requestId) {
|
|
30634
|
-
const { sort, pagination, parsedFilters } = normalizedParams;
|
|
30635
|
-
const { perPage, nextToken } = pagination;
|
|
30636
|
-
logger10.debug("Executing shadow query", {
|
|
30637
|
-
requestId,
|
|
30638
|
-
resource,
|
|
30639
|
-
sortField: sort.field,
|
|
30640
|
-
hasFilters: parsedFilters.length > 0
|
|
30641
|
-
});
|
|
30642
|
-
const optimizableFilter = findOptimizableFilter(sort.field, parsedFilters);
|
|
30643
|
-
const shadowRecords = await executeShadowRecordQuery(
|
|
30644
|
-
resource,
|
|
30645
|
-
sort,
|
|
30646
|
-
perPage,
|
|
30647
|
-
nextToken,
|
|
30648
|
-
optimizableFilter,
|
|
30649
|
-
requestId
|
|
30650
|
-
);
|
|
30651
|
-
const recordIds = extractRecordIds(shadowRecords.Items || []);
|
|
30652
|
-
if (recordIds.length === 0) {
|
|
30653
|
-
return {
|
|
30654
|
-
items: [],
|
|
30655
|
-
pageInfo: {
|
|
30656
|
-
hasNextPage: false,
|
|
30657
|
-
hasPreviousPage: false
|
|
30658
|
-
}
|
|
30659
|
-
};
|
|
30660
|
-
}
|
|
30661
|
-
const mainRecords = await fetchMainRecords(resource, recordIds, requestId);
|
|
30662
|
-
const recordMap = new Map(
|
|
30663
|
-
mainRecords.map((item) => {
|
|
30664
|
-
const data2 = item.data;
|
|
30665
|
-
return [data2.id, extractCleanRecord(item)];
|
|
30666
|
-
})
|
|
30667
|
-
);
|
|
30668
|
-
const seenIds = /* @__PURE__ */ new Set();
|
|
30669
|
-
let items = recordIds.filter((id) => {
|
|
30670
|
-
if (seenIds.has(id)) {
|
|
30671
|
-
return false;
|
|
32041
|
+
if (findResult.items.length === 0) {
|
|
32042
|
+
throw new ItemNotFoundError(`Record not found with filter`, {
|
|
32043
|
+
resource,
|
|
32044
|
+
filter: params.filter
|
|
32045
|
+
});
|
|
30672
32046
|
}
|
|
30673
|
-
|
|
30674
|
-
|
|
30675
|
-
}).map((id) => recordMap.get(id)).filter((record) => record !== void 0);
|
|
30676
|
-
if (parsedFilters.length > 0) {
|
|
30677
|
-
items = items.filter((record) => matchesAllFilters(record, parsedFilters));
|
|
32047
|
+
const foundRecord = findResult.items[0];
|
|
32048
|
+
targetId = foundRecord.id;
|
|
30678
32049
|
}
|
|
30679
|
-
const hasNextPage = (shadowRecords.Items?.length || 0) < perPage ? false : shadowRecords.LastEvaluatedKey !== void 0;
|
|
30680
|
-
const nextTokenValue = hasNextPage && shadowRecords.LastEvaluatedKey ? encodeNextToken(
|
|
30681
|
-
shadowRecords.LastEvaluatedKey.PK,
|
|
30682
|
-
shadowRecords.LastEvaluatedKey.SK
|
|
30683
|
-
) : void 0;
|
|
30684
|
-
logger10.info("Shadow query succeeded", {
|
|
30685
|
-
requestId,
|
|
30686
|
-
resource,
|
|
30687
|
-
sortField: sort.field,
|
|
30688
|
-
shadowCount: shadowRecords.Items?.length || 0,
|
|
30689
|
-
mainCount: items.length,
|
|
30690
|
-
hasNextPage
|
|
30691
|
-
});
|
|
30692
|
-
return {
|
|
30693
|
-
items,
|
|
30694
|
-
pageInfo: {
|
|
30695
|
-
hasNextPage,
|
|
30696
|
-
hasPreviousPage: !!nextToken
|
|
30697
|
-
},
|
|
30698
|
-
...nextTokenValue && { nextToken: nextTokenValue }
|
|
30699
|
-
};
|
|
30700
|
-
}
|
|
30701
|
-
__name(executeShadowQuery, "executeShadowQuery");
|
|
30702
|
-
async function executeShadowRecordQuery(resource, sort, perPage, nextToken, optimizableFilter, _requestId) {
|
|
30703
32050
|
const dbClient2 = getDBClient();
|
|
30704
32051
|
const tableName = getTableName();
|
|
30705
|
-
|
|
30706
|
-
|
|
30707
|
-
const decoded = decodeNextToken(nextToken);
|
|
30708
|
-
exclusiveStartKey = {
|
|
30709
|
-
PK: decoded.PK,
|
|
30710
|
-
SK: decoded.SK
|
|
30711
|
-
};
|
|
30712
|
-
}
|
|
30713
|
-
const { keyConditionExpression, expressionAttributeValues } = buildKeyCondition(
|
|
30714
|
-
resource,
|
|
30715
|
-
sort.field,
|
|
30716
|
-
optimizableFilter
|
|
30717
|
-
);
|
|
30718
|
-
return await executeDynamoDBOperation(
|
|
32052
|
+
const mainSK = generateMainRecordSK2(targetId);
|
|
32053
|
+
const getResult = await executeDynamoDBOperation(
|
|
30719
32054
|
() => dbClient2.send(
|
|
30720
|
-
new import_lib_dynamodb6.
|
|
32055
|
+
new import_lib_dynamodb6.GetCommand({
|
|
30721
32056
|
TableName: tableName,
|
|
30722
|
-
|
|
30723
|
-
|
|
30724
|
-
|
|
30725
|
-
|
|
30726
|
-
ExclusiveStartKey: exclusiveStartKey,
|
|
32057
|
+
Key: {
|
|
32058
|
+
PK: resource,
|
|
32059
|
+
SK: mainSK
|
|
32060
|
+
},
|
|
30727
32061
|
ConsistentRead: true
|
|
30728
32062
|
})
|
|
30729
32063
|
),
|
|
30730
|
-
"
|
|
32064
|
+
"GetItem"
|
|
30731
32065
|
);
|
|
30732
|
-
|
|
30733
|
-
|
|
30734
|
-
function buildKeyCondition(resource, sortField, optimizableFilter) {
|
|
30735
|
-
const expressionAttributeValues = {
|
|
30736
|
-
":pk": resource
|
|
30737
|
-
};
|
|
30738
|
-
if (!optimizableFilter) {
|
|
30739
|
-
return {
|
|
30740
|
-
keyConditionExpression: "PK = :pk AND begins_with(SK, :skPrefix)",
|
|
30741
|
-
expressionAttributeValues: {
|
|
30742
|
-
...expressionAttributeValues,
|
|
30743
|
-
":skPrefix": `${sortField}#`
|
|
30744
|
-
}
|
|
30745
|
-
};
|
|
32066
|
+
if (!getResult.Item) {
|
|
32067
|
+
throw new ItemNotFoundError(`Record not found: ${targetId}`, { resource, id: targetId });
|
|
30746
32068
|
}
|
|
30747
|
-
const
|
|
30748
|
-
const
|
|
30749
|
-
const
|
|
30750
|
-
|
|
30751
|
-
|
|
30752
|
-
|
|
30753
|
-
|
|
30754
|
-
|
|
30755
|
-
|
|
30756
|
-
|
|
30757
|
-
|
|
30758
|
-
|
|
30759
|
-
|
|
30760
|
-
|
|
30761
|
-
|
|
30762
|
-
|
|
30763
|
-
|
|
30764
|
-
|
|
30765
|
-
|
|
30766
|
-
}
|
|
30767
|
-
};
|
|
30768
|
-
case "$gte":
|
|
30769
|
-
return {
|
|
30770
|
-
keyConditionExpression: "PK = :pk AND SK >= :skValue",
|
|
30771
|
-
expressionAttributeValues: {
|
|
30772
|
-
...expressionAttributeValues,
|
|
30773
|
-
":skValue": `${skValue}#id#`
|
|
30774
|
-
}
|
|
30775
|
-
};
|
|
30776
|
-
case "$lt":
|
|
30777
|
-
return {
|
|
30778
|
-
keyConditionExpression: "PK = :pk AND begins_with(SK, :skPrefix) AND SK < :skValue",
|
|
30779
|
-
expressionAttributeValues: {
|
|
30780
|
-
...expressionAttributeValues,
|
|
30781
|
-
":skPrefix": `${sortField}#`,
|
|
30782
|
-
":skValue": `${skValue}#id#`
|
|
30783
|
-
}
|
|
30784
|
-
};
|
|
30785
|
-
case "$lte":
|
|
30786
|
-
return {
|
|
30787
|
-
keyConditionExpression: "PK = :pk AND begins_with(SK, :skPrefix) AND SK <= :skValue",
|
|
30788
|
-
expressionAttributeValues: {
|
|
30789
|
-
...expressionAttributeValues,
|
|
30790
|
-
":skPrefix": `${sortField}#`,
|
|
30791
|
-
":skValue": `${skValue}#id#~`
|
|
30792
|
-
}
|
|
30793
|
-
};
|
|
30794
|
-
default:
|
|
30795
|
-
return {
|
|
30796
|
-
keyConditionExpression: "PK = :pk AND begins_with(SK, :skPrefix)",
|
|
30797
|
-
expressionAttributeValues: {
|
|
30798
|
-
...expressionAttributeValues,
|
|
30799
|
-
":skPrefix": `${sortField}#`
|
|
32069
|
+
const existingData = getResult.Item.data;
|
|
32070
|
+
const shadowKeys = existingData.__shadowKeys || [];
|
|
32071
|
+
const transactItems = [];
|
|
32072
|
+
transactItems.push({
|
|
32073
|
+
Delete: {
|
|
32074
|
+
TableName: tableName,
|
|
32075
|
+
Key: {
|
|
32076
|
+
PK: resource,
|
|
32077
|
+
SK: mainSK
|
|
32078
|
+
}
|
|
32079
|
+
}
|
|
32080
|
+
});
|
|
32081
|
+
for (const shadowSK of shadowKeys) {
|
|
32082
|
+
transactItems.push({
|
|
32083
|
+
Delete: {
|
|
32084
|
+
TableName: tableName,
|
|
32085
|
+
Key: {
|
|
32086
|
+
PK: resource,
|
|
32087
|
+
SK: shadowSK
|
|
30800
32088
|
}
|
|
30801
|
-
}
|
|
30802
|
-
|
|
30803
|
-
}
|
|
30804
|
-
__name(buildKeyCondition, "buildKeyCondition");
|
|
30805
|
-
function encodeValueForShadowSK(value, type) {
|
|
30806
|
-
if (type === "number") {
|
|
30807
|
-
return String(value).padStart(NUMBER_FORMAT.SHADOW_SK_DIGITS, NUMBER_FORMAT.ZERO_PAD_CHAR);
|
|
30808
|
-
} else if (type === "date") {
|
|
30809
|
-
return new Date(String(value)).toISOString();
|
|
30810
|
-
} else if (type === "boolean") {
|
|
30811
|
-
return String(value);
|
|
30812
|
-
} else {
|
|
30813
|
-
return String(value).replace(/#/g, "##").replace(/ /g, "#");
|
|
32089
|
+
}
|
|
32090
|
+
});
|
|
30814
32091
|
}
|
|
30815
|
-
|
|
30816
|
-
__name(encodeValueForShadowSK, "encodeValueForShadowSK");
|
|
30817
|
-
function extractRecordIds(shadowRecords) {
|
|
30818
|
-
return shadowRecords.map((record) => {
|
|
30819
|
-
const sk = record.SK;
|
|
30820
|
-
const parts = sk.split("#id#");
|
|
30821
|
-
return parts.length > 1 ? parts[1] : null;
|
|
30822
|
-
}).filter((id) => id !== null);
|
|
30823
|
-
}
|
|
30824
|
-
__name(extractRecordIds, "extractRecordIds");
|
|
30825
|
-
async function fetchMainRecords(resource, recordIds, requestId) {
|
|
30826
|
-
const dbClient2 = getDBClient();
|
|
30827
|
-
const tableName = getTableName();
|
|
30828
|
-
const uniqueRecordIds = Array.from(new Set(recordIds));
|
|
30829
|
-
const batchGetResult = await executeDynamoDBOperation(
|
|
32092
|
+
await executeDynamoDBOperation(
|
|
30830
32093
|
() => dbClient2.send(
|
|
30831
|
-
new import_lib_dynamodb6.
|
|
30832
|
-
|
|
30833
|
-
[tableName]: {
|
|
30834
|
-
Keys: uniqueRecordIds.map((id) => ({
|
|
30835
|
-
PK: resource,
|
|
30836
|
-
SK: `id#${id}`
|
|
30837
|
-
})),
|
|
30838
|
-
ConsistentRead: true
|
|
30839
|
-
}
|
|
30840
|
-
}
|
|
32094
|
+
new import_lib_dynamodb6.TransactWriteCommand({
|
|
32095
|
+
TransactItems: transactItems
|
|
30841
32096
|
})
|
|
30842
32097
|
),
|
|
30843
|
-
"
|
|
32098
|
+
"TransactWriteItems"
|
|
30844
32099
|
);
|
|
30845
|
-
|
|
30846
|
-
logger10.debug("Main records fetched", {
|
|
32100
|
+
logger11.info("deleteOne succeeded", {
|
|
30847
32101
|
requestId,
|
|
30848
32102
|
resource,
|
|
30849
|
-
|
|
30850
|
-
|
|
32103
|
+
id: targetId,
|
|
32104
|
+
shadowCount: shadowKeys.length
|
|
30851
32105
|
});
|
|
30852
|
-
return
|
|
32106
|
+
return { id: targetId };
|
|
30853
32107
|
}
|
|
30854
|
-
__name(
|
|
32108
|
+
__name(handleDeleteOne, "handleDeleteOne");
|
|
30855
32109
|
|
|
30856
|
-
// src/server/operations/
|
|
30857
|
-
|
|
30858
|
-
service: "find-handler",
|
|
30859
|
-
level: process.env.LOG_LEVEL || "info"
|
|
30860
|
-
});
|
|
30861
|
-
async function handleFind(resource, params, requestId) {
|
|
30862
|
-
logger11.debug("Executing find", {
|
|
30863
|
-
requestId,
|
|
30864
|
-
resource,
|
|
30865
|
-
params
|
|
30866
|
-
});
|
|
30867
|
-
const nearDetection = detectNearQuery(params.filter);
|
|
30868
|
-
if (nearDetection) {
|
|
30869
|
-
logger11.debug("$near operator detected, executing near search", {
|
|
30870
|
-
requestId,
|
|
30871
|
-
resource,
|
|
30872
|
-
fieldName: nearDetection.fieldName
|
|
30873
|
-
});
|
|
30874
|
-
const limit = params.pagination?.perPage || 10;
|
|
30875
|
-
return executeNearQuery(
|
|
30876
|
-
resource,
|
|
30877
|
-
nearDetection.fieldName,
|
|
30878
|
-
nearDetection.nearQuery,
|
|
30879
|
-
limit,
|
|
30880
|
-
requestId
|
|
30881
|
-
);
|
|
30882
|
-
}
|
|
30883
|
-
const config = initializeFindConfig();
|
|
30884
|
-
const normalizedParams = normalizeFindParams(config, resource, params);
|
|
30885
|
-
validateSortField(config, resource, normalizedParams.sort);
|
|
30886
|
-
logger11.debug("Find parameters normalized", {
|
|
30887
|
-
requestId,
|
|
30888
|
-
resource,
|
|
30889
|
-
sort: normalizedParams.sort,
|
|
30890
|
-
pagination: normalizedParams.pagination,
|
|
30891
|
-
filterCount: normalizedParams.parsedFilters.length
|
|
30892
|
-
});
|
|
30893
|
-
if (normalizedParams.sort.field === "id") {
|
|
30894
|
-
return executeIdQuery(resource, normalizedParams, requestId);
|
|
30895
|
-
}
|
|
30896
|
-
return executeShadowQuery(resource, normalizedParams, requestId);
|
|
30897
|
-
}
|
|
30898
|
-
__name(handleFind, "handleFind");
|
|
32110
|
+
// src/server/operations/operationDispatcher.ts
|
|
32111
|
+
init_find();
|
|
30899
32112
|
|
|
30900
32113
|
// src/server/operations/findMany.ts
|
|
30901
32114
|
var import_lib_dynamodb7 = __toESM(require_dist_cjs66(), 1);
|
|
32115
|
+
init_shared();
|
|
32116
|
+
init_shadow();
|
|
32117
|
+
init_dynamodb3();
|
|
30902
32118
|
var logger12 = createLogger({ service: "records-lambda" });
|
|
30903
32119
|
async function handleFindMany(resource, params, requestId) {
|
|
30904
32120
|
const { ids } = params;
|
|
@@ -30943,6 +32159,11 @@ __name(handleFindMany, "handleFindMany");
|
|
|
30943
32159
|
|
|
30944
32160
|
// src/server/operations/findManyReference.ts
|
|
30945
32161
|
var import_lib_dynamodb8 = __toESM(require_dist_cjs66(), 1);
|
|
32162
|
+
init_shared();
|
|
32163
|
+
init_shadow();
|
|
32164
|
+
init_dynamodb3();
|
|
32165
|
+
init_pagination();
|
|
32166
|
+
init_validation2();
|
|
30946
32167
|
var logger13 = createLogger({ service: "records-lambda" });
|
|
30947
32168
|
async function handleFindManyReference(resource, params, requestId) {
|
|
30948
32169
|
const { target, id, filter, sort: sortParam, pagination } = params;
|
|
@@ -30954,7 +32175,7 @@ async function handleFindManyReference(resource, params, requestId) {
|
|
|
30954
32175
|
});
|
|
30955
32176
|
const shadowConfig = getShadowConfig();
|
|
30956
32177
|
const sort = normalizeSort(shadowConfig, resource, sortParam);
|
|
30957
|
-
|
|
32178
|
+
validateSortField2(shadowConfig, resource, sort);
|
|
30958
32179
|
const { perPage, nextToken } = normalizePagination(pagination);
|
|
30959
32180
|
const dbClient2 = getDBClient();
|
|
30960
32181
|
const tableName = getTableName();
|
|
@@ -31057,6 +32278,9 @@ __name(handleFindManyReference, "handleFindManyReference");
|
|
|
31057
32278
|
|
|
31058
32279
|
// src/server/operations/findOne.ts
|
|
31059
32280
|
var import_lib_dynamodb9 = __toESM(require_dist_cjs66(), 1);
|
|
32281
|
+
init_shared();
|
|
32282
|
+
init_shadow();
|
|
32283
|
+
init_dynamodb3();
|
|
31060
32284
|
var logger14 = createLogger({ service: "records-lambda" });
|
|
31061
32285
|
async function handleFindOne(resource, params, requestId) {
|
|
31062
32286
|
const { id } = params;
|
|
@@ -31096,8 +32320,13 @@ __name(handleFindOne, "handleFindOne");
|
|
|
31096
32320
|
|
|
31097
32321
|
// src/server/operations/insertMany.ts
|
|
31098
32322
|
var import_lib_dynamodb10 = __toESM(require_dist_cjs66(), 1);
|
|
32323
|
+
init_shared();
|
|
32324
|
+
init_shadow();
|
|
32325
|
+
init_shadow();
|
|
32326
|
+
init_dynamodb3();
|
|
31099
32327
|
|
|
31100
32328
|
// src/server/utils/timestamps.ts
|
|
32329
|
+
init_index2();
|
|
31101
32330
|
function getTimestampFields() {
|
|
31102
32331
|
const shadowConfig = getShadowConfig();
|
|
31103
32332
|
return {
|
|
@@ -31133,6 +32362,7 @@ function addUpdateTimestamp(data2) {
|
|
|
31133
32362
|
__name(addUpdateTimestamp, "addUpdateTimestamp");
|
|
31134
32363
|
|
|
31135
32364
|
// src/server/utils/ttl.ts
|
|
32365
|
+
init_index2();
|
|
31136
32366
|
var logger15 = createLogger({ service: "records-lambda" });
|
|
31137
32367
|
function calculateTTL(resource, createdAt) {
|
|
31138
32368
|
const envKey = `${resource.toUpperCase()}_TTL_DAYS`;
|
|
@@ -31383,6 +32613,10 @@ __name(getPreparationErrorCode, "getPreparationErrorCode");
|
|
|
31383
32613
|
|
|
31384
32614
|
// src/server/operations/insertOne.ts
|
|
31385
32615
|
var import_lib_dynamodb11 = __toESM(require_dist_cjs66(), 1);
|
|
32616
|
+
init_shared();
|
|
32617
|
+
init_shadow();
|
|
32618
|
+
init_shadow();
|
|
32619
|
+
init_dynamodb3();
|
|
31386
32620
|
var logger17 = createLogger({ service: "records-lambda" });
|
|
31387
32621
|
async function handleInsertOne(resource, params, requestId) {
|
|
31388
32622
|
logger17.debug("Executing insertOne", {
|
|
@@ -31436,6 +32670,10 @@ __name(handleInsertOne, "handleInsertOne");
|
|
|
31436
32670
|
|
|
31437
32671
|
// src/server/operations/updateMany.ts
|
|
31438
32672
|
var import_lib_dynamodb12 = __toESM(require_dist_cjs66(), 1);
|
|
32673
|
+
init_shared();
|
|
32674
|
+
init_shadow();
|
|
32675
|
+
init_shadow();
|
|
32676
|
+
init_dynamodb3();
|
|
31439
32677
|
var logger18 = createLogger({ service: "records-lambda" });
|
|
31440
32678
|
function applyJsonMergePatch(target, patch) {
|
|
31441
32679
|
const result = { ...target };
|
|
@@ -31455,13 +32693,31 @@ function applyJsonMergePatch(target, patch) {
|
|
|
31455
32693
|
}
|
|
31456
32694
|
__name(applyJsonMergePatch, "applyJsonMergePatch");
|
|
31457
32695
|
async function handleUpdateMany(resource, params, requestId) {
|
|
31458
|
-
const {
|
|
32696
|
+
const { data: patchData } = params;
|
|
31459
32697
|
const startTime = Date.now();
|
|
31460
|
-
|
|
31461
|
-
|
|
31462
|
-
|
|
31463
|
-
|
|
31464
|
-
|
|
32698
|
+
let ids;
|
|
32699
|
+
if ("ids" in params) {
|
|
32700
|
+
ids = params.ids;
|
|
32701
|
+
logger18.debug("Executing updateMany with ids", {
|
|
32702
|
+
requestId,
|
|
32703
|
+
resource,
|
|
32704
|
+
count: ids.length
|
|
32705
|
+
});
|
|
32706
|
+
} else {
|
|
32707
|
+
logger18.debug("Executing updateMany with filter", {
|
|
32708
|
+
requestId,
|
|
32709
|
+
resource,
|
|
32710
|
+
filter: params.filter
|
|
32711
|
+
});
|
|
32712
|
+
const { handleFind: handleFind2 } = await Promise.resolve().then(() => (init_find(), find_exports));
|
|
32713
|
+
const findResult = await handleFind2(resource, { filter: params.filter }, requestId);
|
|
32714
|
+
ids = findResult.items.map((item) => item.id);
|
|
32715
|
+
logger18.debug("Found records with filter", {
|
|
32716
|
+
requestId,
|
|
32717
|
+
resource,
|
|
32718
|
+
count: ids.length
|
|
32719
|
+
});
|
|
32720
|
+
}
|
|
31465
32721
|
if (ids.length === 0) {
|
|
31466
32722
|
return {
|
|
31467
32723
|
count: 0,
|
|
@@ -31713,6 +32969,10 @@ __name(getPreparationErrorCode2, "getPreparationErrorCode");
|
|
|
31713
32969
|
|
|
31714
32970
|
// src/server/operations/updateOne.ts
|
|
31715
32971
|
var import_lib_dynamodb13 = __toESM(require_dist_cjs66(), 1);
|
|
32972
|
+
init_shared();
|
|
32973
|
+
init_shadow();
|
|
32974
|
+
init_shadow();
|
|
32975
|
+
init_dynamodb3();
|
|
31716
32976
|
var logger19 = createLogger({ service: "records-lambda" });
|
|
31717
32977
|
function applyJsonMergePatch2(target, patch) {
|
|
31718
32978
|
const result = { ...target };
|
|
@@ -31732,37 +32992,86 @@ function applyJsonMergePatch2(target, patch) {
|
|
|
31732
32992
|
}
|
|
31733
32993
|
__name(applyJsonMergePatch2, "applyJsonMergePatch");
|
|
31734
32994
|
async function handleUpdateOne(resource, params, requestId) {
|
|
31735
|
-
const {
|
|
32995
|
+
const { data: patchData, options } = params;
|
|
31736
32996
|
const upsert = options?.upsert ?? false;
|
|
31737
|
-
|
|
31738
|
-
|
|
31739
|
-
|
|
31740
|
-
id
|
|
31741
|
-
|
|
31742
|
-
|
|
31743
|
-
|
|
31744
|
-
|
|
31745
|
-
|
|
31746
|
-
|
|
31747
|
-
|
|
31748
|
-
|
|
31749
|
-
|
|
31750
|
-
|
|
31751
|
-
|
|
31752
|
-
|
|
31753
|
-
|
|
31754
|
-
|
|
31755
|
-
|
|
31756
|
-
|
|
31757
|
-
|
|
31758
|
-
|
|
31759
|
-
|
|
32997
|
+
let targetId;
|
|
32998
|
+
let existingItem;
|
|
32999
|
+
if ("id" in params) {
|
|
33000
|
+
targetId = params.id;
|
|
33001
|
+
logger19.debug("Executing updateOne with id", {
|
|
33002
|
+
requestId,
|
|
33003
|
+
resource,
|
|
33004
|
+
id: targetId,
|
|
33005
|
+
upsert
|
|
33006
|
+
});
|
|
33007
|
+
const dbClient2 = getDBClient();
|
|
33008
|
+
const tableName = getTableName();
|
|
33009
|
+
const mainSK = generateMainRecordSK2(targetId);
|
|
33010
|
+
const getResult = await executeDynamoDBOperation(
|
|
33011
|
+
() => dbClient2.send(
|
|
33012
|
+
new import_lib_dynamodb13.GetCommand({
|
|
33013
|
+
TableName: tableName,
|
|
33014
|
+
Key: {
|
|
33015
|
+
PK: resource,
|
|
33016
|
+
SK: mainSK
|
|
33017
|
+
},
|
|
33018
|
+
ConsistentRead: true
|
|
33019
|
+
})
|
|
33020
|
+
),
|
|
33021
|
+
"GetItem"
|
|
33022
|
+
);
|
|
33023
|
+
existingItem = getResult.Item;
|
|
33024
|
+
} else {
|
|
33025
|
+
logger19.debug("Executing updateOne with filter", {
|
|
33026
|
+
requestId,
|
|
33027
|
+
resource,
|
|
33028
|
+
filter: params.filter,
|
|
33029
|
+
upsert
|
|
33030
|
+
});
|
|
33031
|
+
const { handleFind: handleFind2 } = await Promise.resolve().then(() => (init_find(), find_exports));
|
|
33032
|
+
const findResult = await handleFind2(
|
|
33033
|
+
resource,
|
|
33034
|
+
{ filter: params.filter, pagination: { perPage: 1 } },
|
|
33035
|
+
requestId
|
|
33036
|
+
);
|
|
33037
|
+
if (findResult.items.length > 0) {
|
|
33038
|
+
const foundRecord = findResult.items[0];
|
|
33039
|
+
targetId = foundRecord.id;
|
|
33040
|
+
const dbClient2 = getDBClient();
|
|
33041
|
+
const tableName = getTableName();
|
|
33042
|
+
const mainSK = generateMainRecordSK2(targetId);
|
|
33043
|
+
const getResult = await executeDynamoDBOperation(
|
|
33044
|
+
() => dbClient2.send(
|
|
33045
|
+
new import_lib_dynamodb13.GetCommand({
|
|
33046
|
+
TableName: tableName,
|
|
33047
|
+
Key: {
|
|
33048
|
+
PK: resource,
|
|
33049
|
+
SK: mainSK
|
|
33050
|
+
},
|
|
33051
|
+
ConsistentRead: true
|
|
33052
|
+
})
|
|
33053
|
+
),
|
|
33054
|
+
"GetItem"
|
|
33055
|
+
);
|
|
33056
|
+
existingItem = getResult.Item;
|
|
33057
|
+
} else {
|
|
33058
|
+
if (!upsert) {
|
|
33059
|
+
throw new ItemNotFoundError(`Record not found with filter`, {
|
|
33060
|
+
resource,
|
|
33061
|
+
filter: params.filter
|
|
33062
|
+
});
|
|
33063
|
+
}
|
|
33064
|
+
const { ulid: ulid3 } = await Promise.resolve().then(() => (init_shared(), shared_exports));
|
|
33065
|
+
targetId = ulid3();
|
|
33066
|
+
}
|
|
33067
|
+
}
|
|
33068
|
+
if (!existingItem) {
|
|
31760
33069
|
if (!upsert) {
|
|
31761
|
-
throw new ItemNotFoundError(`Record not found: ${
|
|
33070
|
+
throw new ItemNotFoundError(`Record not found: ${targetId}`, { resource, id: targetId });
|
|
31762
33071
|
}
|
|
31763
|
-
return await handleUpsertCreate(resource,
|
|
33072
|
+
return await handleUpsertCreate(resource, targetId, patchData, requestId);
|
|
31764
33073
|
}
|
|
31765
|
-
return await handleUpsertUpdate(resource,
|
|
33074
|
+
return await handleUpsertUpdate(resource, targetId, existingItem, patchData, requestId);
|
|
31766
33075
|
}
|
|
31767
33076
|
__name(handleUpdateOne, "handleUpdateOne");
|
|
31768
33077
|
async function handleUpsertCreate(resource, id, data2, requestId) {
|
|
@@ -32041,6 +33350,9 @@ async function executeOperation(request2, requestId) {
|
|
|
32041
33350
|
}
|
|
32042
33351
|
__name(executeOperation, "executeOperation");
|
|
32043
33352
|
|
|
33353
|
+
// src/server/utils/authHandler.ts
|
|
33354
|
+
init_shared();
|
|
33355
|
+
|
|
32044
33356
|
// node_modules/aws-jwt-verify/dist/esm/error.js
|
|
32045
33357
|
var JwtBaseError = class extends Error {
|
|
32046
33358
|
static {
|
|
@@ -33206,6 +34518,7 @@ var CognitoJwtVerifier = class _CognitoJwtVerifier extends JwtVerifierBase {
|
|
|
33206
34518
|
CognitoJwtVerifier.USER_POOL_ID_REGEX = /^(?<region>[a-z]{2}-(gov-)?[a-z]+-\d)_[a-zA-Z0-9]+$/;
|
|
33207
34519
|
|
|
33208
34520
|
// src/server/utils/auth.ts
|
|
34521
|
+
init_index2();
|
|
33209
34522
|
var logger21 = createLogger({ service: "records-lambda" });
|
|
33210
34523
|
var verifierInstance = null;
|
|
33211
34524
|
function getVerifier(userPoolId, clientId) {
|
|
@@ -33322,7 +34635,14 @@ async function handleCognitoAuthentication(authHeader, requestId) {
|
|
|
33322
34635
|
}
|
|
33323
34636
|
__name(handleCognitoAuthentication, "handleCognitoAuthentication");
|
|
33324
34637
|
|
|
34638
|
+
// src/server/utils/errorHandler.ts
|
|
34639
|
+
init_shared();
|
|
34640
|
+
init_http();
|
|
34641
|
+
init_validation3();
|
|
34642
|
+
|
|
33325
34643
|
// src/server/utils/responseBuilder.ts
|
|
34644
|
+
init_shared();
|
|
34645
|
+
init_http();
|
|
33326
34646
|
var logger23 = createLogger({
|
|
33327
34647
|
service: "response-builder",
|
|
33328
34648
|
level: process.env.LOG_LEVEL || "info"
|
|
@@ -33422,6 +34742,7 @@ function isValidationError(message) {
|
|
|
33422
34742
|
__name(isValidationError, "isValidationError");
|
|
33423
34743
|
|
|
33424
34744
|
// src/server/utils/requestParser.ts
|
|
34745
|
+
init_validation3();
|
|
33425
34746
|
function parseRequestBody(body) {
|
|
33426
34747
|
if (!body) {
|
|
33427
34748
|
throw new Error(VALIDATION_ERROR_MESSAGES.REQUEST_BODY_REQUIRED);
|
|
@@ -33470,7 +34791,7 @@ async function handler(event) {
|
|
|
33470
34791
|
return createCorsResponse(HTTP_STATUS.OK);
|
|
33471
34792
|
}
|
|
33472
34793
|
if (event.requestContext.http.method === "GET" && event.requestContext.http.path === "/version") {
|
|
33473
|
-
const version = "1.3.
|
|
34794
|
+
const version = "1.3.31";
|
|
33474
34795
|
return createSuccessResponse({ version, timestamp: (/* @__PURE__ */ new Date()).toISOString() }, requestId);
|
|
33475
34796
|
}
|
|
33476
34797
|
if (event.requestContext.http.method !== "POST") {
|