@sprucelabs/spruce-heartwood-utils 6.4.0 → 6.4.1
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.
|
@@ -1,33 +1,37 @@
|
|
|
1
1
|
import { AbstractViewController, ViewControllerFactory } from '@sprucelabs/heartwood-view-controllers';
|
|
2
2
|
import { MercuryClient } from '@sprucelabs/mercury-client';
|
|
3
|
-
import {
|
|
3
|
+
import { EventContract, EventNames, SkillEventContract, SpruceSchemas } from '@sprucelabs/mercury-types';
|
|
4
4
|
import { Schema, SchemaValues } from '@sprucelabs/schema';
|
|
5
5
|
declare type Card = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
6
|
-
|
|
7
|
-
declare type
|
|
6
|
+
declare type ResponsePayload<Contract extends EventContract, Name extends EventNames<Contract>> = Contract['eventSignatures'][Name]['responsePayloadSchema'] extends Schema ? SchemaValues<Contract['eventSignatures'][Name]['responsePayloadSchema']> : never;
|
|
7
|
+
declare type EmitPayload<Contract extends EventContract, Name extends EventNames<Contract>> = Contract['eventSignatures'][Name]['emitPayloadSchema'] extends Schema ? SchemaValues<Contract['eventSignatures'][Name]['emitPayloadSchema']> : never;
|
|
8
|
+
export interface CardRegistrarOptions<Contract extends SkillEventContract,
|
|
8
9
|
/** @ts-ignore */
|
|
9
|
-
|
|
10
|
-
declare type EmitPayload<Contract extends SkillEventContract, Name extends EventNames<Contract>
|
|
11
|
-
/** @ts-ignore */
|
|
12
|
-
> = Contract['eventSignatures'][Name]['emitPayloadSchema'] extends Schema ? SchemaValues<Contract['eventSignatures'][Name]['emitPayloadSchema']> : never;
|
|
13
|
-
export interface CardRegistrarOptions<Contract extends SkillEventContract, Name extends EventNames<Contract>> {
|
|
10
|
+
Name extends EventNames<Contract>> {
|
|
14
11
|
client: MercuryClient;
|
|
15
12
|
eventName: Name;
|
|
16
13
|
vcFactory: ViewControllerFactory;
|
|
14
|
+
/** @ts-ignore */
|
|
17
15
|
vcIdsTransformer: (payload: ResponsePayload<Contract, Name>) => string[];
|
|
18
16
|
}
|
|
19
17
|
export declare type EachCardHandler = (vcs: AbstractViewController<any>[]) => Promise<void> | void;
|
|
20
|
-
export declare type CardFetchOptions<Contract extends
|
|
18
|
+
export declare type CardFetchOptions<Contract extends EventContract, Name extends EventNames<Contract>> = {
|
|
21
19
|
each: EachCardHandler;
|
|
22
20
|
} & EmitPayload<Contract, Name>;
|
|
23
|
-
export default class CardRegistrar<
|
|
21
|
+
export default class CardRegistrar<Contract = SkillEventContract,
|
|
24
22
|
/** @ts-ignore */
|
|
25
|
-
|
|
23
|
+
Name extends EventNames<Contract> = EventNames<Contract>> {
|
|
26
24
|
private client;
|
|
27
25
|
private eventName;
|
|
28
26
|
private vcIdsTransformer;
|
|
29
27
|
private remoteVcFactory;
|
|
28
|
+
static Registrar<Contract = SkillEventContract, Name = keyof SkillEventContract['eventSignatures']
|
|
29
|
+
/** @ts-ignore */
|
|
30
|
+
>(options: CardRegistrarOptions<Contract, Name>): CardRegistrar<Contract, Name>;
|
|
31
|
+
/** @ts-ignore */
|
|
30
32
|
constructor(options: CardRegistrarOptions<Contract, Name>);
|
|
31
|
-
fetch(
|
|
33
|
+
fetch(
|
|
34
|
+
/** @ts-ignore */
|
|
35
|
+
options?: CardFetchOptions<Contract, Name>): Promise<AbstractViewController<Card>[]>;
|
|
32
36
|
}
|
|
33
37
|
export {};
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { assertOptions } from '@sprucelabs/schema';
|
|
11
11
|
import RemoteViewControllerFactory from './RemoteViewControllerFactory.js';
|
|
12
12
|
export default class CardRegistrar {
|
|
13
|
+
/** @ts-ignore */
|
|
13
14
|
constructor(options) {
|
|
14
15
|
assertOptions(options, [
|
|
15
16
|
'client',
|
|
@@ -26,7 +27,13 @@ export default class CardRegistrar {
|
|
|
26
27
|
vcFactory: options.vcFactory,
|
|
27
28
|
});
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
+
static Registrar(options) {
|
|
31
|
+
/** @ts-ignore */
|
|
32
|
+
return new this(options);
|
|
33
|
+
}
|
|
34
|
+
fetch(
|
|
35
|
+
/** @ts-ignore */
|
|
36
|
+
options) {
|
|
30
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
38
|
try {
|
|
32
39
|
//@ts-ignore
|
|
@@ -1,33 +1,37 @@
|
|
|
1
1
|
import { AbstractViewController, ViewControllerFactory } from '@sprucelabs/heartwood-view-controllers';
|
|
2
2
|
import { MercuryClient } from '@sprucelabs/mercury-client';
|
|
3
|
-
import {
|
|
3
|
+
import { EventContract, EventNames, SkillEventContract, SpruceSchemas } from '@sprucelabs/mercury-types';
|
|
4
4
|
import { Schema, SchemaValues } from '@sprucelabs/schema';
|
|
5
5
|
declare type Card = SpruceSchemas.HeartwoodViewControllers.v2021_02_11.Card;
|
|
6
|
-
|
|
7
|
-
declare type
|
|
6
|
+
declare type ResponsePayload<Contract extends EventContract, Name extends EventNames<Contract>> = Contract['eventSignatures'][Name]['responsePayloadSchema'] extends Schema ? SchemaValues<Contract['eventSignatures'][Name]['responsePayloadSchema']> : never;
|
|
7
|
+
declare type EmitPayload<Contract extends EventContract, Name extends EventNames<Contract>> = Contract['eventSignatures'][Name]['emitPayloadSchema'] extends Schema ? SchemaValues<Contract['eventSignatures'][Name]['emitPayloadSchema']> : never;
|
|
8
|
+
export interface CardRegistrarOptions<Contract extends SkillEventContract,
|
|
8
9
|
/** @ts-ignore */
|
|
9
|
-
|
|
10
|
-
declare type EmitPayload<Contract extends SkillEventContract, Name extends EventNames<Contract>
|
|
11
|
-
/** @ts-ignore */
|
|
12
|
-
> = Contract['eventSignatures'][Name]['emitPayloadSchema'] extends Schema ? SchemaValues<Contract['eventSignatures'][Name]['emitPayloadSchema']> : never;
|
|
13
|
-
export interface CardRegistrarOptions<Contract extends SkillEventContract, Name extends EventNames<Contract>> {
|
|
10
|
+
Name extends EventNames<Contract>> {
|
|
14
11
|
client: MercuryClient;
|
|
15
12
|
eventName: Name;
|
|
16
13
|
vcFactory: ViewControllerFactory;
|
|
14
|
+
/** @ts-ignore */
|
|
17
15
|
vcIdsTransformer: (payload: ResponsePayload<Contract, Name>) => string[];
|
|
18
16
|
}
|
|
19
17
|
export declare type EachCardHandler = (vcs: AbstractViewController<any>[]) => Promise<void> | void;
|
|
20
|
-
export declare type CardFetchOptions<Contract extends
|
|
18
|
+
export declare type CardFetchOptions<Contract extends EventContract, Name extends EventNames<Contract>> = {
|
|
21
19
|
each: EachCardHandler;
|
|
22
20
|
} & EmitPayload<Contract, Name>;
|
|
23
|
-
export default class CardRegistrar<
|
|
21
|
+
export default class CardRegistrar<Contract = SkillEventContract,
|
|
24
22
|
/** @ts-ignore */
|
|
25
|
-
|
|
23
|
+
Name extends EventNames<Contract> = EventNames<Contract>> {
|
|
26
24
|
private client;
|
|
27
25
|
private eventName;
|
|
28
26
|
private vcIdsTransformer;
|
|
29
27
|
private remoteVcFactory;
|
|
28
|
+
static Registrar<Contract = SkillEventContract, Name = keyof SkillEventContract['eventSignatures']
|
|
29
|
+
/** @ts-ignore */
|
|
30
|
+
>(options: CardRegistrarOptions<Contract, Name>): CardRegistrar<Contract, Name>;
|
|
31
|
+
/** @ts-ignore */
|
|
30
32
|
constructor(options: CardRegistrarOptions<Contract, Name>);
|
|
31
|
-
fetch(
|
|
33
|
+
fetch(
|
|
34
|
+
/** @ts-ignore */
|
|
35
|
+
options?: CardFetchOptions<Contract, Name>): Promise<AbstractViewController<Card>[]>;
|
|
32
36
|
}
|
|
33
37
|
export {};
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const schema_1 = require("@sprucelabs/schema");
|
|
7
7
|
const RemoteViewControllerFactory_1 = __importDefault(require("./RemoteViewControllerFactory"));
|
|
8
8
|
class CardRegistrar {
|
|
9
|
+
/** @ts-ignore */
|
|
9
10
|
constructor(options) {
|
|
10
11
|
(0, schema_1.assertOptions)(options, [
|
|
11
12
|
'client',
|
|
@@ -22,7 +23,13 @@ class CardRegistrar {
|
|
|
22
23
|
vcFactory: options.vcFactory,
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
+
static Registrar(options) {
|
|
27
|
+
/** @ts-ignore */
|
|
28
|
+
return new this(options);
|
|
29
|
+
}
|
|
30
|
+
async fetch(
|
|
31
|
+
/** @ts-ignore */
|
|
32
|
+
options) {
|
|
26
33
|
try {
|
|
27
34
|
//@ts-ignore
|
|
28
35
|
const { each, target, payload } = options !== null && options !== void 0 ? options : {};
|