1- # ` apollo- reporting- protobuf`
1+ # Usage reporting protobuf
22
33> ** Note:** The Apollo usage reporting API is subject to change. We strongly
44> encourage developers to contact Apollo support at ` [email protected] ` 55> to discuss their use case prior to building their own reporting agent using
66> this module.
77
8- This module provides JavaScript/TypeScript
9- [ Protocol buffer] ( https://developers.google.com/protocol-buffers/ ) definitions
10- for the Apollo usage reporting API. These definitions are generated for
11- consumption from the ` reports.proto ` file which is defined internally within
12- Apollo.
8+ This subdirectory provides JavaScript/TypeScript [ Protocol
9+ buffer] ( https://developers.google.com/protocol-buffers/ ) definitions for the
10+ Apollo usage reporting API. These definitions are generated for consumption
11+ from the ` reports.proto ` file which is defined internally within Apollo.
1312
1413## Development
1514
@@ -18,22 +17,25 @@ Apollo.
1817> this can't be avoided, the time just hasn't been taken to make those changes.
1918> We'd happily accept a PR which makes the appropriate changes!
2019
21- Currently, this package generates a majority of its code with
20+ This directory contains .js and .d.ts files. The index files are written
21+ manually and the files in ` generated ` are automatically generated with
2222` @apollo/protobufjs ` (a fork of
2323[ ` protobufjs ` ] ( https://www.npmjs.com/package/protobufjs ) that we maintain
24- specifically for this package) based on the ` reports.proto ` file. The output is
25- generated with the ` generate ` npm script.
26-
27- The root of the repository provides some ` devDependencies ` necessary to build
28- these definitions and the ` prepare ` npm script is invoked programmatically via
29- the monorepo tooling (e.g. Lerna) thanks to _ this_ module's ` postinstall `
30- script. Therefore, when making changes to this module, run scripts via `npx
31- lerna run SCRIPTNAME` in the ** root** of this monorepo in order to update the
32- definitions in _ this_ module.
24+ specifically for this package) based on the ` reports.proto ` file. None of these
25+ files are generated from .ts files by tsc, which is why this directory is not
26+ under ` src ` .
3327
3428To update ` reports.proto ` to the current version recognized by the Studio usage
35- reporting ingress, run ` lerna run update-proto ` . To then regenerate the JS and
36- TS files, run ` npx lerna run generate` . We check in the generated code and only
29+ reporting ingress, run ` npm run protobuf-update ` . To then regenerate the JS and
30+ TS files, run ` npm run protobuf- generate` . We check in the generated code and only
3731regenerate it manually, partially to make builds faster (no need to run pbjs on
3832every ` npm install ` ) and partially so that we don't have to make sure that
3933` pbjs ` runs on every Node version that we support.
34+
35+ The files in this subdirectory are large, so we want to avoid loading them at
36+ runtime unless necessary. Thus, files in this directory should only be imported
37+ in three contexts:
38+ - Inside ` src/plugin ` , in files that will only be loaded indirectly via the
39+ runtime require calls in ` src/plugin/index.ts `
40+ - In tests
41+ - At compile-time only via ` import type ` calls
0 commit comments