@powerhousedao/codegen 6.2.0-dev.32 → 6.2.0-dev.34
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-DuI7d4bA.mjs → file-builders-DcAgx6QK.mjs} +73 -16
- package/dist/file-builders-DcAgx6QK.mjs.map +1 -0
- package/dist/index-DtbVU1fc.d.mts.map +1 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +63 -63
- package/dist/src/file-builders/index.mjs +1 -1
- package/dist/src/name-builders/index.mjs +1 -1
- package/dist/src/templates/index.d.mts +5 -2
- package/dist/src/templates/index.d.mts.map +1 -1
- package/dist/src/templates/index.mjs +2 -2
- package/dist/src/utils/index.mjs +1 -1
- package/package.json +3 -3
- package/dist/file-builders-DuI7d4bA.mjs.map +0 -1
|
@@ -18,6 +18,7 @@ import { stripVTControlCharacters } from "node:util";
|
|
|
18
18
|
import path$1, { join as join$1, relative } from "node:path";
|
|
19
19
|
import { generate } from "@graphql-codegen/cli";
|
|
20
20
|
import { generatorTypeDefs, validationSchema } from "@powerhousedao/document-engineering/graphql";
|
|
21
|
+
import { Kind, parse } from "graphql";
|
|
21
22
|
import { realpathSync } from "node:fs";
|
|
22
23
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
23
24
|
function isEOL(c) {
|
|
@@ -1662,7 +1663,7 @@ function sanitizeInput(input) {
|
|
|
1662
1663
|
* @param content YAML string to parse.
|
|
1663
1664
|
* @param options Parsing options.
|
|
1664
1665
|
* @returns Parsed document.
|
|
1665
|
-
*/ function parse(content, options = {}) {
|
|
1666
|
+
*/ function parse$1(content, options = {}) {
|
|
1666
1667
|
content = sanitizeInput(content);
|
|
1667
1668
|
const documentGenerator = new LoaderState(content, {
|
|
1668
1669
|
...options,
|
|
@@ -1745,7 +1746,7 @@ tag("jsx");
|
|
|
1745
1746
|
const tsx = tag("tsx");
|
|
1746
1747
|
const json = tag("json", JSON.parse);
|
|
1747
1748
|
tag("xml");
|
|
1748
|
-
const yaml = tag("yaml", parse);
|
|
1749
|
+
const yaml = tag("yaml", parse$1);
|
|
1749
1750
|
tag("toml");
|
|
1750
1751
|
tag("ini");
|
|
1751
1752
|
tag("csv");
|
|
@@ -3747,6 +3748,20 @@ export { processorFactory } from "./processors/factory.js";
|
|
|
3747
3748
|
export const manifest: Manifest = manifestJson;
|
|
3748
3749
|
`.raw;
|
|
3749
3750
|
//#endregion
|
|
3751
|
+
//#region src/templates/boilerplate/reactor.ts
|
|
3752
|
+
const reactorTsTemplate = ts$1`
|
|
3753
|
+
/**
|
|
3754
|
+
* WARNING: DO NOT EDIT
|
|
3755
|
+
* This file is auto-generated and updated by codegen
|
|
3756
|
+
*/
|
|
3757
|
+
import type { Manifest } from "document-model";
|
|
3758
|
+
import manifestJson from "../powerhouse.manifest.json" with { type: "json" };
|
|
3759
|
+
export { documentModels } from "../document-models/document-models.js";
|
|
3760
|
+
export { upgradeManifests } from "../document-models/upgrade-manifests.js";
|
|
3761
|
+
export { processorFactory } from "../processors/factory.js";
|
|
3762
|
+
export const manifest: Manifest = manifestJson;
|
|
3763
|
+
`.raw;
|
|
3764
|
+
//#endregion
|
|
3750
3765
|
//#region src/templates/boilerplate/LICENSE.ts
|
|
3751
3766
|
const licenseTemplate = `
|
|
3752
3767
|
GNU AFFERO GENERAL PUBLIC LICENSE
|
|
@@ -5668,11 +5683,11 @@ export function create${v.phDocumentTypeName}(
|
|
|
5668
5683
|
}>,
|
|
5669
5684
|
): ${v.phDocumentTypeName} {
|
|
5670
5685
|
const document = utils.createDocument(
|
|
5671
|
-
|
|
5672
|
-
createBaseState(state
|
|
5673
|
-
state
|
|
5674
|
-
state
|
|
5675
|
-
)
|
|
5686
|
+
createState(
|
|
5687
|
+
createBaseState(state?.auth, { version: ${v.version}, ...state?.document }),
|
|
5688
|
+
state?.global,
|
|
5689
|
+
state?.local,
|
|
5690
|
+
)
|
|
5676
5691
|
);
|
|
5677
5692
|
|
|
5678
5693
|
return document;
|
|
@@ -5834,7 +5849,7 @@ import {
|
|
|
5834
5849
|
baseCreateDocument,
|
|
5835
5850
|
baseSaveToFileHandle,
|
|
5836
5851
|
baseLoadFromInputVersioned,
|
|
5837
|
-
|
|
5852
|
+
createBaseState,
|
|
5838
5853
|
} from "document-model";
|
|
5839
5854
|
import { reducer } from './reducer.js';
|
|
5840
5855
|
${makeOlderReducerImports(v.versions, v.version) ? makeOlderReducerImports(v.versions, v.version) + "\n" : ""}import { ${v.upgradeManifestName} } from "../../upgrades/upgrade-manifest.js";
|
|
@@ -5853,7 +5868,7 @@ export const initialLocalState: ${v.localStateName} = ${v.initialLocalState};
|
|
|
5853
5868
|
export const utils: DocumentModelUtils<${v.phStateName}> = {
|
|
5854
5869
|
fileExtension: "${v.documentModelState.extension}",
|
|
5855
5870
|
createState(state) {
|
|
5856
|
-
return { ...
|
|
5871
|
+
return { ...createBaseState(state?.auth, { version: ${v.version}, ...state?.document }), global: { ...initialGlobalState, ...state?.global }, local: { ...initialLocalState, ...state?.local } };
|
|
5857
5872
|
},
|
|
5858
5873
|
createDocument(state) {
|
|
5859
5874
|
return baseCreateDocument(
|
|
@@ -6126,7 +6141,8 @@ function makeCamelCaseOperationNamesForImport(operations) {
|
|
|
6126
6141
|
function makeOperationInputSchemasForImport(operations) {
|
|
6127
6142
|
return pipe(operations, map(prop("name")), filter(isString), map((n) => `${pascalCase(n)}InputSchema`));
|
|
6128
6143
|
}
|
|
6129
|
-
|
|
6144
|
+
const VALID_ISO_DATETIME = `"2024-01-01T00:00:00.000Z"`;
|
|
6145
|
+
function makeTestCaseForOperation(operation, isPhDocumentOfTypeFunctionName, dateLikeInputFields = []) {
|
|
6130
6146
|
if (operation.name === null) throw new Error(`Operation is missing name.`);
|
|
6131
6147
|
const camelCaseActionName = camelCase(operation.name);
|
|
6132
6148
|
const pascalCaseActionName = pascalCase(operation.name);
|
|
@@ -6137,7 +6153,7 @@ function makeTestCaseForOperation(operation, isPhDocumentOfTypeFunctionName) {
|
|
|
6137
6153
|
it('should handle ${camelCaseActionName} operation', () => {
|
|
6138
6154
|
const document = utils.createDocument();
|
|
6139
6155
|
const input = generateMock(
|
|
6140
|
-
${actionInputSchemaName}(),
|
|
6156
|
+
${actionInputSchemaName}(),${dateLikeInputFields.length > 0 ? `\n { ${dateLikeInputFields.map((field) => `${field}: ${VALID_ISO_DATETIME}`).join(", ")} },` : ""}
|
|
6141
6157
|
);
|
|
6142
6158
|
|
|
6143
6159
|
const updatedDocument = reducer(
|
|
@@ -6183,7 +6199,7 @@ const documentModelOperationsModuleTestFileTemplate = (v) => ts$1`
|
|
|
6183
6199
|
*/
|
|
6184
6200
|
|
|
6185
6201
|
import { describe, it, expect } from 'vitest';
|
|
6186
|
-
import { generateMock } from '
|
|
6202
|
+
import { generateMock } from 'document-model';
|
|
6187
6203
|
import {
|
|
6188
6204
|
reducer,
|
|
6189
6205
|
utils,
|
|
@@ -7197,6 +7213,7 @@ async function writeGeneratedProjectRootFiles(projectDir) {
|
|
|
7197
7213
|
await writeFileEnsuringDir(join(projectDir, ".oxlintrc.json"), await formatSafe(oxlintConfigTemplate, "json"));
|
|
7198
7214
|
await writeFileEnsuringDir(join(projectDir, ".oxfmtrc.json"), await formatSafe(oxfmtConfigTemplate, "json"));
|
|
7199
7215
|
await writeFileEnsuringDir(join(projectDir, "index.ts"), await formatSafe(indexTsTemplate));
|
|
7216
|
+
await writeFileEnsuringDir(join(projectDir, "reactor/index.ts"), await formatSafe(reactorTsTemplate));
|
|
7200
7217
|
await writeFileEnsuringDir(join(projectDir, "style.css"), await formatSafe(styleTemplate, "css"));
|
|
7201
7218
|
await writeFileEnsuringDir(join(projectDir, "vitest.config.ts"), await formatSafe(vitestConfigTemplate));
|
|
7202
7219
|
}
|
|
@@ -7433,6 +7450,39 @@ const scalarsValidation = {
|
|
|
7433
7450
|
AttachmentRef: "z.custom<`attachment://v${number}:${string}`>((val) => /^attachment:\\/\\/v\\d+:.+$/.test(val as string))",
|
|
7434
7451
|
...validationSchema
|
|
7435
7452
|
};
|
|
7453
|
+
const DATE_LIKE_SCALARS = new Set(["Date", "DateTime"]);
|
|
7454
|
+
function unwrapNamedTypeName(type) {
|
|
7455
|
+
if (type.kind === Kind.NAMED_TYPE) return type.name.value;
|
|
7456
|
+
if (type.kind === Kind.NON_NULL_TYPE || type.kind === Kind.LIST_TYPE) return unwrapNamedTypeName(type.type);
|
|
7457
|
+
return null;
|
|
7458
|
+
}
|
|
7459
|
+
function getDateLikeFieldNames(stateSchemaSDL) {
|
|
7460
|
+
const names = /* @__PURE__ */ new Set();
|
|
7461
|
+
if (!stateSchemaSDL) return names;
|
|
7462
|
+
let doc;
|
|
7463
|
+
try {
|
|
7464
|
+
doc = parse(stateSchemaSDL);
|
|
7465
|
+
} catch {
|
|
7466
|
+
return names;
|
|
7467
|
+
}
|
|
7468
|
+
for (const def of doc.definitions) {
|
|
7469
|
+
if (def.kind !== Kind.OBJECT_TYPE_DEFINITION) continue;
|
|
7470
|
+
for (const field of def.fields ?? []) if (DATE_LIKE_SCALARS.has(unwrapNamedTypeName(field.type) ?? "")) names.add(field.name.value);
|
|
7471
|
+
}
|
|
7472
|
+
return names;
|
|
7473
|
+
}
|
|
7474
|
+
function getInputFieldNames(operationSDL) {
|
|
7475
|
+
if (!operationSDL) return [];
|
|
7476
|
+
let doc;
|
|
7477
|
+
try {
|
|
7478
|
+
doc = parse(operationSDL);
|
|
7479
|
+
} catch {
|
|
7480
|
+
return [];
|
|
7481
|
+
}
|
|
7482
|
+
const inputDef = doc.definitions.find((d) => d.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION);
|
|
7483
|
+
if (!inputDef || inputDef.kind !== Kind.INPUT_OBJECT_TYPE_DEFINITION) return [];
|
|
7484
|
+
return (inputDef.fields ?? []).map((f) => f.name.value);
|
|
7485
|
+
}
|
|
7436
7486
|
const avoidOptionals = {
|
|
7437
7487
|
field: true,
|
|
7438
7488
|
inputValue: false
|
|
@@ -7820,7 +7870,11 @@ async function makeDocumentModelModulesOperationTestFiles(fileMakerArgs) {
|
|
|
7820
7870
|
});
|
|
7821
7871
|
}
|
|
7822
7872
|
async function makeOperationModuleTestFile(args) {
|
|
7823
|
-
const { project, module, version, versionImportPath, testsDirPath, isPhDocumentOfTypeFunctionName } = args;
|
|
7873
|
+
const { project, module, specification, version, versionImportPath, testsDirPath, isPhDocumentOfTypeFunctionName } = args;
|
|
7874
|
+
const dateLikeFieldsByScope = {
|
|
7875
|
+
global: getDateLikeFieldNames(specification.state.global.schema),
|
|
7876
|
+
local: getDateLikeFieldNames(specification.state.local.schema)
|
|
7877
|
+
};
|
|
7824
7878
|
const kebabCaseModuleName = kebabCase(module.name);
|
|
7825
7879
|
const moduleOperationsTypeName = `${pascalCase(module.name)}Operations`;
|
|
7826
7880
|
const filePath = path.join(testsDirPath, `${kebabCaseModuleName}.test.ts`);
|
|
@@ -7882,7 +7936,10 @@ async function makeOperationModuleTestFile(args) {
|
|
|
7882
7936
|
const testCasesToAdd = pipe(module.operations, filter((o) => {
|
|
7883
7937
|
const expectedTestCaseName = `should handle ${camelCase(o.name ?? "")} operation`;
|
|
7884
7938
|
return !testCaseNames.some((name) => name === expectedTestCaseName);
|
|
7885
|
-
}), map((o) =>
|
|
7939
|
+
}), map((o) => {
|
|
7940
|
+
const dateLikeStateFields = o.scope === "local" ? dateLikeFieldsByScope.local : dateLikeFieldsByScope.global;
|
|
7941
|
+
return makeTestCaseForOperation(o, isPhDocumentOfTypeFunctionName, getInputFieldNames(o.schema).filter((f) => dateLikeStateFields.has(f)));
|
|
7942
|
+
}));
|
|
7886
7943
|
describeCallBody.addStatements(testCasesToAdd);
|
|
7887
7944
|
const GENERATE_MOCK_NAME = "generateMock";
|
|
7888
7945
|
const GENERATE_MOCK_MODULE_SPECIFIER = "document-model";
|
|
@@ -8575,6 +8632,6 @@ async function makeSubgraphsIndexFile(args) {
|
|
|
8575
8632
|
await formatSourceFileWithPrettier(sourceFile);
|
|
8576
8633
|
}
|
|
8577
8634
|
//#endregion
|
|
8578
|
-
export {
|
|
8635
|
+
export { loadDocumentModelInDir as $, switchboardEntrypointTemplate as $n, documentModelOperationsModuleCreatorsFileTemplate as $t, writeGeneratedProjectRootFiles as A, packageJsonExportsTemplate as An, analyticsProcessorTemplate as At, getInitialStates as B, indexTsTemplate as Bn, documentModelTestFileTemplate as Bt, applyProjectCustomizations as C, tsConfigTemplate as Cn, relationalDbProcessorTemplate as Ct, writeGeneratedDocumentModelsFiles as D, readmeTemplate as Dn, processorsIndexTemplate as Dt, writeCIFiles as E, styleTemplate as En, relationalDbFactoryTemplate as Et, makeEditorModuleFile as F, npmrcTemplate as Fn, upgradeManifestTemplate as Ft, getAllImportNames as G, geminiSettingsTemplate as Gn, documentModelHooksFileTemplate as Gt, buildTsMorphProject as H, indexHtmlTemplate as Hn, documentModelSrcIndexFileTemplate as Ht, makeEditorsFile as I, mcpTemplate as In, documentModelOperationsModuleTestFileTemplate as It, getObjectProperty as J, editorsIndexTemplate as Jn, documentModelSchemaIndexTemplate as Jt, getBooleanPropertyValue as K, oxfmtConfigTemplate as Kn, documentModelGenUtilsTemplate as Kt, makeEditorsIndexFile as L, mainTsxTemplate as Ln, makeOperationImportNames as Lt, writeModuleFiles as M, pnpmWorkspaceTemplate as Mn, analyticsFactoryTemplate as Mt, writeProjectRootFiles as N, exportsTemplate as Nn, documentModelUtilsTemplate as Nt, writeGeneratedEditorsFiles as O, ManifestTemplate as On, processorsFactoryTemplate as Ot, tsMorphGenerateApp as P, packageJsonTemplate as Pn, upgradeTransitionTemplate as Pt, getVariableDeclarationByTypeName as Q, documentModelsTemplate as Qn, documentModelOperationsModuleErrorFileTemplate as Qt, validateDocumentModelState as R, licenseTemplate as Rn, makeOperationsImports as Rt, buildBoilerplatePackageJson as S, vitestConfigTemplate as Sn, relationalDbSchemaTemplate as St, writeAllGeneratedProjectFiles as T, subgraphsIndexTemplate as Tn, relationalDbIndexTemplate as Tt, getDefaultProjectOptions as U, gitIgnoreTemplate as Un, documentModelModuleFileTemplate as Ut, DEFAULT_PROJECT_OPTIONS as V, legacyIndexHtmlTemplate as Vn, documentModelSrcUtilsTemplate as Vt, getAllImportModuleSpecifiers as W, syncAndPublishWorkflowTemplate as Wn, documentModelIndexTemplate as Wt, getStringArrayPropertyElements as X, upgradeManifestsTemplate as Xn, documentModelPhFactoriesFileTemplate as Xt, getProperyAssignmentByName as Y, editorsTemplate as Yn, documentModelGenReducerFileTemplate as Yt, getStringPropertyValue as Z, documentModelsIndexTemplate as Zn, documentModelOperationsModuleOperationsFileTemplate as Zt, tsMorphGenerateDocumentEditor as _, documentModelGenActionsFileTemplate as _n, parseConfig as _t, getOrCreateManifestFile as a, getEditorVariableNames as an, agentsTemplate as ar, getPreviousVersionSourceFile as at, makeCliDocsFromHelp as b, documentEditorEditorFileTemplate as bn, subgraphLibFileTemplate as bt, operationHasEmptyInput as c, getActionInputName as cn, driveExplorerNavigationBreadcrumbsFileTemplate as cr, getAppMetadata as ct, generateDocumentModelZodSchemas as d, getActionTypeName as dn, appFilesFileTemplate as dr, formatSourceFileWithPrettier as dt, documentModelOperationModuleActionsFileTemplate as en, nginxConfTemplate as er, buildObjectLiteral as et, generateTypesAndZodSchemasFromGraphql as f, documentModelGenIndexFileTemplate as fn, emptyStateFileTemplate as fr, runOxfmt as ft, scalarsValidation as g, documentModelGenControllerFileTemplate as gn, parseArgs as gt, scalars as h, documentModelGenCreatorsFileTemplate as hn, createDocumentFileTemplate as hr, configSpec as ht, createOrUpdateManifest as i, getDocumentModelVariableNames as in, claudeSettingsLocalTemplate as ir, getOrCreateSourceFile as it, writeGeneratedSubgraphsFiles as j, packageJsonScriptsTemplate as jn, analyticsIndexTemplate as jt, writeGeneratedProcessorsFiles as k, buildPowerhouseConfigTemplate as kn, factoryBuildersTemplate as kt, operationHasInput as l, getActionInputTypeNames as ln, folderTreeFileTemplate as lr, getEditorMetadata as lt, getInputFieldNames as m, documentModelDocumentSchemaFileTemplate as mn, appDriveContentsFileTemplate as mr, documentModelDocumentTypeMetadata as mt, tsMorphGenerateSubgraph as n, getDocumentModelDirName as nn, connectEntrypointTemplate as nr, ensureDirectoriesExist as nt, pruneManifestSection as o, getLatestDocumentModelSpec as on, appEditorFileTemplate as or, getSubgraphMetadata as ot, getDateLikeFieldNames as p, documentModelDocumentTypeTemplate as pn, driveExplorerFileTemplate as pr, getDocumentTypeMetadata as pt, getObjectLiteral as q, oxlintConfigTemplate as qn, documentModelGenTypesTemplate as qt, tsMorphGenerateProcessor as r, getDocumentModelSpecByVersionNumber as rn, cursorMcpTemplate as rr, getOrCreateDirectory as rt, makeModulesIndexFile as s, getLatestDocumentModelSpecVersionNumber as sn, appConfigFileTemplate as sr, getProcessorMetadata as st, makeSubgraphsIndexFile as t, getModuleExportType as tn, dockerfileTemplate as tr, buildStringLiteral as tt, tsMorphGenerateDocumentModel as u, getActionType as un, appFoldersFileTemplate as ur, formatSafe as ut, getCommandHelpInfo as v, documentModelRootActionsFileTemplate as vn, customSubgraphResolversTemplate as vt, writeAiConfigFiles as w, tsconfigPathsTemplate as wn, relationalDbMigrationsTemplate as wt, writeCliDocsMarkdownFile as x, docsFromCliHelpTemplate as xn, subgraphIndexFileTemplate as xt, getCommandsHelpInfo as y, documentEditorModuleFileTemplate as yn, customSubgraphSchemaTemplate as yt, updateVersionedImports as z, reactorTsTemplate as zn, makeTestCaseForOperation as zt };
|
|
8579
8636
|
|
|
8580
|
-
//# sourceMappingURL=file-builders-
|
|
8637
|
+
//# sourceMappingURL=file-builders-DcAgx6QK.mjs.map
|