joist-codegen 2.5.0-next.25 → 2.5.0-next.27

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/build/config.cjs CHANGED
@@ -116,6 +116,8 @@ const config = zod.z.object({
116
116
  * of test database names, i.e. `mydb_test_1`, `mydb_test_2`, etc.
117
117
  */
118
118
  createFlushFunction: zod.z.optional(zod.z.union([zod.z.boolean(), zod.z.array(zod.z.string())])),
119
+ /** Creates a starter test alongside each new entity file unless explicitly disabled. */
120
+ scaffoldTests: zod.z.optional(zod.z.boolean()),
119
121
  entitiesDirectory: zod.z.string().default("./src/entities"),
120
122
  codegenPlugins: zod.z.optional(zod.z.array(zod.z.string())),
121
123
  entities: zod.z.record(zod.z.string(), entityConfig).default({}),
@@ -1 +1 @@
1
- {"version":3,"file":"config.cjs","names":["createFromBuffer","readFileSync","getPath","z","groupBy","getStiEntities","trueIfResolved","getLatestCodemodVersion","sortKeys","parse","join","existsSync","dirname"],"sources":["../src/config.ts"],"sourcesContent":["import { existsSync, promises as fs, readFileSync } from \"fs\";\nimport { dirname, join } from \"path\";\n\nimport { createFromBuffer } from \"@dprint/formatter\";\nimport { getPath } from \"@dprint/json\";\nimport { groupBy } from \"joist-utils\";\nimport { type ParseError, parse } from \"jsonc-parser\";\nimport { z } from \"zod\";\n\nimport { getLatestCodemodVersion } from \"./codemods/index.ts\";\nimport { type DbMetadata, type Entity, type EntityDbMetadata } from \"./EntityDbMetadata.ts\";\nimport { getStiEntities } from \"./inheritance.ts\";\nimport { logger } from \"./logger.ts\";\nimport { fail, sortKeys, trueIfResolved } from \"./utils.ts\";\n\nconst jsonFormatter = createFromBuffer(readFileSync(getPath()));\n\nconst fieldConfig = z\n .object({\n // For getters & ReactiveFields\n derived: z.optional(z.union([z.literal(\"sync\"), z.literal(\"async\")])),\n protected: z.optional(z.boolean()),\n ignore: z.optional(z.boolean()),\n superstruct: z.optional(z.string()),\n zodSchema: z.optional(z.string()),\n type: z.optional(z.string()),\n serde: z.optional(z.string()),\n stiDiscriminator: z.optional(z.record(z.string(), z.string())),\n stiType: z.optional(z.union([z.string(), z.array(z.string())])),\n // Allow subclasses to mark fields as required\n notNull: z.optional(z.boolean()),\n // Allow overriding scanEntities default detection for fields with defaults added by helpers\n hasDefault: z.optional(z.boolean()),\n // Exclude a (large jsonb/text) column from the default SELECT and expose it as a lazy-loaded LazyField\n lazy: z.optional(z.boolean()),\n /** Mark the entity for read locking whenever the field's value is read. */\n assertUnchanged: z.optional(z.boolean()),\n })\n .strict()\n .refine((field) => !field.assertUnchanged || (!field.derived && !field.lazy && !field.ignore), {\n message: \"assertUnchanged requires a non-derived, non-lazy, non-ignored field\",\n path: [\"assertUnchanged\"],\n });\n\nexport type FieldConfig = z.infer<typeof fieldConfig>;\n\nconst relationConfig = z\n .object({\n // For ReactiveReferences\n derived: z.optional(z.literal(\"async\")),\n polymorphic: z.optional(z.union([z.literal(\"notNull\"), z.literal(true)])),\n large: z.optional(z.boolean()),\n orderBy: z.optional(z.string()),\n /**\n * Controls whether this collection's `.get`/`.load` hide soft-deleted entities.\n *\n * Defaults to `\"exclude\"` (soft-deleted entities are hidden); set to `\"include\"` to have\n * this specific o2m/m2m always return soft-deleted entities from `.get`/`.load`.\n */\n softDeletes: z.optional(z.union([z.literal(\"include\"), z.literal(\"exclude\")])),\n // Allow pushing m2o/m2m/o2o relations in a base type (Task) down to a subtype (TaskOld)\n stiType: z.optional(z.union([z.string(), z.array(z.string())])),\n /**\n * Allow specializing a base type relation (SmallPublisher.group: SmallPublisherGroup).\n *\n * Self-referential FKs also support `subType: \"self\"` that means each subtype will point\n * at its own subtype.\n */\n subType: z.optional(z.string()),\n /** Allow skipping self-referential fields getting a `...Recursive` relation. */\n skipRecursiveRelations: z.optional(z.boolean()),\n // Allow marking m2o FKs as required on subclasses\n notNull: z.optional(z.boolean()),\n // Allow overriding scanEntities default detection for fields with defaults added by helpers\n hasDefault: z.optional(z.boolean()),\n })\n .strict();\n\nexport type RelationConfig = z.infer<typeof relationConfig>;\n\nconst uniqueByConfig = z\n .union([z.string(), z.array(z.string()), z.array(z.array(z.string()))])\n .transform(normalizeUniqueByConfig);\n\nconst entityConfig = z\n .object({\n tag: z.string(),\n tableName: z.optional(z.string()),\n fields: z.optional(z.record(z.string(), fieldConfig)),\n relations: z.optional(z.record(z.string(), relationConfig)),\n /** Whether this entity should be abstract, e.g. for inheritance a subtype must be instantiated instead of this type. */\n abstract: z.optional(z.boolean()),\n orderBy: z.optional(z.string()),\n uniqueBy: z.optional(uniqueByConfig),\n })\n .strict();\n\nexport type EntityConfig = z.infer<typeof entityConfig>;\n\nconst timestampConfig = z\n .object({\n /** The names to check for this timestamp, i.e. `created_at` `created`, etc. */\n names: z.array(z.string()),\n /** Whether this timestamp column is required to consider a table an entity, defaults to `false`. */\n required: z.optional(z.boolean()),\n })\n .strict();\n\nexport type TimestampConfig = z.infer<typeof timestampConfig>;\n\nexport const config = z\n .object({\n /** The _build-time_ database URL for reading database metadata. */\n databaseUrl: z.optional(z.string()),\n /** Your application's request-level `Context` type. */\n contextType: z.optional(z.string()),\n /** Your application's database client's `Transaction` type. */\n transactionType: z.optional(z.string()),\n /**\n * Allows the user to specify the `updated_at` / `created_at` column names to look up, and if they're optional.\n *\n * We default to looking for `updated_at`, `updatedAt`, `created_at`, `createdAt`, and optional to true,\n * e.g. tables are not required to have both timestamp columns to be considered entities.\n *\n * These defaults are the most lenient, to facilitate running Joist against an existing schema and\n * seeing all of your entities, regardless of your previous conventions.\n */\n timestampColumns: z.optional(\n z.object({\n createdAt: z.optional(timestampConfig),\n updatedAt: z.optional(timestampConfig),\n deletedAt: z.optional(timestampConfig),\n }),\n ),\n /**\n * Allows the user to have codegen output `Temporal` types instead of the base JS `Date`\n *\n * Additionally, allows for specifying the default time zone for `Temporal` types when converting dates to/from\n * the database.\n */\n temporal: z.optional(z.union([z.boolean(), z.object({ timeZone: z.string() })])),\n /**\n * By default, we create a `flush_database` function for fast testing.\n *\n * However, if you don't want to use this, or you have your own bespoke function like we do\n * that is more application-aware, then you can disable Joist's out-of-the-box one.\n *\n * If you have more than one test database, you can set `createFlushFunction` to the array\n * of test database names, i.e. `mydb_test_1`, `mydb_test_2`, etc.\n */\n createFlushFunction: z.optional(z.union([z.boolean(), z.array(z.string())])),\n entitiesDirectory: z.string().default(\"./src/entities\"),\n codegenPlugins: z.optional(z.array(z.string())),\n entities: z.record(z.string(), entityConfig).default({}),\n ignoredTables: z.optional(z.array(z.string())),\n /** The type of entity `id` fields; defaults to `tagged-string`. */\n idType: z.optional(z.union([z.literal(\"tagged-string\"), z.literal(\"untagged-string\"), z.literal(\"number\")])),\n /** The separator between entity tags and ids; defaults to `:`, and `\"\"` disables the separator. */\n tagDelimiter: z.optional(z.string()),\n /** How we should support non-deferred foreign keys. */\n nonDeferredForeignKeys: z.optional(z.union([z.literal(\"error\"), z.literal(\"warn\"), z.literal(\"ignore\")])),\n /** Enables esm output. */\n esm: z.optional(z.boolean()),\n /** Controls the style of GraphQL pagination scaffolding. */\n paginationStyle: z.optional(z.union([z.literal(\"cursor\"), z.literal(\"limit\")])).default(\"cursor\"),\n /** Enables documentation syncing between .md files and JSDocs. */\n docs: z.optional(z.boolean()),\n /** Installs Joist's bundled Agent Skills into `.claude/skills` and `.agents/skills`; on by default, set `false` to disable. */\n skills: z.optional(z.boolean()),\n /** Output a metadata-docs.ts file with entity/field documentation available at runtime. */\n outputDocs: z.optional(z.boolean()),\n /** Auto-set by probing the project's `tsconfig.json` file. */\n allowImportingTsExtensions: z.optional(z.boolean()),\n /** The latest Joist codemod counter that has been applied to this project. */\n codemodVersion: z.number().int().min(0).default(0),\n\n /** A list of postgres schemas to use for finding tables */\n schemas: z.optional(z.array(z.string())),\n })\n .strict();\n\nexport type Config = z.infer<typeof config> & {\n // We don't persist this, and instead just use it as a cache\n __tableToEntityName?: Record<string, string>;\n};\n\nexport const ormMaintainedFields = [\"createdAt\", \"updatedAt\"];\n\n/** Ensure the user doesn't have any typos in their config. */\nexport function warnInvalidConfigEntries(config: Config, db: DbMetadata): void {\n const entitiesByName = groupBy(db.entities, (e) => e.name);\n for (const [entityName, entityConfig] of Object.entries(config.entities)) {\n const entities = entitiesByName[entityName];\n if (!entities) {\n logger.warn(`Found config for non-existent entity ${entityName}`);\n continue;\n }\n // We don't have keyBy...\n const [entity] = entities;\n\n // Check fields\n const fields = [...entity.primitives, ...entity.enums];\n for (const [name, config] of Object.entries(entityConfig.fields || {})) {\n if (config.ignore) continue;\n let field = fields.find((f) => f.fieldName === name);\n // STI types might be in the base type\n if (!field && entity.stiDiscriminatorField) {\n const stiEntities = getStiEntities(db.entities).get(entity.name)?.subTypes;\n field = stiEntities?.flatMap((st) => [...st.primitives, ...st.enums]).find((f) => f.fieldName === name);\n }\n if (!field) logger.warn(`Found config for non-existent field ${entityName}.${name}`);\n }\n\n // Check relations\n const relations = [\n ...entity.manyToOnes,\n ...entity.oneToManys,\n ...entity.manyToManys,\n ...entity.manyToManyEnums,\n ...entity.oneToOnes,\n ...entity.largeOneToManys,\n ...entity.largeManyToManys,\n ...entity.polymorphics,\n ];\n for (const [name, _] of Object.entries(entityConfig.relations || {})) {\n let relation = relations.find((r) => r.fieldName === name);\n // STI types might be in the subtypes\n if (!relation && entity.stiDiscriminatorField) {\n const stiEntities = getStiEntities(db.entities).get(entity.name)?.subTypes;\n relation = stiEntities\n ?.flatMap((entity) => [\n ...entity.manyToOnes,\n ...entity.oneToManys,\n ...entity.manyToManys,\n ...entity.oneToOnes,\n ...entity.largeOneToManys,\n ...entity.largeManyToManys,\n ...entity.polymorphics,\n ])\n ?.find((f) => f.fieldName === name);\n }\n // CTI subtype specializations (i.e. SmallPublisher.group: SmallPublisherGroup) need to look in the base type\n if (!relation && entity.baseType) {\n const baseType = entity.baseType;\n relation = [\n ...baseType.manyToOnes,\n ...baseType.oneToManys,\n ...baseType.manyToManys,\n ...baseType.oneToOnes,\n ...baseType.largeOneToManys,\n ...baseType.largeManyToManys,\n ...baseType.polymorphics,\n ].find((f) => f.fieldName === name);\n }\n\n if (!relation) logger.warn(`Found config for non-existent relation ${entityName}.${name}`);\n }\n\n const uniqueFields = [\n ...entity.primitives,\n ...entity.enums,\n ...entity.pgEnums,\n ...entity.manyToOnes,\n ...entity.polymorphics,\n ];\n for (const uniqueBy of entityConfig.uniqueBy || []) {\n for (const name of uniqueBy) {\n const field = uniqueFields.find((f) => f.fieldName === name);\n if (!field) {\n logger.warn(`Found uniqueBy for non-existent or non-queryable field ${entityName}.${name}`);\n } else if (field.kind === \"primitive\" && (field.derived || field.customSerde)) {\n logger.warn(`Found uniqueBy for unsupported primitive field ${entityName}.${name}`);\n } else if (field.kind === \"enum\" && (field.derived || field.isArray)) {\n logger.warn(`Found uniqueBy for unsupported enum field ${entityName}.${name}`);\n }\n }\n }\n }\n}\n\nexport function isGetterField(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.fields?.[fieldName]?.derived === \"sync\";\n}\n\nexport function isReactiveField(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.fields?.[fieldName]?.derived === \"async\";\n}\n\nexport function isReactiveReference(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.relations?.[fieldName]?.derived === \"async\";\n}\n\n/** Returns true if this m2m relation is configured as a ReactiveManyToMany (derived: async). */\nexport function isReactiveManyToMany(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.relations?.[fieldName]?.derived === \"async\";\n}\n\nexport function isProtected(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.fields?.[fieldName]?.protected === true;\n}\n\n/** Whether a column should be excluded from the default SELECT and exposed as a lazy-loaded `LazyField`. */\nexport function isLazyField(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.fields?.[fieldName]?.lazy === true;\n}\n\nexport function serdeConfig(config: Config, entity: Entity, fieldName: string): string | undefined {\n return config.entities[entity.name]?.fields?.[fieldName]?.serde;\n}\n\nexport function superstructConfig(config: Config, entity: Entity, fieldName: string): string | undefined {\n return config.entities[entity.name]?.fields?.[fieldName]?.superstruct;\n}\n\nexport function zodSchemaConfig(config: Config, entity: Entity, fieldName: string): string | undefined {\n return config.entities[entity.name]?.fields?.[fieldName]?.zodSchema;\n}\n\nexport function fieldTypeConfig(config: Config, entity: Entity, fieldName: string): string | undefined {\n return config.entities[entity.name]?.fields?.[fieldName]?.type;\n}\n\nexport function isLargeCollection(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.relations?.[fieldName]?.large === true;\n}\n\n/** Whether a collection should include (or exclude) soft-deleted entities from `.get`/`.load`. */\nexport function softDeletesConfig(\n config: Config,\n entity: Entity,\n fieldName: string,\n): \"include\" | \"exclude\" | undefined {\n return config.entities[entity.name]?.relations?.[fieldName]?.softDeletes;\n}\n\nexport function isFieldIgnored(\n config: Config,\n entity: Entity,\n fieldName: string,\n notNull: boolean = false,\n hasDefault: boolean = false,\n): boolean {\n const ignore = config.entities[entity.name]?.fields?.[fieldName]?.ignore === true;\n if (ignore && notNull && !hasDefault) {\n fail(\n `notNull field ${entity.name}.${fieldName} cannot be ignored. Alter the column to be optional or have a default value prior to ignoring it.`,\n );\n }\n return ignore;\n}\n\nexport function isFieldHasDefault(config: Config, entity: Entity, fieldName: string): boolean {\n const entityConfig = config.entities[entity.name] ?? {};\n const fieldConfig = entityConfig.fields?.[fieldName] ?? entityConfig.relations?.[fieldName] ?? {};\n return fieldConfig.hasDefault === true;\n}\n\nconst configPath = \"./joist-config.json\";\n\nexport async function loadConfig(): Promise<Config> {\n const exists = await trueIfResolved(fs.access(configPath));\n if (exists) {\n const content = await fs.readFile(configPath);\n const result = config.safeParse(stripLegacyConfigKeys(JSON.parse(content.toString())));\n if (!result.success) {\n throw new Error(\n `Invalid joist-config.json: ${result.error.issues\n .map((ze) => `${ze.path.map(String).join(\"/\")} ${ze.message}`)\n .join(\"\\n\")}`,\n );\n }\n result.data.allowImportingTsExtensions ??= projectIsUsingEsmWithImports();\n return result.data;\n }\n // Brand-new projects should not be prompted to run historical codemods.\n const initial = config.parse({ codemodVersion: getLatestCodemodVersion() });\n initial.allowImportingTsExtensions ??= projectIsUsingEsmWithImports();\n return initial;\n}\n\n/**\n * Writes the potentially-updated config entry back to `joist-config.json`.\n *\n * We format the output with prettier so it should both a) look nice and b) be deterministic,\n * such that no changes to the config show up as noops to the scm.\n */\nexport async function writeConfig(config: Config): Promise<void> {\n const sorted: Partial<Config> = sortKeys(config);\n delete sorted.__tableToEntityName;\n delete sorted.allowImportingTsExtensions;\n if (sorted.paginationStyle === \"cursor\") {\n delete sorted.paginationStyle;\n }\n const input = JSON.stringify(sorted);\n const content = jsonFormatter.formatText({ filePath: \"test.json\", fileText: input });\n await fs.writeFile(configPath, content);\n}\n\nexport function stripStiPlaceholders(config: Config, entities: EntityDbMetadata[]): void {\n // Defacto (with today's setup) the config of STI entities lives on the base entity,\n // so don't write confusing subtype-specific entries into the config file.\n // ...hopefully we don't have any code accidentally looking for the STI config...\n for (const entity of entities) {\n if (entity.inheritanceType === \"sti\" && entity.stiDiscriminatorValue) {\n delete config.entities[entity.name];\n }\n }\n}\n\n/** Applies defaults to the timestamp config. */\nexport function getTimestampConfig(config: Config): {\n updatedAtConf: Required<TimestampConfig>;\n createdAtConf: Required<TimestampConfig>;\n deletedAtConf: Required<TimestampConfig>;\n} {\n return {\n createdAtConf: {\n names: [\"created_at\", \"createdAt\"],\n required: false,\n ...config?.timestampColumns?.createdAt,\n },\n updatedAtConf: {\n names: [\"updated_at\", \"updatedAt\"],\n required: false,\n ...config?.timestampColumns?.updatedAt,\n },\n deletedAtConf: {\n names: [\"deleted_at\", \"deletedAt\"],\n required: false,\n ...config?.timestampColumns?.deletedAt,\n },\n };\n}\n\nfunction projectIsUsingEsmWithImports(): boolean {\n // Attempt to find the project's tsconfig.json in the current directory or up the directory hierarchy\n const configPath = findTsConfigFile(process.cwd());\n if (!configPath) {\n return false;\n }\n try {\n // Use jsonc-parser to parse the tsconfig.json file (not the old tsc readConfigFile which was\n // dropped in TypeScript 7), allowing for comments and trailing commas.\n const errors: ParseError[] = [];\n const parsed: unknown = parse(readFileSync(configPath, \"utf8\"), errors, { allowTrailingComma: true });\n if (errors.length > 0 || typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) return false;\n const compilerOptions = (parsed as Record<string, unknown>).compilerOptions;\n return (\n typeof compilerOptions === \"object\" &&\n compilerOptions !== null &&\n !Array.isArray(compilerOptions) &&\n (compilerOptions as Record<string, unknown>).allowImportingTsExtensions === true\n );\n } catch {\n return false;\n }\n}\n\n/** Normalizes `uniqueBy` config sugar into runtime identity candidates. */\nfunction normalizeUniqueByConfig(uniqueBy: string | string[] | string[][]): string[][] {\n if (typeof uniqueBy === \"string\") return [[uniqueBy]];\n if (uniqueBy.every((field) => typeof field === \"string\")) return [uniqueBy];\n return uniqueBy;\n}\n\nfunction stripLegacyConfigKeys(raw: unknown): unknown {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) {\n return raw;\n }\n // Accept old configs so the deprecated key disappears on the next write.\n const parsed = { ...(raw as Record<string, unknown>) };\n delete parsed.version;\n return parsed;\n}\n\n/** Finds the nearest `tsconfig.json` in `directory` or one of its ancestors. */\nfunction findTsConfigFile(directory: string): string | undefined {\n while (true) {\n const fileName = join(directory, \"tsconfig.json\");\n if (existsSync(fileName)) return fileName;\n const parent = dirname(directory);\n if (parent === directory) return undefined;\n directory = parent;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAM,iBAAA,GAAgBA,kBAAAA,iBAAAA,EAAAA,GAAiBC,GAAAA,aAAAA,EAAAA,GAAaC,aAAAA,QAAAA,CAAQ,CAAC,CAAC;AAE9D,MAAM,cAAcC,IAAAA,EACjB,OAAO;CAEN,SAASA,IAAAA,EAAE,SAASA,IAAAA,EAAE,MAAM,CAACA,IAAAA,EAAE,QAAQ,MAAM,GAAGA,IAAAA,EAAE,QAAQ,OAAO,CAAC,CAAC,CAAC;CACpE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rF,IAAI,OAAO,aAAa,UAAU,OAAO,CAAC,CAAC,QAAQ,CAAC;CACpD,IAAI,SAAS,OAAO,UAAU,OAAO,UAAU,QAAQ,GAAG,OAAO,CAAC,QAAQ;CAC1E,OAAO;AACT;AAEA,SAAS,sBAAsB,KAAuB;CACpD,IAAI,CAAC,OAAO,OAAO,QAAQ,YAAY,MAAM,QAAQ,GAAG,GACtD,OAAO;CAGT,MAAM,SAAS,EAAE,GAAI,IAAgC;CACrD,OAAO,OAAO;CACd,OAAO;AACT;;AAGA,SAAS,iBAAiB,WAAuC;CAC/D,OAAO,MAAM;EACX,MAAM,YAAA,GAAWS,KAAAA,KAAAA,CAAK,WAAW,eAAe;EAChD,KAAA,GAAIC,GAAAA,WAAAA,CAAW,QAAQ,GAAG,OAAO;EACjC,MAAM,UAAA,GAASC,KAAAA,QAAAA,CAAQ,SAAS;EAChC,IAAI,WAAW,WAAW,OAAO,KAAA;EACjC,YAAY;CACd;AACF"}
1
+ {"version":3,"file":"config.cjs","names":["createFromBuffer","readFileSync","getPath","z","groupBy","getStiEntities","trueIfResolved","getLatestCodemodVersion","sortKeys","parse","join","existsSync","dirname"],"sources":["../src/config.ts"],"sourcesContent":["import { existsSync, promises as fs, readFileSync } from \"fs\";\nimport { dirname, join } from \"path\";\n\nimport { createFromBuffer } from \"@dprint/formatter\";\nimport { getPath } from \"@dprint/json\";\nimport { groupBy } from \"joist-utils\";\nimport { type ParseError, parse } from \"jsonc-parser\";\nimport { z } from \"zod\";\n\nimport { getLatestCodemodVersion } from \"./codemods/index.ts\";\nimport { type DbMetadata, type Entity, type EntityDbMetadata } from \"./EntityDbMetadata.ts\";\nimport { getStiEntities } from \"./inheritance.ts\";\nimport { logger } from \"./logger.ts\";\nimport { fail, sortKeys, trueIfResolved } from \"./utils.ts\";\n\nconst jsonFormatter = createFromBuffer(readFileSync(getPath()));\n\nconst fieldConfig = z\n .object({\n // For getters & ReactiveFields\n derived: z.optional(z.union([z.literal(\"sync\"), z.literal(\"async\")])),\n protected: z.optional(z.boolean()),\n ignore: z.optional(z.boolean()),\n superstruct: z.optional(z.string()),\n zodSchema: z.optional(z.string()),\n type: z.optional(z.string()),\n serde: z.optional(z.string()),\n stiDiscriminator: z.optional(z.record(z.string(), z.string())),\n stiType: z.optional(z.union([z.string(), z.array(z.string())])),\n // Allow subclasses to mark fields as required\n notNull: z.optional(z.boolean()),\n // Allow overriding scanEntities default detection for fields with defaults added by helpers\n hasDefault: z.optional(z.boolean()),\n // Exclude a (large jsonb/text) column from the default SELECT and expose it as a lazy-loaded LazyField\n lazy: z.optional(z.boolean()),\n /** Mark the entity for read locking whenever the field's value is read. */\n assertUnchanged: z.optional(z.boolean()),\n })\n .strict()\n .refine((field) => !field.assertUnchanged || (!field.derived && !field.lazy && !field.ignore), {\n message: \"assertUnchanged requires a non-derived, non-lazy, non-ignored field\",\n path: [\"assertUnchanged\"],\n });\n\nexport type FieldConfig = z.infer<typeof fieldConfig>;\n\nconst relationConfig = z\n .object({\n // For ReactiveReferences\n derived: z.optional(z.literal(\"async\")),\n polymorphic: z.optional(z.union([z.literal(\"notNull\"), z.literal(true)])),\n large: z.optional(z.boolean()),\n orderBy: z.optional(z.string()),\n /**\n * Controls whether this collection's `.get`/`.load` hide soft-deleted entities.\n *\n * Defaults to `\"exclude\"` (soft-deleted entities are hidden); set to `\"include\"` to have\n * this specific o2m/m2m always return soft-deleted entities from `.get`/`.load`.\n */\n softDeletes: z.optional(z.union([z.literal(\"include\"), z.literal(\"exclude\")])),\n // Allow pushing m2o/m2m/o2o relations in a base type (Task) down to a subtype (TaskOld)\n stiType: z.optional(z.union([z.string(), z.array(z.string())])),\n /**\n * Allow specializing a base type relation (SmallPublisher.group: SmallPublisherGroup).\n *\n * Self-referential FKs also support `subType: \"self\"` that means each subtype will point\n * at its own subtype.\n */\n subType: z.optional(z.string()),\n /** Allow skipping self-referential fields getting a `...Recursive` relation. */\n skipRecursiveRelations: z.optional(z.boolean()),\n // Allow marking m2o FKs as required on subclasses\n notNull: z.optional(z.boolean()),\n // Allow overriding scanEntities default detection for fields with defaults added by helpers\n hasDefault: z.optional(z.boolean()),\n })\n .strict();\n\nexport type RelationConfig = z.infer<typeof relationConfig>;\n\nconst uniqueByConfig = z\n .union([z.string(), z.array(z.string()), z.array(z.array(z.string()))])\n .transform(normalizeUniqueByConfig);\n\nconst entityConfig = z\n .object({\n tag: z.string(),\n tableName: z.optional(z.string()),\n fields: z.optional(z.record(z.string(), fieldConfig)),\n relations: z.optional(z.record(z.string(), relationConfig)),\n /** Whether this entity should be abstract, e.g. for inheritance a subtype must be instantiated instead of this type. */\n abstract: z.optional(z.boolean()),\n orderBy: z.optional(z.string()),\n uniqueBy: z.optional(uniqueByConfig),\n })\n .strict();\n\nexport type EntityConfig = z.infer<typeof entityConfig>;\n\nconst timestampConfig = z\n .object({\n /** The names to check for this timestamp, i.e. `created_at` `created`, etc. */\n names: z.array(z.string()),\n /** Whether this timestamp column is required to consider a table an entity, defaults to `false`. */\n required: z.optional(z.boolean()),\n })\n .strict();\n\nexport type TimestampConfig = z.infer<typeof timestampConfig>;\n\nexport const config = z\n .object({\n /** The _build-time_ database URL for reading database metadata. */\n databaseUrl: z.optional(z.string()),\n /** Your application's request-level `Context` type. */\n contextType: z.optional(z.string()),\n /** Your application's database client's `Transaction` type. */\n transactionType: z.optional(z.string()),\n /**\n * Allows the user to specify the `updated_at` / `created_at` column names to look up, and if they're optional.\n *\n * We default to looking for `updated_at`, `updatedAt`, `created_at`, `createdAt`, and optional to true,\n * e.g. tables are not required to have both timestamp columns to be considered entities.\n *\n * These defaults are the most lenient, to facilitate running Joist against an existing schema and\n * seeing all of your entities, regardless of your previous conventions.\n */\n timestampColumns: z.optional(\n z.object({\n createdAt: z.optional(timestampConfig),\n updatedAt: z.optional(timestampConfig),\n deletedAt: z.optional(timestampConfig),\n }),\n ),\n /**\n * Allows the user to have codegen output `Temporal` types instead of the base JS `Date`\n *\n * Additionally, allows for specifying the default time zone for `Temporal` types when converting dates to/from\n * the database.\n */\n temporal: z.optional(z.union([z.boolean(), z.object({ timeZone: z.string() })])),\n /**\n * By default, we create a `flush_database` function for fast testing.\n *\n * However, if you don't want to use this, or you have your own bespoke function like we do\n * that is more application-aware, then you can disable Joist's out-of-the-box one.\n *\n * If you have more than one test database, you can set `createFlushFunction` to the array\n * of test database names, i.e. `mydb_test_1`, `mydb_test_2`, etc.\n */\n createFlushFunction: z.optional(z.union([z.boolean(), z.array(z.string())])),\n /** Creates a starter test alongside each new entity file unless explicitly disabled. */\n scaffoldTests: z.optional(z.boolean()),\n entitiesDirectory: z.string().default(\"./src/entities\"),\n codegenPlugins: z.optional(z.array(z.string())),\n entities: z.record(z.string(), entityConfig).default({}),\n ignoredTables: z.optional(z.array(z.string())),\n /** The type of entity `id` fields; defaults to `tagged-string`. */\n idType: z.optional(z.union([z.literal(\"tagged-string\"), z.literal(\"untagged-string\"), z.literal(\"number\")])),\n /** The separator between entity tags and ids; defaults to `:`, and `\"\"` disables the separator. */\n tagDelimiter: z.optional(z.string()),\n /** How we should support non-deferred foreign keys. */\n nonDeferredForeignKeys: z.optional(z.union([z.literal(\"error\"), z.literal(\"warn\"), z.literal(\"ignore\")])),\n /** Enables esm output. */\n esm: z.optional(z.boolean()),\n /** Controls the style of GraphQL pagination scaffolding. */\n paginationStyle: z.optional(z.union([z.literal(\"cursor\"), z.literal(\"limit\")])).default(\"cursor\"),\n /** Enables documentation syncing between .md files and JSDocs. */\n docs: z.optional(z.boolean()),\n /** Installs Joist's bundled Agent Skills into `.claude/skills` and `.agents/skills`; on by default, set `false` to disable. */\n skills: z.optional(z.boolean()),\n /** Output a metadata-docs.ts file with entity/field documentation available at runtime. */\n outputDocs: z.optional(z.boolean()),\n /** Auto-set by probing the project's `tsconfig.json` file. */\n allowImportingTsExtensions: z.optional(z.boolean()),\n /** The latest Joist codemod counter that has been applied to this project. */\n codemodVersion: z.number().int().min(0).default(0),\n\n /** A list of postgres schemas to use for finding tables */\n schemas: z.optional(z.array(z.string())),\n })\n .strict();\n\nexport type Config = z.infer<typeof config> & {\n // We don't persist this, and instead just use it as a cache\n __tableToEntityName?: Record<string, string>;\n};\n\nexport const ormMaintainedFields = [\"createdAt\", \"updatedAt\"];\n\n/** Ensure the user doesn't have any typos in their config. */\nexport function warnInvalidConfigEntries(config: Config, db: DbMetadata): void {\n const entitiesByName = groupBy(db.entities, (e) => e.name);\n for (const [entityName, entityConfig] of Object.entries(config.entities)) {\n const entities = entitiesByName[entityName];\n if (!entities) {\n logger.warn(`Found config for non-existent entity ${entityName}`);\n continue;\n }\n // We don't have keyBy...\n const [entity] = entities;\n\n // Check fields\n const fields = [...entity.primitives, ...entity.enums];\n for (const [name, config] of Object.entries(entityConfig.fields || {})) {\n if (config.ignore) continue;\n let field = fields.find((f) => f.fieldName === name);\n // STI types might be in the base type\n if (!field && entity.stiDiscriminatorField) {\n const stiEntities = getStiEntities(db.entities).get(entity.name)?.subTypes;\n field = stiEntities?.flatMap((st) => [...st.primitives, ...st.enums]).find((f) => f.fieldName === name);\n }\n if (!field) logger.warn(`Found config for non-existent field ${entityName}.${name}`);\n }\n\n // Check relations\n const relations = [\n ...entity.manyToOnes,\n ...entity.oneToManys,\n ...entity.manyToManys,\n ...entity.manyToManyEnums,\n ...entity.oneToOnes,\n ...entity.largeOneToManys,\n ...entity.largeManyToManys,\n ...entity.polymorphics,\n ];\n for (const [name, _] of Object.entries(entityConfig.relations || {})) {\n let relation = relations.find((r) => r.fieldName === name);\n // STI types might be in the subtypes\n if (!relation && entity.stiDiscriminatorField) {\n const stiEntities = getStiEntities(db.entities).get(entity.name)?.subTypes;\n relation = stiEntities\n ?.flatMap((entity) => [\n ...entity.manyToOnes,\n ...entity.oneToManys,\n ...entity.manyToManys,\n ...entity.oneToOnes,\n ...entity.largeOneToManys,\n ...entity.largeManyToManys,\n ...entity.polymorphics,\n ])\n ?.find((f) => f.fieldName === name);\n }\n // CTI subtype specializations (i.e. SmallPublisher.group: SmallPublisherGroup) need to look in the base type\n if (!relation && entity.baseType) {\n const baseType = entity.baseType;\n relation = [\n ...baseType.manyToOnes,\n ...baseType.oneToManys,\n ...baseType.manyToManys,\n ...baseType.oneToOnes,\n ...baseType.largeOneToManys,\n ...baseType.largeManyToManys,\n ...baseType.polymorphics,\n ].find((f) => f.fieldName === name);\n }\n\n if (!relation) logger.warn(`Found config for non-existent relation ${entityName}.${name}`);\n }\n\n const uniqueFields = [\n ...entity.primitives,\n ...entity.enums,\n ...entity.pgEnums,\n ...entity.manyToOnes,\n ...entity.polymorphics,\n ];\n for (const uniqueBy of entityConfig.uniqueBy || []) {\n for (const name of uniqueBy) {\n const field = uniqueFields.find((f) => f.fieldName === name);\n if (!field) {\n logger.warn(`Found uniqueBy for non-existent or non-queryable field ${entityName}.${name}`);\n } else if (field.kind === \"primitive\" && (field.derived || field.customSerde)) {\n logger.warn(`Found uniqueBy for unsupported primitive field ${entityName}.${name}`);\n } else if (field.kind === \"enum\" && (field.derived || field.isArray)) {\n logger.warn(`Found uniqueBy for unsupported enum field ${entityName}.${name}`);\n }\n }\n }\n }\n}\n\nexport function isGetterField(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.fields?.[fieldName]?.derived === \"sync\";\n}\n\nexport function isReactiveField(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.fields?.[fieldName]?.derived === \"async\";\n}\n\nexport function isReactiveReference(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.relations?.[fieldName]?.derived === \"async\";\n}\n\n/** Returns true if this m2m relation is configured as a ReactiveManyToMany (derived: async). */\nexport function isReactiveManyToMany(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.relations?.[fieldName]?.derived === \"async\";\n}\n\nexport function isProtected(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.fields?.[fieldName]?.protected === true;\n}\n\n/** Whether a column should be excluded from the default SELECT and exposed as a lazy-loaded `LazyField`. */\nexport function isLazyField(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.fields?.[fieldName]?.lazy === true;\n}\n\nexport function serdeConfig(config: Config, entity: Entity, fieldName: string): string | undefined {\n return config.entities[entity.name]?.fields?.[fieldName]?.serde;\n}\n\nexport function superstructConfig(config: Config, entity: Entity, fieldName: string): string | undefined {\n return config.entities[entity.name]?.fields?.[fieldName]?.superstruct;\n}\n\nexport function zodSchemaConfig(config: Config, entity: Entity, fieldName: string): string | undefined {\n return config.entities[entity.name]?.fields?.[fieldName]?.zodSchema;\n}\n\nexport function fieldTypeConfig(config: Config, entity: Entity, fieldName: string): string | undefined {\n return config.entities[entity.name]?.fields?.[fieldName]?.type;\n}\n\nexport function isLargeCollection(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.relations?.[fieldName]?.large === true;\n}\n\n/** Whether a collection should include (or exclude) soft-deleted entities from `.get`/`.load`. */\nexport function softDeletesConfig(\n config: Config,\n entity: Entity,\n fieldName: string,\n): \"include\" | \"exclude\" | undefined {\n return config.entities[entity.name]?.relations?.[fieldName]?.softDeletes;\n}\n\nexport function isFieldIgnored(\n config: Config,\n entity: Entity,\n fieldName: string,\n notNull: boolean = false,\n hasDefault: boolean = false,\n): boolean {\n const ignore = config.entities[entity.name]?.fields?.[fieldName]?.ignore === true;\n if (ignore && notNull && !hasDefault) {\n fail(\n `notNull field ${entity.name}.${fieldName} cannot be ignored. Alter the column to be optional or have a default value prior to ignoring it.`,\n );\n }\n return ignore;\n}\n\nexport function isFieldHasDefault(config: Config, entity: Entity, fieldName: string): boolean {\n const entityConfig = config.entities[entity.name] ?? {};\n const fieldConfig = entityConfig.fields?.[fieldName] ?? entityConfig.relations?.[fieldName] ?? {};\n return fieldConfig.hasDefault === true;\n}\n\nconst configPath = \"./joist-config.json\";\n\nexport async function loadConfig(): Promise<Config> {\n const exists = await trueIfResolved(fs.access(configPath));\n if (exists) {\n const content = await fs.readFile(configPath);\n const result = config.safeParse(stripLegacyConfigKeys(JSON.parse(content.toString())));\n if (!result.success) {\n throw new Error(\n `Invalid joist-config.json: ${result.error.issues\n .map((ze) => `${ze.path.map(String).join(\"/\")} ${ze.message}`)\n .join(\"\\n\")}`,\n );\n }\n result.data.allowImportingTsExtensions ??= projectIsUsingEsmWithImports();\n return result.data;\n }\n // Brand-new projects should not be prompted to run historical codemods.\n const initial = config.parse({ codemodVersion: getLatestCodemodVersion() });\n initial.allowImportingTsExtensions ??= projectIsUsingEsmWithImports();\n return initial;\n}\n\n/**\n * Writes the potentially-updated config entry back to `joist-config.json`.\n *\n * We format the output with prettier so it should both a) look nice and b) be deterministic,\n * such that no changes to the config show up as noops to the scm.\n */\nexport async function writeConfig(config: Config): Promise<void> {\n const sorted: Partial<Config> = sortKeys(config);\n delete sorted.__tableToEntityName;\n delete sorted.allowImportingTsExtensions;\n if (sorted.paginationStyle === \"cursor\") {\n delete sorted.paginationStyle;\n }\n const input = JSON.stringify(sorted);\n const content = jsonFormatter.formatText({ filePath: \"test.json\", fileText: input });\n await fs.writeFile(configPath, content);\n}\n\nexport function stripStiPlaceholders(config: Config, entities: EntityDbMetadata[]): void {\n // Defacto (with today's setup) the config of STI entities lives on the base entity,\n // so don't write confusing subtype-specific entries into the config file.\n // ...hopefully we don't have any code accidentally looking for the STI config...\n for (const entity of entities) {\n if (entity.inheritanceType === \"sti\" && entity.stiDiscriminatorValue) {\n delete config.entities[entity.name];\n }\n }\n}\n\n/** Applies defaults to the timestamp config. */\nexport function getTimestampConfig(config: Config): {\n updatedAtConf: Required<TimestampConfig>;\n createdAtConf: Required<TimestampConfig>;\n deletedAtConf: Required<TimestampConfig>;\n} {\n return {\n createdAtConf: {\n names: [\"created_at\", \"createdAt\"],\n required: false,\n ...config?.timestampColumns?.createdAt,\n },\n updatedAtConf: {\n names: [\"updated_at\", \"updatedAt\"],\n required: false,\n ...config?.timestampColumns?.updatedAt,\n },\n deletedAtConf: {\n names: [\"deleted_at\", \"deletedAt\"],\n required: false,\n ...config?.timestampColumns?.deletedAt,\n },\n };\n}\n\nfunction projectIsUsingEsmWithImports(): boolean {\n // Attempt to find the project's tsconfig.json in the current directory or up the directory hierarchy\n const configPath = findTsConfigFile(process.cwd());\n if (!configPath) {\n return false;\n }\n try {\n // Use jsonc-parser to parse the tsconfig.json file (not the old tsc readConfigFile which was\n // dropped in TypeScript 7), allowing for comments and trailing commas.\n const errors: ParseError[] = [];\n const parsed: unknown = parse(readFileSync(configPath, \"utf8\"), errors, { allowTrailingComma: true });\n if (errors.length > 0 || typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) return false;\n const compilerOptions = (parsed as Record<string, unknown>).compilerOptions;\n return (\n typeof compilerOptions === \"object\" &&\n compilerOptions !== null &&\n !Array.isArray(compilerOptions) &&\n (compilerOptions as Record<string, unknown>).allowImportingTsExtensions === true\n );\n } catch {\n return false;\n }\n}\n\n/** Normalizes `uniqueBy` config sugar into runtime identity candidates. */\nfunction normalizeUniqueByConfig(uniqueBy: string | string[] | string[][]): string[][] {\n if (typeof uniqueBy === \"string\") return [[uniqueBy]];\n if (uniqueBy.every((field) => typeof field === \"string\")) return [uniqueBy];\n return uniqueBy;\n}\n\nfunction stripLegacyConfigKeys(raw: unknown): unknown {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) {\n return raw;\n }\n // Accept old configs so the deprecated key disappears on the next write.\n const parsed = { ...(raw as Record<string, unknown>) };\n delete parsed.version;\n return parsed;\n}\n\n/** Finds the nearest `tsconfig.json` in `directory` or one of its ancestors. */\nfunction findTsConfigFile(directory: string): string | undefined {\n while (true) {\n const fileName = join(directory, \"tsconfig.json\");\n if (existsSync(fileName)) return fileName;\n const parent = dirname(directory);\n if (parent === directory) return undefined;\n directory = parent;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAM,iBAAA,GAAgBA,kBAAAA,iBAAAA,EAAAA,GAAiBC,GAAAA,aAAAA,EAAAA,GAAaC,aAAAA,QAAAA,CAAQ,CAAC,CAAC;AAE9D,MAAM,cAAcC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AM,QAAQ,MAAM,GAAG,OAAO;EACxG,MAAM,kBAAmB,OAAmC;EAC5D,OACE,OAAO,oBAAoB,YAC3B,oBAAoB,QACpB,CAAC,MAAM,QAAQ,eAAe,KAC7B,gBAA4C,+BAA+B;CAEhF,QAAQ;EACN,OAAO;CACT;AACF;;AAGA,SAAS,wBAAwB,UAAsD;CACrF,IAAI,OAAO,aAAa,UAAU,OAAO,CAAC,CAAC,QAAQ,CAAC;CACpD,IAAI,SAAS,OAAO,UAAU,OAAO,UAAU,QAAQ,GAAG,OAAO,CAAC,QAAQ;CAC1E,OAAO;AACT;AAEA,SAAS,sBAAsB,KAAuB;CACpD,IAAI,CAAC,OAAO,OAAO,QAAQ,YAAY,MAAM,QAAQ,GAAG,GACtD,OAAO;CAGT,MAAM,SAAS,EAAE,GAAI,IAAgC;CACrD,OAAO,OAAO;CACd,OAAO;AACT;;AAGA,SAAS,iBAAiB,WAAuC;CAC/D,OAAO,MAAM;EACX,MAAM,YAAA,GAAWS,KAAAA,KAAAA,CAAK,WAAW,eAAe;EAChD,KAAA,GAAIC,GAAAA,WAAAA,CAAW,QAAQ,GAAG,OAAO;EACjC,MAAM,UAAA,GAASC,KAAAA,QAAAA,CAAQ,SAAS;EAChC,IAAI,WAAW,WAAW,OAAO,KAAA;EACjC,YAAY;CACd;AACF"}
@@ -91,6 +91,7 @@ export declare const config: z.ZodObject<{
91
91
  timeZone: z.ZodString;
92
92
  }, z.core.$strip>]>>;
93
93
  createFlushFunction: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
94
+ scaffoldTests: z.ZodOptional<z.ZodBoolean>;
94
95
  entitiesDirectory: z.ZodDefault<z.ZodString>;
95
96
  codegenPlugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
96
97
  entities: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.cts","names":[],"sources":["../src/config.ts"],"mappings":";;cA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c,eACd,QAAQ,QACR,QAAQ,QACR,mBACA,mBACA;wBAWc,kBAAkB,QAAQ,QAAQ,QAAQ,QAAQ;wBAQ5C,cAAc,QAAQ;;;;;;;wBA2BtB,YAAY,QAAQ,SAAS;wBAYnC,qBAAqB,QAAQ,QAAQ,UAAU;;wBAY/C,mBAAmB,QAAQ;EACzC,eAAe,SAAS;EACxB,eAAe,SAAS;EACxB,eAAe,SAAS"}
@@ -91,6 +91,7 @@ export declare const config: z.ZodObject<{
91
91
  timeZone: z.ZodString;
92
92
  }, z.core.$strip>]>>;
93
93
  createFlushFunction: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
94
+ scaffoldTests: z.ZodOptional<z.ZodBoolean>;
94
95
  entitiesDirectory: z.ZodDefault<z.ZodString>;
95
96
  codegenPlugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
96
97
  entities: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.mts","names":[],"sources":["../src/config.ts"],"mappings":";;cAiBM,aAAW,EAAA;;;;;;;;;;;;;;GAyBb,EAAA,KAAA;YAEQ,cAAc,EAAE,aAAa;cAEnC,gBAAc,EAAA;;;;;;;;;;;GA8BT,EAAA,KAAA;YAEC,iBAAiB,EAAE,aAAa;cAMtC,cAAY,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAWP,EAAA,KAAA;YAEC,eAAe,EAAE,aAAa;cAEpC,iBAAe,EAAA;;;GAOV,EAAA,KAAA;YAEC,kBAAkB,EAAE,aAAa;qBAEhC,QAAM,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqER,EAAA,KAAA;YAEC,SAAS,EAAE,aAAa;EAElC,sBAAsB;;qBAGX;;wBAGG,yBAAyB,QAAQ,QAAQ,IAAI;wBA2F7C,cAAc,QAAQ,QAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuER,EAAA,KAAA;YAEC,SAAS,EAAE,aAAa;EAElC,sBAAsB;;qBAGX;;wBAGG,yBAAyB,QAAQ,QAAQ,IAAI;wBA2F7C,cAAc,QAAQ,QAAQ,QAAQ,QAAQ;wBAI9C,gBAAgB,QAAQ,QAAQ,QAAQ,QAAQ;wBAIhD,oBAAoB,QAAQ,QAAQ,QAAQ,QAAQ;;wBAKpD,qBAAqB,QAAQ,QAAQ,QAAQ,QAAQ;wBAIrD,YAAY,QAAQ,QAAQ,QAAQ,QAAQ;;wBAK5C,YAAY,QAAQ,QAAQ,QAAQ,QAAQ;wBAI5C,YAAY,QAAQ,QAAQ,QAAQ,QAAQ;wBAI5C,kBAAkB,QAAQ,QAAQ,QAAQ,QAAQ;wBAIlD,gBAAgB,QAAQ,QAAQ,QAAQ,QAAQ;wBAIhD,gBAAgB,QAAQ,QAAQ,QAAQ,QAAQ;wBAIhD,kBAAkB,QAAQ,QAAQ,QAAQ,QAAQ;;wBAKlD,kBACd,QAAQ,QACR,QAAQ,QACR;wBAKc,eACd,QAAQ,QACR,QAAQ,QACR,mBACA,mBACA;wBAWc,kBAAkB,QAAQ,QAAQ,QAAQ,QAAQ;wBAQ5C,cAAc,QAAQ;;;;;;;wBA2BtB,YAAY,QAAQ,SAAS;wBAYnC,qBAAqB,QAAQ,QAAQ,UAAU;;wBAY/C,mBAAmB,QAAQ;EACzC,eAAe,SAAS;EACxB,eAAe,SAAS;EACxB,eAAe,SAAS"}
package/build/config.js CHANGED
@@ -115,6 +115,8 @@ const config = z.object({
115
115
  * of test database names, i.e. `mydb_test_1`, `mydb_test_2`, etc.
116
116
  */
117
117
  createFlushFunction: z.optional(z.union([z.boolean(), z.array(z.string())])),
118
+ /** Creates a starter test alongside each new entity file unless explicitly disabled. */
119
+ scaffoldTests: z.optional(z.boolean()),
118
120
  entitiesDirectory: z.string().default("./src/entities"),
119
121
  codegenPlugins: z.optional(z.array(z.string())),
120
122
  entities: z.record(z.string(), entityConfig).default({}),
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":["fs"],"sources":["../src/config.ts"],"sourcesContent":["import { existsSync, promises as fs, readFileSync } from \"fs\";\nimport { dirname, join } from \"path\";\n\nimport { createFromBuffer } from \"@dprint/formatter\";\nimport { getPath } from \"@dprint/json\";\nimport { groupBy } from \"joist-utils\";\nimport { type ParseError, parse } from \"jsonc-parser\";\nimport { z } from \"zod\";\n\nimport { getLatestCodemodVersion } from \"./codemods/index.ts\";\nimport { type DbMetadata, type Entity, type EntityDbMetadata } from \"./EntityDbMetadata.ts\";\nimport { getStiEntities } from \"./inheritance.ts\";\nimport { logger } from \"./logger.ts\";\nimport { fail, sortKeys, trueIfResolved } from \"./utils.ts\";\n\nconst jsonFormatter = createFromBuffer(readFileSync(getPath()));\n\nconst fieldConfig = z\n .object({\n // For getters & ReactiveFields\n derived: z.optional(z.union([z.literal(\"sync\"), z.literal(\"async\")])),\n protected: z.optional(z.boolean()),\n ignore: z.optional(z.boolean()),\n superstruct: z.optional(z.string()),\n zodSchema: z.optional(z.string()),\n type: z.optional(z.string()),\n serde: z.optional(z.string()),\n stiDiscriminator: z.optional(z.record(z.string(), z.string())),\n stiType: z.optional(z.union([z.string(), z.array(z.string())])),\n // Allow subclasses to mark fields as required\n notNull: z.optional(z.boolean()),\n // Allow overriding scanEntities default detection for fields with defaults added by helpers\n hasDefault: z.optional(z.boolean()),\n // Exclude a (large jsonb/text) column from the default SELECT and expose it as a lazy-loaded LazyField\n lazy: z.optional(z.boolean()),\n /** Mark the entity for read locking whenever the field's value is read. */\n assertUnchanged: z.optional(z.boolean()),\n })\n .strict()\n .refine((field) => !field.assertUnchanged || (!field.derived && !field.lazy && !field.ignore), {\n message: \"assertUnchanged requires a non-derived, non-lazy, non-ignored field\",\n path: [\"assertUnchanged\"],\n });\n\nexport type FieldConfig = z.infer<typeof fieldConfig>;\n\nconst relationConfig = z\n .object({\n // For ReactiveReferences\n derived: z.optional(z.literal(\"async\")),\n polymorphic: z.optional(z.union([z.literal(\"notNull\"), z.literal(true)])),\n large: z.optional(z.boolean()),\n orderBy: z.optional(z.string()),\n /**\n * Controls whether this collection's `.get`/`.load` hide soft-deleted entities.\n *\n * Defaults to `\"exclude\"` (soft-deleted entities are hidden); set to `\"include\"` to have\n * this specific o2m/m2m always return soft-deleted entities from `.get`/`.load`.\n */\n softDeletes: z.optional(z.union([z.literal(\"include\"), z.literal(\"exclude\")])),\n // Allow pushing m2o/m2m/o2o relations in a base type (Task) down to a subtype (TaskOld)\n stiType: z.optional(z.union([z.string(), z.array(z.string())])),\n /**\n * Allow specializing a base type relation (SmallPublisher.group: SmallPublisherGroup).\n *\n * Self-referential FKs also support `subType: \"self\"` that means each subtype will point\n * at its own subtype.\n */\n subType: z.optional(z.string()),\n /** Allow skipping self-referential fields getting a `...Recursive` relation. */\n skipRecursiveRelations: z.optional(z.boolean()),\n // Allow marking m2o FKs as required on subclasses\n notNull: z.optional(z.boolean()),\n // Allow overriding scanEntities default detection for fields with defaults added by helpers\n hasDefault: z.optional(z.boolean()),\n })\n .strict();\n\nexport type RelationConfig = z.infer<typeof relationConfig>;\n\nconst uniqueByConfig = z\n .union([z.string(), z.array(z.string()), z.array(z.array(z.string()))])\n .transform(normalizeUniqueByConfig);\n\nconst entityConfig = z\n .object({\n tag: z.string(),\n tableName: z.optional(z.string()),\n fields: z.optional(z.record(z.string(), fieldConfig)),\n relations: z.optional(z.record(z.string(), relationConfig)),\n /** Whether this entity should be abstract, e.g. for inheritance a subtype must be instantiated instead of this type. */\n abstract: z.optional(z.boolean()),\n orderBy: z.optional(z.string()),\n uniqueBy: z.optional(uniqueByConfig),\n })\n .strict();\n\nexport type EntityConfig = z.infer<typeof entityConfig>;\n\nconst timestampConfig = z\n .object({\n /** The names to check for this timestamp, i.e. `created_at` `created`, etc. */\n names: z.array(z.string()),\n /** Whether this timestamp column is required to consider a table an entity, defaults to `false`. */\n required: z.optional(z.boolean()),\n })\n .strict();\n\nexport type TimestampConfig = z.infer<typeof timestampConfig>;\n\nexport const config = z\n .object({\n /** The _build-time_ database URL for reading database metadata. */\n databaseUrl: z.optional(z.string()),\n /** Your application's request-level `Context` type. */\n contextType: z.optional(z.string()),\n /** Your application's database client's `Transaction` type. */\n transactionType: z.optional(z.string()),\n /**\n * Allows the user to specify the `updated_at` / `created_at` column names to look up, and if they're optional.\n *\n * We default to looking for `updated_at`, `updatedAt`, `created_at`, `createdAt`, and optional to true,\n * e.g. tables are not required to have both timestamp columns to be considered entities.\n *\n * These defaults are the most lenient, to facilitate running Joist against an existing schema and\n * seeing all of your entities, regardless of your previous conventions.\n */\n timestampColumns: z.optional(\n z.object({\n createdAt: z.optional(timestampConfig),\n updatedAt: z.optional(timestampConfig),\n deletedAt: z.optional(timestampConfig),\n }),\n ),\n /**\n * Allows the user to have codegen output `Temporal` types instead of the base JS `Date`\n *\n * Additionally, allows for specifying the default time zone for `Temporal` types when converting dates to/from\n * the database.\n */\n temporal: z.optional(z.union([z.boolean(), z.object({ timeZone: z.string() })])),\n /**\n * By default, we create a `flush_database` function for fast testing.\n *\n * However, if you don't want to use this, or you have your own bespoke function like we do\n * that is more application-aware, then you can disable Joist's out-of-the-box one.\n *\n * If you have more than one test database, you can set `createFlushFunction` to the array\n * of test database names, i.e. `mydb_test_1`, `mydb_test_2`, etc.\n */\n createFlushFunction: z.optional(z.union([z.boolean(), z.array(z.string())])),\n entitiesDirectory: z.string().default(\"./src/entities\"),\n codegenPlugins: z.optional(z.array(z.string())),\n entities: z.record(z.string(), entityConfig).default({}),\n ignoredTables: z.optional(z.array(z.string())),\n /** The type of entity `id` fields; defaults to `tagged-string`. */\n idType: z.optional(z.union([z.literal(\"tagged-string\"), z.literal(\"untagged-string\"), z.literal(\"number\")])),\n /** The separator between entity tags and ids; defaults to `:`, and `\"\"` disables the separator. */\n tagDelimiter: z.optional(z.string()),\n /** How we should support non-deferred foreign keys. */\n nonDeferredForeignKeys: z.optional(z.union([z.literal(\"error\"), z.literal(\"warn\"), z.literal(\"ignore\")])),\n /** Enables esm output. */\n esm: z.optional(z.boolean()),\n /** Controls the style of GraphQL pagination scaffolding. */\n paginationStyle: z.optional(z.union([z.literal(\"cursor\"), z.literal(\"limit\")])).default(\"cursor\"),\n /** Enables documentation syncing between .md files and JSDocs. */\n docs: z.optional(z.boolean()),\n /** Installs Joist's bundled Agent Skills into `.claude/skills` and `.agents/skills`; on by default, set `false` to disable. */\n skills: z.optional(z.boolean()),\n /** Output a metadata-docs.ts file with entity/field documentation available at runtime. */\n outputDocs: z.optional(z.boolean()),\n /** Auto-set by probing the project's `tsconfig.json` file. */\n allowImportingTsExtensions: z.optional(z.boolean()),\n /** The latest Joist codemod counter that has been applied to this project. */\n codemodVersion: z.number().int().min(0).default(0),\n\n /** A list of postgres schemas to use for finding tables */\n schemas: z.optional(z.array(z.string())),\n })\n .strict();\n\nexport type Config = z.infer<typeof config> & {\n // We don't persist this, and instead just use it as a cache\n __tableToEntityName?: Record<string, string>;\n};\n\nexport const ormMaintainedFields = [\"createdAt\", \"updatedAt\"];\n\n/** Ensure the user doesn't have any typos in their config. */\nexport function warnInvalidConfigEntries(config: Config, db: DbMetadata): void {\n const entitiesByName = groupBy(db.entities, (e) => e.name);\n for (const [entityName, entityConfig] of Object.entries(config.entities)) {\n const entities = entitiesByName[entityName];\n if (!entities) {\n logger.warn(`Found config for non-existent entity ${entityName}`);\n continue;\n }\n // We don't have keyBy...\n const [entity] = entities;\n\n // Check fields\n const fields = [...entity.primitives, ...entity.enums];\n for (const [name, config] of Object.entries(entityConfig.fields || {})) {\n if (config.ignore) continue;\n let field = fields.find((f) => f.fieldName === name);\n // STI types might be in the base type\n if (!field && entity.stiDiscriminatorField) {\n const stiEntities = getStiEntities(db.entities).get(entity.name)?.subTypes;\n field = stiEntities?.flatMap((st) => [...st.primitives, ...st.enums]).find((f) => f.fieldName === name);\n }\n if (!field) logger.warn(`Found config for non-existent field ${entityName}.${name}`);\n }\n\n // Check relations\n const relations = [\n ...entity.manyToOnes,\n ...entity.oneToManys,\n ...entity.manyToManys,\n ...entity.manyToManyEnums,\n ...entity.oneToOnes,\n ...entity.largeOneToManys,\n ...entity.largeManyToManys,\n ...entity.polymorphics,\n ];\n for (const [name, _] of Object.entries(entityConfig.relations || {})) {\n let relation = relations.find((r) => r.fieldName === name);\n // STI types might be in the subtypes\n if (!relation && entity.stiDiscriminatorField) {\n const stiEntities = getStiEntities(db.entities).get(entity.name)?.subTypes;\n relation = stiEntities\n ?.flatMap((entity) => [\n ...entity.manyToOnes,\n ...entity.oneToManys,\n ...entity.manyToManys,\n ...entity.oneToOnes,\n ...entity.largeOneToManys,\n ...entity.largeManyToManys,\n ...entity.polymorphics,\n ])\n ?.find((f) => f.fieldName === name);\n }\n // CTI subtype specializations (i.e. SmallPublisher.group: SmallPublisherGroup) need to look in the base type\n if (!relation && entity.baseType) {\n const baseType = entity.baseType;\n relation = [\n ...baseType.manyToOnes,\n ...baseType.oneToManys,\n ...baseType.manyToManys,\n ...baseType.oneToOnes,\n ...baseType.largeOneToManys,\n ...baseType.largeManyToManys,\n ...baseType.polymorphics,\n ].find((f) => f.fieldName === name);\n }\n\n if (!relation) logger.warn(`Found config for non-existent relation ${entityName}.${name}`);\n }\n\n const uniqueFields = [\n ...entity.primitives,\n ...entity.enums,\n ...entity.pgEnums,\n ...entity.manyToOnes,\n ...entity.polymorphics,\n ];\n for (const uniqueBy of entityConfig.uniqueBy || []) {\n for (const name of uniqueBy) {\n const field = uniqueFields.find((f) => f.fieldName === name);\n if (!field) {\n logger.warn(`Found uniqueBy for non-existent or non-queryable field ${entityName}.${name}`);\n } else if (field.kind === \"primitive\" && (field.derived || field.customSerde)) {\n logger.warn(`Found uniqueBy for unsupported primitive field ${entityName}.${name}`);\n } else if (field.kind === \"enum\" && (field.derived || field.isArray)) {\n logger.warn(`Found uniqueBy for unsupported enum field ${entityName}.${name}`);\n }\n }\n }\n }\n}\n\nexport function isGetterField(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.fields?.[fieldName]?.derived === \"sync\";\n}\n\nexport function isReactiveField(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.fields?.[fieldName]?.derived === \"async\";\n}\n\nexport function isReactiveReference(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.relations?.[fieldName]?.derived === \"async\";\n}\n\n/** Returns true if this m2m relation is configured as a ReactiveManyToMany (derived: async). */\nexport function isReactiveManyToMany(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.relations?.[fieldName]?.derived === \"async\";\n}\n\nexport function isProtected(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.fields?.[fieldName]?.protected === true;\n}\n\n/** Whether a column should be excluded from the default SELECT and exposed as a lazy-loaded `LazyField`. */\nexport function isLazyField(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.fields?.[fieldName]?.lazy === true;\n}\n\nexport function serdeConfig(config: Config, entity: Entity, fieldName: string): string | undefined {\n return config.entities[entity.name]?.fields?.[fieldName]?.serde;\n}\n\nexport function superstructConfig(config: Config, entity: Entity, fieldName: string): string | undefined {\n return config.entities[entity.name]?.fields?.[fieldName]?.superstruct;\n}\n\nexport function zodSchemaConfig(config: Config, entity: Entity, fieldName: string): string | undefined {\n return config.entities[entity.name]?.fields?.[fieldName]?.zodSchema;\n}\n\nexport function fieldTypeConfig(config: Config, entity: Entity, fieldName: string): string | undefined {\n return config.entities[entity.name]?.fields?.[fieldName]?.type;\n}\n\nexport function isLargeCollection(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.relations?.[fieldName]?.large === true;\n}\n\n/** Whether a collection should include (or exclude) soft-deleted entities from `.get`/`.load`. */\nexport function softDeletesConfig(\n config: Config,\n entity: Entity,\n fieldName: string,\n): \"include\" | \"exclude\" | undefined {\n return config.entities[entity.name]?.relations?.[fieldName]?.softDeletes;\n}\n\nexport function isFieldIgnored(\n config: Config,\n entity: Entity,\n fieldName: string,\n notNull: boolean = false,\n hasDefault: boolean = false,\n): boolean {\n const ignore = config.entities[entity.name]?.fields?.[fieldName]?.ignore === true;\n if (ignore && notNull && !hasDefault) {\n fail(\n `notNull field ${entity.name}.${fieldName} cannot be ignored. Alter the column to be optional or have a default value prior to ignoring it.`,\n );\n }\n return ignore;\n}\n\nexport function isFieldHasDefault(config: Config, entity: Entity, fieldName: string): boolean {\n const entityConfig = config.entities[entity.name] ?? {};\n const fieldConfig = entityConfig.fields?.[fieldName] ?? entityConfig.relations?.[fieldName] ?? {};\n return fieldConfig.hasDefault === true;\n}\n\nconst configPath = \"./joist-config.json\";\n\nexport async function loadConfig(): Promise<Config> {\n const exists = await trueIfResolved(fs.access(configPath));\n if (exists) {\n const content = await fs.readFile(configPath);\n const result = config.safeParse(stripLegacyConfigKeys(JSON.parse(content.toString())));\n if (!result.success) {\n throw new Error(\n `Invalid joist-config.json: ${result.error.issues\n .map((ze) => `${ze.path.map(String).join(\"/\")} ${ze.message}`)\n .join(\"\\n\")}`,\n );\n }\n result.data.allowImportingTsExtensions ??= projectIsUsingEsmWithImports();\n return result.data;\n }\n // Brand-new projects should not be prompted to run historical codemods.\n const initial = config.parse({ codemodVersion: getLatestCodemodVersion() });\n initial.allowImportingTsExtensions ??= projectIsUsingEsmWithImports();\n return initial;\n}\n\n/**\n * Writes the potentially-updated config entry back to `joist-config.json`.\n *\n * We format the output with prettier so it should both a) look nice and b) be deterministic,\n * such that no changes to the config show up as noops to the scm.\n */\nexport async function writeConfig(config: Config): Promise<void> {\n const sorted: Partial<Config> = sortKeys(config);\n delete sorted.__tableToEntityName;\n delete sorted.allowImportingTsExtensions;\n if (sorted.paginationStyle === \"cursor\") {\n delete sorted.paginationStyle;\n }\n const input = JSON.stringify(sorted);\n const content = jsonFormatter.formatText({ filePath: \"test.json\", fileText: input });\n await fs.writeFile(configPath, content);\n}\n\nexport function stripStiPlaceholders(config: Config, entities: EntityDbMetadata[]): void {\n // Defacto (with today's setup) the config of STI entities lives on the base entity,\n // so don't write confusing subtype-specific entries into the config file.\n // ...hopefully we don't have any code accidentally looking for the STI config...\n for (const entity of entities) {\n if (entity.inheritanceType === \"sti\" && entity.stiDiscriminatorValue) {\n delete config.entities[entity.name];\n }\n }\n}\n\n/** Applies defaults to the timestamp config. */\nexport function getTimestampConfig(config: Config): {\n updatedAtConf: Required<TimestampConfig>;\n createdAtConf: Required<TimestampConfig>;\n deletedAtConf: Required<TimestampConfig>;\n} {\n return {\n createdAtConf: {\n names: [\"created_at\", \"createdAt\"],\n required: false,\n ...config?.timestampColumns?.createdAt,\n },\n updatedAtConf: {\n names: [\"updated_at\", \"updatedAt\"],\n required: false,\n ...config?.timestampColumns?.updatedAt,\n },\n deletedAtConf: {\n names: [\"deleted_at\", \"deletedAt\"],\n required: false,\n ...config?.timestampColumns?.deletedAt,\n },\n };\n}\n\nfunction projectIsUsingEsmWithImports(): boolean {\n // Attempt to find the project's tsconfig.json in the current directory or up the directory hierarchy\n const configPath = findTsConfigFile(process.cwd());\n if (!configPath) {\n return false;\n }\n try {\n // Use jsonc-parser to parse the tsconfig.json file (not the old tsc readConfigFile which was\n // dropped in TypeScript 7), allowing for comments and trailing commas.\n const errors: ParseError[] = [];\n const parsed: unknown = parse(readFileSync(configPath, \"utf8\"), errors, { allowTrailingComma: true });\n if (errors.length > 0 || typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) return false;\n const compilerOptions = (parsed as Record<string, unknown>).compilerOptions;\n return (\n typeof compilerOptions === \"object\" &&\n compilerOptions !== null &&\n !Array.isArray(compilerOptions) &&\n (compilerOptions as Record<string, unknown>).allowImportingTsExtensions === true\n );\n } catch {\n return false;\n }\n}\n\n/** Normalizes `uniqueBy` config sugar into runtime identity candidates. */\nfunction normalizeUniqueByConfig(uniqueBy: string | string[] | string[][]): string[][] {\n if (typeof uniqueBy === \"string\") return [[uniqueBy]];\n if (uniqueBy.every((field) => typeof field === \"string\")) return [uniqueBy];\n return uniqueBy;\n}\n\nfunction stripLegacyConfigKeys(raw: unknown): unknown {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) {\n return raw;\n }\n // Accept old configs so the deprecated key disappears on the next write.\n const parsed = { ...(raw as Record<string, unknown>) };\n delete parsed.version;\n return parsed;\n}\n\n/** Finds the nearest `tsconfig.json` in `directory` or one of its ancestors. */\nfunction findTsConfigFile(directory: string): string | undefined {\n while (true) {\n const fileName = join(directory, \"tsconfig.json\");\n if (existsSync(fileName)) return fileName;\n const parent = dirname(directory);\n if (parent === directory) return undefined;\n directory = parent;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAeA,MAAM,gBAAgB,iBAAiB,aAAa,QAAQ,CAAC,CAAC;AAE9D,MAAM,cAAc,EACjB,OAAO;CAEN,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,QAAQ,MAAM,GAAG,EAAE,QAAQ,OAAO,CAAC,CAAC,CAAC;CACpE,WAAW,EAAE,SAAS,EAAE,QAAQ,CAAC;CACjC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC;CAC9B,aAAa,EAAE,SAAS,EAAE,OAAO,CAAC;CAClC,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC;CAChC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC;CAC3B,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC;CAC5B,kBAAkB,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC;CAC7D,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CAE9D,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC;CAE/B,YAAY,EAAE,SAAS,EAAE,QAAQ,CAAC;CAElC,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC;;CAE5B,iBAAiB,EAAE,SAAS,EAAE,QAAQ,CAAC;AACzC,CAAC,CAAC,CACD,OAAO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ACF;AAEA,SAAS,+BAAwC;CAE/C,MAAM,aAAa,iBAAiB,QAAQ,IAAI,CAAC;CACjD,IAAI,CAAC,YACH,OAAO;CAET,IAAI;EAGF,MAAM,SAAuB,CAAC;EAC9B,MAAM,SAAkB,MAAM,aAAa,YAAY,MAAM,GAAG,QAAQ,EAAE,oBAAoB,KAAK,CAAC;EACpG,IAAI,OAAO,SAAS,KAAK,OAAO,WAAW,YAAY,WAAW,QAAQ,MAAM,QAAQ,MAAM,GAAG,OAAO;EACxG,MAAM,kBAAmB,OAAmC;EAC5D,OACE,OAAO,oBAAoB,YAC3B,oBAAoB,QACpB,CAAC,MAAM,QAAQ,eAAe,KAC7B,gBAA4C,+BAA+B;CAEhF,QAAQ;EACN,OAAO;CACT;AACF;;AAGA,SAAS,wBAAwB,UAAsD;CACrF,IAAI,OAAO,aAAa,UAAU,OAAO,CAAC,CAAC,QAAQ,CAAC;CACpD,IAAI,SAAS,OAAO,UAAU,OAAO,UAAU,QAAQ,GAAG,OAAO,CAAC,QAAQ;CAC1E,OAAO;AACT;AAEA,SAAS,sBAAsB,KAAuB;CACpD,IAAI,CAAC,OAAO,OAAO,QAAQ,YAAY,MAAM,QAAQ,GAAG,GACtD,OAAO;CAGT,MAAM,SAAS,EAAE,GAAI,IAAgC;CACrD,OAAO,OAAO;CACd,OAAO;AACT;;AAGA,SAAS,iBAAiB,WAAuC;CAC/D,OAAO,MAAM;EACX,MAAM,WAAW,KAAK,WAAW,eAAe;EAChD,IAAI,WAAW,QAAQ,GAAG,OAAO;EACjC,MAAM,SAAS,QAAQ,SAAS;EAChC,IAAI,WAAW,WAAW,OAAO,KAAA;EACjC,YAAY;CACd;AACF"}
1
+ {"version":3,"file":"config.js","names":["fs"],"sources":["../src/config.ts"],"sourcesContent":["import { existsSync, promises as fs, readFileSync } from \"fs\";\nimport { dirname, join } from \"path\";\n\nimport { createFromBuffer } from \"@dprint/formatter\";\nimport { getPath } from \"@dprint/json\";\nimport { groupBy } from \"joist-utils\";\nimport { type ParseError, parse } from \"jsonc-parser\";\nimport { z } from \"zod\";\n\nimport { getLatestCodemodVersion } from \"./codemods/index.ts\";\nimport { type DbMetadata, type Entity, type EntityDbMetadata } from \"./EntityDbMetadata.ts\";\nimport { getStiEntities } from \"./inheritance.ts\";\nimport { logger } from \"./logger.ts\";\nimport { fail, sortKeys, trueIfResolved } from \"./utils.ts\";\n\nconst jsonFormatter = createFromBuffer(readFileSync(getPath()));\n\nconst fieldConfig = z\n .object({\n // For getters & ReactiveFields\n derived: z.optional(z.union([z.literal(\"sync\"), z.literal(\"async\")])),\n protected: z.optional(z.boolean()),\n ignore: z.optional(z.boolean()),\n superstruct: z.optional(z.string()),\n zodSchema: z.optional(z.string()),\n type: z.optional(z.string()),\n serde: z.optional(z.string()),\n stiDiscriminator: z.optional(z.record(z.string(), z.string())),\n stiType: z.optional(z.union([z.string(), z.array(z.string())])),\n // Allow subclasses to mark fields as required\n notNull: z.optional(z.boolean()),\n // Allow overriding scanEntities default detection for fields with defaults added by helpers\n hasDefault: z.optional(z.boolean()),\n // Exclude a (large jsonb/text) column from the default SELECT and expose it as a lazy-loaded LazyField\n lazy: z.optional(z.boolean()),\n /** Mark the entity for read locking whenever the field's value is read. */\n assertUnchanged: z.optional(z.boolean()),\n })\n .strict()\n .refine((field) => !field.assertUnchanged || (!field.derived && !field.lazy && !field.ignore), {\n message: \"assertUnchanged requires a non-derived, non-lazy, non-ignored field\",\n path: [\"assertUnchanged\"],\n });\n\nexport type FieldConfig = z.infer<typeof fieldConfig>;\n\nconst relationConfig = z\n .object({\n // For ReactiveReferences\n derived: z.optional(z.literal(\"async\")),\n polymorphic: z.optional(z.union([z.literal(\"notNull\"), z.literal(true)])),\n large: z.optional(z.boolean()),\n orderBy: z.optional(z.string()),\n /**\n * Controls whether this collection's `.get`/`.load` hide soft-deleted entities.\n *\n * Defaults to `\"exclude\"` (soft-deleted entities are hidden); set to `\"include\"` to have\n * this specific o2m/m2m always return soft-deleted entities from `.get`/`.load`.\n */\n softDeletes: z.optional(z.union([z.literal(\"include\"), z.literal(\"exclude\")])),\n // Allow pushing m2o/m2m/o2o relations in a base type (Task) down to a subtype (TaskOld)\n stiType: z.optional(z.union([z.string(), z.array(z.string())])),\n /**\n * Allow specializing a base type relation (SmallPublisher.group: SmallPublisherGroup).\n *\n * Self-referential FKs also support `subType: \"self\"` that means each subtype will point\n * at its own subtype.\n */\n subType: z.optional(z.string()),\n /** Allow skipping self-referential fields getting a `...Recursive` relation. */\n skipRecursiveRelations: z.optional(z.boolean()),\n // Allow marking m2o FKs as required on subclasses\n notNull: z.optional(z.boolean()),\n // Allow overriding scanEntities default detection for fields with defaults added by helpers\n hasDefault: z.optional(z.boolean()),\n })\n .strict();\n\nexport type RelationConfig = z.infer<typeof relationConfig>;\n\nconst uniqueByConfig = z\n .union([z.string(), z.array(z.string()), z.array(z.array(z.string()))])\n .transform(normalizeUniqueByConfig);\n\nconst entityConfig = z\n .object({\n tag: z.string(),\n tableName: z.optional(z.string()),\n fields: z.optional(z.record(z.string(), fieldConfig)),\n relations: z.optional(z.record(z.string(), relationConfig)),\n /** Whether this entity should be abstract, e.g. for inheritance a subtype must be instantiated instead of this type. */\n abstract: z.optional(z.boolean()),\n orderBy: z.optional(z.string()),\n uniqueBy: z.optional(uniqueByConfig),\n })\n .strict();\n\nexport type EntityConfig = z.infer<typeof entityConfig>;\n\nconst timestampConfig = z\n .object({\n /** The names to check for this timestamp, i.e. `created_at` `created`, etc. */\n names: z.array(z.string()),\n /** Whether this timestamp column is required to consider a table an entity, defaults to `false`. */\n required: z.optional(z.boolean()),\n })\n .strict();\n\nexport type TimestampConfig = z.infer<typeof timestampConfig>;\n\nexport const config = z\n .object({\n /** The _build-time_ database URL for reading database metadata. */\n databaseUrl: z.optional(z.string()),\n /** Your application's request-level `Context` type. */\n contextType: z.optional(z.string()),\n /** Your application's database client's `Transaction` type. */\n transactionType: z.optional(z.string()),\n /**\n * Allows the user to specify the `updated_at` / `created_at` column names to look up, and if they're optional.\n *\n * We default to looking for `updated_at`, `updatedAt`, `created_at`, `createdAt`, and optional to true,\n * e.g. tables are not required to have both timestamp columns to be considered entities.\n *\n * These defaults are the most lenient, to facilitate running Joist against an existing schema and\n * seeing all of your entities, regardless of your previous conventions.\n */\n timestampColumns: z.optional(\n z.object({\n createdAt: z.optional(timestampConfig),\n updatedAt: z.optional(timestampConfig),\n deletedAt: z.optional(timestampConfig),\n }),\n ),\n /**\n * Allows the user to have codegen output `Temporal` types instead of the base JS `Date`\n *\n * Additionally, allows for specifying the default time zone for `Temporal` types when converting dates to/from\n * the database.\n */\n temporal: z.optional(z.union([z.boolean(), z.object({ timeZone: z.string() })])),\n /**\n * By default, we create a `flush_database` function for fast testing.\n *\n * However, if you don't want to use this, or you have your own bespoke function like we do\n * that is more application-aware, then you can disable Joist's out-of-the-box one.\n *\n * If you have more than one test database, you can set `createFlushFunction` to the array\n * of test database names, i.e. `mydb_test_1`, `mydb_test_2`, etc.\n */\n createFlushFunction: z.optional(z.union([z.boolean(), z.array(z.string())])),\n /** Creates a starter test alongside each new entity file unless explicitly disabled. */\n scaffoldTests: z.optional(z.boolean()),\n entitiesDirectory: z.string().default(\"./src/entities\"),\n codegenPlugins: z.optional(z.array(z.string())),\n entities: z.record(z.string(), entityConfig).default({}),\n ignoredTables: z.optional(z.array(z.string())),\n /** The type of entity `id` fields; defaults to `tagged-string`. */\n idType: z.optional(z.union([z.literal(\"tagged-string\"), z.literal(\"untagged-string\"), z.literal(\"number\")])),\n /** The separator between entity tags and ids; defaults to `:`, and `\"\"` disables the separator. */\n tagDelimiter: z.optional(z.string()),\n /** How we should support non-deferred foreign keys. */\n nonDeferredForeignKeys: z.optional(z.union([z.literal(\"error\"), z.literal(\"warn\"), z.literal(\"ignore\")])),\n /** Enables esm output. */\n esm: z.optional(z.boolean()),\n /** Controls the style of GraphQL pagination scaffolding. */\n paginationStyle: z.optional(z.union([z.literal(\"cursor\"), z.literal(\"limit\")])).default(\"cursor\"),\n /** Enables documentation syncing between .md files and JSDocs. */\n docs: z.optional(z.boolean()),\n /** Installs Joist's bundled Agent Skills into `.claude/skills` and `.agents/skills`; on by default, set `false` to disable. */\n skills: z.optional(z.boolean()),\n /** Output a metadata-docs.ts file with entity/field documentation available at runtime. */\n outputDocs: z.optional(z.boolean()),\n /** Auto-set by probing the project's `tsconfig.json` file. */\n allowImportingTsExtensions: z.optional(z.boolean()),\n /** The latest Joist codemod counter that has been applied to this project. */\n codemodVersion: z.number().int().min(0).default(0),\n\n /** A list of postgres schemas to use for finding tables */\n schemas: z.optional(z.array(z.string())),\n })\n .strict();\n\nexport type Config = z.infer<typeof config> & {\n // We don't persist this, and instead just use it as a cache\n __tableToEntityName?: Record<string, string>;\n};\n\nexport const ormMaintainedFields = [\"createdAt\", \"updatedAt\"];\n\n/** Ensure the user doesn't have any typos in their config. */\nexport function warnInvalidConfigEntries(config: Config, db: DbMetadata): void {\n const entitiesByName = groupBy(db.entities, (e) => e.name);\n for (const [entityName, entityConfig] of Object.entries(config.entities)) {\n const entities = entitiesByName[entityName];\n if (!entities) {\n logger.warn(`Found config for non-existent entity ${entityName}`);\n continue;\n }\n // We don't have keyBy...\n const [entity] = entities;\n\n // Check fields\n const fields = [...entity.primitives, ...entity.enums];\n for (const [name, config] of Object.entries(entityConfig.fields || {})) {\n if (config.ignore) continue;\n let field = fields.find((f) => f.fieldName === name);\n // STI types might be in the base type\n if (!field && entity.stiDiscriminatorField) {\n const stiEntities = getStiEntities(db.entities).get(entity.name)?.subTypes;\n field = stiEntities?.flatMap((st) => [...st.primitives, ...st.enums]).find((f) => f.fieldName === name);\n }\n if (!field) logger.warn(`Found config for non-existent field ${entityName}.${name}`);\n }\n\n // Check relations\n const relations = [\n ...entity.manyToOnes,\n ...entity.oneToManys,\n ...entity.manyToManys,\n ...entity.manyToManyEnums,\n ...entity.oneToOnes,\n ...entity.largeOneToManys,\n ...entity.largeManyToManys,\n ...entity.polymorphics,\n ];\n for (const [name, _] of Object.entries(entityConfig.relations || {})) {\n let relation = relations.find((r) => r.fieldName === name);\n // STI types might be in the subtypes\n if (!relation && entity.stiDiscriminatorField) {\n const stiEntities = getStiEntities(db.entities).get(entity.name)?.subTypes;\n relation = stiEntities\n ?.flatMap((entity) => [\n ...entity.manyToOnes,\n ...entity.oneToManys,\n ...entity.manyToManys,\n ...entity.oneToOnes,\n ...entity.largeOneToManys,\n ...entity.largeManyToManys,\n ...entity.polymorphics,\n ])\n ?.find((f) => f.fieldName === name);\n }\n // CTI subtype specializations (i.e. SmallPublisher.group: SmallPublisherGroup) need to look in the base type\n if (!relation && entity.baseType) {\n const baseType = entity.baseType;\n relation = [\n ...baseType.manyToOnes,\n ...baseType.oneToManys,\n ...baseType.manyToManys,\n ...baseType.oneToOnes,\n ...baseType.largeOneToManys,\n ...baseType.largeManyToManys,\n ...baseType.polymorphics,\n ].find((f) => f.fieldName === name);\n }\n\n if (!relation) logger.warn(`Found config for non-existent relation ${entityName}.${name}`);\n }\n\n const uniqueFields = [\n ...entity.primitives,\n ...entity.enums,\n ...entity.pgEnums,\n ...entity.manyToOnes,\n ...entity.polymorphics,\n ];\n for (const uniqueBy of entityConfig.uniqueBy || []) {\n for (const name of uniqueBy) {\n const field = uniqueFields.find((f) => f.fieldName === name);\n if (!field) {\n logger.warn(`Found uniqueBy for non-existent or non-queryable field ${entityName}.${name}`);\n } else if (field.kind === \"primitive\" && (field.derived || field.customSerde)) {\n logger.warn(`Found uniqueBy for unsupported primitive field ${entityName}.${name}`);\n } else if (field.kind === \"enum\" && (field.derived || field.isArray)) {\n logger.warn(`Found uniqueBy for unsupported enum field ${entityName}.${name}`);\n }\n }\n }\n }\n}\n\nexport function isGetterField(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.fields?.[fieldName]?.derived === \"sync\";\n}\n\nexport function isReactiveField(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.fields?.[fieldName]?.derived === \"async\";\n}\n\nexport function isReactiveReference(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.relations?.[fieldName]?.derived === \"async\";\n}\n\n/** Returns true if this m2m relation is configured as a ReactiveManyToMany (derived: async). */\nexport function isReactiveManyToMany(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.relations?.[fieldName]?.derived === \"async\";\n}\n\nexport function isProtected(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.fields?.[fieldName]?.protected === true;\n}\n\n/** Whether a column should be excluded from the default SELECT and exposed as a lazy-loaded `LazyField`. */\nexport function isLazyField(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.fields?.[fieldName]?.lazy === true;\n}\n\nexport function serdeConfig(config: Config, entity: Entity, fieldName: string): string | undefined {\n return config.entities[entity.name]?.fields?.[fieldName]?.serde;\n}\n\nexport function superstructConfig(config: Config, entity: Entity, fieldName: string): string | undefined {\n return config.entities[entity.name]?.fields?.[fieldName]?.superstruct;\n}\n\nexport function zodSchemaConfig(config: Config, entity: Entity, fieldName: string): string | undefined {\n return config.entities[entity.name]?.fields?.[fieldName]?.zodSchema;\n}\n\nexport function fieldTypeConfig(config: Config, entity: Entity, fieldName: string): string | undefined {\n return config.entities[entity.name]?.fields?.[fieldName]?.type;\n}\n\nexport function isLargeCollection(config: Config, entity: Entity, fieldName: string): boolean {\n return config.entities[entity.name]?.relations?.[fieldName]?.large === true;\n}\n\n/** Whether a collection should include (or exclude) soft-deleted entities from `.get`/`.load`. */\nexport function softDeletesConfig(\n config: Config,\n entity: Entity,\n fieldName: string,\n): \"include\" | \"exclude\" | undefined {\n return config.entities[entity.name]?.relations?.[fieldName]?.softDeletes;\n}\n\nexport function isFieldIgnored(\n config: Config,\n entity: Entity,\n fieldName: string,\n notNull: boolean = false,\n hasDefault: boolean = false,\n): boolean {\n const ignore = config.entities[entity.name]?.fields?.[fieldName]?.ignore === true;\n if (ignore && notNull && !hasDefault) {\n fail(\n `notNull field ${entity.name}.${fieldName} cannot be ignored. Alter the column to be optional or have a default value prior to ignoring it.`,\n );\n }\n return ignore;\n}\n\nexport function isFieldHasDefault(config: Config, entity: Entity, fieldName: string): boolean {\n const entityConfig = config.entities[entity.name] ?? {};\n const fieldConfig = entityConfig.fields?.[fieldName] ?? entityConfig.relations?.[fieldName] ?? {};\n return fieldConfig.hasDefault === true;\n}\n\nconst configPath = \"./joist-config.json\";\n\nexport async function loadConfig(): Promise<Config> {\n const exists = await trueIfResolved(fs.access(configPath));\n if (exists) {\n const content = await fs.readFile(configPath);\n const result = config.safeParse(stripLegacyConfigKeys(JSON.parse(content.toString())));\n if (!result.success) {\n throw new Error(\n `Invalid joist-config.json: ${result.error.issues\n .map((ze) => `${ze.path.map(String).join(\"/\")} ${ze.message}`)\n .join(\"\\n\")}`,\n );\n }\n result.data.allowImportingTsExtensions ??= projectIsUsingEsmWithImports();\n return result.data;\n }\n // Brand-new projects should not be prompted to run historical codemods.\n const initial = config.parse({ codemodVersion: getLatestCodemodVersion() });\n initial.allowImportingTsExtensions ??= projectIsUsingEsmWithImports();\n return initial;\n}\n\n/**\n * Writes the potentially-updated config entry back to `joist-config.json`.\n *\n * We format the output with prettier so it should both a) look nice and b) be deterministic,\n * such that no changes to the config show up as noops to the scm.\n */\nexport async function writeConfig(config: Config): Promise<void> {\n const sorted: Partial<Config> = sortKeys(config);\n delete sorted.__tableToEntityName;\n delete sorted.allowImportingTsExtensions;\n if (sorted.paginationStyle === \"cursor\") {\n delete sorted.paginationStyle;\n }\n const input = JSON.stringify(sorted);\n const content = jsonFormatter.formatText({ filePath: \"test.json\", fileText: input });\n await fs.writeFile(configPath, content);\n}\n\nexport function stripStiPlaceholders(config: Config, entities: EntityDbMetadata[]): void {\n // Defacto (with today's setup) the config of STI entities lives on the base entity,\n // so don't write confusing subtype-specific entries into the config file.\n // ...hopefully we don't have any code accidentally looking for the STI config...\n for (const entity of entities) {\n if (entity.inheritanceType === \"sti\" && entity.stiDiscriminatorValue) {\n delete config.entities[entity.name];\n }\n }\n}\n\n/** Applies defaults to the timestamp config. */\nexport function getTimestampConfig(config: Config): {\n updatedAtConf: Required<TimestampConfig>;\n createdAtConf: Required<TimestampConfig>;\n deletedAtConf: Required<TimestampConfig>;\n} {\n return {\n createdAtConf: {\n names: [\"created_at\", \"createdAt\"],\n required: false,\n ...config?.timestampColumns?.createdAt,\n },\n updatedAtConf: {\n names: [\"updated_at\", \"updatedAt\"],\n required: false,\n ...config?.timestampColumns?.updatedAt,\n },\n deletedAtConf: {\n names: [\"deleted_at\", \"deletedAt\"],\n required: false,\n ...config?.timestampColumns?.deletedAt,\n },\n };\n}\n\nfunction projectIsUsingEsmWithImports(): boolean {\n // Attempt to find the project's tsconfig.json in the current directory or up the directory hierarchy\n const configPath = findTsConfigFile(process.cwd());\n if (!configPath) {\n return false;\n }\n try {\n // Use jsonc-parser to parse the tsconfig.json file (not the old tsc readConfigFile which was\n // dropped in TypeScript 7), allowing for comments and trailing commas.\n const errors: ParseError[] = [];\n const parsed: unknown = parse(readFileSync(configPath, \"utf8\"), errors, { allowTrailingComma: true });\n if (errors.length > 0 || typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) return false;\n const compilerOptions = (parsed as Record<string, unknown>).compilerOptions;\n return (\n typeof compilerOptions === \"object\" &&\n compilerOptions !== null &&\n !Array.isArray(compilerOptions) &&\n (compilerOptions as Record<string, unknown>).allowImportingTsExtensions === true\n );\n } catch {\n return false;\n }\n}\n\n/** Normalizes `uniqueBy` config sugar into runtime identity candidates. */\nfunction normalizeUniqueByConfig(uniqueBy: string | string[] | string[][]): string[][] {\n if (typeof uniqueBy === \"string\") return [[uniqueBy]];\n if (uniqueBy.every((field) => typeof field === \"string\")) return [uniqueBy];\n return uniqueBy;\n}\n\nfunction stripLegacyConfigKeys(raw: unknown): unknown {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) {\n return raw;\n }\n // Accept old configs so the deprecated key disappears on the next write.\n const parsed = { ...(raw as Record<string, unknown>) };\n delete parsed.version;\n return parsed;\n}\n\n/** Finds the nearest `tsconfig.json` in `directory` or one of its ancestors. */\nfunction findTsConfigFile(directory: string): string | undefined {\n while (true) {\n const fileName = join(directory, \"tsconfig.json\");\n if (existsSync(fileName)) return fileName;\n const parent = dirname(directory);\n if (parent === directory) return undefined;\n directory = parent;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAeA,MAAM,gBAAgB,iBAAiB,aAAa,QAAQ,CAAC,CAAC;AAE9D,MAAM,cAAc,EACjB,OAAO;CAEN,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,QAAQ,MAAM,GAAG,EAAE,QAAQ,OAAO,CAAC,CAAC,CAAC;CACpE,WAAW,EAAE,SAAS,EAAE,QAAQ,CAAC;CACjC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC;CAC9B,aAAa,EAAE,SAAS,EAAE,OAAO,CAAC;CAClC,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC;CAChC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC;CAC3B,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC;CAC5B,kBAAkB,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC;CAC7D,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CAE9D,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC;CAE/B,YAAY,EAAE,SAAS,EAAE,QAAQ,CAAC;CAElC,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC;;CAE5B,iBAAiB,EAAE,SAAS,EAAE,QAAQ,CAAC;AACzC,CAAC,CAAC,CACD,OAAO,CAAC,CACR,QAAQ,UAAU,CAAC,MAAM,mBAAoB,CAAC,MAAM,WAAW,CAAC,MAAM,QAAQ,CAAC,MAAM,QAAS;CAC7F,SAAS;CACT,MAAM,CAAC,iBAAiB;AAC1B,CAAC;AAIH,MAAM,iBAAiB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B,CAAC;EAC9B,MAAM,SAAkB,MAAM,aAAa,YAAY,MAAM,GAAG,QAAQ,EAAE,oBAAoB,KAAK,CAAC;EACpG,IAAI,OAAO,SAAS,KAAK,OAAO,WAAW,YAAY,WAAW,QAAQ,MAAM,QAAQ,MAAM,GAAG,OAAO;EACxG,MAAM,kBAAmB,OAAmC;EAC5D,OACE,OAAO,oBAAoB,YAC3B,oBAAoB,QACpB,CAAC,MAAM,QAAQ,eAAe,KAC7B,gBAA4C,+BAA+B;CAEhF,QAAQ;EACN,OAAO;CACT;AACF;;AAGA,SAAS,wBAAwB,UAAsD;CACrF,IAAI,OAAO,aAAa,UAAU,OAAO,CAAC,CAAC,QAAQ,CAAC;CACpD,IAAI,SAAS,OAAO,UAAU,OAAO,UAAU,QAAQ,GAAG,OAAO,CAAC,QAAQ;CAC1E,OAAO;AACT;AAEA,SAAS,sBAAsB,KAAuB;CACpD,IAAI,CAAC,OAAO,OAAO,QAAQ,YAAY,MAAM,QAAQ,GAAG,GACtD,OAAO;CAGT,MAAM,SAAS,EAAE,GAAI,IAAgC;CACrD,OAAO,OAAO;CACd,OAAO;AACT;;AAGA,SAAS,iBAAiB,WAAuC;CAC/D,OAAO,MAAM;EACX,MAAM,WAAW,KAAK,WAAW,eAAe;EAChD,IAAI,WAAW,QAAQ,GAAG,OAAO;EACjC,MAAM,SAAS,QAAQ,SAAS;EAChC,IAAI,WAAW,WAAW,OAAO,KAAA;EACjC,YAAY;CACd;AACF"}
@@ -28,19 +28,23 @@ async function generateFiles(config, dbMeta) {
28
28
  const entityFiles = entities.map((meta) => {
29
29
  const entityName = meta.entity.name;
30
30
  const hasEntityFile = files.includes(`${entityName}.ts`);
31
- return [{
32
- name: `./codegen/${entityName}Codegen.ts`,
33
- contents: require_generateEntityCodegenFile.generateEntityCodegenFile(config, dbMeta, meta, scopeMembersByEntity[entityName] ?? [], config.docs ? entityDocs[entityName] : void 0),
34
- overwrite: true
35
- }, ...hasEntityFile ? [] : [{
36
- name: `${entityName}.ts`,
37
- contents: require_generateEntityFile.generateEntityFile(config, meta),
38
- overwrite: false
39
- }, {
40
- name: `${entityName}.test.ts`,
41
- contents: require_generateEntityTestFile.generateEntityTestFile(config, meta),
42
- overwrite: false
43
- }]];
31
+ return [
32
+ {
33
+ name: `./codegen/${entityName}Codegen.ts`,
34
+ contents: require_generateEntityCodegenFile.generateEntityCodegenFile(config, dbMeta, meta, scopeMembersByEntity[entityName] ?? [], config.docs ? entityDocs[entityName] : void 0),
35
+ overwrite: true
36
+ },
37
+ ...hasEntityFile ? [] : [{
38
+ name: `${entityName}.ts`,
39
+ contents: require_generateEntityFile.generateEntityFile(config, meta),
40
+ overwrite: false
41
+ }],
42
+ ...hasEntityFile || config.scaffoldTests === false ? [] : [{
43
+ name: `${entityName}.test.ts`,
44
+ contents: require_generateEntityTestFile.generateEntityTestFile(config, meta),
45
+ overwrite: false
46
+ }]
47
+ ];
44
48
  }).reduce(require_utils.merge, []);
45
49
  const enumFiles = Object.values(enums).map((enumData) => {
46
50
  const enumName = require_utils.tableToEntityName(config, enumData.table);
@@ -1 +1 @@
1
- {"version":3,"file":"generate.cjs","names":["createRequire","syncDocs","loadEntityDocs","findAllEntityScopes","generateEntityCodegenFile","generateEntityFile","generateEntityTestFile","merge","tableToEntityName","generateEnumFile","generatePgEnumFile","imp","setRuntimeConfig","def","JoistEntityManager","Entity","getIdType","generateColumnDeclarations","generateMetadataFile","configureMetadata","generateEntitiesFile","generateFactoriesFiles","generateMetadataDocsFile","readdir"],"sources":["../src/generate.ts"],"sourcesContent":["import { readdir } from \"fs/promises\";\nimport { createRequire } from \"node:module\";\n\nimport { type CodegenFile, code, def, imp } from \"ts-poet\";\n\nimport { generateMetadataDocsFile, loadEntityDocs, syncDocs } from \"./docs/index.ts\";\nimport { findAllEntityScopes } from \"./findEntityScopes.ts\";\nimport { generateEntitiesFile } from \"./generateEntitiesFile.ts\";\nimport { generateEntityCodegenFile, getIdType } from \"./generateEntityCodegenFile.ts\";\nimport { generateEntityFile } from \"./generateEntityFile.ts\";\nimport { generateEntityTestFile } from \"./generateEntityTestFile.ts\";\nimport { generateEnumFile } from \"./generateEnumFile.ts\";\nimport { generateFactoriesFiles } from \"./generateFactoriesFiles.ts\";\nimport { generateColumnDeclarations, generateMetadataFile } from \"./generateMetadataFile.ts\";\nimport { generatePgEnumFile } from \"./generatePgEnumFile.ts\";\nimport { type Config, type DbMetadata } from \"./index.ts\";\nimport { Entity, JoistEntityManager, configureMetadata, setRuntimeConfig } from \"./symbols.ts\";\nimport { merge, tableToEntityName } from \"./utils.ts\";\n\nconst runtimeRequire = createRequire(import.meta.url);\n\nexport type DPrintOptions = Record<string, unknown>;\n\n/**\n * Provides an API for hooking into the codegen build step.\n */\nexport interface CodegenPlugin {\n run(config: Config, dbMeta: DbMetadata): Promise<CodegenFile>;\n}\n\n/** Generates our `${Entity}` and `${Entity}Codegen` files based on the `db` schema. */\nexport async function generateFiles(config: Config, dbMeta: DbMetadata): Promise<CodegenFile[]> {\n const { entities, enums, pgEnums } = dbMeta;\n const entityNames = entities.map((meta) => meta.entity.name);\n\n // Find existing entities so that, besides just using `overwrite: false`, we can completely\n // skip making test files except for the _first_ time we create an entity. This achieves\n // `.history`-like \"create once\" behavior without the need for the `.history` file.\n const files = await readExistingFiles(config);\n\n // Sync documentation: backfill .md from existing JSDocs, then sync MD -> JSDoc\n if (config.docs) {\n await syncDocs(config.entitiesDirectory, entityNames);\n }\n\n // Load the .md docs once (post-sync) to inject into codegen JSDocs and the runtime metadata-docs.ts\n const entityDocs =\n config.docs || config.outputDocs ? await loadEntityDocs(config.entitiesDirectory, entityNames) : {};\n\n const scopeMembersByEntity = await findAllEntityScopes(\n config,\n entities.map((meta) => meta.entity),\n );\n\n const entityFiles = entities\n .map((meta) => {\n const entityName = meta.entity.name;\n const hasEntityFile = files.includes(`${entityName}.ts`);\n return [\n {\n name: `./codegen/${entityName}Codegen.ts`,\n contents: generateEntityCodegenFile(\n config,\n dbMeta,\n meta,\n scopeMembersByEntity[entityName] ?? [],\n config.docs ? entityDocs[entityName] : undefined,\n ),\n overwrite: true,\n },\n ...(hasEntityFile\n ? []\n : [\n { name: `${entityName}.ts`, contents: generateEntityFile(config, meta), overwrite: false },\n { name: `${entityName}.test.ts`, contents: generateEntityTestFile(config, meta), overwrite: false },\n ]),\n ];\n })\n .reduce(merge, []);\n\n const enumFiles = Object.values(enums)\n .map((enumData) => {\n const enumName = tableToEntityName(config, enumData.table);\n return [\n {\n name: `./enums/${enumName}.ts`,\n contents: generateEnumFile(config, enumData, enumName),\n overwrite: true,\n },\n ];\n })\n .reduce(merge, []);\n const pgEnumFiles = Object.values(pgEnums)\n .map((enumData) => {\n return [\n {\n name: `./enums/${enumData.name}.ts`,\n contents: generatePgEnumFile(config, enumData),\n overwrite: true,\n },\n ];\n })\n .reduce(merge, []);\n\n const contextType = config.contextType ? imp(`t:${config.contextType}`) : \"{}\";\n const txnType = config.transactionType ? imp(`t:${config.transactionType}`) : \"unknown\";\n const maybeTagDelimiter =\n config.tagDelimiter === undefined\n ? code``\n : code`tagDelimiter: ${config.tagDelimiter === \"\" ? \"undefined\" : JSON.stringify(config.tagDelimiter)},`;\n\n const metadataFile: CodegenFile = {\n name: \"./codegen/metadata.ts\",\n contents: code`\n ${setRuntimeConfig}({\n temporal: ${config.temporal ? { timeZone: typeof config.temporal === \"boolean\" ? \"UTC\" : config.temporal.timeZone } : \"false\"},\n ${maybeTagDelimiter}\n });\n \n export class ${def(\"EntityManager\")} extends ${JoistEntityManager}<${contextType}, Entity, ${txnType}> {}\n\n export interface ${def(\"Entity\")} extends ${Entity} {\n id: ${getIdType(config)};\n em: EntityManager;\n }\n\n ${entities.map((meta) => generateColumnDeclarations(config, dbMeta, meta))}\n ${entities.map((meta) => generateMetadataFile(config, dbMeta, meta))}\n\n export const allMetadata = [${entities.map((meta) => meta.entity.metaName).join(\", \")}];\n ${configureMetadata}(allMetadata);\n `,\n overwrite: true,\n toStringOpts: { dprintOptions: { lineWidth: 400 } },\n };\n\n const enumsTables = Object.values(enums)\n .map(({ table }) => table)\n .sort((a, b) => a.name.localeCompare(b.name));\n\n const entitiesFile: CodegenFile = {\n name: \"./entities.ts\",\n contents: generateEntitiesFile(config, entities, enumsTables, Object.values(pgEnums)),\n overwrite: true,\n toStringOpts: { dprintOptions: { \"module.sortExportDeclarations\": \"maintain\" } },\n };\n\n const factoriesFiles: CodegenFile[] = generateFactoriesFiles(entities);\n\n const esmExt = config.esm ? (config.allowImportingTsExtensions ? \".ts\" : \".js\") : \"\";\n const indexFile: CodegenFile = {\n name: \"./index.ts\",\n contents: code`export * from \"./entities${esmExt}\"`,\n overwrite: false,\n };\n\n // Look for modules to require and call the exported `.run(Config, DbMeta)` method\n const pluginFiles: CodegenFile[] = (\n await Promise.all(\n (config.codegenPlugins ?? []).map((p) => {\n const plugin = runtimeRequire(p) as CodegenPlugin;\n return plugin.run(config, dbMeta);\n }),\n )\n ).flat();\n\n // Generate metadata-docs.ts if enabled\n const docsFile = config.outputDocs ? generateMetadataDocsFile(dbMeta, entityDocs) : undefined;\n\n return [\n ...entityFiles,\n ...enumFiles,\n ...pgEnumFiles,\n entitiesFile,\n ...factoriesFiles,\n metadataFile,\n ...(docsFile ? [docsFile] : []),\n indexFile,\n ...pluginFiles,\n ];\n}\n\n/** Reads the `entitiesDirectory` but just ignores if it doesn't exist yet. */\nasync function readExistingFiles(config: Config): Promise<string[]> {\n try {\n return await readdir(config.entitiesDirectory);\n } catch (e) {\n return [];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,MAAM,kBAAA,G,qBAAiBA,CAAAA,CAAAA,cAAAA,CAAAA,QAAAA,KAAAA,CAAAA,CAAAA,cAAAA,UAAAA,CAAAA,CAAAA,IAA6B;;AAYpD,eAAsB,cAAc,QAAgB,QAA4C;CAC9F,MAAM,EAAE,UAAU,OAAO,YAAY;CACrC,MAAM,cAAc,SAAS,KAAK,SAAS,KAAK,OAAO,IAAI;CAK3D,MAAM,QAAQ,MA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,KAAK,cAAc,EAAE,IAAI,CAAC;CAE9C,MAAM,eAA4B;EAChC,MAAM;EACN,UAAUC,6BAAAA,qBAAqB,QAAQ,UAAU,aAAa,OAAO,OAAO,OAAO,CAAC;EACpF,WAAW;EACX,cAAc,EAAE,eAAe,EAAE,iCAAiC,WAAW,EAAE;CACjF;CAEA,MAAM,iBAAgCC,+BAAAA,uBAAuB,QAAQ;CAErE,MAAM,SAAS,OAAO,MAAO,OAAO,6BAA6B,QAAQ,QAAS;CAClF,MAAM,YAAyB;EAC7B,MAAM;EACN,UAAU,QAAA,IAAI,4BAA4B,OAAO;EACjD,WAAW;CACb;CAGA,MAAM,eACJ,MAAM,QAAQ,KACX,OAAO,kBAAkB,CAAC,EAAA,CAAG,KAAK,MAAM;EAEvC,OADe,eAAe,CAClB,CAAC,CAAC,IAAI,QAAQ,MAAM;CAClC,CAAC,CACH,EAAA,CACA,KAAK;CAGP,MAAM,WAAW,OAAO,aAAaC,oCAAAA,yBAAyB,QAAQ,UAAU,IAAI,KAAA;CAEpF,OAAO;EACL,GAAG;EACH,GAAG;EACH,GAAG;EACH;EACA,GAAG;EACH;EACA,GAAI,WAAW,CAAC,QAAQ,IAAI,CAAC;EAC7B;EACA,GAAG;CACL;AACF;;AAGA,eAAe,kBAAkB,QAAmC;CAClE,IAAI;EACF,OAAO,OAAA,GAAMC,YAAAA,QAAAA,CAAQ,OAAO,iBAAiB;CAC/C,SAAS,GAAG;EACV,OAAO,CAAC;CACV;AACF"}
1
+ {"version":3,"file":"generate.cjs","names":["createRequire","syncDocs","loadEntityDocs","findAllEntityScopes","generateEntityCodegenFile","generateEntityFile","generateEntityTestFile","merge","tableToEntityName","generateEnumFile","generatePgEnumFile","imp","setRuntimeConfig","def","JoistEntityManager","Entity","getIdType","generateColumnDeclarations","generateMetadataFile","configureMetadata","generateEntitiesFile","generateFactoriesFiles","generateMetadataDocsFile","readdir"],"sources":["../src/generate.ts"],"sourcesContent":["import { readdir } from \"fs/promises\";\nimport { createRequire } from \"node:module\";\n\nimport { type CodegenFile, code, def, imp } from \"ts-poet\";\n\nimport { generateMetadataDocsFile, loadEntityDocs, syncDocs } from \"./docs/index.ts\";\nimport { findAllEntityScopes } from \"./findEntityScopes.ts\";\nimport { generateEntitiesFile } from \"./generateEntitiesFile.ts\";\nimport { generateEntityCodegenFile, getIdType } from \"./generateEntityCodegenFile.ts\";\nimport { generateEntityFile } from \"./generateEntityFile.ts\";\nimport { generateEntityTestFile } from \"./generateEntityTestFile.ts\";\nimport { generateEnumFile } from \"./generateEnumFile.ts\";\nimport { generateFactoriesFiles } from \"./generateFactoriesFiles.ts\";\nimport { generateColumnDeclarations, generateMetadataFile } from \"./generateMetadataFile.ts\";\nimport { generatePgEnumFile } from \"./generatePgEnumFile.ts\";\nimport { type Config, type DbMetadata } from \"./index.ts\";\nimport { Entity, JoistEntityManager, configureMetadata, setRuntimeConfig } from \"./symbols.ts\";\nimport { merge, tableToEntityName } from \"./utils.ts\";\n\nconst runtimeRequire = createRequire(import.meta.url);\n\nexport type DPrintOptions = Record<string, unknown>;\n\n/**\n * Provides an API for hooking into the codegen build step.\n */\nexport interface CodegenPlugin {\n run(config: Config, dbMeta: DbMetadata): Promise<CodegenFile>;\n}\n\n/** Generates our `${Entity}` and `${Entity}Codegen` files based on the `db` schema. */\nexport async function generateFiles(config: Config, dbMeta: DbMetadata): Promise<CodegenFile[]> {\n const { entities, enums, pgEnums } = dbMeta;\n const entityNames = entities.map((meta) => meta.entity.name);\n\n // Find existing entities so that, besides just using `overwrite: false`, we can completely\n // skip making test files except for the _first_ time we create an entity. This achieves\n // `.history`-like \"create once\" behavior without the need for the `.history` file.\n const files = await readExistingFiles(config);\n\n // Sync documentation: backfill .md from existing JSDocs, then sync MD -> JSDoc\n if (config.docs) {\n await syncDocs(config.entitiesDirectory, entityNames);\n }\n\n // Load the .md docs once (post-sync) to inject into codegen JSDocs and the runtime metadata-docs.ts\n const entityDocs =\n config.docs || config.outputDocs ? await loadEntityDocs(config.entitiesDirectory, entityNames) : {};\n\n const scopeMembersByEntity = await findAllEntityScopes(\n config,\n entities.map((meta) => meta.entity),\n );\n\n const entityFiles = entities\n .map((meta) => {\n const entityName = meta.entity.name;\n const hasEntityFile = files.includes(`${entityName}.ts`);\n return [\n {\n name: `./codegen/${entityName}Codegen.ts`,\n contents: generateEntityCodegenFile(\n config,\n dbMeta,\n meta,\n scopeMembersByEntity[entityName] ?? [],\n config.docs ? entityDocs[entityName] : undefined,\n ),\n overwrite: true,\n },\n ...(hasEntityFile\n ? []\n : [{ name: `${entityName}.ts`, contents: generateEntityFile(config, meta), overwrite: false }]),\n ...(hasEntityFile || config.scaffoldTests === false\n ? []\n : [{ name: `${entityName}.test.ts`, contents: generateEntityTestFile(config, meta), overwrite: false }]),\n ];\n })\n .reduce(merge, []);\n\n const enumFiles = Object.values(enums)\n .map((enumData) => {\n const enumName = tableToEntityName(config, enumData.table);\n return [\n {\n name: `./enums/${enumName}.ts`,\n contents: generateEnumFile(config, enumData, enumName),\n overwrite: true,\n },\n ];\n })\n .reduce(merge, []);\n const pgEnumFiles = Object.values(pgEnums)\n .map((enumData) => {\n return [\n {\n name: `./enums/${enumData.name}.ts`,\n contents: generatePgEnumFile(config, enumData),\n overwrite: true,\n },\n ];\n })\n .reduce(merge, []);\n\n const contextType = config.contextType ? imp(`t:${config.contextType}`) : \"{}\";\n const txnType = config.transactionType ? imp(`t:${config.transactionType}`) : \"unknown\";\n const maybeTagDelimiter =\n config.tagDelimiter === undefined\n ? code``\n : code`tagDelimiter: ${config.tagDelimiter === \"\" ? \"undefined\" : JSON.stringify(config.tagDelimiter)},`;\n\n const metadataFile: CodegenFile = {\n name: \"./codegen/metadata.ts\",\n contents: code`\n ${setRuntimeConfig}({\n temporal: ${config.temporal ? { timeZone: typeof config.temporal === \"boolean\" ? \"UTC\" : config.temporal.timeZone } : \"false\"},\n ${maybeTagDelimiter}\n });\n \n export class ${def(\"EntityManager\")} extends ${JoistEntityManager}<${contextType}, Entity, ${txnType}> {}\n\n export interface ${def(\"Entity\")} extends ${Entity} {\n id: ${getIdType(config)};\n em: EntityManager;\n }\n\n ${entities.map((meta) => generateColumnDeclarations(config, dbMeta, meta))}\n ${entities.map((meta) => generateMetadataFile(config, dbMeta, meta))}\n\n export const allMetadata = [${entities.map((meta) => meta.entity.metaName).join(\", \")}];\n ${configureMetadata}(allMetadata);\n `,\n overwrite: true,\n toStringOpts: { dprintOptions: { lineWidth: 400 } },\n };\n\n const enumsTables = Object.values(enums)\n .map(({ table }) => table)\n .sort((a, b) => a.name.localeCompare(b.name));\n\n const entitiesFile: CodegenFile = {\n name: \"./entities.ts\",\n contents: generateEntitiesFile(config, entities, enumsTables, Object.values(pgEnums)),\n overwrite: true,\n toStringOpts: { dprintOptions: { \"module.sortExportDeclarations\": \"maintain\" } },\n };\n\n const factoriesFiles: CodegenFile[] = generateFactoriesFiles(entities);\n\n const esmExt = config.esm ? (config.allowImportingTsExtensions ? \".ts\" : \".js\") : \"\";\n const indexFile: CodegenFile = {\n name: \"./index.ts\",\n contents: code`export * from \"./entities${esmExt}\"`,\n overwrite: false,\n };\n\n // Look for modules to require and call the exported `.run(Config, DbMeta)` method\n const pluginFiles: CodegenFile[] = (\n await Promise.all(\n (config.codegenPlugins ?? []).map((p) => {\n const plugin = runtimeRequire(p) as CodegenPlugin;\n return plugin.run(config, dbMeta);\n }),\n )\n ).flat();\n\n // Generate metadata-docs.ts if enabled\n const docsFile = config.outputDocs ? generateMetadataDocsFile(dbMeta, entityDocs) : undefined;\n\n return [\n ...entityFiles,\n ...enumFiles,\n ...pgEnumFiles,\n entitiesFile,\n ...factoriesFiles,\n metadataFile,\n ...(docsFile ? [docsFile] : []),\n indexFile,\n ...pluginFiles,\n ];\n}\n\n/** Reads the `entitiesDirectory` but just ignores if it doesn't exist yet. */\nasync function readExistingFiles(config: Config): Promise<string[]> {\n try {\n return await readdir(config.entitiesDirectory);\n } catch (e) {\n return [];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;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AG;EACV,OAAO,CAAC;CACV;AACF"}
package/build/generate.js CHANGED
@@ -28,19 +28,23 @@ async function generateFiles(config, dbMeta) {
28
28
  const entityFiles = entities.map((meta) => {
29
29
  const entityName = meta.entity.name;
30
30
  const hasEntityFile = files.includes(`${entityName}.ts`);
31
- return [{
32
- name: `./codegen/${entityName}Codegen.ts`,
33
- contents: generateEntityCodegenFile(config, dbMeta, meta, scopeMembersByEntity[entityName] ?? [], config.docs ? entityDocs[entityName] : void 0),
34
- overwrite: true
35
- }, ...hasEntityFile ? [] : [{
36
- name: `${entityName}.ts`,
37
- contents: generateEntityFile(config, meta),
38
- overwrite: false
39
- }, {
40
- name: `${entityName}.test.ts`,
41
- contents: generateEntityTestFile(config, meta),
42
- overwrite: false
43
- }]];
31
+ return [
32
+ {
33
+ name: `./codegen/${entityName}Codegen.ts`,
34
+ contents: generateEntityCodegenFile(config, dbMeta, meta, scopeMembersByEntity[entityName] ?? [], config.docs ? entityDocs[entityName] : void 0),
35
+ overwrite: true
36
+ },
37
+ ...hasEntityFile ? [] : [{
38
+ name: `${entityName}.ts`,
39
+ contents: generateEntityFile(config, meta),
40
+ overwrite: false
41
+ }],
42
+ ...hasEntityFile || config.scaffoldTests === false ? [] : [{
43
+ name: `${entityName}.test.ts`,
44
+ contents: generateEntityTestFile(config, meta),
45
+ overwrite: false
46
+ }]
47
+ ];
44
48
  }).reduce(merge, []);
45
49
  const enumFiles = Object.values(enums).map((enumData) => {
46
50
  const enumName = tableToEntityName(config, enumData.table);
@@ -1 +1 @@
1
- {"version":3,"file":"generate.js","names":[],"sources":["../src/generate.ts"],"sourcesContent":["import { readdir } from \"fs/promises\";\nimport { createRequire } from \"node:module\";\n\nimport { type CodegenFile, code, def, imp } from \"ts-poet\";\n\nimport { generateMetadataDocsFile, loadEntityDocs, syncDocs } from \"./docs/index.ts\";\nimport { findAllEntityScopes } from \"./findEntityScopes.ts\";\nimport { generateEntitiesFile } from \"./generateEntitiesFile.ts\";\nimport { generateEntityCodegenFile, getIdType } from \"./generateEntityCodegenFile.ts\";\nimport { generateEntityFile } from \"./generateEntityFile.ts\";\nimport { generateEntityTestFile } from \"./generateEntityTestFile.ts\";\nimport { generateEnumFile } from \"./generateEnumFile.ts\";\nimport { generateFactoriesFiles } from \"./generateFactoriesFiles.ts\";\nimport { generateColumnDeclarations, generateMetadataFile } from \"./generateMetadataFile.ts\";\nimport { generatePgEnumFile } from \"./generatePgEnumFile.ts\";\nimport { type Config, type DbMetadata } from \"./index.ts\";\nimport { Entity, JoistEntityManager, configureMetadata, setRuntimeConfig } from \"./symbols.ts\";\nimport { merge, tableToEntityName } from \"./utils.ts\";\n\nconst runtimeRequire = createRequire(import.meta.url);\n\nexport type DPrintOptions = Record<string, unknown>;\n\n/**\n * Provides an API for hooking into the codegen build step.\n */\nexport interface CodegenPlugin {\n run(config: Config, dbMeta: DbMetadata): Promise<CodegenFile>;\n}\n\n/** Generates our `${Entity}` and `${Entity}Codegen` files based on the `db` schema. */\nexport async function generateFiles(config: Config, dbMeta: DbMetadata): Promise<CodegenFile[]> {\n const { entities, enums, pgEnums } = dbMeta;\n const entityNames = entities.map((meta) => meta.entity.name);\n\n // Find existing entities so that, besides just using `overwrite: false`, we can completely\n // skip making test files except for the _first_ time we create an entity. This achieves\n // `.history`-like \"create once\" behavior without the need for the `.history` file.\n const files = await readExistingFiles(config);\n\n // Sync documentation: backfill .md from existing JSDocs, then sync MD -> JSDoc\n if (config.docs) {\n await syncDocs(config.entitiesDirectory, entityNames);\n }\n\n // Load the .md docs once (post-sync) to inject into codegen JSDocs and the runtime metadata-docs.ts\n const entityDocs =\n config.docs || config.outputDocs ? await loadEntityDocs(config.entitiesDirectory, entityNames) : {};\n\n const scopeMembersByEntity = await findAllEntityScopes(\n config,\n entities.map((meta) => meta.entity),\n );\n\n const entityFiles = entities\n .map((meta) => {\n const entityName = meta.entity.name;\n const hasEntityFile = files.includes(`${entityName}.ts`);\n return [\n {\n name: `./codegen/${entityName}Codegen.ts`,\n contents: generateEntityCodegenFile(\n config,\n dbMeta,\n meta,\n scopeMembersByEntity[entityName] ?? [],\n config.docs ? entityDocs[entityName] : undefined,\n ),\n overwrite: true,\n },\n ...(hasEntityFile\n ? []\n : [\n { name: `${entityName}.ts`, contents: generateEntityFile(config, meta), overwrite: false },\n { name: `${entityName}.test.ts`, contents: generateEntityTestFile(config, meta), overwrite: false },\n ]),\n ];\n })\n .reduce(merge, []);\n\n const enumFiles = Object.values(enums)\n .map((enumData) => {\n const enumName = tableToEntityName(config, enumData.table);\n return [\n {\n name: `./enums/${enumName}.ts`,\n contents: generateEnumFile(config, enumData, enumName),\n overwrite: true,\n },\n ];\n })\n .reduce(merge, []);\n const pgEnumFiles = Object.values(pgEnums)\n .map((enumData) => {\n return [\n {\n name: `./enums/${enumData.name}.ts`,\n contents: generatePgEnumFile(config, enumData),\n overwrite: true,\n },\n ];\n })\n .reduce(merge, []);\n\n const contextType = config.contextType ? imp(`t:${config.contextType}`) : \"{}\";\n const txnType = config.transactionType ? imp(`t:${config.transactionType}`) : \"unknown\";\n const maybeTagDelimiter =\n config.tagDelimiter === undefined\n ? code``\n : code`tagDelimiter: ${config.tagDelimiter === \"\" ? \"undefined\" : JSON.stringify(config.tagDelimiter)},`;\n\n const metadataFile: CodegenFile = {\n name: \"./codegen/metadata.ts\",\n contents: code`\n ${setRuntimeConfig}({\n temporal: ${config.temporal ? { timeZone: typeof config.temporal === \"boolean\" ? \"UTC\" : config.temporal.timeZone } : \"false\"},\n ${maybeTagDelimiter}\n });\n \n export class ${def(\"EntityManager\")} extends ${JoistEntityManager}<${contextType}, Entity, ${txnType}> {}\n\n export interface ${def(\"Entity\")} extends ${Entity} {\n id: ${getIdType(config)};\n em: EntityManager;\n }\n\n ${entities.map((meta) => generateColumnDeclarations(config, dbMeta, meta))}\n ${entities.map((meta) => generateMetadataFile(config, dbMeta, meta))}\n\n export const allMetadata = [${entities.map((meta) => meta.entity.metaName).join(\", \")}];\n ${configureMetadata}(allMetadata);\n `,\n overwrite: true,\n toStringOpts: { dprintOptions: { lineWidth: 400 } },\n };\n\n const enumsTables = Object.values(enums)\n .map(({ table }) => table)\n .sort((a, b) => a.name.localeCompare(b.name));\n\n const entitiesFile: CodegenFile = {\n name: \"./entities.ts\",\n contents: generateEntitiesFile(config, entities, enumsTables, Object.values(pgEnums)),\n overwrite: true,\n toStringOpts: { dprintOptions: { \"module.sortExportDeclarations\": \"maintain\" } },\n };\n\n const factoriesFiles: CodegenFile[] = generateFactoriesFiles(entities);\n\n const esmExt = config.esm ? (config.allowImportingTsExtensions ? \".ts\" : \".js\") : \"\";\n const indexFile: CodegenFile = {\n name: \"./index.ts\",\n contents: code`export * from \"./entities${esmExt}\"`,\n overwrite: false,\n };\n\n // Look for modules to require and call the exported `.run(Config, DbMeta)` method\n const pluginFiles: CodegenFile[] = (\n await Promise.all(\n (config.codegenPlugins ?? []).map((p) => {\n const plugin = runtimeRequire(p) as CodegenPlugin;\n return plugin.run(config, dbMeta);\n }),\n )\n ).flat();\n\n // Generate metadata-docs.ts if enabled\n const docsFile = config.outputDocs ? generateMetadataDocsFile(dbMeta, entityDocs) : undefined;\n\n return [\n ...entityFiles,\n ...enumFiles,\n ...pgEnumFiles,\n entitiesFile,\n ...factoriesFiles,\n metadataFile,\n ...(docsFile ? [docsFile] : []),\n indexFile,\n ...pluginFiles,\n ];\n}\n\n/** Reads the `entitiesDirectory` but just ignores if it doesn't exist yet. */\nasync function readExistingFiles(config: Config): Promise<string[]> {\n try {\n return await readdir(config.entitiesDirectory);\n } catch (e) {\n return [];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,MAAM,iBAAiB,cAAc,YAAY,GAAG;;AAYpD,eAAsB,cAAc,QAAgB,QAA4C;CAC9F,MAAM,EAAE,UAAU,OAAO,YAAY;CACrC,MAAM,cAAc,SAAS,KAAK,SAAS,KAAK,OAAO,IAAI;CAK3D,MAAM,QAAQ,MAAM,kBAAkB,MAAM;CAG5C,IAAI,OAAO,MACT,M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AAU,IAAI,4BAA4B,OAAO;EACjD,WAAW;CACb;CAGA,MAAM,eACJ,MAAM,QAAQ,KACX,OAAO,kBAAkB,CAAC,EAAA,CAAG,KAAK,MAAM;EAEvC,OADe,eAAe,CAClB,CAAC,CAAC,IAAI,QAAQ,MAAM;CAClC,CAAC,CACH,EAAA,CACA,KAAK;CAGP,MAAM,WAAW,OAAO,aAAa,yBAAyB,QAAQ,UAAU,IAAI,KAAA;CAEpF,OAAO;EACL,GAAG;EACH,GAAG;EACH,GAAG;EACH;EACA,GAAG;EACH;EACA,GAAI,WAAW,CAAC,QAAQ,IAAI,CAAC;EAC7B;EACA,GAAG;CACL;AACF;;AAGA,eAAe,kBAAkB,QAAmC;CAClE,IAAI;EACF,OAAO,MAAM,QAAQ,OAAO,iBAAiB;CAC/C,SAAS,GAAG;EACV,OAAO,CAAC;CACV;AACF"}
1
+ {"version":3,"file":"generate.js","names":[],"sources":["../src/generate.ts"],"sourcesContent":["import { readdir } from \"fs/promises\";\nimport { createRequire } from \"node:module\";\n\nimport { type CodegenFile, code, def, imp } from \"ts-poet\";\n\nimport { generateMetadataDocsFile, loadEntityDocs, syncDocs } from \"./docs/index.ts\";\nimport { findAllEntityScopes } from \"./findEntityScopes.ts\";\nimport { generateEntitiesFile } from \"./generateEntitiesFile.ts\";\nimport { generateEntityCodegenFile, getIdType } from \"./generateEntityCodegenFile.ts\";\nimport { generateEntityFile } from \"./generateEntityFile.ts\";\nimport { generateEntityTestFile } from \"./generateEntityTestFile.ts\";\nimport { generateEnumFile } from \"./generateEnumFile.ts\";\nimport { generateFactoriesFiles } from \"./generateFactoriesFiles.ts\";\nimport { generateColumnDeclarations, generateMetadataFile } from \"./generateMetadataFile.ts\";\nimport { generatePgEnumFile } from \"./generatePgEnumFile.ts\";\nimport { type Config, type DbMetadata } from \"./index.ts\";\nimport { Entity, JoistEntityManager, configureMetadata, setRuntimeConfig } from \"./symbols.ts\";\nimport { merge, tableToEntityName } from \"./utils.ts\";\n\nconst runtimeRequire = createRequire(import.meta.url);\n\nexport type DPrintOptions = Record<string, unknown>;\n\n/**\n * Provides an API for hooking into the codegen build step.\n */\nexport interface CodegenPlugin {\n run(config: Config, dbMeta: DbMetadata): Promise<CodegenFile>;\n}\n\n/** Generates our `${Entity}` and `${Entity}Codegen` files based on the `db` schema. */\nexport async function generateFiles(config: Config, dbMeta: DbMetadata): Promise<CodegenFile[]> {\n const { entities, enums, pgEnums } = dbMeta;\n const entityNames = entities.map((meta) => meta.entity.name);\n\n // Find existing entities so that, besides just using `overwrite: false`, we can completely\n // skip making test files except for the _first_ time we create an entity. This achieves\n // `.history`-like \"create once\" behavior without the need for the `.history` file.\n const files = await readExistingFiles(config);\n\n // Sync documentation: backfill .md from existing JSDocs, then sync MD -> JSDoc\n if (config.docs) {\n await syncDocs(config.entitiesDirectory, entityNames);\n }\n\n // Load the .md docs once (post-sync) to inject into codegen JSDocs and the runtime metadata-docs.ts\n const entityDocs =\n config.docs || config.outputDocs ? await loadEntityDocs(config.entitiesDirectory, entityNames) : {};\n\n const scopeMembersByEntity = await findAllEntityScopes(\n config,\n entities.map((meta) => meta.entity),\n );\n\n const entityFiles = entities\n .map((meta) => {\n const entityName = meta.entity.name;\n const hasEntityFile = files.includes(`${entityName}.ts`);\n return [\n {\n name: `./codegen/${entityName}Codegen.ts`,\n contents: generateEntityCodegenFile(\n config,\n dbMeta,\n meta,\n scopeMembersByEntity[entityName] ?? [],\n config.docs ? entityDocs[entityName] : undefined,\n ),\n overwrite: true,\n },\n ...(hasEntityFile\n ? []\n : [{ name: `${entityName}.ts`, contents: generateEntityFile(config, meta), overwrite: false }]),\n ...(hasEntityFile || config.scaffoldTests === false\n ? []\n : [{ name: `${entityName}.test.ts`, contents: generateEntityTestFile(config, meta), overwrite: false }]),\n ];\n })\n .reduce(merge, []);\n\n const enumFiles = Object.values(enums)\n .map((enumData) => {\n const enumName = tableToEntityName(config, enumData.table);\n return [\n {\n name: `./enums/${enumName}.ts`,\n contents: generateEnumFile(config, enumData, enumName),\n overwrite: true,\n },\n ];\n })\n .reduce(merge, []);\n const pgEnumFiles = Object.values(pgEnums)\n .map((enumData) => {\n return [\n {\n name: `./enums/${enumData.name}.ts`,\n contents: generatePgEnumFile(config, enumData),\n overwrite: true,\n },\n ];\n })\n .reduce(merge, []);\n\n const contextType = config.contextType ? imp(`t:${config.contextType}`) : \"{}\";\n const txnType = config.transactionType ? imp(`t:${config.transactionType}`) : \"unknown\";\n const maybeTagDelimiter =\n config.tagDelimiter === undefined\n ? code``\n : code`tagDelimiter: ${config.tagDelimiter === \"\" ? \"undefined\" : JSON.stringify(config.tagDelimiter)},`;\n\n const metadataFile: CodegenFile = {\n name: \"./codegen/metadata.ts\",\n contents: code`\n ${setRuntimeConfig}({\n temporal: ${config.temporal ? { timeZone: typeof config.temporal === \"boolean\" ? \"UTC\" : config.temporal.timeZone } : \"false\"},\n ${maybeTagDelimiter}\n });\n \n export class ${def(\"EntityManager\")} extends ${JoistEntityManager}<${contextType}, Entity, ${txnType}> {}\n\n export interface ${def(\"Entity\")} extends ${Entity} {\n id: ${getIdType(config)};\n em: EntityManager;\n }\n\n ${entities.map((meta) => generateColumnDeclarations(config, dbMeta, meta))}\n ${entities.map((meta) => generateMetadataFile(config, dbMeta, meta))}\n\n export const allMetadata = [${entities.map((meta) => meta.entity.metaName).join(\", \")}];\n ${configureMetadata}(allMetadata);\n `,\n overwrite: true,\n toStringOpts: { dprintOptions: { lineWidth: 400 } },\n };\n\n const enumsTables = Object.values(enums)\n .map(({ table }) => table)\n .sort((a, b) => a.name.localeCompare(b.name));\n\n const entitiesFile: CodegenFile = {\n name: \"./entities.ts\",\n contents: generateEntitiesFile(config, entities, enumsTables, Object.values(pgEnums)),\n overwrite: true,\n toStringOpts: { dprintOptions: { \"module.sortExportDeclarations\": \"maintain\" } },\n };\n\n const factoriesFiles: CodegenFile[] = generateFactoriesFiles(entities);\n\n const esmExt = config.esm ? (config.allowImportingTsExtensions ? \".ts\" : \".js\") : \"\";\n const indexFile: CodegenFile = {\n name: \"./index.ts\",\n contents: code`export * from \"./entities${esmExt}\"`,\n overwrite: false,\n };\n\n // Look for modules to require and call the exported `.run(Config, DbMeta)` method\n const pluginFiles: CodegenFile[] = (\n await Promise.all(\n (config.codegenPlugins ?? []).map((p) => {\n const plugin = runtimeRequire(p) as CodegenPlugin;\n return plugin.run(config, dbMeta);\n }),\n )\n ).flat();\n\n // Generate metadata-docs.ts if enabled\n const docsFile = config.outputDocs ? generateMetadataDocsFile(dbMeta, entityDocs) : undefined;\n\n return [\n ...entityFiles,\n ...enumFiles,\n ...pgEnumFiles,\n entitiesFile,\n ...factoriesFiles,\n metadataFile,\n ...(docsFile ? [docsFile] : []),\n indexFile,\n ...pluginFiles,\n ];\n}\n\n/** Reads the `entitiesDirectory` but just ignores if it doesn't exist yet. */\nasync function readExistingFiles(config: Config): Promise<string[]> {\n try {\n return await readdir(config.entitiesDirectory);\n } catch (e) {\n return [];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,MAAM,iBAAiB,cAAc,YAAY,GAAG;;AAYpD,eAAsB,cAAc,QAAgB,QAA4C;CAC9F,MAAM,EAAE,UAAU,OAAO,YAAY;CACrC,MAAM,cAAc,SAAS,KAAK,SAAS,KAAK,OAAO,IAAI;CAK3D,MAAM,QAAQ,MAAM,kBAAkB,MAAM;CAG5C,IAAI,OAAO,MACT,MAAM,SAAS,OAAO,mBAAmB,WAAW;CAItD,MAAM,aACJ,OAAO,QAAQ,OAAO,aAAa,MAAM,eAAe,OAAO,mBAAmB,WAAW,IAAI,CAAC;CAEpG,MAAM,uBAAuB,MAAM,oBACjC,QACA,SAAS,KAAK,SAAS,KAAK,MAAM,CACpC;CAEA,MAAM,cAAc,SACjB,KAAK,SAAS;EACb,MAAM,aAAa,KAAK,OAAO;EAC/B,MAAM,gBAAgB,MAAM,SAAS,GAAG,WAAW,IAAI;EACvD,OAAO;GACL;IACE,MAAM,aAAa,WAAW;IAC9B,UAAU,0BACR,QAC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;EACH,GAAG;EACH;EACA,GAAG;EACH;EACA,GAAI,WAAW,CAAC,QAAQ,IAAI,CAAC;EAC7B;EACA,GAAG;CACL;AACF;;AAGA,eAAe,kBAAkB,QAAmC;CAClE,IAAI;EACF,OAAO,MAAM,QAAQ,OAAO,iBAAiB;CAC/C,SAAS,GAAG;EACV,OAAO,CAAC;CACV;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "joist-codegen",
3
- "version": "2.5.0-next.25",
3
+ "version": "2.5.0-next.27",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
@@ -48,7 +48,7 @@
48
48
  "skills"
49
49
  ],
50
50
  "peerDependencies": {
51
- "joist-utils": "2.5.0-next.25",
51
+ "joist-utils": "2.5.0-next.27",
52
52
  "knex": "^3.1.0",
53
53
  "pg": "^8.23.0"
54
54
  },