Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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: 3 additions & 5 deletions packages/admin-ui/src/TimeAgo/getElapsedSeconds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import type { TDate } from "./types.js";
import { toEpochMs } from "./toEpochMs.js";

export function getElapsedSeconds(datetime: TDate, relativeDate?: TDate): number {
const now = relativeDate
? Temporal.Instant.fromEpochMilliseconds(toEpochMs(relativeDate))
: Temporal.Now.instant();
const past = Temporal.Instant.fromEpochMilliseconds(toEpochMs(datetime));
return Math.round(now.since(past).total("second"));
const nowMs = relativeDate ? toEpochMs(relativeDate) : Date.now();
const pastMs = toEpochMs(datetime);
return Math.round((nowMs - pastMs) / 1000);
}
2 changes: 2 additions & 0 deletions packages/api-aco/src/exports/api/aco/folder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ export {
} from "~/features/folder/ListFolders/abstractions.js";

export { FilterStorageOperations } from "~/features/folder/shared/abstractions.js";

export type { Folder } from "~/folder/folder.types.js";
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,17 @@ import {
EntryAfterUpdateRevisionDescriptionEvent,
EntryBeforeUpdateRevisionDescriptionEvent
} from "./events.js";
import { AccessControl, CmsContext } from "~/features/shared/abstractions.js";
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
import { AccessControl } from "~/features/shared/abstractions.js";
import { GetRevisionByIdUseCase } from "~/features/contentEntry/GetRevisionById/abstractions.js";
import type { CmsEntry, CmsEntryValues, CmsModel } from "~/types/index.js";
import { EntryLockedError, EntryNotAuthorizedError } from "~/domain/contentEntry/errors.js";
import { EntryNotAuthorizedError } from "~/domain/contentEntry/errors.js";
import { UpdateEntryRepository } from "../UpdateEntry/index.js";

class UpdateRevisionDescriptionUseCaseImpl implements UseCaseAbstraction.Interface {
public constructor(
private eventPublisher: EventPublisher.Interface,
private repository: UpdateEntryRepository.Interface,
private accessControl: AccessControl.Interface,
private cmsContext: CmsContext.Interface,
private tenantContext: TenantContext.Interface,
private identityContext: IdentityContext.Interface,
private getRevisionByIdUseCase: GetRevisionByIdUseCase.Interface
) {}

Expand All @@ -44,11 +39,6 @@ class UpdateRevisionDescriptionUseCaseImpl implements UseCaseAbstraction.Interfa

const originalEntry = result.value;

// Check if entry is locked
if (originalEntry.locked) {
return Result.fail(new EntryLockedError());
}

const entry = {
...originalEntry,
revisionDescription
Expand Down Expand Up @@ -102,13 +92,5 @@ class UpdateRevisionDescriptionUseCaseImpl implements UseCaseAbstraction.Interfa
export const UpdateRevisionDescriptionUseCase = createImplementation({
abstraction: UseCaseAbstraction,
implementation: UpdateRevisionDescriptionUseCaseImpl,
dependencies: [
EventPublisher,
UpdateEntryRepository,
AccessControl,
CmsContext,
TenantContext,
IdentityContext,
GetRevisionByIdUseCase
]
dependencies: [EventPublisher, UpdateEntryRepository, AccessControl, GetRevisionByIdUseCase]
});
9 changes: 8 additions & 1 deletion packages/build-tools/bundling/importValidatorPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ const cyan = "\x1b[36m";
const reset = "\x1b[0m";
const bold = "\x1b[1m";

const whitelist = ["@webiny/cognito", "@webiny/auth0", "@webiny/okta", "@webiny/plugins"];
const whitelist = [
"@webiny/cognito",
"@webiny/auth0",
"@webiny/okta",
"@webiny/plugins",
"@webiny/sdk",
"@webiny/stdlib"
];

export const createImportValidatorPlugin = () => {
return {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/files/references.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
"url": "https://github.com/webiny/webiny-js.git"
},
"exports": {
".": "./index.js"
".": "./index.js",
"./*": "./*"
},
"dependencies": {
"p-map": "^7.0.4",
"p-retry": "^8.0.0",
"standardwebhooks": "^1.0.0",
"zod": "4.4.3"
},
"author": "Webiny",
Expand Down
34 changes: 34 additions & 0 deletions packages/sdk/src/methods/webhooks/verifyWebhookPayload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* This is a node only file, as it uses the "standardwebhooks" package which is not compatible with browsers.
* NEVER import into UI or export alongside ui-facing code.
*/
if (typeof process === "undefined" || typeof process.versions?.node === "undefined") {
throw new Error("@webiny/sdk/webhooks is only available in Node.js environments.");
}

import { Webhook } from "standardwebhooks";
import { Result } from "~/Result.js";

export interface WebhookSignPayloadHeaders {
"webhook-id": string;
"webhook-timestamp": string;
"webhook-signature": string;
}

export const createVerifyWebhookPayload = (secret: string | undefined) => {
if (!secret) {
return async () => {
throw new Error("Signing secret is not defined.");
};
}

return async <T>(rawBody: string | Buffer, headers: WebhookSignPayloadHeaders) => {
try {
const wh = new Webhook(secret);
const payload = wh.verify(rawBody, headers) as T;
return Result.ok<T>(payload);
} catch (error) {
return Result.fail(error);
}
};
};
2 changes: 2 additions & 0 deletions packages/sdk/src/webhooks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { createVerifyWebhookPayload } from "./methods/webhooks/verifyWebhookPayload.js";
export type { WebhookSignPayloadHeaders } from "./methods/webhooks/verifyWebhookPayload.js";
11 changes: 8 additions & 3 deletions packages/telemetry/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ export const sendEvent = async ({ event, version, properties }) => {
return;
}

// The WTS client reads the machine id from `~/.webiny/config` (user.id field)
// via the same path globalConfig writes to. No need to pass user explicitly.
const wts = new WTS({ source: "cli" });
// Use the canonical Webiny machine id — the top-level `id` field in
// `~/.webiny/config`, owned by @webiny/global-config. The admin app
// (REACT_APP_WEBINY_TELEMETRY_USER_ID) and the website install/finish alias
// both key off this same id, so passing it here keeps CLI, admin, and
// website events on a single PostHog person. Without it, the WTS client
// falls back to its own `user.id` field, which is a different UUID and
// fragments funnels across surfaces.
const wts = new WTS({ source: "cli", distinctId: globalConfig.get("id") });

const wcpProperties = {};
const [wcpOrgId, wcpProjectId] = getWcpOrgProjectId();
Expand Down
2 changes: 1 addition & 1 deletion packages/webiny/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
"./extensions": "./extensions.js",
"./api/tenant-manager": "./api/tenant-manager.js"
},
"exportGenerationHash": "a9e9428800c668172653eb3821a9ac0a0abab1a1f0ee06c19356f7c9b80b6818",
"exportGenerationHash": "c9051138bc4811bb11e9d43908abd64b81fa4265430dfa82983b003d2360fa85",
"webiny": {
"publishFrom": "dist"
}
Expand Down
1 change: 1 addition & 0 deletions packages/webiny/src/api/aco/folder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ export {
ListFoldersRepository
} from "@webiny/api-aco/features/folder/ListFolders/abstractions.js";
export { FilterStorageOperations } from "@webiny/api-aco/features/folder/shared/abstractions.js";
export type { Folder } from "@webiny/api-aco/folder/folder.types.js";
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14248,6 +14248,7 @@ __metadata:
"@webiny/build-tools": "npm:0.0.0"
p-map: "npm:^7.0.4"
p-retry: "npm:^8.0.0"
standardwebhooks: "npm:^1.0.0"
typescript: "npm:6.0.3"
vitest: "npm:^4.1.7"
zod: "npm:4.4.3"
Expand Down