@openhi/constructs 0.0.111 → 0.0.113
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/lib/chunk-23PUSHBV.mjs +24 -0
- package/lib/chunk-23PUSHBV.mjs.map +1 -0
- package/lib/{chunk-7FUAMZOF.mjs → chunk-53OHXLIL.mjs} +3 -3
- package/lib/chunk-6NBGYGFL.mjs +1803 -0
- package/lib/chunk-6NBGYGFL.mjs.map +1 -0
- package/lib/chunk-7RZHFI77.mjs +22 -0
- package/lib/chunk-7RZHFI77.mjs.map +1 -0
- package/lib/{chunk-7Q2IJ2J5.mjs → chunk-CUUKXDB2.mjs} +6 -6
- package/lib/chunk-FYHBHHWK.mjs +47 -0
- package/lib/chunk-FYHBHHWK.mjs.map +1 -0
- package/lib/{chunk-MULKGFIJ.mjs → chunk-GBDIGTNV.mjs} +165 -10
- package/lib/chunk-GBDIGTNV.mjs.map +1 -0
- package/lib/chunk-HQ67J7BP.mjs +199 -0
- package/lib/chunk-HQ67J7BP.mjs.map +1 -0
- package/lib/{chunk-AJ3G3THO.mjs → chunk-KO64HPWQ.mjs} +2 -2
- package/lib/{chunk-BB5MK4L3.mjs → chunk-KSFC72TT.mjs} +3 -3
- package/lib/{chunk-2TPJ6HOF.mjs → chunk-NZRW7ROK.mjs} +72 -54
- package/lib/chunk-NZRW7ROK.mjs.map +1 -0
- package/lib/chunk-QJDHVMKT.mjs +117 -0
- package/lib/chunk-QJDHVMKT.mjs.map +1 -0
- package/lib/{chunk-IS4VQRI4.mjs → chunk-QMBJ4VHC.mjs} +12 -47
- package/lib/chunk-QMBJ4VHC.mjs.map +1 -0
- package/lib/chunk-TRY7JGWO.mjs +16 -0
- package/lib/chunk-TRY7JGWO.mjs.map +1 -0
- package/lib/chunk-W4KR4CSL.mjs +236 -0
- package/lib/chunk-W4KR4CSL.mjs.map +1 -0
- package/lib/{chunk-AGF3RAAZ.mjs → chunk-WPCBVDFZ.mjs} +2 -2
- package/lib/chunk-WQWFVEVX.mjs +66 -0
- package/lib/chunk-WQWFVEVX.mjs.map +1 -0
- package/lib/{chunk-SYBADQXI.mjs → chunk-ZM4GDHHC.mjs} +77 -2
- package/lib/chunk-ZM4GDHHC.mjs.map +1 -0
- package/lib/delete-chunk.handler.d.mts +29 -0
- package/lib/delete-chunk.handler.d.ts +29 -0
- package/lib/delete-chunk.handler.js +2716 -0
- package/lib/delete-chunk.handler.js.map +1 -0
- package/lib/delete-chunk.handler.mjs +47 -0
- package/lib/delete-chunk.handler.mjs.map +1 -0
- package/lib/events-CjS-sm0W.d.mts +107 -0
- package/lib/events-CjS-sm0W.d.ts +107 -0
- package/lib/events-Da_cFgtc.d.mts +208 -0
- package/lib/events-Da_cFgtc.d.ts +208 -0
- package/lib/finalize.handler.d.mts +35 -0
- package/lib/finalize.handler.d.ts +35 -0
- package/lib/finalize.handler.js +875 -0
- package/lib/finalize.handler.js.map +1 -0
- package/lib/finalize.handler.mjs +166 -0
- package/lib/finalize.handler.mjs.map +1 -0
- package/lib/index.d.mts +189 -2
- package/lib/index.d.ts +500 -3
- package/lib/index.js +1753 -174
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +571 -17
- package/lib/index.mjs.map +1 -1
- package/lib/list-chunks.handler.d.mts +28 -0
- package/lib/list-chunks.handler.d.ts +28 -0
- package/lib/list-chunks.handler.js +2746 -0
- package/lib/list-chunks.handler.js.map +1 -0
- package/lib/list-chunks.handler.mjs +54 -0
- package/lib/list-chunks.handler.mjs.map +1 -0
- package/lib/platform-deploy-bridge.handler.js +76 -1
- package/lib/platform-deploy-bridge.handler.js.map +1 -1
- package/lib/platform-deploy-bridge.handler.mjs +1 -1
- package/lib/pre-token-generation.handler.js +1106 -155
- package/lib/pre-token-generation.handler.js.map +1 -1
- package/lib/pre-token-generation.handler.mjs +6 -4
- package/lib/pre-token-generation.handler.mjs.map +1 -1
- package/lib/provision-default-workspace.handler.js +1529 -142
- package/lib/provision-default-workspace.handler.js.map +1 -1
- package/lib/provision-default-workspace.handler.mjs +8 -4
- package/lib/provision-default-workspace.handler.mjs.map +1 -1
- package/lib/rename-finalize.handler.d.mts +30 -0
- package/lib/rename-finalize.handler.d.ts +30 -0
- package/lib/rename-finalize.handler.js +795 -0
- package/lib/rename-finalize.handler.js.map +1 -0
- package/lib/rename-finalize.handler.mjs +90 -0
- package/lib/rename-finalize.handler.mjs.map +1 -0
- package/lib/rename-list-targets.handler.d.mts +26 -0
- package/lib/rename-list-targets.handler.d.ts +26 -0
- package/lib/rename-list-targets.handler.js +2985 -0
- package/lib/rename-list-targets.handler.js.map +1 -0
- package/lib/rename-list-targets.handler.mjs +431 -0
- package/lib/rename-list-targets.handler.mjs.map +1 -0
- package/lib/rename-rewrite-chunk.handler.d.mts +35 -0
- package/lib/rename-rewrite-chunk.handler.d.ts +35 -0
- package/lib/rename-rewrite-chunk.handler.js +2021 -0
- package/lib/rename-rewrite-chunk.handler.js.map +1 -0
- package/lib/rename-rewrite-chunk.handler.mjs +27 -0
- package/lib/rename-rewrite-chunk.handler.mjs.map +1 -0
- package/lib/rest-api-lambda.handler.js +4021 -932
- package/lib/rest-api-lambda.handler.js.map +1 -1
- package/lib/rest-api-lambda.handler.mjs +1786 -80
- package/lib/rest-api-lambda.handler.mjs.map +1 -1
- package/lib/seed-demo-data.handler.js +1588 -124
- package/lib/seed-demo-data.handler.js.map +1 -1
- package/lib/seed-demo-data.handler.mjs +10 -6
- package/lib/seed-system-data.handler.js +1179 -155
- package/lib/seed-system-data.handler.js.map +1 -1
- package/lib/seed-system-data.handler.mjs +5 -4
- package/lib/seed-system-data.handler.mjs.map +1 -1
- package/package.json +2 -2
- package/lib/chunk-2TPJ6HOF.mjs.map +0 -1
- package/lib/chunk-IS4VQRI4.mjs.map +0 -1
- package/lib/chunk-MULKGFIJ.mjs.map +0 -1
- package/lib/chunk-QR5JVSCF.mjs +0 -862
- package/lib/chunk-QR5JVSCF.mjs.map +0 -1
- package/lib/chunk-SYBADQXI.mjs.map +0 -1
- /package/lib/{chunk-7FUAMZOF.mjs.map → chunk-53OHXLIL.mjs.map} +0 -0
- /package/lib/{chunk-7Q2IJ2J5.mjs.map → chunk-CUUKXDB2.mjs.map} +0 -0
- /package/lib/{chunk-AJ3G3THO.mjs.map → chunk-KO64HPWQ.mjs.map} +0 -0
- /package/lib/{chunk-BB5MK4L3.mjs.map → chunk-KSFC72TT.mjs.map} +0 -0
- /package/lib/{chunk-AGF3RAAZ.mjs.map → chunk-WPCBVDFZ.mjs.map} +0 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConflictError,
|
|
3
|
+
DomainError,
|
|
4
|
+
ValidationError
|
|
5
|
+
} from "./chunk-FYHBHHWK.mjs";
|
|
6
|
+
|
|
7
|
+
// src/data/operations/control/multi-write-operation.ts
|
|
8
|
+
var TRANSACT_WRITE_ITEM_LIMIT = 100;
|
|
9
|
+
async function executeMultiWrite(params) {
|
|
10
|
+
const { service, triples, token } = params;
|
|
11
|
+
if (triples.length === 0) {
|
|
12
|
+
throw new ValidationError(
|
|
13
|
+
"executeMultiWrite called with zero triples; at least one triple is required"
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
if (triples.length > TRANSACT_WRITE_ITEM_LIMIT) {
|
|
17
|
+
throw new ValidationError(
|
|
18
|
+
`executeMultiWrite received ${triples.length} triples; DynamoDB TransactWriteItems is limited to ${TRANSACT_WRITE_ITEM_LIMIT} items per call`,
|
|
19
|
+
{
|
|
20
|
+
details: {
|
|
21
|
+
itemsRequested: triples.length,
|
|
22
|
+
limit: TRANSACT_WRITE_ITEM_LIMIT
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
for (const [index, triple] of triples.entries()) {
|
|
28
|
+
if (!triple || typeof triple !== "object") {
|
|
29
|
+
throw new ValidationError(
|
|
30
|
+
`executeMultiWrite triple at index ${index} is not an object`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
if (typeof triple.entity !== "string" || triple.entity.length === 0) {
|
|
34
|
+
throw new ValidationError(
|
|
35
|
+
`executeMultiWrite triple at index ${index} is missing a non-empty 'entity' key`
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
if (!isSupportedAction(triple.action)) {
|
|
39
|
+
throw new ValidationError(
|
|
40
|
+
`executeMultiWrite triple at index ${index} has unsupported action '${String(
|
|
41
|
+
triple.action
|
|
42
|
+
)}'; supported: 'put' | 'create' | 'delete'`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
if (!triple.item || typeof triple.item !== "object") {
|
|
46
|
+
throw new ValidationError(
|
|
47
|
+
`executeMultiWrite triple at index ${index} is missing an 'item' payload`
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
let result;
|
|
52
|
+
try {
|
|
53
|
+
result = await service.transaction.write(
|
|
54
|
+
(entities) => triples.map((triple, index) => {
|
|
55
|
+
const transactEntity = entities[triple.entity];
|
|
56
|
+
if (transactEntity === void 0) {
|
|
57
|
+
throw new ValidationError(
|
|
58
|
+
`executeMultiWrite triple at index ${index} references unknown entity '${triple.entity}'; ensure the service exposes it`
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
switch (triple.action) {
|
|
62
|
+
case "put":
|
|
63
|
+
return transactEntity.put(triple.item).commit();
|
|
64
|
+
case "create":
|
|
65
|
+
return transactEntity.create(triple.item).commit();
|
|
66
|
+
case "delete":
|
|
67
|
+
return transactEntity.delete(triple.item).commit();
|
|
68
|
+
default:
|
|
69
|
+
throw new ValidationError(
|
|
70
|
+
`executeMultiWrite triple at index ${index} has unsupported action '${String(
|
|
71
|
+
triple.action
|
|
72
|
+
)}'`
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
).go(token === void 0 ? void 0 : { token });
|
|
77
|
+
} catch (err) {
|
|
78
|
+
if (err instanceof DomainError) {
|
|
79
|
+
throw err;
|
|
80
|
+
}
|
|
81
|
+
throw new ConflictError(buildCancellationMessage(err), {
|
|
82
|
+
cause: err,
|
|
83
|
+
details: extractCancellationReasons(err)
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
if (result.canceled) {
|
|
87
|
+
throw new ConflictError(
|
|
88
|
+
"TransactWriteItems was canceled by DynamoDB (check CancellationReasons on the cause for details)",
|
|
89
|
+
{ details: { canceled: true, data: result.data } }
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
return { itemsWritten: triples.length, canceled: false };
|
|
93
|
+
}
|
|
94
|
+
function isSupportedAction(value) {
|
|
95
|
+
return value === "put" || value === "create" || value === "delete";
|
|
96
|
+
}
|
|
97
|
+
function buildCancellationMessage(err) {
|
|
98
|
+
if (err instanceof Error && err.message) {
|
|
99
|
+
return `TransactWriteItems failed: ${err.message}`;
|
|
100
|
+
}
|
|
101
|
+
return "TransactWriteItems failed (no error message available)";
|
|
102
|
+
}
|
|
103
|
+
function extractCancellationReasons(err) {
|
|
104
|
+
if (err && typeof err === "object") {
|
|
105
|
+
const cancellationReasons = err.CancellationReasons;
|
|
106
|
+
if (cancellationReasons !== void 0) {
|
|
107
|
+
return { CancellationReasons: cancellationReasons };
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return void 0;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export {
|
|
114
|
+
TRANSACT_WRITE_ITEM_LIMIT,
|
|
115
|
+
executeMultiWrite
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=chunk-QJDHVMKT.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/data/operations/control/multi-write-operation.ts"],"sourcesContent":["/**\n * Operations-layer multi-write helper for the control plane.\n *\n * Per ADR-018 § Implementation Notes and the ADR-018 implementation\n * guide § 3, every cross-entity mutation in the control plane (canonical\n * record + adjacency-list projections) MUST flow through this helper.\n * Lambda handlers call operations; operations call this helper; nothing\n * under `data/operations/control/` may call `service.transaction.write`\n * directly after #1010 lands.\n *\n * The helper accepts an array of `{ entity, action, item }` triples,\n * maps each one to ElectroDB's transaction-write builder, and submits\n * the batch via `TransactWriteItems` — all-or-nothing atomicity. It\n * enforces the 100-item DynamoDB transaction ceiling at the helper\n * boundary and surfaces conditional-check / transaction-conflict\n * failures as typed domain errors so REST adapters can map to the\n * right HTTP status (409 / 400 / 500).\n *\n * Idempotency belongs to the caller — every call attempts a fresh\n * `TransactWriteItems`. Callers compose conditional expressions\n * (e.g. `vid` matches, `attribute_not_exists(PK)`) per triple via\n * ElectroDB's `where` builder; the helper does not invent conditions.\n *\n * Per ADR-018 Open Item Follow-up #2 the implementation uses ElectroDB's\n * `service.transaction.write` rather than a hand-rolled\n * `TransactWriteItemsCommand`. Reasons: (a) ElectroDB derives the\n * `TransactWriteItem` payload (Item attributes, GSI keys, watch-driven\n * fields) from the entity schema — hand-rolling would duplicate the\n * watch/derive logic and silently drift on schema changes; (b) it\n * preserves the existing single-write call-site idiom\n * (`service.entities.<x>.put({...}).go()` reads almost identically to\n * `entities.<x>.put({...}).commit()` inside the txn builder), keeping\n * the operations layer ergonomic; (c) ElectroDB's `canceled` flag and\n * `ElectroValidationError` propagation give us a single typed handle on\n * cancellation-vs-validation. We can drop to raw `TransactWriteItems`\n * later if a future operation needs DDB features ElectroDB has not yet\n * surfaced.\n *\n * @see ADR-018 § Implementation Notes\n * @see .state/adr-018-implementation-guide.md § 3 — Multi-Write Helper API Contract\n * @see .claude/rules/data-layer-layout.md\n */\n\nimport type { Entity, Service } from \"electrodb\";\nimport { ConflictError, DomainError, ValidationError } from \"../../errors\";\n\n/**\n * Maximum items allowed in a single DynamoDB `TransactWriteItems`\n * call (AWS, raised from 25 → 100 on 2024-09-23). The helper enforces\n * this ceiling at the boundary so callers do not silently lose the\n * tail of an oversized batch when DDB rejects the call.\n */\nexport const TRANSACT_WRITE_ITEM_LIMIT = 100 as const;\n\n/** Supported actions on a multi-write triple. */\nexport type MultiWriteAction = \"put\" | \"create\" | \"delete\";\n\n/**\n * A single entry in a multi-write call: which entity to act on, the\n * action, and the per-action payload.\n *\n * - `put` / `create` — `item` is the full record (matches\n * `entity.put(item)` / `entity.create(item)` shape).\n * - `delete` — `item` is the key composite (matches\n * `entity.delete(key)` shape).\n *\n * `entity` is a string key into the service's `entities` map (e.g.\n * `\"membership\"`, `\"tenant\"`). Using a string key avoids leaking the\n * transaction-bound entity reference across the helper boundary —\n * ElectroDB's `service.transaction.write(fn)` only honours entity\n * references that the closure-provided `entities` argument exposes.\n */\nexport interface MultiWriteTriple<EntityKey extends string = string> {\n readonly entity: EntityKey;\n readonly action: MultiWriteAction;\n readonly item: Record<string, unknown>;\n}\n\n/** A service object exposing the ElectroDB `transaction.write` builder. */\ntype ServiceLike = Pick<\n Service<Record<string, Entity<any, any, any, any>>>,\n \"transaction\"\n>;\n\n/** Parameters for {@link executeMultiWrite}. */\nexport interface ExecuteMultiWriteParams<EntityKey extends string = string> {\n /**\n * ElectroDB `Service` (control-plane or data-plane) exposing\n * `transaction.write` and the entity set the triples reference.\n * Inject via `getDynamoControlService(tableName)` /\n * `getDynamoDataService(tableName)` — matches the service-factory\n * pattern every other operation under `data/operations/` uses.\n */\n readonly service: ServiceLike;\n /**\n * The triples to commit atomically. Order is preserved on the wire\n * (ElectroDB submits them in the same order); duplicates are not\n * de-duplicated by the helper.\n */\n readonly triples: ReadonlyArray<MultiWriteTriple<EntityKey>>;\n /** Optional idempotency token forwarded to ElectroDB. */\n readonly token?: string;\n}\n\n/** Successful multi-write result. */\nexport interface ExecuteMultiWriteResult {\n /** Number of triples committed. */\n readonly itemsWritten: number;\n /**\n * `canceled` flag returned by ElectroDB. Always `false` on the\n * success path — failures throw {@link ConflictError} or\n * {@link ValidationError}. Surfaced for completeness so callers can\n * assert on it in tests if they wish.\n */\n readonly canceled: false;\n}\n\n/**\n * Submits `triples` as a single `TransactWriteItems` via ElectroDB's\n * `service.transaction.write` builder. All-or-nothing: every triple\n * lands or none does.\n *\n * Throws:\n * - {@link ValidationError} when `triples` is empty, exceeds the\n * {@link TRANSACT_WRITE_ITEM_LIMIT}, references an entity that the\n * service does not expose, or carries an unsupported `action`.\n * - {@link ConflictError} when DynamoDB cancels the transaction\n * (e.g. `ConditionalCheckFailed`, `TransactionConflict`,\n * `ProvisionedThroughputExceeded`). The original ElectroDB error\n * (carrying `CancellationReasons`) is attached as `cause`.\n * - The original {@link DomainError} on rethrow if the caller's own\n * validation hook surfaces one (e.g. nested ValidationError).\n *\n * Note on `update` / `patch` actions: not yet supported by the triple\n * shape because ElectroDB's transaction-write builder structures them\n * as `entity.update(key).set({...}).commit()` (key + delta), which\n * does not flatten cleanly into a single `item` payload. Add a\n * separate triple variant when the first consumer needs it; today\n * every ADR-018 multi-write is a `put` (canonical + projections) or a\n * `delete` (cascade rewriter). See ADR-018 § Open Item Follow-up #2.\n */\nexport async function executeMultiWrite<EntityKey extends string = string>(\n params: ExecuteMultiWriteParams<EntityKey>,\n): Promise<ExecuteMultiWriteResult> {\n const { service, triples, token } = params;\n\n if (triples.length === 0) {\n throw new ValidationError(\n \"executeMultiWrite called with zero triples; at least one triple is required\",\n );\n }\n if (triples.length > TRANSACT_WRITE_ITEM_LIMIT) {\n throw new ValidationError(\n `executeMultiWrite received ${triples.length} triples; DynamoDB TransactWriteItems is limited to ${TRANSACT_WRITE_ITEM_LIMIT} items per call`,\n {\n details: {\n itemsRequested: triples.length,\n limit: TRANSACT_WRITE_ITEM_LIMIT,\n },\n },\n );\n }\n\n for (const [index, triple] of triples.entries()) {\n if (!triple || typeof triple !== \"object\") {\n throw new ValidationError(\n `executeMultiWrite triple at index ${index} is not an object`,\n );\n }\n if (typeof triple.entity !== \"string\" || triple.entity.length === 0) {\n throw new ValidationError(\n `executeMultiWrite triple at index ${index} is missing a non-empty 'entity' key`,\n );\n }\n if (!isSupportedAction(triple.action)) {\n throw new ValidationError(\n `executeMultiWrite triple at index ${index} has unsupported action '${String(\n triple.action,\n )}'; supported: 'put' | 'create' | 'delete'`,\n );\n }\n if (!triple.item || typeof triple.item !== \"object\") {\n throw new ValidationError(\n `executeMultiWrite triple at index ${index} is missing an 'item' payload`,\n );\n }\n }\n\n let result: { canceled: boolean; data: unknown };\n try {\n result = await service.transaction\n .write((entities: Record<string, any>) =>\n triples.map((triple, index) => {\n const transactEntity = entities[triple.entity];\n if (transactEntity === undefined) {\n throw new ValidationError(\n `executeMultiWrite triple at index ${index} references unknown entity '${triple.entity}'; ensure the service exposes it`,\n );\n }\n switch (triple.action) {\n case \"put\":\n return transactEntity.put(triple.item).commit();\n case \"create\":\n return transactEntity.create(triple.item).commit();\n case \"delete\":\n return transactEntity.delete(triple.item).commit();\n default:\n // Exhaustiveness guard; pre-flight validates this already.\n throw new ValidationError(\n `executeMultiWrite triple at index ${index} has unsupported action '${String(\n (triple as MultiWriteTriple).action,\n )}'`,\n );\n }\n }),\n )\n .go(token === undefined ? undefined : { token });\n } catch (err) {\n // Pre-flight ValidationErrors thrown inside the builder bubble\n // through unchanged so callers see a 400, not a 409.\n if (err instanceof DomainError) {\n throw err;\n }\n throw new ConflictError(buildCancellationMessage(err), {\n cause: err,\n details: extractCancellationReasons(err),\n });\n }\n\n if (result.canceled) {\n throw new ConflictError(\n \"TransactWriteItems was canceled by DynamoDB (check CancellationReasons on the cause for details)\",\n { details: { canceled: true, data: result.data } },\n );\n }\n\n return { itemsWritten: triples.length, canceled: false };\n}\n\nfunction isSupportedAction(value: unknown): value is MultiWriteAction {\n return value === \"put\" || value === \"create\" || value === \"delete\";\n}\n\nfunction buildCancellationMessage(err: unknown): string {\n if (err instanceof Error && err.message) {\n return `TransactWriteItems failed: ${err.message}`;\n }\n return \"TransactWriteItems failed (no error message available)\";\n}\n\nfunction extractCancellationReasons(err: unknown): unknown {\n if (err && typeof err === \"object\") {\n const cancellationReasons = (err as { CancellationReasons?: unknown })\n .CancellationReasons;\n if (cancellationReasons !== undefined) {\n return { CancellationReasons: cancellationReasons };\n }\n }\n return undefined;\n}\n"],"mappings":";;;;;;;AA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1,47 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NotFoundError
|
|
3
|
+
} from "./chunk-FYHBHHWK.mjs";
|
|
1
4
|
import {
|
|
2
5
|
SHARD_COUNT,
|
|
3
|
-
computeShard
|
|
6
|
+
computeShard
|
|
7
|
+
} from "./chunk-6NBGYGFL.mjs";
|
|
8
|
+
import {
|
|
4
9
|
defaultTableName,
|
|
5
10
|
dynamoClient
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
|
|
8
|
-
// src/data/errors/domain-errors.ts
|
|
9
|
-
var DomainError = class extends Error {
|
|
10
|
-
constructor(message, code, options) {
|
|
11
|
-
super(message, options);
|
|
12
|
-
this.name = this.constructor.name;
|
|
13
|
-
this.code = code;
|
|
14
|
-
this.details = options?.details;
|
|
15
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
var NotFoundError = class extends DomainError {
|
|
19
|
-
constructor(message, options) {
|
|
20
|
-
super(message, "NOT_FOUND", options);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
var ValidationError = class extends DomainError {
|
|
24
|
-
constructor(message, options) {
|
|
25
|
-
super(message, "VALIDATION", options);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
var ConflictError = class extends DomainError {
|
|
29
|
-
constructor(message, options) {
|
|
30
|
-
super(message, "CONFLICT", options);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
var ForbiddenError = class extends DomainError {
|
|
34
|
-
constructor(message, options) {
|
|
35
|
-
super(message, "FORBIDDEN", options);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
function domainErrorToHttpStatus(err) {
|
|
39
|
-
if (err instanceof NotFoundError) return 404;
|
|
40
|
-
if (err instanceof ValidationError) return 400;
|
|
41
|
-
if (err instanceof ConflictError) return 409;
|
|
42
|
-
if (err instanceof ForbiddenError) return 403;
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
11
|
+
} from "./chunk-TRY7JGWO.mjs";
|
|
45
12
|
|
|
46
13
|
// src/data/dynamo/dynamo-data-service.ts
|
|
47
14
|
import { Service } from "electrodb";
|
|
@@ -1062,7 +1029,8 @@ var dataPlaneService = new Service(dataPlaneEntities, {
|
|
|
1062
1029
|
client: dynamoClient
|
|
1063
1030
|
});
|
|
1064
1031
|
var DynamoDataService = {
|
|
1065
|
-
entities: dataPlaneService.entities
|
|
1032
|
+
entities: dataPlaneService.entities,
|
|
1033
|
+
transaction: dataPlaneService.transaction
|
|
1066
1034
|
};
|
|
1067
1035
|
function getDynamoDataService(tableName) {
|
|
1068
1036
|
const resolved = tableName ?? defaultTableName;
|
|
@@ -1071,7 +1039,8 @@ function getDynamoDataService(tableName) {
|
|
|
1071
1039
|
client: dynamoClient
|
|
1072
1040
|
});
|
|
1073
1041
|
return {
|
|
1074
|
-
entities: service.entities
|
|
1042
|
+
entities: service.entities,
|
|
1043
|
+
transaction: service.transaction
|
|
1075
1044
|
};
|
|
1076
1045
|
}
|
|
1077
1046
|
|
|
@@ -1369,10 +1338,6 @@ async function updateDataEntityById(entity, tenantId, workspaceId, id, resourceL
|
|
|
1369
1338
|
}
|
|
1370
1339
|
|
|
1371
1340
|
export {
|
|
1372
|
-
NotFoundError,
|
|
1373
|
-
ValidationError,
|
|
1374
|
-
ForbiddenError,
|
|
1375
|
-
domainErrorToHttpStatus,
|
|
1376
1341
|
getDynamoDataService,
|
|
1377
1342
|
compressResource,
|
|
1378
1343
|
decompressResource,
|
|
@@ -1387,4 +1352,4 @@ export {
|
|
|
1387
1352
|
buildUpdatedResourceWithAudit,
|
|
1388
1353
|
updateDataEntityById
|
|
1389
1354
|
};
|
|
1390
|
-
//# sourceMappingURL=chunk-
|
|
1355
|
+
//# sourceMappingURL=chunk-QMBJ4VHC.mjs.map
|