@powerhousedao/codegen 6.2.0-dev.33 → 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-DVMKE0wQ.mjs → file-builders-DcAgx6QK.mjs} +51 -9
- package/dist/file-builders-DcAgx6QK.mjs.map +1 -0
- 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 +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.mjs +1 -1
- package/package.json +3 -3
- package/dist/file-builders-DVMKE0wQ.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");
|
|
@@ -6140,7 +6141,8 @@ function makeCamelCaseOperationNamesForImport(operations) {
|
|
|
6140
6141
|
function makeOperationInputSchemasForImport(operations) {
|
|
6141
6142
|
return pipe(operations, map(prop("name")), filter(isString), map((n) => `${pascalCase(n)}InputSchema`));
|
|
6142
6143
|
}
|
|
6143
|
-
|
|
6144
|
+
const VALID_ISO_DATETIME = `"2024-01-01T00:00:00.000Z"`;
|
|
6145
|
+
function makeTestCaseForOperation(operation, isPhDocumentOfTypeFunctionName, dateLikeInputFields = []) {
|
|
6144
6146
|
if (operation.name === null) throw new Error(`Operation is missing name.`);
|
|
6145
6147
|
const camelCaseActionName = camelCase(operation.name);
|
|
6146
6148
|
const pascalCaseActionName = pascalCase(operation.name);
|
|
@@ -6151,7 +6153,7 @@ function makeTestCaseForOperation(operation, isPhDocumentOfTypeFunctionName) {
|
|
|
6151
6153
|
it('should handle ${camelCaseActionName} operation', () => {
|
|
6152
6154
|
const document = utils.createDocument();
|
|
6153
6155
|
const input = generateMock(
|
|
6154
|
-
${actionInputSchemaName}(),
|
|
6156
|
+
${actionInputSchemaName}(),${dateLikeInputFields.length > 0 ? `\n { ${dateLikeInputFields.map((field) => `${field}: ${VALID_ISO_DATETIME}`).join(", ")} },` : ""}
|
|
6155
6157
|
);
|
|
6156
6158
|
|
|
6157
6159
|
const updatedDocument = reducer(
|
|
@@ -6197,7 +6199,7 @@ const documentModelOperationsModuleTestFileTemplate = (v) => ts$1`
|
|
|
6197
6199
|
*/
|
|
6198
6200
|
|
|
6199
6201
|
import { describe, it, expect } from 'vitest';
|
|
6200
|
-
import { generateMock } from '
|
|
6202
|
+
import { generateMock } from 'document-model';
|
|
6201
6203
|
import {
|
|
6202
6204
|
reducer,
|
|
6203
6205
|
utils,
|
|
@@ -7448,6 +7450,39 @@ const scalarsValidation = {
|
|
|
7448
7450
|
AttachmentRef: "z.custom<`attachment://v${number}:${string}`>((val) => /^attachment:\\/\\/v\\d+:.+$/.test(val as string))",
|
|
7449
7451
|
...validationSchema
|
|
7450
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
|
+
}
|
|
7451
7486
|
const avoidOptionals = {
|
|
7452
7487
|
field: true,
|
|
7453
7488
|
inputValue: false
|
|
@@ -7835,7 +7870,11 @@ async function makeDocumentModelModulesOperationTestFiles(fileMakerArgs) {
|
|
|
7835
7870
|
});
|
|
7836
7871
|
}
|
|
7837
7872
|
async function makeOperationModuleTestFile(args) {
|
|
7838
|
-
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
|
+
};
|
|
7839
7878
|
const kebabCaseModuleName = kebabCase(module.name);
|
|
7840
7879
|
const moduleOperationsTypeName = `${pascalCase(module.name)}Operations`;
|
|
7841
7880
|
const filePath = path.join(testsDirPath, `${kebabCaseModuleName}.test.ts`);
|
|
@@ -7897,7 +7936,10 @@ async function makeOperationModuleTestFile(args) {
|
|
|
7897
7936
|
const testCasesToAdd = pipe(module.operations, filter((o) => {
|
|
7898
7937
|
const expectedTestCaseName = `should handle ${camelCase(o.name ?? "")} operation`;
|
|
7899
7938
|
return !testCaseNames.some((name) => name === expectedTestCaseName);
|
|
7900
|
-
}), 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
|
+
}));
|
|
7901
7943
|
describeCallBody.addStatements(testCasesToAdd);
|
|
7902
7944
|
const GENERATE_MOCK_NAME = "generateMock";
|
|
7903
7945
|
const GENERATE_MOCK_MODULE_SPECIFIER = "document-model";
|
|
@@ -8590,6 +8632,6 @@ async function makeSubgraphsIndexFile(args) {
|
|
|
8590
8632
|
await formatSourceFileWithPrettier(sourceFile);
|
|
8591
8633
|
}
|
|
8592
8634
|
//#endregion
|
|
8593
|
-
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 };
|
|
8594
8636
|
|
|
8595
|
-
//# sourceMappingURL=file-builders-
|
|
8637
|
+
//# sourceMappingURL=file-builders-DcAgx6QK.mjs.map
|