@aglyn/aglyn 1.0.0-beta.209 → 1.0.0-beta.211
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/package.json +11 -11
- package/src/lib/app-utils/docs-index.generated.js +1 -1
- package/src/lib/app-utils/docs-index.generated.js.map +1 -1
- package/src/lib/app-utils/announce-site-wide-change.d.ts +0 -45
- package/src/lib/app-utils/announce-site-wide-change.js +0 -58
- package/src/lib/app-utils/announce-site-wide-change.js.map +0 -1
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2026 Aglyn LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* A plugin's console card just saved a SITE-WIDE setting: drop every cached
|
|
19
|
-
* page of the site (AGL-3386).
|
|
20
|
-
*
|
|
21
|
-
* The plugin-side door to the console's own `/api/screens/revalidate`, which
|
|
22
|
-
* a plugin cannot import. A setting that lives on the host document, or on a
|
|
23
|
-
* site-wide settings document beside it — the announcement bar, the popup,
|
|
24
|
-
* the store's currency — is rendered on every page and saved with no publish
|
|
25
|
-
* step, so without this the live site shows it only once each page's
|
|
26
|
-
* hour-long cache happens to lapse.
|
|
27
|
-
*
|
|
28
|
-
* `entireHost` because such a setting has no address of its own. It is the
|
|
29
|
-
* console route's explicit whole-site branch, authorized for exactly the
|
|
30
|
-
* roles the rules let write the site — the caller already proved that by
|
|
31
|
-
* writing.
|
|
32
|
-
*
|
|
33
|
-
* Call it AFTER the write has succeeded, and do not await it into the save's
|
|
34
|
-
* outcome: it never throws and never rejects, because a cache hint that fails
|
|
35
|
-
* must not make a successful save look failed. The hour-long window is still
|
|
36
|
-
* underneath as the backstop.
|
|
37
|
-
*/
|
|
38
|
-
export declare function announceSiteWideChange(options: {
|
|
39
|
-
/** The signed-in user; its ID token authenticates the console route. */
|
|
40
|
-
user: {
|
|
41
|
-
getIdToken?: () => Promise<string>;
|
|
42
|
-
} | null | undefined;
|
|
43
|
-
hostId: string;
|
|
44
|
-
}): Promise<boolean>;
|
|
45
|
-
export default announceSiteWideChange;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2026 Aglyn LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/ import { authorizedFetch } from "@aglyn/shared-util-http/authorized-token";
|
|
17
|
-
/**
|
|
18
|
-
* A plugin's console card just saved a SITE-WIDE setting: drop every cached
|
|
19
|
-
* page of the site (AGL-3386).
|
|
20
|
-
*
|
|
21
|
-
* The plugin-side door to the console's own `/api/screens/revalidate`, which
|
|
22
|
-
* a plugin cannot import. A setting that lives on the host document, or on a
|
|
23
|
-
* site-wide settings document beside it — the announcement bar, the popup,
|
|
24
|
-
* the store's currency — is rendered on every page and saved with no publish
|
|
25
|
-
* step, so without this the live site shows it only once each page's
|
|
26
|
-
* hour-long cache happens to lapse.
|
|
27
|
-
*
|
|
28
|
-
* `entireHost` because such a setting has no address of its own. It is the
|
|
29
|
-
* console route's explicit whole-site branch, authorized for exactly the
|
|
30
|
-
* roles the rules let write the site — the caller already proved that by
|
|
31
|
-
* writing.
|
|
32
|
-
*
|
|
33
|
-
* Call it AFTER the write has succeeded, and do not await it into the save's
|
|
34
|
-
* outcome: it never throws and never rejects, because a cache hint that fails
|
|
35
|
-
* must not make a successful save look failed. The hour-long window is still
|
|
36
|
-
* underneath as the backstop.
|
|
37
|
-
*/ export async function announceSiteWideChange(options) {
|
|
38
|
-
const { user, hostId } = options;
|
|
39
|
-
if (!hostId) return false;
|
|
40
|
-
try {
|
|
41
|
-
const response = await authorizedFetch(user, '/api/screens/revalidate', {
|
|
42
|
-
method: 'POST',
|
|
43
|
-
headers: {
|
|
44
|
-
'Content-Type': 'application/json'
|
|
45
|
-
},
|
|
46
|
-
body: JSON.stringify({
|
|
47
|
-
hostId,
|
|
48
|
-
entireHost: true
|
|
49
|
-
})
|
|
50
|
-
});
|
|
51
|
-
return response.ok;
|
|
52
|
-
} catch (unused) {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
export default announceSiteWideChange;
|
|
57
|
-
|
|
58
|
-
//# sourceMappingURL=announce-site-wide-change.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/announce-site-wide-change.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\n\n/**\n * A plugin's console card just saved a SITE-WIDE setting: drop every cached\n * page of the site (AGL-3386).\n *\n * The plugin-side door to the console's own `/api/screens/revalidate`, which\n * a plugin cannot import. A setting that lives on the host document, or on a\n * site-wide settings document beside it — the announcement bar, the popup,\n * the store's currency — is rendered on every page and saved with no publish\n * step, so without this the live site shows it only once each page's\n * hour-long cache happens to lapse.\n *\n * `entireHost` because such a setting has no address of its own. It is the\n * console route's explicit whole-site branch, authorized for exactly the\n * roles the rules let write the site — the caller already proved that by\n * writing.\n *\n * Call it AFTER the write has succeeded, and do not await it into the save's\n * outcome: it never throws and never rejects, because a cache hint that fails\n * must not make a successful save look failed. The hour-long window is still\n * underneath as the backstop.\n */\nexport async function announceSiteWideChange(options: {\n /** The signed-in user; its ID token authenticates the console route. */\n user: { getIdToken?: () => Promise<string> } | null | undefined\n hostId: string\n}): Promise<boolean> {\n const { user, hostId } = options\n if (!hostId) return false\n try {\n const response = await authorizedFetch(user, '/api/screens/revalidate', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId, entireHost: true }),\n })\n return response.ok\n } catch {\n return false\n }\n}\n\nexport default announceSiteWideChange\n"],"names":["authorizedFetch","announceSiteWideChange","options","user","hostId","response","method","headers","body","JSON","stringify","entireHost","ok"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,eAAe,QAAQ,2CAA0C;AAE1E;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,eAAeC,uBAAuBC,OAI5C;IACC,MAAM,EAAEC,IAAI,EAAEC,MAAM,EAAE,GAAGF;IACzB,IAAI,CAACE,QAAQ,OAAO;IACpB,IAAI;QACF,MAAMC,WAAW,MAAML,gBAAgBG,MAAM,2BAA2B;YACtEG,QAAQ;YACRC,SAAS;gBAAE,gBAAgB;YAAmB;YAC9CC,MAAMC,KAAKC,SAAS,CAAC;gBAAEN;gBAAQO,YAAY;YAAK;QAClD;QACA,OAAON,SAASO,EAAE;IACpB,EAAE,eAAM;QACN,OAAO;IACT;AACF;AAEA,eAAeX,uBAAsB"}
|