@superdurable/connector-amazon-dynamodb 0.1.0 → 0.2.0

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/README.md CHANGED
@@ -1,3 +1,5 @@
1
1
  # Amazon DynamoDB TypeScript package
2
2
 
3
- `AmazonDynamoDBClient.getItem()` binds the signed `getItem` Query. `GetItemInput` contains `tableName`, the complete DynamoDB `key` AttributeValue map, and `consistentRead`. The `found` output contains `{ exists: true, item }`; `missing` has an empty item map. See the [connector guide](../README.md) for configuration and IAM permissions. The [runnable Flow](examples/item-lookup/README.md) exercises a real Dex Worker with a local provider fixture. Live AWS access has not been verified.
3
+ `AmazonDynamoDBClient.getItem()` binds the signed `getItem` Query. `GetItemInput` contains `tableName`, the complete DynamoDB `key` AttributeValue map, and `consistentRead`. The `found` output contains `{ exists: true, item }`; `missing` has an empty item map. See the [connector guide](../README.md) for configuration and IAM permissions. The [runnable examples](examples/item-lookup/README.md) exercise a real Dex Worker with a local provider fixture. Live AWS access has not been verified.
4
+
5
+ Version 0.2.0 adds signed replacement, absolute update, deletion, and bounded scan Steps. The scan output contains item AttributeValue maps and a continuation key. Custom connection bindings must supply all five operations. Generated mocks offer a default for each operation.
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "connectorId": "amazon-dynamodb",
3
- "releaseTag": "connectors/amazon/dynamodb/go/v0.1.0",
3
+ "releaseTag": "connectors/amazon/dynamodb/go/v0.2.0",
4
4
  "package": {
5
5
  "ecosystem": "npm",
6
6
  "name": "@superdurable/connector-amazon-dynamodb",
7
- "version": "0.1.0"
7
+ "version": "0.2.0"
8
8
  },
9
9
  "factories": [
10
10
  {
@@ -71,6 +71,247 @@
71
71
  ],
72
72
  "type": "object"
73
73
  }
74
+ },
75
+ {
76
+ "name": "newPutItemStep",
77
+ "kind": "mutation",
78
+ "operationId": "putItem",
79
+ "inputType": "PutItemInput",
80
+ "description": "Create or completely replace one item by its supplied primary key attributes.",
81
+ "fields": {
82
+ "stepType": "stepType",
83
+ "annotations": "annotations",
84
+ "connectionName": "connectionName",
85
+ "resultAttribute": "resultAttribute"
86
+ },
87
+ "branches": [
88
+ {
89
+ "id": "written",
90
+ "field": "written",
91
+ "optional": false
92
+ },
93
+ {
94
+ "id": "providerRejected",
95
+ "field": "providerRejected",
96
+ "optional": true
97
+ },
98
+ {
99
+ "id": "invalidResponse",
100
+ "field": "invalidResponse",
101
+ "optional": true
102
+ },
103
+ {
104
+ "id": "defect",
105
+ "field": "defect",
106
+ "optional": true
107
+ }
108
+ ],
109
+ "inputSchema": {
110
+ "additionalProperties": false,
111
+ "description": "PutItemInput supplies a complete item including its table primary key.",
112
+ "properties": {
113
+ "item": {
114
+ "additionalProperties": {},
115
+ "description": "Item is the complete map of DynamoDB AttributeValue objects.",
116
+ "type": [
117
+ "object",
118
+ "null"
119
+ ]
120
+ },
121
+ "tableName": {
122
+ "description": "TableName identifies the table in the configured Region.",
123
+ "type": "string"
124
+ }
125
+ },
126
+ "required": [
127
+ "item",
128
+ "tableName"
129
+ ],
130
+ "type": "object"
131
+ }
132
+ },
133
+ {
134
+ "name": "newUpdateItemStep",
135
+ "kind": "mutation",
136
+ "operationId": "updateItem",
137
+ "inputType": "UpdateItemInput",
138
+ "description": "Set absolute attribute values on one item without changing its key; create the item if absent.",
139
+ "fields": {
140
+ "stepType": "stepType",
141
+ "annotations": "annotations",
142
+ "connectionName": "connectionName",
143
+ "resultAttribute": "resultAttribute"
144
+ },
145
+ "branches": [
146
+ {
147
+ "id": "updated",
148
+ "field": "updated",
149
+ "optional": false
150
+ },
151
+ {
152
+ "id": "providerRejected",
153
+ "field": "providerRejected",
154
+ "optional": true
155
+ },
156
+ {
157
+ "id": "invalidResponse",
158
+ "field": "invalidResponse",
159
+ "optional": true
160
+ },
161
+ {
162
+ "id": "defect",
163
+ "field": "defect",
164
+ "optional": true
165
+ }
166
+ ],
167
+ "inputSchema": {
168
+ "additionalProperties": false,
169
+ "description": "UpdateItemInput sets absolute values on one item by complete primary key.",
170
+ "properties": {
171
+ "attributes": {
172
+ "additionalProperties": {},
173
+ "description": "Attributes contains non-key attributes to set to absolute values.",
174
+ "type": [
175
+ "object",
176
+ "null"
177
+ ]
178
+ },
179
+ "key": {
180
+ "additionalProperties": {},
181
+ "description": "Key is the complete table primary key.",
182
+ "type": [
183
+ "object",
184
+ "null"
185
+ ]
186
+ },
187
+ "tableName": {
188
+ "description": "TableName identifies the table in the configured Region.",
189
+ "type": "string"
190
+ }
191
+ },
192
+ "required": [
193
+ "attributes",
194
+ "key",
195
+ "tableName"
196
+ ],
197
+ "type": "object"
198
+ }
199
+ },
200
+ {
201
+ "name": "newDeleteItemStep",
202
+ "kind": "mutation",
203
+ "operationId": "deleteItem",
204
+ "inputType": "DeleteItemInput",
205
+ "description": "Delete one item by complete primary key; repeating the deletion has the same final state.",
206
+ "fields": {
207
+ "stepType": "stepType",
208
+ "annotations": "annotations",
209
+ "connectionName": "connectionName",
210
+ "resultAttribute": "resultAttribute"
211
+ },
212
+ "branches": [
213
+ {
214
+ "id": "deleted",
215
+ "field": "deleted",
216
+ "optional": false
217
+ },
218
+ {
219
+ "id": "providerRejected",
220
+ "field": "providerRejected",
221
+ "optional": true
222
+ },
223
+ {
224
+ "id": "invalidResponse",
225
+ "field": "invalidResponse",
226
+ "optional": true
227
+ },
228
+ {
229
+ "id": "defect",
230
+ "field": "defect",
231
+ "optional": true
232
+ }
233
+ ],
234
+ "inputSchema": {
235
+ "additionalProperties": false,
236
+ "description": "DeleteItemInput identifies one item by its complete primary key.",
237
+ "properties": {
238
+ "key": {
239
+ "additionalProperties": {},
240
+ "description": "Key is the complete table primary key.",
241
+ "type": [
242
+ "object",
243
+ "null"
244
+ ]
245
+ },
246
+ "tableName": {
247
+ "description": "TableName identifies the table in the configured Region.",
248
+ "type": "string"
249
+ }
250
+ },
251
+ "required": [
252
+ "key",
253
+ "tableName"
254
+ ],
255
+ "type": "object"
256
+ }
257
+ },
258
+ {
259
+ "name": "newScanItemsStep",
260
+ "kind": "query",
261
+ "operationId": "scanItems",
262
+ "inputType": "ScanItemsInput",
263
+ "description": "Scan one bounded page of table items and return the continuation key.",
264
+ "fields": {
265
+ "stepType": "stepType",
266
+ "annotations": "annotations",
267
+ "connectionName": "connectionName",
268
+ "resultAttribute": "resultAttribute"
269
+ },
270
+ "branches": [
271
+ {
272
+ "id": "scanned",
273
+ "field": "scanned",
274
+ "optional": false
275
+ },
276
+ {
277
+ "id": "providerRejected",
278
+ "field": "providerRejected",
279
+ "optional": true
280
+ },
281
+ {
282
+ "id": "invalidResponse",
283
+ "field": "invalidResponse",
284
+ "optional": true
285
+ },
286
+ {
287
+ "id": "defect",
288
+ "field": "defect",
289
+ "optional": true
290
+ }
291
+ ],
292
+ "inputSchema": {
293
+ "additionalProperties": false,
294
+ "description": "ScanItemsInput selects one bounded page of table items.",
295
+ "properties": {
296
+ "exclusiveStartKey": {
297
+ "additionalProperties": {},
298
+ "description": "ExclusiveStartKey resumes from a prior page's LastEvaluatedKey; nil starts at the beginning.",
299
+ "type": "object"
300
+ },
301
+ "limit": {
302
+ "description": "Limit bounds evaluated items, 1 to 1000; zero uses DynamoDB's page limit.",
303
+ "type": "integer"
304
+ },
305
+ "tableName": {
306
+ "description": "TableName identifies the table in the configured Region.",
307
+ "type": "string"
308
+ }
309
+ },
310
+ "required": [
311
+ "tableName"
312
+ ],
313
+ "type": "object"
314
+ }
74
315
  }
75
316
  ]
76
317
  }
@@ -0,0 +1,276 @@
1
+ // src/generated/models.ts
2
+ import { z } from "zod";
3
+ import { SecretString } from "@superdurable/connectors-sdk";
4
+ var ConfigSchema = z.object({
5
+ "region": z.string().optional(),
6
+ "endpoint": z.string().optional(),
7
+ "timeoutMs": z.number().int().optional(),
8
+ "maxResponseBytes": z.number().int().optional()
9
+ });
10
+ var CredentialMaterialError = class extends TypeError {
11
+ constructor(message) {
12
+ super(message);
13
+ this.name = "CredentialMaterialError";
14
+ }
15
+ };
16
+ var sdkCredentialDecodingFailureMessages = /* @__PURE__ */ new Set([
17
+ "project credential decoding failed",
18
+ "shared project credential decoding failed",
19
+ "project credential decoding failed: this connector version does not support shared credentials"
20
+ ]);
21
+ function isCredentialMaterialError(error) {
22
+ return error instanceof CredentialMaterialError || error instanceof TypeError && sdkCredentialDecodingFailureMessages.has(error.message);
23
+ }
24
+ function decodeCredentials(value) {
25
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new CredentialMaterialError("credential fields are invalid");
26
+ const fields = value;
27
+ const allowed = /* @__PURE__ */ new Set(["access_key_id", "secret_access_key", "session_token"]);
28
+ if (Object.keys(fields).some((key) => !allowed.has(key))) throw new CredentialMaterialError("stored credential does not match the connector credential fields");
29
+ if (fields["access_key_id"] != null && !(typeof fields["access_key_id"] === "string")) throw new CredentialMaterialError("credential access_key_id has an invalid type");
30
+ if (fields["secret_access_key"] != null && !(typeof fields["secret_access_key"] === "string")) throw new CredentialMaterialError("credential secret_access_key has an invalid type");
31
+ if (fields["session_token"] != null && !(typeof fields["session_token"] === "string")) throw new CredentialMaterialError("credential session_token has an invalid type");
32
+ const credentials = {};
33
+ if (!fields["access_key_id"]) throw new CredentialMaterialError("credential access_key_id is required");
34
+ credentials.accessKeyId = new SecretString(fields["access_key_id"] ?? "");
35
+ if (!fields["secret_access_key"]) throw new CredentialMaterialError("credential secret_access_key is required");
36
+ credentials.secretAccessKey = new SecretString(fields["secret_access_key"] ?? "");
37
+ credentials.sessionToken = new SecretString(fields["session_token"] ?? "");
38
+ return credentials;
39
+ }
40
+ var GetItemInputSchema = z.strictObject({
41
+ "tableName": z.string(),
42
+ "key": z.record(z.string(), z.unknown().nullable()).nullable(),
43
+ "consistentRead": z.boolean()
44
+ });
45
+ var ItemResultSchema = z.strictObject({
46
+ "exists": z.boolean(),
47
+ "item": z.record(z.string(), z.unknown().nullable()).nullable()
48
+ });
49
+ var PutItemInputSchema = z.strictObject({
50
+ "tableName": z.string(),
51
+ "item": z.record(z.string(), z.unknown().nullable()).nullable()
52
+ });
53
+ var ItemWriteResultSchema = z.strictObject({
54
+ "applied": z.boolean()
55
+ });
56
+ var UpdateItemInputSchema = z.strictObject({
57
+ "tableName": z.string(),
58
+ "key": z.record(z.string(), z.unknown().nullable()).nullable(),
59
+ "attributes": z.record(z.string(), z.unknown().nullable()).nullable()
60
+ });
61
+ var DeleteItemInputSchema = z.strictObject({
62
+ "tableName": z.string(),
63
+ "key": z.record(z.string(), z.unknown().nullable()).nullable()
64
+ });
65
+ var ScanItemsInputSchema = z.strictObject({
66
+ "tableName": z.string(),
67
+ "limit": z.number().int().optional(),
68
+ "exclusiveStartKey": z.record(z.string(), z.unknown().nullable()).optional()
69
+ });
70
+ var ItemPageSchema = z.strictObject({
71
+ "items": z.array(z.record(z.string(), z.unknown().nullable()).nullable()).nullable(),
72
+ "count": z.number().int(),
73
+ "lastEvaluatedKey": z.record(z.string(), z.unknown().nullable()).nullable()
74
+ });
75
+
76
+ // src/generated/definitions.ts
77
+ var ConnectorID = "amazon-dynamodb";
78
+ var ProviderID = "amazon-dynamodb";
79
+ var GetItemBranch = {
80
+ Found: "found",
81
+ Missing: "missing",
82
+ ProviderRejected: "providerRejected",
83
+ InvalidResponse: "invalidResponse",
84
+ Defect: "defect"
85
+ };
86
+ var GetItemBranchFound = GetItemBranch.Found;
87
+ var GetItemBranchMissing = GetItemBranch.Missing;
88
+ var GetItemBranchProviderRejected = GetItemBranch.ProviderRejected;
89
+ var GetItemBranchInvalidResponse = GetItemBranch.InvalidResponse;
90
+ var GetItemBranchDefect = GetItemBranch.Defect;
91
+ var GetItemDefinition = {
92
+ operation: { connectorId: ConnectorID, operationId: "getItem" },
93
+ branches: [
94
+ { id: "found", description: "DynamoDB returned the item." },
95
+ { id: "missing", description: "The table has no item with that key.", optional: true },
96
+ { id: "providerRejected", description: "DynamoDB conclusively rejected the request or credentials.", optional: true },
97
+ { id: "invalidResponse", description: "DynamoDB returned malformed or oversized item JSON.", optional: true },
98
+ { id: "defect", description: "The table, key, endpoint, Region, or credentials are invalid.", optional: true }
99
+ ],
100
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
101
+ };
102
+ var GetItemMetadata = { kind: "query", idempotency: "none", authorization: "required" };
103
+ var PutItemBranch = {
104
+ Written: "written",
105
+ ProviderRejected: "providerRejected",
106
+ InvalidResponse: "invalidResponse",
107
+ Defect: "defect"
108
+ };
109
+ var PutItemBranchWritten = PutItemBranch.Written;
110
+ var PutItemBranchProviderRejected = PutItemBranch.ProviderRejected;
111
+ var PutItemBranchInvalidResponse = PutItemBranch.InvalidResponse;
112
+ var PutItemBranchDefect = PutItemBranch.Defect;
113
+ var PutItemDefinition = {
114
+ operation: { connectorId: ConnectorID, operationId: "putItem" },
115
+ branches: [
116
+ { id: "written", description: "DynamoDB accepted the item replacement." },
117
+ { id: "providerRejected", description: "DynamoDB conclusively rejected the write or credentials.", optional: true },
118
+ { id: "invalidResponse", description: "DynamoDB returned malformed or oversized write JSON.", optional: true },
119
+ { id: "defect", description: "The table or item is invalid.", optional: true }
120
+ ],
121
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" },
122
+ repeatOnUnknown: "safe"
123
+ };
124
+ var PutItemMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
125
+ var UpdateItemBranch = {
126
+ Updated: "updated",
127
+ ProviderRejected: "providerRejected",
128
+ InvalidResponse: "invalidResponse",
129
+ Defect: "defect"
130
+ };
131
+ var UpdateItemBranchUpdated = UpdateItemBranch.Updated;
132
+ var UpdateItemBranchProviderRejected = UpdateItemBranch.ProviderRejected;
133
+ var UpdateItemBranchInvalidResponse = UpdateItemBranch.InvalidResponse;
134
+ var UpdateItemBranchDefect = UpdateItemBranch.Defect;
135
+ var UpdateItemDefinition = {
136
+ operation: { connectorId: ConnectorID, operationId: "updateItem" },
137
+ branches: [
138
+ { id: "updated", description: "DynamoDB accepted the absolute attribute update." },
139
+ { id: "providerRejected", description: "DynamoDB conclusively rejected the update or credentials.", optional: true },
140
+ { id: "invalidResponse", description: "DynamoDB returned malformed or oversized update JSON.", optional: true },
141
+ { id: "defect", description: "The table, key, or attributes are invalid.", optional: true }
142
+ ],
143
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" },
144
+ repeatOnUnknown: "safe"
145
+ };
146
+ var UpdateItemMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
147
+ var DeleteItemBranch = {
148
+ Deleted: "deleted",
149
+ ProviderRejected: "providerRejected",
150
+ InvalidResponse: "invalidResponse",
151
+ Defect: "defect"
152
+ };
153
+ var DeleteItemBranchDeleted = DeleteItemBranch.Deleted;
154
+ var DeleteItemBranchProviderRejected = DeleteItemBranch.ProviderRejected;
155
+ var DeleteItemBranchInvalidResponse = DeleteItemBranch.InvalidResponse;
156
+ var DeleteItemBranchDefect = DeleteItemBranch.Defect;
157
+ var DeleteItemDefinition = {
158
+ operation: { connectorId: ConnectorID, operationId: "deleteItem" },
159
+ branches: [
160
+ { id: "deleted", description: "DynamoDB accepted the deletion." },
161
+ { id: "providerRejected", description: "DynamoDB conclusively rejected the deletion or credentials.", optional: true },
162
+ { id: "invalidResponse", description: "DynamoDB returned malformed or oversized deletion JSON.", optional: true },
163
+ { id: "defect", description: "The table or key is invalid.", optional: true }
164
+ ],
165
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" },
166
+ repeatOnUnknown: "safe"
167
+ };
168
+ var DeleteItemMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
169
+ var ScanItemsBranch = {
170
+ Scanned: "scanned",
171
+ ProviderRejected: "providerRejected",
172
+ InvalidResponse: "invalidResponse",
173
+ Defect: "defect"
174
+ };
175
+ var ScanItemsBranchScanned = ScanItemsBranch.Scanned;
176
+ var ScanItemsBranchProviderRejected = ScanItemsBranch.ProviderRejected;
177
+ var ScanItemsBranchInvalidResponse = ScanItemsBranch.InvalidResponse;
178
+ var ScanItemsBranchDefect = ScanItemsBranch.Defect;
179
+ var ScanItemsDefinition = {
180
+ operation: { connectorId: ConnectorID, operationId: "scanItems" },
181
+ branches: [
182
+ { id: "scanned", description: "DynamoDB returned an item page, possibly empty." },
183
+ { id: "providerRejected", description: "DynamoDB conclusively rejected the scan or credentials.", optional: true },
184
+ { id: "invalidResponse", description: "DynamoDB returned malformed or oversized page JSON.", optional: true },
185
+ { id: "defect", description: "The table, limit, or continuation key is invalid.", optional: true }
186
+ ],
187
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
188
+ };
189
+ var ScanItemsMetadata = { kind: "query", idempotency: "none", authorization: "required" };
190
+
191
+ // src/generated/connection.ts
192
+ import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
193
+ var Connection = class {
194
+ /** Stable provider and connection name. */
195
+ reference;
196
+ /** Bound provider operations. */
197
+ operations;
198
+ /** Validate a reference and bind operations. */
199
+ constructor(reference, operations) {
200
+ this.reference = ConnectionRefSchema.parse(reference);
201
+ if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
202
+ if (!operations) throw new TypeError("connector operations are required");
203
+ this.operations = operations;
204
+ }
205
+ };
206
+ function newConnection(client, reference) {
207
+ if (!client) throw new TypeError("connector client is required");
208
+ return new Connection(reference, client);
209
+ }
210
+ function newConnectionWithOperations(operations, reference) {
211
+ return new Connection(reference, operations);
212
+ }
213
+ function newProjectConnection(project, connectionName, createClient) {
214
+ if (!project) throw new TypeError("loaded project is required");
215
+ const reference = ConnectionRefSchema.parse({ provider: ProviderID, name: connectionName });
216
+ const selected = project.configuration.connections.find((entry) => entry.connectorId === ConnectorID && entry.connectionName === connectionName);
217
+ if (!selected || selected.provider !== ProviderID) throw new TypeError("project connection is not configured");
218
+ return newConnection(createClient(project, connectionName), reference);
219
+ }
220
+
221
+ export {
222
+ ConfigSchema,
223
+ CredentialMaterialError,
224
+ isCredentialMaterialError,
225
+ decodeCredentials,
226
+ GetItemInputSchema,
227
+ ItemResultSchema,
228
+ PutItemInputSchema,
229
+ ItemWriteResultSchema,
230
+ UpdateItemInputSchema,
231
+ DeleteItemInputSchema,
232
+ ScanItemsInputSchema,
233
+ ItemPageSchema,
234
+ ConnectorID,
235
+ ProviderID,
236
+ GetItemBranch,
237
+ GetItemBranchFound,
238
+ GetItemBranchMissing,
239
+ GetItemBranchProviderRejected,
240
+ GetItemBranchInvalidResponse,
241
+ GetItemBranchDefect,
242
+ GetItemDefinition,
243
+ GetItemMetadata,
244
+ PutItemBranch,
245
+ PutItemBranchWritten,
246
+ PutItemBranchProviderRejected,
247
+ PutItemBranchInvalidResponse,
248
+ PutItemBranchDefect,
249
+ PutItemDefinition,
250
+ PutItemMetadata,
251
+ UpdateItemBranch,
252
+ UpdateItemBranchUpdated,
253
+ UpdateItemBranchProviderRejected,
254
+ UpdateItemBranchInvalidResponse,
255
+ UpdateItemBranchDefect,
256
+ UpdateItemDefinition,
257
+ UpdateItemMetadata,
258
+ DeleteItemBranch,
259
+ DeleteItemBranchDeleted,
260
+ DeleteItemBranchProviderRejected,
261
+ DeleteItemBranchInvalidResponse,
262
+ DeleteItemBranchDefect,
263
+ DeleteItemDefinition,
264
+ DeleteItemMetadata,
265
+ ScanItemsBranch,
266
+ ScanItemsBranchScanned,
267
+ ScanItemsBranchProviderRejected,
268
+ ScanItemsBranchInvalidResponse,
269
+ ScanItemsBranchDefect,
270
+ ScanItemsDefinition,
271
+ ScanItemsMetadata,
272
+ Connection,
273
+ newConnection,
274
+ newConnectionWithOperations,
275
+ newProjectConnection
276
+ };