@functional-systems/lambdadb 0.5.0-rc.2 → 0.5.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.
Files changed (47) hide show
  1. package/CHANGELOG.md +55 -1
  2. package/README.md +9 -2
  3. package/dist/commonjs/lib/config.d.ts +2 -2
  4. package/dist/commonjs/lib/config.js +2 -2
  5. package/dist/commonjs/lib/config.js.map +1 -1
  6. package/dist/commonjs/models/operations/bulkupsertdocs.d.ts +3 -3
  7. package/dist/commonjs/models/operations/bulkupsertdocs.d.ts.map +1 -1
  8. package/dist/commonjs/models/operations/bulkupsertdocs.js +1 -1
  9. package/dist/commonjs/models/operations/bulkupsertdocs.js.map +1 -1
  10. package/dist/commonjs/models/versioning.d.ts +38 -5
  11. package/dist/commonjs/models/versioning.d.ts.map +1 -1
  12. package/dist/commonjs/models/versioning.js +22 -3
  13. package/dist/commonjs/models/versioning.js.map +1 -1
  14. package/dist/commonjs/types/public.d.ts +23 -9
  15. package/dist/commonjs/types/public.d.ts.map +1 -1
  16. package/dist/commonjs/types/public.js +22 -3
  17. package/dist/commonjs/types/public.js.map +1 -1
  18. package/dist/commonjs/versioning.d.ts +1 -1
  19. package/dist/commonjs/versioning.d.ts.map +1 -1
  20. package/dist/commonjs/versioning.js +10 -10
  21. package/dist/commonjs/versioning.js.map +1 -1
  22. package/dist/esm/lib/config.d.ts +2 -2
  23. package/dist/esm/lib/config.js +2 -2
  24. package/dist/esm/lib/config.js.map +1 -1
  25. package/dist/esm/models/operations/bulkupsertdocs.d.ts +3 -3
  26. package/dist/esm/models/operations/bulkupsertdocs.d.ts.map +1 -1
  27. package/dist/esm/models/operations/bulkupsertdocs.js +1 -1
  28. package/dist/esm/models/operations/bulkupsertdocs.js.map +1 -1
  29. package/dist/esm/models/versioning.d.ts +38 -5
  30. package/dist/esm/models/versioning.d.ts.map +1 -1
  31. package/dist/esm/models/versioning.js +21 -2
  32. package/dist/esm/models/versioning.js.map +1 -1
  33. package/dist/esm/types/public.d.ts +23 -9
  34. package/dist/esm/types/public.d.ts.map +1 -1
  35. package/dist/esm/types/public.js +19 -2
  36. package/dist/esm/types/public.js.map +1 -1
  37. package/dist/esm/versioning.d.ts +1 -1
  38. package/dist/esm/versioning.d.ts.map +1 -1
  39. package/dist/esm/versioning.js +12 -12
  40. package/dist/esm/versioning.js.map +1 -1
  41. package/jsr.json +1 -1
  42. package/package.json +1 -1
  43. package/src/lib/config.ts +2 -2
  44. package/src/models/operations/bulkupsertdocs.ts +4 -4
  45. package/src/models/versioning.ts +58 -6
  46. package/src/types/public.ts +43 -9
  47. package/src/versioning.ts +15 -12
@@ -27,16 +27,46 @@ export type BranchSource = BranchRef & {
27
27
 
28
28
  export type TagSource = TagRef;
29
29
 
30
- /** A Branch or Tag used as the source of a new Branch or Tag. */
30
+ /** A Branch or Tag used as the source of a new Tag. */
31
31
  export type RefSource = BranchSource | TagSource;
32
32
 
33
33
  /** A Branch or Tag used as the target of an Alias. */
34
34
  export type AliasTarget = BranchRef | TagRef;
35
35
 
36
- export type RefDetails = {
36
+ export type SnapshotDetails = {
37
+ snapshotId: string;
38
+ /** Snapshot commit time as Unix epoch milliseconds. */
39
+ snapshotCommittedAt: number;
40
+ };
41
+
42
+ /** Historical direct source identity, independent of snapshot origin. */
43
+ export type ParentBranchDetails = {
44
+ branchId: string;
45
+ name: string;
46
+ };
47
+
48
+ export type BranchDetails = {
37
49
  name: string;
38
- snapshotId: string | null;
39
- /** Ref creation time as Unix epoch milliseconds. */
50
+ /**
51
+ * Fixed direct source, even for an empty head or an ancestor snapshot selected
52
+ * by asOf. Null for main or unrecorded parents. Survives parent deletion and
53
+ * name reuse; this metadata does not prevent parent deletion.
54
+ */
55
+ parentBranch: ParentBranchDetails | null;
56
+ /** Current committed head; null for an empty branch. */
57
+ headSnapshot: SnapshotDetails | null;
58
+ /**
59
+ * Fixed fork snapshot, not the previous head. Null for main or an empty source.
60
+ * This metadata does not extend snapshot retention.
61
+ */
62
+ parentSnapshot: SnapshotDetails | null;
63
+ /** Branch creation time as Unix epoch milliseconds. */
64
+ createdAt: number;
65
+ };
66
+
67
+ export type TagDetails = SnapshotDetails & {
68
+ name: string;
69
+ /** Tag creation time, independent of the pinned snapshot commit time. */
40
70
  createdAt: number;
41
71
  };
42
72
 
@@ -99,9 +129,31 @@ export const AliasTarget$schema: z.ZodType<AliasTarget> = z.union([
99
129
  ]);
100
130
 
101
131
  /** @internal */
102
- export const RefDetails$inboundSchema: z.ZodType<RefDetails> = z.object({
132
+ export const SnapshotDetails$inboundSchema: z.ZodType<SnapshotDetails> = z.object({
133
+ snapshotId: z.string(),
134
+ snapshotCommittedAt: z.number().int(),
135
+ });
136
+
137
+ /** @internal */
138
+ export const ParentBranchDetails$inboundSchema: z.ZodType<ParentBranchDetails> = z.object({
139
+ branchId: z.string(),
140
+ name: z.string(),
141
+ });
142
+
143
+ /** @internal */
144
+ export const BranchDetails$inboundSchema: z.ZodType<BranchDetails> = z.object({
145
+ name: z.string(),
146
+ parentBranch: ParentBranchDetails$inboundSchema.nullable(),
147
+ headSnapshot: SnapshotDetails$inboundSchema.nullable(),
148
+ parentSnapshot: SnapshotDetails$inboundSchema.nullable(),
149
+ createdAt: z.number().int(),
150
+ });
151
+
152
+ /** @internal */
153
+ export const TagDetails$inboundSchema: z.ZodType<TagDetails> = z.object({
103
154
  name: z.string(),
104
- snapshotId: z.string().nullable(),
155
+ snapshotId: z.string(),
156
+ snapshotCommittedAt: z.number().int(),
105
157
  createdAt: z.number().int(),
106
158
  });
107
159
 
@@ -20,7 +20,9 @@ import type {
20
20
  AliasRef,
21
21
  BranchRef,
22
22
  ReadRef,
23
- RefDetails as RefDetailsModel,
23
+ BranchDetails as BranchDetailsModel,
24
+ SnapshotDetails as SnapshotDetailsModel,
25
+ TagDetails as TagDetailsModel,
24
26
  TagRef,
25
27
  } from "../models/versioning.js";
26
28
 
@@ -80,13 +82,25 @@ export type {
80
82
  AliasTarget,
81
83
  BranchRef,
82
84
  BranchSource,
85
+ ParentBranchDetails,
83
86
  ReadRef,
84
87
  RefSource,
85
88
  TagRef,
86
89
  TagSource,
87
90
  } from "../models/versioning.js";
88
91
 
89
- export type RefDetails = Omit<RefDetailsModel, "createdAt"> & {
92
+ export type SnapshotDetails = Omit<SnapshotDetailsModel, "snapshotCommittedAt"> & {
93
+ snapshotCommittedAt: Date;
94
+ };
95
+
96
+ export type BranchDetails = Omit<BranchDetailsModel, "createdAt" | "headSnapshot" | "parentSnapshot"> & {
97
+ headSnapshot: SnapshotDetails | null;
98
+ parentSnapshot: SnapshotDetails | null;
99
+ createdAt: Date;
100
+ };
101
+
102
+ export type TagDetails = Omit<TagDetailsModel, "createdAt" | "snapshotCommittedAt"> & {
103
+ snapshotCommittedAt: Date;
90
104
  createdAt: Date;
91
105
  };
92
106
 
@@ -96,19 +110,20 @@ export type AliasDetails = Omit<AliasDetailsModel, "createdAt"> & {
96
110
 
97
111
  export type CreateBranchInput = {
98
112
  branchName: string;
99
- source?: import("../models/versioning.js").RefSource | undefined;
113
+ /** Omit to use main; only Branch sources support creating a Branch. */
114
+ source?: import("../models/versioning.js").BranchSource | undefined;
100
115
  };
101
116
 
102
- export type CreateBranchResponse = { branch: RefDetails };
103
- export type ListBranchesResponse = { branches: RefDetails[] };
117
+ export type CreateBranchResponse = { branch: BranchDetails };
118
+ export type ListBranchesResponse = { branches: BranchDetails[] };
104
119
 
105
120
  export type CreateTagInput = {
106
121
  tagName: string;
107
122
  source?: import("../models/versioning.js").RefSource | undefined;
108
123
  };
109
124
 
110
- export type CreateTagResponse = { tag: RefDetails };
111
- export type ListTagsResponse = { tags: RefDetails[] };
125
+ export type CreateTagResponse = { tag: TagDetails };
126
+ export type ListTagsResponse = { tags: TagDetails[] };
112
127
 
113
128
  export type CreateAliasInput = {
114
129
  aliasName: string;
@@ -231,8 +246,27 @@ export function createCollectionResponseWithDates(
231
246
  }
232
247
 
233
248
  /** @internal */
234
- export function refDetailsWithDate(details: RefDetailsModel): RefDetails {
235
- return { ...details, createdAt: new Date(details.createdAt) };
249
+ export function snapshotDetailsWithDate(details: SnapshotDetailsModel): SnapshotDetails {
250
+ return { ...details, snapshotCommittedAt: new Date(details.snapshotCommittedAt) };
251
+ }
252
+
253
+ /** @internal */
254
+ export function branchDetailsWithDates(details: BranchDetailsModel): BranchDetails {
255
+ return {
256
+ ...details,
257
+ headSnapshot: details.headSnapshot === null ? null : snapshotDetailsWithDate(details.headSnapshot),
258
+ parentSnapshot: details.parentSnapshot === null ? null : snapshotDetailsWithDate(details.parentSnapshot),
259
+ createdAt: new Date(details.createdAt),
260
+ };
261
+ }
262
+
263
+ /** @internal */
264
+ export function tagDetailsWithDates(details: TagDetailsModel): TagDetails {
265
+ return {
266
+ ...snapshotDetailsWithDate(details),
267
+ name: details.name,
268
+ createdAt: new Date(details.createdAt),
269
+ };
236
270
  }
237
271
 
238
272
  /** @internal */
package/src/versioning.ts CHANGED
@@ -13,7 +13,9 @@ import type { SDKValidationError } from "./models/errors/sdkvalidationerror.js";
13
13
  import {
14
14
  AliasDetails$inboundSchema,
15
15
  AliasTarget$schema,
16
- RefDetails$inboundSchema,
16
+ BranchDetails$inboundSchema,
17
+ BranchSource$schema,
18
+ TagDetails$inboundSchema,
17
19
  RefSource$schema,
18
20
  type AliasRef,
19
21
  type BranchRef,
@@ -30,7 +32,8 @@ import type {
30
32
  } from "./models/errors/httpclienterrors.js";
31
33
  import {
32
34
  aliasDetailsWithDate,
33
- refDetailsWithDate,
35
+ branchDetailsWithDates,
36
+ tagDetailsWithDates,
34
37
  type AliasResponse,
35
38
  type CreateAliasInput,
36
39
  type CreateBranchInput,
@@ -47,7 +50,7 @@ import type { Result } from "./types/fp.js";
47
50
 
48
51
  /** Exact public contract revision implemented by this SDK. */
49
52
  export const DATA_VERSIONING_CONTRACT_REVISION =
50
- "b171ff0a408bbeb024535941b83b861d205a829f" as const;
53
+ "c44180406c05b1a9043d8516e7c7f60df91fc9a7" as const;
51
54
 
52
55
  const refNamePattern = /^[a-zA-Z0-9_-]{3,52}$/;
53
56
  const refNameSchema = z.string().regex(refNamePattern);
@@ -235,17 +238,17 @@ function pathFor(collectionName: string, suffix: string): string {
235
238
 
236
239
  const createBranchSchema: z.ZodType<CreateBranchInput> = z.object({
237
240
  branchName: z.string().regex(refNamePattern),
238
- source: RefSource$schema.optional(),
241
+ source: BranchSource$schema.optional(),
239
242
  }).strict();
240
- const createBranchResponseSchema = z.object({ branch: RefDetails$inboundSchema });
241
- const listBranchesResponseSchema = z.object({ branches: z.array(RefDetails$inboundSchema) });
243
+ const createBranchResponseSchema = z.object({ branch: BranchDetails$inboundSchema });
244
+ const listBranchesResponseSchema = z.object({ branches: z.array(BranchDetails$inboundSchema) });
242
245
 
243
246
  const createTagSchema: z.ZodType<CreateTagInput> = z.object({
244
247
  tagName: z.string().regex(refNamePattern),
245
248
  source: RefSource$schema.optional(),
246
249
  }).strict();
247
- const createTagResponseSchema = z.object({ tag: RefDetails$inboundSchema });
248
- const listTagsResponseSchema = z.object({ tags: z.array(RefDetails$inboundSchema) });
250
+ const createTagResponseSchema = z.object({ tag: TagDetails$inboundSchema });
251
+ const listTagsResponseSchema = z.object({ tags: z.array(TagDetails$inboundSchema) });
249
252
 
250
253
  const createAliasSchema: z.ZodType<CreateAliasInput> = z.object({
251
254
  aliasName: z.string().regex(refNamePattern),
@@ -284,7 +287,7 @@ export class CollectionBranches {
284
287
  conflict: "already-exists",
285
288
  }, options);
286
289
  if (!result.ok) return result;
287
- return { ok: true, value: { branch: refDetailsWithDate(result.value.branch) } };
290
+ return { ok: true, value: { branch: branchDetailsWithDates(result.value.branch) } };
288
291
  }
289
292
 
290
293
  async list(options?: RequestOptions): Promise<ListBranchesResponse> {
@@ -301,7 +304,7 @@ export class CollectionBranches {
301
304
  successStatus: 200,
302
305
  }, options);
303
306
  if (!result.ok) return result;
304
- return { ok: true, value: { branches: result.value.branches.map(refDetailsWithDate) } };
307
+ return { ok: true, value: { branches: result.value.branches.map(branchDetailsWithDates) } };
305
308
  }
306
309
 
307
310
  async delete(branchName: string, options?: RequestOptions): Promise<MessageResponse> {
@@ -356,7 +359,7 @@ export class CollectionTags {
356
359
  conflict: "already-exists",
357
360
  }, options);
358
361
  if (!result.ok) return result;
359
- return { ok: true, value: { tag: refDetailsWithDate(result.value.tag) } };
362
+ return { ok: true, value: { tag: tagDetailsWithDates(result.value.tag) } };
360
363
  }
361
364
 
362
365
  async list(options?: RequestOptions): Promise<ListTagsResponse> {
@@ -373,7 +376,7 @@ export class CollectionTags {
373
376
  successStatus: 200,
374
377
  }, options);
375
378
  if (!result.ok) return result;
376
- return { ok: true, value: { tags: result.value.tags.map(refDetailsWithDate) } };
379
+ return { ok: true, value: { tags: result.value.tags.map(tagDetailsWithDates) } };
377
380
  }
378
381
 
379
382
  async delete(tagName: string, options?: RequestOptions): Promise<MessageResponse> {