@powerhousedao/reactor-api 6.2.3-dev.6 → 6.2.3-dev.60
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/README.md +7 -2
- package/dist/{adapter-gateway-apollo-DowrX6E_.mjs → adapter-gateway-apollo-DTcAJpfN.mjs} +3 -3
- package/dist/{adapter-gateway-apollo-CxJNBVyD.mjs → adapter-gateway-apollo-DwAmdCYz.mjs} +17 -15
- package/dist/{adapter-gateway-apollo-CxJNBVyD.mjs.map → adapter-gateway-apollo-DwAmdCYz.mjs.map} +1 -1
- package/dist/{adapter-gateway-mercurius-CZVy88Za.mjs → adapter-gateway-mercurius-BhO0nwH_.mjs} +5 -5
- package/dist/{adapter-gateway-mercurius-CZVy88Za.mjs.map → adapter-gateway-mercurius-BhO0nwH_.mjs.map} +1 -1
- package/dist/adapter-gateway-stitching-969ZPot-.mjs +4 -0
- package/dist/{adapter-gateway-stitching-CaZjvRzx.mjs → adapter-gateway-stitching-ClVkjojb.mjs} +31 -14
- package/dist/adapter-gateway-stitching-ClVkjojb.mjs.map +1 -0
- package/dist/{adapter-http-express-B39rPhqH.mjs → adapter-http-express-P0t-mdMV.mjs} +10 -10
- package/dist/adapter-http-express-P0t-mdMV.mjs.map +1 -0
- package/dist/{adapter-http-fastify-BwXO6rqE.mjs → adapter-http-fastify-D0OP5q9K.mjs} +13 -12
- package/dist/adapter-http-fastify-D0OP5q9K.mjs.map +1 -0
- package/dist/base-document-models-69WRTSfH.mjs +1243 -0
- package/dist/base-document-models-69WRTSfH.mjs.map +1 -0
- package/dist/create-schema-DLTPkNpK.d.mts +138 -0
- package/dist/create-schema-DLTPkNpK.d.mts.map +1 -0
- package/dist/index.d.mts +2021 -732
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3900 -1548
- package/dist/index.mjs.map +1 -1
- package/dist/pglite-node-Ow9i5Rb4.mjs +573 -0
- package/dist/pglite-node-Ow9i5Rb4.mjs.map +1 -0
- package/dist/rolldown-runtime-8H4AJuhK.mjs +16 -0
- package/dist/run-node-handler-CQjyjOuN.mjs +52 -0
- package/dist/run-node-handler-CQjyjOuN.mjs.map +1 -0
- package/dist/src/graphql/subgraph-types.d.mts +37 -0
- package/dist/src/graphql/subgraph-types.d.mts.map +1 -0
- package/dist/src/graphql/subgraph-types.mjs +105 -0
- package/dist/src/graphql/subgraph-types.mjs.map +1 -0
- package/dist/src/packages/https-hooks.d.mts +4 -4
- package/dist/src/packages/https-hooks.d.mts.map +1 -1
- package/dist/src/packages/https-hooks.mjs +2 -2
- package/dist/src/packages/https-hooks.mjs.map +1 -1
- package/dist/src/packages/vite-loader.d.mts +21 -10
- package/dist/src/packages/vite-loader.d.mts.map +1 -1
- package/dist/src/packages/vite-loader.mjs +121 -59
- package/dist/src/packages/vite-loader.mjs.map +1 -1
- package/dist/src/pglite/pglite-node.d.mts +130 -0
- package/dist/src/pglite/pglite-node.d.mts.map +1 -0
- package/dist/src/pglite/pglite-node.mjs +4 -0
- package/dist/{utils-XWVecaNn.mjs → subgraph-extraction-CcgWd0De.mjs} +540 -17
- package/dist/subgraph-extraction-CcgWd0De.mjs.map +1 -0
- package/dist/{types-DcYyNcHJ.d.mts → types-D3pD6fvQ.d.mts} +40 -5
- package/dist/types-D3pD6fvQ.d.mts.map +1 -0
- package/dist/{websocket-DncAB9XK.mjs → websocket-_SH5aBcy.mjs} +3 -3
- package/dist/{websocket-DncAB9XK.mjs.map → websocket-_SH5aBcy.mjs.map} +1 -1
- package/package.json +29 -19
- package/dist/adapter-gateway-stitching-CaZjvRzx.mjs.map +0 -1
- package/dist/adapter-http-express-B39rPhqH.mjs.map +0 -1
- package/dist/adapter-http-fastify-BwXO6rqE.mjs.map +0 -1
- package/dist/path-normalize-BOQwY9wR.mjs +0 -23
- package/dist/path-normalize-BOQwY9wR.mjs.map +0 -1
- package/dist/types-DcYyNcHJ.d.mts.map +0 -1
- package/dist/utils-XWVecaNn.mjs.map +0 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __exportAll = (all, no_symbols) => {
|
|
5
|
+
let target = {};
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
11
|
+
return target;
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { __exportAll as t };
|
|
15
|
+
!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]="e3b80eba-208e-51a9-b437-5ac76accf5d0")}catch(e){}}();
|
|
16
|
+
//# debugId=e3b80eba-208e-51a9-b437-5ac76accf5d0
|
|
@@ -0,0 +1,52 @@
|
|
|
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]="b96f00d4-5192-57bc-b435-7cc0f7c0f5c8")}catch(e){}}();
|
|
3
|
+
import { childLogger } from "document-model";
|
|
4
|
+
//#region src/graphql/gateway/path-normalize.ts
|
|
5
|
+
/**
|
|
6
|
+
* Normalises a route path for path-to-regexp v8:
|
|
7
|
+
* - Collapses duplicate slashes (e.g. "//explorer" → "/explorer")
|
|
8
|
+
* - Converts legacy optional-param syntax "/:param?" → "{/:param}". The
|
|
9
|
+
* slash must move inside the group: in p-r v8 a group whose content
|
|
10
|
+
* begins with "/" is what makes the slash and the parameter optional
|
|
11
|
+
* together, while a literal "/" left in front of the group compiles to
|
|
12
|
+
* a pattern that matches nothing (and v8 rejects a bare ":param?").
|
|
13
|
+
*
|
|
14
|
+
* Shared by both http adapters so registry dispatch matches the same path
|
|
15
|
+
* shapes regardless of which framework is in use.
|
|
16
|
+
*/
|
|
17
|
+
function normalizePath(path) {
|
|
18
|
+
return path.replace(/\/+/g, "/").replace(/\/:(\w+)\?/g, "{/:$1}");
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/graphql/gateway/run-node-handler.ts
|
|
22
|
+
const logger = childLogger(["reactor-api", "node-route"]);
|
|
23
|
+
/**
|
|
24
|
+
* Runs a node route handler without awaiting it. A throw or rejection is
|
|
25
|
+
* logged and answered with a 500, or ends the socket if headers already went
|
|
26
|
+
* out; it never reaches the process as an unhandled rejection.
|
|
27
|
+
*/
|
|
28
|
+
function runNodeHandler(handler, req, res, body) {
|
|
29
|
+
const fail = (err) => {
|
|
30
|
+
logger.error("Node route handler failed for @method @url: @error", req.method, req.url, err);
|
|
31
|
+
if (res.headersSent) {
|
|
32
|
+
res.destroy();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
res.statusCode = 500;
|
|
36
|
+
res.setHeader("Content-Type", "application/json");
|
|
37
|
+
res.end(JSON.stringify({ error: "Internal error" }));
|
|
38
|
+
};
|
|
39
|
+
let result;
|
|
40
|
+
try {
|
|
41
|
+
result = handler(req, res, body);
|
|
42
|
+
} catch (err) {
|
|
43
|
+
fail(err);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (result) result.catch(fail);
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { normalizePath as n, runNodeHandler as t };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=run-node-handler-CQjyjOuN.mjs.map
|
|
52
|
+
//# debugId=b96f00d4-5192-57bc-b435-7cc0f7c0f5c8
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-node-handler-CQjyjOuN.mjs","sources":["../src/graphql/gateway/path-normalize.ts","../src/graphql/gateway/run-node-handler.ts"],"sourcesContent":["/**\n * Normalises a route path for path-to-regexp v8:\n * - Collapses duplicate slashes (e.g. \"//explorer\" → \"/explorer\")\n * - Converts legacy optional-param syntax \"/:param?\" → \"{/:param}\". The\n * slash must move inside the group: in p-r v8 a group whose content\n * begins with \"/\" is what makes the slash and the parameter optional\n * together, while a literal \"/\" left in front of the group compiles to\n * a pattern that matches nothing (and v8 rejects a bare \":param?\").\n *\n * Shared by both http adapters so registry dispatch matches the same path\n * shapes regardless of which framework is in use.\n */\nexport function normalizePath(path: string): string {\n return path.replace(/\\/+/g, \"/\").replace(/\\/:(\\w+)\\?/g, \"{/:$1}\");\n}\n","import { childLogger } from \"document-model\";\nimport type http from \"node:http\";\n\nconst logger = childLogger([\"reactor-api\", \"node-route\"]);\n\nexport type NodeHandler = (\n req: http.IncomingMessage,\n res: http.ServerResponse,\n body?: unknown,\n) => void | Promise<void>;\n\n/**\n * Runs a node route handler without awaiting it. A throw or rejection is\n * logged and answered with a 500, or ends the socket if headers already went\n * out; it never reaches the process as an unhandled rejection.\n */\nexport function runNodeHandler(\n handler: NodeHandler,\n req: http.IncomingMessage,\n res: http.ServerResponse,\n body: unknown,\n): void {\n const fail = (err: unknown): void => {\n logger.error(\n \"Node route handler failed for @method @url: @error\",\n req.method,\n req.url,\n err,\n );\n if (res.headersSent) {\n res.destroy();\n return;\n }\n res.statusCode = 500;\n res.setHeader(\"Content-Type\", \"application/json\");\n res.end(JSON.stringify({ error: \"Internal error\" }));\n };\n\n let result: void | Promise<void>;\n try {\n result = handler(req, res, body);\n } catch (err) {\n fail(err);\n return;\n }\n if (result) {\n result.catch(fail);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAYA,SAAgB,cAAc,MAAsB;CAClD,OAAO,KAAK,QAAQ,QAAQ,GAAG,CAAC,CAAC,QAAQ,eAAe,QAAQ;AAClE;;;ACXA,MAAM,SAAS,YAAY,CAAC,eAAe,YAAY,CAAC;;;;;;AAaxD,SAAgB,eACd,SACA,KACA,KACA,MACM;CACN,MAAM,QAAQ,QAAuB;EACnC,OAAO,MACL,sDACA,IAAI,QACJ,IAAI,KACJ,GACF;EACA,IAAI,IAAI,aAAa;GACnB,IAAI,QAAQ;GACZ;EACF;EACA,IAAI,aAAa;EACjB,IAAI,UAAU,gBAAgB,kBAAkB;EAChD,IAAI,IAAI,KAAK,UAAU,EAAE,OAAO,iBAAiB,CAAC,CAAC;CACrD;CAEA,IAAI;CACJ,IAAI;EACF,SAAS,QAAQ,KAAK,KAAK,IAAI;CACjC,SAAS,KAAK;EACZ,KAAK,GAAG;EACR;CACF;CACA,IAAI,QACF,OAAO,MAAM,IAAI;AAErB","debug_id":"b96f00d4-5192-57bc-b435-7cc0f7c0f5c8"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { C as reservedTypeNames, a as ReservedTypeNames } from "../../create-schema-DLTPkNpK.mjs";
|
|
2
|
+
import { DocumentNode } from "graphql";
|
|
3
|
+
import { DocumentModelGlobalState } from "@powerhousedao/shared/document-model";
|
|
4
|
+
//#region src/graphql/subgraph-type-ownership.d.ts
|
|
5
|
+
type OwnershipConflict = {
|
|
6
|
+
claim: string;
|
|
7
|
+
owner: string;
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/graphql/subgraph-types.d.ts
|
|
11
|
+
/** Owner of the types every generated document-model schema carries. */
|
|
12
|
+
export declare const DOCUMENT_MODEL_SCHEMA_OWNER = "document-model schema";
|
|
13
|
+
/** The type definitions of every core subgraph, by subgraph name. */
|
|
14
|
+
export declare const coreSubgraphTypeDefs: ReadonlyMap<string, DocumentNode>;
|
|
15
|
+
/** A package's own subgraph, in the order the package exports it. */
|
|
16
|
+
export type PackageSubgraph = {
|
|
17
|
+
name: string;
|
|
18
|
+
typeDefs: DocumentNode;
|
|
19
|
+
};
|
|
20
|
+
export type PackageSubgraphConflicts = {
|
|
21
|
+
/** Set when the server refuses the subgraph's name. */
|
|
22
|
+
nameHeldBy?: "core" | "document model";
|
|
23
|
+
/** Types and root fields the subgraph loses. */
|
|
24
|
+
claims: OwnershipConflict[];
|
|
25
|
+
};
|
|
26
|
+
export type PackageSubgraphReport = {
|
|
27
|
+
/** By subgraph name; subgraphs without a conflict are left out. */
|
|
28
|
+
conflicts: Map<string, PackageSubgraphConflicts>;
|
|
29
|
+
/** Models whose schema does not generate, left out of the check. */
|
|
30
|
+
skippedModels: string[];
|
|
31
|
+
};
|
|
32
|
+
/** Package subgraphs the server refuses or excludes; host subgraphs unchecked. */
|
|
33
|
+
export declare function findPackageSubgraphConflicts(subgraphs: readonly PackageSubgraph[], documentModels: readonly DocumentModelGlobalState[]): PackageSubgraphReport;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { type OwnershipConflict, type ReservedTypeNames, reservedTypeNames };
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=subgraph-types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subgraph-types.d.mts","names":[],"sources":["../../../src/graphql/subgraph-type-ownership.ts","../../../src/graphql/subgraph-types.ts"],"mappings":";;;;KAqJY;EAAsB;EAAe;;;;;qBCvHpC;;qBAGA,sBAAsB,oBAAoB;;YAS3C;EAAoB;EAAc,UAAU;;YAE5C;;EAEV;;EAEA,QAAQ;;YAGE;;EAEV,WAAW,YAAY;;EAEvB;;;wBAec,6BACd,oBAAoB,mBACpB,yBAAyB,6BACxB"}
|
|
@@ -0,0 +1,105 @@
|
|
|
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]="b8e7b48c-09ef-5ac8-b3ea-6beffcac4f22")}catch(e){}}();
|
|
3
|
+
import { C as hasOperationSchemas, D as schema_default$1, a as collectSubgraphClaims, b as getDocumentModelSubgraphName, g as findSubgraphTypeCollisions, h as documentModelSubgraphTypes, i as inspectionTypeDefs, n as systemTypeDefs, r as schema_default, s as resolveClaimOwnership, t as baseDocumentModels, v as generatedTypesOf, w as reservedTypeNames } from "../../base-document-models-69WRTSfH.mjs";
|
|
4
|
+
import { typedefs } from "@powerhousedao/analytics-engine-graphql";
|
|
5
|
+
import { gql } from "graphql-tag";
|
|
6
|
+
//#region src/graphql/subgraph-types.ts
|
|
7
|
+
/** Owner of the types every generated document-model schema carries. */
|
|
8
|
+
const DOCUMENT_MODEL_SCHEMA_OWNER = "document-model schema";
|
|
9
|
+
/** The type definitions of every core subgraph, by subgraph name. */
|
|
10
|
+
const coreSubgraphTypeDefs = /* @__PURE__ */ new Map([
|
|
11
|
+
["analytics", gql(typedefs)],
|
|
12
|
+
["system", systemTypeDefs],
|
|
13
|
+
["r", gql(schema_default)],
|
|
14
|
+
["inspection", inspectionTypeDefs],
|
|
15
|
+
["auth", gql(schema_default$1)]
|
|
16
|
+
]);
|
|
17
|
+
function claimsOf(typeDefs, generated) {
|
|
18
|
+
try {
|
|
19
|
+
return collectSubgraphClaims(typeDefs, generated);
|
|
20
|
+
} catch {
|
|
21
|
+
return /* @__PURE__ */ new Map();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** Package subgraphs the server refuses or excludes; host subgraphs unchecked. */
|
|
25
|
+
function findPackageSubgraphConflicts(subgraphs, documentModels) {
|
|
26
|
+
const models = [];
|
|
27
|
+
const modelSubgraphs = [];
|
|
28
|
+
const skippedModels = [];
|
|
29
|
+
const allModels = [...baseDocumentModels.map(([, model]) => model.documentModel.global), ...documentModels];
|
|
30
|
+
for (const model of allModels) {
|
|
31
|
+
let typeDefs;
|
|
32
|
+
try {
|
|
33
|
+
generatedTypesOf([model]);
|
|
34
|
+
if (hasOperationSchemas(model)) typeDefs = documentModelSubgraphTypes(model).typeDefs;
|
|
35
|
+
} catch {
|
|
36
|
+
skippedModels.push(model.name);
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
models.push(model);
|
|
40
|
+
const name = getDocumentModelSubgraphName(model);
|
|
41
|
+
if (typeDefs && !modelSubgraphs.some((owner) => owner.name === name)) modelSubgraphs.push({
|
|
42
|
+
name,
|
|
43
|
+
typeDefs
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
const generated = generatedTypesOf(models);
|
|
47
|
+
const fixed = generatedTypesOf([]).names;
|
|
48
|
+
const generatedOwners = /* @__PURE__ */ new Map();
|
|
49
|
+
for (const model of models) for (const name of generatedTypesOf([model]).names) if (!fixed.has(name)) generatedOwners.set(name, getDocumentModelSubgraphName(model));
|
|
50
|
+
const conflicts = /* @__PURE__ */ new Map();
|
|
51
|
+
const admitted = [];
|
|
52
|
+
for (const subgraph of subgraphs) {
|
|
53
|
+
if (coreSubgraphTypeDefs.has(subgraph.name)) {
|
|
54
|
+
conflicts.set(subgraph.name, {
|
|
55
|
+
nameHeldBy: "core",
|
|
56
|
+
claims: []
|
|
57
|
+
});
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (modelSubgraphs.some((owner) => owner.name === subgraph.name)) {
|
|
61
|
+
conflicts.set(subgraph.name, {
|
|
62
|
+
nameHeldBy: "document model",
|
|
63
|
+
claims: []
|
|
64
|
+
});
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
let collisions;
|
|
68
|
+
try {
|
|
69
|
+
collisions = findSubgraphTypeCollisions(generated, subgraph.typeDefs);
|
|
70
|
+
} catch {
|
|
71
|
+
collisions = [];
|
|
72
|
+
}
|
|
73
|
+
if (collisions.length > 0) {
|
|
74
|
+
conflicts.set(subgraph.name, { claims: collisions.map((claim) => ({
|
|
75
|
+
claim,
|
|
76
|
+
owner: generatedOwners.get(claim) ?? "document-model schema"
|
|
77
|
+
})) });
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
admitted.push(subgraph);
|
|
81
|
+
}
|
|
82
|
+
const packageNames = new Set(admitted.map(({ name }) => name));
|
|
83
|
+
const excluded = resolveClaimOwnership([
|
|
84
|
+
...Array.from(coreSubgraphTypeDefs, ([name, typeDefs]) => ({
|
|
85
|
+
name,
|
|
86
|
+
typeDefs
|
|
87
|
+
})),
|
|
88
|
+
...modelSubgraphs,
|
|
89
|
+
...admitted
|
|
90
|
+
].map(({ name, typeDefs }) => ({
|
|
91
|
+
candidate: name,
|
|
92
|
+
name,
|
|
93
|
+
claims: claimsOf(typeDefs, generated.names)
|
|
94
|
+
})));
|
|
95
|
+
for (const [name, claims] of excluded) if (packageNames.has(name)) conflicts.set(name, { claims });
|
|
96
|
+
return {
|
|
97
|
+
conflicts,
|
|
98
|
+
skippedModels
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
export { DOCUMENT_MODEL_SCHEMA_OWNER, coreSubgraphTypeDefs, findPackageSubgraphConflicts, reservedTypeNames };
|
|
103
|
+
|
|
104
|
+
//# sourceMappingURL=subgraph-types.mjs.map
|
|
105
|
+
//# debugId=b8e7b48c-09ef-5ac8-b3ea-6beffcac4f22
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subgraph-types.mjs","sources":["../../../src/graphql/subgraph-types.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 findSubgraphTypeCollisions,\n documentModelSubgraphTypes,\n generatedTypesOf,\n getDocumentModelSubgraphName,\n hasOperationSchemas,\n} from \"../utils/create-schema.js\";\nimport authSchema from \"./auth/schema.graphql\";\nimport { inspectionTypeDefs } from \"./inspection/schema.js\";\nimport reactorSchema from \"./reactor/schema.graphql\";\nimport {\n collectSubgraphClaims,\n type OwnershipConflict,\n resolveClaimOwnership,\n type SubgraphClaims,\n} from \"./subgraph-type-ownership.js\";\nimport { systemTypeDefs } from \"./system/schema.js\";\n\nexport {\n reservedTypeNames,\n type ReservedTypeNames,\n} from \"../utils/create-schema.js\";\nexport type { OwnershipConflict } from \"./subgraph-type-ownership.js\";\n\n/** Owner of the types every generated document-model schema carries. */\nexport const DOCUMENT_MODEL_SCHEMA_OWNER = \"document-model schema\";\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 [\"auth\", gql(authSchema)],\n]);\n\n/** A package's own subgraph, in the order the package exports it. */\nexport type PackageSubgraph = { name: string; typeDefs: DocumentNode };\n\nexport type PackageSubgraphConflicts = {\n /** Set when the server refuses the subgraph's name. */\n nameHeldBy?: \"core\" | \"document model\";\n /** Types and root fields the subgraph loses. */\n claims: OwnershipConflict[];\n};\n\nexport type PackageSubgraphReport = {\n /** By subgraph name; subgraphs without a conflict are left out. */\n conflicts: Map<string, PackageSubgraphConflicts>;\n /** Models whose schema does not generate, left out of the check. */\n skippedModels: string[];\n};\n\ntype ModelSubgraph = { name: string; typeDefs: DocumentNode };\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\n/** Package subgraphs the server refuses or excludes; host subgraphs unchecked. */\nexport function findPackageSubgraphConflicts(\n subgraphs: readonly PackageSubgraph[],\n documentModels: readonly DocumentModelGlobalState[],\n): PackageSubgraphReport {\n const models: DocumentModelGlobalState[] = [];\n const modelSubgraphs: ModelSubgraph[] = [];\n const skippedModels: string[] = [];\n const allModels = [\n ...baseDocumentModels.map(([, model]) => model.documentModel.global),\n ...documentModels,\n ];\n for (const model of allModels) {\n let typeDefs: DocumentNode | undefined;\n try {\n generatedTypesOf([model]);\n if (hasOperationSchemas(model)) {\n typeDefs = documentModelSubgraphTypes(model).typeDefs;\n }\n } catch {\n skippedModels.push(model.name);\n continue;\n }\n models.push(model);\n const name = getDocumentModelSubgraphName(model);\n if (typeDefs && !modelSubgraphs.some((owner) => owner.name === name)) {\n modelSubgraphs.push({ name, typeDefs });\n }\n }\n\n const generated = generatedTypesOf(models);\n const fixed = generatedTypesOf([]).names;\n const generatedOwners = new Map<string, string>();\n for (const model of models) {\n for (const name of generatedTypesOf([model]).names) {\n if (!fixed.has(name)) {\n generatedOwners.set(name, getDocumentModelSubgraphName(model));\n }\n }\n }\n\n const conflicts = new Map<string, PackageSubgraphConflicts>();\n const admitted: PackageSubgraph[] = [];\n for (const subgraph of subgraphs) {\n if (coreSubgraphTypeDefs.has(subgraph.name)) {\n conflicts.set(subgraph.name, { nameHeldBy: \"core\", claims: [] });\n continue;\n }\n if (modelSubgraphs.some((owner) => owner.name === subgraph.name)) {\n conflicts.set(subgraph.name, {\n nameHeldBy: \"document model\",\n claims: [],\n });\n continue;\n }\n let collisions: string[];\n try {\n collisions = findSubgraphTypeCollisions(generated, subgraph.typeDefs);\n } catch {\n collisions = [];\n }\n if (collisions.length > 0) {\n conflicts.set(subgraph.name, {\n claims: collisions.map((claim) => ({\n claim,\n owner: generatedOwners.get(claim) ?? DOCUMENT_MODEL_SCHEMA_OWNER,\n })),\n });\n continue;\n }\n admitted.push(subgraph);\n }\n\n const packageNames = new Set(admitted.map(({ name }) => name));\n const excluded = resolveClaimOwnership(\n [\n ...Array.from(coreSubgraphTypeDefs, ([name, typeDefs]) => ({\n name,\n typeDefs,\n })),\n ...modelSubgraphs,\n ...admitted,\n ].map(({ name, typeDefs }) => ({\n candidate: name,\n name,\n claims: claimsOf(typeDefs, generated.names),\n })),\n );\n for (const [name, claims] of excluded) {\n if (packageNames.has(name)) conflicts.set(name, { claims });\n }\n return { conflicts, skippedModels };\n}\n"],"names":["analyticsType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ext) => Promise<LoadResult>;
|
|
|
25
25
|
/**
|
|
26
26
|
* Resolve hook: resolves relative specifiers against HTTP/HTTPS parent URLs.
|
|
27
27
|
*/
|
|
28
|
-
declare function resolve(specifier: string, context: ResolveContext, nextResolve: NextResolve): Promise<ResolveResult>;
|
|
28
|
+
export declare function resolve(specifier: string, context: ResolveContext, nextResolve: NextResolve): Promise<ResolveResult>;
|
|
29
29
|
/**
|
|
30
30
|
* Load hook: fetches module source from HTTP/HTTPS URLs.
|
|
31
31
|
*/
|
|
32
|
-
declare function load(url: string, context: LoadContext, nextLoad: NextLoad): Promise<LoadResult>;
|
|
32
|
+
export declare function load(url: string, context: LoadContext, nextLoad: NextLoad): Promise<LoadResult>;
|
|
33
33
|
/**
|
|
34
34
|
* Path to this hooks file for use with node:module register()
|
|
35
35
|
*/
|
|
36
|
-
declare const httpsHooksPath: string;
|
|
36
|
+
export declare const httpsHooksPath: string;
|
|
37
37
|
//#endregion
|
|
38
|
-
export {
|
|
38
|
+
export {};
|
|
39
39
|
//# sourceMappingURL=https-hooks.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"https-hooks.d.mts","names":[],"sources":["../../../src/packages/https-hooks.mts"],"mappings":";;;;;KASK
|
|
1
|
+
{"version":3,"file":"https-hooks.d.mts","names":[],"sources":["../../../src/packages/https-hooks.mts"],"mappings":";;;;;KASK;EAAmB;EAAoB;;KACvC;EACH;EACA;EACA;;KAEG,eACH,mBACA,SAAS,mBACN,QAAQ;KAER;EAAgB;;KAChB;EAAe;EAAgB;EAAwB;;KACvD,YAAY,aAAa,SAAS,gBAAgB,QAAQ;;;;wBAKzC,QACpB,mBACA,SAAS,gBACT,aAAa,cACZ,QAAQ;;;;wBAgEW,KACpB,aACA,SAAS,aACT,UAAU,WACT,QAAQ;;;;qBAoFE"}
|
|
@@ -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]="8149a6c4-bab0-57e3-a471-cfc77d529bbf")}catch(e){}}();
|
|
3
3
|
import { pathToFileURL } from "node:url";
|
|
4
4
|
import { get } from "node:http";
|
|
5
5
|
import { get as get$1 } from "node:https";
|
|
@@ -99,4 +99,4 @@ const httpsHooksPath = import.meta.url;
|
|
|
99
99
|
export { httpsHooksPath, load, resolve };
|
|
100
100
|
|
|
101
101
|
//# sourceMappingURL=https-hooks.mjs.map
|
|
102
|
-
//# debugId=
|
|
102
|
+
//# debugId=8149a6c4-bab0-57e3-a471-cfc77d529bbf
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"https-hooks.mjs","sources":["../../../src/packages/https-hooks.mts"],"sourcesContent":["import { get as httpGet } from \"node:http\";\nimport { get } from \"node:https\";\nimport { pathToFileURL } from \"node:url\";\n\n/**\n * Node.js module loader hooks that enable importing from HTTP/HTTPS URLs.\n * See: https://nodejs.org/docs/latest-v24.x/api/module.html#import-from-https\n */\n\ntype ResolveContext = { parentURL?: string; conditions?: string[] };\ntype ResolveResult = {\n url: string;\n shortCircuit?: boolean;\n format?: string;\n};\ntype NextResolve = (\n specifier: string,\n context: ResolveContext,\n) => Promise<ResolveResult>;\n\ntype LoadContext = { format?: string };\ntype LoadResult = { format: string; shortCircuit?: boolean; source: string };\ntype NextLoad = (url: string, context: LoadContext) => Promise<LoadResult>;\n\n/**\n * Resolve hook: resolves relative specifiers against HTTP/HTTPS parent URLs.\n */\nexport async function resolve(\n specifier: string,\n context: ResolveContext,\n nextResolve: NextResolve,\n): Promise<ResolveResult> {\n const { parentURL } = context;\n\n // If the specifier is already an HTTP(S) URL, resolve it directly\n if (specifier.startsWith(\"https://\") || specifier.startsWith(\"http://\")) {\n return { url: specifier, shortCircuit: true, format: \"module\" };\n }\n\n // If the parent is an HTTP(S) URL and specifier is relative, resolve against it.\n // Only handle relative specifiers (./ or ../), not bare package specifiers.\n if (\n parentURL &&\n (parentURL.startsWith(\"https://\") || parentURL.startsWith(\"http://\")) &&\n (specifier.startsWith(\"./\") || specifier.startsWith(\"../\"))\n ) {\n const resolved = new URL(specifier, parentURL).href;\n return { url: resolved, shortCircuit: true, format: \"module\" };\n }\n\n // Bare specifiers from HTTP modules need a node_modules root to resolve\n // against. Under pnpm's strict isolation the deps a registry-built bundle\n // needs split into two classes:\n // - Peer deps the *consumer* declared (react, react-dom, graphql, …) —\n // live at the consumer project root.\n // - Things reactor-api keeps external by design (the reactor-api package\n // itself, for class identity; internal helpers) — live in reactor-api's\n // own tree.\n // Neither root sees the other under strict mode, so try the consumer first\n // (its declared peers win on version) and fall back to reactor-api's tree.\n //\n // At this point: specifier is not an http(s):// URL (branch 1) and not\n // relative (branch 2). Only redirect bare package specifiers; let absolute\n // paths and other URL schemes (e.g. \"node:fs\", \"file://…\") fall through.\n if (\n parentURL &&\n (parentURL.startsWith(\"https://\") || parentURL.startsWith(\"http://\"))\n ) {\n const isBareSpecifier =\n !specifier.startsWith(\"/\") && !/^[a-z][a-z0-9+.-]*:/i.test(specifier);\n if (isBareSpecifier) {\n const consumerRoot = pathToFileURL(process.cwd() + \"/\").href;\n try {\n return await nextResolve(specifier, {\n ...context,\n parentURL: consumerRoot,\n });\n } catch (e) {\n const code = (e as NodeJS.ErrnoException | undefined)?.code;\n if (code !== \"ERR_MODULE_NOT_FOUND\") throw e;\n return nextResolve(specifier, {\n ...context,\n parentURL: import.meta.url,\n });\n }\n }\n }\n\n // Let Node.js handle all other specifiers\n return nextResolve(specifier, context);\n}\n\n/**\n * Load hook: fetches module source from HTTP/HTTPS URLs.\n */\nexport async function load(\n url: string,\n context: LoadContext,\n nextLoad: NextLoad,\n): Promise<LoadResult> {\n // Handle HTTPS URLs\n if (url.startsWith(\"https://\")) {\n const source = await fetchModule(url, get);\n return {\n format: \"module\",\n shortCircuit: true,\n source: patchCreateRequire(source),\n };\n }\n\n // Handle HTTP URLs (for local development)\n if (url.startsWith(\"http://\")) {\n const source = await fetchModule(url, httpGet);\n return {\n format: \"module\",\n shortCircuit: true,\n source: patchCreateRequire(source),\n };\n }\n\n // Let Node.js handle all other URLs\n return nextLoad(url, context);\n}\n\n/**\n * Rewrite `createRequire(import.meta.url)` in HTTP-loaded modules so that\n * `createRequire` receives a local file URL instead of an HTTP URL it cannot handle.\n *\n * The base is baked in at hook time as a string literal. Injecting a live\n * `process.cwd()` call into the module source (the previous approach) crashes\n * with \"process.cwd is not a function\": HTTP-loaded modules execute in the\n * module-customization realm, which has no full `process`. This hook itself\n * runs where `process.cwd()` works, so we resolve the base here and embed the\n * resulting file URL as a literal — no runtime `process` access in the loaded\n * module. Any package whose bundle contains `createRequire(import.meta.url)`\n * (common CJS interop) failed to load before this.\n */\nfunction patchCreateRequire(source: string): string {\n const requireBase = pathToFileURL(process.cwd() + \"/\").href;\n return source.replace(\n /createRequire\\(import\\.meta\\.url\\)/g,\n `createRequire(${JSON.stringify(requireBase)})`,\n );\n}\n\nfunction fetchModule(\n url: string,\n getter: typeof get | typeof httpGet,\n): Promise<string> {\n return new Promise((resolve, reject) => {\n getter(url, (res) => {\n // Handle redirects\n if (\n res.statusCode &&\n res.statusCode >= 300 &&\n res.statusCode < 400 &&\n res.headers.location\n ) {\n const redirectUrl = res.headers.location;\n const redirectGetter = redirectUrl.startsWith(\"https://\")\n ? get\n : httpGet;\n fetchModule(redirectUrl, redirectGetter).then(resolve).catch(reject);\n return;\n }\n\n if (res.statusCode && res.statusCode >= 400) {\n reject(new Error(`Failed to fetch ${url}: ${res.statusCode}`));\n return;\n }\n\n let data = \"\";\n res.setEncoding(\"utf8\");\n res.on(\"data\", (chunk) => (data += chunk));\n res.on(\"end\", () => resolve(data));\n res.on(\"error\", reject);\n }).on(\"error\", reject);\n });\n}\n\n/**\n * Path to this hooks file for use with node:module register()\n */\nexport const httpsHooksPath: string = import.meta.url;\n"],"names":["get","httpGet"],"mappings":";;;;;;;;;AA2BA,eAAsB,QACpB,WACA,SACA,aACwB;CACxB,MAAM,EAAE,cAAc;
|
|
1
|
+
{"version":3,"file":"https-hooks.mjs","sources":["../../../src/packages/https-hooks.mts"],"sourcesContent":["import { get as httpGet } from \"node:http\";\nimport { get } from \"node:https\";\nimport { pathToFileURL } from \"node:url\";\n\n/**\n * Node.js module loader hooks that enable importing from HTTP/HTTPS URLs.\n * See: https://nodejs.org/docs/latest-v24.x/api/module.html#import-from-https\n */\n\ntype ResolveContext = { parentURL?: string; conditions?: string[] };\ntype ResolveResult = {\n url: string;\n shortCircuit?: boolean;\n format?: string;\n};\ntype NextResolve = (\n specifier: string,\n context: ResolveContext,\n) => Promise<ResolveResult>;\n\ntype LoadContext = { format?: string };\ntype LoadResult = { format: string; shortCircuit?: boolean; source: string };\ntype NextLoad = (url: string, context: LoadContext) => Promise<LoadResult>;\n\n/**\n * Resolve hook: resolves relative specifiers against HTTP/HTTPS parent URLs.\n */\nexport async function resolve(\n specifier: string,\n context: ResolveContext,\n nextResolve: NextResolve,\n): Promise<ResolveResult> {\n const { parentURL } = context;\n\n // If the specifier is already an HTTP(S) URL, resolve it directly\n if (specifier.startsWith(\"https://\") || specifier.startsWith(\"http://\")) {\n return { url: specifier, shortCircuit: true, format: \"module\" };\n }\n\n // If the parent is an HTTP(S) URL and specifier is relative, resolve against it.\n // Only handle relative specifiers (./ or ../), not bare package specifiers.\n if (\n parentURL &&\n (parentURL.startsWith(\"https://\") || parentURL.startsWith(\"http://\")) &&\n (specifier.startsWith(\"./\") || specifier.startsWith(\"../\"))\n ) {\n const resolved = new URL(specifier, parentURL).href;\n return { url: resolved, shortCircuit: true, format: \"module\" };\n }\n\n // Bare specifiers from HTTP modules need a node_modules root to resolve\n // against. Under pnpm's strict isolation the deps a registry-built bundle\n // needs split into two classes:\n // - Peer deps the *consumer* declared (react, react-dom, graphql, …) —\n // live at the consumer project root.\n // - Things reactor-api keeps external by design (the reactor-api package\n // itself, for class identity; internal helpers) — live in reactor-api's\n // own tree.\n // Neither root sees the other under strict mode, so try the consumer first\n // (its declared peers win on version) and fall back to reactor-api's tree.\n //\n // At this point: specifier is not an http(s):// URL (branch 1) and not\n // relative (branch 2). Only redirect bare package specifiers; let absolute\n // paths and other URL schemes (e.g. \"node:fs\", \"file://…\") fall through.\n if (\n parentURL &&\n (parentURL.startsWith(\"https://\") || parentURL.startsWith(\"http://\"))\n ) {\n const isBareSpecifier =\n !specifier.startsWith(\"/\") && !/^[a-z][a-z0-9+.-]*:/i.test(specifier);\n if (isBareSpecifier) {\n const consumerRoot = pathToFileURL(process.cwd() + \"/\").href;\n try {\n return await nextResolve(specifier, {\n ...context,\n parentURL: consumerRoot,\n });\n } catch (e) {\n const code = (e as NodeJS.ErrnoException | undefined)?.code;\n if (code !== \"ERR_MODULE_NOT_FOUND\") throw e;\n return nextResolve(specifier, {\n ...context,\n parentURL: import.meta.url,\n });\n }\n }\n }\n\n // Let Node.js handle all other specifiers\n return nextResolve(specifier, context);\n}\n\n/**\n * Load hook: fetches module source from HTTP/HTTPS URLs.\n */\nexport async function load(\n url: string,\n context: LoadContext,\n nextLoad: NextLoad,\n): Promise<LoadResult> {\n // Handle HTTPS URLs\n if (url.startsWith(\"https://\")) {\n const source = await fetchModule(url, get);\n return {\n format: \"module\",\n shortCircuit: true,\n source: patchCreateRequire(source),\n };\n }\n\n // Handle HTTP URLs (for local development)\n if (url.startsWith(\"http://\")) {\n const source = await fetchModule(url, httpGet);\n return {\n format: \"module\",\n shortCircuit: true,\n source: patchCreateRequire(source),\n };\n }\n\n // Let Node.js handle all other URLs\n return nextLoad(url, context);\n}\n\n/**\n * Rewrite `createRequire(import.meta.url)` in HTTP-loaded modules so that\n * `createRequire` receives a local file URL instead of an HTTP URL it cannot handle.\n *\n * The base is baked in at hook time as a string literal. Injecting a live\n * `process.cwd()` call into the module source (the previous approach) crashes\n * with \"process.cwd is not a function\": HTTP-loaded modules execute in the\n * module-customization realm, which has no full `process`. This hook itself\n * runs where `process.cwd()` works, so we resolve the base here and embed the\n * resulting file URL as a literal — no runtime `process` access in the loaded\n * module. Any package whose bundle contains `createRequire(import.meta.url)`\n * (common CJS interop) failed to load before this.\n */\nfunction patchCreateRequire(source: string): string {\n const requireBase = pathToFileURL(process.cwd() + \"/\").href;\n return source.replace(\n /createRequire\\(import\\.meta\\.url\\)/g,\n `createRequire(${JSON.stringify(requireBase)})`,\n );\n}\n\nfunction fetchModule(\n url: string,\n getter: typeof get | typeof httpGet,\n): Promise<string> {\n return new Promise((resolve, reject) => {\n getter(url, (res) => {\n // Handle redirects\n if (\n res.statusCode &&\n res.statusCode >= 300 &&\n res.statusCode < 400 &&\n res.headers.location\n ) {\n const redirectUrl = res.headers.location;\n const redirectGetter = redirectUrl.startsWith(\"https://\")\n ? get\n : httpGet;\n fetchModule(redirectUrl, redirectGetter).then(resolve).catch(reject);\n return;\n }\n\n if (res.statusCode && res.statusCode >= 400) {\n reject(new Error(`Failed to fetch ${url}: ${res.statusCode}`));\n return;\n }\n\n let data = \"\";\n res.setEncoding(\"utf8\");\n res.on(\"data\", (chunk) => (data += chunk));\n res.on(\"end\", () => resolve(data));\n res.on(\"error\", reject);\n }).on(\"error\", reject);\n });\n}\n\n/**\n * Path to this hooks file for use with node:module register()\n */\nexport const httpsHooksPath: string = import.meta.url;\n"],"names":["get","httpGet"],"mappings":";;;;;;;;;AA2BA,eAAsB,QACpB,WACA,SACA,aACwB;CACxB,MAAM,EAAE,cAAc;CAGtB,IAAI,UAAU,WAAW,UAAU,KAAK,UAAU,WAAW,SAAS,GACpE,OAAO;EAAE,KAAK;EAAW,cAAc;EAAM,QAAQ;CAAS;CAKhE,IACE,cACC,UAAU,WAAW,UAAU,KAAK,UAAU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AAI,aAAa,OACjB,IAAI,QAAQ,UACZ;IACA,MAAM,cAAc,IAAI,QAAQ;IAIhC,YAAY,aAHW,YAAY,WAAW,UAAU,IACpDD,QACAC,GACmC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,MAAM,MAAM;IACnE;GACF;GAEA,IAAI,IAAI,cAAc,IAAI,cAAc,KAAK;IAC3C,uBAAO,IAAI,MAAM,mBAAmB,IAAI,IAAI,IAAI,YAAY,CAAC;IAC7D;GACF;GAEA,IAAI,OAAO;GACX,IAAI,YAAY,MAAM;GACtB,IAAI,GAAG,SAAS,UAAW,QAAQ,KAAM;GACzC,IAAI,GAAG,aAAa,QAAQ,IAAI,CAAC;GACjC,IAAI,GAAG,SAAS,MAAM;EACxB,CAAC,CAAC,CAAC,GAAG,SAAS,MAAM;CACvB,CAAC;AACH;;;;AAKA,MAAa,iBAAyB,YAAY","debug_id":"8149a6c4-bab0-57e3-a471-cfc77d529bbf"}
|
|
@@ -1,30 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ILogger } from "document-model";
|
|
1
|
+
import { d as ReportError, o as ISubscribablePackageLoader, s as ISubscriptionOptions, u as PackagePieceEntry } from "../../types-D3pD6fvQ.mjs";
|
|
3
2
|
import { DocumentModelModule, UpgradeManifest } from "@powerhousedao/shared/document-model";
|
|
3
|
+
import { ILogger } from "document-model";
|
|
4
4
|
import { Logger, ViteDevServer } from "vite";
|
|
5
5
|
import { ProcessorFactoryBuilder, SubgraphClass } from "@powerhousedao/reactor-api";
|
|
6
|
-
|
|
7
6
|
//#region src/packages/vite-loader.d.mts
|
|
8
|
-
declare function createViteLogger(logger: ILogger, prefix?: string): Logger;
|
|
9
|
-
|
|
7
|
+
export declare function createViteLogger(logger: ILogger, prefix?: string): Logger;
|
|
8
|
+
export interface VitePackageLoaderOptions {
|
|
9
|
+
/** Modules, as paths or file URLs, whose dependencies a package the project
|
|
10
|
+
* does not install may resolve from. This loader's own module always is. */
|
|
11
|
+
resolveFrom?: string[];
|
|
12
|
+
reportError?: ReportError;
|
|
13
|
+
}
|
|
14
|
+
export declare class VitePackageLoader implements ISubscribablePackageLoader {
|
|
10
15
|
#private;
|
|
11
16
|
private readonly logger;
|
|
12
17
|
private readonly vite;
|
|
18
|
+
private readonly importers;
|
|
13
19
|
readonly name = "VitePackageLoader";
|
|
14
|
-
static build(vite: ViteDevServer): VitePackageLoader;
|
|
15
|
-
constructor(vite: ViteDevServer);
|
|
20
|
+
static build(vite: ViteDevServer, options?: VitePackageLoaderOptions): VitePackageLoader;
|
|
21
|
+
constructor(vite: ViteDevServer, options?: VitePackageLoaderOptions);
|
|
16
22
|
private getDocumentModelsPath;
|
|
17
23
|
private getSubgraphsPath;
|
|
18
24
|
private getProcessorsPath;
|
|
19
|
-
|
|
25
|
+
private getPiecesPath;
|
|
26
|
+
private aliasedRoot;
|
|
27
|
+
private pieceRoot;
|
|
28
|
+
loadDocumentModels(identifier: string): Promise<DocumentModelModule[]>;
|
|
20
29
|
loadUpgradeManifests(identifier: string): Promise<UpgradeManifest<readonly number[]>[]>;
|
|
21
30
|
loadSubgraphs(identifier: string): Promise<SubgraphClass[]>;
|
|
22
31
|
loadProcessors(identifier: string): Promise<ProcessorFactoryBuilder | null>;
|
|
32
|
+
loadPieces(identifier: string): Promise<PackagePieceEntry[]>;
|
|
23
33
|
onDocumentModelsChange(identifier: string, handler: (documentModels: DocumentModelModule[]) => void, options?: ISubscriptionOptions): () => void;
|
|
24
34
|
onSubgraphsChange(identifier: string, handler: (subgraphs: SubgraphClass[]) => void, options?: ISubscriptionOptions): () => void;
|
|
25
35
|
onProcessorsChange(identifier: string, handler: (processors: ProcessorFactoryBuilder | null) => void, options?: ISubscriptionOptions): () => void;
|
|
36
|
+
onPiecesChange(identifier: string, handler: (pieces: PackagePieceEntry[]) => void, options?: ISubscriptionOptions): () => void;
|
|
26
37
|
}
|
|
27
|
-
declare function startViteServer(root: string, logger?: Logger): Promise<ViteDevServer>;
|
|
38
|
+
export declare function startViteServer(root: string, logger?: Logger): Promise<ViteDevServer>;
|
|
28
39
|
//#endregion
|
|
29
|
-
export {
|
|
40
|
+
export {};
|
|
30
41
|
//# sourceMappingURL=vite-loader.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-loader.d.mts","names":[],"sources":["../../../src/packages/vite-loader.mts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"vite-loader.d.mts","names":[],"sources":["../../../src/packages/vite-loader.mts"],"mappings":";;;;;;wBAgCgB,iBAAiB,QAAQ,SAAS,kBAAW;iBA2B5C;;;EAGf;EACA,cAAc;;qBAQH,6BAA6B;;mBACvB;mBAEA;mBAEA;WAIR;SAEF,MAAM,MAAM,eAAe,UAAU,2BAAwB;EAIpE,YAAY,MAAM,eAAe,UAAS;UA0DlC;UAIA;UAIA;UAIA;UAMA;UASA;EAcF,mBAAmB,qBAAqB,QAAQ;EAehD,qBACJ,qBACC,QAAQ;EAoBL,cAAc,qBAAqB,QAAQ;EAiB3C,eACJ,qBACC,QAAQ;EAkBL,WAAW,qBAAqB,QAAQ;EA0C9C,uBACE,oBACA,UAAU,gBAAgB,gCAC1B,UAAU;EAwBZ,kBACE,oBACA,UAAU,WAAW,0BACrB,UAAU;EAuBZ,mBACE,oBACA,UAAU,YAAY,yCACtB,UAAU;EAuBZ,eACE,oBACA,UAAU,QAAQ,8BAClB,UAAU;;wBA6BQ,gBAAgB,cAAc,SAAS,SAAM,QAAA"}
|