@shapeshift-labs/frontier-engine 0.0.0 → 0.1.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/README.md +198 -9
- package/benchmarks/package-bench.mjs +71 -0
- package/dist/engine.d.ts +3 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +3843 -0
- package/dist/engine.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/profile.d.ts +25 -0
- package/dist/profile.d.ts.map +1 -0
- package/dist/profile.js +268 -0
- package/dist/profile.js.map +1 -0
- package/dist/types.d.ts +121 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +54 -13
- package/index.js +0 -1
package/dist/profile.js
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
export function readProfilePlans(profile, label = 'profile') {
|
|
2
|
+
if (profile === undefined || profile === null || profile.plans === undefined)
|
|
3
|
+
return undefined;
|
|
4
|
+
return normalizeProfilePlans(profile.plans, label + ' plans');
|
|
5
|
+
}
|
|
6
|
+
export function cloneProfilePlans(plans) {
|
|
7
|
+
return plans === undefined ? undefined : normalizeProfilePlans(plans, 'profile plans');
|
|
8
|
+
}
|
|
9
|
+
export function mergeProfilePlans(...items) {
|
|
10
|
+
let out;
|
|
11
|
+
for (let i = 0, length = items.length; i < length; i++) {
|
|
12
|
+
const item = items[i];
|
|
13
|
+
if (item === undefined)
|
|
14
|
+
continue;
|
|
15
|
+
const normalized = normalizeProfilePlans(item, 'profile plans');
|
|
16
|
+
if (out === undefined)
|
|
17
|
+
out = {};
|
|
18
|
+
if (normalized.diff !== undefined)
|
|
19
|
+
out.diff = { ...(out.diff || {}), ...normalized.diff };
|
|
20
|
+
if (normalized.equality !== undefined)
|
|
21
|
+
out.equality = { ...(out.equality || {}), ...normalized.equality };
|
|
22
|
+
if (normalized.history !== undefined)
|
|
23
|
+
out.history = { ...(out.history || {}), ...normalized.history };
|
|
24
|
+
if (normalized.codec !== undefined)
|
|
25
|
+
out.codec = { ...(out.codec || {}), ...normalized.codec };
|
|
26
|
+
if (normalized.state !== undefined)
|
|
27
|
+
out.state = { ...(out.state || {}), ...normalized.state };
|
|
28
|
+
if (normalized.crdt !== undefined)
|
|
29
|
+
out.crdt = { ...(out.crdt || {}), ...normalized.crdt };
|
|
30
|
+
}
|
|
31
|
+
return out === undefined || Object.keys(out).length === 0 ? undefined : out;
|
|
32
|
+
}
|
|
33
|
+
export function createEngineProfilePlansSnapshot(inherited, snapshot) {
|
|
34
|
+
const generated = {
|
|
35
|
+
diff: createDiffPlan(snapshot),
|
|
36
|
+
equality: createEqualityPlan(snapshot),
|
|
37
|
+
history: {
|
|
38
|
+
strategy: snapshot.historyStrategy || 'auto'
|
|
39
|
+
},
|
|
40
|
+
codec: {
|
|
41
|
+
patch: 'auto',
|
|
42
|
+
history: 'binary'
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
return mergeProfilePlans(inherited, generated);
|
|
46
|
+
}
|
|
47
|
+
export function createStateProfilePlansSnapshot(inherited, stats) {
|
|
48
|
+
const state = {
|
|
49
|
+
routing: 'patch-router',
|
|
50
|
+
apply: 'owned-mutable'
|
|
51
|
+
};
|
|
52
|
+
if (stats.watches !== 0) {
|
|
53
|
+
state.watches = stats.watches;
|
|
54
|
+
if (stats.exactWatches !== 0)
|
|
55
|
+
state.exactWatches = stats.exactWatches;
|
|
56
|
+
if (stats.wildcardWatches !== 0)
|
|
57
|
+
state.wildcardWatches = stats.wildcardWatches;
|
|
58
|
+
if (stats.fieldWatches !== 0)
|
|
59
|
+
state.fieldWatches = stats.fieldWatches;
|
|
60
|
+
if (stats.rangeWatches !== 0)
|
|
61
|
+
state.rangeWatches = stats.rangeWatches;
|
|
62
|
+
}
|
|
63
|
+
return mergeProfilePlans(inherited, { state });
|
|
64
|
+
}
|
|
65
|
+
export function createCrdtProfilePlansSnapshot(inherited, nativeTextProfileCount) {
|
|
66
|
+
const crdt = {
|
|
67
|
+
update: nativeTextProfileCount === 0 ? 'binary' : 'columnar-text',
|
|
68
|
+
text: nativeTextProfileCount === 0 ? 'chunked-ids' : 'native-piece'
|
|
69
|
+
};
|
|
70
|
+
return mergeProfilePlans(inherited, {
|
|
71
|
+
codec: { crdt: crdt.update === 'columnar-text' ? 'columnar-text' : 'binary' },
|
|
72
|
+
crdt
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function createDiffPlan(snapshot) {
|
|
76
|
+
const plan = {
|
|
77
|
+
strategy: snapshot.schemaCount === 0
|
|
78
|
+
? 'structural'
|
|
79
|
+
: snapshot.adaptivePlan
|
|
80
|
+
? 'adaptive-schema'
|
|
81
|
+
: 'schema',
|
|
82
|
+
schemaCount: snapshot.schemaCount
|
|
83
|
+
};
|
|
84
|
+
if (snapshot.schemaPaths !== undefined && snapshot.schemaPaths.length !== 0) {
|
|
85
|
+
plan.paths = clonePathList(snapshot.schemaPaths);
|
|
86
|
+
}
|
|
87
|
+
return plan;
|
|
88
|
+
}
|
|
89
|
+
function createEqualityPlan(snapshot) {
|
|
90
|
+
const settings = snapshot.settings || {};
|
|
91
|
+
if (isObjectKey(settings.versionKey)) {
|
|
92
|
+
return { strategy: 'token', token: 'versionKey', key: settings.versionKey };
|
|
93
|
+
}
|
|
94
|
+
if (isObjectKey(settings.fingerprintKey)) {
|
|
95
|
+
return { strategy: 'token', token: 'fingerprintKey', key: settings.fingerprintKey };
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
strategy: snapshot.schemaCount === 0 ? 'fast-json' : 'schema'
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function normalizeProfilePlans(value, label) {
|
|
102
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value)) {
|
|
103
|
+
throw new TypeError(label + ' must be an object');
|
|
104
|
+
}
|
|
105
|
+
const input = value;
|
|
106
|
+
const out = {};
|
|
107
|
+
if (input.diff !== undefined)
|
|
108
|
+
out.diff = normalizeDiffPlan(input.diff, label + '.diff');
|
|
109
|
+
if (input.equality !== undefined)
|
|
110
|
+
out.equality = normalizeEqualityPlan(input.equality, label + '.equality');
|
|
111
|
+
if (input.history !== undefined)
|
|
112
|
+
out.history = normalizeHistoryPlan(input.history, label + '.history');
|
|
113
|
+
if (input.codec !== undefined)
|
|
114
|
+
out.codec = normalizeCodecPlan(input.codec, label + '.codec');
|
|
115
|
+
if (input.state !== undefined)
|
|
116
|
+
out.state = normalizeStatePlan(input.state, label + '.state');
|
|
117
|
+
if (input.crdt !== undefined)
|
|
118
|
+
out.crdt = normalizeCrdtPlan(input.crdt, label + '.crdt');
|
|
119
|
+
return out;
|
|
120
|
+
}
|
|
121
|
+
function normalizeDiffPlan(value, label) {
|
|
122
|
+
const input = readPlanObject(value, label);
|
|
123
|
+
const out = {};
|
|
124
|
+
if (input.strategy !== undefined) {
|
|
125
|
+
if (input.strategy !== 'structural' && input.strategy !== 'schema' && input.strategy !== 'adaptive-schema') {
|
|
126
|
+
throw new TypeError(label + '.strategy is invalid');
|
|
127
|
+
}
|
|
128
|
+
out.strategy = input.strategy;
|
|
129
|
+
}
|
|
130
|
+
if (input.schemaCount !== undefined)
|
|
131
|
+
out.schemaCount = readNonNegativeInteger(input.schemaCount, label + '.schemaCount');
|
|
132
|
+
if (input.paths !== undefined)
|
|
133
|
+
out.paths = clonePathList(input.paths);
|
|
134
|
+
return out;
|
|
135
|
+
}
|
|
136
|
+
function normalizeEqualityPlan(value, label) {
|
|
137
|
+
const input = readPlanObject(value, label);
|
|
138
|
+
const out = {};
|
|
139
|
+
if (input.strategy !== undefined) {
|
|
140
|
+
if (input.strategy !== 'fast-json' && input.strategy !== 'schema' && input.strategy !== 'token') {
|
|
141
|
+
throw new TypeError(label + '.strategy is invalid');
|
|
142
|
+
}
|
|
143
|
+
out.strategy = input.strategy;
|
|
144
|
+
}
|
|
145
|
+
if (input.token !== undefined) {
|
|
146
|
+
if (input.token !== 'versionKey' && input.token !== 'fingerprintKey')
|
|
147
|
+
throw new TypeError(label + '.token is invalid');
|
|
148
|
+
out.token = input.token;
|
|
149
|
+
}
|
|
150
|
+
if (input.key !== undefined) {
|
|
151
|
+
if (!isObjectKey(input.key))
|
|
152
|
+
throw new TypeError(label + '.key must be a string or number');
|
|
153
|
+
out.key = input.key;
|
|
154
|
+
}
|
|
155
|
+
return out;
|
|
156
|
+
}
|
|
157
|
+
function normalizeHistoryPlan(value, label) {
|
|
158
|
+
const input = readPlanObject(value, label);
|
|
159
|
+
const out = {};
|
|
160
|
+
if (input.strategy !== undefined) {
|
|
161
|
+
if (input.strategy !== 'auto' &&
|
|
162
|
+
input.strategy !== 'string-append' &&
|
|
163
|
+
input.strategy !== 'row-object-assign' &&
|
|
164
|
+
input.strategy !== 'object-assign' &&
|
|
165
|
+
input.strategy !== 'scalar-object') {
|
|
166
|
+
throw new TypeError(label + '.strategy is invalid');
|
|
167
|
+
}
|
|
168
|
+
out.strategy = input.strategy;
|
|
169
|
+
}
|
|
170
|
+
return out;
|
|
171
|
+
}
|
|
172
|
+
function normalizeCodecPlan(value, label) {
|
|
173
|
+
const input = readPlanObject(value, label);
|
|
174
|
+
const out = {};
|
|
175
|
+
if (input.patch !== undefined) {
|
|
176
|
+
if (input.patch !== 'auto' && input.patch !== 'json' && input.patch !== 'binary')
|
|
177
|
+
throw new TypeError(label + '.patch is invalid');
|
|
178
|
+
out.patch = input.patch;
|
|
179
|
+
}
|
|
180
|
+
if (input.history !== undefined) {
|
|
181
|
+
if (input.history !== 'auto' && input.history !== 'binary' && input.history !== 'binary-columnar') {
|
|
182
|
+
throw new TypeError(label + '.history is invalid');
|
|
183
|
+
}
|
|
184
|
+
out.history = input.history;
|
|
185
|
+
}
|
|
186
|
+
if (input.crdt !== undefined) {
|
|
187
|
+
if (input.crdt !== 'auto' && input.crdt !== 'json' && input.crdt !== 'binary' && input.crdt !== 'columnar-text') {
|
|
188
|
+
throw new TypeError(label + '.crdt is invalid');
|
|
189
|
+
}
|
|
190
|
+
out.crdt = input.crdt;
|
|
191
|
+
}
|
|
192
|
+
return out;
|
|
193
|
+
}
|
|
194
|
+
function normalizeStatePlan(value, label) {
|
|
195
|
+
const input = readPlanObject(value, label);
|
|
196
|
+
const out = {};
|
|
197
|
+
if (input.routing !== undefined) {
|
|
198
|
+
if (input.routing !== 'patch-router')
|
|
199
|
+
throw new TypeError(label + '.routing is invalid');
|
|
200
|
+
out.routing = input.routing;
|
|
201
|
+
}
|
|
202
|
+
if (input.apply !== undefined) {
|
|
203
|
+
if (input.apply !== 'owned-mutable' && input.apply !== 'immutable')
|
|
204
|
+
throw new TypeError(label + '.apply is invalid');
|
|
205
|
+
out.apply = input.apply;
|
|
206
|
+
}
|
|
207
|
+
copyOptionalNonNegativeInteger(out, input, 'watches', label);
|
|
208
|
+
copyOptionalNonNegativeInteger(out, input, 'exactWatches', label);
|
|
209
|
+
copyOptionalNonNegativeInteger(out, input, 'wildcardWatches', label);
|
|
210
|
+
copyOptionalNonNegativeInteger(out, input, 'fieldWatches', label);
|
|
211
|
+
copyOptionalNonNegativeInteger(out, input, 'rangeWatches', label);
|
|
212
|
+
return out;
|
|
213
|
+
}
|
|
214
|
+
function normalizeCrdtPlan(value, label) {
|
|
215
|
+
const input = readPlanObject(value, label);
|
|
216
|
+
const out = {};
|
|
217
|
+
if (input.update !== undefined) {
|
|
218
|
+
if (input.update !== 'auto' && input.update !== 'json' && input.update !== 'binary' && input.update !== 'columnar-text') {
|
|
219
|
+
throw new TypeError(label + '.update is invalid');
|
|
220
|
+
}
|
|
221
|
+
out.update = input.update;
|
|
222
|
+
}
|
|
223
|
+
if (input.text !== undefined) {
|
|
224
|
+
if (input.text !== 'chunked-ids' && input.text !== 'native-piece')
|
|
225
|
+
throw new TypeError(label + '.text is invalid');
|
|
226
|
+
out.text = input.text;
|
|
227
|
+
}
|
|
228
|
+
return out;
|
|
229
|
+
}
|
|
230
|
+
function readPlanObject(value, label) {
|
|
231
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
232
|
+
throw new TypeError(label + ' must be an object');
|
|
233
|
+
return value;
|
|
234
|
+
}
|
|
235
|
+
function clonePathList(paths) {
|
|
236
|
+
if (!Array.isArray(paths))
|
|
237
|
+
throw new TypeError('profile plan paths must be an array');
|
|
238
|
+
const out = new Array(paths.length);
|
|
239
|
+
for (let i = 0, length = paths.length; i < length; i++) {
|
|
240
|
+
const path = paths[i];
|
|
241
|
+
if (!Array.isArray(path))
|
|
242
|
+
throw new TypeError('profile plan path must be an array');
|
|
243
|
+
const cloned = new Array(path.length);
|
|
244
|
+
for (let j = 0, pathLength = path.length; j < pathLength; j++) {
|
|
245
|
+
const segment = path[j];
|
|
246
|
+
if (!isObjectKey(segment))
|
|
247
|
+
throw new TypeError('profile plan path segments must be strings or numbers');
|
|
248
|
+
cloned[j] = segment;
|
|
249
|
+
}
|
|
250
|
+
out[i] = cloned;
|
|
251
|
+
}
|
|
252
|
+
return out;
|
|
253
|
+
}
|
|
254
|
+
function copyOptionalNonNegativeInteger(out, input, key, label) {
|
|
255
|
+
const value = input[key];
|
|
256
|
+
if (value === undefined)
|
|
257
|
+
return;
|
|
258
|
+
out[key] = readNonNegativeInteger(value, label + '.' + key);
|
|
259
|
+
}
|
|
260
|
+
function readNonNegativeInteger(value, label) {
|
|
261
|
+
if (!Number.isSafeInteger(value) || value < 0)
|
|
262
|
+
throw new TypeError(label + ' must be a non-negative safe integer');
|
|
263
|
+
return value;
|
|
264
|
+
}
|
|
265
|
+
function isObjectKey(value) {
|
|
266
|
+
return typeof value === 'string' || typeof value === 'number';
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../src/profile.ts"],"names":[],"mappings":"AA8BA,MAAM,UAAU,gBAAgB,CAAC,OAAoD,EAAE,KAAK,GAAG,SAAS;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,CAAC,uDAAuD,CAAC,CAAC;YACxG,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;QACtB,CAAC;QACD,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IAClB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,8BAA8B,CAAC,GAAqB,EAAE,KAAuB,EAAE,GAA2B,EAAE,KAAa;IAChI,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO;IAC/B,GAAW,CAAC,GAAG,CAAC,GAAG,sBAAsB,CAAC,KAAK,EAAE,KAAK,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;AACvE,CAAC;AAED,SAAS,sBAAsB,CAAC,KAAc,EAAE,KAAa;IAC3D,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAK,KAAgB,GAAG,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,KAAK,GAAG,sCAAsC,CAAC,CAAC;IAC/H,OAAO,KAAe,CAAC;AACzB,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AAChE,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { DiffOptions, JsonObject, JsonPath, JsonValue, ObjectKey, Patch, PatchOperation } from '@shapeshift-labs/frontier/types';
|
|
2
|
+
import type { PatchHistoryBuilder, PatchHistoryCodecOptions } from '@shapeshift-labs/frontier-codec';
|
|
3
|
+
export type { DiffOptions, JsonObject, JsonPath, JsonValue, ObjectKey, Patch, PatchOperation, PatchHistoryBuilder, PatchHistoryCodecOptions };
|
|
4
|
+
export interface ProfilePlans {
|
|
5
|
+
diff?: DiffProfilePlan;
|
|
6
|
+
equality?: EqualityProfilePlan;
|
|
7
|
+
history?: HistoryProfilePlan;
|
|
8
|
+
codec?: CodecProfilePlan;
|
|
9
|
+
state?: StateProfilePlan;
|
|
10
|
+
crdt?: CrdtProfilePlan;
|
|
11
|
+
}
|
|
12
|
+
export interface DiffProfilePlan {
|
|
13
|
+
strategy?: 'structural' | 'schema' | 'adaptive-schema';
|
|
14
|
+
schemaCount?: number;
|
|
15
|
+
paths?: JsonPath[];
|
|
16
|
+
}
|
|
17
|
+
export interface EqualityProfilePlan {
|
|
18
|
+
strategy?: 'fast-json' | 'schema' | 'token';
|
|
19
|
+
token?: 'versionKey' | 'fingerprintKey';
|
|
20
|
+
key?: ObjectKey;
|
|
21
|
+
}
|
|
22
|
+
export interface HistoryProfilePlan {
|
|
23
|
+
strategy?: 'auto' | 'string-append' | 'row-object-assign' | 'object-assign' | 'scalar-object';
|
|
24
|
+
}
|
|
25
|
+
export interface CodecProfilePlan {
|
|
26
|
+
patch?: 'auto' | 'json' | 'binary';
|
|
27
|
+
history?: 'auto' | 'binary' | 'binary-columnar';
|
|
28
|
+
crdt?: 'auto' | 'json' | 'binary' | 'columnar-text';
|
|
29
|
+
}
|
|
30
|
+
export interface StateProfilePlan {
|
|
31
|
+
routing?: 'patch-router';
|
|
32
|
+
apply?: 'owned-mutable' | 'immutable';
|
|
33
|
+
watches?: number;
|
|
34
|
+
exactWatches?: number;
|
|
35
|
+
wildcardWatches?: number;
|
|
36
|
+
fieldWatches?: number;
|
|
37
|
+
rangeWatches?: number;
|
|
38
|
+
}
|
|
39
|
+
export interface CrdtProfilePlan {
|
|
40
|
+
update?: 'auto' | 'json' | 'binary' | 'columnar-text';
|
|
41
|
+
text?: 'chunked-ids' | 'native-piece';
|
|
42
|
+
}
|
|
43
|
+
export type SchemaField = ObjectKey | NestedObjectSchemaField;
|
|
44
|
+
export interface NestedObjectSchemaField {
|
|
45
|
+
key: ObjectKey;
|
|
46
|
+
type: 'object';
|
|
47
|
+
fields: SchemaField[];
|
|
48
|
+
}
|
|
49
|
+
export interface ObjectSchema {
|
|
50
|
+
type: 'object';
|
|
51
|
+
path?: JsonPath;
|
|
52
|
+
fields: SchemaField[];
|
|
53
|
+
}
|
|
54
|
+
export interface RecordArraySchema {
|
|
55
|
+
type: 'array';
|
|
56
|
+
path?: JsonPath;
|
|
57
|
+
key?: ObjectKey;
|
|
58
|
+
item: {
|
|
59
|
+
type: 'object';
|
|
60
|
+
key?: ObjectKey;
|
|
61
|
+
fields: SchemaField[];
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export type SingleSchema = ObjectSchema | RecordArraySchema;
|
|
65
|
+
export interface MultiSchema {
|
|
66
|
+
schemas: SingleSchema[];
|
|
67
|
+
}
|
|
68
|
+
export type Schema = SingleSchema | MultiSchema;
|
|
69
|
+
export interface DiffProfile {
|
|
70
|
+
version?: 1;
|
|
71
|
+
settings?: EngineProfileSettings;
|
|
72
|
+
plans?: ProfilePlans;
|
|
73
|
+
schema?: SingleSchema;
|
|
74
|
+
schemas?: SingleSchema[];
|
|
75
|
+
}
|
|
76
|
+
export interface EngineProfileSettings {
|
|
77
|
+
cacheSize?: number;
|
|
78
|
+
adaptive?: boolean;
|
|
79
|
+
adaptiveThreshold?: number;
|
|
80
|
+
arrayKey?: ObjectKey | false | null;
|
|
81
|
+
autoArrayKey?: boolean;
|
|
82
|
+
recordKeyCandidates?: ObjectKey[] | false | null;
|
|
83
|
+
containerKeys?: ObjectKey[] | false | null;
|
|
84
|
+
stable?: boolean;
|
|
85
|
+
sortKeys?: boolean;
|
|
86
|
+
maxPatchOperations?: number | null;
|
|
87
|
+
versionKey?: ObjectKey;
|
|
88
|
+
fingerprintKey?: ObjectKey;
|
|
89
|
+
}
|
|
90
|
+
export interface EngineOptions<TValue extends JsonValue = JsonValue> extends DiffOptions<TValue> {
|
|
91
|
+
cacheSize?: number;
|
|
92
|
+
maxEntries?: number;
|
|
93
|
+
adaptive?: boolean;
|
|
94
|
+
adaptiveThreshold?: number;
|
|
95
|
+
schema?: Schema | null;
|
|
96
|
+
containerKeys?: ObjectKey[] | false | null;
|
|
97
|
+
profile?: DiffProfile | null;
|
|
98
|
+
}
|
|
99
|
+
export type TrainingSample<TSource extends JsonValue = JsonValue, TTarget extends JsonValue = JsonValue> = [TSource, TTarget] | {
|
|
100
|
+
source: TSource;
|
|
101
|
+
target: TTarget;
|
|
102
|
+
} | {
|
|
103
|
+
before: TSource;
|
|
104
|
+
after: TTarget;
|
|
105
|
+
};
|
|
106
|
+
export interface DiffEngine {
|
|
107
|
+
diff<TSource extends JsonValue, TTarget extends JsonValue>(source: TSource, target: TTarget, options?: DiffOptions<TSource | TTarget>): Patch;
|
|
108
|
+
diffInto<TSource extends JsonValue, TTarget extends JsonValue>(source: TSource, target: TTarget, patch: Patch, options?: DiffOptions<TSource | TTarget>): Patch;
|
|
109
|
+
equals<TSource extends JsonValue, TTarget extends JsonValue>(source: TSource, target: TTarget, options?: DiffOptions<TSource | TTarget>): boolean;
|
|
110
|
+
diffHistory<TSource extends JsonValue, TTarget extends JsonValue>(initial: TSource, states: TTarget[], options?: DiffOptions<TSource | TTarget>): Patch[];
|
|
111
|
+
encodeHistory(patches: Patch[], options?: PatchHistoryCodecOptions): Uint8Array;
|
|
112
|
+
decodeHistory(bytes: ArrayBuffer | ArrayBufferView, options?: PatchHistoryCodecOptions): Patch[];
|
|
113
|
+
applyHistory(source: JsonValue, patches: Patch[], options?: PatchHistoryCodecOptions): JsonValue;
|
|
114
|
+
applyEncodedHistory(source: JsonValue, bytes: ArrayBuffer | ArrayBufferView, options?: PatchHistoryCodecOptions): JsonValue;
|
|
115
|
+
createHistoryBuilder(): PatchHistoryBuilder;
|
|
116
|
+
clear(): void;
|
|
117
|
+
train(samples: TrainingSample[]): DiffProfile;
|
|
118
|
+
getProfile(): DiffProfile;
|
|
119
|
+
loadProfile(profile?: DiffProfile | null): void;
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","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a,CAAC,KAAK,EAAE,WAAW,GAAG,eAAe,EAAE,OAAO,CAAC,EAAE,wBAAwB,GAAG,KAAK,EAAE,CAAC;IACjG,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAC;IACjG,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,GAAG,eAAe,EAAE,OAAO,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAC;IAC5H,oBAAoB,IAAI,mBAAmB,CAAC;IAC5C,KAAK,IAAI,IAAI,CAAC;IACd,KAAK,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,WAAW,CAAC;IAC9C,UAAU,IAAI,WAAW,CAAC;IAC1B,WAAW,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,GAAG,IAAI,CAAC;CACjD"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,32 +1,73 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapeshift-labs/frontier-engine",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Stateful planned diff engine, adaptive profiles, and reusable diff planning for Frontier.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+ssh://git@github.com/siliconjungle/-shapeshift-labs-frontier-engine.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/siliconjungle/-shapeshift-labs-frontier-engine#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/siliconjungle/-shapeshift-labs-frontier-engine/issues"
|
|
15
|
+
},
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
8
18
|
"exports": {
|
|
9
|
-
".":
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js",
|
|
22
|
+
"default": "./dist/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./engine": {
|
|
25
|
+
"types": "./dist/engine.d.ts",
|
|
26
|
+
"import": "./dist/engine.js",
|
|
27
|
+
"default": "./dist/engine.js"
|
|
28
|
+
},
|
|
29
|
+
"./profile": {
|
|
30
|
+
"types": "./dist/profile.d.ts",
|
|
31
|
+
"import": "./dist/profile.js",
|
|
32
|
+
"default": "./dist/profile.js"
|
|
33
|
+
},
|
|
34
|
+
"./types": {
|
|
35
|
+
"types": "./dist/types.d.ts",
|
|
36
|
+
"default": "./dist/types.d.ts"
|
|
37
|
+
},
|
|
10
38
|
"./package.json": "./package.json"
|
|
11
39
|
},
|
|
12
40
|
"files": [
|
|
13
|
-
"
|
|
41
|
+
"dist",
|
|
14
42
|
"README.md",
|
|
15
|
-
"LICENSE"
|
|
43
|
+
"LICENSE",
|
|
44
|
+
"benchmarks/package-bench.mjs"
|
|
16
45
|
],
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"url": "git+ssh://git@github.com/siliconjungle/-shapeshift-labs-frontier.git"
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=18"
|
|
20
48
|
},
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
"
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@shapeshift-labs/frontier": "^0.1.5",
|
|
51
|
+
"@shapeshift-labs/frontier-codec": "^0.1.3"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "node build.mjs",
|
|
55
|
+
"test": "npm run build && npm run typecheck && node test/smoke.mjs",
|
|
56
|
+
"prepack": "npm run test",
|
|
57
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
58
|
+
"fuzz": "npm run build && node test/fuzz.mjs --cases 400",
|
|
59
|
+
"bench": "npm run build && node benchmarks/package-bench.mjs",
|
|
60
|
+
"pack:dry": "npm pack --dry-run"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"typescript": "^6.0.3"
|
|
24
64
|
},
|
|
25
65
|
"keywords": [
|
|
26
66
|
"frontier",
|
|
27
67
|
"json",
|
|
28
68
|
"diff",
|
|
29
69
|
"engine",
|
|
30
|
-
"
|
|
70
|
+
"adaptive",
|
|
71
|
+
"profile"
|
|
31
72
|
]
|
|
32
73
|
}
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
throw new Error('@shapeshift-labs/frontier-engine is reserved and not ready for use. Use @shapeshift-labs/frontier/engine until the package is implemented.');
|