@fabriktor/fx 0.0.207 → 0.0.209
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/feed/feed.d.ts +3 -0
- package/dist/src/feed/feed.js +2 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/payments/payments.d.ts +3 -3
- package/dist/src/payments/payments.js +2 -1
- package/dist/src/session/signup.d.ts +36 -0
- package/dist/src/session/signup.js +104 -0
- package/package.json +3 -3
package/dist/src/feed/feed.d.ts
CHANGED
package/dist/src/feed/feed.js
CHANGED
|
@@ -13,6 +13,7 @@ export * from "./media.js";
|
|
|
13
13
|
import { saveFeedPost, newFeedPostSaveState, } from "./media.js";
|
|
14
14
|
export const FeedEvents = {
|
|
15
15
|
Changed: createEvent(),
|
|
16
|
+
Created: createEvent(),
|
|
16
17
|
};
|
|
17
18
|
const newFeedSessionToken = "";
|
|
18
19
|
const resourceFeedSessionToken = "feed_session_token";
|
|
@@ -137,6 +138,7 @@ export class FeedFX {
|
|
|
137
138
|
signal.throwIfAborted();
|
|
138
139
|
const post = await this.requireFeedPost(id, signal);
|
|
139
140
|
this.changed(post.id);
|
|
141
|
+
this.events.publish(FeedEvents.Created, { post });
|
|
140
142
|
if (resolvedID(post.reply_to_post_id))
|
|
141
143
|
this.changed(post.reply_to_post_id);
|
|
142
144
|
if (resolvedID(post.referenced_post_id))
|
package/dist/src/index.d.ts
CHANGED
|
@@ -59,6 +59,7 @@ export * from "./routes/tracking.js";
|
|
|
59
59
|
export * from "./routes/validation.js";
|
|
60
60
|
export * from "./routes/workspace.js";
|
|
61
61
|
export * from "./session/session.js";
|
|
62
|
+
export * from "./session/signup.js";
|
|
62
63
|
export * from "./storage/capture.js";
|
|
63
64
|
export * from "./storage/storage.js";
|
|
64
65
|
export * from "./timesheets/access.js";
|
package/dist/src/index.js
CHANGED
|
@@ -59,6 +59,7 @@ export * from "./routes/tracking.js";
|
|
|
59
59
|
export * from "./routes/validation.js";
|
|
60
60
|
export * from "./routes/workspace.js";
|
|
61
61
|
export * from "./session/session.js";
|
|
62
|
+
export * from "./session/signup.js";
|
|
62
63
|
export * from "./storage/capture.js";
|
|
63
64
|
export * from "./storage/storage.js";
|
|
64
65
|
export * from "./timesheets/access.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PaymentEntityTypeBill, PaymentEntityTypePayroll, type Bill, type Payroll, PSPPaymentStatusPending, PSPPaymentStatusPartial, PSPPaymentStatusFull, type CreditLedgerEntry, type CreditGrant, type Payment, type PmtAccount, type PmtBankAccount, type PmtCard, type PmtCustomer, type PmtPublicSession, type PmtRefund, type SortStripeBalanceResult } from "@fabriktor/schema";
|
|
2
|
-
import { type PaymentsOperator, type BillableOperator, type PayrollsOperator } from "@fabriktor/client";
|
|
2
|
+
import { type PaymentsOperator, type BillableOperator, type PayrollsOperator, type RequestOptions } from "@fabriktor/client";
|
|
3
3
|
import { PreActionBlocked } from "../core/pre-action.js";
|
|
4
4
|
import { type SearchOptions, type OwnerSearchOptions, type SearchPage } from "../core/search.js";
|
|
5
5
|
import { EventBus } from "../core/events.js";
|
|
@@ -234,7 +234,7 @@ export interface PaymentsFXOperator {
|
|
|
234
234
|
createCreditLedgerEntry(opts: CreateCreditLedgerEntryOptions): Promise<CreditLedgerEntry>;
|
|
235
235
|
replaceCreditLedgerEntry(opts: ReplaceCreditLedgerEntryOptions): Promise<CreditLedgerEntry>;
|
|
236
236
|
searchCreditLedger(opts: SearchCreditLedgerOptions): Promise<SearchCreditLedgerPage>;
|
|
237
|
-
claimSignupCredits(): Promise<CreditGrant | undefined>;
|
|
237
|
+
claimSignupCredits(opts?: RequestOptions): Promise<CreditGrant | undefined>;
|
|
238
238
|
purchaseAppleCredits(opts: PurchaseAppleCreditsOptions): Promise<void>;
|
|
239
239
|
purchaseGoogleCredits(opts: PurchaseGoogleCreditsOptions): Promise<void>;
|
|
240
240
|
prepareStripeCreditPurchase(opts: PrepareStripeCreditPurchaseOptions): Promise<PrepareStripeCreditPurchaseResult>;
|
|
@@ -286,7 +286,7 @@ export declare class PaymentsFX implements PaymentsFXOperator {
|
|
|
286
286
|
createCreditLedgerEntry(opts: CreateCreditLedgerEntryOptions): Promise<CreditLedgerEntry>;
|
|
287
287
|
replaceCreditLedgerEntry(opts: ReplaceCreditLedgerEntryOptions): Promise<CreditLedgerEntry>;
|
|
288
288
|
searchCreditLedger(opts: SearchCreditLedgerOptions): Promise<SearchCreditLedgerPage>;
|
|
289
|
-
claimSignupCredits(): Promise<CreditGrant | undefined>;
|
|
289
|
+
claimSignupCredits(opts?: RequestOptions): Promise<CreditGrant | undefined>;
|
|
290
290
|
purchaseAppleCredits(opts: PurchaseAppleCreditsOptions): Promise<void>;
|
|
291
291
|
purchaseGoogleCredits(opts: PurchaseGoogleCreditsOptions): Promise<void>;
|
|
292
292
|
prepareStripeCreditPurchase(opts: PrepareStripeCreditPurchaseOptions): Promise<PrepareStripeCreditPurchaseResult>;
|
|
@@ -690,9 +690,10 @@ export class PaymentsFX {
|
|
|
690
690
|
search: (searchOpts) => this.payments.searchManyCreditLedger(searchOpts),
|
|
691
691
|
});
|
|
692
692
|
}
|
|
693
|
-
async claimSignupCredits() {
|
|
693
|
+
async claimSignupCredits(opts = {}) {
|
|
694
694
|
try {
|
|
695
695
|
const out = await this.payments.claimCredits({
|
|
696
|
+
...opts,
|
|
696
697
|
type: CreditGrantTypeSignup,
|
|
697
698
|
});
|
|
698
699
|
if (!out.value) {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type InFeedPost, type InMarketplacePost } from "@fabriktor/schema";
|
|
2
|
+
import type { FeedFXOperator } from "../feed/feed.js";
|
|
3
|
+
import type { MarketplaceFXOperator } from "../marketplace/marketplace.js";
|
|
4
|
+
export type SignupIntroduction = {
|
|
5
|
+
text: string;
|
|
6
|
+
hiring: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type SignupPostsInput = {
|
|
9
|
+
welcome: string;
|
|
10
|
+
user_type: string;
|
|
11
|
+
country: string;
|
|
12
|
+
state: string;
|
|
13
|
+
city: string;
|
|
14
|
+
introduction?: SignupIntroduction;
|
|
15
|
+
};
|
|
16
|
+
export type SignupPostTask = {
|
|
17
|
+
idempotency_key: string;
|
|
18
|
+
attempted: boolean;
|
|
19
|
+
created_id?: string;
|
|
20
|
+
status: "pending" | "done" | "rejected" | "unconfirmed";
|
|
21
|
+
} & ({
|
|
22
|
+
kind: "feed";
|
|
23
|
+
input: InFeedPost;
|
|
24
|
+
} | {
|
|
25
|
+
kind: "marketplace";
|
|
26
|
+
input: InMarketplacePost;
|
|
27
|
+
});
|
|
28
|
+
export declare function newSignupPosts(opts: SignupPostsInput): SignupPostTask[];
|
|
29
|
+
export type CreateSignupPostsOptions = {
|
|
30
|
+
posts: SignupPostTask[];
|
|
31
|
+
feed: Pick<FeedFXOperator, "createFeedPost">;
|
|
32
|
+
marketplace: Pick<MarketplaceFXOperator, "createMarketplacePost">;
|
|
33
|
+
signal: AbortSignal;
|
|
34
|
+
on_change: () => void;
|
|
35
|
+
};
|
|
36
|
+
export declare function createSignupPosts(opts: CreateSignupPostsOptions): Promise<PromiseSettledResult<void>[]>;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { PostTypeEmployment, Private, UserTypeEmployer, ZeroID, } from "@fabriktor/schema";
|
|
2
|
+
import { errUnconfirmedMutation } from "../core/err.js";
|
|
3
|
+
import { resolvedID } from "../core/id.js";
|
|
4
|
+
import { marketplacePostTypes } from "../marketplace/validation.js";
|
|
5
|
+
export function newSignupPosts(opts) {
|
|
6
|
+
const checkpoint = () => ({
|
|
7
|
+
idempotency_key: crypto.randomUUID(),
|
|
8
|
+
attempted: false,
|
|
9
|
+
status: "pending",
|
|
10
|
+
});
|
|
11
|
+
const posts = [
|
|
12
|
+
{
|
|
13
|
+
...checkpoint(),
|
|
14
|
+
kind: "feed",
|
|
15
|
+
input: {
|
|
16
|
+
text: { text: opts.welcome, file: "", file_url: "", mime: "" },
|
|
17
|
+
objects: [],
|
|
18
|
+
is_uploading: false,
|
|
19
|
+
has_media: false,
|
|
20
|
+
visibility: Private,
|
|
21
|
+
referenced_post_id: ZeroID,
|
|
22
|
+
reply_to_post_id: ZeroID,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
const text = opts.introduction?.text.trim();
|
|
27
|
+
if (!text)
|
|
28
|
+
return posts;
|
|
29
|
+
for (const post_type of marketplacePostTypes(opts.user_type)) {
|
|
30
|
+
if (opts.user_type === UserTypeEmployer &&
|
|
31
|
+
post_type === PostTypeEmployment &&
|
|
32
|
+
!opts.introduction?.hiring)
|
|
33
|
+
continue;
|
|
34
|
+
posts.push({
|
|
35
|
+
...checkpoint(),
|
|
36
|
+
kind: "marketplace",
|
|
37
|
+
input: {
|
|
38
|
+
text: { text, file: "", file_url: "", mime: "" },
|
|
39
|
+
post_type,
|
|
40
|
+
user_type: opts.user_type,
|
|
41
|
+
country: opts.country,
|
|
42
|
+
state: opts.state,
|
|
43
|
+
city: opts.city,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return posts;
|
|
48
|
+
}
|
|
49
|
+
export async function createSignupPosts(opts) {
|
|
50
|
+
return await Promise.allSettled(opts.posts.map(async (post) => {
|
|
51
|
+
if (post.status !== "pending")
|
|
52
|
+
return;
|
|
53
|
+
opts.signal.throwIfAborted();
|
|
54
|
+
if (post.attempted && !resolvedID(post.created_id)) {
|
|
55
|
+
post.status = "unconfirmed";
|
|
56
|
+
opts.on_change();
|
|
57
|
+
throw errUnconfirmedMutation();
|
|
58
|
+
}
|
|
59
|
+
const checkpoint = {
|
|
60
|
+
attempted: post.attempted,
|
|
61
|
+
created_id: post.created_id,
|
|
62
|
+
before_request: () => {
|
|
63
|
+
opts.signal.throwIfAborted();
|
|
64
|
+
post.attempted = true;
|
|
65
|
+
opts.on_change();
|
|
66
|
+
},
|
|
67
|
+
on_created: (id) => {
|
|
68
|
+
post.created_id = id;
|
|
69
|
+
opts.on_change();
|
|
70
|
+
},
|
|
71
|
+
on_rejected: () => {
|
|
72
|
+
post.attempted = false;
|
|
73
|
+
post.status = "rejected";
|
|
74
|
+
opts.on_change();
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
const request = {
|
|
78
|
+
...checkpoint,
|
|
79
|
+
idempotency_key: post.idempotency_key,
|
|
80
|
+
signal: opts.signal,
|
|
81
|
+
};
|
|
82
|
+
try {
|
|
83
|
+
if (post.kind === "feed")
|
|
84
|
+
await opts.feed.createFeedPost({ ...request, in: post.input });
|
|
85
|
+
else
|
|
86
|
+
await opts.marketplace.createMarketplacePost({
|
|
87
|
+
...request,
|
|
88
|
+
in: post.input,
|
|
89
|
+
});
|
|
90
|
+
post.status = "done";
|
|
91
|
+
opts.on_change();
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
// A transport failure or 409 is not evidence that a post was committed.
|
|
95
|
+
if (post.status === "pending" &&
|
|
96
|
+
post.attempted &&
|
|
97
|
+
!resolvedID(post.created_id)) {
|
|
98
|
+
post.status = "unconfirmed";
|
|
99
|
+
opts.on_change();
|
|
100
|
+
}
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
}));
|
|
104
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabriktor/fx",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.209",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"typescript": "^6.0.3"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@fabriktor/client": "0.0.
|
|
20
|
+
"@fabriktor/client": "0.0.127",
|
|
21
21
|
"@fabriktor/fx": "0.0.94",
|
|
22
|
-
"@fabriktor/schema": "0.0.
|
|
22
|
+
"@fabriktor/schema": "0.0.96",
|
|
23
23
|
"convert": "8.0.2"
|
|
24
24
|
}
|
|
25
25
|
}
|