@conduction/nextcloud-vue 2.160.0 → 2.162.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/dist/esm/components/CnActionsMenu/CnActionsMenu.vue2.js +3 -2
- package/dist/esm/components/CnActionsMenu/CnActionsMenu.vue2.js.map +1 -1
- package/dist/esm/components/CnActionsMenu/CnActionsMenu.vue3.js.map +1 -1
- package/dist/esm/components/CnAddressSearch/CnAddressSearch.vue.js +1 -1
- package/dist/esm/components/CnAddressSearch/CnAddressSearch.vue2.js +2 -1
- package/dist/esm/components/CnAddressSearch/CnAddressSearch.vue2.js.map +1 -1
- package/dist/esm/components/CnAddressSearch/CnAddressSearch.vue3.js.map +1 -1
- package/dist/esm/components/CnAuditTrailCard/CnAuditTrailCard.vue.js +1 -1
- package/dist/esm/components/CnAuditTrailCard/CnAuditTrailCard.vue2.js +20 -2
- package/dist/esm/components/CnAuditTrailCard/CnAuditTrailCard.vue2.js.map +1 -1
- package/dist/esm/components/CnAuditTrailCard/CnAuditTrailCard.vue3.js.map +1 -1
- package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue.js +1 -1
- package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue2.js +2 -1
- package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue2.js.map +1 -1
- package/dist/esm/components/CnDashboardPage/CnDashboardPage.vue3.js.map +1 -1
- package/dist/esm/components/CnDataTable/CnDataTable.vue2.js +8 -8
- package/dist/esm/components/CnDataTable/CnDataTable.vue2.js.map +1 -1
- package/dist/esm/components/CnDataTable/CnDataTable.vue3.js.map +1 -1
- package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue.js +1 -1
- package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue2.js +23 -0
- package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue2.js.map +1 -1
- package/dist/esm/components/CnDetailWidgetHost/CnDetailWidgetHost.vue3.js.map +1 -1
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue.js +1 -1
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue2.js +48 -5
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue3.js +2 -1
- package/dist/esm/components/CnFactsWidget/CnFactsWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue.js +1 -1
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue2.js +4 -3
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue2.js.map +1 -1
- package/dist/esm/components/CnFilesBrowser/CnFilesBrowser.vue3.js.map +1 -1
- package/dist/esm/components/CnFilesBrowser/filesBrowser.js +6 -5
- package/dist/esm/components/CnFilesBrowser/filesBrowser.js.map +1 -1
- package/dist/esm/components/CnFilesWidget/CnFilesWidget.vue.js +1 -1
- package/dist/esm/components/CnFilesWidget/CnFilesWidget.vue2.js +2 -1
- package/dist/esm/components/CnFilesWidget/CnFilesWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnFilesWidget/CnFilesWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnFlowRunsWidget/CnFlowRunsWidget.vue.js +1 -1
- package/dist/esm/components/CnFlowRunsWidget/CnFlowRunsWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnFlowRunsWidget/CnFlowRunsWidget.vue3.js +41 -39
- package/dist/esm/components/CnFlowRunsWidget/CnFlowRunsWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnFolderSidebar/webdavFolders.js +2 -1
- package/dist/esm/components/CnFolderSidebar/webdavFolders.js.map +1 -1
- package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js +11 -3
- package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js.map +1 -1
- package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js.map +1 -1
- package/dist/esm/components/CnMenuWidget/menuActive.js +2 -1
- package/dist/esm/components/CnMenuWidget/menuActive.js.map +1 -1
- package/dist/esm/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue.js +1 -1
- package/dist/esm/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue2.js +39 -2
- package/dist/esm/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue3.js +1 -1
- package/dist/esm/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnPageTreeNode/CnPageTreeNode.vue.js +1 -1
- package/dist/esm/components/CnPageTreeNode/CnPageTreeNode.vue2.js +2 -1
- package/dist/esm/components/CnPageTreeNode/CnPageTreeNode.vue2.js.map +1 -1
- package/dist/esm/components/CnPageTreeNode/CnPageTreeNode.vue3.js.map +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue.js +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js +5 -5
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnRecordListWidget/CnRecordListWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnStatWidget/CnStatWidget.vue.js +1 -1
- package/dist/esm/components/CnStatWidget/CnStatWidget.vue2.js +10 -1
- package/dist/esm/components/CnStatWidget/CnStatWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnStatWidget/CnStatWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnTabsWidget/CnTabsWidget.vue.js +1 -1
- package/dist/esm/components/CnTabsWidget/CnTabsWidget.vue2.js +3 -2
- package/dist/esm/components/CnTabsWidget/CnTabsWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnTabsWidget/CnTabsWidget.vue3.js.map +1 -1
- package/dist/esm/components/CnTimelineWidget/CnTimelineWidget.vue.js +1 -1
- package/dist/esm/components/CnTimelineWidget/CnTimelineWidget.vue2.js +2 -2
- package/dist/esm/components/CnTimelineWidget/CnTimelineWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnTimelineWidget/CnTimelineWidget.vue3.js.map +1 -1
- package/dist/esm/integrations/builtin/email/CnEmailTab.vue.js +1 -1
- package/dist/esm/integrations/builtin/email/CnEmailTab.vue2.js +130 -1
- package/dist/esm/integrations/builtin/email/CnEmailTab.vue2.js.map +1 -1
- package/dist/esm/integrations/builtin/email/CnEmailTab.vue3.js +27 -16
- package/dist/esm/integrations/builtin/email/CnEmailTab.vue3.js.map +1 -1
- package/dist/esm/l10n/en.json.js +9 -1
- package/dist/esm/l10n/en.json.js.map +1 -1
- package/dist/esm/l10n/nl.json.js +9 -1
- package/dist/esm/l10n/nl.json.js.map +1 -1
- package/dist/esm/library-style.js +1 -1
- package/dist/esm/nextcloud-vue.css +641 -569
- package/dist/esm/utils/auditEntries.js +25 -1
- package/dist/esm/utils/auditEntries.js.map +1 -1
- package/dist/esm/utils/buildManifestRoutes.js +2 -1
- package/dist/esm/utils/buildManifestRoutes.js.map +1 -1
- package/dist/esm/utils/cnFetch.js +1 -15
- package/dist/esm/utils/cnFetch.js.map +1 -1
- package/dist/esm/utils/fillTemplate.js +29 -2
- package/dist/esm/utils/fillTemplate.js.map +1 -1
- package/dist/esm/utils/forge.js +4 -1
- package/dist/esm/utils/forge.js.map +1 -1
- package/dist/esm/utils/myTeam.js +17 -3
- package/dist/esm/utils/myTeam.js.map +1 -1
- package/dist/esm/utils/rowAggregate.js +20 -1
- package/dist/esm/utils/rowAggregate.js.map +1 -1
- package/dist/esm/utils/trailingSlashes.js +24 -0
- package/dist/esm/utils/trailingSlashes.js.map +1 -0
- package/dist/nextcloud-vue.cjs.js +1069 -683
- package/dist/nextcloud-vue.cjs.js.map +2 -2
- package/dist/nextcloud-vue.css +641 -569
- package/l10n/en.json +9 -1
- package/l10n/nl.json +9 -1
- package/package.json +1 -1
- package/src/components/CnActionsMenu/CnActionsMenu.vue +3 -2
- package/src/components/CnAddressSearch/CnAddressSearch.vue +2 -1
- package/src/components/CnAuditTrailCard/CnAuditTrailCard.vue +20 -2
- package/src/components/CnDashboardPage/CnDashboardPage.vue +2 -1
- package/src/components/CnDataTable/CnDataTable.vue +8 -8
- package/src/components/CnDetailWidgetHost/CnDetailWidgetHost.vue +23 -0
- package/src/components/CnFactsWidget/CnFactsWidget.vue +49 -5
- package/src/components/CnFilesBrowser/CnFilesBrowser.vue +4 -3
- package/src/components/CnFilesBrowser/filesBrowser.js +6 -5
- package/src/components/CnFilesWidget/CnFilesWidget.vue +2 -1
- package/src/components/CnFlowRunsWidget/CnFlowRunsWidget.vue +1 -1
- package/src/components/CnFolderSidebar/webdavFolders.js +2 -1
- package/src/components/CnIndexPage/CnIndexPage.vue +11 -3
- package/src/components/CnMenuWidget/menuActive.js +2 -1
- package/src/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue +40 -3
- package/src/components/CnPageTreeNode/CnPageTreeNode.vue +2 -1
- package/src/components/CnRecordListWidget/CnRecordListWidget.vue +5 -5
- package/src/components/CnStatWidget/CnStatWidget.vue +10 -1
- package/src/components/CnTabsWidget/CnTabsWidget.vue +3 -2
- package/src/components/CnTimelineWidget/CnTimelineWidget.vue +2 -2
- package/src/css/dialog.css +7 -0
- package/src/css/look-board-detail.css +35 -0
- package/src/css/look-board.css +18 -1
- package/src/integrations/builtin/email/CnEmailTab.vue +155 -4
- package/src/utils/auditEntries.js +24 -0
- package/src/utils/buildManifestRoutes.js +2 -1
- package/src/utils/cnFetch.js +3 -15
- package/src/utils/fillTemplate.js +29 -2
- package/src/utils/forge.js +3 -1
- package/src/utils/myTeam.js +17 -3
- package/src/utils/rowAggregate.js +19 -0
- package/src/utils/trailingSlashes.js +21 -0
|
@@ -44,5 +44,29 @@ function keepAuditEntries(entries, { excludeActions = [], excludeActors = [] } =
|
|
|
44
44
|
&& !isEmptyUpdate(entry))
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
/**
|
|
48
|
+
* The trail query parameters that leave the excluded actions and actors out
|
|
49
|
+
* on the server (`action[notIn]`, `user[notIn]`), so a page read from the
|
|
50
|
+
* trail holds what a history shows. `keepAuditEntries` still filters what
|
|
51
|
+
* comes back. Empty when nothing is left out.
|
|
52
|
+
*
|
|
53
|
+
* @param {{excludeActions?: Array<string>, excludeActors?: Array<string>}} [options] What to leave out.
|
|
54
|
+
* @return {Object<string, string>} The parameters.
|
|
55
|
+
* @spec openspec/changes/audit-card-exclusions-in-the-query/specs/audit-trail/spec.md#requirement-a-timeline-and-a-tab-count-ask-the-trail-to-leave-out-what-they-hide
|
|
56
|
+
*/
|
|
57
|
+
function auditExclusionParams({ excludeActions = [], excludeActors = [] } = {}) {
|
|
58
|
+
const list = (values) => (Array.isArray(values) ? values : []).map(String).filter(Boolean);
|
|
59
|
+
const params = {};
|
|
60
|
+
const actions = list(excludeActions);
|
|
61
|
+
const actors = list(excludeActors);
|
|
62
|
+
if (actions.length > 0) {
|
|
63
|
+
params['action[notIn]'] = actions.join(',');
|
|
64
|
+
}
|
|
65
|
+
if (actors.length > 0) {
|
|
66
|
+
params['user[notIn]'] = actors.join(',');
|
|
67
|
+
}
|
|
68
|
+
return params
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export { auditExclusionParams, isEmptyUpdate, keepAuditEntries };
|
|
48
72
|
//# sourceMappingURL=auditEntries.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auditEntries.js","sources":["../../../src/utils/auditEntries.js"],"sourcesContent":["/**\n * SPDX-FileCopyrightText: 2026 Conduction B.V.\n * SPDX-License-Identifier: EUPL-1.2\n *\n * auditEntries — which audit entries a history shows. Read by the History\n * card (CnAuditTrailCard) and by a tab that counts the history\n * (CnTabsWidget `countFrom.auditTrail`), so the two never disagree.\n */\n\n/**\n * Whether an audit entry is an update that changed no field: its `changed`\n * map holds only `@self` bookkeeping or pairs whose old and new are equal.\n * An entry without a `changed` map is kept, since nothing says it was empty.\n *\n * @param {object} entry The audit entry.\n * @return {boolean}\n */\nexport function isEmptyUpdate(entry) {\n\tif (String((entry && (entry.action || entry.event)) || '').toLowerCase() !== 'update') {\n\t\treturn false\n\t}\n\tconst changed = entry.changed\n\tif (!changed || typeof changed !== 'object' || Array.isArray(changed)) {\n\t\treturn false\n\t}\n\treturn Object.entries(changed).every(([field, pair]) => field.startsWith('@')\n\t\t|| (pair && typeof pair === 'object' && JSON.stringify(pair.old ?? null) === JSON.stringify(pair.new ?? null)))\n}\n\n/**\n * The entries a history shows: without the actions and actors it leaves out\n * (case-insensitive) and without updates that changed nothing.\n *\n * @param {Array<object>} entries The audit entries.\n * @param {{excludeActions?: Array<string>, excludeActors?: Array<string>}} [options] What to leave out.\n * @return {Array<object>} The entries kept.\n * @spec openspec/changes/tab-count-audit-trail/specs/tab-counts/spec.md#requirement-a-history-tab-can-count-the-records-changes\n */\nexport function keepAuditEntries(entries, { excludeActions = [], excludeActors = [] } = {}) {\n\tconst excluded = (Array.isArray(excludeActions) ? excludeActions : []).map((action) => String(action).toLowerCase())\n\tconst actors = (Array.isArray(excludeActors) ? excludeActors : []).map((actor) => String(actor).toLowerCase())\n\treturn (Array.isArray(entries) ? entries : []).filter((entry) => !excluded.includes(String(entry.action || entry.event || '').toLowerCase())\n\t\t&& !actors.includes(String(entry.user || '').toLowerCase())\n\t\t&& !isEmptyUpdate(entry))\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,aAAa,CAAC,KAAK,EAAE;AACrC,CAAC,IAAI,MAAM,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,WAAW,EAAE,KAAK,QAAQ,EAAE;AACxF,EAAE,OAAO,KAAK;AACd,EAAE;AACF,CAAC,MAAM,OAAO,GAAG,KAAK,CAAC,QAAO;AAC9B,CAAC,IAAI,CAAC,OA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,EAAE,CAAC;AAC7I,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AAC7D,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAC3B;;;;"}
|
|
1
|
+
{"version":3,"file":"auditEntries.js","sources":["../../../src/utils/auditEntries.js"],"sourcesContent":["/**\n * SPDX-FileCopyrightText: 2026 Conduction B.V.\n * SPDX-License-Identifier: EUPL-1.2\n *\n * auditEntries — which audit entries a history shows. Read by the History\n * card (CnAuditTrailCard) and by a tab that counts the history\n * (CnTabsWidget `countFrom.auditTrail`), so the two never disagree.\n */\n\n/**\n * Whether an audit entry is an update that changed no field: its `changed`\n * map holds only `@self` bookkeeping or pairs whose old and new are equal.\n * An entry without a `changed` map is kept, since nothing says it was empty.\n *\n * @param {object} entry The audit entry.\n * @return {boolean}\n */\nexport function isEmptyUpdate(entry) {\n\tif (String((entry && (entry.action || entry.event)) || '').toLowerCase() !== 'update') {\n\t\treturn false\n\t}\n\tconst changed = entry.changed\n\tif (!changed || typeof changed !== 'object' || Array.isArray(changed)) {\n\t\treturn false\n\t}\n\treturn Object.entries(changed).every(([field, pair]) => field.startsWith('@')\n\t\t|| (pair && typeof pair === 'object' && JSON.stringify(pair.old ?? null) === JSON.stringify(pair.new ?? null)))\n}\n\n/**\n * The entries a history shows: without the actions and actors it leaves out\n * (case-insensitive) and without updates that changed nothing.\n *\n * @param {Array<object>} entries The audit entries.\n * @param {{excludeActions?: Array<string>, excludeActors?: Array<string>}} [options] What to leave out.\n * @return {Array<object>} The entries kept.\n * @spec openspec/changes/tab-count-audit-trail/specs/tab-counts/spec.md#requirement-a-history-tab-can-count-the-records-changes\n */\nexport function keepAuditEntries(entries, { excludeActions = [], excludeActors = [] } = {}) {\n\tconst excluded = (Array.isArray(excludeActions) ? excludeActions : []).map((action) => String(action).toLowerCase())\n\tconst actors = (Array.isArray(excludeActors) ? excludeActors : []).map((actor) => String(actor).toLowerCase())\n\treturn (Array.isArray(entries) ? entries : []).filter((entry) => !excluded.includes(String(entry.action || entry.event || '').toLowerCase())\n\t\t&& !actors.includes(String(entry.user || '').toLowerCase())\n\t\t&& !isEmptyUpdate(entry))\n}\n\n/**\n * The trail query parameters that leave the excluded actions and actors out\n * on the server (`action[notIn]`, `user[notIn]`), so a page read from the\n * trail holds what a history shows. `keepAuditEntries` still filters what\n * comes back. Empty when nothing is left out.\n *\n * @param {{excludeActions?: Array<string>, excludeActors?: Array<string>}} [options] What to leave out.\n * @return {Object<string, string>} The parameters.\n * @spec openspec/changes/audit-card-exclusions-in-the-query/specs/audit-trail/spec.md#requirement-a-timeline-and-a-tab-count-ask-the-trail-to-leave-out-what-they-hide\n */\nexport function auditExclusionParams({ excludeActions = [], excludeActors = [] } = {}) {\n\tconst list = (values) => (Array.isArray(values) ? values : []).map(String).filter(Boolean)\n\tconst params = {}\n\tconst actions = list(excludeActions)\n\tconst actors = list(excludeActors)\n\tif (actions.length > 0) {\n\t\tparams['action[notIn]'] = actions.join(',')\n\t}\n\tif (actors.length > 0) {\n\t\tparams['user[notIn]'] = actors.join(',')\n\t}\n\treturn params\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,aAAa,CAAC,KAAK,EAAE;AACrC,CAAC,IAAI,MAAM,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,WAAW,EAAE,KAAK,QAAQ,EAAE;AACxF,EAAE,OAAO,KAAK;AACd,EAAE;AACF,CAAC,MAAM,OAAO,GAAG,KAAK,CAAC,QAAO;AAC9B,CAAC,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;AACxE,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AAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AAC7D,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAC3B,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,oBAAoB,CAAC,EAAE,cAAc,GAAG,EAAE,EAAE,aAAa,GAAG,EAAE,EAAE,GAAG,EAAE,EAAE;AACvF,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,EAAC;AAC3F,CAAC,MAAM,MAAM,GAAG,GAAE;AAClB,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,EAAC;AACrC,CAAC,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,EAAC;AACnC,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;AACzB,EAAE,MAAM,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,EAAC;AAC7C,EAAE;AACF,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;AACxB,EAAE,MAAM,CAAC,aAAa,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAC;AAC1C,EAAE;AACF,CAAC,OAAO,MAAM;AACd;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { routeParamNames } from './routeParams.js';
|
|
2
|
+
import { stripTrailingSlashes } from './trailingSlashes.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* SPDX-FileCopyrightText: 2026 Conduction B.V.
|
|
@@ -74,7 +75,7 @@ function pageHasSplitView(page) {
|
|
|
74
75
|
* @spec openspec/changes/case-page-and-list-as-a-place/specs/index-page/spec.md
|
|
75
76
|
*/
|
|
76
77
|
function splitRoutePath(route) {
|
|
77
|
-
const base = typeof route === 'string' ? route
|
|
78
|
+
const base = typeof route === 'string' ? stripTrailingSlashes(route) : '';
|
|
78
79
|
const param = routeParamNames(base).includes('id') ? 'splitId' : 'id';
|
|
79
80
|
return `${base}/split/:${param}`
|
|
80
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildManifestRoutes.js","sources":["../../../src/utils/buildManifestRoutes.js"],"sourcesContent":["/**\n * SPDX-FileCopyrightText: 2026 Conduction B.V.\n * SPDX-License-Identifier: EUPL-1.2\n *\n * buildManifestRoutes: the manifest's pages as vue-router route records.\n *\n * Until now every consuming app wrote this by hand:\n *\n * routes: manifest.pages.map((p) => ({ name: p.id, path: p.route, component: CnPageRenderer }))\n *\n * That one-liner can only ever produce one route per page, which is fine\n * until a page wants a second address for the same surface. The split view\n * needs exactly that: `/cases/split/:id` must mount the SAME index page as\n * `/cases`, because a list that unmounts loses the scroll position the split\n * view exists to keep. Five apps writing the extra record by hand would be\n * five spellings of it within a month, so the library builds them.\n *\n * Every record carries `meta.cnPageId`. CnPageRenderer reads that before it\n * falls back to matching `$route.name === page.id`, so a route whose name is\n * not a page id still resolves to its page instead of rendering nothing.\n *\n * @spec openspec/changes/case-page-and-list-as-a-place/specs/index-page/spec.md\n * @module utils/buildManifestRoutes\n */\n\nimport { routeParamNames } from './routeParams.js'\n\n/**\n * Suffix that turns a page id into the name of its split route.\n *\n * Exported so a caller that needs to push to the split route by name spells\n * it the same way the builder did, rather than re-deriving the convention.\n */\nexport const SPLIT_ROUTE_SUFFIX = '__split'\n\n/**\n * The route name a page's split view is registered under.\n *\n * @param {string} pageId The manifest page id.\n * @return {string} The split route's name.\n * @spec openspec/changes/case-page-and-list-as-a-place/specs/index-page/spec.md\n */\nexport function splitRouteName(pageId) {\n\treturn `${pageId}${SPLIT_ROUTE_SUFFIX}`\n}\n\n/**\n * Whether a page declares a working split view.\n *\n * Both halves matter: the key must be there AND `enabled` must be true. A\n * page carrying `splitView: { enabled: false }` is a page that has thought\n * about the split view and decided against it, and it must render exactly\n * as a page that never mentioned it.\n *\n * @param {object} page A manifest page entry.\n * @return {boolean} True when a split route should be emitted.\n * @spec openspec/changes/case-page-and-list-as-a-place/specs/index-page/spec.md\n */\nexport function pageHasSplitView(page) {\n\treturn page?.type === 'index' && page?.splitView?.enabled === true\n}\n\n/**\n * The path pattern for a page's split route.\n *\n * The param is named `id` unless the page's own path already binds `id`, in\n * which case it is `splitId`. Two params of one name in one path make\n * vue-router keep the last and silently drop the first, which reads as \"the\n * split opened the wrong record\" and is very hard to trace back to here.\n *\n * @param {string} route The page's own path pattern, e.g. `/cases`.\n * @return {string} The split path, e.g. `/cases/split/:id`.\n * @spec openspec/changes/case-page-and-list-as-a-place/specs/index-page/spec.md\n */\nexport function splitRoutePath(route) {\n\tconst base = typeof route === 'string' ? route.replace(/\\/+$/, '') : ''\n\tconst param = routeParamNames(base).includes('id') ? 'splitId' : 'id'\n\treturn `${base}/split/:${param}`\n}\n\n/**\n * Build the vue-router route records for a manifest.\n *\n * One record per page, plus one extra for every index page declaring\n * `splitView.enabled`. The extra record points at the same component with the\n * same props, so the router swaps the URL without swapping the page.\n *\n * `tabInAddress` needs no record of its own: the tab travels as the `_tab`\n * query parameter on the detail page's existing route. The underscore is not\n * decoration, it is what keeps `resolveQueryFilters` from reading the tab as\n * a filter and sending it to the API.\n *\n * @param {object} manifest The app manifest (v1 or v2; only `pages[]` is read).\n * @param {object} [options] Options.\n * @param {object} [options.component] Component every route mounts. Normally CnPageRenderer.\n * @param {object|boolean|((route: object) => object)} [options.props] `props` for each record, passed straight through to vue-router.\n * @param {(page: object, record: object) => object} [options.decorate] Called with each page and its record; the returned record is used. Lets a host add `beforeEnter`, extra `meta` or a per-page component without re-implementing the builder.\n * @return {Array<object>} Route records, in manifest order, each split route directly after its page.\n *\n * @example\n * import { buildManifestRoutes, CnPageRenderer } from '@conduction/nextcloud-vue'\n *\n * const router = createRouter({\n * history: createWebHashHistory(),\n * routes: buildManifestRoutes(manifest, {\n * component: CnPageRenderer,\n * props: { manifest, customComponents },\n * }),\n * })\n * @spec openspec/changes/case-page-and-list-as-a-place/specs/index-page/spec.md\n */\nexport function buildManifestRoutes(manifest, options = {}) {\n\tconst pages = Array.isArray(manifest?.pages) ? manifest.pages : []\n\tconst { component = null, props, decorate = null } = options\n\tconst records = []\n\n\tfor (const page of pages) {\n\t\tif (!page || typeof page.id !== 'string' || typeof page.route !== 'string') {\n\t\t\tcontinue\n\t\t}\n\n\t\trecords.push(finish(page, {\n\t\t\tname: page.id,\n\t\t\tpath: page.route,\n\t\t\tcomponent,\n\t\t\t...(props === undefined ? {} : { props }),\n\t\t\tmeta: { cnPageId: page.id },\n\t\t}, decorate))\n\n\t\tif (pageHasSplitView(page)) {\n\t\t\trecords.push(finish(page, {\n\t\t\t\tname: splitRouteName(page.id),\n\t\t\t\tpath: splitRoutePath(page.route),\n\t\t\t\tcomponent,\n\t\t\t\t...(props === undefined ? {} : { props }),\n\t\t\t\tmeta: {\n\t\t\t\t\tcnPageId: page.id,\n\t\t\t\t\tcnSplitOf: page.id,\n\t\t\t\t\tcnSplitBreakpoint: page.splitView.breakpoint ?? null,\n\t\t\t\t},\n\t\t\t}, decorate))\n\t\t}\n\t}\n\n\treturn records\n}\n\n/**\n * Hand a record to the caller's `decorate` hook, if there is one.\n *\n * A hook returning nothing keeps the record rather than dropping it: losing\n * a route because a hook forgot to return is a blank page with no error.\n *\n * @param {object} page The page the record was built from.\n * @param {object} record The record.\n * @param {((page: object, record: object) => object)|null} decorate The hook, or null.\n * @return {object} The record to register.\n */\nfunction finish(page, record, decorate) {\n\tif (typeof decorate !== 'function') {\n\t\treturn record\n\t}\n\treturn decorate(page, record) || record\n}\n\n/**\n * The page id a route resolves to.\n *\n * `meta.cnPageId` first, the route name second. The fallback is what keeps\n * every hand-written router working: an app that still maps its own pages\n * has no `meta`, and its route names are page ids by construction.\n *\n * @param {object} route A vue-router route object (`$route`).\n * @return {string|null} The page id, or null when the route names none.\n * @spec openspec/changes/case-page-and-list-as-a-place/specs/index-page/spec.md\n */\nexport function pageIdForRoute(route) {\n\tconst fromMeta = route?.meta?.cnPageId\n\tif (typeof fromMeta === 'string' && fromMeta !== '') {\n\t\treturn fromMeta\n\t}\n\tconst name = route?.name\n\treturn typeof name === 'string' && name !== '' ? name : null\n}\n\n/**\n * The record id a split route is showing, if it is a split route at all.\n *\n * @param {object} route A vue-router route object (`$route`).\n * @return {string|null} The id from the path, or null when this is not a split route.\n * @spec openspec/changes/case-page-and-list-as-a-place/specs/index-page/spec.md\n */\nexport function splitIdForRoute(route) {\n\tif (!route?.meta?.cnSplitOf) {\n\t\treturn null\n\t}\n\tconst params = route.params || {}\n\tconst id = params.splitId ?? params.id\n\treturn id === undefined || id === null || id === '' ? null : String(id)\n}\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,kBAAkB,GAAG,UAAS;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc,CAAC,MAAM,EAAE;AACvC,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,EAAE,kBAAkB,CAAC,CAAC;AACxC,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gBAAgB,CAAC,IAAI,EAAE;AACvC,CAAC,OAAO,IAAI,EAAE,IAAI,KAAK,OAAO,IAAI,IAAI,EAAE,SAAS,EAAE,OAAO,KAAK,IAAI;AACnE,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc,CAAC,KAAK,EAAE;AACtC,CAAC,MAAM,IAAI,GAAG,OAAO,KAAK,KAAK,QAAQ,GAAG,KAAK,CAAC,OAA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G,KAAK,EAAE,KAAI;AACzB,CAAC,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,EAAE,GAAG,IAAI,GAAG,IAAI;AAC7D,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,eAAe,CAAC,KAAK,EAAE;AACvC,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE;AAC9B,EAAE,OAAO,IAAI;AACb,EAAE;AACF,CAAC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,GAAE;AAClC,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,GAAE;AACvC,CAAC,OAAO,EAAE,KAAK,SAAS,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC;AACxE;;;;"}
|
|
1
|
+
{"version":3,"file":"buildManifestRoutes.js","sources":["../../../src/utils/buildManifestRoutes.js"],"sourcesContent":["/**\n * SPDX-FileCopyrightText: 2026 Conduction B.V.\n * SPDX-License-Identifier: EUPL-1.2\n *\n * buildManifestRoutes: the manifest's pages as vue-router route records.\n *\n * Until now every consuming app wrote this by hand:\n *\n * routes: manifest.pages.map((p) => ({ name: p.id, path: p.route, component: CnPageRenderer }))\n *\n * That one-liner can only ever produce one route per page, which is fine\n * until a page wants a second address for the same surface. The split view\n * needs exactly that: `/cases/split/:id` must mount the SAME index page as\n * `/cases`, because a list that unmounts loses the scroll position the split\n * view exists to keep. Five apps writing the extra record by hand would be\n * five spellings of it within a month, so the library builds them.\n *\n * Every record carries `meta.cnPageId`. CnPageRenderer reads that before it\n * falls back to matching `$route.name === page.id`, so a route whose name is\n * not a page id still resolves to its page instead of rendering nothing.\n *\n * @spec openspec/changes/case-page-and-list-as-a-place/specs/index-page/spec.md\n * @module utils/buildManifestRoutes\n */\n\nimport { routeParamNames } from './routeParams.js'\nimport { stripTrailingSlashes } from './trailingSlashes.js'\n\n/**\n * Suffix that turns a page id into the name of its split route.\n *\n * Exported so a caller that needs to push to the split route by name spells\n * it the same way the builder did, rather than re-deriving the convention.\n */\nexport const SPLIT_ROUTE_SUFFIX = '__split'\n\n/**\n * The route name a page's split view is registered under.\n *\n * @param {string} pageId The manifest page id.\n * @return {string} The split route's name.\n * @spec openspec/changes/case-page-and-list-as-a-place/specs/index-page/spec.md\n */\nexport function splitRouteName(pageId) {\n\treturn `${pageId}${SPLIT_ROUTE_SUFFIX}`\n}\n\n/**\n * Whether a page declares a working split view.\n *\n * Both halves matter: the key must be there AND `enabled` must be true. A\n * page carrying `splitView: { enabled: false }` is a page that has thought\n * about the split view and decided against it, and it must render exactly\n * as a page that never mentioned it.\n *\n * @param {object} page A manifest page entry.\n * @return {boolean} True when a split route should be emitted.\n * @spec openspec/changes/case-page-and-list-as-a-place/specs/index-page/spec.md\n */\nexport function pageHasSplitView(page) {\n\treturn page?.type === 'index' && page?.splitView?.enabled === true\n}\n\n/**\n * The path pattern for a page's split route.\n *\n * The param is named `id` unless the page's own path already binds `id`, in\n * which case it is `splitId`. Two params of one name in one path make\n * vue-router keep the last and silently drop the first, which reads as \"the\n * split opened the wrong record\" and is very hard to trace back to here.\n *\n * @param {string} route The page's own path pattern, e.g. `/cases`.\n * @return {string} The split path, e.g. `/cases/split/:id`.\n * @spec openspec/changes/case-page-and-list-as-a-place/specs/index-page/spec.md\n */\nexport function splitRoutePath(route) {\n\tconst base = typeof route === 'string' ? stripTrailingSlashes(route) : ''\n\tconst param = routeParamNames(base).includes('id') ? 'splitId' : 'id'\n\treturn `${base}/split/:${param}`\n}\n\n/**\n * Build the vue-router route records for a manifest.\n *\n * One record per page, plus one extra for every index page declaring\n * `splitView.enabled`. The extra record points at the same component with the\n * same props, so the router swaps the URL without swapping the page.\n *\n * `tabInAddress` needs no record of its own: the tab travels as the `_tab`\n * query parameter on the detail page's existing route. The underscore is not\n * decoration, it is what keeps `resolveQueryFilters` from reading the tab as\n * a filter and sending it to the API.\n *\n * @param {object} manifest The app manifest (v1 or v2; only `pages[]` is read).\n * @param {object} [options] Options.\n * @param {object} [options.component] Component every route mounts. Normally CnPageRenderer.\n * @param {object|boolean|((route: object) => object)} [options.props] `props` for each record, passed straight through to vue-router.\n * @param {(page: object, record: object) => object} [options.decorate] Called with each page and its record; the returned record is used. Lets a host add `beforeEnter`, extra `meta` or a per-page component without re-implementing the builder.\n * @return {Array<object>} Route records, in manifest order, each split route directly after its page.\n *\n * @example\n * import { buildManifestRoutes, CnPageRenderer } from '@conduction/nextcloud-vue'\n *\n * const router = createRouter({\n * history: createWebHashHistory(),\n * routes: buildManifestRoutes(manifest, {\n * component: CnPageRenderer,\n * props: { manifest, customComponents },\n * }),\n * })\n * @spec openspec/changes/case-page-and-list-as-a-place/specs/index-page/spec.md\n */\nexport function buildManifestRoutes(manifest, options = {}) {\n\tconst pages = Array.isArray(manifest?.pages) ? manifest.pages : []\n\tconst { component = null, props, decorate = null } = options\n\tconst records = []\n\n\tfor (const page of pages) {\n\t\tif (!page || typeof page.id !== 'string' || typeof page.route !== 'string') {\n\t\t\tcontinue\n\t\t}\n\n\t\trecords.push(finish(page, {\n\t\t\tname: page.id,\n\t\t\tpath: page.route,\n\t\t\tcomponent,\n\t\t\t...(props === undefined ? {} : { props }),\n\t\t\tmeta: { cnPageId: page.id },\n\t\t}, decorate))\n\n\t\tif (pageHasSplitView(page)) {\n\t\t\trecords.push(finish(page, {\n\t\t\t\tname: splitRouteName(page.id),\n\t\t\t\tpath: splitRoutePath(page.route),\n\t\t\t\tcomponent,\n\t\t\t\t...(props === undefined ? {} : { props }),\n\t\t\t\tmeta: {\n\t\t\t\t\tcnPageId: page.id,\n\t\t\t\t\tcnSplitOf: page.id,\n\t\t\t\t\tcnSplitBreakpoint: page.splitView.breakpoint ?? null,\n\t\t\t\t},\n\t\t\t}, decorate))\n\t\t}\n\t}\n\n\treturn records\n}\n\n/**\n * Hand a record to the caller's `decorate` hook, if there is one.\n *\n * A hook returning nothing keeps the record rather than dropping it: losing\n * a route because a hook forgot to return is a blank page with no error.\n *\n * @param {object} page The page the record was built from.\n * @param {object} record The record.\n * @param {((page: object, record: object) => object)|null} decorate The hook, or null.\n * @return {object} The record to register.\n */\nfunction finish(page, record, decorate) {\n\tif (typeof decorate !== 'function') {\n\t\treturn record\n\t}\n\treturn decorate(page, record) || record\n}\n\n/**\n * The page id a route resolves to.\n *\n * `meta.cnPageId` first, the route name second. The fallback is what keeps\n * every hand-written router working: an app that still maps its own pages\n * has no `meta`, and its route names are page ids by construction.\n *\n * @param {object} route A vue-router route object (`$route`).\n * @return {string|null} The page id, or null when the route names none.\n * @spec openspec/changes/case-page-and-list-as-a-place/specs/index-page/spec.md\n */\nexport function pageIdForRoute(route) {\n\tconst fromMeta = route?.meta?.cnPageId\n\tif (typeof fromMeta === 'string' && fromMeta !== '') {\n\t\treturn fromMeta\n\t}\n\tconst name = route?.name\n\treturn typeof name === 'string' && name !== '' ? name : null\n}\n\n/**\n * The record id a split route is showing, if it is a split route at all.\n *\n * @param {object} route A vue-router route object (`$route`).\n * @return {string|null} The id from the path, or null when this is not a split route.\n * @spec openspec/changes/case-page-and-list-as-a-place/specs/index-page/spec.md\n */\nexport function splitIdForRoute(route) {\n\tif (!route?.meta?.cnSplitOf) {\n\t\treturn null\n\t}\n\tconst params = route.params || {}\n\tconst id = params.splitId ?? params.id\n\treturn id === undefined || id === null || id === '' ? null : String(id)\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,kBAAkB,GAAG,UAAS;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc,CAAC,MAAM,EAAE;AACvC,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,EAAE,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AAO,MAAM;AACf,EAAE;AACF,CAAC,OAAO,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM;AACxC,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc,CAAC,KAAK,EAAE;AACtC,CAAC,MAAM,QAAQ,GAAG,KAAK,EAAE,IAAI,EAAE,SAAQ;AACvC,CAAC,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,EAAE,EAAE;AACtD,EAAE,OAAO,QAAQ;AACjB,EAAE;AACF,CAAC,MAAM,IAAI,GAAG,KAAK,EAAE,KAAI;AACzB,CAAC,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,EAAE,GAAG,IAAI,GAAG,IAAI;AAC7D,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,eAAe,CAAC,KAAK,EAAE;AACvC,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE;AAC9B,EAAE,OAAO,IAAI;AACb,EAAE;AACF,CAAC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,GAAE;AAClC,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,GAAE;AACvC,CAAC,OAAO,EAAE,KAAK,SAAS,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC;AACxE;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { trackedFetch } from './diagnostics.js';
|
|
2
2
|
import { buildQueryString, buildHeaders, prefixUrl } from './headers.js';
|
|
3
|
+
import { stripTrailingSlashes } from './trailingSlashes.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* The one HTTP client for Conduction Nextcloud apps (ADR-071 Decision 1).
|
|
@@ -65,21 +66,6 @@ function configureCnFetch(config = {}) {
|
|
|
65
66
|
};
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
/**
|
|
69
|
-
* Drop trailing `/` characters in one linear pass (a `/\/+$/` pattern
|
|
70
|
-
* backtracks quadratically on a long run of slashes).
|
|
71
|
-
*
|
|
72
|
-
* @param {string} value The string to trim.
|
|
73
|
-
* @return {string} The string without trailing slashes.
|
|
74
|
-
*/
|
|
75
|
-
function stripTrailingSlashes(value) {
|
|
76
|
-
let end = value.length;
|
|
77
|
-
while (end > 0 && value.charCodeAt(end - 1) === 47) {
|
|
78
|
-
end--;
|
|
79
|
-
}
|
|
80
|
-
return value.slice(0, end)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
69
|
/**
|
|
84
70
|
* The bearer credential, resolved.
|
|
85
71
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cnFetch.js","sources":["../../../src/utils/cnFetch.js"],"sourcesContent":["/**\n * The one HTTP client for Conduction Nextcloud apps (ADR-071 Decision 1).\n *\n * ADR-071 names `cnFetch` / `cnFetchJson` as library-owned and says raw\n * `fetch()` with a hand-set requesttoken in app code is review-blocking once\n * shipped. Until now the library did not actually ship them, so every app was\n * left hand-rolling the same four steps — and an ADR that mandates an\n * abstraction nobody provides produces \"violations\" the app cannot fix.\n *\n * This composes helpers this library already had, rather than inventing a\n * parallel idiom:\n *\n * - {@link prefixUrl} — Nextcloud may be served with or without\n * `/index.php`; an API call must use the SAME\n * prefix as the page or the request is rejected.\n * - {@link buildHeaders} — the single blessed CSRF idiom\n * (`requesttoken: OC.requestToken`), plus\n * Content-Type, the OpenRegister organisation\n * header and the translation-target header.\n * - {@link buildQueryString} — consistent query serialisation.\n *\n * The shape is exactly what `visibleWhen.js` (and a dozen call sites like it)\n * already wrote by hand:\n *\n * const response = await fetch(prefixUrl(url), { headers: buildHeaders() })\n * if (!response.ok) throw new Error(`endpoint returned ${response.status}`)\n * const data = await response.json()\n *\n * @module utils/cnFetch\n */\n\nimport { trackedFetch } from './diagnostics.js'\nimport { buildHeaders, buildQueryString, prefixUrl } from './headers.js'\n\n/** The hosts the runtime can boot under. */\nexport const CN_HOSTS = ['nextcloud', 'public']\n\nlet transport = { host: 'nextcloud', baseUrl: '', credential: null }\n\n/**\n * Choose where `cnFetch` runs. The default, `'nextcloud'`, is today's behaviour:\n * the Nextcloud URL prefix and the `requesttoken` header. Under `'public'`\n * (a public origin with no Nextcloud behind it) URLs resolve from `baseUrl`,\n * the request carries `Authorization: Bearer <credential>` and no\n * `requesttoken`, and the credential is stripped from any error `cnFetchJson`\n * throws. An unrecognised host throws; it never falls back to either mode.\n *\n * @spec openspec/changes/public-manifest-runtime/tasks.md#task-2\n * @param {object} [config] The transport.\n * @param {string} [config.host] `'nextcloud'` (default) or `'public'`.\n * @param {string} [config.baseUrl] Public mode: the API base, e.g. `https://portal.example/api`.\n * @param {string|Function} [config.credential] Public mode: the bearer credential, or a function returning it.\n * @throws {Error} When `host` is not one of the accepted values.\n */\nexport function configureCnFetch(config = {}) {\n\tconst host = config.host === undefined ? 'nextcloud' : config.host\n\tif (!CN_HOSTS.includes(host)) {\n\t\tthrow new Error(`cnFetch: unknown host \"${String(host)}\". Accepted values: ${CN_HOSTS.join(', ')}.`)\n\t}\n\ttransport = {\n\t\thost,\n\t\tbaseUrl: typeof config.baseUrl === 'string' ? stripTrailingSlashes(config.baseUrl) : '',\n\t\tcredential: config.credential || null,\n\t}\n}\n\n/**\n * Drop trailing `/` characters in one linear pass (a `/\\/+$/` pattern\n * backtracks quadratically on a long run of slashes).\n *\n * @param {string} value The string to trim.\n * @return {string} The string without trailing slashes.\n */\nexport function stripTrailingSlashes(value) {\n\tlet end = value.length\n\twhile (end > 0 && value.charCodeAt(end - 1) === 47) {\n\t\tend--\n\t}\n\treturn value.slice(0, end)\n}\n\n/**\n * The bearer credential, resolved.\n *\n * @return {string} The credential, or ''.\n */\nfunction currentCredential() {\n\tconst c = transport.credential\n\tconst value = typeof c === 'function' ? c() : c\n\treturn typeof value === 'string' ? value : ''\n}\n\n/**\n * Remove the credential from a value before it reaches a log or an error.\n *\n * @param {unknown} value A string, or an object or array holding strings.\n * @return {unknown} The same shape with the credential replaced.\n */\nfunction redact(value) {\n\tconst secret = currentCredential()\n\tif (secret === '' || value === null || value === undefined) {\n\t\treturn value\n\t}\n\tif (typeof value === 'string') {\n\t\treturn value.split(secret).join('[redacted]')\n\t}\n\tif (typeof value === 'object') {\n\t\ttry {\n\t\t\treturn JSON.parse(JSON.stringify(value).split(secret).join('[redacted]'))\n\t\t} catch {\n\t\t\treturn value\n\t\t}\n\t}\n\treturn value\n}\n\n/**\n * An HTTP error carrying the status and the parsed body, so a caller can\n * branch on the status without re-reading a consumed stream.\n *\n * A bare `Error(message)` loses the status, which is the single most useful\n * fact about a failed request — callers then re-parse the message string to\n * recover it, and that is how a 404-vs-403 distinction gets lost.\n */\nexport class CnHttpError extends Error {\n\t/**\n\t * @param {string} message Human-readable message.\n\t * @param {number} status HTTP status code.\n\t * @param {unknown} body Parsed response body, or the raw text when it was not JSON.\n\t * @param {string} url The requested URL, for logs.\n\t */\n\tconstructor(message, status, body, url) {\n\t\tsuper(message)\n\t\tthis.name = 'CnHttpError'\n\t\tthis.status = status\n\t\tthis.body = body\n\t\tthis.url = url\n\t}\n}\n\n/**\n * `fetch` with Nextcloud's URL prefix and headers applied.\n *\n * Returns the raw `Response` untouched — it does NOT throw on a non-2xx, so a\n * caller that legitimately expects a 404 (a probe) can read `response.status`\n * without exception handling. Use {@link cnFetchJson} for the common case.\n *\n * @param {string} url App-absolute path, e.g. `/apps/openregister/api/objects`.\n * @param {object} [options] Standard `fetch` options.\n * @param {object} [options.query] Serialised via {@link buildQueryString} and appended.\n * @param {object|string|null} [options.headerOptions] Passed to {@link buildHeaders}.\n * @return {Promise<Response>} The raw response.\n */\nexport async function cnFetch(url, options = {}) {\n\tconst { query, headerOptions, headers, ...rest } = options\n\tconst qs = query ? buildQueryString(query) : ''\n\t// Caller-supplied headers win, so a one-off Content-Type or Accept does not\n\t// require bypassing this helper entirely — bypassing is how apps end up\n\t// hand-setting requesttoken again.\n\tif (transport.host === 'public') {\n\t\t// No Nextcloud here: bearer auth, the configured base, no requesttoken.\n\t\tconst contentType = (headerOptions && typeof headerOptions === 'object' && Object.hasOwn(headerOptions, 'contentType'))\n\t\t\t? headerOptions.contentType\n\t\t\t: (typeof headerOptions === 'string' ? headerOptions : 'application/json')\n\t\tconst base = { Accept: 'application/json', ...(contentType ? { 'Content-Type': contentType } : {}) }\n\t\tconst credential = currentCredential()\n\t\tconst publicHeaders = { ...base, ...(credential ? { Authorization: `Bearer ${credential}` } : {}), ...(headers || {}) }\n\t\tconst target = /^[a-z][a-z0-9+.-]*:/i.test(url) ? url : `${transport.baseUrl}${url}`\n\t\treturn trackedFetch(`${target}${qs}`, { ...rest, headers: publicHeaders }, 'cnFetch')\n\t}\n\tconst merged = { ...buildHeaders(headerOptions), ...(headers || {}) }\n\treturn trackedFetch(prefixUrl(`${url}${qs}`), { ...rest, headers: merged }, 'cnFetch')\n}\n\n/**\n * `cnFetch` + JSON parsing + error normalisation.\n *\n * Throws {@link CnHttpError} on a non-2xx, carrying the status and the parsed\n * body. Returns the parsed body on success.\n *\n * A 204 (and any empty body) resolves to `null` rather than throwing on an\n * empty JSON parse — DELETE endpoints in this stack answer 204, and making the\n * happy path throw is how callers learn to wrap everything in try/catch and\n * swallow real errors along the way.\n *\n * @param {string} url App-absolute path.\n * @param {object} [options] As {@link cnFetch}.\n * @throws {CnHttpError} When the response status is not 2xx.\n * @return {Promise<unknown>} Parsed JSON body, or null for an empty body.\n */\nexport async function cnFetchJson(url, options = {}) {\n\tconst response = await cnFetch(url, options)\n\n\t// Read the body ONCE. A Response body is a stream and can only be consumed\n\t// a single time, so the error path must reuse what was already read rather\n\t// than calling .json() again on a spent stream.\n\tconst raw = await response.text()\n\tlet parsed = null\n\tif (raw !== '') {\n\t\ttry {\n\t\t\tparsed = JSON.parse(raw)\n\t\t} catch {\n\t\t\tparsed = raw\n\t\t}\n\t}\n\n\tif (!response.ok) {\n\t\tconst detail\n\t\t\t= parsed && typeof parsed === 'object' && typeof parsed.error === 'string'\n\t\t\t\t? parsed.error\n\t\t\t\t: response.statusText || 'request failed'\n\t\tthrow new CnHttpError(\n\t\t\tredact(`${url} returned ${response.status}: ${detail}`),\n\t\t\tresponse.status,\n\t\t\tredact(parsed),\n\t\t\turl,\n\t\t)\n\t}\n\n\treturn parsed\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACY,MAAC,QAAQ,GAAG,CAAC,WAAW,EAAE,QAAQ,EAAC;AAC/C;AACA,IAAI,SAAS,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,GAAE;AACpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gBAAgB,CAAC,MAAM,GAAG,EAAE,EAAE;AAC9C,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,KAAK,SAAS,GAAG,WAAW,GAAG,MAAM,CAAC,KAAI;AACnE,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;AAC/B,EAAE,MAAM,IAAI,KAAK,CAAC,CAAC,uBAAuB,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,oBAAoB,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACtG,EAAE;AACF,CAAC,SAAS,GAAG;AACb,EAAE,IAAI;AACN,EAAE,OAAO,EAAE,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,GAAG,oBAAoB,CAAC,MAAM,CAAC,OAAO,CAAC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,MAAM,GAAG,KAAI;AAClB,CAAC,IAAI,GAAG,KAAK,EAAE,EAAE;AACjB,EAAE,IAAI;AACN,GAAG,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,EAAC;AAC3B,GAAG,CAAC,MAAM;AACV,GAAG,MAAM,GAAG,IAAG;AACf,GAAG;AACH,EAAE;AACF;AACA,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;AACnB,EAAE,MAAM,MAAM;AACd,KAAK,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ;AAC7E,MAAM,MAAM,CAAC,KAAK;AAClB,MAAM,QAAQ,CAAC,UAAU,IAAI,iBAAgB;AAC7C,EAAE,MAAM,IAAI,WAAW;AACvB,GAAG,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;AAC1D,GAAG,QAAQ,CAAC,MAAM;AAClB,GAAG,MAAM,CAAC,MAAM,CAAC;AACjB,GAAG,GAAG;AACN,GAAG;AACH,EAAE;AACF;AACA,CAAC,OAAO,MAAM;AACd;;;;"}
|
|
1
|
+
{"version":3,"file":"cnFetch.js","sources":["../../../src/utils/cnFetch.js"],"sourcesContent":["/**\n * The one HTTP client for Conduction Nextcloud apps (ADR-071 Decision 1).\n *\n * ADR-071 names `cnFetch` / `cnFetchJson` as library-owned and says raw\n * `fetch()` with a hand-set requesttoken in app code is review-blocking once\n * shipped. Until now the library did not actually ship them, so every app was\n * left hand-rolling the same four steps — and an ADR that mandates an\n * abstraction nobody provides produces \"violations\" the app cannot fix.\n *\n * This composes helpers this library already had, rather than inventing a\n * parallel idiom:\n *\n * - {@link prefixUrl} — Nextcloud may be served with or without\n * `/index.php`; an API call must use the SAME\n * prefix as the page or the request is rejected.\n * - {@link buildHeaders} — the single blessed CSRF idiom\n * (`requesttoken: OC.requestToken`), plus\n * Content-Type, the OpenRegister organisation\n * header and the translation-target header.\n * - {@link buildQueryString} — consistent query serialisation.\n *\n * The shape is exactly what `visibleWhen.js` (and a dozen call sites like it)\n * already wrote by hand:\n *\n * const response = await fetch(prefixUrl(url), { headers: buildHeaders() })\n * if (!response.ok) throw new Error(`endpoint returned ${response.status}`)\n * const data = await response.json()\n *\n * @module utils/cnFetch\n */\n\nimport { trackedFetch } from './diagnostics.js'\nimport { buildHeaders, buildQueryString, prefixUrl } from './headers.js'\nimport { stripTrailingSlashes } from './trailingSlashes.js'\n\nexport { stripTrailingSlashes }\n\n/** The hosts the runtime can boot under. */\nexport const CN_HOSTS = ['nextcloud', 'public']\n\nlet transport = { host: 'nextcloud', baseUrl: '', credential: null }\n\n/**\n * Choose where `cnFetch` runs. The default, `'nextcloud'`, is today's behaviour:\n * the Nextcloud URL prefix and the `requesttoken` header. Under `'public'`\n * (a public origin with no Nextcloud behind it) URLs resolve from `baseUrl`,\n * the request carries `Authorization: Bearer <credential>` and no\n * `requesttoken`, and the credential is stripped from any error `cnFetchJson`\n * throws. An unrecognised host throws; it never falls back to either mode.\n *\n * @spec openspec/changes/public-manifest-runtime/tasks.md#task-2\n * @param {object} [config] The transport.\n * @param {string} [config.host] `'nextcloud'` (default) or `'public'`.\n * @param {string} [config.baseUrl] Public mode: the API base, e.g. `https://portal.example/api`.\n * @param {string|Function} [config.credential] Public mode: the bearer credential, or a function returning it.\n * @throws {Error} When `host` is not one of the accepted values.\n */\nexport function configureCnFetch(config = {}) {\n\tconst host = config.host === undefined ? 'nextcloud' : config.host\n\tif (!CN_HOSTS.includes(host)) {\n\t\tthrow new Error(`cnFetch: unknown host \"${String(host)}\". Accepted values: ${CN_HOSTS.join(', ')}.`)\n\t}\n\ttransport = {\n\t\thost,\n\t\tbaseUrl: typeof config.baseUrl === 'string' ? stripTrailingSlashes(config.baseUrl) : '',\n\t\tcredential: config.credential || null,\n\t}\n}\n\n/**\n * The bearer credential, resolved.\n *\n * @return {string} The credential, or ''.\n */\nfunction currentCredential() {\n\tconst c = transport.credential\n\tconst value = typeof c === 'function' ? c() : c\n\treturn typeof value === 'string' ? value : ''\n}\n\n/**\n * Remove the credential from a value before it reaches a log or an error.\n *\n * @param {unknown} value A string, or an object or array holding strings.\n * @return {unknown} The same shape with the credential replaced.\n */\nfunction redact(value) {\n\tconst secret = currentCredential()\n\tif (secret === '' || value === null || value === undefined) {\n\t\treturn value\n\t}\n\tif (typeof value === 'string') {\n\t\treturn value.split(secret).join('[redacted]')\n\t}\n\tif (typeof value === 'object') {\n\t\ttry {\n\t\t\treturn JSON.parse(JSON.stringify(value).split(secret).join('[redacted]'))\n\t\t} catch {\n\t\t\treturn value\n\t\t}\n\t}\n\treturn value\n}\n\n/**\n * An HTTP error carrying the status and the parsed body, so a caller can\n * branch on the status without re-reading a consumed stream.\n *\n * A bare `Error(message)` loses the status, which is the single most useful\n * fact about a failed request — callers then re-parse the message string to\n * recover it, and that is how a 404-vs-403 distinction gets lost.\n */\nexport class CnHttpError extends Error {\n\t/**\n\t * @param {string} message Human-readable message.\n\t * @param {number} status HTTP status code.\n\t * @param {unknown} body Parsed response body, or the raw text when it was not JSON.\n\t * @param {string} url The requested URL, for logs.\n\t */\n\tconstructor(message, status, body, url) {\n\t\tsuper(message)\n\t\tthis.name = 'CnHttpError'\n\t\tthis.status = status\n\t\tthis.body = body\n\t\tthis.url = url\n\t}\n}\n\n/**\n * `fetch` with Nextcloud's URL prefix and headers applied.\n *\n * Returns the raw `Response` untouched — it does NOT throw on a non-2xx, so a\n * caller that legitimately expects a 404 (a probe) can read `response.status`\n * without exception handling. Use {@link cnFetchJson} for the common case.\n *\n * @param {string} url App-absolute path, e.g. `/apps/openregister/api/objects`.\n * @param {object} [options] Standard `fetch` options.\n * @param {object} [options.query] Serialised via {@link buildQueryString} and appended.\n * @param {object|string|null} [options.headerOptions] Passed to {@link buildHeaders}.\n * @return {Promise<Response>} The raw response.\n */\nexport async function cnFetch(url, options = {}) {\n\tconst { query, headerOptions, headers, ...rest } = options\n\tconst qs = query ? buildQueryString(query) : ''\n\t// Caller-supplied headers win, so a one-off Content-Type or Accept does not\n\t// require bypassing this helper entirely — bypassing is how apps end up\n\t// hand-setting requesttoken again.\n\tif (transport.host === 'public') {\n\t\t// No Nextcloud here: bearer auth, the configured base, no requesttoken.\n\t\tconst contentType = (headerOptions && typeof headerOptions === 'object' && Object.hasOwn(headerOptions, 'contentType'))\n\t\t\t? headerOptions.contentType\n\t\t\t: (typeof headerOptions === 'string' ? headerOptions : 'application/json')\n\t\tconst base = { Accept: 'application/json', ...(contentType ? { 'Content-Type': contentType } : {}) }\n\t\tconst credential = currentCredential()\n\t\tconst publicHeaders = { ...base, ...(credential ? { Authorization: `Bearer ${credential}` } : {}), ...(headers || {}) }\n\t\tconst target = /^[a-z][a-z0-9+.-]*:/i.test(url) ? url : `${transport.baseUrl}${url}`\n\t\treturn trackedFetch(`${target}${qs}`, { ...rest, headers: publicHeaders }, 'cnFetch')\n\t}\n\tconst merged = { ...buildHeaders(headerOptions), ...(headers || {}) }\n\treturn trackedFetch(prefixUrl(`${url}${qs}`), { ...rest, headers: merged }, 'cnFetch')\n}\n\n/**\n * `cnFetch` + JSON parsing + error normalisation.\n *\n * Throws {@link CnHttpError} on a non-2xx, carrying the status and the parsed\n * body. Returns the parsed body on success.\n *\n * A 204 (and any empty body) resolves to `null` rather than throwing on an\n * empty JSON parse — DELETE endpoints in this stack answer 204, and making the\n * happy path throw is how callers learn to wrap everything in try/catch and\n * swallow real errors along the way.\n *\n * @param {string} url App-absolute path.\n * @param {object} [options] As {@link cnFetch}.\n * @throws {CnHttpError} When the response status is not 2xx.\n * @return {Promise<unknown>} Parsed JSON body, or null for an empty body.\n */\nexport async function cnFetchJson(url, options = {}) {\n\tconst response = await cnFetch(url, options)\n\n\t// Read the body ONCE. A Response body is a stream and can only be consumed\n\t// a single time, so the error path must reuse what was already read rather\n\t// than calling .json() again on a spent stream.\n\tconst raw = await response.text()\n\tlet parsed = null\n\tif (raw !== '') {\n\t\ttry {\n\t\t\tparsed = JSON.parse(raw)\n\t\t} catch {\n\t\t\tparsed = raw\n\t\t}\n\t}\n\n\tif (!response.ok) {\n\t\tconst detail\n\t\t\t= parsed && typeof parsed === 'object' && typeof parsed.error === 'string'\n\t\t\t\t? parsed.error\n\t\t\t\t: response.statusText || 'request failed'\n\t\tthrow new CnHttpError(\n\t\t\tredact(`${url} returned ${response.status}: ${detail}`),\n\t\t\tresponse.status,\n\t\t\tredact(parsed),\n\t\t\turl,\n\t\t)\n\t}\n\n\treturn parsed\n}\n"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA;AACY,MAAC,QAAQ,GAAG,CAAC,WAAW,EAAE,QAAQ,EAAC;AAC/C;AACA,IAAI,SAAS,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,GAAE;AACpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gBAAgB,CAAC,MAAM,GAAG,EAAE,EAAE;AAC9C,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,KAAK,SAAS,GAAG,WAAW,GAAG,MAAM,CAAC,KAAI;AACnE,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;AAC/B,EAAE,MAAM,IAAI,KAAK,CAAC,CAAC,uBAAuB,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,oBAAoB,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACtG,EAAE;AACF,CAAC,SAAS,GAAG;AACb,EAAE,IAAI;AACN,EAAE,OAAO,EAAE,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;AACnB,EAAE,MAAM,MAAM;AACd,KAAK,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ;AAC7E,MAAM,MAAM,CAAC,KAAK;AAClB,MAAM,QAAQ,CAAC,UAAU,IAAI,iBAAgB;AAC7C,EAAE,MAAM,IAAI,WAAW;AACvB,GAAG,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;AAC1D,GAAG,QAAQ,CAAC,MAAM;AAClB,GAAG,MAAM,CAAC,MAAM,CAAC;AACjB,GAAG,GAAG;AACN,GAAG;AACH,EAAE;AACF;AACA,CAAC,OAAO,MAAM;AACd;;;;"}
|
|
@@ -303,6 +303,34 @@ function firstFilled(templates, object, translate = (key) => key, now = new Date
|
|
|
303
303
|
return ''
|
|
304
304
|
}
|
|
305
305
|
|
|
306
|
+
/**
|
|
307
|
+
* Split a template into literal, field, literal, … as
|
|
308
|
+
* `template.split(/\{([^}]+)\}/)` does, in one linear pass.
|
|
309
|
+
*
|
|
310
|
+
* @param {string} template The template, with `{field}` placeholders.
|
|
311
|
+
* @return {string[]} The literals at even indexes, the field names at odd ones.
|
|
312
|
+
*/
|
|
313
|
+
function splitFields(template) {
|
|
314
|
+
const parts = [];
|
|
315
|
+
let literalStart = 0;
|
|
316
|
+
let open = template.indexOf('{');
|
|
317
|
+
while (open !== -1) {
|
|
318
|
+
const close = template.indexOf('}', open + 1);
|
|
319
|
+
if (close === -1) {
|
|
320
|
+
break
|
|
321
|
+
}
|
|
322
|
+
if (close === open + 1) {
|
|
323
|
+
open = template.indexOf('{', close + 1);
|
|
324
|
+
continue
|
|
325
|
+
}
|
|
326
|
+
parts.push(template.slice(literalStart, open), template.slice(open + 1, close));
|
|
327
|
+
literalStart = close + 1;
|
|
328
|
+
open = template.indexOf('{', literalStart);
|
|
329
|
+
}
|
|
330
|
+
parts.push(template.slice(literalStart));
|
|
331
|
+
return parts
|
|
332
|
+
}
|
|
333
|
+
|
|
306
334
|
/**
|
|
307
335
|
* Fill a template such as `"{identifier} · {requester}"` field by field
|
|
308
336
|
* (a table column's `secondary` line, a detail page's meta line).
|
|
@@ -320,8 +348,7 @@ function firstFilled(templates, object, translate = (key) => key, now = new Date
|
|
|
320
348
|
* @return {string} The filled template.
|
|
321
349
|
*/
|
|
322
350
|
function joinTemplateParts(template, valueOf) {
|
|
323
|
-
|
|
324
|
-
const parts = template.split(/\{([^}]+)\}/);
|
|
351
|
+
const parts = splitFields(template);
|
|
325
352
|
const lead = parts[0];
|
|
326
353
|
const tail = parts[parts.length - 1];
|
|
327
354
|
let body = '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fillTemplate.js","sources":["../../../src/utils/fillTemplate.js"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 Conduction B.V.\n// SPDX-License-Identifier: EUPL-1.2\n\nimport { translate as t } from '@nextcloud/l10n'\nimport { boardDateLocale, formatAgo, formatBoardDate, formatBoardWeekday, formatRelativeDate, formatSoon, formatTimeOfDay, isoWeek } from './boardDate.js'\nimport { BUILT_IN_FORMATTERS } from './builtInFormatters.js'\nimport { parseDateValue } from './dateVariant.js'\nimport { formatMoney, metricLocale } from './formatMetric.js'\nimport { groupDisplayName, loadGroupDisplayName } from './groupAutocomplete.js'\nimport { readPath } from './readPath.js'\nimport { userDisplayName } from './userDisplayName.js'\n\nconst TOKEN = /\\{([^{}\\s|]+)(?:\\|([A-Za-z]+)(?::([^{}\\s]+))?)?\\}/g\n\n/**\n * A moment in the board's short form with the time: \"4 okt, 10:52\", or\n * \"14 feb 2024, 09:00\" outside the current year.\n *\n * @param {unknown} value A Date, a timestamp or an ISO string.\n * @param {Date} [now] The reference moment.\n * @return {string} The text, or '' when the value is not a date.\n * @spec openspec/changes/screens-relation-pages/specs/relation-pages/spec.md#requirement-a-record-list-shows-the-objects-that-point-at-this-record\n */\nexport function formatBoardDateTime(value, now = new Date()) {\n\tconst day = formatBoardDate(value, now)\n\tconst date = parseDateValue(value)\n\tif (day === '' || date === null) {\n\t\treturn ''\n\t}\n\tlet time\n\ttry {\n\t\ttime = new Intl.DateTimeFormat(boardDateLocale(), { hour: '2-digit', minute: '2-digit' }).format(date)\n\t} catch {\n\t\ttime = new Intl.DateTimeFormat(undefined, { hour: '2-digit', minute: '2-digit' }).format(date)\n\t}\n\treturn `${day}, ${time}`\n}\n\n/**\n * A date with the month written out: \"7 oktober\", or \"6 oktober 2026\"\n * outside the current year or when `withYear` asks for it.\n *\n * @param {unknown} value A Date, a timestamp or an ISO string.\n * @param {Date} now The reference moment.\n * @param {boolean} [withYear] Always write the year.\n * @return {string} The text, or '' when the value is not a date.\n * @spec openspec/changes/screens-header-meta-tokens/specs/detail-page-board-look/spec.md#requirement-the-header-meta-line-formats-users-long-dates-and-enum-labels\n */\nexport function formatLongDate(value, now = new Date(), withYear = false) {\n\tconst date = parseDateValue(value)\n\tif (date === null) {\n\t\treturn ''\n\t}\n\tconst options = { day: 'numeric', month: 'long' }\n\tif (withYear || date.getFullYear() !== now.getFullYear()) {\n\t\toptions.year = 'numeric'\n\t}\n\ttry {\n\t\treturn new Intl.DateTimeFormat(boardDateLocale(), options).format(date)\n\t} catch {\n\t\treturn new Intl.DateTimeFormat(undefined, options).format(date)\n\t}\n}\n\n/**\n * A date written out in full, the way a letter or an invitation does:\n * \"Donderdag 12 november 2026\". The weekday is capitalised, because the\n * line starts with it.\n *\n * @param {unknown} value A Date, a timestamp or an ISO string.\n * @return {string} The text, or '' when the value is not a date.\n * @spec openspec/changes/template-full-date/specs/detail-page-board-look/spec.md#requirement-a-template-can-write-a-date-in-full\n */\nexport function formatFullDate(value) {\n\tconst date = parseDateValue(value)\n\tif (date === null) {\n\t\treturn ''\n\t}\n\tconst options = { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' }\n\tlet text\n\ttry {\n\t\ttext = new Intl.DateTimeFormat(boardDateLocale(), options).format(date)\n\t} catch {\n\t\ttext = new Intl.DateTimeFormat(undefined, options).format(date)\n\t}\n\treturn text.charAt(0).toLocaleUpperCase() + text.slice(1)\n}\n\n/**\n * How many entries a list holds; with a key, the entries of that list in each\n * of its entries summed (`{sections|count:items}`: the questions of every\n * section of a checklist).\n *\n * @param {Array} list The list.\n * @param {string} key The key of each entry's own list, or '' to count the entries.\n * @return {number} The count.\n */\nfunction countEntries(list, key) {\n\tif (key === '') {\n\t\treturn list.length\n\t}\n\treturn list.reduce((sum, entry) => sum + (entry && Array.isArray(entry[key]) ? entry[key].length : 0), 0)\n}\n\n/**\n * Whether a named formatter is the library's own `date` or `datetime`, which\n * CnAppRoot puts in every page's formatters: the template's board date\n * (\"28 okt\") wins over it, an app's own formatter of that name does not.\n *\n * @param {string} format The format name.\n * @param {(value: unknown, row?: object) => unknown} formatter The formatter found under that name.\n * @return {boolean} True for the built-in date formatters.\n * @spec openspec/changes/template-date-not-shadowed/specs/template-date-not-shadowed/spec.md\n */\nfunction isBuiltInDateFormatter(format, formatter) {\n\treturn (format === 'date' || format === 'datetime') && formatter === BUILT_IN_FORMATTERS[format]\n}\n\n/**\n * Format one token value.\n *\n * @param {unknown} value The raw value.\n * @param {string} format `date`, `datetime`, `weekday`, `longdate`, `fulldate`, `time`, `user`, `group`, `currency`, `relative`, `relativetime`, `ago`, `soon`, `week`, `days`, `lower`, `mailbox` or '' (as is).\n * @param {Date} now The reference moment.\n * @param {string} [arg] The format's argument (`currency:EUR`, or a row path holding the code).\n * @param {object|null} [object] The row, for a currency read from a field.\n * @param {object|null} [config] The app config map, for the reporting currency.\n * @param {object|null} [formatters] The app's named formatters (`cnFormatters`), for any other format name.\n * @return {string} The text, '' when nothing can be shown.\n * @spec openspec/changes/map-list-formatters/specs/map-list-formatters/spec.md#requirement-a-map-list-reads-display-names-through-the-apps-formatters\n */\nfunction formatValue(value, format, now, arg = '', object = null, config = null, formatters = null) {\n\t// `{list|count}`: how many entries a list holds, nothing for an empty one.\n\tif (format === 'count') {\n\t\tconst count = Array.isArray(value) ? countEntries(value, arg) : Number(value)\n\t\treturn Number.isFinite(count) && count > 0 ? String(count) : ''\n\t}\n\tif (value === null || value === undefined || value === '' || typeof value === 'object') {\n\t\treturn ''\n\t}\n\tif (format !== '' && formatters && typeof formatters[format] === 'function' && !isBuiltInDateFormatter(format, formatters[format])) {\n\t\tconst shown = formatters[format](value, object)\n\t\treturn shown === null || shown === undefined ? '' : String(shown)\n\t}\n\tif (format === 'date') {\n\t\treturn formatBoardDate(value, now)\n\t}\n\tif (format === 'datetime') {\n\t\treturn formatBoardDateTime(value, now)\n\t}\n\tif (format === 'weekday') {\n\t\treturn formatBoardWeekday(value, now, { today: arg === 'today' })\n\t}\n\tif (format === 'week') {\n\t\tconst date = parseDateValue(value)\n\t\treturn date === null ? '' : t('nextcloud-vue', 'Week {week}', { week: isoWeek(date) })\n\t}\n\tif (format === 'longdate') {\n\t\treturn formatLongDate(value, now, arg === 'year')\n\t}\n\tif (format === 'fulldate') {\n\t\treturn formatFullDate(value)\n\t}\n\tif (format === 'user') {\n\t\treturn userDisplayName(value)\n\t}\n\tif (format === 'group') {\n\t\tconst name = groupDisplayName(value)\n\t\tif (name === null) {\n\t\t\tloadGroupDisplayName(value)\n\t\t\treturn ''\n\t\t}\n\t\treturn name\n\t}\n\tif (format === 'time') {\n\t\tconst date = parseDateValue(value)\n\t\treturn date === null ? '' : formatTimeOfDay(date)\n\t}\n\tif (format === 'currency') {\n\t\t// `{amount|currency:EUR}` names the code, `{amount|currency:price.code}`\n\t\t// reads it from the row, `{amount|currency}` is the app's reporting\n\t\t// currency (EUR without one).\n\t\tconst isCode = /^[A-Za-z]{3}$/.test(arg)\n\t\treturn formatMoney(value, { currency: isCode ? arg : undefined, currencyField: !isCode && arg ? arg : undefined }, object, config)\n\t}\n\tif (format === 'relative') {\n\t\treturn formatRelativeDate(value, { now })\n\t}\n\tif (format === 'relativetime') {\n\t\treturn formatRelativeDate(value, { now, withTime: true })\n\t}\n\tif (format === 'ago') {\n\t\treturn formatAgo(value, now)\n\t}\n\tif (format === 'soon') {\n\t\treturn formatSoon(value, now)\n\t}\n\tif (format === 'mailbox') {\n\t\t// An address up to and with its @ (\"gemeente@\" from gemeente@zuiddrecht.nl).\n\t\tconst text = String(value)\n\t\tconst at = text.indexOf('@')\n\t\treturn at > 0 ? text.slice(0, at + 1) : text\n\t}\n\tif (format === 'lower') {\n\t\treturn String(value).toLocaleLowerCase()\n\t}\n\t// `{name|lowerfirst}`: a name inside a sentence, \"Verenigingen in Zuiddrecht\"\n\t// read as \"verenigingen in Zuiddrecht\".\n\tif (format === 'lowerfirst') {\n\t\tconst text = String(value)\n\t\treturn text.charAt(0).toLocaleLowerCase() + text.slice(1)\n\t}\n\t// `{count|number}`: grouped in the user's locale, \"2.180\" in Dutch.\n\tif (format === 'number') {\n\t\tconst number = Number(value)\n\t\treturn Number.isFinite(number) ? new Intl.NumberFormat(metricLocale()).format(number) : String(value)\n\t}\n\tif (format === 'days') {\n\t\t// Whole days from the date to now (0 for today; negative for a future date).\n\t\tconst date = parseDateValue(value)\n\t\treturn date === null ? '' : String(Math.floor((now.getTime() - date.getTime()) / 86400000))\n\t}\n\treturn String(value)\n}\n\n/**\n * Fill a row template such as `\"{identifier} · {caseTypeName}\"` or\n * `\"Termijn {deadline|date}\"` from an object.\n *\n * Every `{path}` token is a dot path into the object; `{path|date}` and\n * `{path|datetime}` format it as the boards write dates, `{path|weekday}` adds\n * the short weekday (\"wo 7 okt\"; `{path|weekday:today}` reads \"Vandaag, wo 7 okt\"\n * for today), `{path|longdate}` writes the month out (\"7 oktober\";\n * `{path|longdate:year}` always adds the year), `{path|fulldate}` writes the weekday and the year too (\"Donderdag 12 november 2026\"), `{path|time}` is the time\n * of day (\"08:45\"), `{path|user}` is a user id's display name (looked up\n * once, '' until it arrives), `{path|group}` is a group id's display name\n * (the same, through the group name cache), `{path|currency}`,\n * `{path|currency:EUR}` and `{path|currency:field}` write an amount in a\n * currency (a code, or the row field that holds it; without either, or when\n * the row field is empty, the app's reporting currency), `{path|relative}` and\n * `{path|relativetime}` say \"today\", \"yesterday\" and then the short date\n * (\"vandaag, 09.42\"), `{path|ago}` says how long ago it was (\"10 min\n * geleden\", \"vanochtend\", \"vrijdag\"), `{path|soon}` says when a coming moment\n * is due (\"13.00\" today, \"morgen\", \"woensdag\", then the short date), and `{path|days}` is the\n * whole days since that date (\"has waited {createdAt|days} days\"),\n * `{path|count}` is how many entries a list holds (nothing for an empty one;\n * `{path|count:key}` sums the `key` list of each entry),\n * `{path|lower}` writes the value in lower case (\"Step 2: {statusLabel|lower}\"\n * reads \"Step 2: in progress\" mid-sentence), and any other name is one of\n * the app's formatters, passed as `context.formatters` (`{id|caseAddress}`).\n * A token without a\n * value empties the WHOLE template, because \"Termijn \" is worse than nothing.\n * A template without tokens is returned as written (a constant label).\n *\n * @param {string} template The template, already translated.\n * @param {object|null} object The object to read.\n * @param {Date} [now] The reference moment for dates.\n * @param {{config?: object, formatters?: object}|null} [context] The app config map, for the reporting currency of a money token, and the app's named formatters.\n * @return {string} The filled text, or ''.\n * @spec openspec/changes/screens-relation-pages/specs/relation-pages/spec.md#requirement-a-record-list-shows-the-objects-that-point-at-this-record\n */\nexport function fillTemplate(template, object, now = new Date(), context = null) {\n\tif (typeof template !== 'string' || template.trim() === '') {\n\t\treturn ''\n\t}\n\tlet missing = false\n\tconst text = template.replace(TOKEN, (_match, path, format, arg) => {\n\t\tconst value = object && typeof object === 'object' ? readPath(object, path) : undefined\n\t\tconst shown = formatValue(value, format || '', now, arg || '', object, context && context.config ? context.config : null, context && context.formatters ? context.formatters : null)\n\t\tif (shown === '') {\n\t\t\tmissing = true\n\t\t}\n\t\treturn shown\n\t})\n\treturn missing ? '' : text.trim()\n}\n\n/**\n * The first of several templates that fills: `[\"Klaar {closedAt|date}\",\n * \"Termijn {deadline|date}\"]` reads \"Klaar ...\" once the case is closed and\n * \"Termijn ...\" while it is open. A single string is one candidate.\n *\n * @param {string|string[]} templates The candidates, in order.\n * @param {object|null} object The object to read.\n * @param {(key: string) => string} [translate] Applied to each template before filling.\n * @param {Date} [now] The reference moment for dates.\n * @param {{config?: object}|null} [context] Passed on to `fillTemplate`.\n * @return {string} The first filled text, or ''.\n * @spec openspec/changes/screens-relation-pages/specs/relation-pages/spec.md#requirement-a-record-list-shows-the-objects-that-point-at-this-record\n */\nexport function firstFilled(templates, object, translate = (key) => key, now = new Date(), context = null) {\n\tconst list = Array.isArray(templates) ? templates : [templates]\n\tfor (const template of list) {\n\t\tif (typeof template !== 'string') {\n\t\t\tcontinue\n\t\t}\n\t\tconst text = fillTemplate(translate(template), object, now, context)\n\t\tif (text !== '') {\n\t\t\treturn text\n\t\t}\n\t}\n\treturn ''\n}\n\n/**\n * Fill a template such as `\"{identifier} · {requester}\"` field by field\n * (a table column's `secondary` line, a detail page's meta line).\n *\n * A field without a value takes its separator with it: the text between two\n * fields belongs to the field after it, so an empty requester leaves\n * \"2026-0002\", not \"2026-0002 ·\", and an empty first field does not leave a\n * leading separator either. Text before the first field and after the last\n * one is kept as written. A template whose fields all have values fills\n * exactly as before.\n *\n * @spec openspec/changes/zuiddrecht-pixel-gaps-3/specs/zuiddrecht-pixel-gaps-3/spec.md#requirement-an-empty-field-takes-its-separator-with-it\n * @param {string} template The template, with `{field}` placeholders.\n * @param {(key: string) => string} valueOf The text of a field ('' when empty).\n * @return {string} The filled template.\n */\nexport function joinTemplateParts(template, valueOf) {\n\t// split() with a capture group alternates literal, field, literal, …\n\tconst parts = template.split(/\\{([^}]+)\\}/)\n\tconst lead = parts[0]\n\tconst tail = parts[parts.length - 1]\n\tlet body = ''\n\tfor (let i = 1; i < parts.length; i += 2) {\n\t\tconst value = valueOf(parts[i].trim())\n\t\tif (value === '') {\n\t\t\tcontinue\n\t\t}\n\t\t// The literal before this field: the separator, unless nothing has\n\t\t// been written yet (then there is nothing to separate from).\n\t\tconst separator = i === 1 ? '' : parts[i - 1]\n\t\tbody += (body === '' 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C,MAAM,GAAG,CAAC,EAAC;AACrC,CAAC,IAAI,IAAI,GAAG,GAAE;AACd,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;AAC3C,EAAE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAC;AACxC,EAAE,IAAI,KAAK,KAAK,EAAE,EAAE;AACpB,GAAG,QAAQ;AACX,GAAG;AACH;AACA;AACA,EAAE,MAAM,SAAS,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,EAAC;AAC/C,EAAE,IAAI,IAAI,CAAC,IAAI,KAAK,EAAE,GAAG,EAAE,GAAG,SAAS,IAAI,MAAK;AAChD,EAAE;AACF,CAAC,OAAO,IAAI,GAAG,IAAI,GAAG,IAAI;AAC1B;;;;"}
|
|
1
|
+
{"version":3,"file":"fillTemplate.js","sources":["../../../src/utils/fillTemplate.js"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 Conduction B.V.\n// SPDX-License-Identifier: EUPL-1.2\n\nimport { translate as t } from '@nextcloud/l10n'\nimport { boardDateLocale, formatAgo, formatBoardDate, formatBoardWeekday, formatRelativeDate, formatSoon, formatTimeOfDay, isoWeek } from './boardDate.js'\nimport { BUILT_IN_FORMATTERS } from './builtInFormatters.js'\nimport { parseDateValue } from './dateVariant.js'\nimport { formatMoney, metricLocale } from './formatMetric.js'\nimport { groupDisplayName, loadGroupDisplayName } from './groupAutocomplete.js'\nimport { readPath } from './readPath.js'\nimport { userDisplayName } from './userDisplayName.js'\n\nconst TOKEN = /\\{([^{}\\s|]+)(?:\\|([A-Za-z]+)(?::([^{}\\s]+))?)?\\}/g\n\n/**\n * A moment in the board's short form with the time: \"4 okt, 10:52\", or\n * \"14 feb 2024, 09:00\" outside the current year.\n *\n * @param {unknown} value A Date, a timestamp or an ISO string.\n * @param {Date} [now] The reference moment.\n * @return {string} The text, or '' when the value is not a date.\n * @spec openspec/changes/screens-relation-pages/specs/relation-pages/spec.md#requirement-a-record-list-shows-the-objects-that-point-at-this-record\n */\nexport function formatBoardDateTime(value, now = new Date()) {\n\tconst day = formatBoardDate(value, now)\n\tconst date = parseDateValue(value)\n\tif (day === '' || date === null) {\n\t\treturn ''\n\t}\n\tlet time\n\ttry {\n\t\ttime = new Intl.DateTimeFormat(boardDateLocale(), { hour: '2-digit', minute: '2-digit' }).format(date)\n\t} catch {\n\t\ttime = new Intl.DateTimeFormat(undefined, { hour: '2-digit', minute: '2-digit' }).format(date)\n\t}\n\treturn `${day}, ${time}`\n}\n\n/**\n * A date with the month written out: \"7 oktober\", or \"6 oktober 2026\"\n * outside the current year or when `withYear` asks for it.\n *\n * @param {unknown} value A Date, a timestamp or an ISO string.\n * @param {Date} now The reference moment.\n * @param {boolean} [withYear] Always write the year.\n * @return {string} The text, or '' when the value is not a date.\n * @spec openspec/changes/screens-header-meta-tokens/specs/detail-page-board-look/spec.md#requirement-the-header-meta-line-formats-users-long-dates-and-enum-labels\n */\nexport function formatLongDate(value, now = new Date(), withYear = false) {\n\tconst date = parseDateValue(value)\n\tif (date === null) {\n\t\treturn ''\n\t}\n\tconst options = { day: 'numeric', month: 'long' }\n\tif (withYear || date.getFullYear() !== now.getFullYear()) {\n\t\toptions.year = 'numeric'\n\t}\n\ttry {\n\t\treturn new Intl.DateTimeFormat(boardDateLocale(), options).format(date)\n\t} catch {\n\t\treturn new Intl.DateTimeFormat(undefined, options).format(date)\n\t}\n}\n\n/**\n * A date written out in full, the way a letter or an invitation does:\n * \"Donderdag 12 november 2026\". The weekday is capitalised, because the\n * line starts with it.\n *\n * @param {unknown} value A Date, a timestamp or an ISO string.\n * @return {string} The text, or '' when the value is not a date.\n * @spec openspec/changes/template-full-date/specs/detail-page-board-look/spec.md#requirement-a-template-can-write-a-date-in-full\n */\nexport function formatFullDate(value) {\n\tconst date = parseDateValue(value)\n\tif (date === null) {\n\t\treturn ''\n\t}\n\tconst options = { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' }\n\tlet text\n\ttry {\n\t\ttext = new Intl.DateTimeFormat(boardDateLocale(), options).format(date)\n\t} catch {\n\t\ttext = new Intl.DateTimeFormat(undefined, options).format(date)\n\t}\n\treturn text.charAt(0).toLocaleUpperCase() + text.slice(1)\n}\n\n/**\n * How many entries a list holds; with a key, the entries of that list in each\n * of its entries summed (`{sections|count:items}`: the questions of every\n * section of a checklist).\n *\n * @param {Array} list The list.\n * @param {string} key The key of each entry's own list, or '' to count the entries.\n * @return {number} The count.\n */\nfunction countEntries(list, key) {\n\tif (key === '') {\n\t\treturn list.length\n\t}\n\treturn list.reduce((sum, entry) => sum + (entry && Array.isArray(entry[key]) ? entry[key].length : 0), 0)\n}\n\n/**\n * Whether a named formatter is the library's own `date` or `datetime`, which\n * CnAppRoot puts in every page's formatters: the template's board date\n * (\"28 okt\") wins over it, an app's own formatter of that name does not.\n *\n * @param {string} format The format name.\n * @param {(value: unknown, row?: object) => unknown} formatter The formatter found under that name.\n * @return {boolean} True for the built-in date formatters.\n * @spec openspec/changes/template-date-not-shadowed/specs/template-date-not-shadowed/spec.md\n */\nfunction isBuiltInDateFormatter(format, formatter) {\n\treturn (format === 'date' || format === 'datetime') && formatter === BUILT_IN_FORMATTERS[format]\n}\n\n/**\n * Format one token value.\n *\n * @param {unknown} value The raw value.\n * @param {string} format `date`, `datetime`, `weekday`, `longdate`, `fulldate`, `time`, `user`, `group`, `currency`, `relative`, `relativetime`, `ago`, `soon`, `week`, `days`, `lower`, `mailbox` or '' (as is).\n * @param {Date} now The reference moment.\n * @param {string} [arg] The format's argument (`currency:EUR`, or a row path holding the code).\n * @param {object|null} [object] The row, for a currency read from a field.\n * @param {object|null} [config] The app config map, for the reporting currency.\n * @param {object|null} [formatters] The app's named formatters (`cnFormatters`), for any other format name.\n * @return {string} The text, '' when nothing can be shown.\n * @spec openspec/changes/map-list-formatters/specs/map-list-formatters/spec.md#requirement-a-map-list-reads-display-names-through-the-apps-formatters\n */\nfunction formatValue(value, format, now, arg = '', object = null, config = null, formatters = null) {\n\t// `{list|count}`: how many entries a list holds, nothing for an empty one.\n\tif (format === 'count') {\n\t\tconst count = Array.isArray(value) ? countEntries(value, arg) : Number(value)\n\t\treturn Number.isFinite(count) && count > 0 ? String(count) : ''\n\t}\n\tif (value === null || value === undefined || value === '' || typeof value === 'object') {\n\t\treturn ''\n\t}\n\tif (format !== '' && formatters && typeof formatters[format] === 'function' && !isBuiltInDateFormatter(format, formatters[format])) {\n\t\tconst shown = formatters[format](value, object)\n\t\treturn shown === null || shown === undefined ? '' : String(shown)\n\t}\n\tif (format === 'date') {\n\t\treturn formatBoardDate(value, now)\n\t}\n\tif (format === 'datetime') {\n\t\treturn formatBoardDateTime(value, now)\n\t}\n\tif (format === 'weekday') {\n\t\treturn formatBoardWeekday(value, now, { today: arg === 'today' })\n\t}\n\tif (format === 'week') {\n\t\tconst date = parseDateValue(value)\n\t\treturn date === null ? '' : t('nextcloud-vue', 'Week {week}', { week: isoWeek(date) })\n\t}\n\tif (format === 'longdate') {\n\t\treturn formatLongDate(value, now, arg === 'year')\n\t}\n\tif (format === 'fulldate') {\n\t\treturn formatFullDate(value)\n\t}\n\tif (format === 'user') {\n\t\treturn userDisplayName(value)\n\t}\n\tif (format === 'group') {\n\t\tconst name = groupDisplayName(value)\n\t\tif (name === null) {\n\t\t\tloadGroupDisplayName(value)\n\t\t\treturn ''\n\t\t}\n\t\treturn name\n\t}\n\tif (format === 'time') {\n\t\tconst date = parseDateValue(value)\n\t\treturn date === null ? '' : formatTimeOfDay(date)\n\t}\n\tif (format === 'currency') {\n\t\t// `{amount|currency:EUR}` names the code, `{amount|currency:price.code}`\n\t\t// reads it from the row, `{amount|currency}` is the app's reporting\n\t\t// currency (EUR without one).\n\t\tconst isCode = /^[A-Za-z]{3}$/.test(arg)\n\t\treturn formatMoney(value, { currency: isCode ? arg : undefined, currencyField: !isCode && arg ? arg : undefined }, object, config)\n\t}\n\tif (format === 'relative') {\n\t\treturn formatRelativeDate(value, { now })\n\t}\n\tif (format === 'relativetime') {\n\t\treturn formatRelativeDate(value, { now, withTime: true })\n\t}\n\tif (format === 'ago') {\n\t\treturn formatAgo(value, now)\n\t}\n\tif (format === 'soon') {\n\t\treturn formatSoon(value, now)\n\t}\n\tif (format === 'mailbox') {\n\t\t// An address up to and with its @ (\"gemeente@\" from gemeente@zuiddrecht.nl).\n\t\tconst text = String(value)\n\t\tconst at = text.indexOf('@')\n\t\treturn at > 0 ? text.slice(0, at + 1) : text\n\t}\n\tif (format === 'lower') {\n\t\treturn String(value).toLocaleLowerCase()\n\t}\n\t// `{name|lowerfirst}`: a name inside a sentence, \"Verenigingen in Zuiddrecht\"\n\t// read as \"verenigingen in Zuiddrecht\".\n\tif (format === 'lowerfirst') {\n\t\tconst text = String(value)\n\t\treturn text.charAt(0).toLocaleLowerCase() + text.slice(1)\n\t}\n\t// `{count|number}`: grouped in the user's locale, \"2.180\" in Dutch.\n\tif (format === 'number') {\n\t\tconst number = Number(value)\n\t\treturn Number.isFinite(number) ? new Intl.NumberFormat(metricLocale()).format(number) : String(value)\n\t}\n\tif (format === 'days') {\n\t\t// Whole days from the date to now (0 for today; negative for a future date).\n\t\tconst date = parseDateValue(value)\n\t\treturn date === null ? '' : String(Math.floor((now.getTime() - date.getTime()) / 86400000))\n\t}\n\treturn String(value)\n}\n\n/**\n * Fill a row template such as `\"{identifier} · {caseTypeName}\"` or\n * `\"Termijn {deadline|date}\"` from an object.\n *\n * Every `{path}` token is a dot path into the object; `{path|date}` and\n * `{path|datetime}` format it as the boards write dates, `{path|weekday}` adds\n * the short weekday (\"wo 7 okt\"; `{path|weekday:today}` reads \"Vandaag, wo 7 okt\"\n * for today), `{path|longdate}` writes the month out (\"7 oktober\";\n * `{path|longdate:year}` always adds the year), `{path|fulldate}` writes the weekday and the year too (\"Donderdag 12 november 2026\"), `{path|time}` is the time\n * of day (\"08:45\"), `{path|user}` is a user id's display name (looked up\n * once, '' until it arrives), `{path|group}` is a group id's display name\n * (the same, through the group name cache), `{path|currency}`,\n * `{path|currency:EUR}` and `{path|currency:field}` write an amount in a\n * currency (a code, or the row field that holds it; without either, or when\n * the row field is empty, the app's reporting currency), `{path|relative}` and\n * `{path|relativetime}` say \"today\", \"yesterday\" and then the short date\n * (\"vandaag, 09.42\"), `{path|ago}` says how long ago it was (\"10 min\n * geleden\", \"vanochtend\", \"vrijdag\"), `{path|soon}` says when a coming moment\n * is due (\"13.00\" today, \"morgen\", \"woensdag\", then the short date), and `{path|days}` is the\n * whole days since that date (\"has waited {createdAt|days} days\"),\n * `{path|count}` is how many entries a list holds (nothing for an empty one;\n * `{path|count:key}` sums the `key` list of each entry),\n * `{path|lower}` writes the value in lower case (\"Step 2: {statusLabel|lower}\"\n * reads \"Step 2: in progress\" mid-sentence), and any other name is one of\n * the app's formatters, passed as `context.formatters` (`{id|caseAddress}`).\n * A token without a\n * value empties the WHOLE template, because \"Termijn \" is worse than nothing.\n * A template without tokens is returned as written (a constant label).\n *\n * @param {string} template The template, already translated.\n * @param {object|null} object The object to read.\n * @param {Date} [now] The reference moment for dates.\n * @param {{config?: object, formatters?: object}|null} [context] The app config map, for the reporting currency of a money token, and the app's named formatters.\n * @return {string} The filled text, or ''.\n * @spec openspec/changes/screens-relation-pages/specs/relation-pages/spec.md#requirement-a-record-list-shows-the-objects-that-point-at-this-record\n */\nexport function fillTemplate(template, object, now = new Date(), context = null) {\n\tif (typeof template !== 'string' || template.trim() === '') {\n\t\treturn ''\n\t}\n\tlet missing = false\n\tconst text = template.replace(TOKEN, (_match, path, format, arg) => {\n\t\tconst value = object && typeof object === 'object' ? readPath(object, path) : undefined\n\t\tconst shown = formatValue(value, format || '', now, arg || '', object, context && context.config ? context.config : null, context && context.formatters ? context.formatters : null)\n\t\tif (shown === '') {\n\t\t\tmissing = true\n\t\t}\n\t\treturn shown\n\t})\n\treturn missing ? '' : text.trim()\n}\n\n/**\n * The first of several templates that fills: `[\"Klaar {closedAt|date}\",\n * \"Termijn {deadline|date}\"]` reads \"Klaar ...\" once the case is closed and\n * \"Termijn ...\" while it is open. A single string is one candidate.\n *\n * @param {string|string[]} templates The candidates, in order.\n * @param {object|null} object The object to read.\n * @param {(key: string) => string} [translate] Applied to each template before filling.\n * @param {Date} [now] The reference moment for dates.\n * @param {{config?: object}|null} [context] Passed on to `fillTemplate`.\n * @return {string} The first filled text, or ''.\n * @spec openspec/changes/screens-relation-pages/specs/relation-pages/spec.md#requirement-a-record-list-shows-the-objects-that-point-at-this-record\n */\nexport function firstFilled(templates, object, translate = (key) => key, now = new Date(), context = null) {\n\tconst list = Array.isArray(templates) ? templates : [templates]\n\tfor (const template of list) {\n\t\tif (typeof template !== 'string') {\n\t\t\tcontinue\n\t\t}\n\t\tconst text = fillTemplate(translate(template), object, now, context)\n\t\tif (text !== '') {\n\t\t\treturn text\n\t\t}\n\t}\n\treturn ''\n}\n\n/**\n * Split a template into literal, field, literal, … as\n * `template.split(/\\{([^}]+)\\}/)` does, in one linear pass.\n *\n * @param {string} template The template, with `{field}` placeholders.\n * @return {string[]} The literals at even indexes, the field names at odd ones.\n */\nfunction splitFields(template) {\n\tconst parts = []\n\tlet literalStart = 0\n\tlet open = template.indexOf('{')\n\twhile (open !== -1) {\n\t\tconst close = template.indexOf('}', open + 1)\n\t\tif (close === -1) {\n\t\t\tbreak\n\t\t}\n\t\tif (close === open + 1) {\n\t\t\topen = template.indexOf('{', close + 1)\n\t\t\tcontinue\n\t\t}\n\t\tparts.push(template.slice(literalStart, open), template.slice(open + 1, close))\n\t\tliteralStart = close + 1\n\t\topen = template.indexOf('{', literalStart)\n\t}\n\tparts.push(template.slice(literalStart))\n\treturn parts\n}\n\n/**\n * Fill a template such as `\"{identifier} · {requester}\"` field by field\n * (a table column's `secondary` line, a detail page's meta line).\n *\n * A field without a value takes its separator with it: the text between two\n * fields belongs to the field after it, so an empty requester leaves\n * \"2026-0002\", not \"2026-0002 ·\", and an empty first field does not leave a\n * leading separator either. Text before the first field and after the last\n * one is kept as written. A template whose fields all have values fills\n * exactly as before.\n *\n * @spec openspec/changes/zuiddrecht-pixel-gaps-3/specs/zuiddrecht-pixel-gaps-3/spec.md#requirement-an-empty-field-takes-its-separator-with-it\n * @param {string} template The template, with `{field}` placeholders.\n * @param {(key: string) => string} valueOf The text of a field ('' when empty).\n * @return {string} The filled template.\n */\nexport function joinTemplateParts(template, valueOf) {\n\tconst parts = splitFields(template)\n\tconst lead = parts[0]\n\tconst tail = parts[parts.length - 1]\n\tlet body = ''\n\tfor (let i = 1; i < parts.length; i += 2) {\n\t\tconst value = valueOf(parts[i].trim())\n\t\tif (value === '') {\n\t\t\tcontinue\n\t\t}\n\t\t// The literal before this field: the separator, unless nothing has\n\t\t// been written yet (then there is nothing to separate from).\n\t\tconst separator = i === 1 ? '' : parts[i - 1]\n\t\tbody += (body === '' ? '' : separator) + value\n\t}\n\treturn lead + body + tail\n}\n"],"names":["t"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AASA;AACA,MAAM,KAAK,GAAG,qDAAoD;AAClE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,mBAAmB,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI,IAAI,EAAE,EAAE;AAC7D,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,KAAK,EAAE,GAAG,EAAC;AACxC,CAAC,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,EAAC;AACnC,CAAC,IAAI,GAAG,KAAK,EAAE,IAAI,IAAI,KAAK,IAAI,EAAE;AAClC,EAAE,OAAO,EAAE;AACX,EAAE;AACF,CAAC,IAAI,KAAI;AACT,CAAC,IAAI;AACL,EAAE,IAAI,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,eAAe,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI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;AACzC,CAAC,OAAO,KAAK;AACb,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,iBAAiB,CAAC,QAAQ,EAAE,OAAO,EAAE;AACrD,CAAC,MAAM,KAAK,GAAG,WAAW,CAAC,QAAQ,EAAC;AACpC,CAAC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,EAAC;AACtB,CAAC,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAC;AACrC,CAAC,IAAI,IAAI,GAAG,GAAE;AACd,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;AAC3C,EAAE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAC;AACxC,EAAE,IAAI,KAAK,KAAK,EAAE,EAAE;AACpB,GAAG,QAAQ;AACX,GAAG;AACH;AACA;AACA,EAAE,MAAM,SAAS,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,EAAC;AAC/C,EAAE,IAAI,IAAI,CAAC,IAAI,KAAK,EAAE,GAAG,EAAE,GAAG,SAAS,IAAI,MAAK;AAChD,EAAE;AACF,CAAC,OAAO,IAAI,GAAG,IAAI,GAAG,IAAI;AAC1B;;;;"}
|
package/dist/esm/utils/forge.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { stripTrailingSlashes } from './trailingSlashes.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* SPDX-License-Identifier: EUPL-1.2
|
|
3
5
|
* SPDX-FileCopyrightText: 2026 Conduction B.V.
|
|
@@ -25,6 +27,7 @@
|
|
|
25
27
|
* else in the suggestion flow needs to change.
|
|
26
28
|
*/
|
|
27
29
|
|
|
30
|
+
|
|
28
31
|
/**
|
|
29
32
|
* Default host per forge type. `forgejo`/`gitea` are self-hosted, so they
|
|
30
33
|
* have no canonical public host — a `baseUrl` MUST be supplied for those.
|
|
@@ -101,7 +104,7 @@ function resolveForge(forge) {
|
|
|
101
104
|
const baseUrl = (forge && forge.baseUrl)
|
|
102
105
|
|| FORGE_DEFAULT_BASE_URLS[type]
|
|
103
106
|
|| DEFAULT_FORGE.baseUrl;
|
|
104
|
-
return { type, baseUrl: baseUrl
|
|
107
|
+
return { type, baseUrl: stripTrailingSlashes(baseUrl) }
|
|
105
108
|
}
|
|
106
109
|
|
|
107
110
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forge.js","sources":["../../../src/utils/forge.js"],"sourcesContent":["/**\n * SPDX-License-Identifier: EUPL-1.2\n * SPDX-FileCopyrightText: 2026 Conduction B.V.\n *\n * Forge abstraction for the in-product feature-request deep-link.\n *\n * The Conduction fleet's source of truth moved from GitHub to Codeberg\n * (Forgejo). The two forges prefill a \"new issue\" form very differently,\n * so each forge type gets its own URL builder:\n *\n * - **github** — GitHub Issue Forms support per-field deep-linking: a\n * `template=<file>` plus one query parameter per form-field `id`\n * (`problem`, `proposed-solution`, …). The pre-filled form renders\n * field-by-field on github.com.\n *\n * - **codeberg / forgejo / gitea** — Forgejo/Gitea only support the\n * universal `title` + `body` query parameters\n * (https://forgejo.org/docs/latest/user/issue-pull-request-templates/);\n * there is no per-field deep-link. So the structured fields are\n * assembled into a single Markdown `body` instead.\n *\n * Switching the whole fleet back to GitHub (or onto a self-hosted\n * Forgejo/Gitea) is a one-line config change: set `forge.type` (and\n * `forge.baseUrl` for self-hosted) on the manifest's `nav.forge`. Nothing\n * else in the suggestion flow needs to change.\n */\n\n/**\n * Default host per forge type. `forgejo`/`gitea` are self-hosted, so they\n * have no canonical public host — a `baseUrl` MUST be supplied for those.\n *\n * @type {Record<string, string>}\n */\nexport const FORGE_DEFAULT_BASE_URLS = {\n\tcodeberg: 'https://codeberg.org',\n\tgithub: 'https://github.com',\n\tforgejo: '',\n\tgitea: '',\n}\n\n/**\n * Fleet default forge. GitHub is the only host the fleet publishes to,\n * including for issues.\n *\n * This defaulted to Codeberg, and NO app overrides it — none of the fleet\n * manifests carries a `forge` entry — so every app's in-product \"Request a\n * feature\" deep-link pointed at an unmaintained mirror. The failure was\n * invisible from the app side: each app looked correctly configured because\n * it configured nothing.\n *\n * Changing the type also changes the URL SHAPE, not just the host:\n * `github` builds a per-field Issue-Form link (`template=` + field params),\n * while `codeberg`/`forgejo`/`gitea` assemble a Markdown body. That form is\n * `.github/ISSUE_TEMPLATE/feature-request.yml`, which must exist in the\n * consuming repo — see buildFeatureRequestUrl below.\n *\n * @type {{type: string, baseUrl: string}}\n */\nexport const DEFAULT_FORGE = {\n\ttype: 'github',\n\tbaseUrl: FORGE_DEFAULT_BASE_URLS.github,\n}\n\nconst ISSUE_FORM_TEMPLATE = 'feature-request.yml'\n\n/**\n * Issue form for the in-product \"Report a bug\" deep link. Like\n * ISSUE_FORM_TEMPLATE this is a FILENAME that must resolve in the target repo\n * — GitHub silently ignores a `template` it cannot find and drops the user on\n * the blank issue form.\n *\n * It resolves for every app in the fleet without any per-repo work, verified\n * against GitHub on 2026-09-02 across 21 app repos: the ConductionNL/.github\n * repository carries bug-report.yml (alongside feature-request.yml,\n * technical-task.yml and user-story.yml) as ORG-LEVEL default issue templates,\n * which GitHub offers in every repo that does not define its own\n * .github/ISSUE_TEMPLATE directory — 7 of the 21 rely on exactly that. The\n * other 14 define their own directory, which overrides the org defaults\n * wholesale, and all 14 use these same filenames.\n *\n * That override is the thing to watch: a repo that adds its own\n * .github/ISSUE_TEMPLATE without a bug-report.yml silently loses this link's\n * form and lands the reporter on the blank issue page. opencatalogi is the\n * near-miss — it kept bug_report.yml/feature_request.yml with underscores AND\n * added the hyphenated pair, so both deep links resolve there today.\n *\n * @type {string}\n */\nconst BUG_REPORT_TEMPLATE = 'bug-report.yml'\n\n/**\n * Normalise a (possibly partial) forge config to `{type, baseUrl}` with a\n * resolved host. Falls back to the GitHub default for an unknown/empty\n * type, and to the type's canonical host when `baseUrl` is omitted.\n *\n * @param {{type?: string, baseUrl?: string}|null|undefined} forge Raw config.\n * @return {{type: string, baseUrl: string}} Resolved config.\n */\nexport function resolveForge(forge) {\n\tconst type = (forge && forge.type) || DEFAULT_FORGE.type\n\tconst baseUrl = (forge && forge.baseUrl)\n\t\t|| FORGE_DEFAULT_BASE_URLS[type]\n\t\t|| DEFAULT_FORGE.baseUrl\n\treturn { type, baseUrl: baseUrl.replace(/\\/+$/, '') }\n}\n\n/**\n * Human-facing display name for a forge type (a proper noun — never\n * translated). Used in button labels and explanatory copy.\n *\n * @param {string} type Forge type (`codeberg` | `github` | `forgejo` | `gitea`).\n * @return {string} Display name, e.g. `Codeberg`. Title-cases unknown types.\n */\nexport function forgeDisplayName(type) {\n\tconst names = { codeberg: 'Codeberg', github: 'GitHub', forgejo: 'Forgejo', gitea: 'Gitea' }\n\tif (names[type]) {\n\t\treturn names[type]\n\t}\n\treturn type ? type.charAt(0).toUpperCase() + type.slice(1) : ''\n}\n\n/**\n * Build the \"request a feature\" new-issue deep-link for the given forge.\n *\n * Mirrors buildBugReportUrl deliberately (team decision, 2026-09-04): the\n * in-product suggestion form is gone, and Request-a-feature sends the user\n * straight to the forge's feature-request issue FORM, exactly like Report a\n * bug. The forge is where the whole conversation happens in English — the\n * form's own fields ask the structured questions the in-product modal used\n * to ask, and asking for English belongs in that form (the org-level\n * feature-request.yml), which every requester sees.\n *\n * Only `template` and `title` are prefilled. A query parameter REPLACES an\n * issue-form field's default value rather than appending to it, so\n * prefilling any content field would wipe the form's own skeleton (see\n * buildBugReportUrl for the history of that lesson). The headline is the\n * AUTHORED (untranslated) title when one can be recovered, else the surface\n * slug — English by construction, never the translated display title.\n *\n * @param {{type?: string, baseUrl?: string}} forge Forge config (resolved internally).\n * @param {string} repo `<owner>/<repo>` slug on the forge.\n * @param {object} [payload] Optional context. Every field is optional; the\n * link stays valid with none of them.\n * @param {string} [payload.title] The surface's AUTHORED (untranslated) title.\n * @param {string} [payload.surface] Stable surface slug, e.g. `dashboard:secrets`.\n * Used as the headline only when no authored title can be recovered.\n * @return {string} Absolute URL safe to pass to window.open.\n */\nexport function buildFeatureRequestUrl(forge, repo, payload = {}) {\n\tconst { type, baseUrl } = resolveForge(forge)\n\tconst params = new URLSearchParams()\n\n\tconst headline = (payload.title || '').trim()\n\t\t|| (payload.surface || '').trim()\n\n\tif (type === 'github') {\n\t\tparams.set('template', ISSUE_FORM_TEMPLATE)\n\t}\n\tparams.set('title', headline ? `[FEATURE] ${headline}` : '[FEATURE] ')\n\n\treturn `${baseUrl}/${repo}/issues/new?${params.toString()}`\n}\n\n/**\n * Build the \"report a bug\" new-issue deep-link for the given forge.\n *\n * Mirrors buildFeatureRequestUrl: on GitHub it targets the bug-report issue\n * FORM so the reporter gets the structured fields (description, steps,\n * expected/actual, severity) instead of an empty textarea; on\n * Forgejo/Gitea/Codeberg, which have no per-field deep-link, it passes the\n * universal `title` only.\n *\n * **Everything this generates is English and locale-independent, by design.**\n * The issue title used to be the surface's DISPLAY title, which is translated:\n * a report filed from a French UI arrived as `[BUG] Activité récente` and one\n * from a Russian UI in Cyrillic, unreadable to a maintainer even though the\n * English msgid was sitting in the manifest all along. So `title` here is the\n * AUTHORED source string — English, because English is the msgid in this\n * fleet. When no source string can be recovered the headline falls back to the\n * surface slug, which is English by construction; it never falls back to the\n * translated string, because that is the whole failure being fixed.\n *\n * The localized title is not carried anywhere in the URL. It was, briefly, as\n * context — but a maintainer can reconstruct it from the English headline and\n * the reporter's own prose, and it was the single longest thing in a link a\n * human has to look at.\n *\n * The reporter's own prose is theirs and stays in whatever language they\n * write; asking for English belongs in the issue FORM (the org-level\n * bug-report.yml), which every reporter sees, not in a URL parameter.\n *\n * The title is prefixed `[BUG]` to match the form's own `title: \"[BUG] \"`\n * default — a `title` query parameter REPLACES that default rather than\n * appending to it, so without the prefix a deep-linked report is the only one\n * in the tracker without it.\n *\n * @param {{type?: string, baseUrl?: string}} forge Forge config (resolved internally).\n * @param {string} repo `<owner>/<repo>` slug on the forge.\n * @param {object} [payload] Optional context. Every field is optional; the\n * link stays valid with none of them.\n * @param {string} [payload.title] The surface's AUTHORED (untranslated) title, e.g. `Recent activity`.\n * @param {string} [payload.surface] Stable surface slug, e.g. `dashboard:secrets`.\n * Used as the headline only when no authored title can be recovered.\n * @return {string} Absolute URL safe to pass to window.open.\n */\nexport function buildBugReportUrl(forge, repo, payload = {}) {\n\tconst { type, baseUrl } = resolveForge(forge)\n\tconst params = new URLSearchParams()\n\n\t// Headline: the authored title if we have one, else the surface slug. The\n\t// app id is NOT prefixed — the issue is filed in that app's own repo, so\n\t// it would only repeat the destination.\n\tconst headline = (payload.title || '').trim()\n\t\t|| (payload.surface || '').trim()\n\n\tif (type === 'github') {\n\t\tparams.set('template', BUG_REPORT_TEMPLATE)\n\t}\n\tparams.set('title', headline ? `[BUG] ${headline}` : '[BUG] ')\n\n\t// NOTHING ELSE is prefilled, deliberately. An earlier cut filled the form's\n\t// `environment` field with the app id, route, surface slug, UI language and\n\t// localized screen title: it doubled the URL to ~400 characters of visible\n\t// percent-encoding, and every line was either implied by where the issue\n\t// lands (the app), by the English headline (the surface, the localized\n\t// title) or by simply reading the report (the language).\n\t//\n\t// It also cost something real. A query parameter REPLACES a field's default\n\t// value, so prefilling `environment` wiped the form's own\n\t// \"- Namespace: / - Version: / - Browser:\" skeleton and the prefill had to\n\t// re-state it verbatim just to stand still. Sending nothing leaves the\n\t// form's skeleton intact and the link short enough to read.\n\n\treturn `${baseUrl}/${repo}/issues/new?${params.toString()}`\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,uBAAuB,GA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MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,mBAAmB,EAAC;AAC7C,EAAE;AACF,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,GAAG,QAAQ,EAAC;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC5D;;;;"}
|
|
1
|
+
{"version":3,"file":"forge.js","sources":["../../../src/utils/forge.js"],"sourcesContent":["/**\n * SPDX-License-Identifier: EUPL-1.2\n * SPDX-FileCopyrightText: 2026 Conduction B.V.\n *\n * Forge abstraction for the in-product feature-request deep-link.\n *\n * The Conduction fleet's source of truth moved from GitHub to Codeberg\n * (Forgejo). The two forges prefill a \"new issue\" form very differently,\n * so each forge type gets its own URL builder:\n *\n * - **github** — GitHub Issue Forms support per-field deep-linking: a\n * `template=<file>` plus one query parameter per form-field `id`\n * (`problem`, `proposed-solution`, …). The pre-filled form renders\n * field-by-field on github.com.\n *\n * - **codeberg / forgejo / gitea** — Forgejo/Gitea only support the\n * universal `title` + `body` query parameters\n * (https://forgejo.org/docs/latest/user/issue-pull-request-templates/);\n * there is no per-field deep-link. So the structured fields are\n * assembled into a single Markdown `body` instead.\n *\n * Switching the whole fleet back to GitHub (or onto a self-hosted\n * Forgejo/Gitea) is a one-line config change: set `forge.type` (and\n * `forge.baseUrl` for self-hosted) on the manifest's `nav.forge`. Nothing\n * else in the suggestion flow needs to change.\n */\n\nimport { stripTrailingSlashes } from './trailingSlashes.js'\n\n/**\n * Default host per forge type. `forgejo`/`gitea` are self-hosted, so they\n * have no canonical public host — a `baseUrl` MUST be supplied for those.\n *\n * @type {Record<string, string>}\n */\nexport const FORGE_DEFAULT_BASE_URLS = {\n\tcodeberg: 'https://codeberg.org',\n\tgithub: 'https://github.com',\n\tforgejo: '',\n\tgitea: '',\n}\n\n/**\n * Fleet default forge. GitHub is the only host the fleet publishes to,\n * including for issues.\n *\n * This defaulted to Codeberg, and NO app overrides it — none of the fleet\n * manifests carries a `forge` entry — so every app's in-product \"Request a\n * feature\" deep-link pointed at an unmaintained mirror. The failure was\n * invisible from the app side: each app looked correctly configured because\n * it configured nothing.\n *\n * Changing the type also changes the URL SHAPE, not just the host:\n * `github` builds a per-field Issue-Form link (`template=` + field params),\n * while `codeberg`/`forgejo`/`gitea` assemble a Markdown body. That form is\n * `.github/ISSUE_TEMPLATE/feature-request.yml`, which must exist in the\n * consuming repo — see buildFeatureRequestUrl below.\n *\n * @type {{type: string, baseUrl: string}}\n */\nexport const DEFAULT_FORGE = {\n\ttype: 'github',\n\tbaseUrl: FORGE_DEFAULT_BASE_URLS.github,\n}\n\nconst ISSUE_FORM_TEMPLATE = 'feature-request.yml'\n\n/**\n * Issue form for the in-product \"Report a bug\" deep link. Like\n * ISSUE_FORM_TEMPLATE this is a FILENAME that must resolve in the target repo\n * — GitHub silently ignores a `template` it cannot find and drops the user on\n * the blank issue form.\n *\n * It resolves for every app in the fleet without any per-repo work, verified\n * against GitHub on 2026-09-02 across 21 app repos: the ConductionNL/.github\n * repository carries bug-report.yml (alongside feature-request.yml,\n * technical-task.yml and user-story.yml) as ORG-LEVEL default issue templates,\n * which GitHub offers in every repo that does not define its own\n * .github/ISSUE_TEMPLATE directory — 7 of the 21 rely on exactly that. The\n * other 14 define their own directory, which overrides the org defaults\n * wholesale, and all 14 use these same filenames.\n *\n * That override is the thing to watch: a repo that adds its own\n * .github/ISSUE_TEMPLATE without a bug-report.yml silently loses this link's\n * form and lands the reporter on the blank issue page. opencatalogi is the\n * near-miss — it kept bug_report.yml/feature_request.yml with underscores AND\n * added the hyphenated pair, so both deep links resolve there today.\n *\n * @type {string}\n */\nconst BUG_REPORT_TEMPLATE = 'bug-report.yml'\n\n/**\n * Normalise a (possibly partial) forge config to `{type, baseUrl}` with a\n * resolved host. Falls back to the GitHub default for an unknown/empty\n * type, and to the type's canonical host when `baseUrl` is omitted.\n *\n * @param {{type?: string, baseUrl?: string}|null|undefined} forge Raw config.\n * @return {{type: string, baseUrl: string}} Resolved config.\n */\nexport function resolveForge(forge) {\n\tconst type = (forge && forge.type) || DEFAULT_FORGE.type\n\tconst baseUrl = (forge && forge.baseUrl)\n\t\t|| FORGE_DEFAULT_BASE_URLS[type]\n\t\t|| DEFAULT_FORGE.baseUrl\n\treturn { type, baseUrl: stripTrailingSlashes(baseUrl) }\n}\n\n/**\n * Human-facing display name for a forge type (a proper noun — never\n * translated). Used in button labels and explanatory copy.\n *\n * @param {string} type Forge type (`codeberg` | `github` | `forgejo` | `gitea`).\n * @return {string} Display name, e.g. `Codeberg`. Title-cases unknown types.\n */\nexport function forgeDisplayName(type) {\n\tconst names = { codeberg: 'Codeberg', github: 'GitHub', forgejo: 'Forgejo', gitea: 'Gitea' }\n\tif (names[type]) {\n\t\treturn names[type]\n\t}\n\treturn type ? type.charAt(0).toUpperCase() + type.slice(1) : ''\n}\n\n/**\n * Build the \"request a feature\" new-issue deep-link for the given forge.\n *\n * Mirrors buildBugReportUrl deliberately (team decision, 2026-09-04): the\n * in-product suggestion form is gone, and Request-a-feature sends the user\n * straight to the forge's feature-request issue FORM, exactly like Report a\n * bug. The forge is where the whole conversation happens in English — the\n * form's own fields ask the structured questions the in-product modal used\n * to ask, and asking for English belongs in that form (the org-level\n * feature-request.yml), which every requester sees.\n *\n * Only `template` and `title` are prefilled. A query parameter REPLACES an\n * issue-form field's default value rather than appending to it, so\n * prefilling any content field would wipe the form's own skeleton (see\n * buildBugReportUrl for the history of that lesson). The headline is the\n * AUTHORED (untranslated) title when one can be recovered, else the surface\n * slug — English by construction, never the translated display title.\n *\n * @param {{type?: string, baseUrl?: string}} forge Forge config (resolved internally).\n * @param {string} repo `<owner>/<repo>` slug on the forge.\n * @param {object} [payload] Optional context. Every field is optional; the\n * link stays valid with none of them.\n * @param {string} [payload.title] The surface's AUTHORED (untranslated) title.\n * @param {string} [payload.surface] Stable surface slug, e.g. `dashboard:secrets`.\n * Used as the headline only when no authored title can be recovered.\n * @return {string} Absolute URL safe to pass to window.open.\n */\nexport function buildFeatureRequestUrl(forge, repo, payload = {}) {\n\tconst { type, baseUrl } = resolveForge(forge)\n\tconst params = new URLSearchParams()\n\n\tconst headline = (payload.title || '').trim()\n\t\t|| (payload.surface || '').trim()\n\n\tif (type === 'github') {\n\t\tparams.set('template', ISSUE_FORM_TEMPLATE)\n\t}\n\tparams.set('title', headline ? `[FEATURE] ${headline}` : '[FEATURE] ')\n\n\treturn `${baseUrl}/${repo}/issues/new?${params.toString()}`\n}\n\n/**\n * Build the \"report a bug\" new-issue deep-link for the given forge.\n *\n * Mirrors buildFeatureRequestUrl: on GitHub it targets the bug-report issue\n * FORM so the reporter gets the structured fields (description, steps,\n * expected/actual, severity) instead of an empty textarea; on\n * Forgejo/Gitea/Codeberg, which have no per-field deep-link, it passes the\n * universal `title` only.\n *\n * **Everything this generates is English and locale-independent, by design.**\n * The issue title used to be the surface's DISPLAY title, which is translated:\n * a report filed from a French UI arrived as `[BUG] Activité récente` and one\n * from a Russian UI in Cyrillic, unreadable to a maintainer even though the\n * English msgid was sitting in the manifest all along. So `title` here is the\n * AUTHORED source string — English, because English is the msgid in this\n * fleet. When no source string can be recovered the headline falls back to the\n * surface slug, which is English by construction; it never falls back to the\n * translated string, because that is the whole failure being fixed.\n *\n * The localized title is not carried anywhere in the URL. It was, briefly, as\n * context — but a maintainer can reconstruct it from the English headline and\n * the reporter's own prose, and it was the single longest thing in a link a\n * human has to look at.\n *\n * The reporter's own prose is theirs and stays in whatever language they\n * write; asking for English belongs in the issue FORM (the org-level\n * bug-report.yml), which every reporter sees, not in a URL parameter.\n *\n * The title is prefixed `[BUG]` to match the form's own `title: \"[BUG] \"`\n * default — a `title` query parameter REPLACES that default rather than\n * appending to it, so without the prefix a deep-linked report is the only one\n * in the tracker without it.\n *\n * @param {{type?: string, baseUrl?: string}} forge Forge config (resolved internally).\n * @param {string} repo `<owner>/<repo>` slug on the forge.\n * @param {object} [payload] Optional context. Every field is optional; the\n * link stays valid with none of them.\n * @param {string} [payload.title] The surface's AUTHORED (untranslated) title, e.g. `Recent activity`.\n * @param {string} [payload.surface] Stable surface slug, e.g. `dashboard:secrets`.\n * Used as the headline only when no authored title can be recovered.\n * @return {string} Absolute URL safe to pass to window.open.\n */\nexport function buildBugReportUrl(forge, repo, payload = {}) {\n\tconst { type, baseUrl } = resolveForge(forge)\n\tconst params = new URLSearchParams()\n\n\t// Headline: the authored title if we have one, else the surface slug. The\n\t// app id is NOT prefixed — the issue is filed in that app's own repo, so\n\t// it would only repeat the destination.\n\tconst headline = (payload.title || '').trim()\n\t\t|| (payload.surface || '').trim()\n\n\tif (type === 'github') {\n\t\tparams.set('template', BUG_REPORT_TEMPLATE)\n\t}\n\tparams.set('title', headline ? `[BUG] ${headline}` : '[BUG] ')\n\n\t// NOTHING ELSE is prefilled, deliberately. An earlier cut filled the form's\n\t// `environment` field with the app id, route, surface slug, UI language and\n\t// localized screen title: it doubled the URL to ~400 characters of visible\n\t// percent-encoding, and every line was either implied by where the issue\n\t// lands (the app), by the English headline (the surface, the localized\n\t// title) or by simply reading the report (the language).\n\t//\n\t// It also cost something real. A query parameter REPLACES a field's default\n\t// value, so prefilling `environment` wiped the form's own\n\t// \"- Namespace: / - Version: / - Browser:\" skeleton and the prefill had to\n\t// re-state it verbatim just to stand still. Sending nothing leaves the\n\t// form's skeleton intact and the link short enough to read.\n\n\treturn `${baseUrl}/${repo}/issues/new?${params.toString()}`\n}\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,uBAAuB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CAAC,UAAU,EAAE,mBAAmB,EAAC;AAC7C,EAAE;AACF,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,GAAG,QAAQ,EAAC;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC5D;;;;"}
|
package/dist/esm/utils/myTeam.js
CHANGED
|
@@ -195,9 +195,23 @@ function fillMyTeamToken(text, name) {
|
|
|
195
195
|
if (typeof text !== 'string' || !text.includes('{myTeam}')) {
|
|
196
196
|
return text
|
|
197
197
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
198
|
+
let out = '';
|
|
199
|
+
let pos = 0;
|
|
200
|
+
for (;;) {
|
|
201
|
+
const open = text.indexOf('[', pos);
|
|
202
|
+
const close = open === -1 ? -1 : text.indexOf(']', open + 1);
|
|
203
|
+
if (close === -1) {
|
|
204
|
+
break
|
|
205
|
+
}
|
|
206
|
+
const part = text.slice(open + 1, close);
|
|
207
|
+
if (part.includes('{myTeam}')) {
|
|
208
|
+
out += text.slice(pos, open) + (name ? part.replaceAll('{myTeam}', name) : '');
|
|
209
|
+
} else {
|
|
210
|
+
out += text.slice(pos, close + 1);
|
|
211
|
+
}
|
|
212
|
+
pos = close + 1;
|
|
213
|
+
}
|
|
214
|
+
return (out + text.slice(pos)).replaceAll('{myTeam}', name)
|
|
201
215
|
}
|
|
202
216
|
|
|
203
217
|
export { fillMyTeamToken, loadMyTeam, loadMyTeamName, peekMyTeam, peekMyTeamName, registerMyTeamNameSource, registerMyTeamSource };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"myTeam.js","sources":["../../../src/utils/myTeam.js"],"sourcesContent":["/**\n * SPDX-FileCopyrightText: 2026 Conduction B.V.\n * SPDX-License-Identifier: EUPL-1.2\n *\n * The current user's primary team, for the `@myTeam` filter token.\n *\n * A team is the app's notion, not Nextcloud's: Nextcloud knows the groups a\n * user is in, and only the app knows which one of them is the user's team.\n * So the app registers where to read it (`registerMyTeamSource`), and the\n * library reads it once per page. This module imports no `@nextcloud/*`\n * package, for the same reason `userGroupsPeek.js` does not: the token\n * resolver runs on public pages and in node.\n *\n * @module utils/myTeam\n */\n\nimport { reactive } from 'vue'\n\n/**\n * `team` is the group id, `''` when the user has no team (or the app named no\n * source), and `null` while it has not been read.\n *\n * @type {{ team: (string|null) }}\n */\nconst _state = reactive({ team: null })\n\n/** The app's loader, `() => Promise<string|null>`. */\nlet _source = null\n\n/** The read in flight, shared by every caller. */\nlet _pending = null\n\n/**\n * The team the app answered, as kept: one group id, a list of two or more,\n * or `''` for none. Blank entries are dropped and a list of one reads as that\n * one id.\n *\n * @spec openspec/changes/my-team-source-may-answer-several-teams/specs/schema-utilities/spec.md#requirement-myteam-may-resolve-to-several-teams\n * @param {unknown} team What the app's loader answered.\n * @return {string|string[]} The kept team.\n */\nfunction normalizeTeam(team) {\n\tif (Array.isArray(team)) {\n\t\tconst ids = team.filter((id) => typeof id === 'string').map((id) => id.trim()).filter((id) => id !== '')\n\t\tif (ids.length === 0) {\n\t\t\treturn ''\n\t\t}\n\t\treturn ids.length === 1 ? ids[0] : ids\n\t}\n\treturn typeof team === 'string' ? team.trim() : ''\n}\n\n/**\n * Name where the current user's primary team is read: a function answering\n * the team's Nextcloud group id, or null/'' for a user in no team.\n *\n * @spec openspec/changes/saved-view-tokens-my-team/specs/schema-utilities/spec.md#requirement-myteam-resolves-to-the-current-users-primary-team\n * @param {(() => Promise<string|string[]|null>)|null} loader The app's loader (a group id, or the ids of several teams), or null to unregister.\n * @return {void}\n */\nexport function registerMyTeamSource(loader) {\n\t_source = typeof loader === 'function' ? loader : null\n\t_state.team = null\n\t_pending = null\n}\n\n/**\n * Read the team, once. Resolves to the group id, or `''` when there is none,\n * when no source is registered, or when the read fails.\n *\n * @spec openspec/changes/saved-view-tokens-my-team/specs/schema-utilities/spec.md#requirement-myteam-resolves-to-the-current-users-primary-team\n * @return {Promise<string|string[]>} The team's group id (or ids), or ''.\n */\nexport function loadMyTeam() {\n\tif (_state.team !== null) {\n\t\treturn Promise.resolve(_state.team)\n\t}\n\tif (_pending) {\n\t\treturn _pending\n\t}\n\tif (!_source) {\n\t\t_state.team = ''\n\t\treturn Promise.resolve('')\n\t}\n\t_pending = Promise.resolve()\n\t\t.then(() => _source())\n\t\t.then((team) => normalizeTeam(team))\n\t\t.catch(() => '')\n\t\t.then((team) => {\n\t\t\t_state.team = team\n\t\t\t_pending = null\n\t\t\treturn team\n\t\t})\n\treturn _pending\n}\n\n/**\n * Synchronous, reactive read: the group id, `''` for no team, or `null` while\n * it is being read (and starts the read on first use).\n *\n * @spec openspec/changes/saved-view-tokens-my-team/specs/schema-utilities/spec.md#requirement-myteam-resolves-to-the-current-users-primary-team\n * @return {string|string[]|null} The team (or teams), '' or null.\n */\nexport function peekMyTeam() {\n\tif (_state.team === null) {\n\t\tloadMyTeam()\n\t}\n\treturn _state.team\n}\n\n/**\n * The reader's team by name, for `{myTeam}` in a count line. `name` is `''`\n * for no team (or no source) and `null` while it has not been read.\n *\n * @type {{ name: (string|null) }}\n */\nconst _nameState = reactive({ name: null })\n\n/** The app's name loader, `() => Promise<string|null>`. */\nlet _nameSource = null\n\n/** The name read in flight. */\nlet _namePending = null\n\n/**\n * Name where the reader's team name is read: a function answering the\n * team's display name, or null/'' for a reader in no team.\n *\n * @spec openspec/changes/count-line-my-team-name/specs/index-page/spec.md#requirement-the-count-line-can-name-the-readers-team\n * @param {(() => Promise<string|null>)|null} loader The app's loader, or null to unregister.\n * @return {void}\n */\nexport function registerMyTeamNameSource(loader) {\n\t_nameSource = typeof loader === 'function' ? loader : null\n\t_nameState.name = null\n\t_namePending = null\n}\n\n/**\n * Read the team name, once. Resolves to the name, or `''` without a team,\n * without a source, or when the read fails.\n *\n * @spec openspec/changes/count-line-my-team-name/specs/index-page/spec.md#requirement-the-count-line-can-name-the-readers-team\n * @return {Promise<string>} The name, or ''.\n */\nexport function loadMyTeamName() {\n\tif (_nameState.name !== null) {\n\t\treturn Promise.resolve(_nameState.name)\n\t}\n\tif (_namePending) {\n\t\treturn _namePending\n\t}\n\tif (!_nameSource) {\n\t\t_nameState.name = ''\n\t\treturn Promise.resolve('')\n\t}\n\t_namePending = Promise.resolve()\n\t\t.then(() => _nameSource())\n\t\t.then((name) => (typeof name === 'string' ? name.trim() : ''))\n\t\t.catch(() => '')\n\t\t.then((name) => {\n\t\t\t_nameState.name = name\n\t\t\t_namePending = null\n\t\t\treturn name\n\t\t})\n\treturn _namePending\n}\n\n/**\n * Synchronous, reactive read of the team name: the name, `''` for no team,\n * or `null` while it is read (and starts the read on first use).\n *\n * @spec openspec/changes/count-line-my-team-name/specs/index-page/spec.md#requirement-the-count-line-can-name-the-readers-team\n * @return {string|null} The name, '' or null.\n */\nexport function peekMyTeamName() {\n\tif (_nameState.name === null) {\n\t\tloadMyTeamName()\n\t}\n\treturn _nameState.name\n}\n\n/**\n * Fill `{myTeam}` in a line with the team name. A part in square brackets\n * that holds `{myTeam}` is left out while there is no name; other brackets\n * are kept as written.\n *\n * @spec openspec/changes/count-line-my-team-name/specs/index-page/spec.md#requirement-the-count-line-can-name-the-readers-team\n * @param {string} text The line.\n * @param {string} name The team name, '' for none.\n * @return {string} The filled line.\n */\nexport function fillMyTeamToken(text, name) {\n\tif (typeof text !== 'string' || !text.includes('{myTeam}')) {\n\t\treturn text\n\t}\n\treturn text\n\t\t.replace(/\\[([^\\]]*\\{myTeam\\}[^\\]]*)\\]/g, (match, part) => (name ? part.replaceAll('{myTeam}', name) : ''))\n\t\t.replaceAll('{myTeam}', name)\n}\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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,CAAC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;AAC7D,EAAE,OAAO,IAAI;AACb,EAAE;AACF,CAAC,OAAO,IAAI;AACZ,GAAG,OAAO,CAAC,+BAA+B,EAAE,CAAC,KAAK,EAAE,IAAI,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;AAC7G,GAAG,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC;AAC/B;;;;"}
|
|
1
|
+
{"version":3,"file":"myTeam.js","sources":["../../../src/utils/myTeam.js"],"sourcesContent":["/**\n * SPDX-FileCopyrightText: 2026 Conduction B.V.\n * SPDX-License-Identifier: EUPL-1.2\n *\n * The current user's primary team, for the `@myTeam` filter token.\n *\n * A team is the app's notion, not Nextcloud's: Nextcloud knows the groups a\n * user is in, and only the app knows which one of them is the user's team.\n * So the app registers where to read it (`registerMyTeamSource`), and the\n * library reads it once per page. This module imports no `@nextcloud/*`\n * package, for the same reason `userGroupsPeek.js` does not: the token\n * resolver runs on public pages and in node.\n *\n * @module utils/myTeam\n */\n\nimport { reactive } from 'vue'\n\n/**\n * `team` is the group id, `''` when the user has no team (or the app named no\n * source), and `null` while it has not been read.\n *\n * @type {{ team: (string|null) }}\n */\nconst _state = reactive({ team: null })\n\n/** The app's loader, `() => Promise<string|null>`. */\nlet _source = null\n\n/** The read in flight, shared by every caller. */\nlet _pending = null\n\n/**\n * The team the app answered, as kept: one group id, a list of two or more,\n * or `''` for none. Blank entries are dropped and a list of one reads as that\n * one id.\n *\n * @spec openspec/changes/my-team-source-may-answer-several-teams/specs/schema-utilities/spec.md#requirement-myteam-may-resolve-to-several-teams\n * @param {unknown} team What the app's loader answered.\n * @return {string|string[]} The kept team.\n */\nfunction normalizeTeam(team) {\n\tif (Array.isArray(team)) {\n\t\tconst ids = team.filter((id) => typeof id === 'string').map((id) => id.trim()).filter((id) => id !== '')\n\t\tif (ids.length === 0) {\n\t\t\treturn ''\n\t\t}\n\t\treturn ids.length === 1 ? ids[0] : ids\n\t}\n\treturn typeof team === 'string' ? team.trim() : ''\n}\n\n/**\n * Name where the current user's primary team is read: a function answering\n * the team's Nextcloud group id, or null/'' for a user in no team.\n *\n * @spec openspec/changes/saved-view-tokens-my-team/specs/schema-utilities/spec.md#requirement-myteam-resolves-to-the-current-users-primary-team\n * @param {(() => Promise<string|string[]|null>)|null} loader The app's loader (a group id, or the ids of several teams), or null to unregister.\n * @return {void}\n */\nexport function registerMyTeamSource(loader) {\n\t_source = typeof loader === 'function' ? loader : null\n\t_state.team = null\n\t_pending = null\n}\n\n/**\n * Read the team, once. Resolves to the group id, or `''` when there is none,\n * when no source is registered, or when the read fails.\n *\n * @spec openspec/changes/saved-view-tokens-my-team/specs/schema-utilities/spec.md#requirement-myteam-resolves-to-the-current-users-primary-team\n * @return {Promise<string|string[]>} The team's group id (or ids), or ''.\n */\nexport function loadMyTeam() {\n\tif (_state.team !== null) {\n\t\treturn Promise.resolve(_state.team)\n\t}\n\tif (_pending) {\n\t\treturn _pending\n\t}\n\tif (!_source) {\n\t\t_state.team = ''\n\t\treturn Promise.resolve('')\n\t}\n\t_pending = Promise.resolve()\n\t\t.then(() => _source())\n\t\t.then((team) => normalizeTeam(team))\n\t\t.catch(() => '')\n\t\t.then((team) => {\n\t\t\t_state.team = team\n\t\t\t_pending = null\n\t\t\treturn team\n\t\t})\n\treturn _pending\n}\n\n/**\n * Synchronous, reactive read: the group id, `''` for no team, or `null` while\n * it is being read (and starts the read on first use).\n *\n * @spec openspec/changes/saved-view-tokens-my-team/specs/schema-utilities/spec.md#requirement-myteam-resolves-to-the-current-users-primary-team\n * @return {string|string[]|null} The team (or teams), '' or null.\n */\nexport function peekMyTeam() {\n\tif (_state.team === null) {\n\t\tloadMyTeam()\n\t}\n\treturn _state.team\n}\n\n/**\n * The reader's team by name, for `{myTeam}` in a count line. `name` is `''`\n * for no team (or no source) and `null` while it has not been read.\n *\n * @type {{ name: (string|null) }}\n */\nconst _nameState = reactive({ name: null })\n\n/** The app's name loader, `() => Promise<string|null>`. */\nlet _nameSource = null\n\n/** The name read in flight. */\nlet _namePending = null\n\n/**\n * Name where the reader's team name is read: a function answering the\n * team's display name, or null/'' for a reader in no team.\n *\n * @spec openspec/changes/count-line-my-team-name/specs/index-page/spec.md#requirement-the-count-line-can-name-the-readers-team\n * @param {(() => Promise<string|null>)|null} loader The app's loader, or null to unregister.\n * @return {void}\n */\nexport function registerMyTeamNameSource(loader) {\n\t_nameSource = typeof loader === 'function' ? loader : null\n\t_nameState.name = null\n\t_namePending = null\n}\n\n/**\n * Read the team name, once. Resolves to the name, or `''` without a team,\n * without a source, or when the read fails.\n *\n * @spec openspec/changes/count-line-my-team-name/specs/index-page/spec.md#requirement-the-count-line-can-name-the-readers-team\n * @return {Promise<string>} The name, or ''.\n */\nexport function loadMyTeamName() {\n\tif (_nameState.name !== null) {\n\t\treturn Promise.resolve(_nameState.name)\n\t}\n\tif (_namePending) {\n\t\treturn _namePending\n\t}\n\tif (!_nameSource) {\n\t\t_nameState.name = ''\n\t\treturn Promise.resolve('')\n\t}\n\t_namePending = Promise.resolve()\n\t\t.then(() => _nameSource())\n\t\t.then((name) => (typeof name === 'string' ? name.trim() : ''))\n\t\t.catch(() => '')\n\t\t.then((name) => {\n\t\t\t_nameState.name = name\n\t\t\t_namePending = null\n\t\t\treturn name\n\t\t})\n\treturn _namePending\n}\n\n/**\n * Synchronous, reactive read of the team name: the name, `''` for no team,\n * or `null` while it is read (and starts the read on first use).\n *\n * @spec openspec/changes/count-line-my-team-name/specs/index-page/spec.md#requirement-the-count-line-can-name-the-readers-team\n * @return {string|null} The name, '' or null.\n */\nexport function peekMyTeamName() {\n\tif (_nameState.name === null) {\n\t\tloadMyTeamName()\n\t}\n\treturn _nameState.name\n}\n\n/**\n * Fill `{myTeam}` in a line with the team name. A part in square brackets\n * that holds `{myTeam}` is left out while there is no name; other brackets\n * are kept as written.\n *\n * @spec openspec/changes/count-line-my-team-name/specs/index-page/spec.md#requirement-the-count-line-can-name-the-readers-team\n * @param {string} text The line.\n * @param {string} name The team name, '' for none.\n * @return {string} The filled line.\n */\nexport function fillMyTeamToken(text, name) {\n\tif (typeof text !== 'string' || !text.includes('{myTeam}')) {\n\t\treturn text\n\t}\n\tlet out = ''\n\tlet pos = 0\n\tfor (;;) {\n\t\tconst open = text.indexOf('[', pos)\n\t\tconst close = open === -1 ? -1 : text.indexOf(']', open + 1)\n\t\tif (close === -1) {\n\t\t\tbreak\n\t\t}\n\t\tconst part = text.slice(open + 1, close)\n\t\tif (part.includes('{myTeam}')) {\n\t\t\tout += text.slice(pos, open) + (name ? part.replaceAll('{myTeam}', name) : '')\n\t\t} else {\n\t\t\tout += text.slice(pos, close + 1)\n\t\t}\n\t\tpos = close + 1\n\t}\n\treturn (out + text.slice(pos)).replaceAll('{myTeam}', name)\n}\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,MAAM,GAAG,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAC;AACvC;AACA;AACA,IAAI,OAAO,GAAG,KAAI;AAClB;AACA;AACA,IAAI,QAAQ,GAAG,KAAI;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,aAAa,CAAC,IAAI,EAAE;AAC7B,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;AAC1B,EAAE,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EA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