create-disposabl-app 0.19.6 → 0.19.8
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/apps/desktop/forge.config.mts +7 -0
- package/dist/templates/default/apps/desktop/vite.main.config.mts +2 -3
- package/dist/templates/default/apps/desktop/website-config.ts +3 -0
- package/dist/templates/default/packages/backend/convex/_generated/api.d.ts +2 -0
- package/dist/templates/default/packages/backend/convex/revenuecat.ts +2 -0
- package/dist/templates/default/packages/disposabl-kit/PAYMENTS.md +4 -2
- package/dist/templates/default/packages/disposabl-kit/server/revenuecat-functions.ts +99 -0
- package/dist/templates/default/packages/disposabl-kit/server/revenuecat-validator.ts +7 -0
- package/dist/templates/default/packages/tests/desktop-packaging.test.ts +80 -0
- package/dist/templates/default/packages/tests/revenuecat-inbox.test.ts +79 -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.19.
|
|
1566
|
+
var version = "0.19.8";
|
|
1567
1567
|
|
|
1568
1568
|
// ../cli/telemetry.ts
|
|
1569
1569
|
var import_proper_lockfile2 = __toESM(require_proper_lockfile(), 1);
|
|
@@ -10,6 +10,8 @@ import { VitePlugin } from '@electron-forge/plugin-vite';
|
|
|
10
10
|
import { FusesPlugin } from '@electron-forge/plugin-fuses';
|
|
11
11
|
import { FuseV1Options, FuseVersion } from '@electron/fuses';
|
|
12
12
|
import { desktopAuthScheme } from '../../packages/disposabl-kit/lib/desktop-auth';
|
|
13
|
+
import { externalUrl } from './src/navigation';
|
|
14
|
+
import { configuredWebsite } from './website-config';
|
|
13
15
|
|
|
14
16
|
const executableName = manifest.name.toLowerCase().replace(/[^a-z0-9-]/g, '-');
|
|
15
17
|
const authScheme = desktopAuthScheme(
|
|
@@ -83,6 +85,11 @@ const config: ForgeConfig = {
|
|
|
83
85
|
rebuildConfig: {},
|
|
84
86
|
hooks: {
|
|
85
87
|
prePackage: async (_config, platform, arch) => {
|
|
88
|
+
const website = configuredWebsite();
|
|
89
|
+
if (website && (!website.startsWith('https://') || !externalUrl(website)))
|
|
90
|
+
throw new Error(
|
|
91
|
+
'Desktop packaging requires a valid HTTPS website without credentials. Set CONVEX_SITE_URL or VITE_CONVEX_SITE_URL, or leave both blank for the starter.',
|
|
92
|
+
);
|
|
86
93
|
const supported =
|
|
87
94
|
(platform === 'darwin' && arch === 'arm64') ||
|
|
88
95
|
((platform === 'win32' || platform === 'linux') && arch === 'x64');
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineConfig } from 'vite';
|
|
2
2
|
import manifest from './package.json' with { type: 'json' };
|
|
3
|
+
import { configuredWebsite } from './website-config';
|
|
3
4
|
|
|
4
5
|
export default defineConfig({
|
|
5
6
|
define: {
|
|
@@ -12,8 +13,6 @@ export default defineConfig({
|
|
|
12
13
|
DISPOSABL_UPDATE_CHANNEL: JSON.stringify(
|
|
13
14
|
process.env.DISPOSABL_DESKTOP_UPDATE_CHANNEL || 'production',
|
|
14
15
|
),
|
|
15
|
-
DISPOSABL_WEB_URL: JSON.stringify(
|
|
16
|
-
process.env.CONVEX_SITE_URL || process.env.VITE_CONVEX_SITE_URL || '',
|
|
17
|
-
),
|
|
16
|
+
DISPOSABL_WEB_URL: JSON.stringify(configuredWebsite()),
|
|
18
17
|
},
|
|
19
18
|
});
|
|
@@ -16,6 +16,7 @@ import type * as files_index from "../files/index.js";
|
|
|
16
16
|
import type * as files_internal from "../files/internal.js";
|
|
17
17
|
import type * as http from "../http.js";
|
|
18
18
|
import type * as mcp from "../mcp.js";
|
|
19
|
+
import type * as revenuecat from "../revenuecat.js";
|
|
19
20
|
import type * as telemetry from "../telemetry.js";
|
|
20
21
|
import type * as users_index from "../users/index.js";
|
|
21
22
|
import type * as users_internal from "../users/internal.js";
|
|
@@ -35,6 +36,7 @@ declare const fullApi: ApiFromModules<{
|
|
|
35
36
|
"files/internal": typeof files_internal;
|
|
36
37
|
http: typeof http;
|
|
37
38
|
mcp: typeof mcp;
|
|
39
|
+
revenuecat: typeof revenuecat;
|
|
38
40
|
telemetry: typeof telemetry;
|
|
39
41
|
"users/index": typeof users_index;
|
|
40
42
|
"users/internal": typeof users_internal;
|
|
@@ -58,9 +58,11 @@ After completing the verification below, an operator may explicitly set `REVENUE
|
|
|
58
58
|
|
|
59
59
|
The authenticated webhook checks app, environment, store, product, transaction and a known local user, then durably records delivery and transaction ownership. A stable balance ID excludes the customer, so an account switch cannot create a second grant. A scheduled worker atomically changes `queued` to `grant_unknown` before calling Autumn 2.6 `balances.create` with the configured top-up credit quantity. Only an explicit `{success:true}` response records a grant. A timeout, malformed response, provider error, or worker crash leaves `grant_unknown`: duplicate deliveries and action retries cannot issue another create. A separate paid transaction can proceed independently. An HTTP 200 after persistence means accepted for processing, never credited.
|
|
60
60
|
|
|
61
|
-
A cancellation before dispatch creates a local tombstone; a later purchase cannot grant. Cancellation during a write is held until the result is known. After a grant, cancellation enters `refund_review` because the webhook alone does not prove the refund is full. An operator must establish the scope and spent-credit policy from provider records before calling private `revenuecat:confirmFullRefund` with a nonsecret evidence reference. It targets only that balance ID via `balances.update` with `remaining: 0`. An uncertain update is held as `refund_unknown`. Transfers and refund reversals require review; transfer notifications are stored separately and place affected customers on hold across both apps in the same project and environment. A transfer arriving after dispatch cannot cancel an in-flight provider request.
|
|
61
|
+
A cancellation before dispatch creates a local tombstone; a later purchase cannot grant. Cancellation during a write is held until the result is known. After a grant, cancellation enters `refund_review` because the webhook alone does not prove the refund is full. An operator must establish the scope and spent-credit policy from provider records before calling private `revenuecat:confirmFullRefund` with a nonsecret evidence reference. It targets only that balance ID via `balances.update` with `remaining: 0`. An uncertain update is held as `refund_unknown`. Transfers and refund reversals require review; transfer notifications are stored separately and place affected customers on hold across both apps in the same project and environment. A transfer arriving after dispatch cannot cancel an in-flight provider request. Transfer holds remain active after an operator records a review; incomplete event identities are rejected. A release policy must first establish whether previously queued credits may be granted to the stored customer after each provider transfer, including account ownership and prior provider writes. No automatic restore, replay of an uncertain operation, or missed-webhook reconciliation is implied.
|
|
62
62
|
|
|
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.
|
|
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
|
+
|
|
65
|
+
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.
|
|
64
66
|
|
|
65
67
|
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.
|
|
66
68
|
|
|
@@ -182,6 +182,53 @@ export const inspectTransfers = internalQuery({
|
|
|
182
182
|
ctx.db.query("revenueCatTransfers").order("desc").take(100),
|
|
183
183
|
});
|
|
184
184
|
|
|
185
|
+
// Recording a review does not decide whether affected credits may be granted.
|
|
186
|
+
export const recordTransferReview = internalMutation({
|
|
187
|
+
args: {
|
|
188
|
+
project: v.string(),
|
|
189
|
+
app: v.string(),
|
|
190
|
+
environment: v.string(),
|
|
191
|
+
deliveryId: v.string(),
|
|
192
|
+
from: v.array(v.string()),
|
|
193
|
+
to: v.array(v.string()),
|
|
194
|
+
evidence: v.string(),
|
|
195
|
+
},
|
|
196
|
+
returns: v.boolean(),
|
|
197
|
+
handler: async (
|
|
198
|
+
ctx,
|
|
199
|
+
{ project, app, environment, deliveryId, from, to, evidence },
|
|
200
|
+
) => {
|
|
201
|
+
if (!evidence.trim() || evidence.length > 1000)
|
|
202
|
+
throw new Error("Provider evidence is required");
|
|
203
|
+
if (from.length > 20 || to.length > 20) return false;
|
|
204
|
+
const row = await ctx.db
|
|
205
|
+
.query("revenueCatTransfers")
|
|
206
|
+
.withIndex("by_delivery", (q) =>
|
|
207
|
+
q
|
|
208
|
+
.eq("project", project)
|
|
209
|
+
.eq("app", app)
|
|
210
|
+
.eq("environment", environment)
|
|
211
|
+
.eq("deliveryId", deliveryId),
|
|
212
|
+
)
|
|
213
|
+
.unique();
|
|
214
|
+
if (
|
|
215
|
+
!row ||
|
|
216
|
+
JSON.stringify(row.from) !== JSON.stringify(from) ||
|
|
217
|
+
JSON.stringify(row.to) !== JSON.stringify(to)
|
|
218
|
+
)
|
|
219
|
+
return false;
|
|
220
|
+
if (row.review) return row.review.evidence === evidence.trim();
|
|
221
|
+
await ctx.db.patch("revenueCatTransfers", row._id, {
|
|
222
|
+
review: {
|
|
223
|
+
decision: "retain_hold",
|
|
224
|
+
evidence: evidence.trim(),
|
|
225
|
+
reviewedAt: Date.now(),
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
return true;
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
|
|
185
232
|
export const inspectConflicts = internalQuery({
|
|
186
233
|
args: {},
|
|
187
234
|
returns: v.array(v.any()),
|
|
@@ -347,6 +394,10 @@ export const claim = internalMutation({
|
|
|
347
394
|
)
|
|
348
395
|
.take(1);
|
|
349
396
|
if (holds.length) return null;
|
|
397
|
+
if (row.state === "queued") {
|
|
398
|
+
const customerId = ctx.db.normalizeId("users", row.customer);
|
|
399
|
+
if (!customerId || !(await ctx.db.get("users", customerId))) return null;
|
|
400
|
+
}
|
|
350
401
|
const kind: "grant" | "refund" =
|
|
351
402
|
row.state === "queued" ? "grant" : "refund";
|
|
352
403
|
await ctx.db.patch("revenueCatPurchases", row._id, {
|
|
@@ -356,6 +407,54 @@ export const claim = internalMutation({
|
|
|
356
407
|
},
|
|
357
408
|
});
|
|
358
409
|
|
|
410
|
+
/** Schedule only a specifically identified queued grant; dispatch rechecks its route and claim. */
|
|
411
|
+
export const redispatchQueued = internalMutation({
|
|
412
|
+
args: {
|
|
413
|
+
balanceId: v.string(),
|
|
414
|
+
project: v.string(),
|
|
415
|
+
app: v.string(),
|
|
416
|
+
environment: v.string(),
|
|
417
|
+
store: v.string(),
|
|
418
|
+
product: v.string(),
|
|
419
|
+
customer: v.string(),
|
|
420
|
+
},
|
|
421
|
+
returns: v.boolean(),
|
|
422
|
+
handler: async (ctx, args) => {
|
|
423
|
+
const row = await ctx.db
|
|
424
|
+
.query("revenueCatPurchases")
|
|
425
|
+
.withIndex("by_balanceId", (q) => q.eq("balanceId", args.balanceId))
|
|
426
|
+
.unique();
|
|
427
|
+
if (
|
|
428
|
+
!row ||
|
|
429
|
+
row.project !== args.project ||
|
|
430
|
+
row.app !== args.app ||
|
|
431
|
+
row.environment !== args.environment ||
|
|
432
|
+
row.store !== args.store ||
|
|
433
|
+
row.product !== args.product ||
|
|
434
|
+
row.customer !== args.customer ||
|
|
435
|
+
row.state !== "queued" ||
|
|
436
|
+
row.refundPending ||
|
|
437
|
+
row.reviewPending
|
|
438
|
+
)
|
|
439
|
+
return false;
|
|
440
|
+
const customerId = ctx.db.normalizeId("users", row.customer);
|
|
441
|
+
if (!customerId || !(await ctx.db.get("users", customerId))) return false;
|
|
442
|
+
const holds = await ctx.db
|
|
443
|
+
.query("revenueCatTransferHolds")
|
|
444
|
+
.withIndex("by_customer_active", (q) =>
|
|
445
|
+
q
|
|
446
|
+
.eq("project", row.project)
|
|
447
|
+
.eq("environment", row.environment)
|
|
448
|
+
.eq("customer", row.customer)
|
|
449
|
+
.eq("active", true),
|
|
450
|
+
)
|
|
451
|
+
.take(1);
|
|
452
|
+
if (holds.length) return false;
|
|
453
|
+
await ctx.scheduler.runAfter(0, dispatchRef, { balanceId: args.balanceId });
|
|
454
|
+
return true;
|
|
455
|
+
},
|
|
456
|
+
});
|
|
457
|
+
|
|
359
458
|
export const complete = internalMutation({
|
|
360
459
|
args: {
|
|
361
460
|
balanceId: v.string(),
|
|
@@ -57,6 +57,13 @@ export const revenueCatTransfers = defineTable({
|
|
|
57
57
|
deliveryId: v.string(),
|
|
58
58
|
from: v.array(v.string()),
|
|
59
59
|
to: v.array(v.string()),
|
|
60
|
+
review: v.optional(
|
|
61
|
+
v.object({
|
|
62
|
+
decision: v.literal("retain_hold"),
|
|
63
|
+
evidence: v.string(),
|
|
64
|
+
reviewedAt: v.number(),
|
|
65
|
+
}),
|
|
66
|
+
),
|
|
60
67
|
}).index("by_delivery", ["project", "app", "environment", "deliveryId"]);
|
|
61
68
|
export const revenueCatTransferHolds = defineTable({
|
|
62
69
|
project: v.string(),
|
|
@@ -10,3 +10,83 @@ test("macOS disk image uses a bounded title without overriding artifact names",
|
|
|
10
10
|
assert.equal(maker.config.title, "Install");
|
|
11
11
|
assert.equal(maker.config.name, undefined);
|
|
12
12
|
});
|
|
13
|
+
|
|
14
|
+
test("packaging validates the website Vite embeds", async () => {
|
|
15
|
+
const previous = {
|
|
16
|
+
CONVEX_SITE_URL: process.env.CONVEX_SITE_URL,
|
|
17
|
+
VITE_CONVEX_SITE_URL: process.env.VITE_CONVEX_SITE_URL,
|
|
18
|
+
};
|
|
19
|
+
const cases = [
|
|
20
|
+
{ convex: "", vite: "", embedded: "", valid: true },
|
|
21
|
+
{
|
|
22
|
+
convex: "https://app.example/path",
|
|
23
|
+
vite: "",
|
|
24
|
+
embedded: "https://app.example/path",
|
|
25
|
+
valid: true,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
convex: "http://127.0.0.1:39876",
|
|
29
|
+
vite: "https://app.example",
|
|
30
|
+
embedded: "http://127.0.0.1:39876",
|
|
31
|
+
valid: false,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
convex: "",
|
|
35
|
+
vite: "https://app.example",
|
|
36
|
+
embedded: "https://app.example",
|
|
37
|
+
valid: true,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
convex: "https://app.example",
|
|
41
|
+
vite: "http://invalid.example",
|
|
42
|
+
embedded: "https://app.example",
|
|
43
|
+
valid: true,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
convex: "",
|
|
47
|
+
vite: "http://invalid.example",
|
|
48
|
+
embedded: "http://invalid.example",
|
|
49
|
+
valid: false,
|
|
50
|
+
},
|
|
51
|
+
{ convex: "https://", vite: "", embedded: "https://", valid: false },
|
|
52
|
+
{
|
|
53
|
+
convex: "https://user:pass@app.example",
|
|
54
|
+
vite: "",
|
|
55
|
+
embedded: "https://user:pass@app.example",
|
|
56
|
+
valid: false,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
convex: "HTTPS://app.example",
|
|
60
|
+
vite: "",
|
|
61
|
+
embedded: "HTTPS://app.example",
|
|
62
|
+
valid: false,
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
try {
|
|
66
|
+
for (const [index, item] of cases.entries()) {
|
|
67
|
+
process.env.CONVEX_SITE_URL = item.convex;
|
|
68
|
+
process.env.VITE_CONVEX_SITE_URL = item.vite;
|
|
69
|
+
const vite = await import(
|
|
70
|
+
`../../apps/desktop/vite.main.config.mts?case=${index}`
|
|
71
|
+
);
|
|
72
|
+
assert.equal(
|
|
73
|
+
JSON.parse(vite.default.define.DISPOSABL_WEB_URL),
|
|
74
|
+
item.embedded,
|
|
75
|
+
);
|
|
76
|
+
const hook = config.hooks!.prePackage!;
|
|
77
|
+
const check = () =>
|
|
78
|
+
hook(config as Parameters<typeof hook>[0], "darwin", "arm64");
|
|
79
|
+
if (item.valid) await assert.doesNotReject(check);
|
|
80
|
+
else
|
|
81
|
+
await assert.rejects(
|
|
82
|
+
check,
|
|
83
|
+
/Desktop packaging requires a valid HTTPS website/,
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
} finally {
|
|
87
|
+
for (const [name, value] of Object.entries(previous)) {
|
|
88
|
+
if (value === undefined) delete process.env[name];
|
|
89
|
+
else process.env[name] = value;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
});
|
|
@@ -16,6 +16,8 @@ import {
|
|
|
16
16
|
complete,
|
|
17
17
|
confirmFullRefund,
|
|
18
18
|
receiveTransfer,
|
|
19
|
+
recordTransferReview,
|
|
20
|
+
redispatchQueued,
|
|
19
21
|
createWebhook,
|
|
20
22
|
webhookAuthorized,
|
|
21
23
|
webhook,
|
|
@@ -685,6 +687,83 @@ describe("RevenueCat consumable inbox", () => {
|
|
|
685
687
|
"grant",
|
|
686
688
|
);
|
|
687
689
|
});
|
|
690
|
+
test("transfer review is scoped, idempotent and retains holds; redispatch is targeted", async () => {
|
|
691
|
+
const f = fixture();
|
|
692
|
+
const id = await balanceId(event);
|
|
693
|
+
await call(receive, f.ctx, { event, balanceId: id });
|
|
694
|
+
const transfer = {
|
|
695
|
+
project: "proj",
|
|
696
|
+
app: "app",
|
|
697
|
+
environment: "SANDBOX",
|
|
698
|
+
deliveryId: "transfer",
|
|
699
|
+
from: ["user-1"],
|
|
700
|
+
to: ["user-2"],
|
|
701
|
+
};
|
|
702
|
+
await call(receiveTransfer, f.ctx, transfer);
|
|
703
|
+
await call(receiveTransfer, f.ctx, { ...transfer, deliveryId: "second" });
|
|
704
|
+
const review = { ...transfer, evidence: " provider case 123 " };
|
|
705
|
+
assert.equal(
|
|
706
|
+
await call(recordTransferReview, f.ctx, { ...review, app: "wrong" }),
|
|
707
|
+
false,
|
|
708
|
+
);
|
|
709
|
+
assert.equal(
|
|
710
|
+
await call(recordTransferReview, f.ctx, { ...review, to: ["user-3"] }),
|
|
711
|
+
false,
|
|
712
|
+
);
|
|
713
|
+
await assert.rejects(
|
|
714
|
+
call(recordTransferReview, f.ctx, { ...review, evidence: " " }),
|
|
715
|
+
/Provider evidence/,
|
|
716
|
+
);
|
|
717
|
+
await assert.rejects(
|
|
718
|
+
call(recordTransferReview, f.ctx, {
|
|
719
|
+
...review,
|
|
720
|
+
evidence: "x".repeat(1001),
|
|
721
|
+
}),
|
|
722
|
+
/Provider evidence/,
|
|
723
|
+
);
|
|
724
|
+
assert.equal(await call(recordTransferReview, f.ctx, review), true);
|
|
725
|
+
const saved = f.tables.revenueCatTransfers![0].review;
|
|
726
|
+
assert.equal(saved.decision, "retain_hold");
|
|
727
|
+
assert.equal(saved.evidence, "provider case 123");
|
|
728
|
+
assert.equal(typeof saved.reviewedAt, "number");
|
|
729
|
+
assert.equal(await call(recordTransferReview, f.ctx, review), true);
|
|
730
|
+
assert.equal(
|
|
731
|
+
await call(recordTransferReview, f.ctx, {
|
|
732
|
+
...review,
|
|
733
|
+
evidence: "different",
|
|
734
|
+
}),
|
|
735
|
+
false,
|
|
736
|
+
);
|
|
737
|
+
assert.deepEqual(f.tables.revenueCatTransfers![0].review, saved);
|
|
738
|
+
await call(receiveTransfer, f.ctx, transfer);
|
|
739
|
+
assert.ok(f.tables.revenueCatTransferHolds!.every((hold) => hold.active));
|
|
740
|
+
const target = { ...scopedClaim(id), customer: event.customer };
|
|
741
|
+
const jobs = f.jobs.length;
|
|
742
|
+
assert.equal(await call(redispatchQueued, f.ctx, target), false);
|
|
743
|
+
assert.equal(await call(claim, f.ctx, scopedClaim(id)), null);
|
|
744
|
+
assert.equal(f.jobs.length, jobs);
|
|
745
|
+
// Simulate independently reconciled holds to exercise redispatch without defining a release policy.
|
|
746
|
+
f.tables.revenueCatTransferHolds!.forEach((hold) => {
|
|
747
|
+
hold.active = false;
|
|
748
|
+
});
|
|
749
|
+
assert.equal(
|
|
750
|
+
await call(redispatchQueued, f.ctx, { ...target, customer: "user-2" }),
|
|
751
|
+
false,
|
|
752
|
+
);
|
|
753
|
+
assert.equal(
|
|
754
|
+
await call(redispatchQueued, f.ctx, { ...target, product: "wrong" }),
|
|
755
|
+
false,
|
|
756
|
+
);
|
|
757
|
+
assert.equal(await call(redispatchQueued, f.ctx, target), true);
|
|
758
|
+
assert.equal(f.jobs.length, jobs + 1);
|
|
759
|
+
await call(receiveTransfer, f.ctx, { ...transfer, deliveryId: "third" });
|
|
760
|
+
assert.equal(await call(claim, f.ctx, scopedClaim(id)), null);
|
|
761
|
+
f.tables.revenueCatTransferHolds!.forEach((hold) => {
|
|
762
|
+
hold.active = false;
|
|
763
|
+
});
|
|
764
|
+
assert.equal((await call(claim, f.ctx, scopedClaim(id))).kind, "grant");
|
|
765
|
+
assert.equal(await call(redispatchQueued, f.ctx, target), false);
|
|
766
|
+
});
|
|
688
767
|
test("disabled and incomplete configuration cannot read or dispatch payments", () => {
|
|
689
768
|
assert.equal(revenueCatConfigs(false, {}), null);
|
|
690
769
|
assert.equal(
|