rwsdk 1.0.0-alpha.9 → 1.0.0-beta.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/lib/constants.mjs +1 -2
- package/dist/lib/e2e/browser.d.mts +1 -1
- package/dist/lib/e2e/browser.mjs +3 -4
- package/dist/lib/e2e/dev.mjs +62 -52
- package/dist/lib/e2e/environment.d.mts +2 -6
- package/dist/lib/e2e/environment.mjs +59 -72
- package/dist/lib/e2e/index.d.mts +5 -4
- package/dist/lib/e2e/index.mjs +5 -4
- package/dist/lib/e2e/poll.d.mts +8 -0
- package/dist/lib/e2e/poll.mjs +31 -0
- package/dist/lib/e2e/release.mjs +4 -4
- package/dist/lib/e2e/retry.d.mts +4 -0
- package/dist/lib/e2e/retry.mjs +16 -0
- package/dist/lib/e2e/setup.d.mts +2 -0
- package/dist/lib/e2e/setup.mjs +1 -0
- package/dist/lib/e2e/tarball.d.mts +3 -2
- package/dist/lib/e2e/tarball.mjs +5 -5
- package/dist/lib/e2e/testHarness.d.mts +59 -50
- package/dist/lib/e2e/testHarness.mjs +289 -343
- package/dist/lib/getShortName.mjs +1 -2
- package/dist/lib/getShortName.test.mjs +2 -2
- package/dist/lib/getSrcPaths.js +2 -2
- package/dist/lib/hasPkgScript.test.mjs +2 -2
- package/dist/lib/jsonUtils.test.mjs +2 -2
- package/dist/lib/normalizeModulePath.test.mjs +2 -2
- package/dist/lib/setupEnvFiles.mjs +2 -2
- package/dist/lib/smokeTests/artifacts.mjs +2 -2
- package/dist/lib/smokeTests/browser.d.mts +1 -1
- package/dist/lib/smokeTests/browser.mjs +6 -7
- package/dist/lib/smokeTests/cleanup.mjs +6 -9
- package/dist/lib/smokeTests/codeUpdates.mjs +5 -5
- package/dist/lib/smokeTests/development.mjs +2 -2
- package/dist/lib/smokeTests/environment.d.mts +2 -3
- package/dist/lib/smokeTests/environment.mjs +17 -3
- package/dist/lib/smokeTests/release.d.mts +2 -2
- package/dist/lib/smokeTests/release.mjs +3 -3
- package/dist/lib/smokeTests/reporting.mjs +2 -2
- package/dist/lib/smokeTests/runSmokeTests.mjs +4 -4
- package/dist/lib/smokeTests/utils.mjs +3 -3
- package/dist/lib/testUtils/stubEnvVars.mjs +1 -1
- package/dist/llms/rules/middleware.d.ts +1 -1
- package/dist/llms/rules/middleware.js +4 -4
- package/dist/runtime/client/client.d.ts +2 -2
- package/dist/runtime/client/client.js +2 -2
- package/dist/runtime/client/navigation.test.js +1 -1
- package/dist/runtime/client/types.d.ts +1 -1
- package/dist/runtime/entries/client.d.ts +2 -2
- package/dist/runtime/entries/client.js +2 -2
- package/dist/runtime/entries/router.d.ts +1 -1
- package/dist/runtime/entries/router.js +1 -1
- package/dist/runtime/entries/worker.d.ts +5 -6
- package/dist/runtime/entries/worker.js +5 -6
- package/dist/runtime/imports/worker.js +1 -1
- package/dist/runtime/lib/auth/session.d.ts +2 -2
- package/dist/runtime/lib/auth/session.js +5 -5
- package/dist/runtime/lib/db/DOWorkerDialect.d.ts +1 -1
- package/dist/runtime/lib/db/DOWorkerDialect.js +1 -1
- package/dist/runtime/lib/db/SqliteDurableObject.js +2 -2
- package/dist/runtime/lib/db/index.d.ts +2 -2
- package/dist/runtime/lib/db/index.js +2 -2
- package/dist/runtime/lib/db/migrations.d.ts +1 -1
- package/dist/runtime/lib/db/typeInference/builders/alterTable.d.ts +3 -3
- package/dist/runtime/lib/db/typeInference/builders/columnDefinition.d.ts +1 -1
- package/dist/runtime/lib/db/typeInference/builders/createTable.d.ts +2 -2
- package/dist/runtime/lib/db/typeInference/builders/createView.d.ts +1 -1
- package/dist/runtime/lib/db/typeInference/builders/dropTable.d.ts +1 -1
- package/dist/runtime/lib/db/typeInference/builders/dropView.d.ts +1 -1
- package/dist/runtime/lib/db/typeInference/builders/schema.d.ts +3 -3
- package/dist/runtime/lib/db/typeInference/database.d.ts +2 -2
- package/dist/runtime/lib/memoizeOnId.test.js +1 -1
- package/dist/runtime/lib/realtime/client.js +2 -2
- package/dist/runtime/lib/realtime/durableObject.js +1 -1
- package/dist/runtime/lib/realtime/protocol.test.js +1 -1
- package/dist/runtime/lib/realtime/shared.test.js +1 -1
- package/dist/runtime/lib/realtime/validateUpgradeRequest.test.js +1 -1
- package/dist/runtime/lib/realtime/worker.js +2 -2
- package/dist/runtime/lib/router.d.ts +1 -1
- package/dist/runtime/lib/router.test.js +2 -3
- package/dist/runtime/lib/rwContext.d.ts +1 -1
- package/dist/runtime/lib/stitchDocumentAndAppStreams.d.ts +18 -0
- package/dist/runtime/lib/stitchDocumentAndAppStreams.js +143 -0
- package/dist/runtime/lib/turnstile/useTurnstile.js +1 -1
- package/dist/runtime/lib/turnstile/verifyTurnstileToken.test.js +1 -1
- package/dist/runtime/register/worker.d.ts +1 -1
- package/dist/runtime/register/worker.js +34 -22
- package/dist/runtime/render/assembleDocument.d.ts +1 -1
- package/dist/runtime/render/createThenableFromReadableStream.js +1 -1
- package/dist/runtime/render/preloads.d.ts +2 -2
- package/dist/runtime/render/renderDocumentHtmlStream.js +6 -6
- package/dist/runtime/render/renderHtmlStream.d.ts +1 -1
- package/dist/runtime/render/renderToRscStream.d.ts +4 -1
- package/dist/runtime/render/renderToRscStream.js +11 -1
- package/dist/runtime/render/renderToStream.d.ts +1 -1
- package/dist/runtime/render/renderToStream.js +2 -2
- package/dist/runtime/render/stylesheets.d.ts +1 -1
- package/dist/runtime/requestInfo/types.d.ts +0 -2
- package/dist/runtime/requestInfo/worker.d.ts +1 -1
- package/dist/runtime/requestInfo/worker.js +1 -9
- package/dist/runtime/script.js +1 -1
- package/dist/runtime/ssrBridge.d.ts +2 -2
- package/dist/runtime/ssrBridge.js +2 -2
- package/dist/runtime/worker.d.ts +1 -1
- package/dist/runtime/worker.js +3 -11
- package/dist/scripts/addon.d.mts +1 -0
- package/dist/scripts/addon.mjs +70 -0
- package/dist/scripts/debug-sync.mjs +106 -137
- package/dist/scripts/ensure-deploy-env.mjs +6 -6
- package/dist/scripts/migrate-new.mjs +3 -4
- package/dist/scripts/smoke-test.mjs +2 -2
- package/dist/scripts/worker-run.mjs +7 -9
- package/dist/vite/buildApp.mjs +1 -1
- package/dist/vite/checkIsUsingPrisma.test.mjs +1 -1
- package/dist/vite/configPlugin.mjs +33 -6
- package/dist/vite/createDirectiveLookupPlugin.mjs +1 -1
- package/dist/vite/createDirectiveLookupPlugin.test.mjs +2 -2
- package/dist/vite/createViteAwareResolver.d.mts +1 -2
- package/dist/vite/createViteAwareResolver.mjs +1 -1
- package/dist/vite/directiveModulesDevPlugin.mjs +4 -4
- package/dist/vite/directiveModulesDevPlugin.test.mjs +2 -2
- package/dist/vite/directivesPlugin.mjs +3 -3
- package/dist/vite/directivesPlugin.test.mjs +1 -1
- package/dist/vite/ensureAliasArray.test.mjs +1 -1
- package/dist/vite/findSpecifiers.mjs +1 -1
- package/dist/vite/findSpecifiers.test.mjs +2 -2
- package/dist/vite/findSsrSpecifiers.mjs +1 -1
- package/dist/vite/findSsrSpecifiers.test.mjs +1 -1
- package/dist/vite/getViteEsbuild.mjs +1 -1
- package/dist/vite/hasDirective.test.mjs +1 -1
- package/dist/vite/index.d.mts +1 -1
- package/dist/vite/invalidateCacheIfPrismaClientChanged.mjs +2 -2
- package/dist/vite/isJsFile.test.mjs +1 -1
- package/dist/vite/{reactConditionsResolverPlugin.d.mts → knownDepsResolverPlugin.d.mts} +3 -3
- package/dist/vite/{reactConditionsResolverPlugin.mjs → knownDepsResolverPlugin.mjs} +29 -24
- package/dist/vite/linkerPlugin.mjs +2 -2
- package/dist/vite/linkerPlugin.test.mjs +1 -1
- package/dist/vite/miniflareHMRPlugin.mjs +5 -5
- package/dist/vite/miniflareHMRPlugin.test.mjs +1 -1
- package/dist/vite/prismaPlugin.mjs +1 -1
- package/dist/vite/redwoodPlugin.d.mts +2 -0
- package/dist/vite/redwoodPlugin.mjs +36 -17
- package/dist/vite/redwoodPlugin.test.mjs +2 -2
- package/dist/vite/resolveForcedPaths.d.mts +4 -0
- package/dist/vite/resolveForcedPaths.mjs +9 -0
- package/dist/vite/runDirectivesScan.d.mts +2 -1
- package/dist/vite/runDirectivesScan.mjs +53 -17
- package/dist/vite/runDirectivesScan.test.mjs +2 -2
- package/dist/vite/ssrBridgePlugin.mjs +10 -3
- package/dist/vite/transformClientComponents.mjs +8 -6
- package/dist/vite/transformClientComponents.test.mjs +117 -59
- package/dist/vite/transformJsxScriptTagsPlugin.mjs +1 -1
- package/dist/vite/transformJsxScriptTagsPlugin.test.mjs +2 -2
- package/dist/vite/transformServerFunctions.d.mts +1 -1
- package/dist/vite/transformServerFunctions.mjs +5 -5
- package/dist/vite/transformServerFunctions.test.mjs +3 -3
- package/package.json +54 -44
- package/dist/runtime/imports/resolveSSRValue.d.ts +0 -1
- package/dist/runtime/imports/resolveSSRValue.js +0 -8
- package/dist/runtime/lib/injectHtmlAtMarker.d.ts +0 -11
- package/dist/runtime/lib/injectHtmlAtMarker.js +0 -90
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { getShortName } from "./getShortName.mjs";
|
|
3
1
|
import path from "node:path";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { getShortName } from "./getShortName.mjs";
|
|
4
4
|
describe("getShortName", () => {
|
|
5
5
|
it("should return the relative path if the file is inside the root", () => {
|
|
6
6
|
const root = path.join("/Users", "test", "project");
|
package/dist/lib/getSrcPaths.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import path from "path";
|
|
3
1
|
import { glob } from "glob";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import ts from "typescript";
|
|
4
4
|
/**
|
|
5
5
|
* Gets all source file paths by parsing tsconfig.json using TypeScript's compiler API.
|
|
6
6
|
* Falls back to a glob pattern if tsconfig parsing fails.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { beforeEach, describe, expect, it } from "vitest";
|
|
2
|
+
import { _resetPkgCache, hasPkgScript } from "./hasPkgScript.mjs";
|
|
3
3
|
// Manually reset the cache before each test
|
|
4
4
|
beforeEach(() => {
|
|
5
5
|
_resetPkgCache();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { describe,
|
|
2
|
-
import {
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { extractAllJson, extractLastJson, parseJson } from "./jsonUtils.mjs";
|
|
3
3
|
describe("jsonUtils", () => {
|
|
4
4
|
describe("extractLastJson", () => {
|
|
5
5
|
it("should extract the last JSON object from a string", () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { describe,
|
|
2
|
-
import {
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { findCommonAncestorDepth, normalizeModulePath, } from "./normalizeModulePath.mjs";
|
|
3
3
|
describe("findCommonAncestorDepth", () => {
|
|
4
4
|
it("should return the correct depth for common paths", () => {
|
|
5
5
|
expect(findCommonAncestorDepth("/a/b/c", "/a/b/d")).toBe(2);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { resolve } from "node:path";
|
|
2
|
-
import { symlink, copyFile } from "node:fs/promises";
|
|
3
1
|
import { pathExists } from "fs-extra";
|
|
2
|
+
import { copyFile, symlink } from "node:fs/promises";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
4
|
export async function setupEnvFiles({ rootDir, }) {
|
|
5
5
|
const envPath = resolve(rootDir, ".env");
|
|
6
6
|
const devVarsPath = resolve(rootDir, ".dev.vars");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { createWriteStream, existsSync, mkdirSync } from "fs";
|
|
2
|
+
import { mkdirp, pathExists } from "fs-extra";
|
|
1
3
|
import * as fs from "fs/promises";
|
|
2
4
|
import { join } from "path";
|
|
3
|
-
import { mkdirp, pathExists } from "fs-extra";
|
|
4
|
-
import { createWriteStream, existsSync, mkdirSync } from "fs";
|
|
5
5
|
import { log } from "./constants.mjs";
|
|
6
6
|
// Stream capturer for logging
|
|
7
7
|
export const capturer = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { Browser, Page } from "puppeteer-core";
|
|
1
2
|
import { SmokeTestOptions, SmokeTestResult } from "./types.mjs";
|
|
2
|
-
import type { Page, Browser } from "puppeteer-core";
|
|
3
3
|
export declare function checkUrlStyles(page: Page, expectedColor: "red" | "green"): Promise<void>;
|
|
4
4
|
export declare function checkClientModuleStyles(page: Page, expectedColor: "blue" | "green"): Promise<void>;
|
|
5
5
|
/**
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
+
import * as fs from "fs/promises";
|
|
1
2
|
import { join } from "path";
|
|
2
|
-
import { log } from "./constants.mjs";
|
|
3
|
-
import { takeScreenshot } from "./artifacts.mjs";
|
|
4
|
-
import { RETRIES } from "./constants.mjs";
|
|
5
3
|
import { $ } from "../$.mjs";
|
|
6
|
-
import {
|
|
4
|
+
import { getBrowserPath as getE2EBrowserPath, launchBrowser as launchE2EBrowser, } from "../../lib/e2e/browser.mjs";
|
|
5
|
+
import { takeScreenshot } from "./artifacts.mjs";
|
|
6
|
+
import { log, RETRIES } from "./constants.mjs";
|
|
7
7
|
import { reportSmokeTestResult } from "./reporting.mjs";
|
|
8
8
|
import { updateTestStatus } from "./state.mjs";
|
|
9
|
-
import * as fs from "fs/promises";
|
|
10
|
-
import { template as urlStylesTemplate } from "./templates/smokeTestUrlStyles.css.template";
|
|
11
9
|
import { template as clientStylesTemplate } from "./templates/smokeTestClientStyles.module.css.template";
|
|
12
|
-
import {
|
|
10
|
+
import { template as urlStylesTemplate } from "./templates/smokeTestUrlStyles.css.template";
|
|
11
|
+
import { fail, withRetries } from "./utils.mjs";
|
|
13
12
|
export async function checkUrlStyles(page, expectedColor) {
|
|
14
13
|
const selector = '[data-testid="smoke-test-url-styles"]';
|
|
15
14
|
log(`Checking for element with selector: ${selector}`);
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { setTimeout } from "node:timers/promises";
|
|
3
|
-
import { pathExists } from "fs-extra";
|
|
4
|
-
import { mkdirp } from "fs-extra";
|
|
1
|
+
import { copy, mkdirp, pathExists } from "fs-extra";
|
|
5
2
|
import * as fs from "fs/promises";
|
|
6
|
-
import { copy } from "fs-extra";
|
|
7
|
-
import { relative } from "path";
|
|
8
3
|
import ignore from "ignore";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { isRunningInCI } from "./utils.mjs";
|
|
4
|
+
import { setTimeout } from "node:timers/promises";
|
|
5
|
+
import { join, relative } from "path";
|
|
12
6
|
import { capturer } from "./artifacts.mjs";
|
|
7
|
+
import { log } from "./constants.mjs";
|
|
8
|
+
import { deleteD1Database, deleteWorker, listD1Databases } from "./release.mjs";
|
|
13
9
|
import { state } from "./state.mjs";
|
|
10
|
+
import { isRunningInCI } from "./utils.mjs";
|
|
14
11
|
/**
|
|
15
12
|
* Cleans up any resources used during testing
|
|
16
13
|
*/
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { join } from "path";
|
|
2
1
|
import * as fs from "fs/promises";
|
|
2
|
+
import { parse as parseJsonc } from "jsonc-parser";
|
|
3
|
+
import MagicString from "magic-string";
|
|
4
|
+
import { join } from "path";
|
|
3
5
|
import { log } from "./constants.mjs";
|
|
4
|
-
import { getSmokeTestFunctionsTemplate } from "./templates/smokeTestFunctions.template";
|
|
5
6
|
import { getSmokeTestTemplate } from "./templates/SmokeTest.template";
|
|
6
7
|
import { getSmokeTestClientTemplate } from "./templates/SmokeTestClient.template";
|
|
7
|
-
import { template as smokeTestUrlStylesCssTemplate } from "./templates/smokeTestUrlStyles.css.template";
|
|
8
8
|
import { template as smokeTestClientStylesCssTemplate } from "./templates/smokeTestClientStyles.module.css.template";
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
9
|
+
import { getSmokeTestFunctionsTemplate } from "./templates/smokeTestFunctions.template";
|
|
10
|
+
import { template as smokeTestUrlStylesCssTemplate } from "./templates/smokeTestUrlStyles.css.template";
|
|
11
11
|
/**
|
|
12
12
|
* Creates the smoke test components in the target project directory
|
|
13
13
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { runDevServer as runE2EDevServer } from "../../lib/e2e/dev.mjs";
|
|
2
|
+
import { checkServerUp, checkUrl, launchBrowser } from "./browser.mjs";
|
|
1
3
|
import { log, RETRIES } from "./constants.mjs";
|
|
2
|
-
import { checkUrl, checkServerUp, launchBrowser } from "./browser.mjs";
|
|
3
4
|
import { state } from "./state.mjs";
|
|
4
|
-
import { runDevServer as runE2EDevServer } from "../../lib/e2e/dev.mjs";
|
|
5
5
|
/**
|
|
6
6
|
* Run the local development server and return the URL
|
|
7
7
|
*/
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SmokeTestOptions
|
|
1
|
+
import { TestResources } from "../../lib/e2e/types.mjs";
|
|
2
|
+
import { SmokeTestOptions } from "./types.mjs";
|
|
3
3
|
/**
|
|
4
4
|
* Sets up the test environment for smoke tests, preparing any resources needed for testing
|
|
5
5
|
*/
|
|
6
6
|
export declare function setupTestEnvironment(options?: SmokeTestOptions): Promise<TestResources>;
|
|
7
|
-
export { copyProjectToTempDir };
|
|
@@ -1,11 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { setupTarballEnvironment } from "../../lib/e2e/tarball.mjs";
|
|
2
2
|
import { createSmokeTestComponents } from "./codeUpdates.mjs";
|
|
3
3
|
import { log } from "./constants.mjs";
|
|
4
4
|
/**
|
|
5
5
|
* Sets up the test environment for smoke tests, preparing any resources needed for testing
|
|
6
6
|
*/
|
|
7
7
|
export async function setupTestEnvironment(options = {}) {
|
|
8
|
-
|
|
8
|
+
if (!options.projectDir) {
|
|
9
|
+
throw new Error("projectDir is required for smoke tests");
|
|
10
|
+
}
|
|
11
|
+
const tarballEnv = await setupTarballEnvironment({
|
|
12
|
+
projectDir: options.projectDir,
|
|
13
|
+
packageManager: options.packageManager,
|
|
14
|
+
});
|
|
15
|
+
const resources = {
|
|
16
|
+
tempDirCleanup: tarballEnv.cleanup,
|
|
17
|
+
workerName: undefined,
|
|
18
|
+
originalCwd: process.cwd(),
|
|
19
|
+
targetDir: tarballEnv.targetDir,
|
|
20
|
+
workerCreatedDuringTest: false,
|
|
21
|
+
stopDev: undefined,
|
|
22
|
+
resourceUniqueKey: `smoke-test-${Date.now()}`,
|
|
23
|
+
};
|
|
9
24
|
if (resources.targetDir) {
|
|
10
25
|
// Create the smoke test components in the user's project
|
|
11
26
|
log("Creating smoke test components");
|
|
@@ -13,4 +28,3 @@ export async function setupTestEnvironment(options = {}) {
|
|
|
13
28
|
}
|
|
14
29
|
return resources;
|
|
15
30
|
}
|
|
16
|
-
export { copyProjectToTempDir };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { $expect, deleteD1Database, deleteWorker, isRelatedToTest, listD1Databases } from "../../lib/e2e/release.mjs";
|
|
1
2
|
import { TestResources } from "./types.mjs";
|
|
2
|
-
|
|
3
|
-
export { deleteWorker, deleteD1Database, isRelatedToTest, $expect, listD1Databases, };
|
|
3
|
+
export { $expect, deleteD1Database, deleteWorker, isRelatedToTest, listD1Databases, };
|
|
4
4
|
/**
|
|
5
5
|
* Run the release command to deploy to Cloudflare
|
|
6
6
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { setTimeout } from "node:timers/promises";
|
|
2
|
+
import { $expect, deleteD1Database, deleteWorker, isRelatedToTest, listD1Databases, runRelease as runE2ERelease, } from "../../lib/e2e/release.mjs";
|
|
3
|
+
import { checkServerUp, checkUrl } from "./browser.mjs";
|
|
2
4
|
import { log } from "./constants.mjs";
|
|
3
|
-
|
|
4
|
-
import { runRelease as runE2ERelease, deleteWorker, deleteD1Database, isRelatedToTest, $expect, listD1Databases, } from "../../lib/e2e/release.mjs";
|
|
5
|
-
export { deleteWorker, deleteD1Database, isRelatedToTest, $expect, listD1Databases, };
|
|
5
|
+
export { $expect, deleteD1Database, deleteWorker, isRelatedToTest, listD1Databases, };
|
|
6
6
|
/**
|
|
7
7
|
* Run the release command to deploy to Cloudflare
|
|
8
8
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { join, basename } from "path";
|
|
2
|
-
import { writeFile } from "fs/promises";
|
|
3
1
|
import { mkdirp } from "fs-extra";
|
|
2
|
+
import { writeFile } from "fs/promises";
|
|
3
|
+
import { basename, join } from "path";
|
|
4
4
|
import { log } from "./constants.mjs";
|
|
5
5
|
import { state } from "./state.mjs";
|
|
6
6
|
/**
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { join } from "path";
|
|
2
|
-
import { getBrowserPath } from "./browser.mjs";
|
|
3
2
|
import { setupArtifactsDirectory } from "./artifacts.mjs";
|
|
4
|
-
import {
|
|
3
|
+
import { getBrowserPath } from "./browser.mjs";
|
|
5
4
|
import { runDevServer, runDevTest } from "./development.mjs";
|
|
5
|
+
import { setupTestEnvironment } from "./environment.mjs";
|
|
6
6
|
import { runReleaseTest } from "./release.mjs";
|
|
7
|
-
import { fail, teardown, log } from "./utils.mjs";
|
|
8
|
-
import { state, updateTestStatus } from "./state.mjs";
|
|
9
7
|
import { initializeTestStatus } from "./reporting.mjs";
|
|
8
|
+
import { state, updateTestStatus } from "./state.mjs";
|
|
9
|
+
import { fail, log, teardown } from "./utils.mjs";
|
|
10
10
|
/**
|
|
11
11
|
* Main function that orchestrates the smoke test flow
|
|
12
12
|
*/
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { mkdirp } from "fs-extra";
|
|
1
2
|
import { setTimeout } from "node:timers/promises";
|
|
2
3
|
import { join } from "path";
|
|
4
|
+
import { cleanupResources } from "./cleanup.mjs";
|
|
3
5
|
import { log } from "./constants.mjs";
|
|
4
|
-
import { mkdirp } from "fs-extra";
|
|
5
|
-
import { state } from "./state.mjs";
|
|
6
6
|
import { generateFinalReport } from "./reporting.mjs";
|
|
7
|
-
import {
|
|
7
|
+
import { state } from "./state.mjs";
|
|
8
8
|
// Re-export log from constants
|
|
9
9
|
export { log };
|
|
10
10
|
// Helper function to detect if running in CI environment
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const middleware = "\n\n# RedwoodSDK: Middleware\n\nYou're an expert at Cloudflare, TypeScript, and building web apps with RedwoodSDK. Generate high quality **RedwoodSDK middleware** that adhere to the following best practices:\n\n## Guidelines\n\n1. Create focused, single-responsibility middleware functions\n2. Organize middleware in dedicated files (e.g., `middleware.ts`, `middleware.tsx`)\n3. Use typed parameters and return values\n4. Include clear error handling and logging\n5. Follow the principle of least privilege\n6. Implement proper security headers and CORS policies\n7. Optimize for performance with caching strategies\n\n## What is Middleware?\n\nMiddleware functions in RedwoodSDK are functions that run on every request before your route handlers. They can:\n\n- Add security headers\n- Handle CORS\n- Implement caching strategies\n- Add request/response logging\n- Transform request/response data\n- Implement rate limiting\n- Add performance monitoring\n- Handle error boundaries\n- Setup sessions\n- Authenticate users\n\n## Example Templates\n\n### Basic Middleware Structure\n\n```tsx\nexport default defineApp([\n setCommonHeaders(),\n async ({ ctx, request,
|
|
1
|
+
export declare const middleware = "\n\n# RedwoodSDK: Middleware\n\nYou're an expert at Cloudflare, TypeScript, and building web apps with RedwoodSDK. Generate high quality **RedwoodSDK middleware** that adhere to the following best practices:\n\n## Guidelines\n\n1. Create focused, single-responsibility middleware functions\n2. Organize middleware in dedicated files (e.g., `middleware.ts`, `middleware.tsx`)\n3. Use typed parameters and return values\n4. Include clear error handling and logging\n5. Follow the principle of least privilege\n6. Implement proper security headers and CORS policies\n7. Optimize for performance with caching strategies\n\n## What is Middleware?\n\nMiddleware functions in RedwoodSDK are functions that run on every request before your route handlers. They can:\n\n- Add security headers\n- Handle CORS\n- Implement caching strategies\n- Add request/response logging\n- Transform request/response data\n- Implement rate limiting\n- Add performance monitoring\n- Handle error boundaries\n- Setup sessions\n- Authenticate users\n\n## Example Templates\n\n### Basic Middleware Structure\n\n```tsx\nexport default defineApp([\n setCommonHeaders(),\n async ({ ctx, request, response }) => {\n await setupDb(env);\n setupSessionStore(env);\n try {\n // Grab the session's data.\n ctx.session = await sessions.load(request);\n } catch (error) {\n if (error instanceof ErrorResponse && error.code === 401) {\n await sessions.remove(request, response.headers);\n response.headers.set(\"Location\", \"/user/login\");\n\n return new Response(null, {\n status: 302,\n headers: response.headers,\n });\n }\n\n throw error;\n }\n\n // Populate the ctx with the user's data\n if (ctx.session?.userId) {\n ctx.user = await db.user.findUnique({\n where: {\n id: ctx.session.userId,\n },\n });\n }\n },\n // Route handlers\n]);\n```\n";
|
|
@@ -36,7 +36,7 @@ Middleware functions in RedwoodSDK are functions that run on every request befor
|
|
|
36
36
|
\`\`\`tsx
|
|
37
37
|
export default defineApp([
|
|
38
38
|
setCommonHeaders(),
|
|
39
|
-
async ({ ctx, request,
|
|
39
|
+
async ({ ctx, request, response }) => {
|
|
40
40
|
await setupDb(env);
|
|
41
41
|
setupSessionStore(env);
|
|
42
42
|
try {
|
|
@@ -44,12 +44,12 @@ export default defineApp([
|
|
|
44
44
|
ctx.session = await sessions.load(request);
|
|
45
45
|
} catch (error) {
|
|
46
46
|
if (error instanceof ErrorResponse && error.code === 401) {
|
|
47
|
-
await sessions.remove(request, headers);
|
|
48
|
-
headers.set("Location", "/user/login");
|
|
47
|
+
await sessions.remove(request, response.headers);
|
|
48
|
+
response.headers.set("Location", "/user/login");
|
|
49
49
|
|
|
50
50
|
return new Response(null, {
|
|
51
51
|
status: 302,
|
|
52
|
-
headers,
|
|
52
|
+
headers: response.headers,
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./setWebpackRequire";
|
|
2
|
-
export { ClientOnly } from "./ClientOnly.js";
|
|
3
2
|
export { default as React } from "react";
|
|
4
|
-
|
|
3
|
+
export { ClientOnly } from "./ClientOnly.js";
|
|
4
|
+
import type { HydrationOptions, Transport } from "./types";
|
|
5
5
|
export declare const fetchTransport: Transport;
|
|
6
6
|
export declare const initClient: ({ transport, hydrateRootOptions, handleResponse, }?: {
|
|
7
7
|
transport?: Transport;
|
|
@@ -7,10 +7,10 @@ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
|
7
7
|
import "./setWebpackRequire";
|
|
8
8
|
import React from "react";
|
|
9
9
|
import { hydrateRoot } from "react-dom/client";
|
|
10
|
-
import {
|
|
10
|
+
import { createFromFetch, createFromReadableStream, encodeReply, } from "react-server-dom-webpack/client.browser";
|
|
11
11
|
import { rscStream } from "rsc-html-stream/client";
|
|
12
|
-
export { ClientOnly } from "./ClientOnly.js";
|
|
13
12
|
export { default as React } from "react";
|
|
13
|
+
export { ClientOnly } from "./ClientOnly.js";
|
|
14
14
|
export const fetchTransport = (transportContext) => {
|
|
15
15
|
const fetchCallServer = async (id, args) => {
|
|
16
16
|
const url = new URL(window.location.href);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CallServerCallback } from "react-server-dom-webpack/client.browser";
|
|
2
|
-
export type { CallServerCallback } from "react-server-dom-webpack/client.browser";
|
|
3
2
|
export type { HydrationOptions } from "react-dom/client";
|
|
3
|
+
export type { CallServerCallback } from "react-server-dom-webpack/client.browser";
|
|
4
4
|
export type ActionResponse<Result> = {
|
|
5
5
|
node: React.ReactNode;
|
|
6
6
|
actionResult: Result;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./types/client";
|
|
2
2
|
export * from "../client/client";
|
|
3
|
-
export * from "../register/client";
|
|
4
|
-
export * from "../lib/streams/consumeEventStream";
|
|
5
3
|
export * from "../client/navigation";
|
|
4
|
+
export * from "../lib/streams/consumeEventStream";
|
|
5
|
+
export * from "../register/client";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./types/client";
|
|
2
2
|
export * from "../client/client";
|
|
3
|
-
export * from "../register/client";
|
|
4
|
-
export * from "../lib/streams/consumeEventStream";
|
|
5
3
|
export * from "../client/navigation";
|
|
4
|
+
export * from "../lib/streams/consumeEventStream";
|
|
5
|
+
export * from "../register/client";
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import "./types/worker";
|
|
2
|
-
export * from "../register/worker";
|
|
3
|
-
export * from "../worker";
|
|
4
2
|
export * from "../error";
|
|
5
|
-
export * from "../script";
|
|
6
3
|
export * from "../lib/utils";
|
|
4
|
+
export * from "../register/worker";
|
|
5
|
+
export * from "../render/renderToStream";
|
|
6
|
+
export * from "../render/renderToString";
|
|
7
7
|
export * from "../requestInfo/types";
|
|
8
8
|
export * from "../requestInfo/worker";
|
|
9
|
-
export * from "../
|
|
10
|
-
export * from "../
|
|
11
|
-
export * from "../imports/resolveSSRValue";
|
|
9
|
+
export * from "../script";
|
|
10
|
+
export * from "../worker";
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import "./types/worker";
|
|
2
|
-
export * from "../register/worker";
|
|
3
|
-
export * from "../worker";
|
|
4
2
|
export * from "../error";
|
|
5
|
-
export * from "../script";
|
|
6
3
|
export * from "../lib/utils";
|
|
4
|
+
export * from "../register/worker";
|
|
5
|
+
export * from "../render/renderToStream";
|
|
6
|
+
export * from "../render/renderToString";
|
|
7
7
|
export * from "../requestInfo/types";
|
|
8
8
|
export * from "../requestInfo/worker";
|
|
9
|
-
export * from "../
|
|
10
|
-
export * from "../
|
|
11
|
-
export * from "../imports/resolveSSRValue";
|
|
9
|
+
export * from "../script";
|
|
10
|
+
export * from "../worker";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { requestInfo } from "../requestInfo/worker";
|
|
2
1
|
import { ssrWebpackRequire as baseSsrWebpackRequire } from "rwsdk/__ssr_bridge";
|
|
3
2
|
import { memoizeOnId } from "../lib/memoizeOnId";
|
|
3
|
+
import { requestInfo } from "../requestInfo/worker";
|
|
4
4
|
// @ts-ignore
|
|
5
5
|
import { useServerLookup } from "virtual:use-server-lookup.js";
|
|
6
6
|
export const loadServerModule = memoizeOnId(async (id) => {
|
|
@@ -35,10 +35,10 @@ export declare const defineSessionStore: <Session, SessionInputData>({ cookieNam
|
|
|
35
35
|
unset: (sessionId: string) => Promise<void>;
|
|
36
36
|
}) => {
|
|
37
37
|
load: (request: Request) => Promise<Session | null>;
|
|
38
|
-
save: (
|
|
38
|
+
save: (responseHeaders: Headers, sessionInputData: SessionInputData, { maxAge }?: {
|
|
39
39
|
maxAge?: number | true;
|
|
40
40
|
}) => Promise<void>;
|
|
41
|
-
remove: (request: Request,
|
|
41
|
+
remove: (request: Request, responseHeaders: Headers) => Promise<void>;
|
|
42
42
|
};
|
|
43
43
|
type SessionStoreFromDurableObject<SessionDurableObject> = SessionDurableObject extends DurableObjectMethods<infer Session, infer SessionInputData> ? SessionStore<Session, SessionInputData> : never;
|
|
44
44
|
export declare const defineDurableSession: <SessionDurableObject extends DurableObjectMethods<any, any>>({ cookieName, createCookie, secretKey, sessionDurableObject, }: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ErrorResponse } from "../../error";
|
|
2
1
|
import { env } from "cloudflare:workers";
|
|
2
|
+
import { ErrorResponse } from "../../error";
|
|
3
3
|
const AUTH_SECRET_KEY = env.AUTH_SECRET_KEY ??
|
|
4
4
|
(import.meta.env.VITE_IS_DEV_SERVER
|
|
5
5
|
? "development-secret-key-do-not-use-in-production"
|
|
@@ -89,17 +89,17 @@ export const defineSessionStore = ({ cookieName = "session_id", createCookie = c
|
|
|
89
89
|
throw new ErrorResponse(401, "Invalid session id");
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
|
-
const save = async (
|
|
92
|
+
const save = async (responseHeaders, sessionInputData, { maxAge } = {}) => {
|
|
93
93
|
const sessionId = await generateSessionId({ secretKey });
|
|
94
94
|
await set(sessionId, sessionInputData);
|
|
95
|
-
|
|
95
|
+
responseHeaders.set("Set-Cookie", createCookie({ name: cookieName, sessionId, maxAge }));
|
|
96
96
|
};
|
|
97
|
-
const remove = async (request,
|
|
97
|
+
const remove = async (request, responseHeaders) => {
|
|
98
98
|
const sessionId = getSessionIdFromCookie(request);
|
|
99
99
|
if (sessionId) {
|
|
100
100
|
await unset(sessionId);
|
|
101
101
|
}
|
|
102
|
-
|
|
102
|
+
responseHeaders.set("Set-Cookie", createCookie({ name: cookieName, sessionId: "", maxAge: 0 }));
|
|
103
103
|
};
|
|
104
104
|
return {
|
|
105
105
|
load,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DatabaseConnection, Driver, QueryResult, SqliteAdapter, SqliteIntrospector, SqliteQueryCompiler } from "kysely";
|
|
2
2
|
type DOWorkerDialectConfig = {
|
|
3
3
|
kyselyExecuteQuery: (compiledQuery: {
|
|
4
4
|
sql: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { DODialect } from "kysely-do";
|
|
2
1
|
import { DurableObject } from "cloudflare:workers";
|
|
2
|
+
import { DODialect } from "kysely-do";
|
|
3
3
|
import { Kysely, ParseJSONResultsPlugin, } from "kysely";
|
|
4
|
-
import { createMigrator } from "./index.js";
|
|
5
4
|
import debug from "../debug.js";
|
|
5
|
+
import { createMigrator } from "./index.js";
|
|
6
6
|
const log = debug("sdk:do-db");
|
|
7
7
|
// Base class for Durable Objects that need Kysely database access
|
|
8
8
|
export class SqliteDurableObject extends DurableObject {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { CheckConstraintNode, Expression, ForeignKeyConstraintBuilder, PrimaryKeyConstraintNode, sql, UniqueConstraintNode } from "kysely";
|
|
2
|
+
import { AddColumnOp, AlterColumnOp, AlterOperation, DropColumnOp, ExecutedBuilder, ModifyColumnOp, RenameColumnOp, SqlToTsType } from "../utils";
|
|
3
3
|
import { AlterColumnBuilderCallback } from "./alterColumn";
|
|
4
|
-
import {
|
|
4
|
+
import { ColumnDefinitionBuilder } from "./columnDefinition";
|
|
5
5
|
type DataTypeExpression = string | typeof sql;
|
|
6
6
|
interface CheckConstraintBuilder {
|
|
7
7
|
$call<T>(func: (qb: this) => T): T;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Expression, sql
|
|
1
|
+
import { ColumnDefinitionNode, Expression, sql } from "kysely";
|
|
2
2
|
type DefaultValueExpression = string | number | boolean | null | typeof sql;
|
|
3
3
|
export interface ColumnDefinitionBuilder<TType> {
|
|
4
4
|
autoIncrement(): ColumnDefinitionBuilder<TType>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CheckConstraintNode, CompiledQuery, CreateTableNode, Expression, ForeignKeyConstraintBuilder, PrimaryKeyConstraintNode, UniqueConstraintNode } from "kysely";
|
|
2
|
+
import { ExecutedBuilder, Prettify, SqlToTsType } from "../utils";
|
|
2
3
|
import { ColumnDefinitionBuilder } from "./columnDefinition";
|
|
3
|
-
import { CompiledQuery, CreateTableNode, Expression, ForeignKeyConstraintBuilder, CheckConstraintNode, UniqueConstraintNode, PrimaryKeyConstraintNode } from "kysely";
|
|
4
4
|
interface CheckConstraintBuilder {
|
|
5
5
|
$call<T>(func: (qb: this) => T): T;
|
|
6
6
|
toOperationNode(): CheckConstraintNode;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { CompiledQuery, CreateViewNode, RawBuilder, SelectQueryBuilder } from "kysely";
|
|
1
2
|
import { ExecutedBuilder } from "../utils";
|
|
2
|
-
import { CreateViewNode, CompiledQuery, SelectQueryBuilder, RawBuilder } from "kysely";
|
|
3
3
|
export interface CreateViewBuilder<TName extends string, TSchema extends Record<string, any> = {}, TColumns extends string[] = []> {
|
|
4
4
|
readonly __viewName: TName;
|
|
5
5
|
readonly __schema: TSchema;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { CompiledQuery, DropTableNode } from "kysely";
|
|
1
2
|
import { ExecutedBuilder } from "../utils";
|
|
2
|
-
import { DropTableNode, CompiledQuery } from "kysely";
|
|
3
3
|
export interface DropTableBuilder<TName extends string> {
|
|
4
4
|
readonly __tableName: TName;
|
|
5
5
|
ifExists(): DropTableBuilder<TName>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { CompiledQuery, DropViewNode } from "kysely";
|
|
1
2
|
import { ExecutedBuilder } from "../utils";
|
|
2
|
-
import { DropViewNode, CompiledQuery } from "kysely";
|
|
3
3
|
export interface DropViewBuilder<TName extends string> {
|
|
4
4
|
readonly __viewName: TName;
|
|
5
5
|
ifExists(): DropViewBuilder<TName>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CreateIndexBuilder, CreateSchemaBuilder, CreateTypeBuilder, DropIndexBuilder, DropSchemaBuilder, DropTypeBuilder, KyselyPlugin, RefreshMaterializedViewBuilder } from "kysely";
|
|
2
2
|
import { AlterTableBuilder } from "./alterTable";
|
|
3
|
-
import {
|
|
3
|
+
import { CreateTableBuilder } from "./createTable";
|
|
4
4
|
import { CreateViewBuilder } from "./createView";
|
|
5
|
+
import { DropTableBuilder } from "./dropTable";
|
|
5
6
|
import { DropViewBuilder } from "./dropView";
|
|
6
|
-
import { CreateIndexBuilder, DropIndexBuilder, CreateSchemaBuilder, DropSchemaBuilder, CreateTypeBuilder, DropTypeBuilder, KyselyPlugin, RefreshMaterializedViewBuilder } from "kysely";
|
|
7
7
|
export interface SchemaBuilder {
|
|
8
8
|
createTable<TName extends string>(name: TName): CreateTableBuilder<TName, {}>;
|
|
9
9
|
alterTable<TName extends string>(name: TName): AlterTableBuilder<TName, []>;
|