@powerhousedao/academy 3.2.0-dev.6 → 3.2.0-dev.7
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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## 3.2.0-dev.7 (2025-06-28)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- starting to stub out a complete example of the analytics processor ([a84ed2dcf](https://github.com/powerhouse-inc/powerhouse/commit/a84ed2dcf))
|
|
6
|
+
|
|
7
|
+
### ❤️ Thank You
|
|
8
|
+
|
|
9
|
+
- Benjamin Jordan (@thegoldenmule)
|
|
10
|
+
|
|
1
11
|
## 3.2.0-dev.6 (2025-06-27)
|
|
2
12
|
|
|
3
13
|
### 🚀 Features
|
|
@@ -7,7 +7,7 @@ An Analytics Processor is an object that can track analytics for operations and
|
|
|
7
7
|
The `ph-cli` utility can be used to generate the scaffolding for an Analytics Processor.
|
|
8
8
|
|
|
9
9
|
```
|
|
10
|
-
|
|
10
|
+
ph generate -p MyAnalyticsProcessor --processor-type analytics
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
This will generate two files: a class that implements `IProcessor` and a `ProcessorFactory` function that creates an instance of your processor. We can start with the factory.
|
|
@@ -340,3 +340,91 @@ export class DriveProcessorProcessor implements IProcessor {
|
|
|
340
340
|
async onDisconnect() {}
|
|
341
341
|
}
|
|
342
342
|
```
|
|
343
|
+
|
|
344
|
+
## Learn by example: Contributor Billing
|
|
345
|
+
|
|
346
|
+
Here we have documented the entire development process for the contributor billing processor.
|
|
347
|
+
|
|
348
|
+
First, we setup the repository locally.
|
|
349
|
+
|
|
350
|
+
```
|
|
351
|
+
$ git clone git@github.com:powerhouse-inc/contributor-billing.git
|
|
352
|
+
$ cd contributor-billing
|
|
353
|
+
~/contributor-billing $ pnpm install
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
Now we can generate an analytics processor, using default settings.
|
|
357
|
+
|
|
358
|
+
```
|
|
359
|
+
~/contributor-billing $ ph generate -p LineItemProcessor --processor-type analytics
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
We can see what was generated:
|
|
363
|
+
|
|
364
|
+
```
|
|
365
|
+
~/contributor-billing $ tree processors
|
|
366
|
+
processors
|
|
367
|
+
├── index.ts
|
|
368
|
+
└── line-item-processor
|
|
369
|
+
└── index.ts
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
> Note that `processors/index.ts` will only be created if it does not already exist. In this case, you will be responsible for adding the processor to the `processorFactory` function.
|
|
373
|
+
|
|
374
|
+
### `IProcessorFactory`
|
|
375
|
+
|
|
376
|
+
Let's check out the generated `index.ts` file.
|
|
377
|
+
|
|
378
|
+
```ts
|
|
379
|
+
/**
|
|
380
|
+
* This is a scaffold file meant for customization.
|
|
381
|
+
* Delete the file and run the code generator again to have it reset
|
|
382
|
+
*/
|
|
383
|
+
|
|
384
|
+
import { ProcessorRecord } from "document-drive/processors/types";
|
|
385
|
+
import { LineItemProcessorProcessor } from "./line-item-processor/index.js";
|
|
386
|
+
|
|
387
|
+
export const processorFactory =
|
|
388
|
+
(module: any) =>
|
|
389
|
+
(driveId: string): ProcessorRecord[] => {
|
|
390
|
+
return [
|
|
391
|
+
{
|
|
392
|
+
processor: new LineItemProcessorProcessor(module.analyticsStore),
|
|
393
|
+
filter: {
|
|
394
|
+
branch: ["main"],
|
|
395
|
+
documentId: ["*"],
|
|
396
|
+
scope: ["*"],
|
|
397
|
+
documentType: ["*"],
|
|
398
|
+
},
|
|
399
|
+
},
|
|
400
|
+
];
|
|
401
|
+
};
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
This is described in more detail in the [ProcessorFactory](#processorfactory) section, but for our purposes, we only want our processor to run for our document type, so we should change the filter's `documentType`.
|
|
405
|
+
|
|
406
|
+
```ts
|
|
407
|
+
filter: {
|
|
408
|
+
branch: ["main"],
|
|
409
|
+
documentId: ["*"],
|
|
410
|
+
scope: ["*"],
|
|
411
|
+
documentType: ["powerhouse/billing-statement"],
|
|
412
|
+
},
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
### Data Design
|
|
416
|
+
|
|
417
|
+
Before we get into the meat of the processor, we need to design the data we're going to be working with.
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
### `IProcessor`
|
|
422
|
+
|
|
423
|
+
Now we can open up `line-item-processor/index.ts` to add the custom logic we're looking for. This will be in the `onStrands` function.
|
|
424
|
+
|
|
425
|
+
```ts
|
|
426
|
+
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
|