@powerhousedao/codegen 6.2.0-dev.3 → 6.2.0-dev.31
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/{file-builders-DYqyzzbb.mjs → file-builders-DuI7d4bA.mjs} +220 -204
- package/dist/file-builders-DuI7d4bA.mjs.map +1 -0
- package/dist/{index-DqWWfHAz.d.mts → index-DtbVU1fc.d.mts} +2 -3
- package/dist/index-DtbVU1fc.d.mts.map +1 -0
- package/dist/index.d.mts +3 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +733 -203
- package/dist/index.mjs.map +1 -1
- package/dist/src/file-builders/index.d.mts +2 -2
- package/dist/src/file-builders/index.mjs +2 -2
- package/dist/src/name-builders/index.d.mts +1 -1
- package/dist/src/name-builders/index.mjs +1 -1
- package/dist/src/templates/index.d.mts +9 -6
- package/dist/src/templates/index.d.mts.map +1 -1
- package/dist/src/templates/index.mjs +2 -2
- package/dist/src/utils/index.d.mts +5 -6
- package/dist/src/utils/index.d.mts.map +1 -1
- package/dist/src/utils/index.mjs +2 -2
- package/package.json +20 -5
- package/dist/file-builders-DYqyzzbb.mjs.map +0 -1
- package/dist/index-DqWWfHAz.d.mts.map +0 -1
|
@@ -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 "
|
|
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,8 @@ 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 { realpathSync } from "node:fs";
|
|
22
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
20
23
|
function isEOL(c) {
|
|
21
24
|
return c === 10 || c === 13;
|
|
22
25
|
}
|
|
@@ -1736,7 +1739,7 @@ var TemplateClass = class TemplateClass extends String {
|
|
|
1736
1739
|
}
|
|
1737
1740
|
const html = tag("html");
|
|
1738
1741
|
const css = tag("css");
|
|
1739
|
-
|
|
1742
|
+
tag("js");
|
|
1740
1743
|
const ts$1 = tag("ts");
|
|
1741
1744
|
tag("jsx");
|
|
1742
1745
|
const tsx = tag("tsx");
|
|
@@ -1800,7 +1803,7 @@ export function CreateDocument() {
|
|
|
1800
1803
|
return (
|
|
1801
1804
|
<div>
|
|
1802
1805
|
{/* Customize section title here */}
|
|
1803
|
-
<h3 className="mb-3 mt-4 text-sm font-bold text-
|
|
1806
|
+
<h3 className="mb-3 mt-4 text-sm font-bold text-muted-foreground">
|
|
1804
1807
|
Create document
|
|
1805
1808
|
</h3>
|
|
1806
1809
|
{/* Customize layout by changing flex-wrap, gap, or grid layout */}
|
|
@@ -1829,7 +1832,7 @@ function CreateDocumentButton({ documentModelModule }: Props) {
|
|
|
1829
1832
|
documentModelModule.documentModel.global.description;
|
|
1830
1833
|
return (
|
|
1831
1834
|
<button
|
|
1832
|
-
className="cursor-pointer rounded-md bg-
|
|
1835
|
+
className="cursor-pointer rounded-md bg-secondary py-2 px-3 hover:hover-effect"
|
|
1833
1836
|
title={documentModelName}
|
|
1834
1837
|
aria-description={documentModelDescription}
|
|
1835
1838
|
onClick={() => showCreateDocumentModal(documentType)}
|
|
@@ -1907,7 +1910,7 @@ export function EmptyState() {
|
|
|
1907
1910
|
if (hasNodes) return null;
|
|
1908
1911
|
|
|
1909
1912
|
return (
|
|
1910
|
-
<div className="py-12 text-center text-
|
|
1913
|
+
<div className="py-12 text-center text-muted-foreground">
|
|
1911
1914
|
<p className="text-lg">This folder is empty</p>
|
|
1912
1915
|
<p className="mt-2 text-sm">Create your first document or folder below</p>
|
|
1913
1916
|
</div>
|
|
@@ -1933,7 +1936,7 @@ export function Files() {
|
|
|
1933
1936
|
|
|
1934
1937
|
return (
|
|
1935
1938
|
<div>
|
|
1936
|
-
<h3 className="mb-2 text-sm font-semibold text-
|
|
1939
|
+
<h3 className="mb-2 text-sm font-semibold text-muted-foreground">Documents</h3>
|
|
1937
1940
|
<div className="flex flex-wrap gap-4">
|
|
1938
1941
|
{fileNodes.map((fileNode) => (
|
|
1939
1942
|
<FileItem key={fileNode.id} fileNode={fileNode} />
|
|
@@ -1962,7 +1965,7 @@ export function Folders() {
|
|
|
1962
1965
|
|
|
1963
1966
|
return (
|
|
1964
1967
|
<div>
|
|
1965
|
-
<h3 className="mb-2 text-sm font-bold text-
|
|
1968
|
+
<h3 className="mb-2 text-sm font-bold text-muted-foreground">Folders</h3>
|
|
1966
1969
|
<div className="flex flex-wrap gap-4">
|
|
1967
1970
|
{folderNodes.map((folderNode) => (
|
|
1968
1971
|
<FolderItem key={folderNode.id} folderNode={folderNode} />
|
|
@@ -2088,7 +2091,7 @@ import { Breadcrumbs } from "@powerhousedao/design-system/connect";
|
|
|
2088
2091
|
/** Shows the navigation breadcrumbs for the selected drive or folder */
|
|
2089
2092
|
export function NavigationBreadcrumbs() {
|
|
2090
2093
|
return (
|
|
2091
|
-
<div className="border-b border-
|
|
2094
|
+
<div className="border-b border-border pb-3 space-y-3">
|
|
2092
2095
|
<Breadcrumbs />
|
|
2093
2096
|
</div>
|
|
2094
2097
|
);
|
|
@@ -2122,7 +2125,7 @@ export default function Editor(props: EditorProps) {
|
|
|
2122
2125
|
// you can update these configs in \`./config.ts\`
|
|
2123
2126
|
useSetPHAppConfig(editorConfig);
|
|
2124
2127
|
return (
|
|
2125
|
-
<div className="bg-
|
|
2128
|
+
<div className="bg-background p-6">
|
|
2126
2129
|
<DriveExplorer {...props} />
|
|
2127
2130
|
</div>
|
|
2128
2131
|
);
|
|
@@ -2205,7 +2208,7 @@ If the \`reactor-mcp\` server is unavailable, ask the user to run \`ph vetra\` o
|
|
|
2205
2208
|
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
2209
|
|
|
2207
2210
|
- **TypeScript Check**: Run \`npm run tsc\` to validate type safety
|
|
2208
|
-
- **
|
|
2211
|
+
- **Lint Check**: Run \`npm run lint:fix\` to check for errors with oxlint (type-aware rules plus TypeScript type checking)
|
|
2209
2212
|
- **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
2213
|
|
|
2211
2214
|
#### Strategy: reaching 100% reducer coverage
|
|
@@ -2300,7 +2303,7 @@ The \`useSelectedTodoDocument\` (and every other document hook) is auto-generate
|
|
|
2300
2303
|
|
|
2301
2304
|
### Editor code conventions (TypeScript & module resolution)
|
|
2302
2305
|
|
|
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
|
|
2306
|
+
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
2307
|
|
|
2305
2308
|
#### Always use the top-level barrel for document-model imports
|
|
2306
2309
|
|
|
@@ -2348,7 +2351,7 @@ When a third-party CLI generates extensionless imports, do a bulk find-and-repla
|
|
|
2348
2351
|
|
|
2349
2352
|
#### Stringifying \`unknown\` values
|
|
2350
2353
|
|
|
2351
|
-
The boilerplate
|
|
2354
|
+
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
2355
|
|
|
2353
2356
|
~~~typescript
|
|
2354
2357
|
function str(v: unknown): string {
|
|
@@ -2940,8 +2943,8 @@ RUN pnpm config set @jsr:registry https://npm.jsr.io
|
|
|
2940
2943
|
ARG TAG=latest
|
|
2941
2944
|
ARG PH_CONNECT_BASE_PATH="/"
|
|
2942
2945
|
|
|
2943
|
-
# Install ph-cmd, prisma, and
|
|
2944
|
-
RUN pnpm add -g ph-cmd@$TAG prisma@5.17.0
|
|
2946
|
+
# Install ph-cmd, prisma, and oxfmt globally
|
|
2947
|
+
RUN pnpm add -g ph-cmd@$TAG prisma@5.17.0 oxfmt
|
|
2945
2948
|
|
|
2946
2949
|
# Initialize project based on tag (dev/staging/latest)
|
|
2947
2950
|
RUN case "$TAG" in \\
|
|
@@ -3200,144 +3203,120 @@ const editorsIndexTemplate = `
|
|
|
3200
3203
|
*/
|
|
3201
3204
|
`;
|
|
3202
3205
|
//#endregion
|
|
3203
|
-
//#region src/templates/boilerplate/
|
|
3204
|
-
const
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
/**
|
|
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
|
-
},
|
|
3206
|
+
//#region src/templates/boilerplate/oxlintrc.json.ts
|
|
3207
|
+
const oxlintConfigTemplate = json`
|
|
3208
|
+
{
|
|
3209
|
+
"$schema": "https://raw.githubusercontent.com/oxc-project/oxc/main/npm/oxlint/configuration_schema.json",
|
|
3210
|
+
"plugins": ["typescript", "react", "react-hooks"],
|
|
3211
|
+
"categories": { "correctness": "error" },
|
|
3212
|
+
"ignorePatterns": [
|
|
3213
|
+
"**/node_modules/**",
|
|
3214
|
+
"**/dist/**",
|
|
3215
|
+
"**/.ph/**",
|
|
3216
|
+
"**/storybook-static/**",
|
|
3217
|
+
"**/.vite/**"
|
|
3266
3218
|
],
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3219
|
+
"rules": {
|
|
3220
|
+
"typescript/await-thenable": "error",
|
|
3221
|
+
"typescript/ban-ts-comment": "error",
|
|
3222
|
+
"typescript/no-array-constructor": "error",
|
|
3223
|
+
"typescript/no-array-delete": "error",
|
|
3224
|
+
"typescript/no-base-to-string": "error",
|
|
3225
|
+
"typescript/no-duplicate-enum-values": "error",
|
|
3226
|
+
"typescript/no-extra-non-null-assertion": "error",
|
|
3227
|
+
"typescript/no-for-in-array": "error",
|
|
3228
|
+
"typescript/no-implied-eval": "error",
|
|
3229
|
+
"typescript/no-misused-new": "error",
|
|
3230
|
+
"typescript/no-namespace": "error",
|
|
3231
|
+
"typescript/no-non-null-asserted-optional-chain": "error",
|
|
3232
|
+
"typescript/no-redundant-type-constituents": "error",
|
|
3233
|
+
"typescript/no-require-imports": "error",
|
|
3234
|
+
"typescript/no-this-alias": "error",
|
|
3235
|
+
"typescript/no-unnecessary-type-assertion": "error",
|
|
3236
|
+
"typescript/no-unnecessary-type-constraint": "error",
|
|
3237
|
+
"typescript/no-unsafe-argument": "error",
|
|
3238
|
+
"typescript/no-unsafe-assignment": "error",
|
|
3239
|
+
"typescript/no-unsafe-call": "error",
|
|
3240
|
+
"typescript/no-unsafe-declaration-merging": "error",
|
|
3241
|
+
"typescript/no-unsafe-enum-comparison": "error",
|
|
3242
|
+
"typescript/no-unsafe-function-type": "error",
|
|
3243
|
+
"typescript/no-unsafe-member-access": "error",
|
|
3244
|
+
"typescript/no-unsafe-return": "error",
|
|
3245
|
+
"typescript/no-unsafe-unary-minus": "error",
|
|
3246
|
+
"typescript/no-unused-expressions": "error",
|
|
3247
|
+
"typescript/no-wrapper-object-types": "error",
|
|
3248
|
+
"typescript/only-throw-error": "error",
|
|
3249
|
+
"typescript/prefer-as-const": "error",
|
|
3250
|
+
"typescript/prefer-namespace-keyword": "error",
|
|
3251
|
+
"typescript/prefer-promise-reject-errors": "error",
|
|
3252
|
+
"typescript/restrict-plus-operands": "error",
|
|
3253
|
+
"typescript/triple-slash-reference": "error",
|
|
3254
|
+
"typescript/unbound-method": "error",
|
|
3255
|
+
"typescript/consistent-type-imports": [
|
|
3256
|
+
"error",
|
|
3257
|
+
{
|
|
3258
|
+
"prefer": "type-imports",
|
|
3259
|
+
"disallowTypeAnnotations": true,
|
|
3260
|
+
"fixStyle": "separate-type-imports"
|
|
3261
|
+
}
|
|
3262
|
+
],
|
|
3263
|
+
"typescript/no-explicit-any": "off",
|
|
3264
|
+
"typescript/no-unused-vars": [
|
|
3265
|
+
"warn",
|
|
3266
|
+
{
|
|
3267
|
+
"argsIgnorePattern": "^_",
|
|
3268
|
+
"varsIgnorePattern": "^_",
|
|
3269
|
+
"caughtErrorsIgnorePattern": "^_"
|
|
3270
|
+
}
|
|
3271
|
+
],
|
|
3272
|
+
"typescript/no-unnecessary-condition": "warn",
|
|
3273
|
+
"typescript/require-await": "warn",
|
|
3274
|
+
"typescript/no-misused-promises": "warn",
|
|
3275
|
+
"typescript/no-floating-promises": "warn",
|
|
3276
|
+
"typescript/no-empty-object-type": "warn",
|
|
3277
|
+
"typescript/no-duplicate-type-constituents": "warn",
|
|
3278
|
+
"typescript/restrict-template-expressions": ["warn", { "allowNumber": true }],
|
|
3279
|
+
"react-hooks/rules-of-hooks": "error",
|
|
3280
|
+
"react-hooks/exhaustive-deps": "warn"
|
|
3299
3281
|
},
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
javascriptConfig,
|
|
3339
|
-
eslintPluginPrettierRecommended,
|
|
3340
|
-
);
|
|
3282
|
+
"overrides": [
|
|
3283
|
+
{
|
|
3284
|
+
"files": ["**/*.js", "**/*.cjs", "**/*.mjs"],
|
|
3285
|
+
"rules": {
|
|
3286
|
+
"typescript/await-thenable": "off",
|
|
3287
|
+
"typescript/no-array-delete": "off",
|
|
3288
|
+
"typescript/no-base-to-string": "off",
|
|
3289
|
+
"typescript/no-duplicate-type-constituents": "off",
|
|
3290
|
+
"typescript/no-floating-promises": "off",
|
|
3291
|
+
"typescript/no-for-in-array": "off",
|
|
3292
|
+
"typescript/no-implied-eval": "off",
|
|
3293
|
+
"typescript/no-misused-promises": "off",
|
|
3294
|
+
"typescript/no-redundant-type-constituents": "off",
|
|
3295
|
+
"typescript/no-unnecessary-condition": "off",
|
|
3296
|
+
"typescript/no-unnecessary-type-assertion": "off",
|
|
3297
|
+
"typescript/no-unsafe-argument": "off",
|
|
3298
|
+
"typescript/no-unsafe-assignment": "off",
|
|
3299
|
+
"typescript/no-unsafe-call": "off",
|
|
3300
|
+
"typescript/no-unsafe-enum-comparison": "off",
|
|
3301
|
+
"typescript/no-unsafe-member-access": "off",
|
|
3302
|
+
"typescript/no-unsafe-return": "off",
|
|
3303
|
+
"typescript/no-unsafe-unary-minus": "off",
|
|
3304
|
+
"typescript/only-throw-error": "off",
|
|
3305
|
+
"typescript/prefer-promise-reject-errors": "off",
|
|
3306
|
+
"typescript/require-await": "off",
|
|
3307
|
+
"typescript/restrict-plus-operands": "off",
|
|
3308
|
+
"typescript/restrict-template-expressions": "off",
|
|
3309
|
+
"typescript/unbound-method": "off"
|
|
3310
|
+
}
|
|
3311
|
+
}
|
|
3312
|
+
]
|
|
3313
|
+
}
|
|
3314
|
+
`.raw;
|
|
3315
|
+
const oxfmtConfigTemplate = json`
|
|
3316
|
+
{
|
|
3317
|
+
"$schema": "https://raw.githubusercontent.com/oxc-project/oxc/main/npm/oxfmt/configuration_schema.json",
|
|
3318
|
+
"printWidth": 80
|
|
3319
|
+
}
|
|
3341
3320
|
`.raw;
|
|
3342
3321
|
//#endregion
|
|
3343
3322
|
//#region src/templates/boilerplate/gemini/settings.json.ts
|
|
@@ -3733,7 +3712,6 @@ const gitIgnoreTemplate = `
|
|
|
3733
3712
|
dist
|
|
3734
3713
|
coverage
|
|
3735
3714
|
node_modules
|
|
3736
|
-
.eslintcache
|
|
3737
3715
|
.env.local
|
|
3738
3716
|
*.tsbuildinfo
|
|
3739
3717
|
|
|
@@ -4492,8 +4470,10 @@ const packageJsonTemplate = (projectName, peerDependencies, devDependencies) =>
|
|
|
4492
4470
|
"test": "vitest run",
|
|
4493
4471
|
"test:watch": "vitest",
|
|
4494
4472
|
"test:coverage": "vitest run --coverage",
|
|
4495
|
-
"lint": "
|
|
4496
|
-
"lint:fix": "
|
|
4473
|
+
"lint": "oxlint --type-aware --type-check",
|
|
4474
|
+
"lint:fix": "oxlint --type-aware --type-check --fix",
|
|
4475
|
+
"format": "oxfmt",
|
|
4476
|
+
"format:check": "oxfmt --check",
|
|
4497
4477
|
"tsc": "tsc",
|
|
4498
4478
|
"tsc:watch": "tsc --watch",
|
|
4499
4479
|
"check-circular-imports": "npx dpdm -T ./index.ts",
|
|
@@ -4521,8 +4501,10 @@ const packageJsonScriptsTemplate = {
|
|
|
4521
4501
|
build: "npm run tsc && npm run tailwind",
|
|
4522
4502
|
test: "vitest run",
|
|
4523
4503
|
"test:watch": "vitest",
|
|
4524
|
-
lint: "
|
|
4525
|
-
"lint:fix": "
|
|
4504
|
+
lint: "oxlint --type-aware --type-check",
|
|
4505
|
+
"lint:fix": "oxlint --type-aware --type-check --fix",
|
|
4506
|
+
format: "oxfmt",
|
|
4507
|
+
"format:check": "oxfmt --check",
|
|
4526
4508
|
tsc: "tsc",
|
|
4527
4509
|
"tsc:watch": "tsc --watch",
|
|
4528
4510
|
tailwind: "pnpm exec tailwindcss -i ./style.css -o ./dist/style.css",
|
|
@@ -4635,8 +4617,8 @@ This tutorial will guide you through the process of creating a new document mode
|
|
|
4635
4617
|
<summary>Available NPM commands</summary>
|
|
4636
4618
|
|
|
4637
4619
|
- \`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
|
|
4639
|
-
- \`format\`: Formats the code using
|
|
4620
|
+
- \`lint\`: Checks for errors with oxlint, including type-aware rules and TypeScript type checking.
|
|
4621
|
+
- \`format\`: Formats the code using oxfmt.
|
|
4640
4622
|
- \`build\`: Builds the library project using Vite.
|
|
4641
4623
|
- \`storybook\`: Starts Storybook in development mode.
|
|
4642
4624
|
- \`build-storybook\`: Builds Storybook.
|
|
@@ -4998,7 +4980,7 @@ export default function Editor() {
|
|
|
4998
4980
|
};
|
|
4999
4981
|
|
|
5000
4982
|
return (
|
|
5001
|
-
<div className="mx-auto max-w-4xl bg-
|
|
4983
|
+
<div className="mx-auto max-w-4xl bg-background p-6">
|
|
5002
4984
|
<DocumentToolbar />
|
|
5003
4985
|
|
|
5004
4986
|
{/* "ph-default-styles" sets default styles for basic UI elements */}
|
|
@@ -5387,10 +5369,9 @@ function getDocumentModelVariableNames(documentModelName) {
|
|
|
5387
5369
|
//#endregion
|
|
5388
5370
|
//#region src/templates/document-model/gen/modules/actions.ts
|
|
5389
5371
|
function getActionTypeExport(operation) {
|
|
5390
|
-
const baseActionTypeName = operationHasAttachment(operation) ? "ActionWithAttachment" : "Action";
|
|
5391
5372
|
const actionTypeName = getActionTypeName(operation);
|
|
5392
5373
|
const actionInputName = getActionInputName(operation) ?? `"{}"`;
|
|
5393
|
-
return ts$1`export type ${actionTypeName} =
|
|
5374
|
+
return ts$1`export type ${actionTypeName} = Action & { type: "${getActionType(operation)}"; input: ${actionInputName} };`.raw;
|
|
5394
5375
|
}
|
|
5395
5376
|
function getActionTypeExports(args) {
|
|
5396
5377
|
return args.module.operations.map(getActionTypeExport).join("\n");
|
|
@@ -5400,17 +5381,12 @@ function getModuleExportType(args) {
|
|
|
5400
5381
|
const actionTypeNames = module.operations.map(getActionTypeName).join(" |\n");
|
|
5401
5382
|
return ts$1`export type ${pascalCaseDocumentType}${pascalCase(module.name)}Action = ${actionTypeNames};`.raw;
|
|
5402
5383
|
}
|
|
5403
|
-
function getDocumentModelActionTypeImportNames(args) {
|
|
5404
|
-
const actionTypeImports = ["Action"];
|
|
5405
|
-
if (args.module.operations.some((a) => operationHasAttachment(a))) actionTypeImports.push("ActionWithAttachment");
|
|
5406
|
-
return actionTypeImports.join(",\n");
|
|
5407
|
-
}
|
|
5408
5384
|
const documentModelOperationModuleActionsFileTemplate = (v) => ts$1`
|
|
5409
5385
|
/**
|
|
5410
5386
|
* WARNING: DO NOT EDIT
|
|
5411
5387
|
* This file is auto-generated and updated by codegen
|
|
5412
5388
|
*/
|
|
5413
|
-
import type {
|
|
5389
|
+
import type { Action } from 'document-model';
|
|
5414
5390
|
import type {
|
|
5415
5391
|
${getActionInputTypeNames(v)}
|
|
5416
5392
|
} from '../types.js';
|
|
@@ -5421,11 +5397,6 @@ ${getModuleExportType(v)}
|
|
|
5421
5397
|
`.raw;
|
|
5422
5398
|
//#endregion
|
|
5423
5399
|
//#region src/templates/document-model/gen/modules/creators.ts
|
|
5424
|
-
function makeDocumentModelTypeImports(args) {
|
|
5425
|
-
const actionTypeImports = ["createAction"];
|
|
5426
|
-
if (args.module.operations.some((a) => operationHasAttachment(a))) actionTypeImports.push("AttachmentInput");
|
|
5427
|
-
return actionTypeImports.join(",\n");
|
|
5428
|
-
}
|
|
5429
5400
|
function makeActionInputSchemaName(action) {
|
|
5430
5401
|
if (!action.name || !action.schema) return;
|
|
5431
5402
|
return `${pascalCase(action.name)}InputSchema`;
|
|
@@ -5454,15 +5425,12 @@ function makeActionCreatorWithInput(operation) {
|
|
|
5454
5425
|
const actionTypeName = makeActionTypeName(operation);
|
|
5455
5426
|
const inputSchemaName = makeActionInputSchemaName(operation);
|
|
5456
5427
|
const inputTypeName = makeActionInputTypeName(operation);
|
|
5457
|
-
const hasAttachment = operationHasAttachment(operation);
|
|
5458
|
-
const argsArray = [operationHasEmptyInput(operation) ? `input: ${inputTypeName} = {}` : `input: ${inputTypeName}`];
|
|
5459
|
-
if (hasAttachment) argsArray.push(`attachments: AttachmentInput[]`);
|
|
5460
5428
|
return ts$1`
|
|
5461
|
-
export const ${camelCaseActionName} = (${
|
|
5429
|
+
export const ${camelCaseActionName} = (${operationHasEmptyInput(operation) ? `input: ${inputTypeName} = {}` : `input: ${inputTypeName}`}) =>
|
|
5462
5430
|
createAction<${actionTypeName}>(
|
|
5463
5431
|
"${constantCaseActionName}",
|
|
5464
5432
|
{...input},
|
|
5465
|
-
|
|
5433
|
+
undefined,
|
|
5466
5434
|
${inputSchemaName},
|
|
5467
5435
|
"${operation.scope}"
|
|
5468
5436
|
);`.raw;
|
|
@@ -5486,7 +5454,7 @@ const documentModelOperationsModuleCreatorsFileTemplate = (v) => ts$1`
|
|
|
5486
5454
|
* WARNING: DO NOT EDIT
|
|
5487
5455
|
* This file is auto-generated and updated by codegen
|
|
5488
5456
|
*/
|
|
5489
|
-
import {
|
|
5457
|
+
import { createAction } from "document-model";
|
|
5490
5458
|
import {
|
|
5491
5459
|
${makeActionInputSchemaImports(v)}
|
|
5492
5460
|
} from '../schema/zod.js';
|
|
@@ -5844,6 +5812,14 @@ export type {
|
|
|
5844
5812
|
`.raw;
|
|
5845
5813
|
//#endregion
|
|
5846
5814
|
//#region src/templates/document-model/gen/utils.ts
|
|
5815
|
+
function makeOlderReducerImports(versions, currentVersion) {
|
|
5816
|
+
return versions.filter((k) => k < currentVersion).map((k) => `import { reducer as reducerV${k} } from "../../v${k}/gen/reducer.js";`).join("\n");
|
|
5817
|
+
}
|
|
5818
|
+
function makeReducersObject(versions, currentVersion) {
|
|
5819
|
+
return `{ ${versions.filter((k) => k <= currentVersion).map((k) => {
|
|
5820
|
+
return `${k}: ${k === currentVersion ? "reducer" : `reducerV${k}`} as unknown as Reducer<PHBaseState>`;
|
|
5821
|
+
}).join(", ")} }`;
|
|
5822
|
+
}
|
|
5847
5823
|
const documentModelGenUtilsTemplate = (v) => ts$1`
|
|
5848
5824
|
/**
|
|
5849
5825
|
* WARNING: DO NOT EDIT
|
|
@@ -5851,14 +5827,17 @@ const documentModelGenUtilsTemplate = (v) => ts$1`
|
|
|
5851
5827
|
*/
|
|
5852
5828
|
import type {
|
|
5853
5829
|
DocumentModelUtils,
|
|
5830
|
+
PHBaseState,
|
|
5831
|
+
Reducer,
|
|
5854
5832
|
} from "document-model";
|
|
5855
5833
|
import {
|
|
5856
5834
|
baseCreateDocument,
|
|
5857
5835
|
baseSaveToFileHandle,
|
|
5858
|
-
|
|
5836
|
+
baseLoadFromInputVersioned,
|
|
5859
5837
|
defaultBaseState,
|
|
5860
5838
|
} from "document-model";
|
|
5861
5839
|
import { reducer } from './reducer.js';
|
|
5840
|
+
${makeOlderReducerImports(v.versions, v.version) ? makeOlderReducerImports(v.versions, v.version) + "\n" : ""}import { ${v.upgradeManifestName} } from "../../upgrades/upgrade-manifest.js";
|
|
5862
5841
|
import { ${v.documentTypeVariableName} } from "./document-type.js";
|
|
5863
5842
|
import {
|
|
5864
5843
|
${v.assertIsPhDocumentOfTypeFunctionName},
|
|
@@ -5887,7 +5866,10 @@ export const utils: DocumentModelUtils<${v.phStateName}> = {
|
|
|
5887
5866
|
return baseSaveToFileHandle(document, input);
|
|
5888
5867
|
},
|
|
5889
5868
|
loadFromInput(input) {
|
|
5890
|
-
return
|
|
5869
|
+
return baseLoadFromInputVersioned(input, {
|
|
5870
|
+
reducers: ${makeReducersObject(v.versions, v.version)},
|
|
5871
|
+
upgradeManifest: ${v.upgradeManifestName},
|
|
5872
|
+
});
|
|
5891
5873
|
},
|
|
5892
5874
|
isStateOfType(state) {
|
|
5893
5875
|
return ${v.isPhStateOfTypeFunctionName}(state);
|
|
@@ -6563,9 +6545,9 @@ type Query {
|
|
|
6563
6545
|
//#endregion
|
|
6564
6546
|
//#region src/templates/subgraphs/custom-resolvers.ts
|
|
6565
6547
|
const customSubgraphResolversTemplate = (v) => ts$1`
|
|
6566
|
-
import { type
|
|
6548
|
+
import { type BaseSubgraph } from "${REACTOR_API_PACKAGE}";
|
|
6567
6549
|
|
|
6568
|
-
export const getResolvers = (subgraph:
|
|
6550
|
+
export const getResolvers = (subgraph: BaseSubgraph): Record<string, unknown> => {
|
|
6569
6551
|
const reactor = subgraph.reactorClient;
|
|
6570
6552
|
|
|
6571
6553
|
return ({
|
|
@@ -6639,26 +6621,31 @@ function getDocumentTypeMetadata({ project, documentModelId }) {
|
|
|
6639
6621
|
}
|
|
6640
6622
|
//#endregion
|
|
6641
6623
|
//#region src/utils/format-with-prettier.ts
|
|
6642
|
-
|
|
6624
|
+
const FORMAT_OPTIONS = { printWidth: 80 };
|
|
6625
|
+
/** Formats the text of a ts-morph source file with oxfmt before writing the text to memory */
|
|
6643
6626
|
async function formatSourceFileWithPrettier(sourceFile) {
|
|
6644
6627
|
sourceFile.organizeImports();
|
|
6645
6628
|
const formattedText = await formatSafe(sourceFile.getFullText());
|
|
6646
6629
|
sourceFile.replaceWithText(formattedText);
|
|
6647
6630
|
}
|
|
6631
|
+
const EXT_MAP = {
|
|
6632
|
+
typescript: ".ts",
|
|
6633
|
+
json: ".json",
|
|
6634
|
+
html: ".html",
|
|
6635
|
+
css: ".css",
|
|
6636
|
+
babel: ".js",
|
|
6637
|
+
markdown: ".md"
|
|
6638
|
+
};
|
|
6648
6639
|
async function formatSafe(sourceText, parser = "typescript") {
|
|
6649
6640
|
try {
|
|
6650
|
-
return await format(
|
|
6641
|
+
return (await format(`file${EXT_MAP[parser] ?? ".ts"}`, sourceText, FORMAT_OPTIONS)).code;
|
|
6651
6642
|
} catch (error) {
|
|
6652
6643
|
console.error(error);
|
|
6653
6644
|
return sourceText;
|
|
6654
6645
|
}
|
|
6655
6646
|
}
|
|
6656
|
-
async function
|
|
6657
|
-
await spawnAsync("npx", [
|
|
6658
|
-
"prettier",
|
|
6659
|
-
"--write",
|
|
6660
|
-
"."
|
|
6661
|
-
]);
|
|
6647
|
+
async function runOxfmt() {
|
|
6648
|
+
await spawnAsync("npx", ["oxfmt", "."]);
|
|
6662
6649
|
}
|
|
6663
6650
|
//#endregion
|
|
6664
6651
|
//#region src/utils/get-editor-metadata.ts
|
|
@@ -6750,6 +6737,9 @@ function getPreviousVersionSourceFile(args) {
|
|
|
6750
6737
|
const previousVersion = version - 1;
|
|
6751
6738
|
if (previousVersion < 1) return;
|
|
6752
6739
|
const previousVersionFilePath = filePath.replace(`/v${version}/`, `/v${previousVersion}/`);
|
|
6740
|
+
try {
|
|
6741
|
+
project.addSourceFileAtPath(previousVersionFilePath);
|
|
6742
|
+
} catch {}
|
|
6753
6743
|
return project.getSourceFile(previousVersionFilePath);
|
|
6754
6744
|
}
|
|
6755
6745
|
//#endregion
|
|
@@ -6879,8 +6869,10 @@ function getDefaultProjectOptions(tsConfigFilePath) {
|
|
|
6879
6869
|
/** Instantiates a ts-morph Project using the default typescript config and nearest tsconfig.json file */
|
|
6880
6870
|
function buildTsMorphProject(projectDir) {
|
|
6881
6871
|
process.chdir(projectDir);
|
|
6872
|
+
const tsConfigFilePath = path.join(projectDir, "tsconfig.json");
|
|
6882
6873
|
return new Project({
|
|
6883
|
-
|
|
6874
|
+
...DEFAULT_PROJECT_OPTIONS,
|
|
6875
|
+
tsConfigFilePath,
|
|
6884
6876
|
skipFileDependencyResolution: true
|
|
6885
6877
|
});
|
|
6886
6878
|
}
|
|
@@ -7007,6 +6999,7 @@ async function makeEditorModuleFile({ project, editorDirPath, editorName, docume
|
|
|
7007
6999
|
}
|
|
7008
7000
|
async function makeEditorsFile(args) {
|
|
7009
7001
|
const { project, editorsDirPath } = args;
|
|
7002
|
+
project.addSourceFilesAtPaths(path.join(editorsDirPath, "**", "module.ts"));
|
|
7010
7003
|
const sourceFile = project.createSourceFile(path.join(editorsDirPath, "editors.ts"), editorsTemplate, { overwrite: true });
|
|
7011
7004
|
const editorsArray = sourceFile.getVariableDeclarationOrThrow("editors").getFirstDescendantByKindOrThrow(SyntaxKind.ArrayLiteralExpression);
|
|
7012
7005
|
pipe(project.getDirectoryOrThrow(editorsDirPath).getDescendantSourceFiles(), filter((sourceFile) => sourceFile.getBaseName() === "module.ts"), uniqueBy((sourceFile) => sourceFile.getFilePath()), map((sourceFile) => getVariableDeclarationByTypeName(sourceFile, "EditorModule")), filter(isTruthy), map((variableDeclaration) => ({
|
|
@@ -7027,6 +7020,7 @@ async function makeEditorsFile(args) {
|
|
|
7027
7020
|
}
|
|
7028
7021
|
async function makeEditorsIndexFile(args) {
|
|
7029
7022
|
const { project, editorsDirPath } = args;
|
|
7023
|
+
project.addSourceFilesAtPaths(path.join(editorsDirPath, "**", "module.ts"));
|
|
7030
7024
|
const sourceFile = project.createSourceFile(path.join(editorsDirPath, "index.ts"), "", { overwrite: true });
|
|
7031
7025
|
pipe(project.getDirectoryOrThrow(editorsDirPath).getDescendantSourceFiles(), filter((sourceFile) => sourceFile.getBaseName() === "module.ts"), uniqueBy((sourceFile) => sourceFile.getFilePath()), map((sourceFile) => getVariableDeclarationByTypeName(sourceFile, "EditorModule")), filter(isTruthy), map((variableDeclaration) => ({
|
|
7032
7026
|
name: variableDeclaration.getName(),
|
|
@@ -7200,7 +7194,8 @@ async function writeGeneratedProjectRootFiles(projectDir) {
|
|
|
7200
7194
|
await writeFileEnsuringDir(join(projectDir, "tsconfig.json"), await formatSafe(tsConfigTemplate, "json"));
|
|
7201
7195
|
await writeFileEnsuringDir(join(projectDir, "index.html"), await formatSafe(indexHtmlTemplate, "html"));
|
|
7202
7196
|
await writeFileEnsuringDir(join(projectDir, "main.tsx"), await formatSafe(mainTsxTemplate));
|
|
7203
|
-
await writeFileEnsuringDir(join(projectDir, "
|
|
7197
|
+
await writeFileEnsuringDir(join(projectDir, ".oxlintrc.json"), await formatSafe(oxlintConfigTemplate, "json"));
|
|
7198
|
+
await writeFileEnsuringDir(join(projectDir, ".oxfmtrc.json"), await formatSafe(oxfmtConfigTemplate, "json"));
|
|
7204
7199
|
await writeFileEnsuringDir(join(projectDir, "index.ts"), await formatSafe(indexTsTemplate));
|
|
7205
7200
|
await writeFileEnsuringDir(join(projectDir, "style.css"), await formatSafe(styleTemplate, "css"));
|
|
7206
7201
|
await writeFileEnsuringDir(join(projectDir, "vitest.config.ts"), await formatSafe(vitestConfigTemplate));
|
|
@@ -7406,18 +7401,36 @@ async function makeEditorComponent(args) {
|
|
|
7406
7401
|
}
|
|
7407
7402
|
//#endregion
|
|
7408
7403
|
//#region src/codegen/graphql.ts
|
|
7404
|
+
function makePluginLoader() {
|
|
7405
|
+
const selfPath = fileURLToPath(import.meta.url);
|
|
7406
|
+
let selfReal = selfPath;
|
|
7407
|
+
try {
|
|
7408
|
+
selfReal = realpathSync(selfPath);
|
|
7409
|
+
} catch {}
|
|
7410
|
+
const requirers = [createRequire(selfPath), createRequire(selfReal)];
|
|
7411
|
+
return async (name) => {
|
|
7412
|
+
let lastErr;
|
|
7413
|
+
for (const requireFrom of requirers) try {
|
|
7414
|
+
return await import(pathToFileURL(requireFrom.resolve(name)).href);
|
|
7415
|
+
} catch (err) {
|
|
7416
|
+
lastErr = err;
|
|
7417
|
+
}
|
|
7418
|
+
throw lastErr;
|
|
7419
|
+
};
|
|
7420
|
+
}
|
|
7421
|
+
const pluginLoader = makePluginLoader();
|
|
7409
7422
|
const scalars = {
|
|
7410
7423
|
Unknown: "unknown",
|
|
7411
7424
|
DateTime: "string",
|
|
7412
|
-
Attachment: "string",
|
|
7413
7425
|
Address: "`${string}:0x${string}`",
|
|
7426
|
+
AttachmentRef: "`attachment://v${number}:${string}`",
|
|
7414
7427
|
...generatorTypeDefs
|
|
7415
7428
|
};
|
|
7416
7429
|
const scalarsValidation = {
|
|
7417
7430
|
Unknown: "z.unknown()",
|
|
7418
7431
|
DateTime: "z.string().datetime()",
|
|
7419
|
-
Attachment: "z.string()",
|
|
7420
7432
|
Address: "z.custom<`${string}:0x${string}`>((val) => /^[a-zA-Z0-9]+:0x[a-fA-F0-9]{40}$/.test(val as string))",
|
|
7433
|
+
AttachmentRef: "z.custom<`attachment://v${number}:${string}`>((val) => /^attachment:\\/\\/v\\d+:.+$/.test(val as string))",
|
|
7421
7434
|
...validationSchema
|
|
7422
7435
|
};
|
|
7423
7436
|
const avoidOptionals = {
|
|
@@ -7466,15 +7479,16 @@ function buildGraphqlDocumentStringForSpecification(specification) {
|
|
|
7466
7479
|
...moduleSchemas
|
|
7467
7480
|
];
|
|
7468
7481
|
}
|
|
7469
|
-
async function
|
|
7470
|
-
return await format(content, {
|
|
7482
|
+
async function formatContent(path, content) {
|
|
7483
|
+
return (await format(path, content, { printWidth: 80 })).code;
|
|
7471
7484
|
}
|
|
7472
7485
|
async function generateTypesAndZodSchemasFromGraphql(args) {
|
|
7473
7486
|
const { schemaDirPath, schema } = args;
|
|
7474
7487
|
await generate({
|
|
7475
7488
|
overwrite: true,
|
|
7476
7489
|
watch: false,
|
|
7477
|
-
|
|
7490
|
+
pluginLoader,
|
|
7491
|
+
hooks: { beforeOneFileWrite: formatContent },
|
|
7478
7492
|
generates: {
|
|
7479
7493
|
[`${schemaDirPath}/types.ts`]: {
|
|
7480
7494
|
schema,
|
|
@@ -7700,7 +7714,7 @@ async function makeReducerOperationHandlersForModules(fileMakerArgs) {
|
|
|
7700
7714
|
module
|
|
7701
7715
|
});
|
|
7702
7716
|
}
|
|
7703
|
-
async function makeReducerOperationHandlerForModule({ project, module, version, srcDirPath, versionImportPath, pascalCaseDocumentType, camelCaseDocumentType }) {
|
|
7717
|
+
async function makeReducerOperationHandlerForModule({ project, module, version, srcDirPath, genDirPath, versionImportPath, pascalCaseDocumentType, camelCaseDocumentType }) {
|
|
7704
7718
|
const kebabCaseModuleName = kebabCase(module.name);
|
|
7705
7719
|
const pascalCaseModuleName = pascalCase(module.name);
|
|
7706
7720
|
const filePath = path.join(srcDirPath, "reducers", `${kebabCaseModuleName}.ts`);
|
|
@@ -7717,11 +7731,13 @@ async function makeReducerOperationHandlerForModule({ project, module, version,
|
|
|
7717
7731
|
const operationsInterfaceVariableName = `${camelCaseDocumentType}${pascalCaseModuleName}Operations`;
|
|
7718
7732
|
const existingOperationsInterfaceTypeImport = sourceFile.getImportDeclaration((importDeclaration) => !!importDeclaration.getNamedImports().find((importSpecifier) => importSpecifier.getName() === operationsInterfaceTypeName));
|
|
7719
7733
|
if (existingOperationsInterfaceTypeImport) existingOperationsInterfaceTypeImport.remove();
|
|
7720
|
-
|
|
7734
|
+
sourceFile.addImportDeclaration({
|
|
7721
7735
|
namedImports: [operationsInterfaceTypeName],
|
|
7722
7736
|
moduleSpecifier: versionImportPath,
|
|
7723
7737
|
isTypeOnly: true
|
|
7724
|
-
})
|
|
7738
|
+
});
|
|
7739
|
+
const operationsInterface = project.getSourceFile(path.join(genDirPath, kebabCaseModuleName, "operations.ts"))?.getInterface(operationsInterfaceTypeName);
|
|
7740
|
+
const operationsInterfaceTypeProperties = operationsInterface ? [...operationsInterface.getProperties(), ...operationsInterface.getMethods()].map((member) => member.getName()) : void 0;
|
|
7725
7741
|
if (!operationsInterfaceTypeProperties) throw new Error("Failed to create operation handler object");
|
|
7726
7742
|
let operationsInterfaceVariableStatement = sourceFile.getVariableStatement(operationsInterfaceVariableName);
|
|
7727
7743
|
if (!operationsInterfaceVariableStatement) operationsInterfaceVariableStatement = sourceFile.addVariableStatement({
|
|
@@ -8100,6 +8116,7 @@ async function tsMorphGenerateDocumentModel(documentModelState, project) {
|
|
|
8100
8116
|
documentModelDirPath,
|
|
8101
8117
|
latestVersion
|
|
8102
8118
|
});
|
|
8119
|
+
project.addSourceFilesAtPaths([join$1(documentModelsDirPath, "**", "module.ts"), join$1(documentModelsDirPath, "**", "upgrade-manifest.ts")]);
|
|
8103
8120
|
await makeDocumentModelsFile({
|
|
8104
8121
|
project,
|
|
8105
8122
|
documentModelsDirPath
|
|
@@ -8231,9 +8248,6 @@ function operationHasInput(operation) {
|
|
|
8231
8248
|
function operationHasEmptyInput(operation) {
|
|
8232
8249
|
return operation.schema?.includes("_empty") && !operation.schema.replace(/_empty:\s*Boolean/, "").match(/\w+:\s*\w+/);
|
|
8233
8250
|
}
|
|
8234
|
-
function operationHasAttachment(operation) {
|
|
8235
|
-
return operation.schema?.includes(": Attachment");
|
|
8236
|
-
}
|
|
8237
8251
|
//#endregion
|
|
8238
8252
|
//#region src/file-builders/index-files.ts
|
|
8239
8253
|
/**
|
|
@@ -8432,6 +8446,7 @@ async function tsMorphGenerateProcessor(args) {
|
|
|
8432
8446
|
const processorsDirPath = processorsDir.getPath();
|
|
8433
8447
|
const dirPath = path.join(processorsDirPath, kebabCaseName);
|
|
8434
8448
|
await ensureDirectoriesExist(project, processorsDirPath, dirPath);
|
|
8449
|
+
project.addSourceFilesAtPaths(path.join(dirPath, "*.ts"));
|
|
8435
8450
|
if (isCustomizedProcessorDir(project.getDirectory(dirPath))) {
|
|
8436
8451
|
const relativePath = path.relative(projectDir, path.join(dirPath, "index.ts"));
|
|
8437
8452
|
console.warn(`[codegen] Skipping processor scaffold for "${kebabCaseName}": legacy layout detected "${relativePath}"`);
|
|
@@ -8546,6 +8561,7 @@ async function makeCustomSubgraphFiles(project, dirPath, v) {
|
|
|
8546
8561
|
}
|
|
8547
8562
|
async function makeSubgraphsIndexFile(args) {
|
|
8548
8563
|
const { project, subgraphsDir } = args;
|
|
8564
|
+
project.addSourceFilesAtPaths(path.join(subgraphsDir, "**", "index.ts"));
|
|
8549
8565
|
const { sourceFile } = getOrCreateSourceFile(project, path.join(subgraphsDir, "index.ts"));
|
|
8550
8566
|
const existingExportNames = pipe(sourceFile.getExportDeclarations(), map((exportDeclaration) => exportDeclaration.getNamespaceExport()?.getName()), filter(isTruthy));
|
|
8551
8567
|
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) => ({
|
|
@@ -8559,6 +8575,6 @@ async function makeSubgraphsIndexFile(args) {
|
|
|
8559
8575
|
await formatSourceFileWithPrettier(sourceFile);
|
|
8560
8576
|
}
|
|
8561
8577
|
//#endregion
|
|
8562
|
-
export {
|
|
8578
|
+
export { buildStringLiteral as $, connectEntrypointTemplate 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, editorsIndexTemplate 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, documentModelsIndexTemplate as Jn, documentModelPhFactoriesFileTemplate as Jt, getObjectProperty as K, editorsTemplate 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, dockerfileTemplate 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, oxfmtConfigTemplate as Un, documentModelHooksFileTemplate as Ut, getDefaultProjectOptions as V, syncAndPublishWorkflowTemplate as Vn, documentModelModuleFileTemplate as Vt, getBooleanPropertyValue as W, oxlintConfigTemplate as Wn, documentModelGenUtilsTemplate as Wt, getVariableDeclarationByTypeName as X, switchboardEntrypointTemplate as Xn, documentModelOperationsModuleErrorFileTemplate as Xt, getStringPropertyValue as Y, documentModelsTemplate as Yn, documentModelOperationsModuleOperationsFileTemplate as Yt, loadDocumentModelInDir as Z, nginxConfTemplate as Zn, documentModelOperationsModuleCreatorsFileTemplate as Zt, getCommandsHelpInfo as _, documentEditorModuleFileTemplate as _n, customSubgraphSchemaTemplate as _t, getOrCreateManifestFile as a, getLatestDocumentModelSpecVersionNumber as an, driveExplorerNavigationBreadcrumbsFileTemplate as ar, getProcessorMetadata as at, buildBoilerplatePackageJson as b, vitestConfigTemplate as bn, relationalDbSchemaTemplate as bt, operationHasEmptyInput as c, getActionType as cn, appFilesFileTemplate as cr, formatSafe as ct, generateDocumentModelZodSchemas as d, documentModelDocumentTypeTemplate as dn, appDriveContentsFileTemplate as dr, getDocumentTypeMetadata as dt, getDocumentModelDirName as en, cursorMcpTemplate as er, ensureDirectoriesExist as et, generateTypesAndZodSchemasFromGraphql as f, documentModelDocumentSchemaFileTemplate as fn, createDocumentFileTemplate as fr, 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, appConfigFileTemplate 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, emptyStateFileTemplate as lr, formatSourceFileWithPrettier as lt, scalarsValidation as m, documentModelGenControllerFileTemplate as mn, parseArgs as mt, tsMorphGenerateSubgraph as n, getDocumentModelVariableNames as nn, agentsTemplate as nr, getOrCreateSourceFile as nt, pruneManifestSection as o, getActionInputName as on, folderTreeFileTemplate as or, getAppMetadata as ot, scalars as p, documentModelGenCreatorsFileTemplate as pn, configSpec as pt, getProperyAssignmentByName as q, upgradeManifestsTemplate as qn, documentModelGenReducerFileTemplate as qt, tsMorphGenerateProcessor as r, getEditorVariableNames as rn, appEditorFileTemplate as rr, getPreviousVersionSourceFile as rt, makeModulesIndexFile as s, getActionInputTypeNames as sn, appFoldersFileTemplate as sr, getEditorMetadata as st, makeSubgraphsIndexFile as t, getDocumentModelSpecByVersionNumber as tn, claudeSettingsLocalTemplate as tr, getOrCreateDirectory as tt, tsMorphGenerateDocumentModel as u, documentModelGenIndexFileTemplate as un, driveExplorerFileTemplate as ur, runOxfmt 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 };
|
|
8563
8579
|
|
|
8564
|
-
//# sourceMappingURL=file-builders-
|
|
8580
|
+
//# sourceMappingURL=file-builders-DuI7d4bA.mjs.map
|