@functional-systems/lambdadb 0.2.0 → 0.3.0-dev

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.
Files changed (49) hide show
  1. package/README.md +54 -49
  2. package/dist/commonjs/client.d.ts +107 -0
  3. package/dist/commonjs/client.d.ts.map +1 -0
  4. package/dist/commonjs/client.js +163 -0
  5. package/dist/commonjs/client.js.map +1 -0
  6. package/dist/commonjs/index.d.ts +2 -0
  7. package/dist/commonjs/index.d.ts.map +1 -1
  8. package/dist/commonjs/index.js +5 -1
  9. package/dist/commonjs/index.js.map +1 -1
  10. package/dist/commonjs/lib/config.d.ts +3 -3
  11. package/dist/commonjs/lib/config.js +3 -3
  12. package/dist/commonjs/models/operations/fetchdocs.d.ts +8 -0
  13. package/dist/commonjs/models/operations/fetchdocs.d.ts.map +1 -1
  14. package/dist/commonjs/models/operations/fetchdocs.js +2 -0
  15. package/dist/commonjs/models/operations/fetchdocs.js.map +1 -1
  16. package/dist/commonjs/models/operations/querycollection.d.ts +8 -0
  17. package/dist/commonjs/models/operations/querycollection.d.ts.map +1 -1
  18. package/dist/commonjs/models/operations/querycollection.js +2 -0
  19. package/dist/commonjs/models/operations/querycollection.js.map +1 -1
  20. package/dist/esm/client.d.ts +107 -0
  21. package/dist/esm/client.d.ts.map +1 -0
  22. package/dist/esm/client.js +158 -0
  23. package/dist/esm/client.js.map +1 -0
  24. package/dist/esm/index.d.ts +2 -0
  25. package/dist/esm/index.d.ts.map +1 -1
  26. package/dist/esm/index.js +2 -0
  27. package/dist/esm/index.js.map +1 -1
  28. package/dist/esm/lib/config.d.ts +3 -3
  29. package/dist/esm/lib/config.js +3 -3
  30. package/dist/esm/models/operations/fetchdocs.d.ts +8 -0
  31. package/dist/esm/models/operations/fetchdocs.d.ts.map +1 -1
  32. package/dist/esm/models/operations/fetchdocs.js +2 -0
  33. package/dist/esm/models/operations/fetchdocs.js.map +1 -1
  34. package/dist/esm/models/operations/querycollection.d.ts +8 -0
  35. package/dist/esm/models/operations/querycollection.d.ts.map +1 -1
  36. package/dist/esm/models/operations/querycollection.js +2 -0
  37. package/dist/esm/models/operations/querycollection.js.map +1 -1
  38. package/examples/collectionScoped.example.ts +32 -0
  39. package/examples/collectionsList.example.ts +8 -12
  40. package/examples/package-lock.json +1 -1
  41. package/jsr.json +1 -1
  42. package/package.json +5 -3
  43. package/src/client.ts +272 -0
  44. package/src/index.ts +7 -0
  45. package/src/lib/config.ts +3 -3
  46. package/src/models/operations/fetchdocs.ts +10 -0
  47. package/src/models/operations/querycollection.ts +10 -0
  48. package/_speakeasy/.github/action-inputs-config.json +0 -53
  49. package/_speakeasy/.github/action-security-config.json +0 -88
package/src/client.ts ADDED
@@ -0,0 +1,272 @@
1
+ /**
2
+ * Collection-scoped facade for LambdaDB API.
3
+ * Use this client for a better DX: no need to pass collectionName on every call.
4
+ *
5
+ * @example
6
+ * const client = new LambdaDBClient({ projectApiKey: "..." });
7
+ * const collection = client.collection("my-collection");
8
+ * await collection.get();
9
+ * await collection.docs.list({ size: 20 });
10
+ * await collection.docs.upsert({ docs: [{ id: "1", text: "hello" }] });
11
+ */
12
+
13
+ import { LambdaDBCore } from "./core.js";
14
+ import { collectionsCreate } from "./funcs/collectionsCreate.js";
15
+ import { collectionsDelete } from "./funcs/collectionsDelete.js";
16
+ import { collectionsGet } from "./funcs/collectionsGet.js";
17
+ import { collectionsList } from "./funcs/collectionsList.js";
18
+ import { collectionsQuery } from "./funcs/collectionsQuery.js";
19
+ import { collectionsUpdate } from "./funcs/collectionsUpdate.js";
20
+ import { collectionsDocsBulkUpsert } from "./funcs/collectionsDocsBulkUpsert.js";
21
+ import { collectionsDocsDelete } from "./funcs/collectionsDocsDelete.js";
22
+ import { collectionsDocsFetch } from "./funcs/collectionsDocsFetch.js";
23
+ import { collectionsDocsGetBulkUpsert } from "./funcs/collectionsDocsGetBulkUpsert.js";
24
+ import { collectionsDocsListDocs } from "./funcs/collectionsDocsListDocs.js";
25
+ import { collectionsDocsUpdate } from "./funcs/collectionsDocsUpdate.js";
26
+ import { collectionsDocsUpsert } from "./funcs/collectionsDocsUpsert.js";
27
+ import type { RequestOptions } from "./lib/sdks.js";
28
+ import type * as operations from "./models/operations/index.js";
29
+ import type * as models from "./models/index.js";
30
+ import { unwrapAsync } from "./types/fp.js";
31
+
32
+ export type { RequestOptions };
33
+
34
+ // Re-export common types for facade users
35
+ export type { operations, models };
36
+
37
+ /**
38
+ * Client with collection-scoped API. Prefer this over the legacy
39
+ * `LambdaDB` when you want to avoid passing collectionName on every call.
40
+ */
41
+ export class LambdaDBClient extends LambdaDBCore {
42
+ /**
43
+ * Get a handle for a specific collection. All methods on the handle
44
+ * use this collection name; you do not pass it again.
45
+ */
46
+ collection(collectionName: string): CollectionHandle {
47
+ return new CollectionHandle(this, collectionName);
48
+ }
49
+
50
+ /**
51
+ * List all collections in the project.
52
+ */
53
+ async listCollections(options?: RequestOptions) {
54
+ return unwrapAsync(collectionsList(this, options));
55
+ }
56
+
57
+ /**
58
+ * Create a new collection.
59
+ */
60
+ async createCollection(
61
+ request: operations.CreateCollectionRequest,
62
+ options?: RequestOptions,
63
+ ) {
64
+ return unwrapAsync(collectionsCreate(this, request, options));
65
+ }
66
+ }
67
+
68
+ /**
69
+ * Handle for a single collection. All methods operate on this collection.
70
+ */
71
+ export class CollectionHandle {
72
+ constructor(
73
+ private readonly client: LambdaDBCore,
74
+ readonly collectionName: string,
75
+ ) {}
76
+
77
+ /**
78
+ * Get metadata of this collection.
79
+ */
80
+ async get(options?: RequestOptions) {
81
+ return unwrapAsync(
82
+ collectionsGet(this.client, { collectionName: this.collectionName }, options),
83
+ );
84
+ }
85
+
86
+ /**
87
+ * Configure (update) this collection.
88
+ */
89
+ async update(
90
+ requestBody: operations.UpdateCollectionRequestBody,
91
+ options?: RequestOptions,
92
+ ) {
93
+ return unwrapAsync(
94
+ collectionsUpdate(
95
+ this.client,
96
+ {
97
+ collectionName: this.collectionName,
98
+ requestBody,
99
+ },
100
+ options,
101
+ ),
102
+ );
103
+ }
104
+
105
+ /**
106
+ * Delete this collection.
107
+ */
108
+ async delete(options?: RequestOptions) {
109
+ return unwrapAsync(
110
+ collectionsDelete(
111
+ this.client,
112
+ { collectionName: this.collectionName },
113
+ options,
114
+ ),
115
+ );
116
+ }
117
+
118
+ /**
119
+ * Search this collection with a query.
120
+ */
121
+ async query(
122
+ requestBody: operations.QueryCollectionRequestBody,
123
+ options?: RequestOptions,
124
+ ) {
125
+ return unwrapAsync(
126
+ collectionsQuery(
127
+ this.client,
128
+ {
129
+ collectionName: this.collectionName,
130
+ requestBody,
131
+ },
132
+ options,
133
+ ),
134
+ );
135
+ }
136
+
137
+ readonly docs: CollectionDocs = new CollectionDocs(this.client, this.collectionName);
138
+ }
139
+
140
+ /**
141
+ * Document operations scoped to a collection.
142
+ */
143
+ class CollectionDocs {
144
+ constructor(
145
+ private readonly client: LambdaDBCore,
146
+ private readonly collectionName: string,
147
+ ) {}
148
+
149
+ /**
150
+ * List documents in the collection.
151
+ */
152
+ async list(
153
+ params?: { size?: number; pageToken?: string },
154
+ options?: RequestOptions,
155
+ ) {
156
+ return unwrapAsync(
157
+ collectionsDocsListDocs(
158
+ this.client,
159
+ { collectionName: this.collectionName, ...params },
160
+ options,
161
+ ),
162
+ );
163
+ }
164
+
165
+ /**
166
+ * Upsert documents. Max payload 6MB.
167
+ */
168
+ async upsert(
169
+ body: { docs: Array<Record<string, unknown>> },
170
+ options?: RequestOptions,
171
+ ): Promise<models.MessageResponse> {
172
+ return unwrapAsync(
173
+ collectionsDocsUpsert(
174
+ this.client,
175
+ {
176
+ collectionName: this.collectionName,
177
+ requestBody: body,
178
+ },
179
+ options,
180
+ ),
181
+ );
182
+ }
183
+
184
+ /**
185
+ * Update documents (each doc must have id). Max payload 6MB.
186
+ */
187
+ async update(
188
+ body: { docs: Array<Record<string, unknown>> },
189
+ options?: RequestOptions,
190
+ ): Promise<models.MessageResponse> {
191
+ return unwrapAsync(
192
+ collectionsDocsUpdate(
193
+ this.client,
194
+ {
195
+ collectionName: this.collectionName,
196
+ requestBody: body,
197
+ },
198
+ options,
199
+ ),
200
+ );
201
+ }
202
+
203
+ /**
204
+ * Delete documents by ids and/or filter.
205
+ */
206
+ async delete(
207
+ body: operations.DeleteDocsRequestBody,
208
+ options?: RequestOptions,
209
+ ): Promise<models.MessageResponse> {
210
+ return unwrapAsync(
211
+ collectionsDocsDelete(
212
+ this.client,
213
+ {
214
+ collectionName: this.collectionName,
215
+ requestBody: body,
216
+ },
217
+ options,
218
+ ),
219
+ );
220
+ }
221
+
222
+ /**
223
+ * Fetch documents by IDs (max 100).
224
+ */
225
+ async fetch(
226
+ body: operations.FetchDocsRequestBody,
227
+ options?: RequestOptions,
228
+ ) {
229
+ return unwrapAsync(
230
+ collectionsDocsFetch(
231
+ this.client,
232
+ {
233
+ collectionName: this.collectionName,
234
+ requestBody: body,
235
+ },
236
+ options,
237
+ ),
238
+ );
239
+ }
240
+
241
+ /**
242
+ * Get presigned URL and metadata for bulk upload (up to 200MB).
243
+ */
244
+ async getBulkUpsert(options?: RequestOptions) {
245
+ return unwrapAsync(
246
+ collectionsDocsGetBulkUpsert(
247
+ this.client,
248
+ { collectionName: this.collectionName },
249
+ options,
250
+ ),
251
+ );
252
+ }
253
+
254
+ /**
255
+ * Trigger bulk upsert with an object key from getBulkUpsert().
256
+ */
257
+ async bulkUpsert(
258
+ body: { objectKey: string },
259
+ options?: RequestOptions,
260
+ ): Promise<models.MessageResponse> {
261
+ return unwrapAsync(
262
+ collectionsDocsBulkUpsert(
263
+ this.client,
264
+ {
265
+ collectionName: this.collectionName,
266
+ requestBody: body,
267
+ },
268
+ options,
269
+ ),
270
+ );
271
+ }
272
+ }
package/src/index.ts CHANGED
@@ -7,3 +7,10 @@ export * as files from "./lib/files.js";
7
7
  export { HTTPClient } from "./lib/http.js";
8
8
  export type { Fetcher, HTTPClientOptions } from "./lib/http.js";
9
9
  export * from "./sdk/sdk.js";
10
+
11
+ /** Collection-scoped client (recommended). See docs/REFACTORING_PROPOSAL.md */
12
+ export {
13
+ LambdaDBClient,
14
+ CollectionHandle,
15
+ type RequestOptions as ClientRequestOptions,
16
+ } from "./client.js";
package/src/lib/config.ts CHANGED
@@ -71,8 +71,8 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
71
71
  export const SDK_METADATA = {
72
72
  language: "typescript",
73
73
  openapiDocVersion: "1.1.1",
74
- sdkVersion: "0.2.0",
75
- genVersion: "2.797.1",
74
+ sdkVersion: "0.2.1",
75
+ genVersion: "2.798.0",
76
76
  userAgent:
77
- "speakeasy-sdk/typescript 0.2.0 2.797.1 1.1.1 @functional-systems/lambdadb",
77
+ "speakeasy-sdk/typescript 0.2.1 2.798.0 1.1.1 @functional-systems/lambdadb",
78
78
  } as const;
@@ -55,6 +55,14 @@ export type FetchDocsResponse = {
55
55
  */
56
56
  took: number;
57
57
  docs: Array<FetchDocsDoc>;
58
+ /**
59
+ * Whether the list of documents is included.
60
+ */
61
+ isDocsInline: boolean;
62
+ /**
63
+ * Download URL for the list of documents.
64
+ */
65
+ docsUrl?: string | undefined;
58
66
  };
59
67
 
60
68
  /** @internal */
@@ -144,6 +152,8 @@ export const FetchDocsResponse$inboundSchema: z.ZodType<
144
152
  total: z.number().int(),
145
153
  took: z.number().int(),
146
154
  docs: z.array(z.lazy(() => FetchDocsDoc$inboundSchema)),
155
+ isDocsInline: z.boolean(),
156
+ docsUrl: z.string().optional(),
147
157
  });
148
158
 
149
159
  export function fetchDocsResponseFromJSON(
@@ -77,6 +77,14 @@ export type QueryCollectionResponse = {
77
77
  * List of documents.
78
78
  */
79
79
  docs: Array<QueryCollectionDoc>;
80
+ /**
81
+ * Whether the list of documents is included.
82
+ */
83
+ isDocsInline: boolean;
84
+ /**
85
+ * Optional download URL for the list of documents.
86
+ */
87
+ docsUrl?: string | undefined;
80
88
  };
81
89
 
82
90
  /** @internal */
@@ -172,6 +180,8 @@ export const QueryCollectionResponse$inboundSchema: z.ZodType<
172
180
  maxScore: z.number().optional(),
173
181
  total: z.number().int(),
174
182
  docs: z.array(z.lazy(() => QueryCollectionDoc$inboundSchema)),
183
+ isDocsInline: z.boolean(),
184
+ docsUrl: z.string().optional(),
175
185
  });
176
186
 
177
187
  export function queryCollectionResponseFromJSON(
@@ -1,53 +0,0 @@
1
- [
2
- {
3
- "name": "mode",
4
- "validation_regex": "/^(direct|pr)$/.source",
5
- "validation_message": "Must be `direct` or `pr`"
6
- },
7
- {
8
- "name": "speakeasy_version",
9
- "validation_regex": "/^[\\w.\\-]+$/.source",
10
- "validation_message": "Letters, numbers, or .-_ only"
11
- },
12
- {
13
- "name": "openapi_doc_location",
14
- "validation_regex": "/^((https?):\\/\\/([\\w\\-]+\\.)+\\w+(\\/.*)?|[\\w.\\-\\/]+)$/i.source",
15
- "validation_message": "Must be a valid server URL or file path containing letters, numbers, or .-_/ only"
16
- },
17
- {
18
- "name": "openapi_doc_auth_header",
19
- "validation_regex": "/^[A-Za-z\\-]+$/.source",
20
- "validation_message": "Letters or - only"
21
- },
22
- {
23
- "name": "create_release"
24
- },
25
- {
26
- "name": "publish_python",
27
- "language": "python"
28
- },
29
- {
30
- "name": "publish_typescript",
31
- "language": "typescript"
32
- },
33
- {
34
- "name": "publish_java",
35
- "language": "java"
36
- },
37
- {
38
- "name": "publish_php",
39
- "language": "php"
40
- },
41
- {
42
- "name": "publish_ruby",
43
- "language": "ruby"
44
- },
45
- {
46
- "name": "publish_csharp",
47
- "language": "csharp"
48
- },
49
- {
50
- "name": "publish_terraform",
51
- "language": "terraform"
52
- }
53
- ]
@@ -1,88 +0,0 @@
1
- [
2
- {
3
- "name": "pypi_token",
4
- "secret_name": "PYPI_TOKEN",
5
- "validation_regex": "/^[\\w.\\-]+$/.source",
6
- "validation_message": "Letters, numbers, or .-_ only",
7
- "language": "python"
8
- },
9
- {
10
- "name": "npm_token",
11
- "secret_name": "NPM_TOKEN",
12
- "validation_regex": "/^[\\w.\\-]+$/.source",
13
- "validation_message": "Letters, numbers, or .-_ only",
14
- "language": "typescript"
15
- },
16
- {
17
- "name": "packagist_username",
18
- "validation_regex": "/^[\\w.\\-]+$/.source",
19
- "validation_message": "Letters, numbers, or .-_ only",
20
- "language": "php"
21
- },
22
- {
23
- "name": "packagist_token",
24
- "validation_regex": "/^[\\w.\\-]+$/.source",
25
- "validation_message": "Letters, numbers, or .-_ only",
26
- "language": "php"
27
- },
28
- {
29
- "name": "openapi_doc_auth_token",
30
- "secret_name": "SPEC_TOKEN",
31
- "validation_regex": "/^[\\w.\\-]+$/.source",
32
- "validation_message": "Letters, numbers, or .-_ only"
33
- },
34
- {
35
- "name": "speakeasy_api_key",
36
- "secret_name": "SPEAKEASY_API_KEY",
37
- "validation_regex": "/^[\\w.\\-]+$/.source",
38
- "validation_message": "Letters, numbers, or .-_ only"
39
- },
40
- {
41
- "name": "ossrh_username",
42
- "secret_name": "MAVEN_USERNAME",
43
- "validation_regex": "/^[\\w.\\-]+$/.source",
44
- "validation_message": "Letters, numbers, or .-_ only",
45
- "language": "java"
46
- },
47
- {
48
- "name": "ossrh_password",
49
- "secret_name": "MAVEN_PASSWORD",
50
- "language": "java"
51
- },
52
- {
53
- "name": "java_gpg_secret_key",
54
- "validation_regex": "/^[\\w.\\-\\t \\r\\n]+$/.source",
55
- "validation_message": "Letters, numbers, tabs, spaces, newlines, or .-_ only",
56
- "language": "java"
57
- },
58
- {
59
- "name": "java_gpg_passphrase",
60
- "language": "java"
61
- },
62
- {
63
- "name": "terraform_gpg_secret_key",
64
- "secret_name": "TERRAFORM_GPG_SECRET_KEY",
65
- "validation_regex": "/^[\\w.\\-\\t \\r\\n]+$/.source",
66
- "validation_message": "Letters, numbers, tabs, spaces, newlines, or .-_ only",
67
- "language": "terraform"
68
- },
69
- {
70
- "name": "terraform_gpg_passphrase",
71
- "secret_name": "TERRAFORM_GPG_PASSPHRASE",
72
- "language": "terraform"
73
- },
74
- {
75
- "name": "rubygems_auth_token",
76
- "secret_name": "RUBYGEMS_AUTH_TOKEN",
77
- "language": "ruby"
78
- },
79
- {
80
- "name": "nuget_api_key",
81
- "secret_name": "NUGET_API_KEY",
82
- "language": "csharp"
83
- },
84
- {
85
- "name": "slack_webhook_url",
86
- "secret_name": "SLACK_WEBHOOK_URL"
87
- }
88
- ]