@powerhousedao/codegen 6.2.0-dev.2 → 6.2.0-dev.20
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-kIBA6RCN.mjs} +49 -30
- package/dist/file-builders-kIBA6RCN.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 +80 -77
- 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
|
}
|
|
@@ -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 ({
|
|
@@ -7406,18 +7409,36 @@ async function makeEditorComponent(args) {
|
|
|
7406
7409
|
}
|
|
7407
7410
|
//#endregion
|
|
7408
7411
|
//#region src/codegen/graphql.ts
|
|
7412
|
+
function makePluginLoader() {
|
|
7413
|
+
const selfPath = fileURLToPath(import.meta.url);
|
|
7414
|
+
let selfReal = selfPath;
|
|
7415
|
+
try {
|
|
7416
|
+
selfReal = realpathSync(selfPath);
|
|
7417
|
+
} catch {}
|
|
7418
|
+
const requirers = [createRequire(selfPath), createRequire(selfReal)];
|
|
7419
|
+
return async (name) => {
|
|
7420
|
+
let lastErr;
|
|
7421
|
+
for (const requireFrom of requirers) try {
|
|
7422
|
+
return await import(pathToFileURL(requireFrom.resolve(name)).href);
|
|
7423
|
+
} catch (err) {
|
|
7424
|
+
lastErr = err;
|
|
7425
|
+
}
|
|
7426
|
+
throw lastErr;
|
|
7427
|
+
};
|
|
7428
|
+
}
|
|
7429
|
+
const pluginLoader = makePluginLoader();
|
|
7409
7430
|
const scalars = {
|
|
7410
7431
|
Unknown: "unknown",
|
|
7411
7432
|
DateTime: "string",
|
|
7412
|
-
Attachment: "string",
|
|
7413
7433
|
Address: "`${string}:0x${string}`",
|
|
7434
|
+
AttachmentRef: "`attachment://v${number}:${string}`",
|
|
7414
7435
|
...generatorTypeDefs
|
|
7415
7436
|
};
|
|
7416
7437
|
const scalarsValidation = {
|
|
7417
7438
|
Unknown: "z.unknown()",
|
|
7418
7439
|
DateTime: "z.string().datetime()",
|
|
7419
|
-
Attachment: "z.string()",
|
|
7420
7440
|
Address: "z.custom<`${string}:0x${string}`>((val) => /^[a-zA-Z0-9]+:0x[a-fA-F0-9]{40}$/.test(val as string))",
|
|
7441
|
+
AttachmentRef: "z.custom<`attachment://v${number}:${string}`>((val) => /^attachment:\\/\\/v\\d+:.+$/.test(val as string))",
|
|
7421
7442
|
...validationSchema
|
|
7422
7443
|
};
|
|
7423
7444
|
const avoidOptionals = {
|
|
@@ -7474,6 +7495,7 @@ async function generateTypesAndZodSchemasFromGraphql(args) {
|
|
|
7474
7495
|
await generate({
|
|
7475
7496
|
overwrite: true,
|
|
7476
7497
|
watch: false,
|
|
7498
|
+
pluginLoader,
|
|
7477
7499
|
hooks: { beforeOneFileWrite: formatContentWithPrettier },
|
|
7478
7500
|
generates: {
|
|
7479
7501
|
[`${schemaDirPath}/types.ts`]: {
|
|
@@ -8231,9 +8253,6 @@ function operationHasInput(operation) {
|
|
|
8231
8253
|
function operationHasEmptyInput(operation) {
|
|
8232
8254
|
return operation.schema?.includes("_empty") && !operation.schema.replace(/_empty:\s*Boolean/, "").match(/\w+:\s*\w+/);
|
|
8233
8255
|
}
|
|
8234
|
-
function operationHasAttachment(operation) {
|
|
8235
|
-
return operation.schema?.includes(": Attachment");
|
|
8236
|
-
}
|
|
8237
8256
|
//#endregion
|
|
8238
8257
|
//#region src/file-builders/index-files.ts
|
|
8239
8258
|
/**
|
|
@@ -8559,6 +8578,6 @@ async function makeSubgraphsIndexFile(args) {
|
|
|
8559
8578
|
await formatSourceFileWithPrettier(sourceFile);
|
|
8560
8579
|
}
|
|
8561
8580
|
//#endregion
|
|
8562
|
-
export {
|
|
8581
|
+
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
8582
|
|
|
8564
|
-
//# sourceMappingURL=file-builders-
|
|
8583
|
+
//# sourceMappingURL=file-builders-kIBA6RCN.mjs.map
|