@powerhousedao/reactor-api 6.2.3-dev.94 → 6.2.3-dev.95
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/{base-document-models-577xnrmL.mjs → base-document-models-CCYv5XxL.mjs} +245 -228
- package/dist/base-document-models-CCYv5XxL.mjs.map +1 -0
- package/dist/{create-schema-BO0wYVr2.d.mts → create-schema-DJzlm_Fz.d.mts} +2 -2
- package/dist/{create-schema-BO0wYVr2.d.mts.map → create-schema-DJzlm_Fz.d.mts.map} +1 -1
- package/dist/index.d.mts +78 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +112 -47
- package/dist/index.mjs.map +1 -1
- package/dist/{package-subgraph-check-zi0YDhBj.mjs → package-subgraph-check-DPlf58ps.mjs} +4 -4
- package/dist/{package-subgraph-check-zi0YDhBj.mjs.map → package-subgraph-check-DPlf58ps.mjs.map} +1 -1
- package/dist/src/graphql/subgraph-types.d.mts +1 -1
- package/dist/src/graphql/subgraph-types.mjs +1 -1
- package/dist/src/packages/vite-loader.d.mts +1 -1
- package/dist/src/packages/vite-loader.d.mts.map +1 -1
- package/dist/src/packages/vite-loader.mjs +17 -10
- package/dist/src/packages/vite-loader.mjs.map +1 -1
- package/dist/{subgraph-extraction-DioqM_Dc.mjs → subgraph-extraction-C_hFvSaS.mjs} +9 -4
- package/dist/{subgraph-extraction-DioqM_Dc.mjs.map → subgraph-extraction-C_hFvSaS.mjs.map} +1 -1
- package/dist/{types-PXB1ctpi.d.mts → types-Bz_xjf8j.d.mts} +8 -2
- package/dist/types-Bz_xjf8j.d.mts.map +1 -0
- package/package.json +13 -13
- package/dist/base-document-models-577xnrmL.mjs.map +0 -1
- package/dist/types-PXB1ctpi.d.mts.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
-
import {
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="aceef59e-9d4a-5f8d-bfb3-f7990add4124")}catch(e){}}();
|
|
3
|
+
import { E as findSubgraphTypeCollisions, N as reservedTypeNames, O as generatedTypesOf, V as schema_default$1, a as inspectionAdminTypeDefs, f as decideAdmission, g as collectSubgraphClaims, h as supergraphClaimLosers, i as inspectionTypeDefs, j as getGeneratedDocumentModelTypes, k as getDocumentModelSubgraphName, l as RegistrationOrder, m as documentModelSubgraphSources, n as systemTypeDefs, o as CORE_ORIGIN, p as describeOrigin, r as schema_default, s as DOCUMENT_MODEL_ORIGIN, t as baseDocumentModels, u as admitDocumentModels, v as DocumentModelSchemaCache } from "./base-document-models-CCYv5XxL.mjs";
|
|
4
4
|
import "./subgraph-schema-owner-BEjuk2Xv.mjs";
|
|
5
5
|
import { typedefs } from "@powerhousedao/analytics-engine-graphql";
|
|
6
6
|
import { gql } from "graphql-tag";
|
|
@@ -134,5 +134,5 @@ function checkPackageSubgraphs(subgraphs, documentModels) {
|
|
|
134
134
|
//#endregion
|
|
135
135
|
export { checkPackageSubgraphs };
|
|
136
136
|
|
|
137
|
-
//# sourceMappingURL=package-subgraph-check-
|
|
138
|
-
//# debugId=
|
|
137
|
+
//# sourceMappingURL=package-subgraph-check-DPlf58ps.mjs.map
|
|
138
|
+
//# debugId=aceef59e-9d4a-5f8d-bfb3-f7990add4124
|
package/dist/{package-subgraph-check-zi0YDhBj.mjs.map → package-subgraph-check-DPlf58ps.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-subgraph-check-zi0YDhBj.mjs","sources":["../src/graphql/package-subgraph-check.ts"],"sourcesContent":["import { typedefs as analyticsTypeDefs } from \"@powerhousedao/analytics-engine-graphql\";\nimport type { DocumentModelGlobalState } from \"@powerhousedao/shared/document-model\";\nimport type { DocumentNode } from \"graphql\";\nimport { gql } from \"graphql-tag\";\nimport { baseDocumentModels } from \"../packages/base-document-models.js\";\nimport {\n DocumentModelSchemaCache,\n type DocumentModelSource,\n findSubgraphTypeCollisions,\n generatedTypesOf,\n getDocumentModelSubgraphName,\n getGeneratedDocumentModelTypes,\n reservedTypeNames,\n} from \"../utils/create-schema.js\";\nimport authSchema from \"./auth/schema.graphql\";\nimport { inspectionAdminTypeDefs } from \"./inspection/admin-schema.js\";\nimport { inspectionTypeDefs } from \"./inspection/schema.js\";\nimport reactorSchema from \"./reactor/schema.graphql\";\nimport {\n type Admission,\n admitDocumentModels,\n CORE_ORIGIN,\n decideAdmission,\n describeOrigin,\n DOCUMENT_MODEL_ORIGIN,\n documentModelSubgraphSources,\n RegistrationOrder,\n type SubgraphOrigin,\n supergraphClaimLosers,\n} from \"./subgraph-admission.js\";\nimport {\n collectSubgraphClaims,\n type SubgraphClaims,\n} from \"./subgraph-type-ownership.js\";\nimport { systemTypeDefs } from \"./system/schema.js\";\nimport { DOCUMENT_MODEL_SCHEMA_OWNER } from \"./subgraph-schema-owner.js\";\nimport type {\n PackageSubgraph,\n PackageSubgraphConflicts,\n PackageSubgraphReport,\n RefusedDocumentModel,\n} from \"./subgraph-types.js\";\n\n/** The type definitions of every core subgraph, by subgraph name. */\nexport const coreSubgraphTypeDefs: ReadonlyMap<string, DocumentNode> = new Map([\n [\"analytics\", gql(analyticsTypeDefs)],\n [\"system\", systemTypeDefs],\n [\"r\", gql(reactorSchema)],\n [\"inspection\", inspectionTypeDefs],\n [\"inspection-admin\", inspectionAdminTypeDefs],\n [\"auth\", gql(authSchema)],\n]);\n\nconst PACKAGE_ORIGIN: SubgraphOrigin = \"package\";\n\ntype Registered = {\n name: string;\n origin: SubgraphOrigin;\n typeDefs: DocumentNode;\n ownTypeNames?: ReadonlySet<string>;\n};\n\ntype Rejection = Extract<Admission<Registered>, { action: \"reject\" }>;\n\nfunction claimsOf(typeDefs: DocumentNode, generated: ReadonlySet<string>) {\n try {\n return collectSubgraphClaims(typeDefs, generated);\n } catch {\n // Malformed typeDefs fail where the schema is built, so claim nothing.\n return new Map() as SubgraphClaims;\n }\n}\n\nfunction describeModelSubgraphRejection(rejection: Rejection): string {\n switch (rejection.reason) {\n case \"core name\":\n return `its subgraph name is taken by a subgraph from ${describeOrigin(CORE_ORIGIN)}`;\n case \"rank\":\n return `its subgraph name is taken by a subgraph from ${describeOrigin(rejection.holderOrigin)}`;\n case \"collision\":\n return `its subgraph defines generated types: ${rejection.collisions.join(\", \")}`;\n }\n}\n\nfunction packageConflict(\n rejection: Rejection,\n owners: ReadonlyMap<string, string>,\n): PackageSubgraphConflicts {\n switch (rejection.reason) {\n case \"core name\":\n return { nameHeldBy: \"core\", claims: [] };\n case \"rank\":\n return { nameHeldBy: \"document model\", claims: [] };\n case \"collision\":\n return {\n claims: rejection.collisions.map((claim) => ({\n claim,\n owner: owners.get(claim) ?? DOCUMENT_MODEL_SCHEMA_OWNER,\n })),\n };\n }\n}\n\n/** Server admission replayed for one package; hosts and other packages unknown. */\nexport function checkPackageSubgraphs(\n subgraphs: readonly PackageSubgraph[],\n documentModels: readonly DocumentModelGlobalState[],\n): PackageSubgraphReport {\n const packageModels: DocumentModelSource[] = documentModels.map((global) => ({\n documentModel: { global },\n }));\n const { admitted, schemas, refusals } = admitDocumentModels(\n new DocumentModelSchemaCache<DocumentModelSource>().resolve([\n ...baseDocumentModels.map(([, model]) => model),\n ...packageModels,\n ]),\n reservedTypeNames(coreSubgraphTypeDefs.values()),\n );\n const generated = getGeneratedDocumentModelTypes(admitted, schemas);\n const fixed = generatedTypesOf([]).names;\n const generatedOwners = new Map<string, string>();\n for (const model of admitted) {\n const owner = getDocumentModelSubgraphName(model.documentModel.global);\n const { names } = getGeneratedDocumentModelTypes([model], schemas);\n for (const name of names) {\n if (!fixed.has(name)) generatedOwners.set(name, owner);\n }\n }\n\n const holders = new Map<string, Registered>();\n const order = new RegistrationOrder();\n const register = (entry: Registered): Admission<Registered> => {\n const holder = holders.get(entry.name);\n const admission = decideAdmission(\n entry,\n entry.origin,\n holder ? [{ holder, origin: holder.origin }] : [],\n () => {\n try {\n return findSubgraphTypeCollisions(\n generated,\n entry.typeDefs,\n entry.ownTypeNames,\n );\n } catch {\n return [];\n }\n },\n );\n if (admission.action === \"add\") {\n holders.set(entry.name, entry);\n order.record(entry.origin, entry.name);\n }\n return admission;\n };\n\n for (const [name, typeDefs] of coreSubgraphTypeDefs) {\n register({ name, origin: CORE_ORIGIN, typeDefs });\n }\n\n const refusedModels: RefusedDocumentModel[] = refusals\n .filter(({ model }) => packageModels.includes(model))\n .map(({ model, reason, subgraphOnly }) => ({\n name: model.documentModel.global.name,\n reason,\n subgraphOnly,\n }));\n for (const { model, types } of documentModelSubgraphSources(\n admitted,\n schemas,\n )) {\n const admission = register({\n name: getDocumentModelSubgraphName(model.documentModel.global),\n origin: DOCUMENT_MODEL_ORIGIN,\n typeDefs: types.typeDefs,\n ownTypeNames: types.typeNames,\n });\n if (admission.action === \"reject\" && packageModels.includes(model)) {\n refusedModels.push({\n name: model.documentModel.global.name,\n reason: describeModelSubgraphRejection(admission),\n subgraphOnly: true,\n });\n }\n }\n\n const conflicts = new Map<string, PackageSubgraphConflicts>();\n for (const { name, typeDefs } of subgraphs) {\n const admission = register({ name, origin: PACKAGE_ORIGIN, typeDefs });\n if (admission.action === \"reject\") {\n conflicts.set(name, packageConflict(admission, generatedOwners));\n } else if (admission.action === \"add\" && admission.replaces.length > 0) {\n conflicts.set(name, { nameHeldBy: \"package\", claims: [] });\n }\n }\n\n const excluded = supergraphClaimLosers(\n Array.from(holders.values(), (entry) => ({\n member: entry,\n name: entry.name,\n origin: entry.origin,\n claims: claimsOf(entry.typeDefs, generated.names),\n })),\n order,\n );\n for (const [entry, claims] of excluded) {\n if (entry.origin !== PACKAGE_ORIGIN) continue;\n conflicts.set(entry.name, { ...conflicts.get(entry.name), claims });\n }\n return { conflicts, refusedModels };\n}\n"],"names":["analyticsTypeDefs","reactorSchema","authSchema"],"mappings":";;;;;;;;AA4CA,MAAa,uCAA0D,IAAI,IAAI;CAC7E,CAAC,aAAa,IAAIA,QAAiB,CAAC;CACpC,CAAC,UAAU,cAAc;CACzB,CAAC,KAAK,IAAIC,cAAa,CAAC;CACxB,CAAC,cAAc,kBAAkB;CACjC,CAAC,oBAAoB,uBAAuB;CAC5C,CAAC,QAAQ,IAAIC,gBAAU,CAAC;AAC1B,CAAC;AAED,MAAM,iBAAiC;AAWvC,SAAS,SAAS,UAAwB,WAAgC;CACxE,IAAI;EACF,OAAO,sBAAsB,UAAU,SAAS;CAClD,QAAQ;EAEN,uBAAO,IAAI,IAAI;CACjB;AACF;AAEA,SAAS,+BAA+B,WAA8B;CACpE,QAAQ,UAAU,QAAlB;EACE,KAAK,aACH,OAAO,iDAAiD,eAAe,WAAW;EACpF,KAAK,QACH,OAAO,iDAAiD,eAAe,UAAU,YAAY;EAC/F,KAAK,aACH,OAAO,yCAAyC,UAAU,WAAW,KAAK,IAAI;CAClF;AACF;AAEA,SAAS,gBACP,WACA,QAC0B;CAC1B,QAAQ,UAAU,QAAlB;EACE,KAAK,aACH,OAAO;GAAE,YAAY;GAAQ,QAAQ,CAAC;EAAE;EAC1C,KAAK,QACH,OAAO;GAAE,YAAY;GAAkB,QAAQ,CAAC;EAAE;EACpD,KAAK,aACH,OAAO,EACL,QAAQ,UAAU,WAAW,KAAK,WAAW;GAC3C;GACA,OAAO,OAAO,IAAI,KAAK,KAAA;EACzB,EAAE,EACJ;CACJ;AACF;;AAGA,SAAgB,sBACd,WACA,gBACuB;CACvB,MAAM,gBAAuC,eAAe,KAAK,YAAY,EAC3E,eAAe,EAAE,OAAO,EAC1B,EAAE;CACF,MAAM,EAAE,UAAU,SAAS,aAAa,oBACtC,IAAI,yB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J,KAAK,MAAM,EAAE,OAAO,WAAW,6BAC7B,UACA,OACF,GAAG;EACD,MAAM,YAAY,SAAS;GACzB,MAAM,6BAA6B,MAAM,cAAc,MAAM;GAC7D,QAAQ;GACR,UAAU,MAAM;GAChB,cAAc,MAAM;EACtB,CAAC;EACD,IAAI,UAAU,WAAW,YAAY,cAAc,SAAS,KAAK,GAC/D,cAAc,KAAK;GACjB,MAAM,MAAM,cAAc,OAAO;GACjC,QAAQ,+BAA+B,SAAS;GAChD,cAAc;EAChB,CAAC;CAEL;CAEA,MAAM,4BAAY,IAAI,IAAsC;CAC5D,KAAK,MAAM,EAAE,MAAM,cAAc,WAAW;EAC1C,MAAM,YAAY,SAAS;GAAE;GAAM,QAAQ;GAAgB;EAAS,CAAC;EACrE,IAAI,UAAU,WAAW,UACvB,UAAU,IAAI,MAAM,gBAAgB,WAAW,eAAe,CAAC;OAC1D,IAAI,UAAU,WAAW,SAAS,UAAU,SAAS,SAAS,GACnE,UAAU,IAAI,MAAM;GAAE,YAAY;GAAW,QAAQ,CAAC;EAAE,CAAC;CAE7D;CAEA,MAAM,WAAW,sBACf,MAAM,KAAK,QAAQ,OAAO,IAAI,WAAW;EACvC,QAAQ;EACR,MAAM,MAAM;EACZ,QAAQ,MAAM;EACd,QAAQ,SAAS,MAAM,UAAU,UAAU,KAAK;CAClD,EAAE,GACF,KACF;CACA,KAAK,MAAM,CAAC,OAAO,WAAW,UAAU;EACtC,IAAI,MAAM,WAAW,gBAAgB;EACrC,UAAU,IAAI,MAAM,MAAM;GAAE,GAAG,UAAU,IAAI,MAAM,IAAI;GAAG;EAAO,CAAC;CACpE;CACA,OAAO;EAAE;EAAW;CAAc;AACpC","debug_id":"8b8a8d26-ec43-5a5b-ad2c-945fcd5e384f"}
|
|
1
|
+
{"version":3,"file":"package-subgraph-check-DPlf58ps.mjs","sources":["../src/graphql/package-subgraph-check.ts"],"sourcesContent":["import { typedefs as analyticsTypeDefs } from \"@powerhousedao/analytics-engine-graphql\";\nimport type { DocumentModelGlobalState } from \"@powerhousedao/shared/document-model\";\nimport type { DocumentNode } from \"graphql\";\nimport { gql } from \"graphql-tag\";\nimport { baseDocumentModels } from \"../packages/base-document-models.js\";\nimport {\n DocumentModelSchemaCache,\n type DocumentModelSource,\n findSubgraphTypeCollisions,\n generatedTypesOf,\n getDocumentModelSubgraphName,\n getGeneratedDocumentModelTypes,\n reservedTypeNames,\n} from \"../utils/create-schema.js\";\nimport authSchema from \"./auth/schema.graphql\";\nimport { inspectionAdminTypeDefs } from \"./inspection/admin-schema.js\";\nimport { inspectionTypeDefs } from \"./inspection/schema.js\";\nimport reactorSchema from \"./reactor/schema.graphql\";\nimport {\n type Admission,\n admitDocumentModels,\n CORE_ORIGIN,\n decideAdmission,\n describeOrigin,\n DOCUMENT_MODEL_ORIGIN,\n documentModelSubgraphSources,\n RegistrationOrder,\n type SubgraphOrigin,\n supergraphClaimLosers,\n} from \"./subgraph-admission.js\";\nimport {\n collectSubgraphClaims,\n type SubgraphClaims,\n} from \"./subgraph-type-ownership.js\";\nimport { systemTypeDefs } from \"./system/schema.js\";\nimport { DOCUMENT_MODEL_SCHEMA_OWNER } from \"./subgraph-schema-owner.js\";\nimport type {\n PackageSubgraph,\n PackageSubgraphConflicts,\n PackageSubgraphReport,\n RefusedDocumentModel,\n} from \"./subgraph-types.js\";\n\n/** The type definitions of every core subgraph, by subgraph name. */\nexport const coreSubgraphTypeDefs: ReadonlyMap<string, DocumentNode> = new Map([\n [\"analytics\", gql(analyticsTypeDefs)],\n [\"system\", systemTypeDefs],\n [\"r\", gql(reactorSchema)],\n [\"inspection\", inspectionTypeDefs],\n [\"inspection-admin\", inspectionAdminTypeDefs],\n [\"auth\", gql(authSchema)],\n]);\n\nconst PACKAGE_ORIGIN: SubgraphOrigin = \"package\";\n\ntype Registered = {\n name: string;\n origin: SubgraphOrigin;\n typeDefs: DocumentNode;\n ownTypeNames?: ReadonlySet<string>;\n};\n\ntype Rejection = Extract<Admission<Registered>, { action: \"reject\" }>;\n\nfunction claimsOf(typeDefs: DocumentNode, generated: ReadonlySet<string>) {\n try {\n return collectSubgraphClaims(typeDefs, generated);\n } catch {\n // Malformed typeDefs fail where the schema is built, so claim nothing.\n return new Map() as SubgraphClaims;\n }\n}\n\nfunction describeModelSubgraphRejection(rejection: Rejection): string {\n switch (rejection.reason) {\n case \"core name\":\n return `its subgraph name is taken by a subgraph from ${describeOrigin(CORE_ORIGIN)}`;\n case \"rank\":\n return `its subgraph name is taken by a subgraph from ${describeOrigin(rejection.holderOrigin)}`;\n case \"collision\":\n return `its subgraph defines generated types: ${rejection.collisions.join(\", \")}`;\n }\n}\n\nfunction packageConflict(\n rejection: Rejection,\n owners: ReadonlyMap<string, string>,\n): PackageSubgraphConflicts {\n switch (rejection.reason) {\n case \"core name\":\n return { nameHeldBy: \"core\", claims: [] };\n case \"rank\":\n return { nameHeldBy: \"document model\", claims: [] };\n case \"collision\":\n return {\n claims: rejection.collisions.map((claim) => ({\n claim,\n owner: owners.get(claim) ?? DOCUMENT_MODEL_SCHEMA_OWNER,\n })),\n };\n }\n}\n\n/** Server admission replayed for one package; hosts and other packages unknown. */\nexport function checkPackageSubgraphs(\n subgraphs: readonly PackageSubgraph[],\n documentModels: readonly DocumentModelGlobalState[],\n): PackageSubgraphReport {\n const packageModels: DocumentModelSource[] = documentModels.map((global) => ({\n documentModel: { global },\n }));\n const { admitted, schemas, refusals } = admitDocumentModels(\n new DocumentModelSchemaCache<DocumentModelSource>().resolve([\n ...baseDocumentModels.map(([, model]) => model),\n ...packageModels,\n ]),\n reservedTypeNames(coreSubgraphTypeDefs.values()),\n );\n const generated = getGeneratedDocumentModelTypes(admitted, schemas);\n const fixed = generatedTypesOf([]).names;\n const generatedOwners = new Map<string, string>();\n for (const model of admitted) {\n const owner = getDocumentModelSubgraphName(model.documentModel.global);\n const { names } = getGeneratedDocumentModelTypes([model], schemas);\n for (const name of names) {\n if (!fixed.has(name)) generatedOwners.set(name, owner);\n }\n }\n\n const holders = new Map<string, Registered>();\n const order = new RegistrationOrder();\n const register = (entry: Registered): Admission<Registered> => {\n const holder = holders.get(entry.name);\n const admission = decideAdmission(\n entry,\n entry.origin,\n holder ? [{ holder, origin: holder.origin }] : [],\n () => {\n try {\n return findSubgraphTypeCollisions(\n generated,\n entry.typeDefs,\n entry.ownTypeNames,\n );\n } catch {\n return [];\n }\n },\n );\n if (admission.action === \"add\") {\n holders.set(entry.name, entry);\n order.record(entry.origin, entry.name);\n }\n return admission;\n };\n\n for (const [name, typeDefs] of coreSubgraphTypeDefs) {\n register({ name, origin: CORE_ORIGIN, typeDefs });\n }\n\n const refusedModels: RefusedDocumentModel[] = refusals\n .filter(({ model }) => packageModels.includes(model))\n .map(({ model, reason, subgraphOnly }) => ({\n name: model.documentModel.global.name,\n reason,\n subgraphOnly,\n }));\n for (const { model, types } of documentModelSubgraphSources(\n admitted,\n schemas,\n )) {\n const admission = register({\n name: getDocumentModelSubgraphName(model.documentModel.global),\n origin: DOCUMENT_MODEL_ORIGIN,\n typeDefs: types.typeDefs,\n ownTypeNames: types.typeNames,\n });\n if (admission.action === \"reject\" && packageModels.includes(model)) {\n refusedModels.push({\n name: model.documentModel.global.name,\n reason: describeModelSubgraphRejection(admission),\n subgraphOnly: true,\n });\n }\n }\n\n const conflicts = new Map<string, PackageSubgraphConflicts>();\n for (const { name, typeDefs } of subgraphs) {\n const admission = register({ name, origin: PACKAGE_ORIGIN, typeDefs });\n if (admission.action === \"reject\") {\n conflicts.set(name, packageConflict(admission, generatedOwners));\n } else if (admission.action === \"add\" && admission.replaces.length > 0) {\n conflicts.set(name, { nameHeldBy: \"package\", claims: [] });\n }\n }\n\n const excluded = supergraphClaimLosers(\n Array.from(holders.values(), (entry) => ({\n member: entry,\n name: entry.name,\n origin: entry.origin,\n claims: claimsOf(entry.typeDefs, generated.names),\n })),\n order,\n );\n for (const [entry, claims] of excluded) {\n if (entry.origin !== PACKAGE_ORIGIN) continue;\n conflicts.set(entry.name, { ...conflicts.get(entry.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,SAAS;GACzB,MAAM,6BAA6B,MAAM,cAAc,MAAM;GAC7D,QAAQ;GACR,UAAU,MAAM;GAChB,cAAc,MAAM;EACtB,CAAC;EACD,IAAI,UAAU,WAAW,YAAY,cAAc,SAAS,KAAK,GAC/D,cAAc,KAAK;GACjB,MAAM,MAAM,cAAc,OAAO;GACjC,QAAQ,+BAA+B,SAAS;GAChD,cAAc;EAChB,CAAC;CAEL;CAEA,MAAM,4BAAY,IAAI,IAAsC;CAC5D,KAAK,MAAM,EAAE,MAAM,cAAc,WAAW;EAC1C,MAAM,YAAY,SAAS;GAAE;GAAM,QAAQ;GAAgB;EAAS,CAAC;EACrE,IAAI,UAAU,WAAW,UACvB,UAAU,IAAI,MAAM,gBAAgB,WAAW,eAAe,CAAC;OAC1D,IAAI,UAAU,WAAW,SAAS,UAAU,SAAS,SAAS,GACnE,UAAU,IAAI,MAAM;GAAE,YAAY;GAAW,QAAQ,CAAC;EAAE,CAAC;CAE7D;CAEA,MAAM,WAAW,sBACf,MAAM,KAAK,QAAQ,OAAO,IAAI,WAAW;EACvC,QAAQ;EACR,MAAM,MAAM;EACZ,QAAQ,MAAM;EACd,QAAQ,SAAS,MAAM,UAAU,UAAU,KAAK;CAClD,EAAE,GACF,KACF;CACA,KAAK,MAAM,CAAC,OAAO,WAAW,UAAU;EACtC,IAAI,MAAM,WAAW,gBAAgB;EACrC,UAAU,IAAI,MAAM,MAAM;GAAE,GAAG,UAAU,IAAI,MAAM,IAAI;GAAG;EAAO,CAAC;CACpE;CACA,OAAO;EAAE;EAAW;CAAc;AACpC","debug_id":"aceef59e-9d4a-5f8d-bfb3-f7990add4124"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as ReservedTypeNames } from "../../create-schema-
|
|
1
|
+
import { i as ReservedTypeNames } from "../../create-schema-DJzlm_Fz.mjs";
|
|
2
2
|
import { DocumentNode } from "graphql";
|
|
3
3
|
import { DocumentModelGlobalState } from "@powerhousedao/shared/document-model";
|
|
4
4
|
//#region src/graphql/subgraph-type-ownership.d.ts
|
|
@@ -4,7 +4,7 @@ import { t as DOCUMENT_MODEL_SCHEMA_OWNER } from "../../subgraph-schema-owner-BE
|
|
|
4
4
|
//#region src/graphql/subgraph-types.ts
|
|
5
5
|
/** Loaded on call: the check pulls in the base models and core schemas. */
|
|
6
6
|
async function findPackageSubgraphConflicts(subgraphs, documentModels) {
|
|
7
|
-
const { checkPackageSubgraphs } = await import("../../package-subgraph-check-
|
|
7
|
+
const { checkPackageSubgraphs } = await import("../../package-subgraph-check-DPlf58ps.mjs");
|
|
8
8
|
return checkPackageSubgraphs(subgraphs, documentModels);
|
|
9
9
|
}
|
|
10
10
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as ScalarExport,
|
|
1
|
+
import { d as ScalarExport, o as ISubscribablePackageLoader, p as ReportError, s as ISubscriptionOptions, u as PackagePieceEntry } from "../../types-Bz_xjf8j.mjs";
|
|
2
2
|
import { ILogger } from "document-model";
|
|
3
3
|
import { DocumentModelModule, UpgradeManifest } from "@powerhousedao/shared/document-model";
|
|
4
4
|
import { Logger, ViteDevServer } from "vite";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-loader.d.mts","names":[],"sources":["../../../src/packages/vite-loader.mts"],"mappings":";;;;;;wBAwCgB,iBAAiB,QAAQ,SAAS,kBAAW;iBA2B5C;;;EAGf;EACA,cAAc;;
|
|
1
|
+
{"version":3,"file":"vite-loader.d.mts","names":[],"sources":["../../../src/packages/vite-loader.mts"],"mappings":";;;;;;wBAwCgB,iBAAiB,QAAQ,SAAS,kBAAW;iBA2B5C;;;EAGf;EACA,cAAc;;qBAUH,6BAA6B;;mBACvB;mBAEA;mBAEA;WAQR;SAEF,MAAM,MAAM,eAAe,UAAU,2BAAwB;EAIpE,YAAY,MAAM,eAAe,UAAS;UA+DlC;UAIA;UAIA;UAIA;UAIA;UAMA;UASA;EAcF,mBAAmB,qBAAqB,QAAQ;EAmBhD,qBACJ,qBACC,QAAQ;EAoBL,cAAc,qBAAqB,QAAQ;EAiB3C,YAAY,qBAAqB,QAAQ;EAczC,eACJ,qBACC,QAAQ;EAkBL,WAAW,qBAAqB,QAAQ;EAyF9C,uBACE,oBACA,UAAU,gBAAgB,gCAC1B,UAAU;EAgBZ,kBACE,oBACA,UAAU,WAAW,0BACrB,UAAU;EAaZ,gBACE,oBACA,UAAU,SAAS,yBACnB,UAAU;EAaZ,mBACE,oBACA,UAAU,YAAY,yCACtB,UAAU;EAaZ,eACE,oBACA,UAAU,QAAQ,8BAClB,UAAU;;;;;;;;wBA4BE,2BAA2B,gBAAY;wBAqBjC,gBAAgB,cAAc,SAAS,SAAM,QAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
-
import { S as isSubpath, _ as runDetached, b as extractUpgradeManifests, i as PIECES_SUBPATH, l as piecesFromListModule, n as scalarExportsOf, o as packageRootOf, r as BUILT_PIECE_LIST, s as pieceListLocation, t as extractSubgraphs, u as extractDocumentModels, v as PACKAGE_MODULE_FAILED, x as failedLoadHeader, y as debounce } from "../../subgraph-extraction-
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="cc1bbfa0-d615-5b07-8e65-2a1931a1af2c")}catch(e){}}();
|
|
3
|
+
import { S as isSubpath, _ as runDetached, b as extractUpgradeManifests, i as PIECES_SUBPATH, l as piecesFromListModule, n as scalarExportsOf, o as packageRootOf, r as BUILT_PIECE_LIST, s as pieceListLocation, t as extractSubgraphs, u as extractDocumentModels, v as PACKAGE_MODULE_FAILED, x as failedLoadHeader, y as debounce } from "../../subgraph-extraction-C_hFvSaS.mjs";
|
|
4
4
|
import { childLogger } from "document-model";
|
|
5
5
|
import { getCodegenStatusRegistry } from "@powerhousedao/shared/processors";
|
|
6
6
|
import path from "node:path";
|
|
@@ -16,11 +16,17 @@ function createViteLogger(logger, prefix = "") {
|
|
|
16
16
|
customLogger.error = (msg, options) => options?.error ? logger.error("@line", msg, options.error) : logger.error("@line", msg);
|
|
17
17
|
return customLogger;
|
|
18
18
|
}
|
|
19
|
+
const FILE_EVENTS = [
|
|
20
|
+
"change",
|
|
21
|
+
"add",
|
|
22
|
+
"unlink"
|
|
23
|
+
];
|
|
19
24
|
var VitePackageLoader = class VitePackageLoader {
|
|
20
25
|
logger = childLogger(["reactor-api", "vite-loader"]);
|
|
21
26
|
vite;
|
|
22
27
|
importers;
|
|
23
28
|
#reportError;
|
|
29
|
+
#fileListeners = /* @__PURE__ */ new Set();
|
|
24
30
|
name = "VitePackageLoader";
|
|
25
31
|
static build(vite, options) {
|
|
26
32
|
return new VitePackageLoader(vite, options);
|
|
@@ -178,17 +184,18 @@ var VitePackageLoader = class VitePackageLoader {
|
|
|
178
184
|
const listener = (changedPath) => {
|
|
179
185
|
if (matches(changedPath)) reloadOnce();
|
|
180
186
|
};
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
"add",
|
|
184
|
-
"unlink"
|
|
185
|
-
];
|
|
186
|
-
for (const event of events) this.vite.watcher.on(event, listener);
|
|
187
|
+
if (this.#fileListeners.size === 0) for (const event of FILE_EVENTS) this.vite.watcher.on(event, this.#dispatchFileEvent);
|
|
188
|
+
this.#fileListeners.add(listener);
|
|
187
189
|
return () => {
|
|
188
190
|
subscribed = false;
|
|
189
|
-
|
|
191
|
+
if (!this.#fileListeners.delete(listener)) return;
|
|
192
|
+
if (this.#fileListeners.size > 0) return;
|
|
193
|
+
for (const event of FILE_EVENTS) this.vite.watcher.off(event, this.#dispatchFileEvent);
|
|
190
194
|
};
|
|
191
195
|
}
|
|
196
|
+
#dispatchFileEvent = (changedPath) => {
|
|
197
|
+
for (const listener of [...this.#fileListeners]) listener(changedPath);
|
|
198
|
+
};
|
|
192
199
|
onDocumentModelsChange(identifier, handler, options) {
|
|
193
200
|
const watched = [this.getDocumentModelsPath(identifier), this.getScalarsPath(identifier)];
|
|
194
201
|
return this.#watch(`Reloading the document models of ${identifier}`, {
|
|
@@ -280,4 +287,4 @@ async function startViteServer(root, logger) {
|
|
|
280
287
|
export { VitePackageLoader, createViteLogger, ignoreBuildOutputButPieces, startViteServer };
|
|
281
288
|
|
|
282
289
|
//# sourceMappingURL=vite-loader.mjs.map
|
|
283
|
-
//# debugId=
|
|
290
|
+
//# debugId=cc1bbfa0-d615-5b07-8e65-2a1931a1af2c
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-loader.mjs","sources":["../../../src/packages/vite-loader.mts"],"sourcesContent":["import { viteCommonjs } from \"@originjs/vite-plugin-commonjs\";\nimport type {\n ProcessorFactoryBuilder,\n SubgraphClass,\n} from \"@powerhousedao/reactor-api\";\nimport type {\n DocumentModelModule,\n UpgradeManifest,\n} from \"@powerhousedao/shared/document-model\";\nimport { getCodegenStatusRegistry } from \"@powerhousedao/shared/processors\";\nimport { childLogger, type ILogger } from \"document-model\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { readPackage } from \"read-pkg\";\nimport type { Logger, PluginOption, ViteDevServer } from \"vite\";\nimport { createLogger, createServer } from \"vite\";\nimport { extractDocumentModels } from \"./document-model-detection.js\";\nimport { type ScalarExport, scalarExportsOf } from \"./scalar-exports.js\";\nimport { extractSubgraphs } from \"./subgraph-extraction.js\";\nimport {\n BUILT_PIECE_LIST,\n PIECES_SUBPATH,\n packageRootOf,\n pieceListLocation,\n piecesFromListModule,\n} from \"./pieces.js\";\nimport type {\n ISubscribablePackageLoader,\n ISubscriptionOptions,\n PackagePieceEntry,\n} from \"./types.js\";\nimport {\n PACKAGE_MODULE_FAILED,\n debounce,\n extractUpgradeManifests,\n failedLoadHeader,\n isSubpath,\n} from \"./util.js\";\nimport { runDetached, type ReportError } from \"../utils/detached.js\";\n\nexport function createViteLogger(logger: ILogger, prefix = \"\") {\n const customLogger = createLogger(\"info\", {\n prefix,\n });\n // Wrapped rather than assigned: the logger methods are bound to their own\n // instance, and re-homing them onto Vite's logger object made every Vite\n // log line throw.\n //\n // Vite's text goes through as a replacement, never as the format string: it\n // is somebody else's prose, not a template. `ILogger` substitutes `@token`,\n // and Vite log lines are full of npm scopes, so `pre-transforming\n // @powerhousedao/design-system` came out as `pre-transforming\n // null/design-system`. Substituting into `@line` instead emits it verbatim.\n //\n // Vite's second argument is dropped for the same reason. It is `LogOptions`\n // -- `{ clear, timestamp }` -- and forwarding it made it the replacement for\n // whatever `@token` the line happened to contain, or got appended as JSON.\n // Only `error` keeps it, where it carries the error itself.\n customLogger.info = (msg) => logger.info(\"@line\", msg);\n customLogger.warn = (msg) => logger.warn(\"@line\", msg);\n customLogger.error = (msg, options) =>\n options?.error\n ? logger.error(\"@line\", msg, options.error)\n : logger.error(\"@line\", msg);\n return customLogger;\n}\n\nexport interface VitePackageLoaderOptions {\n /** Modules, as paths or file URLs, whose dependencies a package the project\n * does not install may resolve from. This loader's own module always is. */\n resolveFrom?: string[];\n reportError?: ReportError;\n}\n\ninterface LoadedModule {\n id: string;\n namespace: Record<string, unknown>;\n}\n\nexport class VitePackageLoader implements ISubscribablePackageLoader {\n private readonly logger = childLogger([\"reactor-api\", \"vite-loader\"]);\n\n private readonly vite: ViteDevServer;\n\n private readonly importers: string[];\n\n readonly #reportError?: ReportError;\n\n readonly name = \"VitePackageLoader\";\n\n static build(vite: ViteDevServer, options?: VitePackageLoaderOptions) {\n return new VitePackageLoader(vite, options);\n }\n\n constructor(vite: ViteDevServer, options: VitePackageLoaderOptions = {}) {\n this.vite = vite;\n this.importers = [...(options.resolveFrom ?? []), import.meta.url].map(\n (from) => (from.startsWith(\"file:\") ? fileURLToPath(from) : from),\n );\n this.#reportError = options.reportError;\n }\n\n // The project first, then the host's own dependencies. A bare name or a path\n // Vite cannot resolve is a package without that module, not an error.\n async #resolve(identifier: string, subpath: string) {\n const aliased = path.isAbsolute(identifier)\n ? undefined\n : this.aliasedRoot(identifier);\n const specifier = path.posix.join(aliased ?? identifier, subpath);\n const bare = !aliased && !path.isAbsolute(identifier);\n const importers = bare ? [undefined, ...this.importers] : [undefined];\n const container = this.vite.environments.ssr.pluginContainer;\n for (const importer of importers) {\n try {\n const resolved = await container.resolveId(specifier, importer);\n if (resolved && !resolved.external) return resolved.id;\n } catch (e) {\n this.logger.debug(\"Could not resolve @specifier: @error\", specifier, e);\n }\n }\n return undefined;\n }\n\n // Resolved before it is loaded, so only a module that exists and fails is\n // reported and thrown; one a package does not have is a debug-level miss.\n async #load(\n identifier: string,\n subpath: string,\n kind: string,\n ): Promise<LoadedModule | undefined> {\n const id = await this.#resolve(identifier, subpath);\n if (id === undefined) {\n this.logger.debug(\"No @subpath module in @pkg\", subpath, identifier);\n return undefined;\n }\n try {\n const namespace = (await this.vite.ssrLoadModule(id)) as Record<\n string,\n unknown\n >;\n return { id, namespace };\n } catch (e) {\n const message = e instanceof Error ? e.message : String(e);\n this.logger.error(\n `${failedLoadHeader(kind)}\\n @id: @error`,\n identifier,\n id,\n message,\n );\n // Tagged: vite's own code can read as a package without the module.\n throw Object.assign(\n new Error(`Failed to load ${id}: ${message}`, { cause: e }),\n { code: PACKAGE_MODULE_FAILED },\n );\n }\n }\n\n private getDocumentModelsPath(identifier: string): string {\n return path.posix.join(identifier, \"./document-models\");\n }\n\n private getSubgraphsPath(identifier: string): string {\n return path.posix.join(identifier, \"./subgraphs\");\n }\n\n private getScalarsPath(identifier: string): string {\n return path.posix.join(identifier, \"./scalars\");\n }\n\n private getProcessorsPath(identifier: string): string {\n return path.posix.join(identifier, \"./processors\");\n }\n\n private getPiecesPath(identifier: string): string {\n return path.posix.join(identifier, `./${PIECES_SUBPATH}`);\n }\n\n // The dev server aliases the local project by its own package name, so a\n // package that is this project is rooted at the source tree vite serves.\n private aliasedRoot(identifier: string): string | undefined {\n const alias = this.vite.config.resolve.alias;\n const entries = Array.isArray(alias) ? alias : [];\n const hit = entries.find((entry) => entry.find === identifier);\n return typeof hit?.replacement === \"string\" ? hit.replacement : undefined;\n }\n\n // What a declared piece path is relative to. Not the module vite loaded: a\n // list read from source still points at the built output beside it.\n private pieceRoot(identifier: string, listId?: string): string | undefined {\n if (!path.isAbsolute(identifier)) {\n const aliased = this.aliasedRoot(identifier);\n if (aliased) return aliased;\n // A built list resolved from wherever the package is installed.\n if (listId) return packageRootOf(path.dirname(listId));\n }\n try {\n return pieceListLocation(identifier).root;\n } catch {\n return undefined;\n }\n }\n\n async loadDocumentModels(identifier: string): Promise<DocumentModelModule[]> {\n this.logger.debug(\n \"Loading document models from\",\n this.getDocumentModelsPath(identifier),\n );\n const loaded = await this.#load(\n identifier,\n \"document-models\",\n \"document models\",\n );\n if (!loaded) return [];\n\n const documentModels = extractDocumentModels(loaded.namespace);\n this.logger.verbose(\n ` ➜ Loaded ${documentModels.length} Document Models from: ${identifier}`,\n );\n return documentModels;\n }\n\n async loadUpgradeManifests(\n identifier: string,\n ): Promise<UpgradeManifest<readonly number[]>[]> {\n // Projects generated before the aggregate index re-exported the\n // manifests only expose them at document-models/upgrade-manifests.\n for (const subpath of [\n \"document-models\",\n \"document-models/upgrade-manifests\",\n ]) {\n const loaded = await this.#load(identifier, subpath, \"upgrade manifests\");\n if (!loaded) continue;\n const manifests = extractUpgradeManifests(loaded.namespace);\n if (manifests.length > 0) {\n this.logger.verbose(\n ` ➜ Loaded ${manifests.length} Upgrade Manifests from: ${identifier}`,\n );\n return manifests;\n }\n }\n return [];\n }\n\n async loadSubgraphs(identifier: string): Promise<SubgraphClass[]> {\n this.logger.verbose(\n \"Loading subgraphs from\",\n this.getSubgraphsPath(identifier),\n );\n const loaded = await this.#load(identifier, \"subgraphs\", \"subgraphs\");\n if (!loaded) return [];\n\n const subgraphs = extractSubgraphs(loaded.namespace);\n\n this.logger.debug(\n ` ➜ Loaded ${subgraphs.length} Subgraphs from: ${identifier}`,\n );\n\n return subgraphs;\n }\n\n async loadScalars(identifier: string): Promise<ScalarExport[]> {\n this.logger.verbose(\n \"Loading scalars from\",\n this.getScalarsPath(identifier),\n );\n const loaded = await this.#load(identifier, \"scalars\", \"scalars\");\n if (!loaded) return [];\n const scalars = scalarExportsOf(loaded.namespace);\n this.logger.debug(\n ` ➜ Loaded ${scalars.length} Scalars from: ${identifier}`,\n );\n return scalars;\n }\n\n async loadProcessors(\n identifier: string,\n ): Promise<ProcessorFactoryBuilder | null> {\n this.logger.verbose(\n \"Loading processors from\",\n this.getProcessorsPath(identifier),\n );\n const loaded = await this.#load(identifier, \"processors\", \"processors\");\n const factory = loaded?.namespace.processorFactory;\n if (typeof factory === \"function\") {\n this.logger.verbose(` ➜ Loaded Processor Factory from: ${identifier}`);\n return factory as ProcessorFactoryBuilder;\n }\n\n this.logger.verbose(` ➜ No Processor Factory found for: ${identifier}`);\n return null;\n }\n\n // The list only, never a piece: in dev it is usually the TypeScript source,\n // and what it names is still the built bundle a worker will load.\n async loadPieces(identifier: string): Promise<PackagePieceEntry[]> {\n this.logger.verbose(\"Loading pieces from\", this.getPiecesPath(identifier));\n const loaded = await this.#load(identifier, PIECES_SUBPATH, \"pieces\");\n if (!loaded) return [];\n\n const root = this.pieceRoot(identifier, loaded.id);\n if (root === undefined) {\n this.logger.debug(` ➜ No package root found for: ${identifier}`);\n return [];\n }\n\n const pieces = piecesFromListModule(loaded.namespace, {\n root,\n identifier,\n logger: this.logger,\n });\n this.logger.debug(\n ` ➜ Loaded ${pieces.length} Pieces from: ${identifier}`,\n );\n return pieces;\n }\n\n // One detached reload per burst of file events. \"add\" and \"unlink\" too, or a\n // removed entry never reports empty and its registrations leak. Once\n // unsubscribed, no pending or running reload reaches `handler`, and a\n // failed load leaves the last good set.\n #watch<T>(\n label: string,\n reported: { pkg: string; kind: string },\n matches: (changedPath: string) => unknown,\n load: () => Promise<T>,\n handler: (value: T) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n let subscribed = true;\n // Read by reactor-mcp's getCodegenStatus, e.g. for broken generated code.\n const report = (failure?: string) =>\n getCodegenStatusRegistry().reportLoad(\n reported.pkg,\n reported.kind,\n failure,\n );\n const reloadOnce = debounce(\n () =>\n runDetached(\n label,\n async () => {\n if (!subscribed) return;\n let value: T;\n try {\n value = await load();\n } catch (e) {\n if ((e as NodeJS.ErrnoException).code === PACKAGE_MODULE_FAILED) {\n report(`[${this.name}] ${(e as Error).message}`);\n return;\n }\n throw e;\n }\n report();\n if (subscribed) handler(value);\n },\n { logger: this.logger, report: this.#reportError },\n ),\n options?.debounce ?? 100,\n );\n const listener = (changedPath: string) => {\n if (matches(changedPath)) void reloadOnce();\n };\n const events = [\"change\", \"add\", \"unlink\"] as const;\n for (const event of events) this.vite.watcher.on(event, listener);\n\n return () => {\n subscribed = false;\n for (const event of events) this.vite.watcher.off(event, listener);\n };\n }\n\n onDocumentModelsChange(\n identifier: string,\n handler: (documentModels: DocumentModelModule[]) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n const watched = [\n this.getDocumentModelsPath(identifier),\n this.getScalarsPath(identifier),\n ];\n return this.#watch(\n `Reloading the document models of ${identifier}`,\n { pkg: identifier, kind: \"document models\" },\n (changedPath) => watched.some((dir) => isSubpath(dir, changedPath)),\n () => this.loadDocumentModels(identifier),\n handler,\n options,\n );\n }\n\n onSubgraphsChange(\n identifier: string,\n handler: (subgraphs: SubgraphClass[]) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n const subgraphsPath = this.getSubgraphsPath(identifier);\n return this.#watch(\n `Reloading the subgraphs of ${identifier}`,\n { pkg: identifier, kind: \"subgraphs\" },\n (changedPath) => isSubpath(subgraphsPath, changedPath),\n () => this.loadSubgraphs(identifier),\n handler,\n options,\n );\n }\n\n onScalarsChange(\n identifier: string,\n handler: (scalars: ScalarExport[]) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n const scalarsPath = this.getScalarsPath(identifier);\n return this.#watch(\n `Reloading the scalars of ${identifier}`,\n { pkg: identifier, kind: \"scalars\" },\n (changedPath) => isSubpath(scalarsPath, changedPath),\n () => this.loadScalars(identifier),\n handler,\n options,\n );\n }\n\n onProcessorsChange(\n identifier: string,\n handler: (processors: ProcessorFactoryBuilder | null) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n const processorsPath = this.getProcessorsPath(identifier);\n return this.#watch(\n `Reloading the processors of ${identifier}`,\n { pkg: identifier, kind: \"processors\" },\n (changedPath) => isSubpath(processorsPath, changedPath),\n () => this.loadProcessors(identifier),\n handler,\n options,\n );\n }\n\n onPiecesChange(\n identifier: string,\n handler: (pieces: PackagePieceEntry[]) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n // Both the source list and the build output: the list says which pieces a\n // package ships, and only the build decides whether one is there to run.\n const watched = [this.getPiecesPath(identifier)];\n const root = this.pieceRoot(identifier);\n if (root !== undefined) {\n watched.push(path.dirname(path.resolve(root, BUILT_PIECE_LIST)));\n }\n return this.#watch(\n `Reloading the pieces of ${identifier}`,\n { pkg: identifier, kind: \"pieces\" },\n (changedPath) => watched.some((dir) => isSubpath(dir, changedPath)),\n () => this.loadPieces(identifier),\n handler,\n options,\n );\n }\n}\n\nconst toSlashes = (file: string) => file.replaceAll(\"\\\\\", \"/\");\n\n/**\n * The project's build output, but for the built piece list `onPiecesChange`\n * watches: its own `dist/` and a Tauri shell's Rust `target/`. On Windows\n * every watched file costs a synchronous `fs.watch` at startup, over a\n * minute for a built project with a built desktop shell.\n */\nexport function ignoreBuildOutputButPieces(root: string) {\n const dist = `${toSlashes(path.resolve(root, \"dist\"))}/`;\n const pieces = toSlashes(path.dirname(path.resolve(root, BUILT_PIECE_LIST)));\n return (file: string) => {\n const at = toSlashes(path.resolve(root, file));\n if (\n at.includes(\"/tauri-shell/target/\") ||\n at.includes(\"/src-tauri/target/\")\n ) {\n return true;\n }\n if (!at.startsWith(dist)) return false;\n // The piece list's folder, what is in it, and the folders leading to it stay watched.\n return !(\n at === pieces ||\n at.startsWith(`${pieces}/`) ||\n pieces.startsWith(`${at}/`)\n );\n };\n}\n\nexport async function startViteServer(root: string, logger?: Logger) {\n const packageJson = await readPackage({ cwd: root });\n\n const vite = await createServer({\n root,\n configFile: false,\n customLogger: logger,\n server: {\n middlewareMode: true,\n // It loads modules, never serves a page: no HMR, and no WebSocket port\n // (24678 by default) for a second project's Vetra to collide on.\n hmr: false,\n ws: false,\n watch: { ignored: [\"**/.ph/**\", ignoreBuildOutputButPieces(root)] },\n },\n appType: \"custom\",\n // Its own cache, and no client deps to optimize: Studio's cache is the\n // project's node_modules/.vite, which it would otherwise rewrite.\n cacheDir: path.join(root, \"node_modules\", \".vite-reactor\"),\n optimizeDeps: { noDiscovery: true, include: [], entries: [] },\n build: {\n rollupOptions: {\n input: [],\n },\n },\n resolve: {\n tsconfigPaths: true,\n alias: {\n [packageJson.name]: root,\n },\n },\n plugins: [\n // cast: the plugin ships types built against an older vite, and the\n // mismatched Plugin type crashes tsc 6 during assignability checking\n viteCommonjs() as PluginOption,\n {\n name: \"suppress-hmr\",\n handleHotUpdate() {\n return []; // return empty array to suppress server refresh\n },\n },\n ],\n });\n\n return vite;\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAwCA,SAAgB,iBAAiB,QAAiB,SAAS,IAAI;CAC7D,MAAM,eAAe,aAAa,QAAQ,EACxC,OACF,CAAC;CAeD,aAAa,QAAQ,QAAQ,OAAO,KAAK,SAAS,GAAG;CACrD,aAAa,QAAQ,QAAQ,OAAO,KAAK,SAAS,GAAG;CACrD,aAAa,SAAS,KAAK,YACzB,SAAS,QACL,OAAO,MAAM,SAAS,KAAK,QAAQ,KAAK,IACxC,OAAO,MAAM,SAAS,GAAG;CAC/B,OAAO;AACT;AAcA,IAAa,oBAAb,MAAa,kBAAwD;CACnE,SAA0B,YAAY,CAAC,eAAe,aA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CACF;CACF,CAAC;AAGH","debug_id":"3c0c3439-7d79-5d48-8171-b4a29015a658"}
|
|
1
|
+
{"version":3,"file":"vite-loader.mjs","sources":["../../../src/packages/vite-loader.mts"],"sourcesContent":["import { viteCommonjs } from \"@originjs/vite-plugin-commonjs\";\nimport type {\n ProcessorFactoryBuilder,\n SubgraphClass,\n} from \"@powerhousedao/reactor-api\";\nimport type {\n DocumentModelModule,\n UpgradeManifest,\n} from \"@powerhousedao/shared/document-model\";\nimport { getCodegenStatusRegistry } from \"@powerhousedao/shared/processors\";\nimport { childLogger, type ILogger } from \"document-model\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { readPackage } from \"read-pkg\";\nimport type { Logger, PluginOption, ViteDevServer } from \"vite\";\nimport { createLogger, createServer } from \"vite\";\nimport { extractDocumentModels } from \"./document-model-detection.js\";\nimport { type ScalarExport, scalarExportsOf } from \"./scalar-exports.js\";\nimport { extractSubgraphs } from \"./subgraph-extraction.js\";\nimport {\n BUILT_PIECE_LIST,\n PIECES_SUBPATH,\n packageRootOf,\n pieceListLocation,\n piecesFromListModule,\n} from \"./pieces.js\";\nimport type {\n ISubscribablePackageLoader,\n ISubscriptionOptions,\n PackagePieceEntry,\n} from \"./types.js\";\nimport {\n PACKAGE_MODULE_FAILED,\n debounce,\n extractUpgradeManifests,\n failedLoadHeader,\n isSubpath,\n} from \"./util.js\";\nimport { runDetached, type ReportError } from \"../utils/detached.js\";\n\nexport function createViteLogger(logger: ILogger, prefix = \"\") {\n const customLogger = createLogger(\"info\", {\n prefix,\n });\n // Wrapped rather than assigned: the logger methods are bound to their own\n // instance, and re-homing them onto Vite's logger object made every Vite\n // log line throw.\n //\n // Vite's text goes through as a replacement, never as the format string: it\n // is somebody else's prose, not a template. `ILogger` substitutes `@token`,\n // and Vite log lines are full of npm scopes, so `pre-transforming\n // @powerhousedao/design-system` came out as `pre-transforming\n // null/design-system`. Substituting into `@line` instead emits it verbatim.\n //\n // Vite's second argument is dropped for the same reason. It is `LogOptions`\n // -- `{ clear, timestamp }` -- and forwarding it made it the replacement for\n // whatever `@token` the line happened to contain, or got appended as JSON.\n // Only `error` keeps it, where it carries the error itself.\n customLogger.info = (msg) => logger.info(\"@line\", msg);\n customLogger.warn = (msg) => logger.warn(\"@line\", msg);\n customLogger.error = (msg, options) =>\n options?.error\n ? logger.error(\"@line\", msg, options.error)\n : logger.error(\"@line\", msg);\n return customLogger;\n}\n\nexport interface VitePackageLoaderOptions {\n /** Modules, as paths or file URLs, whose dependencies a package the project\n * does not install may resolve from. This loader's own module always is. */\n resolveFrom?: string[];\n reportError?: ReportError;\n}\n\ninterface LoadedModule {\n id: string;\n namespace: Record<string, unknown>;\n}\n\nconst FILE_EVENTS = [\"change\", \"add\", \"unlink\"] as const;\n\nexport class VitePackageLoader implements ISubscribablePackageLoader {\n private readonly logger = childLogger([\"reactor-api\", \"vite-loader\"]);\n\n private readonly vite: ViteDevServer;\n\n private readonly importers: string[];\n\n readonly #reportError?: ReportError;\n\n // One watcher listener per event for every subscription, so Vite's watcher\n // stays under its listener limit however many packages are watched.\n readonly #fileListeners = new Set<(changedPath: string) => void>();\n\n readonly name = \"VitePackageLoader\";\n\n static build(vite: ViteDevServer, options?: VitePackageLoaderOptions) {\n return new VitePackageLoader(vite, options);\n }\n\n constructor(vite: ViteDevServer, options: VitePackageLoaderOptions = {}) {\n this.vite = vite;\n this.importers = [...(options.resolveFrom ?? []), import.meta.url].map(\n (from) => (from.startsWith(\"file:\") ? fileURLToPath(from) : from),\n );\n this.#reportError = options.reportError;\n }\n\n // The project first, then the host's own dependencies. A bare name or a path\n // Vite cannot resolve is a package without that module, not an error.\n async #resolve(identifier: string, subpath: string) {\n const aliased = path.isAbsolute(identifier)\n ? undefined\n : this.aliasedRoot(identifier);\n const specifier = path.posix.join(aliased ?? identifier, subpath);\n const bare = !aliased && !path.isAbsolute(identifier);\n const importers = bare ? [undefined, ...this.importers] : [undefined];\n const container = this.vite.environments.ssr.pluginContainer;\n for (const importer of importers) {\n try {\n const resolved = await container.resolveId(specifier, importer);\n if (resolved && !resolved.external) return resolved.id;\n } catch (e) {\n this.logger.debug(\"Could not resolve @specifier: @error\", specifier, e);\n }\n }\n return undefined;\n }\n\n // Resolved before it is loaded, so only a module that exists and fails is\n // reported and thrown; one a package does not have is a debug-level miss.\n async #load(\n identifier: string,\n subpath: string,\n kind: string,\n ): Promise<LoadedModule | undefined> {\n const id = await this.#resolve(identifier, subpath);\n if (id === undefined) {\n this.logger.debug(\"No @subpath module in @pkg\", subpath, identifier);\n return undefined;\n }\n try {\n const namespace = (await this.vite.ssrLoadModule(id)) as Record<\n string,\n unknown\n >;\n return { id, namespace };\n } catch (e) {\n const message = e instanceof Error ? e.message : String(e);\n this.logger.error(\n `${failedLoadHeader(kind)}\\n @id: @error`,\n identifier,\n id,\n message,\n );\n // Tagged: vite's own code can read as a package without the module.\n throw Object.assign(\n new Error(`Failed to load ${id}: ${message}`, { cause: e }),\n { code: PACKAGE_MODULE_FAILED },\n );\n }\n }\n\n private getDocumentModelsPath(identifier: string): string {\n return path.posix.join(identifier, \"./document-models\");\n }\n\n private getSubgraphsPath(identifier: string): string {\n return path.posix.join(identifier, \"./subgraphs\");\n }\n\n private getScalarsPath(identifier: string): string {\n return path.posix.join(identifier, \"./scalars\");\n }\n\n private getProcessorsPath(identifier: string): string {\n return path.posix.join(identifier, \"./processors\");\n }\n\n private getPiecesPath(identifier: string): string {\n return path.posix.join(identifier, `./${PIECES_SUBPATH}`);\n }\n\n // The dev server aliases the local project by its own package name, so a\n // package that is this project is rooted at the source tree vite serves.\n private aliasedRoot(identifier: string): string | undefined {\n const alias = this.vite.config.resolve.alias;\n const entries = Array.isArray(alias) ? alias : [];\n const hit = entries.find((entry) => entry.find === identifier);\n return typeof hit?.replacement === \"string\" ? hit.replacement : undefined;\n }\n\n // What a declared piece path is relative to. Not the module vite loaded: a\n // list read from source still points at the built output beside it.\n private pieceRoot(identifier: string, listId?: string): string | undefined {\n if (!path.isAbsolute(identifier)) {\n const aliased = this.aliasedRoot(identifier);\n if (aliased) return aliased;\n // A built list resolved from wherever the package is installed.\n if (listId) return packageRootOf(path.dirname(listId));\n }\n try {\n return pieceListLocation(identifier).root;\n } catch {\n return undefined;\n }\n }\n\n async loadDocumentModels(identifier: string): Promise<DocumentModelModule[]> {\n this.logger.debug(\n \"Loading document models from\",\n this.getDocumentModelsPath(identifier),\n );\n const loaded = await this.#load(\n identifier,\n \"document-models\",\n \"document models\",\n );\n if (!loaded) return [];\n\n const documentModels = extractDocumentModels(loaded.namespace);\n this.logger.verbose(\n ` ➜ Loaded ${documentModels.length} Document Models from: ${identifier}`,\n );\n return documentModels;\n }\n\n async loadUpgradeManifests(\n identifier: string,\n ): Promise<UpgradeManifest<readonly number[]>[]> {\n // Projects generated before the aggregate index re-exported the\n // manifests only expose them at document-models/upgrade-manifests.\n for (const subpath of [\n \"document-models\",\n \"document-models/upgrade-manifests\",\n ]) {\n const loaded = await this.#load(identifier, subpath, \"upgrade manifests\");\n if (!loaded) continue;\n const manifests = extractUpgradeManifests(loaded.namespace);\n if (manifests.length > 0) {\n this.logger.verbose(\n ` ➜ Loaded ${manifests.length} Upgrade Manifests from: ${identifier}`,\n );\n return manifests;\n }\n }\n return [];\n }\n\n async loadSubgraphs(identifier: string): Promise<SubgraphClass[]> {\n this.logger.verbose(\n \"Loading subgraphs from\",\n this.getSubgraphsPath(identifier),\n );\n const loaded = await this.#load(identifier, \"subgraphs\", \"subgraphs\");\n if (!loaded) return [];\n\n const subgraphs = extractSubgraphs(loaded.namespace);\n\n this.logger.debug(\n ` ➜ Loaded ${subgraphs.length} Subgraphs from: ${identifier}`,\n );\n\n return subgraphs;\n }\n\n async loadScalars(identifier: string): Promise<ScalarExport[]> {\n this.logger.verbose(\n \"Loading scalars from\",\n this.getScalarsPath(identifier),\n );\n const loaded = await this.#load(identifier, \"scalars\", \"scalars\");\n if (!loaded) return [];\n const scalars = scalarExportsOf(loaded.namespace);\n this.logger.debug(\n ` ➜ Loaded ${scalars.length} Scalars from: ${identifier}`,\n );\n return scalars;\n }\n\n async loadProcessors(\n identifier: string,\n ): Promise<ProcessorFactoryBuilder | null> {\n this.logger.verbose(\n \"Loading processors from\",\n this.getProcessorsPath(identifier),\n );\n const loaded = await this.#load(identifier, \"processors\", \"processors\");\n const factory = loaded?.namespace.processorFactory;\n if (typeof factory === \"function\") {\n this.logger.verbose(` ➜ Loaded Processor Factory from: ${identifier}`);\n return factory as ProcessorFactoryBuilder;\n }\n\n this.logger.verbose(` ➜ No Processor Factory found for: ${identifier}`);\n return null;\n }\n\n // The list only, never a piece: in dev it is usually the TypeScript source,\n // and what it names is still the built bundle a worker will load.\n async loadPieces(identifier: string): Promise<PackagePieceEntry[]> {\n this.logger.verbose(\"Loading pieces from\", this.getPiecesPath(identifier));\n const loaded = await this.#load(identifier, PIECES_SUBPATH, \"pieces\");\n if (!loaded) return [];\n\n const root = this.pieceRoot(identifier, loaded.id);\n if (root === undefined) {\n this.logger.debug(` ➜ No package root found for: ${identifier}`);\n return [];\n }\n\n const pieces = piecesFromListModule(loaded.namespace, {\n root,\n identifier,\n logger: this.logger,\n });\n this.logger.debug(\n ` ➜ Loaded ${pieces.length} Pieces from: ${identifier}`,\n );\n return pieces;\n }\n\n // One detached reload per burst of file events. \"add\" and \"unlink\" too, or a\n // removed entry never reports empty and its registrations leak. Once\n // unsubscribed, no pending or running reload reaches `handler`, and a\n // failed load leaves the last good set.\n #watch<T>(\n label: string,\n reported: { pkg: string; kind: string },\n matches: (changedPath: string) => unknown,\n load: () => Promise<T>,\n handler: (value: T) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n let subscribed = true;\n // Read by reactor-mcp's getCodegenStatus, e.g. for broken generated code.\n const report = (failure?: string) =>\n getCodegenStatusRegistry().reportLoad(\n reported.pkg,\n reported.kind,\n failure,\n );\n const reloadOnce = debounce(\n () =>\n runDetached(\n label,\n async () => {\n if (!subscribed) return;\n let value: T;\n try {\n value = await load();\n } catch (e) {\n if ((e as NodeJS.ErrnoException).code === PACKAGE_MODULE_FAILED) {\n report(`[${this.name}] ${(e as Error).message}`);\n return;\n }\n throw e;\n }\n report();\n if (subscribed) handler(value);\n },\n { logger: this.logger, report: this.#reportError },\n ),\n options?.debounce ?? 100,\n );\n const listener = (changedPath: string) => {\n if (matches(changedPath)) void reloadOnce();\n };\n if (this.#fileListeners.size === 0) {\n for (const event of FILE_EVENTS) {\n this.vite.watcher.on(event, this.#dispatchFileEvent);\n }\n }\n this.#fileListeners.add(listener);\n\n return () => {\n subscribed = false;\n if (!this.#fileListeners.delete(listener)) return;\n if (this.#fileListeners.size > 0) return;\n for (const event of FILE_EVENTS) {\n this.vite.watcher.off(event, this.#dispatchFileEvent);\n }\n };\n }\n\n readonly #dispatchFileEvent = (changedPath: string) => {\n for (const listener of [...this.#fileListeners]) listener(changedPath);\n };\n\n onDocumentModelsChange(\n identifier: string,\n handler: (documentModels: DocumentModelModule[]) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n const watched = [\n this.getDocumentModelsPath(identifier),\n this.getScalarsPath(identifier),\n ];\n return this.#watch(\n `Reloading the document models of ${identifier}`,\n { pkg: identifier, kind: \"document models\" },\n (changedPath) => watched.some((dir) => isSubpath(dir, changedPath)),\n () => this.loadDocumentModels(identifier),\n handler,\n options,\n );\n }\n\n onSubgraphsChange(\n identifier: string,\n handler: (subgraphs: SubgraphClass[]) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n const subgraphsPath = this.getSubgraphsPath(identifier);\n return this.#watch(\n `Reloading the subgraphs of ${identifier}`,\n { pkg: identifier, kind: \"subgraphs\" },\n (changedPath) => isSubpath(subgraphsPath, changedPath),\n () => this.loadSubgraphs(identifier),\n handler,\n options,\n );\n }\n\n onScalarsChange(\n identifier: string,\n handler: (scalars: ScalarExport[]) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n const scalarsPath = this.getScalarsPath(identifier);\n return this.#watch(\n `Reloading the scalars of ${identifier}`,\n { pkg: identifier, kind: \"scalars\" },\n (changedPath) => isSubpath(scalarsPath, changedPath),\n () => this.loadScalars(identifier),\n handler,\n options,\n );\n }\n\n onProcessorsChange(\n identifier: string,\n handler: (processors: ProcessorFactoryBuilder | null) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n const processorsPath = this.getProcessorsPath(identifier);\n return this.#watch(\n `Reloading the processors of ${identifier}`,\n { pkg: identifier, kind: \"processors\" },\n (changedPath) => isSubpath(processorsPath, changedPath),\n () => this.loadProcessors(identifier),\n handler,\n options,\n );\n }\n\n onPiecesChange(\n identifier: string,\n handler: (pieces: PackagePieceEntry[]) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n // Both the source list and the build output: the list says which pieces a\n // package ships, and only the build decides whether one is there to run.\n const watched = [this.getPiecesPath(identifier)];\n const root = this.pieceRoot(identifier);\n if (root !== undefined) {\n watched.push(path.dirname(path.resolve(root, BUILT_PIECE_LIST)));\n }\n return this.#watch(\n `Reloading the pieces of ${identifier}`,\n { pkg: identifier, kind: \"pieces\" },\n (changedPath) => watched.some((dir) => isSubpath(dir, changedPath)),\n () => this.loadPieces(identifier),\n handler,\n options,\n );\n }\n}\n\nconst toSlashes = (file: string) => file.replaceAll(\"\\\\\", \"/\");\n\n/**\n * The project's build output, but for the built piece list `onPiecesChange`\n * watches: its own `dist/` and a Tauri shell's Rust `target/`. On Windows\n * every watched file costs a synchronous `fs.watch` at startup, over a\n * minute for a built project with a built desktop shell.\n */\nexport function ignoreBuildOutputButPieces(root: string) {\n const dist = `${toSlashes(path.resolve(root, \"dist\"))}/`;\n const pieces = toSlashes(path.dirname(path.resolve(root, BUILT_PIECE_LIST)));\n return (file: string) => {\n const at = toSlashes(path.resolve(root, file));\n if (\n at.includes(\"/tauri-shell/target/\") ||\n at.includes(\"/src-tauri/target/\")\n ) {\n return true;\n }\n if (!at.startsWith(dist)) return false;\n // The piece list's folder, what is in it, and the folders leading to it stay watched.\n return !(\n at === pieces ||\n at.startsWith(`${pieces}/`) ||\n pieces.startsWith(`${at}/`)\n );\n };\n}\n\nexport async function startViteServer(root: string, logger?: Logger) {\n const packageJson = await readPackage({ cwd: root });\n\n const vite = await createServer({\n root,\n configFile: false,\n customLogger: logger,\n server: {\n middlewareMode: true,\n // It loads modules, never serves a page: no HMR, and no WebSocket port\n // (24678 by default) for a second project's Vetra to collide on.\n hmr: false,\n ws: false,\n watch: { ignored: [\"**/.ph/**\", ignoreBuildOutputButPieces(root)] },\n },\n appType: \"custom\",\n // Its own cache, and no client deps to optimize: Studio's cache is the\n // project's node_modules/.vite, which it would otherwise rewrite.\n cacheDir: path.join(root, \"node_modules\", \".vite-reactor\"),\n optimizeDeps: { noDiscovery: true, include: [], entries: [] },\n build: {\n rollupOptions: {\n input: [],\n },\n },\n resolve: {\n tsconfigPaths: true,\n alias: {\n [packageJson.name]: root,\n },\n },\n plugins: [\n // cast: the plugin ships types built against an older vite, and the\n // mismatched Plugin type crashes tsc 6 during assignability checking\n viteCommonjs() as PluginOption,\n {\n name: \"suppress-hmr\",\n handleHotUpdate() {\n return []; // return empty array to suppress server refresh\n },\n },\n ],\n });\n\n return vite;\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAwCA,SAAgB,iBAAiB,QAAiB,SAAS,IAAI;CAC7D,MAAM,eAAe,aAAa,QAAQ,EACxC,OACF,CAAC;CAeD,aAAa,QAAQ,QAAQ,OAAO,KAAK,SAAS,GAAG;CACrD,aAAa,QAAQ,QAAQ,OAAO,KAAK,SAAS,GAAG;CACrD,aAAa,SAAS,KAAK,YACzB,SAAS,QACL,OAAO,MAAM,SAAS,KAAK,QAAQ,KAAK,IACxC,OAAO,MAAM,SAAS,GAAG;CAC/B,OAAO;AACT;AAcA,MAAM,cAAc;CAAC;CAAU;CAAO;AAAQ;AAE9C,IAAa,oBAAb,MAAa,kBAAwD;CACnE,SAA0B,YAAY,CAAC,eAAe,aAAa,CAAC;CAEpE;CAEA;CAEA;CAIA,iCAA0B,IAAI,IAAmC;CAEjE,OAAgB;CAEhB,OAAO,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O,CAAC,EACV,EACF;EACA,SAAS;GACP,eAAe;GACf,OAAO,GACJ,YAAY,OAAO,KACtB;EACF;EACA,SAAS,CAGP,aAAa,GACb;GACE,MAAM;GACN,kBAAkB;IAChB,OAAO,CAAC;GACV;EACF,CACF;CACF,CAAC;AAGH","debug_id":"cc1bbfa0-d615-5b07-8e65-2a1931a1af2c"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="1629639f-53d5-56ba-9006-abc2cb9963c0")}catch(e){}}();
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { childLogger } from "document-model";
|
|
5
5
|
import { gql } from "graphql-tag";
|
|
@@ -12,8 +12,8 @@ import { verifyAuthBearerToken } from "@renown/sdk";
|
|
|
12
12
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
13
13
|
import path, { dirname, isAbsolute, join } from "node:path";
|
|
14
14
|
import { existsSync, readFileSync } from "node:fs";
|
|
15
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
16
15
|
import { isScalarDefinition, scalarDefinitionVersion } from "document-model/scalars";
|
|
16
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
17
17
|
import { packageJsonExports } from "@powerhousedao/shared/clis/constants";
|
|
18
18
|
//#region src/graphql/errors.ts
|
|
19
19
|
/** Caller (authenticated or anonymous) lacks permission for the document. */
|
|
@@ -1816,6 +1816,11 @@ function piecesFromListModule(module, context) {
|
|
|
1816
1816
|
}
|
|
1817
1817
|
//#endregion
|
|
1818
1818
|
//#region src/packages/scalar-exports.ts
|
|
1819
|
+
/**
|
|
1820
|
+
* @experimental The scalar exports of a package's `scalars` entry, as this
|
|
1821
|
+
* host reads them; ph-cli passes them to `buildScalarRegistry` for release
|
|
1822
|
+
* evidence.
|
|
1823
|
+
*/
|
|
1819
1824
|
function scalarExportsOf(namespace) {
|
|
1820
1825
|
return Object.entries(namespace).flatMap(([exportName, value]) => {
|
|
1821
1826
|
if (isScalarDefinition(value)) return [{
|
|
@@ -1875,5 +1880,5 @@ function valuesByName(record) {
|
|
|
1875
1880
|
//#endregion
|
|
1876
1881
|
export { RequestClientBinder as A, CanonicalDocumentIdResolutionError as B, loadDocumentModels as C, manifestDeclaredSubgraphs as D, loadSubgraphs as E, READABLE_DOCUMENTS_NAMESPACE as F, AuthEvaluationUnsupportedError as G, AuthorizationPolicy as H, ReadableDocumentsProjection as I, MalformedStoredOperationError as J, AuthenticationRequiredError as K, applyReadableFilter as L, createCredentialInvalidator as M, DEFAULT_ROOT_TYPES as N, BaseSubgraph as O, EVERYONE as P, isDocumentListed as R, isSubpath as S, loadScalars as T, AuthorizedDocumentHandle as U, createCanonicalDocumentIdResolver as V, createAuthorizationService as W, RefusalNotRecordedError as Y, runDetached as _, PIECE_SOURCE_LIST as a, extractUpgradeManifests as b, piecesFromCdnList as c, buildGraphQlDocument as d, buildGraphQlDriveDocument as f, reportFailure as g, isSubgraphClass as h, PIECES_SUBPATH as i, AuthService as j, callerSubject as k, piecesFromListModule as l, buildGraphqlOperations as m, scalarExportsOf as n, packageRootOf as o, buildGraphqlOperation as p, ForbiddenError as q, BUILT_PIECE_LIST as r, pieceListLocation as s, extractSubgraphs as t, extractDocumentModels as u, PACKAGE_MODULE_FAILED as v, loadProcessors as w, failedLoadHeader as x, debounce as y, readableDocumentsSubquery as z };
|
|
1877
1882
|
|
|
1878
|
-
//# sourceMappingURL=subgraph-extraction-
|
|
1879
|
-
//# debugId=
|
|
1883
|
+
//# sourceMappingURL=subgraph-extraction-C_hFvSaS.mjs.map
|
|
1884
|
+
//# debugId=1629639f-53d5-56ba-9006-abc2cb9963c0
|