@cerios/salesforce-sobjectly 1.0.0 → 1.1.0
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/README.md +1 -1
- package/dist/cli.cjs +4 -4
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +5 -4
- package/dist/cli.mjs.map +1 -1
- package/dist/{codegen-BgDgU2RR.cjs → codegen-Bylrt2Ju.cjs} +207 -43
- package/dist/codegen-Bylrt2Ju.cjs.map +1 -0
- package/dist/{codegen-CSx0WAtK.mjs → codegen-C6MEYiWo.mjs} +211 -45
- package/dist/codegen-C6MEYiWo.mjs.map +1 -0
- package/dist/codegen.cjs +1 -1
- package/dist/codegen.d.cts +19 -4
- package/dist/codegen.d.mts +19 -4
- package/dist/codegen.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{sf-cli-DEVZQTR7.cjs → sf-cli-R6LHwqoo.cjs} +8 -5
- package/dist/{sf-cli-DEVZQTR7.cjs.map → sf-cli-R6LHwqoo.cjs.map} +1 -1
- package/dist/{sf-cli-CtWtdkJ0.mjs → sf-cli-_Ua-M_Zi.mjs} +8 -5
- package/dist/{sf-cli-CtWtdkJ0.mjs.map → sf-cli-_Ua-M_Zi.mjs.map} +1 -1
- package/package.json +1 -1
- package/sobjectly.config.schema.json +2 -2
- package/dist/codegen-BgDgU2RR.cjs.map +0 -1
- package/dist/codegen-CSx0WAtK.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cerios/salesforce-sobjectly",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Type-safe Salesforce REST API client for TypeScript. Generated SObject types, a typed SOQL builder, CRUD, composite, sObject collections, SOSL, invocable actions/Flow, Tooling API and Bulk API 2.0.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -104,8 +104,8 @@
|
|
|
104
104
|
"description": "Per sObject, fields to leave out of the update input."
|
|
105
105
|
},
|
|
106
106
|
"picklists": {
|
|
107
|
-
"enum": ["union", "string"],
|
|
108
|
-
"description": "\"union\" (default): picklists become unions of their values. \"string\": plain strings."
|
|
107
|
+
"enum": ["union", "string", "const", "enum"],
|
|
108
|
+
"description": "\"union\" (default): picklists become unions of their values. \"string\": plain strings. \"const\": a union plus a named const object and type per picklist, e.g. CaseStatus.Working. \"enum\": a TypeScript enum per picklist; restricted picklists then only accept enum members."
|
|
109
109
|
},
|
|
110
110
|
"constants": {
|
|
111
111
|
"type": "boolean",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codegen-BgDgU2RR.cjs","names":["IDENTIFIER","createHash","isApiVersion","join","existsSync","resolve","extname","dirname","createJiti","readFileSync","relative","join","normalizeApiVersion","existsSync","readFileSync","createInterface","existsSync","readFile","isAbsolute","resolve","SalesforceClient","accessToken","sfCli","clientCredentials","readFileSync","jwtBearer","mkdir","dirname","writeFile","rm","rename"],"sources":["../src/codegen/type-mapper.ts","../src/codegen/generator.ts","../src/codegen/validate-config.ts","../src/codegen/config.ts","../src/codegen/load-config.ts","../src/codegen/init.ts","../src/codegen/prompter.ts","../src/codegen/index.ts"],"sourcesContent":["import type { FieldDescribe } from \"../types/describe\";\n\nimport type { PicklistMode } from \"./config\";\n\n/** The subset of a field describe the generator needs. */\nexport type CodegenField = Pick<\n\tFieldDescribe,\n\t| \"name\"\n\t| \"label\"\n\t| \"type\"\n\t| \"nillable\"\n\t| \"createable\"\n\t| \"updateable\"\n\t| \"defaultedOnCreate\"\n\t| \"referenceTo\"\n\t| \"relationshipName\"\n> &\n\tPartial<Pick<FieldDescribe, \"picklistValues\" | \"restrictedPicklist\" | \"externalId\" | \"idLookup\">>;\n\nexport const ADDRESS_TYPE = \"SalesforceAddress\";\nexport const GEOLOCATION_TYPE = \"SalesforceGeolocation\";\n\n/** Maps each Salesforce field type to a TypeScript type. Types not listed become `unknown`. */\nexport const FIELD_TYPE_MAP: Readonly<Record<string, string>> = {\n\tboolean: \"boolean\",\n\tint: \"number\",\n\tlong: \"number\",\n\tdouble: \"number\",\n\tcurrency: \"number\",\n\tpercent: \"number\",\n\t/** ISO date, `yyyy-MM-dd`. */\n\tdate: \"string\",\n\t/** ISO date-time, e.g. `2026-01-31T12:00:00.000+0000`. */\n\tdatetime: \"string\",\n\t/** `HH:mm:ss.SSSZ`. */\n\ttime: \"string\",\n\tid: \"string\",\n\treference: \"string\",\n\tstring: \"string\",\n\ttextarea: \"string\",\n\tpicklist: \"string\",\n\t/** Values separated by `;`. */\n\tmultipicklist: \"string\",\n\tcombobox: \"string\",\n\temail: \"string\",\n\tphone: \"string\",\n\turl: \"string\",\n\tencryptedstring: \"string\",\n\t/** Base64-encoded content. */\n\tbase64: \"string\",\n\taddress: ADDRESS_TYPE,\n\tlocation: GEOLOCATION_TYPE,\n};\n\n/** Returns the TypeScript type for a field, including `| null` for nillable fields. */\nexport function mapFieldType(field: CodegenField, picklists: PicklistMode = \"union\"): string {\n\tconst base = picklistType(field, picklists) ?? FIELD_TYPE_MAP[field.type] ?? \"unknown\";\n\treturn field.nillable && base !== \"unknown\" ? `${base} | null` : base;\n}\n\nfunction picklistType(field: CodegenField, picklists: PicklistMode): string | undefined {\n\tif (picklists !== \"union\" || (field.type !== \"picklist\" && field.type !== \"combobox\")) {\n\t\treturn undefined;\n\t}\n\tconst values = [...new Set((field.picklistValues ?? []).filter((entry) => entry.active).map((entry) => entry.value))];\n\tif (values.length === 0) {\n\t\treturn undefined;\n\t}\n\tconst union = values.map((value) => JSON.stringify(value)).join(\" | \");\n\treturn field.restrictedPicklist && field.type === \"picklist\" ? union : `${union} | (string & {})`;\n}\n","import { createHash } from \"node:crypto\";\n\nimport type { ApiVersion } from \"../types/common\";\nimport type { ChildRelationship, RecordTypeInfo } from \"../types/describe\";\n\nimport type { PicklistMode } from \"./config\";\nimport { ADDRESS_TYPE, type CodegenField, GEOLOCATION_TYPE, mapFieldType } from \"./type-mapper\";\n\n/** The subset of an sObject describe the generator needs. */\nexport interface CodegenDescribe {\n\tname: string;\n\tlabel?: string;\n\tfields: CodegenField[];\n\tchildRelationships: Pick<ChildRelationship, \"childSObject\" | \"field\" | \"relationshipName\">[];\n\trecordTypeInfos?: Pick<RecordTypeInfo, \"developerName\">[];\n}\n\nexport interface GenerateSourceOptions {\n\texcludeCreateFields?: Partial<Record<string, readonly string[]>>;\n\texcludeUpdateFields?: Partial<Record<string, readonly string[]>>;\n\tpicklists?: PicklistMode;\n\timportSource?: string;\n\t/** When set, the output exports it as `API_VERSION`, so the client can use the same version. */\n\tapiVersion?: ApiVersion;\n\t/** Emit the `PICKLIST_VALUES` and `RECORD_TYPES` runtime constants. Defaults to `true`. */\n\tconstants?: boolean;\n}\n\n/** Field types whose kind is recorded in the registry's `fieldKinds`. */\nconst FIELD_KINDS = new Set([\"date\", \"datetime\", \"time\", \"multipicklist\"]);\n\nconst IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;\n\n/**\n * Generates the TypeScript source for a set of sObject describes: a read interface, create\n * and update input types per sObject, and the `SObjectRegistry` that ties them together.\n * The output is deterministic: sObjects are sorted by name and fields by name (`Id` first).\n */\nexport function generateSource(describes: readonly CodegenDescribe[], options: GenerateSourceOptions = {}): string {\n\tconst sorted = [...describes].sort((a, b) => compare(a.name, b.name));\n\tassertGeneratableNames(sorted);\n\tconst names = new Set(sorted.map((describe) => describe.name));\n\tconst sections = [imports(sorted, options.importSource ?? \"@cerios/salesforce-sobjectly\")];\n\tconst objectHashes: string[] = [];\n\n\tfor (const describe of sorted) {\n\t\tconst objectSections = [\n\t\t\treadInterface(describe, options.picklists ?? \"union\"),\n\t\t\tinputType(describe, \"CreateInput\", \"createable\", lookup(options.excludeCreateFields, describe.name)),\n\t\t\tinputType(describe, \"UpdateInput\", \"updateable\", lookup(options.excludeUpdateFields, describe.name)),\n\t\t];\n\t\tsections.push(...objectSections);\n\t\tconst fingerprint = [\n\t\t\t...objectSections,\n\t\t\tregistryEntry(describe, names),\n\t\t\toptions.constants === false ? \"\" : picklistEntry(describe),\n\t\t].join(\"\\n\");\n\t\tobjectHashes.push(`${describe.name}:${sha256(fingerprint).slice(0, OBJECT_HASH_LENGTH)}`);\n\t}\n\tsections.push(registry(sorted, names));\n\tif (options.constants !== false) {\n\t\tsections.push(picklistConstants(sorted), recordTypeConstants(sorted));\n\t}\n\tif (options.apiVersion) {\n\t\tsections.push(apiVersionConstant(options.apiVersion));\n\t}\n\tconst body = sections.filter((section) => section.length > 0).join(\"\\n\\n\");\n\treturn `${header(sha256(body), objectHashes)}\\n\\n${body}\\n`;\n}\n\n/** Names the generated file uses itself; an sObject with one of these names would break it. */\nconst RESERVED_TYPE_NAMES = new Set([\n\t\"Record\",\n\t\"Pick\",\n\t\"Partial\",\n\t\"SObjectRegistry\",\n\t\"PICKLIST_VALUES\",\n\t\"RECORD_TYPES\",\n\t\"API_VERSION\",\n\tADDRESS_TYPE,\n\tGEOLOCATION_TYPE,\n]);\n\n/** Fails with a clear message for sObject names the generated TypeScript can't represent. */\nfunction assertGeneratableNames(describes: readonly CodegenDescribe[]): void {\n\tconst seen = new Map<string, string>();\n\tconst generated = new Set(\n\t\tdescribes.flatMap((describe) => [`${describe.name}CreateInput`, `${describe.name}UpdateInput`]),\n\t);\n\tfor (const { name } of describes) {\n\t\tif (!IDENTIFIER.test(name)) {\n\t\t\tthrow new Error(`sObject name \"${name}\" is not a valid TypeScript identifier.`);\n\t\t}\n\t\tif (RESERVED_TYPE_NAMES.has(name) || generated.has(name)) {\n\t\t\tthrow new Error(`sObject name \"${name}\" clashes with a type the generated file defines; exclude it.`);\n\t\t}\n\t\tconst previous = seen.get(name.toLowerCase());\n\t\tif (previous !== undefined) {\n\t\t\tthrow new Error(`sObjects \"${previous}\" and \"${name}\" differ only in case; list each sObject once.`);\n\t\t}\n\t\tseen.set(name.toLowerCase(), name);\n\t}\n}\n\n/** Looks up a per-sObject option case-insensitively (sObject names are case-insensitive in Salesforce). */\nfunction lookup(map: Partial<Record<string, readonly string[]>> | undefined, name: string): readonly string[] {\n\tif (!map) {\n\t\treturn [];\n\t}\n\tconst key = Object.keys(map).find((candidate) => candidate.toLowerCase() === name.toLowerCase());\n\treturn key === undefined ? [] : (map[key] ?? []);\n}\n\nconst CONTENT_HASH_PREFIX = \"// sobjectly-content-hash: sha256:\";\nconst OBJECT_HASHES_PREFIX = \"// sobjectly-sobjects: \";\nconst OBJECT_HASH_LENGTH = 12;\n\nfunction header(contentHash: string, objectHashes: readonly string[]): string {\n\treturn [\n\t\t\"// ──────────────────────────────────────────────────────────────\",\n\t\t\"// AUTO-GENERATED by @cerios/salesforce-sobjectly (`sobjectly generate`).\",\n\t\t\"// Do not edit manually; re-run the generator instead.\",\n\t\t\"// ──────────────────────────────────────────────────────────────\",\n\t\t`${CONTENT_HASH_PREFIX}${contentHash}`,\n\t\t`${OBJECT_HASHES_PREFIX}${objectHashes.join(\",\")}`,\n\t\t\"/* eslint-disable */\",\n\t].join(\"\\n\");\n}\n\n/** The content hashes a generated file records in its header. */\nexport interface GeneratedFileHashes {\n\t/** SHA-256 of the unformatted generated content; formatting changes don't affect it. */\n\tcontentHash: string;\n\t/** Short hash per sObject, to tell which sObjects changed. */\n\tsobjects: Map<string, string>;\n}\n\n/** Reads the content hashes from a generated file's header (also after reformatting). */\nexport function readGeneratedHashes(source: string): GeneratedFileHashes | undefined {\n\tconst lines = source.split(/\\r?\\n/).map((line) => line.trim());\n\tconst hashLine = lines.find((line) => line.startsWith(CONTENT_HASH_PREFIX));\n\tif (!hashLine) {\n\t\treturn undefined;\n\t}\n\tconst objectsLine = lines.find((line) => line.startsWith(OBJECT_HASHES_PREFIX)) ?? OBJECT_HASHES_PREFIX;\n\tconst sobjects = new Map<string, string>();\n\tfor (const entry of objectsLine.slice(OBJECT_HASHES_PREFIX.length).split(\",\")) {\n\t\tconst [name, hash] = entry.split(\":\");\n\t\tif (name && hash) {\n\t\t\tsobjects.set(name, hash);\n\t\t}\n\t}\n\treturn { contentHash: hashLine.slice(CONTENT_HASH_PREFIX.length), sobjects };\n}\n\nfunction sha256(text: string): string {\n\treturn createHash(\"sha256\").update(text).digest(\"hex\");\n}\n\nfunction imports(describes: readonly CodegenDescribe[], importSource: string): string {\n\tconst used: string[] = [];\n\tconst fields = describes.flatMap((describe) => describe.fields);\n\tif (fields.some((field) => field.type === \"address\")) {\n\t\tused.push(ADDRESS_TYPE);\n\t}\n\tif (fields.some((field) => field.type === \"location\")) {\n\t\tused.push(GEOLOCATION_TYPE);\n\t}\n\treturn used.length > 0 ? `import type { ${used.join(\", \")} } from ${JSON.stringify(importSource)};` : \"\";\n}\n\nfunction sortedFields(describe: CodegenDescribe): CodegenField[] {\n\treturn [...describe.fields].sort((a, b) => (a.name === \"Id\" ? -1 : b.name === \"Id\" ? 1 : compare(a.name, b.name)));\n}\n\nfunction readInterface(describe: CodegenDescribe, picklists: PicklistMode): string {\n\tconst lines = sortedFields(describe).map((field) => {\n\t\tconst comment = `\\t/** ${escapeComment(field.label)} (${escapeComment(field.type)}) */`;\n\t\treturn `${comment}\\n\\t${propertyKey(field.name)}: ${mapFieldType(field, picklists)};`;\n\t});\n\tconst doc = describe.label ? `/** ${escapeComment(describe.label)} */\\n` : \"\";\n\treturn `${doc}export interface ${describe.name} {\\n${lines.join(\"\\n\")}\\n}`;\n}\n\n/**\n * Create input: required fields are `createable && !nillable && !defaultedOnCreate`; other\n * createable fields are optional. Validation rules and record types can add more requirements\n * at runtime. Update input: every updateable field is optional.\n */\nfunction inputType(\n\tdescribe: CodegenDescribe,\n\tsuffix: \"CreateInput\" | \"UpdateInput\",\n\tflag: \"createable\" | \"updateable\",\n\texcluded: readonly string[],\n): string {\n\tconst typeName = `${describe.name}${suffix}`;\n\tconst excludedNames = new Set(excluded.map((name) => name.toLowerCase()));\n\tconst allowed = sortedFields(describe).filter((field) => field[flag] && !excludedNames.has(field.name.toLowerCase()));\n\tif (allowed.length === 0) {\n\t\treturn `export type ${typeName} = Record<string, never>;`;\n\t}\n\tconst required =\n\t\tsuffix === \"CreateInput\"\n\t\t\t? allowed.filter((field) => !field.nillable && !field.defaultedOnCreate).map((field) => field.name)\n\t\t\t: [];\n\tconst optional = allowed.map((field) => field.name).filter((name) => !required.includes(name));\n\tconst parts: string[] = [];\n\tif (required.length > 0) {\n\t\tparts.push(`Pick<${describe.name}, ${keyUnion(required)}>`);\n\t}\n\tif (optional.length > 0) {\n\t\tparts.push(`Partial<Pick<${describe.name}, ${keyUnion(optional)}>>`);\n\t}\n\treturn `export type ${typeName} = ${parts.join(\" & \")};`;\n}\n\nfunction registry(describes: readonly CodegenDescribe[], names: ReadonlySet<string>): string {\n\tconst entries = describes.map((describe) => registryEntry(describe, names));\n\treturn [\n\t\t\"/**\",\n\t\t\" * Maps every generated sObject to its read, create and update types and its relationships.\",\n\t\t\" * Pass it to the client: `new SalesforceClient<SObjectRegistry>({ ... })`.\",\n\t\t\" */\",\n\t\t\"export interface SObjectRegistry {\",\n\t\t...entries,\n\t\t\"}\",\n\t].join(\"\\n\");\n}\n\nfunction registryEntry(describe: CodegenDescribe, names: ReadonlySet<string>): string {\n\tconst parents = describe.fields\n\t\t.filter(\n\t\t\t(field) =>\n\t\t\t\tfield.relationshipName &&\n\t\t\t\tfield.referenceTo.length === 1 &&\n\t\t\t\tnames.has(field.referenceTo[0]) &&\n\t\t\t\tIDENTIFIER.test(field.relationshipName),\n\t\t)\n\t\t.map((field) => [field.relationshipName as string, field.referenceTo[0]] as const);\n\tconst children = describe.childRelationships\n\t\t.filter(\n\t\t\t(relationship) =>\n\t\t\t\trelationship.relationshipName &&\n\t\t\t\tnames.has(relationship.childSObject) &&\n\t\t\t\tIDENTIFIER.test(relationship.relationshipName),\n\t\t)\n\t\t.map((relationship) => [relationship.relationshipName as string, relationship.childSObject] as const);\n\treturn [\n\t\t`\\t${describe.name}: {`,\n\t\t`\\t\\tread: ${describe.name};`,\n\t\t`\\t\\tcreate: ${describe.name}CreateInput;`,\n\t\t`\\t\\tupdate: ${describe.name}UpdateInput;`,\n\t\t`\\t\\tparents: ${relationshipMap(parents)};`,\n\t\t`\\t\\tchildren: ${relationshipMap(children)};`,\n\t\t`\\t\\texternalIds: ${unionOrNever(externalIdFields(describe))};`,\n\t\t`\\t\\tfieldKinds: ${fieldKindMap(describe)};`,\n\t\t`\\t\\trecordTypes: ${unionOrNever(recordTypeNames(describe))};`,\n\t\t`\\t\\tpolymorphicParents: ${polymorphicMap(describe)};`,\n\t\t\"\\t};\",\n\t].join(\"\\n\");\n}\n\n/** `Id` plus every field marked `externalId` or `idLookup`: the fields upsert accepts. */\nfunction externalIdFields(describe: CodegenDescribe): string[] {\n\tconst names = describe.fields\n\t\t.filter((field) => field.name === \"Id\" || field.externalId === true || field.idLookup === true)\n\t\t.map((field) => field.name);\n\treturn [...new Set(names)].sort(compare);\n}\n\nfunction recordTypeNames(describe: CodegenDescribe): string[] {\n\tconst names = (describe.recordTypeInfos ?? []).map((info) => info.developerName);\n\treturn [...new Set(names.filter((name) => typeof name === \"string\" && name.length > 0))].sort(compare);\n}\n\nfunction fieldKindMap(describe: CodegenDescribe): string {\n\tconst lines = sortedFields(describe)\n\t\t.filter((field) => FIELD_KINDS.has(field.type))\n\t\t.map((field) => `\\t\\t\\t${propertyKey(field.name)}: ${JSON.stringify(field.type)};`);\n\treturn lines.length > 0 ? `{\\n${lines.join(\"\\n\")}\\n\\t\\t}` : \"Record<never, never>\";\n}\n\n/** Lookups with more than one target (e.g. `Owner` -> User or Group); `parents` leaves these out. */\nfunction polymorphicMap(describe: CodegenDescribe): string {\n\tconst entries = new Map<string, string>();\n\tfor (const field of sortedFields(describe)) {\n\t\tconst name = field.relationshipName;\n\t\tif (name && field.referenceTo.length > 1 && IDENTIFIER.test(name) && !entries.has(name)) {\n\t\t\tentries.set(name, unionOrNever([...field.referenceTo].sort(compare)));\n\t\t}\n\t}\n\tconst lines = [...entries.entries()]\n\t\t.sort(([a], [b]) => compare(a, b))\n\t\t.map(([name, targets]) => `\\t\\t\\t${name}: ${targets};`);\n\treturn lines.length > 0 ? `{\\n${lines.join(\"\\n\")}\\n\\t\\t}` : \"Record<never, never>\";\n}\n\n/** `PICKLIST_VALUES`: the active values of every picklist and multi-select picklist field. */\nfunction picklistConstants(describes: readonly CodegenDescribe[]): string {\n\tconst entries = describes.map(picklistEntry).filter((entry) => entry.length > 0);\n\treturn [\n\t\t\"/** Active picklist values per sObject and field, e.g. to loop over every status in a test. */\",\n\t\t`export const PICKLIST_VALUES = {${entries.length > 0 ? `\\n${entries.join(\"\\n\")}\\n` : \"\"}} as const;`,\n\t].join(\"\\n\");\n}\n\n/** One sObject's entry in `PICKLIST_VALUES`, or `\"\"` when it has no picklists. */\nfunction picklistEntry(describe: CodegenDescribe): string {\n\tconst fields = sortedFields(describe)\n\t\t.map((field) => [field.name, activePicklistValues(field)] as const)\n\t\t.filter(([, values]) => values.length > 0)\n\t\t.map(([name, values]) => `\\t\\t${propertyKey(name)}: [${values.map((value) => JSON.stringify(value)).join(\", \")}],`);\n\treturn fields.length > 0 ? `\\t${describe.name}: {\\n${fields.join(\"\\n\")}\\n\\t},` : \"\";\n}\n\n/** `RECORD_TYPES`: the record type DeveloperNames per sObject. */\nfunction recordTypeConstants(describes: readonly CodegenDescribe[]): string {\n\tconst entries = describes\n\t\t.map((describe) => [describe.name, recordTypeNames(describe)] as const)\n\t\t.filter(([, names]) => names.length > 0)\n\t\t.map(([name, names]) => `\\t${name}: [${names.map((value) => JSON.stringify(value)).join(\", \")}],`);\n\treturn [\n\t\t\"/** Record type DeveloperNames per sObject. Resolve ids with `sf.sobject(name).recordTypeId(developerName)`. */\",\n\t\t`export const RECORD_TYPES = {${entries.length > 0 ? `\\n${entries.join(\"\\n\")}\\n` : \"\"}} as const;`,\n\t].join(\"\\n\");\n}\n\nfunction activePicklistValues(field: CodegenField): string[] {\n\tif (field.type !== \"picklist\" && field.type !== \"multipicklist\" && field.type !== \"combobox\") {\n\t\treturn [];\n\t}\n\treturn [...new Set((field.picklistValues ?? []).filter((entry) => entry.active).map((entry) => entry.value))];\n}\n\nfunction unionOrNever(values: readonly string[]): string {\n\treturn values.length > 0 ? values.map((value) => JSON.stringify(value)).join(\" | \") : \"never\";\n}\n\nfunction apiVersionConstant(apiVersion: ApiVersion): string {\n\tif (!/^v\\d+\\.\\d+$/.test(apiVersion)) {\n\t\tthrow new Error(`Invalid apiVersion \"${apiVersion}\".`);\n\t}\n\treturn [\n\t\t\"/**\",\n\t\t\" * The API version these types were generated with. Pass it to the client so requests use the\",\n\t\t\" * same version: `new SalesforceClient<SObjectRegistry>({ apiVersion: API_VERSION, ... })`.\",\n\t\t\" */\",\n\t\t`export const API_VERSION = ${JSON.stringify(apiVersion)};`,\n\t].join(\"\\n\");\n}\n\nfunction relationshipMap(entries: readonly (readonly [string, string])[]): string {\n\tconst unique = new Map<string, string>();\n\tfor (const [name, target] of entries) {\n\t\tif (!unique.has(name)) {\n\t\t\tunique.set(name, target);\n\t\t}\n\t}\n\tif (unique.size === 0) {\n\t\treturn \"Record<never, never>\";\n\t}\n\tconst lines = [...unique.entries()]\n\t\t.sort(([a], [b]) => compare(a, b))\n\t\t.map(([name, target]) => `\\t\\t\\t${name}: ${JSON.stringify(target)};`);\n\treturn `{\\n${lines.join(\"\\n\")}\\n\\t\\t}`;\n}\n\nfunction keyUnion(names: readonly string[]): string {\n\treturn names.map((name) => JSON.stringify(name)).join(\" | \");\n}\n\nfunction propertyKey(name: string): string {\n\treturn IDENTIFIER.test(name) ? name : JSON.stringify(name);\n}\n\nfunction escapeComment(value: string | null | undefined): string {\n\treturn String(value ?? \"\")\n\t\t.replace(/\\*\\//g, \"*\\\\/\")\n\t\t.replace(/\\r?\\n/g, \" \");\n}\n\nfunction compare(a: string, b: string): number {\n\treturn a < b ? -1 : a > b ? 1 : 0;\n}\n","import { isApiVersion } from \"../api-version\";\n\nimport type { CodegenConfig, EnvAuth } from \"./config\";\n\n/** Thrown when a codegen config is invalid. Lists every problem found. */\nexport class CodegenConfigError extends Error {\n\toverride readonly name: string = \"CodegenConfigError\";\n\n\tconstructor(\n\t\treadonly source: string,\n\t\treadonly problems: string[],\n\t) {\n\t\tsuper(`Invalid sobjectly config (${source}):\\n${problems.map((problem) => ` - ${problem}`).join(\"\\n\")}`);\n\t}\n}\n\n/** The env-variable options each env-based auth type accepts. */\nexport const AUTH_OPTIONS: Record<EnvAuth[\"type\"], readonly string[]> = {\n\tclientCredentials: [\"loginUrlEnv\", \"clientIdEnv\", \"clientSecretEnv\"],\n\taccessToken: [\"accessTokenEnv\", \"instanceUrlEnv\"],\n\tjwtBearer: [\"loginUrlEnv\", \"clientIdEnv\", \"usernameEnv\", \"privateKeyEnv\", \"privateKeyPathEnv\"],\n\tsfCli: [\"targetOrg\"],\n};\n\nexport const PICKLIST_MODES = [\"union\", \"string\"] as const;\n\nconst IDENTIFIER = /^[A-Za-z][A-Za-z0-9_]*$/;\n\ninterface Context {\n\tconfig: Record<string, unknown>;\n\tjson: boolean;\n\tproblem: (message: string) => void;\n}\n\ntype Validator = (value: unknown, context: Context) => void;\n\nconst VALIDATORS: Record<string, Validator> = {\n\t$schema: (value, { problem }) => {\n\t\tif (typeof value !== \"string\") {\n\t\t\tproblem(\"$schema: must be a string.\");\n\t\t}\n\t},\n\toutput: (value, { problem }) => {\n\t\tif (value === undefined) {\n\t\t\tproblem('output: required, e.g. \"src/generated/sobjects.ts\".');\n\t\t} else if (typeof value !== \"string\" || !/\\.(ts|mts|cts)$/.test(value)) {\n\t\t\tproblem(`output: must be a TypeScript file path such as \"src/generated/sobjects.ts\", got ${show(value)}.`);\n\t\t}\n\t},\n\tapiVersion: (value, { problem }) => {\n\t\tif (value === undefined || value === \"\") {\n\t\t\tproblem('apiVersion: required, e.g. \"v66.0\".');\n\t\t} else if (!isApiVersion(value)) {\n\t\t\tproblem(`apiVersion: must look like \"v66.0\", got ${show(value)}.`);\n\t\t}\n\t},\n\tsobjects: (value, { problem }) => validateNames(\"sobjects\", value, problem),\n\texclude: (value, { problem }) => validateNames(\"exclude\", value, problem),\n\tauth: validateAuth,\n\texcludeCreateFields: (value, context) => validateFieldMap(\"excludeCreateFields\", value, context),\n\texcludeUpdateFields: (value, context) => validateFieldMap(\"excludeUpdateFields\", value, context),\n\tpicklists: (value, { problem }) => {\n\t\tif (!PICKLIST_MODES.includes(value as (typeof PICKLIST_MODES)[number])) {\n\t\t\tproblem(`picklists: must be \"union\" or \"string\", got ${show(value)}.`);\n\t\t}\n\t},\n\tconstants: (value, { problem }) => {\n\t\tif (typeof value !== \"boolean\") {\n\t\t\tproblem(`constants: must be true or false, got ${show(value)}.`);\n\t\t}\n\t},\n\tconcurrency: (value, { problem }) => {\n\t\tif (!Number.isInteger(value) || (value as number) < 1) {\n\t\t\tproblem(`concurrency: must be a positive integer, got ${show(value)}.`);\n\t\t}\n\t},\n\tcontinueOnDescribeError: (value, { problem }) => {\n\t\tif (typeof value !== \"boolean\") {\n\t\t\tproblem(`continueOnDescribeError: must be true or false, got ${show(value)}.`);\n\t\t}\n\t},\n\timportSource: (value, { problem }) => {\n\t\tif (typeof value !== \"string\" || value.length === 0) {\n\t\t\tproblem(`importSource: must be a non-empty string, got ${show(value)}.`);\n\t\t}\n\t},\n\tformat: (value, { problem, json }) => {\n\t\tif (json) {\n\t\t\tproblem(\"format: only supported in a TypeScript config.\");\n\t\t} else if (typeof value !== \"function\") {\n\t\t\tproblem(\"format: must be a function (source, filePath) => string.\");\n\t\t}\n\t},\n\ttransport: (value, { problem, json }) => {\n\t\tif (json) {\n\t\t\tproblem(\"transport: only supported in a TypeScript config.\");\n\t\t} else if (typeof (value as { send?: unknown } | null)?.send !== \"function\") {\n\t\t\tproblem(\"transport: must be an HttpTransport (an object with a send() method).\");\n\t\t}\n\t},\n};\n\n/** The options a config may contain. */\nexport const CONFIG_OPTIONS: readonly string[] = Object.keys(VALIDATORS).filter((key) => key !== \"$schema\");\n\n/**\n * Checks a loaded config and returns it typed. Throws a `CodegenConfigError` listing every\n * problem. `json` disallows the options that only a TypeScript config can express.\n */\nexport function validateConfig(value: unknown, options: { source: string; json?: boolean }): CodegenConfig {\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n\t\tthrow new CodegenConfigError(options.source, [\n\t\t\t\"the config must be an object (export default defineConfig({ ... }) or a JSON object).\",\n\t\t]);\n\t}\n\tconst problems: string[] = [];\n\tconst context: Context = {\n\t\tconfig: value as Record<string, unknown>,\n\t\tjson: options.json ?? false,\n\t\tproblem: (message) => problems.push(message),\n\t};\n\tfor (const required of [\"apiVersion\", \"output\"]) {\n\t\tif (!(required in value)) {\n\t\t\tVALIDATORS[required]?.(undefined, context);\n\t\t}\n\t}\n\tfor (const [key, option] of Object.entries(value)) {\n\t\tconst validate = VALIDATORS[key];\n\t\tif (!validate) {\n\t\t\tproblems.push(`${key}: unknown option. Valid options: ${CONFIG_OPTIONS.join(\", \")}.`);\n\t\t} else if (option !== undefined || key === \"apiVersion\" || key === \"output\") {\n\t\t\tvalidate(option, context);\n\t\t}\n\t}\n\tif (problems.length > 0) {\n\t\tif (problems.some((problem) => problem.startsWith(\"apiVersion\") || problem.startsWith(\"output\"))) {\n\t\t\tproblems.push('Run \"npx sobjectly init\" to create a valid config.');\n\t\t}\n\t\tthrow new CodegenConfigError(options.source, problems);\n\t}\n\tconst { $schema: _schema, ...config } = value as Record<string, unknown>;\n\treturn config as unknown as CodegenConfig;\n}\n\nfunction validateNames(key: string, value: unknown, problem: (message: string) => void): void {\n\tif (!Array.isArray(value)) {\n\t\tproblem(`${key}: must be an array of sObject API names, got ${show(value)}.`);\n\t\treturn;\n\t}\n\tif (key === \"sobjects\" && value.length === 0) {\n\t\tproblem(\"sobjects: list at least one sObject, or leave it out to generate every queryable sObject.\");\n\t}\n\tvalue.forEach((name, index) => {\n\t\tif (typeof name !== \"string\" || !IDENTIFIER.test(name)) {\n\t\t\tproblem(`${key}[${index}]: ${show(name)} is not a valid sObject API name.`);\n\t\t}\n\t});\n}\n\nfunction validateFieldMap(key: string, value: unknown, { config, problem }: Context): void {\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n\t\tproblem(`${key}: must be an object like { \"Account\": [\"FieldName\"] }, got ${show(value)}.`);\n\t\treturn;\n\t}\n\t// sObject names are case-insensitive; the generator looks these keys up the same way.\n\tconst listed = Array.isArray(config.sobjects)\n\t\t? new Set((config.sobjects as unknown[]).map((name) => (typeof name === \"string\" ? name.toLowerCase() : name)))\n\t\t: undefined;\n\tfor (const [sobject, fields] of Object.entries(value)) {\n\t\tif (listed && !listed.has(sobject.toLowerCase())) {\n\t\t\tproblem(`${key}.${sobject}: \"${sobject}\" is not listed in sobjects.`);\n\t\t}\n\t\tif (!Array.isArray(fields) || fields.some((field) => typeof field !== \"string\" || field.length === 0)) {\n\t\t\tproblem(`${key}.${sobject}: must be an array of field API names, got ${show(fields)}.`);\n\t\t}\n\t}\n}\n\nfunction validateAuth(value: unknown, { json, problem }: Context): void {\n\tif (typeof value !== \"object\" || value === null) {\n\t\tproblem(`auth: must be an object like { \"type\": \"clientCredentials\" }, got ${show(value)}.`);\n\t\treturn;\n\t}\n\tif (typeof (value as { getToken?: unknown }).getToken === \"function\") {\n\t\tif (json) {\n\t\t\tproblem(\"auth: auth providers are only supported in a TypeScript config.\");\n\t\t}\n\t\treturn;\n\t}\n\tconst { type, ...rest } = value as Record<string, unknown>;\n\tconst allowed = AUTH_OPTIONS[type as EnvAuth[\"type\"]] as readonly string[] | undefined;\n\tif (!allowed) {\n\t\tproblem(`auth.type: must be one of ${Object.keys(AUTH_OPTIONS).join(\", \")}, got ${show(type)}.`);\n\t\treturn;\n\t}\n\tfor (const [key, option] of Object.entries(rest)) {\n\t\tif (!allowed.includes(key)) {\n\t\t\tproblem(`auth.${key}: not an option of \"${String(type)}\". Valid options: ${allowed.join(\", \")}.`);\n\t\t} else if (typeof option !== \"string\" || option.length === 0) {\n\t\t\tproblem(`auth.${key}: must be a non-empty string, got ${show(option)}.`);\n\t\t}\n\t}\n}\n\nfunction show(value: unknown): string {\n\tif (value === undefined) {\n\t\treturn \"undefined\";\n\t}\n\tif (typeof value === \"function\") {\n\t\treturn \"a function\";\n\t}\n\ttry {\n\t\treturn JSON.stringify(value) ?? typeof value;\n\t} catch {\n\t\treturn typeof value;\n\t}\n}\n","import type { AuthProvider } from \"../auth/types\";\nimport type { HttpTransport } from \"../http/transport\";\nimport type { ApiVersion } from \"../types/common\";\n\n/** Client credentials read from environment variables (defaults shown). */\nexport interface EnvClientCredentialsAuth {\n\ttype: \"clientCredentials\";\n\t/** Defaults to `SF_LOGIN_URL` (your My Domain URL). */\n\tloginUrlEnv?: string;\n\t/** Defaults to `SF_CLIENT_ID`. */\n\tclientIdEnv?: string;\n\t/** Defaults to `SF_CLIENT_SECRET`. */\n\tclientSecretEnv?: string;\n}\n\n/** An access token read from environment variables (defaults shown), e.g. from `sf org display`. */\nexport interface EnvAccessTokenAuth {\n\ttype: \"accessToken\";\n\t/** Defaults to `SF_ACCESS_TOKEN`. */\n\taccessTokenEnv?: string;\n\t/** Defaults to `SF_INSTANCE_URL`. */\n\tinstanceUrlEnv?: string;\n}\n\n/** JWT bearer flow with values read from environment variables (defaults shown). */\nexport interface EnvJwtBearerAuth {\n\ttype: \"jwtBearer\";\n\t/** Defaults to `SF_LOGIN_URL`. */\n\tloginUrlEnv?: string;\n\t/** Defaults to `SF_CLIENT_ID`. */\n\tclientIdEnv?: string;\n\t/** Defaults to `SF_USERNAME`. */\n\tusernameEnv?: string;\n\t/** The PEM key itself. Defaults to `SF_PRIVATE_KEY`. */\n\tprivateKeyEnv?: string;\n\t/** A path to the PEM key file, used when the key variable is empty. Defaults to `SF_PRIVATE_KEY_PATH`. */\n\tprivateKeyPathEnv?: string;\n}\n\n/** An auth setting that reads credentials from environment variables. The only kind a JSON config can use. */\n/** An org you are logged into with the Salesforce CLI (`sf org login web --alias my-org`). */\nexport interface SfCliAuth {\n\ttype: \"sfCli\";\n\t/** The org alias or username. Defaults to the CLI's default org. */\n\ttargetOrg?: string;\n}\n\nexport type EnvAuth = EnvClientCredentialsAuth | EnvAccessTokenAuth | EnvJwtBearerAuth | SfCliAuth;\n\n/** Env-based auth, or any auth provider (TypeScript configs only). */\nexport type CodegenAuth = EnvAuth | AuthProvider;\n\nexport type PicklistMode =\n\t/** Every picklist is `string`. */\n\t| \"string\"\n\t/** Restricted picklists become a union of their values; unrestricted ones `\"A\" | \"B\" | (string & {})`. */\n\t| \"union\";\n\n/**\n * The codegen config. `S` is the union of the listed sObject names; `defineConfig` infers it, so\n * per-sObject options such as `excludeCreateFields` only accept listed names.\n */\nexport interface CodegenConfig<S extends string = string> {\n\t/** Output file, relative to the config file's directory, e.g. `\"src/generated/sobjects.ts\"`. */\n\toutput: string;\n\t/**\n\t * The API version to describe with, e.g. `\"v66.0\"`. Required. It is also written to the\n\t * generated file as `API_VERSION`, so the client can use the same version.\n\t */\n\tapiVersion: ApiVersion;\n\t/**\n\t * sObjects to generate. Strongly recommended: without it every queryable sObject in the org\n\t * is generated, which can be thousands of types.\n\t */\n\tsobjects?: readonly S[];\n\t/** sObjects to skip (applied after `sobjects`). */\n\texclude?: readonly string[];\n\t/** How to authenticate. Defaults to client credentials from `SF_LOGIN_URL`, `SF_CLIENT_ID` and `SF_CLIENT_SECRET`. */\n\tauth?: CodegenAuth;\n\t/** Fields to leave out of the create input per sObject (e.g. fields describe marks createable but REST rejects). */\n\texcludeCreateFields?: Partial<Record<NoInfer<S>, readonly string[]>>;\n\t/** Fields to leave out of the update input per sObject. */\n\texcludeUpdateFields?: Partial<Record<NoInfer<S>, readonly string[]>>;\n\t/** How picklists are typed. Defaults to `\"union\"`. */\n\tpicklists?: PicklistMode;\n\t/** Emit the `PICKLIST_VALUES` and `RECORD_TYPES` runtime constants. Defaults to `true`. */\n\tconstants?: boolean;\n\t/** Parallel describe calls. Defaults to 10. */\n\tconcurrency?: number;\n\t/** Skip sObjects whose describe fails instead of failing the run. Defaults to `false`. */\n\tcontinueOnDescribeError?: boolean;\n\t/** Where the generated file imports helper types from. Defaults to `\"@cerios/salesforce-sobjectly\"`. */\n\timportSource?: string;\n\t/** Post-processes the generated source, e.g. with your formatter. TypeScript configs only. */\n\tformat?: (source: string, filePath: string) => string | Promise<string>;\n\t/** A custom transport for the describe calls (e.g. behind a proxy). TypeScript configs only. */\n\ttransport?: HttpTransport;\n}\n\n/**\n * The shape of `sobjectly.config.json`: everything that can be written as JSON (no functions,\n * no auth providers). `$schema` points editors at the bundled JSON Schema.\n */\nexport type JsonCodegenConfig = Omit<CodegenConfig, \"auth\" | \"format\" | \"transport\"> & {\n\t$schema?: string;\n\tauth?: EnvAuth;\n};\n\n/**\n * Type-checks a `sobjectly.config.ts`. The listed `sobjects` become a literal union, so a typo in\n * a per-sObject option is a compile error:\n *\n * ```ts\n * export default defineConfig({\n * \tapiVersion: \"v66.0\",\n * \toutput: \"src/generated/sobjects.ts\",\n * \tsobjects: [\"Account\", \"Contact\"],\n * \texcludeCreateFields: { Acount: [\"Name\"] }, // ❌ \"Acount\" is not in sobjects\n * });\n * ```\n */\nexport function defineConfig<const S extends string = string>(config: CodegenConfig<S>): CodegenConfig<S> {\n\treturn config;\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { dirname, extname, join, resolve } from \"node:path\";\n\nimport { createJiti } from \"jiti\";\n\nimport type { CodegenConfig } from \"./config\";\nimport { CodegenConfigError, validateConfig } from \"./validate-config\";\n\n/** Config file names, in lookup order. */\nexport const CONFIG_FILE_NAMES = [\n\t\"sobjectly.config.ts\",\n\t\"sobjectly.config.mts\",\n\t\"sobjectly.config.cts\",\n\t\"sobjectly.config.json\",\n];\n\nconst TYPESCRIPT_EXTENSIONS = new Set([\".ts\", \".mts\", \".cts\"]);\n\n/** Looks for a `sobjectly.config.{ts,mts,cts,json}` file in `cwd`; the first match in lookup order wins. */\nexport function findConfigFile(cwd: string = process.cwd()): string | undefined {\n\treturn findConfigFiles(cwd)[0];\n}\n\n/** Every `sobjectly.config.*` file in `cwd`, in lookup order. */\nexport function findConfigFiles(cwd: string = process.cwd()): string[] {\n\treturn CONFIG_FILE_NAMES.map((name) => join(cwd, name)).filter((path) => existsSync(path));\n}\n\n/**\n * Loads and validates a TypeScript (`.ts`, `.mts`, `.cts`) or JSON config file. Returns the\n * config and the directory it lives in. Throws a `CodegenConfigError` listing every problem.\n */\nexport async function loadConfig(configPath: string): Promise<{ config: CodegenConfig; directory: string }> {\n\tconst absolutePath = resolve(configPath);\n\tif (!existsSync(absolutePath)) {\n\t\tthrow new Error(`Config file not found: ${absolutePath}`);\n\t}\n\tconst extension = extname(absolutePath).toLowerCase();\n\tconst directory = dirname(absolutePath);\n\tif (extension === \".json\") {\n\t\treturn { config: validateConfig(readJson(absolutePath), { source: absolutePath, json: true }), directory };\n\t}\n\tif (!TYPESCRIPT_EXTENSIONS.has(extension)) {\n\t\tthrow new Error(`Unsupported config file \"${absolutePath}\". Use sobjectly.config.ts or sobjectly.config.json.`);\n\t}\n\tconst jiti = createJiti(join(directory, \"_sobjectly_loader.js\"), { interopDefault: true });\n\tconst loaded = await jiti.import<unknown>(absolutePath, { default: true });\n\treturn { config: validateConfig(loaded, { source: absolutePath }), directory };\n}\n\nfunction readJson(path: string): unknown {\n\ttry {\n\t\treturn JSON.parse(readFileSync(path, \"utf8\")) as unknown;\n\t} catch (error) {\n\t\tthrow new CodegenConfigError(path, [`not valid JSON: ${error instanceof Error ? error.message : String(error)}`]);\n\t}\n}\n","import { existsSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { join, relative } from \"node:path\";\n\nimport { normalizeApiVersion } from \"../api-version\";\nimport type { ApiVersion } from \"../types/common\";\n\nimport type { PicklistMode } from \"./config\";\nimport { findConfigFiles } from \"./load-config\";\nimport type { Choice, Prompter } from \"./prompter\";\n\nexport type InitAuthType = \"clientCredentials\" | \"accessToken\" | \"jwtBearer\" | \"sfCli\";\nexport type InitConfigFormat = \"ts\" | \"json\";\n\nexport interface InitAnswers {\n\tapiVersion: ApiVersion;\n\toutput: string;\n\tsobjects: string[];\n\tauth: InitAuthType;\n\t/** The Salesforce CLI org alias, for `auth: \"sfCli\"`. Omitted means the CLI's default org. */\n\ttargetOrg?: string;\n\tpicklists: PicklistMode;\n\tformat: InitConfigFormat;\n}\n\nexport interface InitOptions {\n\tcwd: string;\n\tprompter: Prompter;\n\tlog: (message: string) => void;\n\t/** Answers given up front (e.g. CLI flags); those questions are skipped. */\n\tpreset?: Partial<InitAnswers>;\n\t/** Accept the suggested answer for every question not in `preset`. `apiVersion` must then be preset. */\n\tyes?: boolean;\n\t/** Overwrite an existing config without asking. */\n\tforce?: boolean;\n}\n\nexport interface InitResult {\n\t/** `undefined` when the user chose not to overwrite an existing config. */\n\tconfigPath: string | undefined;\n\tanswers?: InitAnswers;\n\tenvExampleUpdated?: boolean;\n\tscriptAdded?: boolean;\n}\n\nconst SOBJECT_NAME = /^[A-Za-z][A-Za-z0-9_]*$/;\nconst NPM_SCRIPT = \"sobjects:generate\";\n\n/** The environment variables each auth type reads by default. */\nexport const AUTH_ENV_VARS: Record<InitAuthType, string[]> = {\n\tclientCredentials: [\"SF_LOGIN_URL\", \"SF_CLIENT_ID\", \"SF_CLIENT_SECRET\"],\n\taccessToken: [\"SF_ACCESS_TOKEN\", \"SF_INSTANCE_URL\"],\n\tjwtBearer: [\"SF_LOGIN_URL\", \"SF_CLIENT_ID\", \"SF_USERNAME\", \"SF_PRIVATE_KEY_PATH\"],\n\tsfCli: [],\n};\n\nconst AUTH_CHOICES: Choice<InitAuthType>[] = [\n\t{ value: \"clientCredentials\", label: \"Client credentials (recommended for CI and test automation)\" },\n\t{ value: \"sfCli\", label: \"Salesforce CLI org (recommended for local development; no secrets needed)\" },\n\t{ value: \"accessToken\", label: \"Access token (e.g. from `sf org display`)\" },\n\t{ value: \"jwtBearer\", label: \"JWT bearer (certificate-based, runs as a user)\" },\n];\n\nconst PICKLIST_CHOICES: Choice<PicklistMode>[] = [\n\t{ value: \"union\", label: 'Union of values, e.g. \"New\" | \"Closed\" (type-safe)' },\n\t{ value: \"string\", label: \"Plain string\" },\n];\n\nconst FORMAT_CHOICES: Choice<InitConfigFormat>[] = [\n\t{ value: \"ts\", label: \"TypeScript (sobjectly.config.ts, type-checked with defineConfig)\" },\n\t{ value: \"json\", label: \"JSON (sobjectly.config.json, validated with a JSON Schema)\" },\n];\n\n/**\n * Creates a `sobjectly.config` file by asking for the API version, output path, sObjects, auth\n * method, picklist mode and file format. Optionally adds the auth variables to `.env.example`\n * and an npm script to `package.json`.\n */\nexport async function runInit(options: InitOptions): Promise<InitResult> {\n\tconst { cwd, prompter, log } = options;\n\tconst existing = findConfigFiles(cwd);\n\tif (existing.length > 0 && !options.force) {\n\t\tconst names = existing.map((path) => relative(cwd, path)).join(\" and \");\n\t\tconst overwrite = options.yes ? false : await prompter.confirm(`${names} already exists. Replace it?`, false);\n\t\tif (!overwrite) {\n\t\t\tlog(`Kept the existing ${names}.`);\n\t\t\treturn { configPath: undefined };\n\t\t}\n\t}\n\n\tvalidatePreset(options.preset ?? {});\n\tconst answers = await askQuestions(options);\n\tconst configPath = join(cwd, `sobjectly.config.${answers.format}`);\n\t// Only one config may exist, otherwise the lookup order would silently pick one.\n\tfor (const path of existing.filter((path) => path !== configPath)) {\n\t\trmSync(path);\n\t\tlog(`Removed ${relative(cwd, path)}`);\n\t}\n\twriteFileSync(configPath, renderConfig(answers), \"utf8\");\n\tlog(`\\nCreated ${relative(cwd, configPath)}`);\n\n\tconst envExampleUpdated = await maybeUpdateEnvExample(options, answers.auth);\n\tconst scriptAdded = await maybeAddScript(options);\n\tprintNextSteps(log, answers, scriptAdded, cwd);\n\treturn { configPath, answers, envExampleUpdated, scriptAdded };\n}\n\nasync function askQuestions(options: InitOptions): Promise<InitAnswers> {\n\tconst { prompter, preset = {}, yes } = options;\n\tconst apiVersion = preset.apiVersion ?? (await askApiVersion(prompter, yes));\n\tconst output =\n\t\tpreset.output ??\n\t\t(yes\n\t\t\t? \"src/generated/sobjects.ts\"\n\t\t\t: await prompter.ask(\"Where should the generated types be written?\", {\n\t\t\t\t\tdefaultValue: \"src/generated/sobjects.ts\",\n\t\t\t\t\tvalidate: validateOutput,\n\t\t\t\t}));\n\tconst sobjects = preset.sobjects ?? (await askSObjects(prompter, yes));\n\tconst auth =\n\t\tpreset.auth ??\n\t\t(yes\n\t\t\t? \"clientCredentials\"\n\t\t\t: await prompter.choose(\"How should the generator log in to Salesforce?\", AUTH_CHOICES, \"clientCredentials\"));\n\tconst targetOrg = auth === \"sfCli\" ? (preset.targetOrg ?? (await askTargetOrg(prompter, yes))) : undefined;\n\tconst picklists =\n\t\tpreset.picklists ??\n\t\t(yes ? \"union\" : await prompter.choose(\"How should picklist fields be typed?\", PICKLIST_CHOICES, \"union\"));\n\tconst format =\n\t\tpreset.format ?? (yes ? \"ts\" : await prompter.choose(\"Which config file format?\", FORMAT_CHOICES, \"ts\"));\n\treturn { apiVersion, output, sobjects, auth, ...(targetOrg ? { targetOrg } : {}), picklists, format };\n}\n\nasync function askTargetOrg(prompter: Prompter, yes: boolean | undefined): Promise<string | undefined> {\n\tif (yes) {\n\t\treturn undefined;\n\t}\n\tconst answer = await prompter.ask(\"Which Salesforce CLI org alias? Leave empty to use the CLI's default org\", {\n\t\tvalidate: (value) => (value === \"\" || /^[\\w.@+-]+$/.test(value) ? undefined : \"Enter an org alias or username.\"),\n\t});\n\treturn answer === \"\" ? undefined : answer;\n}\n\nasync function askApiVersion(prompter: Prompter, yes: boolean | undefined): Promise<ApiVersion> {\n\tif (yes) {\n\t\tthrow new Error(\"An API version is required: pass --api-version (e.g. --api-version v66.0).\");\n\t}\n\tconst answer = await prompter.ask(\n\t\t\"Which Salesforce API version should be used? (e.g. v66.0; your org lists them at https://<my-domain>.my.salesforce.com/services/data/)\",\n\t\t{ validate: (value) => (normalizeApiVersion(value) ? undefined : 'Enter a version like \"v66.0\" or \"66\".') },\n\t);\n\treturn normalizeApiVersion(answer) as ApiVersion;\n}\n\nasync function askSObjects(prompter: Prompter, yes: boolean | undefined): Promise<string[]> {\n\tconst defaultValue = \"Account, Contact\";\n\tconst answer = yes\n\t\t? defaultValue\n\t\t: await prompter.ask(\"Which sObjects do you want types for? Use comma-separated API names\", {\n\t\t\t\tdefaultValue,\n\t\t\t\tvalidate: validateSObjects,\n\t\t\t});\n\treturn parseSObjects(answer);\n}\n\n/** Splits a comma/space separated list of sObject names, removing duplicates. */\nexport function parseSObjects(answer: string): string[] {\n\treturn [...new Set(answer.split(/[\\s,]+/).filter((name) => name.length > 0))];\n}\n\nfunction validateSObjects(answer: string): string | undefined {\n\treturn validateSObjectNames(parseSObjects(answer));\n}\n\nfunction validateSObjectNames(names: readonly string[]): string | undefined {\n\tif (names.length === 0) {\n\t\treturn \"Enter at least one sObject, e.g. Account.\";\n\t}\n\tconst invalid = names.filter((name) => !SOBJECT_NAME.test(name));\n\treturn invalid.length > 0 ? `Not a valid sObject API name: ${invalid.join(\", \")}` : undefined;\n}\n\n/** Answers given as flags get the same checks as typed answers. */\nfunction validatePreset(preset: Partial<InitAnswers>): void {\n\tconst errors = [\n\t\t// Check the names as given: joining and re-splitting would let \"Bad Name\" pass as two names.\n\t\tpreset.sobjects === undefined ? undefined : validateSObjectNames(preset.sobjects),\n\t\tpreset.output === undefined ? undefined : validateOutput(preset.output),\n\t\tpreset.targetOrg === undefined || /^[\\w.@+-]+$/.test(preset.targetOrg)\n\t\t\t? undefined\n\t\t\t: `Invalid org alias \"${preset.targetOrg}\".`,\n\t].filter((error): error is string => error !== undefined);\n\tif (errors.length > 0) {\n\t\tthrow new Error(errors.join(\" \"));\n\t}\n}\n\nfunction validateOutput(answer: string): string | undefined {\n\treturn /\\.(ts|mts|cts)$/.test(answer)\n\t\t? undefined\n\t\t: \"The output must be a TypeScript file, e.g. src/generated/sobjects.ts.\";\n}\n\n/** The `$schema` reference written into `sobjectly.config.json`. */\nexport const JSON_SCHEMA_REFERENCE = \"./node_modules/@cerios/salesforce-sobjectly/sobjectly.config.schema.json\";\n\n/** Renders the config file in the chosen format. */\nexport function renderConfig(answers: InitAnswers): string {\n\treturn answers.format === \"json\" ? renderJsonConfig(answers) : renderTypeScriptConfig(answers);\n}\n\nfunction renderJsonConfig(answers: InitAnswers): string {\n\tconst config = {\n\t\t$schema: JSON_SCHEMA_REFERENCE,\n\t\tapiVersion: answers.apiVersion,\n\t\toutput: answers.output,\n\t\tsobjects: answers.sobjects,\n\t\tauth: authSetting(answers),\n\t\tpicklists: answers.picklists,\n\t};\n\treturn `${JSON.stringify(config, null, \"\\t\")}\\n`;\n}\n\nfunction renderTypeScriptConfig(answers: InitAnswers): string {\n\tconst envVars = AUTH_ENV_VARS[answers.auth];\n\tconst sobjects = answers.sobjects.map((name) => JSON.stringify(name)).join(\", \");\n\treturn [\n\t\t'import { defineConfig } from \"@cerios/salesforce-sobjectly/codegen\";',\n\t\t\"\",\n\t\t\"export default defineConfig({\",\n\t\t\"\\t// The Salesforce REST API version. The generated file exports it as API_VERSION for the client.\",\n\t\t`\\tapiVersion: ${JSON.stringify(answers.apiVersion)},`,\n\t\t\"\\t// Where the generated types are written, relative to this file.\",\n\t\t`\\toutput: ${JSON.stringify(answers.output)},`,\n\t\t\"\\t// The sObjects to generate types for.\",\n\t\t`\\tsobjects: [${sobjects}],`,\n\t\t`\\t// ${authComment(answers.auth, envVars)}`,\n\t\t`\\tauth: ${renderAuth(answers)},`,\n\t\t`\\tpicklists: ${JSON.stringify(answers.picklists)},`,\n\t\t\"});\",\n\t\t\"\",\n\t].join(\"\\n\");\n}\n\nfunction authSetting(answers: InitAnswers): { type: InitAuthType; targetOrg?: string } {\n\treturn answers.auth === \"sfCli\" && answers.targetOrg\n\t\t? { type: \"sfCli\", targetOrg: answers.targetOrg }\n\t\t: { type: answers.auth };\n}\n\nfunction renderAuth(answers: InitAnswers): string {\n\tconst setting = authSetting(answers);\n\tconst targetOrg = setting.targetOrg ? `, targetOrg: ${JSON.stringify(setting.targetOrg)}` : \"\";\n\treturn `{ type: ${JSON.stringify(setting.type)}${targetOrg} }`;\n}\n\nfunction authComment(auth: InitAuthType, envVars: readonly string[]): string {\n\treturn auth === \"sfCli\"\n\t\t? \"Uses an org you are logged into with the Salesforce CLI (sf org login web).\"\n\t\t: `Reads ${formatList(envVars)} from the environment.`;\n}\n\nasync function maybeUpdateEnvExample(options: InitOptions, auth: InitAuthType): Promise<boolean> {\n\tconst path = join(options.cwd, \".env.example\");\n\tconst content = existsSync(path) ? readFileSync(path, \"utf8\") : \"\";\n\tconst missing = AUTH_ENV_VARS[auth].filter((name) => !new RegExp(`^${name}=`, \"m\").test(content));\n\tif (missing.length === 0) {\n\t\treturn false;\n\t}\n\tconst add =\n\t\toptions.yes === true || (await options.prompter.confirm(`Add ${formatList(missing)} to .env.example?`, true));\n\tif (!add) {\n\t\treturn false;\n\t}\n\tconst block = [\"# Salesforce credentials for `sobjectly generate`\", ...missing.map((name) => `${name}=`)].join(\"\\n\");\n\tconst separator = content.length === 0 ? \"\" : content.endsWith(\"\\n\") ? \"\\n\" : \"\\n\\n\";\n\twriteFileSync(path, `${content}${separator}${block}\\n`, \"utf8\");\n\toptions.log(\"Updated .env.example\");\n\treturn true;\n}\n\nasync function maybeAddScript(options: InitOptions): Promise<boolean> {\n\tconst path = join(options.cwd, \"package.json\");\n\tif (!existsSync(path)) {\n\t\treturn false;\n\t}\n\tconst raw = readFileSync(path, \"utf8\");\n\tconst bom = raw.startsWith(\"\") ? \"\" : \"\";\n\tlet pkg: { scripts?: Record<string, string> };\n\ttry {\n\t\tpkg = JSON.parse(raw.slice(bom.length)) as { scripts?: Record<string, string> };\n\t} catch {\n\t\toptions.log(`Skipped adding the \"${NPM_SCRIPT}\" script: package.json is not valid JSON.`);\n\t\treturn false;\n\t}\n\tif (pkg.scripts?.[NPM_SCRIPT]) {\n\t\treturn false;\n\t}\n\tconst add = options.yes === true || (await options.prompter.confirm(`Add an npm script \"${NPM_SCRIPT}\"?`, true));\n\tif (!add) {\n\t\treturn false;\n\t}\n\tpkg.scripts = { ...pkg.scripts, [NPM_SCRIPT]: \"sobjectly generate\" };\n\tconst indent = /^[ \\t]+/m.exec(raw)?.[0] ?? \"\\t\";\n\tconst newline = raw.includes(\"\\r\\n\") ? \"\\r\\n\" : \"\\n\";\n\tconst json = JSON.stringify(pkg, null, indent).replace(/\\n/g, newline);\n\twriteFileSync(path, `${bom}${json}${newline}`, \"utf8\");\n\toptions.log(`Added the \"${NPM_SCRIPT}\" script to package.json`);\n\treturn true;\n}\n\nfunction printNextSteps(log: (message: string) => void, answers: InitAnswers, scriptAdded: boolean, cwd: string): void {\n\tconst cli = answers.auth === \"sfCli\";\n\tconst envFile = cli ? \"\" : \" --env-file .env\";\n\tconst command = scriptAdded\n\t\t? `npm run ${NPM_SCRIPT}${envFile ? ` --${envFile}` : \"\"}`\n\t\t: `npx sobjectly generate${envFile}`;\n\tconst gitignore = join(cwd, \".gitignore\");\n\tconst envIgnored = existsSync(gitignore) && /^\\.env\\b/m.test(readFileSync(gitignore, \"utf8\"));\n\tconst firstStep = cli\n\t\t? ` 1. Log in with the Salesforce CLI: sf org login web${answers.targetOrg ? ` --alias ${answers.targetOrg}` : \" --set-default\"}`\n\t\t: ` 1. Put ${formatList(AUTH_ENV_VARS[answers.auth])} in a .env file${envIgnored ? \"\" : \" (and add .env to .gitignore)\"}.`;\n\tlog(\n\t\t[\n\t\t\t\"\",\n\t\t\t\"Next steps:\",\n\t\t\tfirstStep,\n\t\t\t` 2. Generate the types: ${command}`,\n\t\t\t\" 3. Use them:\",\n\t\t\t` import { API_VERSION, type SObjectRegistry } from \"./${answers.output.replace(/\\.(ts|mts|cts)$/, \"\")}\";`,\n\t\t\t\" const sf = new SalesforceClient<SObjectRegistry>({ apiVersion: API_VERSION, auth });\",\n\t\t].join(\"\\n\"),\n\t);\n}\n\nfunction formatList(items: readonly string[]): string {\n\tif (items.length <= 1) {\n\t\treturn items.join(\"\");\n\t}\n\treturn `${items.slice(0, -1).join(\", \")} and ${items.at(-1)}`;\n}\n","import { createInterface } from \"node:readline\";\n\nexport interface Choice<T extends string> {\n\tvalue: T;\n\tlabel: string;\n}\n\n/** Asks questions. The CLI uses `readlinePrompter`; tests pass a scripted implementation. */\nexport interface Prompter {\n\t/** Asks for text. `validate` returns an error message to ask again, or `undefined` to accept. */\n\task(\n\t\tquestion: string,\n\t\toptions?: { defaultValue?: string; validate?: (answer: string) => string | undefined },\n\t): Promise<string>;\n\t/** Asks to pick one of `choices`, by number or value. */\n\tchoose<T extends string>(question: string, choices: readonly Choice<T>[], defaultValue: T): Promise<T>;\n\t/** Asks a yes/no question. */\n\tconfirm(question: string, defaultValue: boolean): Promise<boolean>;\n\tclose(): void;\n}\n\n/**\n * A prompter on stdin/stdout (or the given streams). Lines are queued as they arrive, so piped\n * input (`printf \"v66.0\\n...\" | sobjectly init`) works too. If the input ends before a question\n * is answered, the question rejects.\n */\nexport function readlinePrompter(\n\tinput: NodeJS.ReadableStream = process.stdin,\n\toutput: NodeJS.WritableStream = process.stdout,\n): Prompter {\n\tconst interactive = (input as { isTTY?: boolean }).isTTY === true;\n\tconst rl = createInterface({ input, output, terminal: interactive });\n\tconst lines: string[] = [];\n\tlet waiting: { resolve: (line: string) => void; reject: (error: Error) => void } | undefined;\n\tlet closed = false;\n\n\trl.on(\"line\", (line) => {\n\t\tif (waiting) {\n\t\t\tconst { resolve } = waiting;\n\t\t\twaiting = undefined;\n\t\t\tresolve(line);\n\t\t} else {\n\t\t\tlines.push(line);\n\t\t}\n\t});\n\trl.on(\"close\", () => {\n\t\tclosed = true;\n\t\twaiting?.reject(new Error(\"Input ended before all questions were answered.\"));\n\t\twaiting = undefined;\n\t});\n\n\tconst readLine = (prompt: string): Promise<string> => {\n\t\tif (closed) {\n\t\t\t// Piped input can end while answers are still queued; readline can't prompt after close.\n\t\t\toutput.write(prompt);\n\t\t} else {\n\t\t\trl.setPrompt(prompt);\n\t\t\trl.prompt();\n\t\t}\n\t\tconst queued = lines.shift();\n\t\tif (queued !== undefined) {\n\t\t\tif (!interactive) {\n\t\t\t\toutput.write(`${queued}\\n`);\n\t\t\t}\n\t\t\treturn Promise.resolve(queued);\n\t\t}\n\t\tif (closed) {\n\t\t\treturn Promise.reject(new Error(\"Input ended before all questions were answered.\"));\n\t\t}\n\t\treturn new Promise((resolve, reject) => {\n\t\t\twaiting = {\n\t\t\t\tresolve: (line: string): void => {\n\t\t\t\t\tif (!interactive) {\n\t\t\t\t\t\toutput.write(`${line}\\n`);\n\t\t\t\t\t}\n\t\t\t\t\tresolve(line);\n\t\t\t\t},\n\t\t\t\treject,\n\t\t\t};\n\t\t});\n\t};\n\n\tconst ask: Prompter[\"ask\"] = async (question, options = {}) => {\n\t\tconst suffix = options.defaultValue ? ` (${options.defaultValue})` : \"\";\n\t\tfor (;;) {\n\t\t\tconst raw = (await readLine(`? ${question}${suffix}: `)).trim();\n\t\t\tconst answer = raw === \"\" ? (options.defaultValue ?? \"\") : raw;\n\t\t\tconst error = options.validate?.(answer);\n\t\t\tif (error === undefined) {\n\t\t\t\treturn answer;\n\t\t\t}\n\t\t\toutput.write(` ${error}\\n`);\n\t\t}\n\t};\n\n\treturn {\n\t\task,\n\t\tasync choose(question, choices, defaultValue) {\n\t\t\toutput.write(`? ${question}\\n`);\n\t\t\tchoices.forEach((choice, index) => {\n\t\t\t\toutput.write(` ${index + 1}) ${choice.label}${choice.value === defaultValue ? \" (default)\" : \"\"}\\n`);\n\t\t\t});\n\t\t\tconst answer = await ask(\"Choose a number\", {\n\t\t\t\tdefaultValue: String(choices.findIndex((choice) => choice.value === defaultValue) + 1),\n\t\t\t\tvalidate: (value) => (pick(choices, value) ? undefined : `Enter a number from 1 to ${choices.length}.`),\n\t\t\t});\n\t\t\treturn (pick(choices, answer) ?? choices[0]).value;\n\t\t},\n\t\tasync confirm(question, defaultValue) {\n\t\t\tconst answer = await ask(`${question} ${defaultValue ? \"(Y/n)\" : \"(y/N)\"}`, {\n\t\t\t\tvalidate: (value) => (value === \"\" || /^(y|yes|n|no)$/i.test(value) ? undefined : \"Answer y or n.\"),\n\t\t\t});\n\t\t\treturn answer === \"\" ? defaultValue : /^y/i.test(answer);\n\t\t},\n\t\tclose() {\n\t\t\trl.close();\n\t\t},\n\t};\n}\n\nfunction pick<T extends string>(choices: readonly Choice<T>[], answer: string): Choice<T> | undefined {\n\tconst index = Number(answer);\n\tif (Number.isInteger(index) && index >= 1 && index <= choices.length) {\n\t\treturn choices[index - 1];\n\t}\n\treturn choices.find((choice) => choice.value.toLowerCase() === answer.toLowerCase());\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { mkdir, readFile, rename, rm, writeFile } from \"node:fs/promises\";\nimport { dirname, isAbsolute, resolve } from \"node:path\";\n\nimport { accessToken, clientCredentials, jwtBearer } from \"../auth/providers\";\nimport { sfCli } from \"../auth/sf-cli\";\nimport type { AuthProvider } from \"../auth/types\";\nimport { SalesforceClient } from \"../client\";\nimport type { ApiVersion } from \"../types/common\";\nimport type { DescribeSObjectResult } from \"../types/describe\";\n\nimport type { CodegenAuth, CodegenConfig, EnvJwtBearerAuth } from \"./config\";\nimport { type CodegenDescribe, type GeneratedFileHashes, generateSource, readGeneratedHashes } from \"./generator\";\nimport { validateConfig } from \"./validate-config\";\n\nexport { defineConfig } from \"./config\";\nexport type {\n\tCodegenAuth,\n\tCodegenConfig,\n\tEnvAuth,\n\tJsonCodegenConfig,\n\tEnvAccessTokenAuth,\n\tEnvClientCredentialsAuth,\n\tEnvJwtBearerAuth,\n\tPicklistMode,\n\tSfCliAuth,\n} from \"./config\";\nexport { generateSource, readGeneratedHashes } from \"./generator\";\nexport type { CodegenDescribe, GeneratedFileHashes, GenerateSourceOptions } from \"./generator\";\nexport { FIELD_TYPE_MAP, mapFieldType } from \"./type-mapper\";\nexport type { CodegenField } from \"./type-mapper\";\nexport { CONFIG_FILE_NAMES, findConfigFile, findConfigFiles, loadConfig } from \"./load-config\";\nexport { AUTH_OPTIONS, CONFIG_OPTIONS, CodegenConfigError, validateConfig } from \"./validate-config\";\nexport { AUTH_ENV_VARS, parseSObjects, renderConfig, runInit } from \"./init\";\nexport type { InitAnswers, InitAuthType, InitConfigFormat, InitOptions, InitResult } from \"./init\";\nexport { readlinePrompter } from \"./prompter\";\nexport type { Choice, Prompter } from \"./prompter\";\n\nexport interface CodegenLogger {\n\tinfo(message: string): void;\n\twarn(message: string): void;\n}\n\nexport interface GenerateOptions {\n\t/** Directory that `output` is resolved against. Defaults to `process.cwd()`. */\n\tcwd?: string;\n\tlogger?: CodegenLogger;\n\t/** Environment to read credentials from. Defaults to `process.env`. */\n\tenv?: Record<string, string | undefined>;\n\t/** Write the file. Defaults to `true`; with `false` the source is only returned. */\n\twrite?: boolean;\n}\n\nexport interface GenerateResult {\n\toutputPath: string;\n\t/** The concrete API version the types were generated with. */\n\tapiVersion: ApiVersion;\n\tsobjects: string[];\n\tskipped: { name: string; error: string }[];\n\t/** The generated source (after the `format` hook). */\n\tsource: string;\n\t/** SHA-256 of the unformatted content, as recorded in the file header. */\n\tcontentHash: string;\n}\n\nexport interface CheckResult {\n\t/** `true` when the file on disk has the same content (formatting differences are ignored). */\n\tupToDate: boolean;\n\t/** Why the file is out of date. */\n\treason?: \"missing\" | \"changed\";\n\toutputPath: string;\n\t/** sObjects that would be added, removed or changed (known when the file has hash headers). */\n\tadded: string[];\n\tremoved: string[];\n\tchanged: string[];\n}\n\nconst silentLogger: CodegenLogger = { info: () => undefined, warn: () => undefined };\n\n/** Describes the configured sObjects and writes the generated types to `config.output`. */\nexport async function generate(input: CodegenConfig, options: GenerateOptions = {}): Promise<GenerateResult> {\n\tconst logger = options.logger ?? silentLogger;\n\tconst built = await buildSource(input, options);\n\tconst { config } = built;\n\tlet source = built.raw;\n\tif (config.format) {\n\t\tsource = await config.format(source, built.outputPath);\n\t}\n\tif (options.write !== false) {\n\t\tawait writeAtomically(built.outputPath, source);\n\t\tlogger.info(`Wrote ${built.sobjects.length} sObject type(s) to ${built.outputPath}`);\n\t}\n\tconst { contentHash } = readGeneratedHashes(built.raw) as GeneratedFileHashes;\n\treturn {\n\t\toutputPath: built.outputPath,\n\t\tapiVersion: config.apiVersion,\n\t\tsobjects: built.sobjects,\n\t\tskipped: built.skipped,\n\t\tsource,\n\t\tcontentHash,\n\t};\n}\n\n/**\n * Checks whether the generated file on disk is up to date with the org, without writing it.\n * Only content counts: a file reformatted by Prettier, oxfmt or the `format` hook is up to date.\n */\nexport async function checkGenerated(input: CodegenConfig, options: GenerateOptions = {}): Promise<CheckResult> {\n\tconst built = await buildSource(input, options);\n\tconst empty = { outputPath: built.outputPath, added: [], removed: [], changed: [] };\n\tif (!existsSync(built.outputPath)) {\n\t\treturn { ...empty, upToDate: false, reason: \"missing\" };\n\t}\n\tconst existing = await readFile(built.outputPath, \"utf8\");\n\tconst expected = readGeneratedHashes(built.raw) as GeneratedFileHashes;\n\tconst actual = readGeneratedHashes(existing);\n\tif (!actual) {\n\t\t// Older files have no hash header: compare content, ignoring formatting.\n\t\tconst upToDate = normalizeSource(existing) === normalizeSource(built.raw);\n\t\treturn { ...empty, upToDate, reason: upToDate ? undefined : \"changed\" };\n\t}\n\tif (actual.contentHash === expected.contentHash) {\n\t\treturn { ...empty, upToDate: true };\n\t}\n\treturn { ...empty, upToDate: false, reason: \"changed\", ...diffObjects(actual.sobjects, expected.sobjects) };\n}\n\nasync function buildSource(\n\tinput: CodegenConfig,\n\toptions: GenerateOptions,\n): Promise<{\n\tconfig: CodegenConfig;\n\toutputPath: string;\n\traw: string;\n\tsobjects: string[];\n\tskipped: GenerateResult[\"skipped\"];\n}> {\n\tconst config = validateConfig(input, { source: \"generate()\" });\n\tconst { apiVersion } = config;\n\tconst logger = options.logger ?? silentLogger;\n\tconst env = options.env ?? process.env;\n\tconst outputPath = isAbsolute(config.output) ? config.output : resolve(options.cwd ?? process.cwd(), config.output);\n\n\tconst client = new SalesforceClient({\n\t\tauth: resolveAuth(config.auth, env),\n\t\tapiVersion,\n\t\ttransport: config.transport,\n\t\tretry: true,\n\t});\n\n\tconst names = await resolveSObjectNames(client, config, logger);\n\tlogger.info(`Describing ${names.length} sObject(s) with API ${apiVersion}...`);\n\tconst { describes, skipped } = await describeAll(client, names, config, logger);\n\n\tconst raw = generateSource(describes, {\n\t\texcludeCreateFields: config.excludeCreateFields,\n\t\texcludeUpdateFields: config.excludeUpdateFields,\n\t\tpicklists: config.picklists,\n\t\tconstants: config.constants,\n\t\timportSource: config.importSource,\n\t\tapiVersion,\n\t});\n\treturn { config, outputPath, raw, sobjects: describes.map((describe) => describe.name).sort(), skipped };\n}\n\nfunction diffObjects(\n\tactual: ReadonlyMap<string, string>,\n\texpected: ReadonlyMap<string, string>,\n): Pick<CheckResult, \"added\" | \"removed\" | \"changed\"> {\n\treturn {\n\t\tadded: [...expected.keys()].filter((name) => !actual.has(name)),\n\t\tremoved: [...actual.keys()].filter((name) => !expected.has(name)),\n\t\tchanged: [...expected.entries()]\n\t\t\t.filter(([name, hash]) => actual.has(name) && actual.get(name) !== hash)\n\t\t\t.map(([name]) => name),\n\t};\n}\n\n/** Strips comments, whitespace, quote style, semicolons and commas, so only content remains. */\nfunction normalizeSource(source: string): string {\n\tlet result = \"\";\n\tlet index = 0;\n\twhile (index < source.length) {\n\t\tconst char = source[index];\n\t\tconst next = source[index + 1];\n\t\tif (char === '\"' || char === \"'\") {\n\t\t\t// Keep the string's content exactly; only the quote style is normalised.\n\t\t\tlet end = index + 1;\n\t\t\twhile (end < source.length && source[end] !== char) {\n\t\t\t\tend += source[end] === \"\\\\\" ? 2 : 1;\n\t\t\t}\n\t\t\tresult += `\"${source\n\t\t\t\t.slice(index + 1, end)\n\t\t\t\t.replace(/\\\\'/g, \"'\")\n\t\t\t\t.replace(/\"/g, '\\\\\"')}\"`;\n\t\t\tindex = end + 1;\n\t\t} else if (char === \"/\" && next === \"/\") {\n\t\t\tindex = source.indexOf(\"\\n\", index) === -1 ? source.length : source.indexOf(\"\\n\", index);\n\t\t} else if (char === \"/\" && next === \"*\") {\n\t\t\tconst end = source.indexOf(\"*/\", index + 2);\n\t\t\tindex = end === -1 ? source.length : end + 2;\n\t\t} else {\n\t\t\tif (!/[\\s;,]/.test(char)) {\n\t\t\t\tresult += char;\n\t\t\t}\n\t\t\tindex++;\n\t\t}\n\t}\n\treturn result;\n}\n\n/** Turns the config's auth setting into an auth provider, reading env-based credentials. */\nexport function resolveAuth(auth: CodegenAuth | undefined, env: Record<string, string | undefined>): AuthProvider {\n\tconst setting = auth ?? { type: \"clientCredentials\" };\n\tif (\"getToken\" in setting) {\n\t\treturn setting;\n\t}\n\tconst read = (name: string): string => {\n\t\tconst value = env[name];\n\t\tif (!value) {\n\t\t\tthrow new Error(`Environment variable ${name} is not set.`);\n\t\t}\n\t\treturn value;\n\t};\n\tswitch (setting.type) {\n\t\tcase \"accessToken\":\n\t\t\treturn accessToken({\n\t\t\t\taccessToken: read(setting.accessTokenEnv ?? \"SF_ACCESS_TOKEN\"),\n\t\t\t\tinstanceUrl: read(setting.instanceUrlEnv ?? \"SF_INSTANCE_URL\"),\n\t\t\t});\n\t\tcase \"jwtBearer\":\n\t\t\treturn jwtBearerFromEnv(setting, env, read);\n\t\tcase \"sfCli\":\n\t\t\treturn sfCli({ targetOrg: setting.targetOrg });\n\t\tcase \"clientCredentials\":\n\t\t\treturn clientCredentials({\n\t\t\t\tloginUrl: read(setting.loginUrlEnv ?? \"SF_LOGIN_URL\"),\n\t\t\t\tclientId: read(setting.clientIdEnv ?? \"SF_CLIENT_ID\"),\n\t\t\t\tclientSecret: read(setting.clientSecretEnv ?? \"SF_CLIENT_SECRET\"),\n\t\t\t});\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown codegen auth type \"${(setting as { type: string }).type}\".`);\n\t}\n}\n\nfunction jwtBearerFromEnv(\n\tsetting: EnvJwtBearerAuth,\n\tenv: Record<string, string | undefined>,\n\tread: (name: string) => string,\n): AuthProvider {\n\tconst keyEnv = setting.privateKeyEnv ?? \"SF_PRIVATE_KEY\";\n\tconst privateKey = env[keyEnv]\n\t\t? read(keyEnv)\n\t\t: readFileSync(read(setting.privateKeyPathEnv ?? \"SF_PRIVATE_KEY_PATH\"), \"utf8\");\n\treturn jwtBearer({\n\t\tloginUrl: read(setting.loginUrlEnv ?? \"SF_LOGIN_URL\"),\n\t\tclientId: read(setting.clientIdEnv ?? \"SF_CLIENT_ID\"),\n\t\tusername: read(setting.usernameEnv ?? \"SF_USERNAME\"),\n\t\tprivateKey,\n\t});\n}\n\nasync function resolveSObjectNames(\n\tclient: SalesforceClient,\n\tconfig: CodegenConfig,\n\tlogger: CodegenLogger,\n): Promise<string[]> {\n\t// sObject names are case-insensitive in Salesforce.\n\tconst exclude = new Set((config.exclude ?? []).map((name) => name.toLowerCase()));\n\tif (config.sobjects && config.sobjects.length > 0) {\n\t\tconst unique = new Map<string, string>();\n\t\tfor (const name of config.sobjects) {\n\t\t\tif (!unique.has(name.toLowerCase())) {\n\t\t\t\tunique.set(name.toLowerCase(), name);\n\t\t\t}\n\t\t}\n\t\treturn [...unique.entries()].filter(([key]) => !exclude.has(key)).map(([, name]) => name);\n\t}\n\tlogger.warn(\"No `sobjects` configured: generating every queryable sObject. Consider an explicit list.\");\n\tconst global = await client.describeGlobal();\n\treturn global.sobjects\n\t\t.filter((sobject) => sobject.queryable && !sobject.deprecatedAndHidden && !exclude.has(sobject.name.toLowerCase()))\n\t\t.map((sobject) => sobject.name);\n}\n\nasync function describeAll(\n\tclient: SalesforceClient,\n\tnames: readonly string[],\n\tconfig: CodegenConfig,\n\tlogger: CodegenLogger,\n): Promise<{ describes: CodegenDescribe[]; skipped: GenerateResult[\"skipped\"] }> {\n\tconst concurrency = Math.max(1, config.concurrency ?? 10);\n\tconst describes: CodegenDescribe[] = [];\n\tconst skipped: GenerateResult[\"skipped\"] = [];\n\tlet next = 0;\n\tlet done = 0;\n\t// Stops the other workers (and their in-flight requests) once one describe has failed.\n\tconst failed = new AbortController();\n\n\tconst worker = async (): Promise<void> => {\n\t\twhile (next < names.length && !failed.signal.aborted) {\n\t\t\tconst name = names[next++];\n\t\t\ttry {\n\t\t\t\tconst describe: DescribeSObjectResult = await client.sobject(name).describe({ signal: failed.signal });\n\t\t\t\tdescribes.push(describe);\n\t\t\t} catch (error) {\n\t\t\t\tif (failed.signal.aborted) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\tif (!config.continueOnDescribeError) {\n\t\t\t\t\tfailed.abort();\n\t\t\t\t\tthrow new Error(`Describing sObject \"${name}\" failed: ${message}`, { cause: error });\n\t\t\t\t}\n\t\t\t\tlogger.warn(`Skipping sObject \"${name}\": ${message}`);\n\t\t\t\tskipped.push({ name, error: message });\n\t\t\t}\n\t\t\tdone++;\n\t\t\tif (done % 10 === 0 || done === names.length) {\n\t\t\t\tlogger.info(`Described ${done}/${names.length} sObject(s)`);\n\t\t\t}\n\t\t}\n\t};\n\n\tawait Promise.all(Array.from({ length: Math.min(concurrency, names.length) }, () => worker()));\n\t// Two configured names can resolve to the same sObject (e.g. a different case): keep one.\n\tconst unique = new Map(describes.map((describe) => [describe.name, describe] as const));\n\treturn { describes: [...unique.values()], skipped };\n}\n\nasync function writeAtomically(filePath: string, content: string): Promise<void> {\n\tawait mkdir(dirname(filePath), { recursive: true });\n\tconst temporary = `${filePath}.${process.pid}.${Date.now()}.tmp`;\n\ttry {\n\t\tawait writeFile(temporary, content, \"utf8\");\n\t\tawait renameWithRetry(temporary, filePath);\n\t} catch (error) {\n\t\tawait rm(temporary, { force: true });\n\t\tthrow error;\n\t}\n}\n\n/** On Windows a virus scanner or indexer can briefly lock the target file; retry a few times. */\nasync function renameWithRetry(from: string, to: string): Promise<void> {\n\tfor (let attempt = 1; ; attempt++) {\n\t\ttry {\n\t\t\tawait rename(from, to);\n\t\t\treturn;\n\t\t} catch (error) {\n\t\t\tconst code = (error as NodeJS.ErrnoException).code;\n\t\t\tif (attempt >= 5 || (code !== \"EPERM\" && code !== \"EBUSY\" && code !== \"EACCES\")) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tawait new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AM,QAAQ,IAAI,MAAM,KAAK,EAAE,QAAQ,KAAK,IAAI,aAAa,MAAM,MAAM,EAAE,SAAS,OAAO,CAAC,CAAC;CAG7F,OAAO;EAAE,WAAW,CAAC,GAAG,IADL,IAAI,UAAU,KAAK,aAAa,CAAC,SAAS,MAAM,QAAQ,CAAU,CACxD,CAAC,CAAC,OAAO,CAAC;EAAG;CAAQ;AACnD;AAEA,eAAe,gBAAgB,UAAkB,SAAgC;CAChF,OAAA,GAAMC,iBAAAA,MAAAA,EAAAA,GAAMC,UAAAA,QAAAA,CAAQ,QAAQ,GAAG,EAAE,WAAW,KAAK,CAAC;CAClD,MAAM,YAAY,GAAG,SAAS,GAAG,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE;CAC3D,IAAI;EACH,OAAA,GAAMC,iBAAAA,UAAAA,CAAU,WAAW,SAAS,MAAM;EAC1C,MAAM,gBAAgB,WAAW,QAAQ;CAC1C,SAAS,OAAO;EACf,OAAA,GAAMC,iBAAAA,GAAAA,CAAG,WAAW,EAAE,OAAO,KAAK,CAAC;EACnC,MAAM;CACP;AACD;;AAGA,eAAe,gBAAgB,MAAc,IAA2B;CACvE,KAAK,IAAI,UAAU,IAAK,WACvB,IAAI;EACH,OAAA,GAAMC,iBAAAA,OAAAA,CAAO,MAAM,EAAE;EACrB;CACD,SAAS,OAAO;EACf,MAAM,OAAQ,MAAgC;EAC9C,IAAI,WAAW,KAAM,SAAS,WAAW,SAAS,WAAW,SAAS,UACrE,MAAM;EAEP,MAAM,IAAI,SAAS,YAAY,WAAW,SAAS,KAAK,OAAO,CAAC;CACjE;AAEF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codegen-CSx0WAtK.mjs","names":["IDENTIFIER"],"sources":["../src/codegen/type-mapper.ts","../src/codegen/generator.ts","../src/codegen/validate-config.ts","../src/codegen/config.ts","../src/codegen/load-config.ts","../src/codegen/init.ts","../src/codegen/prompter.ts","../src/codegen/index.ts"],"sourcesContent":["import type { FieldDescribe } from \"../types/describe\";\n\nimport type { PicklistMode } from \"./config\";\n\n/** The subset of a field describe the generator needs. */\nexport type CodegenField = Pick<\n\tFieldDescribe,\n\t| \"name\"\n\t| \"label\"\n\t| \"type\"\n\t| \"nillable\"\n\t| \"createable\"\n\t| \"updateable\"\n\t| \"defaultedOnCreate\"\n\t| \"referenceTo\"\n\t| \"relationshipName\"\n> &\n\tPartial<Pick<FieldDescribe, \"picklistValues\" | \"restrictedPicklist\" | \"externalId\" | \"idLookup\">>;\n\nexport const ADDRESS_TYPE = \"SalesforceAddress\";\nexport const GEOLOCATION_TYPE = \"SalesforceGeolocation\";\n\n/** Maps each Salesforce field type to a TypeScript type. Types not listed become `unknown`. */\nexport const FIELD_TYPE_MAP: Readonly<Record<string, string>> = {\n\tboolean: \"boolean\",\n\tint: \"number\",\n\tlong: \"number\",\n\tdouble: \"number\",\n\tcurrency: \"number\",\n\tpercent: \"number\",\n\t/** ISO date, `yyyy-MM-dd`. */\n\tdate: \"string\",\n\t/** ISO date-time, e.g. `2026-01-31T12:00:00.000+0000`. */\n\tdatetime: \"string\",\n\t/** `HH:mm:ss.SSSZ`. */\n\ttime: \"string\",\n\tid: \"string\",\n\treference: \"string\",\n\tstring: \"string\",\n\ttextarea: \"string\",\n\tpicklist: \"string\",\n\t/** Values separated by `;`. */\n\tmultipicklist: \"string\",\n\tcombobox: \"string\",\n\temail: \"string\",\n\tphone: \"string\",\n\turl: \"string\",\n\tencryptedstring: \"string\",\n\t/** Base64-encoded content. */\n\tbase64: \"string\",\n\taddress: ADDRESS_TYPE,\n\tlocation: GEOLOCATION_TYPE,\n};\n\n/** Returns the TypeScript type for a field, including `| null` for nillable fields. */\nexport function mapFieldType(field: CodegenField, picklists: PicklistMode = \"union\"): string {\n\tconst base = picklistType(field, picklists) ?? FIELD_TYPE_MAP[field.type] ?? \"unknown\";\n\treturn field.nillable && base !== \"unknown\" ? `${base} | null` : base;\n}\n\nfunction picklistType(field: CodegenField, picklists: PicklistMode): string | undefined {\n\tif (picklists !== \"union\" || (field.type !== \"picklist\" && field.type !== \"combobox\")) {\n\t\treturn undefined;\n\t}\n\tconst values = [...new Set((field.picklistValues ?? []).filter((entry) => entry.active).map((entry) => entry.value))];\n\tif (values.length === 0) {\n\t\treturn undefined;\n\t}\n\tconst union = values.map((value) => JSON.stringify(value)).join(\" | \");\n\treturn field.restrictedPicklist && field.type === \"picklist\" ? union : `${union} | (string & {})`;\n}\n","import { createHash } from \"node:crypto\";\n\nimport type { ApiVersion } from \"../types/common\";\nimport type { ChildRelationship, RecordTypeInfo } from \"../types/describe\";\n\nimport type { PicklistMode } from \"./config\";\nimport { ADDRESS_TYPE, type CodegenField, GEOLOCATION_TYPE, mapFieldType } from \"./type-mapper\";\n\n/** The subset of an sObject describe the generator needs. */\nexport interface CodegenDescribe {\n\tname: string;\n\tlabel?: string;\n\tfields: CodegenField[];\n\tchildRelationships: Pick<ChildRelationship, \"childSObject\" | \"field\" | \"relationshipName\">[];\n\trecordTypeInfos?: Pick<RecordTypeInfo, \"developerName\">[];\n}\n\nexport interface GenerateSourceOptions {\n\texcludeCreateFields?: Partial<Record<string, readonly string[]>>;\n\texcludeUpdateFields?: Partial<Record<string, readonly string[]>>;\n\tpicklists?: PicklistMode;\n\timportSource?: string;\n\t/** When set, the output exports it as `API_VERSION`, so the client can use the same version. */\n\tapiVersion?: ApiVersion;\n\t/** Emit the `PICKLIST_VALUES` and `RECORD_TYPES` runtime constants. Defaults to `true`. */\n\tconstants?: boolean;\n}\n\n/** Field types whose kind is recorded in the registry's `fieldKinds`. */\nconst FIELD_KINDS = new Set([\"date\", \"datetime\", \"time\", \"multipicklist\"]);\n\nconst IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;\n\n/**\n * Generates the TypeScript source for a set of sObject describes: a read interface, create\n * and update input types per sObject, and the `SObjectRegistry` that ties them together.\n * The output is deterministic: sObjects are sorted by name and fields by name (`Id` first).\n */\nexport function generateSource(describes: readonly CodegenDescribe[], options: GenerateSourceOptions = {}): string {\n\tconst sorted = [...describes].sort((a, b) => compare(a.name, b.name));\n\tassertGeneratableNames(sorted);\n\tconst names = new Set(sorted.map((describe) => describe.name));\n\tconst sections = [imports(sorted, options.importSource ?? \"@cerios/salesforce-sobjectly\")];\n\tconst objectHashes: string[] = [];\n\n\tfor (const describe of sorted) {\n\t\tconst objectSections = [\n\t\t\treadInterface(describe, options.picklists ?? \"union\"),\n\t\t\tinputType(describe, \"CreateInput\", \"createable\", lookup(options.excludeCreateFields, describe.name)),\n\t\t\tinputType(describe, \"UpdateInput\", \"updateable\", lookup(options.excludeUpdateFields, describe.name)),\n\t\t];\n\t\tsections.push(...objectSections);\n\t\tconst fingerprint = [\n\t\t\t...objectSections,\n\t\t\tregistryEntry(describe, names),\n\t\t\toptions.constants === false ? \"\" : picklistEntry(describe),\n\t\t].join(\"\\n\");\n\t\tobjectHashes.push(`${describe.name}:${sha256(fingerprint).slice(0, OBJECT_HASH_LENGTH)}`);\n\t}\n\tsections.push(registry(sorted, names));\n\tif (options.constants !== false) {\n\t\tsections.push(picklistConstants(sorted), recordTypeConstants(sorted));\n\t}\n\tif (options.apiVersion) {\n\t\tsections.push(apiVersionConstant(options.apiVersion));\n\t}\n\tconst body = sections.filter((section) => section.length > 0).join(\"\\n\\n\");\n\treturn `${header(sha256(body), objectHashes)}\\n\\n${body}\\n`;\n}\n\n/** Names the generated file uses itself; an sObject with one of these names would break it. */\nconst RESERVED_TYPE_NAMES = new Set([\n\t\"Record\",\n\t\"Pick\",\n\t\"Partial\",\n\t\"SObjectRegistry\",\n\t\"PICKLIST_VALUES\",\n\t\"RECORD_TYPES\",\n\t\"API_VERSION\",\n\tADDRESS_TYPE,\n\tGEOLOCATION_TYPE,\n]);\n\n/** Fails with a clear message for sObject names the generated TypeScript can't represent. */\nfunction assertGeneratableNames(describes: readonly CodegenDescribe[]): void {\n\tconst seen = new Map<string, string>();\n\tconst generated = new Set(\n\t\tdescribes.flatMap((describe) => [`${describe.name}CreateInput`, `${describe.name}UpdateInput`]),\n\t);\n\tfor (const { name } of describes) {\n\t\tif (!IDENTIFIER.test(name)) {\n\t\t\tthrow new Error(`sObject name \"${name}\" is not a valid TypeScript identifier.`);\n\t\t}\n\t\tif (RESERVED_TYPE_NAMES.has(name) || generated.has(name)) {\n\t\t\tthrow new Error(`sObject name \"${name}\" clashes with a type the generated file defines; exclude it.`);\n\t\t}\n\t\tconst previous = seen.get(name.toLowerCase());\n\t\tif (previous !== undefined) {\n\t\t\tthrow new Error(`sObjects \"${previous}\" and \"${name}\" differ only in case; list each sObject once.`);\n\t\t}\n\t\tseen.set(name.toLowerCase(), name);\n\t}\n}\n\n/** Looks up a per-sObject option case-insensitively (sObject names are case-insensitive in Salesforce). */\nfunction lookup(map: Partial<Record<string, readonly string[]>> | undefined, name: string): readonly string[] {\n\tif (!map) {\n\t\treturn [];\n\t}\n\tconst key = Object.keys(map).find((candidate) => candidate.toLowerCase() === name.toLowerCase());\n\treturn key === undefined ? [] : (map[key] ?? []);\n}\n\nconst CONTENT_HASH_PREFIX = \"// sobjectly-content-hash: sha256:\";\nconst OBJECT_HASHES_PREFIX = \"// sobjectly-sobjects: \";\nconst OBJECT_HASH_LENGTH = 12;\n\nfunction header(contentHash: string, objectHashes: readonly string[]): string {\n\treturn [\n\t\t\"// ──────────────────────────────────────────────────────────────\",\n\t\t\"// AUTO-GENERATED by @cerios/salesforce-sobjectly (`sobjectly generate`).\",\n\t\t\"// Do not edit manually; re-run the generator instead.\",\n\t\t\"// ──────────────────────────────────────────────────────────────\",\n\t\t`${CONTENT_HASH_PREFIX}${contentHash}`,\n\t\t`${OBJECT_HASHES_PREFIX}${objectHashes.join(\",\")}`,\n\t\t\"/* eslint-disable */\",\n\t].join(\"\\n\");\n}\n\n/** The content hashes a generated file records in its header. */\nexport interface GeneratedFileHashes {\n\t/** SHA-256 of the unformatted generated content; formatting changes don't affect it. */\n\tcontentHash: string;\n\t/** Short hash per sObject, to tell which sObjects changed. */\n\tsobjects: Map<string, string>;\n}\n\n/** Reads the content hashes from a generated file's header (also after reformatting). */\nexport function readGeneratedHashes(source: string): GeneratedFileHashes | undefined {\n\tconst lines = source.split(/\\r?\\n/).map((line) => line.trim());\n\tconst hashLine = lines.find((line) => line.startsWith(CONTENT_HASH_PREFIX));\n\tif (!hashLine) {\n\t\treturn undefined;\n\t}\n\tconst objectsLine = lines.find((line) => line.startsWith(OBJECT_HASHES_PREFIX)) ?? OBJECT_HASHES_PREFIX;\n\tconst sobjects = new Map<string, string>();\n\tfor (const entry of objectsLine.slice(OBJECT_HASHES_PREFIX.length).split(\",\")) {\n\t\tconst [name, hash] = entry.split(\":\");\n\t\tif (name && hash) {\n\t\t\tsobjects.set(name, hash);\n\t\t}\n\t}\n\treturn { contentHash: hashLine.slice(CONTENT_HASH_PREFIX.length), sobjects };\n}\n\nfunction sha256(text: string): string {\n\treturn createHash(\"sha256\").update(text).digest(\"hex\");\n}\n\nfunction imports(describes: readonly CodegenDescribe[], importSource: string): string {\n\tconst used: string[] = [];\n\tconst fields = describes.flatMap((describe) => describe.fields);\n\tif (fields.some((field) => field.type === \"address\")) {\n\t\tused.push(ADDRESS_TYPE);\n\t}\n\tif (fields.some((field) => field.type === \"location\")) {\n\t\tused.push(GEOLOCATION_TYPE);\n\t}\n\treturn used.length > 0 ? `import type { ${used.join(\", \")} } from ${JSON.stringify(importSource)};` : \"\";\n}\n\nfunction sortedFields(describe: CodegenDescribe): CodegenField[] {\n\treturn [...describe.fields].sort((a, b) => (a.name === \"Id\" ? -1 : b.name === \"Id\" ? 1 : compare(a.name, b.name)));\n}\n\nfunction readInterface(describe: CodegenDescribe, picklists: PicklistMode): string {\n\tconst lines = sortedFields(describe).map((field) => {\n\t\tconst comment = `\\t/** ${escapeComment(field.label)} (${escapeComment(field.type)}) */`;\n\t\treturn `${comment}\\n\\t${propertyKey(field.name)}: ${mapFieldType(field, picklists)};`;\n\t});\n\tconst doc = describe.label ? `/** ${escapeComment(describe.label)} */\\n` : \"\";\n\treturn `${doc}export interface ${describe.name} {\\n${lines.join(\"\\n\")}\\n}`;\n}\n\n/**\n * Create input: required fields are `createable && !nillable && !defaultedOnCreate`; other\n * createable fields are optional. Validation rules and record types can add more requirements\n * at runtime. Update input: every updateable field is optional.\n */\nfunction inputType(\n\tdescribe: CodegenDescribe,\n\tsuffix: \"CreateInput\" | \"UpdateInput\",\n\tflag: \"createable\" | \"updateable\",\n\texcluded: readonly string[],\n): string {\n\tconst typeName = `${describe.name}${suffix}`;\n\tconst excludedNames = new Set(excluded.map((name) => name.toLowerCase()));\n\tconst allowed = sortedFields(describe).filter((field) => field[flag] && !excludedNames.has(field.name.toLowerCase()));\n\tif (allowed.length === 0) {\n\t\treturn `export type ${typeName} = Record<string, never>;`;\n\t}\n\tconst required =\n\t\tsuffix === \"CreateInput\"\n\t\t\t? allowed.filter((field) => !field.nillable && !field.defaultedOnCreate).map((field) => field.name)\n\t\t\t: [];\n\tconst optional = allowed.map((field) => field.name).filter((name) => !required.includes(name));\n\tconst parts: string[] = [];\n\tif (required.length > 0) {\n\t\tparts.push(`Pick<${describe.name}, ${keyUnion(required)}>`);\n\t}\n\tif (optional.length > 0) {\n\t\tparts.push(`Partial<Pick<${describe.name}, ${keyUnion(optional)}>>`);\n\t}\n\treturn `export type ${typeName} = ${parts.join(\" & \")};`;\n}\n\nfunction registry(describes: readonly CodegenDescribe[], names: ReadonlySet<string>): string {\n\tconst entries = describes.map((describe) => registryEntry(describe, names));\n\treturn [\n\t\t\"/**\",\n\t\t\" * Maps every generated sObject to its read, create and update types and its relationships.\",\n\t\t\" * Pass it to the client: `new SalesforceClient<SObjectRegistry>({ ... })`.\",\n\t\t\" */\",\n\t\t\"export interface SObjectRegistry {\",\n\t\t...entries,\n\t\t\"}\",\n\t].join(\"\\n\");\n}\n\nfunction registryEntry(describe: CodegenDescribe, names: ReadonlySet<string>): string {\n\tconst parents = describe.fields\n\t\t.filter(\n\t\t\t(field) =>\n\t\t\t\tfield.relationshipName &&\n\t\t\t\tfield.referenceTo.length === 1 &&\n\t\t\t\tnames.has(field.referenceTo[0]) &&\n\t\t\t\tIDENTIFIER.test(field.relationshipName),\n\t\t)\n\t\t.map((field) => [field.relationshipName as string, field.referenceTo[0]] as const);\n\tconst children = describe.childRelationships\n\t\t.filter(\n\t\t\t(relationship) =>\n\t\t\t\trelationship.relationshipName &&\n\t\t\t\tnames.has(relationship.childSObject) &&\n\t\t\t\tIDENTIFIER.test(relationship.relationshipName),\n\t\t)\n\t\t.map((relationship) => [relationship.relationshipName as string, relationship.childSObject] as const);\n\treturn [\n\t\t`\\t${describe.name}: {`,\n\t\t`\\t\\tread: ${describe.name};`,\n\t\t`\\t\\tcreate: ${describe.name}CreateInput;`,\n\t\t`\\t\\tupdate: ${describe.name}UpdateInput;`,\n\t\t`\\t\\tparents: ${relationshipMap(parents)};`,\n\t\t`\\t\\tchildren: ${relationshipMap(children)};`,\n\t\t`\\t\\texternalIds: ${unionOrNever(externalIdFields(describe))};`,\n\t\t`\\t\\tfieldKinds: ${fieldKindMap(describe)};`,\n\t\t`\\t\\trecordTypes: ${unionOrNever(recordTypeNames(describe))};`,\n\t\t`\\t\\tpolymorphicParents: ${polymorphicMap(describe)};`,\n\t\t\"\\t};\",\n\t].join(\"\\n\");\n}\n\n/** `Id` plus every field marked `externalId` or `idLookup`: the fields upsert accepts. */\nfunction externalIdFields(describe: CodegenDescribe): string[] {\n\tconst names = describe.fields\n\t\t.filter((field) => field.name === \"Id\" || field.externalId === true || field.idLookup === true)\n\t\t.map((field) => field.name);\n\treturn [...new Set(names)].sort(compare);\n}\n\nfunction recordTypeNames(describe: CodegenDescribe): string[] {\n\tconst names = (describe.recordTypeInfos ?? []).map((info) => info.developerName);\n\treturn [...new Set(names.filter((name) => typeof name === \"string\" && name.length > 0))].sort(compare);\n}\n\nfunction fieldKindMap(describe: CodegenDescribe): string {\n\tconst lines = sortedFields(describe)\n\t\t.filter((field) => FIELD_KINDS.has(field.type))\n\t\t.map((field) => `\\t\\t\\t${propertyKey(field.name)}: ${JSON.stringify(field.type)};`);\n\treturn lines.length > 0 ? `{\\n${lines.join(\"\\n\")}\\n\\t\\t}` : \"Record<never, never>\";\n}\n\n/** Lookups with more than one target (e.g. `Owner` -> User or Group); `parents` leaves these out. */\nfunction polymorphicMap(describe: CodegenDescribe): string {\n\tconst entries = new Map<string, string>();\n\tfor (const field of sortedFields(describe)) {\n\t\tconst name = field.relationshipName;\n\t\tif (name && field.referenceTo.length > 1 && IDENTIFIER.test(name) && !entries.has(name)) {\n\t\t\tentries.set(name, unionOrNever([...field.referenceTo].sort(compare)));\n\t\t}\n\t}\n\tconst lines = [...entries.entries()]\n\t\t.sort(([a], [b]) => compare(a, b))\n\t\t.map(([name, targets]) => `\\t\\t\\t${name}: ${targets};`);\n\treturn lines.length > 0 ? `{\\n${lines.join(\"\\n\")}\\n\\t\\t}` : \"Record<never, never>\";\n}\n\n/** `PICKLIST_VALUES`: the active values of every picklist and multi-select picklist field. */\nfunction picklistConstants(describes: readonly CodegenDescribe[]): string {\n\tconst entries = describes.map(picklistEntry).filter((entry) => entry.length > 0);\n\treturn [\n\t\t\"/** Active picklist values per sObject and field, e.g. to loop over every status in a test. */\",\n\t\t`export const PICKLIST_VALUES = {${entries.length > 0 ? `\\n${entries.join(\"\\n\")}\\n` : \"\"}} as const;`,\n\t].join(\"\\n\");\n}\n\n/** One sObject's entry in `PICKLIST_VALUES`, or `\"\"` when it has no picklists. */\nfunction picklistEntry(describe: CodegenDescribe): string {\n\tconst fields = sortedFields(describe)\n\t\t.map((field) => [field.name, activePicklistValues(field)] as const)\n\t\t.filter(([, values]) => values.length > 0)\n\t\t.map(([name, values]) => `\\t\\t${propertyKey(name)}: [${values.map((value) => JSON.stringify(value)).join(\", \")}],`);\n\treturn fields.length > 0 ? `\\t${describe.name}: {\\n${fields.join(\"\\n\")}\\n\\t},` : \"\";\n}\n\n/** `RECORD_TYPES`: the record type DeveloperNames per sObject. */\nfunction recordTypeConstants(describes: readonly CodegenDescribe[]): string {\n\tconst entries = describes\n\t\t.map((describe) => [describe.name, recordTypeNames(describe)] as const)\n\t\t.filter(([, names]) => names.length > 0)\n\t\t.map(([name, names]) => `\\t${name}: [${names.map((value) => JSON.stringify(value)).join(\", \")}],`);\n\treturn [\n\t\t\"/** Record type DeveloperNames per sObject. Resolve ids with `sf.sobject(name).recordTypeId(developerName)`. */\",\n\t\t`export const RECORD_TYPES = {${entries.length > 0 ? `\\n${entries.join(\"\\n\")}\\n` : \"\"}} as const;`,\n\t].join(\"\\n\");\n}\n\nfunction activePicklistValues(field: CodegenField): string[] {\n\tif (field.type !== \"picklist\" && field.type !== \"multipicklist\" && field.type !== \"combobox\") {\n\t\treturn [];\n\t}\n\treturn [...new Set((field.picklistValues ?? []).filter((entry) => entry.active).map((entry) => entry.value))];\n}\n\nfunction unionOrNever(values: readonly string[]): string {\n\treturn values.length > 0 ? values.map((value) => JSON.stringify(value)).join(\" | \") : \"never\";\n}\n\nfunction apiVersionConstant(apiVersion: ApiVersion): string {\n\tif (!/^v\\d+\\.\\d+$/.test(apiVersion)) {\n\t\tthrow new Error(`Invalid apiVersion \"${apiVersion}\".`);\n\t}\n\treturn [\n\t\t\"/**\",\n\t\t\" * The API version these types were generated with. Pass it to the client so requests use the\",\n\t\t\" * same version: `new SalesforceClient<SObjectRegistry>({ apiVersion: API_VERSION, ... })`.\",\n\t\t\" */\",\n\t\t`export const API_VERSION = ${JSON.stringify(apiVersion)};`,\n\t].join(\"\\n\");\n}\n\nfunction relationshipMap(entries: readonly (readonly [string, string])[]): string {\n\tconst unique = new Map<string, string>();\n\tfor (const [name, target] of entries) {\n\t\tif (!unique.has(name)) {\n\t\t\tunique.set(name, target);\n\t\t}\n\t}\n\tif (unique.size === 0) {\n\t\treturn \"Record<never, never>\";\n\t}\n\tconst lines = [...unique.entries()]\n\t\t.sort(([a], [b]) => compare(a, b))\n\t\t.map(([name, target]) => `\\t\\t\\t${name}: ${JSON.stringify(target)};`);\n\treturn `{\\n${lines.join(\"\\n\")}\\n\\t\\t}`;\n}\n\nfunction keyUnion(names: readonly string[]): string {\n\treturn names.map((name) => JSON.stringify(name)).join(\" | \");\n}\n\nfunction propertyKey(name: string): string {\n\treturn IDENTIFIER.test(name) ? name : JSON.stringify(name);\n}\n\nfunction escapeComment(value: string | null | undefined): string {\n\treturn String(value ?? \"\")\n\t\t.replace(/\\*\\//g, \"*\\\\/\")\n\t\t.replace(/\\r?\\n/g, \" \");\n}\n\nfunction compare(a: string, b: string): number {\n\treturn a < b ? -1 : a > b ? 1 : 0;\n}\n","import { isApiVersion } from \"../api-version\";\n\nimport type { CodegenConfig, EnvAuth } from \"./config\";\n\n/** Thrown when a codegen config is invalid. Lists every problem found. */\nexport class CodegenConfigError extends Error {\n\toverride readonly name: string = \"CodegenConfigError\";\n\n\tconstructor(\n\t\treadonly source: string,\n\t\treadonly problems: string[],\n\t) {\n\t\tsuper(`Invalid sobjectly config (${source}):\\n${problems.map((problem) => ` - ${problem}`).join(\"\\n\")}`);\n\t}\n}\n\n/** The env-variable options each env-based auth type accepts. */\nexport const AUTH_OPTIONS: Record<EnvAuth[\"type\"], readonly string[]> = {\n\tclientCredentials: [\"loginUrlEnv\", \"clientIdEnv\", \"clientSecretEnv\"],\n\taccessToken: [\"accessTokenEnv\", \"instanceUrlEnv\"],\n\tjwtBearer: [\"loginUrlEnv\", \"clientIdEnv\", \"usernameEnv\", \"privateKeyEnv\", \"privateKeyPathEnv\"],\n\tsfCli: [\"targetOrg\"],\n};\n\nexport const PICKLIST_MODES = [\"union\", \"string\"] as const;\n\nconst IDENTIFIER = /^[A-Za-z][A-Za-z0-9_]*$/;\n\ninterface Context {\n\tconfig: Record<string, unknown>;\n\tjson: boolean;\n\tproblem: (message: string) => void;\n}\n\ntype Validator = (value: unknown, context: Context) => void;\n\nconst VALIDATORS: Record<string, Validator> = {\n\t$schema: (value, { problem }) => {\n\t\tif (typeof value !== \"string\") {\n\t\t\tproblem(\"$schema: must be a string.\");\n\t\t}\n\t},\n\toutput: (value, { problem }) => {\n\t\tif (value === undefined) {\n\t\t\tproblem('output: required, e.g. \"src/generated/sobjects.ts\".');\n\t\t} else if (typeof value !== \"string\" || !/\\.(ts|mts|cts)$/.test(value)) {\n\t\t\tproblem(`output: must be a TypeScript file path such as \"src/generated/sobjects.ts\", got ${show(value)}.`);\n\t\t}\n\t},\n\tapiVersion: (value, { problem }) => {\n\t\tif (value === undefined || value === \"\") {\n\t\t\tproblem('apiVersion: required, e.g. \"v66.0\".');\n\t\t} else if (!isApiVersion(value)) {\n\t\t\tproblem(`apiVersion: must look like \"v66.0\", got ${show(value)}.`);\n\t\t}\n\t},\n\tsobjects: (value, { problem }) => validateNames(\"sobjects\", value, problem),\n\texclude: (value, { problem }) => validateNames(\"exclude\", value, problem),\n\tauth: validateAuth,\n\texcludeCreateFields: (value, context) => validateFieldMap(\"excludeCreateFields\", value, context),\n\texcludeUpdateFields: (value, context) => validateFieldMap(\"excludeUpdateFields\", value, context),\n\tpicklists: (value, { problem }) => {\n\t\tif (!PICKLIST_MODES.includes(value as (typeof PICKLIST_MODES)[number])) {\n\t\t\tproblem(`picklists: must be \"union\" or \"string\", got ${show(value)}.`);\n\t\t}\n\t},\n\tconstants: (value, { problem }) => {\n\t\tif (typeof value !== \"boolean\") {\n\t\t\tproblem(`constants: must be true or false, got ${show(value)}.`);\n\t\t}\n\t},\n\tconcurrency: (value, { problem }) => {\n\t\tif (!Number.isInteger(value) || (value as number) < 1) {\n\t\t\tproblem(`concurrency: must be a positive integer, got ${show(value)}.`);\n\t\t}\n\t},\n\tcontinueOnDescribeError: (value, { problem }) => {\n\t\tif (typeof value !== \"boolean\") {\n\t\t\tproblem(`continueOnDescribeError: must be true or false, got ${show(value)}.`);\n\t\t}\n\t},\n\timportSource: (value, { problem }) => {\n\t\tif (typeof value !== \"string\" || value.length === 0) {\n\t\t\tproblem(`importSource: must be a non-empty string, got ${show(value)}.`);\n\t\t}\n\t},\n\tformat: (value, { problem, json }) => {\n\t\tif (json) {\n\t\t\tproblem(\"format: only supported in a TypeScript config.\");\n\t\t} else if (typeof value !== \"function\") {\n\t\t\tproblem(\"format: must be a function (source, filePath) => string.\");\n\t\t}\n\t},\n\ttransport: (value, { problem, json }) => {\n\t\tif (json) {\n\t\t\tproblem(\"transport: only supported in a TypeScript config.\");\n\t\t} else if (typeof (value as { send?: unknown } | null)?.send !== \"function\") {\n\t\t\tproblem(\"transport: must be an HttpTransport (an object with a send() method).\");\n\t\t}\n\t},\n};\n\n/** The options a config may contain. */\nexport const CONFIG_OPTIONS: readonly string[] = Object.keys(VALIDATORS).filter((key) => key !== \"$schema\");\n\n/**\n * Checks a loaded config and returns it typed. Throws a `CodegenConfigError` listing every\n * problem. `json` disallows the options that only a TypeScript config can express.\n */\nexport function validateConfig(value: unknown, options: { source: string; json?: boolean }): CodegenConfig {\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n\t\tthrow new CodegenConfigError(options.source, [\n\t\t\t\"the config must be an object (export default defineConfig({ ... }) or a JSON object).\",\n\t\t]);\n\t}\n\tconst problems: string[] = [];\n\tconst context: Context = {\n\t\tconfig: value as Record<string, unknown>,\n\t\tjson: options.json ?? false,\n\t\tproblem: (message) => problems.push(message),\n\t};\n\tfor (const required of [\"apiVersion\", \"output\"]) {\n\t\tif (!(required in value)) {\n\t\t\tVALIDATORS[required]?.(undefined, context);\n\t\t}\n\t}\n\tfor (const [key, option] of Object.entries(value)) {\n\t\tconst validate = VALIDATORS[key];\n\t\tif (!validate) {\n\t\t\tproblems.push(`${key}: unknown option. Valid options: ${CONFIG_OPTIONS.join(\", \")}.`);\n\t\t} else if (option !== undefined || key === \"apiVersion\" || key === \"output\") {\n\t\t\tvalidate(option, context);\n\t\t}\n\t}\n\tif (problems.length > 0) {\n\t\tif (problems.some((problem) => problem.startsWith(\"apiVersion\") || problem.startsWith(\"output\"))) {\n\t\t\tproblems.push('Run \"npx sobjectly init\" to create a valid config.');\n\t\t}\n\t\tthrow new CodegenConfigError(options.source, problems);\n\t}\n\tconst { $schema: _schema, ...config } = value as Record<string, unknown>;\n\treturn config as unknown as CodegenConfig;\n}\n\nfunction validateNames(key: string, value: unknown, problem: (message: string) => void): void {\n\tif (!Array.isArray(value)) {\n\t\tproblem(`${key}: must be an array of sObject API names, got ${show(value)}.`);\n\t\treturn;\n\t}\n\tif (key === \"sobjects\" && value.length === 0) {\n\t\tproblem(\"sobjects: list at least one sObject, or leave it out to generate every queryable sObject.\");\n\t}\n\tvalue.forEach((name, index) => {\n\t\tif (typeof name !== \"string\" || !IDENTIFIER.test(name)) {\n\t\t\tproblem(`${key}[${index}]: ${show(name)} is not a valid sObject API name.`);\n\t\t}\n\t});\n}\n\nfunction validateFieldMap(key: string, value: unknown, { config, problem }: Context): void {\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n\t\tproblem(`${key}: must be an object like { \"Account\": [\"FieldName\"] }, got ${show(value)}.`);\n\t\treturn;\n\t}\n\t// sObject names are case-insensitive; the generator looks these keys up the same way.\n\tconst listed = Array.isArray(config.sobjects)\n\t\t? new Set((config.sobjects as unknown[]).map((name) => (typeof name === \"string\" ? name.toLowerCase() : name)))\n\t\t: undefined;\n\tfor (const [sobject, fields] of Object.entries(value)) {\n\t\tif (listed && !listed.has(sobject.toLowerCase())) {\n\t\t\tproblem(`${key}.${sobject}: \"${sobject}\" is not listed in sobjects.`);\n\t\t}\n\t\tif (!Array.isArray(fields) || fields.some((field) => typeof field !== \"string\" || field.length === 0)) {\n\t\t\tproblem(`${key}.${sobject}: must be an array of field API names, got ${show(fields)}.`);\n\t\t}\n\t}\n}\n\nfunction validateAuth(value: unknown, { json, problem }: Context): void {\n\tif (typeof value !== \"object\" || value === null) {\n\t\tproblem(`auth: must be an object like { \"type\": \"clientCredentials\" }, got ${show(value)}.`);\n\t\treturn;\n\t}\n\tif (typeof (value as { getToken?: unknown }).getToken === \"function\") {\n\t\tif (json) {\n\t\t\tproblem(\"auth: auth providers are only supported in a TypeScript config.\");\n\t\t}\n\t\treturn;\n\t}\n\tconst { type, ...rest } = value as Record<string, unknown>;\n\tconst allowed = AUTH_OPTIONS[type as EnvAuth[\"type\"]] as readonly string[] | undefined;\n\tif (!allowed) {\n\t\tproblem(`auth.type: must be one of ${Object.keys(AUTH_OPTIONS).join(\", \")}, got ${show(type)}.`);\n\t\treturn;\n\t}\n\tfor (const [key, option] of Object.entries(rest)) {\n\t\tif (!allowed.includes(key)) {\n\t\t\tproblem(`auth.${key}: not an option of \"${String(type)}\". Valid options: ${allowed.join(\", \")}.`);\n\t\t} else if (typeof option !== \"string\" || option.length === 0) {\n\t\t\tproblem(`auth.${key}: must be a non-empty string, got ${show(option)}.`);\n\t\t}\n\t}\n}\n\nfunction show(value: unknown): string {\n\tif (value === undefined) {\n\t\treturn \"undefined\";\n\t}\n\tif (typeof value === \"function\") {\n\t\treturn \"a function\";\n\t}\n\ttry {\n\t\treturn JSON.stringify(value) ?? typeof value;\n\t} catch {\n\t\treturn typeof value;\n\t}\n}\n","import type { AuthProvider } from \"../auth/types\";\nimport type { HttpTransport } from \"../http/transport\";\nimport type { ApiVersion } from \"../types/common\";\n\n/** Client credentials read from environment variables (defaults shown). */\nexport interface EnvClientCredentialsAuth {\n\ttype: \"clientCredentials\";\n\t/** Defaults to `SF_LOGIN_URL` (your My Domain URL). */\n\tloginUrlEnv?: string;\n\t/** Defaults to `SF_CLIENT_ID`. */\n\tclientIdEnv?: string;\n\t/** Defaults to `SF_CLIENT_SECRET`. */\n\tclientSecretEnv?: string;\n}\n\n/** An access token read from environment variables (defaults shown), e.g. from `sf org display`. */\nexport interface EnvAccessTokenAuth {\n\ttype: \"accessToken\";\n\t/** Defaults to `SF_ACCESS_TOKEN`. */\n\taccessTokenEnv?: string;\n\t/** Defaults to `SF_INSTANCE_URL`. */\n\tinstanceUrlEnv?: string;\n}\n\n/** JWT bearer flow with values read from environment variables (defaults shown). */\nexport interface EnvJwtBearerAuth {\n\ttype: \"jwtBearer\";\n\t/** Defaults to `SF_LOGIN_URL`. */\n\tloginUrlEnv?: string;\n\t/** Defaults to `SF_CLIENT_ID`. */\n\tclientIdEnv?: string;\n\t/** Defaults to `SF_USERNAME`. */\n\tusernameEnv?: string;\n\t/** The PEM key itself. Defaults to `SF_PRIVATE_KEY`. */\n\tprivateKeyEnv?: string;\n\t/** A path to the PEM key file, used when the key variable is empty. Defaults to `SF_PRIVATE_KEY_PATH`. */\n\tprivateKeyPathEnv?: string;\n}\n\n/** An auth setting that reads credentials from environment variables. The only kind a JSON config can use. */\n/** An org you are logged into with the Salesforce CLI (`sf org login web --alias my-org`). */\nexport interface SfCliAuth {\n\ttype: \"sfCli\";\n\t/** The org alias or username. Defaults to the CLI's default org. */\n\ttargetOrg?: string;\n}\n\nexport type EnvAuth = EnvClientCredentialsAuth | EnvAccessTokenAuth | EnvJwtBearerAuth | SfCliAuth;\n\n/** Env-based auth, or any auth provider (TypeScript configs only). */\nexport type CodegenAuth = EnvAuth | AuthProvider;\n\nexport type PicklistMode =\n\t/** Every picklist is `string`. */\n\t| \"string\"\n\t/** Restricted picklists become a union of their values; unrestricted ones `\"A\" | \"B\" | (string & {})`. */\n\t| \"union\";\n\n/**\n * The codegen config. `S` is the union of the listed sObject names; `defineConfig` infers it, so\n * per-sObject options such as `excludeCreateFields` only accept listed names.\n */\nexport interface CodegenConfig<S extends string = string> {\n\t/** Output file, relative to the config file's directory, e.g. `\"src/generated/sobjects.ts\"`. */\n\toutput: string;\n\t/**\n\t * The API version to describe with, e.g. `\"v66.0\"`. Required. It is also written to the\n\t * generated file as `API_VERSION`, so the client can use the same version.\n\t */\n\tapiVersion: ApiVersion;\n\t/**\n\t * sObjects to generate. Strongly recommended: without it every queryable sObject in the org\n\t * is generated, which can be thousands of types.\n\t */\n\tsobjects?: readonly S[];\n\t/** sObjects to skip (applied after `sobjects`). */\n\texclude?: readonly string[];\n\t/** How to authenticate. Defaults to client credentials from `SF_LOGIN_URL`, `SF_CLIENT_ID` and `SF_CLIENT_SECRET`. */\n\tauth?: CodegenAuth;\n\t/** Fields to leave out of the create input per sObject (e.g. fields describe marks createable but REST rejects). */\n\texcludeCreateFields?: Partial<Record<NoInfer<S>, readonly string[]>>;\n\t/** Fields to leave out of the update input per sObject. */\n\texcludeUpdateFields?: Partial<Record<NoInfer<S>, readonly string[]>>;\n\t/** How picklists are typed. Defaults to `\"union\"`. */\n\tpicklists?: PicklistMode;\n\t/** Emit the `PICKLIST_VALUES` and `RECORD_TYPES` runtime constants. Defaults to `true`. */\n\tconstants?: boolean;\n\t/** Parallel describe calls. Defaults to 10. */\n\tconcurrency?: number;\n\t/** Skip sObjects whose describe fails instead of failing the run. Defaults to `false`. */\n\tcontinueOnDescribeError?: boolean;\n\t/** Where the generated file imports helper types from. Defaults to `\"@cerios/salesforce-sobjectly\"`. */\n\timportSource?: string;\n\t/** Post-processes the generated source, e.g. with your formatter. TypeScript configs only. */\n\tformat?: (source: string, filePath: string) => string | Promise<string>;\n\t/** A custom transport for the describe calls (e.g. behind a proxy). TypeScript configs only. */\n\ttransport?: HttpTransport;\n}\n\n/**\n * The shape of `sobjectly.config.json`: everything that can be written as JSON (no functions,\n * no auth providers). `$schema` points editors at the bundled JSON Schema.\n */\nexport type JsonCodegenConfig = Omit<CodegenConfig, \"auth\" | \"format\" | \"transport\"> & {\n\t$schema?: string;\n\tauth?: EnvAuth;\n};\n\n/**\n * Type-checks a `sobjectly.config.ts`. The listed `sobjects` become a literal union, so a typo in\n * a per-sObject option is a compile error:\n *\n * ```ts\n * export default defineConfig({\n * \tapiVersion: \"v66.0\",\n * \toutput: \"src/generated/sobjects.ts\",\n * \tsobjects: [\"Account\", \"Contact\"],\n * \texcludeCreateFields: { Acount: [\"Name\"] }, // ❌ \"Acount\" is not in sobjects\n * });\n * ```\n */\nexport function defineConfig<const S extends string = string>(config: CodegenConfig<S>): CodegenConfig<S> {\n\treturn config;\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { dirname, extname, join, resolve } from \"node:path\";\n\nimport { createJiti } from \"jiti\";\n\nimport type { CodegenConfig } from \"./config\";\nimport { CodegenConfigError, validateConfig } from \"./validate-config\";\n\n/** Config file names, in lookup order. */\nexport const CONFIG_FILE_NAMES = [\n\t\"sobjectly.config.ts\",\n\t\"sobjectly.config.mts\",\n\t\"sobjectly.config.cts\",\n\t\"sobjectly.config.json\",\n];\n\nconst TYPESCRIPT_EXTENSIONS = new Set([\".ts\", \".mts\", \".cts\"]);\n\n/** Looks for a `sobjectly.config.{ts,mts,cts,json}` file in `cwd`; the first match in lookup order wins. */\nexport function findConfigFile(cwd: string = process.cwd()): string | undefined {\n\treturn findConfigFiles(cwd)[0];\n}\n\n/** Every `sobjectly.config.*` file in `cwd`, in lookup order. */\nexport function findConfigFiles(cwd: string = process.cwd()): string[] {\n\treturn CONFIG_FILE_NAMES.map((name) => join(cwd, name)).filter((path) => existsSync(path));\n}\n\n/**\n * Loads and validates a TypeScript (`.ts`, `.mts`, `.cts`) or JSON config file. Returns the\n * config and the directory it lives in. Throws a `CodegenConfigError` listing every problem.\n */\nexport async function loadConfig(configPath: string): Promise<{ config: CodegenConfig; directory: string }> {\n\tconst absolutePath = resolve(configPath);\n\tif (!existsSync(absolutePath)) {\n\t\tthrow new Error(`Config file not found: ${absolutePath}`);\n\t}\n\tconst extension = extname(absolutePath).toLowerCase();\n\tconst directory = dirname(absolutePath);\n\tif (extension === \".json\") {\n\t\treturn { config: validateConfig(readJson(absolutePath), { source: absolutePath, json: true }), directory };\n\t}\n\tif (!TYPESCRIPT_EXTENSIONS.has(extension)) {\n\t\tthrow new Error(`Unsupported config file \"${absolutePath}\". Use sobjectly.config.ts or sobjectly.config.json.`);\n\t}\n\tconst jiti = createJiti(join(directory, \"_sobjectly_loader.js\"), { interopDefault: true });\n\tconst loaded = await jiti.import<unknown>(absolutePath, { default: true });\n\treturn { config: validateConfig(loaded, { source: absolutePath }), directory };\n}\n\nfunction readJson(path: string): unknown {\n\ttry {\n\t\treturn JSON.parse(readFileSync(path, \"utf8\")) as unknown;\n\t} catch (error) {\n\t\tthrow new CodegenConfigError(path, [`not valid JSON: ${error instanceof Error ? error.message : String(error)}`]);\n\t}\n}\n","import { existsSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { join, relative } from \"node:path\";\n\nimport { normalizeApiVersion } from \"../api-version\";\nimport type { ApiVersion } from \"../types/common\";\n\nimport type { PicklistMode } from \"./config\";\nimport { findConfigFiles } from \"./load-config\";\nimport type { Choice, Prompter } from \"./prompter\";\n\nexport type InitAuthType = \"clientCredentials\" | \"accessToken\" | \"jwtBearer\" | \"sfCli\";\nexport type InitConfigFormat = \"ts\" | \"json\";\n\nexport interface InitAnswers {\n\tapiVersion: ApiVersion;\n\toutput: string;\n\tsobjects: string[];\n\tauth: InitAuthType;\n\t/** The Salesforce CLI org alias, for `auth: \"sfCli\"`. Omitted means the CLI's default org. */\n\ttargetOrg?: string;\n\tpicklists: PicklistMode;\n\tformat: InitConfigFormat;\n}\n\nexport interface InitOptions {\n\tcwd: string;\n\tprompter: Prompter;\n\tlog: (message: string) => void;\n\t/** Answers given up front (e.g. CLI flags); those questions are skipped. */\n\tpreset?: Partial<InitAnswers>;\n\t/** Accept the suggested answer for every question not in `preset`. `apiVersion` must then be preset. */\n\tyes?: boolean;\n\t/** Overwrite an existing config without asking. */\n\tforce?: boolean;\n}\n\nexport interface InitResult {\n\t/** `undefined` when the user chose not to overwrite an existing config. */\n\tconfigPath: string | undefined;\n\tanswers?: InitAnswers;\n\tenvExampleUpdated?: boolean;\n\tscriptAdded?: boolean;\n}\n\nconst SOBJECT_NAME = /^[A-Za-z][A-Za-z0-9_]*$/;\nconst NPM_SCRIPT = \"sobjects:generate\";\n\n/** The environment variables each auth type reads by default. */\nexport const AUTH_ENV_VARS: Record<InitAuthType, string[]> = {\n\tclientCredentials: [\"SF_LOGIN_URL\", \"SF_CLIENT_ID\", \"SF_CLIENT_SECRET\"],\n\taccessToken: [\"SF_ACCESS_TOKEN\", \"SF_INSTANCE_URL\"],\n\tjwtBearer: [\"SF_LOGIN_URL\", \"SF_CLIENT_ID\", \"SF_USERNAME\", \"SF_PRIVATE_KEY_PATH\"],\n\tsfCli: [],\n};\n\nconst AUTH_CHOICES: Choice<InitAuthType>[] = [\n\t{ value: \"clientCredentials\", label: \"Client credentials (recommended for CI and test automation)\" },\n\t{ value: \"sfCli\", label: \"Salesforce CLI org (recommended for local development; no secrets needed)\" },\n\t{ value: \"accessToken\", label: \"Access token (e.g. from `sf org display`)\" },\n\t{ value: \"jwtBearer\", label: \"JWT bearer (certificate-based, runs as a user)\" },\n];\n\nconst PICKLIST_CHOICES: Choice<PicklistMode>[] = [\n\t{ value: \"union\", label: 'Union of values, e.g. \"New\" | \"Closed\" (type-safe)' },\n\t{ value: \"string\", label: \"Plain string\" },\n];\n\nconst FORMAT_CHOICES: Choice<InitConfigFormat>[] = [\n\t{ value: \"ts\", label: \"TypeScript (sobjectly.config.ts, type-checked with defineConfig)\" },\n\t{ value: \"json\", label: \"JSON (sobjectly.config.json, validated with a JSON Schema)\" },\n];\n\n/**\n * Creates a `sobjectly.config` file by asking for the API version, output path, sObjects, auth\n * method, picklist mode and file format. Optionally adds the auth variables to `.env.example`\n * and an npm script to `package.json`.\n */\nexport async function runInit(options: InitOptions): Promise<InitResult> {\n\tconst { cwd, prompter, log } = options;\n\tconst existing = findConfigFiles(cwd);\n\tif (existing.length > 0 && !options.force) {\n\t\tconst names = existing.map((path) => relative(cwd, path)).join(\" and \");\n\t\tconst overwrite = options.yes ? false : await prompter.confirm(`${names} already exists. Replace it?`, false);\n\t\tif (!overwrite) {\n\t\t\tlog(`Kept the existing ${names}.`);\n\t\t\treturn { configPath: undefined };\n\t\t}\n\t}\n\n\tvalidatePreset(options.preset ?? {});\n\tconst answers = await askQuestions(options);\n\tconst configPath = join(cwd, `sobjectly.config.${answers.format}`);\n\t// Only one config may exist, otherwise the lookup order would silently pick one.\n\tfor (const path of existing.filter((path) => path !== configPath)) {\n\t\trmSync(path);\n\t\tlog(`Removed ${relative(cwd, path)}`);\n\t}\n\twriteFileSync(configPath, renderConfig(answers), \"utf8\");\n\tlog(`\\nCreated ${relative(cwd, configPath)}`);\n\n\tconst envExampleUpdated = await maybeUpdateEnvExample(options, answers.auth);\n\tconst scriptAdded = await maybeAddScript(options);\n\tprintNextSteps(log, answers, scriptAdded, cwd);\n\treturn { configPath, answers, envExampleUpdated, scriptAdded };\n}\n\nasync function askQuestions(options: InitOptions): Promise<InitAnswers> {\n\tconst { prompter, preset = {}, yes } = options;\n\tconst apiVersion = preset.apiVersion ?? (await askApiVersion(prompter, yes));\n\tconst output =\n\t\tpreset.output ??\n\t\t(yes\n\t\t\t? \"src/generated/sobjects.ts\"\n\t\t\t: await prompter.ask(\"Where should the generated types be written?\", {\n\t\t\t\t\tdefaultValue: \"src/generated/sobjects.ts\",\n\t\t\t\t\tvalidate: validateOutput,\n\t\t\t\t}));\n\tconst sobjects = preset.sobjects ?? (await askSObjects(prompter, yes));\n\tconst auth =\n\t\tpreset.auth ??\n\t\t(yes\n\t\t\t? \"clientCredentials\"\n\t\t\t: await prompter.choose(\"How should the generator log in to Salesforce?\", AUTH_CHOICES, \"clientCredentials\"));\n\tconst targetOrg = auth === \"sfCli\" ? (preset.targetOrg ?? (await askTargetOrg(prompter, yes))) : undefined;\n\tconst picklists =\n\t\tpreset.picklists ??\n\t\t(yes ? \"union\" : await prompter.choose(\"How should picklist fields be typed?\", PICKLIST_CHOICES, \"union\"));\n\tconst format =\n\t\tpreset.format ?? (yes ? \"ts\" : await prompter.choose(\"Which config file format?\", FORMAT_CHOICES, \"ts\"));\n\treturn { apiVersion, output, sobjects, auth, ...(targetOrg ? { targetOrg } : {}), picklists, format };\n}\n\nasync function askTargetOrg(prompter: Prompter, yes: boolean | undefined): Promise<string | undefined> {\n\tif (yes) {\n\t\treturn undefined;\n\t}\n\tconst answer = await prompter.ask(\"Which Salesforce CLI org alias? Leave empty to use the CLI's default org\", {\n\t\tvalidate: (value) => (value === \"\" || /^[\\w.@+-]+$/.test(value) ? undefined : \"Enter an org alias or username.\"),\n\t});\n\treturn answer === \"\" ? undefined : answer;\n}\n\nasync function askApiVersion(prompter: Prompter, yes: boolean | undefined): Promise<ApiVersion> {\n\tif (yes) {\n\t\tthrow new Error(\"An API version is required: pass --api-version (e.g. --api-version v66.0).\");\n\t}\n\tconst answer = await prompter.ask(\n\t\t\"Which Salesforce API version should be used? (e.g. v66.0; your org lists them at https://<my-domain>.my.salesforce.com/services/data/)\",\n\t\t{ validate: (value) => (normalizeApiVersion(value) ? undefined : 'Enter a version like \"v66.0\" or \"66\".') },\n\t);\n\treturn normalizeApiVersion(answer) as ApiVersion;\n}\n\nasync function askSObjects(prompter: Prompter, yes: boolean | undefined): Promise<string[]> {\n\tconst defaultValue = \"Account, Contact\";\n\tconst answer = yes\n\t\t? defaultValue\n\t\t: await prompter.ask(\"Which sObjects do you want types for? Use comma-separated API names\", {\n\t\t\t\tdefaultValue,\n\t\t\t\tvalidate: validateSObjects,\n\t\t\t});\n\treturn parseSObjects(answer);\n}\n\n/** Splits a comma/space separated list of sObject names, removing duplicates. */\nexport function parseSObjects(answer: string): string[] {\n\treturn [...new Set(answer.split(/[\\s,]+/).filter((name) => name.length > 0))];\n}\n\nfunction validateSObjects(answer: string): string | undefined {\n\treturn validateSObjectNames(parseSObjects(answer));\n}\n\nfunction validateSObjectNames(names: readonly string[]): string | undefined {\n\tif (names.length === 0) {\n\t\treturn \"Enter at least one sObject, e.g. Account.\";\n\t}\n\tconst invalid = names.filter((name) => !SOBJECT_NAME.test(name));\n\treturn invalid.length > 0 ? `Not a valid sObject API name: ${invalid.join(\", \")}` : undefined;\n}\n\n/** Answers given as flags get the same checks as typed answers. */\nfunction validatePreset(preset: Partial<InitAnswers>): void {\n\tconst errors = [\n\t\t// Check the names as given: joining and re-splitting would let \"Bad Name\" pass as two names.\n\t\tpreset.sobjects === undefined ? undefined : validateSObjectNames(preset.sobjects),\n\t\tpreset.output === undefined ? undefined : validateOutput(preset.output),\n\t\tpreset.targetOrg === undefined || /^[\\w.@+-]+$/.test(preset.targetOrg)\n\t\t\t? undefined\n\t\t\t: `Invalid org alias \"${preset.targetOrg}\".`,\n\t].filter((error): error is string => error !== undefined);\n\tif (errors.length > 0) {\n\t\tthrow new Error(errors.join(\" \"));\n\t}\n}\n\nfunction validateOutput(answer: string): string | undefined {\n\treturn /\\.(ts|mts|cts)$/.test(answer)\n\t\t? undefined\n\t\t: \"The output must be a TypeScript file, e.g. src/generated/sobjects.ts.\";\n}\n\n/** The `$schema` reference written into `sobjectly.config.json`. */\nexport const JSON_SCHEMA_REFERENCE = \"./node_modules/@cerios/salesforce-sobjectly/sobjectly.config.schema.json\";\n\n/** Renders the config file in the chosen format. */\nexport function renderConfig(answers: InitAnswers): string {\n\treturn answers.format === \"json\" ? renderJsonConfig(answers) : renderTypeScriptConfig(answers);\n}\n\nfunction renderJsonConfig(answers: InitAnswers): string {\n\tconst config = {\n\t\t$schema: JSON_SCHEMA_REFERENCE,\n\t\tapiVersion: answers.apiVersion,\n\t\toutput: answers.output,\n\t\tsobjects: answers.sobjects,\n\t\tauth: authSetting(answers),\n\t\tpicklists: answers.picklists,\n\t};\n\treturn `${JSON.stringify(config, null, \"\\t\")}\\n`;\n}\n\nfunction renderTypeScriptConfig(answers: InitAnswers): string {\n\tconst envVars = AUTH_ENV_VARS[answers.auth];\n\tconst sobjects = answers.sobjects.map((name) => JSON.stringify(name)).join(\", \");\n\treturn [\n\t\t'import { defineConfig } from \"@cerios/salesforce-sobjectly/codegen\";',\n\t\t\"\",\n\t\t\"export default defineConfig({\",\n\t\t\"\\t// The Salesforce REST API version. The generated file exports it as API_VERSION for the client.\",\n\t\t`\\tapiVersion: ${JSON.stringify(answers.apiVersion)},`,\n\t\t\"\\t// Where the generated types are written, relative to this file.\",\n\t\t`\\toutput: ${JSON.stringify(answers.output)},`,\n\t\t\"\\t// The sObjects to generate types for.\",\n\t\t`\\tsobjects: [${sobjects}],`,\n\t\t`\\t// ${authComment(answers.auth, envVars)}`,\n\t\t`\\tauth: ${renderAuth(answers)},`,\n\t\t`\\tpicklists: ${JSON.stringify(answers.picklists)},`,\n\t\t\"});\",\n\t\t\"\",\n\t].join(\"\\n\");\n}\n\nfunction authSetting(answers: InitAnswers): { type: InitAuthType; targetOrg?: string } {\n\treturn answers.auth === \"sfCli\" && answers.targetOrg\n\t\t? { type: \"sfCli\", targetOrg: answers.targetOrg }\n\t\t: { type: answers.auth };\n}\n\nfunction renderAuth(answers: InitAnswers): string {\n\tconst setting = authSetting(answers);\n\tconst targetOrg = setting.targetOrg ? `, targetOrg: ${JSON.stringify(setting.targetOrg)}` : \"\";\n\treturn `{ type: ${JSON.stringify(setting.type)}${targetOrg} }`;\n}\n\nfunction authComment(auth: InitAuthType, envVars: readonly string[]): string {\n\treturn auth === \"sfCli\"\n\t\t? \"Uses an org you are logged into with the Salesforce CLI (sf org login web).\"\n\t\t: `Reads ${formatList(envVars)} from the environment.`;\n}\n\nasync function maybeUpdateEnvExample(options: InitOptions, auth: InitAuthType): Promise<boolean> {\n\tconst path = join(options.cwd, \".env.example\");\n\tconst content = existsSync(path) ? readFileSync(path, \"utf8\") : \"\";\n\tconst missing = AUTH_ENV_VARS[auth].filter((name) => !new RegExp(`^${name}=`, \"m\").test(content));\n\tif (missing.length === 0) {\n\t\treturn false;\n\t}\n\tconst add =\n\t\toptions.yes === true || (await options.prompter.confirm(`Add ${formatList(missing)} to .env.example?`, true));\n\tif (!add) {\n\t\treturn false;\n\t}\n\tconst block = [\"# Salesforce credentials for `sobjectly generate`\", ...missing.map((name) => `${name}=`)].join(\"\\n\");\n\tconst separator = content.length === 0 ? \"\" : content.endsWith(\"\\n\") ? \"\\n\" : \"\\n\\n\";\n\twriteFileSync(path, `${content}${separator}${block}\\n`, \"utf8\");\n\toptions.log(\"Updated .env.example\");\n\treturn true;\n}\n\nasync function maybeAddScript(options: InitOptions): Promise<boolean> {\n\tconst path = join(options.cwd, \"package.json\");\n\tif (!existsSync(path)) {\n\t\treturn false;\n\t}\n\tconst raw = readFileSync(path, \"utf8\");\n\tconst bom = raw.startsWith(\"\") ? \"\" : \"\";\n\tlet pkg: { scripts?: Record<string, string> };\n\ttry {\n\t\tpkg = JSON.parse(raw.slice(bom.length)) as { scripts?: Record<string, string> };\n\t} catch {\n\t\toptions.log(`Skipped adding the \"${NPM_SCRIPT}\" script: package.json is not valid JSON.`);\n\t\treturn false;\n\t}\n\tif (pkg.scripts?.[NPM_SCRIPT]) {\n\t\treturn false;\n\t}\n\tconst add = options.yes === true || (await options.prompter.confirm(`Add an npm script \"${NPM_SCRIPT}\"?`, true));\n\tif (!add) {\n\t\treturn false;\n\t}\n\tpkg.scripts = { ...pkg.scripts, [NPM_SCRIPT]: \"sobjectly generate\" };\n\tconst indent = /^[ \\t]+/m.exec(raw)?.[0] ?? \"\\t\";\n\tconst newline = raw.includes(\"\\r\\n\") ? \"\\r\\n\" : \"\\n\";\n\tconst json = JSON.stringify(pkg, null, indent).replace(/\\n/g, newline);\n\twriteFileSync(path, `${bom}${json}${newline}`, \"utf8\");\n\toptions.log(`Added the \"${NPM_SCRIPT}\" script to package.json`);\n\treturn true;\n}\n\nfunction printNextSteps(log: (message: string) => void, answers: InitAnswers, scriptAdded: boolean, cwd: string): void {\n\tconst cli = answers.auth === \"sfCli\";\n\tconst envFile = cli ? \"\" : \" --env-file .env\";\n\tconst command = scriptAdded\n\t\t? `npm run ${NPM_SCRIPT}${envFile ? ` --${envFile}` : \"\"}`\n\t\t: `npx sobjectly generate${envFile}`;\n\tconst gitignore = join(cwd, \".gitignore\");\n\tconst envIgnored = existsSync(gitignore) && /^\\.env\\b/m.test(readFileSync(gitignore, \"utf8\"));\n\tconst firstStep = cli\n\t\t? ` 1. Log in with the Salesforce CLI: sf org login web${answers.targetOrg ? ` --alias ${answers.targetOrg}` : \" --set-default\"}`\n\t\t: ` 1. Put ${formatList(AUTH_ENV_VARS[answers.auth])} in a .env file${envIgnored ? \"\" : \" (and add .env to .gitignore)\"}.`;\n\tlog(\n\t\t[\n\t\t\t\"\",\n\t\t\t\"Next steps:\",\n\t\t\tfirstStep,\n\t\t\t` 2. Generate the types: ${command}`,\n\t\t\t\" 3. Use them:\",\n\t\t\t` import { API_VERSION, type SObjectRegistry } from \"./${answers.output.replace(/\\.(ts|mts|cts)$/, \"\")}\";`,\n\t\t\t\" const sf = new SalesforceClient<SObjectRegistry>({ apiVersion: API_VERSION, auth });\",\n\t\t].join(\"\\n\"),\n\t);\n}\n\nfunction formatList(items: readonly string[]): string {\n\tif (items.length <= 1) {\n\t\treturn items.join(\"\");\n\t}\n\treturn `${items.slice(0, -1).join(\", \")} and ${items.at(-1)}`;\n}\n","import { createInterface } from \"node:readline\";\n\nexport interface Choice<T extends string> {\n\tvalue: T;\n\tlabel: string;\n}\n\n/** Asks questions. The CLI uses `readlinePrompter`; tests pass a scripted implementation. */\nexport interface Prompter {\n\t/** Asks for text. `validate` returns an error message to ask again, or `undefined` to accept. */\n\task(\n\t\tquestion: string,\n\t\toptions?: { defaultValue?: string; validate?: (answer: string) => string | undefined },\n\t): Promise<string>;\n\t/** Asks to pick one of `choices`, by number or value. */\n\tchoose<T extends string>(question: string, choices: readonly Choice<T>[], defaultValue: T): Promise<T>;\n\t/** Asks a yes/no question. */\n\tconfirm(question: string, defaultValue: boolean): Promise<boolean>;\n\tclose(): void;\n}\n\n/**\n * A prompter on stdin/stdout (or the given streams). Lines are queued as they arrive, so piped\n * input (`printf \"v66.0\\n...\" | sobjectly init`) works too. If the input ends before a question\n * is answered, the question rejects.\n */\nexport function readlinePrompter(\n\tinput: NodeJS.ReadableStream = process.stdin,\n\toutput: NodeJS.WritableStream = process.stdout,\n): Prompter {\n\tconst interactive = (input as { isTTY?: boolean }).isTTY === true;\n\tconst rl = createInterface({ input, output, terminal: interactive });\n\tconst lines: string[] = [];\n\tlet waiting: { resolve: (line: string) => void; reject: (error: Error) => void } | undefined;\n\tlet closed = false;\n\n\trl.on(\"line\", (line) => {\n\t\tif (waiting) {\n\t\t\tconst { resolve } = waiting;\n\t\t\twaiting = undefined;\n\t\t\tresolve(line);\n\t\t} else {\n\t\t\tlines.push(line);\n\t\t}\n\t});\n\trl.on(\"close\", () => {\n\t\tclosed = true;\n\t\twaiting?.reject(new Error(\"Input ended before all questions were answered.\"));\n\t\twaiting = undefined;\n\t});\n\n\tconst readLine = (prompt: string): Promise<string> => {\n\t\tif (closed) {\n\t\t\t// Piped input can end while answers are still queued; readline can't prompt after close.\n\t\t\toutput.write(prompt);\n\t\t} else {\n\t\t\trl.setPrompt(prompt);\n\t\t\trl.prompt();\n\t\t}\n\t\tconst queued = lines.shift();\n\t\tif (queued !== undefined) {\n\t\t\tif (!interactive) {\n\t\t\t\toutput.write(`${queued}\\n`);\n\t\t\t}\n\t\t\treturn Promise.resolve(queued);\n\t\t}\n\t\tif (closed) {\n\t\t\treturn Promise.reject(new Error(\"Input ended before all questions were answered.\"));\n\t\t}\n\t\treturn new Promise((resolve, reject) => {\n\t\t\twaiting = {\n\t\t\t\tresolve: (line: string): void => {\n\t\t\t\t\tif (!interactive) {\n\t\t\t\t\t\toutput.write(`${line}\\n`);\n\t\t\t\t\t}\n\t\t\t\t\tresolve(line);\n\t\t\t\t},\n\t\t\t\treject,\n\t\t\t};\n\t\t});\n\t};\n\n\tconst ask: Prompter[\"ask\"] = async (question, options = {}) => {\n\t\tconst suffix = options.defaultValue ? ` (${options.defaultValue})` : \"\";\n\t\tfor (;;) {\n\t\t\tconst raw = (await readLine(`? ${question}${suffix}: `)).trim();\n\t\t\tconst answer = raw === \"\" ? (options.defaultValue ?? \"\") : raw;\n\t\t\tconst error = options.validate?.(answer);\n\t\t\tif (error === undefined) {\n\t\t\t\treturn answer;\n\t\t\t}\n\t\t\toutput.write(` ${error}\\n`);\n\t\t}\n\t};\n\n\treturn {\n\t\task,\n\t\tasync choose(question, choices, defaultValue) {\n\t\t\toutput.write(`? ${question}\\n`);\n\t\t\tchoices.forEach((choice, index) => {\n\t\t\t\toutput.write(` ${index + 1}) ${choice.label}${choice.value === defaultValue ? \" (default)\" : \"\"}\\n`);\n\t\t\t});\n\t\t\tconst answer = await ask(\"Choose a number\", {\n\t\t\t\tdefaultValue: String(choices.findIndex((choice) => choice.value === defaultValue) + 1),\n\t\t\t\tvalidate: (value) => (pick(choices, value) ? undefined : `Enter a number from 1 to ${choices.length}.`),\n\t\t\t});\n\t\t\treturn (pick(choices, answer) ?? choices[0]).value;\n\t\t},\n\t\tasync confirm(question, defaultValue) {\n\t\t\tconst answer = await ask(`${question} ${defaultValue ? \"(Y/n)\" : \"(y/N)\"}`, {\n\t\t\t\tvalidate: (value) => (value === \"\" || /^(y|yes|n|no)$/i.test(value) ? undefined : \"Answer y or n.\"),\n\t\t\t});\n\t\t\treturn answer === \"\" ? defaultValue : /^y/i.test(answer);\n\t\t},\n\t\tclose() {\n\t\t\trl.close();\n\t\t},\n\t};\n}\n\nfunction pick<T extends string>(choices: readonly Choice<T>[], answer: string): Choice<T> | undefined {\n\tconst index = Number(answer);\n\tif (Number.isInteger(index) && index >= 1 && index <= choices.length) {\n\t\treturn choices[index - 1];\n\t}\n\treturn choices.find((choice) => choice.value.toLowerCase() === answer.toLowerCase());\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { mkdir, readFile, rename, rm, writeFile } from \"node:fs/promises\";\nimport { dirname, isAbsolute, resolve } from \"node:path\";\n\nimport { accessToken, clientCredentials, jwtBearer } from \"../auth/providers\";\nimport { sfCli } from \"../auth/sf-cli\";\nimport type { AuthProvider } from \"../auth/types\";\nimport { SalesforceClient } from \"../client\";\nimport type { ApiVersion } from \"../types/common\";\nimport type { DescribeSObjectResult } from \"../types/describe\";\n\nimport type { CodegenAuth, CodegenConfig, EnvJwtBearerAuth } from \"./config\";\nimport { type CodegenDescribe, type GeneratedFileHashes, generateSource, readGeneratedHashes } from \"./generator\";\nimport { validateConfig } from \"./validate-config\";\n\nexport { defineConfig } from \"./config\";\nexport type {\n\tCodegenAuth,\n\tCodegenConfig,\n\tEnvAuth,\n\tJsonCodegenConfig,\n\tEnvAccessTokenAuth,\n\tEnvClientCredentialsAuth,\n\tEnvJwtBearerAuth,\n\tPicklistMode,\n\tSfCliAuth,\n} from \"./config\";\nexport { generateSource, readGeneratedHashes } from \"./generator\";\nexport type { CodegenDescribe, GeneratedFileHashes, GenerateSourceOptions } from \"./generator\";\nexport { FIELD_TYPE_MAP, mapFieldType } from \"./type-mapper\";\nexport type { CodegenField } from \"./type-mapper\";\nexport { CONFIG_FILE_NAMES, findConfigFile, findConfigFiles, loadConfig } from \"./load-config\";\nexport { AUTH_OPTIONS, CONFIG_OPTIONS, CodegenConfigError, validateConfig } from \"./validate-config\";\nexport { AUTH_ENV_VARS, parseSObjects, renderConfig, runInit } from \"./init\";\nexport type { InitAnswers, InitAuthType, InitConfigFormat, InitOptions, InitResult } from \"./init\";\nexport { readlinePrompter } from \"./prompter\";\nexport type { Choice, Prompter } from \"./prompter\";\n\nexport interface CodegenLogger {\n\tinfo(message: string): void;\n\twarn(message: string): void;\n}\n\nexport interface GenerateOptions {\n\t/** Directory that `output` is resolved against. Defaults to `process.cwd()`. */\n\tcwd?: string;\n\tlogger?: CodegenLogger;\n\t/** Environment to read credentials from. Defaults to `process.env`. */\n\tenv?: Record<string, string | undefined>;\n\t/** Write the file. Defaults to `true`; with `false` the source is only returned. */\n\twrite?: boolean;\n}\n\nexport interface GenerateResult {\n\toutputPath: string;\n\t/** The concrete API version the types were generated with. */\n\tapiVersion: ApiVersion;\n\tsobjects: string[];\n\tskipped: { name: string; error: string }[];\n\t/** The generated source (after the `format` hook). */\n\tsource: string;\n\t/** SHA-256 of the unformatted content, as recorded in the file header. */\n\tcontentHash: string;\n}\n\nexport interface CheckResult {\n\t/** `true` when the file on disk has the same content (formatting differences are ignored). */\n\tupToDate: boolean;\n\t/** Why the file is out of date. */\n\treason?: \"missing\" | \"changed\";\n\toutputPath: string;\n\t/** sObjects that would be added, removed or changed (known when the file has hash headers). */\n\tadded: string[];\n\tremoved: string[];\n\tchanged: string[];\n}\n\nconst silentLogger: CodegenLogger = { info: () => undefined, warn: () => undefined };\n\n/** Describes the configured sObjects and writes the generated types to `config.output`. */\nexport async function generate(input: CodegenConfig, options: GenerateOptions = {}): Promise<GenerateResult> {\n\tconst logger = options.logger ?? silentLogger;\n\tconst built = await buildSource(input, options);\n\tconst { config } = built;\n\tlet source = built.raw;\n\tif (config.format) {\n\t\tsource = await config.format(source, built.outputPath);\n\t}\n\tif (options.write !== false) {\n\t\tawait writeAtomically(built.outputPath, source);\n\t\tlogger.info(`Wrote ${built.sobjects.length} sObject type(s) to ${built.outputPath}`);\n\t}\n\tconst { contentHash } = readGeneratedHashes(built.raw) as GeneratedFileHashes;\n\treturn {\n\t\toutputPath: built.outputPath,\n\t\tapiVersion: config.apiVersion,\n\t\tsobjects: built.sobjects,\n\t\tskipped: built.skipped,\n\t\tsource,\n\t\tcontentHash,\n\t};\n}\n\n/**\n * Checks whether the generated file on disk is up to date with the org, without writing it.\n * Only content counts: a file reformatted by Prettier, oxfmt or the `format` hook is up to date.\n */\nexport async function checkGenerated(input: CodegenConfig, options: GenerateOptions = {}): Promise<CheckResult> {\n\tconst built = await buildSource(input, options);\n\tconst empty = { outputPath: built.outputPath, added: [], removed: [], changed: [] };\n\tif (!existsSync(built.outputPath)) {\n\t\treturn { ...empty, upToDate: false, reason: \"missing\" };\n\t}\n\tconst existing = await readFile(built.outputPath, \"utf8\");\n\tconst expected = readGeneratedHashes(built.raw) as GeneratedFileHashes;\n\tconst actual = readGeneratedHashes(existing);\n\tif (!actual) {\n\t\t// Older files have no hash header: compare content, ignoring formatting.\n\t\tconst upToDate = normalizeSource(existing) === normalizeSource(built.raw);\n\t\treturn { ...empty, upToDate, reason: upToDate ? undefined : \"changed\" };\n\t}\n\tif (actual.contentHash === expected.contentHash) {\n\t\treturn { ...empty, upToDate: true };\n\t}\n\treturn { ...empty, upToDate: false, reason: \"changed\", ...diffObjects(actual.sobjects, expected.sobjects) };\n}\n\nasync function buildSource(\n\tinput: CodegenConfig,\n\toptions: GenerateOptions,\n): Promise<{\n\tconfig: CodegenConfig;\n\toutputPath: string;\n\traw: string;\n\tsobjects: string[];\n\tskipped: GenerateResult[\"skipped\"];\n}> {\n\tconst config = validateConfig(input, { source: \"generate()\" });\n\tconst { apiVersion } = config;\n\tconst logger = options.logger ?? silentLogger;\n\tconst env = options.env ?? process.env;\n\tconst outputPath = isAbsolute(config.output) ? config.output : resolve(options.cwd ?? process.cwd(), config.output);\n\n\tconst client = new SalesforceClient({\n\t\tauth: resolveAuth(config.auth, env),\n\t\tapiVersion,\n\t\ttransport: config.transport,\n\t\tretry: true,\n\t});\n\n\tconst names = await resolveSObjectNames(client, config, logger);\n\tlogger.info(`Describing ${names.length} sObject(s) with API ${apiVersion}...`);\n\tconst { describes, skipped } = await describeAll(client, names, config, logger);\n\n\tconst raw = generateSource(describes, {\n\t\texcludeCreateFields: config.excludeCreateFields,\n\t\texcludeUpdateFields: config.excludeUpdateFields,\n\t\tpicklists: config.picklists,\n\t\tconstants: config.constants,\n\t\timportSource: config.importSource,\n\t\tapiVersion,\n\t});\n\treturn { config, outputPath, raw, sobjects: describes.map((describe) => describe.name).sort(), skipped };\n}\n\nfunction diffObjects(\n\tactual: ReadonlyMap<string, string>,\n\texpected: ReadonlyMap<string, string>,\n): Pick<CheckResult, \"added\" | \"removed\" | \"changed\"> {\n\treturn {\n\t\tadded: [...expected.keys()].filter((name) => !actual.has(name)),\n\t\tremoved: [...actual.keys()].filter((name) => !expected.has(name)),\n\t\tchanged: [...expected.entries()]\n\t\t\t.filter(([name, hash]) => actual.has(name) && actual.get(name) !== hash)\n\t\t\t.map(([name]) => name),\n\t};\n}\n\n/** Strips comments, whitespace, quote style, semicolons and commas, so only content remains. */\nfunction normalizeSource(source: string): string {\n\tlet result = \"\";\n\tlet index = 0;\n\twhile (index < source.length) {\n\t\tconst char = source[index];\n\t\tconst next = source[index + 1];\n\t\tif (char === '\"' || char === \"'\") {\n\t\t\t// Keep the string's content exactly; only the quote style is normalised.\n\t\t\tlet end = index + 1;\n\t\t\twhile (end < source.length && source[end] !== char) {\n\t\t\t\tend += source[end] === \"\\\\\" ? 2 : 1;\n\t\t\t}\n\t\t\tresult += `\"${source\n\t\t\t\t.slice(index + 1, end)\n\t\t\t\t.replace(/\\\\'/g, \"'\")\n\t\t\t\t.replace(/\"/g, '\\\\\"')}\"`;\n\t\t\tindex = end + 1;\n\t\t} else if (char === \"/\" && next === \"/\") {\n\t\t\tindex = source.indexOf(\"\\n\", index) === -1 ? source.length : source.indexOf(\"\\n\", index);\n\t\t} else if (char === \"/\" && next === \"*\") {\n\t\t\tconst end = source.indexOf(\"*/\", index + 2);\n\t\t\tindex = end === -1 ? source.length : end + 2;\n\t\t} else {\n\t\t\tif (!/[\\s;,]/.test(char)) {\n\t\t\t\tresult += char;\n\t\t\t}\n\t\t\tindex++;\n\t\t}\n\t}\n\treturn result;\n}\n\n/** Turns the config's auth setting into an auth provider, reading env-based credentials. */\nexport function resolveAuth(auth: CodegenAuth | undefined, env: Record<string, string | undefined>): AuthProvider {\n\tconst setting = auth ?? { type: \"clientCredentials\" };\n\tif (\"getToken\" in setting) {\n\t\treturn setting;\n\t}\n\tconst read = (name: string): string => {\n\t\tconst value = env[name];\n\t\tif (!value) {\n\t\t\tthrow new Error(`Environment variable ${name} is not set.`);\n\t\t}\n\t\treturn value;\n\t};\n\tswitch (setting.type) {\n\t\tcase \"accessToken\":\n\t\t\treturn accessToken({\n\t\t\t\taccessToken: read(setting.accessTokenEnv ?? \"SF_ACCESS_TOKEN\"),\n\t\t\t\tinstanceUrl: read(setting.instanceUrlEnv ?? \"SF_INSTANCE_URL\"),\n\t\t\t});\n\t\tcase \"jwtBearer\":\n\t\t\treturn jwtBearerFromEnv(setting, env, read);\n\t\tcase \"sfCli\":\n\t\t\treturn sfCli({ targetOrg: setting.targetOrg });\n\t\tcase \"clientCredentials\":\n\t\t\treturn clientCredentials({\n\t\t\t\tloginUrl: read(setting.loginUrlEnv ?? \"SF_LOGIN_URL\"),\n\t\t\t\tclientId: read(setting.clientIdEnv ?? \"SF_CLIENT_ID\"),\n\t\t\t\tclientSecret: read(setting.clientSecretEnv ?? \"SF_CLIENT_SECRET\"),\n\t\t\t});\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown codegen auth type \"${(setting as { type: string }).type}\".`);\n\t}\n}\n\nfunction jwtBearerFromEnv(\n\tsetting: EnvJwtBearerAuth,\n\tenv: Record<string, string | undefined>,\n\tread: (name: string) => string,\n): AuthProvider {\n\tconst keyEnv = setting.privateKeyEnv ?? \"SF_PRIVATE_KEY\";\n\tconst privateKey = env[keyEnv]\n\t\t? read(keyEnv)\n\t\t: readFileSync(read(setting.privateKeyPathEnv ?? \"SF_PRIVATE_KEY_PATH\"), \"utf8\");\n\treturn jwtBearer({\n\t\tloginUrl: read(setting.loginUrlEnv ?? \"SF_LOGIN_URL\"),\n\t\tclientId: read(setting.clientIdEnv ?? \"SF_CLIENT_ID\"),\n\t\tusername: read(setting.usernameEnv ?? \"SF_USERNAME\"),\n\t\tprivateKey,\n\t});\n}\n\nasync function resolveSObjectNames(\n\tclient: SalesforceClient,\n\tconfig: CodegenConfig,\n\tlogger: CodegenLogger,\n): Promise<string[]> {\n\t// sObject names are case-insensitive in Salesforce.\n\tconst exclude = new Set((config.exclude ?? []).map((name) => name.toLowerCase()));\n\tif (config.sobjects && config.sobjects.length > 0) {\n\t\tconst unique = new Map<string, string>();\n\t\tfor (const name of config.sobjects) {\n\t\t\tif (!unique.has(name.toLowerCase())) {\n\t\t\t\tunique.set(name.toLowerCase(), name);\n\t\t\t}\n\t\t}\n\t\treturn [...unique.entries()].filter(([key]) => !exclude.has(key)).map(([, name]) => name);\n\t}\n\tlogger.warn(\"No `sobjects` configured: generating every queryable sObject. Consider an explicit list.\");\n\tconst global = await client.describeGlobal();\n\treturn global.sobjects\n\t\t.filter((sobject) => sobject.queryable && !sobject.deprecatedAndHidden && !exclude.has(sobject.name.toLowerCase()))\n\t\t.map((sobject) => sobject.name);\n}\n\nasync function describeAll(\n\tclient: SalesforceClient,\n\tnames: readonly string[],\n\tconfig: CodegenConfig,\n\tlogger: CodegenLogger,\n): Promise<{ describes: CodegenDescribe[]; skipped: GenerateResult[\"skipped\"] }> {\n\tconst concurrency = Math.max(1, config.concurrency ?? 10);\n\tconst describes: CodegenDescribe[] = [];\n\tconst skipped: GenerateResult[\"skipped\"] = [];\n\tlet next = 0;\n\tlet done = 0;\n\t// Stops the other workers (and their in-flight requests) once one describe has failed.\n\tconst failed = new AbortController();\n\n\tconst worker = async (): Promise<void> => {\n\t\twhile (next < names.length && !failed.signal.aborted) {\n\t\t\tconst name = names[next++];\n\t\t\ttry {\n\t\t\t\tconst describe: DescribeSObjectResult = await client.sobject(name).describe({ signal: failed.signal });\n\t\t\t\tdescribes.push(describe);\n\t\t\t} catch (error) {\n\t\t\t\tif (failed.signal.aborted) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\tif (!config.continueOnDescribeError) {\n\t\t\t\t\tfailed.abort();\n\t\t\t\t\tthrow new Error(`Describing sObject \"${name}\" failed: ${message}`, { cause: error });\n\t\t\t\t}\n\t\t\t\tlogger.warn(`Skipping sObject \"${name}\": ${message}`);\n\t\t\t\tskipped.push({ name, error: message });\n\t\t\t}\n\t\t\tdone++;\n\t\t\tif (done % 10 === 0 || done === names.length) {\n\t\t\t\tlogger.info(`Described ${done}/${names.length} sObject(s)`);\n\t\t\t}\n\t\t}\n\t};\n\n\tawait Promise.all(Array.from({ length: Math.min(concurrency, names.length) }, () => worker()));\n\t// Two configured names can resolve to the same sObject (e.g. a different case): keep one.\n\tconst unique = new Map(describes.map((describe) => [describe.name, describe] as const));\n\treturn { describes: [...unique.values()], skipped };\n}\n\nasync function writeAtomically(filePath: string, content: string): Promise<void> {\n\tawait mkdir(dirname(filePath), { recursive: true });\n\tconst temporary = `${filePath}.${process.pid}.${Date.now()}.tmp`;\n\ttry {\n\t\tawait writeFile(temporary, content, \"utf8\");\n\t\tawait renameWithRetry(temporary, filePath);\n\t} catch (error) {\n\t\tawait rm(temporary, { force: true });\n\t\tthrow error;\n\t}\n}\n\n/** On Windows a virus scanner or indexer can briefly lock the target file; retry a few times. */\nasync function renameWithRetry(from: string, to: string): Promise<void> {\n\tfor (let attempt = 1; ; attempt++) {\n\t\ttry {\n\t\t\tawait rename(from, to);\n\t\t\treturn;\n\t\t} catch (error) {\n\t\t\tconst code = (error as NodeJS.ErrnoException).code;\n\t\t\tif (attempt >= 5 || (code !== \"EPERM\" && code !== \"EBUSY\" && code !== \"EACCES\")) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 50 * attempt));\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;AAuDA,SAAgB,aAAa,OAAqB,YAA0B,SAAiB;CAC5F,MAAM,OAAO,aAAa,OAAO,SAAS,KAAK,eAAe,MAAM,SAAS;CAC7E,OAAO,MAAM,YAAY,SAAS,YAAY,GAAG,KAAK,WAAW;AAClE;AAEA,SAAS,aAAa,OAAqB,WAA6C;CACvF,IAAI,cAAc,WAAY,MAAM,SAAS,cAAc,MAAM,SAAS,YACzE;CAED,MAAM,SAAS,CAAC,GAAG,IAAI,KAAK,MAAM,kBAAkB,CAAC,EAAA,CAAG,QAAQ,UAAU,MAAM,MAAM,CAAC,CAAC,KAAK,UAAU,MAAM,KAAK,CAAC,CAAC;CACpH,IAAI,OAAO,WAAW,GACrB;CAED,MAAM,QAAQ,OAAO,KAAK,UAAU,KAAK,UAAU,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK;CACrE,OAAO,MAAM,sBAAsB,MAAM,SAAS,aAAa,QAAQ,GAAG,MAAM;AACjF;;;CAnDa,eAAe;CACf,mBAAmB;CAGnB,iBAAmD;EAC/D,SAAS;EACT,KAAK;EACL,MAAM;EACN,QAAQ;EACR,UAAU;EACV,SAAS;;EAET,MAAM;;EAEN,UAAU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