@functional-systems/lambdadb 0.3.0 → 0.3.2

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 (66) hide show
  1. package/FUNCTIONS.md +1 -1
  2. package/README.md +22 -7
  3. package/dist/commonjs/client.d.ts +28 -9
  4. package/dist/commonjs/client.d.ts.map +1 -1
  5. package/dist/commonjs/client.js +71 -12
  6. package/dist/commonjs/client.js.map +1 -1
  7. package/dist/commonjs/funcs/collectionsList.d.ts +1 -1
  8. package/dist/commonjs/funcs/collectionsList.d.ts.map +1 -1
  9. package/dist/commonjs/funcs/collectionsList.js +9 -3
  10. package/dist/commonjs/funcs/collectionsList.js.map +1 -1
  11. package/dist/commonjs/models/collectionresponse.d.ts +12 -0
  12. package/dist/commonjs/models/collectionresponse.d.ts.map +1 -1
  13. package/dist/commonjs/models/collectionresponse.js +3 -0
  14. package/dist/commonjs/models/collectionresponse.js.map +1 -1
  15. package/dist/commonjs/models/operations/listcollections.d.ts +19 -0
  16. package/dist/commonjs/models/operations/listcollections.d.ts.map +1 -1
  17. package/dist/commonjs/models/operations/listcollections.js +7 -1
  18. package/dist/commonjs/models/operations/listcollections.js.map +1 -1
  19. package/dist/commonjs/models/operations/listdocs.d.ts +17 -3
  20. package/dist/commonjs/models/operations/listdocs.d.ts.map +1 -1
  21. package/dist/commonjs/models/operations/listdocs.js +9 -2
  22. package/dist/commonjs/models/operations/listdocs.js.map +1 -1
  23. package/dist/commonjs/sdk/collections.d.ts +1 -1
  24. package/dist/commonjs/sdk/collections.d.ts.map +1 -1
  25. package/dist/commonjs/sdk/collections.js +2 -2
  26. package/dist/commonjs/sdk/collections.js.map +1 -1
  27. package/dist/commonjs/types/public.d.ts +38 -1
  28. package/dist/commonjs/types/public.d.ts.map +1 -1
  29. package/dist/commonjs/types/public.js +30 -0
  30. package/dist/commonjs/types/public.js.map +1 -1
  31. package/dist/esm/client.d.ts +28 -9
  32. package/dist/esm/client.d.ts.map +1 -1
  33. package/dist/esm/client.js +71 -12
  34. package/dist/esm/client.js.map +1 -1
  35. package/dist/esm/funcs/collectionsList.d.ts +1 -1
  36. package/dist/esm/funcs/collectionsList.d.ts.map +1 -1
  37. package/dist/esm/funcs/collectionsList.js +9 -3
  38. package/dist/esm/funcs/collectionsList.js.map +1 -1
  39. package/dist/esm/models/collectionresponse.d.ts +12 -0
  40. package/dist/esm/models/collectionresponse.d.ts.map +1 -1
  41. package/dist/esm/models/collectionresponse.js +3 -0
  42. package/dist/esm/models/collectionresponse.js.map +1 -1
  43. package/dist/esm/models/operations/listcollections.d.ts +19 -0
  44. package/dist/esm/models/operations/listcollections.d.ts.map +1 -1
  45. package/dist/esm/models/operations/listcollections.js +6 -0
  46. package/dist/esm/models/operations/listcollections.js.map +1 -1
  47. package/dist/esm/models/operations/listdocs.d.ts +17 -3
  48. package/dist/esm/models/operations/listdocs.d.ts.map +1 -1
  49. package/dist/esm/models/operations/listdocs.js +8 -1
  50. package/dist/esm/models/operations/listdocs.js.map +1 -1
  51. package/dist/esm/sdk/collections.d.ts +1 -1
  52. package/dist/esm/sdk/collections.d.ts.map +1 -1
  53. package/dist/esm/sdk/collections.js +2 -2
  54. package/dist/esm/sdk/collections.js.map +1 -1
  55. package/dist/esm/types/public.d.ts +38 -1
  56. package/dist/esm/types/public.d.ts.map +1 -1
  57. package/dist/esm/types/public.js +27 -1
  58. package/dist/esm/types/public.js.map +1 -1
  59. package/package.json +1 -1
  60. package/src/client.ts +100 -24
  61. package/src/funcs/collectionsList.ts +10 -0
  62. package/src/models/collectionresponse.ts +15 -0
  63. package/src/models/operations/listcollections.ts +29 -0
  64. package/src/models/operations/listdocs.ts +27 -2
  65. package/src/sdk/collections.ts +2 -0
  66. package/src/types/public.ts +74 -1
@@ -22,6 +22,11 @@ export type ListDocsRequest = {
22
22
  pageToken?: string | undefined;
23
23
  };
24
24
 
25
+ export type ListDocsDoc = {
26
+ collection: string;
27
+ doc: { [k: string]: any };
28
+ };
29
+
25
30
  /**
26
31
  * Documents list.
27
32
  */
@@ -30,8 +35,16 @@ export type ListDocsResponse = {
30
35
  /**
31
36
  * A list of documents.
32
37
  */
33
- docs: Array<{ [k: string]: any }>;
38
+ docs: Array<ListDocsDoc>;
34
39
  nextPageToken?: string | undefined;
40
+ /**
41
+ * Whether the list of documents is included.
42
+ */
43
+ isDocsInline: boolean;
44
+ /**
45
+ * Download URL for the list of documents.
46
+ */
47
+ docsUrl?: string | undefined;
35
48
  };
36
49
 
37
50
  /** @internal */
@@ -58,6 +71,16 @@ export function listDocsRequestToJSON(
58
71
  return JSON.stringify(ListDocsRequest$outboundSchema.parse(listDocsRequest));
59
72
  }
60
73
 
74
+ /** @internal */
75
+ export const ListDocsDoc$inboundSchema: z.ZodType<
76
+ ListDocsDoc,
77
+ z.ZodTypeDef,
78
+ unknown
79
+ > = z.object({
80
+ collection: z.string(),
81
+ doc: z.record(z.any()),
82
+ });
83
+
61
84
  /** @internal */
62
85
  export const ListDocsResponse$inboundSchema: z.ZodType<
63
86
  ListDocsResponse,
@@ -65,8 +88,10 @@ export const ListDocsResponse$inboundSchema: z.ZodType<
65
88
  unknown
66
89
  > = z.object({
67
90
  total: z.number().int(),
68
- docs: z.array(z.record(z.any())),
91
+ docs: z.array(ListDocsDoc$inboundSchema),
69
92
  nextPageToken: z.string().optional(),
93
+ isDocsInline: z.boolean(),
94
+ docsUrl: z.string().optional(),
70
95
  });
71
96
 
72
97
  export function listDocsResponseFromJSON(
@@ -27,10 +27,12 @@ export class Collections extends ClientSDK {
27
27
  * List all collections in an existing project.
28
28
  */
29
29
  async list(
30
+ request?: operations.ListCollectionsRequest,
30
31
  options?: RequestOptions,
31
32
  ): Promise<operations.ListCollectionsResponse> {
32
33
  return unwrapAsync(collectionsList(
33
34
  this,
35
+ request,
34
36
  options,
35
37
  ));
36
38
  }
@@ -14,10 +14,17 @@ export type { FetchDocsRequestBody as FetchDocsInput } from "../models/operation
14
14
  export type { BulkUpsertDocsRequestBody as BulkUpsertInput } from "../models/operations/bulkupsertdocs.js";
15
15
 
16
16
  import type { ListDocsRequest } from "../models/operations/listdocs.js";
17
+ import type { ListCollectionsRequest } from "../models/operations/listcollections.js";
17
18
 
18
19
  /** Parameters for listing documents (size, pageToken). */
19
20
  export type ListDocsInput = Pick<ListDocsRequest, "size" | "pageToken">;
20
21
 
22
+ /** Parameters for listing collections (size, pageToken). */
23
+ export type ListCollectionsInput = Pick<
24
+ ListCollectionsRequest,
25
+ "size" | "pageToken"
26
+ >;
27
+
21
28
  // ---- Response types ----
22
29
  export type { ListCollectionsResponse } from "../models/operations/listcollections.js";
23
30
  export type { CreateCollectionResponse } from "../models/operations/createcollection.js";
@@ -27,7 +34,10 @@ export type {
27
34
  QueryCollectionResponse,
28
35
  QueryCollectionDoc,
29
36
  } from "../models/operations/querycollection.js";
30
- export type { ListDocsResponse } from "../models/operations/listdocs.js";
37
+ export type {
38
+ ListDocsResponse,
39
+ ListDocsDoc,
40
+ } from "../models/operations/listdocs.js";
31
41
  export type { MessageResponse } from "../models/index.js";
32
42
  export type {
33
43
  FetchDocsResponse,
@@ -43,3 +53,66 @@ export type {
43
53
  FieldsSelectorUnion,
44
54
  CollectionResponse,
45
55
  } from "../models/index.js";
56
+
57
+ // ---- Timestamp helpers (Unix seconds → Date) ----
58
+ import type { CollectionResponse as CollectionResponseModel } from "../models/index.js";
59
+
60
+ /**
61
+ * Collection response with timestamp fields as Date (for better DX).
62
+ * Use {@link collectionResponseWithDates} to convert API response.
63
+ */
64
+ export type CollectionResponseWithDates = Omit<
65
+ CollectionResponseModel,
66
+ "createdAt" | "updatedAt" | "dataUpdatedAt"
67
+ > & {
68
+ createdAt?: Date | undefined;
69
+ updatedAt?: Date | undefined;
70
+ dataUpdatedAt?: Date | undefined;
71
+ };
72
+
73
+ /**
74
+ * List collections response with timestamp fields as Date.
75
+ */
76
+ export type ListCollectionsResponseWithDates = {
77
+ collections: CollectionResponseWithDates[];
78
+ nextPageToken?: string | undefined;
79
+ };
80
+
81
+ /**
82
+ * Converts Unix-second timestamp fields to Date. Safe to call on partial responses.
83
+ */
84
+ export function collectionResponseWithDates(
85
+ c: CollectionResponseModel,
86
+ ): CollectionResponseWithDates {
87
+ const { createdAt, updatedAt, dataUpdatedAt, ...rest } = c;
88
+ const out: CollectionResponseWithDates = { ...rest };
89
+ if (createdAt != null) out.createdAt = new Date(createdAt * 1000);
90
+ if (updatedAt != null) out.updatedAt = new Date(updatedAt * 1000);
91
+ if (dataUpdatedAt != null)
92
+ out.dataUpdatedAt = new Date(dataUpdatedAt * 1000);
93
+ return out;
94
+ }
95
+
96
+ /** Converts ListCollectionsResponse to use Date for timestamp fields. */
97
+ export function listCollectionsResponseWithDates(res: {
98
+ collections: CollectionResponseModel[];
99
+ nextPageToken?: string | undefined;
100
+ }): ListCollectionsResponseWithDates {
101
+ const out: ListCollectionsResponseWithDates = {
102
+ collections: res.collections.map(collectionResponseWithDates),
103
+ };
104
+ if (res.nextPageToken !== undefined) out.nextPageToken = res.nextPageToken;
105
+ return out;
106
+ }
107
+
108
+ /** Get collection response with timestamp fields as Date. */
109
+ export type GetCollectionResponseWithDates = {
110
+ collection: CollectionResponseWithDates;
111
+ };
112
+
113
+ /** Converts GetCollectionResponse to use Date for timestamp fields. */
114
+ export function getCollectionResponseWithDates(res: {
115
+ collection: CollectionResponseModel;
116
+ }): GetCollectionResponseWithDates {
117
+ return { collection: collectionResponseWithDates(res.collection) };
118
+ }