@live-change/relations-plugin 0.7.39 → 0.8.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/boundTo.js +5 -5
- package/boundToAny.js +5 -5
- package/changeTriggers.js +4 -5
- package/combinations.js +1 -1
- package/dataUtils.js +2 -2
- package/entity.js +8 -6
- package/index.js +15 -13
- package/itemEvents.js +4 -3
- package/itemOf.js +7 -7
- package/itemOfAny.js +7 -7
- package/package.json +4 -3
- package/pluralRelationAnyUtils.js +9 -8
- package/pluralRelationUtils.js +8 -7
- package/propertyEvents.js +4 -3
- package/propertyOf.js +6 -6
- package/propertyOfAny.js +7 -8
- package/relatedTo.js +8 -9
- package/relatedToAny.js +8 -9
- package/singularRelationAnyUtils.js +10 -8
- package/singularRelationUtils.js +5 -6
- package/utils.js +9 -9
- package/utilsAny.js +7 -7
- package/tests/tests.js +0 -220
package/boundTo.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
2
|
defineProperties, defineIndex,
|
|
3
3
|
processModelsAnnotation, generateId
|
|
4
|
-
}
|
|
4
|
+
} from './utils.js'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
import { defineSetEvent, defineUpdatedEvent, defineTransferredEvent, defineResetEvent } from './propertyEvents.js'
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
import { defineView, defineSetAction, defineUpdateAction, defineResetAction } from './singularRelationUtils.js'
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
export default function(service, app) {
|
|
11
11
|
processModelsAnnotation(service, app, 'boundTo', false, (config, context) => {
|
|
12
12
|
|
|
13
13
|
context.relationWord = 'Friend'
|
package/boundToAny.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
2
|
defineAnyProperties, defineAnyIndex,
|
|
3
3
|
processModelsAnyAnnotation, generateAnyId
|
|
4
|
-
}
|
|
4
|
+
} from './utilsAny.js'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
import { defineSetEvent, defineUpdatedEvent, defineTransferredEvent, defineResetEvent } from './propertyEvents.js'
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
import { defineView, defineSetAction, defineUpdateAction, defineResetAction } from './singularRelationUtils.js'
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
export default function(service, app) {
|
|
11
11
|
processModelsAnyAnnotation(service, app, 'boundToAny', false, (config, context) => {
|
|
12
12
|
|
|
13
13
|
context.relationWord = 'Friend'
|
package/changeTriggers.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {
|
|
1
|
+
import { extractObjectData, extractIdentifiers } from "./dataUtils.js"
|
|
2
|
+
import {
|
|
4
3
|
TriggerDefinition
|
|
5
|
-
}
|
|
4
|
+
} from "@live-change/framework"
|
|
6
5
|
|
|
7
6
|
async function fireChangeTriggers(context, objectType, identifiers, object, oldData, data) {
|
|
8
7
|
const { service, modelName, app } = context
|
|
@@ -255,7 +254,7 @@ function registerParentCopyTriggers(context, config) {
|
|
|
255
254
|
}
|
|
256
255
|
}
|
|
257
256
|
|
|
258
|
-
|
|
257
|
+
export {
|
|
259
258
|
fireChangeTriggers,
|
|
260
259
|
registerParentDeleteTriggers,
|
|
261
260
|
registerParentCopyTriggers,
|
package/combinations.js
CHANGED
package/dataUtils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import App from "@live-change/framework"
|
|
2
2
|
|
|
3
3
|
function extractIdentifiers(otherPropertyNames, properties) {
|
|
4
4
|
const identifiers = {}
|
|
@@ -18,7 +18,7 @@ function extractObjectData(writeableProperties, properties, defaults) {
|
|
|
18
18
|
return App.utils.mergeDeep({}, defaults, JSON.parse(JSON.stringify(objectData)))
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
export {
|
|
22
22
|
extractIdentifiers,
|
|
23
23
|
extractObjectData
|
|
24
24
|
}
|
package/entity.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
2
|
defineProperties, defineIndex,
|
|
3
3
|
processModelsAnnotation, extractIdParts, extractIdentifiers, extractObjectData
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
} from './utils.js'
|
|
5
|
+
import { fireChangeTriggers } from "./changeTriggers.js"
|
|
6
|
+
import App from '@live-change/framework'
|
|
7
|
+
import {
|
|
8
|
+
PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition, EventDefinition
|
|
9
|
+
} from "@live-change/framework"
|
|
8
10
|
|
|
9
11
|
const annotation = 'entity'
|
|
10
12
|
|
|
@@ -195,7 +197,7 @@ function defineDeleteAction(config, context) {
|
|
|
195
197
|
})
|
|
196
198
|
}
|
|
197
199
|
|
|
198
|
-
|
|
200
|
+
export default function(service, app) {
|
|
199
201
|
if (!service) throw new Error("no service")
|
|
200
202
|
if (!app) throw new Error("no app")
|
|
201
203
|
|
package/index.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import entity from './entity.js'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import propertyOf from './propertyOf.js'
|
|
4
|
+
import itemOf from './itemOf.js'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
import propertyOfAny from './propertyOfAny.js'
|
|
7
|
+
import itemOfAny from './itemOfAny.js'
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
import relatedTo from './relatedTo.js'
|
|
10
|
+
import relatedToAny from './relatedToAny.js'
|
|
11
|
+
|
|
12
|
+
import boundTo from './boundTo.js'
|
|
13
|
+
import boundToAny from './boundToAny.js'
|
|
11
14
|
|
|
12
|
-
const boundTo = require('./boundTo.js')
|
|
13
|
-
const boundToAny = require('./boundToAny.js')
|
|
14
15
|
|
|
15
16
|
const processors = [
|
|
16
17
|
entity,
|
|
@@ -20,10 +21,11 @@ const processors = [
|
|
|
20
21
|
boundTo, boundToAny
|
|
21
22
|
]
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
const plugin = function(app, services) {
|
|
24
25
|
app.defaultProcessors.push(...processors)
|
|
25
26
|
}
|
|
27
|
+
plugin.processors = processors
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
export default plugin
|
|
30
|
+
|
|
31
|
+
export { processors }
|
package/itemEvents.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition, EventDefinition
|
|
3
|
+
} from "@live-change/framework"
|
|
3
4
|
|
|
4
5
|
function defineCreatedEvent(config, context) {
|
|
5
6
|
const {
|
|
@@ -72,7 +73,7 @@ function defineCopyEvent(config, context) {
|
|
|
72
73
|
})
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
|
|
76
|
+
export {
|
|
76
77
|
defineCreatedEvent, defineUpdatedEvent, defineTransferredEvent, defineDeletedEvent,
|
|
77
78
|
defineCopyEvent,
|
|
78
79
|
}
|
package/itemOf.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
2
|
defineProperties, defineIndexes,
|
|
3
3
|
processModelsAnnotation, addAccessControlParents,
|
|
4
4
|
defineDeleteByOwnerEvents, defineParentDeleteTriggers, defineParentCopyTriggers
|
|
5
|
-
}
|
|
5
|
+
} from './utils.js'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import {
|
|
8
8
|
defineCreatedEvent, defineUpdatedEvent, defineDeletedEvent, defineTransferredEvent,
|
|
9
9
|
defineCopyEvent
|
|
10
|
-
}
|
|
10
|
+
} from './itemEvents.js'
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
import {
|
|
13
13
|
defineView, defineCreateAction, defineUpdateAction, defineDeleteAction, defineSortIndex,
|
|
14
14
|
defineCopyAction, defineCopyOnParentCopyTrigger
|
|
15
|
-
}
|
|
15
|
+
} from './pluralRelationUtils.js'
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
export default function(service, app) {
|
|
18
18
|
processModelsAnnotation(service, app, 'itemOf', false, (config, context) => {
|
|
19
19
|
|
|
20
20
|
context.relationWord = 'Item'
|
package/itemOfAny.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
2
|
defineAnyProperties, defineAnyIndexes,
|
|
3
3
|
processModelsAnyAnnotation, addAccessControlAnyParents, generateAnyId, defineDeleteByOwnerEvents,
|
|
4
4
|
defineParentDeleteTrigger
|
|
5
|
-
}
|
|
5
|
+
} from './utilsAny.js'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import {
|
|
8
8
|
defineCreatedEvent, defineUpdatedEvent, defineDeletedEvent, defineTransferredEvent,
|
|
9
|
-
}
|
|
9
|
+
} from './itemEvents.js'
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
import {
|
|
12
12
|
defineView, defineCreateAction, defineUpdateAction, defineDeleteAction, defineSortIndex
|
|
13
|
-
}
|
|
13
|
+
} from './pluralRelationAnyUtils.js'
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
export default function(service, app) {
|
|
16
16
|
processModelsAnyAnnotation(service, app, 'itemOfAny',false, (config, context) => {
|
|
17
17
|
|
|
18
18
|
context.relationWord = 'Item'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/relations-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -20,9 +20,10 @@
|
|
|
20
20
|
"name": "Michał Łaszczewski",
|
|
21
21
|
"url": "https://www.viamage.com/"
|
|
22
22
|
},
|
|
23
|
+
"type": "module",
|
|
23
24
|
"dependencies": {
|
|
24
|
-
"@live-change/framework": "^0.
|
|
25
|
+
"@live-change/framework": "^0.8.0",
|
|
25
26
|
"pluralize": "^8.0.0"
|
|
26
27
|
},
|
|
27
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "59b8c38965b6b737b6123fdcdf12fd0b5bed164f"
|
|
28
29
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
const { PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition, EventDefinition } = App
|
|
3
|
-
const { extractTypeAndIdParts, extractIdentifiersWithTypes, prepareAccessControl } = require("./utilsAny.js")
|
|
4
|
-
const { extractObjectData, extractIdentifiers} = require("./utils.js")
|
|
1
|
+
import App from "@live-change/framework"
|
|
5
2
|
const { extractRange } = App
|
|
3
|
+
import {
|
|
4
|
+
PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition, EventDefinition
|
|
5
|
+
} from "@live-change/framework"
|
|
6
|
+
import { extractTypeAndIdParts, extractIdentifiersWithTypes, prepareAccessControl } from "./utilsAny.js"
|
|
7
|
+
import { extractObjectData, extractIdentifiers} from "./utils.js"
|
|
8
|
+
import { fireChangeTriggers } from "./changeTriggers.js"
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const pluralize = require('pluralize')
|
|
10
|
+
import pluralize from 'pluralize'
|
|
10
11
|
|
|
11
12
|
function defineView(config, context) {
|
|
12
13
|
const { service, modelRuntime, otherPropertyNames, joinedOthersPropertyName, joinedOthersClassName,
|
|
@@ -194,4 +195,4 @@ function defineSortIndex(context, sortFields) {
|
|
|
194
195
|
})
|
|
195
196
|
}
|
|
196
197
|
|
|
197
|
-
|
|
198
|
+
export { defineView, defineCreateAction, defineUpdateAction, defineDeleteAction, defineSortIndex }
|
package/pluralRelationUtils.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import App from '@live-change/framework'
|
|
2
|
+
import {
|
|
3
|
+
PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition, TriggerDefinition
|
|
4
|
+
} from "@live-change/framework"
|
|
5
|
+
import { extractIdParts, extractIdentifiers, extractObjectData, prepareAccessControl } from "./utils.js"
|
|
6
|
+
import { fireChangeTriggers } from "./changeTriggers.js"
|
|
7
|
+
import pluralize from 'pluralize'
|
|
7
8
|
|
|
8
9
|
function defineView(config, context) {
|
|
9
10
|
const { service, modelRuntime, otherPropertyNames, joinedOthersPropertyName, joinedOthersClassName,
|
|
@@ -338,7 +339,7 @@ function defineSortIndex(context, sortFields) {
|
|
|
338
339
|
})
|
|
339
340
|
}
|
|
340
341
|
|
|
341
|
-
|
|
342
|
+
export {
|
|
342
343
|
defineView,
|
|
343
344
|
defineCreateAction, defineUpdateAction, defineDeleteAction, defineCopyAction,
|
|
344
345
|
defineCopyOnParentCopyTrigger,
|
package/propertyEvents.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition, EventDefinition
|
|
3
|
+
} from '@live-change/framework'
|
|
3
4
|
|
|
4
5
|
function defineSetEvent(config, context, generateId) {
|
|
5
6
|
const {
|
|
@@ -65,6 +66,6 @@ function defineResetEvent(config, context, generateId) {
|
|
|
65
66
|
})
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
|
|
69
|
+
export {
|
|
69
70
|
defineSetEvent, defineUpdatedEvent, defineTransferredEvent, defineResetEvent
|
|
70
71
|
}
|
package/propertyOf.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
2
|
defineProperties, defineIndexes,
|
|
3
3
|
processModelsAnnotation, generateId, addAccessControlParents,
|
|
4
4
|
defineDeleteByOwnerEvents, defineParentDeleteTriggers
|
|
5
|
-
}
|
|
5
|
+
} from './utils.js'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import { defineSetEvent, defineUpdatedEvent, defineTransferredEvent, defineResetEvent } from './propertyEvents.js'
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
import {
|
|
10
10
|
defineView, defineSetAction, defineUpdateAction, defineSetOrUpdateAction, defineResetAction
|
|
11
|
-
}
|
|
11
|
+
} from './singularRelationUtils.js'
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
export default function(service, app) {
|
|
14
14
|
processModelsAnnotation(service, app, 'propertyOf', false, (config, context) => {
|
|
15
15
|
|
|
16
16
|
context.relationWord = 'Property'
|
package/propertyOfAny.js
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
2
|
defineAnyProperties, defineAnyIndexes,
|
|
3
3
|
processModelsAnyAnnotation, generateAnyId, addAccessControlAnyParents,
|
|
4
4
|
defineDeleteByOwnerEvents, defineParentDeleteTrigger
|
|
5
|
-
}
|
|
5
|
+
} from './utilsAny.js'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import {
|
|
8
8
|
defineSetEvent, defineUpdatedEvent, defineTransferredEvent, defineResetEvent
|
|
9
|
-
}
|
|
9
|
+
} from './propertyEvents.js'
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
import {
|
|
12
12
|
defineObjectView, defineRangeViews, defineSetAction, defineUpdateAction, defineSetOrUpdateAction, defineResetAction
|
|
13
|
-
}
|
|
14
|
-
const {defineResetByOwner} = require("./propertyEvents");
|
|
13
|
+
} from './singularRelationAnyUtils.js'
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
export default function(service, app) {
|
|
17
16
|
processModelsAnyAnnotation(service, app, 'propertyOfAny', false, (config, context) => {
|
|
18
17
|
|
|
19
18
|
context.relationWord = 'Property'
|
package/relatedTo.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
defineProperties, defineIndex,
|
|
3
|
-
|
|
4
|
-
} = require('./utils.js')
|
|
1
|
+
import {
|
|
2
|
+
defineProperties, defineIndex, processModelsAnnotation
|
|
3
|
+
} from './utils.js'
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
import {
|
|
7
6
|
defineCreatedEvent, defineUpdatedEvent, defineDeletedEvent, defineTransferredEvent,
|
|
8
|
-
}
|
|
7
|
+
} from './itemEvents.js'
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
import {
|
|
11
10
|
defineView, defineCreateAction, defineUpdateAction, defineDeleteAction, defineSortIndex
|
|
12
|
-
}
|
|
11
|
+
} from './pluralRelationUtils.js'
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
export default function(service, app) {
|
|
15
14
|
processModelsAnnotation(service, app, 'relatedTo', true, (config, context) => {
|
|
16
15
|
|
|
17
16
|
context.relationWord = 'Friend'
|
package/relatedToAny.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
defineAnyProperties, defineAnyIndex,
|
|
3
|
-
|
|
4
|
-
} = require('./utilsAny.js')
|
|
1
|
+
import {
|
|
2
|
+
defineAnyProperties, defineAnyIndex, processModelsAnyAnnotation
|
|
3
|
+
} from './utilsAny.js'
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
import {
|
|
7
6
|
defineCreatedEvent, defineUpdatedEvent, defineDeletedEvent, defineTransferredEvent,
|
|
8
|
-
}
|
|
7
|
+
} from './itemEvents.js'
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
import {
|
|
11
10
|
defineView, defineCreateAction, defineUpdateAction, defineDeleteAction, defineSortIndex
|
|
12
|
-
}
|
|
11
|
+
} from './pluralRelationAnyUtils.js'
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
export default function(service, app) {
|
|
15
14
|
processModelsAnyAnnotation(service, app, 'relatedToAny',true, (config, context) => {
|
|
16
15
|
|
|
17
16
|
context.relationWord = 'Friend'
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import App from '@live-change/framework'
|
|
2
|
+
import { PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition } from '@live-change/framework'
|
|
3
|
+
import {
|
|
4
|
+
extractTypeAndIdParts, extractIdentifiersWithTypes, generateAnyId, prepareAccessControl
|
|
5
|
+
} from './utilsAny.js'
|
|
6
|
+
import { extractObjectData } from "./utils.js"
|
|
7
|
+
import { allCombinations } from "./combinations.js"
|
|
8
|
+
import { fireChangeTriggers } from "./changeTriggers.js"
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
const {fireChangeTriggers} = require("./changeTriggers.js");
|
|
10
|
+
import pluralize from 'pluralize'
|
|
9
11
|
|
|
10
12
|
function createIdentifiersProperties(keys) {
|
|
11
13
|
const identifiers = {}
|
|
@@ -241,7 +243,7 @@ function defineResetAction(config, context) {
|
|
|
241
243
|
})
|
|
242
244
|
}
|
|
243
245
|
|
|
244
|
-
|
|
246
|
+
export {
|
|
245
247
|
defineObjectView, defineRangeViews,
|
|
246
248
|
defineSetAction, defineUpdateAction, defineSetOrUpdateAction, defineResetAction
|
|
247
249
|
}
|
package/singularRelationUtils.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {
|
|
1
|
+
import { PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition } from "@live-change/framework"
|
|
2
|
+
import {
|
|
4
3
|
extractIdentifiers, extractObjectData, generateId, extractIdParts, prepareAccessControl
|
|
5
|
-
}
|
|
6
|
-
|
|
4
|
+
} from "./utils.js"
|
|
5
|
+
import { fireChangeTriggers } from "./changeTriggers.js"
|
|
7
6
|
|
|
8
7
|
function defineView(config, context) {
|
|
9
8
|
const { service, modelRuntime, otherPropertyNames, joinedOthersPropertyName, joinedOthersClassName,
|
|
@@ -189,4 +188,4 @@ function defineResetAction(config, context) {
|
|
|
189
188
|
})
|
|
190
189
|
}
|
|
191
190
|
|
|
192
|
-
|
|
191
|
+
export { defineView, defineSetAction, defineUpdateAction, defineSetOrUpdateAction, defineResetAction }
|
package/utils.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import App from "@live-change/framework"
|
|
2
2
|
const app = App.app()
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { allCombinations } from "./combinations.js"
|
|
4
|
+
import {
|
|
5
5
|
fireChangeTriggers, registerParentDeleteTriggers, registerParentCopyTriggers
|
|
6
|
-
}
|
|
7
|
-
|
|
6
|
+
} from "./changeTriggers.js"
|
|
7
|
+
import {
|
|
8
8
|
PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition, EventDefinition, TriggerDefinition
|
|
9
|
-
}
|
|
9
|
+
} from "@live-change/framework"
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
import {
|
|
12
12
|
extractObjectData, extractIdentifiers
|
|
13
|
-
}
|
|
13
|
+
} from './dataUtils.js'
|
|
14
14
|
|
|
15
15
|
function extractIdParts(otherPropertyNames, properties) {
|
|
16
16
|
const idParts = []
|
|
@@ -188,7 +188,7 @@ function defineParentCopyTriggers(config, context) {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
|
|
191
|
-
|
|
191
|
+
export {
|
|
192
192
|
extractIdParts, extractIdentifiers, extractObjectData, defineProperties, defineIndex, defineIndexes,
|
|
193
193
|
processModelsAnnotation, generateId, addAccessControlParents, prepareAccessControl,
|
|
194
194
|
defineDeleteByOwnerEvents, defineParentDeleteTriggers, defineParentCopyTriggers,
|
package/utilsAny.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import App from "@live-change/framework"
|
|
2
2
|
const app = App.app()
|
|
3
|
-
|
|
3
|
+
import {
|
|
4
4
|
PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition, EventDefinition, TriggerDefinition
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
} from "@live-change/framework"
|
|
6
|
+
import { allCombinations } from "./combinations.js"
|
|
7
|
+
import { fireChangeTriggers, registerParentDeleteTriggers } from "./changeTriggers.js"
|
|
8
|
+
import { extractObjectData } from "./dataUtils.js"
|
|
9
9
|
|
|
10
10
|
function extractTypeAndIdParts(otherPropertyNames, properties) {
|
|
11
11
|
const typeAndIdParts = []
|
|
@@ -192,7 +192,7 @@ function defineParentDeleteTrigger(config, context) {
|
|
|
192
192
|
registerParentDeleteTriggers(context, config)
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
|
|
195
|
+
export {
|
|
196
196
|
extractTypeAndIdParts, extractIdentifiersWithTypes, defineAnyProperties,
|
|
197
197
|
defineAnyIndex, defineAnyIndexes,
|
|
198
198
|
processModelsAnyAnnotation, generateAnyId,
|
package/tests/tests.js
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
const test = require('blue-tape')
|
|
2
|
-
const r = require('rethinkdb')
|
|
3
|
-
const testUtils = require('rethink-event-sourcing/tape-test-utils.js')
|
|
4
|
-
const crypto = require('crypto')
|
|
5
|
-
|
|
6
|
-
test('Session service login, logout', t => {
|
|
7
|
-
t.plan(9)
|
|
8
|
-
|
|
9
|
-
let conn
|
|
10
|
-
|
|
11
|
-
testUtils.connectToDatabase(t, r, (connection) => conn = connection)
|
|
12
|
-
|
|
13
|
-
let sessionId = crypto.randomBytes(24).toString('hex')
|
|
14
|
-
let userId = crypto.randomBytes(24).toString('hex')
|
|
15
|
-
|
|
16
|
-
t.test('create user', t => {
|
|
17
|
-
t.plan(2)
|
|
18
|
-
|
|
19
|
-
testUtils.runCommand(t, r, 'user', {
|
|
20
|
-
type: 'create',
|
|
21
|
-
userId: userId
|
|
22
|
-
}, (cId) => { }).then(
|
|
23
|
-
result => {
|
|
24
|
-
}
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
t.test('check if user exists', t=> {
|
|
28
|
-
t.plan(2)
|
|
29
|
-
setTimeout(()=>{
|
|
30
|
-
r.table('user').get(userId).run(conn).then(
|
|
31
|
-
userRow => {
|
|
32
|
-
if(userRow) t.pass('user exists')
|
|
33
|
-
t.equals(userRow.display, 'unknown', 'user display name unknown')
|
|
34
|
-
}
|
|
35
|
-
).catch(t.fail)
|
|
36
|
-
}, 150)
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
t.test('create session', t => {
|
|
42
|
-
t.plan(2)
|
|
43
|
-
|
|
44
|
-
testUtils.runCommand(t, r, 'session', {
|
|
45
|
-
type: 'createSessionIfNotExists',
|
|
46
|
-
sessionId: sessionId
|
|
47
|
-
}, (cId) => {})
|
|
48
|
-
|
|
49
|
-
t.test('check if session exists', t=> {
|
|
50
|
-
t.plan(1)
|
|
51
|
-
setTimeout(()=>{
|
|
52
|
-
r.table('session').get(sessionId).run(conn).then(
|
|
53
|
-
session => {
|
|
54
|
-
if(session) t.pass('session exists')
|
|
55
|
-
else t.fail('session not found')
|
|
56
|
-
}
|
|
57
|
-
).catch(t.fail)
|
|
58
|
-
}, 250)
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
t.test('login', t => {
|
|
64
|
-
t.plan(2)
|
|
65
|
-
|
|
66
|
-
testUtils.pushEvents(t, r, 'session', [
|
|
67
|
-
{
|
|
68
|
-
type: "loggedIn",
|
|
69
|
-
sessionId: sessionId,
|
|
70
|
-
userId: userId,
|
|
71
|
-
roles: [],
|
|
72
|
-
expire: null
|
|
73
|
-
}
|
|
74
|
-
])
|
|
75
|
-
|
|
76
|
-
t.test('check if logged in', t=> {
|
|
77
|
-
t.plan(2)
|
|
78
|
-
setTimeout(()=>{
|
|
79
|
-
r.table('session').get(sessionId).run(conn).then(
|
|
80
|
-
session => {
|
|
81
|
-
t.equal(session.userId, userId, 'user id match')
|
|
82
|
-
t.pass('logged in')
|
|
83
|
-
}
|
|
84
|
-
).catch(t.fail)
|
|
85
|
-
}, 150)
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
let commandId
|
|
91
|
-
|
|
92
|
-
t.test('logout', t => {
|
|
93
|
-
t.plan(3)
|
|
94
|
-
|
|
95
|
-
testUtils.runCommand(t, r, 'session', {
|
|
96
|
-
type: 'logout',
|
|
97
|
-
sessionId: sessionId
|
|
98
|
-
}, (cId) => commandId = cId)
|
|
99
|
-
|
|
100
|
-
t.test('Check if there are events generated', t => {
|
|
101
|
-
t.plan(2)
|
|
102
|
-
|
|
103
|
-
setTimeout(()=>{
|
|
104
|
-
testUtils.getGeneratedEvents(r, 'session', commandId,
|
|
105
|
-
(events) => {
|
|
106
|
-
t.equal(events.length, 1, "generated one event")
|
|
107
|
-
t.equal(events[0].type, "loggedOut", "loggedOut event found")
|
|
108
|
-
})
|
|
109
|
-
}, 150)
|
|
110
|
-
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
t.test('check if logged off', t=> {
|
|
114
|
-
t.plan(2)
|
|
115
|
-
setTimeout(()=>{
|
|
116
|
-
r.table('session').get(sessionId).run(conn).then(
|
|
117
|
-
session => {
|
|
118
|
-
console.log("session", session)
|
|
119
|
-
t.equal(session.userId, undefined, 'userId not exists')
|
|
120
|
-
t.pass('logged out')
|
|
121
|
-
}
|
|
122
|
-
).catch(t.fail)
|
|
123
|
-
}, 150)
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
t.test('second login', t => {
|
|
129
|
-
t.plan(2)
|
|
130
|
-
|
|
131
|
-
testUtils.pushEvents(t, r, 'session', [
|
|
132
|
-
{
|
|
133
|
-
type: "loggedIn",
|
|
134
|
-
sessionId: sessionId,
|
|
135
|
-
userId: userId,
|
|
136
|
-
roles: [],
|
|
137
|
-
expire: null
|
|
138
|
-
}
|
|
139
|
-
])
|
|
140
|
-
|
|
141
|
-
t.test('check if logged in', t=> {
|
|
142
|
-
t.plan(2)
|
|
143
|
-
setTimeout(()=>{
|
|
144
|
-
r.table('session').get(sessionId).run(conn).then(
|
|
145
|
-
session => {
|
|
146
|
-
t.equal(session.userId, userId, 'user id match')
|
|
147
|
-
t.pass('logged in')
|
|
148
|
-
}
|
|
149
|
-
).catch(t.fail)
|
|
150
|
-
}, 150)
|
|
151
|
-
})
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
t.test('change user roles, check session roles', t=> {
|
|
155
|
-
t.plan(3)
|
|
156
|
-
|
|
157
|
-
testUtils.runCommand(t, r, 'user', {
|
|
158
|
-
type: 'updateRoles',
|
|
159
|
-
userId: userId,
|
|
160
|
-
roles: ['test_object']
|
|
161
|
-
}, (cId) => { }).then(
|
|
162
|
-
result => {
|
|
163
|
-
}
|
|
164
|
-
)
|
|
165
|
-
|
|
166
|
-
t.test('check if user roles is changed', t => {
|
|
167
|
-
t.plan(1)
|
|
168
|
-
setTimeout( () => {
|
|
169
|
-
r.table('user').get(userId).run(conn).then(
|
|
170
|
-
user => {
|
|
171
|
-
t.deepEqual(user.roles, [ 'test_object' ], 'roles are updated correctly')
|
|
172
|
-
}
|
|
173
|
-
).catch( t.fail )
|
|
174
|
-
}, 150)
|
|
175
|
-
})
|
|
176
|
-
|
|
177
|
-
t.test('check if session roles is changed', t => {
|
|
178
|
-
t.plan(1)
|
|
179
|
-
setTimeout( () => {
|
|
180
|
-
r.table('session').get(sessionId).run(conn).then(
|
|
181
|
-
session => {
|
|
182
|
-
t.deepEqual(session.roles, [ 'test_object' ], 'roles are updated correctly')
|
|
183
|
-
}
|
|
184
|
-
).catch( t.fail )
|
|
185
|
-
}, 300)
|
|
186
|
-
})
|
|
187
|
-
|
|
188
|
-
})
|
|
189
|
-
|
|
190
|
-
t.test('delete user and check if session is logged out', t => {
|
|
191
|
-
t.plan(2)
|
|
192
|
-
|
|
193
|
-
testUtils.runCommand(t, r, 'user', {
|
|
194
|
-
type: 'remove',
|
|
195
|
-
userId: userId
|
|
196
|
-
}, (cId) => { }).then(result => {})
|
|
197
|
-
|
|
198
|
-
t.test('check if logged out', t=> {
|
|
199
|
-
t.plan(2)
|
|
200
|
-
setTimeout(()=>{
|
|
201
|
-
r.table('session').get(sessionId).run(conn).then(
|
|
202
|
-
session => {
|
|
203
|
-
console.log("session", session)
|
|
204
|
-
t.equal(session.userId, undefined, 'userId not exists')
|
|
205
|
-
t.pass('logged out')
|
|
206
|
-
}
|
|
207
|
-
).catch(t.fail)
|
|
208
|
-
}, 150)
|
|
209
|
-
})
|
|
210
|
-
|
|
211
|
-
})
|
|
212
|
-
|
|
213
|
-
t.test('close connection', t => {
|
|
214
|
-
conn.close(() => {
|
|
215
|
-
t.pass('closed')
|
|
216
|
-
t.end()
|
|
217
|
-
})
|
|
218
|
-
})
|
|
219
|
-
|
|
220
|
-
})
|