@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.
- package/CHANGELOG.md +55 -1
- package/README.md +9 -2
- package/dist/commonjs/lib/config.d.ts +2 -2
- package/dist/commonjs/lib/config.js +2 -2
- package/dist/commonjs/lib/config.js.map +1 -1
- package/dist/commonjs/models/operations/bulkupsertdocs.d.ts +3 -3
- package/dist/commonjs/models/operations/bulkupsertdocs.d.ts.map +1 -1
- package/dist/commonjs/models/operations/bulkupsertdocs.js +1 -1
- package/dist/commonjs/models/operations/bulkupsertdocs.js.map +1 -1
- package/dist/commonjs/models/versioning.d.ts +38 -5
- package/dist/commonjs/models/versioning.d.ts.map +1 -1
- package/dist/commonjs/models/versioning.js +22 -3
- package/dist/commonjs/models/versioning.js.map +1 -1
- package/dist/commonjs/types/public.d.ts +23 -9
- package/dist/commonjs/types/public.d.ts.map +1 -1
- package/dist/commonjs/types/public.js +22 -3
- package/dist/commonjs/types/public.js.map +1 -1
- package/dist/commonjs/versioning.d.ts +1 -1
- package/dist/commonjs/versioning.d.ts.map +1 -1
- package/dist/commonjs/versioning.js +10 -10
- package/dist/commonjs/versioning.js.map +1 -1
- package/dist/esm/lib/config.d.ts +2 -2
- package/dist/esm/lib/config.js +2 -2
- package/dist/esm/lib/config.js.map +1 -1
- package/dist/esm/models/operations/bulkupsertdocs.d.ts +3 -3
- package/dist/esm/models/operations/bulkupsertdocs.d.ts.map +1 -1
- package/dist/esm/models/operations/bulkupsertdocs.js +1 -1
- package/dist/esm/models/operations/bulkupsertdocs.js.map +1 -1
- package/dist/esm/models/versioning.d.ts +38 -5
- package/dist/esm/models/versioning.d.ts.map +1 -1
- package/dist/esm/models/versioning.js +21 -2
- package/dist/esm/models/versioning.js.map +1 -1
- package/dist/esm/types/public.d.ts +23 -9
- package/dist/esm/types/public.d.ts.map +1 -1
- package/dist/esm/types/public.js +19 -2
- package/dist/esm/types/public.js.map +1 -1
- package/dist/esm/versioning.d.ts +1 -1
- package/dist/esm/versioning.d.ts.map +1 -1
- package/dist/esm/versioning.js +12 -12
- package/dist/esm/versioning.js.map +1 -1
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/lib/config.ts +2 -2
- package/src/models/operations/bulkupsertdocs.ts +4 -4
- package/src/models/versioning.ts +58 -6
- package/src/types/public.ts +43 -9
- package/src/versioning.ts +15 -12
package/src/models/versioning.ts
CHANGED
|
@@ -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
|
|
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
|
|
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
|
-
|
|
39
|
-
|
|
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
|
|
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()
|
|
155
|
+
snapshotId: z.string(),
|
|
156
|
+
snapshotCommittedAt: z.number().int(),
|
|
105
157
|
createdAt: z.number().int(),
|
|
106
158
|
});
|
|
107
159
|
|
package/src/types/public.ts
CHANGED
|
@@ -20,7 +20,9 @@ import type {
|
|
|
20
20
|
AliasRef,
|
|
21
21
|
BranchRef,
|
|
22
22
|
ReadRef,
|
|
23
|
-
|
|
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
|
|
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
|
-
|
|
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:
|
|
103
|
-
export type ListBranchesResponse = { branches:
|
|
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:
|
|
111
|
-
export type ListTagsResponse = { tags:
|
|
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
|
|
235
|
-
return { ...details,
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
"
|
|
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:
|
|
241
|
+
source: BranchSource$schema.optional(),
|
|
239
242
|
}).strict();
|
|
240
|
-
const createBranchResponseSchema = z.object({ branch:
|
|
241
|
-
const listBranchesResponseSchema = z.object({ branches: z.array(
|
|
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:
|
|
248
|
-
const listTagsResponseSchema = z.object({ tags: z.array(
|
|
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:
|
|
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(
|
|
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:
|
|
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(
|
|
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> {
|