@functional-systems/lambdadb 0.2.1 → 0.3.0-dev.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.
- package/README.md +54 -49
- package/dist/commonjs/client.d.ts +128 -0
- package/dist/commonjs/client.d.ts.map +1 -0
- package/dist/commonjs/client.js +182 -0
- package/dist/commonjs/client.js.map +1 -0
- package/dist/commonjs/index.d.ts +2 -0
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +7 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/esm/client.d.ts +128 -0
- package/dist/esm/client.d.ts.map +1 -0
- package/dist/esm/client.js +177 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/examples/collectionScoped.example.ts +32 -0
- package/examples/collectionsList.example.ts +8 -12
- package/package.json +5 -3
- package/src/client.ts +321 -0
- package/src/index.ts +10 -0
- package/_speakeasy/.github/action-inputs-config.json +0 -53
- package/_speakeasy/.github/action-security-config.json +0 -88
|
@@ -0,0 +1,128 @@
|
|
|
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
|
+
import { LambdaDBCore } from "./core.js";
|
|
13
|
+
import type { SDKOptions } from "./lib/config.js";
|
|
14
|
+
import type { RequestOptions } from "./lib/sdks.js";
|
|
15
|
+
import type * as operations from "./models/operations/index.js";
|
|
16
|
+
import type * as models from "./models/index.js";
|
|
17
|
+
export type { RequestOptions };
|
|
18
|
+
export type { operations, models };
|
|
19
|
+
/** Default base URL for the LambdaDB API. */
|
|
20
|
+
export declare const DEFAULT_BASE_URL = "https://api.lambdadb.ai";
|
|
21
|
+
/** Default project name when not specified. */
|
|
22
|
+
export declare const DEFAULT_PROJECT_NAME = "playground";
|
|
23
|
+
/**
|
|
24
|
+
* Options for LambdaDBClient. Supports baseUrl + projectName (recommended) or
|
|
25
|
+
* legacy projectHost / serverURL. When neither serverURL nor projectHost is set,
|
|
26
|
+
* the base URL is built as `${baseUrl}/projects/${projectName}`.
|
|
27
|
+
*/
|
|
28
|
+
export type LambdaDBClientOptions = SDKOptions & {
|
|
29
|
+
/**
|
|
30
|
+
* API base URL (e.g. https://api.lambdadb.ai). Default: "https://api.lambdadb.ai"
|
|
31
|
+
*/
|
|
32
|
+
baseUrl?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Project name (path segment under /projects/). Default: "playground"
|
|
35
|
+
*/
|
|
36
|
+
projectName?: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Client with collection-scoped API. Prefer this over the legacy
|
|
40
|
+
* `LambdaDB` when you want to avoid passing collectionName on every call.
|
|
41
|
+
*/
|
|
42
|
+
export declare class LambdaDBClient extends LambdaDBCore {
|
|
43
|
+
constructor(options?: LambdaDBClientOptions);
|
|
44
|
+
/**
|
|
45
|
+
* Get a handle for a specific collection. All methods on the handle
|
|
46
|
+
* use this collection name; you do not pass it again.
|
|
47
|
+
*/
|
|
48
|
+
collection(collectionName: string): CollectionHandle;
|
|
49
|
+
/**
|
|
50
|
+
* List all collections in the project.
|
|
51
|
+
*/
|
|
52
|
+
listCollections(options?: RequestOptions): Promise<operations.ListCollectionsResponse>;
|
|
53
|
+
/**
|
|
54
|
+
* Create a new collection.
|
|
55
|
+
*/
|
|
56
|
+
createCollection(request: operations.CreateCollectionRequest, options?: RequestOptions): Promise<operations.CreateCollectionResponse>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Handle for a single collection. All methods operate on this collection.
|
|
60
|
+
*/
|
|
61
|
+
export declare class CollectionHandle {
|
|
62
|
+
private readonly client;
|
|
63
|
+
readonly collectionName: string;
|
|
64
|
+
constructor(client: LambdaDBCore, collectionName: string);
|
|
65
|
+
/**
|
|
66
|
+
* Get metadata of this collection.
|
|
67
|
+
*/
|
|
68
|
+
get(options?: RequestOptions): Promise<operations.GetCollectionResponse>;
|
|
69
|
+
/**
|
|
70
|
+
* Configure (update) this collection.
|
|
71
|
+
*/
|
|
72
|
+
update(requestBody: operations.UpdateCollectionRequestBody, options?: RequestOptions): Promise<operations.UpdateCollectionResponse>;
|
|
73
|
+
/**
|
|
74
|
+
* Delete this collection.
|
|
75
|
+
*/
|
|
76
|
+
delete(options?: RequestOptions): Promise<models.MessageResponse>;
|
|
77
|
+
/**
|
|
78
|
+
* Search this collection with a query.
|
|
79
|
+
*/
|
|
80
|
+
query(requestBody: operations.QueryCollectionRequestBody, options?: RequestOptions): Promise<operations.QueryCollectionResponse>;
|
|
81
|
+
readonly docs: CollectionDocs;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Document operations scoped to a collection.
|
|
85
|
+
*/
|
|
86
|
+
declare class CollectionDocs {
|
|
87
|
+
private readonly client;
|
|
88
|
+
private readonly collectionName;
|
|
89
|
+
constructor(client: LambdaDBCore, collectionName: string);
|
|
90
|
+
/**
|
|
91
|
+
* List documents in the collection.
|
|
92
|
+
*/
|
|
93
|
+
list(params?: {
|
|
94
|
+
size?: number;
|
|
95
|
+
pageToken?: string;
|
|
96
|
+
}, options?: RequestOptions): Promise<operations.ListDocsResponse>;
|
|
97
|
+
/**
|
|
98
|
+
* Upsert documents. Max payload 6MB.
|
|
99
|
+
*/
|
|
100
|
+
upsert(body: {
|
|
101
|
+
docs: Array<Record<string, unknown>>;
|
|
102
|
+
}, options?: RequestOptions): Promise<models.MessageResponse>;
|
|
103
|
+
/**
|
|
104
|
+
* Update documents (each doc must have id). Max payload 6MB.
|
|
105
|
+
*/
|
|
106
|
+
update(body: {
|
|
107
|
+
docs: Array<Record<string, unknown>>;
|
|
108
|
+
}, options?: RequestOptions): Promise<models.MessageResponse>;
|
|
109
|
+
/**
|
|
110
|
+
* Delete documents by ids and/or filter.
|
|
111
|
+
*/
|
|
112
|
+
delete(body: operations.DeleteDocsRequestBody, options?: RequestOptions): Promise<models.MessageResponse>;
|
|
113
|
+
/**
|
|
114
|
+
* Fetch documents by IDs (max 100).
|
|
115
|
+
*/
|
|
116
|
+
fetch(body: operations.FetchDocsRequestBody, options?: RequestOptions): Promise<operations.FetchDocsResponse>;
|
|
117
|
+
/**
|
|
118
|
+
* Get presigned URL and metadata for bulk upload (up to 200MB).
|
|
119
|
+
*/
|
|
120
|
+
getBulkUpsert(options?: RequestOptions): Promise<operations.GetBulkUpsertDocsResponse>;
|
|
121
|
+
/**
|
|
122
|
+
* Trigger bulk upsert with an object key from getBulkUpsert().
|
|
123
|
+
*/
|
|
124
|
+
bulkUpsert(body: {
|
|
125
|
+
objectKey: string;
|
|
126
|
+
}, options?: RequestOptions): Promise<models.MessageResponse>;
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAclD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAGjD,YAAY,EAAE,cAAc,EAAE,CAAC;AAG/B,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,CA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cAAc,EAAE,MAAM;IAGzC;;OAEG;IACG,IAAI,CACR,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,EAC9C,OAAO,CAAC,EAAE,cAAc;IAW1B;;OAEG;IACG,MAAM,CACV,IAAI,EAAE;QAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;KAAE,EAC9C,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC;IAalC;;OAEG;IACG,MAAM,CACV,IAAI,EAAE;QAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;KAAE,EAC9C,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC;IAalC;;OAEG;IACG,MAAM,CACV,IAAI,EAAE,UAAU,CAAC,qBAAqB,EACtC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC;IAalC;;OAEG;IACG,KAAK,CACT,IAAI,EAAE,UAAU,CAAC,oBAAoB,EACrC,OAAO,CAAC,EAAE,cAAc;IAc1B;;OAEG;IACG,aAAa,CAAC,OAAO,CAAC,EAAE,cAAc;IAU5C;;OAEG;IACG,UAAU,CACd,IAAI,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,EAC3B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC;CAYnC"}
|
|
@@ -0,0 +1,177 @@
|
|
|
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
|
+
import { LambdaDBCore } from "./core.js";
|
|
13
|
+
import { collectionsCreate } from "./funcs/collectionsCreate.js";
|
|
14
|
+
import { collectionsDelete } from "./funcs/collectionsDelete.js";
|
|
15
|
+
import { collectionsGet } from "./funcs/collectionsGet.js";
|
|
16
|
+
import { collectionsList } from "./funcs/collectionsList.js";
|
|
17
|
+
import { collectionsQuery } from "./funcs/collectionsQuery.js";
|
|
18
|
+
import { collectionsUpdate } from "./funcs/collectionsUpdate.js";
|
|
19
|
+
import { collectionsDocsBulkUpsert } from "./funcs/collectionsDocsBulkUpsert.js";
|
|
20
|
+
import { collectionsDocsDelete } from "./funcs/collectionsDocsDelete.js";
|
|
21
|
+
import { collectionsDocsFetch } from "./funcs/collectionsDocsFetch.js";
|
|
22
|
+
import { collectionsDocsGetBulkUpsert } from "./funcs/collectionsDocsGetBulkUpsert.js";
|
|
23
|
+
import { collectionsDocsListDocs } from "./funcs/collectionsDocsListDocs.js";
|
|
24
|
+
import { collectionsDocsUpdate } from "./funcs/collectionsDocsUpdate.js";
|
|
25
|
+
import { collectionsDocsUpsert } from "./funcs/collectionsDocsUpsert.js";
|
|
26
|
+
import { unwrapAsync } from "./types/fp.js";
|
|
27
|
+
/** Default base URL for the LambdaDB API. */
|
|
28
|
+
export const DEFAULT_BASE_URL = "https://api.lambdadb.ai";
|
|
29
|
+
/** Default project name when not specified. */
|
|
30
|
+
export const DEFAULT_PROJECT_NAME = "playground";
|
|
31
|
+
function normalizeClientOptions(options = {}) {
|
|
32
|
+
const { baseUrl = DEFAULT_BASE_URL, projectName = DEFAULT_PROJECT_NAME, serverURL, projectHost, ...rest } = options;
|
|
33
|
+
if (serverURL !== undefined && serverURL !== null) {
|
|
34
|
+
return { ...rest, serverURL };
|
|
35
|
+
}
|
|
36
|
+
if (projectHost !== undefined && projectHost !== null) {
|
|
37
|
+
return { ...rest, projectHost };
|
|
38
|
+
}
|
|
39
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
40
|
+
const serverURLFromBase = `${base}/projects/${encodeURIComponent(projectName)}`;
|
|
41
|
+
return { ...rest, serverURL: serverURLFromBase };
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Client with collection-scoped API. Prefer this over the legacy
|
|
45
|
+
* `LambdaDB` when you want to avoid passing collectionName on every call.
|
|
46
|
+
*/
|
|
47
|
+
export class LambdaDBClient extends LambdaDBCore {
|
|
48
|
+
constructor(options) {
|
|
49
|
+
super(normalizeClientOptions(options));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get a handle for a specific collection. All methods on the handle
|
|
53
|
+
* use this collection name; you do not pass it again.
|
|
54
|
+
*/
|
|
55
|
+
collection(collectionName) {
|
|
56
|
+
return new CollectionHandle(this, collectionName);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* List all collections in the project.
|
|
60
|
+
*/
|
|
61
|
+
async listCollections(options) {
|
|
62
|
+
return unwrapAsync(collectionsList(this, options));
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Create a new collection.
|
|
66
|
+
*/
|
|
67
|
+
async createCollection(request, options) {
|
|
68
|
+
return unwrapAsync(collectionsCreate(this, request, options));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Handle for a single collection. All methods operate on this collection.
|
|
73
|
+
*/
|
|
74
|
+
export class CollectionHandle {
|
|
75
|
+
constructor(client, collectionName) {
|
|
76
|
+
this.client = client;
|
|
77
|
+
this.collectionName = collectionName;
|
|
78
|
+
this.docs = new CollectionDocs(this.client, this.collectionName);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get metadata of this collection.
|
|
82
|
+
*/
|
|
83
|
+
async get(options) {
|
|
84
|
+
return unwrapAsync(collectionsGet(this.client, { collectionName: this.collectionName }, options));
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Configure (update) this collection.
|
|
88
|
+
*/
|
|
89
|
+
async update(requestBody, options) {
|
|
90
|
+
return unwrapAsync(collectionsUpdate(this.client, {
|
|
91
|
+
collectionName: this.collectionName,
|
|
92
|
+
requestBody,
|
|
93
|
+
}, options));
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Delete this collection.
|
|
97
|
+
*/
|
|
98
|
+
async delete(options) {
|
|
99
|
+
return unwrapAsync(collectionsDelete(this.client, { collectionName: this.collectionName }, options));
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Search this collection with a query.
|
|
103
|
+
*/
|
|
104
|
+
async query(requestBody, options) {
|
|
105
|
+
return unwrapAsync(collectionsQuery(this.client, {
|
|
106
|
+
collectionName: this.collectionName,
|
|
107
|
+
requestBody,
|
|
108
|
+
}, options));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Document operations scoped to a collection.
|
|
113
|
+
*/
|
|
114
|
+
class CollectionDocs {
|
|
115
|
+
constructor(client, collectionName) {
|
|
116
|
+
this.client = client;
|
|
117
|
+
this.collectionName = collectionName;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* List documents in the collection.
|
|
121
|
+
*/
|
|
122
|
+
async list(params, options) {
|
|
123
|
+
return unwrapAsync(collectionsDocsListDocs(this.client, { collectionName: this.collectionName, ...params }, options));
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Upsert documents. Max payload 6MB.
|
|
127
|
+
*/
|
|
128
|
+
async upsert(body, options) {
|
|
129
|
+
return unwrapAsync(collectionsDocsUpsert(this.client, {
|
|
130
|
+
collectionName: this.collectionName,
|
|
131
|
+
requestBody: body,
|
|
132
|
+
}, options));
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Update documents (each doc must have id). Max payload 6MB.
|
|
136
|
+
*/
|
|
137
|
+
async update(body, options) {
|
|
138
|
+
return unwrapAsync(collectionsDocsUpdate(this.client, {
|
|
139
|
+
collectionName: this.collectionName,
|
|
140
|
+
requestBody: body,
|
|
141
|
+
}, options));
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Delete documents by ids and/or filter.
|
|
145
|
+
*/
|
|
146
|
+
async delete(body, options) {
|
|
147
|
+
return unwrapAsync(collectionsDocsDelete(this.client, {
|
|
148
|
+
collectionName: this.collectionName,
|
|
149
|
+
requestBody: body,
|
|
150
|
+
}, options));
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Fetch documents by IDs (max 100).
|
|
154
|
+
*/
|
|
155
|
+
async fetch(body, options) {
|
|
156
|
+
return unwrapAsync(collectionsDocsFetch(this.client, {
|
|
157
|
+
collectionName: this.collectionName,
|
|
158
|
+
requestBody: body,
|
|
159
|
+
}, options));
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Get presigned URL and metadata for bulk upload (up to 200MB).
|
|
163
|
+
*/
|
|
164
|
+
async getBulkUpsert(options) {
|
|
165
|
+
return unwrapAsync(collectionsDocsGetBulkUpsert(this.client, { collectionName: this.collectionName }, options));
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Trigger bulk upsert with an object key from getBulkUpsert().
|
|
169
|
+
*/
|
|
170
|
+
async bulkUpsert(body, options) {
|
|
171
|
+
return unwrapAsync(collectionsDocsBulkUpsert(this.client, {
|
|
172
|
+
collectionName: this.collectionName,
|
|
173
|
+
requestBody: body,
|
|
174
|
+
}, options));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,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EACD,OAAO,CACR,CACF,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CACV,IAA8C,EAC9C,OAAwB;QAExB,OAAO,WAAW,CAChB,qBAAqB,CACnB,IAAI,CAAC,MAAM,EACX;YACE,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,WAAW,EAAE,IAAI;SAClB,EACD,OAAO,CACR,CACF,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CACV,IAAsC,EACtC,OAAwB;QAExB,OAAO,WAAW,CAChB,qBAAqB,CACnB,IAAI,CAAC,MAAM,EACX;YACE,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,WAAW,EAAE,IAAI;SAClB,EACD,OAAO,CACR,CACF,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK,CACT,IAAqC,EACrC,OAAwB;QAExB,OAAO,WAAW,CAChB,oBAAoB,CAClB,IAAI,CAAC,MAAM,EACX;YACE,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,WAAW,EAAE,IAAI;SAClB,EACD,OAAO,CACR,CACF,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,aAAa,CAAC,OAAwB;QAC1C,OAAO,WAAW,CAChB,4BAA4B,CAC1B,IAAI,CAAC,MAAM,EACX,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,EACvC,OAAO,CACR,CACF,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU,CACd,IAA2B,EAC3B,OAAwB;QAExB,OAAO,WAAW,CAChB,yBAAyB,CACvB,IAAI,CAAC,MAAM,EACX;YACE,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,WAAW,EAAE,IAAI;SAClB,EACD,OAAO,CACR,CACF,CAAC;IACJ,CAAC;CACF"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -3,4 +3,6 @@ export * as files from "./lib/files.js";
|
|
|
3
3
|
export { HTTPClient } from "./lib/http.js";
|
|
4
4
|
export type { Fetcher, HTTPClientOptions } from "./lib/http.js";
|
|
5
5
|
export * from "./sdk/sdk.js";
|
|
6
|
+
/** Collection-scoped client (recommended). See docs/REFACTORING_PROPOSAL.md */
|
|
7
|
+
export { LambdaDBClient, CollectionHandle, DEFAULT_BASE_URL, DEFAULT_PROJECT_NAME, type RequestOptions as ClientRequestOptions, type LambdaDBClientOptions, } from "./client.js";
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,iBAAiB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAChE,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,iBAAiB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAChE,cAAc,cAAc,CAAC;AAE7B,+EAA+E;AAC/E,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,KAAK,cAAc,IAAI,oBAAoB,EAC3C,KAAK,qBAAqB,GAC3B,MAAM,aAAa,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -5,4 +5,6 @@ export * from "./lib/config.js";
|
|
|
5
5
|
export * as files from "./lib/files.js";
|
|
6
6
|
export { HTTPClient } from "./lib/http.js";
|
|
7
7
|
export * from "./sdk/sdk.js";
|
|
8
|
+
/** Collection-scoped client (recommended). See docs/REFACTORING_PROPOSAL.md */
|
|
9
|
+
export { LambdaDBClient, CollectionHandle, DEFAULT_BASE_URL, DEFAULT_PROJECT_NAME, } from "./client.js";
|
|
8
10
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,iBAAiB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,iBAAiB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,cAAc,cAAc,CAAC;AAE7B,+EAA+E;AAC/E,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,GAGrB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import dotenv from "dotenv";
|
|
2
|
+
dotenv.config();
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Example: collection-scoped API — get a collection handle once, then call
|
|
6
|
+
* methods without passing collectionName every time.
|
|
7
|
+
*
|
|
8
|
+
* Run from the examples directory:
|
|
9
|
+
* npm run build && npx tsx collectionScoped.example.ts
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { LambdaDBClient } from "@functional-systems/lambdadb";
|
|
13
|
+
|
|
14
|
+
const client = new LambdaDBClient({
|
|
15
|
+
projectApiKey: process.env.LAMBDADB_PROJECT_API_KEY ?? "<YOUR_PROJECT_API_KEY>",
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const COLLECTION_NAME = "my-collection";
|
|
19
|
+
|
|
20
|
+
async function main() {
|
|
21
|
+
const collection = client.collection(COLLECTION_NAME);
|
|
22
|
+
|
|
23
|
+
// Collection metadata
|
|
24
|
+
const meta = await collection.get();
|
|
25
|
+
console.log("Collection:", meta);
|
|
26
|
+
|
|
27
|
+
// List documents (no collectionName in the call)
|
|
28
|
+
const { docs, total, nextPageToken } = await collection.docs.list({ size: 10 });
|
|
29
|
+
console.log(`Documents: ${docs.length} of ${total}`, nextPageToken ? "(has more)" : "");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
main().catch(console.error);
|
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
1
|
import dotenv from "dotenv";
|
|
6
2
|
dotenv.config();
|
|
3
|
+
|
|
7
4
|
/**
|
|
8
|
-
* Example
|
|
5
|
+
* Example: list collections using the recommended LambdaDBClient.
|
|
9
6
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* Run from the examples directory:
|
|
8
|
+
* npm run build && npx tsx collectionsList.example.ts
|
|
12
9
|
*/
|
|
13
10
|
|
|
14
|
-
import {
|
|
11
|
+
import { LambdaDBClient } from "@functional-systems/lambdadb";
|
|
15
12
|
|
|
16
|
-
const
|
|
17
|
-
projectApiKey: "<YOUR_PROJECT_API_KEY>",
|
|
13
|
+
const client = new LambdaDBClient({
|
|
14
|
+
projectApiKey: process.env.LAMBDADB_PROJECT_API_KEY ?? "<YOUR_PROJECT_API_KEY>",
|
|
18
15
|
});
|
|
19
16
|
|
|
20
17
|
async function main() {
|
|
21
|
-
const result = await
|
|
22
|
-
|
|
18
|
+
const result = await client.listCollections();
|
|
23
19
|
console.log(result);
|
|
24
20
|
}
|
|
25
21
|
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@functional-systems/lambdadb",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-dev.1",
|
|
4
4
|
"author": "Functional Systems, Inc.",
|
|
5
5
|
"homepage": "https://github.com/lambdadb/lambdadb-typescript-client#readme",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
|
-
"repository":
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/lambdadb/lambdadb-typescript-client.git"
|
|
10
|
+
},
|
|
8
11
|
"type": "module",
|
|
9
12
|
"tshy": {
|
|
10
13
|
"sourceDialects": [
|
|
@@ -27,7 +30,6 @@
|
|
|
27
30
|
"build": "tshy",
|
|
28
31
|
"prepublishOnly": "npm run build"
|
|
29
32
|
},
|
|
30
|
-
"peerDependencies": {},
|
|
31
33
|
"devDependencies": {
|
|
32
34
|
"@eslint/js": "^9.19.0",
|
|
33
35
|
"eslint": "^9.19.0",
|