@colixsystems/widget-sdk 0.333.0 → 0.334.0
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/README.md +7 -1
- package/dist/contract.cjs +6 -3
- package/dist/contract.js +6 -3
- package/dist/index.d.ts +5 -1
- package/dist/linter.cjs +61 -22
- package/dist/linter.js +61 -22
- package/package.json +1 -1
- package/src/contract.js +6 -3
package/README.md
CHANGED
|
@@ -91,7 +91,13 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
|
|
|
91
91
|
|
|
92
92
|
## Status
|
|
93
93
|
|
|
94
|
-
`v0.
|
|
94
|
+
`v0.334.0` — pre-publish. The package surface (types, function names, export paths) is the v1 contract; runtime behaviour for some hooks is stubbed (each hook documents what's wired and what isn't). It is **not yet published to npm**.
|
|
95
|
+
|
|
96
|
+
### What's new in 0.334.0 (contract 1.272.0)
|
|
97
|
+
|
|
98
|
+
**A widget that sells access plans must let a buyer cancel.** A held monthly plan renews until `useAccessPlans().cancel(planId)` stops it, so a widget that calls `purchase` but never `cancel` left its subscribers no way to stop paying. The linter now refuses it with `access-plan-cancel-missing` (an error, so it blocks the publish). For a held plan with `renews: true`, render a "Cancel renewal" control that calls `cancel(plan.id)`, and once it resolves show `access_ends_at`, the day access ends. A one-time plan never renews, so the control never shows for it. The check reads the whole file, so one component may buy and another cancel; `cancel` counts only where it is called or passed on, never in text such as "Cancel any time". A widget that hands the whole hook result to a child component (`<PlanList plans={ap} />`) is left to that child.
|
|
99
|
+
|
|
100
|
+
**A plan taken off sale stays listed to its holders.** `plans` now also holds a plan the signed-in user holds after the workspace stopped selling it, with `purchase_available: false`, so they can still see it and cancel it. Show the buy control only where `purchase_available` is true.
|
|
95
101
|
|
|
96
102
|
### What's new in 0.332.0 (contract 1.271.0)
|
|
97
103
|
|
package/dist/contract.cjs
CHANGED
|
@@ -2484,7 +2484,7 @@ const HOOKS = [
|
|
|
2484
2484
|
signature: "useAccessPlans()",
|
|
2485
2485
|
returnShape: {
|
|
2486
2486
|
plans:
|
|
2487
|
-
"Array<{ id, name, price_cents, currency, billing: \"one_time\" | \"monthly\", owned, renews, access_ends_at, purchase_available }> // owned: the user holds it; renews: a held monthly plan will charge again; access_ends_at: end of held access without a renewal (null for one-time); purchase_available: this plan can be bought here — false in an iOS/Android build for a plan the workspace does not sell in-app",
|
|
2487
|
+
"Array<{ id, name, price_cents, currency, billing: \"one_time\" | \"monthly\", owned, renews, access_ends_at, purchase_available }> // owned: the user holds it; renews: a held monthly plan will charge again; access_ends_at: end of held access without a renewal (null for one-time); purchase_available: this plan can be bought here — false in an iOS/Android build for a plan the workspace does not sell in-app, and for a plan the user holds that is no longer on sale (listed so they can still cancel it)",
|
|
2488
2488
|
loading: "boolean",
|
|
2489
2489
|
error: "PaymentError | null",
|
|
2490
2490
|
purchaseAvailable:
|
|
@@ -2492,7 +2492,7 @@ const HOOKS = [
|
|
|
2492
2492
|
purchase:
|
|
2493
2493
|
"(planId, { return_path? }?) => Promise<{ plan_id, status: \"ACTIVE\" | \"PENDING\" }> // pass ONLY the plan id; the server sets price and group; the host opens hosted Checkout on the web and the store's in-app purchase sheet in an iOS/Android build; access arrives with the payment confirmation, so refresh() a moment later",
|
|
2494
2494
|
cancel:
|
|
2495
|
-
"(planId) => Promise<{ plan_id, renews: false, access_ends_at }> // stop a renewing monthly plan; access runs to access_ends_at — offer it beside every plan with renews: true",
|
|
2495
|
+
"(planId) => Promise<{ plan_id, renews: false, access_ends_at }> // stop a renewing monthly plan; access runs to access_ends_at — offer it beside every plan with renews: true; a widget that calls purchase without it is refused (access-plan-cancel-missing)",
|
|
2496
2496
|
refresh: "() => Promise<void> // re-read after returning from Checkout",
|
|
2497
2497
|
},
|
|
2498
2498
|
requiredContextSlice: [
|
|
@@ -7073,7 +7073,10 @@ const CONTRACT = deepFreeze({
|
|
|
7073
7073
|
// value, and an update may still change it.
|
|
7074
7074
|
// 1.271.0: additive (sc-17551) — `useDatastoreAggregate` groups by a
|
|
7075
7075
|
// relation column; new warning lint `aggregate-error-not-read`.
|
|
7076
|
-
|
|
7076
|
+
// 1.272.0: stricter lint (sc-17552) — a widget that calls
|
|
7077
|
+
// useAccessPlans().purchase without cancel is the publish-blocking
|
|
7078
|
+
// `access-plan-cancel-missing` finding.
|
|
7079
|
+
version: "1.272.0",
|
|
7077
7080
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7078
7081
|
hooks: HOOKS,
|
|
7079
7082
|
primitives: PRIMITIVES,
|
package/dist/contract.js
CHANGED
|
@@ -2479,7 +2479,7 @@ const HOOKS = [
|
|
|
2479
2479
|
signature: "useAccessPlans()",
|
|
2480
2480
|
returnShape: {
|
|
2481
2481
|
plans:
|
|
2482
|
-
"Array<{ id, name, price_cents, currency, billing: \"one_time\" | \"monthly\", owned, renews, access_ends_at, purchase_available }> // owned: the user holds it; renews: a held monthly plan will charge again; access_ends_at: end of held access without a renewal (null for one-time); purchase_available: this plan can be bought here — false in an iOS/Android build for a plan the workspace does not sell in-app",
|
|
2482
|
+
"Array<{ id, name, price_cents, currency, billing: \"one_time\" | \"monthly\", owned, renews, access_ends_at, purchase_available }> // owned: the user holds it; renews: a held monthly plan will charge again; access_ends_at: end of held access without a renewal (null for one-time); purchase_available: this plan can be bought here — false in an iOS/Android build for a plan the workspace does not sell in-app, and for a plan the user holds that is no longer on sale (listed so they can still cancel it)",
|
|
2483
2483
|
loading: "boolean",
|
|
2484
2484
|
error: "PaymentError | null",
|
|
2485
2485
|
purchaseAvailable:
|
|
@@ -2487,7 +2487,7 @@ const HOOKS = [
|
|
|
2487
2487
|
purchase:
|
|
2488
2488
|
"(planId, { return_path? }?) => Promise<{ plan_id, status: \"ACTIVE\" | \"PENDING\" }> // pass ONLY the plan id; the server sets price and group; the host opens hosted Checkout on the web and the store's in-app purchase sheet in an iOS/Android build; access arrives with the payment confirmation, so refresh() a moment later",
|
|
2489
2489
|
cancel:
|
|
2490
|
-
"(planId) => Promise<{ plan_id, renews: false, access_ends_at }> // stop a renewing monthly plan; access runs to access_ends_at — offer it beside every plan with renews: true",
|
|
2490
|
+
"(planId) => Promise<{ plan_id, renews: false, access_ends_at }> // stop a renewing monthly plan; access runs to access_ends_at — offer it beside every plan with renews: true; a widget that calls purchase without it is refused (access-plan-cancel-missing)",
|
|
2491
2491
|
refresh: "() => Promise<void> // re-read after returning from Checkout",
|
|
2492
2492
|
},
|
|
2493
2493
|
requiredContextSlice: [
|
|
@@ -7068,7 +7068,10 @@ const CONTRACT = deepFreeze({
|
|
|
7068
7068
|
// value, and an update may still change it.
|
|
7069
7069
|
// 1.271.0: additive (sc-17551) — `useDatastoreAggregate` groups by a
|
|
7070
7070
|
// relation column; new warning lint `aggregate-error-not-read`.
|
|
7071
|
-
|
|
7071
|
+
// 1.272.0: stricter lint (sc-17552) — a widget that calls
|
|
7072
|
+
// useAccessPlans().purchase without cancel is the publish-blocking
|
|
7073
|
+
// `access-plan-cancel-missing` finding.
|
|
7074
|
+
version: "1.272.0",
|
|
7072
7075
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7073
7076
|
hooks: HOOKS,
|
|
7074
7077
|
primitives: PRIMITIVES,
|
package/dist/index.d.ts
CHANGED
|
@@ -1676,7 +1676,11 @@ export interface AccessPlan {
|
|
|
1676
1676
|
renews: boolean;
|
|
1677
1677
|
/** ISO time held access ends without a renewal; null for one-time access. */
|
|
1678
1678
|
access_ends_at: string | null;
|
|
1679
|
-
/**
|
|
1679
|
+
/**
|
|
1680
|
+
* Whether this plan can be bought here: false in a store build that does not
|
|
1681
|
+
* sell it in-app, and for a plan the user holds that is no longer on sale
|
|
1682
|
+
* (listed so they can still cancel it).
|
|
1683
|
+
*/
|
|
1680
1684
|
purchase_available: boolean;
|
|
1681
1685
|
}
|
|
1682
1686
|
|
package/dist/linter.cjs
CHANGED
|
@@ -1925,34 +1925,51 @@ function _destructuredLocals(pattern) {
|
|
|
1925
1925
|
return locals;
|
|
1926
1926
|
}
|
|
1927
1927
|
|
|
1928
|
-
//
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
const
|
|
1939
|
-
|
|
1940
|
-
|
|
1928
|
+
// What the code reads, scanned once: bare identifiers, `name.field` member
|
|
1929
|
+
// reads, names handed whole to a child (`={ap}`, `...ap`), which does the work,
|
|
1930
|
+
// and names called or passed on: JSX text ("cancel any time") is neither.
|
|
1931
|
+
function _codeReads(code) {
|
|
1932
|
+
const members = new Set();
|
|
1933
|
+
for (const m of code.matchAll(/(?<![\w$])([\w$]+)(?=\s*\??\.\s*([\w$]+))/g)) members.add(`${m[1]}.${m[2]}`);
|
|
1934
|
+
const handedOn = new Set();
|
|
1935
|
+
for (const m of code.matchAll(/=\{\s*([\w$]+)\s*\}|\.\.\.\s*([\w$]+)/g)) handedOn.add(m[1] || m[2]);
|
|
1936
|
+
const used = new Set(handedOn);
|
|
1937
|
+
// No variable-length lookbehind: masked strings are long space runs.
|
|
1938
|
+
for (const m of code.matchAll(/(?<![\w$.])([\w$]+)(?=\s*\()|[,(]\s*([\w$]+)(?=\s*[,)])/g)) used.add(m[1] || m[2]);
|
|
1939
|
+
return { words: new Set(code.match(/(?<![\w$.])[\w$]+/g)), members, handedOn, used };
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
// Each `const x = hook(` binding: its line, and which of its fields the code
|
|
1943
|
+
// reads (any read) or uses (calls or passes on). One scan per hook: a
|
|
1944
|
+
// per-binding scan was quadratic in the bindings.
|
|
1945
|
+
function _hookBindings(code, hook) {
|
|
1946
|
+
const bindings = new RegExp(String.raw`\b(?:const|let|var)\s+([\w$]+|\{[^{}]*\})\s*=\s*${hook}\s*\(`, "g");
|
|
1947
|
+
const calls = [...code.matchAll(bindings)];
|
|
1948
|
+
if (calls.length === 0) return [];
|
|
1949
|
+
// A destructure names every field; only reads elsewhere count.
|
|
1950
|
+
const { words, members, handedOn, used } = _codeReads(code.replace(bindings, (m) => " ".repeat(m.length)));
|
|
1951
|
+
const lineAt = _lineCounter(code);
|
|
1952
|
+
return calls.map((call) => {
|
|
1953
|
+
const binding = call[1];
|
|
1954
|
+
const locals = binding.startsWith("{") ? _destructuredLocals(binding) : null;
|
|
1955
|
+
const local = (field, seen) => (locals ? !!locals[field] && seen.has(locals[field]) : members.has(`${binding}.${field}`));
|
|
1956
|
+
return {
|
|
1957
|
+
line: lineAt(call.index),
|
|
1958
|
+
reads: (field) => local(field, words),
|
|
1959
|
+
uses: (field) => local(field, used),
|
|
1960
|
+
handedOn: !locals && handedOn.has(binding),
|
|
1961
|
+
};
|
|
1962
|
+
});
|
|
1941
1963
|
}
|
|
1942
1964
|
|
|
1943
1965
|
function _bankIdOrderRules(source) {
|
|
1944
1966
|
const code = _stripNonCode(source);
|
|
1967
|
+
const lines = source.split(/\r?\n/);
|
|
1945
1968
|
const findings = [];
|
|
1946
1969
|
for (const { hook, verb, sameDevice } of BANKID_ORDER_HOOKS) {
|
|
1947
|
-
const
|
|
1948
|
-
|
|
1949
|
-
// The destructure itself names every field; only reads elsewhere count.
|
|
1950
|
-
const rest = code.slice(0, call.index) + " ".repeat(call[0].length) + code.slice(call.index + call[0].length);
|
|
1951
|
-
const { read, handedOn } = _bankIdOrderReads(call[1]);
|
|
1952
|
-
const reads = (field) => !!read(field) && read(field).test(rest);
|
|
1953
|
-
if (!reads(verb) || (handedOn && handedOn.test(rest))) continue;
|
|
1970
|
+
for (const { line, reads, handedOn } of _hookBindings(code, hook)) {
|
|
1971
|
+
if (!reads(verb) || handedOn) continue;
|
|
1954
1972
|
if (reads("qr") && (!sameDevice || reads("autoStartToken"))) continue;
|
|
1955
|
-
const line = code.slice(0, call.index).split(/\r?\n/).length;
|
|
1956
1973
|
findings.push({
|
|
1957
1974
|
rule: "bankid-order-not-shown",
|
|
1958
1975
|
severity: "error",
|
|
@@ -1962,13 +1979,34 @@ function _bankIdOrderRules(source) {
|
|
|
1962
1979
|
(sameDevice ? ` and a button calling Linking.openURL(bankIdAppUrl(autoStartToken))` : "") +
|
|
1963
1980
|
`, or BankID ends it unopened.`,
|
|
1964
1981
|
line,
|
|
1965
|
-
snippet: (
|
|
1982
|
+
snippet: (lines[line - 1] || "").trim().slice(0, 200),
|
|
1966
1983
|
});
|
|
1967
1984
|
}
|
|
1968
1985
|
}
|
|
1969
1986
|
return findings;
|
|
1970
1987
|
}
|
|
1971
1988
|
|
|
1989
|
+
// sc-17552 — a plan a widget sells, its holder can stop renewing there.
|
|
1990
|
+
// One-time plans never renew, so the control never shows for them. Judged per
|
|
1991
|
+
// file: one component may buy and another cancel.
|
|
1992
|
+
function _accessPlanCancelRules(source) {
|
|
1993
|
+
const code = _stripNonCode(source);
|
|
1994
|
+
const lines = source.split(/\r?\n/);
|
|
1995
|
+
const bindings = _hookBindings(code, "useAccessPlans");
|
|
1996
|
+
if (bindings.some(({ uses, handedOn }) => uses("cancel") || handedOn)) return [];
|
|
1997
|
+
return bindings
|
|
1998
|
+
.filter(({ uses }) => uses("purchase"))
|
|
1999
|
+
.map(({ line }) => ({
|
|
2000
|
+
rule: "access-plan-cancel-missing",
|
|
2001
|
+
severity: "error",
|
|
2002
|
+
label:
|
|
2003
|
+
"useAccessPlans().purchase() sells a plan its buyer can never cancel. For a held plan with renews: true, " +
|
|
2004
|
+
"render a \"Cancel renewal\" control that calls cancel(plan.id), and show access_ends_at once it is cancelled.",
|
|
2005
|
+
line,
|
|
2006
|
+
snippet: (lines[line - 1] || "").trim().slice(0, 200),
|
|
2007
|
+
}));
|
|
2008
|
+
}
|
|
2009
|
+
|
|
1972
2010
|
// sc-16511 — soft warning, the read twin of `datastore-error-not-branched`.
|
|
1973
2011
|
// A read refused because the viewer may not see the table (a signed-out
|
|
1974
2012
|
// visitor gets NOT_FOUND, a signed-in one FORBIDDEN) never clears on a retry,
|
|
@@ -3802,6 +3840,7 @@ function lintSource(source, options) {
|
|
|
3802
3840
|
findings.push(..._readErrorHandlingRules(source));
|
|
3803
3841
|
findings.push(..._aggregateErrorRules(source));
|
|
3804
3842
|
findings.push(..._bankIdOrderRules(source));
|
|
3843
|
+
findings.push(..._accessPlanCancelRules(source));
|
|
3805
3844
|
// sc-5206 — soft warnings steering a widget toward the two new hooks.
|
|
3806
3845
|
findings.push(..._rawUseMemoIntoDatastoreQueryRules(source));
|
|
3807
3846
|
findings.push(..._handRolledWriteGateRules(source));
|
package/dist/linter.js
CHANGED
|
@@ -1920,34 +1920,51 @@ function _destructuredLocals(pattern) {
|
|
|
1920
1920
|
return locals;
|
|
1921
1921
|
}
|
|
1922
1922
|
|
|
1923
|
-
//
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
const
|
|
1934
|
-
|
|
1935
|
-
|
|
1923
|
+
// What the code reads, scanned once: bare identifiers, `name.field` member
|
|
1924
|
+
// reads, names handed whole to a child (`={ap}`, `...ap`), which does the work,
|
|
1925
|
+
// and names called or passed on: JSX text ("cancel any time") is neither.
|
|
1926
|
+
function _codeReads(code) {
|
|
1927
|
+
const members = new Set();
|
|
1928
|
+
for (const m of code.matchAll(/(?<![\w$])([\w$]+)(?=\s*\??\.\s*([\w$]+))/g)) members.add(`${m[1]}.${m[2]}`);
|
|
1929
|
+
const handedOn = new Set();
|
|
1930
|
+
for (const m of code.matchAll(/=\{\s*([\w$]+)\s*\}|\.\.\.\s*([\w$]+)/g)) handedOn.add(m[1] || m[2]);
|
|
1931
|
+
const used = new Set(handedOn);
|
|
1932
|
+
// No variable-length lookbehind: masked strings are long space runs.
|
|
1933
|
+
for (const m of code.matchAll(/(?<![\w$.])([\w$]+)(?=\s*\()|[,(]\s*([\w$]+)(?=\s*[,)])/g)) used.add(m[1] || m[2]);
|
|
1934
|
+
return { words: new Set(code.match(/(?<![\w$.])[\w$]+/g)), members, handedOn, used };
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
// Each `const x = hook(` binding: its line, and which of its fields the code
|
|
1938
|
+
// reads (any read) or uses (calls or passes on). One scan per hook: a
|
|
1939
|
+
// per-binding scan was quadratic in the bindings.
|
|
1940
|
+
function _hookBindings(code, hook) {
|
|
1941
|
+
const bindings = new RegExp(String.raw`\b(?:const|let|var)\s+([\w$]+|\{[^{}]*\})\s*=\s*${hook}\s*\(`, "g");
|
|
1942
|
+
const calls = [...code.matchAll(bindings)];
|
|
1943
|
+
if (calls.length === 0) return [];
|
|
1944
|
+
// A destructure names every field; only reads elsewhere count.
|
|
1945
|
+
const { words, members, handedOn, used } = _codeReads(code.replace(bindings, (m) => " ".repeat(m.length)));
|
|
1946
|
+
const lineAt = _lineCounter(code);
|
|
1947
|
+
return calls.map((call) => {
|
|
1948
|
+
const binding = call[1];
|
|
1949
|
+
const locals = binding.startsWith("{") ? _destructuredLocals(binding) : null;
|
|
1950
|
+
const local = (field, seen) => (locals ? !!locals[field] && seen.has(locals[field]) : members.has(`${binding}.${field}`));
|
|
1951
|
+
return {
|
|
1952
|
+
line: lineAt(call.index),
|
|
1953
|
+
reads: (field) => local(field, words),
|
|
1954
|
+
uses: (field) => local(field, used),
|
|
1955
|
+
handedOn: !locals && handedOn.has(binding),
|
|
1956
|
+
};
|
|
1957
|
+
});
|
|
1936
1958
|
}
|
|
1937
1959
|
|
|
1938
1960
|
function _bankIdOrderRules(source) {
|
|
1939
1961
|
const code = _stripNonCode(source);
|
|
1962
|
+
const lines = source.split(/\r?\n/);
|
|
1940
1963
|
const findings = [];
|
|
1941
1964
|
for (const { hook, verb, sameDevice } of BANKID_ORDER_HOOKS) {
|
|
1942
|
-
const
|
|
1943
|
-
|
|
1944
|
-
// The destructure itself names every field; only reads elsewhere count.
|
|
1945
|
-
const rest = code.slice(0, call.index) + " ".repeat(call[0].length) + code.slice(call.index + call[0].length);
|
|
1946
|
-
const { read, handedOn } = _bankIdOrderReads(call[1]);
|
|
1947
|
-
const reads = (field) => !!read(field) && read(field).test(rest);
|
|
1948
|
-
if (!reads(verb) || (handedOn && handedOn.test(rest))) continue;
|
|
1965
|
+
for (const { line, reads, handedOn } of _hookBindings(code, hook)) {
|
|
1966
|
+
if (!reads(verb) || handedOn) continue;
|
|
1949
1967
|
if (reads("qr") && (!sameDevice || reads("autoStartToken"))) continue;
|
|
1950
|
-
const line = code.slice(0, call.index).split(/\r?\n/).length;
|
|
1951
1968
|
findings.push({
|
|
1952
1969
|
rule: "bankid-order-not-shown",
|
|
1953
1970
|
severity: "error",
|
|
@@ -1957,13 +1974,34 @@ function _bankIdOrderRules(source) {
|
|
|
1957
1974
|
(sameDevice ? ` and a button calling Linking.openURL(bankIdAppUrl(autoStartToken))` : "") +
|
|
1958
1975
|
`, or BankID ends it unopened.`,
|
|
1959
1976
|
line,
|
|
1960
|
-
snippet: (
|
|
1977
|
+
snippet: (lines[line - 1] || "").trim().slice(0, 200),
|
|
1961
1978
|
});
|
|
1962
1979
|
}
|
|
1963
1980
|
}
|
|
1964
1981
|
return findings;
|
|
1965
1982
|
}
|
|
1966
1983
|
|
|
1984
|
+
// sc-17552 — a plan a widget sells, its holder can stop renewing there.
|
|
1985
|
+
// One-time plans never renew, so the control never shows for them. Judged per
|
|
1986
|
+
// file: one component may buy and another cancel.
|
|
1987
|
+
function _accessPlanCancelRules(source) {
|
|
1988
|
+
const code = _stripNonCode(source);
|
|
1989
|
+
const lines = source.split(/\r?\n/);
|
|
1990
|
+
const bindings = _hookBindings(code, "useAccessPlans");
|
|
1991
|
+
if (bindings.some(({ uses, handedOn }) => uses("cancel") || handedOn)) return [];
|
|
1992
|
+
return bindings
|
|
1993
|
+
.filter(({ uses }) => uses("purchase"))
|
|
1994
|
+
.map(({ line }) => ({
|
|
1995
|
+
rule: "access-plan-cancel-missing",
|
|
1996
|
+
severity: "error",
|
|
1997
|
+
label:
|
|
1998
|
+
"useAccessPlans().purchase() sells a plan its buyer can never cancel. For a held plan with renews: true, " +
|
|
1999
|
+
"render a \"Cancel renewal\" control that calls cancel(plan.id), and show access_ends_at once it is cancelled.",
|
|
2000
|
+
line,
|
|
2001
|
+
snippet: (lines[line - 1] || "").trim().slice(0, 200),
|
|
2002
|
+
}));
|
|
2003
|
+
}
|
|
2004
|
+
|
|
1967
2005
|
// sc-16511 — soft warning, the read twin of `datastore-error-not-branched`.
|
|
1968
2006
|
// A read refused because the viewer may not see the table (a signed-out
|
|
1969
2007
|
// visitor gets NOT_FOUND, a signed-in one FORBIDDEN) never clears on a retry,
|
|
@@ -3797,6 +3835,7 @@ export function lintSource(source, options) {
|
|
|
3797
3835
|
findings.push(..._readErrorHandlingRules(source));
|
|
3798
3836
|
findings.push(..._aggregateErrorRules(source));
|
|
3799
3837
|
findings.push(..._bankIdOrderRules(source));
|
|
3838
|
+
findings.push(..._accessPlanCancelRules(source));
|
|
3800
3839
|
// sc-5206 — soft warnings steering a widget toward the two new hooks.
|
|
3801
3840
|
findings.push(..._rawUseMemoIntoDatastoreQueryRules(source));
|
|
3802
3841
|
findings.push(..._handRolledWriteGateRules(source));
|
package/package.json
CHANGED
package/src/contract.js
CHANGED
|
@@ -2479,7 +2479,7 @@ const HOOKS = [
|
|
|
2479
2479
|
signature: "useAccessPlans()",
|
|
2480
2480
|
returnShape: {
|
|
2481
2481
|
plans:
|
|
2482
|
-
"Array<{ id, name, price_cents, currency, billing: \"one_time\" | \"monthly\", owned, renews, access_ends_at, purchase_available }> // owned: the user holds it; renews: a held monthly plan will charge again; access_ends_at: end of held access without a renewal (null for one-time); purchase_available: this plan can be bought here — false in an iOS/Android build for a plan the workspace does not sell in-app",
|
|
2482
|
+
"Array<{ id, name, price_cents, currency, billing: \"one_time\" | \"monthly\", owned, renews, access_ends_at, purchase_available }> // owned: the user holds it; renews: a held monthly plan will charge again; access_ends_at: end of held access without a renewal (null for one-time); purchase_available: this plan can be bought here — false in an iOS/Android build for a plan the workspace does not sell in-app, and for a plan the user holds that is no longer on sale (listed so they can still cancel it)",
|
|
2483
2483
|
loading: "boolean",
|
|
2484
2484
|
error: "PaymentError | null",
|
|
2485
2485
|
purchaseAvailable:
|
|
@@ -2487,7 +2487,7 @@ const HOOKS = [
|
|
|
2487
2487
|
purchase:
|
|
2488
2488
|
"(planId, { return_path? }?) => Promise<{ plan_id, status: \"ACTIVE\" | \"PENDING\" }> // pass ONLY the plan id; the server sets price and group; the host opens hosted Checkout on the web and the store's in-app purchase sheet in an iOS/Android build; access arrives with the payment confirmation, so refresh() a moment later",
|
|
2489
2489
|
cancel:
|
|
2490
|
-
"(planId) => Promise<{ plan_id, renews: false, access_ends_at }> // stop a renewing monthly plan; access runs to access_ends_at — offer it beside every plan with renews: true",
|
|
2490
|
+
"(planId) => Promise<{ plan_id, renews: false, access_ends_at }> // stop a renewing monthly plan; access runs to access_ends_at — offer it beside every plan with renews: true; a widget that calls purchase without it is refused (access-plan-cancel-missing)",
|
|
2491
2491
|
refresh: "() => Promise<void> // re-read after returning from Checkout",
|
|
2492
2492
|
},
|
|
2493
2493
|
requiredContextSlice: [
|
|
@@ -7068,7 +7068,10 @@ const CONTRACT = deepFreeze({
|
|
|
7068
7068
|
// value, and an update may still change it.
|
|
7069
7069
|
// 1.271.0: additive (sc-17551) — `useDatastoreAggregate` groups by a
|
|
7070
7070
|
// relation column; new warning lint `aggregate-error-not-read`.
|
|
7071
|
-
|
|
7071
|
+
// 1.272.0: stricter lint (sc-17552) — a widget that calls
|
|
7072
|
+
// useAccessPlans().purchase without cancel is the publish-blocking
|
|
7073
|
+
// `access-plan-cancel-missing` finding.
|
|
7074
|
+
version: "1.272.0",
|
|
7072
7075
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7073
7076
|
hooks: HOOKS,
|
|
7074
7077
|
primitives: PRIMITIVES,
|