@sprucelabs/spruce-heartwood-utils 7.8.1 → 7.10.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/build/esm/index-module.d.ts +1 -0
- package/build/esm/index-module.js +1 -0
- package/build/esm/tests/remoteVcAssert.js +2 -1
- package/build/esm/types/heartwood-module.types.d.ts +6 -0
- package/build/esm/types/heartwood-module.types.js +1 -0
- package/build/esm/viewControllers/CardRegistrar.js +16 -4
- package/build/index-module.d.ts +1 -0
- package/build/index-module.js +15 -0
- package/build/tests/remoteVcAssert.js +5 -1
- package/build/types/heartwood-module.types.d.ts +6 -0
- package/build/types/heartwood-module.types.js +3 -0
- package/build/viewControllers/CardRegistrar.js +16 -4
- package/package.json +6 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { default as RemoteViewControllerFactory } from './viewControllers/RemoteViewControllerFactory';
|
|
2
2
|
export { default as CardRegistrar } from './viewControllers/CardRegistrar';
|
|
3
3
|
export { default as remoteVcAssert } from './tests/remoteVcAssert';
|
|
4
|
+
export * from './types/heartwood-module.types';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { default as RemoteViewControllerFactory } from './viewControllers/RemoteViewControllerFactory.js';
|
|
2
2
|
export { default as CardRegistrar } from './viewControllers/CardRegistrar.js';
|
|
3
3
|
export { default as remoteVcAssert } from './tests/remoteVcAssert.js';
|
|
4
|
+
export * from './types/heartwood-module.types.js';
|
|
@@ -11,6 +11,7 @@ import { AbstractViewController, vcAssert, } from '@sprucelabs/heartwood-view-co
|
|
|
11
11
|
import { assertOptions } from '@sprucelabs/schema';
|
|
12
12
|
import { eventFaker, } from '@sprucelabs/spruce-test-fixtures';
|
|
13
13
|
import { assert } from '@sprucelabs/test';
|
|
14
|
+
import slug from '../utilities/slug.js';
|
|
14
15
|
const remoteVcAssert = {
|
|
15
16
|
assertSkillViewRendersRemoteCards(options) {
|
|
16
17
|
var _a;
|
|
@@ -125,7 +126,7 @@ function generateVcSource(options) {
|
|
|
125
126
|
].join('\n\n');
|
|
126
127
|
}
|
|
127
128
|
export function generateId() {
|
|
128
|
-
return `${Math.round(new Date().getTime() * (Math.random() * 100))}
|
|
129
|
+
return slug(`${Math.round(new Date().getTime() * (Math.random() * 100))}`);
|
|
129
130
|
}
|
|
130
131
|
class ThrowingErrorCardVc extends AbstractViewController {
|
|
131
132
|
constructor(options) {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SkillViewControllerLoadOptions, SpruceSchemas, ViewController } from '@sprucelabs/heartwood-view-controllers';
|
|
2
|
+
declare type Card = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
3
|
+
export interface RemoteDashboardCard extends ViewController<Card> {
|
|
4
|
+
load?(options: SkillViewControllerLoadOptions): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -38,12 +38,24 @@ export default class CardRegistrar {
|
|
|
38
38
|
try {
|
|
39
39
|
//@ts-ignore
|
|
40
40
|
const { each, controllerOptionsHandler, target, payload } = options !== null && options !== void 0 ? options : {};
|
|
41
|
-
|
|
41
|
+
let targetAndPayload;
|
|
42
|
+
if (target && payload) {
|
|
43
|
+
targetAndPayload = { target, payload };
|
|
44
|
+
}
|
|
45
|
+
else if (payload) {
|
|
46
|
+
targetAndPayload = { payload };
|
|
47
|
+
}
|
|
48
|
+
else if (target) {
|
|
49
|
+
targetAndPayload = { target };
|
|
50
|
+
}
|
|
42
51
|
const cards = [];
|
|
43
|
-
yield this.client.
|
|
52
|
+
yield this.client.emit(this.eventName, targetAndPayload, (targetAndPayload) => __awaiter(this, void 0, void 0, function* () {
|
|
44
53
|
var _a;
|
|
45
|
-
const { payload } = targetAndPayload !== null && targetAndPayload !== void 0 ? targetAndPayload : {};
|
|
46
|
-
|
|
54
|
+
const { payload, errors } = targetAndPayload !== null && targetAndPayload !== void 0 ? targetAndPayload : {};
|
|
55
|
+
if (errors === null || errors === void 0 ? void 0 : errors[0]) {
|
|
56
|
+
throw errors === null || errors === void 0 ? void 0 : errors[0];
|
|
57
|
+
}
|
|
58
|
+
const vcIds = payload ? this.vcIdsTransformer(payload) : [];
|
|
47
59
|
if (!Array.isArray(vcIds)) {
|
|
48
60
|
throw 'Your vcIdsTransform MUST return an array!';
|
|
49
61
|
}
|
package/build/index-module.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { default as RemoteViewControllerFactory } from './viewControllers/RemoteViewControllerFactory';
|
|
2
2
|
export { default as CardRegistrar } from './viewControllers/CardRegistrar';
|
|
3
3
|
export { default as remoteVcAssert } from './tests/remoteVcAssert';
|
|
4
|
+
export * from './types/heartwood-module.types';
|
package/build/index-module.js
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
18
|
};
|
|
@@ -10,4 +24,5 @@ var CardRegistrar_1 = require("./viewControllers/CardRegistrar");
|
|
|
10
24
|
Object.defineProperty(exports, "CardRegistrar", { enumerable: true, get: function () { return __importDefault(CardRegistrar_1).default; } });
|
|
11
25
|
var remoteVcAssert_1 = require("./tests/remoteVcAssert");
|
|
12
26
|
Object.defineProperty(exports, "remoteVcAssert", { enumerable: true, get: function () { return __importDefault(remoteVcAssert_1).default; } });
|
|
27
|
+
__exportStar(require("./types/heartwood-module.types"), exports);
|
|
13
28
|
//# sourceMappingURL=index-module.js.map
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.generateId = void 0;
|
|
4
7
|
const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-controllers");
|
|
5
8
|
const schema_1 = require("@sprucelabs/schema");
|
|
6
9
|
const spruce_test_fixtures_1 = require("@sprucelabs/spruce-test-fixtures");
|
|
7
10
|
const test_1 = require("@sprucelabs/test");
|
|
11
|
+
const slug_1 = __importDefault(require("../utilities/slug"));
|
|
8
12
|
const remoteVcAssert = {
|
|
9
13
|
async assertSkillViewRendersRemoteCards(options) {
|
|
10
14
|
var _a;
|
|
@@ -117,7 +121,7 @@ function generateVcSource(options) {
|
|
|
117
121
|
].join('\n\n');
|
|
118
122
|
}
|
|
119
123
|
function generateId() {
|
|
120
|
-
return `${Math.round(new Date().getTime() * (Math.random() * 100))}
|
|
124
|
+
return (0, slug_1.default)(`${Math.round(new Date().getTime() * (Math.random() * 100))}`);
|
|
121
125
|
}
|
|
122
126
|
exports.generateId = generateId;
|
|
123
127
|
class ThrowingErrorCardVc extends heartwood_view_controllers_1.AbstractViewController {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SkillViewControllerLoadOptions, SpruceSchemas, ViewController } from '@sprucelabs/heartwood-view-controllers';
|
|
2
|
+
declare type Card = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
3
|
+
export interface RemoteDashboardCard extends ViewController<Card> {
|
|
4
|
+
load?(options: SkillViewControllerLoadOptions): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
export {};
|
|
@@ -33,12 +33,24 @@ class CardRegistrar {
|
|
|
33
33
|
try {
|
|
34
34
|
//@ts-ignore
|
|
35
35
|
const { each, controllerOptionsHandler, target, payload } = options !== null && options !== void 0 ? options : {};
|
|
36
|
-
|
|
36
|
+
let targetAndPayload;
|
|
37
|
+
if (target && payload) {
|
|
38
|
+
targetAndPayload = { target, payload };
|
|
39
|
+
}
|
|
40
|
+
else if (payload) {
|
|
41
|
+
targetAndPayload = { payload };
|
|
42
|
+
}
|
|
43
|
+
else if (target) {
|
|
44
|
+
targetAndPayload = { target };
|
|
45
|
+
}
|
|
37
46
|
const cards = [];
|
|
38
|
-
await this.client.
|
|
47
|
+
await this.client.emit(this.eventName, targetAndPayload, async (targetAndPayload) => {
|
|
39
48
|
var _a;
|
|
40
|
-
const { payload } = targetAndPayload !== null && targetAndPayload !== void 0 ? targetAndPayload : {};
|
|
41
|
-
|
|
49
|
+
const { payload, errors } = targetAndPayload !== null && targetAndPayload !== void 0 ? targetAndPayload : {};
|
|
50
|
+
if (errors === null || errors === void 0 ? void 0 : errors[0]) {
|
|
51
|
+
throw errors === null || errors === void 0 ? void 0 : errors[0];
|
|
52
|
+
}
|
|
53
|
+
const vcIds = payload ? this.vcIdsTransformer(payload) : [];
|
|
42
54
|
if (!Array.isArray(vcIds)) {
|
|
43
55
|
throw 'Your vcIdsTransform MUST return an array!';
|
|
44
56
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sprucelabs/spruce-heartwood-utils",
|
|
3
3
|
"description": "Heartwood Utilities",
|
|
4
|
-
"version": "7.
|
|
4
|
+
"version": "7.10.0",
|
|
5
5
|
"skill": {
|
|
6
6
|
"namespace": "heartwood"
|
|
7
7
|
},
|
|
@@ -33,7 +33,11 @@
|
|
|
33
33
|
"build/tests/remoteVcAssert.js",
|
|
34
34
|
"build/tests/remoteVcAssert.d.ts",
|
|
35
35
|
"build/esm/tests/remoteVcAssert.js",
|
|
36
|
-
"build/esm/tests/remoteVcAssert.d.ts"
|
|
36
|
+
"build/esm/tests/remoteVcAssert.d.ts",
|
|
37
|
+
"build/types/heartwood-module.types.js",
|
|
38
|
+
"build/types/heartwood-module.types.d.ts",
|
|
39
|
+
"build/esm/types/heartwood-module.types.js",
|
|
40
|
+
"build/esm/types/heartwood-module.types.d.ts"
|
|
37
41
|
],
|
|
38
42
|
"keywords": [],
|
|
39
43
|
"scripts": {
|