@powerhousedao/codegen 6.2.0-dev.2 → 6.2.0-dev.21
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-NNaY31PO.mjs} +73 -42
- package/dist/file-builders-NNaY31PO.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 +100 -83
- 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 +1 -1
- package/dist/src/templates/index.d.mts.map +1 -1
- package/dist/src/templates/index.mjs +1 -1
- package/dist/src/utils/index.d.mts +1 -1
- package/dist/src/utils/index.mjs +1 -1
- package/package.json +3 -3
- 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";
|
|
@@ -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
|
}
|
|
@@ -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
|
);
|
|
@@ -4998,7 +5001,7 @@ export default function Editor() {
|
|
|
4998
5001
|
};
|
|
4999
5002
|
|
|
5000
5003
|
return (
|
|
5001
|
-
<div className="mx-auto max-w-4xl bg-
|
|
5004
|
+
<div className="mx-auto max-w-4xl bg-background p-6">
|
|
5002
5005
|
<DocumentToolbar />
|
|
5003
5006
|
|
|
5004
5007
|
{/* "ph-default-styles" sets default styles for basic UI elements */}
|
|
@@ -5387,10 +5390,9 @@ function getDocumentModelVariableNames(documentModelName) {
|
|
|
5387
5390
|
//#endregion
|
|
5388
5391
|
//#region src/templates/document-model/gen/modules/actions.ts
|
|
5389
5392
|
function getActionTypeExport(operation) {
|
|
5390
|
-
const baseActionTypeName = operationHasAttachment(operation) ? "ActionWithAttachment" : "Action";
|
|
5391
5393
|
const actionTypeName = getActionTypeName(operation);
|
|
5392
5394
|
const actionInputName = getActionInputName(operation) ?? `"{}"`;
|
|
5393
|
-
return ts$1`export type ${actionTypeName} =
|
|
5395
|
+
return ts$1`export type ${actionTypeName} = Action & { type: "${getActionType(operation)}"; input: ${actionInputName} };`.raw;
|
|
5394
5396
|
}
|
|
5395
5397
|
function getActionTypeExports(args) {
|
|
5396
5398
|
return args.module.operations.map(getActionTypeExport).join("\n");
|
|
@@ -5400,17 +5402,12 @@ function getModuleExportType(args) {
|
|
|
5400
5402
|
const actionTypeNames = module.operations.map(getActionTypeName).join(" |\n");
|
|
5401
5403
|
return ts$1`export type ${pascalCaseDocumentType}${pascalCase(module.name)}Action = ${actionTypeNames};`.raw;
|
|
5402
5404
|
}
|
|
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
5405
|
const documentModelOperationModuleActionsFileTemplate = (v) => ts$1`
|
|
5409
5406
|
/**
|
|
5410
5407
|
* WARNING: DO NOT EDIT
|
|
5411
5408
|
* This file is auto-generated and updated by codegen
|
|
5412
5409
|
*/
|
|
5413
|
-
import type {
|
|
5410
|
+
import type { Action } from 'document-model';
|
|
5414
5411
|
import type {
|
|
5415
5412
|
${getActionInputTypeNames(v)}
|
|
5416
5413
|
} from '../types.js';
|
|
@@ -5421,11 +5418,6 @@ ${getModuleExportType(v)}
|
|
|
5421
5418
|
`.raw;
|
|
5422
5419
|
//#endregion
|
|
5423
5420
|
//#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
5421
|
function makeActionInputSchemaName(action) {
|
|
5430
5422
|
if (!action.name || !action.schema) return;
|
|
5431
5423
|
return `${pascalCase(action.name)}InputSchema`;
|
|
@@ -5454,15 +5446,12 @@ function makeActionCreatorWithInput(operation) {
|
|
|
5454
5446
|
const actionTypeName = makeActionTypeName(operation);
|
|
5455
5447
|
const inputSchemaName = makeActionInputSchemaName(operation);
|
|
5456
5448
|
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
5449
|
return ts$1`
|
|
5461
|
-
export const ${camelCaseActionName} = (${
|
|
5450
|
+
export const ${camelCaseActionName} = (${operationHasEmptyInput(operation) ? `input: ${inputTypeName} = {}` : `input: ${inputTypeName}`}) =>
|
|
5462
5451
|
createAction<${actionTypeName}>(
|
|
5463
5452
|
"${constantCaseActionName}",
|
|
5464
5453
|
{...input},
|
|
5465
|
-
|
|
5454
|
+
undefined,
|
|
5466
5455
|
${inputSchemaName},
|
|
5467
5456
|
"${operation.scope}"
|
|
5468
5457
|
);`.raw;
|
|
@@ -5486,7 +5475,7 @@ const documentModelOperationsModuleCreatorsFileTemplate = (v) => ts$1`
|
|
|
5486
5475
|
* WARNING: DO NOT EDIT
|
|
5487
5476
|
* This file is auto-generated and updated by codegen
|
|
5488
5477
|
*/
|
|
5489
|
-
import {
|
|
5478
|
+
import { createAction } from "document-model";
|
|
5490
5479
|
import {
|
|
5491
5480
|
${makeActionInputSchemaImports(v)}
|
|
5492
5481
|
} from '../schema/zod.js';
|
|
@@ -5844,6 +5833,14 @@ export type {
|
|
|
5844
5833
|
`.raw;
|
|
5845
5834
|
//#endregion
|
|
5846
5835
|
//#region src/templates/document-model/gen/utils.ts
|
|
5836
|
+
function makeOlderReducerImports(versions, currentVersion) {
|
|
5837
|
+
return versions.filter((k) => k < currentVersion).map((k) => `import { reducer as reducerV${k} } from "../../v${k}/gen/reducer.js";`).join("\n");
|
|
5838
|
+
}
|
|
5839
|
+
function makeReducersObject(versions, currentVersion) {
|
|
5840
|
+
return `{ ${versions.filter((k) => k <= currentVersion).map((k) => {
|
|
5841
|
+
return `${k}: ${k === currentVersion ? "reducer" : `reducerV${k}`} as unknown as Reducer<PHBaseState>`;
|
|
5842
|
+
}).join(", ")} }`;
|
|
5843
|
+
}
|
|
5847
5844
|
const documentModelGenUtilsTemplate = (v) => ts$1`
|
|
5848
5845
|
/**
|
|
5849
5846
|
* WARNING: DO NOT EDIT
|
|
@@ -5851,14 +5848,17 @@ const documentModelGenUtilsTemplate = (v) => ts$1`
|
|
|
5851
5848
|
*/
|
|
5852
5849
|
import type {
|
|
5853
5850
|
DocumentModelUtils,
|
|
5851
|
+
PHBaseState,
|
|
5852
|
+
Reducer,
|
|
5854
5853
|
} from "document-model";
|
|
5855
5854
|
import {
|
|
5856
5855
|
baseCreateDocument,
|
|
5857
5856
|
baseSaveToFileHandle,
|
|
5858
|
-
|
|
5857
|
+
baseLoadFromInputVersioned,
|
|
5859
5858
|
defaultBaseState,
|
|
5860
5859
|
} from "document-model";
|
|
5861
5860
|
import { reducer } from './reducer.js';
|
|
5861
|
+
${makeOlderReducerImports(v.versions, v.version) ? makeOlderReducerImports(v.versions, v.version) + "\n" : ""}import { ${v.upgradeManifestName} } from "../../upgrades/upgrade-manifest.js";
|
|
5862
5862
|
import { ${v.documentTypeVariableName} } from "./document-type.js";
|
|
5863
5863
|
import {
|
|
5864
5864
|
${v.assertIsPhDocumentOfTypeFunctionName},
|
|
@@ -5887,7 +5887,10 @@ export const utils: DocumentModelUtils<${v.phStateName}> = {
|
|
|
5887
5887
|
return baseSaveToFileHandle(document, input);
|
|
5888
5888
|
},
|
|
5889
5889
|
loadFromInput(input) {
|
|
5890
|
-
return
|
|
5890
|
+
return baseLoadFromInputVersioned(input, {
|
|
5891
|
+
reducers: ${makeReducersObject(v.versions, v.version)},
|
|
5892
|
+
upgradeManifest: ${v.upgradeManifestName},
|
|
5893
|
+
});
|
|
5891
5894
|
},
|
|
5892
5895
|
isStateOfType(state) {
|
|
5893
5896
|
return ${v.isPhStateOfTypeFunctionName}(state);
|
|
@@ -6563,9 +6566,9 @@ type Query {
|
|
|
6563
6566
|
//#endregion
|
|
6564
6567
|
//#region src/templates/subgraphs/custom-resolvers.ts
|
|
6565
6568
|
const customSubgraphResolversTemplate = (v) => ts$1`
|
|
6566
|
-
import { type
|
|
6569
|
+
import { type BaseSubgraph } from "${REACTOR_API_PACKAGE}";
|
|
6567
6570
|
|
|
6568
|
-
export const getResolvers = (subgraph:
|
|
6571
|
+
export const getResolvers = (subgraph: BaseSubgraph): Record<string, unknown> => {
|
|
6569
6572
|
const reactor = subgraph.reactorClient;
|
|
6570
6573
|
|
|
6571
6574
|
return ({
|
|
@@ -6750,6 +6753,9 @@ function getPreviousVersionSourceFile(args) {
|
|
|
6750
6753
|
const previousVersion = version - 1;
|
|
6751
6754
|
if (previousVersion < 1) return;
|
|
6752
6755
|
const previousVersionFilePath = filePath.replace(`/v${version}/`, `/v${previousVersion}/`);
|
|
6756
|
+
try {
|
|
6757
|
+
project.addSourceFileAtPath(previousVersionFilePath);
|
|
6758
|
+
} catch {}
|
|
6753
6759
|
return project.getSourceFile(previousVersionFilePath);
|
|
6754
6760
|
}
|
|
6755
6761
|
//#endregion
|
|
@@ -6879,8 +6885,10 @@ function getDefaultProjectOptions(tsConfigFilePath) {
|
|
|
6879
6885
|
/** Instantiates a ts-morph Project using the default typescript config and nearest tsconfig.json file */
|
|
6880
6886
|
function buildTsMorphProject(projectDir) {
|
|
6881
6887
|
process.chdir(projectDir);
|
|
6888
|
+
const tsConfigFilePath = path.join(projectDir, "tsconfig.json");
|
|
6882
6889
|
return new Project({
|
|
6883
|
-
|
|
6890
|
+
...DEFAULT_PROJECT_OPTIONS,
|
|
6891
|
+
tsConfigFilePath,
|
|
6884
6892
|
skipFileDependencyResolution: true
|
|
6885
6893
|
});
|
|
6886
6894
|
}
|
|
@@ -7007,6 +7015,7 @@ async function makeEditorModuleFile({ project, editorDirPath, editorName, docume
|
|
|
7007
7015
|
}
|
|
7008
7016
|
async function makeEditorsFile(args) {
|
|
7009
7017
|
const { project, editorsDirPath } = args;
|
|
7018
|
+
project.addSourceFilesAtPaths(path.join(editorsDirPath, "**", "module.ts"));
|
|
7010
7019
|
const sourceFile = project.createSourceFile(path.join(editorsDirPath, "editors.ts"), editorsTemplate, { overwrite: true });
|
|
7011
7020
|
const editorsArray = sourceFile.getVariableDeclarationOrThrow("editors").getFirstDescendantByKindOrThrow(SyntaxKind.ArrayLiteralExpression);
|
|
7012
7021
|
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 +7036,7 @@ async function makeEditorsFile(args) {
|
|
|
7027
7036
|
}
|
|
7028
7037
|
async function makeEditorsIndexFile(args) {
|
|
7029
7038
|
const { project, editorsDirPath } = args;
|
|
7039
|
+
project.addSourceFilesAtPaths(path.join(editorsDirPath, "**", "module.ts"));
|
|
7030
7040
|
const sourceFile = project.createSourceFile(path.join(editorsDirPath, "index.ts"), "", { overwrite: true });
|
|
7031
7041
|
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
7042
|
name: variableDeclaration.getName(),
|
|
@@ -7406,18 +7416,36 @@ async function makeEditorComponent(args) {
|
|
|
7406
7416
|
}
|
|
7407
7417
|
//#endregion
|
|
7408
7418
|
//#region src/codegen/graphql.ts
|
|
7419
|
+
function makePluginLoader() {
|
|
7420
|
+
const selfPath = fileURLToPath(import.meta.url);
|
|
7421
|
+
let selfReal = selfPath;
|
|
7422
|
+
try {
|
|
7423
|
+
selfReal = realpathSync(selfPath);
|
|
7424
|
+
} catch {}
|
|
7425
|
+
const requirers = [createRequire(selfPath), createRequire(selfReal)];
|
|
7426
|
+
return async (name) => {
|
|
7427
|
+
let lastErr;
|
|
7428
|
+
for (const requireFrom of requirers) try {
|
|
7429
|
+
return await import(pathToFileURL(requireFrom.resolve(name)).href);
|
|
7430
|
+
} catch (err) {
|
|
7431
|
+
lastErr = err;
|
|
7432
|
+
}
|
|
7433
|
+
throw lastErr;
|
|
7434
|
+
};
|
|
7435
|
+
}
|
|
7436
|
+
const pluginLoader = makePluginLoader();
|
|
7409
7437
|
const scalars = {
|
|
7410
7438
|
Unknown: "unknown",
|
|
7411
7439
|
DateTime: "string",
|
|
7412
|
-
Attachment: "string",
|
|
7413
7440
|
Address: "`${string}:0x${string}`",
|
|
7441
|
+
AttachmentRef: "`attachment://v${number}:${string}`",
|
|
7414
7442
|
...generatorTypeDefs
|
|
7415
7443
|
};
|
|
7416
7444
|
const scalarsValidation = {
|
|
7417
7445
|
Unknown: "z.unknown()",
|
|
7418
7446
|
DateTime: "z.string().datetime()",
|
|
7419
|
-
Attachment: "z.string()",
|
|
7420
7447
|
Address: "z.custom<`${string}:0x${string}`>((val) => /^[a-zA-Z0-9]+:0x[a-fA-F0-9]{40}$/.test(val as string))",
|
|
7448
|
+
AttachmentRef: "z.custom<`attachment://v${number}:${string}`>((val) => /^attachment:\\/\\/v\\d+:.+$/.test(val as string))",
|
|
7421
7449
|
...validationSchema
|
|
7422
7450
|
};
|
|
7423
7451
|
const avoidOptionals = {
|
|
@@ -7474,6 +7502,7 @@ async function generateTypesAndZodSchemasFromGraphql(args) {
|
|
|
7474
7502
|
await generate({
|
|
7475
7503
|
overwrite: true,
|
|
7476
7504
|
watch: false,
|
|
7505
|
+
pluginLoader,
|
|
7477
7506
|
hooks: { beforeOneFileWrite: formatContentWithPrettier },
|
|
7478
7507
|
generates: {
|
|
7479
7508
|
[`${schemaDirPath}/types.ts`]: {
|
|
@@ -7700,7 +7729,7 @@ async function makeReducerOperationHandlersForModules(fileMakerArgs) {
|
|
|
7700
7729
|
module
|
|
7701
7730
|
});
|
|
7702
7731
|
}
|
|
7703
|
-
async function makeReducerOperationHandlerForModule({ project, module, version, srcDirPath, versionImportPath, pascalCaseDocumentType, camelCaseDocumentType }) {
|
|
7732
|
+
async function makeReducerOperationHandlerForModule({ project, module, version, srcDirPath, genDirPath, versionImportPath, pascalCaseDocumentType, camelCaseDocumentType }) {
|
|
7704
7733
|
const kebabCaseModuleName = kebabCase(module.name);
|
|
7705
7734
|
const pascalCaseModuleName = pascalCase(module.name);
|
|
7706
7735
|
const filePath = path.join(srcDirPath, "reducers", `${kebabCaseModuleName}.ts`);
|
|
@@ -7717,11 +7746,13 @@ async function makeReducerOperationHandlerForModule({ project, module, version,
|
|
|
7717
7746
|
const operationsInterfaceVariableName = `${camelCaseDocumentType}${pascalCaseModuleName}Operations`;
|
|
7718
7747
|
const existingOperationsInterfaceTypeImport = sourceFile.getImportDeclaration((importDeclaration) => !!importDeclaration.getNamedImports().find((importSpecifier) => importSpecifier.getName() === operationsInterfaceTypeName));
|
|
7719
7748
|
if (existingOperationsInterfaceTypeImport) existingOperationsInterfaceTypeImport.remove();
|
|
7720
|
-
|
|
7749
|
+
sourceFile.addImportDeclaration({
|
|
7721
7750
|
namedImports: [operationsInterfaceTypeName],
|
|
7722
7751
|
moduleSpecifier: versionImportPath,
|
|
7723
7752
|
isTypeOnly: true
|
|
7724
|
-
})
|
|
7753
|
+
});
|
|
7754
|
+
const operationsInterface = project.getSourceFile(path.join(genDirPath, kebabCaseModuleName, "operations.ts"))?.getInterface(operationsInterfaceTypeName);
|
|
7755
|
+
const operationsInterfaceTypeProperties = operationsInterface ? [...operationsInterface.getProperties(), ...operationsInterface.getMethods()].map((member) => member.getName()) : void 0;
|
|
7725
7756
|
if (!operationsInterfaceTypeProperties) throw new Error("Failed to create operation handler object");
|
|
7726
7757
|
let operationsInterfaceVariableStatement = sourceFile.getVariableStatement(operationsInterfaceVariableName);
|
|
7727
7758
|
if (!operationsInterfaceVariableStatement) operationsInterfaceVariableStatement = sourceFile.addVariableStatement({
|
|
@@ -8100,6 +8131,7 @@ async function tsMorphGenerateDocumentModel(documentModelState, project) {
|
|
|
8100
8131
|
documentModelDirPath,
|
|
8101
8132
|
latestVersion
|
|
8102
8133
|
});
|
|
8134
|
+
project.addSourceFilesAtPaths([join$1(documentModelsDirPath, "**", "module.ts"), join$1(documentModelsDirPath, "**", "upgrade-manifest.ts")]);
|
|
8103
8135
|
await makeDocumentModelsFile({
|
|
8104
8136
|
project,
|
|
8105
8137
|
documentModelsDirPath
|
|
@@ -8231,9 +8263,6 @@ function operationHasInput(operation) {
|
|
|
8231
8263
|
function operationHasEmptyInput(operation) {
|
|
8232
8264
|
return operation.schema?.includes("_empty") && !operation.schema.replace(/_empty:\s*Boolean/, "").match(/\w+:\s*\w+/);
|
|
8233
8265
|
}
|
|
8234
|
-
function operationHasAttachment(operation) {
|
|
8235
|
-
return operation.schema?.includes(": Attachment");
|
|
8236
|
-
}
|
|
8237
8266
|
//#endregion
|
|
8238
8267
|
//#region src/file-builders/index-files.ts
|
|
8239
8268
|
/**
|
|
@@ -8432,6 +8461,7 @@ async function tsMorphGenerateProcessor(args) {
|
|
|
8432
8461
|
const processorsDirPath = processorsDir.getPath();
|
|
8433
8462
|
const dirPath = path.join(processorsDirPath, kebabCaseName);
|
|
8434
8463
|
await ensureDirectoriesExist(project, processorsDirPath, dirPath);
|
|
8464
|
+
project.addSourceFilesAtPaths(path.join(dirPath, "*.ts"));
|
|
8435
8465
|
if (isCustomizedProcessorDir(project.getDirectory(dirPath))) {
|
|
8436
8466
|
const relativePath = path.relative(projectDir, path.join(dirPath, "index.ts"));
|
|
8437
8467
|
console.warn(`[codegen] Skipping processor scaffold for "${kebabCaseName}": legacy layout detected "${relativePath}"`);
|
|
@@ -8546,6 +8576,7 @@ async function makeCustomSubgraphFiles(project, dirPath, v) {
|
|
|
8546
8576
|
}
|
|
8547
8577
|
async function makeSubgraphsIndexFile(args) {
|
|
8548
8578
|
const { project, subgraphsDir } = args;
|
|
8579
|
+
project.addSourceFilesAtPaths(path.join(subgraphsDir, "**", "index.ts"));
|
|
8549
8580
|
const { sourceFile } = getOrCreateSourceFile(project, path.join(subgraphsDir, "index.ts"));
|
|
8550
8581
|
const existingExportNames = pipe(sourceFile.getExportDeclarations(), map((exportDeclaration) => exportDeclaration.getNamespaceExport()?.getName()), filter(isTruthy));
|
|
8551
8582
|
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 +8590,6 @@ async function makeSubgraphsIndexFile(args) {
|
|
|
8559
8590
|
await formatSourceFileWithPrettier(sourceFile);
|
|
8560
8591
|
}
|
|
8561
8592
|
//#endregion
|
|
8562
|
-
export {
|
|
8593
|
+
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 };
|
|
8563
8594
|
|
|
8564
|
-
//# sourceMappingURL=file-builders-
|
|
8595
|
+
//# sourceMappingURL=file-builders-NNaY31PO.mjs.map
|