on-zero 0.6.11 → 0.6.13
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/dist/cjs/createZeroSQLiteServer.cjs +319 -0
- package/dist/cjs/createZeroSQLiteServer.native.js +440 -0
- package/dist/cjs/createZeroSQLiteServer.native.js.map +1 -0
- package/dist/cjs/createZeroSQLiteServer.test.cjs +429 -0
- package/dist/cjs/createZeroSQLiteServer.test.native.js +466 -0
- package/dist/cjs/createZeroSQLiteServer.test.native.js.map +1 -0
- package/dist/cjs/createZeroServer.cjs +20 -234
- package/dist/cjs/createZeroServer.native.js +24 -250
- package/dist/cjs/createZeroServer.native.js.map +1 -1
- package/dist/cjs/createZeroServer.test.cjs +35 -1
- package/dist/cjs/createZeroServer.test.native.js +38 -1
- package/dist/cjs/createZeroServer.test.native.js.map +1 -1
- package/dist/cjs/createZeroServerCore.cjs +362 -0
- package/dist/cjs/createZeroServerCore.native.js +389 -0
- package/dist/cjs/createZeroServerCore.native.js.map +1 -0
- package/dist/cjs/generate-lite.cjs +1 -0
- package/dist/cjs/generate-lite.native.js +1 -0
- package/dist/cjs/generate-lite.native.js.map +1 -1
- package/dist/cjs/generate-lite.test.cjs +5 -1
- package/dist/cjs/generate-lite.test.native.js +5 -1
- package/dist/cjs/generate-lite.test.native.js.map +1 -1
- package/dist/cjs/generate.cjs +20 -11
- package/dist/cjs/generate.native.js +29 -21
- package/dist/cjs/generate.native.js.map +1 -1
- package/dist/cjs/generate.test.cjs +110 -0
- package/dist/cjs/generate.test.native.js +110 -0
- package/dist/cjs/generate.test.native.js.map +1 -1
- package/dist/cjs/httpPull/transport.test.cjs +44 -0
- package/dist/cjs/httpPull/transport.test.native.js +53 -0
- package/dist/cjs/httpPull/transport.test.native.js.map +1 -1
- package/dist/cjs/httpPullTransport.cjs +4 -1
- package/dist/cjs/httpPullTransport.native.js +5 -2
- package/dist/cjs/httpPullTransport.native.js.map +1 -1
- package/dist/cjs/server.cjs +2 -1
- package/dist/cjs/syncHost.cjs +164 -0
- package/dist/cjs/syncHost.native.js +371 -0
- package/dist/cjs/syncHost.native.js.map +1 -0
- package/dist/cjs/syncHost.test.cjs +229 -0
- package/dist/cjs/syncHost.test.native.js +278 -0
- package/dist/cjs/syncHost.test.native.js.map +1 -0
- package/dist/esm/createZeroSQLiteServer.mjs +293 -0
- package/dist/esm/createZeroSQLiteServer.mjs.map +1 -0
- package/dist/esm/createZeroSQLiteServer.native.js +411 -0
- package/dist/esm/createZeroSQLiteServer.native.js.map +1 -0
- package/dist/esm/createZeroSQLiteServer.test.mjs +430 -0
- package/dist/esm/createZeroSQLiteServer.test.mjs.map +1 -0
- package/dist/esm/createZeroSQLiteServer.test.native.js +464 -0
- package/dist/esm/createZeroSQLiteServer.test.native.js.map +1 -0
- package/dist/esm/createZeroServer.mjs +17 -231
- package/dist/esm/createZeroServer.mjs.map +1 -1
- package/dist/esm/createZeroServer.native.js +21 -247
- package/dist/esm/createZeroServer.native.js.map +1 -1
- package/dist/esm/createZeroServer.test.mjs +35 -1
- package/dist/esm/createZeroServer.test.mjs.map +1 -1
- package/dist/esm/createZeroServer.test.native.js +38 -1
- package/dist/esm/createZeroServer.test.native.js.map +1 -1
- package/dist/esm/createZeroServerCore.mjs +336 -0
- package/dist/esm/createZeroServerCore.mjs.map +1 -0
- package/dist/esm/createZeroServerCore.native.js +360 -0
- package/dist/esm/createZeroServerCore.native.js.map +1 -0
- package/dist/esm/generate-lite.mjs +1 -0
- package/dist/esm/generate-lite.mjs.map +1 -1
- package/dist/esm/generate-lite.native.js +1 -0
- package/dist/esm/generate-lite.native.js.map +1 -1
- package/dist/esm/generate-lite.test.mjs +5 -1
- package/dist/esm/generate-lite.test.mjs.map +1 -1
- package/dist/esm/generate-lite.test.native.js +5 -1
- package/dist/esm/generate-lite.test.native.js.map +1 -1
- package/dist/esm/generate.mjs +20 -11
- package/dist/esm/generate.mjs.map +1 -1
- package/dist/esm/generate.native.js +29 -21
- package/dist/esm/generate.native.js.map +1 -1
- package/dist/esm/generate.test.mjs +87 -1
- package/dist/esm/generate.test.mjs.map +1 -1
- package/dist/esm/generate.test.native.js +87 -1
- package/dist/esm/generate.test.native.js.map +1 -1
- package/dist/esm/httpPull/transport.test.mjs +44 -0
- package/dist/esm/httpPull/transport.test.mjs.map +1 -1
- package/dist/esm/httpPull/transport.test.native.js +53 -0
- package/dist/esm/httpPull/transport.test.native.js.map +1 -1
- package/dist/esm/httpPullTransport.mjs +4 -1
- package/dist/esm/httpPullTransport.mjs.map +1 -1
- package/dist/esm/httpPullTransport.native.js +5 -2
- package/dist/esm/httpPullTransport.native.js.map +1 -1
- package/dist/esm/server.mjs +1 -0
- package/dist/esm/server.mjs.map +1 -1
- package/dist/esm/syncHost.mjs +138 -0
- package/dist/esm/syncHost.mjs.map +1 -0
- package/dist/esm/syncHost.native.js +342 -0
- package/dist/esm/syncHost.native.js.map +1 -0
- package/dist/esm/syncHost.test.mjs +206 -0
- package/dist/esm/syncHost.test.mjs.map +1 -0
- package/dist/esm/syncHost.test.native.js +252 -0
- package/dist/esm/syncHost.test.native.js.map +1 -0
- package/package.json +19 -3
- package/readme.md +26 -0
- package/src/createZeroSQLiteServer.test.ts +461 -0
- package/src/createZeroSQLiteServer.ts +523 -0
- package/src/createZeroServer.test.ts +39 -1
- package/src/createZeroServer.ts +35 -428
- package/src/createZeroServerCore.ts +557 -0
- package/src/generate-lite.test.ts +4 -0
- package/src/generate-lite.ts +1 -0
- package/src/generate.test.ts +87 -1
- package/src/generate.ts +29 -20
- package/src/httpPull/transport.test.ts +47 -0
- package/src/httpPullTransport.ts +15 -1
- package/src/server.ts +1 -0
- package/src/syncHost.test.ts +216 -0
- package/src/syncHost.ts +255 -0
- package/test-fixtures/server-return-types.ts +50 -0
- package/test-fixtures/tsconfig.json +13 -0
- package/types/createZeroSQLiteServer.d.ts +37 -0
- package/types/createZeroSQLiteServer.d.ts.map +1 -0
- package/types/createZeroSQLiteServer.test.d.ts +2 -0
- package/types/createZeroSQLiteServer.test.d.ts.map +1 -0
- package/types/createZeroServer.d.ts +11 -293
- package/types/createZeroServer.d.ts.map +1 -1
- package/types/createZeroServerCore.d.ts +310 -0
- package/types/createZeroServerCore.d.ts.map +1 -0
- package/types/generate-lite.d.ts.map +1 -1
- package/types/generate.d.ts +2 -1
- package/types/generate.d.ts.map +1 -1
- package/types/httpPullTransport.d.ts +2 -0
- package/types/httpPullTransport.d.ts.map +1 -1
- package/types/server.d.ts +1 -0
- package/types/server.d.ts.map +1 -1
- package/types/syncHost.d.ts +51 -0
- package/types/syncHost.d.ts.map +1 -0
- package/types/syncHost.test.d.ts +2 -0
- package/types/syncHost.test.d.ts.map +1 -0
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import { asQueryInternals } from "@rocicorp/zero/bindings";
|
|
2
|
+
import { createPermissions } from "./createPermissions.native.js";
|
|
3
|
+
import { resolveServerQuery } from "./createZeroServerCore.native.js";
|
|
4
|
+
import { createZeroSQLiteServer, createZeroSQLiteTransaction } from "./createZeroSQLiteServer.native.js";
|
|
5
|
+
import { createMutators } from "./helpers/createMutators.native.js";
|
|
6
|
+
import { runWithAuthScope } from "./helpers/mutatorContext.native.js";
|
|
7
|
+
import { runWithQueryContext } from "./helpers/queryContext.native.js";
|
|
8
|
+
import { setEnvironment, setSchema } from "./state.native.js";
|
|
9
|
+
function _assert_this_initialized(self) {
|
|
10
|
+
if (self === void 0) {
|
|
11
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
12
|
+
}
|
|
13
|
+
return self;
|
|
14
|
+
}
|
|
15
|
+
function _call_super(_this, derived, args) {
|
|
16
|
+
derived = _get_prototype_of(derived);
|
|
17
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
18
|
+
}
|
|
19
|
+
function _class_call_check(instance, Constructor) {
|
|
20
|
+
if (!(instance instanceof Constructor)) {
|
|
21
|
+
throw new TypeError("Cannot call a class as a function");
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function _construct(Parent, args, Class) {
|
|
25
|
+
if (_is_native_reflect_construct()) {
|
|
26
|
+
_construct = Reflect.construct;
|
|
27
|
+
} else {
|
|
28
|
+
_construct = function construct(Parent2, args2, Class2) {
|
|
29
|
+
var a = [null];
|
|
30
|
+
a.push.apply(a, args2);
|
|
31
|
+
var Constructor = Function.bind.apply(Parent2, a);
|
|
32
|
+
var instance = new Constructor();
|
|
33
|
+
if (Class2) _set_prototype_of(instance, Class2.prototype);
|
|
34
|
+
return instance;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return _construct.apply(null, arguments);
|
|
38
|
+
}
|
|
39
|
+
function _define_property(obj, key, value) {
|
|
40
|
+
if (key in obj) {
|
|
41
|
+
Object.defineProperty(obj, key, {
|
|
42
|
+
value,
|
|
43
|
+
enumerable: true,
|
|
44
|
+
configurable: true,
|
|
45
|
+
writable: true
|
|
46
|
+
});
|
|
47
|
+
} else {
|
|
48
|
+
obj[key] = value;
|
|
49
|
+
}
|
|
50
|
+
return obj;
|
|
51
|
+
}
|
|
52
|
+
function _get_prototype_of(o) {
|
|
53
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o2) {
|
|
54
|
+
return o2.__proto__ || Object.getPrototypeOf(o2);
|
|
55
|
+
};
|
|
56
|
+
return _get_prototype_of(o);
|
|
57
|
+
}
|
|
58
|
+
function _inherits(subClass, superClass) {
|
|
59
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
60
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
61
|
+
}
|
|
62
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
63
|
+
constructor: {
|
|
64
|
+
value: subClass,
|
|
65
|
+
writable: true,
|
|
66
|
+
configurable: true
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
70
|
+
}
|
|
71
|
+
function _instanceof(left, right) {
|
|
72
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
73
|
+
return !!right[Symbol.hasInstance](left);
|
|
74
|
+
} else {
|
|
75
|
+
return left instanceof right;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function _is_native_function(fn) {
|
|
79
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
80
|
+
}
|
|
81
|
+
function _possible_constructor_return(self, call) {
|
|
82
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
83
|
+
return call;
|
|
84
|
+
}
|
|
85
|
+
return _assert_this_initialized(self);
|
|
86
|
+
}
|
|
87
|
+
function _set_prototype_of(o, p) {
|
|
88
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o2, p2) {
|
|
89
|
+
o2.__proto__ = p2;
|
|
90
|
+
return o2;
|
|
91
|
+
};
|
|
92
|
+
return _set_prototype_of(o, p);
|
|
93
|
+
}
|
|
94
|
+
function _type_of(obj) {
|
|
95
|
+
"@swc/helpers - typeof";
|
|
96
|
+
|
|
97
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
98
|
+
}
|
|
99
|
+
function _wrap_native_super(Class) {
|
|
100
|
+
var _cache = typeof Map === "function" ? /* @__PURE__ */new Map() : void 0;
|
|
101
|
+
_wrap_native_super = function wrapNativeSuper(Class2) {
|
|
102
|
+
if (Class2 === null || !_is_native_function(Class2)) return Class2;
|
|
103
|
+
if (typeof Class2 !== "function") {
|
|
104
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
105
|
+
}
|
|
106
|
+
if (typeof _cache !== "undefined") {
|
|
107
|
+
if (_cache.has(Class2)) return _cache.get(Class2);
|
|
108
|
+
_cache.set(Class2, Wrapper);
|
|
109
|
+
}
|
|
110
|
+
function Wrapper() {
|
|
111
|
+
return _construct(Class2, arguments, _get_prototype_of(this).constructor);
|
|
112
|
+
}
|
|
113
|
+
Wrapper.prototype = Object.create(Class2.prototype, {
|
|
114
|
+
constructor: {
|
|
115
|
+
value: Wrapper,
|
|
116
|
+
enumerable: false,
|
|
117
|
+
writable: true,
|
|
118
|
+
configurable: true
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
return _set_prototype_of(Wrapper, Class2);
|
|
122
|
+
};
|
|
123
|
+
return _wrap_native_super(Class);
|
|
124
|
+
}
|
|
125
|
+
function _is_native_reflect_construct() {
|
|
126
|
+
try {
|
|
127
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
128
|
+
} catch (_) {}
|
|
129
|
+
return (_is_native_reflect_construct = function () {
|
|
130
|
+
return !!result;
|
|
131
|
+
})();
|
|
132
|
+
}
|
|
133
|
+
var MutationApplicationError = /* @__PURE__ */function (Error1) {
|
|
134
|
+
"use strict";
|
|
135
|
+
|
|
136
|
+
_inherits(MutationApplicationError2, Error1);
|
|
137
|
+
function MutationApplicationError2(details) {
|
|
138
|
+
var message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : details;
|
|
139
|
+
_class_call_check(this, MutationApplicationError2);
|
|
140
|
+
var _this;
|
|
141
|
+
_this = _call_super(this, MutationApplicationError2, [message]), _define_property(_this, "details", void 0), _this.details = details;
|
|
142
|
+
_this.name = "MutationApplicationError";
|
|
143
|
+
return _this;
|
|
144
|
+
}
|
|
145
|
+
return MutationApplicationError2;
|
|
146
|
+
}(_wrap_native_super(Error));
|
|
147
|
+
function createZeroSyncHostAdapter(param) {
|
|
148
|
+
var {
|
|
149
|
+
encodeValue,
|
|
150
|
+
mapAuthData = defaultMapAuthData,
|
|
151
|
+
transaction,
|
|
152
|
+
...options
|
|
153
|
+
} = param;
|
|
154
|
+
setSchema(options.schema);
|
|
155
|
+
setEnvironment("server");
|
|
156
|
+
var _options_defaultAllowAdminRole;
|
|
157
|
+
var permissions = createPermissions({
|
|
158
|
+
environment: "server",
|
|
159
|
+
schema: options.schema,
|
|
160
|
+
adminRoleMode: (_options_defaultAllowAdminRole = options.defaultAllowAdminRole) !== null && _options_defaultAllowAdminRole !== void 0 ? _options_defaultAllowAdminRole : "all"
|
|
161
|
+
});
|
|
162
|
+
var transactionOptions = {
|
|
163
|
+
encodeValue,
|
|
164
|
+
schema: options.schema
|
|
165
|
+
};
|
|
166
|
+
var mutators = {};
|
|
167
|
+
var _iteratorNormalCompletion = true,
|
|
168
|
+
_didIteratorError = false,
|
|
169
|
+
_iteratorError = void 0;
|
|
170
|
+
try {
|
|
171
|
+
var _loop = function () {
|
|
172
|
+
var [modelName, model] = _step.value;
|
|
173
|
+
var _model_mutate;
|
|
174
|
+
var _iteratorNormalCompletion2 = true,
|
|
175
|
+
_didIteratorError2 = false,
|
|
176
|
+
_iteratorError2 = void 0;
|
|
177
|
+
try {
|
|
178
|
+
var _loop2 = function () {
|
|
179
|
+
var mutatorName = _step1.value;
|
|
180
|
+
mutators[`${modelName}|${mutatorName}`] = async function (executor, args, context) {
|
|
181
|
+
var _modelMutators_modelName;
|
|
182
|
+
var authData = mapAuthData(context.claims);
|
|
183
|
+
var asyncTasks = [];
|
|
184
|
+
var modelMutators = createMutators({
|
|
185
|
+
asyncTasks,
|
|
186
|
+
authData,
|
|
187
|
+
can: permissions.can,
|
|
188
|
+
createServerActions: options.createServerActions,
|
|
189
|
+
environment: "server",
|
|
190
|
+
models: options.models,
|
|
191
|
+
mutationValidators: options.mutations,
|
|
192
|
+
validateMutation: options.validateMutation
|
|
193
|
+
});
|
|
194
|
+
var mutation = (_modelMutators_modelName = modelMutators[modelName]) === null || _modelMutators_modelName === void 0 ? void 0 : _modelMutators_modelName[mutatorName];
|
|
195
|
+
if (!mutation) throw new Error(`unknown on-zero mutator: ${modelName}|${mutatorName}`);
|
|
196
|
+
var mutationID = numericMutationID(context.mutationID);
|
|
197
|
+
var _context_clientID;
|
|
198
|
+
var onZeroTransaction = createZeroSQLiteTransaction(transactionOptions, toSQLiteExecutor(executor), {
|
|
199
|
+
clientGroupID: "orez-sync-host",
|
|
200
|
+
clientID: (_context_clientID = context.clientID) !== null && _context_clientID !== void 0 ? _context_clientID : "",
|
|
201
|
+
mutationID,
|
|
202
|
+
upstreamSchema: "orez-sync-host"
|
|
203
|
+
});
|
|
204
|
+
try {
|
|
205
|
+
await mutation(onZeroTransaction, args);
|
|
206
|
+
} catch (error) {
|
|
207
|
+
throw asMutationApplicationError(error);
|
|
208
|
+
}
|
|
209
|
+
var _iteratorNormalCompletion3 = true,
|
|
210
|
+
_didIteratorError3 = false,
|
|
211
|
+
_iteratorError3 = void 0;
|
|
212
|
+
try {
|
|
213
|
+
var _loop3 = function () {
|
|
214
|
+
var task = _step2.value;
|
|
215
|
+
context.defer(function () {
|
|
216
|
+
return runWithAuthScope(authData, task);
|
|
217
|
+
});
|
|
218
|
+
};
|
|
219
|
+
for (var _iterator3 = asyncTasks[Symbol.iterator](), _step2; !(_iteratorNormalCompletion3 = (_step2 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) _loop3();
|
|
220
|
+
} catch (err) {
|
|
221
|
+
_didIteratorError3 = true;
|
|
222
|
+
_iteratorError3 = err;
|
|
223
|
+
} finally {
|
|
224
|
+
try {
|
|
225
|
+
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
226
|
+
_iterator3.return();
|
|
227
|
+
}
|
|
228
|
+
} finally {
|
|
229
|
+
if (_didIteratorError3) {
|
|
230
|
+
throw _iteratorError3;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
for (var _iterator2 = Object.keys((_model_mutate = model.mutate) !== null && _model_mutate !== void 0 ? _model_mutate : {})[Symbol.iterator](), _step1; !(_iteratorNormalCompletion2 = (_step1 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) _loop2();
|
|
237
|
+
} catch (err) {
|
|
238
|
+
_didIteratorError2 = true;
|
|
239
|
+
_iteratorError2 = err;
|
|
240
|
+
} finally {
|
|
241
|
+
try {
|
|
242
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
243
|
+
_iterator2.return();
|
|
244
|
+
}
|
|
245
|
+
} finally {
|
|
246
|
+
if (_didIteratorError2) {
|
|
247
|
+
throw _iteratorError2;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
for (var _iterator = Object.entries(options.models)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) _loop();
|
|
253
|
+
} catch (err) {
|
|
254
|
+
_didIteratorError = true;
|
|
255
|
+
_iteratorError = err;
|
|
256
|
+
} finally {
|
|
257
|
+
try {
|
|
258
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
259
|
+
_iterator.return();
|
|
260
|
+
}
|
|
261
|
+
} finally {
|
|
262
|
+
if (_didIteratorError) {
|
|
263
|
+
throw _iteratorError;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
mutators._zero_cleanupResults = async function () {};
|
|
268
|
+
var direct = createZeroSQLiteServer({
|
|
269
|
+
...options,
|
|
270
|
+
encodeValue,
|
|
271
|
+
transactionProvider: function (work) {
|
|
272
|
+
return transaction(function (executor) {
|
|
273
|
+
return work(toSQLiteExecutor(executor));
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
return {
|
|
278
|
+
mutators: Object.freeze(mutators),
|
|
279
|
+
async resolveQuery(name, args, claims) {
|
|
280
|
+
if (!options.queries) {
|
|
281
|
+
throw new Error("No queries registered with createZeroSyncHostAdapter. Pass the syncedQueries registry via the queries option.");
|
|
282
|
+
}
|
|
283
|
+
var authData = mapAuthData(claims);
|
|
284
|
+
var query = await runWithQueryContext({
|
|
285
|
+
authData
|
|
286
|
+
}, function () {
|
|
287
|
+
return resolveServerQuery({
|
|
288
|
+
authData,
|
|
289
|
+
args: args[0],
|
|
290
|
+
name,
|
|
291
|
+
permissions,
|
|
292
|
+
queries: options.queries,
|
|
293
|
+
validateQuery: options.validateQuery
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
return asQueryInternals(query).ast;
|
|
297
|
+
},
|
|
298
|
+
server: {
|
|
299
|
+
mutate: direct.mutate,
|
|
300
|
+
query: direct.query,
|
|
301
|
+
transaction: direct.transaction
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
function defaultMapAuthData(claims) {
|
|
306
|
+
return {
|
|
307
|
+
...claims,
|
|
308
|
+
id: typeof claims.id === "string" ? claims.id : claims.userID
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
function toSQLiteExecutor(executor) {
|
|
312
|
+
return {
|
|
313
|
+
exec(sql, params) {
|
|
314
|
+
return executor.exec(sql, params);
|
|
315
|
+
},
|
|
316
|
+
query(sql, params) {
|
|
317
|
+
return executor.query(sql, params);
|
|
318
|
+
},
|
|
319
|
+
queryAst(ast, format, queryName) {
|
|
320
|
+
return executor.queryAst(ast, format, queryName);
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
function numericMutationID(value) {
|
|
325
|
+
if (value === void 0) return 0;
|
|
326
|
+
var numeric = typeof value === "number" ? value : Number(value);
|
|
327
|
+
if (!Number.isSafeInteger(numeric) || numeric < 0) {
|
|
328
|
+
throw new TypeError(`invalid Zero mutation ID: ${value}`);
|
|
329
|
+
}
|
|
330
|
+
return numeric;
|
|
331
|
+
}
|
|
332
|
+
function asMutationApplicationError(error) {
|
|
333
|
+
if ((typeof error === "undefined" ? "undefined" : _type_of(error)) === "object" && error !== null && error.name === "MutationApplicationError" && typeof error.details === "string") {
|
|
334
|
+
return error;
|
|
335
|
+
}
|
|
336
|
+
var message = _instanceof(error, Error) ? error.message : String(error);
|
|
337
|
+
var applicationError = new MutationApplicationError(message);
|
|
338
|
+
if (_instanceof(error, Error) && error.stack) applicationError.stack = error.stack;
|
|
339
|
+
return applicationError;
|
|
340
|
+
}
|
|
341
|
+
export { MutationApplicationError, createZeroSyncHostAdapter };
|
|
342
|
+
//# sourceMappingURL=syncHost.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["asQueryInternals","createPermissions","resolveServerQuery","createZeroSQLiteServer","createZeroSQLiteTransaction","createMutators","runWithAuthScope","runWithQueryContext","setEnvironment","setSchema","_assert_this_initialized","self","ReferenceError","_call_super","_this","derived","args","_get_prototype_of","_possible_constructor_return","_is_native_reflect_construct","Reflect","construct","constructor","apply","_class_call_check","instance","Constructor","TypeError","_construct","Parent","Class","Parent2","args2","Class2","a","push","Function","bind","_set_prototype_of","prototype","arguments","_define_property","obj","key","value","Object","defineProperty","enumerable","configurable","writable","o","setPrototypeOf","getPrototypeOf","o2","__proto__","_inherits","subClass","superClass","create","_instanceof","left","right","Symbol","hasInstance","_is_native_function","fn","toString","call","indexOf","_type_of","p","p2","_wrap_native_super","_cache","Map","wrapNativeSuper","has","get","set","Wrapper","result","Boolean","valueOf","_","MutationApplicationError","Error1","MutationApplicationError2","details","message","length","name","Error","createZeroSyncHostAdapter","param","encodeValue","mapAuthData","defaultMapAuthData","transaction","options"],"sources":["../../src/syncHost.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,gBAAA,QAAwB;AAEjC,SAASC,iBAAA,QAAyB;AAClC,SAASC,kBAAA,QAAwD;AACjE,SAAAC,sBAAA,EAAAC,2BAAA;AAAA,SACEC,cAAA;AAAA,SACAC,gBAAA;AAAA,SAGKC,mBAAA;AACP,SAASC,cAAA,EAAAC,SAAsB;AAC/B,SAASC,wBAAwBA,CAAAC,IAAA;EACjC,IAAAA,IAAS;IACT,MAAS,IAAAC,cAAgB,4DAAiB;EAoEnC;EACL,OAAAD,IAAA;AAIE;AAHS,SAAAE,YAAAC,KAAA,EAAAC,OAAA,EAAAC,IAAA;EAITD,OAAK,GAAAE,iBAAO,CAAAF,OAAA;EACd,OAAAG,4BAAA,CAAAJ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AAAI,wBAA2B,kBAA4C,UAAAC,MAAA;EACrE,YAAI;;EACJ9B,SAAM,CAAA+B,yBAA2B,EAAAD,MAAA,CAAW;EAC5C,SAAKC,yBAA4BA,CAAAC,OAAK;IACpC,IAAAC,OAAU,GAAAhD,SAAU,CAAAiD,MAAA,QAAAjD,SAAA,EAA6B,MAAK,KAAE,IAAAA,SAAA,MAAA+C,OAAA;IAC1D/D,iBAAA,OAAA8D,yBAAA;IACA,IAAAxE,KAAO;IACTA,KAAA,GAAAD,WAAA,OAAAyE,yBAAA,GAEAE,OAAS,CACP,CACE,EAAA/C,gBAAiB,CAAA3B,KAAA,WACjB,OAAU,IAAAA,KACT,CAAAyE,OAA6B,GAASA,OAAA;IAGvCzE,KAAA,CAAA4E,IAAO;IACT,OAAA5E,KAAA;EACA;EACA,OAAMwE,yBAAuB;AAC7B,EAAAd,kBAAI,CAAAmB,KAAiB;AACrB,SAAOC,0BAAAC,KAAA;EACT;IAAAC,WAAA;IAAAC,WAAA,GAAAC,kBAAA;IAAAC,WAAA;IAAA,GAAAC;EAAA,IAAAL,KAAA","ignoreList":[]}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { DatabaseSync } from "node:sqlite";
|
|
2
|
+
import { defineQueries, defineQuery } from "@rocicorp/zero";
|
|
3
|
+
import * as v from "valibot";
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, test } from "vitest";
|
|
5
|
+
import { getScopedAuthData } from "./helpers/mutatorContext.mjs";
|
|
6
|
+
import { zeroHttpFixtureSchema } from "./httpPull/fixtureSchema.mjs";
|
|
7
|
+
import { createZeroSyncHostAdapter } from "./syncHost.mjs";
|
|
8
|
+
import { zql } from "./zql.mjs";
|
|
9
|
+
const queries = defineQueries({
|
|
10
|
+
project: {
|
|
11
|
+
byOwner: defineQuery(v.object({
|
|
12
|
+
ownerId: v.string()
|
|
13
|
+
}), ({
|
|
14
|
+
args
|
|
15
|
+
}) => zql.project.where("ownerId", args.ownerId))
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
describe("createZeroSyncHostAdapter", () => {
|
|
19
|
+
let db;
|
|
20
|
+
let executor;
|
|
21
|
+
let transaction;
|
|
22
|
+
let lastQueryFormat;
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
db = new DatabaseSync(":memory:");
|
|
25
|
+
db.exec("CREATE TABLE project (id TEXT PRIMARY KEY, ownerId TEXT NOT NULL, name TEXT NOT NULL)");
|
|
26
|
+
executor = {
|
|
27
|
+
exec(sql, params = []) {
|
|
28
|
+
db.prepare(sql).run(...params);
|
|
29
|
+
},
|
|
30
|
+
query(sql, params = []) {
|
|
31
|
+
return db.prepare(sql).all(...params);
|
|
32
|
+
},
|
|
33
|
+
queryAst(_ast, format) {
|
|
34
|
+
lastQueryFormat = format;
|
|
35
|
+
const rows = db.prepare("SELECT * FROM project ORDER BY id").all();
|
|
36
|
+
return format.singular ? rows[0] : rows;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
transaction = async work => {
|
|
40
|
+
const effects = [];
|
|
41
|
+
db.exec("BEGIN");
|
|
42
|
+
try {
|
|
43
|
+
const value = await work(executor, {
|
|
44
|
+
defer(effect) {
|
|
45
|
+
effects.push(effect);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
db.exec("COMMIT");
|
|
49
|
+
for (const effect of effects) await effect();
|
|
50
|
+
return value;
|
|
51
|
+
} catch (error) {
|
|
52
|
+
db.exec("ROLLBACK");
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
afterEach(() => {
|
|
58
|
+
db.close();
|
|
59
|
+
});
|
|
60
|
+
test("adapts pipe-named mutators, auth, validation, and deferred effects", async () => {
|
|
61
|
+
let effectAuthID;
|
|
62
|
+
let validatedAuthID;
|
|
63
|
+
const adapter = createZeroSyncHostAdapter({
|
|
64
|
+
schema: zeroHttpFixtureSchema,
|
|
65
|
+
models: {
|
|
66
|
+
project: {
|
|
67
|
+
mutate: {
|
|
68
|
+
create: async ({
|
|
69
|
+
authData,
|
|
70
|
+
server,
|
|
71
|
+
tx
|
|
72
|
+
}, value) => {
|
|
73
|
+
expect(authData?.id).toBe("u1");
|
|
74
|
+
await tx.mutate.project.insert(value);
|
|
75
|
+
server?.asyncTasks.push(async () => {
|
|
76
|
+
effectAuthID = getScopedAuthData()?.id;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
createServerActions: () => ({}),
|
|
83
|
+
queries,
|
|
84
|
+
transaction,
|
|
85
|
+
validateMutation({
|
|
86
|
+
authData
|
|
87
|
+
}) {
|
|
88
|
+
validatedAuthID = authData?.id;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
expect(Object.keys(adapter.mutators)).toEqual(["project|create", "_zero_cleanupResults"]);
|
|
92
|
+
await transaction((tx, context) => adapter.mutators["project|create"](tx, {
|
|
93
|
+
id: "p1",
|
|
94
|
+
ownerId: "u1",
|
|
95
|
+
name: "first"
|
|
96
|
+
}, mutationContext(context)));
|
|
97
|
+
expect(db.prepare("SELECT * FROM project").all()).toEqual([{
|
|
98
|
+
id: "p1",
|
|
99
|
+
ownerId: "u1",
|
|
100
|
+
name: "first"
|
|
101
|
+
}]);
|
|
102
|
+
expect(validatedAuthID).toBe("u1");
|
|
103
|
+
expect(effectAuthID).toBe("u1");
|
|
104
|
+
});
|
|
105
|
+
test("returns a structural application error and drops rolled-back effects", async () => {
|
|
106
|
+
let effectRuns = 0;
|
|
107
|
+
const adapter = createZeroSyncHostAdapter({
|
|
108
|
+
schema: zeroHttpFixtureSchema,
|
|
109
|
+
models: {
|
|
110
|
+
project: {
|
|
111
|
+
mutate: {
|
|
112
|
+
reject: async ({
|
|
113
|
+
server,
|
|
114
|
+
tx
|
|
115
|
+
}, value) => {
|
|
116
|
+
await tx.mutate.project.insert(value);
|
|
117
|
+
server?.asyncTasks.push(async () => {
|
|
118
|
+
effectRuns++;
|
|
119
|
+
});
|
|
120
|
+
throw new Error("denied");
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
createServerActions: () => ({}),
|
|
126
|
+
transaction
|
|
127
|
+
});
|
|
128
|
+
const error = await transaction((tx, context) => adapter.mutators["project|reject"](tx, {
|
|
129
|
+
id: "p1",
|
|
130
|
+
ownerId: "u1",
|
|
131
|
+
name: "must roll back"
|
|
132
|
+
}, mutationContext(context))).catch(caught => caught);
|
|
133
|
+
expect(error).toMatchObject({
|
|
134
|
+
name: "MutationApplicationError",
|
|
135
|
+
message: "denied",
|
|
136
|
+
details: "denied"
|
|
137
|
+
});
|
|
138
|
+
expect(db.prepare("SELECT * FROM project").all()).toEqual([]);
|
|
139
|
+
expect(effectRuns).toBe(0);
|
|
140
|
+
});
|
|
141
|
+
test("uses the host queryAst compiler surface for direct server queries", async () => {
|
|
142
|
+
db.prepare("INSERT INTO project (id, ownerId, name) VALUES (?, ?, ?)").run("p1", "u1", "first");
|
|
143
|
+
const adapter = createZeroSyncHostAdapter({
|
|
144
|
+
schema: zeroHttpFixtureSchema,
|
|
145
|
+
models: {},
|
|
146
|
+
createServerActions: () => ({}),
|
|
147
|
+
transaction
|
|
148
|
+
});
|
|
149
|
+
await expect(adapter.server.query(q => q.project.one())).resolves.toEqual({
|
|
150
|
+
id: "p1",
|
|
151
|
+
ownerId: "u1",
|
|
152
|
+
name: "first"
|
|
153
|
+
});
|
|
154
|
+
expect(lastQueryFormat).toEqual({
|
|
155
|
+
relationships: {},
|
|
156
|
+
singular: true
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
test("resolves auth-sensitive named queries and runs query validation", async () => {
|
|
160
|
+
let validation;
|
|
161
|
+
const adapter = createZeroSyncHostAdapter({
|
|
162
|
+
schema: zeroHttpFixtureSchema,
|
|
163
|
+
models: {},
|
|
164
|
+
createServerActions: () => ({}),
|
|
165
|
+
queries,
|
|
166
|
+
transaction,
|
|
167
|
+
validateQuery(args) {
|
|
168
|
+
validation = args;
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
const ast = await adapter.resolveQuery("project|byOwner", [{
|
|
172
|
+
ownerId: "u1"
|
|
173
|
+
}], {
|
|
174
|
+
userID: "u1",
|
|
175
|
+
role: "member"
|
|
176
|
+
});
|
|
177
|
+
expect(ast).toMatchObject({
|
|
178
|
+
table: "project"
|
|
179
|
+
});
|
|
180
|
+
expect(JSON.stringify(ast)).toContain("ownerId");
|
|
181
|
+
expect(JSON.stringify(ast)).toContain("u1");
|
|
182
|
+
expect(validation).toEqual({
|
|
183
|
+
authData: {
|
|
184
|
+
id: "u1",
|
|
185
|
+
role: "member",
|
|
186
|
+
userID: "u1"
|
|
187
|
+
},
|
|
188
|
+
queryName: "project|byOwner",
|
|
189
|
+
params: {
|
|
190
|
+
ownerId: "u1"
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
function mutationContext(context) {
|
|
196
|
+
return {
|
|
197
|
+
...context,
|
|
198
|
+
claims: {
|
|
199
|
+
userID: "u1",
|
|
200
|
+
role: "member"
|
|
201
|
+
},
|
|
202
|
+
clientID: "client-a",
|
|
203
|
+
mutationID: "1"
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=syncHost.test.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DatabaseSync","defineQueries","defineQuery","v","afterEach","beforeEach","describe","expect","test","getScopedAuthData","zeroHttpFixtureSchema","createZeroSyncHostAdapter","zql","queries","project","byOwner","object","ownerId","string","args","where","db","executor","transaction","lastQueryFormat","exec","sql","params","prepare","run","query","all","queryAst","_ast","format","rows","singular","work","effects","value","defer","effect","push","error","close","effectAuthID","validatedAuthID","adapter","schema","models","mutate","create","authData","server","tx","id","toBe","insert","asyncTasks","createServerActions","validateMutation","Object","keys","mutators","toEqual","context","name","mutationContext","effectRuns","reject","Error","catch","caught","toMatchObject","message","details","q","one","resolves","relationships","validation","validateQuery","ast","resolveQuery","userID","role","table","JSON","stringify","toContain","queryName","claims","clientID","mutationID"],"sources":["../../src/syncHost.test.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,YAAA,QAAwC;AAEjD,SAASC,aAAA,EAAeC,WAAA,QAAmB;AAC3C,YAAYC,CAAA,MAAO;AACnB,SAASC,SAAA,EAAWC,UAAA,EAAYC,QAAA,EAAUC,MAAA,EAAQC,IAAA,QAAY;AAE9D,SAASC,iBAAA,QAAyB;AAClC,SAASC,qBAAA,QAA6B;AACtC,SAASC,yBAAA,QAAiC;AAC1C,SAASC,GAAA,QAAW;AASpB,MAAMC,OAAA,GAAUZ,aAAA,CAAc;EAC5Ba,OAAA,EAAS;IACPC,OAAA,EAASb,WAAA,CAAYC,CAAA,CAAEa,MAAA,CAAO;MAAEC,OAAA,EAASd,CAAA,CAAEe,MAAA,CAAO;IAAE,CAAC,GAAG,CAAC;MAAEC;IAAK,MAC9DP,GAAA,CAAIE,OAAA,CAAQM,KAAA,CAAM,WAAWD,IAAA,CAAKF,OAAO,CAC3C;EACF;AACF,CAAC;AAEDX,QAAA,CAAS,6BAA6B,MAAM;EAC1C,IAAIe,EAAA;EACJ,IAAIC,QAAA;EACJ,IAAIC,WAAA;EACJ,IAAIC,eAAA;EAEJnB,UAAA,CAAW,MAAM;IACfgB,EAAA,GAAK,IAAIrB,YAAA,CAAa,UAAU;IAChCqB,EAAA,CAAGI,IAAA,CACD,uFACF;IACAH,QAAA,GAAW;MACTG,KAAKC,GAAA,EAAKC,MAAA,GAAS,EAAC,EAAG;QACrBN,EAAA,CAAGO,OAAA,CAAQF,GAAG,EAAEG,GAAA,CAAI,GAAIF,MAA0B;MACpD;MACAG,MAA2CJ,GAAA,EAAKC,MAAA,GAAS,EAAC,EAAG;QAC3D,OAAON,EAAA,CAAGO,OAAA,CAAQF,GAAG,EAAEK,GAAA,CAAI,GAAIJ,MAA0B;MAC3D;MACAK,SA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