@referalli/cli 0.4.1 → 0.4.2
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/CHANGELOG.md +5 -0
- package/dist/src/apply.js +17 -6
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,11 @@ All notable changes to `@referalli/cli` are recorded here. The format follows
|
|
|
5
5
|
[Semantic Versioning](https://semver.org/spec/v2.0.0.html). Before 1.0, a minor
|
|
6
6
|
bump may include breaking changes; they are called out under **Changed**.
|
|
7
7
|
|
|
8
|
+
## 0.4.2 - 2026-11-03
|
|
9
|
+
|
|
10
|
+
- Fixed: `plan`/`apply` with a `billingConnections:` list failed with `conns.filter is not a function` (the connections list now arrives in the list envelope).
|
|
11
|
+
- Programs take `publicPage` (`pitch`, `autoApprove`) and `riskPolicy` (`holdBotScore`, `holdRiskScore`, `holdHighRiskLevel`, `holdDisposableEmail`, `holdVelocity`, `holdUnverifiedEmail`, `holdSelfReferral`). Only the keys you list are compared; `apply` merges them into the live settings.
|
|
12
|
+
|
|
8
13
|
## 0.4.1 - 2026-11-03
|
|
9
14
|
|
|
10
15
|
- New `env pull [--mode live|test]`: prints one mode's tracking token (`REFERALLI_TRACKING_TOKEN`, `NEXT_PUBLIC_REFERALLI_TRACKING_TOKEN`), aff.js URL, link base and, for the key's own mode, the program id as `.env` lines. Keys are never pulled.
|
package/dist/src/apply.js
CHANGED
|
@@ -14,7 +14,9 @@ export class ConfigError extends Error {
|
|
|
14
14
|
const PROGRAM_TOP = ['name', 'attributionModel', 'cookieWindowDays', 'signupToConversionDays', 'termsMd', 'status', 'publicHandle'];
|
|
15
15
|
// Program settings: PATCH takes them top-level, GET returns them under `settings`.
|
|
16
16
|
const PROGRAM_SETTINGS = ['probabilisticPolicy', 'selfReferralPolicy', 'splitCommissions', 'allowPaidSearch', 'challengeLinks', 'settlement'];
|
|
17
|
-
|
|
17
|
+
// Mappings merged into what's live: only the keys the file names are compared, and PATCH sends the live block with them applied.
|
|
18
|
+
const PROGRAM_BLOCKS = { publicPage: ['pitch', 'autoApprove'], riskPolicy: ['holdBotScore', 'holdRiskScore', 'holdHighRiskLevel', 'holdDisposableEmail', 'holdVelocity', 'holdUnverifiedEmail', 'holdSelfReferral'] };
|
|
19
|
+
const PROGRAM_KEYS = ['slug', ...PROGRAM_TOP, ...PROGRAM_SETTINGS, ...Object.keys(PROGRAM_BLOCKS), 'destinationUrl', 'commissionRule', 'stripeCredits'];
|
|
18
20
|
const STRIPE_KEYS = ['enabled', 'referrerMatch', 'metadataKey', 'refereeRewards', 'balanceCurrency', 'createCustomerIfMissing', 'waitForCustomer', 'secretKeyEnv'];
|
|
19
21
|
const WEBHOOK_KEYS = ['url', 'topics', 'programs', 'status', 'alertContacts'];
|
|
20
22
|
const API_KEY_KEYS = ['name', 'owner', 'mode', 'scopes', 'expiresInDays', 'programs', 'apiVersion'];
|
|
@@ -58,6 +60,13 @@ export function parseConfig(text, file = 'config') {
|
|
|
58
60
|
checkKeys(p, PROGRAM_KEYS, where, 'slug');
|
|
59
61
|
if (p.commissionRule !== undefined && !isObj(p.commissionRule))
|
|
60
62
|
throw new ConfigError(`${where}.commissionRule: expected a mapping`);
|
|
63
|
+
for (const [block, keys] of Object.entries(PROGRAM_BLOCKS)) {
|
|
64
|
+
if (p[block] === undefined)
|
|
65
|
+
continue;
|
|
66
|
+
if (!isObj(p[block]))
|
|
67
|
+
throw new ConfigError(`${where}.${block}: expected a mapping`);
|
|
68
|
+
checkKeys(p[block], [...keys], `${where}.${block}`);
|
|
69
|
+
}
|
|
61
70
|
if (p.stripeCredits !== undefined) {
|
|
62
71
|
checkKeys(p.stripeCredits, STRIPE_KEYS, `${where}.stripeCredits`);
|
|
63
72
|
if (typeof p.stripeCredits.enabled !== 'boolean')
|
|
@@ -141,7 +150,7 @@ export async function buildPlan(client, config, env) {
|
|
|
141
150
|
const cur = programs.find((p) => p.slug === spec.slug);
|
|
142
151
|
const label = `program "${spec.slug}"`;
|
|
143
152
|
const desired = {};
|
|
144
|
-
for (const k of [...PROGRAM_TOP, ...PROGRAM_SETTINGS, 'destinationUrl'])
|
|
153
|
+
for (const k of [...PROGRAM_TOP, ...PROGRAM_SETTINGS, ...Object.keys(PROGRAM_BLOCKS), 'destinationUrl'])
|
|
145
154
|
if (spec[k] !== undefined)
|
|
146
155
|
desired[k] = spec[k];
|
|
147
156
|
if (!cur) {
|
|
@@ -163,12 +172,14 @@ export async function buildPlan(client, config, env) {
|
|
|
163
172
|
else {
|
|
164
173
|
const now = (k) => k === 'destinationUrl'
|
|
165
174
|
? (cur.settings.widget?.destinationUrl ?? null)
|
|
166
|
-
: PROGRAM_SETTINGS.includes(k)
|
|
175
|
+
: PROGRAM_SETTINGS.includes(k) || k === 'riskPolicy'
|
|
167
176
|
? cur.settings[k]
|
|
168
177
|
: cur[k];
|
|
178
|
+
// A block counts as changed only on the keys the file names; the new value is the live block with them applied.
|
|
179
|
+
const want = (k, v) => (k in PROGRAM_BLOCKS ? { ...(now(k) ?? {}), ...v } : v);
|
|
169
180
|
const fields = Object.entries(desired)
|
|
170
|
-
.filter(([k, v]) => !same(now(k), v))
|
|
171
|
-
.map(([k, v]) => [k, now(k), v]);
|
|
181
|
+
.filter(([k, v]) => !same(now(k), want(k, v)))
|
|
182
|
+
.map(([k, v]) => [k, now(k), want(k, v)]);
|
|
172
183
|
const patch = Object.fromEntries(fields.map(([k, , v]) => [k, v]));
|
|
173
184
|
changes.push({
|
|
174
185
|
action: fields.length ? 'update' : 'noop',
|
|
@@ -308,7 +319,7 @@ export async function buildPlan(client, config, env) {
|
|
|
308
319
|
});
|
|
309
320
|
}
|
|
310
321
|
if (config.billingConnections.length) {
|
|
311
|
-
const conns = await client
|
|
322
|
+
const conns = await listAll(client, '/v1/billing/connections');
|
|
312
323
|
for (const spec of config.billingConnections) {
|
|
313
324
|
const label = `billingConnection "${spec.name}"`;
|
|
314
325
|
checkRefs(spec.programs, label);
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Kept in step with package.json by test/version.test.ts. */
|
|
2
|
-
export declare const VERSION = "0.4.
|
|
2
|
+
export declare const VERSION = "0.4.2";
|
package/dist/src/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Kept in step with package.json by test/version.test.ts. */
|
|
2
|
-
export const VERSION = '0.4.
|
|
2
|
+
export const VERSION = '0.4.2';
|
package/package.json
CHANGED