@prismatic-io/components-aws-dynamodb 0.0.0-stage → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1289 @@
1
+ let _prismatic_io_spectral = require("@prismatic-io/spectral");
2
+ let _aws_sdk_client_sts = require("@aws-sdk/client-sts");
3
+ let _aws_sdk_client_dynamodb = require("@aws-sdk/client-dynamodb");
4
+ let _aws_sdk_lib_dynamodb = require("@aws-sdk/lib-dynamodb");
5
+ //#region ../../packages/aws-utils/dist/connection/assumeRole.js
6
+ var __awaiter$3 = function(thisArg, _arguments, P, generator) {
7
+ function adopt(value) {
8
+ return value instanceof P ? value : new P(function(resolve) {
9
+ resolve(value);
10
+ });
11
+ }
12
+ return new (P || (P = Promise))(function(resolve, reject) {
13
+ function fulfilled(value) {
14
+ try {
15
+ step(generator.next(value));
16
+ } catch (e) {
17
+ reject(e);
18
+ }
19
+ }
20
+ function rejected(value) {
21
+ try {
22
+ step(generator["throw"](value));
23
+ } catch (e) {
24
+ reject(e);
25
+ }
26
+ }
27
+ function step(result) {
28
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
29
+ }
30
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
31
+ });
32
+ };
33
+ const assumeRole = (region, accessKeyId, secretAccessKey, roleArn, externalId) => __awaiter$3(void 0, void 0, void 0, function* () {
34
+ const { Credentials: { AccessKeyId, SecretAccessKey, SessionToken } } = yield new _aws_sdk_client_sts.STSClient(Object.assign(Object.assign({}, region.length > 0 && { region }), { credentials: {
35
+ accessKeyId,
36
+ secretAccessKey
37
+ } })).send(new _aws_sdk_client_sts.AssumeRoleCommand({
38
+ RoleArn: _prismatic_io_spectral.util.types.toString(roleArn),
39
+ RoleSessionName: "integration-session",
40
+ ExternalId: externalId
41
+ }));
42
+ return {
43
+ accessKeyId: AccessKeyId,
44
+ secretAccessKey: SecretAccessKey,
45
+ sessionToken: SessionToken
46
+ };
47
+ });
48
+ //#endregion
49
+ //#region ../../packages/aws-utils/dist/connection/assumeRoleConnection.js
50
+ const assumeRoleConnection = {
51
+ key: "awsAssumeRole",
52
+ display: {
53
+ label: "AWS Role ARN",
54
+ description: "Connect to AWS using an assumed role"
55
+ },
56
+ inputs: {
57
+ roleARN: {
58
+ label: "Role ARN",
59
+ placeholder: "arn:aws:iam::OtherAccount-ID:role/assumed-role-name",
60
+ type: "string",
61
+ required: true,
62
+ shown: true,
63
+ comments: "An AWS IAM Role ARN",
64
+ example: "arn:aws:iam::OtherAccount-ID:role/assumed-role-name"
65
+ },
66
+ accessKeyId: {
67
+ label: "Access Key ID",
68
+ placeholder: "Access Key ID",
69
+ type: "string",
70
+ required: true,
71
+ shown: true,
72
+ comments: "An AWS IAM Access Key ID",
73
+ example: "AKIAIOSFODNN7EXAMPLE"
74
+ },
75
+ secretAccessKey: {
76
+ label: "Secret Access Key",
77
+ placeholder: "Secret Access Key",
78
+ type: "password",
79
+ required: true,
80
+ shown: true,
81
+ comments: "An AWS IAM Secret Access Key",
82
+ example: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
83
+ },
84
+ externalId: {
85
+ label: "External ID",
86
+ placeholder: "shared-common-secret",
87
+ type: "string",
88
+ required: false,
89
+ shown: true,
90
+ comments: "Provides enhanced security measures to the connection. Optional, but recommended. Please check [AWS docs](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_common-scenarios_third-party.html#id_roles_third-party_external-id) for more information.",
91
+ example: "shared-common-secret"
92
+ }
93
+ }
94
+ };
95
+ //#endregion
96
+ //#region ../../packages/aws-utils/dist/helpers/misc.js
97
+ const toTrimmedString = (value) => _prismatic_io_spectral.util.types.toString(value).trim();
98
+ const toOptionalString = (value) => value ? _prismatic_io_spectral.util.types.toString(value) : void 0;
99
+ //#endregion
100
+ //#region ../../packages/aws-utils/dist/data/awsRegions.js
101
+ const awsRegions = [
102
+ "af-south-1",
103
+ "ap-east-1",
104
+ "ap-east-2",
105
+ "ap-northeast-1",
106
+ "ap-northeast-2",
107
+ "ap-northeast-3",
108
+ "ap-south-1",
109
+ "ap-south-2",
110
+ "ap-southeast-1",
111
+ "ap-southeast-2",
112
+ "ap-southeast-3",
113
+ "ap-southeast-4",
114
+ "ap-southeast-5",
115
+ "ap-southeast-6",
116
+ "ap-southeast-7",
117
+ "ca-central-1",
118
+ "ca-west-1",
119
+ "eu-central-1",
120
+ "eu-central-2",
121
+ "eu-north-1",
122
+ "eu-south-1",
123
+ "eu-south-2",
124
+ "eu-west-1",
125
+ "eu-west-2",
126
+ "eu-west-3",
127
+ "il-central-1",
128
+ "me-central-1",
129
+ "me-south-1",
130
+ "mx-central-1",
131
+ "sa-east-1",
132
+ "us-east-1",
133
+ "us-east-2",
134
+ "us-gov-east-1",
135
+ "us-gov-west-1",
136
+ "us-west-1",
137
+ "us-west-2"
138
+ ];
139
+ //#endregion
140
+ //#region ../../packages/aws-utils/dist/dataSources/selectRegion.js
141
+ var __awaiter$1 = function(thisArg, _arguments, P, generator) {
142
+ function adopt(value) {
143
+ return value instanceof P ? value : new P(function(resolve) {
144
+ resolve(value);
145
+ });
146
+ }
147
+ return new (P || (P = Promise))(function(resolve, reject) {
148
+ function fulfilled(value) {
149
+ try {
150
+ step(generator.next(value));
151
+ } catch (e) {
152
+ reject(e);
153
+ }
154
+ }
155
+ function rejected(value) {
156
+ try {
157
+ step(generator["throw"](value));
158
+ } catch (e) {
159
+ reject(e);
160
+ }
161
+ }
162
+ function step(result) {
163
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
164
+ }
165
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
166
+ });
167
+ };
168
+ const selectRegion = (0, _prismatic_io_spectral.dataSource)({
169
+ display: {
170
+ label: "Select AWS Region",
171
+ description: "Select an AWS region"
172
+ },
173
+ dataSourceType: "picklist",
174
+ perform: () => __awaiter$1(void 0, void 0, void 0, function* () {
175
+ return Promise.resolve({ result: awsRegions.map((region) => ({
176
+ label: region,
177
+ key: region
178
+ })) });
179
+ }),
180
+ inputs: {}
181
+ });
182
+ //#endregion
183
+ //#region ../../packages/aws-utils/dist/inputs/awsRegion.js
184
+ const awsRegion = (0, _prismatic_io_spectral.input)({
185
+ label: "AWS Region",
186
+ placeholder: "AWS Region",
187
+ type: "string",
188
+ required: false,
189
+ comments: "AWS provides services in multiple regions, like us-west-2 or eu-west-1.",
190
+ example: "us-east-1",
191
+ dataSource: "selectRegion",
192
+ clean: _prismatic_io_spectral.util.types.toString
193
+ });
194
+ (0, _prismatic_io_spectral.input)({
195
+ label: "Connection",
196
+ type: "connection",
197
+ required: false
198
+ });
199
+ (0, _prismatic_io_spectral.input)({
200
+ label: "Dynamic Access Key ID",
201
+ type: "string",
202
+ required: false,
203
+ clean: _prismatic_io_spectral.util.types.toString,
204
+ comments: "Use this input to authenticate with AWS if you are using a dynamically-generated access key. Otherwise, use the connection to enter a static access key ID."
205
+ });
206
+ (0, _prismatic_io_spectral.input)({
207
+ label: "Dynamic Secret Access Key",
208
+ type: "password",
209
+ required: false,
210
+ clean: _prismatic_io_spectral.util.types.toString,
211
+ comments: "Use this input to authenticate with AWS if you are using a dynamically-generated secret access key. Otherwise, use the connection to enter a static secret access key."
212
+ });
213
+ (0, _prismatic_io_spectral.input)({
214
+ label: "Dynamic Session Token",
215
+ type: "password",
216
+ required: false,
217
+ clean: (value) => _prismatic_io_spectral.util.types.toString(value) || void 0,
218
+ comments: "Use this input to authenticate with AWS if you are using a OPTIONAL dynamically-generated session token."
219
+ });
220
+ //#endregion
221
+ //#region src/connections.ts
222
+ const accessKeySecretPair = (0, _prismatic_io_spectral.connection)({
223
+ key: "apiKeySecret",
224
+ display: {
225
+ description: "Authenticates requests to Amazon DynamoDB using an API Key and API Secret.",
226
+ label: "Access Key and Secret"
227
+ },
228
+ inputs: {
229
+ accessKeyId: {
230
+ label: "Access Key ID",
231
+ placeholder: "Enter Access Key ID",
232
+ type: "string",
233
+ required: true,
234
+ shown: true,
235
+ comments: "An AWS IAM Access Key ID. Learn how to create access keys in the [AWS IAM documentation](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html).",
236
+ example: "AKIAIOSFODNN7EXAMPLE"
237
+ },
238
+ secretAccessKey: {
239
+ label: "Secret Access Key",
240
+ placeholder: "Enter Secret Access Key",
241
+ type: "password",
242
+ required: true,
243
+ shown: true,
244
+ comments: "An AWS IAM Secret Access Key. Learn how to create access keys in the [AWS IAM documentation](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html).",
245
+ example: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
246
+ }
247
+ }
248
+ });
249
+ var connections_default = [accessKeySecretPair, assumeRoleConnection];
250
+ //#endregion
251
+ //#region src/util.ts
252
+ const toSet = (input) => input instanceof Array ? input : [];
253
+ const S = (input) => _prismatic_io_spectral.util.types.toString(input);
254
+ const B = (input) => Buffer.from(_prismatic_io_spectral.util.types.toString(input));
255
+ const coerceValue = (key, value, type) => {
256
+ switch (type) {
257
+ case "S": return { S: S(value) };
258
+ case "N": return { N: S(value) };
259
+ case "BOOL": return { BOOL: _prismatic_io_spectral.util.types.toBool(value) };
260
+ case "B": return { B: B(value) };
261
+ case "SS": return { SS: toSet(value).map(S) };
262
+ case "NS": return { NS: toSet(value).map(S) };
263
+ case "BS": return { BS: toSet(value).map(B) };
264
+ case "L": return { L: value };
265
+ case "M": return { M: value };
266
+ default: throw new Error(`You must specify a value type for key "${key}"`);
267
+ }
268
+ };
269
+ const convertDataType = (items, itemTypes) => {
270
+ if (items.length !== itemTypes.length) throw new Error("The number of items and item types must be the same. Check your inputs.");
271
+ if (items.length === 0) return;
272
+ const itemTypesMap = _prismatic_io_spectral.util.types.keyValPairListToObject(itemTypes);
273
+ const itemsResult = {};
274
+ for (const item of items) itemsResult[item.key] = coerceValue(item.key, item.value, _prismatic_io_spectral.util.types.toString(itemTypesMap[item.key]));
275
+ return itemsResult;
276
+ };
277
+ const getItemKeySearch = async ({ client, tableName, hashKeyValue, rangeKeyValue }) => {
278
+ const keys = {};
279
+ const describeCommand = new _aws_sdk_client_dynamodb.DescribeTableCommand({ TableName: tableName });
280
+ const { Table } = await client.send(describeCommand);
281
+ const hashKey = _prismatic_io_spectral.util.types.toString(Table?.KeySchema?.filter((key) => key.KeyType === "HASH")[0].AttributeName);
282
+ const hashKeyType = _prismatic_io_spectral.util.types.toString(Table?.AttributeDefinitions?.filter((attribute) => attribute.AttributeName === hashKey)[0].AttributeType);
283
+ keys[hashKey] = coerceValue(hashKey, hashKeyValue, hashKeyType);
284
+ const rangeKey = _prismatic_io_spectral.util.types.toString(Table?.KeySchema?.filter((key) => key.KeyType === "RANGE")?.[0]?.AttributeName);
285
+ if (rangeKey && !rangeKeyValue) throw new Error("Your table has a range key, but you did not provide a range key value");
286
+ if (!rangeKey && rangeKeyValue) throw new Error("Your table does not have a range key, but you provided one");
287
+ if (rangeKey) {
288
+ const rangeKeyType = _prismatic_io_spectral.util.types.toString(Table?.AttributeDefinitions?.filter((attribute) => attribute.AttributeName === rangeKey)[0].AttributeType);
289
+ keys[rangeKey] = coerceValue(rangeKey, rangeKeyValue, rangeKeyType);
290
+ }
291
+ return keys;
292
+ };
293
+ const cleanObject = (value) => value ? _prismatic_io_spectral.util.types.toObject(value) : void 0;
294
+ const cleanKeyValueListInput = (value) => value ? _prismatic_io_spectral.util.types.keyValPairListToObject(value, _prismatic_io_spectral.util.types.toObject) : void 0;
295
+ let transformDynamoDBValue;
296
+ let transformDynamoDBObject = (item) => {
297
+ return Object.entries(item).reduce((acc, [key, value]) => {
298
+ acc[key] = transformDynamoDBValue(value);
299
+ return acc;
300
+ }, {});
301
+ };
302
+ transformDynamoDBValue = (value) => {
303
+ if ("S" in value) return value.S;
304
+ if ("N" in value) return Number(value.N);
305
+ if ("BOOL" in value) return value.BOOL;
306
+ if ("M" in value) return transformDynamoDBObject(value.M);
307
+ if ("L" in value) return value.L.map(transformDynamoDBValue);
308
+ return null;
309
+ };
310
+ const toOptionalNumber = (value) => value ? _prismatic_io_spectral.util.types.toNumber(value) : void 0;
311
+ //#endregion
312
+ //#region src/inputs.ts
313
+ const valueTypes = {
314
+ S: "String",
315
+ N: "Number",
316
+ B: "Buffer",
317
+ L: "List/Array",
318
+ M: "Map/Object",
319
+ SS: "String Set",
320
+ NS: "Number Set",
321
+ BS: "Buffer Set",
322
+ BOOL: "Boolean"
323
+ };
324
+ const item = (0, _prismatic_io_spectral.input)({
325
+ label: "Value",
326
+ type: "string",
327
+ collection: "keyvaluelist",
328
+ required: true,
329
+ placeholder: "Enter key-value pairs",
330
+ comments: "Key-value pairs representing the item to insert into the table. Each key corresponds to an attribute name.",
331
+ example: "customerId"
332
+ });
333
+ const itemTypes = (0, _prismatic_io_spectral.input)({
334
+ label: "Value Types",
335
+ type: "string",
336
+ collection: "keyvaluelist",
337
+ required: true,
338
+ model: Object.entries(valueTypes).map(([value, label]) => ({
339
+ label,
340
+ value
341
+ })),
342
+ example: "N",
343
+ placeholder: "Select data types for each value",
344
+ comments: "The DynamoDB data type for each item attribute. Must specify a type for each key in the Value field. See [DynamoDB data types](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes)."
345
+ });
346
+ (0, _prismatic_io_spectral.input)({
347
+ label: "Value Type",
348
+ type: "string",
349
+ required: true,
350
+ example: "N",
351
+ placeholder: "Select data type",
352
+ model: Object.entries(valueTypes).map(([value, label]) => ({
353
+ label,
354
+ value
355
+ })),
356
+ comments: "The DynamoDB data type for the hash key attribute. See [DynamoDB data types](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes)."
357
+ });
358
+ const expressionAttributeValues = (0, _prismatic_io_spectral.input)({
359
+ label: "Expression Attribute Values",
360
+ type: "string",
361
+ collection: "keyvaluelist",
362
+ required: true,
363
+ placeholder: "Enter attribute values (e.g., :price)",
364
+ example: ":limit",
365
+ comments: "Expression attribute values are substitutes for actual values in expressions. Each key must begin with a colon (:) followed by alphanumeric characters. Learn more about [expression attribute values](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ExpressionAttributeValues.html)."
366
+ });
367
+ const expressionAttributeValueTypes = (0, _prismatic_io_spectral.input)({
368
+ label: "Expression Attribute Value Types",
369
+ type: "string",
370
+ collection: "keyvaluelist",
371
+ required: true,
372
+ model: Object.entries(valueTypes).map(([value, label]) => ({
373
+ label,
374
+ value
375
+ })),
376
+ placeholder: "Select data types for each attribute value",
377
+ comments: "The DynamoDB data type for each expression attribute value. Must specify a type for each value provided in Expression Attribute Values."
378
+ });
379
+ const query = (0, _prismatic_io_spectral.input)({
380
+ label: "Update Expression",
381
+ type: "string",
382
+ required: true,
383
+ example: "set Title = :t, Subtitle = :s",
384
+ placeholder: "Enter update expression",
385
+ comments: "An update expression specifying how to modify item attributes. Learn more about [update expressions](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html).",
386
+ clean: _prismatic_io_spectral.util.types.toString
387
+ });
388
+ const value = (0, _prismatic_io_spectral.input)({
389
+ label: "Hash / Primary Key Value",
390
+ type: "string",
391
+ required: true,
392
+ example: "cust_1234",
393
+ placeholder: "Enter primary key value",
394
+ comments: "The value of the hash key (primary key) to match.",
395
+ clean: _prismatic_io_spectral.util.types.toString
396
+ });
397
+ const rangeKeyValue = (0, _prismatic_io_spectral.input)({
398
+ label: "Range / Sort Key Value",
399
+ type: "string",
400
+ required: false,
401
+ example: "Acme Inc",
402
+ placeholder: "Enter sort key value",
403
+ comments: "The value of the optional range key (sort key) to match. <strong>Required</strong> if your table has a range key.",
404
+ clean: toOptionalString
405
+ });
406
+ const tableName = (0, _prismatic_io_spectral.input)({
407
+ label: "Table Name",
408
+ type: "string",
409
+ required: true,
410
+ example: "Customers",
411
+ placeholder: "Enter table name",
412
+ comments: "The name of the DynamoDB table to interact with.",
413
+ dataSource: "selectTable",
414
+ clean: _prismatic_io_spectral.util.types.toString
415
+ });
416
+ const attributeDefinition = (0, _prismatic_io_spectral.input)({
417
+ label: "Attribute Definition",
418
+ type: "code",
419
+ language: "json",
420
+ required: true,
421
+ example: JSON.stringify([{
422
+ AttributeName: "customerId",
423
+ AttributeType: "N"
424
+ }, {
425
+ AttributeName: "customerName",
426
+ AttributeType: "S"
427
+ }], null, 2),
428
+ comments: "Array of attribute definitions. Each object must contain an AttributeName and AttributeType. See [DynamoDB data types](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes).",
429
+ clean: _prismatic_io_spectral.util.types.toObject
430
+ });
431
+ const keySchema = (0, _prismatic_io_spectral.input)({
432
+ label: "Key Schema",
433
+ type: "code",
434
+ required: true,
435
+ language: "json",
436
+ example: JSON.stringify([{
437
+ KeyType: "HASH",
438
+ AttributeName: "customerId"
439
+ }, {
440
+ KeyType: "RANGE",
441
+ AttributeName: "customerName"
442
+ }], null, 2),
443
+ comments: "Array of key schema elements. Each object must contain a KeyType (HASH or RANGE) and an AttributeName. Learn more about [key schemas](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.CoreComponents.html#HowItWorks.CoreComponents.PrimaryKey).",
444
+ clean: _prismatic_io_spectral.util.types.toObject
445
+ });
446
+ const billingMode = (0, _prismatic_io_spectral.input)({
447
+ label: "Billing Mode",
448
+ type: "string",
449
+ required: true,
450
+ default: "PROVISIONED",
451
+ model: [{
452
+ label: "Provisioned",
453
+ value: "PROVISIONED"
454
+ }, {
455
+ label: "Pay Per Request",
456
+ value: "PAY_PER_REQUEST"
457
+ }],
458
+ placeholder: "Select billing mode",
459
+ comments: "The billing mode for the table. Learn more about [billing modes](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadWriteCapacityMode.html).",
460
+ clean: _prismatic_io_spectral.util.types.toString
461
+ });
462
+ const readCapacityUnits = (0, _prismatic_io_spectral.input)({
463
+ label: "Read Capacity Units",
464
+ type: "string",
465
+ required: false,
466
+ example: "6000",
467
+ placeholder: "Enter read capacity units",
468
+ comments: "The number of read capacity units. One unit = one strongly consistent read/sec or two eventually consistent reads/sec for items up to 4 KB. Learn more about [read capacity](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ProvisionedThroughput.html).",
469
+ clean: toOptionalNumber
470
+ });
471
+ const writeCapacityUnits = (0, _prismatic_io_spectral.input)({
472
+ label: "Write Capacity Units",
473
+ type: "string",
474
+ required: false,
475
+ example: "6000",
476
+ placeholder: "Enter write capacity units",
477
+ comments: "The number of write capacity units. One unit = one write/sec for items up to 1 KB. Larger items consume additional units. Learn more about [write capacity](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ProvisionedThroughput.html).",
478
+ clean: toOptionalNumber
479
+ });
480
+ const conditionExpression = (0, _prismatic_io_spectral.input)({
481
+ label: "Condition Expression",
482
+ type: "string",
483
+ required: false,
484
+ example: "Price > :limit",
485
+ placeholder: "Enter condition expression",
486
+ comments: "A condition that must be satisfied for the operation to succeed. Learn more about [condition expressions](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ConditionExpressions.html).",
487
+ clean: toOptionalString
488
+ });
489
+ const connectionInput = (0, _prismatic_io_spectral.input)({
490
+ label: "Connection",
491
+ type: "connection",
492
+ required: true,
493
+ comments: "The AWS DynamoDB connection to use."
494
+ });
495
+ const parameters = (0, _prismatic_io_spectral.input)({
496
+ label: "Parameters",
497
+ type: "code",
498
+ required: false,
499
+ language: "json",
500
+ default: JSON.stringify(["Rose"], null, 2),
501
+ comments: "Array of parameter values for the PartiQL statement. Parameters are referenced using ? placeholders in the statement. Learn more about [PartiQL parameters](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ql-reference.html).",
502
+ clean: cleanObject
503
+ });
504
+ const statement = (0, _prismatic_io_spectral.input)({
505
+ label: "Statement",
506
+ type: "string",
507
+ required: true,
508
+ example: "INSERT INTO Flowers value {'Name':?}",
509
+ placeholder: "Enter PartiQL statement",
510
+ comments: "The PartiQL statement to execute. Use ? for parameters. Learn more about [PartiQL for DynamoDB](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ql-reference.html).",
511
+ clean: toOptionalString
512
+ });
513
+ const queryParameters = (0, _prismatic_io_spectral.input)({
514
+ label: "Query Parameters",
515
+ type: "string",
516
+ collection: "keyvaluelist",
517
+ required: false,
518
+ placeholder: "Enter additional query parameters",
519
+ comments: "Additional parameters to pass to the query operation. These are merged with the command input.",
520
+ clean: cleanKeyValueListInput
521
+ });
522
+ const keyConditionExpression = (0, _prismatic_io_spectral.input)({
523
+ label: "Key Condition Expression",
524
+ type: "string",
525
+ required: false,
526
+ example: "Season = :s and Episode > :e",
527
+ placeholder: "Enter key condition expression",
528
+ comments: "The condition specifying key values for the query. Must specify the partition key and optionally a sort key condition. Learn more about [key condition expressions](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html#Query.KeyConditionExpressions).",
529
+ clean: toOptionalString
530
+ });
531
+ const filterExpression = (0, _prismatic_io_spectral.input)({
532
+ label: "Filter Expression",
533
+ type: "string",
534
+ required: false,
535
+ example: "contains (Subtitle, :topic)",
536
+ placeholder: "Enter filter expression",
537
+ comments: "A condition to filter query results after they're retrieved. Cannot filter on partition or sort keys. Learn more about [filter expressions](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html#Query.FilterExpression).",
538
+ clean: toOptionalString
539
+ });
540
+ const fetchAll = (0, _prismatic_io_spectral.input)({
541
+ label: "Fetch All",
542
+ type: "boolean",
543
+ required: false,
544
+ default: "false",
545
+ comments: "When true, automatically fetch all pages of results using pagination. When false, return only the first page.",
546
+ clean: _prismatic_io_spectral.util.types.toBool
547
+ });
548
+ //#endregion
549
+ //#region src/auth.ts
550
+ const validateConnection = (connection) => {
551
+ if (![accessKeySecretPair.key, assumeRoleConnection.key].includes(connection.key)) throw new _prismatic_io_spectral.ConnectionError(connection, `Unsupported connection method ${connection.key}.`);
552
+ };
553
+ const getCredentials = (connection) => {
554
+ validateConnection(connection);
555
+ return {
556
+ accessKeyId: toTrimmedString(connection.fields.accessKeyId),
557
+ secretAccessKey: toTrimmedString(connection.fields.secretAccessKey)
558
+ };
559
+ };
560
+ const createDynamoClient = async ({ awsConnection, region: awsRegion, debug, logger }) => {
561
+ const { accessKeyId, secretAccessKey } = getCredentials(awsConnection);
562
+ const credentials = awsConnection.key === assumeRoleConnection.key ? await assumeRole(awsRegion, accessKeyId, secretAccessKey, toTrimmedString(awsConnection.fields.roleARN), toOptionalString(awsConnection.fields?.externalId)) : {
563
+ accessKeyId,
564
+ secretAccessKey
565
+ };
566
+ return new _aws_sdk_client_dynamodb.DynamoDBClient({
567
+ region: awsRegion.length > 0 ? awsRegion : void 0,
568
+ credentials,
569
+ logger: debug ? logger : void 0
570
+ });
571
+ };
572
+ //#endregion
573
+ //#region src/examplePayloads.ts
574
+ const createItemExamplePayload = { data: {
575
+ $metadata: {
576
+ httpStatusCode: 200,
577
+ requestId: "ABC123DEF456GHI789JKL012MNO345PQ",
578
+ extendedRequestId: void 0,
579
+ cfId: void 0,
580
+ attempts: 1,
581
+ totalRetryDelay: 0
582
+ },
583
+ ConsumedCapacity: {
584
+ TableName: "Users",
585
+ CapacityUnits: 1
586
+ }
587
+ } };
588
+ const getItemExamplePayload = { data: {
589
+ result: {
590
+ $metadata: {
591
+ httpStatusCode: 200,
592
+ requestId: "Q46HIT95LVKPO8HB708JFS47VV4KQNSO5AEMVJF66Q9ASUAAJG",
593
+ extendedRequestId: void 0,
594
+ cfId: void 0,
595
+ attempts: 1,
596
+ totalRetryDelay: 0
597
+ },
598
+ Item: {
599
+ userId: { S: "user-12345" },
600
+ email: { S: "john.doe@example.com" },
601
+ firstName: { S: "John" },
602
+ lastName: { S: "Doe" },
603
+ age: { N: "32" },
604
+ isActive: { BOOL: true },
605
+ createdAt: { S: "2024-01-15T10:30:00.000Z" },
606
+ lastLogin: { S: "2024-03-20T14:22:10.000Z" },
607
+ preferences: { M: {
608
+ theme: { S: "dark" },
609
+ notifications: { BOOL: true }
610
+ } },
611
+ tags: { L: [{ S: "premium" }, { S: "verified" }] }
612
+ },
613
+ ConsumedCapacity: {
614
+ TableName: "Users",
615
+ CapacityUnits: .5
616
+ }
617
+ },
618
+ found: true
619
+ } };
620
+ const updateItemExamplePayload = { data: {
621
+ $metadata: {
622
+ httpStatusCode: 200,
623
+ requestId: "XYZ789ABC123DEF456GHI012JKL345MN",
624
+ extendedRequestId: void 0,
625
+ cfId: void 0,
626
+ attempts: 1,
627
+ totalRetryDelay: 0
628
+ },
629
+ Attributes: {
630
+ userId: { S: "user-12345" },
631
+ email: { S: "john.doe@example.com" },
632
+ firstName: { S: "John" },
633
+ lastName: { S: "Smith" },
634
+ age: { N: "32" },
635
+ isActive: { BOOL: true },
636
+ updatedAt: { S: "2024-03-20T14:22:10.000Z" }
637
+ },
638
+ ConsumedCapacity: {
639
+ TableName: "Users",
640
+ CapacityUnits: 1
641
+ }
642
+ } };
643
+ const deleteItemExamplePayload = { data: {
644
+ $metadata: {
645
+ httpStatusCode: 200,
646
+ requestId: "MNO345PQR678STU901VWX234YZA567BC",
647
+ extendedRequestId: void 0,
648
+ cfId: void 0,
649
+ attempts: 1,
650
+ totalRetryDelay: 0
651
+ },
652
+ ConsumedCapacity: {
653
+ TableName: "Users",
654
+ CapacityUnits: 1
655
+ }
656
+ } };
657
+ const queryItemsExamplePayload = { data: {
658
+ $metadata: {
659
+ httpStatusCode: 200,
660
+ requestId: "DEF456GHI789JKL012MNO345PQR678ST",
661
+ extendedRequestId: void 0,
662
+ cfId: void 0,
663
+ attempts: 1,
664
+ totalRetryDelay: 0
665
+ },
666
+ Items: [{
667
+ userId: "user-12345",
668
+ email: "john.doe@example.com",
669
+ firstName: "John",
670
+ lastName: "Doe",
671
+ age: 32,
672
+ isActive: true,
673
+ createdAt: "2024-01-15T10:30:00.000Z",
674
+ preferences: {
675
+ theme: "dark",
676
+ notifications: true
677
+ },
678
+ tags: ["premium", "verified"]
679
+ }, {
680
+ userId: "user-67890",
681
+ email: "jane.smith@example.com",
682
+ firstName: "Jane",
683
+ lastName: "Smith",
684
+ age: 28,
685
+ isActive: true,
686
+ createdAt: "2024-02-10T09:15:30.000Z",
687
+ preferences: {
688
+ theme: "light",
689
+ notifications: false
690
+ },
691
+ tags: ["verified"]
692
+ }],
693
+ Count: 2,
694
+ ScannedCount: 2,
695
+ ConsumedCapacity: {
696
+ TableName: "Users",
697
+ CapacityUnits: .5
698
+ }
699
+ } };
700
+ const createTableExamplePayload = { data: {
701
+ $metadata: {
702
+ httpStatusCode: 200,
703
+ requestId: "GHI789JKL012MNO345PQR678STU901VW",
704
+ extendedRequestId: void 0,
705
+ cfId: void 0,
706
+ attempts: 1,
707
+ totalRetryDelay: 0
708
+ },
709
+ TableDescription: {
710
+ TableName: "Users",
711
+ TableArn: "arn:aws:dynamodb:us-east-1:123456789012:table/Users",
712
+ TableStatus: "CREATING",
713
+ CreationDateTime: /* @__PURE__ */ new Date("2024-03-20T10:30:00.000Z"),
714
+ AttributeDefinitions: [{
715
+ AttributeName: "userId",
716
+ AttributeType: "S"
717
+ }, {
718
+ AttributeName: "email",
719
+ AttributeType: "S"
720
+ }],
721
+ KeySchema: [{
722
+ AttributeName: "userId",
723
+ KeyType: "HASH"
724
+ }],
725
+ TableSizeBytes: 0,
726
+ ItemCount: 0,
727
+ ProvisionedThroughput: {
728
+ ReadCapacityUnits: 5,
729
+ WriteCapacityUnits: 5,
730
+ NumberOfDecreasesToday: 0
731
+ },
732
+ GlobalSecondaryIndexes: [{
733
+ IndexName: "EmailIndex",
734
+ KeySchema: [{
735
+ AttributeName: "email",
736
+ KeyType: "HASH"
737
+ }],
738
+ Projection: { ProjectionType: "ALL" },
739
+ IndexStatus: "CREATING",
740
+ ProvisionedThroughput: {
741
+ ReadCapacityUnits: 5,
742
+ WriteCapacityUnits: 5,
743
+ NumberOfDecreasesToday: 0
744
+ }
745
+ }]
746
+ }
747
+ } };
748
+ const describeTableExamplePayload = { data: {
749
+ $metadata: {
750
+ httpStatusCode: 200,
751
+ requestId: "JKL012MNO345PQR678STU901VWX234YZ",
752
+ extendedRequestId: void 0,
753
+ cfId: void 0,
754
+ attempts: 1,
755
+ totalRetryDelay: 0
756
+ },
757
+ Table: {
758
+ TableName: "Users",
759
+ TableArn: "arn:aws:dynamodb:us-east-1:123456789012:table/Users",
760
+ TableStatus: "ACTIVE",
761
+ CreationDateTime: /* @__PURE__ */ new Date("2024-03-20T10:30:00.000Z"),
762
+ AttributeDefinitions: [{
763
+ AttributeName: "userId",
764
+ AttributeType: "S"
765
+ }, {
766
+ AttributeName: "email",
767
+ AttributeType: "S"
768
+ }],
769
+ KeySchema: [{
770
+ AttributeName: "userId",
771
+ KeyType: "HASH"
772
+ }],
773
+ TableSizeBytes: 524288,
774
+ ItemCount: 1247,
775
+ ProvisionedThroughput: {
776
+ ReadCapacityUnits: 5,
777
+ WriteCapacityUnits: 5,
778
+ NumberOfDecreasesToday: 0,
779
+ LastIncreaseDateTime: /* @__PURE__ */ new Date("2024-03-15T08:00:00.000Z"),
780
+ LastDecreaseDateTime: /* @__PURE__ */ new Date("2024-03-10T16:30:00.000Z")
781
+ },
782
+ GlobalSecondaryIndexes: [{
783
+ IndexName: "EmailIndex",
784
+ KeySchema: [{
785
+ AttributeName: "email",
786
+ KeyType: "HASH"
787
+ }],
788
+ Projection: { ProjectionType: "ALL" },
789
+ IndexStatus: "ACTIVE",
790
+ IndexSizeBytes: 524288,
791
+ ItemCount: 1247,
792
+ ProvisionedThroughput: {
793
+ ReadCapacityUnits: 5,
794
+ WriteCapacityUnits: 5,
795
+ NumberOfDecreasesToday: 0
796
+ }
797
+ }]
798
+ }
799
+ } };
800
+ const deleteTableExamplePayload = { data: {
801
+ $metadata: {
802
+ httpStatusCode: 200,
803
+ requestId: "PQR678STU901VWX234YZA567BCD890EF",
804
+ extendedRequestId: void 0,
805
+ cfId: void 0,
806
+ attempts: 1,
807
+ totalRetryDelay: 0
808
+ },
809
+ TableDescription: {
810
+ TableName: "Users",
811
+ TableArn: "arn:aws:dynamodb:us-east-1:123456789012:table/Users",
812
+ TableStatus: "DELETING",
813
+ CreationDateTime: /* @__PURE__ */ new Date("2024-03-20T10:30:00.000Z"),
814
+ AttributeDefinitions: [{
815
+ AttributeName: "userId",
816
+ AttributeType: "S"
817
+ }],
818
+ KeySchema: [{
819
+ AttributeName: "userId",
820
+ KeyType: "HASH"
821
+ }],
822
+ TableSizeBytes: 524288,
823
+ ItemCount: 1247,
824
+ ProvisionedThroughput: {
825
+ ReadCapacityUnits: 5,
826
+ WriteCapacityUnits: 5,
827
+ NumberOfDecreasesToday: 0
828
+ }
829
+ }
830
+ } };
831
+ const listTablesExamplePayload = { data: {
832
+ result: {
833
+ $metadata: {
834
+ httpStatusCode: 200,
835
+ requestId: "STU901VWX234YZA567BCD890EFG123HI",
836
+ extendedRequestId: void 0,
837
+ cfId: void 0,
838
+ attempts: 1,
839
+ totalRetryDelay: 0
840
+ },
841
+ TableNames: [
842
+ "Users",
843
+ "Orders",
844
+ "Products",
845
+ "Inventory",
846
+ "Analytics"
847
+ ],
848
+ LastEvaluatedTableName: void 0
849
+ },
850
+ found: true
851
+ } };
852
+ const rawRequestExamplePayload = { data: {
853
+ $metadata: {
854
+ httpStatusCode: 200,
855
+ requestId: "VWX234YZA567BCD890EFG123HIJ456KL",
856
+ extendedRequestId: void 0,
857
+ cfId: void 0,
858
+ attempts: 1,
859
+ totalRetryDelay: 0
860
+ },
861
+ Items: [{
862
+ userId: { S: "user-12345" },
863
+ email: { S: "john.doe@example.com" },
864
+ firstName: { S: "John" },
865
+ lastName: { S: "Doe" }
866
+ }, {
867
+ userId: { S: "user-67890" },
868
+ email: { S: "jane.smith@example.com" },
869
+ firstName: { S: "Jane" },
870
+ lastName: { S: "Smith" }
871
+ }],
872
+ NextToken: void 0
873
+ } };
874
+ //#endregion
875
+ //#region src/actions/createItem.ts
876
+ const createItem = (0, _prismatic_io_spectral.action)({
877
+ display: {
878
+ label: "Upsert Item",
879
+ description: "Creates a new item, or replaces an existing item with a new item"
880
+ },
881
+ perform: async (context, { awsConnection, awsRegion, item, itemTypes, conditionExpression, expressionAttributeValues, expressionAttributeValueTypes, tableName }) => {
882
+ const client = await createDynamoClient({
883
+ awsConnection,
884
+ region: awsRegion,
885
+ debug: context.debug.enabled,
886
+ logger: context.logger
887
+ });
888
+ const command = new _aws_sdk_client_dynamodb.PutItemCommand({
889
+ TableName: tableName,
890
+ Item: convertDataType(item, itemTypes),
891
+ ConditionExpression: conditionExpression,
892
+ ExpressionAttributeValues: conditionExpression ? convertDataType(expressionAttributeValues, expressionAttributeValueTypes) : void 0
893
+ });
894
+ return { data: await client.send(command) };
895
+ },
896
+ inputs: {
897
+ awsRegion,
898
+ tableName,
899
+ item,
900
+ itemTypes,
901
+ conditionExpression,
902
+ expressionAttributeValues: {
903
+ ...expressionAttributeValues,
904
+ required: false
905
+ },
906
+ expressionAttributeValueTypes: {
907
+ ...expressionAttributeValueTypes,
908
+ required: false
909
+ },
910
+ awsConnection: connectionInput
911
+ },
912
+ examplePayload: createItemExamplePayload
913
+ });
914
+ //#endregion
915
+ //#region src/actions/getItem.ts
916
+ const getItem = (0, _prismatic_io_spectral.action)({
917
+ display: {
918
+ label: "Get Item",
919
+ description: "Retrieve an item from a DynamoDB database"
920
+ },
921
+ perform: async (context, { awsConnection, awsRegion, tableName, value, rangeKeyValue }) => {
922
+ const client = await createDynamoClient({
923
+ awsConnection,
924
+ region: awsRegion,
925
+ debug: context.debug.enabled,
926
+ logger: context.logger
927
+ });
928
+ const command = new _aws_sdk_client_dynamodb.GetItemCommand({
929
+ TableName: tableName,
930
+ Key: await getItemKeySearch({
931
+ client,
932
+ tableName,
933
+ hashKeyValue: value,
934
+ rangeKeyValue
935
+ })
936
+ });
937
+ const result = await client.send(command);
938
+ return { data: {
939
+ result,
940
+ found: result?.Item != null
941
+ } };
942
+ },
943
+ inputs: {
944
+ awsRegion,
945
+ tableName,
946
+ value,
947
+ rangeKeyValue,
948
+ awsConnection: connectionInput
949
+ },
950
+ examplePayload: getItemExamplePayload
951
+ });
952
+ //#endregion
953
+ //#region src/actions/deleteItem.ts
954
+ const deleteItem = (0, _prismatic_io_spectral.action)({
955
+ display: {
956
+ label: "Delete Item",
957
+ description: "Delete an item from a DynamoDB database"
958
+ },
959
+ perform: async (context, { awsConnection, awsRegion, tableName, value, rangeKeyValue, conditionExpression, expressionAttributeValues, expressionAttributeValueTypes }) => {
960
+ const client = await createDynamoClient({
961
+ awsConnection,
962
+ region: awsRegion,
963
+ debug: context.debug.enabled,
964
+ logger: context.logger
965
+ });
966
+ const command = new _aws_sdk_client_dynamodb.DeleteItemCommand({
967
+ TableName: tableName,
968
+ Key: await getItemKeySearch({
969
+ client,
970
+ tableName,
971
+ hashKeyValue: value,
972
+ rangeKeyValue
973
+ }),
974
+ ConditionExpression: conditionExpression,
975
+ ExpressionAttributeValues: conditionExpression ? convertDataType(expressionAttributeValues, expressionAttributeValueTypes) : void 0
976
+ });
977
+ return { data: await client.send(command) };
978
+ },
979
+ inputs: {
980
+ awsRegion,
981
+ tableName,
982
+ value,
983
+ rangeKeyValue,
984
+ conditionExpression,
985
+ expressionAttributeValues: {
986
+ ...expressionAttributeValues,
987
+ required: false
988
+ },
989
+ expressionAttributeValueTypes: {
990
+ ...expressionAttributeValueTypes,
991
+ required: false
992
+ },
993
+ awsConnection: connectionInput
994
+ },
995
+ examplePayload: deleteItemExamplePayload
996
+ });
997
+ //#endregion
998
+ //#region src/actions/updateItem.ts
999
+ const updateItem = (0, _prismatic_io_spectral.action)({
1000
+ display: {
1001
+ label: "Update Item",
1002
+ description: "Update an existing item in a DynamoDB database"
1003
+ },
1004
+ perform: async (context, { awsConnection, awsRegion, tableName, value, rangeKeyValue, query, conditionExpression, queryParams, queryParamTypes }) => {
1005
+ const client = await createDynamoClient({
1006
+ awsConnection,
1007
+ region: awsRegion,
1008
+ debug: context.debug.enabled,
1009
+ logger: context.logger
1010
+ });
1011
+ const command = new _aws_sdk_client_dynamodb.UpdateItemCommand({
1012
+ TableName: tableName,
1013
+ Key: await getItemKeySearch({
1014
+ client,
1015
+ tableName,
1016
+ hashKeyValue: value,
1017
+ rangeKeyValue
1018
+ }),
1019
+ UpdateExpression: query,
1020
+ ConditionExpression: conditionExpression,
1021
+ ExpressionAttributeValues: convertDataType(queryParams, queryParamTypes)
1022
+ });
1023
+ return { data: await client.send(command) };
1024
+ },
1025
+ inputs: {
1026
+ awsRegion,
1027
+ tableName,
1028
+ value,
1029
+ rangeKeyValue,
1030
+ query,
1031
+ conditionExpression,
1032
+ queryParams: expressionAttributeValues,
1033
+ queryParamTypes: expressionAttributeValueTypes,
1034
+ awsConnection: connectionInput
1035
+ },
1036
+ examplePayload: updateItemExamplePayload
1037
+ });
1038
+ //#endregion
1039
+ //#region src/actions/index.ts
1040
+ var actions_default = {
1041
+ createItem,
1042
+ createTable: (0, _prismatic_io_spectral.action)({
1043
+ display: {
1044
+ label: "Create Table",
1045
+ description: "Create a new DynamoDB Table"
1046
+ },
1047
+ perform: async (context, { awsConnection, awsRegion, tableName, attributeDefinition, keySchema, billingMode, readCapacityUnits, writeCapacityUnits }) => {
1048
+ const client = await createDynamoClient({
1049
+ awsConnection,
1050
+ region: awsRegion,
1051
+ debug: context.debug.enabled,
1052
+ logger: context.logger
1053
+ });
1054
+ const command = new _aws_sdk_client_dynamodb.CreateTableCommand({
1055
+ TableName: tableName,
1056
+ AttributeDefinitions: attributeDefinition,
1057
+ KeySchema: keySchema,
1058
+ BillingMode: billingMode,
1059
+ ProvisionedThroughput: readCapacityUnits || writeCapacityUnits ? {
1060
+ ReadCapacityUnits: readCapacityUnits,
1061
+ WriteCapacityUnits: writeCapacityUnits
1062
+ } : void 0
1063
+ });
1064
+ return { data: await client.send(command) };
1065
+ },
1066
+ inputs: {
1067
+ awsRegion,
1068
+ tableName: {
1069
+ ...tableName,
1070
+ dataSource: void 0
1071
+ },
1072
+ keySchema,
1073
+ attributeDefinition,
1074
+ billingMode,
1075
+ readCapacityUnits,
1076
+ writeCapacityUnits,
1077
+ awsConnection: connectionInput
1078
+ },
1079
+ examplePayload: createTableExamplePayload
1080
+ }),
1081
+ deleteItem,
1082
+ deleteTable: (0, _prismatic_io_spectral.action)({
1083
+ display: {
1084
+ label: "Delete Table",
1085
+ description: "Delete an existing DynamoDB Table"
1086
+ },
1087
+ perform: async (context, { awsConnection, awsRegion, tableName }) => {
1088
+ const client = await createDynamoClient({
1089
+ awsConnection,
1090
+ region: awsRegion,
1091
+ debug: context.debug.enabled,
1092
+ logger: context.logger
1093
+ });
1094
+ const command = new _aws_sdk_client_dynamodb.DeleteTableCommand({ TableName: tableName });
1095
+ return { data: await client.send(command) };
1096
+ },
1097
+ inputs: {
1098
+ awsRegion,
1099
+ tableName,
1100
+ awsConnection: connectionInput
1101
+ },
1102
+ examplePayload: deleteTableExamplePayload
1103
+ }),
1104
+ describeTable: (0, _prismatic_io_spectral.action)({
1105
+ display: {
1106
+ label: "Describe Table",
1107
+ description: "Fetch metadata about an existing DynamoDB Table"
1108
+ },
1109
+ perform: async (context, { awsConnection, awsRegion, tableName }) => {
1110
+ const client = await createDynamoClient({
1111
+ awsConnection,
1112
+ region: awsRegion,
1113
+ debug: context.debug.enabled,
1114
+ logger: context.logger
1115
+ });
1116
+ const command = new _aws_sdk_client_dynamodb.DescribeTableCommand({ TableName: tableName });
1117
+ return { data: await client.send(command) };
1118
+ },
1119
+ inputs: {
1120
+ awsRegion,
1121
+ tableName,
1122
+ awsConnection: connectionInput
1123
+ },
1124
+ examplePayload: describeTableExamplePayload
1125
+ }),
1126
+ getItem,
1127
+ listTables: (0, _prismatic_io_spectral.action)({
1128
+ display: {
1129
+ label: "List Tables",
1130
+ description: "List all DynamoDB Tables"
1131
+ },
1132
+ perform: async (context, { awsConnection, awsRegion, fetchAll }) => {
1133
+ const client = await createDynamoClient({
1134
+ awsConnection,
1135
+ region: awsRegion,
1136
+ debug: context.debug.enabled,
1137
+ logger: context.logger
1138
+ });
1139
+ if (fetchAll) {
1140
+ const tables = [];
1141
+ const result = (0, _aws_sdk_client_dynamodb.paginateListTables)({ client }, {});
1142
+ for await (const page of result) tables.push(...page.TableNames || []);
1143
+ return { data: {
1144
+ result: tables,
1145
+ found: tables?.length > 0
1146
+ } };
1147
+ }
1148
+ const command = new _aws_sdk_client_dynamodb.ListTablesCommand({});
1149
+ const result = await client.send(command);
1150
+ return { data: {
1151
+ result,
1152
+ found: (result.TableNames?.length ?? 0) > 0
1153
+ } };
1154
+ },
1155
+ inputs: {
1156
+ awsRegion,
1157
+ awsConnection: connectionInput,
1158
+ fetchAll
1159
+ },
1160
+ examplePayload: listTablesExamplePayload
1161
+ }),
1162
+ updateItem,
1163
+ rawRequest: (0, _prismatic_io_spectral.action)({
1164
+ display: {
1165
+ label: "Raw Request",
1166
+ description: "Execute single PartiQL statements."
1167
+ },
1168
+ inputs: {
1169
+ awsRegion,
1170
+ statement,
1171
+ parameters,
1172
+ queryParameters,
1173
+ awsConnection: connectionInput
1174
+ },
1175
+ perform: async (context, { awsConnection, awsRegion, parameters, statement, queryParameters }) => {
1176
+ const client = await createDynamoClient({
1177
+ awsConnection,
1178
+ region: awsRegion,
1179
+ debug: context.debug.enabled,
1180
+ logger: context.logger
1181
+ });
1182
+ const docClient = _aws_sdk_lib_dynamodb.DynamoDBDocumentClient.from(client);
1183
+ const command = new _aws_sdk_lib_dynamodb.ExecuteStatementCommand({
1184
+ Statement: statement,
1185
+ Parameters: parameters,
1186
+ ...queryParameters
1187
+ });
1188
+ return { data: await docClient.send(command) };
1189
+ },
1190
+ examplePayload: rawRequestExamplePayload
1191
+ }),
1192
+ queryItems: (0, _prismatic_io_spectral.action)({
1193
+ display: {
1194
+ label: "Query Items",
1195
+ description: "Query a DynamoDB table"
1196
+ },
1197
+ inputs: {
1198
+ awsRegion,
1199
+ tableName,
1200
+ expressionAttributeValues: {
1201
+ ...expressionAttributeValues,
1202
+ required: false
1203
+ },
1204
+ expressionAttributeValueTypes: {
1205
+ ...expressionAttributeValueTypes,
1206
+ required: false
1207
+ },
1208
+ keyConditionExpression,
1209
+ filterExpression,
1210
+ queryParameters,
1211
+ awsConnection: connectionInput
1212
+ },
1213
+ perform: async (context, { awsConnection, awsRegion, expressionAttributeValues, expressionAttributeValueTypes, filterExpression, keyConditionExpression, queryParameters, tableName }) => {
1214
+ const client = await createDynamoClient({
1215
+ awsConnection,
1216
+ region: awsRegion,
1217
+ debug: context.debug.enabled,
1218
+ logger: context.logger
1219
+ });
1220
+ const command = new _aws_sdk_client_dynamodb.QueryCommand({
1221
+ TableName: tableName,
1222
+ KeyConditionExpression: keyConditionExpression,
1223
+ ExpressionAttributeValues: expressionAttributeValues && expressionAttributeValueTypes ? convertDataType(expressionAttributeValues, expressionAttributeValueTypes) : void 0,
1224
+ FilterExpression: filterExpression,
1225
+ ...queryParameters
1226
+ });
1227
+ const result = await client.send(command);
1228
+ const transformedData = result.Items?.map((item) => transformDynamoDBObject(item));
1229
+ return { data: {
1230
+ ...result,
1231
+ Items: transformedData
1232
+ } };
1233
+ },
1234
+ examplePayload: queryItemsExamplePayload
1235
+ })
1236
+ };
1237
+ //#endregion
1238
+ //#region src/dataSources/index.ts
1239
+ var dataSources_default = {
1240
+ selectRegion,
1241
+ selectTable: (0, _prismatic_io_spectral.dataSource)({
1242
+ display: {
1243
+ label: "Select Table",
1244
+ description: "Select a table from the list of tables"
1245
+ },
1246
+ inputs: {
1247
+ awsConnection: connectionInput,
1248
+ awsRegion: {
1249
+ ...awsRegion,
1250
+ dataSource: void 0,
1251
+ model: void 0
1252
+ }
1253
+ },
1254
+ perform: async (context, { awsConnection, awsRegion }) => {
1255
+ const client = await createDynamoClient({
1256
+ awsConnection,
1257
+ region: awsRegion
1258
+ });
1259
+ const command = new _aws_sdk_client_dynamodb.ListTablesCommand({});
1260
+ const { TableNames } = await client.send(command);
1261
+ return { result: TableNames ? TableNames.map((table) => ({
1262
+ label: table,
1263
+ key: table
1264
+ })) : [] };
1265
+ },
1266
+ dataSourceType: "picklist"
1267
+ })
1268
+ };
1269
+ //#endregion
1270
+ //#region src/index.ts
1271
+ var src_default = (0, _prismatic_io_spectral.component)({
1272
+ key: "aws-dynamodb",
1273
+ documentationUrl: "https://prismatic.io/docs/components/aws-dynamodb/",
1274
+ public: true,
1275
+ display: {
1276
+ label: "Amazon DynamoDB",
1277
+ description: "Manage tables and items in Amazon DynamoDB.",
1278
+ iconPath: "icon.png",
1279
+ category: "Data Platforms"
1280
+ },
1281
+ actions: actions_default,
1282
+ connections: connections_default,
1283
+ dataSources: dataSources_default
1284
+ });
1285
+ //#endregion
1286
+ //#region npm-dist/.entry.ts
1287
+ var _entry_default = (0, _prismatic_io_spectral.callableComponent)(src_default);
1288
+ //#endregion
1289
+ module.exports = _entry_default;