@railbeam/stardorm-api-contract 0.0.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.
- package/dist/index.d.mts +5504 -0
- package/dist/index.d.ts +5504 -0
- package/dist/index.js +983 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +888 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +29 -0
- package/src/agent-feedbacks.ts +58 -0
- package/src/agent.ts +58 -0
- package/src/auth.ts +29 -0
- package/src/billing-handlers.ts +92 -0
- package/src/catalog-build.ts +31 -0
- package/src/catalog-marketplace-response.ts +53 -0
- package/src/catalog.ts +11 -0
- package/src/chat-api.ts +139 -0
- package/src/conversation.ts +132 -0
- package/src/credit-card.ts +150 -0
- package/src/handlers.ts +40 -0
- package/src/index.ts +192 -0
- package/src/iso-3166-1-alpha2.ts +30 -0
- package/src/kyc.ts +34 -0
- package/src/on-ramp.ts +103 -0
- package/src/payment-request.ts +87 -0
- package/src/storage.ts +13 -0
- package/src/tax-rate-for-country.ts +50 -0
- package/src/transfer-drafts.ts +91 -0
- package/src/user.ts +70 -0
- package/tsconfig.json +15 -0
- package/tsup.config.ts +10 -0
package/src/kyc.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
/** Stripe Identity–backed lifecycle for a wallet user. */
|
|
4
|
+
export const userKycStatusSchema = z.enum([
|
|
5
|
+
"not_started",
|
|
6
|
+
"pending",
|
|
7
|
+
"processing",
|
|
8
|
+
"verified",
|
|
9
|
+
"requires_input",
|
|
10
|
+
"canceled",
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
export type UserKycStatus = z.infer<typeof userKycStatusSchema>;
|
|
14
|
+
|
|
15
|
+
export const stripeKycInputSchema = z
|
|
16
|
+
.object({
|
|
17
|
+
/** App path + query (e.g. `/` or `/?conversation=<id>`); joined with `APP_PUBLIC_URL` for Stripe `return_url`. */
|
|
18
|
+
returnPath: z.string().min(1).max(512).optional(),
|
|
19
|
+
})
|
|
20
|
+
.strict();
|
|
21
|
+
|
|
22
|
+
export type StripeKycInput = z.infer<typeof stripeKycInputSchema>;
|
|
23
|
+
|
|
24
|
+
export const userKycStatusDocumentSchema = z.object({
|
|
25
|
+
walletAddress: z.string().min(1),
|
|
26
|
+
status: userKycStatusSchema,
|
|
27
|
+
stripeVerificationSessionId: z.string().optional(),
|
|
28
|
+
lastStripeEventType: z.string().optional(),
|
|
29
|
+
lastError: z.string().optional(),
|
|
30
|
+
createdAt: z.coerce.date().optional(),
|
|
31
|
+
updatedAt: z.coerce.date().optional(),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export type UserKycStatusDocument = z.infer<typeof userKycStatusDocumentSchema>;
|
package/src/on-ramp.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { x402SupportedAssetSchema } from "./chat-api.js";
|
|
3
|
+
|
|
4
|
+
export const onRampFormNetworkOptionSchema = z.object({
|
|
5
|
+
id: z.string().min(1).max(64),
|
|
6
|
+
label: z.string().min(1).max(120),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
/** Persisted on the chat CTA row until the user submits the on-ramp form. */
|
|
10
|
+
export const onRampFormCtaParamsSchema = z.object({
|
|
11
|
+
_onRampForm: z.literal(true),
|
|
12
|
+
supportedAssets: z.array(x402SupportedAssetSchema).min(1).max(24),
|
|
13
|
+
networks: z.array(onRampFormNetworkOptionSchema).max(16).optional(),
|
|
14
|
+
intro: z.string().max(2000).optional(),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export type OnRampFormCtaParams = z.infer<typeof onRampFormCtaParamsSchema>;
|
|
18
|
+
|
|
19
|
+
export function isOnRampFormCtaParams(v: unknown): v is OnRampFormCtaParams {
|
|
20
|
+
return onRampFormCtaParamsSchema.safeParse(v).success;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const weiString = z.union([
|
|
24
|
+
z
|
|
25
|
+
.string()
|
|
26
|
+
.trim()
|
|
27
|
+
.regex(
|
|
28
|
+
/^[1-9]\d*$/,
|
|
29
|
+
"tokenAmountWei must be base units (positive integer string, no decimals)",
|
|
30
|
+
),
|
|
31
|
+
z.number().int().positive().transform((n) => String(n)),
|
|
32
|
+
]);
|
|
33
|
+
|
|
34
|
+
const evmAddr = z
|
|
35
|
+
.string()
|
|
36
|
+
.min(1)
|
|
37
|
+
.refine(
|
|
38
|
+
(s) => /^0x[a-fA-F0-9]{40}$/.test(s.trim()),
|
|
39
|
+
"must be a 0x-prefixed 20-byte address",
|
|
40
|
+
)
|
|
41
|
+
.transform((s) => s.trim().toLowerCase());
|
|
42
|
+
|
|
43
|
+
/** Execution payload for `on_ramp_tokens` (Stripe Checkout + treasury ERC-20 send). */
|
|
44
|
+
export const onRampTokensInputSchema = z.object({
|
|
45
|
+
recipientWallet: evmAddr,
|
|
46
|
+
network: z.string().min(1).max(64),
|
|
47
|
+
tokenAddress: evmAddr,
|
|
48
|
+
tokenDecimals: z.number().int().min(0).max(36),
|
|
49
|
+
tokenSymbol: z.string().min(1).max(32),
|
|
50
|
+
tokenAmountWei: weiString,
|
|
51
|
+
/** Optional spot reference for analytics / UI (per supported token). */
|
|
52
|
+
usdValue: z.number().finite().nonnegative().optional(),
|
|
53
|
+
/** Total USD charged via Stripe (cents). Minimum $1.00. */
|
|
54
|
+
usdAmountCents: z.number().int().min(100).max(10_000_000),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export type OnRampTokensInput = z.infer<typeof onRampTokensInputSchema>;
|
|
58
|
+
|
|
59
|
+
export const onRampRecordStatusSchema = z.enum([
|
|
60
|
+
"pending_checkout",
|
|
61
|
+
"pending_payment",
|
|
62
|
+
"paid_pending_transfer",
|
|
63
|
+
"fulfilled",
|
|
64
|
+
"failed",
|
|
65
|
+
"canceled",
|
|
66
|
+
]);
|
|
67
|
+
|
|
68
|
+
export type OnRampRecordStatus = z.infer<typeof onRampRecordStatusSchema>;
|
|
69
|
+
|
|
70
|
+
export const onRampRecordSchema = z.object({
|
|
71
|
+
id: z.string().min(1),
|
|
72
|
+
status: onRampRecordStatusSchema,
|
|
73
|
+
walletAddress: z.string().min(1),
|
|
74
|
+
recipientWallet: z.string().min(1),
|
|
75
|
+
network: z.string().min(1),
|
|
76
|
+
tokenAddress: z.string().min(1),
|
|
77
|
+
tokenDecimals: z.number().int().min(0).max(36),
|
|
78
|
+
tokenSymbol: z.string().min(1),
|
|
79
|
+
tokenAmountWei: z.string().min(1),
|
|
80
|
+
usdAmountCents: z.number().int().nonnegative(),
|
|
81
|
+
usdValue: z.number().finite().nonnegative().optional(),
|
|
82
|
+
stripeCheckoutSessionId: z.string().optional(),
|
|
83
|
+
stripePaymentIntentId: z.string().optional(),
|
|
84
|
+
fulfillmentTxHash: z.string().optional(),
|
|
85
|
+
errorMessage: z.string().optional(),
|
|
86
|
+
createdAt: z.coerce.date().optional(),
|
|
87
|
+
updatedAt: z.coerce.date().optional(),
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
export type OnRampRecord = z.infer<typeof onRampRecordSchema>;
|
|
91
|
+
|
|
92
|
+
/** Query for GET `/users/me/on-ramps`. */
|
|
93
|
+
export const meOnRampsQuerySchema = z.object({
|
|
94
|
+
limit: z.coerce.number().int().min(1).max(50).default(20),
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
export type MeOnRampsQuery = z.infer<typeof meOnRampsQuerySchema>;
|
|
98
|
+
|
|
99
|
+
export const onRampsListResponseSchema = z.object({
|
|
100
|
+
items: z.array(onRampRecordSchema),
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
export type OnRampsListResponse = z.infer<typeof onRampsListResponseSchema>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { stardormChatAttachmentSchema } from "./chat-api.js";
|
|
3
|
+
|
|
4
|
+
const evmTxHashSchema = z
|
|
5
|
+
.string()
|
|
6
|
+
.regex(/^0x[a-fA-F0-9]{64}$/i, "Invalid transaction hash");
|
|
7
|
+
|
|
8
|
+
const evmAddressSchema = z
|
|
9
|
+
.string()
|
|
10
|
+
.regex(/^0x[a-fA-F0-9]{40}$/i, "Invalid address");
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Body for POST `/payments/:id/pay`.
|
|
14
|
+
* Either record a broadcast EVM tx (`txHash`), or submit a full x402 `PaymentPayload` for facilitator verify+settle when `X402_FACILITATOR_URL` is configured.
|
|
15
|
+
*/
|
|
16
|
+
export const paymentSettlementBodySchema = z
|
|
17
|
+
.object({
|
|
18
|
+
txHash: evmTxHashSchema.optional(),
|
|
19
|
+
payerAddress: evmAddressSchema.optional(),
|
|
20
|
+
/** Matches @x402/core `PaymentPayload` (x402Version, accepted, payload, …). */
|
|
21
|
+
x402PaymentPayload: z.record(z.string(), z.unknown()).optional(),
|
|
22
|
+
})
|
|
23
|
+
.superRefine((val, ctx) => {
|
|
24
|
+
if (!val.txHash && !val.x402PaymentPayload) {
|
|
25
|
+
ctx.addIssue({
|
|
26
|
+
code: z.ZodIssueCode.custom,
|
|
27
|
+
message: "Provide txHash (direct settlement) or x402PaymentPayload (facilitator).",
|
|
28
|
+
path: ["txHash"],
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (val.txHash && val.x402PaymentPayload) {
|
|
32
|
+
ctx.addIssue({
|
|
33
|
+
code: z.ZodIssueCode.custom,
|
|
34
|
+
message: "Provide only one of txHash or x402PaymentPayload.",
|
|
35
|
+
path: ["txHash"],
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export type PaymentSettlementBody = z.infer<typeof paymentSettlementBodySchema>;
|
|
41
|
+
|
|
42
|
+
export const paymentRequestTypeSchema = z.enum(["on-chain", "x402"]);
|
|
43
|
+
|
|
44
|
+
export const paymentRequestStatusSchema = z.enum([
|
|
45
|
+
"pending",
|
|
46
|
+
"paid",
|
|
47
|
+
"expired",
|
|
48
|
+
"cancelled",
|
|
49
|
+
]);
|
|
50
|
+
|
|
51
|
+
export const publicPaymentRequestSchema = z.object({
|
|
52
|
+
id: z.string(),
|
|
53
|
+
type: paymentRequestTypeSchema,
|
|
54
|
+
status: paymentRequestStatusSchema,
|
|
55
|
+
title: z.string(),
|
|
56
|
+
description: z.string().optional(),
|
|
57
|
+
asset: z.string(),
|
|
58
|
+
amount: z.string(),
|
|
59
|
+
payTo: z.string(),
|
|
60
|
+
network: z.string(),
|
|
61
|
+
expiresAt: z.string().optional(),
|
|
62
|
+
resourceId: z.string().optional(),
|
|
63
|
+
resourceUrl: z.string().max(2048).optional(),
|
|
64
|
+
decimals: z.number().int().min(0).max(36).optional(),
|
|
65
|
+
x402Payload: z.record(z.string(), z.unknown()).optional(),
|
|
66
|
+
attachment: stardormChatAttachmentSchema.optional(),
|
|
67
|
+
/** Set when status is `paid` (on-chain settlement recorded). */
|
|
68
|
+
txHash: z.string().optional(),
|
|
69
|
+
paidByWallet: z.string().optional(),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export type PublicPaymentRequest = z.infer<typeof publicPaymentRequestSchema>;
|
|
73
|
+
|
|
74
|
+
/** Query for GET `/users/me/payment-requests`. */
|
|
75
|
+
export const mePaymentRequestsQuerySchema = z.object({
|
|
76
|
+
limit: z.coerce.number().int().min(1).max(50).default(20),
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
export type MePaymentRequestsQuery = z.infer<typeof mePaymentRequestsQuerySchema>;
|
|
80
|
+
|
|
81
|
+
export const paymentRequestsListResponseSchema = z.object({
|
|
82
|
+
items: z.array(publicPaymentRequestSchema),
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
export type PaymentRequestsListResponse = z.infer<
|
|
86
|
+
typeof paymentRequestsListResponseSchema
|
|
87
|
+
>;
|
package/src/storage.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const storageUploadBodySchema = z.object({
|
|
4
|
+
content: z.string().min(1),
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
export const storageUploadResponseSchema = z.object({
|
|
8
|
+
rootHash: z.string().min(1),
|
|
9
|
+
txHash: z.string().optional(),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export type StorageUploadBody = z.infer<typeof storageUploadBodySchema>;
|
|
13
|
+
export type StorageUploadResponse = z.infer<typeof storageUploadResponseSchema>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** EU-27 member states (post-Brexit, excluding GB). */
|
|
2
|
+
const EU27 = new Set([
|
|
3
|
+
"AT",
|
|
4
|
+
"BE",
|
|
5
|
+
"BG",
|
|
6
|
+
"HR",
|
|
7
|
+
"CY",
|
|
8
|
+
"CZ",
|
|
9
|
+
"DK",
|
|
10
|
+
"EE",
|
|
11
|
+
"FI",
|
|
12
|
+
"FR",
|
|
13
|
+
"DE",
|
|
14
|
+
"GR",
|
|
15
|
+
"HU",
|
|
16
|
+
"IE",
|
|
17
|
+
"IT",
|
|
18
|
+
"LV",
|
|
19
|
+
"LT",
|
|
20
|
+
"LU",
|
|
21
|
+
"MT",
|
|
22
|
+
"NL",
|
|
23
|
+
"PL",
|
|
24
|
+
"PT",
|
|
25
|
+
"RO",
|
|
26
|
+
"SK",
|
|
27
|
+
"SI",
|
|
28
|
+
"ES",
|
|
29
|
+
"SE",
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
const EEA_NON_EU = new Set(["IS", "LI", "NO"]);
|
|
33
|
+
|
|
34
|
+
const HIGH_TIER_OECD = new Set(["AU", "CA", "JP", "KR", "NZ"]);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Approximate headline rate for PDF math when native activity is priced in USD.
|
|
38
|
+
* Not tax advice; every jurisdiction has nuance. Unknown ISO codes use the same default as the historical stub (0.2).
|
|
39
|
+
*/
|
|
40
|
+
export function taxRateForCountry(country: string): number {
|
|
41
|
+
const c = country.toUpperCase();
|
|
42
|
+
if (c === "US") return 0.22;
|
|
43
|
+
if (c === "GB" || c === "UK") return 0.2;
|
|
44
|
+
if (c === "DE" || c === "FR") return 0.25;
|
|
45
|
+
if (c === "SG") return 0.17;
|
|
46
|
+
if (EU27.has(c)) return 0.24;
|
|
47
|
+
if (EEA_NON_EU.has(c)) return 0.24;
|
|
48
|
+
if (HIGH_TIER_OECD.has(c)) return 0.25;
|
|
49
|
+
return 0.2;
|
|
50
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
const caip2Eip155 = z
|
|
4
|
+
.string()
|
|
5
|
+
.min(8)
|
|
6
|
+
.max(64)
|
|
7
|
+
.regex(
|
|
8
|
+
/^eip155:\d+$/,
|
|
9
|
+
"network must be CAIP-2 form eip155:<chainId> (e.g. eip155:16602)",
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
const evmAddress20 = z
|
|
13
|
+
.string()
|
|
14
|
+
.trim()
|
|
15
|
+
.refine(
|
|
16
|
+
(s) => /^0x[a-fA-F0-9]{40}$/.test(s),
|
|
17
|
+
"must be a 0x-prefixed 20-byte EVM address",
|
|
18
|
+
)
|
|
19
|
+
.transform((s) => s.trim().toLowerCase());
|
|
20
|
+
|
|
21
|
+
/** Positive integer string in base units (no decimals, no leading zeros except single "0" disallowed for valueWei — use /^[1-9]\\d*$/ for strictly positive). */
|
|
22
|
+
const positiveWeiString = z
|
|
23
|
+
.string()
|
|
24
|
+
.trim()
|
|
25
|
+
.regex(
|
|
26
|
+
/^[1-9]\d*$/,
|
|
27
|
+
"must be a positive integer decimal string (base units / wei)",
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const decimalStringNonNeg = z
|
|
31
|
+
.string()
|
|
32
|
+
.trim()
|
|
33
|
+
.regex(/^\d+$/, "must be a non-negative integer decimal string");
|
|
34
|
+
|
|
35
|
+
const nftStandardSchema = z.enum(["erc721", "erc1155"]);
|
|
36
|
+
|
|
37
|
+
export const draftNativeTransferInputSchema = z.object({
|
|
38
|
+
network: caip2Eip155,
|
|
39
|
+
to: evmAddress20,
|
|
40
|
+
valueWei: positiveWeiString,
|
|
41
|
+
note: z.string().max(500).optional(),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export type DraftNativeTransferInput = z.infer<
|
|
45
|
+
typeof draftNativeTransferInputSchema
|
|
46
|
+
>;
|
|
47
|
+
|
|
48
|
+
export const draftErc20TransferInputSchema = z.object({
|
|
49
|
+
network: caip2Eip155,
|
|
50
|
+
token: evmAddress20,
|
|
51
|
+
tokenSymbol: z.string().min(1).max(32).optional(),
|
|
52
|
+
tokenDecimals: z.number().int().min(0).max(36),
|
|
53
|
+
to: evmAddress20,
|
|
54
|
+
amountWei: positiveWeiString,
|
|
55
|
+
note: z.string().max(500).optional(),
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export type DraftErc20TransferInput = z.infer<
|
|
59
|
+
typeof draftErc20TransferInputSchema
|
|
60
|
+
>;
|
|
61
|
+
|
|
62
|
+
export const draftNftTransferInputSchema = z
|
|
63
|
+
.object({
|
|
64
|
+
network: caip2Eip155,
|
|
65
|
+
contract: evmAddress20,
|
|
66
|
+
standard: nftStandardSchema.default("erc721"),
|
|
67
|
+
to: evmAddress20,
|
|
68
|
+
tokenId: decimalStringNonNeg,
|
|
69
|
+
/** Required for ERC-1155; omit for ERC-721. */
|
|
70
|
+
amount: positiveWeiString.optional(),
|
|
71
|
+
note: z.string().max(500).optional(),
|
|
72
|
+
})
|
|
73
|
+
.superRefine((val, ctx) => {
|
|
74
|
+
if (val.standard === "erc1155") {
|
|
75
|
+
if (!val.amount) {
|
|
76
|
+
ctx.addIssue({
|
|
77
|
+
code: z.ZodIssueCode.custom,
|
|
78
|
+
message: "amount (base units) is required for ERC-1155",
|
|
79
|
+
path: ["amount"],
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
} else if (val.amount != null) {
|
|
83
|
+
ctx.addIssue({
|
|
84
|
+
code: z.ZodIssueCode.custom,
|
|
85
|
+
message: "amount must be omitted for ERC-721",
|
|
86
|
+
path: ["amount"],
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
export type DraftNftTransferInput = z.infer<typeof draftNftTransferInputSchema>;
|
package/src/user.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { handlerActionIdSchema } from "./handlers.js";
|
|
3
|
+
import { stardormChatRichBlockSchema } from "./chat-api.js";
|
|
4
|
+
|
|
5
|
+
export const userAvatarPresetSchema = z.enum(["male", "female"]);
|
|
6
|
+
|
|
7
|
+
export const userPreferencesSchema = z.object({
|
|
8
|
+
autoRoutePrompts: z.boolean(),
|
|
9
|
+
onchainReceipts: z.boolean(),
|
|
10
|
+
emailNotifications: z.boolean(),
|
|
11
|
+
avatarPreset: userAvatarPresetSchema.default("male"),
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const publicUserSchema = z.object({
|
|
15
|
+
id: z.string().min(1),
|
|
16
|
+
walletAddress: z.string().min(1),
|
|
17
|
+
displayName: z.string().optional(),
|
|
18
|
+
email: z.string().optional(),
|
|
19
|
+
activeAgentId: z.string().min(1),
|
|
20
|
+
/** Selected chat thread id when multi-conversation is enabled. */
|
|
21
|
+
activeConversationId: z.string().min(1).optional(),
|
|
22
|
+
preferences: userPreferencesSchema,
|
|
23
|
+
lastLoginAt: z.coerce.date().optional(),
|
|
24
|
+
createdAt: z.coerce.date().optional(),
|
|
25
|
+
updatedAt: z.coerce.date().optional(),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export const updateUserBodySchema = z.object({
|
|
29
|
+
displayName: z.string().optional(),
|
|
30
|
+
email: z.string().nullable().optional(),
|
|
31
|
+
activeAgentId: z.string().optional(),
|
|
32
|
+
activeConversationId: z.string().nullable().optional(),
|
|
33
|
+
preferences: userPreferencesSchema.partial().optional(),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const userUploadResultSchema = z.object({
|
|
37
|
+
rootHash: z.string().min(1),
|
|
38
|
+
txHash: z.string().optional(),
|
|
39
|
+
originalName: z.string(),
|
|
40
|
+
mimeType: z.string(),
|
|
41
|
+
size: z.number().int().nonnegative(),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export const executeHandlerBodySchema = z.object({
|
|
45
|
+
handler: handlerActionIdSchema,
|
|
46
|
+
params: z.unknown().optional(),
|
|
47
|
+
/** Mongo id of the chat message that displayed the handler CTA (required). */
|
|
48
|
+
ctaMessageId: z.string().min(1),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const handlerAttachmentSchema = z.object({
|
|
52
|
+
rootHash: z.string(),
|
|
53
|
+
mimeType: z.string(),
|
|
54
|
+
name: z.string(),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export const executeHandlerResponseSchema = z.object({
|
|
58
|
+
message: z.string(),
|
|
59
|
+
attachments: z.array(handlerAttachmentSchema).optional(),
|
|
60
|
+
data: z.record(z.string(), z.unknown()).optional(),
|
|
61
|
+
rich: stardormChatRichBlockSchema.optional(),
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export type UserAvatarPreset = z.infer<typeof userAvatarPresetSchema>;
|
|
65
|
+
|
|
66
|
+
export type PublicUser = z.infer<typeof publicUserSchema>;
|
|
67
|
+
export type UpdateUserBody = z.infer<typeof updateUserBodySchema>;
|
|
68
|
+
export type UserUploadResult = z.infer<typeof userUploadResultSchema>;
|
|
69
|
+
export type ExecuteHandlerBody = z.infer<typeof executeHandlerBodySchema>;
|
|
70
|
+
export type ExecuteHandlerResponse = z.infer<typeof executeHandlerResponseSchema>;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"declarationMap": true,
|
|
8
|
+
"strict": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"rootDir": "src",
|
|
11
|
+
"outDir": "dist",
|
|
12
|
+
"forceConsistentCasingInFileNames": true
|
|
13
|
+
},
|
|
14
|
+
"include": ["src/**/*.ts"]
|
|
15
|
+
}
|