@sidekickdb/core 2.0.1 → 3.0.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/__example__/standalone.esm.html +1 -1
- package/__example__/standalone.umd.html +2 -2
- package/__tests__/src/Reactor.test.ts +70 -25
- package/__tests__/src/batchedFrames.test.ts +110 -0
- package/__tests__/src/createRouteHandler.test.ts +30 -0
- package/__tests__/src/data/zeneca/triples.json +6 -6
- package/__tests__/src/dataForQueryMemo.test.ts +4 -4
- package/__tests__/src/datalog.test.ts +2 -2
- package/__tests__/src/devtool.test.ts +2 -2
- package/__tests__/src/endpoints.test.ts +2 -2
- package/__tests__/src/infiniteQuery.test.ts +142 -0
- package/__tests__/src/notifyScope.test.ts +6 -6
- package/__tests__/src/queryValidation.test.ts +3 -3
- package/__tests__/src/schema.test.ts +6 -6
- package/__tests__/src/serializeSchema.test.ts +2 -2
- package/__tests__/src/{instaml.test.ts → sideml.test.ts} +106 -112
- package/__tests__/src/{instaql.bench.ts → sideql.bench.ts} +1 -1
- package/__tests__/src/{instaql.test.ts → sideql.test.ts} +25 -34
- package/__tests__/src/{instaqlInference.test.ts → sideqlInference.test.ts} +1 -1
- package/__tests__/src/store.test.ts +32 -32
- package/__tests__/src/transactionValidation.test.ts +4 -4
- package/__tests__/src/utils/e2e.ts +8 -8
- package/dist/commonjs/Connection.d.ts +1 -0
- package/dist/commonjs/Connection.d.ts.map +1 -1
- package/dist/commonjs/Connection.js +19 -3
- package/dist/commonjs/Connection.js.map +1 -1
- package/dist/commonjs/IndexedDBStorage.d.ts.map +1 -1
- package/dist/commonjs/IndexedDBStorage.js +3 -160
- package/dist/commonjs/IndexedDBStorage.js.map +1 -1
- package/dist/commonjs/Reactor.d.ts +7 -7
- package/dist/commonjs/Reactor.d.ts.map +1 -1
- package/dist/commonjs/Reactor.js +37 -38
- package/dist/commonjs/Reactor.js.map +1 -1
- package/dist/commonjs/{InstantError.d.ts → SidekickError.d.ts} +2 -2
- package/dist/commonjs/SidekickError.d.ts.map +1 -0
- package/dist/commonjs/{InstantError.js → SidekickError.js} +7 -7
- package/dist/commonjs/SidekickError.js.map +1 -0
- package/dist/commonjs/Stream.d.ts +5 -5
- package/dist/commonjs/Stream.d.ts.map +1 -1
- package/dist/commonjs/Stream.js +14 -14
- package/dist/commonjs/Stream.js.map +1 -1
- package/dist/commonjs/SyncTable.d.ts +3 -3
- package/dist/commonjs/SyncTable.d.ts.map +1 -1
- package/dist/commonjs/SyncTable.js +7 -7
- package/dist/commonjs/SyncTable.js.map +1 -1
- package/dist/commonjs/attrTypes.d.ts +11 -11
- package/dist/commonjs/attrTypes.d.ts.map +1 -1
- package/dist/commonjs/attrTypes.js.map +1 -1
- package/dist/commonjs/coreTypes.d.ts +4 -4
- package/dist/commonjs/coreTypes.d.ts.map +1 -1
- package/dist/commonjs/coreTypes.js.map +1 -1
- package/dist/commonjs/createRouteHandler.d.ts +1 -1
- package/dist/commonjs/createRouteHandler.d.ts.map +1 -1
- package/dist/commonjs/createRouteHandler.js +5 -5
- package/dist/commonjs/createRouteHandler.js.map +1 -1
- package/dist/commonjs/devtool.js +13 -6
- package/dist/commonjs/devtool.js.map +1 -1
- package/dist/commonjs/endpoints.d.ts +2 -2
- package/dist/commonjs/endpoints.d.ts.map +1 -1
- package/dist/commonjs/endpoints.js +3 -3
- package/dist/commonjs/endpoints.js.map +1 -1
- package/dist/commonjs/framework.d.ts +4 -4
- package/dist/commonjs/framework.d.ts.map +1 -1
- package/dist/commonjs/framework.js +5 -5
- package/dist/commonjs/framework.js.map +1 -1
- package/dist/commonjs/helperTypes.d.ts +24 -24
- package/dist/commonjs/helperTypes.d.ts.map +1 -1
- package/dist/commonjs/helperTypes.js.map +1 -1
- package/dist/commonjs/index.d.ts +36 -36
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +36 -36
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/infiniteQuery.d.ts +7 -7
- package/dist/commonjs/infiniteQuery.d.ts.map +1 -1
- package/dist/commonjs/infiniteQuery.js +16 -3
- package/dist/commonjs/infiniteQuery.js.map +1 -1
- package/dist/commonjs/model/{instaqlResult.d.ts → sideqlResult.d.ts} +2 -2
- package/dist/commonjs/model/sideqlResult.d.ts.map +1 -0
- package/dist/commonjs/model/{instaqlResult.js → sideqlResult.js} +2 -2
- package/dist/commonjs/model/sideqlResult.js.map +1 -0
- package/dist/commonjs/notifyScope.js +3 -3
- package/dist/commonjs/notifyScope.js.map +1 -1
- package/dist/commonjs/parseSchemaFromJSON.d.ts +2 -2
- package/dist/commonjs/parseSchemaFromJSON.d.ts.map +1 -1
- package/dist/commonjs/parseSchemaFromJSON.js.map +1 -1
- package/dist/commonjs/queryTypes.d.ts +32 -32
- package/dist/commonjs/queryTypes.d.ts.map +1 -1
- package/dist/commonjs/queryTypes.js.map +1 -1
- package/dist/commonjs/routeHandlerProtocol.d.ts +7 -7
- package/dist/commonjs/routeHandlerProtocol.d.ts.map +1 -1
- package/dist/commonjs/routeHandlerProtocol.js.map +1 -1
- package/dist/commonjs/rulesTypes.d.ts +20 -20
- package/dist/commonjs/rulesTypes.d.ts.map +1 -1
- package/dist/commonjs/rulesTypes.js.map +1 -1
- package/dist/commonjs/sanityCheckQueries.d.ts +3 -3
- package/dist/commonjs/sanityCheckQueries.d.ts.map +1 -1
- package/dist/commonjs/sanityCheckQueries.js.map +1 -1
- package/dist/commonjs/schema.d.ts +3 -3
- package/dist/commonjs/schema.d.ts.map +1 -1
- package/dist/commonjs/schema.js +2 -2
- package/dist/commonjs/schema.js.map +1 -1
- package/dist/commonjs/schemaTypes.d.ts +8 -8
- package/dist/commonjs/schemaTypes.d.ts.map +1 -1
- package/dist/commonjs/schemaTypes.js +9 -9
- package/dist/commonjs/schemaTypes.js.map +1 -1
- package/dist/commonjs/{instaml.d.ts → sideml.d.ts} +1 -1
- package/dist/commonjs/sideml.d.ts.map +1 -0
- package/dist/commonjs/{instaml.js → sideml.js} +10 -7
- package/dist/commonjs/sideml.js.map +1 -0
- package/dist/commonjs/{instaql.d.ts → sideql.d.ts} +1 -1
- package/dist/commonjs/sideql.d.ts.map +1 -0
- package/dist/commonjs/{instaql.js → sideql.js} +1 -1
- package/dist/commonjs/sideql.js.map +1 -0
- package/dist/commonjs/{instatx.d.ts → sidetx.d.ts} +1 -1
- package/dist/commonjs/sidetx.d.ts.map +1 -0
- package/dist/commonjs/{instatx.js → sidetx.js} +1 -1
- package/dist/commonjs/sidetx.js.map +1 -0
- package/dist/commonjs/store.d.ts +22 -22
- package/dist/commonjs/store.d.ts.map +1 -1
- package/dist/commonjs/store.js +0 -2
- package/dist/commonjs/store.js.map +1 -1
- package/dist/commonjs/transactionValidation.d.ts +1 -1
- package/dist/commonjs/transactionValidation.d.ts.map +1 -1
- package/dist/commonjs/transactionValidation.js +2 -2
- package/dist/commonjs/transactionValidation.js.map +1 -1
- package/dist/commonjs/utils/dates.js +31 -31
- package/dist/commonjs/utils/dates.js.map +1 -1
- package/dist/commonjs/utils/fetch.d.ts +7 -7
- package/dist/commonjs/utils/fetch.d.ts.map +1 -1
- package/dist/commonjs/utils/fetch.js +8 -8
- package/dist/commonjs/utils/fetch.js.map +1 -1
- package/dist/commonjs/utils/flags.d.ts +2 -2
- package/dist/commonjs/utils/flags.d.ts.map +1 -1
- package/dist/commonjs/utils/flags.js +4 -4
- package/dist/commonjs/utils/flags.js.map +1 -1
- package/dist/commonjs/utils/linkIndex.d.ts +2 -2
- package/dist/commonjs/utils/linkIndex.d.ts.map +1 -1
- package/dist/commonjs/utils/linkIndex.js.map +1 -1
- package/dist/commonjs/warningToggle.d.ts +1 -1
- package/dist/commonjs/warningToggle.d.ts.map +1 -1
- package/dist/commonjs/warningToggle.js +3 -3
- package/dist/commonjs/warningToggle.js.map +1 -1
- package/dist/esm/Connection.d.ts +1 -0
- package/dist/esm/Connection.d.ts.map +1 -1
- package/dist/esm/Connection.js +18 -3
- package/dist/esm/Connection.js.map +1 -1
- package/dist/esm/IndexedDBStorage.d.ts.map +1 -1
- package/dist/esm/IndexedDBStorage.js +4 -161
- package/dist/esm/IndexedDBStorage.js.map +1 -1
- package/dist/esm/Reactor.d.ts +7 -7
- package/dist/esm/Reactor.d.ts.map +1 -1
- package/dist/esm/Reactor.js +38 -39
- package/dist/esm/Reactor.js.map +1 -1
- package/dist/esm/{InstantError.d.ts → SidekickError.d.ts} +2 -2
- package/dist/esm/SidekickError.d.ts.map +1 -0
- package/dist/esm/{InstantError.js → SidekickError.js} +5 -5
- package/dist/esm/SidekickError.js.map +1 -0
- package/dist/esm/Stream.d.ts +5 -5
- package/dist/esm/Stream.d.ts.map +1 -1
- package/dist/esm/Stream.js +12 -12
- package/dist/esm/Stream.js.map +1 -1
- package/dist/esm/SyncTable.d.ts +3 -3
- package/dist/esm/SyncTable.d.ts.map +1 -1
- package/dist/esm/SyncTable.js +3 -3
- package/dist/esm/SyncTable.js.map +1 -1
- package/dist/esm/attrTypes.d.ts +11 -11
- package/dist/esm/attrTypes.d.ts.map +1 -1
- package/dist/esm/attrTypes.js.map +1 -1
- package/dist/esm/coreTypes.d.ts +4 -4
- package/dist/esm/coreTypes.d.ts.map +1 -1
- package/dist/esm/coreTypes.js.map +1 -1
- package/dist/esm/createRouteHandler.d.ts +1 -1
- package/dist/esm/createRouteHandler.d.ts.map +1 -1
- package/dist/esm/createRouteHandler.js +3 -3
- package/dist/esm/createRouteHandler.js.map +1 -1
- package/dist/esm/devtool.js +13 -6
- package/dist/esm/devtool.js.map +1 -1
- package/dist/esm/endpoints.d.ts +2 -2
- package/dist/esm/endpoints.d.ts.map +1 -1
- package/dist/esm/endpoints.js +3 -3
- package/dist/esm/endpoints.js.map +1 -1
- package/dist/esm/framework.d.ts +4 -4
- package/dist/esm/framework.d.ts.map +1 -1
- package/dist/esm/framework.js +6 -6
- package/dist/esm/framework.js.map +1 -1
- package/dist/esm/helperTypes.d.ts +24 -24
- package/dist/esm/helperTypes.d.ts.map +1 -1
- package/dist/esm/helperTypes.js.map +1 -1
- package/dist/esm/index.d.ts +36 -36
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +33 -33
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/infiniteQuery.d.ts +7 -7
- package/dist/esm/infiniteQuery.d.ts.map +1 -1
- package/dist/esm/infiniteQuery.js +16 -3
- package/dist/esm/infiniteQuery.js.map +1 -1
- package/dist/esm/model/{instaqlResult.d.ts → sideqlResult.d.ts} +2 -2
- package/dist/esm/model/sideqlResult.d.ts.map +1 -0
- package/dist/esm/model/{instaqlResult.js → sideqlResult.js} +2 -2
- package/dist/esm/model/sideqlResult.js.map +1 -0
- package/dist/esm/notifyScope.js +3 -3
- package/dist/esm/notifyScope.js.map +1 -1
- package/dist/esm/parseSchemaFromJSON.d.ts +2 -2
- package/dist/esm/parseSchemaFromJSON.d.ts.map +1 -1
- package/dist/esm/parseSchemaFromJSON.js.map +1 -1
- package/dist/esm/queryTypes.d.ts +32 -32
- package/dist/esm/queryTypes.d.ts.map +1 -1
- package/dist/esm/queryTypes.js.map +1 -1
- package/dist/esm/routeHandlerProtocol.d.ts +7 -7
- package/dist/esm/routeHandlerProtocol.d.ts.map +1 -1
- package/dist/esm/routeHandlerProtocol.js.map +1 -1
- package/dist/esm/rulesTypes.d.ts +20 -20
- package/dist/esm/rulesTypes.d.ts.map +1 -1
- package/dist/esm/rulesTypes.js.map +1 -1
- package/dist/esm/sanityCheckQueries.d.ts +3 -3
- package/dist/esm/sanityCheckQueries.d.ts.map +1 -1
- package/dist/esm/sanityCheckQueries.js.map +1 -1
- package/dist/esm/schema.d.ts +3 -3
- package/dist/esm/schema.d.ts.map +1 -1
- package/dist/esm/schema.js +3 -3
- package/dist/esm/schema.js.map +1 -1
- package/dist/esm/schemaTypes.d.ts +8 -8
- package/dist/esm/schemaTypes.d.ts.map +1 -1
- package/dist/esm/schemaTypes.js +5 -5
- package/dist/esm/schemaTypes.js.map +1 -1
- package/dist/esm/{instaml.d.ts → sideml.d.ts} +1 -1
- package/dist/esm/sideml.d.ts.map +1 -0
- package/dist/esm/{instaml.js → sideml.js} +6 -3
- package/dist/esm/sideml.js.map +1 -0
- package/dist/esm/{instaql.d.ts → sideql.d.ts} +1 -1
- package/dist/esm/sideql.d.ts.map +1 -0
- package/dist/esm/{instaql.js → sideql.js} +1 -1
- package/dist/esm/sideql.js.map +1 -0
- package/dist/esm/{instatx.d.ts → sidetx.d.ts} +1 -1
- package/dist/esm/sidetx.d.ts.map +1 -0
- package/dist/esm/{instatx.js → sidetx.js} +1 -1
- package/dist/esm/sidetx.js.map +1 -0
- package/dist/esm/store.d.ts +22 -22
- package/dist/esm/store.d.ts.map +1 -1
- package/dist/esm/store.js +0 -2
- package/dist/esm/store.js.map +1 -1
- package/dist/esm/transactionValidation.d.ts +1 -1
- package/dist/esm/transactionValidation.d.ts.map +1 -1
- package/dist/esm/transactionValidation.js +1 -1
- package/dist/esm/transactionValidation.js.map +1 -1
- package/dist/esm/utils/dates.js +31 -31
- package/dist/esm/utils/dates.js.map +1 -1
- package/dist/esm/utils/fetch.d.ts +7 -7
- package/dist/esm/utils/fetch.d.ts.map +1 -1
- package/dist/esm/utils/fetch.js +6 -6
- package/dist/esm/utils/fetch.js.map +1 -1
- package/dist/esm/utils/flags.d.ts +2 -2
- package/dist/esm/utils/flags.d.ts.map +1 -1
- package/dist/esm/utils/flags.js +3 -3
- package/dist/esm/utils/flags.js.map +1 -1
- package/dist/esm/utils/linkIndex.d.ts +2 -2
- package/dist/esm/utils/linkIndex.d.ts.map +1 -1
- package/dist/esm/utils/linkIndex.js.map +1 -1
- package/dist/esm/warningToggle.d.ts +1 -1
- package/dist/esm/warningToggle.d.ts.map +1 -1
- package/dist/esm/warningToggle.js +1 -1
- package/dist/esm/warningToggle.js.map +1 -1
- package/dist/standalone/index.js +2705 -2791
- package/dist/standalone/index.umd.cjs +9 -6
- package/package.json +2 -2
- package/src/Connection.ts +18 -3
- package/src/IndexedDBStorage.ts +3 -181
- package/src/Reactor.js +40 -39
- package/src/{InstantError.ts → SidekickError.ts} +4 -4
- package/src/Stream.ts +35 -32
- package/src/SyncTable.ts +6 -6
- package/src/attrTypes.ts +15 -11
- package/src/coreTypes.ts +5 -5
- package/src/createRouteHandler.ts +9 -7
- package/src/devtool.ts +13 -6
- package/src/endpoints.ts +4 -4
- package/src/framework.ts +13 -13
- package/src/helperTypes.ts +37 -37
- package/src/index.ts +123 -123
- package/src/infiniteQuery.ts +39 -22
- package/src/model/{instaqlResult.js → sideqlResult.js} +1 -1
- package/src/notifyScope.ts +3 -3
- package/src/parseSchemaFromJSON.ts +2 -2
- package/src/queryTypes.ts +55 -55
- package/src/routeHandlerProtocol.ts +8 -8
- package/src/rulesTypes.ts +23 -23
- package/src/sanityCheckQueries.ts +9 -9
- package/src/schema.ts +3 -3
- package/src/schemaTypes.ts +11 -9
- package/src/{instaml.ts → sideml.ts} +17 -14
- package/src/{instaql.ts → sideql.ts} +5 -5
- package/src/store.ts +35 -36
- package/src/transactionValidation.ts +1 -1
- package/src/utils/dates.ts +31 -31
- package/src/utils/fetch.ts +13 -13
- package/src/utils/flags.ts +3 -3
- package/src/utils/linkIndex.ts +2 -2
- package/src/warningToggle.ts +1 -1
- package/vite.config.ts +1 -1
- package/dist/commonjs/InstantError.d.ts.map +0 -1
- package/dist/commonjs/InstantError.js.map +0 -1
- package/dist/commonjs/instaml.d.ts.map +0 -1
- package/dist/commonjs/instaml.js.map +0 -1
- package/dist/commonjs/instaql.d.ts.map +0 -1
- package/dist/commonjs/instaql.js.map +0 -1
- package/dist/commonjs/instatx.d.ts.map +0 -1
- package/dist/commonjs/instatx.js.map +0 -1
- package/dist/commonjs/model/instaqlResult.d.ts.map +0 -1
- package/dist/commonjs/model/instaqlResult.js.map +0 -1
- package/dist/esm/InstantError.d.ts.map +0 -1
- package/dist/esm/InstantError.js.map +0 -1
- package/dist/esm/instaml.d.ts.map +0 -1
- package/dist/esm/instaml.js.map +0 -1
- package/dist/esm/instaql.d.ts.map +0 -1
- package/dist/esm/instaql.js.map +0 -1
- package/dist/esm/instatx.d.ts.map +0 -1
- package/dist/esm/instatx.js.map +0 -1
- package/dist/esm/model/instaqlResult.d.ts.map +0 -1
- package/dist/esm/model/instaqlResult.js.map +0 -1
- /package/src/{instatx.ts → sidetx.ts} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { test, expect } from 'vitest';
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as sideml from '../../src/sideml';
|
|
3
|
+
import * as sidetx from '../../src/sidetx';
|
|
4
4
|
import zenecaAttrs from './data/zeneca/attrs.json';
|
|
5
5
|
import zenecaTriples from './data/zeneca/triples.json';
|
|
6
6
|
import { createStore, transact, AttrsStoreClass } from '../../src/store';
|
|
7
7
|
import uuid from '../../src/utils/id';
|
|
8
|
-
import { i,
|
|
8
|
+
import { i, SidekickDBAttr } from '../../src/index';
|
|
9
9
|
|
|
10
10
|
const zenecaAttrToId = zenecaAttrs.reduce((res, x) => {
|
|
11
11
|
// @ts-expect-error
|
|
@@ -30,8 +30,8 @@ const store = createStore(
|
|
|
30
30
|
test('simple update transform', () => {
|
|
31
31
|
const testId = uuid();
|
|
32
32
|
|
|
33
|
-
const ops =
|
|
34
|
-
const result =
|
|
33
|
+
const ops = sidetx.tx.books[testId].update({ title: 'New Title' });
|
|
34
|
+
const result = sideml.transform({ attrsStore: zenecaAttrsStore }, ops);
|
|
35
35
|
|
|
36
36
|
const expected = [
|
|
37
37
|
// @ts-expect-error
|
|
@@ -49,11 +49,11 @@ test('simple update transform', () => {
|
|
|
49
49
|
test('undefined is ignored in update', () => {
|
|
50
50
|
const testId = uuid();
|
|
51
51
|
|
|
52
|
-
const ops =
|
|
52
|
+
const ops = sidetx.tx.users[testId].update({
|
|
53
53
|
handle: 'bobby',
|
|
54
54
|
fullName: undefined,
|
|
55
55
|
});
|
|
56
|
-
const result =
|
|
56
|
+
const result = sideml.transform({ attrsStore: zenecaAttrsStore }, ops);
|
|
57
57
|
|
|
58
58
|
const expected = [
|
|
59
59
|
// @ts-expect-error
|
|
@@ -71,11 +71,11 @@ test('undefined is ignored in update', () => {
|
|
|
71
71
|
test('ignores id attrs', () => {
|
|
72
72
|
const testId = uuid();
|
|
73
73
|
|
|
74
|
-
const ops =
|
|
74
|
+
const ops = sidetx.tx.books[testId].update({
|
|
75
75
|
title: 'New Title',
|
|
76
76
|
id: 'ploop',
|
|
77
77
|
});
|
|
78
|
-
const result =
|
|
78
|
+
const result = sideml.transform({ attrsStore: zenecaAttrsStore }, ops);
|
|
79
79
|
|
|
80
80
|
const expected = [
|
|
81
81
|
// @ts-expect-error
|
|
@@ -92,9 +92,9 @@ test('ignores id attrs', () => {
|
|
|
92
92
|
test("optimistically adds attrs if they don't exist", () => {
|
|
93
93
|
const testId = uuid();
|
|
94
94
|
|
|
95
|
-
const ops =
|
|
95
|
+
const ops = sidetx.tx.books[testId].update({ newAttr: 'New Title' });
|
|
96
96
|
|
|
97
|
-
const result =
|
|
97
|
+
const result = sideml.transform({ attrsStore: zenecaAttrsStore }, ops);
|
|
98
98
|
|
|
99
99
|
const expected = [
|
|
100
100
|
[
|
|
@@ -121,16 +121,16 @@ test("optimistically adds attrs if they don't exist", () => {
|
|
|
121
121
|
});
|
|
122
122
|
|
|
123
123
|
test('lookup resolves attr ids', () => {
|
|
124
|
-
const ops =
|
|
125
|
-
|
|
124
|
+
const ops = sidetx.tx.users[
|
|
125
|
+
sidetx.lookup('email', 'stopa@example.com')
|
|
126
126
|
].update({
|
|
127
127
|
handle: 'stopa',
|
|
128
128
|
});
|
|
129
129
|
|
|
130
130
|
// @ts-expect-error
|
|
131
|
-
const stopaLookup = [zenecaAttrToId['users/email'], 'stopa@
|
|
131
|
+
const stopaLookup = [zenecaAttrToId['users/email'], 'stopa@example.com'];
|
|
132
132
|
|
|
133
|
-
const result =
|
|
133
|
+
const result = sideml.transform({ attrsStore: zenecaAttrsStore }, ops);
|
|
134
134
|
|
|
135
135
|
const expected = [
|
|
136
136
|
// @ts-expect-error
|
|
@@ -146,9 +146,7 @@ test('lookup resolves attr ids', () => {
|
|
|
146
146
|
});
|
|
147
147
|
|
|
148
148
|
test('lookup creates unique attrs for custom lookups', () => {
|
|
149
|
-
const ops =
|
|
150
|
-
instatx.lookup('newAttr', 'newAttrValue')
|
|
151
|
-
].update({
|
|
149
|
+
const ops = sidetx.tx.users[sidetx.lookup('newAttr', 'newAttrValue')].update({
|
|
152
150
|
handle: 'stopa',
|
|
153
151
|
});
|
|
154
152
|
|
|
@@ -158,7 +156,7 @@ test('lookup creates unique attrs for custom lookups', () => {
|
|
|
158
156
|
'newAttrValue',
|
|
159
157
|
];
|
|
160
158
|
|
|
161
|
-
const result =
|
|
159
|
+
const result = sideml.transform({ attrsStore: zenecaAttrsStore }, ops);
|
|
162
160
|
const expected = [
|
|
163
161
|
[
|
|
164
162
|
'add-attr',
|
|
@@ -187,11 +185,11 @@ test('lookup creates unique attrs for custom lookups', () => {
|
|
|
187
185
|
|
|
188
186
|
test('lookup creates unique attrs for lookups in link values', () => {
|
|
189
187
|
const uid = uuid();
|
|
190
|
-
const ops =
|
|
188
|
+
const ops = sidetx.tx.users[uid]
|
|
191
189
|
.update({})
|
|
192
|
-
.link({ posts:
|
|
190
|
+
.link({ posts: sidetx.lookup('slug', 'life-is-good') });
|
|
193
191
|
|
|
194
|
-
const result =
|
|
192
|
+
const result = sideml.transform(
|
|
195
193
|
{ attrsStore: new AttrsStoreClass({}, null) },
|
|
196
194
|
ops,
|
|
197
195
|
);
|
|
@@ -246,14 +244,14 @@ test('lookup creates unique attrs for lookups in link values', () => {
|
|
|
246
244
|
|
|
247
245
|
test('lookup creates unique attrs for lookups in link values with arrays', () => {
|
|
248
246
|
const uid = uuid();
|
|
249
|
-
const ops =
|
|
247
|
+
const ops = sidetx.tx.users[uid].update({}).link({
|
|
250
248
|
posts: [
|
|
251
|
-
|
|
252
|
-
|
|
249
|
+
sidetx.lookup('slug', 'life-is-good'),
|
|
250
|
+
sidetx.lookup('slug', 'check-this-out'),
|
|
253
251
|
],
|
|
254
252
|
});
|
|
255
253
|
|
|
256
|
-
const result =
|
|
254
|
+
const result = sideml.transform(
|
|
257
255
|
{ attrsStore: new AttrsStoreClass({}, null) },
|
|
258
256
|
ops,
|
|
259
257
|
);
|
|
@@ -319,9 +317,9 @@ test('lookup creates unique attrs for lookups in link values with arrays', () =>
|
|
|
319
317
|
|
|
320
318
|
test('lookup creates unique attrs for lookups in link values when fwd-ident exists', () => {
|
|
321
319
|
const uid = uuid();
|
|
322
|
-
const ops =
|
|
320
|
+
const ops = sidetx.tx.users[uid]
|
|
323
321
|
.update({})
|
|
324
|
-
.link({ posts:
|
|
322
|
+
.link({ posts: sidetx.lookup('slug', 'life-is-good') });
|
|
325
323
|
|
|
326
324
|
const attrId = uuid();
|
|
327
325
|
const existingRefAttr = {
|
|
@@ -332,9 +330,9 @@ test('lookup creates unique attrs for lookups in link values when fwd-ident exis
|
|
|
332
330
|
cardinality: 'one',
|
|
333
331
|
'unique?': true,
|
|
334
332
|
'index?': true,
|
|
335
|
-
} as unknown as
|
|
333
|
+
} as unknown as SidekickDBAttr;
|
|
336
334
|
|
|
337
|
-
const result =
|
|
335
|
+
const result = sideml.transform(
|
|
338
336
|
{ attrsStore: new AttrsStoreClass({ [attrId]: existingRefAttr }, null) },
|
|
339
337
|
ops,
|
|
340
338
|
);
|
|
@@ -376,9 +374,9 @@ test('lookup creates unique attrs for lookups in link values when fwd-ident exis
|
|
|
376
374
|
|
|
377
375
|
test('lookup creates unique attrs for lookups in link values when rev-ident exists', () => {
|
|
378
376
|
const uid = uuid();
|
|
379
|
-
const ops =
|
|
377
|
+
const ops = sidetx.tx.users[uid]
|
|
380
378
|
.update({})
|
|
381
|
-
.link({ posts:
|
|
379
|
+
.link({ posts: sidetx.lookup('slug', 'life-is-good') });
|
|
382
380
|
|
|
383
381
|
const attrId = uuid();
|
|
384
382
|
const existingRefAttr = {
|
|
@@ -389,9 +387,9 @@ test('lookup creates unique attrs for lookups in link values when rev-ident exis
|
|
|
389
387
|
cardinality: 'one',
|
|
390
388
|
'unique?': true,
|
|
391
389
|
'index?': true,
|
|
392
|
-
} as unknown as
|
|
390
|
+
} as unknown as SidekickDBAttr;
|
|
393
391
|
|
|
394
|
-
const result =
|
|
392
|
+
const result = sideml.transform(
|
|
395
393
|
{ attrsStore: new AttrsStoreClass({ [attrId]: existingRefAttr }, null) },
|
|
396
394
|
ops,
|
|
397
395
|
);
|
|
@@ -433,9 +431,9 @@ test('lookup creates unique attrs for lookups in link values when rev-ident exis
|
|
|
433
431
|
|
|
434
432
|
test("lookup doesn't override attrs for lookups in link values", () => {
|
|
435
433
|
const uid = uuid();
|
|
436
|
-
const ops =
|
|
434
|
+
const ops = sidetx.tx.users[uid]
|
|
437
435
|
.update({})
|
|
438
|
-
.link({ posts:
|
|
436
|
+
.link({ posts: sidetx.lookup('slug', 'life-is-good') });
|
|
439
437
|
|
|
440
438
|
const refAttrId = uuid();
|
|
441
439
|
const userIdAttrId = uuid();
|
|
@@ -451,7 +449,7 @@ test("lookup doesn't override attrs for lookups in link values", () => {
|
|
|
451
449
|
cardinality: 'one',
|
|
452
450
|
'unique?': true,
|
|
453
451
|
'index?': true,
|
|
454
|
-
} as unknown as
|
|
452
|
+
} as unknown as SidekickDBAttr,
|
|
455
453
|
[userIdAttrId]: {
|
|
456
454
|
id: userIdAttrId,
|
|
457
455
|
'forward-identity': [uuid(), 'users', 'id'],
|
|
@@ -459,7 +457,7 @@ test("lookup doesn't override attrs for lookups in link values", () => {
|
|
|
459
457
|
cardinality: 'one',
|
|
460
458
|
'unique?': true,
|
|
461
459
|
'index?': false,
|
|
462
|
-
} as unknown as
|
|
460
|
+
} as unknown as SidekickDBAttr,
|
|
463
461
|
[postsSlugAttrId]: {
|
|
464
462
|
id: postsSlugAttrId,
|
|
465
463
|
'forward-identity': [uuid(), 'posts', 'slug'],
|
|
@@ -467,12 +465,12 @@ test("lookup doesn't override attrs for lookups in link values", () => {
|
|
|
467
465
|
cardinality: 'one',
|
|
468
466
|
'unique?': true,
|
|
469
467
|
'index?': true,
|
|
470
|
-
} as unknown as
|
|
468
|
+
} as unknown as SidekickDBAttr,
|
|
471
469
|
},
|
|
472
470
|
null,
|
|
473
471
|
);
|
|
474
472
|
|
|
475
|
-
const result =
|
|
473
|
+
const result = sideml.transform({ attrsStore }, ops);
|
|
476
474
|
|
|
477
475
|
expect(result).toEqual([
|
|
478
476
|
['add-triple', uid, userIdAttrId, uid],
|
|
@@ -494,7 +492,7 @@ test("lookup doesn't override attrs for lookups in self links", () => {
|
|
|
494
492
|
cardinality: 'one',
|
|
495
493
|
'unique?': true,
|
|
496
494
|
'index?': false,
|
|
497
|
-
} as unknown as
|
|
495
|
+
} as unknown as SidekickDBAttr,
|
|
498
496
|
[postsSlugAttrId]: {
|
|
499
497
|
id: postsSlugAttrId,
|
|
500
498
|
'forward-identity': [uuid(), 'posts', 'slug'],
|
|
@@ -502,7 +500,7 @@ test("lookup doesn't override attrs for lookups in self links", () => {
|
|
|
502
500
|
cardinality: 'one',
|
|
503
501
|
'unique?': true,
|
|
504
502
|
'index?': true,
|
|
505
|
-
} as unknown as
|
|
503
|
+
} as unknown as SidekickDBAttr,
|
|
506
504
|
[refAttrId]: {
|
|
507
505
|
id: refAttrId,
|
|
508
506
|
'forward-identity': [uuid(), 'posts', 'parent'],
|
|
@@ -511,24 +509,24 @@ test("lookup doesn't override attrs for lookups in self links", () => {
|
|
|
511
509
|
cardinality: 'one',
|
|
512
510
|
'unique?': true,
|
|
513
511
|
'index?': true,
|
|
514
|
-
} as unknown as
|
|
512
|
+
} as unknown as SidekickDBAttr,
|
|
515
513
|
},
|
|
516
514
|
null,
|
|
517
515
|
);
|
|
518
516
|
|
|
519
|
-
const ops1 =
|
|
517
|
+
const ops1 = sidetx.tx.posts[sidetx.lookup('slug', 'life-is-good')]
|
|
520
518
|
.update({})
|
|
521
|
-
.link({ parent:
|
|
519
|
+
.link({ parent: sidetx.lookup('slug', 'life-is-good') });
|
|
522
520
|
|
|
523
|
-
const result1 =
|
|
521
|
+
const result1 = sideml.transform({ attrsStore }, ops1);
|
|
524
522
|
|
|
525
523
|
expect(result1.filter((x) => x[0] !== 'add-triple')).toEqual([]);
|
|
526
524
|
|
|
527
|
-
const ops2 =
|
|
525
|
+
const ops2 = sidetx.tx.posts[sidetx.lookup('slug', 'life-is-good')]
|
|
528
526
|
.update({})
|
|
529
|
-
.link({ child:
|
|
527
|
+
.link({ child: sidetx.lookup('slug', 'life-is-good') });
|
|
530
528
|
|
|
531
|
-
const result2 =
|
|
529
|
+
const result2 = sideml.transform({ attrsStore }, ops2);
|
|
532
530
|
|
|
533
531
|
expect(result2.filter((x) => x[0] !== 'add-triple')).toEqual([]);
|
|
534
532
|
});
|
|
@@ -536,8 +534,8 @@ test("lookup doesn't override attrs for lookups in self links", () => {
|
|
|
536
534
|
test('lookup creates unique ref attrs for ref lookup', () => {
|
|
537
535
|
const uid = uuid();
|
|
538
536
|
const ops = [
|
|
539
|
-
|
|
540
|
-
|
|
537
|
+
sidetx.tx.users[uid].update({}),
|
|
538
|
+
sidetx.tx.user_prefs[sidetx.lookup('users.id', uid)].update({}),
|
|
541
539
|
];
|
|
542
540
|
|
|
543
541
|
const lookup = [
|
|
@@ -546,7 +544,7 @@ test('lookup creates unique ref attrs for ref lookup', () => {
|
|
|
546
544
|
uid,
|
|
547
545
|
];
|
|
548
546
|
|
|
549
|
-
const result =
|
|
547
|
+
const result = sideml.transform(
|
|
550
548
|
{ attrsStore: new AttrsStoreClass({}, null) },
|
|
551
549
|
ops,
|
|
552
550
|
);
|
|
@@ -601,9 +599,9 @@ test('lookup creates unique ref attrs for ref lookup', () => {
|
|
|
601
599
|
test('lookup creates unique ref attrs for ref lookup in link value', () => {
|
|
602
600
|
const uid = uuid();
|
|
603
601
|
const ops = [
|
|
604
|
-
|
|
602
|
+
sidetx.tx.users[uid]
|
|
605
603
|
.update({})
|
|
606
|
-
.link({ user_prefs:
|
|
604
|
+
.link({ user_prefs: sidetx.lookup('users.id', uid) }),
|
|
607
605
|
];
|
|
608
606
|
|
|
609
607
|
const lookup = [
|
|
@@ -612,7 +610,7 @@ test('lookup creates unique ref attrs for ref lookup in link value', () => {
|
|
|
612
610
|
uid,
|
|
613
611
|
];
|
|
614
612
|
|
|
615
|
-
const result =
|
|
613
|
+
const result = sideml.transform(
|
|
616
614
|
{ attrsStore: new AttrsStoreClass({}, null) },
|
|
617
615
|
ops,
|
|
618
616
|
);
|
|
@@ -656,11 +654,11 @@ test('lookup creates unique ref attrs for ref lookup in link value', () => {
|
|
|
656
654
|
test('lookups create entities from links', () => {
|
|
657
655
|
const bookshelfId = uuid();
|
|
658
656
|
|
|
659
|
-
const ops =
|
|
657
|
+
const ops = sidetx.tx.users[sidetx.lookup('handle', 'bobby_newuser')].link({
|
|
660
658
|
bookshelves: bookshelfId,
|
|
661
659
|
});
|
|
662
660
|
|
|
663
|
-
const result =
|
|
661
|
+
const result = sideml.transform({ attrsStore: zenecaAttrsStore }, ops);
|
|
664
662
|
// @ts-expect-error
|
|
665
663
|
const expectedLookup = [zenecaAttrToId['users/handle'], 'bobby_newuser'];
|
|
666
664
|
const expected = [
|
|
@@ -684,13 +682,11 @@ test('lookups create entities from links', () => {
|
|
|
684
682
|
test('lookups create entities from unlinks', () => {
|
|
685
683
|
const bookshelfId = uuid();
|
|
686
684
|
|
|
687
|
-
const ops =
|
|
688
|
-
instatx.lookup('handle', 'bobby_newuser')
|
|
689
|
-
].unlink({
|
|
685
|
+
const ops = sidetx.tx.users[sidetx.lookup('handle', 'bobby_newuser')].unlink({
|
|
690
686
|
bookshelves: bookshelfId,
|
|
691
687
|
});
|
|
692
688
|
|
|
693
|
-
const result =
|
|
689
|
+
const result = sideml.transform({ attrsStore: zenecaAttrsStore }, ops);
|
|
694
690
|
// @ts-expect-error
|
|
695
691
|
const expectedLookup = [zenecaAttrToId['users/handle'], 'bobby_newuser'];
|
|
696
692
|
const expected = [
|
|
@@ -714,8 +710,8 @@ test('lookups create entities from unlinks', () => {
|
|
|
714
710
|
test('mode: update', () => {
|
|
715
711
|
// create
|
|
716
712
|
var id = uuid();
|
|
717
|
-
var ops =
|
|
718
|
-
var result =
|
|
713
|
+
var ops = sidetx.tx.users[id].update({ handle: 'test' });
|
|
714
|
+
var result = sideml.transform(
|
|
719
715
|
{ attrsStore: zenecaAttrsStore, stores: [store] },
|
|
720
716
|
ops,
|
|
721
717
|
);
|
|
@@ -724,10 +720,10 @@ test('mode: update', () => {
|
|
|
724
720
|
}
|
|
725
721
|
|
|
726
722
|
// update by id
|
|
727
|
-
ops =
|
|
723
|
+
ops = sidetx.tx.users['ce942051-2d74-404a-9c7d-4aa3f2d54ae4'].update({
|
|
728
724
|
handle: 'joe2',
|
|
729
725
|
});
|
|
730
|
-
result =
|
|
726
|
+
result = sideml.transform(
|
|
731
727
|
{ attrsStore: zenecaAttrsStore, stores: [store] },
|
|
732
728
|
ops,
|
|
733
729
|
);
|
|
@@ -736,10 +732,10 @@ test('mode: update', () => {
|
|
|
736
732
|
}
|
|
737
733
|
|
|
738
734
|
// update by lookup
|
|
739
|
-
ops =
|
|
740
|
-
|
|
741
|
-
);
|
|
742
|
-
result =
|
|
735
|
+
ops = sidetx.tx.users[sidetx.lookup('email', 'stopa@example.com')].update({
|
|
736
|
+
handle: 'stopa2',
|
|
737
|
+
});
|
|
738
|
+
result = sideml.transform(
|
|
743
739
|
{ attrsStore: zenecaAttrsStore, stores: [store] },
|
|
744
740
|
ops,
|
|
745
741
|
);
|
|
@@ -748,8 +744,8 @@ test('mode: update', () => {
|
|
|
748
744
|
}
|
|
749
745
|
|
|
750
746
|
// forced mode
|
|
751
|
-
var ops =
|
|
752
|
-
var result =
|
|
747
|
+
var ops = sidetx.tx.users[id].update({ handle: 'test' }, { upsert: false });
|
|
748
|
+
var result = sideml.transform(
|
|
753
749
|
{ attrsStore: zenecaAttrsStore, stores: [store] },
|
|
754
750
|
ops,
|
|
755
751
|
);
|
|
@@ -757,11 +753,11 @@ test('mode: update', () => {
|
|
|
757
753
|
expect(txStep[4]).toEqual({ mode: 'update' });
|
|
758
754
|
}
|
|
759
755
|
|
|
760
|
-
var ops =
|
|
756
|
+
var ops = sidetx.tx.users['ce942051-2d74-404a-9c7d-4aa3f2d54ae4'].update(
|
|
761
757
|
{ handle: 'test' },
|
|
762
758
|
{ upsert: true },
|
|
763
759
|
);
|
|
764
|
-
var result =
|
|
760
|
+
var result = sideml.transform(
|
|
765
761
|
{ attrsStore: zenecaAttrsStore, stores: [store] },
|
|
766
762
|
ops,
|
|
767
763
|
);
|
|
@@ -772,10 +768,10 @@ test('mode: update', () => {
|
|
|
772
768
|
|
|
773
769
|
test('it throws if you use an invalid link attr', () => {
|
|
774
770
|
expect(() =>
|
|
775
|
-
|
|
771
|
+
sideml.transform(
|
|
776
772
|
{ attrsStore: new AttrsStoreClass({}, null) },
|
|
777
|
-
|
|
778
|
-
|
|
773
|
+
sidetx.tx.users[
|
|
774
|
+
sidetx.lookup('user_pref.email', 'test@example.com')
|
|
779
775
|
].update({
|
|
780
776
|
a: 1,
|
|
781
777
|
}),
|
|
@@ -796,7 +792,7 @@ test("it doesn't throw if you have a period in your attr", () => {
|
|
|
796
792
|
'index?': true,
|
|
797
793
|
'unique?': true,
|
|
798
794
|
'value-type': 'blob',
|
|
799
|
-
} as unknown as
|
|
795
|
+
} as unknown as SidekickDBAttr,
|
|
800
796
|
[iid]: {
|
|
801
797
|
id: iid,
|
|
802
798
|
cardinality: 'one',
|
|
@@ -804,7 +800,7 @@ test("it doesn't throw if you have a period in your attr", () => {
|
|
|
804
800
|
'index?': true,
|
|
805
801
|
'unique?': false,
|
|
806
802
|
'value-type': 'blob',
|
|
807
|
-
} as unknown as
|
|
803
|
+
} as unknown as SidekickDBAttr,
|
|
808
804
|
[pid]: {
|
|
809
805
|
id: pid,
|
|
810
806
|
cardinality: 'one',
|
|
@@ -812,15 +808,15 @@ test("it doesn't throw if you have a period in your attr", () => {
|
|
|
812
808
|
'index?': false,
|
|
813
809
|
'unique?': false,
|
|
814
810
|
'value-type': 'blob',
|
|
815
|
-
} as unknown as
|
|
811
|
+
} as unknown as SidekickDBAttr,
|
|
816
812
|
},
|
|
817
813
|
null,
|
|
818
814
|
);
|
|
819
815
|
|
|
820
816
|
expect(
|
|
821
|
-
|
|
817
|
+
sideml.transform(
|
|
822
818
|
{ attrsStore },
|
|
823
|
-
|
|
819
|
+
sidetx.tx.users[sidetx.lookup('attr.with.dot', 'value')].update({
|
|
824
820
|
a: 1,
|
|
825
821
|
}),
|
|
826
822
|
),
|
|
@@ -834,11 +830,11 @@ test("it doesn't create duplicate ref attrs", () => {
|
|
|
834
830
|
const aid = uuid();
|
|
835
831
|
const bid = uuid();
|
|
836
832
|
const ops = [
|
|
837
|
-
|
|
838
|
-
|
|
833
|
+
sidetx.tx.nsA[aid].update({}).link({ nsB: bid }),
|
|
834
|
+
sidetx.tx.nsB[bid].update({}).link({ nsA: aid }),
|
|
839
835
|
];
|
|
840
836
|
|
|
841
|
-
const result =
|
|
837
|
+
const result = sideml.transform(
|
|
842
838
|
{ attrsStore: new AttrsStoreClass({}, null) },
|
|
843
839
|
ops,
|
|
844
840
|
);
|
|
@@ -919,7 +915,7 @@ test('Schema: uses info in `attrs` and `links`', () => {
|
|
|
919
915
|
|
|
920
916
|
const commentId = uuid();
|
|
921
917
|
const bookId = uuid();
|
|
922
|
-
const ops =
|
|
918
|
+
const ops = sidetx.tx.comments[commentId]
|
|
923
919
|
.update({
|
|
924
920
|
slug: 'test-slug',
|
|
925
921
|
})
|
|
@@ -927,7 +923,7 @@ test('Schema: uses info in `attrs` and `links`', () => {
|
|
|
927
923
|
book: bookId,
|
|
928
924
|
});
|
|
929
925
|
|
|
930
|
-
const result =
|
|
926
|
+
const result = sideml.transform(
|
|
931
927
|
{
|
|
932
928
|
attrsStore: zenecaAttrsStore,
|
|
933
929
|
schema: schema,
|
|
@@ -1009,11 +1005,11 @@ test("Schema: doesn't create duplicate ref attrs", () => {
|
|
|
1009
1005
|
const commentId = uuid();
|
|
1010
1006
|
const bookId = uuid();
|
|
1011
1007
|
const ops = [
|
|
1012
|
-
|
|
1013
|
-
|
|
1008
|
+
sidetx.tx.comments[commentId].update({}).link({ book: bookId }),
|
|
1009
|
+
sidetx.tx.books[bookId].update({}).link({ comments: commentId }),
|
|
1014
1010
|
];
|
|
1015
1011
|
|
|
1016
|
-
const result =
|
|
1012
|
+
const result = sideml.transform(
|
|
1017
1013
|
{ attrsStore: zenecaAttrsStore, schema },
|
|
1018
1014
|
ops,
|
|
1019
1015
|
);
|
|
@@ -1064,11 +1060,9 @@ test('Schema: lookup creates unique attrs for custom lookups', () => {
|
|
|
1064
1060
|
},
|
|
1065
1061
|
});
|
|
1066
1062
|
|
|
1067
|
-
const ops =
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
},
|
|
1071
|
-
);
|
|
1063
|
+
const ops = sidetx.tx.users[sidetx.lookup('nickname', 'stopanator')].update({
|
|
1064
|
+
handle: 'stopa',
|
|
1065
|
+
});
|
|
1072
1066
|
|
|
1073
1067
|
const lookup = [
|
|
1074
1068
|
// The attr is going to be created, so we don't know its value yet
|
|
@@ -1076,7 +1070,7 @@ test('Schema: lookup creates unique attrs for custom lookups', () => {
|
|
|
1076
1070
|
'stopanator',
|
|
1077
1071
|
];
|
|
1078
1072
|
|
|
1079
|
-
const result =
|
|
1073
|
+
const result = sideml.transform(
|
|
1080
1074
|
{ attrsStore: zenecaAttrsStore, schema },
|
|
1081
1075
|
ops,
|
|
1082
1076
|
);
|
|
@@ -1131,11 +1125,11 @@ test('Schema: lookup creates unique attrs for lookups in link values', () => {
|
|
|
1131
1125
|
});
|
|
1132
1126
|
|
|
1133
1127
|
const uid = uuid();
|
|
1134
|
-
const ops =
|
|
1128
|
+
const ops = sidetx.tx.users[uid]
|
|
1135
1129
|
.update({})
|
|
1136
|
-
.link({ authoredPosts:
|
|
1130
|
+
.link({ authoredPosts: sidetx.lookup('slug', 'life-is-good') });
|
|
1137
1131
|
|
|
1138
|
-
const result =
|
|
1132
|
+
const result = sideml.transform(
|
|
1139
1133
|
{ attrsStore: new AttrsStoreClass({}, null), schema },
|
|
1140
1134
|
ops,
|
|
1141
1135
|
);
|
|
@@ -1215,14 +1209,14 @@ test('Schema: lookup creates unique attrs for lookups in link values with arrays
|
|
|
1215
1209
|
});
|
|
1216
1210
|
|
|
1217
1211
|
const uid = uuid();
|
|
1218
|
-
const ops =
|
|
1212
|
+
const ops = sidetx.tx.users[uid].update({}).link({
|
|
1219
1213
|
authoredPosts: [
|
|
1220
|
-
|
|
1221
|
-
|
|
1214
|
+
sidetx.lookup('slug', 'life-is-good'),
|
|
1215
|
+
sidetx.lookup('slug', 'check-this-out'),
|
|
1222
1216
|
],
|
|
1223
1217
|
});
|
|
1224
1218
|
|
|
1225
|
-
const result =
|
|
1219
|
+
const result = sideml.transform(
|
|
1226
1220
|
{ attrsStore: new AttrsStoreClass({}, null), schema },
|
|
1227
1221
|
ops,
|
|
1228
1222
|
);
|
|
@@ -1311,8 +1305,8 @@ test('Schema: lookup creates unique ref attrs for ref lookup', () => {
|
|
|
1311
1305
|
|
|
1312
1306
|
const uid = uuid();
|
|
1313
1307
|
const ops = [
|
|
1314
|
-
|
|
1315
|
-
|
|
1308
|
+
sidetx.tx.users[uid].update({}),
|
|
1309
|
+
sidetx.tx.user_prefs[sidetx.lookup('user.id', uid)].update({}),
|
|
1316
1310
|
];
|
|
1317
1311
|
|
|
1318
1312
|
const lookup = [
|
|
@@ -1321,7 +1315,7 @@ test('Schema: lookup creates unique ref attrs for ref lookup', () => {
|
|
|
1321
1315
|
uid,
|
|
1322
1316
|
];
|
|
1323
1317
|
|
|
1324
|
-
const result =
|
|
1318
|
+
const result = sideml.transform(
|
|
1325
1319
|
{ attrsStore: new AttrsStoreClass({}, null), schema },
|
|
1326
1320
|
ops,
|
|
1327
1321
|
);
|
|
@@ -1396,9 +1390,9 @@ test('Schema: lookup creates unique ref attrs for ref lookup in link value', ()
|
|
|
1396
1390
|
});
|
|
1397
1391
|
const uid = uuid();
|
|
1398
1392
|
const ops = [
|
|
1399
|
-
|
|
1393
|
+
sidetx.tx.users[uid]
|
|
1400
1394
|
.update({})
|
|
1401
|
-
.link({ user_pref:
|
|
1395
|
+
.link({ user_pref: sidetx.lookup('user.id', uid) }),
|
|
1402
1396
|
];
|
|
1403
1397
|
|
|
1404
1398
|
const lookup = [
|
|
@@ -1407,7 +1401,7 @@ test('Schema: lookup creates unique ref attrs for ref lookup in link value', ()
|
|
|
1407
1401
|
uid,
|
|
1408
1402
|
];
|
|
1409
1403
|
|
|
1410
|
-
const result =
|
|
1404
|
+
const result = sideml.transform(
|
|
1411
1405
|
{ attrsStore: new AttrsStoreClass({}, null), schema },
|
|
1412
1406
|
ops,
|
|
1413
1407
|
);
|
|
@@ -1463,7 +1457,7 @@ test('Schema: populates checked-data-type', () => {
|
|
|
1463
1457
|
});
|
|
1464
1458
|
|
|
1465
1459
|
const commentId = uuid();
|
|
1466
|
-
const ops =
|
|
1460
|
+
const ops = sidetx.tx.comments[commentId].update({
|
|
1467
1461
|
s: 'str',
|
|
1468
1462
|
n: 'num',
|
|
1469
1463
|
d: 'date',
|
|
@@ -1472,7 +1466,7 @@ test('Schema: populates checked-data-type', () => {
|
|
|
1472
1466
|
j: 'json',
|
|
1473
1467
|
});
|
|
1474
1468
|
|
|
1475
|
-
const result =
|
|
1469
|
+
const result = sideml.transform(
|
|
1476
1470
|
{
|
|
1477
1471
|
attrsStore: zenecaAttrsStore,
|
|
1478
1472
|
schema: schema,
|
|
@@ -1584,8 +1578,8 @@ test('Schema: populates checked-data-type', () => {
|
|
|
1584
1578
|
}
|
|
1585
1579
|
});
|
|
1586
1580
|
|
|
1587
|
-
test('
|
|
1588
|
-
const ops =
|
|
1581
|
+
test('sidetx should not be too permissive', () => {
|
|
1582
|
+
const ops = sidetx.tx.books[uuid()].update({
|
|
1589
1583
|
title: 'New Title',
|
|
1590
1584
|
// @ts-expect-error: testing invalid states
|
|
1591
1585
|
}).this_is_an_unknown_op;
|
|
@@ -3,7 +3,7 @@ import { bench } from 'vitest';
|
|
|
3
3
|
import zenecaAttrs from './data/zeneca/attrs.json';
|
|
4
4
|
import zenecaTriples from './data/zeneca/triples.json';
|
|
5
5
|
import { createStore, AttrsStoreClass } from '../../src/store';
|
|
6
|
-
import query from '../../src/
|
|
6
|
+
import query from '../../src/sideql';
|
|
7
7
|
|
|
8
8
|
const zenecaAttrsStore = new AttrsStoreClass(
|
|
9
9
|
zenecaAttrs.reduce((res, x) => {
|