@powerhousedao/vetra 6.2.3-dev.1 → 6.2.3-dev.100
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/codegen/index.d.ts +30 -19
- package/dist/codegen/index.d.ts.map +1 -1
- package/dist/codegen/index.js +39 -34
- package/dist/codegen/index.js.map +1 -1
- package/dist/codegen/spec.d.ts +3 -2
- package/dist/codegen/spec.js +1 -1
- package/dist/{connect-qpJ9OUaH.js → connect-EqImHuZ2.js} +1 -1
- package/dist/{connect-qpJ9OUaH.js.map → connect-EqImHuZ2.js.map} +1 -1
- package/dist/document-models/app-module/index.d.ts +4 -12
- package/dist/document-models/app-module/index.js +4 -4
- package/dist/document-models/app-module/index.js.map +1 -1
- package/dist/document-models/document-editor/index.d.ts +4 -12
- package/dist/document-models/document-editor/index.js +4 -4
- package/dist/document-models/document-editor/index.js.map +1 -1
- package/dist/document-models/index.d.ts +7 -6
- package/dist/document-models/index.js +5 -5
- package/dist/document-models/processor-module/index.d.ts +4 -12
- package/dist/document-models/processor-module/index.js +5 -5
- package/dist/document-models/processor-module/index.js.map +1 -1
- package/dist/document-models/subgraph-module/index.d.ts +4 -12
- package/dist/document-models/subgraph-module/index.js +4 -4
- package/dist/document-models/subgraph-module/index.js.map +1 -1
- package/dist/document-models/vetra-package/index.d.ts +4 -12
- package/dist/document-models/vetra-package/index.js +3 -3
- package/dist/{editor-_0gdltOt.js → editor-BDR7IYJG.js} +5 -7
- package/dist/editor-BDR7IYJG.js.map +1 -0
- package/dist/{editor-CLbvu3pG.js → editor-CbT_8Z6A.js} +6 -8
- package/dist/editor-CbT_8Z6A.js.map +1 -0
- package/dist/{editor-CCdg1mJL.js → editor-CnfajXGg.js} +5 -7
- package/dist/{editor-CCdg1mJL.js.map → editor-CnfajXGg.js.map} +1 -1
- package/dist/{editor-Fgw7attg.js → editor-Cnk0M044.js} +70 -51
- package/dist/editor-Cnk0M044.js.map +1 -0
- package/dist/{editor-LRAwrgdQ.js → editor-D5SIbFn_.js} +10 -9
- package/dist/editor-D5SIbFn_.js.map +1 -0
- package/dist/{editor-C13SvgUy.js → editor-SJk7cr6k.js} +5 -7
- package/dist/editor-SJk7cr6k.js.map +1 -0
- package/dist/editors/components/index.d.ts +3 -3
- package/dist/editors/components/index.d.ts.map +1 -1
- package/dist/editors/components/index.js.map +1 -1
- package/dist/editors/hooks/index.d.ts +3 -3
- package/dist/editors/hooks/index.d.ts.map +1 -1
- package/dist/editors/hooks/index.js +1 -1
- package/dist/editors/index.d.ts +18 -8
- package/dist/editors/index.d.ts.map +1 -1
- package/dist/editors/index.js +1 -1
- package/dist/{factory-5eiZohiv.js → factory-BUuO4fIN.js} +12 -4
- package/dist/factory-BUuO4fIN.js.map +1 -0
- package/dist/{factory-DMl8eB3P.js → factory-GIkoxPdL.js} +16 -12
- package/dist/factory-GIkoxPdL.js.map +1 -0
- package/dist/{hooks-BIgFcbaF.js → hooks-BbxvC-C3.js} +2 -2
- package/dist/{hooks-BIgFcbaF.js.map → hooks-BbxvC-C3.js.map} +1 -1
- package/dist/index-BwHVZmO6.d.ts +43 -0
- package/dist/index-BwHVZmO6.d.ts.map +1 -0
- package/dist/{index-Dm_gN1DR.d.ts → index-C56rbYzd.d.ts} +27 -59
- package/dist/index-C56rbYzd.d.ts.map +1 -0
- package/dist/index-CDV0nUS6.d.ts +36 -0
- package/dist/index-CDV0nUS6.d.ts.map +1 -0
- package/dist/{index-f_um1g-i.d.ts → index-ChQj71kz.d.ts} +27 -62
- package/dist/index-ChQj71kz.d.ts.map +1 -0
- package/dist/index-CiPX7twW.d.ts +34 -0
- package/dist/index-CiPX7twW.d.ts.map +1 -0
- package/dist/{index-SB-AtQdU.d.ts → index-CqDvbSe4.d.ts} +31 -64
- package/dist/index-CqDvbSe4.d.ts.map +1 -0
- package/dist/index-DGhkn3As.d.ts +40 -0
- package/dist/index-DGhkn3As.d.ts.map +1 -0
- package/dist/index-DoopUfIG.d.ts +32 -0
- package/dist/index-DoopUfIG.d.ts.map +1 -0
- package/dist/{index-B5ijieNt.d.ts → index-RAhSmsFD.d.ts} +22 -55
- package/dist/index-RAhSmsFD.d.ts.map +1 -0
- package/dist/index.d.ts +56 -93
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +84 -12
- package/dist/index.js.map +1 -1
- package/dist/{logger-WHD0fyLm.js → logger-BFxMdimR.js} +1 -1
- package/dist/{logger-WHD0fyLm.js.map → logger-BFxMdimR.js.map} +1 -1
- package/dist/{module-CRq_lUkG.js → module-23VayWKe.js} +9 -9
- package/dist/module-23VayWKe.js.map +1 -0
- package/dist/{module-Chqkdq4U.js → module-2JZcvfVs.js} +3 -3
- package/dist/{module-Chqkdq4U.js.map → module-2JZcvfVs.js.map} +1 -1
- package/dist/{module-DXT-FMxU.js → module-B6S4QGOx.js} +7 -7
- package/dist/module-B6S4QGOx.js.map +1 -0
- package/dist/{module-bKT_e3CH.js → module-BktWa0rB.js} +11 -9
- package/dist/module-BktWa0rB.js.map +1 -0
- package/dist/{module-ciAK1LUC.d.ts → module-C-jL7yqs.d.ts} +38 -70
- package/dist/module-C-jL7yqs.d.ts.map +1 -0
- package/dist/{module-CRfHlbnq.js → module-FXJRy_1W.js} +2 -2
- package/dist/{module-CRfHlbnq.js.map → module-FXJRy_1W.js.map} +1 -1
- package/dist/{module-Bx1OEHxF.js → module-hLzF5tCL.js} +3 -3
- package/dist/{module-Bx1OEHxF.js.map → module-hLzF5tCL.js.map} +1 -1
- package/dist/{ph-factories-CjbIAMgT.js → ph-factories-Bgnr3mK3.js} +2 -2
- package/dist/{ph-factories-CjbIAMgT.js.map → ph-factories-Bgnr3mK3.js.map} +1 -1
- package/dist/{ph-factories-Ce8oAqs9.js → ph-factories-CgoFCmG0.js} +2 -2
- package/dist/{ph-factories-Ce8oAqs9.js.map → ph-factories-CgoFCmG0.js.map} +1 -1
- package/dist/{ph-factories-dVj6mIlR.js → ph-factories-DhLtvC7j.js} +2 -2
- package/dist/{ph-factories-dVj6mIlR.js.map → ph-factories-DhLtvC7j.js.map} +1 -1
- package/dist/{ph-factories-CljTAAVS.js → ph-factories-fEke-Nr8.js} +2 -2
- package/dist/{ph-factories-CljTAAVS.js.map → ph-factories-fEke-Nr8.js.map} +1 -1
- package/dist/powerhouse.manifest.json +76 -0
- package/dist/{processor-trJFuoHh.js → processor-Cb2shrDB.js} +436 -328
- package/dist/processor-Cb2shrDB.js.map +1 -0
- package/dist/processors/codegen/index.d.ts +14 -6
- package/dist/processors/codegen/index.d.ts.map +1 -1
- package/dist/processors/codegen/index.js +2 -2
- package/dist/processors/index.d.ts +2 -3
- package/dist/processors/index.d.ts.map +1 -1
- package/dist/processors/index.js +1 -1
- package/dist/processors/index.js.map +1 -1
- package/dist/processors/vetra-read-model/index.d.ts +47 -49
- package/dist/processors/vetra-read-model/index.d.ts.map +1 -1
- package/dist/processors/vetra-read-model/index.js +1 -1
- package/dist/{spec-api-DobY5TUJ.js → spec-api-BGj7gcQn.js} +24 -18
- package/dist/{spec-api-DobY5TUJ.js.map → spec-api-BGj7gcQn.js.map} +1 -1
- package/dist/{specs-BeVdfCwg.d.ts → specs-DoTSfuxN.d.ts} +7 -4
- package/dist/specs-DoTSfuxN.d.ts.map +1 -0
- package/dist/subgraph-type-lint-Dr8Wu0VB.js +94 -0
- package/dist/subgraph-type-lint-Dr8Wu0VB.js.map +1 -0
- package/dist/switchboard-DUSh_ScZ.js +8 -0
- package/dist/{switchboard-Bf0uvxSu.js.map → switchboard-DUSh_ScZ.js.map} +1 -1
- package/dist/{upgrade-manifest-OlS1ALVv.js → upgrade-manifest-BOZ5nmyK.js} +1 -1
- package/dist/{upgrade-manifest-OlS1ALVv.js.map → upgrade-manifest-BOZ5nmyK.js.map} +1 -1
- package/dist/{upgrade-manifest-BGuy0v65.js → upgrade-manifest-D7xKGmZc.js} +1 -1
- package/dist/{upgrade-manifest-BGuy0v65.js.map → upgrade-manifest-D7xKGmZc.js.map} +1 -1
- package/dist/{upgrade-manifest-Ck3Mgwhc.js → upgrade-manifest-DLxSL23q.js} +1 -1
- package/dist/{upgrade-manifest-Ck3Mgwhc.js.map → upgrade-manifest-DLxSL23q.js.map} +1 -1
- package/dist/{upgrade-manifest-XdOLymuP.js → upgrade-manifest-Dv62Cod7.js} +1 -1
- package/dist/{upgrade-manifest-XdOLymuP.js.map → upgrade-manifest-Dv62Cod7.js.map} +1 -1
- package/dist/{upgrade-manifest-NaS4SWk9.js → upgrade-manifest-d3LquK-H.js} +1 -1
- package/dist/{upgrade-manifest-NaS4SWk9.js.map → upgrade-manifest-d3LquK-H.js.map} +1 -1
- package/dist/{utils-DXCsvCXL.js → utils-876N1Sph.js} +2 -2
- package/dist/{utils-DXCsvCXL.js.map → utils-876N1Sph.js.map} +1 -1
- package/dist/{utils-CkxGmQ2_.js → utils-Al_SGg2a.js} +2 -2
- package/dist/{utils-CkxGmQ2_.js.map → utils-Al_SGg2a.js.map} +1 -1
- package/dist/{utils-DmOIDVQo.js → utils-BJk4_43W.js} +24 -4
- package/dist/utils-BJk4_43W.js.map +1 -0
- package/dist/{utils-B4KdjDnp.js → utils-COP7hJ-K.js} +2 -2
- package/dist/{utils-B4KdjDnp.js.map → utils-COP7hJ-K.js.map} +1 -1
- package/dist/{vetra-package-Bl6TC4wx.js → vetra-package-DSyRtkdJ.js} +2 -2
- package/dist/{vetra-package-Bl6TC4wx.js.map → vetra-package-DSyRtkdJ.js.map} +1 -1
- package/package.json +17 -14
- package/style.css +2 -0
- package/dist/document-models/app-module/index.d.ts.map +0 -1
- package/dist/document-models/document-editor/index.d.ts.map +0 -1
- package/dist/document-models/processor-module/index.d.ts.map +0 -1
- package/dist/document-models/subgraph-module/index.d.ts.map +0 -1
- package/dist/document-models/vetra-package/index.d.ts.map +0 -1
- package/dist/editor-C13SvgUy.js.map +0 -1
- package/dist/editor-CLbvu3pG.js.map +0 -1
- package/dist/editor-Fgw7attg.js.map +0 -1
- package/dist/editor-LRAwrgdQ.js.map +0 -1
- package/dist/editor-_0gdltOt.js.map +0 -1
- package/dist/factory-5eiZohiv.js.map +0 -1
- package/dist/factory-DMl8eB3P.js.map +0 -1
- package/dist/index-B5ijieNt.d.ts.map +0 -1
- package/dist/index-Dm_gN1DR.d.ts.map +0 -1
- package/dist/index-SB-AtQdU.d.ts.map +0 -1
- package/dist/index-f_um1g-i.d.ts.map +0 -1
- package/dist/module-CRq_lUkG.js.map +0 -1
- package/dist/module-DXT-FMxU.js.map +0 -1
- package/dist/module-bKT_e3CH.js.map +0 -1
- package/dist/module-ciAK1LUC.d.ts.map +0 -1
- package/dist/powerhouse.manifest.d.ts +0 -34
- package/dist/powerhouse.manifest.d.ts.map +0 -1
- package/dist/powerhouse.manifest.js +0 -86
- package/dist/powerhouse.manifest.js.map +0 -1
- package/dist/processor-trJFuoHh.js.map +0 -1
- package/dist/specs-BeVdfCwg.d.ts.map +0 -1
- package/dist/switchboard-Bf0uvxSu.js +0 -8
- package/dist/useVetraDocument-BlLdlhrQ.js +0 -30
- package/dist/useVetraDocument-BlLdlhrQ.js.map +0 -1
- package/dist/utils-DmOIDVQo.js.map +0 -1
- /package/dist/{chunk-pbuEa-1d.js → rolldown-runtime-D7D4PA-g.js} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as VetraReadModelProcessor, t as vetraReadModelFactoryBuilder } from "../../factory-
|
|
1
|
+
import { n as VetraReadModelProcessor, t as vetraReadModelFactoryBuilder } from "../../factory-BUuO4fIN.js";
|
|
2
2
|
export { VetraReadModelProcessor, vetraReadModelFactoryBuilder };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { d as appModuleDocumentType, f as reducer, p as actions, r as utils } from "./utils-
|
|
2
|
-
import { t as createAppModuleDocument } from "./ph-factories-
|
|
3
|
-
import { d as documentEditorDocumentType, f as reducer$1, p as actions$1, r as utils$1 } from "./utils-
|
|
4
|
-
import { t as createDocumentEditorDocument } from "./ph-factories-
|
|
5
|
-
import { d as processorModuleDocumentType, f as reducer$2,
|
|
6
|
-
import { t as createProcessorModuleDocument } from "./ph-factories-
|
|
7
|
-
import { d as subgraphModuleDocumentType, f as reducer$3, p as actions$3, r as utils$3 } from "./utils-
|
|
8
|
-
import { n as createSubgraphModuleDocument } from "./ph-factories-
|
|
1
|
+
import { d as appModuleDocumentType, f as reducer, p as actions, r as utils } from "./utils-COP7hJ-K.js";
|
|
2
|
+
import { t as createAppModuleDocument } from "./ph-factories-CgoFCmG0.js";
|
|
3
|
+
import { d as documentEditorDocumentType, f as reducer$1, p as actions$1, r as utils$1 } from "./utils-876N1Sph.js";
|
|
4
|
+
import { t as createDocumentEditorDocument } from "./ph-factories-Bgnr3mK3.js";
|
|
5
|
+
import { d as processorModuleDocumentType, f as reducer$2, g as actions$2, r as utils$2 } from "./utils-BJk4_43W.js";
|
|
6
|
+
import { t as createProcessorModuleDocument } from "./ph-factories-fEke-Nr8.js";
|
|
7
|
+
import { d as subgraphModuleDocumentType, f as reducer$3, p as actions$3, r as utils$3 } from "./utils-Al_SGg2a.js";
|
|
8
|
+
import { n as createSubgraphModuleDocument } from "./ph-factories-DhLtvC7j.js";
|
|
9
9
|
import { documentModelDocumentModelModule } from "document-model";
|
|
10
10
|
import { camelCase, kebabCase } from "change-case";
|
|
11
11
|
import { baseLoadFromFile, baseSaveToFile } from "document-model/node";
|
|
@@ -20,7 +20,7 @@ var app_module_default = {
|
|
|
20
20
|
"website": "https://powerhouse.inc"
|
|
21
21
|
},
|
|
22
22
|
extension: ".app",
|
|
23
|
-
description: "Declares a custom Drive App (a drive-level UI surface) shipped by a Vetra Reactor Package. Use one App Module document per drive app: configure which document types it handles, whether it accepts drag-and-drop, and mark it CONFIRMED to trigger codegen of the corresponding app scaffold under `
|
|
23
|
+
description: "Declares a custom Drive App (a drive-level UI surface) shipped by a Vetra Reactor Package. Use one App Module document per drive app: configure which document types it handles, whether it accepts drag-and-drop, and mark it CONFIRMED to trigger codegen of the corresponding app scaffold under `editors/<app-id>/`.",
|
|
24
24
|
specifications: [{
|
|
25
25
|
"state": {
|
|
26
26
|
"local": {
|
|
@@ -29,7 +29,7 @@ var app_module_default = {
|
|
|
29
29
|
"initialValue": ""
|
|
30
30
|
},
|
|
31
31
|
"global": {
|
|
32
|
-
"schema": "\"\"\"\nConfiguration for a Drive App contributed by the package. Drive apps render a\ncustom view at the drive level (instead of, or alongside, the document file\ntree) and can opt into which document types they accept.\n\"\"\"\ntype AppModuleState {\n \"\"\"Display name of the drive app. Also used as the source for the generated folder name under `
|
|
32
|
+
"schema": "\"\"\"\nConfiguration for a Drive App contributed by the package. Drive apps render a\ncustom view at the drive level (instead of, or alongside, the document file\ntree) and can opt into which document types they accept.\n\"\"\"\ntype AppModuleState {\n \"\"\"Display name of the drive app. Also used as the source for the generated folder name under `editors/`.\"\"\"\n name: String!\n \"\"\"Lifecycle status. While DRAFT the app definition is editable and codegen is skipped; switching to CONFIRMED triggers app scaffold generation.\"\"\"\n status: StatusType!\n \"\"\"Document type ids this app handles. `null` and an empty list both mean the app accepts every document type.\"\"\"\n allowedDocumentTypes: [String!]\n \"\"\"Whether the app surface accepts dropped files from the user. Defaults to true.\"\"\"\n isDragAndDropEnabled: Boolean!\n}\n\n\"\"\"\nLifecycle status of a module definition.\n- DRAFT: still being edited; codegen does not run.\n- CONFIRMED: locked in; codegen produces the corresponding scaffold.\n\"\"\"\nenum StatusType {\n DRAFT\n CONFIRMED\n}",
|
|
33
33
|
"examples": [],
|
|
34
34
|
"initialValue": "{\n \"name\": \"\",\n \"status\": \"DRAFT\",\n \"allowedDocumentTypes\": null,\n \"isDragAndDropEnabled\": true\n}"
|
|
35
35
|
}
|
|
@@ -42,7 +42,7 @@ var app_module_default = {
|
|
|
42
42
|
{
|
|
43
43
|
"id": "f2ba2ddc-8527-4162-93bd-e045e9932013",
|
|
44
44
|
"name": "SET_APP_NAME",
|
|
45
|
-
"description": "Set the display name of the drive app. Also determines the generated folder name under `
|
|
45
|
+
"description": "Set the display name of the drive app. Also determines the generated folder name under `editors/`.",
|
|
46
46
|
"schema": "input SetAppNameInput {\n name: String!\n}",
|
|
47
47
|
"template": "",
|
|
48
48
|
"reducer": "",
|
|
@@ -64,7 +64,7 @@ var app_module_default = {
|
|
|
64
64
|
{
|
|
65
65
|
"id": "7376f168-695f-4aef-94d0-6e381666358c",
|
|
66
66
|
"name": "ADD_DOCUMENT_TYPE",
|
|
67
|
-
"description": "Append a document type id to the list of types this app handles.
|
|
67
|
+
"description": "Append a document type id to the list of types this app handles. The first type added narrows the app from every type to the listed ones.",
|
|
68
68
|
"schema": "input AddDocumentTypeInput {\n documentType: String!\n}",
|
|
69
69
|
"template": "",
|
|
70
70
|
"reducer": "",
|
|
@@ -75,7 +75,7 @@ var app_module_default = {
|
|
|
75
75
|
{
|
|
76
76
|
"id": "310e4e5b-3f14-4e9a-8e09-5583c7698a65",
|
|
77
77
|
"name": "REMOVE_DOCUMENT_TYPE",
|
|
78
|
-
"description": "Remove a document type id from the handled list. No-op if the type is not present.",
|
|
78
|
+
"description": "Remove a document type id from the handled list. No-op if the type is not present. Removing the last type leaves an empty list, which accepts every type.",
|
|
79
79
|
"schema": "input RemoveDocumentTypeInput {\n documentType: String!\n}",
|
|
80
80
|
"template": "",
|
|
81
81
|
"reducer": "",
|
|
@@ -86,7 +86,7 @@ var app_module_default = {
|
|
|
86
86
|
{
|
|
87
87
|
"id": "b365727a-7df3-48f0-a4f8-02362f02ad1d",
|
|
88
88
|
"name": "SET_DOCUMENT_TYPES",
|
|
89
|
-
"description": "Replace the entire allowed-document-types list in one call.
|
|
89
|
+
"description": "Replace the entire allowed-document-types list in one call. An empty list accepts every document type.",
|
|
90
90
|
"schema": "input SetDocumentTypesInput {\n documentTypes: [String!]!\n}",
|
|
91
91
|
"template": "",
|
|
92
92
|
"reducer": "",
|
|
@@ -213,7 +213,7 @@ var processor_module_default = {
|
|
|
213
213
|
"initialValue": ""
|
|
214
214
|
},
|
|
215
215
|
"global": {
|
|
216
|
-
"schema": "\"\"\"\nConfiguration for a processor contributed by the package. A processor receives\noperations from documents of matching types and runs server-side logic (e.g.\nbuilding a read model, indexing, syncing to an external system).\n\"\"\"\ntype ProcessorModuleState {\n \"\"\"Display name of the processor. Also determines the generated folder name under `processors/`.\"\"\"\n name: String!\n \"\"\"Processor implementation kind
|
|
216
|
+
"schema": "\"\"\"\nConfiguration for a processor contributed by the package. A processor receives\noperations from documents of matching types and runs server-side logic (e.g.\nbuilding a read model, indexing, syncing to an external system).\n\"\"\"\ntype ProcessorModuleState {\n \"\"\"Display name of the processor. Also determines the generated folder name under `processors/`.\"\"\"\n name: String!\n \"\"\"Processor implementation kind: `analytics` or `relational`. Determines which scaffold codegen emits; codegen generates nothing for any other value.\"\"\"\n type: String!\n \"\"\"Document types this processor subscribes to. Each entry has a stable id so it can be removed individually.\"\"\"\n documentTypes: [DocumentTypeItem!]!\n \"\"\"Lifecycle status. While DRAFT the processor definition is editable and codegen is skipped; switching to CONFIRMED triggers scaffold generation.\"\"\"\n status: StatusType!\n \"\"\"Drive-app names this processor is attached to. The processor runs in the context of each listed app.\"\"\"\n processorApps: [String!]!\n}\n\n\"\"\"A document type id (e.g. 'my-org/invoice') attached to the processor with a stable entry id.\"\"\"\ntype DocumentTypeItem {\n \"\"\"Stable identifier for the entry; used to remove it.\"\"\"\n id: OID!\n \"\"\"Document type id this processor subscribes to.\"\"\"\n documentType: String!\n}\n\n\"\"\"\nLifecycle status of a module definition.\n- DRAFT: still being edited; codegen does not run.\n- CONFIRMED: locked in; codegen produces the corresponding scaffold.\n\"\"\"\nenum StatusType {\n DRAFT\n CONFIRMED\n}",
|
|
217
217
|
"examples": [],
|
|
218
218
|
"initialValue": "{\n \"name\": \"\",\n \"type\": \"\",\n \"documentTypes\": [],\n \"status\": \"DRAFT\",\n \"processorApps\": []\n}"
|
|
219
219
|
}
|
|
@@ -237,11 +237,17 @@ var processor_module_default = {
|
|
|
237
237
|
{
|
|
238
238
|
"id": "b8f28bb4-c6ae-40e6-86fa-29ef14ff8667",
|
|
239
239
|
"name": "SET_PROCESSOR_TYPE",
|
|
240
|
-
"description": "Set the processor implementation kind
|
|
240
|
+
"description": "Set the processor implementation kind: `analytics` or `relational`. Determines which scaffold codegen emits. Any other value is rejected with UnsupportedProcessorTypeError.",
|
|
241
241
|
"schema": "input SetProcessorTypeInput {\n type: String!\n}",
|
|
242
242
|
"template": "",
|
|
243
243
|
"reducer": "",
|
|
244
|
-
"errors": [
|
|
244
|
+
"errors": [{
|
|
245
|
+
"id": "ac9b9586-e2d5-4676-8c06-22890adcc2fd",
|
|
246
|
+
"name": "UnsupportedProcessorTypeError",
|
|
247
|
+
"code": "UNSUPPORTED_PROCESSOR_TYPE",
|
|
248
|
+
"description": "The processor type is not `analytics` or `relational`, the kinds codegen can generate.",
|
|
249
|
+
"template": ""
|
|
250
|
+
}],
|
|
245
251
|
"examples": [],
|
|
246
252
|
"scope": "global"
|
|
247
253
|
},
|
|
@@ -637,4 +643,4 @@ function pathSubdir(filePath) {
|
|
|
637
643
|
//#endregion
|
|
638
644
|
export { getDocument as a, getDocuments as c, getSpecEntry as d, listSpecDocumentTypes as f, stripLeadingDot as g, specPath as h, deleteDocument as i, validateActions as l, specDir as m, addActionsAndSave as n, getDocumentModelSchema as o, saveSpec as p, createDocument as r, getDocumentModels as s, addActions as t, SPECS_DIRNAME as u };
|
|
639
645
|
|
|
640
|
-
//# sourceMappingURL=spec-api-
|
|
646
|
+
//# sourceMappingURL=spec-api-BGj7gcQn.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec-api-DobY5TUJ.js","names":["documentEditorReducer","documentEditorUtils","documentEditorActions","documentEditorSpec","processorModuleReducer","processorModuleUtils","processorModuleActions","processorModuleSpec","subgraphModuleReducer","subgraphModuleUtils","subgraphModuleActions","subgraphModuleSpec","appModuleReducer","appModuleUtils","appModuleActions","appModuleSpec"],"sources":["../document-models/app-module/app-module.json","../document-models/document-editor/document-editor.json","../document-models/processor-module/processor-module.json","../document-models/subgraph-module/subgraph-module.json","../codegen/specs.ts","../codegen/spec-api.ts"],"sourcesContent":["","","","","import type {\n Action,\n DocumentModelGlobalState,\n PHDocument,\n Reducer,\n} from \"@powerhousedao/shared/document-model\";\nimport { kebabCase } from \"change-case\";\nimport { documentModelDocumentModelModule } from \"document-model\";\nimport { baseSaveToFile } from \"document-model/node\";\nimport { mkdir } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\n/* Import from gen/ + actions.ts directly (not the top-level barrel) so we\n * don't pull in `hooks.ts`, which depends on `@powerhousedao/reactor-browser`\n * (a browser-only module that breaks Node-side spec tooling). */\nimport appModuleSpec from \"../document-models/app-module/app-module.json\" with { type: \"json\" };\nimport { actions as appModuleActions } from \"../document-models/app-module/v1/actions.js\";\nimport {\n appModuleDocumentType,\n createAppModuleDocument,\n reducer as appModuleReducer,\n utils as appModuleUtils,\n} from \"../document-models/app-module/v1/gen/index.js\";\nimport documentEditorSpec from \"../document-models/document-editor/document-editor.json\" with { type: \"json\" };\nimport { actions as documentEditorActions } from \"../document-models/document-editor/v1/actions.js\";\nimport {\n createDocumentEditorDocument,\n documentEditorDocumentType,\n reducer as documentEditorReducer,\n utils as documentEditorUtils,\n} from \"../document-models/document-editor/v1/gen/index.js\";\nimport processorModuleSpec from \"../document-models/processor-module/processor-module.json\" with { type: \"json\" };\nimport { actions as processorModuleActions } from \"../document-models/processor-module/v1/actions.js\";\nimport {\n createProcessorModuleDocument,\n processorModuleDocumentType,\n reducer as processorModuleReducer,\n utils as processorModuleUtils,\n} from \"../document-models/processor-module/v1/gen/index.js\";\nimport subgraphModuleSpec from \"../document-models/subgraph-module/subgraph-module.json\" with { type: \"json\" };\nimport { actions as subgraphModuleActions } from \"../document-models/subgraph-module/v1/actions.js\";\nimport {\n createSubgraphModuleDocument,\n subgraphModuleDocumentType,\n reducer as subgraphModuleReducer,\n utils as subgraphModuleUtils,\n} from \"../document-models/subgraph-module/v1/gen/index.js\";\n\nexport const SPECS_DIRNAME = \"specs\";\n\nconst documentModelDocumentType = \"powerhouse/document-model\";\n\ntype ActionsModule = Record<string, (input?: any) => Action>;\n\ntype SpecEntry = {\n documentType: string;\n subdir: string;\n reducer: Reducer<any>;\n utils: { fileExtension: string };\n actions: ActionsModule;\n createDocument: (state?: any) => PHDocument;\n jsonSpec: DocumentModelGlobalState;\n};\n\nconst SPECS: Record<string, SpecEntry> = {\n [documentModelDocumentType]: {\n documentType: documentModelDocumentType,\n subdir: \"document-models\",\n reducer: documentModelDocumentModelModule.reducer,\n utils: documentModelDocumentModelModule.utils,\n actions: documentModelDocumentModelModule.actions as ActionsModule,\n createDocument: documentModelDocumentModelModule.utils.createDocument,\n jsonSpec: documentModelDocumentModelModule.documentModel\n .global as DocumentModelGlobalState,\n },\n [documentEditorDocumentType]: {\n documentType: documentEditorDocumentType,\n subdir: \"editors\",\n reducer: documentEditorReducer as Reducer<any>,\n utils: documentEditorUtils,\n actions: documentEditorActions as unknown as ActionsModule,\n createDocument: createDocumentEditorDocument as (state?: any) => PHDocument,\n jsonSpec: documentEditorSpec as unknown as DocumentModelGlobalState,\n },\n [processorModuleDocumentType]: {\n documentType: processorModuleDocumentType,\n subdir: \"processors\",\n reducer: processorModuleReducer as Reducer<any>,\n utils: processorModuleUtils,\n actions: processorModuleActions as unknown as ActionsModule,\n createDocument: createProcessorModuleDocument as (\n state?: any,\n ) => PHDocument,\n jsonSpec: processorModuleSpec as unknown as DocumentModelGlobalState,\n },\n [subgraphModuleDocumentType]: {\n documentType: subgraphModuleDocumentType,\n subdir: \"subgraphs\",\n reducer: subgraphModuleReducer as Reducer<any>,\n utils: subgraphModuleUtils,\n actions: subgraphModuleActions as unknown as ActionsModule,\n createDocument: createSubgraphModuleDocument as (state?: any) => PHDocument,\n jsonSpec: subgraphModuleSpec as unknown as DocumentModelGlobalState,\n },\n [appModuleDocumentType]: {\n documentType: appModuleDocumentType,\n subdir: \"apps\",\n reducer: appModuleReducer as Reducer<any>,\n utils: appModuleUtils,\n actions: appModuleActions as unknown as ActionsModule,\n createDocument: createAppModuleDocument as (state?: any) => PHDocument,\n jsonSpec: appModuleSpec as unknown as DocumentModelGlobalState,\n },\n};\n\nexport function getSpecEntry(documentType: string): SpecEntry {\n const entry = SPECS[documentType];\n if (!entry) {\n throw new Error(`No spec handler registered for \"${documentType}\"`);\n }\n return entry;\n}\n\nexport function listSpecDocumentTypes(): string[] {\n return Object.keys(SPECS);\n}\n\n/** Returns the directory that holds specs for a given document type. */\nexport function specDir(projectDir: string, documentType: string): string {\n return join(projectDir, SPECS_DIRNAME, getSpecEntry(documentType).subdir);\n}\n\n/**\n * Deterministic path for a doc-type + display name.\n * Format: `<projectDir>/<specsDir>/<subdir>/<kebab-name>.<ext>.phd`.\n */\nexport function specPath(\n projectDir: string,\n documentType: string,\n name: string,\n): string {\n const entry = getSpecEntry(documentType);\n const baseName = kebabCase(name);\n const ext = stripLeadingDot(entry.utils.fileExtension);\n return join(specDir(projectDir, documentType), `${baseName}.${ext}.phd`);\n}\n\n/* baseSaveToFile expects the extension WITHOUT a leading dot (\"phdm\"), while the\n * document-model utils export it WITH one (\".phdm\"). Normalize so we can pass\n * either through. */\nexport function stripLeadingDot(ext: string): string {\n return ext.startsWith(\".\") ? ext.slice(1) : ext;\n}\n\n/** Saves a document into `<projectDir>/specs/<subdir>/<kebab-name>.<ext>.phd`. */\nexport async function saveSpec(\n doc: PHDocument,\n projectDir: string,\n): Promise<string> {\n const entry = getSpecEntry(doc.header.documentType);\n const dir = specDir(projectDir, doc.header.documentType);\n await mkdir(dir, { recursive: true });\n const name = kebabCase(doc.header.name || \"untitled\");\n return baseSaveToFile(\n doc,\n dir,\n stripLeadingDot(entry.utils.fileExtension),\n name,\n );\n}\n","/**\n * File-backed mirror of reactor-mcp's tool surface. Same function names and\n * input shapes — same agent code works whether it's targeting a live reactor\n * or a `specs/` folder on disk. The \"drive id\" is the project directory;\n * \"document id\" is the file path of the spec.\n *\n * See `packages/reactor-mcp/src/tools/reactor.ts` for the canonical schema.\n */\nimport type {\n Action,\n DocumentModelGlobalState,\n OperationSpecification,\n PHDocument,\n} from \"@powerhousedao/shared/document-model\";\nimport { camelCase } from \"change-case\";\nimport { baseLoadFromFile } from \"document-model/node\";\nimport { readdir, rm, stat } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nimport {\n getSpecEntry,\n listSpecDocumentTypes,\n saveSpec,\n specDir,\n SPECS_DIRNAME,\n} from \"./specs.js\";\n\nexport type DocumentModelInfo = {\n name: string;\n type: string;\n description: string;\n extension: string;\n authorName: string;\n authorWebsite: string;\n};\n\n/** Mirrors reactor-mcp `getDocumentModels`. */\nexport function getDocumentModels(): DocumentModelInfo[] {\n return listSpecDocumentTypes().map((documentType) => {\n const { jsonSpec } = getSpecEntry(documentType);\n return {\n name: jsonSpec.name,\n type: jsonSpec.id,\n description: jsonSpec.description ?? \"\",\n extension: jsonSpec.extension ?? \"\",\n authorName: jsonSpec.author?.name ?? \"\",\n authorWebsite: jsonSpec.author?.website ?? \"\",\n };\n });\n}\n\n/** Mirrors reactor-mcp `getDocumentModelSchema`. Returns the full\n * `DocumentModelGlobalState` (schema + operations + errors), same payload\n * shape reactor-mcp serves. */\nexport function getDocumentModelSchema(\n documentType: string,\n): DocumentModelGlobalState {\n return getSpecEntry(documentType).jsonSpec;\n}\n\n/** Mirrors reactor-mcp `getDocument`. Path = file location on disk. */\nexport async function getDocument(path: string): Promise<PHDocument> {\n // We don't know the documentType ahead of time, so try each registered\n // reducer until one loads cleanly. baseLoadFromFile validates against the\n // reducer; the wrong reducer rejects. Try the path's parent directory first\n // as a fast hint (matches our `specs/<subdir>/` convention).\n const subdir = pathSubdir(path);\n const hint = subdir\n ? listSpecDocumentTypes().find((t) => getSpecEntry(t).subdir === subdir)\n : undefined;\n const order = hint\n ? [hint, ...listSpecDocumentTypes().filter((t) => t !== hint)]\n : listSpecDocumentTypes();\n\n let lastError: unknown;\n for (const documentType of order) {\n const { reducer } = getSpecEntry(documentType);\n try {\n return await baseLoadFromFile(path, reducer);\n } catch (err) {\n lastError = err;\n }\n }\n throw new Error(\n `Failed to load spec at \"${path}\": no registered reducer accepted it. Last error: ${String(lastError)}`,\n );\n}\n\n/** Mirrors reactor-mcp `getDocuments`. `parentId` is the project directory\n * containing `specs/`. */\nexport async function getDocuments(\n projectDir: string,\n opts: { documentType?: string } = {},\n): Promise<PHDocument[]> {\n const documentTypes = opts.documentType\n ? [opts.documentType]\n : listSpecDocumentTypes();\n\n const results: PHDocument[] = [];\n for (const documentType of documentTypes) {\n const dir = specDir(projectDir, documentType);\n const exists = await stat(dir).then(\n (s) => s.isDirectory(),\n () => false,\n );\n if (!exists) continue;\n const entries = await readdir(dir);\n for (const entry of entries) {\n if (!entry.endsWith(\".phd\")) continue;\n results.push(await getDocument(join(dir, entry)));\n }\n }\n return results;\n}\n\n/** Mirrors reactor-mcp `createDocument`. Returns an in-memory document; the\n * caller persists with `saveSpec`. */\nexport function createDocument(\n documentType: string,\n opts: {\n name?: string;\n initialState?: { global?: unknown; local?: unknown };\n } = {},\n): PHDocument {\n const entry = getSpecEntry(documentType);\n const doc = entry.createDocument(opts.initialState);\n if (opts.name) doc.header.name = opts.name;\n return doc;\n}\n\nexport type ActionInput = {\n type: string;\n input?: unknown;\n scope?: string;\n};\n\n/** Mirrors reactor-mcp `addActions`. Validates every action up front against\n * the document model's latest specification, then applies them in order via\n * the reducer. If any action is invalid, throws an aggregated error and\n * leaves `doc` untouched. */\nexport function addActions(\n doc: PHDocument,\n actions: ActionInput[],\n): PHDocument {\n const entry = getSpecEntry(doc.header.documentType);\n const built = validateAndBuildActions(entry, actions);\n let current = doc;\n for (let i = 0; i < built.length; i++) {\n const action = built[i];\n current = entry.reducer(current, action);\n /* The base reducer wraps custom reducers in try/catch and records any\n * throw as `operation.error` instead of propagating. For an atomic\n * batch apply that's the wrong shape — surface the error so callers\n * (and `saveSpec`) bail out before persisting a half-applied doc. */\n const scope = action.scope ?? \"global\";\n const ops = current.operations[scope];\n const last = ops?.[ops.length - 1];\n if (last?.error) {\n const failures: ActionValidationError[] = [\n {\n index: i,\n type: actions[i].type ?? \"<missing>\",\n errors: [`Reducer error: ${last.error}`],\n },\n ];\n throw formatValidationError(failures);\n }\n }\n return current;\n}\n\nexport type ActionValidationError = {\n /** Position in the input array. */\n index: number;\n /** The action's `type` field (or `<missing>` when not a string). */\n type: string;\n /** Human-readable reasons the action was rejected. */\n errors: string[];\n};\n\n/** Validate a list of actions without applying them. Returns one entry per\n * invalid action with all of its problems aggregated. Used by `addActions`\n * and exposed for callers that want a dry-run check. */\nexport function validateActions(\n documentType: string,\n actions: ActionInput[],\n): ActionValidationError[] {\n const entry = getSpecEntry(documentType);\n const failures: ActionValidationError[] = [];\n for (let i = 0; i < actions.length; i++) {\n const errors = collectActionErrors(entry, actions[i]);\n if (errors.length > 0) {\n failures.push({ index: i, type: actions[i].type ?? \"<missing>\", errors });\n }\n }\n return failures;\n}\n\n/** Run validateActions across the batch and, on success, materialize the\n * built Action objects. On any failure throws with every action's errors\n * aggregated — the caller never sees a partial apply. */\nfunction validateAndBuildActions(\n entry: ReturnType<typeof getSpecEntry>,\n actions: ActionInput[],\n): Action[] {\n const built: Action[] = [];\n const failures: ActionValidationError[] = [];\n for (let i = 0; i < actions.length; i++) {\n const item = actions[i];\n const errors = collectActionErrors(entry, item);\n if (errors.length > 0) {\n failures.push({ index: i, type: item.type ?? \"<missing>\", errors });\n continue;\n }\n built.push(buildAction(entry.actions, item));\n }\n if (failures.length > 0) throw formatValidationError(failures);\n return built;\n}\n\n/* Mirrors reactor-mcp's `validateDocumentModelAction`: confirms the operation\n * is declared in the latest spec, looks up the action creator, runs the\n * creator's own input validation, and checks scope. */\nfunction collectActionErrors(\n entry: ReturnType<typeof getSpecEntry>,\n item: ActionInput,\n): string[] {\n const errors: string[] = [];\n if (typeof item.type !== \"string\" || item.type.length === 0) {\n errors.push(\"Missing `type` field\");\n return errors;\n }\n const specs = entry.jsonSpec.specifications;\n if (!specs || specs.length === 0) {\n errors.push(\"Document model has no specifications\");\n return errors;\n }\n const latest = specs[specs.length - 1];\n let operation: OperationSpecification | undefined;\n for (const module of latest.modules ?? []) {\n const found = (module.operations ?? []).find((op) => op.name === item.type);\n if (found) {\n operation = found;\n break;\n }\n }\n if (!operation) {\n errors.push(\n `Operation \"${item.type}\" is not defined in any module of the document model`,\n );\n }\n const creatorName = camelCase(item.type);\n const creator = entry.actions[creatorName];\n if (!creator) {\n errors.push(`No action creator found.`);\n } else {\n try {\n creator(item.input);\n } catch (err) {\n errors.push(\n `Input validation error: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n if (operation?.scope && item.scope && item.scope !== operation.scope) {\n errors.push(\n `Scope \"${item.scope}\" does not match operation scope \"${operation.scope}\"`,\n );\n }\n return errors;\n}\n\nfunction formatValidationError(failures: ActionValidationError[]): Error {\n const lines = failures.map(\n (f) => ` [${f.index}] ${f.type}: ${f.errors.join(\"; \")}`,\n );\n const header =\n failures.length === 1\n ? \"1 action failed validation:\"\n : `${failures.length} actions failed validation:`;\n const err = new Error([header, ...lines].join(\"\\n\")) as Error & {\n failures: ActionValidationError[];\n };\n err.failures = failures;\n return err;\n}\n\nfunction buildAction(\n actionsModule: Record<string, (input?: any) => Action>,\n item: ActionInput,\n): Action {\n const creatorName = camelCase(item.type);\n const creator = actionsModule[creatorName];\n if (!creator) {\n throw new Error(\n `No action creator found for \"${item.type}\" (looked up as \"${creatorName}\")`,\n );\n }\n const action = creator(item.input);\n // Caller may override the scope (creator picks a default).\n if (item.scope) action.scope = item.scope;\n return action;\n}\n\n/** Mirrors reactor-mcp `deleteDocument`. Removes the spec file from disk. */\nexport async function deleteDocument(\n path: string,\n): Promise<{ success: boolean }> {\n try {\n await rm(path);\n return { success: true };\n } catch {\n return { success: false };\n }\n}\n\n/* Convenience: persist after applying actions. Matches the typical agent\n * loop `getDocument → addActions → saveSpec` from the plan. */\nexport async function addActionsAndSave(\n path: string,\n projectDir: string,\n actions: ActionInput[],\n): Promise<{ doc: PHDocument; savedPath: string }> {\n const doc = await getDocument(path);\n const next = addActions(doc, actions);\n const savedPath = await saveSpec(next, projectDir);\n return { doc: next, savedPath };\n}\n\nfunction pathSubdir(filePath: string): string | undefined {\n const parts = filePath.split(/[/\\\\]/);\n const i = parts.lastIndexOf(SPECS_DIRNAME);\n if (i < 0 || i + 1 >= parts.length) return undefined;\n return parts[i + 1];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AIgDA,MAAa,gBAAgB;AAE7B,MAAM,4BAA4B;AAclC,MAAM,QAAmC;EACtC,4BAA4B;EAC3B,cAAc;EACd,QAAQ;EACR,SAAS,iCAAiC;EAC1C,OAAO,iCAAiC;EACxC,SAAS,iCAAiC;EAC1C,gBAAgB,iCAAiC,MAAM;EACvD,UAAU,iCAAiC,cACxC;EACJ;EACA,6BAA6B;EAC5B,cAAc;EACd,QAAQ;EACR,SAASA;EACT,OAAOC;EACP,SAASC;EACT,gBAAgB;EAChB,UAAUC;EACX;EACA,8BAA8B;EAC7B,cAAc;EACd,QAAQ;EACR,SAASC;EACT,OAAOC;EACP,SAASC;EACT,gBAAgB;EAGhB,UAAUC;EACX;EACA,6BAA6B;EAC5B,cAAc;EACd,QAAQ;EACR,SAASC;EACT,OAAOC;EACP,SAASC;EACT,gBAAgB;EAChB,UAAUC;EACX;EACA,wBAAwB;EACvB,cAAc;EACd,QAAQ;EACCC;EACFC;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AC9B,KAAI,CAAC,QACH,OAAM,IAAI,MACR,gCAAgC,KAAK,KAAK,mBAAmB,YAAY,IAC1E;CAEH,MAAM,SAAS,QAAQ,KAAK,MAAM;AAElC,KAAI,KAAK,MAAO,QAAO,QAAQ,KAAK;AACpC,QAAO;;;AAIT,eAAsB,eACpB,MAC+B;AAC/B,KAAI;AACF,QAAM,GAAG,KAAK;AACd,SAAO,EAAE,SAAS,MAAM;SAClB;AACN,SAAO,EAAE,SAAS,OAAO;;;AAM7B,eAAsB,kBACpB,MACA,YACA,SACiD;CAEjD,MAAM,OAAO,WADD,MAAM,YAAY,KAAK,EACN,QAAQ;AAErC,QAAO;EAAE,KAAK;EAAM,WADF,MAAM,SAAS,MAAM,WAAW;EACnB;;AAGjC,SAAS,WAAW,UAAsC;CACxD,MAAM,QAAQ,SAAS,MAAM,QAAQ;CACrC,MAAM,IAAI,MAAM,YAAY,cAAc;AAC1C,KAAI,IAAI,KAAK,IAAI,KAAK,MAAM,OAAQ,QAAO,KAAA;AAC3C,QAAO,MAAM,IAAI"}
|
|
1
|
+
{"version":3,"file":"spec-api-BGj7gcQn.js","names":["documentEditorReducer","documentEditorUtils","documentEditorActions","documentEditorSpec","processorModuleReducer","processorModuleUtils","processorModuleActions","processorModuleSpec","subgraphModuleReducer","subgraphModuleUtils","subgraphModuleActions","subgraphModuleSpec","appModuleReducer","appModuleUtils","appModuleActions","appModuleSpec"],"sources":["../document-models/app-module/app-module.json","../document-models/document-editor/document-editor.json","../document-models/processor-module/processor-module.json","../document-models/subgraph-module/subgraph-module.json","../codegen/specs.ts","../codegen/spec-api.ts"],"sourcesContent":["","","","","import type {\n Action,\n DocumentModelGlobalState,\n PHDocument,\n Reducer,\n} from \"@powerhousedao/shared/document-model\";\nimport { kebabCase } from \"change-case\";\nimport { documentModelDocumentModelModule } from \"document-model\";\nimport { baseSaveToFile } from \"document-model/node\";\nimport { mkdir } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\n/* Import from gen/ + actions.ts directly (not the top-level barrel) so we\n * don't pull in `hooks.ts`, which depends on `@powerhousedao/reactor-browser`\n * (a browser-only module that breaks Node-side spec tooling). */\nimport appModuleSpec from \"../document-models/app-module/app-module.json\" with { type: \"json\" };\nimport { actions as appModuleActions } from \"../document-models/app-module/v1/actions.js\";\nimport {\n appModuleDocumentType,\n createAppModuleDocument,\n reducer as appModuleReducer,\n utils as appModuleUtils,\n} from \"../document-models/app-module/v1/gen/index.js\";\nimport documentEditorSpec from \"../document-models/document-editor/document-editor.json\" with { type: \"json\" };\nimport { actions as documentEditorActions } from \"../document-models/document-editor/v1/actions.js\";\nimport {\n createDocumentEditorDocument,\n documentEditorDocumentType,\n reducer as documentEditorReducer,\n utils as documentEditorUtils,\n} from \"../document-models/document-editor/v1/gen/index.js\";\nimport processorModuleSpec from \"../document-models/processor-module/processor-module.json\" with { type: \"json\" };\nimport { actions as processorModuleActions } from \"../document-models/processor-module/v1/actions.js\";\nimport {\n createProcessorModuleDocument,\n processorModuleDocumentType,\n reducer as processorModuleReducer,\n utils as processorModuleUtils,\n} from \"../document-models/processor-module/v1/gen/index.js\";\nimport subgraphModuleSpec from \"../document-models/subgraph-module/subgraph-module.json\" with { type: \"json\" };\nimport { actions as subgraphModuleActions } from \"../document-models/subgraph-module/v1/actions.js\";\nimport {\n createSubgraphModuleDocument,\n subgraphModuleDocumentType,\n reducer as subgraphModuleReducer,\n utils as subgraphModuleUtils,\n} from \"../document-models/subgraph-module/v1/gen/index.js\";\n\nexport const SPECS_DIRNAME = \"specs\";\n\nconst documentModelDocumentType = \"powerhouse/document-model\";\n\ntype ActionsModule = Record<string, (input?: any) => Action>;\n\ntype SpecEntry = {\n documentType: string;\n subdir: string;\n reducer: Reducer<any>;\n utils: { fileExtension: string };\n actions: ActionsModule;\n createDocument: (state?: any) => PHDocument;\n jsonSpec: DocumentModelGlobalState;\n};\n\nconst SPECS: Record<string, SpecEntry> = {\n [documentModelDocumentType]: {\n documentType: documentModelDocumentType,\n subdir: \"document-models\",\n reducer: documentModelDocumentModelModule.reducer,\n utils: documentModelDocumentModelModule.utils,\n actions: documentModelDocumentModelModule.actions as ActionsModule,\n createDocument: documentModelDocumentModelModule.utils.createDocument,\n jsonSpec: documentModelDocumentModelModule.documentModel\n .global as DocumentModelGlobalState,\n },\n [documentEditorDocumentType]: {\n documentType: documentEditorDocumentType,\n subdir: \"editors\",\n reducer: documentEditorReducer as Reducer<any>,\n utils: documentEditorUtils,\n actions: documentEditorActions as unknown as ActionsModule,\n createDocument: createDocumentEditorDocument as (state?: any) => PHDocument,\n jsonSpec: documentEditorSpec as unknown as DocumentModelGlobalState,\n },\n [processorModuleDocumentType]: {\n documentType: processorModuleDocumentType,\n subdir: \"processors\",\n reducer: processorModuleReducer as Reducer<any>,\n utils: processorModuleUtils,\n actions: processorModuleActions as unknown as ActionsModule,\n createDocument: createProcessorModuleDocument as (\n state?: any,\n ) => PHDocument,\n jsonSpec: processorModuleSpec as unknown as DocumentModelGlobalState,\n },\n [subgraphModuleDocumentType]: {\n documentType: subgraphModuleDocumentType,\n subdir: \"subgraphs\",\n reducer: subgraphModuleReducer as Reducer<any>,\n utils: subgraphModuleUtils,\n actions: subgraphModuleActions as unknown as ActionsModule,\n createDocument: createSubgraphModuleDocument as (state?: any) => PHDocument,\n jsonSpec: subgraphModuleSpec as unknown as DocumentModelGlobalState,\n },\n [appModuleDocumentType]: {\n documentType: appModuleDocumentType,\n subdir: \"apps\",\n reducer: appModuleReducer as Reducer<any>,\n utils: appModuleUtils,\n actions: appModuleActions as unknown as ActionsModule,\n createDocument: createAppModuleDocument as (state?: any) => PHDocument,\n jsonSpec: appModuleSpec as unknown as DocumentModelGlobalState,\n },\n};\n\nexport function getSpecEntry(documentType: string): SpecEntry {\n const entry = SPECS[documentType];\n if (!entry) {\n throw new Error(`No spec handler registered for \"${documentType}\"`);\n }\n return entry;\n}\n\nexport function listSpecDocumentTypes(): string[] {\n return Object.keys(SPECS);\n}\n\n/** Returns the directory that holds specs for a given document type. */\nexport function specDir(projectDir: string, documentType: string): string {\n return join(projectDir, SPECS_DIRNAME, getSpecEntry(documentType).subdir);\n}\n\n/**\n * Deterministic path for a doc-type + display name.\n * Format: `<projectDir>/<specsDir>/<subdir>/<kebab-name>.<ext>.phd`.\n */\nexport function specPath(\n projectDir: string,\n documentType: string,\n name: string,\n): string {\n const entry = getSpecEntry(documentType);\n const baseName = kebabCase(name);\n const ext = stripLeadingDot(entry.utils.fileExtension);\n return join(specDir(projectDir, documentType), `${baseName}.${ext}.phd`);\n}\n\n/* baseSaveToFile expects the extension WITHOUT a leading dot (\"phdm\"), while the\n * document-model utils export it WITH one (\".phdm\"). Normalize so we can pass\n * either through. */\nexport function stripLeadingDot(ext: string): string {\n return ext.startsWith(\".\") ? ext.slice(1) : ext;\n}\n\n/** Saves a document into `<projectDir>/specs/<subdir>/<kebab-name>.<ext>.phd`. */\nexport async function saveSpec(\n doc: PHDocument,\n projectDir: string,\n): Promise<string> {\n const entry = getSpecEntry(doc.header.documentType);\n const dir = specDir(projectDir, doc.header.documentType);\n await mkdir(dir, { recursive: true });\n const name = kebabCase(doc.header.name || \"untitled\");\n return baseSaveToFile(\n doc,\n dir,\n stripLeadingDot(entry.utils.fileExtension),\n name,\n );\n}\n","/**\n * File-backed mirror of reactor-mcp's tool surface. Same function names and\n * input shapes — same agent code works whether it's targeting a live reactor\n * or a `specs/` folder on disk. The \"drive id\" is the project directory;\n * \"document id\" is the file path of the spec.\n *\n * See `packages/reactor-mcp/src/tools/reactor.ts` for the canonical schema.\n */\nimport type {\n Action,\n DocumentModelGlobalState,\n OperationSpecification,\n PHDocument,\n} from \"@powerhousedao/shared/document-model\";\nimport { camelCase } from \"change-case\";\nimport { baseLoadFromFile } from \"document-model/node\";\nimport { readdir, rm, stat } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nimport {\n getSpecEntry,\n listSpecDocumentTypes,\n saveSpec,\n specDir,\n SPECS_DIRNAME,\n} from \"./specs.js\";\n\nexport type DocumentModelInfo = {\n name: string;\n type: string;\n description: string;\n extension: string;\n authorName: string;\n authorWebsite: string;\n};\n\n/** Mirrors reactor-mcp `getDocumentModels`. */\nexport function getDocumentModels(): DocumentModelInfo[] {\n return listSpecDocumentTypes().map((documentType) => {\n const { jsonSpec } = getSpecEntry(documentType);\n return {\n name: jsonSpec.name,\n type: jsonSpec.id,\n description: jsonSpec.description ?? \"\",\n extension: jsonSpec.extension ?? \"\",\n authorName: jsonSpec.author?.name ?? \"\",\n authorWebsite: jsonSpec.author?.website ?? \"\",\n };\n });\n}\n\n/** Mirrors reactor-mcp `getDocumentModelSchema`. Returns the full\n * `DocumentModelGlobalState` (schema + operations + errors), same payload\n * shape reactor-mcp serves. */\nexport function getDocumentModelSchema(\n documentType: string,\n): DocumentModelGlobalState {\n return getSpecEntry(documentType).jsonSpec;\n}\n\n/** Mirrors reactor-mcp `getDocument`. Path = file location on disk. */\nexport async function getDocument(path: string): Promise<PHDocument> {\n // We don't know the documentType ahead of time, so try each registered\n // reducer until one loads cleanly. baseLoadFromFile validates against the\n // reducer; the wrong reducer rejects. Try the path's parent directory first\n // as a fast hint (matches our `specs/<subdir>/` convention).\n const subdir = pathSubdir(path);\n const hint = subdir\n ? listSpecDocumentTypes().find((t) => getSpecEntry(t).subdir === subdir)\n : undefined;\n const order = hint\n ? [hint, ...listSpecDocumentTypes().filter((t) => t !== hint)]\n : listSpecDocumentTypes();\n\n let lastError: unknown;\n for (const documentType of order) {\n const { reducer } = getSpecEntry(documentType);\n try {\n return await baseLoadFromFile(path, reducer);\n } catch (err) {\n lastError = err;\n }\n }\n throw new Error(\n `Failed to load spec at \"${path}\": no registered reducer accepted it. Last error: ${String(lastError)}`,\n );\n}\n\n/** Mirrors reactor-mcp `getDocuments`. `parentId` is the project directory\n * containing `specs/`. */\nexport async function getDocuments(\n projectDir: string,\n opts: { documentType?: string } = {},\n): Promise<PHDocument[]> {\n const documentTypes = opts.documentType\n ? [opts.documentType]\n : listSpecDocumentTypes();\n\n const results: PHDocument[] = [];\n for (const documentType of documentTypes) {\n const dir = specDir(projectDir, documentType);\n const exists = await stat(dir).then(\n (s) => s.isDirectory(),\n () => false,\n );\n if (!exists) continue;\n const entries = await readdir(dir);\n for (const entry of entries) {\n if (!entry.endsWith(\".phd\")) continue;\n results.push(await getDocument(join(dir, entry)));\n }\n }\n return results;\n}\n\n/** Mirrors reactor-mcp `createDocument`. Returns an in-memory document; the\n * caller persists with `saveSpec`. */\nexport function createDocument(\n documentType: string,\n opts: {\n name?: string;\n initialState?: { global?: unknown; local?: unknown };\n } = {},\n): PHDocument {\n const entry = getSpecEntry(documentType);\n const doc = entry.createDocument(opts.initialState);\n if (opts.name) doc.header.name = opts.name;\n return doc;\n}\n\nexport type ActionInput = {\n type: string;\n input?: unknown;\n scope?: string;\n};\n\n/** Mirrors reactor-mcp `addActions`. Validates every action up front against\n * the document model's latest specification, then applies them in order via\n * the reducer. If any action is invalid, throws an aggregated error and\n * leaves `doc` untouched. */\nexport function addActions(\n doc: PHDocument,\n actions: ActionInput[],\n): PHDocument {\n const entry = getSpecEntry(doc.header.documentType);\n const built = validateAndBuildActions(entry, actions);\n let current = doc;\n for (let i = 0; i < built.length; i++) {\n const action = built[i];\n current = entry.reducer(current, action);\n /* The base reducer wraps custom reducers in try/catch and records any\n * throw as `operation.error` instead of propagating. For an atomic\n * batch apply that's the wrong shape — surface the error so callers\n * (and `saveSpec`) bail out before persisting a half-applied doc. */\n const scope = action.scope ?? \"global\";\n const ops = current.operations[scope];\n const last = ops?.[ops.length - 1];\n if (last?.error) {\n const failures: ActionValidationError[] = [\n {\n index: i,\n type: actions[i].type ?? \"<missing>\",\n errors: [`Reducer error: ${last.error}`],\n },\n ];\n throw formatValidationError(failures);\n }\n }\n return current;\n}\n\nexport type ActionValidationError = {\n /** Position in the input array. */\n index: number;\n /** The action's `type` field (or `<missing>` when not a string). */\n type: string;\n /** Human-readable reasons the action was rejected. */\n errors: string[];\n};\n\n/** Validate a list of actions without applying them. Returns one entry per\n * invalid action with all of its problems aggregated. Used by `addActions`\n * and exposed for callers that want a dry-run check. */\nexport function validateActions(\n documentType: string,\n actions: ActionInput[],\n): ActionValidationError[] {\n const entry = getSpecEntry(documentType);\n const failures: ActionValidationError[] = [];\n for (let i = 0; i < actions.length; i++) {\n const errors = collectActionErrors(entry, actions[i]);\n if (errors.length > 0) {\n failures.push({ index: i, type: actions[i].type ?? \"<missing>\", errors });\n }\n }\n return failures;\n}\n\n/** Run validateActions across the batch and, on success, materialize the\n * built Action objects. On any failure throws with every action's errors\n * aggregated — the caller never sees a partial apply. */\nfunction validateAndBuildActions(\n entry: ReturnType<typeof getSpecEntry>,\n actions: ActionInput[],\n): Action[] {\n const built: Action[] = [];\n const failures: ActionValidationError[] = [];\n for (let i = 0; i < actions.length; i++) {\n const item = actions[i];\n const errors = collectActionErrors(entry, item);\n if (errors.length > 0) {\n failures.push({ index: i, type: item.type ?? \"<missing>\", errors });\n continue;\n }\n built.push(buildAction(entry.actions, item));\n }\n if (failures.length > 0) throw formatValidationError(failures);\n return built;\n}\n\n/* Mirrors reactor-mcp's `validateDocumentModelAction`: confirms the operation\n * is declared in the latest spec, looks up the action creator, runs the\n * creator's own input validation, and checks scope. */\nfunction collectActionErrors(\n entry: ReturnType<typeof getSpecEntry>,\n item: ActionInput,\n): string[] {\n const errors: string[] = [];\n if (typeof item.type !== \"string\" || item.type.length === 0) {\n errors.push(\"Missing `type` field\");\n return errors;\n }\n const specs = entry.jsonSpec.specifications;\n if (!specs || specs.length === 0) {\n errors.push(\"Document model has no specifications\");\n return errors;\n }\n const latest = specs[specs.length - 1];\n let operation: OperationSpecification | undefined;\n for (const module of latest.modules ?? []) {\n const found = (module.operations ?? []).find((op) => op.name === item.type);\n if (found) {\n operation = found;\n break;\n }\n }\n if (!operation) {\n errors.push(\n `Operation \"${item.type}\" is not defined in any module of the document model`,\n );\n }\n const creatorName = camelCase(item.type);\n const creator = entry.actions[creatorName];\n if (!creator) {\n errors.push(`No action creator found.`);\n } else {\n try {\n creator(item.input);\n } catch (err) {\n errors.push(\n `Input validation error: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n if (operation?.scope && item.scope && item.scope !== operation.scope) {\n errors.push(\n `Scope \"${item.scope}\" does not match operation scope \"${operation.scope}\"`,\n );\n }\n return errors;\n}\n\nfunction formatValidationError(failures: ActionValidationError[]): Error {\n const lines = failures.map(\n (f) => ` [${f.index}] ${f.type}: ${f.errors.join(\"; \")}`,\n );\n const header =\n failures.length === 1\n ? \"1 action failed validation:\"\n : `${failures.length} actions failed validation:`;\n const err = new Error([header, ...lines].join(\"\\n\")) as Error & {\n failures: ActionValidationError[];\n };\n err.failures = failures;\n return err;\n}\n\nfunction buildAction(\n actionsModule: Record<string, (input?: any) => Action>,\n item: ActionInput,\n): Action {\n const creatorName = camelCase(item.type);\n const creator = actionsModule[creatorName];\n if (!creator) {\n throw new Error(\n `No action creator found for \"${item.type}\" (looked up as \"${creatorName}\")`,\n );\n }\n const action = creator(item.input);\n // Caller may override the scope (creator picks a default).\n if (item.scope) action.scope = item.scope;\n return action;\n}\n\n/** Mirrors reactor-mcp `deleteDocument`. Removes the spec file from disk. */\nexport async function deleteDocument(\n path: string,\n): Promise<{ success: boolean }> {\n try {\n await rm(path);\n return { success: true };\n } catch {\n return { success: false };\n }\n}\n\n/* Convenience: persist after applying actions. Matches the typical agent\n * loop `getDocument → addActions → saveSpec` from the plan. */\nexport async function addActionsAndSave(\n path: string,\n projectDir: string,\n actions: ActionInput[],\n): Promise<{ doc: PHDocument; savedPath: string }> {\n const doc = await getDocument(path);\n const next = addActions(doc, actions);\n const savedPath = await saveSpec(next, projectDir);\n return { doc: next, savedPath };\n}\n\nfunction pathSubdir(filePath: string): string | undefined {\n const parts = filePath.split(/[/\\\\]/);\n const i = parts.lastIndexOf(SPECS_DIRNAME);\n if (i < 0 || i + 1 >= parts.length) return undefined;\n return parts[i + 1];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAK,KAAK,mBAAmB,YAAY,GAC3E;CAEF,MAAM,SAAS,QAAQ,KAAK,KAAK;CAEjC,IAAI,KAAK,OAAO,OAAO,QAAQ,KAAK;CACpC,OAAO;AACT;;AAGA,eAAsB,eACpB,MAC+B;CAC/B,IAAI;EACF,MAAM,GAAG,IAAI;EACb,OAAO,EAAE,SAAS,KAAK;CACzB,QAAQ;EACN,OAAO,EAAE,SAAS,MAAM;CAC1B;AACF;AAIA,eAAsB,kBACpB,MACA,YACA,SACiD;CAEjD,MAAM,OAAO,WAAW,MADN,YAAY,IAAI,GACL,OAAO;CAEpC,OAAO;EAAE,KAAK;EAAM,WAAA,MADI,SAAS,MAAM,UAAU;CACnB;AAChC;AAEA,SAAS,WAAW,UAAsC;CACxD,MAAM,QAAQ,SAAS,MAAM,OAAO;CACpC,MAAM,IAAI,MAAM,YAAY,aAAa;CACzC,IAAI,IAAI,KAAK,IAAI,KAAK,MAAM,QAAQ,OAAO,KAAA;CAC3C,OAAO,MAAM,IAAI;AACnB"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Action, DocumentModelGlobalState, PHDocument, Reducer } from "@powerhousedao/shared/document-model";
|
|
2
|
-
|
|
3
2
|
//#region codegen/spec-api.d.ts
|
|
4
3
|
type DocumentModelInfo = {
|
|
5
4
|
name: string;
|
|
@@ -42,8 +41,11 @@ type ActionInput = {
|
|
|
42
41
|
* leaves `doc` untouched. */
|
|
43
42
|
declare function addActions(doc: PHDocument, actions: ActionInput[]): PHDocument;
|
|
44
43
|
type ActionValidationError = {
|
|
45
|
-
/** Position in the input array. */
|
|
46
|
-
|
|
44
|
+
/** Position in the input array. */
|
|
45
|
+
index: number;
|
|
46
|
+
/** The action's `type` field (or `<missing>` when not a string). */
|
|
47
|
+
type: string;
|
|
48
|
+
/** Human-readable reasons the action was rejected. */
|
|
47
49
|
errors: string[];
|
|
48
50
|
};
|
|
49
51
|
/** Validate a list of actions without applying them. Returns one entry per
|
|
@@ -87,4 +89,5 @@ declare function stripLeadingDot(ext: string): string;
|
|
|
87
89
|
declare function saveSpec(doc: PHDocument, projectDir: string): Promise<string>;
|
|
88
90
|
//#endregion
|
|
89
91
|
export { getDocumentModels as _, specDir as a, ActionInput as c, addActions as d, addActionsAndSave as f, getDocumentModelSchema as g, getDocument as h, saveSpec as i, ActionValidationError as l, deleteDocument as m, getSpecEntry as n, specPath as o, createDocument as p, listSpecDocumentTypes as r, stripLeadingDot as s, SPECS_DIRNAME as t, DocumentModelInfo as u, getDocuments as v, validateActions as y };
|
|
90
|
-
|
|
92
|
+
export {};
|
|
93
|
+
//# sourceMappingURL=specs-DoTSfuxN.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specs-DoTSfuxN.d.ts","names":[],"sources":["../codegen/spec-api.ts","../codegen/specs.ts"],"mappings":";;KA2BY;EACV;EACA;EACA;EACA;EACA;EACA;;;iBAIc,qBAAqB;;;;iBAiBrB,uBACd,uBACC;;iBAKmB,YAAY,eAAe,QAAQ;;;iBA6BnC,aACpB,oBACA;EAAQ;IACP,QAAQ;;;iBAwBK,eACd,sBACA;EACE;EACA;IAAiB;IAAkB;;IAEpC;KAOS;EACV;EACA;EACA;;;;;;iBAOc,WACd,KAAK,YACL,SAAS,gBACR;KA4BS;;EAEV;;EAEA;;EAEA;;;;;iBAMc,gBACd,sBACA,SAAS,gBACR;;iBAuHmB,eACpB,eACC;EAAU;;iBAWS,kBACpB,cACA,oBACA,SAAS,gBACR;EAAU,KAAK;EAAY;;;;cClRjB;KAIR,gBAAgB,gBAAgB,gBAAgB;KAEhD;EACH;EACA;EACA,SAAS;EACT;IAAS;;EACT,SAAS;EACT,iBAAiB,gBAAgB;EACjC,UAAU;;iBAsDI,aAAa,uBAAuB;iBAQpC;;iBAKA,QAAQ,oBAAoB;;;;;iBAQ5B,SACd,oBACA,sBACA;iBAWc,gBAAgB;;iBAKV,SACpB,KAAK,YACL,qBACC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { loadDocumentModelInDir } from "@powerhousedao/codegen/utils";
|
|
2
|
+
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
3
|
+
import { kebabCase } from "change-case";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { findPackageSubgraphConflicts } from "@powerhousedao/reactor-api/subgraph-types";
|
|
6
|
+
import { Kind, parse } from "graphql";
|
|
7
|
+
//#region codegen/subgraph-type-lint.ts
|
|
8
|
+
const GQL_TEMPLATE = /\bgql\s*`([^`]*)`/g;
|
|
9
|
+
const SUBGRAPH_NAME = /\bname\s*=\s*["'`]([^"'`]+)["'`]/;
|
|
10
|
+
const SUBGRAPH_EXPORT = /from\s+["']\.\/([^/"']+)\/index\.js["']/g;
|
|
11
|
+
function directories(path) {
|
|
12
|
+
try {
|
|
13
|
+
return readdirSync(path, { withFileTypes: true }).filter((entry) => entry.isDirectory());
|
|
14
|
+
} catch {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function read(path) {
|
|
19
|
+
try {
|
|
20
|
+
return readFileSync(path, "utf-8");
|
|
21
|
+
} catch {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function readSchema(path) {
|
|
26
|
+
const source = read(path);
|
|
27
|
+
if (source === void 0) return void 0;
|
|
28
|
+
const blocks = Array.from(source.matchAll(GQL_TEMPLATE), ([, sdl]) => sdl);
|
|
29
|
+
if (blocks.length === 0 || blocks.some((sdl) => sdl.includes("${"))) return;
|
|
30
|
+
try {
|
|
31
|
+
return parse(blocks.join("\n"));
|
|
32
|
+
} catch {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** Subgraph directories in the order `subgraphs/index.ts` registers them. */
|
|
37
|
+
function subgraphDirs(subgraphsDir) {
|
|
38
|
+
const exported = Array.from((read(join(subgraphsDir, "index.ts")) ?? "").matchAll(SUBGRAPH_EXPORT), ([, dir]) => dir);
|
|
39
|
+
const position = (dir) => {
|
|
40
|
+
const index = exported.indexOf(dir);
|
|
41
|
+
return index === -1 ? exported.length : index;
|
|
42
|
+
};
|
|
43
|
+
return directories(subgraphsDir).map((entry) => entry.name).sort((a, b) => position(a) - position(b));
|
|
44
|
+
}
|
|
45
|
+
function describeRefusal({ name, reason, subgraphOnly }) {
|
|
46
|
+
const detail = reason.split("\n")[0].replace(/\.$/, "");
|
|
47
|
+
return subgraphOnly ? `The subgraph of document model "${name}" is refused by the server: ${detail}.` : `Document model "${name}" is refused by the server: ${detail}.`;
|
|
48
|
+
}
|
|
49
|
+
function describe(name, conflict) {
|
|
50
|
+
if (conflict.nameHeldBy === "package") return `Subgraph "${name}" is defined more than once, so the server serves only the last. Rename the others.`;
|
|
51
|
+
if (conflict.nameHeldBy) return `Subgraph "${name}" has the name of a ${conflict.nameHeldBy} subgraph, so the server refuses it. Rename the subgraph.`;
|
|
52
|
+
return `Subgraph "${name}" defines ${conflict.claims.map(({ claim, owner }) => `${claim} (owned by "${owner}")`).join(", ")}, so the supergraph leaves it out. Rename them in its schema.ts.`;
|
|
53
|
+
}
|
|
54
|
+
function loadModels(projectDir) {
|
|
55
|
+
return directories(join(projectDir, "document-models")).map(loadDocumentModelInDir).filter((model) => model !== void 0);
|
|
56
|
+
}
|
|
57
|
+
/** Why the server would refuse a new subgraph scaffolded as `name`, if it
|
|
58
|
+
* would; an existing one is left to {@link lintSubgraphTypes}. */
|
|
59
|
+
async function findSubgraphNameConflict(projectDir, name) {
|
|
60
|
+
const subgraphName = kebabCase(name);
|
|
61
|
+
if (existsSync(join(projectDir, "subgraphs", subgraphName, "index.ts"))) return;
|
|
62
|
+
const { conflicts } = await findPackageSubgraphConflicts([{
|
|
63
|
+
name: subgraphName,
|
|
64
|
+
typeDefs: {
|
|
65
|
+
kind: Kind.DOCUMENT,
|
|
66
|
+
definitions: []
|
|
67
|
+
}
|
|
68
|
+
}], loadModels(projectDir));
|
|
69
|
+
const holder = conflicts.get(subgraphName)?.nameHeldBy;
|
|
70
|
+
if (!holder || holder === "package") return void 0;
|
|
71
|
+
return `Subgraph name "${subgraphName}" is taken by a ${holder} subgraph, so the server would refuse this one. Choose another name, such as "${subgraphName}-api".`;
|
|
72
|
+
}
|
|
73
|
+
/** A warning per model or subgraph the server would refuse or leave out. */
|
|
74
|
+
async function lintSubgraphTypes(projectDir) {
|
|
75
|
+
const models = loadModels(projectDir);
|
|
76
|
+
const subgraphsDir = join(projectDir, "subgraphs");
|
|
77
|
+
const subgraphs = [];
|
|
78
|
+
for (const dir of subgraphDirs(subgraphsDir)) {
|
|
79
|
+
const typeDefs = readSchema(join(subgraphsDir, dir, "schema.ts"));
|
|
80
|
+
if (!typeDefs) continue;
|
|
81
|
+
const index = read(join(subgraphsDir, dir, "index.ts")) ?? "";
|
|
82
|
+
subgraphs.push({
|
|
83
|
+
name: SUBGRAPH_NAME.exec(index)?.[1] ?? dir,
|
|
84
|
+
typeDefs
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
if (subgraphs.length === 0 && models.length === 0) return [];
|
|
88
|
+
const { conflicts, refusedModels } = await findPackageSubgraphConflicts(subgraphs, models);
|
|
89
|
+
return [...refusedModels.map(describeRefusal), ...Array.from(conflicts, ([name, conflict]) => describe(name, conflict))];
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
export { lintSubgraphTypes as n, findSubgraphNameConflict as t };
|
|
93
|
+
|
|
94
|
+
//# sourceMappingURL=subgraph-type-lint-Dr8Wu0VB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subgraph-type-lint-Dr8Wu0VB.js","names":[],"sources":["../codegen/subgraph-type-lint.ts"],"sourcesContent":["import { loadDocumentModelInDir } from \"@powerhousedao/codegen/utils\";\nimport {\n findPackageSubgraphConflicts,\n type PackageSubgraph,\n type PackageSubgraphConflicts,\n type RefusedDocumentModel,\n} from \"@powerhousedao/reactor-api/subgraph-types\";\nimport { kebabCase } from \"change-case\";\nimport { type DocumentNode, Kind, parse } from \"graphql\";\nimport { type Dirent, existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\n// Templates with substitutions are skipped: their SDL is only known at runtime.\nconst GQL_TEMPLATE = /\\bgql\\s*`([^`]*)`/g;\nconst SUBGRAPH_NAME = /\\bname\\s*=\\s*[\"'`]([^\"'`]+)[\"'`]/;\nconst SUBGRAPH_EXPORT = /from\\s+[\"']\\.\\/([^/\"']+)\\/index\\.js[\"']/g;\n\nfunction directories(path: string): Dirent[] {\n try {\n return readdirSync(path, { withFileTypes: true }).filter((entry) =>\n entry.isDirectory(),\n );\n } catch {\n return [];\n }\n}\n\nfunction read(path: string): string | undefined {\n try {\n return readFileSync(path, \"utf-8\");\n } catch {\n return undefined;\n }\n}\n\nfunction readSchema(path: string): DocumentNode | undefined {\n const source = read(path);\n if (source === undefined) return undefined;\n const blocks = Array.from(source.matchAll(GQL_TEMPLATE), ([, sdl]) => sdl);\n if (blocks.length === 0 || blocks.some((sdl) => sdl.includes(\"${\"))) {\n return undefined;\n }\n try {\n return parse(blocks.join(\"\\n\"));\n } catch {\n // Invalid SDL fails where the subgraph loads, and is reported there.\n return undefined;\n }\n}\n\n/** Subgraph directories in the order `subgraphs/index.ts` registers them. */\nfunction subgraphDirs(subgraphsDir: string): string[] {\n const exported = Array.from(\n (read(join(subgraphsDir, \"index.ts\")) ?? \"\").matchAll(SUBGRAPH_EXPORT),\n ([, dir]) => dir,\n );\n const position = (dir: string) => {\n const index = exported.indexOf(dir);\n return index === -1 ? exported.length : index;\n };\n return directories(subgraphsDir)\n .map((entry) => entry.name)\n .sort((a, b) => position(a) - position(b));\n}\n\nfunction describeRefusal({\n name,\n reason,\n subgraphOnly,\n}: RefusedDocumentModel): string {\n const detail = reason.split(\"\\n\")[0].replace(/\\.$/, \"\");\n return subgraphOnly\n ? `The subgraph of document model \"${name}\" is refused by the server: ${detail}.`\n : `Document model \"${name}\" is refused by the server: ${detail}.`;\n}\n\nfunction describe(name: string, conflict: PackageSubgraphConflicts): string {\n if (conflict.nameHeldBy === \"package\") {\n return `Subgraph \"${name}\" is defined more than once, so the server serves only the last. Rename the others.`;\n }\n if (conflict.nameHeldBy) {\n return `Subgraph \"${name}\" has the name of a ${conflict.nameHeldBy} subgraph, so the server refuses it. Rename the subgraph.`;\n }\n const claims = conflict.claims\n .map(({ claim, owner }) => `${claim} (owned by \"${owner}\")`)\n .join(\", \");\n return `Subgraph \"${name}\" defines ${claims}, so the supergraph leaves it out. Rename them in its schema.ts.`;\n}\n\nfunction loadModels(projectDir: string) {\n return directories(join(projectDir, \"document-models\"))\n .map(loadDocumentModelInDir)\n .filter((model) => model !== undefined);\n}\n\n/** Why the server would refuse a new subgraph scaffolded as `name`, if it\n * would; an existing one is left to {@link lintSubgraphTypes}. */\nexport async function findSubgraphNameConflict(\n projectDir: string,\n name: string,\n): Promise<string | undefined> {\n const subgraphName = kebabCase(name);\n if (existsSync(join(projectDir, \"subgraphs\", subgraphName, \"index.ts\"))) {\n return undefined;\n }\n const { conflicts } = await findPackageSubgraphConflicts(\n [\n {\n name: subgraphName,\n typeDefs: { kind: Kind.DOCUMENT, definitions: [] },\n },\n ],\n loadModels(projectDir),\n );\n const holder = conflicts.get(subgraphName)?.nameHeldBy;\n if (!holder || holder === \"package\") return undefined;\n return `Subgraph name \"${subgraphName}\" is taken by a ${holder} subgraph, so the server would refuse this one. Choose another name, such as \"${subgraphName}-api\".`;\n}\n\n/** A warning per model or subgraph the server would refuse or leave out. */\nexport async function lintSubgraphTypes(projectDir: string): Promise<string[]> {\n const models = loadModels(projectDir);\n const subgraphsDir = join(projectDir, \"subgraphs\");\n const subgraphs: PackageSubgraph[] = [];\n for (const dir of subgraphDirs(subgraphsDir)) {\n const typeDefs = readSchema(join(subgraphsDir, dir, \"schema.ts\"));\n if (!typeDefs) continue;\n const index = read(join(subgraphsDir, dir, \"index.ts\")) ?? \"\";\n subgraphs.push({ name: SUBGRAPH_NAME.exec(index)?.[1] ?? dir, typeDefs });\n }\n if (subgraphs.length === 0 && models.length === 0) return [];\n\n const { conflicts, refusedModels } = await findPackageSubgraphConflicts(\n subgraphs,\n models,\n );\n return [\n ...refusedModels.map(describeRefusal),\n ...Array.from(conflicts, ([name, conflict]) => describe(name, conflict)),\n ];\n}\n"],"mappings":";;;;;;;AAaA,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,kBAAkB;AAExB,SAAS,YAAY,MAAwB;CAC3C,IAAI;EACF,OAAO,YAAY,MAAM,EAAE,eAAe,KAAK,CAAC,CAAC,CAAC,QAAQ,UACxD,MAAM,YAAY,CACpB;CACF,QAAQ;EACN,OAAO,CAAC;CACV;AACF;AAEA,SAAS,KAAK,MAAkC;CAC9C,IAAI;EACF,OAAO,aAAa,MAAM,OAAO;CACnC,QAAQ;EACN;CACF;AACF;AAEA,SAAS,WAAW,MAAwC;CAC1D,MAAM,SAAS,KAAK,IAAI;CACxB,IAAI,WAAW,KAAA,GAAW,OAAO,KAAA;CACjC,MAAM,SAAS,MAAM,KAAK,OAAO,SAAS,YAAY,IAAI,GAAG,SAAS,GAAG;CACzE,IAAI,OAAO,WAAW,KAAK,OAAO,MAAM,QAAQ,IAAI,SAAS,IAAI,CAAC,GAChE;CAEF,IAAI;EACF,OAAO,MAAM,OAAO,KAAK,IAAI,CAAC;CAChC,QAAQ;EAEN;CACF;AACF;;AAGA,SAAS,aAAa,cAAgC;CACpD,MAAM,WAAW,MAAM,MACpB,KAAK,KAAK,cAAc,UAAU,CAAC,KAAK,GAAA,CAAI,SAAS,eAAe,IACpE,GAAG,SAAS,GACf;CACA,MAAM,YAAY,QAAgB;EAChC,MAAM,QAAQ,SAAS,QAAQ,GAAG;EAClC,OAAO,UAAU,KAAK,SAAS,SAAS;CAC1C;CACA,OAAO,YAAY,YAAY,CAAC,CAC7B,KAAK,UAAU,MAAM,IAAI,CAAC,CAC1B,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,SAAS,CAAC,CAAC;AAC7C;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;EAC5C,MAAM,WAAW,WAAW,KAAK,cAAc,KAAK,WAAW,CAAC;EAChE,IAAI,CAAC,UAAU;EACf,MAAM,QAAQ,KAAK,KAAK,cAAc,KAAK,UAAU,CAAC,KAAK;EAC3D,UAAU,KAAK;GAAE,MAAM,cAAc,KAAK,KAAK,CAAC,GAAG,MAAM;GAAK;EAAS,CAAC;CAC1E;CACA,IAAI,UAAU,WAAW,KAAK,OAAO,WAAW,GAAG,OAAO,CAAC;CAE3D,MAAM,EAAE,WAAW,kBAAkB,MAAM,6BACzC,WACA,MACF;CACA,OAAO,CACL,GAAG,cAAc,IAAI,eAAe,GACpC,GAAG,MAAM,KAAK,YAAY,CAAC,MAAM,cAAc,SAAS,MAAM,QAAQ,CAAC,CACzE;AACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { t as codegenFactoryBuilder } from "./factory-GIkoxPdL.js";
|
|
2
|
+
import { t as vetraReadModelFactoryBuilder } from "./factory-BUuO4fIN.js";
|
|
3
|
+
//#region processors/switchboard.ts
|
|
4
|
+
const processorFactoryBuilders = [vetraReadModelFactoryBuilder, codegenFactoryBuilder];
|
|
5
|
+
//#endregion
|
|
6
|
+
export { processorFactoryBuilders };
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=switchboard-DUSh_ScZ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switchboard-
|
|
1
|
+
{"version":3,"file":"switchboard-DUSh_ScZ.js","names":[],"sources":["../processors/switchboard.ts"],"sourcesContent":["/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport type { ProcessorFactoryBuilder } from \"@powerhousedao/reactor-browser\";\nimport { codegenFactoryBuilder } from \"./codegen/factory.js\";\nimport { vetraReadModelFactoryBuilder } from \"./vetra-read-model/factory.js\";\n\nexport const processorFactoryBuilders: ProcessorFactoryBuilder[] = [\n vetraReadModelFactoryBuilder,\n codegenFactoryBuilder,\n];\n"],"mappings":";;;AAQA,MAAa,2BAAsD,CACjE,8BACA,qBACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade-manifest-
|
|
1
|
+
{"version":3,"file":"upgrade-manifest-BOZ5nmyK.js","names":[],"sources":["../document-models/vetra-package/upgrades/versions.ts","../document-models/vetra-package/upgrades/upgrade-manifest.ts"],"sourcesContent":["export const supportedVersions = [1] as const;\n\nexport const latestVersion = supportedVersions[0];\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport type { UpgradeManifest } from \"document-model\";\nimport { latestVersion, supportedVersions } from \"./versions.js\";\n\nexport const vetraPackageUpgradeManifest: UpgradeManifest<\n typeof supportedVersions\n> = {\n documentType: \"powerhouse/package\",\n latestVersion,\n supportedVersions,\n upgrades: {},\n};\n"],"mappings":";AAAA,MAAa,oBAAoB,CAAC,CAAC;AAEnC,MAAa,gBAAgB,kBAAkB;;;ACK/C,MAAa,8BAET;CACF,cAAc;CACd;CACA;CACA,UAAU,CAAC;AACb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade-manifest-
|
|
1
|
+
{"version":3,"file":"upgrade-manifest-D7xKGmZc.js","names":[],"sources":["../document-models/document-editor/upgrades/versions.ts","../document-models/document-editor/upgrades/upgrade-manifest.ts"],"sourcesContent":["export const supportedVersions = [1] as const;\n\nexport const latestVersion = supportedVersions[0];\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport type { UpgradeManifest } from \"document-model\";\nimport { latestVersion, supportedVersions } from \"./versions.js\";\n\nexport const documentEditorUpgradeManifest: UpgradeManifest<\n typeof supportedVersions\n> = {\n documentType: \"powerhouse/document-editor\",\n latestVersion,\n supportedVersions,\n upgrades: {},\n};\n"],"mappings":";AAAA,MAAa,oBAAoB,CAAC,CAAC;AAEnC,MAAa,gBAAgB,kBAAkB;;;ACK/C,MAAa,gCAET;CACF,cAAc;CACd;CACA;CACA,UAAU,CAAC;AACb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade-manifest-
|
|
1
|
+
{"version":3,"file":"upgrade-manifest-DLxSL23q.js","names":[],"sources":["../document-models/app-module/upgrades/versions.ts","../document-models/app-module/upgrades/upgrade-manifest.ts"],"sourcesContent":["export const supportedVersions = [1] as const;\n\nexport const latestVersion = supportedVersions[0];\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport type { UpgradeManifest } from \"document-model\";\nimport { latestVersion, supportedVersions } from \"./versions.js\";\n\nexport const appModuleUpgradeManifest: UpgradeManifest<\n typeof supportedVersions\n> = {\n documentType: \"powerhouse/app\",\n latestVersion,\n supportedVersions,\n upgrades: {},\n};\n"],"mappings":";AAAA,MAAa,oBAAoB,CAAC,CAAC;AAEnC,MAAa,gBAAgB,kBAAkB;;;ACK/C,MAAa,2BAET;CACF,cAAc;CACd;CACA;CACA,UAAU,CAAC;AACb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade-manifest-
|
|
1
|
+
{"version":3,"file":"upgrade-manifest-Dv62Cod7.js","names":[],"sources":["../document-models/subgraph-module/upgrades/versions.ts","../document-models/subgraph-module/upgrades/upgrade-manifest.ts"],"sourcesContent":["export const supportedVersions = [1] as const;\n\nexport const latestVersion = supportedVersions[0];\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport type { UpgradeManifest } from \"document-model\";\nimport { latestVersion, supportedVersions } from \"./versions.js\";\n\nexport const subgraphModuleUpgradeManifest: UpgradeManifest<\n typeof supportedVersions\n> = {\n documentType: \"powerhouse/subgraph\",\n latestVersion,\n supportedVersions,\n upgrades: {},\n};\n"],"mappings":";AAAA,MAAa,oBAAoB,CAAC,CAAC;AAEnC,MAAa,gBAAgB,kBAAkB;;;ACK/C,MAAa,gCAET;CACF,cAAc;CACd;CACA;CACA,UAAU,CAAC;AACb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade-manifest-
|
|
1
|
+
{"version":3,"file":"upgrade-manifest-d3LquK-H.js","names":[],"sources":["../document-models/processor-module/upgrades/versions.ts","../document-models/processor-module/upgrades/upgrade-manifest.ts"],"sourcesContent":["export const supportedVersions = [1] as const;\n\nexport const latestVersion = supportedVersions[0];\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport type { UpgradeManifest } from \"document-model\";\nimport { latestVersion, supportedVersions } from \"./versions.js\";\n\nexport const processorModuleUpgradeManifest: UpgradeManifest<\n typeof supportedVersions\n> = {\n documentType: \"powerhouse/processor\",\n latestVersion,\n supportedVersions,\n upgrades: {},\n};\n"],"mappings":";AAAA,MAAa,oBAAoB,CAAC,CAAC;AAEnC,MAAa,gBAAgB,kBAAkB;;;ACK/C,MAAa,iCAET;CACF,cAAc;CACd;CACA;CACA,UAAU,CAAC;AACb"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as __exportAll } from "./
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
2
|
import { BaseDocumentHeaderSchema, BaseDocumentStateSchema, baseActions, baseCreateDocument, baseLoadFromInput, baseSaveToFileHandle, createAction, createReducer, defaultBaseState, isDocumentAction } from "document-model";
|
|
3
3
|
import * as z$1 from "zod";
|
|
4
4
|
import { z } from "zod";
|
|
@@ -196,4 +196,4 @@ const utils = {
|
|
|
196
196
|
//#endregion
|
|
197
197
|
export { SetEditorNameInputSchema as C, isDefinedNonNullAny as D, definedNonNullAnySchema as E, RemoveDocumentTypeInputSchema as S, StatusTypeSchema as T, setEditorName as _, DocumentEditorDocumentSchema as a, DocumentEditorStateSchema as b, assertIsDocumentEditorState as c, documentEditorDocumentType as d, reducer as f, removeDocumentType as g, creators_exports as h, DocumentEditorDocumentHeaderSchema as i, isDocumentEditorDocument as l, addDocumentType as m, initialLocalState as n, DocumentEditorPHStateSchema as o, actions as p, utils as r, assertIsDocumentEditorDocument as s, initialGlobalState as t, isDocumentEditorState as u, setEditorStatus as v, SetEditorStatusInputSchema as w, DocumentTypeItemSchema as x, AddDocumentTypeInputSchema as y };
|
|
198
198
|
|
|
199
|
-
//# sourceMappingURL=utils-
|
|
199
|
+
//# sourceMappingURL=utils-876N1Sph.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils-DXCsvCXL.js","names":["z","documentEditorBaseOperationsActions"],"sources":["../document-models/document-editor/v1/gen/schema/zod.ts","../document-models/document-editor/v1/gen/base-operations/creators.ts","../document-models/document-editor/v1/actions.ts","../document-models/document-editor/v1/src/reducers/base-operations.ts","../document-models/document-editor/v1/gen/reducer.ts","../document-models/document-editor/v1/gen/document-type.ts","../document-models/document-editor/v1/gen/document-schema.ts","../document-models/document-editor/v1/gen/utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-empty-object-type */\n/* eslint-disable @typescript-eslint/no-unused-vars */\nimport * as z from \"zod\";\nimport type {\n AddDocumentTypeInput,\n DocumentEditorState,\n DocumentTypeItem,\n RemoveDocumentTypeInput,\n SetEditorNameInput,\n SetEditorStatusInput,\n StatusType,\n} from \"./types.js\";\n\ntype Properties<T> = Required<{\n [K in keyof T]: z.ZodType<T[K]>;\n}>;\n\ntype definedNonNullAny = {};\n\nexport const isDefinedNonNullAny = (v: any): v is definedNonNullAny =>\n v !== undefined && v !== null;\n\nexport const definedNonNullAnySchema = z\n .any()\n .refine((v) => isDefinedNonNullAny(v));\n\nexport const StatusTypeSchema = z.enum([\"CONFIRMED\", \"DRAFT\"]);\n\nexport function AddDocumentTypeInputSchema(): z.ZodObject<\n Properties<AddDocumentTypeInput>\n> {\n return z.object({\n documentType: z.string(),\n id: z.string(),\n });\n}\n\nexport function DocumentEditorStateSchema(): z.ZodObject<\n Properties<DocumentEditorState>\n> {\n return z.object({\n __typename: z.literal(\"DocumentEditorState\").optional(),\n documentTypes: z.array(z.lazy(() => DocumentTypeItemSchema())),\n name: z.string(),\n status: StatusTypeSchema,\n });\n}\n\nexport function DocumentTypeItemSchema(): z.ZodObject<\n Properties<DocumentTypeItem>\n> {\n return z.object({\n __typename: z.literal(\"DocumentTypeItem\").optional(),\n documentType: z.string(),\n id: z.string(),\n });\n}\n\nexport function RemoveDocumentTypeInputSchema(): z.ZodObject<\n Properties<RemoveDocumentTypeInput>\n> {\n return z.object({\n id: z.string(),\n });\n}\n\nexport function SetEditorNameInputSchema(): z.ZodObject<\n Properties<SetEditorNameInput>\n> {\n return z.object({\n name: z.string(),\n });\n}\n\nexport function SetEditorStatusInputSchema(): z.ZodObject<\n Properties<SetEditorStatusInput>\n> {\n return z.object({\n status: StatusTypeSchema,\n });\n}\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport { createAction } from \"document-model\";\nimport {\n AddDocumentTypeInputSchema,\n RemoveDocumentTypeInputSchema,\n SetEditorNameInputSchema,\n SetEditorStatusInputSchema,\n} from \"../schema/zod.js\";\nimport type {\n AddDocumentTypeInput,\n RemoveDocumentTypeInput,\n SetEditorNameInput,\n SetEditorStatusInput,\n} from \"../types.js\";\nimport type {\n AddDocumentTypeAction,\n RemoveDocumentTypeAction,\n SetEditorNameAction,\n SetEditorStatusAction,\n} from \"./actions.js\";\n\nexport const setEditorName = (input: SetEditorNameInput) =>\n createAction<SetEditorNameAction>(\n \"SET_EDITOR_NAME\",\n { ...input },\n undefined,\n SetEditorNameInputSchema,\n \"global\",\n );\n\nexport const addDocumentType = (input: AddDocumentTypeInput) =>\n createAction<AddDocumentTypeAction>(\n \"ADD_DOCUMENT_TYPE\",\n { ...input },\n undefined,\n AddDocumentTypeInputSchema,\n \"global\",\n );\n\nexport const removeDocumentType = (input: RemoveDocumentTypeInput) =>\n createAction<RemoveDocumentTypeAction>(\n \"REMOVE_DOCUMENT_TYPE\",\n { ...input },\n undefined,\n RemoveDocumentTypeInputSchema,\n \"global\",\n );\n\nexport const setEditorStatus = (input: SetEditorStatusInput) =>\n createAction<SetEditorStatusAction>(\n \"SET_EDITOR_STATUS\",\n { ...input },\n undefined,\n SetEditorStatusInputSchema,\n \"global\",\n );\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport { baseActions } from \"document-model\";\nimport { documentEditorBaseOperationsActions } from \"./gen/creators.js\";\n\n/** Actions for the DocumentEditor document model */\n\nexport const actions = {\n ...baseActions,\n ...documentEditorBaseOperationsActions,\n};\n","import type { DocumentEditorBaseOperationsOperations } from \"document-models/document-editor/v1\";\n\nexport const documentEditorBaseOperationsOperations: DocumentEditorBaseOperationsOperations =\n {\n setEditorNameOperation(state, action, _dispatch) {\n const trimmedName = action.input.name.trim();\n if (trimmedName === \"\") {\n throw new Error(\"Editor name cannot be empty\");\n }\n state.name = trimmedName;\n },\n addDocumentTypeOperation(state, action, _dispatch) {\n // Check for duplicate ID\n const existingId = state.documentTypes.find(\n (dt) => dt.id === action.input.id,\n );\n if (existingId) {\n throw new Error(\n `Document type with id \"${action.input.id}\" already exists`,\n );\n }\n\n state.documentTypes.push({\n id: action.input.id,\n documentType: action.input.documentType,\n });\n },\n removeDocumentTypeOperation(state, action, _dispatch) {\n state.documentTypes = state.documentTypes.filter(\n (documentType) => documentType.id !== action.input.id,\n );\n },\n setEditorStatusOperation(state, action, _dispatch) {\n state.status = action.input.status;\n },\n };\n","/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-argument */\nimport type { Reducer, StateReducer } from \"document-model\";\nimport { createReducer, isDocumentAction } from \"document-model\";\nimport type { DocumentEditorPHState } from \"document-models/document-editor/v1\";\n\nimport { documentEditorBaseOperationsOperations } from \"../src/reducers/base-operations.js\";\n\nimport {\n AddDocumentTypeInputSchema,\n RemoveDocumentTypeInputSchema,\n SetEditorNameInputSchema,\n SetEditorStatusInputSchema,\n} from \"./schema/zod.js\";\n\nconst stateReducer: StateReducer<DocumentEditorPHState> = (\n state,\n action,\n dispatch,\n) => {\n if (isDocumentAction(action)) {\n return state;\n }\n switch (action.type) {\n case \"SET_EDITOR_NAME\": {\n SetEditorNameInputSchema().parse(action.input);\n\n documentEditorBaseOperationsOperations.setEditorNameOperation(\n (state as any)[action.scope],\n action as any,\n dispatch,\n );\n\n break;\n }\n\n case \"ADD_DOCUMENT_TYPE\": {\n AddDocumentTypeInputSchema().parse(action.input);\n\n documentEditorBaseOperationsOperations.addDocumentTypeOperation(\n (state as any)[action.scope],\n action as any,\n dispatch,\n );\n\n break;\n }\n\n case \"REMOVE_DOCUMENT_TYPE\": {\n RemoveDocumentTypeInputSchema().parse(action.input);\n\n documentEditorBaseOperationsOperations.removeDocumentTypeOperation(\n (state as any)[action.scope],\n action as any,\n dispatch,\n );\n\n break;\n }\n\n case \"SET_EDITOR_STATUS\": {\n SetEditorStatusInputSchema().parse(action.input);\n\n documentEditorBaseOperationsOperations.setEditorStatusOperation(\n (state as any)[action.scope],\n action as any,\n dispatch,\n );\n\n break;\n }\n\n default:\n return state;\n }\n};\n\nexport const reducer: Reducer<DocumentEditorPHState> =\n createReducer(stateReducer);\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nexport const documentEditorDocumentType = \"powerhouse/document-editor\";\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport {\n BaseDocumentHeaderSchema,\n BaseDocumentStateSchema,\n} from \"document-model\";\nimport { z } from \"zod\";\nimport { documentEditorDocumentType } from \"./document-type.js\";\nimport { DocumentEditorStateSchema } from \"./schema/zod.js\";\nimport type { DocumentEditorDocument, DocumentEditorPHState } from \"./types.js\";\n\n/** Schema for validating the header object of a DocumentEditor document */\nexport const DocumentEditorDocumentHeaderSchema =\n BaseDocumentHeaderSchema.extend({\n documentType: z.literal(documentEditorDocumentType),\n });\n\n/** Schema for validating the state object of a DocumentEditor document */\nexport const DocumentEditorPHStateSchema = BaseDocumentStateSchema.extend({\n global: DocumentEditorStateSchema(),\n});\n\nexport const DocumentEditorDocumentSchema = z.object({\n header: DocumentEditorDocumentHeaderSchema,\n state: DocumentEditorPHStateSchema,\n initialState: DocumentEditorPHStateSchema,\n});\n\n/** Simple helper function to check if a state object is a DocumentEditor document state object */\nexport function isDocumentEditorState(\n state: unknown,\n): state is DocumentEditorPHState {\n return DocumentEditorPHStateSchema.safeParse(state).success;\n}\n\n/** Simple helper function to assert that a document state object is a DocumentEditor document state object */\nexport function assertIsDocumentEditorState(\n state: unknown,\n): asserts state is DocumentEditorPHState {\n DocumentEditorPHStateSchema.parse(state);\n}\n\n/** Simple helper function to check if a document is a DocumentEditor document */\nexport function isDocumentEditorDocument(\n document: unknown,\n): document is DocumentEditorDocument {\n return DocumentEditorDocumentSchema.safeParse(document).success;\n}\n\n/** Simple helper function to assert that a document is a DocumentEditor document */\nexport function assertIsDocumentEditorDocument(\n document: unknown,\n): asserts document is DocumentEditorDocument {\n DocumentEditorDocumentSchema.parse(document);\n}\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport type { DocumentModelUtils } from \"document-model\";\nimport {\n baseCreateDocument,\n baseLoadFromInput,\n baseSaveToFileHandle,\n defaultBaseState,\n} from \"document-model\";\nimport {\n assertIsDocumentEditorDocument,\n assertIsDocumentEditorState,\n isDocumentEditorDocument,\n isDocumentEditorState,\n} from \"./document-schema.js\";\nimport { documentEditorDocumentType } from \"./document-type.js\";\nimport { reducer } from \"./reducer.js\";\nimport type {\n DocumentEditorGlobalState,\n DocumentEditorLocalState,\n DocumentEditorPHState,\n} from \"./types.js\";\n\nexport const initialGlobalState: DocumentEditorGlobalState = {\n name: \"\",\n documentTypes: [],\n status: \"DRAFT\",\n};\nexport const initialLocalState: DocumentEditorLocalState = {};\n\nexport const utils: DocumentModelUtils<DocumentEditorPHState> = {\n fileExtension: \".editor\",\n createState(state) {\n return {\n ...defaultBaseState(),\n global: { ...initialGlobalState, ...state?.global },\n local: { ...initialLocalState, ...state?.local },\n };\n },\n createDocument(state) {\n return baseCreateDocument(\n utils.createState,\n state,\n documentEditorDocumentType,\n );\n },\n saveToFileHandle(document, input) {\n return baseSaveToFileHandle(document, input);\n },\n loadFromInput(input) {\n return baseLoadFromInput(input, reducer);\n },\n isStateOfType(state) {\n return isDocumentEditorState(state);\n },\n assertIsStateOfType(state) {\n return assertIsDocumentEditorState(state);\n },\n isDocumentOfType(document) {\n return isDocumentEditorDocument(document);\n },\n assertIsDocumentOfType(document) {\n return assertIsDocumentEditorDocument(document);\n },\n};\n"],"mappings":";;;;;AAmBA,MAAa,uBAAuB,MAClC,MAAM,KAAA,KAAa,MAAM;AAE3B,MAAa,0BAA0BA,IACpC,KAAK,CACL,QAAQ,MAAM,oBAAoB,EAAE,CAAC;AAExC,MAAa,mBAAmBA,IAAE,KAAK,CAAC,aAAa,QAAQ,CAAC;AAE9D,SAAgB,6BAEd;AACA,QAAOA,IAAE,OAAO;EACd,cAAcA,IAAE,QAAQ;EACxB,IAAIA,IAAE,QAAQ;EACf,CAAC;;AAGJ,SAAgB,4BAEd;AACA,QAAOA,IAAE,OAAO;EACd,YAAYA,IAAE,QAAQ,sBAAsB,CAAC,UAAU;EACvD,eAAeA,IAAE,MAAMA,IAAE,WAAW,wBAAwB,CAAC,CAAC;EAC9D,MAAMA,IAAE,QAAQ;EAChB,QAAQ;EACT,CAAC;;AAGJ,SAAgB,yBAEd;AACA,QAAOA,IAAE,OAAO;EACd,YAAYA,IAAE,QAAQ,mBAAmB,CAAC,UAAU;EACpD,cAAcA,IAAE,QAAQ;EACxB,IAAIA,IAAE,QAAQ;EACf,CAAC;;AAGJ,SAAgB,gCAEd;AACA,QAAOA,IAAE,OAAO,EACd,IAAIA,IAAE,QAAQ,EACf,CAAC;;AAGJ,SAAgB,2BAEd;AACA,QAAOA,IAAE,OAAO,EACd,MAAMA,IAAE,QAAQ,EACjB,CAAC;;AAGJ,SAAgB,6BAEd;AACA,QAAOA,IAAE,OAAO,EACd,QAAQ,kBACT,CAAC;;;;;;;;;;;;;;ACvDJ,MAAa,iBAAiB,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AE9C,cAAc,OAAO;AACnB,SAAO,kBAAkB,OAAO,QAAQ;;CAE1C,cAAc,OAAO;AACnB,SAAO,sBAAsB,MAAM;;CAErC,oBAAoB,OAAO;AACzB,SAAO,4BAA4B,MAAM;;CAE3C,iBAAiB,UAAU;AACzB,SAAO,yBAAyB,SAAS;;CAE3C,uBAAuB,UAAU;AAC/B,SAAO,+BAA+B,SAAS;;CAElD"}
|
|
1
|
+
{"version":3,"file":"utils-876N1Sph.js","names":["z","documentEditorBaseOperationsActions"],"sources":["../document-models/document-editor/v1/gen/schema/zod.ts","../document-models/document-editor/v1/gen/base-operations/creators.ts","../document-models/document-editor/v1/actions.ts","../document-models/document-editor/v1/src/reducers/base-operations.ts","../document-models/document-editor/v1/gen/reducer.ts","../document-models/document-editor/v1/gen/document-type.ts","../document-models/document-editor/v1/gen/document-schema.ts","../document-models/document-editor/v1/gen/utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-empty-object-type */\n/* eslint-disable @typescript-eslint/no-unused-vars */\nimport * as z from \"zod\";\nimport type {\n AddDocumentTypeInput,\n DocumentEditorState,\n DocumentTypeItem,\n RemoveDocumentTypeInput,\n SetEditorNameInput,\n SetEditorStatusInput,\n StatusType,\n} from \"./types.js\";\n\ntype Properties<T> = Required<{\n [K in keyof T]: z.ZodType<T[K]>;\n}>;\n\ntype definedNonNullAny = {};\n\nexport const isDefinedNonNullAny = (v: any): v is definedNonNullAny =>\n v !== undefined && v !== null;\n\nexport const definedNonNullAnySchema = z\n .any()\n .refine((v) => isDefinedNonNullAny(v));\n\nexport const StatusTypeSchema = z.enum([\"CONFIRMED\", \"DRAFT\"]);\n\nexport function AddDocumentTypeInputSchema(): z.ZodObject<\n Properties<AddDocumentTypeInput>\n> {\n return z.object({\n documentType: z.string(),\n id: z.string(),\n });\n}\n\nexport function DocumentEditorStateSchema(): z.ZodObject<\n Properties<DocumentEditorState>\n> {\n return z.object({\n __typename: z.literal(\"DocumentEditorState\").optional(),\n documentTypes: z.array(z.lazy(() => DocumentTypeItemSchema())),\n name: z.string(),\n status: StatusTypeSchema,\n });\n}\n\nexport function DocumentTypeItemSchema(): z.ZodObject<\n Properties<DocumentTypeItem>\n> {\n return z.object({\n __typename: z.literal(\"DocumentTypeItem\").optional(),\n documentType: z.string(),\n id: z.string(),\n });\n}\n\nexport function RemoveDocumentTypeInputSchema(): z.ZodObject<\n Properties<RemoveDocumentTypeInput>\n> {\n return z.object({\n id: z.string(),\n });\n}\n\nexport function SetEditorNameInputSchema(): z.ZodObject<\n Properties<SetEditorNameInput>\n> {\n return z.object({\n name: z.string(),\n });\n}\n\nexport function SetEditorStatusInputSchema(): z.ZodObject<\n Properties<SetEditorStatusInput>\n> {\n return z.object({\n status: StatusTypeSchema,\n });\n}\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport { createAction } from \"document-model\";\nimport {\n AddDocumentTypeInputSchema,\n RemoveDocumentTypeInputSchema,\n SetEditorNameInputSchema,\n SetEditorStatusInputSchema,\n} from \"../schema/zod.js\";\nimport type {\n AddDocumentTypeInput,\n RemoveDocumentTypeInput,\n SetEditorNameInput,\n SetEditorStatusInput,\n} from \"../types.js\";\nimport type {\n AddDocumentTypeAction,\n RemoveDocumentTypeAction,\n SetEditorNameAction,\n SetEditorStatusAction,\n} from \"./actions.js\";\n\nexport const setEditorName = (input: SetEditorNameInput) =>\n createAction<SetEditorNameAction>(\n \"SET_EDITOR_NAME\",\n { ...input },\n undefined,\n SetEditorNameInputSchema,\n \"global\",\n );\n\nexport const addDocumentType = (input: AddDocumentTypeInput) =>\n createAction<AddDocumentTypeAction>(\n \"ADD_DOCUMENT_TYPE\",\n { ...input },\n undefined,\n AddDocumentTypeInputSchema,\n \"global\",\n );\n\nexport const removeDocumentType = (input: RemoveDocumentTypeInput) =>\n createAction<RemoveDocumentTypeAction>(\n \"REMOVE_DOCUMENT_TYPE\",\n { ...input },\n undefined,\n RemoveDocumentTypeInputSchema,\n \"global\",\n );\n\nexport const setEditorStatus = (input: SetEditorStatusInput) =>\n createAction<SetEditorStatusAction>(\n \"SET_EDITOR_STATUS\",\n { ...input },\n undefined,\n SetEditorStatusInputSchema,\n \"global\",\n );\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport { baseActions } from \"document-model\";\nimport { documentEditorBaseOperationsActions } from \"./gen/creators.js\";\n\n/** Actions for the DocumentEditor document model */\n\nexport const actions = {\n ...baseActions,\n ...documentEditorBaseOperationsActions,\n};\n","import type { DocumentEditorBaseOperationsOperations } from \"document-models/document-editor/v1\";\n\nexport const documentEditorBaseOperationsOperations: DocumentEditorBaseOperationsOperations =\n {\n setEditorNameOperation(state, action, _dispatch) {\n const trimmedName = action.input.name.trim();\n if (trimmedName === \"\") {\n throw new Error(\"Editor name cannot be empty\");\n }\n state.name = trimmedName;\n },\n addDocumentTypeOperation(state, action, _dispatch) {\n // Check for duplicate ID\n const existingId = state.documentTypes.find(\n (dt) => dt.id === action.input.id,\n );\n if (existingId) {\n throw new Error(\n `Document type with id \"${action.input.id}\" already exists`,\n );\n }\n\n state.documentTypes.push({\n id: action.input.id,\n documentType: action.input.documentType,\n });\n },\n removeDocumentTypeOperation(state, action, _dispatch) {\n state.documentTypes = state.documentTypes.filter(\n (documentType) => documentType.id !== action.input.id,\n );\n },\n setEditorStatusOperation(state, action, _dispatch) {\n state.status = action.input.status;\n },\n };\n","/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-argument */\nimport type { Reducer, StateReducer } from \"document-model\";\nimport { createReducer, isDocumentAction } from \"document-model\";\nimport type { DocumentEditorPHState } from \"document-models/document-editor/v1\";\n\nimport { documentEditorBaseOperationsOperations } from \"../src/reducers/base-operations.js\";\n\nimport {\n AddDocumentTypeInputSchema,\n RemoveDocumentTypeInputSchema,\n SetEditorNameInputSchema,\n SetEditorStatusInputSchema,\n} from \"./schema/zod.js\";\n\nconst stateReducer: StateReducer<DocumentEditorPHState> = (\n state,\n action,\n dispatch,\n) => {\n if (isDocumentAction(action)) {\n return state;\n }\n switch (action.type) {\n case \"SET_EDITOR_NAME\": {\n SetEditorNameInputSchema().parse(action.input);\n\n documentEditorBaseOperationsOperations.setEditorNameOperation(\n (state as any)[action.scope],\n action as any,\n dispatch,\n );\n\n break;\n }\n\n case \"ADD_DOCUMENT_TYPE\": {\n AddDocumentTypeInputSchema().parse(action.input);\n\n documentEditorBaseOperationsOperations.addDocumentTypeOperation(\n (state as any)[action.scope],\n action as any,\n dispatch,\n );\n\n break;\n }\n\n case \"REMOVE_DOCUMENT_TYPE\": {\n RemoveDocumentTypeInputSchema().parse(action.input);\n\n documentEditorBaseOperationsOperations.removeDocumentTypeOperation(\n (state as any)[action.scope],\n action as any,\n dispatch,\n );\n\n break;\n }\n\n case \"SET_EDITOR_STATUS\": {\n SetEditorStatusInputSchema().parse(action.input);\n\n documentEditorBaseOperationsOperations.setEditorStatusOperation(\n (state as any)[action.scope],\n action as any,\n dispatch,\n );\n\n break;\n }\n\n default:\n return state;\n }\n};\n\nexport const reducer: Reducer<DocumentEditorPHState> =\n createReducer(stateReducer);\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nexport const documentEditorDocumentType = \"powerhouse/document-editor\";\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport {\n BaseDocumentHeaderSchema,\n BaseDocumentStateSchema,\n} from \"document-model\";\nimport { z } from \"zod\";\nimport { documentEditorDocumentType } from \"./document-type.js\";\nimport { DocumentEditorStateSchema } from \"./schema/zod.js\";\nimport type { DocumentEditorDocument, DocumentEditorPHState } from \"./types.js\";\n\n/** Schema for validating the header object of a DocumentEditor document */\nexport const DocumentEditorDocumentHeaderSchema =\n BaseDocumentHeaderSchema.extend({\n documentType: z.literal(documentEditorDocumentType),\n });\n\n/** Schema for validating the state object of a DocumentEditor document */\nexport const DocumentEditorPHStateSchema = BaseDocumentStateSchema.extend({\n global: DocumentEditorStateSchema(),\n});\n\nexport const DocumentEditorDocumentSchema = z.object({\n header: DocumentEditorDocumentHeaderSchema,\n state: DocumentEditorPHStateSchema,\n initialState: DocumentEditorPHStateSchema,\n});\n\n/** Simple helper function to check if a state object is a DocumentEditor document state object */\nexport function isDocumentEditorState(\n state: unknown,\n): state is DocumentEditorPHState {\n return DocumentEditorPHStateSchema.safeParse(state).success;\n}\n\n/** Simple helper function to assert that a document state object is a DocumentEditor document state object */\nexport function assertIsDocumentEditorState(\n state: unknown,\n): asserts state is DocumentEditorPHState {\n DocumentEditorPHStateSchema.parse(state);\n}\n\n/** Simple helper function to check if a document is a DocumentEditor document */\nexport function isDocumentEditorDocument(\n document: unknown,\n): document is DocumentEditorDocument {\n return DocumentEditorDocumentSchema.safeParse(document).success;\n}\n\n/** Simple helper function to assert that a document is a DocumentEditor document */\nexport function assertIsDocumentEditorDocument(\n document: unknown,\n): asserts document is DocumentEditorDocument {\n DocumentEditorDocumentSchema.parse(document);\n}\n","/**\n * WARNING: DO NOT EDIT\n * This file is auto-generated and updated by codegen\n */\nimport type { DocumentModelUtils } from \"document-model\";\nimport {\n baseCreateDocument,\n baseLoadFromInput,\n baseSaveToFileHandle,\n defaultBaseState,\n} from \"document-model\";\nimport {\n assertIsDocumentEditorDocument,\n assertIsDocumentEditorState,\n isDocumentEditorDocument,\n isDocumentEditorState,\n} from \"./document-schema.js\";\nimport { documentEditorDocumentType } from \"./document-type.js\";\nimport { reducer } from \"./reducer.js\";\nimport type {\n DocumentEditorGlobalState,\n DocumentEditorLocalState,\n DocumentEditorPHState,\n} from \"./types.js\";\n\nexport const initialGlobalState: DocumentEditorGlobalState = {\n name: \"\",\n documentTypes: [],\n status: \"DRAFT\",\n};\nexport const initialLocalState: DocumentEditorLocalState = {};\n\nexport const utils: DocumentModelUtils<DocumentEditorPHState> = {\n fileExtension: \".editor\",\n createState(state) {\n return {\n ...defaultBaseState(),\n global: { ...initialGlobalState, ...state?.global },\n local: { ...initialLocalState, ...state?.local },\n };\n },\n createDocument(state) {\n return baseCreateDocument(\n utils.createState,\n state,\n documentEditorDocumentType,\n );\n },\n saveToFileHandle(document, input) {\n return baseSaveToFileHandle(document, input);\n },\n loadFromInput(input) {\n return baseLoadFromInput(input, reducer);\n },\n isStateOfType(state) {\n return isDocumentEditorState(state);\n },\n assertIsStateOfType(state) {\n return assertIsDocumentEditorState(state);\n },\n isDocumentOfType(document) {\n return isDocumentEditorDocument(document);\n },\n assertIsDocumentOfType(document) {\n return assertIsDocumentEditorDocument(document);\n },\n};\n"],"mappings":";;;;;AAmBA,MAAa,uBAAuB,MAClC,MAAM,KAAA,KAAa,MAAM;AAE3B,MAAa,0BAA0BA,IACpC,IAAI,CAAC,CACL,QAAQ,MAAM,oBAAoB,CAAC,CAAC;AAEvC,MAAa,mBAAmBA,IAAE,KAAK,CAAC,aAAa,OAAO,CAAC;AAE7D,SAAgB,6BAEd;CACA,OAAOA,IAAE,OAAO;EACd,cAAcA,IAAE,OAAO;EACvB,IAAIA,IAAE,OAAO;CACf,CAAC;AACH;AAEA,SAAgB,4BAEd;CACA,OAAOA,IAAE,OAAO;EACd,YAAYA,IAAE,QAAQ,qBAAqB,CAAC,CAAC,SAAS;EACtD,eAAeA,IAAE,MAAMA,IAAE,WAAW,uBAAuB,CAAC,CAAC;EAC7D,MAAMA,IAAE,OAAO;EACf,QAAQ;CACV,CAAC;AACH;AAEA,SAAgB,yBAEd;CACA,OAAOA,IAAE,OAAO;EACd,YAAYA,IAAE,QAAQ,kBAAkB,CAAC,CAAC,SAAS;EACnD,cAAcA,IAAE,OAAO;EACvB,IAAIA,IAAE,OAAO;CACf,CAAC;AACH;AAEA,SAAgB,gCAEd;CACA,OAAOA,IAAE,OAAO,EACd,IAAIA,IAAE,OAAO,EACf,CAAC;AACH;AAEA,SAAgB,2BAEd;CACA,OAAOA,IAAE,OAAO,EACd,MAAMA,IAAE,OAAO,EACjB,CAAC;AACH;AAEA,SAAgB,6BAEd;CACA,OAAOA,IAAE,O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AO;GAAM;EACjD;CACF;CACA,eAAe,OAAO;EACpB,OAAO,mBACL,MAAM,aACN,OACA,0BACF;CACF;CACA,iBAAiB,UAAU,OAAO;EAChC,OAAO,qBAAqB,UAAU,KAAK;CAC7C;CACA,cAAc,OAAO;EACnB,OAAO,kBAAkB,OAAO,OAAO;CACzC;CACA,cAAc,OAAO;EACnB,OAAO,sBAAsB,KAAK;CACpC;CACA,oBAAoB,OAAO;EACzB,OAAO,4BAA4B,KAAK;CAC1C;CACA,iBAAiB,UAAU;EACzB,OAAO,yBAAyB,QAAQ;CAC1C;CACA,uBAAuB,UAAU;EAC/B,OAAO,+BAA+B,QAAQ;CAChD;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as __exportAll } from "./
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
2
|
import { BaseDocumentHeaderSchema, BaseDocumentStateSchema, baseActions, baseCreateDocument, baseLoadFromInput, baseSaveToFileHandle, createAction, createReducer, defaultBaseState, isDocumentAction } from "document-model";
|
|
3
3
|
import * as z$1 from "zod";
|
|
4
4
|
import { z } from "zod";
|
|
@@ -156,4 +156,4 @@ const utils = {
|
|
|
156
156
|
//#endregion
|
|
157
157
|
export { isDefinedNonNullAny as S, SetSubgraphNameInputSchema as _, SubgraphModuleDocumentSchema as a, SubgraphModuleStateSchema as b, assertIsSubgraphModuleState as c, subgraphModuleDocumentType as d, reducer as f, setSubgraphStatus as g, setSubgraphName as h, SubgraphModuleDocumentHeaderSchema as i, isSubgraphModuleDocument as l, creators_exports as m, initialLocalState as n, SubgraphModulePHStateSchema as o, actions as p, utils as r, assertIsSubgraphModuleDocument as s, initialGlobalState as t, isSubgraphModuleState as u, SetSubgraphStatusInputSchema as v, definedNonNullAnySchema as x, StatusTypeSchema as y };
|
|
158
158
|
|
|
159
|
-
//# sourceMappingURL=utils-
|
|
159
|
+
//# sourceMappingURL=utils-Al_SGg2a.js.map
|