@uninspired/auth-client 0.0.17 → 0.0.18
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/cjs/index.js +13 -1
- package/dist/cjs/index.js.map +4 -3
- package/dist/esm/index.js +13 -1
- package/dist/esm/index.js.map +4 -3
- package/dist/types/index.d.ts +69 -18
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -33,6 +33,7 @@ __export(exports_src, {
|
|
|
33
33
|
makeRedirectIntent: () => makeRedirectIntent,
|
|
34
34
|
makePublicClient: () => makePublicClient,
|
|
35
35
|
makeMailingListClient: () => makeMailingListClient,
|
|
36
|
+
makeMailingListAdminClient: () => makeMailingListAdminClient,
|
|
36
37
|
makeLoginUrl: () => makeLoginUrl,
|
|
37
38
|
makeCheckoutUrl: () => makeCheckoutUrl,
|
|
38
39
|
makeCheckoutClient: () => makeCheckoutClient,
|
|
@@ -101,6 +102,17 @@ var makeMailingListClient = (baseURL, publicKey, options) => {
|
|
|
101
102
|
}
|
|
102
103
|
});
|
|
103
104
|
};
|
|
105
|
+
// src/clients/mailingListAdminClient.ts
|
|
106
|
+
var import_client5 = require("hono/client");
|
|
107
|
+
var makeMailingListAdminClient = (baseURL, apiKey, options) => {
|
|
108
|
+
return import_client5.hc(baseURL, {
|
|
109
|
+
...options,
|
|
110
|
+
headers: {
|
|
111
|
+
...options?.headers,
|
|
112
|
+
"X-API-Key": apiKey
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
};
|
|
104
116
|
// src/utils/intent.ts
|
|
105
117
|
function makeLoginUrl(apiUrl, redirectUrl, appName) {
|
|
106
118
|
const url = new URL("/login", apiUrl);
|
|
@@ -196,5 +208,5 @@ function formatPrice(amountStr, currencyCode) {
|
|
|
196
208
|
}).format(amount / divisor);
|
|
197
209
|
}
|
|
198
210
|
|
|
199
|
-
//# debugId=
|
|
211
|
+
//# debugId=2013C2F3B5BDF6CD64756E2164756E21
|
|
200
212
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/clients/publicClient.ts", "../../src/clients/appClient.ts", "../../src/clients/authClient.ts", "../../src/clients/checkoutClient.ts", "../../src/clients/mailingListClient.ts", "../../src/utils/intent.ts", "../../../utils/src/intent.ts", "../../../utils/src/checkout.ts", "../../../utils/src/price.ts"],
|
|
3
|
+
"sources": ["../../src/clients/publicClient.ts", "../../src/clients/appClient.ts", "../../src/clients/authClient.ts", "../../src/clients/checkoutClient.ts", "../../src/clients/mailingListClient.ts", "../../src/clients/mailingListAdminClient.ts", "../../src/utils/intent.ts", "../../../utils/src/intent.ts", "../../../utils/src/checkout.ts", "../../../utils/src/price.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { PublicRouter } from \"@us-accounts/api\";\nimport { hc, type ClientRequestOptions } from \"hono/client\";\n\nexport type PublicClient = ReturnType<typeof hc<PublicRouter>>;\n\nexport const makePublicClient = (\n baseURL: string,\n options?: ClientRequestOptions,\n): PublicClient => {\n return hc<PublicRouter>(baseURL, options);\n};\n",
|
|
6
6
|
"import type { AppRouter } from \"@us-accounts/api\";\nimport { hc, type ClientRequestOptions } from \"hono/client\";\n\nexport type AppClient = ReturnType<typeof hc<AppRouter>>;\n\nexport const makeAppClient = (\n baseURL: string,\n options?: ClientRequestOptions,\n): AppClient => {\n return hc<AppRouter>(baseURL, {\n ...options,\n fetch: (url: any, init: any) =>\n (options?.fetch ?? fetch)(url, {\n ...init,\n credentials: \"include\",\n headers: {\n ...init.headers,\n \"Content-Type\": \"application/json\",\n },\n }),\n });\n};\n",
|
|
7
7
|
"import {\n customSessionClient,\n magicLinkClient,\n emailOTPClient,\n passkeyClient,\n} from \"better-auth/client/plugins\";\nimport { createAuthClient } from \"better-auth/react\";\nimport type { Auth } from \"@us-accounts/api\";\n\nexport const makeUsBetterAuthClient = (baseURL: string) => {\n return createAuthClient({\n baseURL,\n plugins: [\n customSessionClient<Auth>(),\n magicLinkClient(),\n emailOTPClient(),\n passkeyClient(),\n ],\n });\n};\n\nexport type AuthClient = ReturnType<typeof makeUsBetterAuthClient>;\n",
|
|
8
8
|
"import type { CheckoutRouter } from \"@us-accounts/api\";\nimport { hc, type ClientRequestOptions } from \"hono/client\";\n\nexport type CheckoutClient = ReturnType<typeof hc<CheckoutRouter>>;\n\nexport const makeCheckoutClient = (\n baseURL: string,\n options?: ClientRequestOptions,\n): CheckoutClient => {\n return hc<CheckoutRouter>(baseURL, {\n ...options,\n fetch: (url: any, init: any) =>\n (options?.fetch ?? fetch)(url, {\n ...init,\n credentials: \"include\",\n headers: {\n ...init.headers,\n \"Content-Type\": \"application/json\",\n },\n }),\n });\n};\n",
|
|
9
9
|
"import type { MailingListRouter } from \"@us-accounts/api\";\nimport { hc, type ClientRequestOptions } from \"hono/client\";\n\nexport type MailingListClient = ReturnType<typeof hc<MailingListRouter>>;\n\nexport const makeMailingListClient = (\n baseURL: string,\n publicKey: string,\n options?: ClientRequestOptions,\n): MailingListClient => {\n return hc<MailingListRouter>(baseURL, {\n ...options,\n headers: {\n ...options?.headers,\n \"X-Public-Key\": publicKey,\n },\n });\n};\n",
|
|
10
|
+
"import type { MailingListAdminRouter } from \"@us-accounts/api\";\nimport { hc, type ClientRequestOptions } from \"hono/client\";\n\nexport type MailingListAdminClient = ReturnType<\n typeof hc<MailingListAdminRouter>\n>;\n\nexport const makeMailingListAdminClient = (\n baseURL: string,\n apiKey: string,\n options?: ClientRequestOptions,\n): MailingListAdminClient => {\n return hc<MailingListAdminRouter>(baseURL, {\n ...options,\n headers: {\n ...options?.headers,\n \"X-API-Key\": apiKey,\n },\n });\n};\n",
|
|
10
11
|
"import type { CheckoutSearch, RedirectIntent } from \"@us-accounts/utils\";\n\nexport function makeLoginUrl(\n apiUrl: string,\n redirectUrl?: string,\n appName?: string,\n) {\n const url = new URL(\"/login\", apiUrl);\n if (redirectUrl) {\n url.searchParams.set(\"intent\", makeRedirectIntent(redirectUrl, appName));\n }\n return url.toString();\n}\n\nfunction noop(...args: any[]) {\n // Do nothing\n}\n\nexport function makeCheckoutUrl(\n apiUrl: string,\n priceId: string,\n productId: string,\n discountCode?: string,\n loginUrl?: string,\n pricingUrl?: string,\n successUrl?: string,\n) {\n const obj = {\n priceId,\n productId,\n discountCode,\n loginUrl,\n pricingUrl,\n successUrl,\n } satisfies CheckoutSearch;\n noop(obj);\n\n const url = new URL(\"/auth/checkout\", apiUrl);\n url.searchParams.set(\"priceId\", priceId);\n url.searchParams.set(\"productId\", productId);\n if (discountCode) {\n url.searchParams.set(\"discountCode\", discountCode);\n }\n if (loginUrl) {\n url.searchParams.set(\"loginUrl\", loginUrl);\n }\n if (pricingUrl) {\n url.searchParams.set(\"pricingUrl\", pricingUrl);\n }\n if (successUrl) {\n url.searchParams.set(\"successUrl\", successUrl);\n }\n return url.toString();\n}\n\nexport function makeRedirectIntent(\n redirectUrl: string,\n appName?: string,\n): string {\n const obj = {\n type: \"redirect\",\n redirectUrl,\n appName,\n } satisfies RedirectIntent;\n\n return JSON.stringify(obj);\n}\n",
|
|
11
12
|
"import { z } from \"zod\";\n\nexport const checkoutIntentSchema = z.object({\n type: z.literal(\"checkout\"),\n priceId: z.string(),\n productId: z.string(),\n discountCode: z.string().optional(),\n loginUrl: z.url().optional(),\n pricingUrl: z.url().optional(),\n successUrl: z.url().optional(),\n});\nexport type CheckoutIntent = z.infer<typeof checkoutIntentSchema>;\n\nexport const redirectIntentSchema = z.object({\n type: z.literal(\"redirect\"),\n redirectUrl: z.url(),\n appName: z.string().optional(),\n});\nexport type RedirectIntent = z.infer<typeof redirectIntentSchema>;\n\nexport const intentSchema = z.discriminatedUnion(\"type\", [\n checkoutIntentSchema,\n redirectIntentSchema,\n]);\nexport type Intent = z.infer<typeof intentSchema>;\n\nexport const intentSearchSchema = z.object({\n intent: intentSchema.optional(),\n});\n",
|
|
12
13
|
"import { z } from \"zod\";\n\nexport const checkoutSearchSchema = z.object({\n priceId: z.string(),\n productId: z.string(),\n discountCode: z.string().optional(),\n loginUrl: z.url().optional(),\n pricingUrl: z.url().optional(),\n successUrl: z.url().optional(),\n});\n\nexport type CheckoutSearch = z.infer<typeof checkoutSearchSchema>;\n",
|
|
13
14
|
"export function formatPrice(amountStr: string, currencyCode: string) {\n const amount = parseInt(amountStr);\n\n if (!amount || !currencyCode) return null;\n const formatter = new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: currencyCode,\n });\n\n const parts = formatter.formatToParts(amount);\n const fractionDigits =\n parts.find((part) => part.type === \"fraction\")?.value.length || 0;\n\n // Calculate the divisor based on decimal places\n const divisor = Math.pow(10, fractionDigits);\n\n return new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: currencyCode,\n }).format(amount / divisor);\n}\n"
|
|
14
15
|
],
|
|
15
|
-
"mappings": "
|
|
16
|
-
"debugId": "
|
|
16
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAC8C,IAA9C;AAIO,IAAM,mBAAmB,CAC9B,SACA,YACiB;AAAA,EACjB,OAAO,iBAAiB,SAAS,OAAO;AAAA;;ACRI,IAA9C;AAIO,IAAM,gBAAgB,CAC3B,SACA,YACc;AAAA,EACd,OAAO,kBAAc,SAAS;AAAA,OACzB;AAAA,IACH,OAAO,CAAC,KAAU,UACf,SAAS,SAAS,OAAO,KAAK;AAAA,SAC1B;AAAA,MACH,aAAa;AAAA,MACb,SAAS;AAAA,WACJ,KAAK;AAAA,QACR,gBAAgB;AAAA,MAClB;AAAA,IACF,CAAC;AAAA,EACL,CAAC;AAAA;;ACfI,IALP;AAMiC,IAAjC;AAGO,IAAM,yBAAyB,CAAC,YAAoB;AAAA,EACzD,OAAO,8BAAiB;AAAA,IACtB;AAAA,IACA,SAAS;AAAA,MACP,mCAA0B;AAAA,MAC1B,+BAAgB;AAAA,MAChB,8BAAe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AAM,uBAAuB,cAAE,OAAO;AAAA,EAC3C,SAAS,cAAE,OAAO;AAAA,EAClB,WAAW,cAAE,OAAO;AAAA,EACpB,cAAc,cAAE,OAAO,EAAE,SAAS;AAAA,EAClC,UAAU,cAAE,IAAI,EAAE,SAAS;AAAA,EAC3B,YAAY,cAAE,IAAI,EAAE,SAAS;AAAA,EAC7B,YAAY,cAAE,IAAI,EAAE,SAAS;AAC/B,CAAC;;ACTM,SAAS,WAAW,CAAC,WAAmB,cAAsB;AAAA,EACnE,MAAM,SAAS,SAAS,SAAS;AAAA,EAEjC,IAAI,CAAC,UAAU,CAAC;AAAA,IAAc,OAAO;AAAA,EACrC,MAAM,YAAY,IAAI,KAAK,aAAa,SAAS;AAAA,IAC/C,OAAO;AAAA,IACP,UAAU;AAAA,EACZ,CAAC;AAAA,EAED,MAAM,QAAQ,UAAU,cAAc,MAAM;AAAA,EAC5C,MAAM,iBACJ,MAAM,KAAK,CAAC,SAAS,KAAK,SAAS,UAAU,GAAG,MAAM,UAAU;AAAA,EAGlE,MAAM,UAAU,KAAK,IAAI,IAAI,cAAc;AAAA,EAE3C,OAAO,IAAI,KAAK,aAAa,SAAS;AAAA,IACpC,OAAO;AAAA,IACP,UAAU;AAAA,EACZ,CAAC,EAAE,OAAO,SAAS,OAAO;AAAA;",
|
|
17
|
+
"debugId": "2013C2F3B5BDF6CD64756E2164756E21",
|
|
17
18
|
"names": []
|
|
18
19
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -63,6 +63,17 @@ var makeMailingListClient = (baseURL, publicKey, options) => {
|
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
65
|
};
|
|
66
|
+
// src/clients/mailingListAdminClient.ts
|
|
67
|
+
import { hc as hc5 } from "hono/client";
|
|
68
|
+
var makeMailingListAdminClient = (baseURL, apiKey, options) => {
|
|
69
|
+
return hc5(baseURL, {
|
|
70
|
+
...options,
|
|
71
|
+
headers: {
|
|
72
|
+
...options?.headers,
|
|
73
|
+
"X-API-Key": apiKey
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
};
|
|
66
77
|
// src/utils/intent.ts
|
|
67
78
|
function makeLoginUrl(apiUrl, redirectUrl, appName) {
|
|
68
79
|
const url = new URL("/login", apiUrl);
|
|
@@ -162,6 +173,7 @@ export {
|
|
|
162
173
|
makeRedirectIntent,
|
|
163
174
|
makePublicClient,
|
|
164
175
|
makeMailingListClient,
|
|
176
|
+
makeMailingListAdminClient,
|
|
165
177
|
makeLoginUrl,
|
|
166
178
|
makeCheckoutUrl,
|
|
167
179
|
makeCheckoutClient,
|
|
@@ -169,5 +181,5 @@ export {
|
|
|
169
181
|
formatPrice
|
|
170
182
|
};
|
|
171
183
|
|
|
172
|
-
//# debugId=
|
|
184
|
+
//# debugId=CC5B6A629B049D6B64756E2164756E21
|
|
173
185
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/clients/publicClient.ts", "../../src/clients/appClient.ts", "../../src/clients/authClient.ts", "../../src/clients/checkoutClient.ts", "../../src/clients/mailingListClient.ts", "../../src/utils/intent.ts", "../../../utils/src/intent.ts", "../../../utils/src/checkout.ts", "../../../utils/src/price.ts"],
|
|
3
|
+
"sources": ["../../src/clients/publicClient.ts", "../../src/clients/appClient.ts", "../../src/clients/authClient.ts", "../../src/clients/checkoutClient.ts", "../../src/clients/mailingListClient.ts", "../../src/clients/mailingListAdminClient.ts", "../../src/utils/intent.ts", "../../../utils/src/intent.ts", "../../../utils/src/checkout.ts", "../../../utils/src/price.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import type { PublicRouter } from \"@us-accounts/api\";\nimport { hc, type ClientRequestOptions } from \"hono/client\";\n\nexport type PublicClient = ReturnType<typeof hc<PublicRouter>>;\n\nexport const makePublicClient = (\n baseURL: string,\n options?: ClientRequestOptions,\n): PublicClient => {\n return hc<PublicRouter>(baseURL, options);\n};\n",
|
|
6
6
|
"import type { AppRouter } from \"@us-accounts/api\";\nimport { hc, type ClientRequestOptions } from \"hono/client\";\n\nexport type AppClient = ReturnType<typeof hc<AppRouter>>;\n\nexport const makeAppClient = (\n baseURL: string,\n options?: ClientRequestOptions,\n): AppClient => {\n return hc<AppRouter>(baseURL, {\n ...options,\n fetch: (url: any, init: any) =>\n (options?.fetch ?? fetch)(url, {\n ...init,\n credentials: \"include\",\n headers: {\n ...init.headers,\n \"Content-Type\": \"application/json\",\n },\n }),\n });\n};\n",
|
|
7
7
|
"import {\n customSessionClient,\n magicLinkClient,\n emailOTPClient,\n passkeyClient,\n} from \"better-auth/client/plugins\";\nimport { createAuthClient } from \"better-auth/react\";\nimport type { Auth } from \"@us-accounts/api\";\n\nexport const makeUsBetterAuthClient = (baseURL: string) => {\n return createAuthClient({\n baseURL,\n plugins: [\n customSessionClient<Auth>(),\n magicLinkClient(),\n emailOTPClient(),\n passkeyClient(),\n ],\n });\n};\n\nexport type AuthClient = ReturnType<typeof makeUsBetterAuthClient>;\n",
|
|
8
8
|
"import type { CheckoutRouter } from \"@us-accounts/api\";\nimport { hc, type ClientRequestOptions } from \"hono/client\";\n\nexport type CheckoutClient = ReturnType<typeof hc<CheckoutRouter>>;\n\nexport const makeCheckoutClient = (\n baseURL: string,\n options?: ClientRequestOptions,\n): CheckoutClient => {\n return hc<CheckoutRouter>(baseURL, {\n ...options,\n fetch: (url: any, init: any) =>\n (options?.fetch ?? fetch)(url, {\n ...init,\n credentials: \"include\",\n headers: {\n ...init.headers,\n \"Content-Type\": \"application/json\",\n },\n }),\n });\n};\n",
|
|
9
9
|
"import type { MailingListRouter } from \"@us-accounts/api\";\nimport { hc, type ClientRequestOptions } from \"hono/client\";\n\nexport type MailingListClient = ReturnType<typeof hc<MailingListRouter>>;\n\nexport const makeMailingListClient = (\n baseURL: string,\n publicKey: string,\n options?: ClientRequestOptions,\n): MailingListClient => {\n return hc<MailingListRouter>(baseURL, {\n ...options,\n headers: {\n ...options?.headers,\n \"X-Public-Key\": publicKey,\n },\n });\n};\n",
|
|
10
|
+
"import type { MailingListAdminRouter } from \"@us-accounts/api\";\nimport { hc, type ClientRequestOptions } from \"hono/client\";\n\nexport type MailingListAdminClient = ReturnType<\n typeof hc<MailingListAdminRouter>\n>;\n\nexport const makeMailingListAdminClient = (\n baseURL: string,\n apiKey: string,\n options?: ClientRequestOptions,\n): MailingListAdminClient => {\n return hc<MailingListAdminRouter>(baseURL, {\n ...options,\n headers: {\n ...options?.headers,\n \"X-API-Key\": apiKey,\n },\n });\n};\n",
|
|
10
11
|
"import type { CheckoutSearch, RedirectIntent } from \"@us-accounts/utils\";\n\nexport function makeLoginUrl(\n apiUrl: string,\n redirectUrl?: string,\n appName?: string,\n) {\n const url = new URL(\"/login\", apiUrl);\n if (redirectUrl) {\n url.searchParams.set(\"intent\", makeRedirectIntent(redirectUrl, appName));\n }\n return url.toString();\n}\n\nfunction noop(...args: any[]) {\n // Do nothing\n}\n\nexport function makeCheckoutUrl(\n apiUrl: string,\n priceId: string,\n productId: string,\n discountCode?: string,\n loginUrl?: string,\n pricingUrl?: string,\n successUrl?: string,\n) {\n const obj = {\n priceId,\n productId,\n discountCode,\n loginUrl,\n pricingUrl,\n successUrl,\n } satisfies CheckoutSearch;\n noop(obj);\n\n const url = new URL(\"/auth/checkout\", apiUrl);\n url.searchParams.set(\"priceId\", priceId);\n url.searchParams.set(\"productId\", productId);\n if (discountCode) {\n url.searchParams.set(\"discountCode\", discountCode);\n }\n if (loginUrl) {\n url.searchParams.set(\"loginUrl\", loginUrl);\n }\n if (pricingUrl) {\n url.searchParams.set(\"pricingUrl\", pricingUrl);\n }\n if (successUrl) {\n url.searchParams.set(\"successUrl\", successUrl);\n }\n return url.toString();\n}\n\nexport function makeRedirectIntent(\n redirectUrl: string,\n appName?: string,\n): string {\n const obj = {\n type: \"redirect\",\n redirectUrl,\n appName,\n } satisfies RedirectIntent;\n\n return JSON.stringify(obj);\n}\n",
|
|
11
12
|
"import { z } from \"zod\";\n\nexport const checkoutIntentSchema = z.object({\n type: z.literal(\"checkout\"),\n priceId: z.string(),\n productId: z.string(),\n discountCode: z.string().optional(),\n loginUrl: z.url().optional(),\n pricingUrl: z.url().optional(),\n successUrl: z.url().optional(),\n});\nexport type CheckoutIntent = z.infer<typeof checkoutIntentSchema>;\n\nexport const redirectIntentSchema = z.object({\n type: z.literal(\"redirect\"),\n redirectUrl: z.url(),\n appName: z.string().optional(),\n});\nexport type RedirectIntent = z.infer<typeof redirectIntentSchema>;\n\nexport const intentSchema = z.discriminatedUnion(\"type\", [\n checkoutIntentSchema,\n redirectIntentSchema,\n]);\nexport type Intent = z.infer<typeof intentSchema>;\n\nexport const intentSearchSchema = z.object({\n intent: intentSchema.optional(),\n});\n",
|
|
12
13
|
"import { z } from \"zod\";\n\nexport const checkoutSearchSchema = z.object({\n priceId: z.string(),\n productId: z.string(),\n discountCode: z.string().optional(),\n loginUrl: z.url().optional(),\n pricingUrl: z.url().optional(),\n successUrl: z.url().optional(),\n});\n\nexport type CheckoutSearch = z.infer<typeof checkoutSearchSchema>;\n",
|
|
13
14
|
"export function formatPrice(amountStr: string, currencyCode: string) {\n const amount = parseInt(amountStr);\n\n if (!amount || !currencyCode) return null;\n const formatter = new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: currencyCode,\n });\n\n const parts = formatter.formatToParts(amount);\n const fractionDigits =\n parts.find((part) => part.type === \"fraction\")?.value.length || 0;\n\n // Calculate the divisor based on decimal places\n const divisor = Math.pow(10, fractionDigits);\n\n return new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: currencyCode,\n }).format(amount / divisor);\n}\n"
|
|
14
15
|
],
|
|
15
|
-
"mappings": ";AACA;AAIO,IAAM,mBAAmB,CAC9B,SACA,YACiB;AAAA,EACjB,OAAO,GAAiB,SAAS,OAAO;AAAA;;ACR1C,eAAS;AAIF,IAAM,gBAAgB,CAC3B,SACA,YACc;AAAA,E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,7 +94,7 @@ declare const appRouter: hono_hono_base.HonoBase<{
|
|
|
94
94
|
input: {
|
|
95
95
|
param: {
|
|
96
96
|
subscriptionId: string;
|
|
97
|
-
action: "
|
|
97
|
+
action: "update" | "cancel";
|
|
98
98
|
};
|
|
99
99
|
};
|
|
100
100
|
output: undefined;
|
|
@@ -268,9 +268,9 @@ declare const mailingListRouter: hono_hono_base.HonoBase<hono_types.BlankEnv, {
|
|
|
268
268
|
callbackUrl: string;
|
|
269
269
|
};
|
|
270
270
|
};
|
|
271
|
-
output: "
|
|
271
|
+
output: "Could not send email";
|
|
272
272
|
outputFormat: "text";
|
|
273
|
-
status:
|
|
273
|
+
status: 500;
|
|
274
274
|
} | {
|
|
275
275
|
input: {
|
|
276
276
|
json: {
|
|
@@ -279,9 +279,9 @@ declare const mailingListRouter: hono_hono_base.HonoBase<hono_types.BlankEnv, {
|
|
|
279
279
|
callbackUrl: string;
|
|
280
280
|
};
|
|
281
281
|
};
|
|
282
|
-
output: "
|
|
282
|
+
output: "Contact already subscribed";
|
|
283
283
|
outputFormat: "text";
|
|
284
|
-
status:
|
|
284
|
+
status: 400;
|
|
285
285
|
} | {
|
|
286
286
|
input: {
|
|
287
287
|
json: {
|
|
@@ -290,9 +290,9 @@ declare const mailingListRouter: hono_hono_base.HonoBase<hono_types.BlankEnv, {
|
|
|
290
290
|
callbackUrl: string;
|
|
291
291
|
};
|
|
292
292
|
};
|
|
293
|
-
output: "
|
|
293
|
+
output: "Success";
|
|
294
294
|
outputFormat: "text";
|
|
295
|
-
status:
|
|
295
|
+
status: 200;
|
|
296
296
|
};
|
|
297
297
|
};
|
|
298
298
|
} & {
|
|
@@ -304,9 +304,9 @@ declare const mailingListRouter: hono_hono_base.HonoBase<hono_types.BlankEnv, {
|
|
|
304
304
|
email: string;
|
|
305
305
|
};
|
|
306
306
|
};
|
|
307
|
-
output:
|
|
308
|
-
outputFormat: "
|
|
309
|
-
status:
|
|
307
|
+
output: "Invalid opt-in token";
|
|
308
|
+
outputFormat: "text";
|
|
309
|
+
status: 400;
|
|
310
310
|
} | {
|
|
311
311
|
input: {
|
|
312
312
|
query: {
|
|
@@ -314,7 +314,7 @@ declare const mailingListRouter: hono_hono_base.HonoBase<hono_types.BlankEnv, {
|
|
|
314
314
|
email: string;
|
|
315
315
|
};
|
|
316
316
|
};
|
|
317
|
-
output: "
|
|
317
|
+
output: "Contact does not exist";
|
|
318
318
|
outputFormat: "text";
|
|
319
319
|
status: 400;
|
|
320
320
|
} | {
|
|
@@ -324,9 +324,9 @@ declare const mailingListRouter: hono_hono_base.HonoBase<hono_types.BlankEnv, {
|
|
|
324
324
|
email: string;
|
|
325
325
|
};
|
|
326
326
|
};
|
|
327
|
-
output: "
|
|
327
|
+
output: "Could not opt in contact";
|
|
328
328
|
outputFormat: "text";
|
|
329
|
-
status:
|
|
329
|
+
status: 500;
|
|
330
330
|
} | {
|
|
331
331
|
input: {
|
|
332
332
|
query: {
|
|
@@ -334,9 +334,9 @@ declare const mailingListRouter: hono_hono_base.HonoBase<hono_types.BlankEnv, {
|
|
|
334
334
|
email: string;
|
|
335
335
|
};
|
|
336
336
|
};
|
|
337
|
-
output:
|
|
338
|
-
outputFormat: "
|
|
339
|
-
status:
|
|
337
|
+
output: undefined;
|
|
338
|
+
outputFormat: "redirect";
|
|
339
|
+
status: 302;
|
|
340
340
|
};
|
|
341
341
|
};
|
|
342
342
|
} & {
|
|
@@ -355,6 +355,54 @@ declare const mailingListRouter: hono_hono_base.HonoBase<hono_types.BlankEnv, {
|
|
|
355
355
|
}, "/">;
|
|
356
356
|
type MailingListRouter = typeof mailingListRouter;
|
|
357
357
|
|
|
358
|
+
declare const mailingListAdminRouter: hono_hono_base.HonoBase<{}, {
|
|
359
|
+
"/exists": {
|
|
360
|
+
$get: {
|
|
361
|
+
input: {
|
|
362
|
+
query: {
|
|
363
|
+
email: string;
|
|
364
|
+
};
|
|
365
|
+
};
|
|
366
|
+
output: {
|
|
367
|
+
exists: boolean;
|
|
368
|
+
};
|
|
369
|
+
outputFormat: "json";
|
|
370
|
+
status: hono_utils_http_status.ContentfulStatusCode;
|
|
371
|
+
};
|
|
372
|
+
};
|
|
373
|
+
} & {
|
|
374
|
+
"/subscribe": {
|
|
375
|
+
$post: {
|
|
376
|
+
input: {
|
|
377
|
+
json: {
|
|
378
|
+
email: string;
|
|
379
|
+
};
|
|
380
|
+
};
|
|
381
|
+
output: {
|
|
382
|
+
success: true;
|
|
383
|
+
};
|
|
384
|
+
outputFormat: "json";
|
|
385
|
+
status: hono_utils_http_status.ContentfulStatusCode;
|
|
386
|
+
};
|
|
387
|
+
};
|
|
388
|
+
} & {
|
|
389
|
+
"/unsubscribe": {
|
|
390
|
+
$post: {
|
|
391
|
+
input: {
|
|
392
|
+
json: {
|
|
393
|
+
email: string;
|
|
394
|
+
};
|
|
395
|
+
};
|
|
396
|
+
output: {
|
|
397
|
+
success: true;
|
|
398
|
+
};
|
|
399
|
+
outputFormat: "json";
|
|
400
|
+
status: hono_utils_http_status.ContentfulStatusCode;
|
|
401
|
+
};
|
|
402
|
+
};
|
|
403
|
+
}, "/">;
|
|
404
|
+
type MailingListAdminRouter = typeof mailingListAdminRouter;
|
|
405
|
+
|
|
358
406
|
type PublicClient = ReturnType<typeof hc<PublicRouter>>;
|
|
359
407
|
declare const makePublicClient: (baseURL: string, options?: ClientRequestOptions) => PublicClient;
|
|
360
408
|
|
|
@@ -3545,11 +3593,14 @@ declare const makeCheckoutClient: (baseURL: string, options?: ClientRequestOptio
|
|
|
3545
3593
|
type MailingListClient = ReturnType<typeof hc<MailingListRouter>>;
|
|
3546
3594
|
declare const makeMailingListClient: (baseURL: string, publicKey: string, options?: ClientRequestOptions) => MailingListClient;
|
|
3547
3595
|
|
|
3596
|
+
type MailingListAdminClient = ReturnType<typeof hc<MailingListAdminRouter>>;
|
|
3597
|
+
declare const makeMailingListAdminClient: (baseURL: string, apiKey: string, options?: ClientRequestOptions) => MailingListAdminClient;
|
|
3598
|
+
|
|
3548
3599
|
declare function makeLoginUrl(apiUrl: string, redirectUrl?: string, appName?: string): string;
|
|
3549
3600
|
declare function makeCheckoutUrl(apiUrl: string, priceId: string, productId: string, discountCode?: string, loginUrl?: string, pricingUrl?: string, successUrl?: string): string;
|
|
3550
3601
|
declare function makeRedirectIntent(redirectUrl: string, appName?: string): string;
|
|
3551
3602
|
|
|
3552
3603
|
declare function formatPrice(amountStr: string, currencyCode: string): string | null;
|
|
3553
3604
|
|
|
3554
|
-
export { formatPrice, makeAppClient, makeCheckoutClient, makeCheckoutUrl, makeLoginUrl, makeMailingListClient, makePublicClient, makeRedirectIntent, makeUsBetterAuthClient };
|
|
3555
|
-
export type { AppClient, AuthClient, CheckoutClient, MailingListClient, PublicClient };
|
|
3605
|
+
export { formatPrice, makeAppClient, makeCheckoutClient, makeCheckoutUrl, makeLoginUrl, makeMailingListAdminClient, makeMailingListClient, makePublicClient, makeRedirectIntent, makeUsBetterAuthClient };
|
|
3606
|
+
export type { AppClient, AuthClient, CheckoutClient, MailingListAdminClient, MailingListClient, PublicClient };
|