@anchrd/intel 0.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +496 -0
- package/bin/intel.mjs +134 -0
- package/dist/adapters/cloudflare/cloudflare-flow-workflow.d.ts +42 -0
- package/dist/adapters/cloudflare/cloudflare-flow-workflow.js +89 -0
- package/dist/adapters/cloudflare/cloudflare.d.ts +29 -0
- package/dist/adapters/cloudflare/cloudflare.js +416 -0
- package/dist/adapters/cloudflare/cloudflare.types.d.ts +31 -0
- package/dist/adapters/cloudflare/cloudflare.types.js +1 -0
- package/dist/adapters/content/content.d.ts +3 -0
- package/dist/adapters/content/content.js +128 -0
- package/dist/adapters/content/content.types.d.ts +38 -0
- package/dist/adapters/content/content.types.js +1 -0
- package/dist/adapters/db/db-audit.d.ts +62 -0
- package/dist/adapters/db/db-audit.js +150 -0
- package/dist/adapters/db/db-boards.d.ts +6 -0
- package/dist/adapters/db/db-boards.js +324 -0
- package/dist/adapters/db/db-feed.d.ts +30 -0
- package/dist/adapters/db/db-feed.js +276 -0
- package/dist/adapters/db/db-flows.d.ts +42 -0
- package/dist/adapters/db/db-flows.js +1311 -0
- package/dist/adapters/db/db-grants.d.ts +133 -0
- package/dist/adapters/db/db-grants.js +269 -0
- package/dist/adapters/db/db-indexing.d.ts +3 -0
- package/dist/adapters/db/db-indexing.js +200 -0
- package/dist/adapters/db/db-oauth.d.ts +3 -0
- package/dist/adapters/db/db-oauth.js +26 -0
- package/dist/adapters/db/db-prompts.d.ts +46 -0
- package/dist/adapters/db/db-prompts.js +144 -0
- package/dist/adapters/db/db.d.ts +6 -0
- package/dist/adapters/db/db.js +1687 -0
- package/dist/adapters/db/db.types.d.ts +16 -0
- package/dist/adapters/db/db.types.js +1 -0
- package/dist/adapters/document-converter/document-converter.d.ts +2 -0
- package/dist/adapters/document-converter/document-converter.js +26 -0
- package/dist/adapters/document-converter/document-converter.types.d.ts +17 -0
- package/dist/adapters/document-converter/document-converter.types.js +1 -0
- package/dist/adapters/flow-runtime/flow-runtime.d.ts +3 -0
- package/dist/adapters/flow-runtime/flow-runtime.js +22 -0
- package/dist/adapters/flow-runtime/flow-runtime.types.d.ts +19 -0
- package/dist/adapters/flow-runtime/flow-runtime.types.js +1 -0
- package/dist/adapters/index-queue/index-queue.d.ts +10 -0
- package/dist/adapters/index-queue/index-queue.js +12 -0
- package/dist/adapters/index-queue/index-queue.types.d.ts +11 -0
- package/dist/adapters/index-queue/index-queue.types.js +1 -0
- package/dist/adapters/json-schema/json-schema.d.ts +2 -0
- package/dist/adapters/json-schema/json-schema.js +77 -0
- package/dist/adapters/openid/openid.d.ts +5 -0
- package/dist/adapters/openid/openid.js +301 -0
- package/dist/adapters/portal-tokens/portal-tokens.d.ts +8 -0
- package/dist/adapters/portal-tokens/portal-tokens.js +79 -0
- package/dist/adapters/remote-tools/remote-tools.d.ts +5 -0
- package/dist/adapters/remote-tools/remote-tools.js +129 -0
- package/dist/adapters/semantic-index/semantic-index.d.ts +2 -0
- package/dist/adapters/semantic-index/semantic-index.js +139 -0
- package/dist/adapters/semantic-index/semantic-index.types.d.ts +56 -0
- package/dist/adapters/semantic-index/semantic-index.types.js +1 -0
- package/dist/adapters/session-cookie/session-cookie.d.ts +5 -0
- package/dist/adapters/session-cookie/session-cookie.js +87 -0
- package/dist/adapters/tool-source-policy/tool-source-policy.d.ts +1 -0
- package/dist/adapters/tool-source-policy/tool-source-policy.js +22 -0
- package/dist/audit/audit.d.ts +2 -0
- package/dist/audit/audit.js +87 -0
- package/dist/audit/audit.types.d.ts +23 -0
- package/dist/audit/audit.types.js +1 -0
- package/dist/auth/auth.d.ts +2 -0
- package/dist/auth/auth.js +284 -0
- package/dist/auth/auth.types.d.ts +108 -0
- package/dist/auth/auth.types.js +1 -0
- package/dist/boards/boards.d.ts +44 -0
- package/dist/boards/boards.js +447 -0
- package/dist/boards/boards.types.d.ts +117 -0
- package/dist/boards/boards.types.js +1 -0
- package/dist/build/build.d.ts +2 -0
- package/dist/build/build.js +192 -0
- package/dist/build/build.types.d.ts +17 -0
- package/dist/build/build.types.js +1 -0
- package/dist/bundle/bundle.d.ts +4 -0
- package/dist/bundle/bundle.js +1194 -0
- package/dist/bundle/bundle.types.d.ts +33 -0
- package/dist/bundle/bundle.types.js +1 -0
- package/dist/cli/cli.d.ts +4 -0
- package/dist/cli/cli.js +262 -0
- package/dist/cli/cli.types.d.ts +14 -0
- package/dist/cli/cli.types.js +1 -0
- package/dist/contract/audit.d.ts +50 -0
- package/dist/contract/audit.js +72 -0
- package/dist/contract/board.d.ts +150 -0
- package/dist/contract/board.js +262 -0
- package/dist/contract/bundle.d.ts +147 -0
- package/dist/contract/bundle.js +139 -0
- package/dist/contract/contract.d.ts +112 -0
- package/dist/contract/contract.js +143 -0
- package/dist/contract/feed.d.ts +126 -0
- package/dist/contract/feed.js +149 -0
- package/dist/contract/flow-run.d.ts +346 -0
- package/dist/contract/flow-run.js +194 -0
- package/dist/contract/flow.d.ts +1057 -0
- package/dist/contract/flow.js +552 -0
- package/dist/contract/node.d.ts +551 -0
- package/dist/contract/node.js +456 -0
- package/dist/contract/share.d.ts +216 -0
- package/dist/contract/share.js +134 -0
- package/dist/contract/table.d.ts +171 -0
- package/dist/contract/table.js +117 -0
- package/dist/contract/tool.d.ts +122 -0
- package/dist/contract/tool.js +172 -0
- package/dist/feed/feed.d.ts +2 -0
- package/dist/feed/feed.js +77 -0
- package/dist/feed/feed.types.d.ts +23 -0
- package/dist/feed/feed.types.js +1 -0
- package/dist/flows/flows.d.ts +41 -0
- package/dist/flows/flows.js +2216 -0
- package/dist/flows/flows.types.d.ts +339 -0
- package/dist/flows/flows.types.js +1 -0
- package/dist/http/http.d.ts +9 -0
- package/dist/http/http.js +874 -0
- package/dist/http/http.types.d.ts +22 -0
- package/dist/http/http.types.js +1 -0
- package/dist/indexing/indexing.d.ts +6 -0
- package/dist/indexing/indexing.js +239 -0
- package/dist/indexing/indexing.types.d.ts +11 -0
- package/dist/indexing/indexing.types.js +1 -0
- package/dist/intel/intel.d.ts +3 -0
- package/dist/intel/intel.js +194 -0
- package/dist/intel/intel.types.d.ts +24 -0
- package/dist/intel/intel.types.js +1 -0
- package/dist/mcp/mcp.d.ts +2 -0
- package/dist/mcp/mcp.js +1292 -0
- package/dist/mcp/mcp.types.d.ts +25 -0
- package/dist/mcp/mcp.types.js +1 -0
- package/dist/nodes/document-links/document-links.d.ts +20 -0
- package/dist/nodes/document-links/document-links.js +57 -0
- package/dist/nodes/nodes.d.ts +2 -0
- package/dist/nodes/nodes.js +1667 -0
- package/dist/nodes/nodes.types.d.ts +511 -0
- package/dist/nodes/nodes.types.js +1 -0
- package/dist/prepare/prepare.d.ts +4 -0
- package/dist/prepare/prepare.js +16 -0
- package/dist/prepare/prepare.types.d.ts +9 -0
- package/dist/prepare/prepare.types.js +1 -0
- package/dist/prompts/prompts.d.ts +2 -0
- package/dist/prompts/prompts.js +65 -0
- package/dist/prompts/prompts.types.d.ts +71 -0
- package/dist/prompts/prompts.types.js +1 -0
- package/dist/shared/callers/callers.d.ts +28 -0
- package/dist/shared/callers/callers.js +30 -0
- package/dist/shared/csv/csv.d.ts +13 -0
- package/dist/shared/csv/csv.js +85 -0
- package/dist/shared/document-text/document-text.d.ts +21 -0
- package/dist/shared/document-text/document-text.js +31 -0
- package/dist/shared/gate-authorization/gate-authorization.d.ts +5 -0
- package/dist/shared/gate-authorization/gate-authorization.js +26 -0
- package/dist/shared/grant-expiry/grant-expiry.d.ts +19 -0
- package/dist/shared/grant-expiry/grant-expiry.js +26 -0
- package/dist/shared/intel-error/intel-error.d.ts +22 -0
- package/dist/shared/intel-error/intel-error.js +27 -0
- package/dist/shared/plain-title/plain-title.d.ts +16 -0
- package/dist/shared/plain-title/plain-title.js +45 -0
- package/dist/shared/problem-details/problem-details.d.ts +30 -0
- package/dist/shared/problem-details/problem-details.js +18 -0
- package/dist/shared/report-unexpected-error/report-unexpected-error.d.ts +1 -0
- package/dist/shared/report-unexpected-error/report-unexpected-error.js +37 -0
- package/dist/shared/safe-return-path/safe-return-path.d.ts +2 -0
- package/dist/shared/safe-return-path/safe-return-path.js +11 -0
- package/dist/shared/sha256/sha256.d.ts +2 -0
- package/dist/shared/sha256/sha256.js +14 -0
- package/dist/tools/tool-servers/tool-servers.d.ts +46 -0
- package/dist/tools/tool-servers/tool-servers.js +177 -0
- package/dist/tools/tools.d.ts +2 -0
- package/dist/tools/tools.js +207 -0
- package/dist/tools/tools.types.d.ts +56 -0
- package/dist/tools/tools.types.js +1 -0
- package/examples/branding/favicon.svg +5 -0
- package/examples/branding/logo.svg +5 -0
- package/examples/branding/theme.css +16 -0
- package/examples/dev.vars.example +7 -0
- package/examples/intel.json +9 -0
- package/migrations/0000_intel_foundation.sql +203 -0
- package/migrations/0001_portal_native_tools.sql +21 -0
- package/migrations/0002_flows_in_the_knowledge_tree.sql +34 -0
- package/migrations/0003_folder_permissions.sql +211 -0
- package/migrations/0004_subflow_runs.sql +14 -0
- package/migrations/0005_flow_node_cleanup.sql +28 -0
- package/migrations/0005_tables_in_the_knowledge_tree.sql +68 -0
- package/migrations/0006_links_are_written_in_the_text.sql +20 -0
- package/migrations/0007_no_node_waits.sql +69 -0
- package/migrations/0008_three_layers.sql +130 -0
- package/migrations/0009_no_context_policy.sql +48 -0
- package/migrations/0010_no_run_waits_a_year.sql +27 -0
- package/migrations/0011_one_name_for_the_tree.sql +53 -0
- package/migrations/0012_table_snapshots.sql +29 -0
- package/migrations/0017_a_vector_per_card.sql +38 -0
- package/migrations/0018_no_context_policy_at_last.sql +97 -0
- package/migrations/0019_one_name_for_the_grants.sql +52 -0
- package/migrations/0020_cascade_purge_replay.sql +11 -0
- package/migrations/0021_a_flow_carries_its_own_grant.sql +44 -0
- package/migrations/0022_a_cursor_over_the_journal.sql +14 -0
- package/migrations/0023_a_board_and_its_tasks.sql +116 -0
- package/migrations/0024_the_archive_is_a_column.sql +33 -0
- package/migrations/0025_archiving_takes_the_subtree.sql +29 -0
- package/migrations/0026_one_feed_over_two_kinds.sql +23 -0
- package/migrations/0027_the_runs_of_every_flow.sql +27 -0
- package/migrations/0028_a_prompt_name_over_two_kinds.sql +70 -0
- package/package.json +118 -0
- package/src/contract/CLAUDE.md +152 -0
- package/src/contract/README.md +102 -0
- package/src/contract/audit.ts +85 -0
- package/src/contract/board.ts +306 -0
- package/src/contract/bundle.ts +157 -0
- package/src/contract/contract.ts +161 -0
- package/src/contract/feed.ts +165 -0
- package/src/contract/flow-run.ts +241 -0
- package/src/contract/flow.ts +675 -0
- package/src/contract/node.ts +583 -0
- package/src/contract/share.ts +196 -0
- package/src/contract/table.ts +178 -0
- package/src/contract/tool.ts +202 -0
- package/ui/README.md +110 -0
- package/ui/components.json +21 -0
- package/ui/index.html +13 -0
- package/ui/package.json +11 -0
- package/ui/scripts/lint-tokens.mjs +187 -0
- package/ui/src/access-summary/access-summary.tsx +385 -0
- package/ui/src/app/action-slot/action-slot.tsx +27 -0
- package/ui/src/app/app-sidebar/app-sidebar.tsx +71 -0
- package/ui/src/app/app-tree/app-tree.tsx +1175 -0
- package/ui/src/app/app.tsx +87 -0
- package/ui/src/app/header-search/header-search.tsx +294 -0
- package/ui/src/app/reindex-dialog/reindex-dialog.tsx +79 -0
- package/ui/src/app/settings-dialog/settings-dialog.tsx +135 -0
- package/ui/src/app/sidebar-preferences/sidebar-preferences.ts +68 -0
- package/ui/src/app/sidebar-preferences/sidebar-preferences.types.ts +15 -0
- package/ui/src/app/sidebar-resize-handle/sidebar-resize-handle.tsx +86 -0
- package/ui/src/app/tree-expansion/tree-expansion.ts +107 -0
- package/ui/src/app/tree-expansion/tree-expansion.types.ts +31 -0
- package/ui/src/app/tree-move/tree-move.tsx +427 -0
- package/ui/src/app/tree-reveal/tree-reveal.ts +64 -0
- package/ui/src/app/tree-reveal/tree-reveal.types.ts +16 -0
- package/ui/src/app/user-footer/user-footer.tsx +188 -0
- package/ui/src/app/view-menu/view-menu.tsx +115 -0
- package/ui/src/app-root/app-root.tsx +109 -0
- package/ui/src/app-root/app-root.types.ts +27 -0
- package/ui/src/archive/archive.tsx +417 -0
- package/ui/src/attachment-detail/attachment-detail.ts +52 -0
- package/ui/src/attachment-viewer/attachment-viewer.tsx +166 -0
- package/ui/src/blocknote-view/blocknote-view.tsx +30 -0
- package/ui/src/board/board-assignee/board-assignee-picker.tsx +132 -0
- package/ui/src/board/board-assignee/board-assignee.ts +48 -0
- package/ui/src/board/board-assignee/board-assignee.tsx +75 -0
- package/ui/src/board/board-chip/board-chip.tsx +46 -0
- package/ui/src/board/board-crumbs/board-crumbs.ts +56 -0
- package/ui/src/board/board-crumbs/board-crumbs.tsx +111 -0
- package/ui/src/board/board-data/board-data.ts +195 -0
- package/ui/src/board/board-data/board-data.types.ts +38 -0
- package/ui/src/board/board-dates/board-dates.ts +40 -0
- package/ui/src/board/board-dates/board-dates.tsx +105 -0
- package/ui/src/board/board-kanban/board-kanban.ts +162 -0
- package/ui/src/board/board-kanban/board-kanban.tsx +680 -0
- package/ui/src/board/board-open-task/board-open-task.ts +32 -0
- package/ui/src/board/board-panel/board-panel.tsx +259 -0
- package/ui/src/board/board-settings/board-settings.tsx +226 -0
- package/ui/src/board/board-status/board-status.tsx +60 -0
- package/ui/src/board/board-stripes/board-stripes.ts +128 -0
- package/ui/src/board/board-table/board-table.ts +53 -0
- package/ui/src/board/board-table/board-table.tsx +610 -0
- package/ui/src/board/board-task/board-task.ts +108 -0
- package/ui/src/board/board-task/board-task.tsx +335 -0
- package/ui/src/board/board-title-row/board-title-row.tsx +66 -0
- package/ui/src/branding/branding.tsx +17 -0
- package/ui/src/branding/custom-logo.ts +1 -0
- package/ui/src/branding/favicon.default.svg +5 -0
- package/ui/src/branding/favicon.svg +5 -0
- package/ui/src/components/ui/avatar.tsx +39 -0
- package/ui/src/components/ui/button.tsx +64 -0
- package/ui/src/components/ui/collapsible.tsx +20 -0
- package/ui/src/components/ui/command.tsx +160 -0
- package/ui/src/components/ui/dialog.tsx +143 -0
- package/ui/src/components/ui/dropdown-menu.tsx +187 -0
- package/ui/src/components/ui/input.tsx +21 -0
- package/ui/src/components/ui/popover.tsx +41 -0
- package/ui/src/components/ui/select.tsx +163 -0
- package/ui/src/components/ui/separator.tsx +26 -0
- package/ui/src/components/ui/sheet.tsx +136 -0
- package/ui/src/components/ui/sidebar.tsx +693 -0
- package/ui/src/components/ui/skeleton.tsx +13 -0
- package/ui/src/components/ui/switch.tsx +25 -0
- package/ui/src/components/ui/table.tsx +82 -0
- package/ui/src/components/ui/tabs.tsx +52 -0
- package/ui/src/components/ui/tooltip.tsx +51 -0
- package/ui/src/data/intel-data-provider/intel-data-provider.ts +685 -0
- package/ui/src/data/intel-data-provider/intel-data-provider.types.ts +266 -0
- package/ui/src/data/query-client.ts +18 -0
- package/ui/src/data/request-refusal/refusal-notice.tsx +36 -0
- package/ui/src/data/request-refusal/request-refusal.ts +51 -0
- package/ui/src/data/sign-in/sign-in.ts +97 -0
- package/ui/src/data/sign-in/sign-in.types.ts +15 -0
- package/ui/src/document-link/document-link.tsx +114 -0
- package/ui/src/document-markdown/document-markdown.ts +195 -0
- package/ui/src/editor-schema/editor-schema.ts +23 -0
- package/ui/src/entry-picker/entry-picker.tsx +238 -0
- package/ui/src/feed/feed.tsx +344 -0
- package/ui/src/file-preview/file-preview-view.tsx +496 -0
- package/ui/src/file-preview/file-preview.tsx +28 -0
- package/ui/src/file-preview/pdf-file-preview.tsx +5 -0
- package/ui/src/file-preview/presentation-file-preview.tsx +21 -0
- package/ui/src/file-preview/spreadsheet-file-preview.tsx +5 -0
- package/ui/src/file-preview/word-file-preview.tsx +5 -0
- package/ui/src/flow-runs/flow-runs.tsx +238 -0
- package/ui/src/flows/flows.tsx +1646 -0
- package/ui/src/flows/node-icon/node-icon.ts +34 -0
- package/ui/src/flows/node-palette/node-palette.tsx +214 -0
- package/ui/src/flows/node-palette/node-palette.types.ts +15 -0
- package/ui/src/folder-contents/folder-contents.tsx +321 -0
- package/ui/src/folder-index/folder-index.ts +55 -0
- package/ui/src/frontmatter/frontmatter.tsx +193 -0
- package/ui/src/graph-pane/graph-pane.tsx +53 -0
- package/ui/src/hooks/use-mobile.ts +19 -0
- package/ui/src/i18n/custom.json +4 -0
- package/ui/src/i18n/de.json +609 -0
- package/ui/src/i18n/en.json +609 -0
- package/ui/src/i18n/es.json +609 -0
- package/ui/src/i18n/i18n-context.tsx +65 -0
- package/ui/src/i18n/i18n-languages/i18n-languages.ts +83 -0
- package/ui/src/i18n/i18n.ts +32 -0
- package/ui/src/i18n/i18n.types.ts +49 -0
- package/ui/src/kind-icon.ts +97 -0
- package/ui/src/lib/utils.ts +6 -0
- package/ui/src/main.tsx +68 -0
- package/ui/src/modal/modal.tsx +53 -0
- package/ui/src/node-details/node-details.tsx +545 -0
- package/ui/src/node-editor/node-editor.tsx +304 -0
- package/ui/src/node-graph/graph-notice.tsx +21 -0
- package/ui/src/node-graph/node-graph.ts +214 -0
- package/ui/src/node-graph/node-graph.tsx +295 -0
- package/ui/src/node-import/node-import.tsx +418 -0
- package/ui/src/node-save-error.ts +46 -0
- package/ui/src/node-source/node-source.tsx +128 -0
- package/ui/src/node-table/node-table.tsx +107 -0
- package/ui/src/nodes/nodes.tsx +240 -0
- package/ui/src/rename-resource/rename-resource.ts +80 -0
- package/ui/src/resolved-names/resolved-names.tsx +67 -0
- package/ui/src/resource-error.ts +33 -0
- package/ui/src/resource-menu/resource-menu.tsx +1156 -0
- package/ui/src/router/router-context.ts +6 -0
- package/ui/src/router/router.tsx +67 -0
- package/ui/src/router/router.types.ts +8 -0
- package/ui/src/router/selection-search.ts +88 -0
- package/ui/src/save-button/save-button.tsx +94 -0
- package/ui/src/section-hint/section-hint.tsx +40 -0
- package/ui/src/sign-in-refused/sign-in-refused.tsx +35 -0
- package/ui/src/styles.css +189 -0
- package/ui/src/table-columns/table-columns.tsx +379 -0
- package/ui/src/theme/custom.css +1 -0
- package/ui/src/theme/theme-context.tsx +89 -0
- package/ui/src/theme/theme.ts +70 -0
- package/ui/src/time/relative-time.tsx +41 -0
- package/ui/src/time/time-context.tsx +78 -0
- package/ui/src/time/time.ts +165 -0
- package/ui/src/title-row/title-row.tsx +185 -0
- package/ui/src/tools/tools.tsx +546 -0
- package/ui/src/user-name/user-name.ts +61 -0
- package/ui/src/verbatim/verbatim.tsx +68 -0
- package/ui/tsconfig.json +17 -0
- package/ui/vite.config.ts +129 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { UI_LANGUAGES } from "../contract/contract.js";
|
|
3
|
+
const UiConfig = z.strictObject({
|
|
4
|
+
theme: z.string().min(1).optional(),
|
|
5
|
+
logo: z.string().min(1).optional(),
|
|
6
|
+
favicon: z.string().min(1).optional(),
|
|
7
|
+
defaultLanguage: z.string().min(1).default("en"),
|
|
8
|
+
languages: z.record(z.string().min(1), z.string().min(1)).default({}),
|
|
9
|
+
});
|
|
10
|
+
const IntelConfig = z.strictObject({
|
|
11
|
+
ui: UiConfig.default({ defaultLanguage: "en", languages: {} }),
|
|
12
|
+
});
|
|
13
|
+
const Catalog = z.record(z.string(), z.string());
|
|
14
|
+
const defaultTheme = `/* Generated by \`intel build\`. Intel defaults are active. */\n`;
|
|
15
|
+
const defaultLogo = `export const customLogoUrl: string | null = null;\n`;
|
|
16
|
+
// The `_headers` file of Workers Assets, written INTO THE BUILD OUTPUT (#543, sibling of
|
|
17
|
+
// anchrd/gate#329).
|
|
18
|
+
//
|
|
19
|
+
// Without it every asset answers with the platform default `public, max-age=0, must-revalidate`,
|
|
20
|
+
// and `public` lets a browser store an ERROR answer too. A `403` that appears once during setup is
|
|
21
|
+
// then replayed on BACK/FORWARD WITHOUT a request leaving the browser — invisible in the worker
|
|
22
|
+
// log, in the Cloudflare Access log, in the firewall and in Cloudflare Analytics, while `curl`
|
|
23
|
+
// against the same address keeps answering `200`. The second rule matters more here than in Gate:
|
|
24
|
+
// the UI ships 1.9 MB of fingerprinted assets that are revalidated on every navigation today.
|
|
25
|
+
//
|
|
26
|
+
// ⚠️ The ERROR answer is NOT replayed on every navigation — that is the asset line right above, a
|
|
27
|
+
// different statement about `/assets/*`, and it stays as it is. The narrower shape is what makes
|
|
28
|
+
// this expensive to diagnose: `must-revalidate` DOES hold for a fresh navigation, so retyping the
|
|
29
|
+
// address returns the REPAIRED page (`200 /` in the worker log), while a history navigation replays
|
|
30
|
+
// the stored answer without any freshness check (`transferSize: 0`). Measured in Chromium with a
|
|
31
|
+
// real cache, anchrd/gate#399. Whoever retypes the address rules the browser cache out and loses
|
|
32
|
+
// the afternoon of anchrd/gate#329 a second time — going BACK is the only handle that shows the
|
|
33
|
+
// frozen answer.
|
|
34
|
+
//
|
|
35
|
+
// ⚠️ `! Cache-Control` is not decoration, and the naive two-rule form from the ticket is WRONG.
|
|
36
|
+
// A request matching several rules inherits ALL their headers, and a header named twice is joined
|
|
37
|
+
// with a comma. Measured against `wrangler dev` 4.112.0 with both spellings side by side:
|
|
38
|
+
// without the detach /assets/app.js → `no-store, public, max-age=31536000, immutable`
|
|
39
|
+
// with the detach /assets/app.js → `public, max-age=31536000, immutable`
|
|
40
|
+
// The joined value carries `no-store`, so those 1.9 MB would never be cached at all — the exact
|
|
41
|
+
// opposite of the second rule's purpose.
|
|
42
|
+
//
|
|
43
|
+
// ⚠️ It has to be written into the TEMPORARY directory, before `replaceDir`. The next run's
|
|
44
|
+
// `--emptyOutDir` applies to that directory, so a file placed into the live outDir afterwards
|
|
45
|
+
// survives exactly one build. And `packages/intel/ui/public/` is no way either: the `files` field of
|
|
46
|
+
// @anchrd/intel does not list `ui/public`, so the file would look right in the repository and never
|
|
47
|
+
// reach a customer.
|
|
48
|
+
//
|
|
49
|
+
// The three `cache-control` writes in this package do not contradict it: `auth/auth.ts` (redirect),
|
|
50
|
+
// `http/http.ts` (zipResponse, attachment bytes) all answer `no-store` under `/auth/*` and `/api/*`,
|
|
51
|
+
// which the assets layer never sees. Nothing serves an SPA route under `/assets/`, so the
|
|
52
|
+
// `immutable` rule cannot swallow one.
|
|
53
|
+
const headersFile = `# Generated by \`intel build\` — do not edit by hand.
|
|
54
|
+
/*
|
|
55
|
+
Cache-Control: no-store
|
|
56
|
+
Content-Security-Policy: default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' blob: data:; font-src 'self' data:; connect-src 'self'; worker-src 'self' blob:; object-src 'none'; base-uri 'self'; frame-ancestors 'none'
|
|
57
|
+
|
|
58
|
+
/assets/*
|
|
59
|
+
! Cache-Control
|
|
60
|
+
Cache-Control: public, max-age=31536000, immutable
|
|
61
|
+
`;
|
|
62
|
+
// Customer paths from intel.json are written into generated CSS and TypeScript comments. A path
|
|
63
|
+
// containing `*/` or a newline would close the comment early, leaving broken output or — in
|
|
64
|
+
// custom-logo.ts — customer-controlled text outside the comment and inside the UI bundle.
|
|
65
|
+
function asComment(path) {
|
|
66
|
+
return path.replaceAll("*/", "*\\/").replace(/[\r\n]+/g, " ");
|
|
67
|
+
}
|
|
68
|
+
function validationMessage(error) {
|
|
69
|
+
return error.issues
|
|
70
|
+
.map((issue) => `${issue.path.join(".") || "intel.json"}: ${issue.message}`)
|
|
71
|
+
.join("; ");
|
|
72
|
+
}
|
|
73
|
+
function validateCatalog(source, candidate) {
|
|
74
|
+
const expected = Object.keys(source).sort();
|
|
75
|
+
const actual = Object.keys(candidate).sort();
|
|
76
|
+
const missing = expected.filter((key) => !actual.includes(key));
|
|
77
|
+
const unknown = actual.filter((key) => !expected.includes(key));
|
|
78
|
+
return { missing, unknown };
|
|
79
|
+
}
|
|
80
|
+
function asSvgDataUrl(svg) {
|
|
81
|
+
return `data:image/svg+xml,${encodeURIComponent(svg)}`;
|
|
82
|
+
}
|
|
83
|
+
export function createBuild(deps) {
|
|
84
|
+
async function readRequired(path, field) {
|
|
85
|
+
const content = await deps.readTextFile(path);
|
|
86
|
+
if (content === null)
|
|
87
|
+
throw new Error(`File not found: ${path} (${field})`);
|
|
88
|
+
return content;
|
|
89
|
+
}
|
|
90
|
+
async function readSvg(path, field) {
|
|
91
|
+
if (!path.toLowerCase().endsWith(".svg")) {
|
|
92
|
+
throw new Error(`${field} must point to an .svg file`);
|
|
93
|
+
}
|
|
94
|
+
return await readRequired(path, field);
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
async build() {
|
|
98
|
+
const location = await deps.resolveUi();
|
|
99
|
+
if (!location) {
|
|
100
|
+
deps.log("Error: the Intel UI was not found in node_modules/@anchrd/intel/ui or packages/intel/ui.");
|
|
101
|
+
return 1;
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
const rawConfig = await deps.readTextFile("intel.json");
|
|
105
|
+
let value = {};
|
|
106
|
+
if (rawConfig !== null) {
|
|
107
|
+
try {
|
|
108
|
+
value = JSON.parse(rawConfig);
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
throw new Error("intel.json is not valid JSON");
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const parsed = IntelConfig.safeParse(value);
|
|
115
|
+
if (!parsed.success)
|
|
116
|
+
throw new Error(validationMessage(parsed.error));
|
|
117
|
+
const config = parsed.data.ui;
|
|
118
|
+
const englishPath = `${location.dir}/src/i18n/en.json`;
|
|
119
|
+
const englishRaw = await readRequired(englishPath, "built-in English catalog");
|
|
120
|
+
let englishJson;
|
|
121
|
+
try {
|
|
122
|
+
englishJson = JSON.parse(englishRaw);
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
throw new Error(`${englishPath} is not valid JSON`);
|
|
126
|
+
}
|
|
127
|
+
const englishParsed = Catalog.safeParse(englishJson);
|
|
128
|
+
if (!englishParsed.success)
|
|
129
|
+
throw new Error("Intel's built-in English catalog is invalid");
|
|
130
|
+
const english = englishParsed.data;
|
|
131
|
+
const catalogs = {};
|
|
132
|
+
for (const [language, path] of Object.entries(config.languages)) {
|
|
133
|
+
const candidateRaw = await readRequired(path, `ui.languages.${language}`);
|
|
134
|
+
let candidateJson;
|
|
135
|
+
try {
|
|
136
|
+
candidateJson = JSON.parse(candidateRaw);
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
throw new Error(`${path} is not valid JSON`);
|
|
140
|
+
}
|
|
141
|
+
const candidateParsed = Catalog.safeParse(candidateJson);
|
|
142
|
+
if (!candidateParsed.success)
|
|
143
|
+
throw new Error(`${path} must contain only string values`);
|
|
144
|
+
const difference = validateCatalog(english, candidateParsed.data);
|
|
145
|
+
if (difference.missing.length || difference.unknown.length) {
|
|
146
|
+
throw new Error(`${path} does not match en.json; missing: ${difference.missing.join(", ") || "none"}; unknown: ${difference.unknown.join(", ") || "none"}`);
|
|
147
|
+
}
|
|
148
|
+
catalogs[language] = candidateParsed.data;
|
|
149
|
+
}
|
|
150
|
+
// A built-in language needs no entry in ui.languages — its catalog is already in the UI.
|
|
151
|
+
// Without this exception, `ui.defaultLanguage: "de"` would force the customer to list a copy
|
|
152
|
+
// of de.json that rots at every UI update, and nobody maintains that copy.
|
|
153
|
+
const builtIn = UI_LANGUAGES;
|
|
154
|
+
if (!builtIn.includes(config.defaultLanguage) && !(config.defaultLanguage in catalogs)) {
|
|
155
|
+
throw new Error(`ui.defaultLanguage ${JSON.stringify(config.defaultLanguage)} is neither built in (${UI_LANGUAGES.join(", ")}) nor listed in ui.languages`);
|
|
156
|
+
}
|
|
157
|
+
const theme = config.theme
|
|
158
|
+
? `/* Generated by \`intel build\` from ${asComment(config.theme)}. */\n${await readRequired(config.theme, "ui.theme")}\n`
|
|
159
|
+
: defaultTheme;
|
|
160
|
+
const logoSvg = config.logo ? await readSvg(config.logo, "ui.logo") : null;
|
|
161
|
+
const faviconPath = config.favicon ?? config.logo;
|
|
162
|
+
const faviconSvg = faviconPath
|
|
163
|
+
? await readSvg(faviconPath, config.favicon ? "ui.favicon" : "ui.logo")
|
|
164
|
+
: await readRequired(`${location.dir}/src/branding/favicon.default.svg`, "default favicon");
|
|
165
|
+
const logoModule = config.logo && logoSvg
|
|
166
|
+
? `/* Generated by \`intel build\` from ${asComment(config.logo)}. */\nexport const customLogoUrl = ${JSON.stringify(asSvgDataUrl(logoSvg))};\n`
|
|
167
|
+
: defaultLogo;
|
|
168
|
+
const languageBundle = `${JSON.stringify({ defaultLanguage: config.defaultLanguage, catalogs }, null, 2)}\n`;
|
|
169
|
+
await deps.writeTextFile(`${location.dir}/src/theme/custom.css`, theme);
|
|
170
|
+
await deps.writeTextFile(`${location.dir}/src/branding/custom-logo.ts`, logoModule);
|
|
171
|
+
await deps.writeTextFile(`${location.dir}/src/branding/favicon.svg`, faviconSvg);
|
|
172
|
+
await deps.writeTextFile(`${location.dir}/src/i18n/custom.json`, languageBundle);
|
|
173
|
+
const temporaryOutDir = `${location.outDir}.tmp`;
|
|
174
|
+
const exitCode = await deps.exec("npm", ["run", "build", "--", "--outDir", temporaryOutDir, "--emptyOutDir"], { cwd: location.dir });
|
|
175
|
+
if (exitCode !== 0) {
|
|
176
|
+
deps.log(`Error: Intel UI build exited with ${exitCode}.`);
|
|
177
|
+
return 1;
|
|
178
|
+
}
|
|
179
|
+
// Into the temporary directory, not into outDir — see `headersFile`. Vite has just emptied
|
|
180
|
+
// and refilled this directory; anything written here travels with the swap.
|
|
181
|
+
await deps.writeTextFile(`${temporaryOutDir}/_headers`, headersFile);
|
|
182
|
+
await deps.replaceDir(temporaryOutDir, location.outDir);
|
|
183
|
+
deps.log(`Intel UI built at ${location.outDir}.`);
|
|
184
|
+
return 0;
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
deps.log(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
188
|
+
return 1;
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface UiLocation {
|
|
2
|
+
dir: string;
|
|
3
|
+
outDir: string;
|
|
4
|
+
}
|
|
5
|
+
export interface BuildDeps {
|
|
6
|
+
readTextFile(path: string): Promise<string | null>;
|
|
7
|
+
writeTextFile(path: string, content: string): Promise<void>;
|
|
8
|
+
resolveUi(): Promise<UiLocation | null>;
|
|
9
|
+
exec(command: string, args: string[], options: {
|
|
10
|
+
cwd: string;
|
|
11
|
+
}): Promise<number>;
|
|
12
|
+
replaceDir(from: string, to: string): Promise<void>;
|
|
13
|
+
log(message: string): void;
|
|
14
|
+
}
|
|
15
|
+
export interface BuildResult {
|
|
16
|
+
build(): Promise<number>;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|