@kubun/mutation 0.4.0 → 0.6.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/lib/apply.d.ts +10 -1
- package/lib/apply.js +1 -100
- package/lib/create.d.ts +7 -6
- package/lib/create.js +1 -52
- package/lib/hlc.d.ts +19 -0
- package/lib/hlc.js +1 -0
- package/lib/index.d.ts +3 -1
- package/lib/index.js +1 -2
- package/lib/operations.d.ts +19 -0
- package/lib/operations.js +1 -0
- package/package.json +7 -10
- package/lib/apply.d.ts.map +0 -1
- package/lib/automerge.d.ts +0 -5
- package/lib/automerge.d.ts.map +0 -1
- package/lib/automerge.js +0 -7
- package/lib/create.d.ts.map +0 -1
- package/lib/index.d.ts.map +0 -1
package/lib/apply.d.ts
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import { type Validator } from '@enkaku/schema';
|
|
2
2
|
import type { KubunDB } from '@kubun/db';
|
|
3
3
|
import type { ChangeDocumentMutation, DocumentData, DocumentMutation, DocumentNode, SetDocumentMutation } from '@kubun/protocol';
|
|
4
|
+
import { HLC } from './hlc.js';
|
|
4
5
|
export type DocumentValidator = Validator<DocumentData>;
|
|
5
6
|
export type ValidatorsRecord = Record<string, Promise<DocumentValidator>>;
|
|
7
|
+
export type AccessChecker = (doc: {
|
|
8
|
+
id: string;
|
|
9
|
+
model: string;
|
|
10
|
+
owner: string;
|
|
11
|
+
data: DocumentData | null;
|
|
12
|
+
}, permissionType: 'read' | 'write') => Promise<boolean>;
|
|
6
13
|
export type MutationContext = {
|
|
7
14
|
db: KubunDB;
|
|
8
15
|
validators: ValidatorsRecord;
|
|
16
|
+
accessChecker?: AccessChecker;
|
|
17
|
+
hlc?: HLC;
|
|
18
|
+
maxDriftMS?: number;
|
|
9
19
|
};
|
|
10
20
|
export declare function getDocumentValidator(ctx: MutationContext, id: string): Promise<DocumentValidator>;
|
|
11
21
|
export declare function applyChangeMutation(ctx: MutationContext, mutation: ChangeDocumentMutation): Promise<DocumentNode>;
|
|
12
22
|
export declare function applySetMutation(ctx: MutationContext, mutation: SetDocumentMutation): Promise<DocumentNode>;
|
|
13
23
|
export declare function applyMutation(ctx: MutationContext, mutation: DocumentMutation): Promise<DocumentNode>;
|
|
14
|
-
//# sourceMappingURL=apply.d.ts.map
|
package/lib/apply.js
CHANGED
|
@@ -1,100 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { fromB64 } from '@enkaku/codec';
|
|
3
|
-
import { asType, createValidator } from '@enkaku/schema';
|
|
4
|
-
import { DocumentID } from '@kubun/id';
|
|
5
|
-
import { automergeReady, automergeToData } from './automerge.js';
|
|
6
|
-
export function getDocumentValidator(ctx, id) {
|
|
7
|
-
if (ctx.validators[id] == null) {
|
|
8
|
-
ctx.validators[id] = ctx.db.getDocumentModel(id).then((model)=>createValidator({
|
|
9
|
-
...model.schema,
|
|
10
|
-
$id: id
|
|
11
|
-
}));
|
|
12
|
-
}
|
|
13
|
-
return ctx.validators[id];
|
|
14
|
-
}
|
|
15
|
-
export async function applyChangeMutation(ctx, mutation) {
|
|
16
|
-
const id = DocumentID.fromString(mutation.sub);
|
|
17
|
-
const docID = id.toString();
|
|
18
|
-
const doc = await ctx.db.getDocument(id);
|
|
19
|
-
if (doc == null) {
|
|
20
|
-
throw new Error(`Document not found: ${docID}`);
|
|
21
|
-
}
|
|
22
|
-
if (mutation.iss !== doc.owner) {
|
|
23
|
-
// TODO: verify capabilities if issuer is not owner
|
|
24
|
-
throw new Error('Invalid mutation issuer');
|
|
25
|
-
}
|
|
26
|
-
if (mutation.data === null) {
|
|
27
|
-
return await ctx.db.saveDocument({
|
|
28
|
-
id,
|
|
29
|
-
existing: doc,
|
|
30
|
-
data: null,
|
|
31
|
-
state: null
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
if (doc.data === null) {
|
|
35
|
-
throw new Error(`Cannot apply changes to empty document: ${docID}`);
|
|
36
|
-
}
|
|
37
|
-
const [docStates, validator] = await Promise.all([
|
|
38
|
-
ctx.db.getDocumentStates([
|
|
39
|
-
docID
|
|
40
|
-
]),
|
|
41
|
-
getDocumentValidator(ctx, id.model.toString()),
|
|
42
|
-
automergeReady
|
|
43
|
-
]);
|
|
44
|
-
// Create doc from data object if state is not present
|
|
45
|
-
const currentDoc = docStates[docID] ? A.load(docStates[docID]) : A.from(doc.data);
|
|
46
|
-
const changes = fromB64(mutation.data);
|
|
47
|
-
// Apply incremental changes or full merge
|
|
48
|
-
const newDoc = mutation.inc ? A.loadIncremental(currentDoc, changes) : A.merge(currentDoc, A.load(changes));
|
|
49
|
-
// Validate merged data
|
|
50
|
-
const data = asType(validator, automergeToData(newDoc));
|
|
51
|
-
return await ctx.db.saveDocument({
|
|
52
|
-
id,
|
|
53
|
-
existing: doc,
|
|
54
|
-
data,
|
|
55
|
-
state: A.save(newDoc)
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
export async function applySetMutation(ctx, mutation) {
|
|
59
|
-
const owner = mutation.aud ?? mutation.iss;
|
|
60
|
-
if (mutation.iss !== owner) {
|
|
61
|
-
// TODO: verify capabilities if issuer is not owner
|
|
62
|
-
throw new Error('Invalid mutation issuer');
|
|
63
|
-
}
|
|
64
|
-
const id = DocumentID.fromString(mutation.sub);
|
|
65
|
-
const [doc, validator] = await Promise.all([
|
|
66
|
-
ctx.db.getDocument(id),
|
|
67
|
-
getDocumentValidator(ctx, id.model.toString()),
|
|
68
|
-
automergeReady
|
|
69
|
-
]);
|
|
70
|
-
const mergeDoc = mutation.data === null ? null : A.load(fromB64(mutation.data));
|
|
71
|
-
const data = mergeDoc ? asType(validator, automergeToData(mergeDoc)) : null;
|
|
72
|
-
if (doc === null) {
|
|
73
|
-
return await ctx.db.createDocument({
|
|
74
|
-
id,
|
|
75
|
-
owner,
|
|
76
|
-
data,
|
|
77
|
-
state: mergeDoc ? A.save(mergeDoc) : null,
|
|
78
|
-
unique: fromB64(mutation.unq)
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
if (doc.owner !== owner) {
|
|
82
|
-
throw new Error(`Cannot change owner from ${doc.owner} to ${owner} in document: ${id.toString()}`);
|
|
83
|
-
}
|
|
84
|
-
return await ctx.db.saveDocument({
|
|
85
|
-
id,
|
|
86
|
-
existing: doc,
|
|
87
|
-
data,
|
|
88
|
-
state: mergeDoc ? A.save(mergeDoc) : null
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
export async function applyMutation(ctx, mutation) {
|
|
92
|
-
switch(mutation.typ){
|
|
93
|
-
case 'change':
|
|
94
|
-
return await applyChangeMutation(ctx, mutation);
|
|
95
|
-
case 'set':
|
|
96
|
-
return await applySetMutation(ctx, mutation);
|
|
97
|
-
default:
|
|
98
|
-
throw new Error('Unsupported mutation type');
|
|
99
|
-
}
|
|
100
|
-
}
|
|
1
|
+
import{fromB64 as t}from"@enkaku/codec";import{asType as e,createValidator as a}from"@enkaku/schema";import{DocumentID as r}from"@kubun/id";import{HLC as i}from"./hlc.js";export function getDocumentValidator(t,e){return null==t.validators[e]&&(t.validators[e]=t.db.getDocumentModel(e).then(t=>a({...t.schema,$id:e}))),t.validators[e]}function n(t,e,a){let r=i.parse(t),n=Date.now(),o=r.wallTime-n;if(o>e)throw Error(`HLC timestamp too far in the future: ${o}ms drift exceeds ${e}ms limit`);a&&a.receive(r)}export async function applyChangeMutation(t,a){let i=r.fromString(a.sub),o=i.toString(),l=await t.db.getDocument(i);if(null==l)throw Error(`Document not found: ${o}`);if(a.iss!==l.owner)throw Error("Invalid mutation issuer");if(t.accessChecker&&!await t.accessChecker(l,"write"))throw Error(`Access denied: cannot write document ${o}`);null!=t.maxDriftMS&&n(a.hlc,t.maxDriftMS,t.hlc);let c=i.model.toString(),u=await t.db.getFieldHLCs(o)??{};if(1===a.patch.length&&"replace"===a.patch[0].op&&"/"===a.patch[0].path&&null===a.patch[0].value){let e={...u,"/":a.hlc},r=Object.entries(e).every(([t,e])=>"/"===t||a.hlc>=e);return(await t.db.updateFieldHLCs(i,e),r)?await t.db.saveDocument({id:i,existing:l,data:null}):l}if(null!=u["/"]&&null===l.data)return l;let s=await getDocumentValidator(t,c),d=a.patch.filter(t=>"value"in t),h={...l.data??{}},m={...u},f=!1;for(let t of d){let e=u[t.path];(null==e||a.hlc>e)&&(h[t.path.slice(1)]=t.value,m[t.path]=a.hlc,f=!0)}if(!f)return l;await t.db.updateFieldHLCs(i,m);let p=e(s,h);return await t.db.saveDocument({id:i,existing:l,data:p})}export async function applySetMutation(a,i){let o=i.aud??i.iss;if(i.iss!==o)throw Error("Invalid mutation issuer");let l=r.fromString(i.sub),c=l.toString(),u=l.model.toString();null!=a.maxDriftMS&&n(i.hlc,a.maxDriftMS,a.hlc);let[s,d]=await Promise.all([a.db.getDocument(l),getDocumentValidator(a,u)]),h=e(d,i.data),m={};for(let t of Object.keys(h))m[`/${t}`]=i.hlc;if(null===s){let e=await a.db.createDocument({id:l,owner:o,data:h,unique:t(i.unq)});return await a.db.updateFieldHLCs(l,m),e}if(s.owner!==o)throw Error(`Cannot change owner from ${s.owner} to ${o} in document: ${l.toString()}`);if(a.accessChecker&&!await a.accessChecker(s,"write"))throw Error(`Access denied: cannot write document ${l.toString()}`);let f=await a.db.getFieldHLCs(c)??{},p={...s.data??{}},w={...f},g=!1;for(let[t,e]of Object.entries(h)){let a=`/${t}`,r=f[a];(null==r||i.hlc>r)&&(p[t]=e,w[a]=i.hlc,g=!0)}if(!g)return s;await a.db.updateFieldHLCs(l,w);let b=e(d,p);return await a.db.saveDocument({id:l,existing:s,data:b})}export async function applyMutation(t,e){switch(e.typ){case"change":return await applyChangeMutation(t,e);case"set":return await applySetMutation(t,e);default:throw Error("Unsupported mutation type")}}
|
package/lib/create.d.ts
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import type { PatchOperation } from '@kubun/graphql';
|
|
2
2
|
import { DocumentID, type DocumentModelID } from '@kubun/id';
|
|
3
3
|
import type { ChangeDocumentMutation, DocumentData, SetDocumentMutation } from '@kubun/protocol';
|
|
4
|
+
import { HLC } from './hlc.js';
|
|
4
5
|
export type CreateSetMutationParams<Data extends DocumentData = DocumentData> = {
|
|
5
|
-
data: Data
|
|
6
|
+
data: Data;
|
|
7
|
+
hlc: HLC;
|
|
6
8
|
issuer: string;
|
|
7
9
|
modelID: DocumentModelID | string;
|
|
8
10
|
owner?: string;
|
|
9
11
|
unique: Uint8Array;
|
|
10
12
|
};
|
|
11
13
|
export declare function createSetMutation<Data extends DocumentData = DocumentData>(params: CreateSetMutationParams<Data>): Promise<SetDocumentMutation>;
|
|
12
|
-
export type CreateChangeMutationParams
|
|
14
|
+
export type CreateChangeMutationParams = {
|
|
13
15
|
docID: DocumentID | string;
|
|
14
|
-
|
|
16
|
+
hlc: HLC;
|
|
15
17
|
issuer: string;
|
|
16
|
-
loadState: (id: string) => Promise<Uint8Array | null>;
|
|
17
18
|
patch: Array<PatchOperation>;
|
|
18
19
|
};
|
|
19
|
-
export declare function createChangeMutation
|
|
20
|
+
export declare function createChangeMutation(params: CreateChangeMutationParams): ChangeDocumentMutation;
|
|
20
21
|
export type CreateRemoveMutationParams = {
|
|
21
22
|
docID: string;
|
|
23
|
+
hlc: HLC;
|
|
22
24
|
issuer: string;
|
|
23
25
|
};
|
|
24
26
|
export declare function createRemoveMutation(params: CreateRemoveMutationParams): ChangeDocumentMutation;
|
|
25
|
-
//# sourceMappingURL=create.d.ts.map
|
package/lib/create.js
CHANGED
|
@@ -1,52 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { toB64 } from '@enkaku/codec';
|
|
3
|
-
import { applyPatches } from '@enkaku/patch';
|
|
4
|
-
import { DocumentID } from '@kubun/id';
|
|
5
|
-
import { automergeReady } from './automerge.js';
|
|
6
|
-
export async function createSetMutation(params) {
|
|
7
|
-
const issuer = params.issuer;
|
|
8
|
-
const owner = params.owner ?? issuer;
|
|
9
|
-
const [docID] = await Promise.all([
|
|
10
|
-
DocumentID.create(params.modelID, owner, params.unique),
|
|
11
|
-
automergeReady
|
|
12
|
-
]);
|
|
13
|
-
return {
|
|
14
|
-
typ: 'set',
|
|
15
|
-
iss: issuer,
|
|
16
|
-
aud: owner,
|
|
17
|
-
sub: docID.toString(),
|
|
18
|
-
data: params.data == null ? null : toB64(A.save(A.from(params.data))),
|
|
19
|
-
unq: toB64(params.unique)
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export async function createChangeMutation(params) {
|
|
23
|
-
const docID = DocumentID.from(params.docID).toString();
|
|
24
|
-
// Load current state of document from DB
|
|
25
|
-
const [state] = await Promise.all([
|
|
26
|
-
params.loadState(docID),
|
|
27
|
-
automergeReady
|
|
28
|
-
]);
|
|
29
|
-
const loadedDoc = state ? A.load(state) : null;
|
|
30
|
-
// Apply patches to loaded doc or locally created one
|
|
31
|
-
const newDoc = A.change(loadedDoc ?? A.from(params.from ?? {}), (proxy)=>{
|
|
32
|
-
applyPatches(proxy, params.patch);
|
|
33
|
-
});
|
|
34
|
-
// Save incremental or full data state
|
|
35
|
-
const data = loadedDoc ? A.saveSince(newDoc, A.getHeads(loadedDoc)) : A.save(newDoc);
|
|
36
|
-
return {
|
|
37
|
-
typ: 'change',
|
|
38
|
-
iss: params.issuer,
|
|
39
|
-
sub: docID,
|
|
40
|
-
data: toB64(data),
|
|
41
|
-
inc: loadedDoc != null
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
export function createRemoveMutation(params) {
|
|
45
|
-
return {
|
|
46
|
-
typ: 'change',
|
|
47
|
-
iss: params.issuer,
|
|
48
|
-
sub: params.docID,
|
|
49
|
-
data: null,
|
|
50
|
-
inc: false
|
|
51
|
-
};
|
|
52
|
-
}
|
|
1
|
+
import{toB64 as e}from"@enkaku/codec";import{DocumentID as t}from"@kubun/id";import{HLC as r}from"./hlc.js";export async function createSetMutation(a){let n=a.issuer,o=a.owner??n,i=await t.create(a.modelID,o,a.unique);return{typ:"set",iss:n,aud:o,sub:i.toString(),data:a.data,hlc:r.serialize(a.hlc.now()),unq:e(a.unique)}}export function createChangeMutation(e){return{typ:"change",iss:e.issuer,sub:t.from(e.docID).toString(),patch:e.patch,hlc:r.serialize(e.hlc.now())}}export function createRemoveMutation(e){return{typ:"change",iss:e.issuer,sub:e.docID,patch:[{op:"replace",path:"/",value:null}],hlc:r.serialize(e.hlc.now())}}
|
package/lib/hlc.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type HLCTimestamp = {
|
|
2
|
+
wallTime: number;
|
|
3
|
+
counter: number;
|
|
4
|
+
nodeID: string;
|
|
5
|
+
};
|
|
6
|
+
type HLCParams = {
|
|
7
|
+
nodeID: string;
|
|
8
|
+
};
|
|
9
|
+
export declare class HLC {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(params: HLCParams);
|
|
12
|
+
get nodeID(): string;
|
|
13
|
+
now(): HLCTimestamp;
|
|
14
|
+
receive(remote: HLCTimestamp): HLCTimestamp;
|
|
15
|
+
static serialize(ts: HLCTimestamp): string;
|
|
16
|
+
static parse(s: string): HLCTimestamp;
|
|
17
|
+
static compare(a: HLCTimestamp, b: HLCTimestamp): number;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
package/lib/hlc.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export class HLC{#t;#e=0;#l=0;constructor(t){this.#t=t.nodeID}get nodeID(){return this.#t}now(){let t=Date.now();return t>this.#e?(this.#e=t,this.#l=0):this.#l++,{wallTime:this.#e,counter:this.#l,nodeID:this.#t}}receive(t){let e=Date.now();return e>this.#e&&e>t.wallTime?(this.#e=e,this.#l=0):t.wallTime>this.#e?(this.#e=t.wallTime,this.#l=t.counter+1):this.#e>t.wallTime?this.#l++:this.#l=Math.max(this.#l,t.counter)+1,{wallTime:this.#e,counter:this.#l,nodeID:this.#t}}static serialize(t){let e=new Date(t.wallTime).toISOString(),l=t.counter.toString().padStart(4,"0");return`${e}:${l}:${t.nodeID}`}static parse(t){let e=t.indexOf("Z"),l=new Date(t.slice(0,e+1)).getTime(),i=t.slice(e+2),a=i.indexOf(":");return{wallTime:l,counter:Number.parseInt(i.slice(0,a),10),nodeID:i.slice(a+1)}}static compare(t,e){return t.wallTime!==e.wallTime?t.wallTime-e.wallTime:t.counter!==e.counter?t.counter-e.counter:t.nodeID<e.nodeID?-1:+(t.nodeID>e.nodeID)}}
|
package/lib/index.d.ts
CHANGED
|
@@ -2,4 +2,6 @@ export type { DocumentValidator, MutationContext, ValidatorsRecord } from './app
|
|
|
2
2
|
export { applyChangeMutation, applyMutation, applySetMutation } from './apply.js';
|
|
3
3
|
export type { CreateChangeMutationParams, CreateRemoveMutationParams, CreateSetMutationParams, } from './create.js';
|
|
4
4
|
export { createChangeMutation, createRemoveMutation, createSetMutation } from './create.js';
|
|
5
|
-
|
|
5
|
+
export { HLC, type HLCTimestamp } from './hlc.js';
|
|
6
|
+
export type { CreateMutationOperationsParams, GetRandomValues, MutationOperations, } from './operations.js';
|
|
7
|
+
export { convertPatchInput, createMutationOperations } from './operations.js';
|
package/lib/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export { createChangeMutation, createRemoveMutation, createSetMutation } from './create.js';
|
|
1
|
+
export{applyChangeMutation,applyMutation,applySetMutation}from"./apply.js";export{createChangeMutation,createRemoveMutation,createSetMutation}from"./create.js";export{HLC}from"./hlc.js";export{convertPatchInput,createMutationOperations}from"./operations.js";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PatchOperation } from '@kubun/graphql';
|
|
2
|
+
import type { ChangeDocumentMutation, DocumentData, SetDocumentMutation } from '@kubun/protocol';
|
|
3
|
+
import type { HLC } from './hlc.js';
|
|
4
|
+
export type GetRandomValues = <T extends ArrayBufferView>(array: T) => T;
|
|
5
|
+
export type CreateMutationOperationsParams<T> = {
|
|
6
|
+
issuer: string;
|
|
7
|
+
hlc: HLC;
|
|
8
|
+
getRandomValues?: GetRandomValues;
|
|
9
|
+
processSetMutation(mutation: SetDocumentMutation): Promise<T>;
|
|
10
|
+
processChangeMutation(mutation: ChangeDocumentMutation): Promise<T>;
|
|
11
|
+
};
|
|
12
|
+
export type MutationOperations<T> = {
|
|
13
|
+
createDocument(modelID: string, data: DocumentData): Promise<T>;
|
|
14
|
+
setDocument(modelID: string, unique: Uint8Array, data: DocumentData): Promise<T>;
|
|
15
|
+
updateDocument(docID: string, patch: Array<PatchOperation>): Promise<T>;
|
|
16
|
+
removeDocument(docID: string): Promise<T>;
|
|
17
|
+
};
|
|
18
|
+
export declare function createMutationOperations<T>(params: CreateMutationOperationsParams<T>): MutationOperations<T>;
|
|
19
|
+
export declare function convertPatchInput(patch: Array<Record<string, unknown>>): Array<PatchOperation>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createChangeMutation as t,createRemoveMutation as e,createSetMutation as a}from"./create.js";export function createMutationOperations(n){let{issuer:r,hlc:o,processSetMutation:c,processChangeMutation:u}=n,i=n.getRandomValues??globalThis.crypto.getRandomValues.bind(globalThis.crypto);return{async createDocument(t,e){let n=i(new Uint8Array(12)),u=await a({issuer:r,hlc:o,modelID:t,data:e,unique:n});return await c(u)},async setDocument(t,e,n){let u=await a({issuer:r,hlc:o,modelID:t,data:n,unique:e});return await c(u)},async updateDocument(e,a){let n=t({issuer:r,hlc:o,docID:e,patch:a});return await u(n)},async removeDocument(t){let a=e({docID:t,issuer:r,hlc:o});return await u(a)}}}export function convertPatchInput(t){return t.map(t=>{let[e,a]=Object.entries(t)[0];return{...a,op:e}})}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubun/mutation",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"license": "see LICENSE.md",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"type": "module",
|
|
@@ -15,17 +15,14 @@
|
|
|
15
15
|
],
|
|
16
16
|
"sideEffects": false,
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@
|
|
19
|
-
"@enkaku/
|
|
20
|
-
"@
|
|
21
|
-
"@enkaku/patch": "^0.12.3",
|
|
22
|
-
"@enkaku/schema": "^0.12.1",
|
|
23
|
-
"@kubun/id": "^0.4.0"
|
|
18
|
+
"@enkaku/codec": "^0.13.0",
|
|
19
|
+
"@enkaku/schema": "^0.13.0",
|
|
20
|
+
"@kubun/id": "^0.6.0"
|
|
24
21
|
},
|
|
25
22
|
"devDependencies": {
|
|
26
|
-
"@kubun/
|
|
27
|
-
"@kubun/
|
|
28
|
-
"@kubun/protocol": "^0.
|
|
23
|
+
"@kubun/db": "^0.6.0",
|
|
24
|
+
"@kubun/graphql": "^0.6.0",
|
|
25
|
+
"@kubun/protocol": "^0.6.0"
|
|
29
26
|
},
|
|
30
27
|
"scripts": {
|
|
31
28
|
"build:clean": "del lib",
|
package/lib/apply.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../src/apply.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2B,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACxE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAExC,OAAO,KAAK,EACV,sBAAsB,EACtB,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACpB,MAAM,iBAAiB,CAAA;AAIxB,MAAM,MAAM,iBAAiB,GAAG,SAAS,CAAC,YAAY,CAAC,CAAA;AACvD,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAA;AAEzE,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,OAAO,CAAA;IACX,UAAU,EAAE,gBAAgB,CAAA;CAC7B,CAAA;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAOjG;AAED,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,eAAe,EACpB,QAAQ,EAAE,sBAAsB,GAC/B,OAAO,CAAC,YAAY,CAAC,CAoCvB;AAED,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,eAAe,EACpB,QAAQ,EAAE,mBAAmB,GAC5B,OAAO,CAAC,YAAY,CAAC,CAqCvB;AAED,wBAAsB,aAAa,CACjC,GAAG,EAAE,eAAe,EACpB,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,YAAY,CAAC,CASvB"}
|
package/lib/automerge.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import * as A from '@automerge/automerge/slim';
|
|
2
|
-
import type { DocumentData } from '@kubun/protocol';
|
|
3
|
-
export declare const automergeReady: import("@enkaku/async").LazyPromise<void>;
|
|
4
|
-
export declare function automergeToData(doc: A.Doc<DocumentData>): DocumentData;
|
|
5
|
-
//# sourceMappingURL=automerge.d.ts.map
|
package/lib/automerge.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"automerge.d.ts","sourceRoot":"","sources":["../src/automerge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,2BAA2B,CAAA;AAE9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAEnD,eAAO,MAAM,cAAc,2CAA0D,CAAA;AAErF,wBAAgB,eAAe,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,YAAY,CAEtE"}
|
package/lib/automerge.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { automergeWasmBase64 } from '@automerge/automerge/automerge.wasm.base64';
|
|
2
|
-
import * as A from '@automerge/automerge/slim';
|
|
3
|
-
import { lazy } from '@enkaku/async';
|
|
4
|
-
export const automergeReady = lazy(()=>A.initializeBase64Wasm(automergeWasmBase64));
|
|
5
|
-
export function automergeToData(doc) {
|
|
6
|
-
return JSON.parse(JSON.stringify(doc));
|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