@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/dist/mock.js CHANGED
@@ -1,13 +1,23 @@
1
1
  import {
2
+ DeleteItemDefinition,
3
+ DeleteItemInputSchema,
2
4
  GetItemDefinition,
3
5
  GetItemInputSchema,
6
+ ItemPageSchema,
4
7
  ItemResultSchema,
8
+ ItemWriteResultSchema,
5
9
  ProviderID,
10
+ PutItemDefinition,
11
+ PutItemInputSchema,
12
+ ScanItemsDefinition,
13
+ ScanItemsInputSchema,
14
+ UpdateItemDefinition,
15
+ UpdateItemInputSchema,
6
16
  newConnectionWithOperations
7
- } from "./chunk-JOLOQV45.js";
17
+ } from "./chunk-NNCKP6U7.js";
8
18
 
9
19
  // src/generated/mock.ts
10
- import { branchCase, retryCase, newQuery } from "@superdurable/connectors-sdk/connectormock";
20
+ import { branchCase, retryCase, newMutation, newQuery } from "@superdurable/connectors-sdk/connectormock";
11
21
  var emptyGetItemInput = GetItemInputSchema.parse({
12
22
  "tableName": "",
13
23
  "key": {},
@@ -17,6 +27,30 @@ var emptyItemResult = ItemResultSchema.parse({
17
27
  "exists": false,
18
28
  "item": {}
19
29
  });
30
+ var emptyPutItemInput = PutItemInputSchema.parse({
31
+ "tableName": "",
32
+ "item": {}
33
+ });
34
+ var emptyItemWriteResult = ItemWriteResultSchema.parse({
35
+ "applied": false
36
+ });
37
+ var emptyUpdateItemInput = UpdateItemInputSchema.parse({
38
+ "tableName": "",
39
+ "key": {},
40
+ "attributes": {}
41
+ });
42
+ var emptyDeleteItemInput = DeleteItemInputSchema.parse({
43
+ "tableName": "",
44
+ "key": {}
45
+ });
46
+ var emptyScanItemsInput = ScanItemsInputSchema.parse({
47
+ "tableName": ""
48
+ });
49
+ var emptyItemPage = ItemPageSchema.parse({
50
+ "items": [],
51
+ "count": 0,
52
+ "lastEvaluatedKey": {}
53
+ });
20
54
  function getItemFound(value, failure) {
21
55
  return branchCase("found", value, failure);
22
56
  }
@@ -42,11 +76,107 @@ function getItemFoundDefault() {
42
76
  function getItemDefault() {
43
77
  return getItemFoundDefault();
44
78
  }
79
+ function putItemWritten(value, failure) {
80
+ return branchCase("written", value, failure);
81
+ }
82
+ function putItemProviderRejected(value, failure) {
83
+ return branchCase("providerRejected", value, failure);
84
+ }
85
+ function putItemInvalidResponse(value, failure) {
86
+ return branchCase("invalidResponse", value, failure);
87
+ }
88
+ function putItemDefect(value, failure) {
89
+ return branchCase("defect", value, failure);
90
+ }
91
+ function putItemRetry(failure, retryAfterMs = 0) {
92
+ return retryCase(failure, retryAfterMs);
93
+ }
94
+ function putItemWrittenDefault() {
95
+ const value = ItemWriteResultSchema.parse({ "applied": true });
96
+ return branchCase("written", value);
97
+ }
98
+ function putItemDefault() {
99
+ return putItemWrittenDefault();
100
+ }
101
+ function updateItemUpdated(value, failure) {
102
+ return branchCase("updated", value, failure);
103
+ }
104
+ function updateItemProviderRejected(value, failure) {
105
+ return branchCase("providerRejected", value, failure);
106
+ }
107
+ function updateItemInvalidResponse(value, failure) {
108
+ return branchCase("invalidResponse", value, failure);
109
+ }
110
+ function updateItemDefect(value, failure) {
111
+ return branchCase("defect", value, failure);
112
+ }
113
+ function updateItemRetry(failure, retryAfterMs = 0) {
114
+ return retryCase(failure, retryAfterMs);
115
+ }
116
+ function updateItemUpdatedDefault() {
117
+ const value = ItemWriteResultSchema.parse({ "applied": true });
118
+ return branchCase("updated", value);
119
+ }
120
+ function updateItemDefault() {
121
+ return updateItemUpdatedDefault();
122
+ }
123
+ function deleteItemDeleted(value, failure) {
124
+ return branchCase("deleted", value, failure);
125
+ }
126
+ function deleteItemProviderRejected(value, failure) {
127
+ return branchCase("providerRejected", value, failure);
128
+ }
129
+ function deleteItemInvalidResponse(value, failure) {
130
+ return branchCase("invalidResponse", value, failure);
131
+ }
132
+ function deleteItemDefect(value, failure) {
133
+ return branchCase("defect", value, failure);
134
+ }
135
+ function deleteItemRetry(failure, retryAfterMs = 0) {
136
+ return retryCase(failure, retryAfterMs);
137
+ }
138
+ function deleteItemDeletedDefault() {
139
+ const value = ItemWriteResultSchema.parse({ "applied": true });
140
+ return branchCase("deleted", value);
141
+ }
142
+ function deleteItemDefault() {
143
+ return deleteItemDeletedDefault();
144
+ }
145
+ function scanItemsScanned(value, failure) {
146
+ return branchCase("scanned", value, failure);
147
+ }
148
+ function scanItemsProviderRejected(value, failure) {
149
+ return branchCase("providerRejected", value, failure);
150
+ }
151
+ function scanItemsInvalidResponse(value, failure) {
152
+ return branchCase("invalidResponse", value, failure);
153
+ }
154
+ function scanItemsDefect(value, failure) {
155
+ return branchCase("defect", value, failure);
156
+ }
157
+ function scanItemsRetry(failure, retryAfterMs = 0) {
158
+ return retryCase(failure, retryAfterMs);
159
+ }
160
+ function scanItemsScannedDefault() {
161
+ const value = ItemPageSchema.parse({ "count": 1, "items": [{ "pk": { "S": "example" } }], "lastEvaluatedKey": {} });
162
+ return branchCase("scanned", value);
163
+ }
164
+ function scanItemsDefault() {
165
+ return scanItemsScannedDefault();
166
+ }
45
167
  var GeneratedMock = class {
46
168
  #getItem;
169
+ #putItem;
170
+ #updateItem;
171
+ #deleteItem;
172
+ #scanItems;
47
173
  #connection;
48
174
  constructor(connectionName) {
49
175
  this.#getItem = newQuery(GetItemDefinition).default(getItemDefault());
176
+ this.#putItem = newMutation(PutItemDefinition).default(putItemDefault());
177
+ this.#updateItem = newMutation(UpdateItemDefinition).default(updateItemDefault());
178
+ this.#deleteItem = newMutation(DeleteItemDefinition).default(deleteItemDefault());
179
+ this.#scanItems = newQuery(ScanItemsDefinition).default(scanItemsDefault());
50
180
  this.#connection = newConnectionWithOperations(this, { provider: ProviderID, name: connectionName });
51
181
  }
52
182
  connection() {
@@ -55,15 +185,44 @@ var GeneratedMock = class {
55
185
  getItem() {
56
186
  return this.#getItem;
57
187
  }
188
+ putItem() {
189
+ return this.#putItem;
190
+ }
191
+ updateItem() {
192
+ return this.#updateItem;
193
+ }
194
+ deleteItem() {
195
+ return this.#deleteItem;
196
+ }
197
+ scanItems() {
198
+ return this.#scanItems;
199
+ }
58
200
  assertNoFailures() {
59
201
  this.#getItem.assertNoFailures();
202
+ this.#putItem.assertNoFailures();
203
+ this.#updateItem.assertNoFailures();
204
+ this.#deleteItem.assertNoFailures();
205
+ this.#scanItems.assertNoFailures();
60
206
  }
61
207
  };
62
208
  export {
63
209
  GeneratedMock,
64
210
  GeneratedMock as Mock,
211
+ deleteItemDefault,
212
+ deleteItemDefect,
213
+ deleteItemDeleted,
214
+ deleteItemDeletedDefault,
215
+ deleteItemInvalidResponse,
216
+ deleteItemProviderRejected,
217
+ deleteItemRetry,
218
+ emptyDeleteItemInput,
65
219
  emptyGetItemInput,
220
+ emptyItemPage,
66
221
  emptyItemResult,
222
+ emptyItemWriteResult,
223
+ emptyPutItemInput,
224
+ emptyScanItemsInput,
225
+ emptyUpdateItemInput,
67
226
  getItemDefault,
68
227
  getItemDefect,
69
228
  getItemFound,
@@ -71,5 +230,26 @@ export {
71
230
  getItemInvalidResponse,
72
231
  getItemMissing,
73
232
  getItemProviderRejected,
74
- getItemRetry
233
+ getItemRetry,
234
+ putItemDefault,
235
+ putItemDefect,
236
+ putItemInvalidResponse,
237
+ putItemProviderRejected,
238
+ putItemRetry,
239
+ putItemWritten,
240
+ putItemWrittenDefault,
241
+ scanItemsDefault,
242
+ scanItemsDefect,
243
+ scanItemsInvalidResponse,
244
+ scanItemsProviderRejected,
245
+ scanItemsRetry,
246
+ scanItemsScanned,
247
+ scanItemsScannedDefault,
248
+ updateItemDefault,
249
+ updateItemDefect,
250
+ updateItemInvalidResponse,
251
+ updateItemProviderRejected,
252
+ updateItemRetry,
253
+ updateItemUpdated,
254
+ updateItemUpdatedDefault
75
255
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdurable/connector-amazon-dynamodb",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "license": "MIT",
5
5
  "description": "Amazon DynamoDB connector for Dex TypeScript applications",
6
6
  "repository": {
@@ -43,7 +43,7 @@
43
43
  "check": "npm run typecheck && npm run lint && npm test && npm run build"
44
44
  },
45
45
  "dependencies": {
46
- "@superdurable/connectors-sdk": "0.1.1",
46
+ "@superdurable/connectors-sdk": "0.12.0",
47
47
  "@superdurable/dex": ">=1.28.0",
48
48
  "zod": "^4.1.0"
49
49
  },
@@ -1,113 +0,0 @@
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
- function decodeCredentials(value) {
11
- if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("credential fields are invalid");
12
- const fields = value;
13
- const allowed = /* @__PURE__ */ new Set(["access_key_id", "secret_access_key", "session_token"]);
14
- if (Object.keys(fields).some((key) => !allowed.has(key))) throw new TypeError("stored credential does not match the connector credential fields");
15
- if (fields["access_key_id"] != null && !(typeof fields["access_key_id"] === "string")) throw new TypeError("credential access_key_id has an invalid type");
16
- if (fields["secret_access_key"] != null && !(typeof fields["secret_access_key"] === "string")) throw new TypeError("credential secret_access_key has an invalid type");
17
- if (fields["session_token"] != null && !(typeof fields["session_token"] === "string")) throw new TypeError("credential session_token has an invalid type");
18
- const credentials = {};
19
- if (!fields["access_key_id"]) throw new TypeError("credential access_key_id is required");
20
- credentials.accessKeyId = new SecretString(fields["access_key_id"] ?? "");
21
- if (!fields["secret_access_key"]) throw new TypeError("credential secret_access_key is required");
22
- credentials.secretAccessKey = new SecretString(fields["secret_access_key"] ?? "");
23
- credentials.sessionToken = new SecretString(fields["session_token"] ?? "");
24
- return credentials;
25
- }
26
- var GetItemInputSchema = z.strictObject({
27
- "tableName": z.string(),
28
- "key": z.record(z.string(), z.unknown().nullable()).nullable(),
29
- "consistentRead": z.boolean()
30
- });
31
- var ItemResultSchema = z.strictObject({
32
- "exists": z.boolean(),
33
- "item": z.record(z.string(), z.unknown().nullable()).nullable()
34
- });
35
-
36
- // src/generated/definitions.ts
37
- var ConnectorID = "amazon-dynamodb";
38
- var ProviderID = "amazon-dynamodb";
39
- var GetItemBranch = {
40
- Found: "found",
41
- Missing: "missing",
42
- ProviderRejected: "providerRejected",
43
- InvalidResponse: "invalidResponse",
44
- Defect: "defect"
45
- };
46
- var GetItemBranchFound = GetItemBranch.Found;
47
- var GetItemBranchMissing = GetItemBranch.Missing;
48
- var GetItemBranchProviderRejected = GetItemBranch.ProviderRejected;
49
- var GetItemBranchInvalidResponse = GetItemBranch.InvalidResponse;
50
- var GetItemBranchDefect = GetItemBranch.Defect;
51
- var GetItemDefinition = {
52
- operation: { connectorId: ConnectorID, operationId: "getItem" },
53
- branches: [
54
- { id: "found", description: "DynamoDB returned the item." },
55
- { id: "missing", description: "The table has no item with that key.", optional: true },
56
- { id: "providerRejected", description: "DynamoDB conclusively rejected the request or credentials.", optional: true },
57
- { id: "invalidResponse", description: "DynamoDB returned malformed or oversized item JSON.", optional: true },
58
- { id: "defect", description: "The table, key, endpoint, Region, or credentials are invalid.", optional: true }
59
- ],
60
- stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
61
- };
62
- var GetItemMetadata = { kind: "query", idempotency: "none", authorization: "required" };
63
-
64
- // src/generated/connection.ts
65
- import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
66
- var Connection = class {
67
- /** Stable provider and connection name. */
68
- reference;
69
- /** Bound provider operations. */
70
- operations;
71
- /** Validate a reference and bind operations. */
72
- constructor(reference, operations) {
73
- this.reference = ConnectionRefSchema.parse(reference);
74
- if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
75
- if (!operations) throw new TypeError("connector operations are required");
76
- this.operations = operations;
77
- }
78
- };
79
- function newConnection(client, reference) {
80
- if (!client) throw new TypeError("connector client is required");
81
- return new Connection(reference, client);
82
- }
83
- function newConnectionWithOperations(operations, reference) {
84
- return new Connection(reference, operations);
85
- }
86
- function newProjectConnection(project, connectionName, createClient) {
87
- if (!project) throw new TypeError("loaded project is required");
88
- const reference = ConnectionRefSchema.parse({ provider: ProviderID, name: connectionName });
89
- const selected = project.configuration.connections.find((entry) => entry.connectorId === ConnectorID && entry.connectionName === connectionName);
90
- if (!selected || selected.provider !== ProviderID) throw new TypeError("project connection is not configured");
91
- return newConnection(createClient(project, connectionName), reference);
92
- }
93
-
94
- export {
95
- ConfigSchema,
96
- decodeCredentials,
97
- GetItemInputSchema,
98
- ItemResultSchema,
99
- ConnectorID,
100
- ProviderID,
101
- GetItemBranch,
102
- GetItemBranchFound,
103
- GetItemBranchMissing,
104
- GetItemBranchProviderRejected,
105
- GetItemBranchInvalidResponse,
106
- GetItemBranchDefect,
107
- GetItemDefinition,
108
- GetItemMetadata,
109
- Connection,
110
- newConnection,
111
- newConnectionWithOperations,
112
- newProjectConnection
113
- };
@@ -1,81 +0,0 @@
1
- import { SecretString, CredentialProvider, Query, ConnectionRef } from '@superdurable/connectors-sdk';
2
- import { z } from 'zod';
3
-
4
- /** Connector configuration; omitted fields use manifest defaults. */
5
- interface Config {
6
- /** AWS Region code for the table, such as eu-west-1. In https://console.aws.amazon.com/dynamodb > Tables, use the console Region selector; blank uses the displayed default. */
7
- region?: string;
8
- /** Optional DynamoDB-compatible API root. Blank derives the regional AWS endpoint from region. Override only for a trusted compatible endpoint; local tests may use loopback HTTP. */
9
- endpoint?: string;
10
- /** Maximum duration of one GetItem request as a positive Go duration such as 15s. Blank uses the displayed default; increase only for a slow network. Runtime value in milliseconds. */
11
- timeoutMs?: number;
12
- /** Maximum complete item response in bytes. Blank uses the displayed default; increase only for unusually large items. */
13
- maxResponseBytes?: number;
14
- }
15
- /** Runtime schema for manifest configuration. */
16
- declare const ConfigSchema: z.ZodObject<{
17
- region: z.ZodOptional<z.ZodString>;
18
- endpoint: z.ZodOptional<z.ZodString>;
19
- timeoutMs: z.ZodOptional<z.ZodNumber>;
20
- maxResponseBytes: z.ZodOptional<z.ZodNumber>;
21
- }, z.core.$strip>;
22
- /** Private connector credentials resolved by the host. */
23
- interface Credentials {
24
- /** Secret-stored AWS access key ID from https://console.aws.amazon.com/iam > Users > selected user > Security credentials > Access keys > Create access key. Long-term IDs start AKIA and temporary IDs start ASIA. Blank prevents signing. */
25
- accessKeyId: SecretString;
26
- /** Secret access key paired with access_key_id, shown once on the IAM Retrieve access keys page. Copy the Value, never the key ID. Blank prevents signing; rotate through IAM. */
27
- secretAccessKey: SecretString;
28
- /** Secret session token for temporary ASIA credentials, from AWS STS. Blank means long-term IAM user credentials. Temporary credentials expire; replace all three fields before expiry. */
29
- sessionToken?: SecretString;
30
- }
31
- /** Decode private credential fields for the connector. */
32
- declare function decodeCredentials(value: unknown): Credentials;
33
- /** Host-owned source of private connector credentials. */
34
- type CredentialSource = CredentialProvider<Credentials>;
35
- /** GetItemInput identifies a table row by all of its S, N, or B key attributes. */
36
- interface GetItemInput {
37
- "tableName": string;
38
- "key": {
39
- [key: string]: unknown | null;
40
- } | null;
41
- "consistentRead": boolean;
42
- }
43
- /** ItemResult returns the item's AttributeValue map when it exists. */
44
- interface ItemResult {
45
- "exists": boolean;
46
- "item": {
47
- [key: string]: unknown | null;
48
- } | null;
49
- }
50
- /** Runtime validator for GetItemInput. */
51
- declare const GetItemInputSchema: z.ZodObject<{
52
- tableName: z.ZodString;
53
- key: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodUnknown>>>;
54
- consistentRead: z.ZodBoolean;
55
- }, z.core.$strict>;
56
- /** Runtime validator for ItemResult. */
57
- declare const ItemResultSchema: z.ZodObject<{
58
- exists: z.ZodBoolean;
59
- item: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodUnknown>>>;
60
- }, z.core.$strict>;
61
-
62
- /** Typed operations supplied by a client or mock. */
63
- interface Operations {
64
- /** Invoke getItem through this connection. */
65
- getItem(): Query<GetItemInput, ItemResult>;
66
- }
67
- /** Named connector connection kept outside Flow state. */
68
- declare class Connection<BoundOperations = Operations> {
69
- /** Stable provider and connection name. */
70
- readonly reference: ConnectionRef;
71
- /** Bound provider operations. */
72
- readonly operations: BoundOperations;
73
- /** Validate a reference and bind operations. */
74
- constructor(reference: ConnectionRef, operations: BoundOperations);
75
- }
76
- /** Bind a client to a named connection. */
77
- declare function newConnection(client: Operations, reference: ConnectionRef): Connection;
78
- /** Bind scripted operations to a named connection. */
79
- declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
80
-
81
- export { Connection as C, type GetItemInput as G, type ItemResult as I, type Operations as O, type Config as a, type Credentials as b, ConfigSchema as c, type CredentialSource as d, GetItemInputSchema as e, ItemResultSchema as f, decodeCredentials as g, newConnectionWithOperations as h, newConnection as n };