@powerhousedao/codegen 6.2.0-dev.9 → 6.2.0-rc.1

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.
@@ -1,3 +1,4 @@
1
+ import { createRequire } from "node:module";
1
2
  import { ANALYTICS_ENGINE_CORE_PACKAGE, BOILERPLATE_ALLOWED_BUILDS, BOILERPLATE_PNPM_OVERRIDES, GRAPHQL_PACKAGE, GRAPHQL_TAG_PACKAGE, PEER_EXTERNAL_DEPENDENCIES, REACTOR_API_PACKAGE, VERSIONED_DEV_DEPENDENCIES, VERSIONED_PEER_DEPENDENCIES, defaultManifest, directoryExists, externalDevDependencies, fileExists, fileExistsSync, isDirectory, makeVersionedDependenciesMap, packageJsonExports, spawnAsync, writeFileEnsuringDir } from "@powerhousedao/shared/clis";
2
3
  import { readdirSync } from "fs";
3
4
  import path, { join } from "path";
@@ -9,7 +10,7 @@ import { DEFAULT_REGISTRY_URL } from "@powerhousedao/shared/registry";
9
10
  import { capitalize, concat, conditional, constant, endsWith, filter, find, first, flatMap, forEach, isDefined, isIncludedIn, isNonNullish, isNot, isStrictEqual, isString, isTruthy, last, map, mapValues, merge, pipe, prop, sort, split, startsWith, subtract, unique, uniqueBy, when } from "remeda";
10
11
  import { IndentationText, Project, SyntaxKind, VariableDeclarationKind, ts } from "ts-morph";
11
12
  import arg from "arg";
12
- import { format } from "prettier";
13
+ import { format } from "oxfmt";
13
14
  import { z } from "zod";
14
15
  import { loadJsonFile, loadJsonFileSync } from "load-json-file";
15
16
  import { writeJsonFile } from "write-json-file";
@@ -17,6 +18,9 @@ import { stripVTControlCharacters } from "node:util";
17
18
  import path$1, { join as join$1, relative } from "node:path";
18
19
  import { generate } from "@graphql-codegen/cli";
19
20
  import { generatorTypeDefs, validationSchema } from "@powerhousedao/document-engineering/graphql";
21
+ import { Kind, parse } from "graphql";
22
+ import { realpathSync } from "node:fs";
23
+ import { fileURLToPath, pathToFileURL } from "node:url";
20
24
  function isEOL(c) {
21
25
  return c === 10 || c === 13;
22
26
  }
@@ -1659,7 +1663,7 @@ function sanitizeInput(input) {
1659
1663
  * @param content YAML string to parse.
1660
1664
  * @param options Parsing options.
1661
1665
  * @returns Parsed document.
1662
- */ function parse(content, options = {}) {
1666
+ */ function parse$1(content, options = {}) {
1663
1667
  content = sanitizeInput(content);
1664
1668
  const documentGenerator = new LoaderState(content, {
1665
1669
  ...options,
@@ -1736,13 +1740,13 @@ var TemplateClass = class TemplateClass extends String {
1736
1740
  }
1737
1741
  const html = tag("html");
1738
1742
  const css = tag("css");
1739
- const js = tag("js");
1743
+ tag("js");
1740
1744
  const ts$1 = tag("ts");
1741
1745
  tag("jsx");
1742
1746
  const tsx = tag("tsx");
1743
1747
  const json = tag("json", JSON.parse);
1744
1748
  tag("xml");
1745
- const yaml = tag("yaml", parse);
1749
+ const yaml = tag("yaml", parse$1);
1746
1750
  tag("toml");
1747
1751
  tag("ini");
1748
1752
  tag("csv");
@@ -1800,7 +1804,7 @@ export function CreateDocument() {
1800
1804
  return (
1801
1805
  <div>
1802
1806
  {/* Customize section title here */}
1803
- <h3 className="mb-3 mt-4 text-sm font-bold text-gray-600">
1807
+ <h3 className="mb-3 mt-4 text-sm font-bold text-muted-foreground">
1804
1808
  Create document
1805
1809
  </h3>
1806
1810
  {/* Customize layout by changing flex-wrap, gap, or grid layout */}
@@ -1829,7 +1833,7 @@ function CreateDocumentButton({ documentModelModule }: Props) {
1829
1833
  documentModelModule.documentModel.global.description;
1830
1834
  return (
1831
1835
  <button
1832
- className="cursor-pointer rounded-md bg-gray-200 py-2 px-3 hover:bg-gray-300"
1836
+ className="cursor-pointer rounded-md bg-secondary py-2 px-3 hover:hover-effect"
1833
1837
  title={documentModelName}
1834
1838
  aria-description={documentModelDescription}
1835
1839
  onClick={() => showCreateDocumentModal(documentType)}
@@ -1907,7 +1911,7 @@ export function EmptyState() {
1907
1911
  if (hasNodes) return null;
1908
1912
 
1909
1913
  return (
1910
- <div className="py-12 text-center text-gray-500">
1914
+ <div className="py-12 text-center text-muted-foreground">
1911
1915
  <p className="text-lg">This folder is empty</p>
1912
1916
  <p className="mt-2 text-sm">Create your first document or folder below</p>
1913
1917
  </div>
@@ -1933,7 +1937,7 @@ export function Files() {
1933
1937
 
1934
1938
  return (
1935
1939
  <div>
1936
- <h3 className="mb-2 text-sm font-semibold text-gray-600">Documents</h3>
1940
+ <h3 className="mb-2 text-sm font-semibold text-muted-foreground">Documents</h3>
1937
1941
  <div className="flex flex-wrap gap-4">
1938
1942
  {fileNodes.map((fileNode) => (
1939
1943
  <FileItem key={fileNode.id} fileNode={fileNode} />
@@ -1962,7 +1966,7 @@ export function Folders() {
1962
1966
 
1963
1967
  return (
1964
1968
  <div>
1965
- <h3 className="mb-2 text-sm font-bold text-gray-600">Folders</h3>
1969
+ <h3 className="mb-2 text-sm font-bold text-muted-foreground">Folders</h3>
1966
1970
  <div className="flex flex-wrap gap-4">
1967
1971
  {folderNodes.map((folderNode) => (
1968
1972
  <FolderItem key={folderNode.id} folderNode={folderNode} />
@@ -2088,7 +2092,7 @@ import { Breadcrumbs } from "@powerhousedao/design-system/connect";
2088
2092
  /** Shows the navigation breadcrumbs for the selected drive or folder */
2089
2093
  export function NavigationBreadcrumbs() {
2090
2094
  return (
2091
- <div className="border-b border-gray-200 pb-3 space-y-3">
2095
+ <div className="border-b border-border pb-3 space-y-3">
2092
2096
  <Breadcrumbs />
2093
2097
  </div>
2094
2098
  );
@@ -2122,7 +2126,7 @@ export default function Editor(props: EditorProps) {
2122
2126
  // you can update these configs in \`./config.ts\`
2123
2127
  useSetPHAppConfig(editorConfig);
2124
2128
  return (
2125
- <div className="bg-gray-50 p-6">
2129
+ <div className="bg-background p-6">
2126
2130
  <DriveExplorer {...props} />
2127
2131
  </div>
2128
2132
  );
@@ -2205,7 +2209,7 @@ If the \`reactor-mcp\` server is unavailable, ask the user to run \`ph vetra\` o
2205
2209
  After doing changes to the code, or after creating a new document model or a new editor, _YOU MUST RUN_ the following commands to check for errors in your implementation:
2206
2210
 
2207
2211
  - **TypeScript Check**: Run \`npm run tsc\` to validate type safety
2208
- - **ESLint Check**: Run \`npm run lint:fix\` to check for errors with ESLint
2212
+ - **Lint Check**: Run \`npm run lint:fix\` to check for errors with oxlint (type-aware rules plus TypeScript type checking)
2209
2213
  - **Reducer Test Coverage**: Run \`npm run test:coverage\` after any change to a document model reducer. Document model reducers are pure synchronous functions and **MUST** stay at or above **95%** coverage on lines, branches, functions, and statements. If coverage drops below the threshold, add tests in \`document-models/<name>/v<n>/tests/\` until the threshold is restored — **DO NOT** lower the threshold or exclude files to make the check pass. Cover the happy path _and_ every error code defined via \`ADD_OPERATION_ERROR\` (each error is a branch that needs explicit test coverage). Push toward 100% by following the strategy below.
2210
2214
 
2211
2215
  #### Strategy: reaching 100% reducer coverage
@@ -2300,7 +2304,7 @@ The \`useSelectedTodoDocument\` (and every other document hook) is auto-generate
2300
2304
 
2301
2305
  ### Editor code conventions (TypeScript & module resolution)
2302
2306
 
2303
- These rules apply to **every** editor regardless of which UI library you use. They come from the project's \`tsconfig\` (\`module: nodenext\`, \`strict\`, \`verbatimModuleSyntax\`) and ESLint config — they are constraints, not stylistic preferences.
2307
+ These rules apply to **every** editor regardless of which UI library you use. They come from the project's \`tsconfig\` (\`module: nodenext\`, \`strict\`, \`verbatimModuleSyntax\`) and oxlint config — they are constraints, not stylistic preferences.
2304
2308
 
2305
2309
  #### Always use the top-level barrel for document-model imports
2306
2310
 
@@ -2348,7 +2352,7 @@ When a third-party CLI generates extensionless imports, do a bulk find-and-repla
2348
2352
 
2349
2353
  #### Stringifying \`unknown\` values
2350
2354
 
2351
- The boilerplate ESLint config enables \`@typescript-eslint/no-base-to-string\` (via \`recommendedTypeChecked\`). \`String(value ?? "")\` on a value typed as \`unknown\` will trip the rule because the default \`Object.prototype.toString\` produces \`"[object Object]"\`. Use a small helper:
2355
+ The boilerplate oxlint config enables \`typescript/no-base-to-string\` (the \`recommendedTypeChecked\` equivalent). \`String(value ?? "")\` on a value typed as \`unknown\` will trip the rule because the default \`Object.prototype.toString\` produces \`"[object Object]"\`. Use a small helper:
2352
2356
 
2353
2357
  ~~~typescript
2354
2358
  function str(v: unknown): string {
@@ -2940,8 +2944,8 @@ RUN pnpm config set @jsr:registry https://npm.jsr.io
2940
2944
  ARG TAG=latest
2941
2945
  ARG PH_CONNECT_BASE_PATH="/"
2942
2946
 
2943
- # Install ph-cmd, prisma, and prettier globally
2944
- RUN pnpm add -g ph-cmd@$TAG prisma@5.17.0 prettier
2947
+ # Install ph-cmd, prisma, and oxfmt globally
2948
+ RUN pnpm add -g ph-cmd@$TAG prisma@5.17.0 oxfmt
2945
2949
 
2946
2950
  # Initialize project based on tag (dev/staging/latest)
2947
2951
  RUN case "$TAG" in \\
@@ -3200,144 +3204,120 @@ const editorsIndexTemplate = `
3200
3204
  */
3201
3205
  `;
3202
3206
  //#endregion
3203
- //#region src/templates/boilerplate/eslint.config.js.ts
3204
- const eslintConfigTemplate = js`
3205
- // @ts-check
3206
- import { default as eslint } from "@eslint/js";
3207
- import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
3208
- import reactPlugin from "eslint-plugin-react";
3209
- import reactHooksPlugin from "eslint-plugin-react-hooks";
3210
- import { defineConfig, globalIgnores } from "eslint/config";
3211
- import globals from "globals";
3212
- import tseslint from "typescript-eslint";
3213
-
3214
- /** These files are typically ignored by eslint by default, so there is no need to investigate why they are ignored. */
3215
- const ignoredFiles = [
3216
- "**/node_modules/",
3217
- "**/dist/",
3218
- "**/.ph/",
3219
- "**/storybook-static/",
3220
- "**/.vite/",
3221
- ];
3222
-
3223
- /** Global configs for eslint ignores */
3224
- const ignored = globalIgnores(ignoredFiles);
3225
-
3226
- /** Typescript (\`.ts\`) files */
3227
- const typescriptFiles = ["**/*.ts"];
3228
-
3229
- /** Typescript React (\`.tsx\`) files */
3230
- const typescriptReactFiles = ["**/*.tsx"];
3231
-
3232
- /** Javascript (\`.js\`, \`.cjs\`, \`.mjs\`) files */
3233
- const javascriptFiles = ["**/*.js", "**/*.cjs", "**/*.mjs"];
3234
-
3235
- /** Typescript rules that we have chosen to opt out of in general */
3236
- /** @type {import("eslint").Linter.RulesRecord} */
3237
- const typescriptRules = {
3238
- "@typescript-eslint/consistent-type-imports": [
3239
- "error",
3240
- {
3241
- prefer: "type-imports",
3242
- disallowTypeAnnotations: true,
3243
- fixStyle: "separate-type-imports",
3244
- },
3245
- ],
3246
- "@typescript-eslint/no-explicit-any": "off",
3247
- "@typescript-eslint/no-unused-vars": [
3248
- "warn",
3249
- {
3250
- argsIgnorePattern: "^_",
3251
- varsIgnorePattern: "^_",
3252
- caughtErrorsIgnorePattern: "^_",
3253
- },
3254
- ],
3255
- "@typescript-eslint/no-unnecessary-condition": "warn",
3256
- "@typescript-eslint/require-await": "warn",
3257
- "@typescript-eslint/no-misused-promises": "warn",
3258
- "@typescript-eslint/no-floating-promises": "warn",
3259
- "@typescript-eslint/no-empty-object-type": "warn",
3260
- "@typescript-eslint/no-duplicate-type-constituents": "warn",
3261
- "@typescript-eslint/restrict-template-expressions": [
3262
- "warn",
3263
- {
3264
- allowNumber: true,
3265
- },
3207
+ //#region src/templates/boilerplate/oxlintrc.json.ts
3208
+ const oxlintConfigTemplate = json`
3209
+ {
3210
+ "$schema": "https://raw.githubusercontent.com/oxc-project/oxc/main/npm/oxlint/configuration_schema.json",
3211
+ "plugins": ["typescript", "react", "react-hooks"],
3212
+ "categories": { "correctness": "error" },
3213
+ "ignorePatterns": [
3214
+ "**/node_modules/**",
3215
+ "**/dist/**",
3216
+ "**/.ph/**",
3217
+ "**/storybook-static/**",
3218
+ "**/.vite/**"
3266
3219
  ],
3267
- };
3268
-
3269
- /** Language options for typescript files
3270
- @type {import("eslint").Linter.LanguageOptions} */
3271
- const typescriptLanguageOptions = {
3272
- sourceType: "module",
3273
- ecmaVersion: "latest",
3274
- globals: {
3275
- ...globals.browser,
3276
- ...globals.node,
3277
- },
3278
- parserOptions: {
3279
- projectService: {
3280
- allowDefaultProject: ["eslint.config.js", "vitest.config.ts", "main.tsx"],
3281
- },
3282
- tsconfigRootDir: import.meta.dirname,
3283
- ecmaFeatures: {
3284
- jsx: true,
3285
- },
3286
- },
3287
- };
3288
-
3289
- /** React plugins */
3290
- const reactPlugins = {
3291
- react: reactPlugin,
3292
- "react-hooks": reactHooksPlugin,
3293
- };
3294
-
3295
- /** React settings */
3296
- const reactSettings = {
3297
- react: {
3298
- version: "detect",
3220
+ "rules": {
3221
+ "typescript/await-thenable": "error",
3222
+ "typescript/ban-ts-comment": "error",
3223
+ "typescript/no-array-constructor": "error",
3224
+ "typescript/no-array-delete": "error",
3225
+ "typescript/no-base-to-string": "error",
3226
+ "typescript/no-duplicate-enum-values": "error",
3227
+ "typescript/no-extra-non-null-assertion": "error",
3228
+ "typescript/no-for-in-array": "error",
3229
+ "typescript/no-implied-eval": "error",
3230
+ "typescript/no-misused-new": "error",
3231
+ "typescript/no-namespace": "error",
3232
+ "typescript/no-non-null-asserted-optional-chain": "error",
3233
+ "typescript/no-redundant-type-constituents": "error",
3234
+ "typescript/no-require-imports": "error",
3235
+ "typescript/no-this-alias": "error",
3236
+ "typescript/no-unnecessary-type-assertion": "error",
3237
+ "typescript/no-unnecessary-type-constraint": "error",
3238
+ "typescript/no-unsafe-argument": "error",
3239
+ "typescript/no-unsafe-assignment": "error",
3240
+ "typescript/no-unsafe-call": "error",
3241
+ "typescript/no-unsafe-declaration-merging": "error",
3242
+ "typescript/no-unsafe-enum-comparison": "error",
3243
+ "typescript/no-unsafe-function-type": "error",
3244
+ "typescript/no-unsafe-member-access": "error",
3245
+ "typescript/no-unsafe-return": "error",
3246
+ "typescript/no-unsafe-unary-minus": "error",
3247
+ "typescript/no-unused-expressions": "error",
3248
+ "typescript/no-wrapper-object-types": "error",
3249
+ "typescript/only-throw-error": "error",
3250
+ "typescript/prefer-as-const": "error",
3251
+ "typescript/prefer-namespace-keyword": "error",
3252
+ "typescript/prefer-promise-reject-errors": "error",
3253
+ "typescript/restrict-plus-operands": "error",
3254
+ "typescript/triple-slash-reference": "error",
3255
+ "typescript/unbound-method": "error",
3256
+ "typescript/consistent-type-imports": [
3257
+ "error",
3258
+ {
3259
+ "prefer": "type-imports",
3260
+ "disallowTypeAnnotations": true,
3261
+ "fixStyle": "separate-type-imports"
3262
+ }
3263
+ ],
3264
+ "typescript/no-explicit-any": "off",
3265
+ "typescript/no-unused-vars": [
3266
+ "warn",
3267
+ {
3268
+ "argsIgnorePattern": "^_",
3269
+ "varsIgnorePattern": "^_",
3270
+ "caughtErrorsIgnorePattern": "^_"
3271
+ }
3272
+ ],
3273
+ "typescript/no-unnecessary-condition": "warn",
3274
+ "typescript/require-await": "warn",
3275
+ "typescript/no-misused-promises": "warn",
3276
+ "typescript/no-floating-promises": "warn",
3277
+ "typescript/no-empty-object-type": "warn",
3278
+ "typescript/no-duplicate-type-constituents": "warn",
3279
+ "typescript/restrict-template-expressions": ["warn", { "allowNumber": true }],
3280
+ "react-hooks/rules-of-hooks": "error",
3281
+ "react-hooks/exhaustive-deps": "warn"
3299
3282
  },
3300
- };
3301
-
3302
- /** Typescript config for both \`.ts\` and \`.tsx\` files */
3303
- const typescriptConfig = {
3304
- files: [...typescriptFiles, ...typescriptReactFiles],
3305
- languageOptions: typescriptLanguageOptions,
3306
- rules: typescriptRules,
3307
- };
3308
-
3309
- /** React config for \`.tsx\` files */
3310
- const reactConfig = {
3311
- files: typescriptReactFiles,
3312
- settings: reactSettings,
3313
- plugins: reactPlugins,
3314
- };
3315
-
3316
- /** Config for javascript files */
3317
- const javascriptConfig = {
3318
- // disable type aware linting for js files
3319
- files: javascriptFiles,
3320
- extends: [tseslint.configs.disableTypeChecked],
3321
- };
3322
-
3323
- /** Recommended config from eslint */
3324
- const eslintRecommendedConfig = eslint.configs.recommended;
3325
-
3326
- /** Recommended config from typescript-eslint */
3327
- const typescriptEsLintRecommendedConfig = [
3328
- ...tseslint.configs.recommendedTypeChecked,
3329
- ];
3330
-
3331
- /** Main config */
3332
- export default defineConfig(
3333
- ignored,
3334
- eslintRecommendedConfig,
3335
- typescriptEsLintRecommendedConfig,
3336
- typescriptConfig,
3337
- reactConfig,
3338
- javascriptConfig,
3339
- eslintPluginPrettierRecommended,
3340
- );
3283
+ "overrides": [
3284
+ {
3285
+ "files": ["**/*.js", "**/*.cjs", "**/*.mjs"],
3286
+ "rules": {
3287
+ "typescript/await-thenable": "off",
3288
+ "typescript/no-array-delete": "off",
3289
+ "typescript/no-base-to-string": "off",
3290
+ "typescript/no-duplicate-type-constituents": "off",
3291
+ "typescript/no-floating-promises": "off",
3292
+ "typescript/no-for-in-array": "off",
3293
+ "typescript/no-implied-eval": "off",
3294
+ "typescript/no-misused-promises": "off",
3295
+ "typescript/no-redundant-type-constituents": "off",
3296
+ "typescript/no-unnecessary-condition": "off",
3297
+ "typescript/no-unnecessary-type-assertion": "off",
3298
+ "typescript/no-unsafe-argument": "off",
3299
+ "typescript/no-unsafe-assignment": "off",
3300
+ "typescript/no-unsafe-call": "off",
3301
+ "typescript/no-unsafe-enum-comparison": "off",
3302
+ "typescript/no-unsafe-member-access": "off",
3303
+ "typescript/no-unsafe-return": "off",
3304
+ "typescript/no-unsafe-unary-minus": "off",
3305
+ "typescript/only-throw-error": "off",
3306
+ "typescript/prefer-promise-reject-errors": "off",
3307
+ "typescript/require-await": "off",
3308
+ "typescript/restrict-plus-operands": "off",
3309
+ "typescript/restrict-template-expressions": "off",
3310
+ "typescript/unbound-method": "off"
3311
+ }
3312
+ }
3313
+ ]
3314
+ }
3315
+ `.raw;
3316
+ const oxfmtConfigTemplate = json`
3317
+ {
3318
+ "$schema": "https://raw.githubusercontent.com/oxc-project/oxc/main/npm/oxfmt/configuration_schema.json",
3319
+ "printWidth": 80
3320
+ }
3341
3321
  `.raw;
3342
3322
  //#endregion
3343
3323
  //#region src/templates/boilerplate/gemini/settings.json.ts
@@ -3733,7 +3713,6 @@ const gitIgnoreTemplate = `
3733
3713
  dist
3734
3714
  coverage
3735
3715
  node_modules
3736
- .eslintcache
3737
3716
  .env.local
3738
3717
  *.tsbuildinfo
3739
3718
 
@@ -3766,7 +3745,21 @@ export { documentModels } from "./document-models/document-models.js";
3766
3745
  export { upgradeManifests } from "./document-models/upgrade-manifests.js";
3767
3746
  export { editors } from "./editors/editors.js";
3768
3747
  export { processorFactory } from "./processors/factory.js";
3769
- export const manifest: Manifest = manifestJson;
3748
+ export const manifest = manifestJson as Manifest;
3749
+ `.raw;
3750
+ //#endregion
3751
+ //#region src/templates/boilerplate/reactor.ts
3752
+ const reactorTsTemplate = ts$1`
3753
+ /**
3754
+ * WARNING: DO NOT EDIT
3755
+ * This file is auto-generated and updated by codegen
3756
+ */
3757
+ import type { Manifest } from "document-model";
3758
+ import manifestJson from "../powerhouse.manifest.json" with { type: "json" };
3759
+ export { documentModels } from "../document-models/document-models.js";
3760
+ export { upgradeManifests } from "../document-models/upgrade-manifests.js";
3761
+ export { processorFactory } from "../processors/factory.js";
3762
+ export const manifest = manifestJson as Manifest;
3770
3763
  `.raw;
3771
3764
  //#endregion
3772
3765
  //#region src/templates/boilerplate/LICENSE.ts
@@ -4492,8 +4485,10 @@ const packageJsonTemplate = (projectName, peerDependencies, devDependencies) =>
4492
4485
  "test": "vitest run",
4493
4486
  "test:watch": "vitest",
4494
4487
  "test:coverage": "vitest run --coverage",
4495
- "lint": "eslint --config eslint.config.js --cache --cache-strategy content",
4496
- "lint:fix": "npm run lint -- --fix",
4488
+ "lint": "oxlint --type-aware --type-check",
4489
+ "lint:fix": "oxlint --type-aware --type-check --fix",
4490
+ "format": "oxfmt",
4491
+ "format:check": "oxfmt --check",
4497
4492
  "tsc": "tsc",
4498
4493
  "tsc:watch": "tsc --watch",
4499
4494
  "check-circular-imports": "npx dpdm -T ./index.ts",
@@ -4521,8 +4516,10 @@ const packageJsonScriptsTemplate = {
4521
4516
  build: "npm run tsc && npm run tailwind",
4522
4517
  test: "vitest run",
4523
4518
  "test:watch": "vitest",
4524
- lint: "eslint --config eslint.config.js --cache --cache-strategy content",
4525
- "lint:fix": "npm run lint -- --fix",
4519
+ lint: "oxlint --type-aware --type-check",
4520
+ "lint:fix": "oxlint --type-aware --type-check --fix",
4521
+ format: "oxfmt",
4522
+ "format:check": "oxfmt --check",
4526
4523
  tsc: "tsc",
4527
4524
  "tsc:watch": "tsc --watch",
4528
4525
  tailwind: "pnpm exec tailwindcss -i ./style.css -o ./dist/style.css",
@@ -4635,8 +4632,8 @@ This tutorial will guide you through the process of creating a new document mode
4635
4632
  <summary>Available NPM commands</summary>
4636
4633
 
4637
4634
  - \`generate\`: Updates the generated code according to the JSON spec and GraphQL schema of your document model, made in Connect.
4638
- - \`lint\`: Checks for errors with ESLint and TypeScript checking.
4639
- - \`format\`: Formats the code using Prettier.
4635
+ - \`lint\`: Checks for errors with oxlint, including type-aware rules and TypeScript type checking.
4636
+ - \`format\`: Formats the code using oxfmt.
4640
4637
  - \`build\`: Builds the library project using Vite.
4641
4638
  - \`storybook\`: Starts Storybook in development mode.
4642
4639
  - \`build-storybook\`: Builds Storybook.
@@ -4998,7 +4995,7 @@ export default function Editor() {
4998
4995
  };
4999
4996
 
5000
4997
  return (
5001
- <div className="mx-auto max-w-4xl bg-gray-50 p-6">
4998
+ <div className="mx-auto max-w-4xl bg-background p-6">
5002
4999
  <DocumentToolbar />
5003
5000
 
5004
5001
  {/* "ph-default-styles" sets default styles for basic UI elements */}
@@ -5686,11 +5683,11 @@ export function create${v.phDocumentTypeName}(
5686
5683
  }>,
5687
5684
  ): ${v.phDocumentTypeName} {
5688
5685
  const document = utils.createDocument(
5689
- state ? createState(
5690
- createBaseState(state.auth, state.document),
5691
- state.global,
5692
- state.local,
5693
- ) : undefined
5686
+ createState(
5687
+ createBaseState(state?.auth, { version: ${v.version}, ...state?.document }),
5688
+ state?.global,
5689
+ state?.local,
5690
+ )
5694
5691
  );
5695
5692
 
5696
5693
  return document;
@@ -5830,6 +5827,14 @@ export type {
5830
5827
  `.raw;
5831
5828
  //#endregion
5832
5829
  //#region src/templates/document-model/gen/utils.ts
5830
+ function makeOlderReducerImports(versions, currentVersion) {
5831
+ return versions.filter((k) => k < currentVersion).map((k) => `import { reducer as reducerV${k} } from "../../v${k}/gen/reducer.js";`).join("\n");
5832
+ }
5833
+ function makeReducersObject(versions, currentVersion) {
5834
+ return `{ ${versions.filter((k) => k <= currentVersion).map((k) => {
5835
+ return `${k}: ${k === currentVersion ? "reducer" : `reducerV${k}`} as unknown as Reducer<PHBaseState>`;
5836
+ }).join(", ")} }`;
5837
+ }
5833
5838
  const documentModelGenUtilsTemplate = (v) => ts$1`
5834
5839
  /**
5835
5840
  * WARNING: DO NOT EDIT
@@ -5837,14 +5842,17 @@ const documentModelGenUtilsTemplate = (v) => ts$1`
5837
5842
  */
5838
5843
  import type {
5839
5844
  DocumentModelUtils,
5845
+ PHBaseState,
5846
+ Reducer,
5840
5847
  } from "document-model";
5841
5848
  import {
5842
5849
  baseCreateDocument,
5843
5850
  baseSaveToFileHandle,
5844
- baseLoadFromInput,
5845
- defaultBaseState,
5851
+ baseLoadFromInputVersioned,
5852
+ createBaseState,
5846
5853
  } from "document-model";
5847
5854
  import { reducer } from './reducer.js';
5855
+ ${makeOlderReducerImports(v.versions, v.version) ? makeOlderReducerImports(v.versions, v.version) + "\n" : ""}import { ${v.upgradeManifestName} } from "../../upgrades/upgrade-manifest.js";
5848
5856
  import { ${v.documentTypeVariableName} } from "./document-type.js";
5849
5857
  import {
5850
5858
  ${v.assertIsPhDocumentOfTypeFunctionName},
@@ -5860,7 +5868,7 @@ export const initialLocalState: ${v.localStateName} = ${v.initialLocalState};
5860
5868
  export const utils: DocumentModelUtils<${v.phStateName}> = {
5861
5869
  fileExtension: "${v.documentModelState.extension}",
5862
5870
  createState(state) {
5863
- return { ...defaultBaseState(), global: { ...initialGlobalState, ...state?.global }, local: { ...initialLocalState, ...state?.local } };
5871
+ return { ...createBaseState(state?.auth, { version: ${v.version}, ...state?.document }), global: { ...initialGlobalState, ...state?.global }, local: { ...initialLocalState, ...state?.local } };
5864
5872
  },
5865
5873
  createDocument(state) {
5866
5874
  return baseCreateDocument(
@@ -5873,7 +5881,10 @@ export const utils: DocumentModelUtils<${v.phStateName}> = {
5873
5881
  return baseSaveToFileHandle(document, input);
5874
5882
  },
5875
5883
  loadFromInput(input) {
5876
- return baseLoadFromInput(input, reducer);
5884
+ return baseLoadFromInputVersioned(input, {
5885
+ reducers: ${makeReducersObject(v.versions, v.version)},
5886
+ upgradeManifest: ${v.upgradeManifestName},
5887
+ });
5877
5888
  },
5878
5889
  isStateOfType(state) {
5879
5890
  return ${v.isPhStateOfTypeFunctionName}(state);
@@ -6130,7 +6141,7 @@ function makeCamelCaseOperationNamesForImport(operations) {
6130
6141
  function makeOperationInputSchemasForImport(operations) {
6131
6142
  return pipe(operations, map(prop("name")), filter(isString), map((n) => `${pascalCase(n)}InputSchema`));
6132
6143
  }
6133
- function makeTestCaseForOperation(operation, isPhDocumentOfTypeFunctionName) {
6144
+ function makeTestCaseForOperation(operation, isPhDocumentOfTypeFunctionName, overrideInputFields = []) {
6134
6145
  if (operation.name === null) throw new Error(`Operation is missing name.`);
6135
6146
  const camelCaseActionName = camelCase(operation.name);
6136
6147
  const pascalCaseActionName = pascalCase(operation.name);
@@ -6141,7 +6152,7 @@ function makeTestCaseForOperation(operation, isPhDocumentOfTypeFunctionName) {
6141
6152
  it('should handle ${camelCaseActionName} operation', () => {
6142
6153
  const document = utils.createDocument();
6143
6154
  const input = generateMock(
6144
- ${actionInputSchemaName}(),
6155
+ ${actionInputSchemaName}(),${overrideInputFields.length > 0 ? `\n { ${overrideInputFields.map(({ name, literal }) => `${name}: ${literal}`).join(", ")} },` : ""}
6145
6156
  );
6146
6157
 
6147
6158
  const updatedDocument = reducer(
@@ -6187,7 +6198,7 @@ const documentModelOperationsModuleTestFileTemplate = (v) => ts$1`
6187
6198
  */
6188
6199
 
6189
6200
  import { describe, it, expect } from 'vitest';
6190
- import { generateMock } from '@powerhousedao/common';
6201
+ import { generateMock } from 'document-model';
6191
6202
  import {
6192
6203
  reducer,
6193
6204
  utils,
@@ -6549,9 +6560,9 @@ type Query {
6549
6560
  //#endregion
6550
6561
  //#region src/templates/subgraphs/custom-resolvers.ts
6551
6562
  const customSubgraphResolversTemplate = (v) => ts$1`
6552
- import { type ISubgraph } from "${REACTOR_API_PACKAGE}";
6563
+ import { type BaseSubgraph } from "${REACTOR_API_PACKAGE}";
6553
6564
 
6554
- export const getResolvers = (subgraph: ISubgraph): Record<string, unknown> => {
6565
+ export const getResolvers = (subgraph: BaseSubgraph): Record<string, unknown> => {
6555
6566
  const reactor = subgraph.reactorClient;
6556
6567
 
6557
6568
  return ({
@@ -6625,26 +6636,31 @@ function getDocumentTypeMetadata({ project, documentModelId }) {
6625
6636
  }
6626
6637
  //#endregion
6627
6638
  //#region src/utils/format-with-prettier.ts
6628
- /** Formats the text of a ts-morph source file with prettier before writing the text to memory */
6639
+ const FORMAT_OPTIONS = { printWidth: 80 };
6640
+ /** Formats the text of a ts-morph source file with oxfmt before writing the text to memory */
6629
6641
  async function formatSourceFileWithPrettier(sourceFile) {
6630
6642
  sourceFile.organizeImports();
6631
6643
  const formattedText = await formatSafe(sourceFile.getFullText());
6632
6644
  sourceFile.replaceWithText(formattedText);
6633
6645
  }
6646
+ const EXT_MAP = {
6647
+ typescript: ".ts",
6648
+ json: ".json",
6649
+ html: ".html",
6650
+ css: ".css",
6651
+ babel: ".js",
6652
+ markdown: ".md"
6653
+ };
6634
6654
  async function formatSafe(sourceText, parser = "typescript") {
6635
6655
  try {
6636
- return await format(sourceText, { parser });
6656
+ return (await format(`file${EXT_MAP[parser] ?? ".ts"}`, sourceText, FORMAT_OPTIONS)).code;
6637
6657
  } catch (error) {
6638
6658
  console.error(error);
6639
6659
  return sourceText;
6640
6660
  }
6641
6661
  }
6642
- async function runPrettier() {
6643
- await spawnAsync("npx", [
6644
- "prettier",
6645
- "--write",
6646
- "."
6647
- ]);
6662
+ async function runOxfmt() {
6663
+ await spawnAsync("npx", ["oxfmt", "."]);
6648
6664
  }
6649
6665
  //#endregion
6650
6666
  //#region src/utils/get-editor-metadata.ts
@@ -6736,6 +6752,9 @@ function getPreviousVersionSourceFile(args) {
6736
6752
  const previousVersion = version - 1;
6737
6753
  if (previousVersion < 1) return;
6738
6754
  const previousVersionFilePath = filePath.replace(`/v${version}/`, `/v${previousVersion}/`);
6755
+ try {
6756
+ project.addSourceFileAtPath(previousVersionFilePath);
6757
+ } catch {}
6739
6758
  return project.getSourceFile(previousVersionFilePath);
6740
6759
  }
6741
6760
  //#endregion
@@ -6865,8 +6884,10 @@ function getDefaultProjectOptions(tsConfigFilePath) {
6865
6884
  /** Instantiates a ts-morph Project using the default typescript config and nearest tsconfig.json file */
6866
6885
  function buildTsMorphProject(projectDir) {
6867
6886
  process.chdir(projectDir);
6887
+ const tsConfigFilePath = path.join(projectDir, "tsconfig.json");
6868
6888
  return new Project({
6869
- tsConfigFilePath: path.join(projectDir, "tsconfig.json"),
6889
+ ...DEFAULT_PROJECT_OPTIONS,
6890
+ tsConfigFilePath,
6870
6891
  skipFileDependencyResolution: true
6871
6892
  });
6872
6893
  }
@@ -6993,6 +7014,7 @@ async function makeEditorModuleFile({ project, editorDirPath, editorName, docume
6993
7014
  }
6994
7015
  async function makeEditorsFile(args) {
6995
7016
  const { project, editorsDirPath } = args;
7017
+ project.addSourceFilesAtPaths(path.join(editorsDirPath, "**", "module.ts"));
6996
7018
  const sourceFile = project.createSourceFile(path.join(editorsDirPath, "editors.ts"), editorsTemplate, { overwrite: true });
6997
7019
  const editorsArray = sourceFile.getVariableDeclarationOrThrow("editors").getFirstDescendantByKindOrThrow(SyntaxKind.ArrayLiteralExpression);
6998
7020
  pipe(project.getDirectoryOrThrow(editorsDirPath).getDescendantSourceFiles(), filter((sourceFile) => sourceFile.getBaseName() === "module.ts"), uniqueBy((sourceFile) => sourceFile.getFilePath()), map((sourceFile) => getVariableDeclarationByTypeName(sourceFile, "EditorModule")), filter(isTruthy), map((variableDeclaration) => ({
@@ -7013,6 +7035,7 @@ async function makeEditorsFile(args) {
7013
7035
  }
7014
7036
  async function makeEditorsIndexFile(args) {
7015
7037
  const { project, editorsDirPath } = args;
7038
+ project.addSourceFilesAtPaths(path.join(editorsDirPath, "**", "module.ts"));
7016
7039
  const sourceFile = project.createSourceFile(path.join(editorsDirPath, "index.ts"), "", { overwrite: true });
7017
7040
  pipe(project.getDirectoryOrThrow(editorsDirPath).getDescendantSourceFiles(), filter((sourceFile) => sourceFile.getBaseName() === "module.ts"), uniqueBy((sourceFile) => sourceFile.getFilePath()), map((sourceFile) => getVariableDeclarationByTypeName(sourceFile, "EditorModule")), filter(isTruthy), map((variableDeclaration) => ({
7018
7041
  name: variableDeclaration.getName(),
@@ -7186,8 +7209,10 @@ async function writeGeneratedProjectRootFiles(projectDir) {
7186
7209
  await writeFileEnsuringDir(join(projectDir, "tsconfig.json"), await formatSafe(tsConfigTemplate, "json"));
7187
7210
  await writeFileEnsuringDir(join(projectDir, "index.html"), await formatSafe(indexHtmlTemplate, "html"));
7188
7211
  await writeFileEnsuringDir(join(projectDir, "main.tsx"), await formatSafe(mainTsxTemplate));
7189
- await writeFileEnsuringDir(join(projectDir, "eslint.config.js"), await formatSafe(eslintConfigTemplate));
7212
+ await writeFileEnsuringDir(join(projectDir, ".oxlintrc.json"), await formatSafe(oxlintConfigTemplate, "json"));
7213
+ await writeFileEnsuringDir(join(projectDir, ".oxfmtrc.json"), await formatSafe(oxfmtConfigTemplate, "json"));
7190
7214
  await writeFileEnsuringDir(join(projectDir, "index.ts"), await formatSafe(indexTsTemplate));
7215
+ await writeFileEnsuringDir(join(projectDir, "reactor/index.ts"), await formatSafe(reactorTsTemplate));
7191
7216
  await writeFileEnsuringDir(join(projectDir, "style.css"), await formatSafe(styleTemplate, "css"));
7192
7217
  await writeFileEnsuringDir(join(projectDir, "vitest.config.ts"), await formatSafe(vitestConfigTemplate));
7193
7218
  }
@@ -7392,6 +7417,24 @@ async function makeEditorComponent(args) {
7392
7417
  }
7393
7418
  //#endregion
7394
7419
  //#region src/codegen/graphql.ts
7420
+ function makePluginLoader() {
7421
+ const selfPath = fileURLToPath(import.meta.url);
7422
+ let selfReal = selfPath;
7423
+ try {
7424
+ selfReal = realpathSync(selfPath);
7425
+ } catch {}
7426
+ const requirers = [createRequire(selfPath), createRequire(selfReal)];
7427
+ return async (name) => {
7428
+ let lastErr;
7429
+ for (const requireFrom of requirers) try {
7430
+ return await import(pathToFileURL(requireFrom.resolve(name)).href);
7431
+ } catch (err) {
7432
+ lastErr = err;
7433
+ }
7434
+ throw lastErr;
7435
+ };
7436
+ }
7437
+ const pluginLoader = makePluginLoader();
7395
7438
  const scalars = {
7396
7439
  Unknown: "unknown",
7397
7440
  DateTime: "string",
@@ -7406,6 +7449,63 @@ const scalarsValidation = {
7406
7449
  AttachmentRef: "z.custom<`attachment://v${number}:${string}`>((val) => /^attachment:\\/\\/v\\d+:.+$/.test(val as string))",
7407
7450
  ...validationSchema
7408
7451
  };
7452
+ const DATE_LIKE_SCALARS = new Set(["Date", "DateTime"]);
7453
+ const SCALAR_MOCK_OVERRIDES = {
7454
+ Date: `"2024-01-01T00:00:00.000Z"`,
7455
+ DateTime: `"2024-01-01T00:00:00.000Z"`,
7456
+ URL: `"https://example.com"`
7457
+ };
7458
+ function unwrapNamedTypeName(type) {
7459
+ if (type.kind === Kind.NAMED_TYPE) return type.name.value;
7460
+ if (type.kind === Kind.NON_NULL_TYPE || type.kind === Kind.LIST_TYPE) return unwrapNamedTypeName(type.type);
7461
+ return null;
7462
+ }
7463
+ function getDateLikeFieldNames(stateSchemaSDL) {
7464
+ const names = /* @__PURE__ */ new Set();
7465
+ if (!stateSchemaSDL) return names;
7466
+ let doc;
7467
+ try {
7468
+ doc = parse(stateSchemaSDL);
7469
+ } catch {
7470
+ return names;
7471
+ }
7472
+ for (const def of doc.definitions) {
7473
+ if (def.kind !== Kind.OBJECT_TYPE_DEFINITION) continue;
7474
+ for (const field of def.fields ?? []) if (DATE_LIKE_SCALARS.has(unwrapNamedTypeName(field.type) ?? "")) names.add(field.name.value);
7475
+ }
7476
+ return names;
7477
+ }
7478
+ function getMockOverrideFieldNames(stateSchemaSDL) {
7479
+ const overrides = /* @__PURE__ */ new Map();
7480
+ if (!stateSchemaSDL) return overrides;
7481
+ let doc;
7482
+ try {
7483
+ doc = parse(stateSchemaSDL);
7484
+ } catch {
7485
+ return overrides;
7486
+ }
7487
+ for (const def of doc.definitions) {
7488
+ if (def.kind !== Kind.OBJECT_TYPE_DEFINITION) continue;
7489
+ for (const field of def.fields ?? []) {
7490
+ const literal = SCALAR_MOCK_OVERRIDES[unwrapNamedTypeName(field.type) ?? ""];
7491
+ if (literal) overrides.set(field.name.value, literal);
7492
+ }
7493
+ }
7494
+ return overrides;
7495
+ }
7496
+ function getInputFieldNames(operationSDL, preferredInputTypeName) {
7497
+ if (!operationSDL) return [];
7498
+ let doc;
7499
+ try {
7500
+ doc = parse(operationSDL);
7501
+ } catch {
7502
+ return [];
7503
+ }
7504
+ const inputDefs = doc.definitions.filter((d) => d.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION);
7505
+ const inputDef = preferredInputTypeName && inputDefs.find((d) => d.name.value === preferredInputTypeName) || inputDefs[0];
7506
+ if (!inputDef || inputDef.kind !== Kind.INPUT_OBJECT_TYPE_DEFINITION) return [];
7507
+ return (inputDef.fields ?? []).map((f) => f.name.value);
7508
+ }
7409
7509
  const avoidOptionals = {
7410
7510
  field: true,
7411
7511
  inputValue: false
@@ -7452,15 +7552,16 @@ function buildGraphqlDocumentStringForSpecification(specification) {
7452
7552
  ...moduleSchemas
7453
7553
  ];
7454
7554
  }
7455
- async function formatContentWithPrettier(path, content) {
7456
- return await format(content, { parser: "typescript" });
7555
+ async function formatContent(path, content) {
7556
+ return (await format(path, content, { printWidth: 80 })).code;
7457
7557
  }
7458
7558
  async function generateTypesAndZodSchemasFromGraphql(args) {
7459
7559
  const { schemaDirPath, schema } = args;
7460
7560
  await generate({
7461
7561
  overwrite: true,
7462
7562
  watch: false,
7463
- hooks: { beforeOneFileWrite: formatContentWithPrettier },
7563
+ pluginLoader,
7564
+ hooks: { beforeOneFileWrite: formatContent },
7464
7565
  generates: {
7465
7566
  [`${schemaDirPath}/types.ts`]: {
7466
7567
  schema,
@@ -7686,7 +7787,7 @@ async function makeReducerOperationHandlersForModules(fileMakerArgs) {
7686
7787
  module
7687
7788
  });
7688
7789
  }
7689
- async function makeReducerOperationHandlerForModule({ project, module, version, srcDirPath, versionImportPath, pascalCaseDocumentType, camelCaseDocumentType }) {
7790
+ async function makeReducerOperationHandlerForModule({ project, module, version, srcDirPath, genDirPath, versionImportPath, pascalCaseDocumentType, camelCaseDocumentType }) {
7690
7791
  const kebabCaseModuleName = kebabCase(module.name);
7691
7792
  const pascalCaseModuleName = pascalCase(module.name);
7692
7793
  const filePath = path.join(srcDirPath, "reducers", `${kebabCaseModuleName}.ts`);
@@ -7703,11 +7804,13 @@ async function makeReducerOperationHandlerForModule({ project, module, version,
7703
7804
  const operationsInterfaceVariableName = `${camelCaseDocumentType}${pascalCaseModuleName}Operations`;
7704
7805
  const existingOperationsInterfaceTypeImport = sourceFile.getImportDeclaration((importDeclaration) => !!importDeclaration.getNamedImports().find((importSpecifier) => importSpecifier.getName() === operationsInterfaceTypeName));
7705
7806
  if (existingOperationsInterfaceTypeImport) existingOperationsInterfaceTypeImport.remove();
7706
- const operationsInterfaceTypeProperties = sourceFile.addImportDeclaration({
7807
+ sourceFile.addImportDeclaration({
7707
7808
  namedImports: [operationsInterfaceTypeName],
7708
7809
  moduleSpecifier: versionImportPath,
7709
7810
  isTypeOnly: true
7710
- }).getNamedImports().find((value) => value.getName() === operationsInterfaceTypeName)?.getNameNode().getType().getProperties().map((symbol) => symbol.getName());
7811
+ });
7812
+ const operationsInterface = project.getSourceFile(path.join(genDirPath, kebabCaseModuleName, "operations.ts"))?.getInterface(operationsInterfaceTypeName);
7813
+ const operationsInterfaceTypeProperties = operationsInterface ? [...operationsInterface.getProperties(), ...operationsInterface.getMethods()].map((member) => member.getName()) : void 0;
7711
7814
  if (!operationsInterfaceTypeProperties) throw new Error("Failed to create operation handler object");
7712
7815
  let operationsInterfaceVariableStatement = sourceFile.getVariableStatement(operationsInterfaceVariableName);
7713
7816
  if (!operationsInterfaceVariableStatement) operationsInterfaceVariableStatement = sourceFile.addVariableStatement({
@@ -7790,7 +7893,11 @@ async function makeDocumentModelModulesOperationTestFiles(fileMakerArgs) {
7790
7893
  });
7791
7894
  }
7792
7895
  async function makeOperationModuleTestFile(args) {
7793
- const { project, module, version, versionImportPath, testsDirPath, isPhDocumentOfTypeFunctionName } = args;
7896
+ const { project, module, specification, version, versionImportPath, testsDirPath, isPhDocumentOfTypeFunctionName } = args;
7897
+ const overrideFieldsByScope = {
7898
+ global: getMockOverrideFieldNames(specification.state.global.schema),
7899
+ local: getMockOverrideFieldNames(specification.state.local.schema)
7900
+ };
7794
7901
  const kebabCaseModuleName = kebabCase(module.name);
7795
7902
  const moduleOperationsTypeName = `${pascalCase(module.name)}Operations`;
7796
7903
  const filePath = path.join(testsDirPath, `${kebabCaseModuleName}.test.ts`);
@@ -7852,7 +7959,13 @@ async function makeOperationModuleTestFile(args) {
7852
7959
  const testCasesToAdd = pipe(module.operations, filter((o) => {
7853
7960
  const expectedTestCaseName = `should handle ${camelCase(o.name ?? "")} operation`;
7854
7961
  return !testCaseNames.some((name) => name === expectedTestCaseName);
7855
- }), map((o) => makeTestCaseForOperation(o, isPhDocumentOfTypeFunctionName)));
7962
+ }), map((o) => {
7963
+ const overrideStateFields = o.scope === "local" ? overrideFieldsByScope.local : overrideFieldsByScope.global;
7964
+ return makeTestCaseForOperation(o, isPhDocumentOfTypeFunctionName, getInputFieldNames(o.schema, `${pascalCase(o.name ?? "")}Input`).filter((f) => overrideStateFields.has(f)).map((f) => ({
7965
+ name: f,
7966
+ literal: overrideStateFields.get(f)
7967
+ })));
7968
+ }));
7856
7969
  describeCallBody.addStatements(testCasesToAdd);
7857
7970
  const GENERATE_MOCK_NAME = "generateMock";
7858
7971
  const GENERATE_MOCK_MODULE_SPECIFIER = "document-model";
@@ -8086,6 +8199,7 @@ async function tsMorphGenerateDocumentModel(documentModelState, project) {
8086
8199
  documentModelDirPath,
8087
8200
  latestVersion
8088
8201
  });
8202
+ project.addSourceFilesAtPaths([join$1(documentModelsDirPath, "**", "module.ts"), join$1(documentModelsDirPath, "**", "upgrade-manifest.ts")]);
8089
8203
  await makeDocumentModelsFile({
8090
8204
  project,
8091
8205
  documentModelsDirPath
@@ -8415,6 +8529,7 @@ async function tsMorphGenerateProcessor(args) {
8415
8529
  const processorsDirPath = processorsDir.getPath();
8416
8530
  const dirPath = path.join(processorsDirPath, kebabCaseName);
8417
8531
  await ensureDirectoriesExist(project, processorsDirPath, dirPath);
8532
+ project.addSourceFilesAtPaths(path.join(dirPath, "*.ts"));
8418
8533
  if (isCustomizedProcessorDir(project.getDirectory(dirPath))) {
8419
8534
  const relativePath = path.relative(projectDir, path.join(dirPath, "index.ts"));
8420
8535
  console.warn(`[codegen] Skipping processor scaffold for "${kebabCaseName}": legacy layout detected "${relativePath}"`);
@@ -8529,6 +8644,7 @@ async function makeCustomSubgraphFiles(project, dirPath, v) {
8529
8644
  }
8530
8645
  async function makeSubgraphsIndexFile(args) {
8531
8646
  const { project, subgraphsDir } = args;
8647
+ project.addSourceFilesAtPaths(path.join(subgraphsDir, "**", "index.ts"));
8532
8648
  const { sourceFile } = getOrCreateSourceFile(project, path.join(subgraphsDir, "index.ts"));
8533
8649
  const existingExportNames = pipe(sourceFile.getExportDeclarations(), map((exportDeclaration) => exportDeclaration.getNamespaceExport()?.getName()), filter(isTruthy));
8534
8650
  const exportDeclarations = pipe(project.getDirectoryOrThrow(subgraphsDir).getDescendantSourceFiles(), filter((sourceFile) => sourceFile.getBaseName() === "index.ts"), uniqueBy((sourceFile) => sourceFile.getFilePath()), map((sourceFile) => sourceFile.getClasses().find((c) => c.getBaseClass()?.getText().includes("BaseSubgraph"))), filter(isTruthy), map((classDeclaration) => ({
@@ -8542,6 +8658,6 @@ async function makeSubgraphsIndexFile(args) {
8542
8658
  await formatSourceFileWithPrettier(sourceFile);
8543
8659
  }
8544
8660
  //#endregion
8545
- export { buildStringLiteral as $, cursorMcpTemplate as $n, getModuleExportType as $t, writeModuleFiles as A, pnpmWorkspaceTemplate as An, analyticsFactoryTemplate as At, buildTsMorphProject as B, gitIgnoreTemplate as Bn, documentModelSrcIndexFileTemplate as Bt, writeAllGeneratedProjectFiles as C, subgraphsIndexTemplate as Cn, relationalDbIndexTemplate as Ct, writeGeneratedProcessorsFiles as D, buildPowerhouseConfigTemplate as Dn, factoryBuildersTemplate as Dt, writeGeneratedEditorsFiles as E, ManifestTemplate as En, processorsFactoryTemplate as Et, makeEditorsIndexFile as F, mainTsxTemplate as Fn, makeOperationImportNames as Ft, getObjectLiteral as G, editorsTemplate as Gn, documentModelGenTypesTemplate as Gt, getAllImportModuleSpecifiers as H, geminiSettingsTemplate as Hn, documentModelIndexTemplate as Ht, validateDocumentModelState as I, licenseTemplate as In, makeOperationsImports as It, getStringArrayPropertyElements as J, documentModelsTemplate as Jn, documentModelPhFactoriesFileTemplate as Jt, getObjectProperty as K, upgradeManifestsTemplate as Kn, documentModelSchemaIndexTemplate as Kt, updateVersionedImports as L, indexTsTemplate as Ln, makeTestCaseForOperation as Lt, tsMorphGenerateApp as M, packageJsonTemplate as Mn, upgradeTransitionTemplate as Mt, makeEditorModuleFile as N, npmrcTemplate as Nn, upgradeManifestTemplate as Nt, writeGeneratedProjectRootFiles as O, packageJsonExportsTemplate as On, analyticsProcessorTemplate as Ot, makeEditorsFile as P, mcpTemplate as Pn, documentModelOperationsModuleTestFileTemplate as Pt, buildObjectLiteral as Q, connectEntrypointTemplate as Qn, documentModelOperationModuleActionsFileTemplate as Qt, getInitialStates as R, legacyIndexHtmlTemplate as Rn, documentModelTestFileTemplate as Rt, writeAiConfigFiles as S, tsconfigPathsTemplate as Sn, relationalDbMigrationsTemplate as St, writeGeneratedDocumentModelsFiles as T, readmeTemplate as Tn, processorsIndexTemplate as Tt, getAllImportNames as U, eslintConfigTemplate as Un, documentModelHooksFileTemplate as Ut, getDefaultProjectOptions as V, syncAndPublishWorkflowTemplate as Vn, documentModelModuleFileTemplate as Vt, getBooleanPropertyValue as W, editorsIndexTemplate as Wn, documentModelGenUtilsTemplate as Wt, getVariableDeclarationByTypeName as X, nginxConfTemplate as Xn, documentModelOperationsModuleErrorFileTemplate as Xt, getStringPropertyValue as Y, switchboardEntrypointTemplate as Yn, documentModelOperationsModuleOperationsFileTemplate as Yt, loadDocumentModelInDir as Z, dockerfileTemplate as Zn, documentModelOperationsModuleCreatorsFileTemplate as Zt, getCommandsHelpInfo as _, documentEditorModuleFileTemplate as _n, customSubgraphSchemaTemplate as _t, getOrCreateManifestFile as a, getLatestDocumentModelSpecVersionNumber as an, folderTreeFileTemplate as ar, getProcessorMetadata as at, buildBoilerplatePackageJson as b, vitestConfigTemplate as bn, relationalDbSchemaTemplate as bt, operationHasEmptyInput as c, getActionType as cn, emptyStateFileTemplate as cr, formatSafe as ct, generateDocumentModelZodSchemas as d, documentModelDocumentTypeTemplate as dn, createDocumentFileTemplate as dr, getDocumentTypeMetadata as dt, getDocumentModelDirName as en, claudeSettingsLocalTemplate as er, ensureDirectoriesExist as et, generateTypesAndZodSchemasFromGraphql as f, documentModelDocumentSchemaFileTemplate as fn, documentModelDocumentTypeMetadata as ft, getCommandHelpInfo as g, documentModelRootActionsFileTemplate as gn, customSubgraphResolversTemplate as gt, tsMorphGenerateDocumentEditor as h, documentModelGenActionsFileTemplate as hn, parseConfig as ht, createOrUpdateManifest as i, getLatestDocumentModelSpec as in, driveExplorerNavigationBreadcrumbsFileTemplate as ir, getSubgraphMetadata as it, writeProjectRootFiles as j, exportsTemplate as jn, documentModelUtilsTemplate as jt, writeGeneratedSubgraphsFiles as k, packageJsonScriptsTemplate as kn, analyticsIndexTemplate as kt, operationHasInput as l, getActionTypeName as ln, driveExplorerFileTemplate as lr, formatSourceFileWithPrettier as lt, scalarsValidation as m, documentModelGenControllerFileTemplate as mn, parseArgs as mt, tsMorphGenerateSubgraph as n, getDocumentModelVariableNames as nn, appEditorFileTemplate as nr, getOrCreateSourceFile as nt, pruneManifestSection as o, getActionInputName as on, appFoldersFileTemplate as or, getAppMetadata as ot, scalars as p, documentModelGenCreatorsFileTemplate as pn, configSpec as pt, getProperyAssignmentByName as q, documentModelsIndexTemplate as qn, documentModelGenReducerFileTemplate as qt, tsMorphGenerateProcessor as r, getEditorVariableNames as rn, appConfigFileTemplate as rr, getPreviousVersionSourceFile as rt, makeModulesIndexFile as s, getActionInputTypeNames as sn, appFilesFileTemplate as sr, getEditorMetadata as st, makeSubgraphsIndexFile as t, getDocumentModelSpecByVersionNumber as tn, agentsTemplate as tr, getOrCreateDirectory as tt, tsMorphGenerateDocumentModel as u, documentModelGenIndexFileTemplate as un, appDriveContentsFileTemplate as ur, runPrettier as ut, makeCliDocsFromHelp as v, documentEditorEditorFileTemplate as vn, subgraphLibFileTemplate as vt, writeCIFiles as w, styleTemplate as wn, relationalDbFactoryTemplate as wt, applyProjectCustomizations as x, tsConfigTemplate as xn, relationalDbProcessorTemplate as xt, writeCliDocsMarkdownFile as y, docsFromCliHelpTemplate as yn, subgraphIndexFileTemplate as yt, DEFAULT_PROJECT_OPTIONS as z, indexHtmlTemplate as zn, documentModelSrcUtilsTemplate as zt };
8661
+ export { getVariableDeclarationByTypeName as $, documentModelsTemplate as $n, documentModelOperationsModuleErrorFileTemplate as $t, writeGeneratedProcessorsFiles as A, buildPowerhouseConfigTemplate as An, factoryBuildersTemplate as At, updateVersionedImports as B, reactorTsTemplate as Bn, makeTestCaseForOperation as Bt, buildBoilerplatePackageJson as C, vitestConfigTemplate as Cn, relationalDbSchemaTemplate as Ct, writeCIFiles as D, styleTemplate as Dn, relationalDbFactoryTemplate as Dt, writeAllGeneratedProjectFiles as E, subgraphsIndexTemplate as En, relationalDbIndexTemplate as Et, tsMorphGenerateApp as F, packageJsonTemplate as Fn, upgradeTransitionTemplate as Ft, getAllImportModuleSpecifiers as G, syncAndPublishWorkflowTemplate as Gn, documentModelIndexTemplate as Gt, DEFAULT_PROJECT_OPTIONS as H, legacyIndexHtmlTemplate as Hn, documentModelSrcUtilsTemplate as Ht, makeEditorModuleFile as I, npmrcTemplate as In, upgradeManifestTemplate as It, getObjectLiteral as J, oxlintConfigTemplate as Jn, documentModelGenTypesTemplate as Jt, getAllImportNames as K, geminiSettingsTemplate as Kn, documentModelHooksFileTemplate as Kt, makeEditorsFile as L, mcpTemplate as Ln, documentModelOperationsModuleTestFileTemplate as Lt, writeGeneratedSubgraphsFiles as M, packageJsonScriptsTemplate as Mn, analyticsIndexTemplate as Mt, writeModuleFiles as N, pnpmWorkspaceTemplate as Nn, analyticsFactoryTemplate as Nt, writeGeneratedDocumentModelsFiles as O, readmeTemplate as On, processorsIndexTemplate as Ot, writeProjectRootFiles as P, exportsTemplate as Pn, documentModelUtilsTemplate as Pt, getStringPropertyValue as Q, documentModelsIndexTemplate as Qn, documentModelOperationsModuleOperationsFileTemplate as Qt, makeEditorsIndexFile as R, mainTsxTemplate as Rn, makeOperationImportNames as Rt, writeCliDocsMarkdownFile as S, docsFromCliHelpTemplate as Sn, subgraphIndexFileTemplate as St, writeAiConfigFiles as T, tsconfigPathsTemplate as Tn, relationalDbMigrationsTemplate as Tt, buildTsMorphProject as U, indexHtmlTemplate as Un, documentModelSrcIndexFileTemplate as Ut, getInitialStates as V, indexTsTemplate as Vn, documentModelTestFileTemplate as Vt, getDefaultProjectOptions as W, gitIgnoreTemplate as Wn, documentModelModuleFileTemplate as Wt, getProperyAssignmentByName as X, editorsTemplate as Xn, documentModelGenReducerFileTemplate as Xt, getObjectProperty as Y, editorsIndexTemplate as Yn, documentModelSchemaIndexTemplate as Yt, getStringArrayPropertyElements as Z, upgradeManifestsTemplate as Zn, documentModelPhFactoriesFileTemplate as Zt, scalarsValidation as _, documentModelGenControllerFileTemplate as _n, parseArgs as _t, getOrCreateManifestFile as a, getDocumentModelVariableNames as an, claudeSettingsLocalTemplate as ar, getOrCreateSourceFile as at, getCommandsHelpInfo as b, documentEditorModuleFileTemplate as bn, customSubgraphSchemaTemplate as bt, operationHasEmptyInput as c, getLatestDocumentModelSpecVersionNumber as cn, appConfigFileTemplate as cr, getProcessorMetadata as ct, generateDocumentModelZodSchemas as d, getActionType as dn, appFoldersFileTemplate as dr, formatSafe as dt, documentModelOperationsModuleCreatorsFileTemplate as en, switchboardEntrypointTemplate as er, loadDocumentModelInDir as et, generateTypesAndZodSchemasFromGraphql as f, getActionTypeName as fn, appFilesFileTemplate as fr, formatSourceFileWithPrettier as ft, scalars as g, documentModelGenCreatorsFileTemplate as gn, createDocumentFileTemplate as gr, configSpec as gt, getMockOverrideFieldNames as h, documentModelDocumentSchemaFileTemplate as hn, appDriveContentsFileTemplate as hr, documentModelDocumentTypeMetadata as ht, createOrUpdateManifest as i, getDocumentModelSpecByVersionNumber as in, cursorMcpTemplate as ir, getOrCreateDirectory as it, writeGeneratedProjectRootFiles as j, packageJsonExportsTemplate as jn, analyticsProcessorTemplate as jt, writeGeneratedEditorsFiles as k, ManifestTemplate as kn, processorsFactoryTemplate as kt, operationHasInput as l, getActionInputName as ln, driveExplorerNavigationBreadcrumbsFileTemplate as lr, getAppMetadata as lt, getInputFieldNames as m, documentModelDocumentTypeTemplate as mn, driveExplorerFileTemplate as mr, getDocumentTypeMetadata as mt, tsMorphGenerateSubgraph as n, getModuleExportType as nn, dockerfileTemplate as nr, buildStringLiteral as nt, pruneManifestSection as o, getEditorVariableNames as on, agentsTemplate as or, getPreviousVersionSourceFile as ot, getDateLikeFieldNames as p, documentModelGenIndexFileTemplate as pn, emptyStateFileTemplate as pr, runOxfmt as pt, getBooleanPropertyValue as q, oxfmtConfigTemplate as qn, documentModelGenUtilsTemplate as qt, tsMorphGenerateProcessor as r, getDocumentModelDirName as rn, connectEntrypointTemplate as rr, ensureDirectoriesExist as rt, makeModulesIndexFile as s, getLatestDocumentModelSpec as sn, appEditorFileTemplate as sr, getSubgraphMetadata as st, makeSubgraphsIndexFile as t, documentModelOperationModuleActionsFileTemplate as tn, nginxConfTemplate as tr, buildObjectLiteral as tt, tsMorphGenerateDocumentModel as u, getActionInputTypeNames as un, folderTreeFileTemplate as ur, getEditorMetadata as ut, tsMorphGenerateDocumentEditor as v, documentModelGenActionsFileTemplate as vn, parseConfig as vt, applyProjectCustomizations as w, tsConfigTemplate as wn, relationalDbProcessorTemplate as wt, makeCliDocsFromHelp as x, documentEditorEditorFileTemplate as xn, subgraphLibFileTemplate as xt, getCommandHelpInfo as y, documentModelRootActionsFileTemplate as yn, customSubgraphResolversTemplate as yt, validateDocumentModelState as z, licenseTemplate as zn, makeOperationsImports as zt };
8546
8662
 
8547
- //# sourceMappingURL=file-builders-DYFnJF60.mjs.map
8663
+ //# sourceMappingURL=file-builders-Btk4MK1I.mjs.map