@exabugs/dynamodb-client 0.1.1 → 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/CHANGELOG.md +57 -0
- package/README.md +216 -187
- package/dist/client/Collection.d.ts +14 -9
- package/dist/client/Collection.d.ts.map +1 -1
- package/dist/client/Collection.js +3 -9
- package/dist/client/Collection.js.map +1 -1
- package/dist/client/Database.d.ts +1 -3
- package/dist/client/Database.d.ts.map +1 -1
- package/dist/client/Database.js +2 -7
- package/dist/client/Database.js.map +1 -1
- package/dist/client/DynamoClient.d.ts +1 -1
- package/dist/client/DynamoClient.d.ts.map +1 -1
- package/dist/client/DynamoClient.js +2 -5
- package/dist/client/DynamoClient.js.map +1 -1
- package/dist/client/FindCursor.d.ts +1 -3
- package/dist/client/FindCursor.d.ts.map +1 -1
- package/dist/client/FindCursor.js +1 -5
- package/dist/client/FindCursor.js.map +1 -1
- package/dist/client/index.iam.d.ts +1 -1
- package/dist/client/index.iam.d.ts.map +1 -1
- package/dist/client/index.iam.js.map +1 -1
- package/dist/integrations/react-admin/dataProvider.d.ts +0 -1
- package/dist/integrations/react-admin/dataProvider.d.ts.map +1 -1
- package/dist/integrations/react-admin/dataProvider.js +10 -11
- package/dist/integrations/react-admin/dataProvider.js.map +1 -1
- package/dist/integrations/react-admin/types.d.ts +0 -2
- package/dist/integrations/react-admin/types.d.ts.map +1 -1
- package/dist/scripts/generate-shadow-config.d.ts +3 -0
- package/dist/scripts/generate-shadow-config.d.ts.map +1 -0
- package/dist/scripts/generate-shadow-config.js +159 -0
- package/dist/scripts/generate-shadow-config.js.map +1 -0
- package/dist/scripts/repair-shadows.js +1 -1
- package/dist/scripts/repair-shadows.js.map +1 -1
- package/dist/server/handler.cjs +2 -2
- package/dist/shadows/generator.d.ts +14 -3
- package/dist/shadows/generator.d.ts.map +1 -1
- package/dist/shadows/generator.js +19 -0
- package/dist/shadows/generator.js.map +1 -1
- package/dist/shadows/index.d.ts +3 -2
- package/dist/shadows/index.d.ts.map +1 -1
- package/dist/shadows/index.js +1 -1
- package/dist/shadows/index.js.map +1 -1
- package/dist/shadows/schema.d.ts +60 -0
- package/dist/shadows/schema.d.ts.map +1 -0
- package/dist/shadows/schema.js +8 -0
- package/dist/shadows/schema.js.map +1 -0
- package/dist/shadows/types.d.ts +1 -5
- package/dist/shadows/types.d.ts.map +1 -1
- package/package.json +7 -4
- package/terraform/examples/advanced/README.md +0 -129
- package/terraform/examples/advanced/main.tf +0 -158
- package/terraform/examples/advanced/shadow.config.json +0 -35
- package/terraform/examples/advanced/variables.tf +0 -28
- package/terraform/examples/basic/README.md +0 -53
- package/terraform/examples/basic/main.tf +0 -99
- package/terraform/examples/basic/variables.tf +0 -17
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,63 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.2.0] - 2024-12-01
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- **BREAKING**: Removed `databaseName` parameter from all APIs
|
|
15
|
+
- `DynamoClient.db()` no longer requires a database name argument
|
|
16
|
+
- `createDataProvider()` no longer requires `databaseName` option
|
|
17
|
+
- `Database` class no longer stores or uses database name
|
|
18
|
+
- `Collection` and `FindCursor` no longer include database name in requests
|
|
19
|
+
- Simplified architecture: DynamoDB table is 1:1 with Lambda function
|
|
20
|
+
- For multi-tenant use cases, use separate DynamoDB tables instead
|
|
21
|
+
|
|
22
|
+
### Migration Guide
|
|
23
|
+
|
|
24
|
+
**Before (v0.1.x):**
|
|
25
|
+
```typescript
|
|
26
|
+
const client = new DynamoClient(apiUrl);
|
|
27
|
+
await client.connect();
|
|
28
|
+
const db = client.db('myapp');
|
|
29
|
+
const collection = db.collection('users');
|
|
30
|
+
|
|
31
|
+
const dataProvider = createDataProvider({
|
|
32
|
+
apiUrl: 'https://...',
|
|
33
|
+
databaseName: 'myapp',
|
|
34
|
+
tokenProvider,
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**After (v0.2.0):**
|
|
39
|
+
```typescript
|
|
40
|
+
const client = new DynamoClient(apiUrl);
|
|
41
|
+
await client.connect();
|
|
42
|
+
const db = client.db();
|
|
43
|
+
const collection = db.collection('users');
|
|
44
|
+
|
|
45
|
+
const dataProvider = createDataProvider({
|
|
46
|
+
apiUrl: 'https://...',
|
|
47
|
+
tokenProvider,
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## [0.1.2] - 2024-11-30
|
|
52
|
+
|
|
53
|
+
### Added
|
|
54
|
+
|
|
55
|
+
- Boolean type support for shadow fields
|
|
56
|
+
- Added `'boolean'` to `ShadowFieldType`
|
|
57
|
+
- Added `formatBoolean()` function for boolean value formatting
|
|
58
|
+
- Boolean values are formatted as `'true'` or `'false'` strings
|
|
59
|
+
- Full test coverage for boolean shadow records
|
|
60
|
+
|
|
61
|
+
### Changed
|
|
62
|
+
|
|
63
|
+
- Updated `formatFieldValue()` to handle boolean type
|
|
64
|
+
- Updated `generateShadowSK()` to support boolean values
|
|
65
|
+
- Exported `formatBoolean` from shadows module
|
|
66
|
+
|
|
10
67
|
## [0.1.0] - 2024-11-29
|
|
11
68
|
|
|
12
69
|
### Added
|
package/README.md
CHANGED
|
@@ -1,267 +1,296 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# 🚀 DynamoDB Client SDK
|
|
4
|
+
|
|
5
|
+
**MongoDB-like API for DynamoDB with Single-Table Design**
|
|
2
6
|
|
|
3
7
|
[](https://github.com/exabugs/dynamodb-client/actions/workflows/ci.yml)
|
|
8
|
+
[](https://codecov.io/gh/exabugs/dynamodb-client)
|
|
4
9
|
[](https://www.npmjs.com/package/@exabugs/dynamodb-client)
|
|
10
|
+
[](https://opensource.org/licenses/MIT)
|
|
11
|
+
[](https://nodejs.org/)
|
|
5
12
|
|
|
6
|
-
|
|
13
|
+
[Features](#-features) •
|
|
14
|
+
[Installation](#-installation) •
|
|
15
|
+
[Quick Start](#-quick-start) •
|
|
16
|
+
[Documentation](#-documentation) •
|
|
17
|
+
[Contributing](#-contributing)
|
|
7
18
|
|
|
8
|
-
|
|
19
|
+
</div>
|
|
9
20
|
|
|
10
|
-
|
|
11
|
-
- 📦 Single-Table Design with Shadow Records
|
|
12
|
-
- 🔐 Multiple authentication methods (IAM, Cognito, Token)
|
|
13
|
-
- ⚡ Lambda function implementation included
|
|
14
|
-
- 🎨 react-admin integration
|
|
15
|
-
- 📝 TypeScript support
|
|
16
|
-
- 🏗️ Terraform modules for deployment
|
|
21
|
+
---
|
|
17
22
|
|
|
18
|
-
##
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
npm install @exabugs/dynamodb-client
|
|
22
|
-
# or
|
|
23
|
-
pnpm add @exabugs/dynamodb-client
|
|
24
|
-
# or
|
|
25
|
-
yarn add @exabugs/dynamodb-client
|
|
26
|
-
```
|
|
23
|
+
## ✨ Features
|
|
27
24
|
|
|
28
|
-
|
|
25
|
+
<table>
|
|
26
|
+
<tr>
|
|
27
|
+
<td width="50%">
|
|
29
28
|
|
|
30
|
-
###
|
|
29
|
+
### 🎯 Developer Experience
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
- **MongoDB-like API** - Familiar syntax for DynamoDB
|
|
32
|
+
- **TypeScript First** - Full type safety out of the box
|
|
33
|
+
- **Zero Config** - Works with sensible defaults
|
|
34
|
+
- **Terraform Ready** - Infrastructure as Code included
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
});
|
|
36
|
+
</td>
|
|
37
|
+
<td width="50%">
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
const collection = db.collection('articles');
|
|
39
|
+
### ⚡ Performance & Scale
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
- **Single-Table Design** - Optimized data modeling
|
|
42
|
+
- **Shadow Records** - Efficient sorting without GSIs
|
|
43
|
+
- **Lambda Native** - Serverless-first architecture
|
|
44
|
+
- **ARM64 Support** - Cost-optimized compute
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
</td>
|
|
47
|
+
</tr>
|
|
48
|
+
<tr>
|
|
49
|
+
<td width="50%">
|
|
47
50
|
|
|
48
|
-
|
|
49
|
-
await collection.updateOne({ id: article.id }, { $set: { status: 'published' } });
|
|
51
|
+
### 🔐 Authentication
|
|
50
52
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
- **IAM Roles** - Native AWS authentication
|
|
54
|
+
- **Cognito** - User pool integration
|
|
55
|
+
- **Custom Tokens** - Flexible auth strategies
|
|
56
|
+
- **OIDC + PKCE** - Secure browser flows
|
|
54
57
|
|
|
55
|
-
|
|
58
|
+
</td>
|
|
59
|
+
<td width="50%">
|
|
56
60
|
|
|
57
|
-
|
|
58
|
-
import { createHandler } from '@exabugs/dynamodb-client/server/handler';
|
|
61
|
+
### 🎨 Integrations
|
|
59
62
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
});
|
|
64
|
-
```
|
|
63
|
+
- **react-admin** - Admin UI out of the box
|
|
64
|
+
- **REST API** - Lambda Function URLs
|
|
65
|
+
- **Terraform** - Complete IaC modules
|
|
65
66
|
|
|
66
|
-
|
|
67
|
+
</td>
|
|
68
|
+
</tr>
|
|
69
|
+
</table>
|
|
67
70
|
|
|
68
|
-
|
|
69
|
-
- AWS Account (for DynamoDB and Lambda)
|
|
71
|
+
---
|
|
70
72
|
|
|
71
|
-
##
|
|
73
|
+
## 📦 Installation
|
|
72
74
|
|
|
73
75
|
```bash
|
|
74
|
-
#
|
|
75
|
-
npm install
|
|
76
|
+
# npm
|
|
77
|
+
npm install @exabugs/dynamodb-client
|
|
76
78
|
|
|
77
|
-
#
|
|
78
|
-
|
|
79
|
+
# pnpm (recommended)
|
|
80
|
+
pnpm add @exabugs/dynamodb-client
|
|
79
81
|
|
|
80
|
-
#
|
|
81
|
-
|
|
82
|
+
# yarn
|
|
83
|
+
yarn add @exabugs/dynamodb-client
|
|
84
|
+
```
|
|
82
85
|
|
|
83
|
-
|
|
84
|
-
npm run build
|
|
86
|
+
---
|
|
85
87
|
|
|
86
|
-
|
|
87
|
-
npm run lint
|
|
88
|
+
## 🏗️ Architecture
|
|
88
89
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
```mermaid
|
|
91
|
+
graph TB
|
|
92
|
+
subgraph "Client Applications"
|
|
93
|
+
A[React Admin]
|
|
94
|
+
B[Mobile App]
|
|
95
|
+
C[Custom App]
|
|
96
|
+
end
|
|
92
97
|
|
|
93
|
-
|
|
98
|
+
subgraph "AWS Lambda"
|
|
99
|
+
D[Lambda Function<br/>Function URL]
|
|
100
|
+
end
|
|
94
101
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
make deploy-stg # stg環境にデプロイ
|
|
110
|
-
make deploy-prd # prd環境にデプロイ
|
|
111
|
-
|
|
112
|
-
# インフラ操作
|
|
113
|
-
make infra-plan ENV=dev # Terraformプランを表示
|
|
114
|
-
make infra-apply ENV=dev # Terraformを適用
|
|
115
|
-
make infra-status # Terraform状態を表示
|
|
116
|
-
|
|
117
|
-
# Lambda操作
|
|
118
|
-
make invoke-fetch ENV=dev # Fetch Lambdaを実行
|
|
119
|
-
make logs-fetch ENV=dev # Fetch Lambdaのログを表示
|
|
120
|
-
make logs-records ENV=dev # Records Lambdaのログを表示
|
|
121
|
-
|
|
122
|
-
# その他
|
|
123
|
-
make shadow-config # shadow.config.jsonを再生成
|
|
102
|
+
subgraph "AWS DynamoDB"
|
|
103
|
+
E[(DynamoDB<br/>Single Table)]
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
A -->|HTTPS| D
|
|
107
|
+
B -->|HTTPS| D
|
|
108
|
+
C -->|HTTPS| D
|
|
109
|
+
D -->|AWS SDK| E
|
|
110
|
+
|
|
111
|
+
style A fill:#61dafb,stroke:#333,stroke-width:2px
|
|
112
|
+
style B fill:#61dafb,stroke:#333,stroke-width:2px
|
|
113
|
+
style C fill:#61dafb,stroke:#333,stroke-width:2px
|
|
114
|
+
style D fill:#ff9900,stroke:#333,stroke-width:2px
|
|
115
|
+
style E fill:#527fff,stroke:#333,stroke-width:2px
|
|
124
116
|
```
|
|
125
117
|
|
|
126
|
-
|
|
118
|
+
---
|
|
127
119
|
|
|
128
|
-
|
|
120
|
+
## 🚀 Quick Start & Examples
|
|
129
121
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
122
|
+
Get started in 3 steps: **Schema Definition → Deploy Infrastructure → Use Client**
|
|
123
|
+
|
|
124
|
+
### Complete Examples Available
|
|
125
|
+
|
|
126
|
+
We provide complete, working examples for every step:
|
|
127
|
+
|
|
128
|
+
| Example | What You'll Learn | Time |
|
|
129
|
+
| ------------------------------------------ | ---------------------------------------------------- | ------ |
|
|
130
|
+
| **[Schema](./examples/schema/)** | Define TypeScript schemas and generate shadow config | 5 min |
|
|
131
|
+
| **[Terraform](./examples/terraform/)** | Deploy Lambda + DynamoDB + Cognito to AWS | 10 min |
|
|
132
|
+
| **[Client](./examples/client/)** | Node.js CRUD operations with MongoDB-like API | 10 min |
|
|
133
|
+
| **[React Admin](./examples/react-admin/)** | Build complete admin UI with authentication | 15 min |
|
|
134
|
+
|
|
135
|
+
### Quick Example
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
// 1. Define schema
|
|
139
|
+
export const MySchema: SchemaRegistryConfig = {
|
|
140
|
+
database: {
|
|
141
|
+
timestamps: {
|
|
142
|
+
createdAt: 'createdAt',
|
|
143
|
+
updatedAt: 'updatedAt',
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
resources: {
|
|
147
|
+
articles: {
|
|
148
|
+
resource: 'articles',
|
|
149
|
+
type: {} as Article,
|
|
150
|
+
shadows: { sortableFields: { title: { type: 'string' } } },
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// 2. Deploy with Terraform (see examples/terraform/)
|
|
156
|
+
// terraform apply
|
|
157
|
+
|
|
158
|
+
// 3. Use the client
|
|
159
|
+
const client = new DynamoClient(FUNCTION_URL);
|
|
160
|
+
const articles = client.db().collection('articles');
|
|
161
|
+
|
|
162
|
+
await articles.insertOne({ title: 'Hello DynamoDB' });
|
|
163
|
+
const article = await articles.findOne({ title: 'Hello DynamoDB' });
|
|
145
164
|
```
|
|
146
165
|
|
|
147
|
-
|
|
166
|
+
### 📚 Full Documentation
|
|
148
167
|
|
|
149
|
-
|
|
168
|
+
👉 **[Complete Examples Guide →](./examples/)** - Step-by-step tutorials with full source code
|
|
150
169
|
|
|
151
|
-
|
|
170
|
+
Each example includes:
|
|
152
171
|
|
|
153
|
-
|
|
172
|
+
- ✅ Complete source code
|
|
173
|
+
- ✅ Step-by-step instructions
|
|
174
|
+
- ✅ Terraform integration
|
|
175
|
+
- ✅ Configuration templates
|
|
154
176
|
|
|
155
|
-
|
|
177
|
+
---
|
|
156
178
|
|
|
157
|
-
|
|
158
|
-
.
|
|
159
|
-
├── apps/ # アプリケーション (Admin UI, Mobile App)
|
|
160
|
-
├── functions/ # Lambda関数 (Fetch, Pipeline, Maintenance)
|
|
161
|
-
├── packages/ # 共有ライブラリ (core, shadows, graphql-types)
|
|
162
|
-
│ └── core/ # Records Lambda(サーバー実装)を含む
|
|
163
|
-
└── infra/ # Terraform設定
|
|
164
|
-
```
|
|
179
|
+
## 📚 Documentation
|
|
165
180
|
|
|
166
|
-
|
|
181
|
+
### Available Documentation
|
|
167
182
|
|
|
168
|
-
|
|
183
|
+
- **[Architecture](docs/ARCHITECTURE.md)** - System architecture and design
|
|
184
|
+
- **[Client Usage](docs/CLIENT_USAGE.md)** - Client-side API guide
|
|
185
|
+
- **[React Admin Integration](docs/react-admin-integration.md)** - Admin UI setup
|
|
186
|
+
- **[Deployment](docs/DEPLOYMENT.md)** - Production deployment guide
|
|
187
|
+
- **[Terraform Modules](terraform/README.md)** - Infrastructure as Code
|
|
169
188
|
|
|
170
|
-
###
|
|
189
|
+
### GitHub Actions
|
|
171
190
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
pnpm --filter @ainews/admin dev
|
|
191
|
+
- **[GitHub Actions Setup](docs/GITHUB_ACTIONS_SETUP.md)** - CI/CD configuration
|
|
192
|
+
- **[Troubleshooting](docs/GITHUB_ACTIONS_TROUBLESHOOTING.md)** - Common issues and solutions
|
|
175
193
|
|
|
176
|
-
|
|
177
|
-
```
|
|
194
|
+
---
|
|
178
195
|
|
|
179
|
-
|
|
196
|
+
## 🛠️ Development
|
|
197
|
+
|
|
198
|
+
### Prerequisites
|
|
199
|
+
|
|
200
|
+
- Node.js >= 18.0.0
|
|
201
|
+
- npm, pnpm, or yarn
|
|
202
|
+
- AWS Account (for deployment)
|
|
180
203
|
|
|
181
|
-
|
|
204
|
+
### Setup
|
|
182
205
|
|
|
183
206
|
```bash
|
|
184
|
-
#
|
|
185
|
-
|
|
207
|
+
# Clone repository
|
|
208
|
+
git clone https://github.com/exabugs/dynamodb-client.git
|
|
209
|
+
cd dynamodb-client
|
|
186
210
|
|
|
187
|
-
#
|
|
188
|
-
|
|
189
|
-
VITE_COGNITO_USER_POOL_CLIENT_ID=xxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
190
|
-
VITE_COGNITO_DOMAIN=ainews-dev-auth.auth.us-east-1.amazoncognito.com
|
|
191
|
-
VITE_COGNITO_REGION=us-east-1
|
|
211
|
+
# Install dependencies
|
|
212
|
+
npm install
|
|
192
213
|
|
|
193
|
-
#
|
|
194
|
-
|
|
214
|
+
# Run tests
|
|
215
|
+
npm test
|
|
216
|
+
|
|
217
|
+
# Build
|
|
218
|
+
npm run build
|
|
195
219
|
```
|
|
196
220
|
|
|
197
|
-
###
|
|
221
|
+
### Available Commands
|
|
198
222
|
|
|
199
|
-
|
|
223
|
+
```bash
|
|
224
|
+
npm test # Run tests
|
|
225
|
+
npm run test:coverage # Run tests with coverage
|
|
226
|
+
npm run lint # Lint code
|
|
227
|
+
npm run format # Format code
|
|
228
|
+
npm run build # Build package
|
|
229
|
+
npm run clean # Clean build artifacts
|
|
230
|
+
```
|
|
200
231
|
|
|
201
|
-
|
|
232
|
+
---
|
|
202
233
|
|
|
203
|
-
|
|
204
|
-
- HashRouter(`#/`)ではクエリパラメータが正しく処理されない
|
|
234
|
+
## 🚢 Deployment
|
|
205
235
|
|
|
206
|
-
###
|
|
236
|
+
### Using Terraform
|
|
207
237
|
|
|
208
|
-
|
|
238
|
+
```bash
|
|
239
|
+
cd terraform
|
|
240
|
+
terraform init
|
|
241
|
+
terraform plan -var-file=envs/dev.tfvars
|
|
242
|
+
terraform apply -var-file=envs/dev.tfvars
|
|
243
|
+
```
|
|
209
244
|
|
|
210
|
-
|
|
211
|
-
2. **キャッシュ設定**:
|
|
212
|
-
- `index.html`: キャッシュしない(TTL=0)
|
|
213
|
-
- 静的アセット(JS/CSS/画像): 長期キャッシュ(TTL=7日〜1年)
|
|
214
|
-
3. **Cognitoコールバック URL**: 本番ドメインを追加
|
|
245
|
+
### Using Make
|
|
215
246
|
|
|
216
|
-
|
|
247
|
+
```bash
|
|
248
|
+
make deploy-dev # Deploy to dev environment
|
|
249
|
+
make deploy-stg # Deploy to staging
|
|
250
|
+
make deploy-prd # Deploy to production
|
|
251
|
+
```
|
|
217
252
|
|
|
218
|
-
|
|
253
|
+
---
|
|
219
254
|
|
|
220
|
-
|
|
255
|
+
## 🤝 Contributing
|
|
221
256
|
|
|
222
|
-
|
|
257
|
+
We welcome contributions!
|
|
223
258
|
|
|
224
|
-
|
|
225
|
-
cd functions/records
|
|
226
|
-
pnpm build
|
|
227
|
-
cd ../../infra
|
|
228
|
-
terraform apply -var-file=envs/dev.tfvars
|
|
229
|
-
```
|
|
259
|
+
### Development Workflow
|
|
230
260
|
|
|
231
|
-
|
|
261
|
+
1. Fork the repository
|
|
262
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
263
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
264
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
265
|
+
5. Open a Pull Request
|
|
232
266
|
|
|
233
|
-
|
|
267
|
+
### Guidelines
|
|
234
268
|
|
|
235
|
-
|
|
269
|
+
- Follow the existing code style
|
|
270
|
+
- Add tests for new features
|
|
271
|
+
- Update documentation as needed
|
|
272
|
+
- Ensure all tests pass before submitting
|
|
236
273
|
|
|
237
|
-
|
|
274
|
+
---
|
|
238
275
|
|
|
239
|
-
|
|
240
|
-
- Vite設定で `strictPort: true` が設定されているため、ポート3000が使用中の場合はエラーになります
|
|
241
|
-
- 他のプロセスがポート3000を使用していないか確認してください
|
|
276
|
+
## 📄 License
|
|
242
277
|
|
|
243
|
-
|
|
278
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
244
279
|
|
|
245
|
-
|
|
246
|
-
admin_callback_urls = [
|
|
247
|
-
"http://localhost:3000",
|
|
248
|
-
"http://localhost:3000/callback",
|
|
249
|
-
...
|
|
250
|
-
]
|
|
251
|
-
```
|
|
280
|
+
---
|
|
252
281
|
|
|
253
|
-
|
|
282
|
+
## 🙏 Acknowledgments
|
|
254
283
|
|
|
255
|
-
|
|
284
|
+
- Built with [AWS SDK for JavaScript](https://aws.amazon.com/sdk-for-javascript/)
|
|
285
|
+
- Inspired by [MongoDB](https://www.mongodb.com/) API design
|
|
286
|
+
- Powered by [TypeScript](https://www.typescriptlang.org/)
|
|
256
287
|
|
|
257
|
-
|
|
288
|
+
---
|
|
258
289
|
|
|
259
|
-
|
|
260
|
-
- [設計書](.kiro/specs/ainews-pipeline/design.md)
|
|
261
|
-
- [実装タスクリスト](.kiro/specs/ainews-pipeline/tasks.md)
|
|
290
|
+
<div align="center">
|
|
262
291
|
|
|
263
|
-
|
|
292
|
+
**[⬆ back to top](#-dynamodb-client-sdk)**
|
|
264
293
|
|
|
265
|
-
|
|
294
|
+
Made with ❤️ by [exabugs](https://github.com/exabugs)
|
|
266
295
|
|
|
267
|
-
|
|
296
|
+
</div>
|
|
@@ -11,9 +11,16 @@ import { FindCursor } from './FindCursor.js';
|
|
|
11
11
|
*/
|
|
12
12
|
export type AuthHeadersGetter<TAuthOptions = unknown> = (endpoint: string, body: string, authOptions?: TAuthOptions) => Promise<Record<string, string>>;
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* ドキュメント入力型の基本インターフェース(id はオプショナル)
|
|
15
15
|
*/
|
|
16
|
-
export interface
|
|
16
|
+
export interface InputBase {
|
|
17
|
+
id?: string;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* ドキュメント結果型の基本インターフェース(id は必須)
|
|
22
|
+
*/
|
|
23
|
+
export interface ResultBase {
|
|
17
24
|
id: string;
|
|
18
25
|
[key: string]: unknown;
|
|
19
26
|
}
|
|
@@ -23,21 +30,19 @@ export interface DocumentBase {
|
|
|
23
30
|
* MongoDB風のCRUD操作を提供します。
|
|
24
31
|
* 型安全なフィルタとクエリAPIでDynamoDBを操作できます。
|
|
25
32
|
*
|
|
26
|
-
* @template TSchema -
|
|
33
|
+
* @template TSchema - コレクションのドキュメント型(ResultBase を extends)
|
|
27
34
|
* @template TAuthOptions - 認証オプションの型
|
|
28
35
|
*/
|
|
29
|
-
export declare class Collection<TSchema extends
|
|
36
|
+
export declare class Collection<TSchema extends ResultBase = ResultBase, TAuthOptions = unknown> {
|
|
30
37
|
private endpoint;
|
|
31
|
-
private databaseName;
|
|
32
38
|
private collectionName;
|
|
33
39
|
private authToken;
|
|
34
40
|
private authOptions;
|
|
35
41
|
private clientOptions;
|
|
36
42
|
private getAuthHeaders;
|
|
37
|
-
constructor(endpoint: string,
|
|
43
|
+
constructor(endpoint: string, collectionName: string, authToken: string | undefined, authOptions: TAuthOptions | undefined, clientOptions: ClientOptions | undefined, getAuthHeaders: AuthHeadersGetter<TAuthOptions>);
|
|
38
44
|
getName(): string;
|
|
39
45
|
getEndpoint(): string;
|
|
40
|
-
getDatabaseName(): string;
|
|
41
46
|
getAuthToken(): string | undefined;
|
|
42
47
|
getAuthOptions(): TAuthOptions | undefined;
|
|
43
48
|
/**
|
|
@@ -47,8 +52,8 @@ export declare class Collection<TSchema extends DocumentBase = DocumentBase, TAu
|
|
|
47
52
|
find(filter?: Filter<TSchema>, options?: FindOptions): FindCursor<TSchema, TAuthOptions>;
|
|
48
53
|
findOne(filter: Filter<TSchema>): Promise<TSchema | null>;
|
|
49
54
|
findMany(ids: string[]): Promise<TSchema[]>;
|
|
50
|
-
insertOne(document: TSchema): Promise<InsertOneResult>;
|
|
51
|
-
insertMany(documents: TSchema[]): Promise<InsertManyResult>;
|
|
55
|
+
insertOne(document: InputBase & Omit<TSchema, 'id'>): Promise<InsertOneResult>;
|
|
56
|
+
insertMany(documents: (InputBase & Omit<TSchema, 'id'>)[]): Promise<InsertManyResult>;
|
|
52
57
|
updateOne(filter: Filter<TSchema>, update: UpdateOperators<TSchema>): Promise<UpdateResult>;
|
|
53
58
|
updateMany(filter: Filter<TSchema>, update: UpdateOperators<TSchema>): Promise<UpdateResult>;
|
|
54
59
|
deleteOne(filter: Filter<TSchema>): Promise<DeleteResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Collection.d.ts","sourceRoot":"","sources":["../../src/client/Collection.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OA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AE,eAAe,CAAC,OAAO,CAAC,GAC/B,OAAO,CAAC,YAAY,CAAC;IAelB,UAAU,CACd,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,EACvB,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC,GAC/B,OAAO,CAAC,YAAY,CAAC;IAkBlB,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC;IASzD,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC;CAUjE"}
|
|
@@ -5,20 +5,18 @@ import { FindCursor } from './FindCursor.js';
|
|
|
5
5
|
* MongoDB風のCRUD操作を提供します。
|
|
6
6
|
* 型安全なフィルタとクエリAPIでDynamoDBを操作できます。
|
|
7
7
|
*
|
|
8
|
-
* @template TSchema -
|
|
8
|
+
* @template TSchema - コレクションのドキュメント型(ResultBase を extends)
|
|
9
9
|
* @template TAuthOptions - 認証オプションの型
|
|
10
10
|
*/
|
|
11
11
|
export class Collection {
|
|
12
12
|
endpoint;
|
|
13
|
-
databaseName;
|
|
14
13
|
collectionName;
|
|
15
14
|
authToken;
|
|
16
15
|
authOptions;
|
|
17
16
|
clientOptions;
|
|
18
17
|
getAuthHeaders;
|
|
19
|
-
constructor(endpoint,
|
|
18
|
+
constructor(endpoint, collectionName, authToken, authOptions, clientOptions, getAuthHeaders) {
|
|
20
19
|
this.endpoint = endpoint;
|
|
21
|
-
this.databaseName = databaseName;
|
|
22
20
|
this.collectionName = collectionName;
|
|
23
21
|
this.authToken = authToken;
|
|
24
22
|
this.authOptions = authOptions;
|
|
@@ -31,9 +29,6 @@ export class Collection {
|
|
|
31
29
|
getEndpoint() {
|
|
32
30
|
return this.endpoint;
|
|
33
31
|
}
|
|
34
|
-
getDatabaseName() {
|
|
35
|
-
return this.databaseName;
|
|
36
|
-
}
|
|
37
32
|
getAuthToken() {
|
|
38
33
|
return this.authToken;
|
|
39
34
|
}
|
|
@@ -46,7 +41,6 @@ export class Collection {
|
|
|
46
41
|
async request(operation, params) {
|
|
47
42
|
const requestBody = JSON.stringify({
|
|
48
43
|
operation,
|
|
49
|
-
database: this.databaseName,
|
|
50
44
|
collection: this.collectionName,
|
|
51
45
|
params,
|
|
52
46
|
});
|
|
@@ -88,7 +82,7 @@ export class Collection {
|
|
|
88
82
|
}
|
|
89
83
|
}
|
|
90
84
|
find(filter = {}, options) {
|
|
91
|
-
return new FindCursor(this.endpoint, this.
|
|
85
|
+
return new FindCursor(this.endpoint, this.collectionName, filter, options, this.authToken, this.authOptions, this.clientOptions, this.getAuthHeaders);
|
|
92
86
|
}
|
|
93
87
|
async findOne(filter) {
|
|
94
88
|
const response = await this.request('findOne', { filter });
|