create-disposabl-app 0.19.8 → 0.20.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/disposabl.js +1 -1
- package/dist/index.js +1 -1
- package/dist/templates/default/packages/backend/convex/revenuecat.ts +1 -0
- package/dist/templates/default/packages/disposabl-kit/PAYMENTS.md +10 -0
- package/dist/templates/default/packages/disposabl-kit/server/billing-handoff.ts +10 -2
- package/dist/templates/default/packages/disposabl-kit/server/revenuecat-functions.ts +32 -2
- package/dist/templates/default/packages/disposabl-kit/server/revenuecat-validator.ts +1 -0
- package/dist/templates/default/packages/tests/README.md +4 -0
- package/dist/templates/default/packages/tests/billing-handoff.test.ts +51 -1
- package/dist/templates/default/packages/tests/revenuecat-inbox.test.ts +88 -0
- package/package.json +1 -1
package/dist/disposabl.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1563,7 +1563,7 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
|
1563
1563
|
import { Command, CommanderError } from "commander";
|
|
1564
1564
|
import * as p2 from "@clack/prompts";
|
|
1565
1565
|
// package.json
|
|
1566
|
-
var version = "0.
|
|
1566
|
+
var version = "0.20.1";
|
|
1567
1567
|
|
|
1568
1568
|
// ../cli/telemetry.ts
|
|
1569
1569
|
var import_proper_lockfile2 = __toESM(require_proper_lockfile(), 1);
|
|
@@ -62,6 +62,16 @@ A cancellation before dispatch creates a local tombstone; a later purchase canno
|
|
|
62
62
|
|
|
63
63
|
Operators can inspect private `revenuecat:inspect` by state and `revenuecat:inspectTransfers` and `revenuecat:inspectConflicts`. `revenuecat:confirmUnknown` records a provider-confirmed grant or refund with a nonsecret evidence reference, without issuing another write. An aggregate customer balance alone is not proof of an individual operation. There is no automatic reissue of a failed or uncertain dispatch. For an existing queued grant, `revenuecat:redispatchQueued` accepts the exact balance, route and customer, and schedules dispatch only if the customer exists and no active transfer holds remain. Dispatch rechecks current configuration and claim state, customer and holds; a later transfer can still block it. Unknown, refund and review states are not redispatched by this tool.
|
|
64
64
|
|
|
65
|
+
### Recover a queued native purchase after payments are re-enabled
|
|
66
|
+
|
|
67
|
+
A worker scheduled while payments were on can run after a payments-off deployment. It returns without claiming the purchase, leaving it `queued`. Re-enabling payments does not reschedule it. Webhooks rejected while payments were off are a separate missed-delivery problem; this procedure only covers an already persisted purchase. Use it only on a deployment that has the internal `revenuecat:redispatchQueued` operation; the published 0.19.6 behavior alone does not establish that this operator operation is available.
|
|
68
|
+
|
|
69
|
+
1. Identify the exact deployment and verify that payments are enabled in its deployed configuration, its custom owner and routes match the original project, app, environment, store and product, and its Autumn key targets the intended organization and environment. Confirm the custom product is not also managed by another integration. Restore the correct configuration before scheduling anything.
|
|
70
|
+
2. From the deployment's backend directory, inspect queued purchases with the appropriate explicit target. For example, use `bun x --no-install convex run --preview-name <channel> revenuecat:inspect '{"state":"queued"}'` for a preview, or replace `--preview-name <channel>` with `--prod` for production. The query returns at most 100 rows, so it is not a complete inventory when the limit is reached. Establish the affected purchase and its stored `balanceId`, `project`, `app`, `environment`, `store`, `product`, and `customer` from trusted records. Investigate conflicts and transfers with `revenuecat:inspectConflicts '{}'` and `revenuecat:inspectTransfers '{}'` on the same target; each is also limited to 100 rows. A missing item in those results is not proof of no conflict or hold.
|
|
71
|
+
3. Verify the purchase and owner against provider records and review any cancellation, transfer or uncertain write before acting. Do not change or delete history, release holds, or retry unknown/refund/review states. A `grant_unknown` requires provider-specific evidence and `revenuecat:confirmUnknown` when a grant is confirmed; an aggregate balance alone is insufficient. Retain transfer holds until a separate release policy is established.
|
|
72
|
+
4. For each verified eligible row, invoke the internal mutation on that same target with the exact stored values, e.g. `bun x --no-install convex run --preview-name <channel> revenuecat:redispatchQueued '{"balanceId":"<balanceId>","project":"<project>","app":"<app>","environment":"<environment>","store":"<store>","product":"<product>","customer":"<customer>"}'`. A `true` result means only that dispatch was scheduled; `false` means the row or scope did not qualify. The mutation rejects pending review/refund flags, active holds, missing customers, mismatched scope and non-queued states. Dispatch independently rechecks configuration, route, customer, hold and claim state, so a later change may still block it.
|
|
73
|
+
5. Inspect the resulting state and corroborate the individual operation with provider records. `granted` reflects a successful response; `grant_unknown` requires reconciliation, not another grant. A row still `queued` needs investigation of configuration, holds and customer before any further targeted scheduling. Preserve the evidence and do not treat scheduling as proof of credit. No provider exactly-once guarantee or automatic recovery is implied.
|
|
74
|
+
|
|
65
75
|
Private `revenuecat:recordTransferReview` records a `retain_hold` decision, a nonsecret provider evidence reference and review time against an exact transfer scope and its original from/to lists. Repeating the same decision is idempotent; conflicting evidence or scope is rejected. It does not release holds, resolve purchase states, transfer ownership, or move balances. The remaining policy question is what provider evidence and account-ownership conditions make every affected queued grant safe for its stored customer after a transfer; until that is defined and verified, keep the holds.
|
|
66
76
|
|
|
67
77
|
Autumn documents a caller-supplied `balance_id`, not its atomic uniqueness and retry semantics. This code does not claim exactly-once behavior across providers. Before enabling or offering the consumable, verify stable ID behavior and balance targeting, event ownership, concurrent delivery, response loss, crashes, refunds and partial refunds in isolated Apple and Google sandboxes; establish a documented provider reconciliation contract and a missed-webhook process. A successful local test or a callback does not prove a purchase or provider write. Native product IDs, pricing, RevenueCat offerings and both stores still need verification; do not set the verification flag until those checks pass. A store purchase remains pending until the authoritative Autumn balance updates; the app never grants credits locally.
|
|
@@ -102,7 +102,10 @@ export const createHandoff = (eligibility?: BillingEligibility) =>
|
|
|
102
102
|
},
|
|
103
103
|
});
|
|
104
104
|
export const create = createHandoff();
|
|
105
|
-
export const inspectHandoff = (
|
|
105
|
+
export const inspectHandoff = (
|
|
106
|
+
eligibility?: BillingEligibility,
|
|
107
|
+
enabled = paymentsEnabled,
|
|
108
|
+
) =>
|
|
106
109
|
query({
|
|
107
110
|
args: { code: v.string() },
|
|
108
111
|
returns: v.union(
|
|
@@ -110,6 +113,7 @@ export const inspectHandoff = (eligibility?: BillingEligibility) =>
|
|
|
110
113
|
v.object({ name: v.union(v.string(), v.null()) }),
|
|
111
114
|
),
|
|
112
115
|
handler: async (ctx, { code }) => {
|
|
116
|
+
if (!enabled) return null;
|
|
113
117
|
try {
|
|
114
118
|
const row = await lookup(ctx, code);
|
|
115
119
|
await eligibility?.(ctx, row.userId);
|
|
@@ -137,7 +141,10 @@ export const inspectHandoff = (eligibility?: BillingEligibility) =>
|
|
|
137
141
|
},
|
|
138
142
|
});
|
|
139
143
|
export const inspect = inspectHandoff();
|
|
140
|
-
export const redeemHandoff = (
|
|
144
|
+
export const redeemHandoff = (
|
|
145
|
+
eligibility?: BillingEligibility,
|
|
146
|
+
enabled = paymentsEnabled,
|
|
147
|
+
) =>
|
|
141
148
|
mutation({
|
|
142
149
|
args: { code: v.string() },
|
|
143
150
|
returns: v.object({
|
|
@@ -150,6 +157,7 @@ export const redeemHandoff = (eligibility?: BillingEligibility) =>
|
|
|
150
157
|
returnClaim: v.union(v.string(), v.null()),
|
|
151
158
|
}),
|
|
152
159
|
handler: async (ctx, { code }) => {
|
|
160
|
+
if (!enabled) throw new ConvexError("Website checkout is unavailable.");
|
|
153
161
|
const row = await lookup(ctx, code);
|
|
154
162
|
await eligibility?.(ctx, row.userId);
|
|
155
163
|
const tokens = await exchangeBrowserSession(
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
docValidator,
|
|
3
|
+
httpActionGeneric,
|
|
4
|
+
makeFunctionReference,
|
|
5
|
+
paginationOptsValidator,
|
|
6
|
+
paginationResultValidator,
|
|
7
|
+
} from "convex/server";
|
|
2
8
|
import { v } from "convex/values";
|
|
3
9
|
import {
|
|
4
10
|
internalAction,
|
|
@@ -19,7 +25,10 @@ import {
|
|
|
19
25
|
type PurchaseEvent,
|
|
20
26
|
type RevenueCatConfig,
|
|
21
27
|
} from "./revenuecat-contract";
|
|
22
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
purchaseEventFields,
|
|
30
|
+
revenueCatDeliveries,
|
|
31
|
+
} from "./revenuecat-validator";
|
|
23
32
|
|
|
24
33
|
const receiveRef = makeFunctionReference<
|
|
25
34
|
"mutation",
|
|
@@ -240,6 +249,27 @@ export const inspectConflicts = internalQuery({
|
|
|
240
249
|
.take(100),
|
|
241
250
|
});
|
|
242
251
|
|
|
252
|
+
// Historical delivery archive, not a queue of unresolved reviews.
|
|
253
|
+
export const inspectReviewDeliveries = internalQuery({
|
|
254
|
+
args: { paginationOpts: paginationOptsValidator },
|
|
255
|
+
returns: paginationResultValidator(
|
|
256
|
+
docValidator("revenueCatDeliveries", revenueCatDeliveries),
|
|
257
|
+
),
|
|
258
|
+
handler: async (ctx, { paginationOpts }) => {
|
|
259
|
+
if (
|
|
260
|
+
!Number.isInteger(paginationOpts.numItems) ||
|
|
261
|
+
paginationOpts.numItems < 1 ||
|
|
262
|
+
paginationOpts.numItems > 100
|
|
263
|
+
)
|
|
264
|
+
throw new Error("Page size must be between 1 and 100");
|
|
265
|
+
return ctx.db
|
|
266
|
+
.query("revenueCatDeliveries")
|
|
267
|
+
.withIndex("by_type", (q) => q.eq("type", "review"))
|
|
268
|
+
.order("desc")
|
|
269
|
+
.paginate(paginationOpts);
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
|
|
243
273
|
export const receive = internalMutation({
|
|
244
274
|
args: { event: v.object(purchaseEventFields), balanceId: v.string() },
|
|
245
275
|
returns: v.string(),
|
|
@@ -22,6 +22,7 @@ export const revenueCatDeliveries = defineTable({
|
|
|
22
22
|
conflict: v.boolean(),
|
|
23
23
|
})
|
|
24
24
|
.index("by_delivery", ["project", "app", "environment", "deliveryId"])
|
|
25
|
+
.index("by_type", ["type"])
|
|
25
26
|
.index("by_conflict", ["conflict"]);
|
|
26
27
|
export const revenueCatPurchases = defineTable({
|
|
27
28
|
balanceId: v.string(),
|
|
@@ -29,6 +29,10 @@ The storage fallback flow (`flows/files.e2e.ts`) uses the same loopback/admin re
|
|
|
29
29
|
|
|
30
30
|
The connections browser flow additionally exercises invalid Autumn key submission when `E2E_CONNECTIONS_ENABLED=1`. Set a temporary `CONNECTIONS_ENCRYPTION_KEY` on the isolated backend for that run; the invalid input is rejected before any Autumn request. Restore the backend setting afterward.
|
|
31
31
|
|
|
32
|
+
## Published CLI OAuth qualification
|
|
33
|
+
|
|
34
|
+
The opt-in `cli-oauth.e2e.ts` flow defaults to a locally bundled CLI. To qualify a previously verified installed artifact, set `E2E_CLI_EXECUTABLE` to its absolute exported executable path and `E2E_CLI_OAUTH=1`, and use an owned fresh backend on 3530/3531 with `E2E_SDK_OWNERSHIP_FILE` as described in `helpers/sdk-auth/README.md`. The executable receives the loopback `DISPOSABL_API_ORIGIN` and a private credential directory. The caller must supervise the isolated web server, enforce outbound isolation and telemetry settings, verify artifact provenance and bytes, and ensure resources are free and exclusively owned. The flow launches login with `--no-browser`, checks the actual loopback callback binding, owner and release, and uses the consent UI. It checks logout and rejection of the revoked token; it does not test expiry or independently invalid tokens. Do not run this against shared or production infrastructure.
|
|
35
|
+
|
|
32
36
|
## Email provider verification
|
|
33
37
|
|
|
34
38
|
`bun run e2e run email-delivery.e2e.ts --target backend --retries 0` tests signup, email verification, a new login, and the verified account. It requires an isolated loopback backend configured with `RESEND_API_KEY` and `RESEND_FROM_EMAIL`, plus `E2E_RESEND_API_KEY` for reading the test message. This explicit provider test sends to a unique `delivered+…@resend.dev` address and polls Resend for that message and consumes one email from the sending quota. It never sends to a person. It skips when the test credential is absent. Keep credentials in the process environment and restore the backend configuration after this run before running username-based fixtures.
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { test } from "node:test";
|
|
2
2
|
import assert from "node:assert/strict";
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
redeemHandoff,
|
|
5
|
+
inspectHandoff,
|
|
5
6
|
cleanup,
|
|
6
7
|
returnTarget,
|
|
7
8
|
} from "../disposabl-kit/server/billing-handoff";
|
|
8
9
|
|
|
10
|
+
const redeem = redeemHandoff(undefined, true);
|
|
11
|
+
|
|
9
12
|
test("billing handoff expires and a redeemed link cannot be replayed", async () => {
|
|
10
13
|
let row: any = {
|
|
11
14
|
_id: "one",
|
|
@@ -181,3 +184,50 @@ test("return target is bound to a redeemed browser session and an allowlisted ch
|
|
|
181
184
|
else process.env.BILLING_IOS_RETURN_CHANNELS = previous;
|
|
182
185
|
}
|
|
183
186
|
});
|
|
187
|
+
|
|
188
|
+
test("disabled payments preserve existing handoffs without identity reads or session exchange", async () => {
|
|
189
|
+
const row = {
|
|
190
|
+
_id: "retained",
|
|
191
|
+
userId: "alice",
|
|
192
|
+
sessionId: "source",
|
|
193
|
+
purchase: "topup",
|
|
194
|
+
expiresAt: Date.now() + 120_000,
|
|
195
|
+
};
|
|
196
|
+
const original = structuredClone(row);
|
|
197
|
+
let reads = 0;
|
|
198
|
+
let exchanges = 0;
|
|
199
|
+
let writes = 0;
|
|
200
|
+
const ctx = {
|
|
201
|
+
db: {
|
|
202
|
+
query: () => {
|
|
203
|
+
reads++;
|
|
204
|
+
return { withIndex: () => ({ unique: async () => row }) };
|
|
205
|
+
},
|
|
206
|
+
normalizeId: () => null,
|
|
207
|
+
delete: async () => {
|
|
208
|
+
writes++;
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
runQuery: async () => {
|
|
212
|
+
reads++;
|
|
213
|
+
return { userId: "alice" };
|
|
214
|
+
},
|
|
215
|
+
runMutation: async () => {
|
|
216
|
+
exchanges++;
|
|
217
|
+
return { userId: "alice" };
|
|
218
|
+
},
|
|
219
|
+
};
|
|
220
|
+
const code = "Q".repeat(43);
|
|
221
|
+
const inspectOff = inspectHandoff(undefined, false) as any;
|
|
222
|
+
const redeemOff = redeemHandoff(undefined, false) as any;
|
|
223
|
+
assert.equal(await inspectOff._handler(ctx, { code }), null);
|
|
224
|
+
await assert.rejects(redeemOff._handler(ctx, { code }), /unavailable/);
|
|
225
|
+
assert.deepEqual(
|
|
226
|
+
{ reads, exchanges, writes },
|
|
227
|
+
{ reads: 0, exchanges: 0, writes: 0 },
|
|
228
|
+
);
|
|
229
|
+
assert.deepEqual(row, original);
|
|
230
|
+
await (redeem as any)._handler(ctx, { code });
|
|
231
|
+
assert.equal(exchanges, 1);
|
|
232
|
+
assert.equal(writes, 1);
|
|
233
|
+
});
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
dispatchBalance,
|
|
25
25
|
dispatch,
|
|
26
26
|
routing,
|
|
27
|
+
inspectReviewDeliveries,
|
|
27
28
|
} from "../disposabl-kit/server/revenuecat-functions";
|
|
28
29
|
|
|
29
30
|
import { creditQuantity } from "../disposabl-kit/payments/config";
|
|
@@ -78,6 +79,27 @@ function fixture() {
|
|
|
78
79
|
};
|
|
79
80
|
filter(q);
|
|
80
81
|
return {
|
|
82
|
+
order: (direction: string) => ({
|
|
83
|
+
paginate: async (opts: {
|
|
84
|
+
cursor: string | null;
|
|
85
|
+
numItems: number;
|
|
86
|
+
}) => {
|
|
87
|
+
assert.equal(_index, "by_type");
|
|
88
|
+
assert.equal(direction, "desc");
|
|
89
|
+
const rows = tables[table]!.filter((row) =>
|
|
90
|
+
Object.entries(fields).every(
|
|
91
|
+
([key, value]) => row[key] === value,
|
|
92
|
+
),
|
|
93
|
+
).reverse();
|
|
94
|
+
const offset = Number(opts.cursor ?? 0);
|
|
95
|
+
const next = offset + opts.numItems;
|
|
96
|
+
return {
|
|
97
|
+
page: rows.slice(offset, next),
|
|
98
|
+
isDone: next >= rows.length,
|
|
99
|
+
continueCursor: String(next),
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
}),
|
|
81
103
|
take: async (n: number) =>
|
|
82
104
|
tables[table]!.filter((row) =>
|
|
83
105
|
Object.entries(fields).every(
|
|
@@ -126,6 +148,72 @@ const scopedClaim = (balanceId: string) => ({
|
|
|
126
148
|
});
|
|
127
149
|
|
|
128
150
|
describe("RevenueCat consumable inbox", () => {
|
|
151
|
+
test("review delivery archive paginates independently of purchase state", async () => {
|
|
152
|
+
const f = fixture();
|
|
153
|
+
const id = await balanceId(event);
|
|
154
|
+
await call(receive, f.ctx, {
|
|
155
|
+
event: { ...event, type: "cancel" },
|
|
156
|
+
balanceId: id,
|
|
157
|
+
});
|
|
158
|
+
await call(receive, f.ctx, {
|
|
159
|
+
event: { ...event, deliveryId: "review-1", type: "review" },
|
|
160
|
+
balanceId: id,
|
|
161
|
+
});
|
|
162
|
+
await call(receive, f.ctx, {
|
|
163
|
+
event: { ...event, deliveryId: "review-2", type: "review" },
|
|
164
|
+
balanceId: id,
|
|
165
|
+
});
|
|
166
|
+
assert.equal(f.tables.revenueCatPurchases![0].state, "tombstone");
|
|
167
|
+
const first = await call(inspectReviewDeliveries, f.ctx, {
|
|
168
|
+
paginationOpts: { numItems: 1, cursor: null },
|
|
169
|
+
});
|
|
170
|
+
assert.deepEqual(
|
|
171
|
+
first.page.map((row: PurchaseEvent) => row.deliveryId),
|
|
172
|
+
["review-2"],
|
|
173
|
+
);
|
|
174
|
+
assert.equal(first.isDone, false);
|
|
175
|
+
const second = await call(inspectReviewDeliveries, f.ctx, {
|
|
176
|
+
paginationOpts: { numItems: 1, cursor: first.continueCursor },
|
|
177
|
+
});
|
|
178
|
+
assert.deepEqual(
|
|
179
|
+
second.page.map((row: PurchaseEvent) => row.deliveryId),
|
|
180
|
+
["review-1"],
|
|
181
|
+
);
|
|
182
|
+
assert.equal(second.isDone, true);
|
|
183
|
+
const refunded = fixture();
|
|
184
|
+
await call(receive, refunded.ctx, { event, balanceId: id });
|
|
185
|
+
await call(claim, refunded.ctx, scopedClaim(id));
|
|
186
|
+
await call(complete, refunded.ctx, { balanceId: id, kind: "grant" });
|
|
187
|
+
await call(receive, refunded.ctx, {
|
|
188
|
+
event: { ...event, deliveryId: "cancel", type: "cancel" },
|
|
189
|
+
balanceId: id,
|
|
190
|
+
});
|
|
191
|
+
await call(confirmFullRefund, refunded.ctx, {
|
|
192
|
+
balanceId: id,
|
|
193
|
+
evidence: "case 123",
|
|
194
|
+
});
|
|
195
|
+
await call(claim, refunded.ctx, scopedClaim(id));
|
|
196
|
+
await call(complete, refunded.ctx, { balanceId: id, kind: "refund" });
|
|
197
|
+
await call(receive, refunded.ctx, {
|
|
198
|
+
event: { ...event, deliveryId: "reversal", type: "review" },
|
|
199
|
+
balanceId: id,
|
|
200
|
+
});
|
|
201
|
+
assert.equal(refunded.tables.revenueCatPurchases![0].state, "refunded");
|
|
202
|
+
assert.equal(
|
|
203
|
+
refunded.tables.revenueCatPurchases![0].refundEvidence,
|
|
204
|
+
"case 123",
|
|
205
|
+
);
|
|
206
|
+
const archive = await call(inspectReviewDeliveries, refunded.ctx, {
|
|
207
|
+
paginationOpts: { numItems: 1, cursor: null },
|
|
208
|
+
});
|
|
209
|
+
assert.equal(archive.page[0].deliveryId, "reversal");
|
|
210
|
+
await assert.rejects(
|
|
211
|
+
call(inspectReviewDeliveries, f.ctx, {
|
|
212
|
+
paginationOpts: { numItems: 101, cursor: null },
|
|
213
|
+
}),
|
|
214
|
+
/Page size/,
|
|
215
|
+
);
|
|
216
|
+
});
|
|
129
217
|
test("managed monthly events are acknowledged only for valid, disjoint configured routes", async () => {
|
|
130
218
|
const monthly = { app: "app", store: "APP_STORE", product: "monthly" };
|
|
131
219
|
const env = {
|