Skip to content

Commit 5ea46d0

Browse files
KingDoxikvoidhash-bot
authored andcommitted
Merge pull request #280 from voidhashcom/t3code/implement-development-mode-e2e
feat: add end-to-end development purchase mode GitOrigin-RevId: bec5d3b28b4c92c625eae4b91e258fd56af9b4ea
1 parent c1e523d commit 5ea46d0

103 files changed

Lines changed: 12198 additions & 3031 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/cli/src/domain/schema/normalized-schema.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ export type ProductProviderConfig = typeof ProductProviderConfigSchema.Type;
3232
// ========================================================
3333

3434
export const NormalizedProductSchema = Schema.Struct({
35+
duration: Schema.NullOr(
36+
Schema.Literals(["weekly", "monthly", "quarterly", "semi-annual", "annual"]),
37+
),
3538
name: Schema.String,
3639
perks: Schema.Array(Schema.String), // perk slugs
3740
providers: Schema.Array(ProductProviderConfigSchema),
@@ -91,6 +94,7 @@ export function createInitialNormalizedSchema(): NormalizedSchema {
9194
"monthly_sub",
9295
{
9396
slug: "monthly_sub",
97+
duration: "monthly",
9498
name: "Monthly",
9599
type: "subscription",
96100
perks: ["all-access"],
@@ -101,6 +105,7 @@ export function createInitialNormalizedSchema(): NormalizedSchema {
101105
"yearly_sub",
102106
{
103107
slug: "yearly_sub",
108+
duration: "annual",
104109
name: "Yearly",
105110
type: "subscription",
106111
perks: ["all-access"],

apps/cli/src/domain/services/codegen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ const make = Effect.gen(function* effect() {
9494
" * Use it like `<voidhash.Provider>` and `voidhash.useProducts()`. The",
9595
" * publishable key is safe to ship in client code.",
9696
" */",
97-
`export const voidhash = createVoidhashClient("${options.publishableKey}");`,
97+
`export const voidhash = createVoidhashClient("${options.publishableKey}", { dev: true });`,
9898
"",
9999
];
100100
yield* fileSystem.writeFileString(filePath, lines.join("\n"));

apps/cli/src/domain/services/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ const make = Effect.gen(function* effect() {
5252
});
5353
}
5454

55-
5655
for (const product of response.products) {
5756
schema.products.set(product.slug, {
57+
duration: product.duration,
5858
name: product.name,
5959
perks: [...product.perks],
6060
providers: product.providers.flatMap((provider) => {

apps/cli/tests/domain/schema/normalized-schema.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ describe("createEmptyNormalizedSchema", () => {
4141
});
4242
schema.perks.set("test-perk", { slug: "test-perk", name: "Test Perk" });
4343
schema.products.set("test-product", {
44+
duration: "monthly",
4445
slug: "test-product",
4546
name: "Test Product",
4647
type: "subscription",

docs/security/endpoint-authorization-matrix.md

Lines changed: 87 additions & 82 deletions
Large diffs are not rendered by default.

examples/react-native-example/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ APP_ENV=production
33
EXPO_PUBLIC_VOIDHASH_PUBLISHABLE_KEY=vh_pk_your_publishable_key
44
# Optional explicit API URL override (e.g. http://192.168.1.100:5001)
55
EXPO_PUBLIC_VOIDHASH_API_URL=http://localhost:8787
6+
EXPO_PUBLIC_VOIDHASH_DEV=true

examples/react-native-example/utils/voidhash/client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const resolveExampleApiUrl = (baseUrl: string) => {
4242
// `process.env.EXPO_PUBLIC_*` must stay a literal member expression: Expo's Babel
4343
// plugin inlines it at build time, so it cannot be read through Effect's Config.
4444
const configuredApiUrl = process.env.EXPO_PUBLIC_VOIDHASH_API_URL;
45+
const devEnabled = process.env.EXPO_PUBLIC_VOIDHASH_DEV !== "false";
4546

4647
const resolveConfiguredApiUrl = () => {
4748
if (!configuredApiUrl) return undefined;
@@ -63,5 +64,6 @@ const baseUrlOption = (): { baseUrl?: string } => {
6364
*/
6465
export const voidhash = createVoidhashClient("vh_pk_QrGDcbcCbCcWHjOouLZipyEBoBrDKoAb", {
6566
debug: true,
67+
dev: devEnabled,
6668
...baseUrlOption(),
6769
});

libraries/node/src/generated/grouped-client.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ export const groupCoreClient = (client: VoidhashCoreClient) => ({
1616
auth: {
1717
session: () => client.authSession(),
1818
},
19+
notifications: {
20+
sendNotification: (request: {
21+
payload: Parameters<VoidhashCoreClient["notificationsSendNotification"]>[0];
22+
}) => client.notificationsSendNotification(request.payload),
23+
},
1924
organizations: {
2025
createOrganization: (request: {
2126
payload: Parameters<VoidhashCoreClient["organizationsCreateOrganization"]>[0];
@@ -28,6 +33,17 @@ export const groupCoreClient = (client: VoidhashCoreClient) => ({
2833
paymentProviderProducts: {
2934
listPaymentProviderProducts: () => client.paymentProviderProductsListPaymentProviderProducts(),
3035
},
36+
paywallDeploys: {
37+
createDeploy: (request: {
38+
payload: Parameters<VoidhashCoreClient["paywallDeploysCreateDeploy"]>[0];
39+
}) => client.paywallDeploysCreateDeploy(request.payload),
40+
finalizeDeploy: (request: { params: { readonly deployId: string } }) =>
41+
client.paywallDeploysFinalizeDeploy(request.params["deployId"]),
42+
uploadBlob: (request: {
43+
params: Parameters<VoidhashCoreClient["paywallDeploysUploadBlob"]>[0];
44+
payload: Parameters<VoidhashCoreClient["paywallDeploysUploadBlob"]>[1];
45+
}) => client.paywallDeploysUploadBlob(request.params, request.payload),
46+
},
3147
paywallLocations: {
3248
listPaywallLocations: () => client.paywallLocationsListPaywallLocations(),
3349
},

libraries/node/tests/client.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ import { createJsonResponse, decodeJson, installFetchMock } from "./helpers";
1515
const EXPECTED_GROUPS = [
1616
"apiKeys",
1717
"auth",
18+
"notifications",
1819
"organizations",
1920
"paymentProviderConfigurations",
2021
"paymentProviderProducts",
22+
"paywallDeploys",
2123
"paywallLocations",
2224
"perks",
2325
"persons",
@@ -380,7 +382,7 @@ describe("@voidhash/node", () => {
380382
_tag: tagOf(effectError),
381383
});
382384
expect(promiseError).toMatchObject({
383-
_tag: "ApiActionForbiddenError",
385+
_tag: "ApiActionForbiddenErrorJsonEncoding",
384386
});
385387
}),
386388
));

libraries/react-native/src/client-react-native.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { purchaseHookFactory } from "./react/hooks/use-purchase";
2828
export function createVoidhashClient(publishableKey: string, options: VoidhashClientOptions = {}) {
2929
const baseUrl = options.baseUrl || "https://api.voidhash.com";
3030
const debug = options.debug ?? false;
31+
const dev = options.dev ?? false;
3132
const distinctId = options.distinctId ?? null;
3233
const ingestUrl = options.ingestUrl;
3334
const readOnly = options.readOnly ?? false;
@@ -57,6 +58,7 @@ export function createVoidhashClient(publishableKey: string, options: VoidhashCl
5758
platform,
5859
debug,
5960
options.unstable_internalSchema,
61+
dev,
6062
);
6163

6264
const { provider, context, useVoidhash } = voidhashProviderFactory(client);

0 commit comments

Comments
 (0)