@fabriktor/fx 0.0.38 → 0.0.40
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/src/billable/billable.d.ts +164 -1
- package/dist/src/billable/billable.js +436 -0
- package/dist/src/calls/calls.d.ts +11 -0
- package/dist/src/calls/calls.js +26 -0
- package/dist/src/chat/chat.d.ts +41 -2
- package/dist/src/chat/chat.js +293 -28
- package/dist/src/contacts/contacts.d.ts +12 -2
- package/dist/src/contacts/contacts.js +33 -7
- package/dist/src/core/id.d.ts +3 -0
- package/dist/src/core/id.js +24 -0
- package/dist/src/feed/feed.d.ts +39 -3
- package/dist/src/feed/feed.js +85 -7
- package/dist/src/fulfillments/fulfillments.d.ts +32 -0
- package/dist/src/fulfillments/fulfillments.js +54 -0
- package/dist/src/fx.d.ts +5 -1
- package/dist/src/fx.js +11 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/jobs/jobs.d.ts +52 -4
- package/dist/src/jobs/jobs.js +120 -9
- package/dist/src/marketplace/marketplace.d.ts +29 -1
- package/dist/src/marketplace/marketplace.js +64 -1
- package/dist/src/memos/memos.js +4 -28
- package/dist/src/payments/payments.d.ts +112 -1
- package/dist/src/payments/payments.js +291 -15
- package/dist/src/payrolls/payrolls.d.ts +134 -1
- package/dist/src/payrolls/payrolls.js +364 -0
- package/dist/src/preferences/preferences.d.ts +83 -1
- package/dist/src/preferences/preferences.js +227 -0
- package/dist/src/privacy/privacy.d.ts +21 -2
- package/dist/src/privacy/privacy.js +56 -5
- package/dist/src/routes/routes.d.ts +63 -3
- package/dist/src/routes/routes.js +151 -1
- package/dist/src/timesheets/timesheets.d.ts +11 -1
- package/dist/src/timesheets/timesheets.js +39 -1
- package/package.json +2 -2
|
@@ -1,7 +1,23 @@
|
|
|
1
|
-
import { type RPMarketplacePull } from "@fabriktor/schema";
|
|
2
1
|
import type { MarketplaceOperator, OperationResultOf } from "@fabriktor/client";
|
|
2
|
+
import { type MarketplaceFavorite, type MarketplacePost, type RPMarketplacePull } from "@fabriktor/schema";
|
|
3
3
|
import { type PullSession, type PullSessionErrorHandler } from "../core/pull.js";
|
|
4
|
+
import { type SearchPage } from "../core/search.js";
|
|
5
|
+
type MarketplacePostInsertOptions = Parameters<MarketplaceOperator["insertOneMarketplacePost"]>[0];
|
|
6
|
+
type MarketplacePostReplaceOptions = Parameters<MarketplaceOperator["replaceOneMarketplacePost"]>[0];
|
|
7
|
+
type MarketplaceFavoriteInsertOptions = Parameters<MarketplaceOperator["insertOneMarketplaceFavorite"]>[0];
|
|
8
|
+
type MarketplaceFavoriteReplaceOptions = Parameters<MarketplaceOperator["replaceOneMarketplaceFavorite"]>[0];
|
|
4
9
|
type MarketplacePullOptions = Parameters<MarketplaceOperator["pull"]>[0];
|
|
10
|
+
export type CreateMarketplacePostOptions = MarketplacePostInsertOptions;
|
|
11
|
+
export type ReplaceMarketplacePostOptions = MarketplacePostReplaceOptions;
|
|
12
|
+
export type CreateMarketplaceFavoriteOptions = MarketplaceFavoriteInsertOptions;
|
|
13
|
+
export type ReplaceMarketplaceFavoriteOptions = MarketplaceFavoriteReplaceOptions;
|
|
14
|
+
export type SearchMarketplacePostsOptions = {
|
|
15
|
+
owner_id: string;
|
|
16
|
+
q?: string;
|
|
17
|
+
page?: number;
|
|
18
|
+
per_page?: number;
|
|
19
|
+
};
|
|
20
|
+
export type SearchMarketplacePostsPage = SearchPage<MarketplacePost>;
|
|
5
21
|
export type MarketplacePullContext = Pick<MarketplacePullOptions, "pull_type" | "entity_id" | "research" | "research_user_type">;
|
|
6
22
|
export type MarketplacePullResult = OperationResultOf<RPMarketplacePull>;
|
|
7
23
|
export type MarketplaceResearchUserType = MarketplacePullOptions["research_user_type"];
|
|
@@ -21,6 +37,11 @@ export type StartMarketplaceWelcomeSessionOptions = {
|
|
|
21
37
|
on_error?: MarketplaceSessionErrorHandler;
|
|
22
38
|
};
|
|
23
39
|
export interface MarketplaceFXOperator {
|
|
40
|
+
createMarketplacePost(opts: CreateMarketplacePostOptions): Promise<MarketplacePost>;
|
|
41
|
+
replaceMarketplacePost(opts: ReplaceMarketplacePostOptions): Promise<MarketplacePost>;
|
|
42
|
+
searchMarketplacePosts(opts: SearchMarketplacePostsOptions): Promise<SearchMarketplacePostsPage>;
|
|
43
|
+
createMarketplaceFavorite(opts: CreateMarketplaceFavoriteOptions): Promise<MarketplaceFavorite>;
|
|
44
|
+
replaceMarketplaceFavorite(opts: ReplaceMarketplaceFavoriteOptions): Promise<MarketplaceFavorite>;
|
|
24
45
|
startSession(opts: StartMarketplaceSessionOptions): Promise<MarketplaceSession>;
|
|
25
46
|
startWelcomeSession(opts: StartMarketplaceWelcomeSessionOptions): Promise<MarketplaceSession>;
|
|
26
47
|
}
|
|
@@ -28,8 +49,15 @@ export declare class MarketplaceFX implements MarketplaceFXOperator {
|
|
|
28
49
|
private marketplace;
|
|
29
50
|
private keep_alive_interval_ms;
|
|
30
51
|
constructor(opts: MarketplaceFXOptions);
|
|
52
|
+
createMarketplacePost(opts: CreateMarketplacePostOptions): Promise<MarketplacePost>;
|
|
53
|
+
replaceMarketplacePost(opts: ReplaceMarketplacePostOptions): Promise<MarketplacePost>;
|
|
54
|
+
searchMarketplacePosts(opts: SearchMarketplacePostsOptions): Promise<SearchMarketplacePostsPage>;
|
|
55
|
+
createMarketplaceFavorite(opts: CreateMarketplaceFavoriteOptions): Promise<MarketplaceFavorite>;
|
|
56
|
+
replaceMarketplaceFavorite(opts: ReplaceMarketplaceFavoriteOptions): Promise<MarketplaceFavorite>;
|
|
31
57
|
startSession(opts: StartMarketplaceSessionOptions): Promise<MarketplaceSession>;
|
|
32
58
|
startWelcomeSession(opts: StartMarketplaceWelcomeSessionOptions): Promise<MarketplaceSession>;
|
|
59
|
+
private findMarketplacePost;
|
|
60
|
+
private findMarketplaceFavorite;
|
|
33
61
|
}
|
|
34
62
|
export declare function newMarketplaceFX(opts: MarketplaceFXOptions): MarketplaceFX;
|
|
35
63
|
export {};
|
|
@@ -3,11 +3,19 @@
|
|
|
3
3
|
// Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
4
4
|
// not use this file except in compliance with the License. You may obtain
|
|
5
5
|
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
import { PullTypeBatch, PullTypeKeepAlive, PullTypeResearch, } from "@fabriktor/schema";
|
|
6
|
+
import { OwnerIDKey, PullTypeBatch, PullTypeKeepAlive, PullTypeResearch, } from "@fabriktor/schema";
|
|
7
7
|
import { errRequired, errResolveFailed, errValidation } from "../core/err.js";
|
|
8
|
+
import { requiredOperationID } from "../core/id.js";
|
|
8
9
|
import { newPullSession, } from "../core/pull.js";
|
|
10
|
+
import { runSearch } from "../core/search.js";
|
|
9
11
|
const newMarketplaceSessionToken = "";
|
|
10
12
|
const resourceMarketplaceSessionToken = "marketplace_session_token";
|
|
13
|
+
const resourceMarketplacePost = "marketplace_post";
|
|
14
|
+
const resourceMarketplaceFavorite = "marketplace_favorite";
|
|
15
|
+
const msgCreatedMarketplacePostIDMissing = "Created marketplace post response did not contain an ID.";
|
|
16
|
+
const msgMarketplacePostMissing = "Marketplace post could not be resolved after the mutation.";
|
|
17
|
+
const msgCreatedMarketplaceFavoriteIDMissing = "Created marketplace favorite response did not contain an ID.";
|
|
18
|
+
const msgMarketplaceFavoriteMissing = "Marketplace favorite could not be resolved after the mutation.";
|
|
11
19
|
const msgKeepAliveIntervalInvalid = "Keep-alive interval must be a finite number greater than zero.";
|
|
12
20
|
const msgMarketplaceSessionClosed = "Marketplace session is closed.";
|
|
13
21
|
const msgMarketplacePullInProgress = "A marketplace pull is already in progress.";
|
|
@@ -24,6 +32,35 @@ export class MarketplaceFX {
|
|
|
24
32
|
this.marketplace = opts.marketplace;
|
|
25
33
|
this.keep_alive_interval_ms = opts.keep_alive_interval_ms;
|
|
26
34
|
}
|
|
35
|
+
async createMarketplacePost(opts) {
|
|
36
|
+
const out = await this.marketplace.insertOneMarketplacePost(opts);
|
|
37
|
+
const id = requiredOperationID(out, msgCreatedMarketplacePostIDMissing);
|
|
38
|
+
return await this.findMarketplacePost(id);
|
|
39
|
+
}
|
|
40
|
+
async replaceMarketplacePost(opts) {
|
|
41
|
+
await this.marketplace.replaceOneMarketplacePost(opts);
|
|
42
|
+
return await this.findMarketplacePost(opts.id);
|
|
43
|
+
}
|
|
44
|
+
async searchMarketplacePosts(opts) {
|
|
45
|
+
return await runSearch({
|
|
46
|
+
search: (searchOpts) => this.marketplace.searchManyMarketplacePosts(searchOpts),
|
|
47
|
+
query: {
|
|
48
|
+
[OwnerIDKey]: opts.owner_id,
|
|
49
|
+
},
|
|
50
|
+
q: opts.q,
|
|
51
|
+
page: opts.page,
|
|
52
|
+
per_page: opts.per_page,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
async createMarketplaceFavorite(opts) {
|
|
56
|
+
const out = await this.marketplace.insertOneMarketplaceFavorite(opts);
|
|
57
|
+
const id = requiredOperationID(out, msgCreatedMarketplaceFavoriteIDMissing);
|
|
58
|
+
return await this.findMarketplaceFavorite(id);
|
|
59
|
+
}
|
|
60
|
+
async replaceMarketplaceFavorite(opts) {
|
|
61
|
+
await this.marketplace.replaceOneMarketplaceFavorite(opts);
|
|
62
|
+
return await this.findMarketplaceFavorite(opts.id);
|
|
63
|
+
}
|
|
27
64
|
async startSession(opts) {
|
|
28
65
|
const { on_error, ...input } = opts;
|
|
29
66
|
const context = marketplaceSessionContext(input);
|
|
@@ -74,6 +111,32 @@ export class MarketplaceFX {
|
|
|
74
111
|
on_error: opts.on_error,
|
|
75
112
|
});
|
|
76
113
|
}
|
|
114
|
+
async findMarketplacePost(id) {
|
|
115
|
+
const out = await this.marketplace.findOneMarketplacePost({
|
|
116
|
+
id,
|
|
117
|
+
});
|
|
118
|
+
const post = out.value;
|
|
119
|
+
if (post === undefined) {
|
|
120
|
+
throw errResolveFailed({
|
|
121
|
+
resource: resourceMarketplacePost,
|
|
122
|
+
msg: msgMarketplacePostMissing,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return post;
|
|
126
|
+
}
|
|
127
|
+
async findMarketplaceFavorite(id) {
|
|
128
|
+
const out = await this.marketplace.findOneMarketplaceFavorite({
|
|
129
|
+
id,
|
|
130
|
+
});
|
|
131
|
+
const favorite = out.value;
|
|
132
|
+
if (favorite === undefined) {
|
|
133
|
+
throw errResolveFailed({
|
|
134
|
+
resource: resourceMarketplaceFavorite,
|
|
135
|
+
msg: msgMarketplaceFavoriteMissing,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return favorite;
|
|
139
|
+
}
|
|
77
140
|
}
|
|
78
141
|
export function newMarketplaceFX(opts) {
|
|
79
142
|
return new MarketplaceFX(opts);
|
package/dist/src/memos/memos.js
CHANGED
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
// Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
4
4
|
// not use this file except in compliance with the License. You may obtain
|
|
5
5
|
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
import { OwnerIDKey
|
|
6
|
+
import { OwnerIDKey } from "@fabriktor/schema";
|
|
7
7
|
import { errResolveFailed } from "../core/err.js";
|
|
8
|
+
import { requiredOperationID } from "../core/id.js";
|
|
8
9
|
import { runSearch } from "../core/search.js";
|
|
9
|
-
const resourceMemoID = "memo_id";
|
|
10
10
|
const resourceMemo = "memo";
|
|
11
|
-
const resourceMemoFolderID = "memo_folder_id";
|
|
12
11
|
const resourceMemoFolder = "memo_folder";
|
|
13
12
|
const msgCreatedMemoIDMissing = "Created memo response did not contain an ID.";
|
|
14
13
|
const msgMemoMissing = "Memo could not be resolved after the mutation.";
|
|
@@ -21,10 +20,7 @@ export class MemosFX {
|
|
|
21
20
|
}
|
|
22
21
|
async createMemo(opts) {
|
|
23
22
|
const out = await this.memos.insertOneMemo(opts);
|
|
24
|
-
const id = requiredOperationID(out,
|
|
25
|
-
resource: resourceMemoID,
|
|
26
|
-
msg: msgCreatedMemoIDMissing,
|
|
27
|
-
});
|
|
23
|
+
const id = requiredOperationID(out, msgCreatedMemoIDMissing);
|
|
28
24
|
return await this.findMemo(id);
|
|
29
25
|
}
|
|
30
26
|
async replaceMemo(opts) {
|
|
@@ -33,10 +29,7 @@ export class MemosFX {
|
|
|
33
29
|
}
|
|
34
30
|
async createMemoFolder(opts) {
|
|
35
31
|
const out = await this.memos.insertOneMemoFolder(opts);
|
|
36
|
-
const id = requiredOperationID(out,
|
|
37
|
-
resource: resourceMemoFolderID,
|
|
38
|
-
msg: msgCreatedMemoFolderIDMissing,
|
|
39
|
-
});
|
|
32
|
+
const id = requiredOperationID(out, msgCreatedMemoFolderIDMissing);
|
|
40
33
|
return await this.findMemoFolder(id);
|
|
41
34
|
}
|
|
42
35
|
async replaceMemoFolder(opts) {
|
|
@@ -95,20 +88,3 @@ export class MemosFX {
|
|
|
95
88
|
export function newMemosFX(opts) {
|
|
96
89
|
return new MemosFX(opts);
|
|
97
90
|
}
|
|
98
|
-
function requiredOperationID(out, opts) {
|
|
99
|
-
const id = resolvedID(out.id);
|
|
100
|
-
if (id === undefined) {
|
|
101
|
-
throw errResolveFailed({
|
|
102
|
-
resource: opts.resource,
|
|
103
|
-
msg: opts.msg,
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
return id;
|
|
107
|
-
}
|
|
108
|
-
function resolvedID(value) {
|
|
109
|
-
const id = value?.trim();
|
|
110
|
-
if (id === undefined || id === "" || id === ZeroID) {
|
|
111
|
-
return undefined;
|
|
112
|
-
}
|
|
113
|
-
return id;
|
|
114
|
-
}
|
|
@@ -1,8 +1,63 @@
|
|
|
1
|
-
import { type Payment, type PmtPublicSession } from "@fabriktor/schema";
|
|
1
|
+
import { type CreditLedgerEntry, type Payment, type PmtAccount, type PmtBankAccount, type PmtCard, type PmtCustomer, type PmtPublicSession, type PmtRefund } from "@fabriktor/schema";
|
|
2
2
|
import type { PaymentsOperator } from "@fabriktor/client";
|
|
3
|
+
import { type SearchPage } from "../core/search.js";
|
|
3
4
|
type PurchaseCreditsPayload = Parameters<PaymentsOperator["purchaseCredits"]>[0];
|
|
4
5
|
type OpenPublicSessionPayload = Parameters<PaymentsOperator["openPmtPublicSession"]>[0];
|
|
5
6
|
type PaymentFromPublicSessionPayload = Parameters<PaymentsOperator["paymentFromPublicSession"]>[0];
|
|
7
|
+
type PaymentInsertOptions = Parameters<PaymentsOperator["insertOnePayment"]>[0];
|
|
8
|
+
type PaymentReplaceOptions = Parameters<PaymentsOperator["replaceOnePayment"]>[0];
|
|
9
|
+
type PmtAccountInsertOptions = Parameters<PaymentsOperator["insertOnePmtAccount"]>[0];
|
|
10
|
+
type PmtAccountReplaceOptions = Parameters<PaymentsOperator["replaceOnePmtAccount"]>[0];
|
|
11
|
+
type PmtBankAccountInsertOptions = Parameters<PaymentsOperator["insertOnePmtBankAccount"]>[0];
|
|
12
|
+
type PmtBankAccountReplaceOptions = Parameters<PaymentsOperator["replaceOnePmtBankAccount"]>[0];
|
|
13
|
+
type PmtCardInsertOptions = Parameters<PaymentsOperator["insertOnePmtCard"]>[0];
|
|
14
|
+
type PmtCardReplaceOptions = Parameters<PaymentsOperator["replaceOnePmtCard"]>[0];
|
|
15
|
+
type PmtRefundInsertOptions = Parameters<PaymentsOperator["insertOnePmtRefund"]>[0];
|
|
16
|
+
type PmtRefundReplaceOptions = Parameters<PaymentsOperator["replaceOnePmtRefund"]>[0];
|
|
17
|
+
type PmtCustomerInsertOptions = Parameters<PaymentsOperator["insertOnePmtCustomer"]>[0];
|
|
18
|
+
type PmtCustomerReplaceOptions = Parameters<PaymentsOperator["replaceOnePmtCustomer"]>[0];
|
|
19
|
+
type PmtPublicSessionInsertOptions = Parameters<PaymentsOperator["insertOnePmtPublicSession"]>[0];
|
|
20
|
+
type PmtPublicSessionReplaceOptions = Parameters<PaymentsOperator["replaceOnePmtPublicSession"]>[0];
|
|
21
|
+
type CreditLedgerEntryInsertOptions = Parameters<PaymentsOperator["insertOneCreditLedgerEntry"]>[0];
|
|
22
|
+
type CreditLedgerEntryReplaceOptions = Parameters<PaymentsOperator["replaceOneCreditLedgerEntry"]>[0];
|
|
23
|
+
type SearchPaymentRecordsOptions = {
|
|
24
|
+
owner_id: string;
|
|
25
|
+
q?: string;
|
|
26
|
+
page?: number;
|
|
27
|
+
per_page?: number;
|
|
28
|
+
};
|
|
29
|
+
export type CreatePaymentOptions = PaymentInsertOptions;
|
|
30
|
+
export type ReplacePaymentOptions = PaymentReplaceOptions;
|
|
31
|
+
export type SearchPaymentsOptions = SearchPaymentRecordsOptions;
|
|
32
|
+
export type SearchPaymentsPage = SearchPage<Payment>;
|
|
33
|
+
export type CreatePmtAccountOptions = PmtAccountInsertOptions;
|
|
34
|
+
export type ReplacePmtAccountOptions = PmtAccountReplaceOptions;
|
|
35
|
+
export type SearchPmtAccountsOptions = SearchPaymentRecordsOptions;
|
|
36
|
+
export type SearchPmtAccountsPage = SearchPage<PmtAccount>;
|
|
37
|
+
export type CreatePmtBankAccountOptions = PmtBankAccountInsertOptions;
|
|
38
|
+
export type ReplacePmtBankAccountOptions = PmtBankAccountReplaceOptions;
|
|
39
|
+
export type SearchPmtBankAccountsOptions = SearchPaymentRecordsOptions;
|
|
40
|
+
export type SearchPmtBankAccountsPage = SearchPage<PmtBankAccount>;
|
|
41
|
+
export type CreatePmtCardOptions = PmtCardInsertOptions;
|
|
42
|
+
export type ReplacePmtCardOptions = PmtCardReplaceOptions;
|
|
43
|
+
export type SearchPmtCardsOptions = SearchPaymentRecordsOptions;
|
|
44
|
+
export type SearchPmtCardsPage = SearchPage<PmtCard>;
|
|
45
|
+
export type CreatePmtRefundOptions = PmtRefundInsertOptions;
|
|
46
|
+
export type ReplacePmtRefundOptions = PmtRefundReplaceOptions;
|
|
47
|
+
export type SearchPmtRefundsOptions = SearchPaymentRecordsOptions;
|
|
48
|
+
export type SearchPmtRefundsPage = SearchPage<PmtRefund>;
|
|
49
|
+
export type CreatePmtCustomerOptions = PmtCustomerInsertOptions;
|
|
50
|
+
export type ReplacePmtCustomerOptions = PmtCustomerReplaceOptions;
|
|
51
|
+
export type SearchPmtCustomersOptions = SearchPaymentRecordsOptions;
|
|
52
|
+
export type SearchPmtCustomersPage = SearchPage<PmtCustomer>;
|
|
53
|
+
export type CreatePmtPublicSessionOptions = PmtPublicSessionInsertOptions;
|
|
54
|
+
export type ReplacePmtPublicSessionOptions = PmtPublicSessionReplaceOptions;
|
|
55
|
+
export type SearchPmtPublicSessionsOptions = SearchPaymentRecordsOptions;
|
|
56
|
+
export type SearchPmtPublicSessionsPage = SearchPage<PmtPublicSession>;
|
|
57
|
+
export type CreateCreditLedgerEntryOptions = CreditLedgerEntryInsertOptions;
|
|
58
|
+
export type ReplaceCreditLedgerEntryOptions = CreditLedgerEntryReplaceOptions;
|
|
59
|
+
export type SearchCreditLedgerOptions = SearchPaymentRecordsOptions;
|
|
60
|
+
export type SearchCreditLedgerPage = SearchPage<CreditLedgerEntry>;
|
|
6
61
|
export declare const PublicPaymentSessionStatus: {
|
|
7
62
|
readonly NotFound: "not_found";
|
|
8
63
|
readonly Ready: "ready";
|
|
@@ -34,6 +89,30 @@ export type PaymentsFXOptions = {
|
|
|
34
89
|
payments: PaymentsOperator;
|
|
35
90
|
};
|
|
36
91
|
export interface PaymentsFXOperator {
|
|
92
|
+
createPayment(opts: CreatePaymentOptions): Promise<Payment>;
|
|
93
|
+
replacePayment(opts: ReplacePaymentOptions): Promise<Payment>;
|
|
94
|
+
searchPayments(opts: SearchPaymentsOptions): Promise<SearchPaymentsPage>;
|
|
95
|
+
createPmtAccount(opts: CreatePmtAccountOptions): Promise<PmtAccount>;
|
|
96
|
+
replacePmtAccount(opts: ReplacePmtAccountOptions): Promise<PmtAccount>;
|
|
97
|
+
searchPmtAccounts(opts: SearchPmtAccountsOptions): Promise<SearchPmtAccountsPage>;
|
|
98
|
+
createPmtBankAccount(opts: CreatePmtBankAccountOptions): Promise<PmtBankAccount>;
|
|
99
|
+
replacePmtBankAccount(opts: ReplacePmtBankAccountOptions): Promise<PmtBankAccount>;
|
|
100
|
+
searchPmtBankAccounts(opts: SearchPmtBankAccountsOptions): Promise<SearchPmtBankAccountsPage>;
|
|
101
|
+
createPmtCard(opts: CreatePmtCardOptions): Promise<PmtCard>;
|
|
102
|
+
replacePmtCard(opts: ReplacePmtCardOptions): Promise<PmtCard>;
|
|
103
|
+
searchPmtCards(opts: SearchPmtCardsOptions): Promise<SearchPmtCardsPage>;
|
|
104
|
+
createPmtRefund(opts: CreatePmtRefundOptions): Promise<PmtRefund>;
|
|
105
|
+
replacePmtRefund(opts: ReplacePmtRefundOptions): Promise<PmtRefund>;
|
|
106
|
+
searchPmtRefunds(opts: SearchPmtRefundsOptions): Promise<SearchPmtRefundsPage>;
|
|
107
|
+
createPmtCustomer(opts: CreatePmtCustomerOptions): Promise<PmtCustomer>;
|
|
108
|
+
replacePmtCustomer(opts: ReplacePmtCustomerOptions): Promise<PmtCustomer>;
|
|
109
|
+
searchPmtCustomers(opts: SearchPmtCustomersOptions): Promise<SearchPmtCustomersPage>;
|
|
110
|
+
createPmtPublicSession(opts: CreatePmtPublicSessionOptions): Promise<PmtPublicSession>;
|
|
111
|
+
replacePmtPublicSession(opts: ReplacePmtPublicSessionOptions): Promise<PmtPublicSession>;
|
|
112
|
+
searchPmtPublicSessions(opts: SearchPmtPublicSessionsOptions): Promise<SearchPmtPublicSessionsPage>;
|
|
113
|
+
createCreditLedgerEntry(opts: CreateCreditLedgerEntryOptions): Promise<CreditLedgerEntry>;
|
|
114
|
+
replaceCreditLedgerEntry(opts: ReplaceCreditLedgerEntryOptions): Promise<CreditLedgerEntry>;
|
|
115
|
+
searchCreditLedger(opts: SearchCreditLedgerOptions): Promise<SearchCreditLedgerPage>;
|
|
37
116
|
purchaseAppleCredits(opts: PurchaseAppleCreditsOptions): Promise<void>;
|
|
38
117
|
purchaseGoogleCredits(opts: PurchaseGoogleCreditsOptions): Promise<void>;
|
|
39
118
|
prepareStripeCreditPurchase(opts: PrepareStripeCreditPurchaseOptions): Promise<PrepareStripeCreditPurchaseResult>;
|
|
@@ -46,6 +125,30 @@ export declare class PaymentsFX implements PaymentsFXOperator {
|
|
|
46
125
|
private payments;
|
|
47
126
|
private submittedPublicSessionIDs;
|
|
48
127
|
constructor(opts: PaymentsFXOptions);
|
|
128
|
+
createPayment(opts: CreatePaymentOptions): Promise<Payment>;
|
|
129
|
+
replacePayment(opts: ReplacePaymentOptions): Promise<Payment>;
|
|
130
|
+
searchPayments(opts: SearchPaymentsOptions): Promise<SearchPaymentsPage>;
|
|
131
|
+
createPmtAccount(opts: CreatePmtAccountOptions): Promise<PmtAccount>;
|
|
132
|
+
replacePmtAccount(opts: ReplacePmtAccountOptions): Promise<PmtAccount>;
|
|
133
|
+
searchPmtAccounts(opts: SearchPmtAccountsOptions): Promise<SearchPmtAccountsPage>;
|
|
134
|
+
createPmtBankAccount(opts: CreatePmtBankAccountOptions): Promise<PmtBankAccount>;
|
|
135
|
+
replacePmtBankAccount(opts: ReplacePmtBankAccountOptions): Promise<PmtBankAccount>;
|
|
136
|
+
searchPmtBankAccounts(opts: SearchPmtBankAccountsOptions): Promise<SearchPmtBankAccountsPage>;
|
|
137
|
+
createPmtCard(opts: CreatePmtCardOptions): Promise<PmtCard>;
|
|
138
|
+
replacePmtCard(opts: ReplacePmtCardOptions): Promise<PmtCard>;
|
|
139
|
+
searchPmtCards(opts: SearchPmtCardsOptions): Promise<SearchPmtCardsPage>;
|
|
140
|
+
createPmtRefund(opts: CreatePmtRefundOptions): Promise<PmtRefund>;
|
|
141
|
+
replacePmtRefund(opts: ReplacePmtRefundOptions): Promise<PmtRefund>;
|
|
142
|
+
searchPmtRefunds(opts: SearchPmtRefundsOptions): Promise<SearchPmtRefundsPage>;
|
|
143
|
+
createPmtCustomer(opts: CreatePmtCustomerOptions): Promise<PmtCustomer>;
|
|
144
|
+
replacePmtCustomer(opts: ReplacePmtCustomerOptions): Promise<PmtCustomer>;
|
|
145
|
+
searchPmtCustomers(opts: SearchPmtCustomersOptions): Promise<SearchPmtCustomersPage>;
|
|
146
|
+
createPmtPublicSession(opts: CreatePmtPublicSessionOptions): Promise<PmtPublicSession>;
|
|
147
|
+
replacePmtPublicSession(opts: ReplacePmtPublicSessionOptions): Promise<PmtPublicSession>;
|
|
148
|
+
searchPmtPublicSessions(opts: SearchPmtPublicSessionsOptions): Promise<SearchPmtPublicSessionsPage>;
|
|
149
|
+
createCreditLedgerEntry(opts: CreateCreditLedgerEntryOptions): Promise<CreditLedgerEntry>;
|
|
150
|
+
replaceCreditLedgerEntry(opts: ReplaceCreditLedgerEntryOptions): Promise<CreditLedgerEntry>;
|
|
151
|
+
searchCreditLedger(opts: SearchCreditLedgerOptions): Promise<SearchCreditLedgerPage>;
|
|
49
152
|
purchaseAppleCredits(opts: PurchaseAppleCreditsOptions): Promise<void>;
|
|
50
153
|
purchaseGoogleCredits(opts: PurchaseGoogleCreditsOptions): Promise<void>;
|
|
51
154
|
prepareStripeCreditPurchase(opts: PrepareStripeCreditPurchaseOptions): Promise<PrepareStripeCreditPurchaseResult>;
|
|
@@ -53,6 +156,14 @@ export declare class PaymentsFX implements PaymentsFXOperator {
|
|
|
53
156
|
openDirectPublicPaymentSession(opts: OpenDirectPublicPaymentSessionOptions): Promise<OpenPublicPaymentSessionResult>;
|
|
54
157
|
openLookupPublicPaymentSession(opts: OpenLookupPublicPaymentSessionOptions): Promise<OpenPublicPaymentSessionResult>;
|
|
55
158
|
payPublicSession(opts: PayPublicSessionOptions): Promise<PayPublicSessionResult>;
|
|
159
|
+
private findPayment;
|
|
160
|
+
private findPmtAccount;
|
|
161
|
+
private findPmtBankAccount;
|
|
162
|
+
private findPmtCard;
|
|
163
|
+
private findPmtRefund;
|
|
164
|
+
private findPmtCustomer;
|
|
165
|
+
private findPmtPublicSession;
|
|
166
|
+
private findCreditLedgerEntry;
|
|
56
167
|
private openPublicPaymentSession;
|
|
57
168
|
}
|
|
58
169
|
export declare function newPaymentsFX(opts: PaymentsFXOptions): PaymentsFX;
|
|
@@ -3,11 +3,37 @@
|
|
|
3
3
|
// Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
4
4
|
// not use this file except in compliance with the License. You may obtain
|
|
5
5
|
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
import { CreditLedgerSourceAndroidIAP, CreditLedgerSourceAppleIAP, CreditLedgerSourceStripe, ZeroID, } from "@fabriktor/schema";
|
|
6
|
+
import { CreditLedgerSourceAndroidIAP, CreditLedgerSourceAppleIAP, CreditLedgerSourceStripe, OwnerIDKey, ZeroID, } from "@fabriktor/schema";
|
|
7
7
|
import { errResolveFailed, errValidation } from "../core/err.js";
|
|
8
|
+
import { requiredOperationID, resolvedID } from "../core/id.js";
|
|
9
|
+
import { runSearch } from "../core/search.js";
|
|
8
10
|
const publicAmountPattern = /^\d+$/;
|
|
11
|
+
const resourcePayment = "payment";
|
|
12
|
+
const resourcePmtAccount = "pmt_account";
|
|
13
|
+
const resourcePmtBankAccount = "pmt_bank_account";
|
|
14
|
+
const resourcePmtCard = "pmt_card";
|
|
15
|
+
const resourcePmtRefund = "pmt_refund";
|
|
16
|
+
const resourcePmtCustomer = "pmt_customer";
|
|
17
|
+
const resourcePmtPublicSession = "pmt_public_session";
|
|
18
|
+
const resourceCreditLedgerEntry = "credit_ledger_entry";
|
|
9
19
|
const resourceStripeCreditPayment = "stripe credit payment";
|
|
10
20
|
const resourcePublicPaymentSession = "public payment session";
|
|
21
|
+
const msgCreatedPaymentIDMissing = "Created payment response did not contain an ID.";
|
|
22
|
+
const msgPaymentMissing = "Payment could not be resolved after the mutation.";
|
|
23
|
+
const msgCreatedPmtAccountIDMissing = "Created payment account response did not contain an ID.";
|
|
24
|
+
const msgPmtAccountMissing = "Payment account could not be resolved after the mutation.";
|
|
25
|
+
const msgCreatedPmtBankAccountIDMissing = "Created payment bank account response did not contain an ID.";
|
|
26
|
+
const msgPmtBankAccountMissing = "Payment bank account could not be resolved after the mutation.";
|
|
27
|
+
const msgCreatedPmtCardIDMissing = "Created payment card response did not contain an ID.";
|
|
28
|
+
const msgPmtCardMissing = "Payment card could not be resolved after the mutation.";
|
|
29
|
+
const msgCreatedPmtRefundIDMissing = "Created payment refund response did not contain an ID.";
|
|
30
|
+
const msgPmtRefundMissing = "Payment refund could not be resolved after the mutation.";
|
|
31
|
+
const msgCreatedPmtCustomerIDMissing = "Created payment customer response did not contain an ID.";
|
|
32
|
+
const msgPmtCustomerMissing = "Payment customer could not be resolved after the mutation.";
|
|
33
|
+
const msgCreatedPmtPublicSessionIDMissing = "Created payment public session response did not contain an ID.";
|
|
34
|
+
const msgPmtPublicSessionMissing = "Payment public session could not be resolved after the mutation.";
|
|
35
|
+
const msgCreatedCreditLedgerEntryIDMissing = "Created credit ledger entry response did not contain an ID.";
|
|
36
|
+
const msgCreditLedgerEntryMissing = "Credit ledger entry could not be resolved after the mutation.";
|
|
11
37
|
const msgStripeCreditPaymentIDMissing = "Stripe credit payment ID could not be resolved.";
|
|
12
38
|
const msgStripeCreditPaymentMissing = "Stripe credit payment could not be resolved.";
|
|
13
39
|
const msgStripeCreditPaymentAlreadyConfirmed = "Stripe credit payment is already confirmed.";
|
|
@@ -30,6 +56,166 @@ export class PaymentsFX {
|
|
|
30
56
|
this.payments = opts.payments;
|
|
31
57
|
this.submittedPublicSessionIDs = new Set();
|
|
32
58
|
}
|
|
59
|
+
async createPayment(opts) {
|
|
60
|
+
const out = await this.payments.insertOnePayment(opts);
|
|
61
|
+
const id = requiredOperationID(out, msgCreatedPaymentIDMissing);
|
|
62
|
+
return await this.findPayment(id);
|
|
63
|
+
}
|
|
64
|
+
async replacePayment(opts) {
|
|
65
|
+
await this.payments.replaceOnePayment(opts);
|
|
66
|
+
return await this.findPayment(opts.id);
|
|
67
|
+
}
|
|
68
|
+
async searchPayments(opts) {
|
|
69
|
+
return await runSearch({
|
|
70
|
+
search: (searchOpts) => this.payments.searchManyPayments(searchOpts),
|
|
71
|
+
query: {
|
|
72
|
+
[OwnerIDKey]: opts.owner_id,
|
|
73
|
+
},
|
|
74
|
+
q: opts.q,
|
|
75
|
+
page: opts.page,
|
|
76
|
+
per_page: opts.per_page,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
async createPmtAccount(opts) {
|
|
80
|
+
const out = await this.payments.insertOnePmtAccount(opts);
|
|
81
|
+
const id = requiredOperationID(out, msgCreatedPmtAccountIDMissing);
|
|
82
|
+
return await this.findPmtAccount(id);
|
|
83
|
+
}
|
|
84
|
+
async replacePmtAccount(opts) {
|
|
85
|
+
await this.payments.replaceOnePmtAccount(opts);
|
|
86
|
+
return await this.findPmtAccount(opts.id);
|
|
87
|
+
}
|
|
88
|
+
async searchPmtAccounts(opts) {
|
|
89
|
+
return await runSearch({
|
|
90
|
+
search: (searchOpts) => this.payments.searchManyPmtAccounts(searchOpts),
|
|
91
|
+
query: {
|
|
92
|
+
[OwnerIDKey]: opts.owner_id,
|
|
93
|
+
},
|
|
94
|
+
q: opts.q,
|
|
95
|
+
page: opts.page,
|
|
96
|
+
per_page: opts.per_page,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
async createPmtBankAccount(opts) {
|
|
100
|
+
const out = await this.payments.insertOnePmtBankAccount(opts);
|
|
101
|
+
const id = requiredOperationID(out, msgCreatedPmtBankAccountIDMissing);
|
|
102
|
+
return await this.findPmtBankAccount(id);
|
|
103
|
+
}
|
|
104
|
+
async replacePmtBankAccount(opts) {
|
|
105
|
+
await this.payments.replaceOnePmtBankAccount(opts);
|
|
106
|
+
return await this.findPmtBankAccount(opts.id);
|
|
107
|
+
}
|
|
108
|
+
async searchPmtBankAccounts(opts) {
|
|
109
|
+
return await runSearch({
|
|
110
|
+
search: (searchOpts) => this.payments.searchManyPmtBankAccounts(searchOpts),
|
|
111
|
+
query: {
|
|
112
|
+
[OwnerIDKey]: opts.owner_id,
|
|
113
|
+
},
|
|
114
|
+
q: opts.q,
|
|
115
|
+
page: opts.page,
|
|
116
|
+
per_page: opts.per_page,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
async createPmtCard(opts) {
|
|
120
|
+
const out = await this.payments.insertOnePmtCard(opts);
|
|
121
|
+
const id = requiredOperationID(out, msgCreatedPmtCardIDMissing);
|
|
122
|
+
return await this.findPmtCard(id);
|
|
123
|
+
}
|
|
124
|
+
async replacePmtCard(opts) {
|
|
125
|
+
await this.payments.replaceOnePmtCard(opts);
|
|
126
|
+
return await this.findPmtCard(opts.id);
|
|
127
|
+
}
|
|
128
|
+
async searchPmtCards(opts) {
|
|
129
|
+
return await runSearch({
|
|
130
|
+
search: (searchOpts) => this.payments.searchManyPmtCards(searchOpts),
|
|
131
|
+
query: {
|
|
132
|
+
[OwnerIDKey]: opts.owner_id,
|
|
133
|
+
},
|
|
134
|
+
q: opts.q,
|
|
135
|
+
page: opts.page,
|
|
136
|
+
per_page: opts.per_page,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
async createPmtRefund(opts) {
|
|
140
|
+
const out = await this.payments.insertOnePmtRefund(opts);
|
|
141
|
+
const id = requiredOperationID(out, msgCreatedPmtRefundIDMissing);
|
|
142
|
+
return await this.findPmtRefund(id);
|
|
143
|
+
}
|
|
144
|
+
async replacePmtRefund(opts) {
|
|
145
|
+
await this.payments.replaceOnePmtRefund(opts);
|
|
146
|
+
return await this.findPmtRefund(opts.id);
|
|
147
|
+
}
|
|
148
|
+
async searchPmtRefunds(opts) {
|
|
149
|
+
return await runSearch({
|
|
150
|
+
search: (searchOpts) => this.payments.searchManyPmtRefunds(searchOpts),
|
|
151
|
+
query: {
|
|
152
|
+
[OwnerIDKey]: opts.owner_id,
|
|
153
|
+
},
|
|
154
|
+
q: opts.q,
|
|
155
|
+
page: opts.page,
|
|
156
|
+
per_page: opts.per_page,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
async createPmtCustomer(opts) {
|
|
160
|
+
const out = await this.payments.insertOnePmtCustomer(opts);
|
|
161
|
+
const id = requiredOperationID(out, msgCreatedPmtCustomerIDMissing);
|
|
162
|
+
return await this.findPmtCustomer(id);
|
|
163
|
+
}
|
|
164
|
+
async replacePmtCustomer(opts) {
|
|
165
|
+
await this.payments.replaceOnePmtCustomer(opts);
|
|
166
|
+
return await this.findPmtCustomer(opts.id);
|
|
167
|
+
}
|
|
168
|
+
async searchPmtCustomers(opts) {
|
|
169
|
+
return await runSearch({
|
|
170
|
+
search: (searchOpts) => this.payments.searchManyPmtCustomers(searchOpts),
|
|
171
|
+
query: {
|
|
172
|
+
[OwnerIDKey]: opts.owner_id,
|
|
173
|
+
},
|
|
174
|
+
q: opts.q,
|
|
175
|
+
page: opts.page,
|
|
176
|
+
per_page: opts.per_page,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
async createPmtPublicSession(opts) {
|
|
180
|
+
const out = await this.payments.insertOnePmtPublicSession(opts);
|
|
181
|
+
const id = requiredOperationID(out, msgCreatedPmtPublicSessionIDMissing);
|
|
182
|
+
return await this.findPmtPublicSession(id);
|
|
183
|
+
}
|
|
184
|
+
async replacePmtPublicSession(opts) {
|
|
185
|
+
await this.payments.replaceOnePmtPublicSession(opts);
|
|
186
|
+
return await this.findPmtPublicSession(opts.id);
|
|
187
|
+
}
|
|
188
|
+
async searchPmtPublicSessions(opts) {
|
|
189
|
+
return await runSearch({
|
|
190
|
+
search: (searchOpts) => this.payments.searchManyPmtPublicSessions(searchOpts),
|
|
191
|
+
query: {
|
|
192
|
+
[OwnerIDKey]: opts.owner_id,
|
|
193
|
+
},
|
|
194
|
+
q: opts.q,
|
|
195
|
+
page: opts.page,
|
|
196
|
+
per_page: opts.per_page,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
async createCreditLedgerEntry(opts) {
|
|
200
|
+
const out = await this.payments.insertOneCreditLedgerEntry(opts);
|
|
201
|
+
const id = requiredOperationID(out, msgCreatedCreditLedgerEntryIDMissing);
|
|
202
|
+
return await this.findCreditLedgerEntry(id);
|
|
203
|
+
}
|
|
204
|
+
async replaceCreditLedgerEntry(opts) {
|
|
205
|
+
await this.payments.replaceOneCreditLedgerEntry(opts);
|
|
206
|
+
return await this.findCreditLedgerEntry(opts.id);
|
|
207
|
+
}
|
|
208
|
+
async searchCreditLedger(opts) {
|
|
209
|
+
return await runSearch({
|
|
210
|
+
search: (searchOpts) => this.payments.searchManyCreditLedger(searchOpts),
|
|
211
|
+
query: {
|
|
212
|
+
[OwnerIDKey]: opts.owner_id,
|
|
213
|
+
},
|
|
214
|
+
q: opts.q,
|
|
215
|
+
page: opts.page,
|
|
216
|
+
per_page: opts.per_page,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
33
219
|
async purchaseAppleCredits(opts) {
|
|
34
220
|
await this.payments.purchaseCredits({
|
|
35
221
|
src: CreditLedgerSourceAppleIAP,
|
|
@@ -145,6 +331,110 @@ export class PaymentsFX {
|
|
|
145
331
|
throw err;
|
|
146
332
|
}
|
|
147
333
|
}
|
|
334
|
+
async findPayment(id) {
|
|
335
|
+
const out = await this.payments.findOnePayment({
|
|
336
|
+
id,
|
|
337
|
+
});
|
|
338
|
+
const payment = out.value;
|
|
339
|
+
if (payment === undefined) {
|
|
340
|
+
throw errResolveFailed({
|
|
341
|
+
resource: resourcePayment,
|
|
342
|
+
msg: msgPaymentMissing,
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
return payment;
|
|
346
|
+
}
|
|
347
|
+
async findPmtAccount(id) {
|
|
348
|
+
const out = await this.payments.findOnePmtAccount({
|
|
349
|
+
id,
|
|
350
|
+
});
|
|
351
|
+
const account = out.value;
|
|
352
|
+
if (account === undefined) {
|
|
353
|
+
throw errResolveFailed({
|
|
354
|
+
resource: resourcePmtAccount,
|
|
355
|
+
msg: msgPmtAccountMissing,
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
return account;
|
|
359
|
+
}
|
|
360
|
+
async findPmtBankAccount(id) {
|
|
361
|
+
const out = await this.payments.findOnePmtBankAccount({
|
|
362
|
+
id,
|
|
363
|
+
});
|
|
364
|
+
const account = out.value;
|
|
365
|
+
if (account === undefined) {
|
|
366
|
+
throw errResolveFailed({
|
|
367
|
+
resource: resourcePmtBankAccount,
|
|
368
|
+
msg: msgPmtBankAccountMissing,
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
return account;
|
|
372
|
+
}
|
|
373
|
+
async findPmtCard(id) {
|
|
374
|
+
const out = await this.payments.findOnePmtCard({
|
|
375
|
+
id,
|
|
376
|
+
});
|
|
377
|
+
const card = out.value;
|
|
378
|
+
if (card === undefined) {
|
|
379
|
+
throw errResolveFailed({
|
|
380
|
+
resource: resourcePmtCard,
|
|
381
|
+
msg: msgPmtCardMissing,
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
return card;
|
|
385
|
+
}
|
|
386
|
+
async findPmtRefund(id) {
|
|
387
|
+
const out = await this.payments.findOnePmtRefund({
|
|
388
|
+
id,
|
|
389
|
+
});
|
|
390
|
+
const refund = out.value;
|
|
391
|
+
if (refund === undefined) {
|
|
392
|
+
throw errResolveFailed({
|
|
393
|
+
resource: resourcePmtRefund,
|
|
394
|
+
msg: msgPmtRefundMissing,
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
return refund;
|
|
398
|
+
}
|
|
399
|
+
async findPmtCustomer(id) {
|
|
400
|
+
const out = await this.payments.findOnePmtCustomer({
|
|
401
|
+
id,
|
|
402
|
+
});
|
|
403
|
+
const customer = out.value;
|
|
404
|
+
if (customer === undefined) {
|
|
405
|
+
throw errResolveFailed({
|
|
406
|
+
resource: resourcePmtCustomer,
|
|
407
|
+
msg: msgPmtCustomerMissing,
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
return customer;
|
|
411
|
+
}
|
|
412
|
+
async findPmtPublicSession(id) {
|
|
413
|
+
const out = await this.payments.findOnePmtPublicSession({
|
|
414
|
+
id,
|
|
415
|
+
});
|
|
416
|
+
const session = out.value;
|
|
417
|
+
if (session === undefined) {
|
|
418
|
+
throw errResolveFailed({
|
|
419
|
+
resource: resourcePmtPublicSession,
|
|
420
|
+
msg: msgPmtPublicSessionMissing,
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
return session;
|
|
424
|
+
}
|
|
425
|
+
async findCreditLedgerEntry(id) {
|
|
426
|
+
const out = await this.payments.findOneCreditLedgerEntry({
|
|
427
|
+
id,
|
|
428
|
+
});
|
|
429
|
+
const entry = out.value;
|
|
430
|
+
if (entry === undefined) {
|
|
431
|
+
throw errResolveFailed({
|
|
432
|
+
resource: resourceCreditLedgerEntry,
|
|
433
|
+
msg: msgCreditLedgerEntryMissing,
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
return entry;
|
|
437
|
+
}
|
|
148
438
|
async openPublicPaymentSession(input) {
|
|
149
439
|
const out = await this.payments.openPmtPublicSession(input);
|
|
150
440
|
if (out === undefined) {
|
|
@@ -238,20 +528,6 @@ function publicSessionID(session) {
|
|
|
238
528
|
function operationID(out) {
|
|
239
529
|
return resolvedID(out.id);
|
|
240
530
|
}
|
|
241
|
-
function resolvedID(v) {
|
|
242
|
-
const out = resolvedValue(v);
|
|
243
|
-
if (out === undefined || out === ZeroID) {
|
|
244
|
-
return undefined;
|
|
245
|
-
}
|
|
246
|
-
return out;
|
|
247
|
-
}
|
|
248
|
-
function resolvedValue(v) {
|
|
249
|
-
const out = v?.trim();
|
|
250
|
-
if (out === undefined || out.length === 0) {
|
|
251
|
-
return undefined;
|
|
252
|
-
}
|
|
253
|
-
return out;
|
|
254
|
-
}
|
|
255
531
|
function zeroAppleIAP() {
|
|
256
532
|
return {
|
|
257
533
|
transaction_id: "",
|