@things-factory/guild-overlay 10.1.314 → 10.1.315
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-client/components/guild-coin-layer.d.ts +20 -0
- package/dist-client/components/guild-coin-layer.js +403 -0
- package/dist-client/components/guild-overlay-setting-let.d.ts +11 -0
- package/dist-client/components/guild-overlay-setting-let.js +63 -0
- package/dist-client/index.d.ts +2 -0
- package/dist-client/index.js +3 -0
- package/dist-client/overlay-state.d.ts +42 -0
- package/dist-client/overlay-state.js +83 -0
- package/dist-client/setup-guild-overlay.d.ts +3 -0
- package/dist-client/setup-guild-overlay.js +29 -0
- package/dist-server/committed.d.ts +7 -0
- package/dist-server/committed.js +48 -0
- package/dist-server/hub-route.d.ts +49 -2
- package/dist-server/index.d.ts +13 -2
- package/dist-server/index.js +12 -3
- package/dist-server/opportunities.d.ts +23 -0
- package/dist-server/opportunities.js +37 -0
- package/dist-server/overlay-resolver.d.ts +58 -0
- package/dist-server/overlay-resolver.js +274 -0
- package/dist-server/prospect.d.ts +21 -0
- package/dist-server/prospect.js +35 -0
- package/dist-server/pulse.d.ts +36 -0
- package/dist-server/pulse.js +27 -0
- package/package.json +9 -5
- package/translations/en.json +14 -5
- package/translations/es.json +14 -5
- package/translations/ja.json +14 -5
- package/translations/ko.json +14 -5
- package/translations/ms.json +14 -5
- package/translations/zh.json +14 -5
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GuildCommitSubscriber = void 0;
|
|
4
|
+
exports.afterCommitOf = afterCommitOf;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const typeorm_1 = require("typeorm");
|
|
7
|
+
const env_1 = require("@things-factory/env");
|
|
8
|
+
/*
|
|
9
|
+
* **After the work commits** (design §3-2) - a coin a person sees must not stand for a save that rolled back. What is
|
|
10
|
+
* queued here runs once the transaction it was queued in commits at its top level, and is dropped if it rolls back.
|
|
11
|
+
* Outside a transaction it runs at once. Kept per transaction runner, as the captured facts are (`capture.ts`).
|
|
12
|
+
*/
|
|
13
|
+
const QUEUED = new WeakMap();
|
|
14
|
+
const depthOf = (runner) => runner.transactionDepth ?? 0;
|
|
15
|
+
function run(job) {
|
|
16
|
+
Promise.resolve()
|
|
17
|
+
.then(job)
|
|
18
|
+
.catch(error => env_1.logger.warn(`[guild-overlay] after-commit work failed: ${error?.message ?? error}`));
|
|
19
|
+
}
|
|
20
|
+
/** Run `job` when `tx` commits - at once when it is not in a transaction. */
|
|
21
|
+
function afterCommitOf(tx, job) {
|
|
22
|
+
const runner = tx?.queryRunner;
|
|
23
|
+
if (!runner?.isTransactionActive)
|
|
24
|
+
return run(job);
|
|
25
|
+
const list = QUEUED.get(runner) ?? [];
|
|
26
|
+
list.push(job);
|
|
27
|
+
QUEUED.set(runner, list);
|
|
28
|
+
}
|
|
29
|
+
let GuildCommitSubscriber = class GuildCommitSubscriber {
|
|
30
|
+
afterTransactionCommit(event) {
|
|
31
|
+
if (depthOf(event.queryRunner) > 0)
|
|
32
|
+
return;
|
|
33
|
+
const jobs = QUEUED.get(event.queryRunner) ?? [];
|
|
34
|
+
QUEUED.delete(event.queryRunner);
|
|
35
|
+
for (const job of jobs)
|
|
36
|
+
run(job);
|
|
37
|
+
}
|
|
38
|
+
afterTransactionRollback(event) {
|
|
39
|
+
if (depthOf(event.queryRunner) > 0)
|
|
40
|
+
return;
|
|
41
|
+
QUEUED.delete(event.queryRunner);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
exports.GuildCommitSubscriber = GuildCommitSubscriber;
|
|
45
|
+
exports.GuildCommitSubscriber = GuildCommitSubscriber = tslib_1.__decorate([
|
|
46
|
+
(0, typeorm_1.EventSubscriber)()
|
|
47
|
+
], GuildCommitSubscriber);
|
|
48
|
+
//# sourceMappingURL=committed.js.map
|
|
@@ -1,10 +1,57 @@
|
|
|
1
1
|
import type { EntityManager } from 'typeorm';
|
|
2
|
-
import { type ContributionRecord } from './contract.js';
|
|
2
|
+
import { type ContributionPerson, type ContributionRecord } from './contract.js';
|
|
3
3
|
export interface LocalGuildHub {
|
|
4
4
|
/** Take these records for the application in this transaction - what the intake door does with a remote batch. */
|
|
5
5
|
accept(tx: EntityManager, domain: {
|
|
6
6
|
id: string;
|
|
7
7
|
}, application: string, records: ContributionRecord[]): Promise<unknown>;
|
|
8
|
+
/** What a save would earn once confirmed, by the rule in force and the person's counts today (design §3-2). */
|
|
9
|
+
prospect?(domain: {
|
|
10
|
+
id: string;
|
|
11
|
+
}, application: string, input: GuildProspectInput): Promise<GuildProspectReply | undefined>;
|
|
12
|
+
/** One person's wallet, level, badges and the GP each kind is worth (design §14-1). */
|
|
13
|
+
overlayOf?(domain: {
|
|
14
|
+
id: string;
|
|
15
|
+
}, user: {
|
|
16
|
+
id: string;
|
|
17
|
+
}): Promise<GuildOverlayDigest>;
|
|
18
|
+
}
|
|
19
|
+
export interface GuildProspectInput {
|
|
20
|
+
kind: string;
|
|
21
|
+
contributor: ContributionPerson;
|
|
22
|
+
eventAt?: string;
|
|
23
|
+
signals?: Record<string, number>;
|
|
24
|
+
}
|
|
25
|
+
/** A range of GP, or why it would earn nothing (`cap`, `no-rule`, `once` …). */
|
|
26
|
+
export type GuildProspectReply = {
|
|
27
|
+
gpLow: number;
|
|
28
|
+
gpHigh: number;
|
|
29
|
+
} | {
|
|
30
|
+
skipped: string;
|
|
31
|
+
};
|
|
32
|
+
export interface GuildWalletDigest {
|
|
33
|
+
balance: number;
|
|
34
|
+
spendable: number;
|
|
35
|
+
pendingGp: number;
|
|
36
|
+
maturedGp: number;
|
|
37
|
+
everGp: number;
|
|
38
|
+
level: number;
|
|
39
|
+
levelFloor: number;
|
|
40
|
+
nextLevelAt?: number;
|
|
41
|
+
}
|
|
42
|
+
export interface GuildBadgeDigest {
|
|
43
|
+
kind: string;
|
|
44
|
+
count: number;
|
|
45
|
+
step: number;
|
|
46
|
+
nextStep?: number;
|
|
47
|
+
}
|
|
48
|
+
export interface GuildOverlayDigest {
|
|
49
|
+
/** false - the host says this person does not earn (office: not an employee at work today); the overlay stays away. */
|
|
50
|
+
eligible?: boolean;
|
|
51
|
+
wallet?: GuildWalletDigest;
|
|
52
|
+
badges: GuildBadgeDigest[];
|
|
53
|
+
/** The contributor's GP for one of each kind by the rule in force - what a quest says one is worth. */
|
|
54
|
+
baseGp: Record<string, number>;
|
|
8
55
|
}
|
|
9
56
|
export declare function registerLocalGuildHub(hub: LocalGuildHub): void;
|
|
10
57
|
/** For tests. */
|
|
@@ -18,7 +65,7 @@ export type HubRoad = {
|
|
|
18
65
|
kind: 'remote';
|
|
19
66
|
peer: string;
|
|
20
67
|
};
|
|
21
|
-
export declare function hubRoadOf(tx: EntityManager, domain: {
|
|
68
|
+
export declare function hubRoadOf(tx: EntityManager | undefined, domain: {
|
|
22
69
|
id: string;
|
|
23
70
|
}): Promise<HubRoad>;
|
|
24
71
|
/** Hand records over on the road the domain's settings name. */
|
package/dist-server/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { GuildCaptureSubscriber } from './capture.js';
|
|
2
|
+
import { GuildCommitSubscriber } from './committed.js';
|
|
3
|
+
import { GuildOverlayResolver } from './overlay-resolver.js';
|
|
2
4
|
import { GuildFactChangeSeam } from './seams/fact-change-seam.js';
|
|
3
5
|
export * from './contract.js';
|
|
4
6
|
export * from './settings.js';
|
|
@@ -6,9 +8,18 @@ export * from './define-kinds.js';
|
|
|
6
8
|
export * from './hub-route.js';
|
|
7
9
|
export * from './emit.js';
|
|
8
10
|
export * from './capture.js';
|
|
11
|
+
export * from './committed.js';
|
|
12
|
+
export * from './pulse.js';
|
|
13
|
+
export * from './prospect.js';
|
|
14
|
+
export * from './opportunities.js';
|
|
15
|
+
export * from './overlay-resolver.js';
|
|
9
16
|
export * from './manifest-boot.js';
|
|
10
17
|
export * from './seams/fact-change-seam.js';
|
|
11
18
|
export * from './seams/activity-callback-seam.js';
|
|
12
19
|
export { contributionFactId, revertFactId, manifestOf, keptSignals, stableJson } from './record-rules.js';
|
|
13
|
-
/** Loaded by the shell from every module: a transaction's captured facts reset, and the fact-change seam (§3-3). */
|
|
14
|
-
export declare const subscribers: (typeof GuildCaptureSubscriber | typeof GuildFactChangeSeam)[];
|
|
20
|
+
/** Loaded by the shell from every module: a transaction's captured facts reset, work run after commit, and the fact-change seam (§3-3). */
|
|
21
|
+
export declare const subscribers: (typeof GuildCaptureSubscriber | typeof GuildCommitSubscriber | typeof GuildFactChangeSeam)[];
|
|
22
|
+
/** The overlay's read and its coins (design §14-1) - on the person's own server. */
|
|
23
|
+
export declare const schema: {
|
|
24
|
+
resolverClasses: (typeof GuildOverlayResolver)[];
|
|
25
|
+
};
|
package/dist-server/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.subscribers = exports.stableJson = exports.keptSignals = exports.manifestOf = exports.revertFactId = exports.contributionFactId = void 0;
|
|
3
|
+
exports.schema = exports.subscribers = exports.stableJson = exports.keptSignals = exports.manifestOf = exports.revertFactId = exports.contributionFactId = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const env_1 = require("@things-factory/env");
|
|
6
6
|
const capture_js_1 = require("./capture.js");
|
|
7
|
+
const committed_js_1 = require("./committed.js");
|
|
8
|
+
const overlay_resolver_js_1 = require("./overlay-resolver.js");
|
|
7
9
|
const manifest_boot_js_1 = require("./manifest-boot.js");
|
|
8
10
|
const fact_change_seam_js_1 = require("./seams/fact-change-seam.js");
|
|
9
11
|
tslib_1.__exportStar(require("./contract.js"), exports);
|
|
@@ -12,6 +14,11 @@ tslib_1.__exportStar(require("./define-kinds.js"), exports);
|
|
|
12
14
|
tslib_1.__exportStar(require("./hub-route.js"), exports);
|
|
13
15
|
tslib_1.__exportStar(require("./emit.js"), exports);
|
|
14
16
|
tslib_1.__exportStar(require("./capture.js"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./committed.js"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./pulse.js"), exports);
|
|
19
|
+
tslib_1.__exportStar(require("./prospect.js"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./opportunities.js"), exports);
|
|
21
|
+
tslib_1.__exportStar(require("./overlay-resolver.js"), exports);
|
|
15
22
|
tslib_1.__exportStar(require("./manifest-boot.js"), exports);
|
|
16
23
|
tslib_1.__exportStar(require("./seams/fact-change-seam.js"), exports);
|
|
17
24
|
tslib_1.__exportStar(require("./seams/activity-callback-seam.js"), exports);
|
|
@@ -21,8 +28,10 @@ Object.defineProperty(exports, "revertFactId", { enumerable: true, get: function
|
|
|
21
28
|
Object.defineProperty(exports, "manifestOf", { enumerable: true, get: function () { return record_rules_js_1.manifestOf; } });
|
|
22
29
|
Object.defineProperty(exports, "keptSignals", { enumerable: true, get: function () { return record_rules_js_1.keptSignals; } });
|
|
23
30
|
Object.defineProperty(exports, "stableJson", { enumerable: true, get: function () { return record_rules_js_1.stableJson; } });
|
|
24
|
-
/** Loaded by the shell from every module: a transaction's captured facts reset, and the fact-change seam (§3-3). */
|
|
25
|
-
exports.subscribers = [capture_js_1.GuildCaptureSubscriber, fact_change_seam_js_1.GuildFactChangeSeam];
|
|
31
|
+
/** Loaded by the shell from every module: a transaction's captured facts reset, work run after commit, and the fact-change seam (§3-3). */
|
|
32
|
+
exports.subscribers = [capture_js_1.GuildCaptureSubscriber, committed_js_1.GuildCommitSubscriber, fact_change_seam_js_1.GuildFactChangeSeam];
|
|
33
|
+
/** The overlay's read and its coins (design §14-1) - on the person's own server. */
|
|
34
|
+
exports.schema = { resolverClasses: [overlay_resolver_js_1.GuildOverlayResolver] };
|
|
26
35
|
/*
|
|
27
36
|
* The guild overlay (operato-guild design §3): every application loads it; a product declares its contribution kinds in
|
|
28
37
|
* its own `server/guild/` and emits facts from the work that confirms them. Off (`Guild::enabled`), nothing happens.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface GuildOpportunity {
|
|
2
|
+
/** The contribution kind doing it earns. */
|
|
3
|
+
kind: string;
|
|
4
|
+
/** How many are waiting for this person. */
|
|
5
|
+
count: number;
|
|
6
|
+
/** Where to do it - defaults to the kind's route. */
|
|
7
|
+
route?: string;
|
|
8
|
+
}
|
|
9
|
+
export type OpportunityCounter = (domain: {
|
|
10
|
+
id: string;
|
|
11
|
+
}, user: {
|
|
12
|
+
id: string;
|
|
13
|
+
}) => Promise<GuildOpportunity[]>;
|
|
14
|
+
/** Once at boot - how this product counts a person's waiting work. Registering a product again replaces it. */
|
|
15
|
+
export declare function registerOpportunityCounter(product: string, counter: OpportunityCounter): void;
|
|
16
|
+
/** Every product's opportunities for this person. A counter that fails is left out - the panel shows what it can. */
|
|
17
|
+
export declare function opportunitiesOf(domain: {
|
|
18
|
+
id: string;
|
|
19
|
+
}, user: {
|
|
20
|
+
id: string;
|
|
21
|
+
}): Promise<GuildOpportunity[]>;
|
|
22
|
+
/** For tests. */
|
|
23
|
+
export declare function forgetOpportunityCounters(): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* **Today's quests** (design §14-1 · §15-5) - what a person could do right now that the guild would pay for. Each product
|
|
4
|
+
* counts its own, by the person and by what they may do: a quest the person cannot act on is never shown. The overlay asks
|
|
5
|
+
* on this server; the counts are the product's, the GP each is worth is the hub's rule digest.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.registerOpportunityCounter = registerOpportunityCounter;
|
|
9
|
+
exports.opportunitiesOf = opportunitiesOf;
|
|
10
|
+
exports.forgetOpportunityCounters = forgetOpportunityCounters;
|
|
11
|
+
const COUNTERS = new Map();
|
|
12
|
+
/** Once at boot - how this product counts a person's waiting work. Registering a product again replaces it. */
|
|
13
|
+
function registerOpportunityCounter(product, counter) {
|
|
14
|
+
if (!product)
|
|
15
|
+
throw new Error('registerOpportunityCounter needs the product name');
|
|
16
|
+
COUNTERS.set(product, counter);
|
|
17
|
+
}
|
|
18
|
+
/** Every product's opportunities for this person. A counter that fails is left out - the panel shows what it can. */
|
|
19
|
+
async function opportunitiesOf(domain, user) {
|
|
20
|
+
const all = [];
|
|
21
|
+
for (const counter of COUNTERS.values()) {
|
|
22
|
+
try {
|
|
23
|
+
for (const one of await counter(domain, user))
|
|
24
|
+
if (one.count > 0)
|
|
25
|
+
all.push(one);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
/* One product's count failing does not empty the panel. */
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return all;
|
|
32
|
+
}
|
|
33
|
+
/** For tests. */
|
|
34
|
+
function forgetOpportunityCounters() {
|
|
35
|
+
COUNTERS.clear();
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=opportunities.js.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type GuildPulseMessage } from './pulse.js';
|
|
2
|
+
export declare class GuildOverlayWallet {
|
|
3
|
+
balance: number;
|
|
4
|
+
spendable: number;
|
|
5
|
+
pendingGp: number;
|
|
6
|
+
maturedGp: number;
|
|
7
|
+
everGp: number;
|
|
8
|
+
level: number;
|
|
9
|
+
levelFloor: number;
|
|
10
|
+
nextLevelAt?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare class GuildOverlayBadge {
|
|
13
|
+
kind: string;
|
|
14
|
+
label?: any;
|
|
15
|
+
count: number;
|
|
16
|
+
step: number;
|
|
17
|
+
nextStep?: number;
|
|
18
|
+
}
|
|
19
|
+
export declare class GuildOverlayQuest {
|
|
20
|
+
kind: string;
|
|
21
|
+
label?: any;
|
|
22
|
+
count: number;
|
|
23
|
+
route?: string;
|
|
24
|
+
gpEach?: number;
|
|
25
|
+
}
|
|
26
|
+
export declare class GuildOverlayKind {
|
|
27
|
+
kind: string;
|
|
28
|
+
label?: any;
|
|
29
|
+
route?: string;
|
|
30
|
+
hint?: any;
|
|
31
|
+
gpEach?: number;
|
|
32
|
+
}
|
|
33
|
+
export declare class GuildOverlay {
|
|
34
|
+
enabled: boolean;
|
|
35
|
+
wallet?: GuildOverlayWallet;
|
|
36
|
+
badges: GuildOverlayBadge[];
|
|
37
|
+
quests: GuildOverlayQuest[];
|
|
38
|
+
kinds: GuildOverlayKind[];
|
|
39
|
+
}
|
|
40
|
+
export declare class GuildPulseNote {
|
|
41
|
+
kind: string;
|
|
42
|
+
contributionKind?: string;
|
|
43
|
+
label?: any;
|
|
44
|
+
title?: string;
|
|
45
|
+
path?: string;
|
|
46
|
+
gp?: number;
|
|
47
|
+
gpLow?: number;
|
|
48
|
+
gpHigh?: number;
|
|
49
|
+
gt?: number;
|
|
50
|
+
count?: number;
|
|
51
|
+
reason?: string;
|
|
52
|
+
hint?: any;
|
|
53
|
+
at: string;
|
|
54
|
+
}
|
|
55
|
+
export declare class GuildOverlayResolver {
|
|
56
|
+
guildOverlay(context: ResolverContext): Promise<GuildOverlay>;
|
|
57
|
+
guildPulse(message: GuildPulseMessage): GuildPulseNote;
|
|
58
|
+
}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GuildOverlayResolver = exports.GuildPulseNote = exports.GuildOverlay = exports.GuildOverlayKind = exports.GuildOverlayQuest = exports.GuildOverlayBadge = exports.GuildOverlayWallet = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const graphql_yoga_1 = require("graphql-yoga");
|
|
6
|
+
const type_graphql_1 = require("type-graphql");
|
|
7
|
+
const shell_1 = require("@things-factory/shell");
|
|
8
|
+
const define_kinds_js_1 = require("./define-kinds.js");
|
|
9
|
+
const hub_route_js_1 = require("./hub-route.js");
|
|
10
|
+
const opportunities_js_1 = require("./opportunities.js");
|
|
11
|
+
const pulse_js_1 = require("./pulse.js");
|
|
12
|
+
const settings_js_1 = require("./settings.js");
|
|
13
|
+
/*
|
|
14
|
+
* **What the game overlay reads** (design §14-1 「제품 서버에 서는 것」) - on the person's own server, about the person only:
|
|
15
|
+
* the wallet chip, the quest panel and the coins. Nobody's coins or balance but one's own are ever drawn.
|
|
16
|
+
*/
|
|
17
|
+
let GuildOverlayWallet = class GuildOverlayWallet {
|
|
18
|
+
};
|
|
19
|
+
exports.GuildOverlayWallet = GuildOverlayWallet;
|
|
20
|
+
tslib_1.__decorate([
|
|
21
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Float),
|
|
22
|
+
tslib_1.__metadata("design:type", Number)
|
|
23
|
+
], GuildOverlayWallet.prototype, "balance", void 0);
|
|
24
|
+
tslib_1.__decorate([
|
|
25
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Float),
|
|
26
|
+
tslib_1.__metadata("design:type", Number)
|
|
27
|
+
], GuildOverlayWallet.prototype, "spendable", void 0);
|
|
28
|
+
tslib_1.__decorate([
|
|
29
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: "This month's GP still held" }),
|
|
30
|
+
tslib_1.__metadata("design:type", Number)
|
|
31
|
+
], GuildOverlayWallet.prototype, "pendingGp", void 0);
|
|
32
|
+
tslib_1.__decorate([
|
|
33
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: "This month's GP that matured" }),
|
|
34
|
+
tslib_1.__metadata("design:type", Number)
|
|
35
|
+
], GuildOverlayWallet.prototype, "maturedGp", void 0);
|
|
36
|
+
tslib_1.__decorate([
|
|
37
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Float, { description: 'Every GP that ever matured - what the level counts' }),
|
|
38
|
+
tslib_1.__metadata("design:type", Number)
|
|
39
|
+
], GuildOverlayWallet.prototype, "everGp", void 0);
|
|
40
|
+
tslib_1.__decorate([
|
|
41
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int),
|
|
42
|
+
tslib_1.__metadata("design:type", Number)
|
|
43
|
+
], GuildOverlayWallet.prototype, "level", void 0);
|
|
44
|
+
tslib_1.__decorate([
|
|
45
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Float),
|
|
46
|
+
tslib_1.__metadata("design:type", Number)
|
|
47
|
+
], GuildOverlayWallet.prototype, "levelFloor", void 0);
|
|
48
|
+
tslib_1.__decorate([
|
|
49
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true }),
|
|
50
|
+
tslib_1.__metadata("design:type", Number)
|
|
51
|
+
], GuildOverlayWallet.prototype, "nextLevelAt", void 0);
|
|
52
|
+
exports.GuildOverlayWallet = GuildOverlayWallet = tslib_1.__decorate([
|
|
53
|
+
(0, type_graphql_1.ObjectType)({ description: "One's guild wallet as the overlay chip shows it" })
|
|
54
|
+
], GuildOverlayWallet);
|
|
55
|
+
let GuildOverlayBadge = class GuildOverlayBadge {
|
|
56
|
+
};
|
|
57
|
+
exports.GuildOverlayBadge = GuildOverlayBadge;
|
|
58
|
+
tslib_1.__decorate([
|
|
59
|
+
(0, type_graphql_1.Field)(),
|
|
60
|
+
tslib_1.__metadata("design:type", String)
|
|
61
|
+
], GuildOverlayBadge.prototype, "kind", void 0);
|
|
62
|
+
tslib_1.__decorate([
|
|
63
|
+
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true }),
|
|
64
|
+
tslib_1.__metadata("design:type", Object)
|
|
65
|
+
], GuildOverlayBadge.prototype, "label", void 0);
|
|
66
|
+
tslib_1.__decorate([
|
|
67
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int),
|
|
68
|
+
tslib_1.__metadata("design:type", Number)
|
|
69
|
+
], GuildOverlayBadge.prototype, "count", void 0);
|
|
70
|
+
tslib_1.__decorate([
|
|
71
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int),
|
|
72
|
+
tslib_1.__metadata("design:type", Number)
|
|
73
|
+
], GuildOverlayBadge.prototype, "step", void 0);
|
|
74
|
+
tslib_1.__decorate([
|
|
75
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true }),
|
|
76
|
+
tslib_1.__metadata("design:type", Number)
|
|
77
|
+
], GuildOverlayBadge.prototype, "nextStep", void 0);
|
|
78
|
+
exports.GuildOverlayBadge = GuildOverlayBadge = tslib_1.__decorate([
|
|
79
|
+
(0, type_graphql_1.ObjectType)({ description: 'A badge - confirmed contributions of one kind past a milestone' })
|
|
80
|
+
], GuildOverlayBadge);
|
|
81
|
+
let GuildOverlayQuest = class GuildOverlayQuest {
|
|
82
|
+
};
|
|
83
|
+
exports.GuildOverlayQuest = GuildOverlayQuest;
|
|
84
|
+
tslib_1.__decorate([
|
|
85
|
+
(0, type_graphql_1.Field)(),
|
|
86
|
+
tslib_1.__metadata("design:type", String)
|
|
87
|
+
], GuildOverlayQuest.prototype, "kind", void 0);
|
|
88
|
+
tslib_1.__decorate([
|
|
89
|
+
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true }),
|
|
90
|
+
tslib_1.__metadata("design:type", Object)
|
|
91
|
+
], GuildOverlayQuest.prototype, "label", void 0);
|
|
92
|
+
tslib_1.__decorate([
|
|
93
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int),
|
|
94
|
+
tslib_1.__metadata("design:type", Number)
|
|
95
|
+
], GuildOverlayQuest.prototype, "count", void 0);
|
|
96
|
+
tslib_1.__decorate([
|
|
97
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
98
|
+
tslib_1.__metadata("design:type", String)
|
|
99
|
+
], GuildOverlayQuest.prototype, "route", void 0);
|
|
100
|
+
tslib_1.__decorate([
|
|
101
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'GP for one, by the rule in force' }),
|
|
102
|
+
tslib_1.__metadata("design:type", Number)
|
|
103
|
+
], GuildOverlayQuest.prototype, "gpEach", void 0);
|
|
104
|
+
exports.GuildOverlayQuest = GuildOverlayQuest = tslib_1.__decorate([
|
|
105
|
+
(0, type_graphql_1.ObjectType)({ description: "Work waiting for this person that the guild pays for - today's quest" })
|
|
106
|
+
], GuildOverlayQuest);
|
|
107
|
+
let GuildOverlayKind = class GuildOverlayKind {
|
|
108
|
+
};
|
|
109
|
+
exports.GuildOverlayKind = GuildOverlayKind;
|
|
110
|
+
tslib_1.__decorate([
|
|
111
|
+
(0, type_graphql_1.Field)(),
|
|
112
|
+
tslib_1.__metadata("design:type", String)
|
|
113
|
+
], GuildOverlayKind.prototype, "kind", void 0);
|
|
114
|
+
tslib_1.__decorate([
|
|
115
|
+
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true }),
|
|
116
|
+
tslib_1.__metadata("design:type", Object)
|
|
117
|
+
], GuildOverlayKind.prototype, "label", void 0);
|
|
118
|
+
tslib_1.__decorate([
|
|
119
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
120
|
+
tslib_1.__metadata("design:type", String)
|
|
121
|
+
], GuildOverlayKind.prototype, "route", void 0);
|
|
122
|
+
tslib_1.__decorate([
|
|
123
|
+
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true }),
|
|
124
|
+
tslib_1.__metadata("design:type", Object)
|
|
125
|
+
], GuildOverlayKind.prototype, "hint", void 0);
|
|
126
|
+
tslib_1.__decorate([
|
|
127
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true }),
|
|
128
|
+
tslib_1.__metadata("design:type", Number)
|
|
129
|
+
], GuildOverlayKind.prototype, "gpEach", void 0);
|
|
130
|
+
exports.GuildOverlayKind = GuildOverlayKind = tslib_1.__decorate([
|
|
131
|
+
(0, type_graphql_1.ObjectType)({ description: 'A contribution kind and the page it happens on - the 「이 화면의 기여」 chip' })
|
|
132
|
+
], GuildOverlayKind);
|
|
133
|
+
let GuildOverlay = class GuildOverlay {
|
|
134
|
+
};
|
|
135
|
+
exports.GuildOverlay = GuildOverlay;
|
|
136
|
+
tslib_1.__decorate([
|
|
137
|
+
(0, type_graphql_1.Field)({ description: 'Guild::enabled - when off, the overlay draws nothing' }),
|
|
138
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
139
|
+
], GuildOverlay.prototype, "enabled", void 0);
|
|
140
|
+
tslib_1.__decorate([
|
|
141
|
+
(0, type_graphql_1.Field)(type => GuildOverlayWallet, { nullable: true }),
|
|
142
|
+
tslib_1.__metadata("design:type", GuildOverlayWallet)
|
|
143
|
+
], GuildOverlay.prototype, "wallet", void 0);
|
|
144
|
+
tslib_1.__decorate([
|
|
145
|
+
(0, type_graphql_1.Field)(type => [GuildOverlayBadge]),
|
|
146
|
+
tslib_1.__metadata("design:type", Array)
|
|
147
|
+
], GuildOverlay.prototype, "badges", void 0);
|
|
148
|
+
tslib_1.__decorate([
|
|
149
|
+
(0, type_graphql_1.Field)(type => [GuildOverlayQuest]),
|
|
150
|
+
tslib_1.__metadata("design:type", Array)
|
|
151
|
+
], GuildOverlay.prototype, "quests", void 0);
|
|
152
|
+
tslib_1.__decorate([
|
|
153
|
+
(0, type_graphql_1.Field)(type => [GuildOverlayKind]),
|
|
154
|
+
tslib_1.__metadata("design:type", Array)
|
|
155
|
+
], GuildOverlay.prototype, "kinds", void 0);
|
|
156
|
+
exports.GuildOverlay = GuildOverlay = tslib_1.__decorate([
|
|
157
|
+
(0, type_graphql_1.ObjectType)({ description: "The overlay's one read - off, or the person's wallet, badges, quests and the kinds with a page" })
|
|
158
|
+
], GuildOverlay);
|
|
159
|
+
let GuildPulseNote = class GuildPulseNote {
|
|
160
|
+
};
|
|
161
|
+
exports.GuildPulseNote = GuildPulseNote;
|
|
162
|
+
tslib_1.__decorate([
|
|
163
|
+
(0, type_graphql_1.Field)(),
|
|
164
|
+
tslib_1.__metadata("design:type", String)
|
|
165
|
+
], GuildPulseNote.prototype, "kind", void 0);
|
|
166
|
+
tslib_1.__decorate([
|
|
167
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
168
|
+
tslib_1.__metadata("design:type", String)
|
|
169
|
+
], GuildPulseNote.prototype, "contributionKind", void 0);
|
|
170
|
+
tslib_1.__decorate([
|
|
171
|
+
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true }),
|
|
172
|
+
tslib_1.__metadata("design:type", Object)
|
|
173
|
+
], GuildPulseNote.prototype, "label", void 0);
|
|
174
|
+
tslib_1.__decorate([
|
|
175
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
176
|
+
tslib_1.__metadata("design:type", String)
|
|
177
|
+
], GuildPulseNote.prototype, "title", void 0);
|
|
178
|
+
tslib_1.__decorate([
|
|
179
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
180
|
+
tslib_1.__metadata("design:type", String)
|
|
181
|
+
], GuildPulseNote.prototype, "path", void 0);
|
|
182
|
+
tslib_1.__decorate([
|
|
183
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true }),
|
|
184
|
+
tslib_1.__metadata("design:type", Number)
|
|
185
|
+
], GuildPulseNote.prototype, "gp", void 0);
|
|
186
|
+
tslib_1.__decorate([
|
|
187
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true }),
|
|
188
|
+
tslib_1.__metadata("design:type", Number)
|
|
189
|
+
], GuildPulseNote.prototype, "gpLow", void 0);
|
|
190
|
+
tslib_1.__decorate([
|
|
191
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true }),
|
|
192
|
+
tslib_1.__metadata("design:type", Number)
|
|
193
|
+
], GuildPulseNote.prototype, "gpHigh", void 0);
|
|
194
|
+
tslib_1.__decorate([
|
|
195
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true }),
|
|
196
|
+
tslib_1.__metadata("design:type", Number)
|
|
197
|
+
], GuildPulseNote.prototype, "gt", void 0);
|
|
198
|
+
tslib_1.__decorate([
|
|
199
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true }),
|
|
200
|
+
tslib_1.__metadata("design:type", Number)
|
|
201
|
+
], GuildPulseNote.prototype, "count", void 0);
|
|
202
|
+
tslib_1.__decorate([
|
|
203
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
204
|
+
tslib_1.__metadata("design:type", String)
|
|
205
|
+
], GuildPulseNote.prototype, "reason", void 0);
|
|
206
|
+
tslib_1.__decorate([
|
|
207
|
+
(0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true }),
|
|
208
|
+
tslib_1.__metadata("design:type", Object)
|
|
209
|
+
], GuildPulseNote.prototype, "hint", void 0);
|
|
210
|
+
tslib_1.__decorate([
|
|
211
|
+
(0, type_graphql_1.Field)(),
|
|
212
|
+
tslib_1.__metadata("design:type", String)
|
|
213
|
+
], GuildPulseNote.prototype, "at", void 0);
|
|
214
|
+
exports.GuildPulseNote = GuildPulseNote = tslib_1.__decorate([
|
|
215
|
+
(0, type_graphql_1.ObjectType)({ description: 'One movement of one person’s coins (design §14-1)' })
|
|
216
|
+
], GuildPulseNote);
|
|
217
|
+
let GuildOverlayResolver = class GuildOverlayResolver {
|
|
218
|
+
async guildOverlay(context) {
|
|
219
|
+
const { domain, user } = context.state;
|
|
220
|
+
const place = await (0, settings_js_1.guildPlaceOf)(domain);
|
|
221
|
+
if (!place.enabled)
|
|
222
|
+
return { enabled: false, badges: [], quests: [], kinds: [] };
|
|
223
|
+
const road = await (0, hub_route_js_1.hubRoadOf)(undefined, domain);
|
|
224
|
+
const digest = road.kind === 'local' && road.hub.overlayOf ? await road.hub.overlayOf(domain, user) : { badges: [], baseGp: {} };
|
|
225
|
+
if (digest.eligible === false)
|
|
226
|
+
return { enabled: false, badges: [], quests: [], kinds: [] };
|
|
227
|
+
const gpOf = (kind) => digest.baseGp[kind];
|
|
228
|
+
const quests = (await (0, opportunities_js_1.opportunitiesOf)(domain, user)).map(one => {
|
|
229
|
+
const declared = (0, define_kinds_js_1.declaredKind)(one.kind)?.kind;
|
|
230
|
+
return { kind: one.kind, label: declared?.label, count: one.count, route: one.route ?? declared?.route, gpEach: gpOf(one.kind) };
|
|
231
|
+
});
|
|
232
|
+
const kinds = Object.keys(digest.baseGp)
|
|
233
|
+
.map(kind => (0, define_kinds_js_1.declaredKind)(kind)?.kind)
|
|
234
|
+
.filter(one => !!one?.route)
|
|
235
|
+
.map(one => ({ kind: one.kind, label: one.label, route: one.route, hint: one.prospectHint, gpEach: gpOf(one.kind) }));
|
|
236
|
+
return {
|
|
237
|
+
enabled: true,
|
|
238
|
+
wallet: digest.wallet,
|
|
239
|
+
badges: digest.badges.map(one => ({ ...one, label: (0, define_kinds_js_1.declaredKind)(one.kind)?.kind.label })),
|
|
240
|
+
quests,
|
|
241
|
+
kinds
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
guildPulse(message) {
|
|
245
|
+
return message.guildPulse;
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
exports.GuildOverlayResolver = GuildOverlayResolver;
|
|
249
|
+
tslib_1.__decorate([
|
|
250
|
+
(0, type_graphql_1.Directive)('@privilege(category: "guild", privilege: "query", domainOwnerGranted: true)'),
|
|
251
|
+
(0, type_graphql_1.Query)(returns => GuildOverlay, { description: "The game overlay's read - the person's own wallet, badges and quests" }),
|
|
252
|
+
tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
|
|
253
|
+
tslib_1.__metadata("design:type", Function),
|
|
254
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
255
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
256
|
+
], GuildOverlayResolver.prototype, "guildOverlay", null);
|
|
257
|
+
tslib_1.__decorate([
|
|
258
|
+
(0, type_graphql_1.Subscription)({
|
|
259
|
+
subscribe: async ({ context }) => {
|
|
260
|
+
const { domain, user } = context.state;
|
|
261
|
+
if (!domain || !user?.id)
|
|
262
|
+
throw new Error('domain and user required');
|
|
263
|
+
return (0, graphql_yoga_1.pipe)(shell_1.pubsub.subscribe(pulse_js_1.GUILD_PULSE_TOPIC), (0, graphql_yoga_1.filter)((message) => message.domainId === domain.id && message.userId === user.id));
|
|
264
|
+
}
|
|
265
|
+
}),
|
|
266
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
267
|
+
tslib_1.__metadata("design:type", Function),
|
|
268
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
269
|
+
tslib_1.__metadata("design:returntype", GuildPulseNote)
|
|
270
|
+
], GuildOverlayResolver.prototype, "guildPulse", null);
|
|
271
|
+
exports.GuildOverlayResolver = GuildOverlayResolver = tslib_1.__decorate([
|
|
272
|
+
(0, type_graphql_1.Resolver)()
|
|
273
|
+
], GuildOverlayResolver);
|
|
274
|
+
//# sourceMappingURL=overlay-resolver.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { EntityManager } from 'typeorm';
|
|
2
|
+
export interface ProspectInput {
|
|
3
|
+
kind: string;
|
|
4
|
+
subject: {
|
|
5
|
+
type: string;
|
|
6
|
+
id: string;
|
|
7
|
+
title?: string;
|
|
8
|
+
path?: string;
|
|
9
|
+
};
|
|
10
|
+
contributor: {
|
|
11
|
+
id: string;
|
|
12
|
+
email?: string;
|
|
13
|
+
userType?: string;
|
|
14
|
+
};
|
|
15
|
+
/** The business day it belongs to - YYYY-MM-DD. */
|
|
16
|
+
eventAt?: string;
|
|
17
|
+
signals?: Record<string, number>;
|
|
18
|
+
}
|
|
19
|
+
export declare function emitProspect(tx: EntityManager, domain: {
|
|
20
|
+
id: string;
|
|
21
|
+
}, input: ProspectInput): Promise<void>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emitProspect = emitProspect;
|
|
4
|
+
const committed_js_1 = require("./committed.js");
|
|
5
|
+
const define_kinds_js_1 = require("./define-kinds.js");
|
|
6
|
+
const hub_route_js_1 = require("./hub-route.js");
|
|
7
|
+
const pulse_js_1 = require("./pulse.js");
|
|
8
|
+
async function emitProspect(tx, domain, input) {
|
|
9
|
+
const person = input.contributor;
|
|
10
|
+
if (!person?.id || (person.userType && person.userType !== 'user'))
|
|
11
|
+
return;
|
|
12
|
+
const declared = (0, define_kinds_js_1.declaredKind)(input.kind);
|
|
13
|
+
if (!declared)
|
|
14
|
+
return;
|
|
15
|
+
const road = await (0, hub_route_js_1.hubRoadOf)(tx, domain);
|
|
16
|
+
if (road.kind !== 'local' || !road.hub.prospect)
|
|
17
|
+
return;
|
|
18
|
+
const hub = road.hub;
|
|
19
|
+
(0, committed_js_1.afterCommitOf)(tx, async () => {
|
|
20
|
+
const reply = await hub.prospect(domain, declared.product, {
|
|
21
|
+
kind: input.kind,
|
|
22
|
+
contributor: { sourceUserId: person.id, email: person.email },
|
|
23
|
+
eventAt: input.eventAt,
|
|
24
|
+
signals: input.signals
|
|
25
|
+
});
|
|
26
|
+
if (!reply)
|
|
27
|
+
return;
|
|
28
|
+
const about = { contributionKind: input.kind, label: declared.kind.label, title: input.subject.title, path: input.subject.path };
|
|
29
|
+
if ('skipped' in reply)
|
|
30
|
+
(0, pulse_js_1.publishGuildPulse)(domain.id, person.id, { kind: 'skipped', ...about, reason: reply.skipped });
|
|
31
|
+
else
|
|
32
|
+
(0, pulse_js_1.publishGuildPulse)(domain.id, person.id, { kind: 'prospect', ...about, gpLow: reply.gpLow, gpHigh: reply.gpHigh, hint: declared.kind.prospectHint });
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=prospect.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { GuildLabel } from './contract.js';
|
|
2
|
+
export declare const GUILD_PULSE_KINDS: readonly ["prospect", "verified", "matured", "issued", "impact", "skipped", "voided"];
|
|
3
|
+
export type GuildPulseKind = (typeof GUILD_PULSE_KINDS)[number];
|
|
4
|
+
export interface GuildPulse {
|
|
5
|
+
kind: GuildPulseKind;
|
|
6
|
+
/** The contribution kind, when the pulse is about one. */
|
|
7
|
+
contributionKind?: string;
|
|
8
|
+
/** The kind's label in the languages it was declared in. */
|
|
9
|
+
label?: GuildLabel;
|
|
10
|
+
/** The record it is about - its title and where it opens. */
|
|
11
|
+
title?: string;
|
|
12
|
+
path?: string;
|
|
13
|
+
/** GP: the amount, or a range for a prospect. */
|
|
14
|
+
gp?: number;
|
|
15
|
+
gpLow?: number;
|
|
16
|
+
gpHigh?: number;
|
|
17
|
+
/** GT, for an issue. */
|
|
18
|
+
gt?: number;
|
|
19
|
+
/** How many, when batched. */
|
|
20
|
+
count?: number;
|
|
21
|
+
/** Why it was skipped or voided - a code the screen words. */
|
|
22
|
+
reason?: string;
|
|
23
|
+
/** The prospect bubble's line. */
|
|
24
|
+
hint?: GuildLabel;
|
|
25
|
+
at: string;
|
|
26
|
+
}
|
|
27
|
+
export declare const GUILD_PULSE_TOPIC = "guild-pulse";
|
|
28
|
+
export interface GuildPulseMessage {
|
|
29
|
+
domainId: string;
|
|
30
|
+
userId: string;
|
|
31
|
+
guildPulse: GuildPulse;
|
|
32
|
+
}
|
|
33
|
+
/** Tell one person on this server. The caller has waited for its work to commit (`afterCommitOf`). */
|
|
34
|
+
export declare function publishGuildPulse(domainId: string, userId: string, pulse: Omit<GuildPulse, 'at'> & {
|
|
35
|
+
at?: string;
|
|
36
|
+
}): void;
|