@powerhousedao/codegen 3.3.0-dev.10 → 3.3.0-dev.12
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/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/index.esm.t +0 -2
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-operational/factory.esm.t +27 -5
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-operational/index.esm.t +13 -18
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-operational/migrations.esm.t +3 -3
- package/dist/src/codegen/kysely.js +1 -1
- package/dist/src/codegen/kysely.js.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +5 -5
package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-operational/factory.esm.t
CHANGED
|
@@ -2,16 +2,38 @@
|
|
|
2
2
|
to: "<%= rootDir %>/<%= h.changeCase.param(name) %>/factory.ts"
|
|
3
3
|
force: true
|
|
4
4
|
---
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import {
|
|
6
|
+
type ProcessorRecord,
|
|
7
|
+
type IProcessorHostModule
|
|
8
|
+
} from "document-drive/processors/types";
|
|
9
|
+
import {
|
|
10
|
+
type RelationalDbProcessorFilter,
|
|
11
|
+
} from "document-drive/processors/relational";
|
|
7
12
|
import { <%= pascalName %>Processor } from "./index.js";
|
|
8
13
|
|
|
9
|
-
export const <%= h.changeCase.camel(name) %>ProcessorFactory = (module: IProcessorHostModule) => (driveId: string): ProcessorRecord[] => {
|
|
10
|
-
|
|
14
|
+
export const <%= h.changeCase.camel(name) %>ProcessorFactory = (module: IProcessorHostModule) => async (driveId: string): Promise<ProcessorRecord[]> => {
|
|
15
|
+
// Create a namespace for the processor and the provided drive id
|
|
16
|
+
const namespace = <%= pascalName %>Processor.getNamespace(driveId);
|
|
17
|
+
|
|
18
|
+
// Create a filter for the processor
|
|
19
|
+
const filter: RelationalDbProcessorFilter = {
|
|
20
|
+
branch: ["main"],
|
|
21
|
+
documentId: ["*"],
|
|
22
|
+
documentType: [<% if(documentTypes.length) { %><%- documentTypes.map(type => `"${type}"`).join(", ") %><% } else { %>"*"<% } %>],
|
|
23
|
+
scope: ["global"],
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// Create a namespaced db for the processor
|
|
27
|
+
const store = await module.relationalDb.createNamespacedDb<<%= pascalName %>Processor>(
|
|
28
|
+
namespace,
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
// Create the processor
|
|
32
|
+
const processor = new <%= pascalName %>Processor(namespace, filter, store);
|
|
11
33
|
return [
|
|
12
34
|
{
|
|
13
35
|
processor,
|
|
14
|
-
filter
|
|
36
|
+
filter,
|
|
15
37
|
},
|
|
16
38
|
];
|
|
17
39
|
}
|
package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-operational/index.esm.t
CHANGED
|
@@ -2,33 +2,29 @@
|
|
|
2
2
|
to: "<%= rootDir %>/<%= h.changeCase.param(name) %>/index.ts"
|
|
3
3
|
force: true
|
|
4
4
|
---
|
|
5
|
-
import { type
|
|
6
|
-
import {
|
|
5
|
+
import { type IRelationalDb } from "document-drive/processors/types";
|
|
6
|
+
import { RelationalDbProcessor } from "document-drive/processors/relational";
|
|
7
7
|
import { type InternalTransmitterUpdate } from "document-drive/server/listener/transmitter/internal";
|
|
8
|
-
import { up } from "./migrations.js";
|
|
9
|
-
import { type DB } from "./schema.js";
|
|
10
8
|
<% documentTypes.forEach(type => { _%>
|
|
11
9
|
import type { <%= documentTypesMap[type].name %>Document } from "<%= documentTypesMap[type].importPath %>/index.js";
|
|
12
10
|
%><% }); _%>
|
|
13
11
|
<% if(documentTypes.length === 0) { %>import { type PHDocument } from "document-model";<% } %>
|
|
14
|
-
|
|
12
|
+
import { up } from "./migrations.js";
|
|
13
|
+
import { type DB } from "./schema.js";
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
type DocumentType = <% if(documentTypes.length) { %><%= documentTypes.map(type => `${documentTypesMap[type].name}Document`).join(" | ") %> <% } else { %>PHDocument<% } %>;
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
documentType: [<% if(documentTypes.length) { %><%- documentTypes.map(type => `"${type}"`).join(", ") %><% } else { %>"*"<% } %>],
|
|
23
|
-
scope: ["global"],
|
|
24
|
-
}
|
|
17
|
+
export class <%= pascalName %>Processor extends RelationalDbProcessor<DB> {
|
|
18
|
+
static override getNamespace(driveId: string): string {
|
|
19
|
+
// Default namespace: `${this.name}_${driveId.replaceAll("-", "_")}`
|
|
20
|
+
return super.getNamespace(driveId);
|
|
25
21
|
}
|
|
26
22
|
|
|
27
|
-
async initAndUpgrade(): Promise<void> {
|
|
28
|
-
await up(this.
|
|
23
|
+
override async initAndUpgrade(): Promise<void> {
|
|
24
|
+
await up(this.relationalDb as IRelationalDb);
|
|
29
25
|
}
|
|
30
26
|
|
|
31
|
-
async onStrands(
|
|
27
|
+
override async onStrands(
|
|
32
28
|
strands: InternalTransmitterUpdate<DocumentType>[],
|
|
33
29
|
): Promise<void> {
|
|
34
30
|
if (strands.length === 0) {
|
|
@@ -41,8 +37,7 @@ export class <%= pascalName %>Processor extends OperationalProcessor<DB> {
|
|
|
41
37
|
}
|
|
42
38
|
|
|
43
39
|
for (const operation of strand.operations) {
|
|
44
|
-
|
|
45
|
-
await this.operationalStore
|
|
40
|
+
await this.relationalDb
|
|
46
41
|
.insertInto("todo")
|
|
47
42
|
.values({
|
|
48
43
|
task: strand.documentId,
|
package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-operational/migrations.esm.t
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
to: "<%= rootDir %>/<%= h.changeCase.param(name) %>/migrations.ts"
|
|
3
3
|
force: true
|
|
4
4
|
---
|
|
5
|
-
import { type
|
|
5
|
+
import { type IRelationalDb } from "document-drive/processors/types"
|
|
6
6
|
|
|
7
|
-
export async function up(db:
|
|
7
|
+
export async function up(db: IRelationalDb<any>): Promise<void> {
|
|
8
8
|
// Create table
|
|
9
9
|
await db.schema
|
|
10
10
|
.createTable("todo")
|
|
@@ -17,7 +17,7 @@ export async function up(db: IOperationalStore): Promise<void> {
|
|
|
17
17
|
.execute();
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export async function down(db:
|
|
20
|
+
export async function down(db: IRelationalDb<any>): Promise<void> {
|
|
21
21
|
// drop table
|
|
22
22
|
await db.schema.dropTable("todo").execute();
|
|
23
23
|
}
|
|
@@ -28,7 +28,7 @@ export async function generateDBSchema({ migrationFile, schemaFile, }) {
|
|
|
28
28
|
console.log(`Schema types generated at ${outFile}`);
|
|
29
29
|
}
|
|
30
30
|
catch (error) {
|
|
31
|
-
console.error("Error running
|
|
31
|
+
console.error("Error running migration:", error);
|
|
32
32
|
throw error;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kysely.js","sourceRoot":"","sources":["../../../src/codegen/kysely.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,SAAS,UAAU,CACjB,OAAe,EACf,IAAc,EACd,GAAY;IAEZ,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE;YACjC,GAAG;YACH,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,IAAI;SACZ,CAAC,CAAC;QAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YACzB,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;gBACf,OAAO,EAAE,CAAC;YACZ,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,IAAI,KAAK,CAAC,iCAAiC,IAAI,EA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