Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/server-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: mdbase-dev/mdbase-spec
ref: fe1f0c854a58565a2dc6499505f95d3294ce314a
ref: 4a2525b221460425ede3b4652fe18b504dc367ec
path: mdbase-spec
persist-credentials: false
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
Expand Down Expand Up @@ -454,12 +454,14 @@ jobs:
--command "SELECT concat(
grant_json #>> '{notification_criteria,0,event,id}',
'|',
grant_json #>> '{notification_criteria,0,event,version}'
grant_json #>> '{notification_criteria,0,event,version}',
'|',
grant_json #>> '{notification_criteria,0,event,digest}'
)
FROM hosted_provider_notification_grants
WHERE grant_id = '22222222-2222-4222-8222-222222222222'")
echo "Recovered notification contract: $contract"
[[ "$contract" == "mdbase.runtime.timer.fired|1.0.0" ]]
[[ "$contract" == "mdbase.runtime.timer.fired|1.0.0|sha256:41105be7a7abf33b31ced47e1e1965242236e40ccaea286b959b0a8c591f5642" ]]

- name: Stop test-only R2 readiness stub
if: always()
Expand Down
16 changes: 9 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ members = [
resolver = "2"

[workspace.package]
version = "0.1.0-beta.26"
version = "0.1.0-beta.27"
edition = "2021"
license = "MIT"
repository = "https://github.com/mdbase-dev/mdbase-connect"
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@mdbase/connect-desktop",
"productName": "mdbase connect",
"version": "0.1.0-beta.26",
"version": "0.1.0-beta.27",
"description": "Connect applications to authorized mdbase collections.",
"author": "mdbase",
"private": true,
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/renderer/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ interface CollectionSummary {
interface ContractRequirement {
id: string;
version: string;
digest: string;
}

interface CollectionContractDescriptor extends ContractRequirement {
Expand Down
6 changes: 3 additions & 3 deletions apps/desktop/src/renderer/view-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface AuthorizationCollection {
types: CollectionTypeDescriptor[];
}

export const allOperations = ["describe", "changes", "read", "query", "list_views", "execute_view", "read_view_source", "create", "update", "rename", "delete", "create_view_source", "update_view_source", "delete_view_source", "validate", "read_type", "create_type", "update_type", "install_type_pack", "list_timers", "put_timer", "cancel_timer", "reconcile_timers"];
export const allOperations = ["describe", "changes", "read", "query", "list_views", "execute_view", "read_view_source", "create", "update", "rename", "delete", "create_view_source", "update_view_source", "delete_view_source", "validate", "read_type", "create_type", "update_type", "apply_type_pack", "list_timers", "put_timer", "cancel_timer", "reconcile_timers"];

export function neededProvisions(
requirements: ApplicationRequirements,
Expand All @@ -32,7 +32,7 @@ const MDBASE_03_OPERATIONS = new Set([
"read_type",
"create_type",
"update_type",
"install_type_pack"
"apply_type_pack"
]);

export function hostedCollectionCompatible(
Expand Down Expand Up @@ -180,7 +180,7 @@ function authorityPromotionPhaseLabel(
}

export function hasContract(contracts: ContractRequirement[], required: ContractRequirement) { return contracts.some((contract) => sameContract(contract, required)); }
function sameContract(left: ContractRequirement, right: ContractRequirement) { return left.id === right.id && left.version === right.version; }
function sameContract(left: ContractRequirement, right: ContractRequirement) { return left.id === right.id && left.version === right.version && left.digest === right.digest; }
export function provisionNames(provisions: TypePackProvision[]) {
return provisions
.map((provision) => provision.manifest.name ?? provision.manifest.id)
Expand Down
5 changes: 4 additions & 1 deletion apps/editor/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { defineConfig, devices } from "@playwright/test";

const port = Number(process.env.MDBASE_EDITOR_E2E_PORT ?? 42_873);
const baseURL = `http://127.0.0.1:${port}/`;
const webServerCommand =
process.env.MDBASE_EDITOR_E2E_WEB_SERVER_COMMAND ??
`pnpm build:e2e && pnpm preview --port ${port} --strictPort`;

export default defineConfig({
testDir: "./tests",
Expand All @@ -13,7 +16,7 @@ export default defineConfig({
trace: "retain-on-failure"
},
webServer: {
command: `pnpm build:e2e && pnpm preview --port ${port} --strictPort`,
command: webServerCommand,
url: `${baseURL}?demo=10`,
reuseExistingServer: false,
timeout: 120_000
Expand Down
38 changes: 19 additions & 19 deletions apps/editor/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import { ConfirmDialog } from "./Dialog";
import { FirstContactDialog } from "./FirstContactDialog";
import {
loadContractCatalog,
loadTypePackProvision,
type ContractCatalogPack
} from "./contract-catalog";
import { reviewCatalogPackInstallation } from "./catalog-pack-installation";
import type { AppPhase, ConnectionState, ContractCatalogLoadState, CreationContext, MobileHistoryState, MobilePane, Surface } from "./app-state-types";
import { gatewayError, missingCoreOperations, missingTypeOperations } from "./gateway";
import { useCollectionAuthorization } from "./collection-authorization";
Expand Down Expand Up @@ -112,6 +112,7 @@ interface Confirmation {
confirmLabel: string;
cancelLabel?: string;
tone?: "default" | "danger";
initialFocus?: "confirm" | "cancel";
onConfirm: () => void | Promise<void>;
}

Expand Down Expand Up @@ -1568,23 +1569,20 @@ export function App({ gateway }: { gateway: CollectionGateway }) {
}

async function installCatalogPack(pack: ContractCatalogPack) {
const previousTypes = new Set(description?.types.map((type) => type.name) ?? []);
const provision = await loadTypePackProvision(pack);
const installed = await gateway.installTypePack(provision);
const next = await refreshDescription();
const addedTypes = next.types.filter((type) => !previousTypes.has(type.name));
const primaryType = pack.primaryType
? addedTypes.find((type) => type.name === pack.primaryType)
: undefined;
if (primaryType && !typeDraftDirty()) {
setTypeWorkspace("definition");
setSelectedTypeName(primaryType.name);
setMobilePane("editor");
await loadTypeSource(primaryType.name);
setNotice(`Added “${pack.displayName}” and opened the new type.`);
return;
}
setNotice(`Installed “${pack.displayName}” (${installed.resources.length} resources, ${addedTypes.length} new ${addedTypes.length === 1 ? "type" : "types"}).`);
await reviewCatalogPackInstallation(pack, gateway, {
installedTypeNames: description?.types.map(({ name }) => name) ?? [],
confirm: (confirmation) => setConfirmation(confirmation),
refreshDescription,
isTypeDraftDirty: typeDraftDirty,
openType: async (name) => {
setTypeWorkspace("definition");
setSelectedTypeName(name);
setMobilePane("editor");
await loadTypeSource(name);
},
notify: setNotice,
onError: (error) => setTypeError(gatewayError(error))
});
}

function typeDraftDirty() {
Expand Down Expand Up @@ -1761,6 +1759,7 @@ export function App({ gateway }: { gateway: CollectionGateway }) {
confirmLabel={confirmation.confirmLabel}
cancelLabel={confirmation.cancelLabel}
tone={confirmation.tone}
initialFocus={confirmation.initialFocus}
onConfirm={confirmation.onConfirm}
onClose={() => setConfirmation(undefined)}
/>}
Expand Down Expand Up @@ -2044,7 +2043,7 @@ export function App({ gateway }: { gateway: CollectionGateway }) {
loading={contractCatalog.status === "loading"}
error={contractCatalog.status === "error" ? contractCatalog.message : undefined}
canInstall={Boolean(connectionSummary?.operations.some((operation) =>
operation === "all" || operation === "install_type_pack"
operation === "all" || operation === "apply_type_pack"
))}
leadingActions={editorLeadingActions}
onInstall={installCatalogPack}
Expand Down Expand Up @@ -2158,6 +2157,7 @@ export function App({ gateway }: { gateway: CollectionGateway }) {
confirmLabel={confirmation.confirmLabel}
cancelLabel={confirmation.cancelLabel}
tone={confirmation.tone}
initialFocus={confirmation.initialFocus}
onConfirm={confirmation.onConfirm}
onClose={() => setConfirmation(undefined)}
/>}
Expand Down
4 changes: 2 additions & 2 deletions apps/editor/src/ConnectApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const desktopReleaseUrl = "https://github.com/mdbase-dev/mdbase-connect/releases
const allOperations = [
"describe", "changes", "read", "query", "list_views", "execute_view", "read_view_source", "validate",
"create", "update", "delete", "rename", "create_view_source", "update_view_source", "delete_view_source",
"read_type", "create_type", "update_type", "install_type_pack", "list_timers", "put_timer", "cancel_timer",
"read_type", "create_type", "update_type", "apply_type_pack", "list_timers", "put_timer", "cancel_timer",
"reconcile_timers"
];

Expand Down Expand Up @@ -603,7 +603,7 @@ function permissionSummary(grants: ApplicationAccessGroup<Grant>["grants"]): str
].filter(Boolean);
const capabilities: string[] = [];
if (verbs.length > 0) capabilities.push(`${joinWords(verbs)} records`);
if (["create_type", "update_type", "install_type_pack", "create_view_source", "update_view_source", "delete_view_source"].some((operation) => operations.has(operation))) capabilities.push("manage types");
if (["create_type", "update_type", "apply_type_pack", "create_view_source", "update_view_source", "delete_view_source"].some((operation) => operations.has(operation))) capabilities.push("manage types");
if (["put_timer", "cancel_timer", "reconcile_timers"].some((operation) => operations.has(operation))) capabilities.push("manage timers");
if (capabilities.length === 0) return `${operations.size} ${operations.size === 1 ? "permission" : "permissions"}`;
const summary = capabilities.join("; ");
Expand Down
7 changes: 4 additions & 3 deletions apps/editor/src/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,13 @@ export function Dialog({ titleId, className, role = "dialog", onClose, children
);
}

export function ConfirmDialog({ title, body, confirmLabel, cancelLabel = "Cancel", tone = "default", onConfirm, onClose }: {
export function ConfirmDialog({ title, body, confirmLabel, cancelLabel = "Cancel", tone = "default", initialFocus, onConfirm, onClose }: {
title: string;
body: ReactNode;
confirmLabel: string;
cancelLabel?: string;
tone?: "default" | "danger";
initialFocus?: "confirm" | "cancel";
onConfirm: () => void | Promise<void>;
onClose: () => void;
}) {
Expand All @@ -121,13 +122,13 @@ export function ConfirmDialog({ title, body, confirmLabel, cancelLabel = "Cancel
</div>
<footer>
<button
data-autofocus={tone === "danger" ? "true" : undefined}
data-autofocus={(initialFocus ?? (tone === "danger" ? "cancel" : "confirm")) === "cancel" ? "true" : undefined}
disabled={busy}
onClick={onClose}
>{cancelLabel}</button>
<button
className={tone === "danger" ? "confirm-danger" : "confirm-primary"}
data-autofocus={tone === "danger" ? undefined : "true"}
data-autofocus={(initialFocus ?? (tone === "danger" ? "cancel" : "confirm")) === "confirm" ? "true" : undefined}
disabled={busy}
onClick={() => void confirm()}
>{busy ? "Working…" : confirmLabel}</button>
Expand Down
3 changes: 2 additions & 1 deletion apps/editor/src/TypeBrowser.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,8 @@ const contractCatalog: ContractCatalog = {
provisionUrl: "https://mdbase.dev/contracts/packs/example.people/1.0.0/provision.json",
provides: [{
id: personContract.id,
version: personContract.version
version: personContract.version,
digest: personContract.digest
}],
resourceCount: 3,
displayName: "Person",
Expand Down
Loading