{"id":16981781,"url":"https://github.com/cesarparra/apex-reflection","last_synced_at":"2026-01-05T15:15:53.888Z","repository":{"id":43047015,"uuid":"407926789","full_name":"cesarParra/apex-reflection","owner":"cesarParra","description":"Basic reflection for the Apex programming language.","archived":false,"fork":false,"pushed_at":"2025-03-21T15:30:52.000Z","size":23133,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-07T04:44:12.978Z","etag":null,"topics":["apex","dart","dartlang","nodejs","npm","reflection","salesforce"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@cparra/apex-reflection","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cesarParra.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-18T17:37:50.000Z","updated_at":"2025-03-21T15:30:23.000Z","dependencies_parsed_at":"2023-01-30T08:46:36.764Z","dependency_job_id":"d1db5047-ef65-42b2-9c02-ff2e758fe4cd","html_url":"https://github.com/cesarParra/apex-reflection","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cesarParra%2Fapex-reflection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cesarParra%2Fapex-reflection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cesarParra%2Fapex-reflection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cesarParra%2Fapex-reflection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cesarParra","download_url":"https://codeload.github.com/cesarParra/apex-reflection/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248505921,"owners_count":21115354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apex","dart","dartlang","nodejs","npm","reflection","salesforce"],"created_at":"2024-10-14T02:06:26.824Z","updated_at":"2026-01-05T15:15:53.882Z","avatar_url":"https://github.com/cesarParra.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Apex Reflection\n\nProvides basic reflection for the Apex programming language.\n\n## Installation\n\n```\nnpm i @cparra/apex-reflection\n```\n\n## Usage\n\nThis library exposes a single function that handles parsing the body of an Apex top level type (class, interface, or\nenum)\nand returns the result.\n\n```typescript\nimport {reflect} from '@cparra/apex-reflection';\n\nconst classBody = 'public with sharing class ExampleClass {}';\nconst response = reflect(classBody);\n```\n\nIf you wish to parse an Apex type that comes from a file, you can read the file contents and use that as the source to\nreflect\n\n```typescript\nimport * as fs from 'fs';\nimport {reflect} from '@cparra/apex-reflection';\n\nconst path = './MyClass.cls';\nconst rawFile = fs.readFileSync(path);\nconst response = reflect(rawFile.toString());\n```\n\nThe `reflect` function returns a `ReflectionResult` which contains either the results of the parsed `Type`\n(which will either be a `ClassMirror`, an `InterfaceMirror` or an `EnumMirror`) or a `ParsingError` if the passed in\nbody was not parsed successfully, with a message indicating where the error occurred.\n\n## Contributing\n\nEven though this library is exposed as a Node.js library, the project's source code is written in Dart. The source can\nbe found in the `lib/src` directory.\n\n### Tests\n\nBoth the Dart source code and the JS output must be tested.\n\nThe Dart tests live in the `test` directory. The Dart source code must have unit tests testing each individual Dart file\nas well as end-to-end tests that verify the overall parsing functionality.\n\nThe JS tests live in `js/apex-reflection-node/__tests__`. These are end-to-end tests that ensure that the transpiled JS\ncode is working as intended.\n\n### JSON serialization\n\nThe reflection operation outputs a JSON representation of the Apex type, which is then deserialized on the JS side to\nreturn typed objects.\n\nSerialization is handled through the [json_serializable](https://pub.dev/packages/json_serializable) package, which\nhelps automatically create the round-trip code for serialization and de-serialization.\n\nWhen changing any of the model classes with serialization support, to re-build the serialization code run\n\n```shell\ndart run build_runner build\n```\n\nTo keep the runner live by watching any modifications to files, run\n\n```shell\ndart run build_runner watch\n```\n\n### Parsing\n\nThe parsing algorithm relies on using ANTLR4 and its Dart target. \n\nTo generate the Antlr4 **Apex** output run:\n\n```shell\njava org.antlr.v4.Tool -Dlanguage=Dart lib/src/antlr/grammars/apex/ApexLexer.g4 lib/src/antlr/grammars/apex/ApexParser.g4\n```\n\nTo generate the Antlr4 **Apexdoc** output run:\n\n```shell\njava org.antlr.v4.Tool -Dlanguage=Dart lib/src/antlr/grammars/apexdoc/ApexdocLexer.g4 lib/src/antlr/grammars/apexdoc/ApexdocParser.g4\n```\n\n## Typescript\n\nThis library provides its own TS type definition.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcesarparra%2Fapex-reflection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcesarparra%2Fapex-reflection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcesarparra%2Fapex-reflection/lists"}