@soda-gql/plugin-common 0.0.1 → 0.0.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soda-gql/plugin-common",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "license": "MIT",
@@ -26,9 +26,9 @@
26
26
  "./package.json": "./package.json"
27
27
  },
28
28
  "dependencies": {
29
- "@soda-gql/builder": "0.0.1",
30
- "@soda-gql/common": "0.0.1",
31
- "@soda-gql/config": "0.0.1",
29
+ "@soda-gql/builder": "0.0.2",
30
+ "@soda-gql/common": "0.0.2",
31
+ "@soda-gql/config": "0.0.2",
32
32
  "neverthrow": "^8.1.1"
33
33
  },
34
34
  "devDependencies": {},
package/dist/index.cjs DELETED
@@ -1,105 +0,0 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
-
23
- //#endregion
24
- let __soda_gql_builder = require("@soda-gql/builder");
25
- __soda_gql_builder = __toESM(__soda_gql_builder);
26
- let __soda_gql_common = require("@soda-gql/common");
27
- __soda_gql_common = __toESM(__soda_gql_common);
28
- let __soda_gql_config = require("@soda-gql/config");
29
- __soda_gql_config = __toESM(__soda_gql_config);
30
- let node_path = require("node:path");
31
- node_path = __toESM(node_path);
32
-
33
- //#region packages/plugin-common/src/errors.ts
34
- /**
35
- * Format a PluginError into a human-readable message.
36
- */
37
- const formatPluginError = (error) => {
38
- return `${`[${error.code}]`}${"stage" in error ? ` (${error.stage})` : ""} ${error.message}`;
39
- };
40
- /**
41
- * Type guard for PluginError.
42
- */
43
- const isPluginError = (value) => {
44
- return typeof value === "object" && value !== null && "type" in value && value.type === "PluginError" && "code" in value && "message" in value;
45
- };
46
- /**
47
- * Assertion helper for unreachable code paths.
48
- * This is the ONLY acceptable throw in plugin code.
49
- */
50
- const assertUnreachable = (value, context) => {
51
- throw new Error(`[INTERNAL] Unreachable code path${context ? ` in ${context}` : ""}: received ${JSON.stringify(value)}`);
52
- };
53
-
54
- //#endregion
55
- //#region packages/plugin-common/src/plugin-session.ts
56
- /**
57
- * Create plugin session by loading config and creating cached builder service.
58
- * Returns null if disabled or config load fails.
59
- */
60
- const createPluginSession = (options, pluginName) => {
61
- if (!(options.enabled ?? true)) return null;
62
- const configResult = (0, __soda_gql_config.loadConfig)(options.configPath);
63
- if (configResult.isErr()) {
64
- console.error(`[${pluginName}] Failed to load config:`, {
65
- code: configResult.error.code,
66
- message: configResult.error.message,
67
- filePath: configResult.error.filePath,
68
- cause: configResult.error.cause
69
- });
70
- return null;
71
- }
72
- const config = configResult.value;
73
- const ensureBuilderService = (0, __soda_gql_common.cachedFn)(() => (0, __soda_gql_builder.createBuilderService)({ config }));
74
- /**
75
- * Build artifact on every invocation (like tsc-plugin).
76
- * If artifact.useBuilder is false and artifact.path is provided, load from file instead.
77
- * This ensures the artifact is always up-to-date with the latest source files.
78
- */
79
- const getArtifact = () => {
80
- const buildResult = ensureBuilderService().build();
81
- if (buildResult.isErr()) {
82
- console.error(`[${pluginName}] Failed to build artifact: ${buildResult.error.message}`);
83
- return null;
84
- }
85
- return buildResult.value;
86
- };
87
- return {
88
- config,
89
- getArtifact
90
- };
91
- };
92
-
93
- //#endregion
94
- //#region packages/plugin-common/src/utils/canonical-id.ts
95
- /**
96
- * Resolve a canonical ID from a filename and AST path.
97
- */
98
- const resolveCanonicalId = (filename, astPath) => (0, __soda_gql_builder.createCanonicalId)((0, node_path.resolve)(filename), astPath);
99
-
100
- //#endregion
101
- exports.assertUnreachable = assertUnreachable;
102
- exports.createPluginSession = createPluginSession;
103
- exports.formatPluginError = formatPluginError;
104
- exports.isPluginError = isPluginError;
105
- exports.resolveCanonicalId = resolveCanonicalId;
package/dist/index.d.cts DELETED
@@ -1,224 +0,0 @@
1
- import { BuilderArtifact, BuilderArtifactInlineOperation, BuilderArtifactModel, BuilderArtifactOperation, BuilderArtifactSlice, BuilderError, CanonicalId } from "@soda-gql/builder";
2
- import { ResolvedSodaGqlConfig } from "@soda-gql/config";
3
-
4
- //#region packages/plugin-common/src/errors.d.ts
5
-
6
- type OptionsInvalidBuilderConfig = {
7
- readonly code: "INVALID_BUILDER_CONFIG";
8
- readonly message: string;
9
- };
10
- type OptionsMissingBuilderConfig = {
11
- readonly code: "MISSING_BUILDER_CONFIG";
12
- readonly message: string;
13
- };
14
- type OptionsConfigLoadFailed = {
15
- readonly code: "CONFIG_LOAD_FAILED";
16
- readonly message: string;
17
- };
18
- type BuilderEntryNotFound = Extract<BuilderError, {
19
- code: "ENTRY_NOT_FOUND";
20
- }>;
21
- type BuilderDocDuplicate = Extract<BuilderError, {
22
- code: "DOC_DUPLICATE";
23
- }>;
24
- type BuilderCircularDependency = Extract<BuilderError, {
25
- code: "GRAPH_CIRCULAR_DEPENDENCY";
26
- }>;
27
- type BuilderModuleEvaluationFailed = Extract<BuilderError, {
28
- code: "RUNTIME_MODULE_LOAD_FAILED";
29
- }>;
30
- type BuilderWriteFailed = Extract<BuilderError, {
31
- code: "WRITE_FAILED";
32
- }>;
33
- type AnalysisMetadataMissingCause = {
34
- readonly filename: string;
35
- };
36
- type AnalysisArtifactMissingCause = {
37
- readonly filename: string;
38
- readonly canonicalId: CanonicalId;
39
- };
40
- type AnalysisUnsupportedArtifactTypeCause = {
41
- readonly filename: string;
42
- readonly canonicalId: CanonicalId;
43
- readonly artifactType: string;
44
- };
45
- type PluginErrorBase<Code extends string, Cause> = {
46
- readonly type: "PluginError";
47
- readonly code: Code;
48
- readonly message: string;
49
- readonly cause: Cause;
50
- };
51
- type PluginOptionsInvalidBuilderConfigError = PluginErrorBase<"OPTIONS_INVALID_BUILDER_CONFIG", OptionsInvalidBuilderConfig | OptionsMissingBuilderConfig | OptionsConfigLoadFailed> & {
52
- readonly stage: "normalize-options";
53
- };
54
- type PluginBuilderEntryNotFoundError = PluginErrorBase<"SODA_GQL_BUILDER_ENTRY_NOT_FOUND", BuilderEntryNotFound> & {
55
- readonly stage: "builder";
56
- readonly entry: string;
57
- };
58
- type PluginBuilderDocDuplicateError = PluginErrorBase<"SODA_GQL_BUILDER_DOC_DUPLICATE", BuilderDocDuplicate> & {
59
- readonly stage: "builder";
60
- readonly name: string;
61
- readonly sources: readonly string[];
62
- };
63
- type PluginBuilderCircularDependencyError = PluginErrorBase<"SODA_GQL_BUILDER_CIRCULAR_DEPENDENCY", BuilderCircularDependency> & {
64
- readonly stage: "builder";
65
- readonly chain: readonly string[];
66
- };
67
- type PluginBuilderModuleEvaluationFailedError = PluginErrorBase<"SODA_GQL_BUILDER_MODULE_EVALUATION_FAILED", BuilderModuleEvaluationFailed> & {
68
- readonly stage: "builder";
69
- readonly filePath: string;
70
- readonly astPath: string;
71
- };
72
- type PluginBuilderWriteFailedError = PluginErrorBase<"SODA_GQL_BUILDER_WRITE_FAILED", BuilderWriteFailed> & {
73
- readonly stage: "builder";
74
- readonly outPath: string;
75
- };
76
- type PluginBuilderUnexpectedError = PluginErrorBase<"SODA_GQL_BUILDER_UNEXPECTED", unknown> & {
77
- readonly stage: "builder";
78
- };
79
- type PluginAnalysisMetadataMissingError = PluginErrorBase<"SODA_GQL_METADATA_NOT_FOUND", AnalysisMetadataMissingCause> & {
80
- readonly stage: "analysis";
81
- readonly filename: string;
82
- };
83
- type PluginAnalysisArtifactMissingError = PluginErrorBase<"SODA_GQL_ANALYSIS_ARTIFACT_NOT_FOUND", AnalysisArtifactMissingCause> & {
84
- readonly stage: "analysis";
85
- readonly filename: string;
86
- readonly canonicalId: CanonicalId;
87
- };
88
- type PluginAnalysisUnsupportedArtifactTypeError = PluginErrorBase<"SODA_GQL_UNSUPPORTED_ARTIFACT_TYPE", AnalysisUnsupportedArtifactTypeCause> & {
89
- readonly stage: "analysis";
90
- readonly filename: string;
91
- readonly canonicalId: CanonicalId;
92
- readonly artifactType: string;
93
- };
94
- type TransformMissingBuilderArgCause = {
95
- readonly filename: string;
96
- readonly builderType: string;
97
- readonly argName: string;
98
- };
99
- type TransformUnsupportedValueTypeCause = {
100
- readonly valueType: string;
101
- };
102
- type TransformAstVisitorFailedCause = {
103
- readonly filename: string;
104
- readonly reason: string;
105
- };
106
- type PluginTransformMissingBuilderArgError = PluginErrorBase<"SODA_GQL_TRANSFORM_MISSING_BUILDER_ARG", TransformMissingBuilderArgCause> & {
107
- readonly stage: "transform";
108
- readonly filename: string;
109
- readonly builderType: string;
110
- readonly argName: string;
111
- };
112
- type PluginTransformUnsupportedValueTypeError = PluginErrorBase<"SODA_GQL_TRANSFORM_UNSUPPORTED_VALUE_TYPE", TransformUnsupportedValueTypeCause> & {
113
- readonly stage: "transform";
114
- readonly valueType: string;
115
- };
116
- type PluginTransformAstVisitorFailedError = PluginErrorBase<"SODA_GQL_TRANSFORM_AST_VISITOR_FAILED", TransformAstVisitorFailedCause> & {
117
- readonly stage: "transform";
118
- readonly filename: string;
119
- readonly reason: string;
120
- };
121
- /**
122
- * Union of all plugin error types.
123
- */
124
- type PluginError = PluginOptionsInvalidBuilderConfigError | PluginBuilderEntryNotFoundError | PluginBuilderDocDuplicateError | PluginBuilderCircularDependencyError | PluginBuilderModuleEvaluationFailedError | PluginBuilderWriteFailedError | PluginBuilderUnexpectedError | PluginAnalysisMetadataMissingError | PluginAnalysisArtifactMissingError | PluginAnalysisUnsupportedArtifactTypeError | PluginTransformMissingBuilderArgError | PluginTransformUnsupportedValueTypeError | PluginTransformAstVisitorFailedError;
125
- /**
126
- * Format a PluginError into a human-readable message.
127
- */
128
- declare const formatPluginError: (error: PluginError) => string;
129
- /**
130
- * Type guard for PluginError.
131
- */
132
- declare const isPluginError: (value: unknown) => value is PluginError;
133
- /**
134
- * Assertion helper for unreachable code paths.
135
- * This is the ONLY acceptable throw in plugin code.
136
- */
137
- declare const assertUnreachable: (value: never, context?: string) => never;
138
- //#endregion
139
- //#region packages/plugin-common/src/plugin-session.d.ts
140
- /**
141
- * Plugin options shared across all plugins.
142
- */
143
- type PluginOptions = {
144
- readonly configPath?: string;
145
- readonly enabled?: boolean;
146
- };
147
- /**
148
- * Plugin session containing builder service and configuration.
149
- */
150
- type PluginSession = {
151
- readonly config: ResolvedSodaGqlConfig;
152
- readonly getArtifact: () => BuilderArtifact | null;
153
- };
154
- /**
155
- * Create plugin session by loading config and creating cached builder service.
156
- * Returns null if disabled or config load fails.
157
- */
158
- declare const createPluginSession: (options: PluginOptions, pluginName: string) => PluginSession | null;
159
- //#endregion
160
- //#region packages/plugin-common/src/types/gql-call.d.ts
161
- /**
162
- * Base interface for all GraphQL call types.
163
- * TCallNode represents the AST node type (e.g., t.CallExpression for Babel, ts.CallExpression for TypeScript).
164
- */
165
- interface GqlCallBase<TCallNode> {
166
- readonly canonicalId: CanonicalId;
167
- readonly builderCall: TCallNode;
168
- }
169
- /**
170
- * GraphQL model call.
171
- */
172
- interface GqlCallModel<TCallNode> extends GqlCallBase<TCallNode> {
173
- readonly type: "model";
174
- readonly artifact: BuilderArtifactModel;
175
- }
176
- /**
177
- * GraphQL slice call.
178
- */
179
- interface GqlCallSlice<TCallNode> extends GqlCallBase<TCallNode> {
180
- readonly type: "slice";
181
- readonly artifact: BuilderArtifactSlice;
182
- }
183
- /**
184
- * GraphQL composed operation call.
185
- * Unified naming: "operation" (was "composedOperation" in tsc-plugin).
186
- */
187
- interface GqlCallOperation<TCallNode> extends GqlCallBase<TCallNode> {
188
- readonly type: "operation";
189
- readonly artifact: BuilderArtifactOperation;
190
- }
191
- /**
192
- * GraphQL inline operation call.
193
- */
194
- interface GqlCallInlineOperation<TCallNode> extends GqlCallBase<TCallNode> {
195
- readonly type: "inlineOperation";
196
- readonly artifact: BuilderArtifactInlineOperation;
197
- }
198
- /**
199
- * Union of all GraphQL call types.
200
- */
201
- type GqlCall<TCallNode> = GqlCallModel<TCallNode> | GqlCallSlice<TCallNode> | GqlCallOperation<TCallNode> | GqlCallInlineOperation<TCallNode>;
202
- //#endregion
203
- //#region packages/plugin-common/src/types/metadata.d.ts
204
- /**
205
- * Unified metadata types used across all plugins.
206
- */
207
- /**
208
- * Metadata for a GraphQL definition.
209
- */
210
- type GqlDefinitionMetadata = {
211
- readonly astPath: string;
212
- readonly isTopLevel: boolean;
213
- readonly isExported: boolean;
214
- readonly exportBinding?: string;
215
- };
216
- //#endregion
217
- //#region packages/plugin-common/src/utils/canonical-id.d.ts
218
- /**
219
- * Resolve a canonical ID from a filename and AST path.
220
- */
221
- declare const resolveCanonicalId: (filename: string, astPath: string) => CanonicalId;
222
- //#endregion
223
- export { GqlCall, GqlCallBase, GqlCallInlineOperation, GqlCallModel, GqlCallOperation, GqlCallSlice, GqlDefinitionMetadata, PluginAnalysisArtifactMissingError, PluginAnalysisMetadataMissingError, PluginAnalysisUnsupportedArtifactTypeError, PluginBuilderCircularDependencyError, PluginBuilderDocDuplicateError, PluginBuilderEntryNotFoundError, PluginBuilderModuleEvaluationFailedError, PluginBuilderUnexpectedError, PluginBuilderWriteFailedError, PluginError, PluginOptions, PluginOptionsInvalidBuilderConfigError, PluginSession, PluginTransformAstVisitorFailedError, PluginTransformMissingBuilderArgError, PluginTransformUnsupportedValueTypeError, assertUnreachable, createPluginSession, formatPluginError, isPluginError, resolveCanonicalId };
224
- //# sourceMappingURL=index.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/errors.ts","../src/plugin-session.ts","../src/types/gql-call.ts","../src/types/metadata.ts","../src/utils/canonical-id.ts"],"sourcesContent":[],"mappings":";;;;;AAOgC,KAA3B,2BAAA,GAC2B;EAC3B,SAAA,IAAA,EAAA,wBAAuB;EAEvB,SAAA,OAAA,EAAA,MAAoB;CAAA;KAHpB,2BAAA,GAG+B;WAAR,IAAA,EAAA,wBAAA;EAAO,SAAA,OAAA,EAAA,MAAA;AAAA,CAAA;KAF9B,uBAAA,GAGmB;WAAW,IAAA,EAAA,oBAAA;WAAR,OAAA,EAAA,MAAA;CAAO;AAAA,KAD7B,oBAAA,GAAuB,OAEE,CAFM,YAEN,EAAA;EAAA,IAAA,EAAA,iBAAA;;KADzB,mBAAA,GAAsB,OACM,CADE,YACF,EAAA;EAAO,IAAA,EAAA,eAAA;AAAA,CAAA,CAAA;KAAnC,yBAAA,GAA4B,OACC,CADO,YACP,EAAA;MAAW,EAAA,2BAAA;;KAAxC,6BAAA,GAAgC,OAAO,CAAC,YAAD,EAAA;EACvC,IAAA,EAAA,4BAAkB;CAAA,CAAA;KAAlB,kBAAA,GAAqB,OAAQ,CAAA,YAAA,EAAA;MAAR,EAAA,cAAA;CAAO,CAAA;AAAA,KAE5B,4BAAA,GAA4B;EAC5B,SAAA,QAAA,EAAA,MAAA;AAA6F,CAAA;AAG/D,KAH9B,4BAAA,GAOe;EAAA,SAAA,QAAA,EAAA,MAAA;WAEH,WAAA,EATsE,WAStE;;KARZ,oCAAA,GAUkB;EAGX,SAAA,QAAA,EAAA,MAAA;EAAsC,SAAA,WAAA,EAX1B,WAW0B;WAEhD,YAAA,EAAA,MAAA;;KATG,eASyD,CAAA,aAAA,MAAA,EAAA,KAAA,CAAA,GAAA;WAFT,IAAA,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ACA,SAAA,QAAA,EE0BgB,wBF1BkE;AAAW;AAG/D;;;AAQjB,UEqBD,sBFrBC,CAAA,SAAA,CAAA,SEqByC,WFrBzC,CEqBqD,SFrBrD,CAAA,CAAA;EAAK,SAAA,IAAA,EAAA,iBAAA;EAGX,SAAA,QAAA,EEoBS,8BFpB6B;;;;;AAAG,KE0BzC,OF1ByC,CAAA,SAAA,CAAA,GE2BjD,YF3BiD,CE2BpC,SF3BoC,CAAA,GE4BjD,YF5BiD,CE4BpC,SF5BoC,CAAA,GE6BjD,gBF7BiD,CE6BhC,SF7BgC,CAAA,GE8BjD,sBF9BiD,CE8B1B,SF9B0B,CAAA;;;;;;;AA3Bc;AAEnC;AAE3B,KGFO,qBAAA,GHEgB;EAEvB,SAAA,OAAA,EAAA,MAAoB;EAAA,SAAA,UAAA,EAAA,OAAA;WAAW,UAAA,EAAA,OAAA;WAAR,aAAA,CAAA,EAAA,MAAA;CAAO;;;AANgC;AAEnC;AACA;AAG3B,cIDQ,kBJCY,EAAA,CAAA,QAAA,EAAA,MAAA,EAAA,OAAA,EAAA,MAAA,EAAA,GID8C,WJC9C"}
package/dist/index.d.ts DELETED
@@ -1,224 +0,0 @@
1
- import { BuilderArtifact, BuilderArtifactInlineOperation, BuilderArtifactModel, BuilderArtifactOperation, BuilderArtifactSlice, BuilderError, CanonicalId } from "@soda-gql/builder";
2
- import { ResolvedSodaGqlConfig } from "@soda-gql/config";
3
-
4
- //#region packages/plugin-common/src/errors.d.ts
5
-
6
- type OptionsInvalidBuilderConfig = {
7
- readonly code: "INVALID_BUILDER_CONFIG";
8
- readonly message: string;
9
- };
10
- type OptionsMissingBuilderConfig = {
11
- readonly code: "MISSING_BUILDER_CONFIG";
12
- readonly message: string;
13
- };
14
- type OptionsConfigLoadFailed = {
15
- readonly code: "CONFIG_LOAD_FAILED";
16
- readonly message: string;
17
- };
18
- type BuilderEntryNotFound = Extract<BuilderError, {
19
- code: "ENTRY_NOT_FOUND";
20
- }>;
21
- type BuilderDocDuplicate = Extract<BuilderError, {
22
- code: "DOC_DUPLICATE";
23
- }>;
24
- type BuilderCircularDependency = Extract<BuilderError, {
25
- code: "GRAPH_CIRCULAR_DEPENDENCY";
26
- }>;
27
- type BuilderModuleEvaluationFailed = Extract<BuilderError, {
28
- code: "RUNTIME_MODULE_LOAD_FAILED";
29
- }>;
30
- type BuilderWriteFailed = Extract<BuilderError, {
31
- code: "WRITE_FAILED";
32
- }>;
33
- type AnalysisMetadataMissingCause = {
34
- readonly filename: string;
35
- };
36
- type AnalysisArtifactMissingCause = {
37
- readonly filename: string;
38
- readonly canonicalId: CanonicalId;
39
- };
40
- type AnalysisUnsupportedArtifactTypeCause = {
41
- readonly filename: string;
42
- readonly canonicalId: CanonicalId;
43
- readonly artifactType: string;
44
- };
45
- type PluginErrorBase<Code extends string, Cause> = {
46
- readonly type: "PluginError";
47
- readonly code: Code;
48
- readonly message: string;
49
- readonly cause: Cause;
50
- };
51
- type PluginOptionsInvalidBuilderConfigError = PluginErrorBase<"OPTIONS_INVALID_BUILDER_CONFIG", OptionsInvalidBuilderConfig | OptionsMissingBuilderConfig | OptionsConfigLoadFailed> & {
52
- readonly stage: "normalize-options";
53
- };
54
- type PluginBuilderEntryNotFoundError = PluginErrorBase<"SODA_GQL_BUILDER_ENTRY_NOT_FOUND", BuilderEntryNotFound> & {
55
- readonly stage: "builder";
56
- readonly entry: string;
57
- };
58
- type PluginBuilderDocDuplicateError = PluginErrorBase<"SODA_GQL_BUILDER_DOC_DUPLICATE", BuilderDocDuplicate> & {
59
- readonly stage: "builder";
60
- readonly name: string;
61
- readonly sources: readonly string[];
62
- };
63
- type PluginBuilderCircularDependencyError = PluginErrorBase<"SODA_GQL_BUILDER_CIRCULAR_DEPENDENCY", BuilderCircularDependency> & {
64
- readonly stage: "builder";
65
- readonly chain: readonly string[];
66
- };
67
- type PluginBuilderModuleEvaluationFailedError = PluginErrorBase<"SODA_GQL_BUILDER_MODULE_EVALUATION_FAILED", BuilderModuleEvaluationFailed> & {
68
- readonly stage: "builder";
69
- readonly filePath: string;
70
- readonly astPath: string;
71
- };
72
- type PluginBuilderWriteFailedError = PluginErrorBase<"SODA_GQL_BUILDER_WRITE_FAILED", BuilderWriteFailed> & {
73
- readonly stage: "builder";
74
- readonly outPath: string;
75
- };
76
- type PluginBuilderUnexpectedError = PluginErrorBase<"SODA_GQL_BUILDER_UNEXPECTED", unknown> & {
77
- readonly stage: "builder";
78
- };
79
- type PluginAnalysisMetadataMissingError = PluginErrorBase<"SODA_GQL_METADATA_NOT_FOUND", AnalysisMetadataMissingCause> & {
80
- readonly stage: "analysis";
81
- readonly filename: string;
82
- };
83
- type PluginAnalysisArtifactMissingError = PluginErrorBase<"SODA_GQL_ANALYSIS_ARTIFACT_NOT_FOUND", AnalysisArtifactMissingCause> & {
84
- readonly stage: "analysis";
85
- readonly filename: string;
86
- readonly canonicalId: CanonicalId;
87
- };
88
- type PluginAnalysisUnsupportedArtifactTypeError = PluginErrorBase<"SODA_GQL_UNSUPPORTED_ARTIFACT_TYPE", AnalysisUnsupportedArtifactTypeCause> & {
89
- readonly stage: "analysis";
90
- readonly filename: string;
91
- readonly canonicalId: CanonicalId;
92
- readonly artifactType: string;
93
- };
94
- type TransformMissingBuilderArgCause = {
95
- readonly filename: string;
96
- readonly builderType: string;
97
- readonly argName: string;
98
- };
99
- type TransformUnsupportedValueTypeCause = {
100
- readonly valueType: string;
101
- };
102
- type TransformAstVisitorFailedCause = {
103
- readonly filename: string;
104
- readonly reason: string;
105
- };
106
- type PluginTransformMissingBuilderArgError = PluginErrorBase<"SODA_GQL_TRANSFORM_MISSING_BUILDER_ARG", TransformMissingBuilderArgCause> & {
107
- readonly stage: "transform";
108
- readonly filename: string;
109
- readonly builderType: string;
110
- readonly argName: string;
111
- };
112
- type PluginTransformUnsupportedValueTypeError = PluginErrorBase<"SODA_GQL_TRANSFORM_UNSUPPORTED_VALUE_TYPE", TransformUnsupportedValueTypeCause> & {
113
- readonly stage: "transform";
114
- readonly valueType: string;
115
- };
116
- type PluginTransformAstVisitorFailedError = PluginErrorBase<"SODA_GQL_TRANSFORM_AST_VISITOR_FAILED", TransformAstVisitorFailedCause> & {
117
- readonly stage: "transform";
118
- readonly filename: string;
119
- readonly reason: string;
120
- };
121
- /**
122
- * Union of all plugin error types.
123
- */
124
- type PluginError = PluginOptionsInvalidBuilderConfigError | PluginBuilderEntryNotFoundError | PluginBuilderDocDuplicateError | PluginBuilderCircularDependencyError | PluginBuilderModuleEvaluationFailedError | PluginBuilderWriteFailedError | PluginBuilderUnexpectedError | PluginAnalysisMetadataMissingError | PluginAnalysisArtifactMissingError | PluginAnalysisUnsupportedArtifactTypeError | PluginTransformMissingBuilderArgError | PluginTransformUnsupportedValueTypeError | PluginTransformAstVisitorFailedError;
125
- /**
126
- * Format a PluginError into a human-readable message.
127
- */
128
- declare const formatPluginError: (error: PluginError) => string;
129
- /**
130
- * Type guard for PluginError.
131
- */
132
- declare const isPluginError: (value: unknown) => value is PluginError;
133
- /**
134
- * Assertion helper for unreachable code paths.
135
- * This is the ONLY acceptable throw in plugin code.
136
- */
137
- declare const assertUnreachable: (value: never, context?: string) => never;
138
- //#endregion
139
- //#region packages/plugin-common/src/plugin-session.d.ts
140
- /**
141
- * Plugin options shared across all plugins.
142
- */
143
- type PluginOptions = {
144
- readonly configPath?: string;
145
- readonly enabled?: boolean;
146
- };
147
- /**
148
- * Plugin session containing builder service and configuration.
149
- */
150
- type PluginSession = {
151
- readonly config: ResolvedSodaGqlConfig;
152
- readonly getArtifact: () => BuilderArtifact | null;
153
- };
154
- /**
155
- * Create plugin session by loading config and creating cached builder service.
156
- * Returns null if disabled or config load fails.
157
- */
158
- declare const createPluginSession: (options: PluginOptions, pluginName: string) => PluginSession | null;
159
- //#endregion
160
- //#region packages/plugin-common/src/types/gql-call.d.ts
161
- /**
162
- * Base interface for all GraphQL call types.
163
- * TCallNode represents the AST node type (e.g., t.CallExpression for Babel, ts.CallExpression for TypeScript).
164
- */
165
- interface GqlCallBase<TCallNode> {
166
- readonly canonicalId: CanonicalId;
167
- readonly builderCall: TCallNode;
168
- }
169
- /**
170
- * GraphQL model call.
171
- */
172
- interface GqlCallModel<TCallNode> extends GqlCallBase<TCallNode> {
173
- readonly type: "model";
174
- readonly artifact: BuilderArtifactModel;
175
- }
176
- /**
177
- * GraphQL slice call.
178
- */
179
- interface GqlCallSlice<TCallNode> extends GqlCallBase<TCallNode> {
180
- readonly type: "slice";
181
- readonly artifact: BuilderArtifactSlice;
182
- }
183
- /**
184
- * GraphQL composed operation call.
185
- * Unified naming: "operation" (was "composedOperation" in tsc-plugin).
186
- */
187
- interface GqlCallOperation<TCallNode> extends GqlCallBase<TCallNode> {
188
- readonly type: "operation";
189
- readonly artifact: BuilderArtifactOperation;
190
- }
191
- /**
192
- * GraphQL inline operation call.
193
- */
194
- interface GqlCallInlineOperation<TCallNode> extends GqlCallBase<TCallNode> {
195
- readonly type: "inlineOperation";
196
- readonly artifact: BuilderArtifactInlineOperation;
197
- }
198
- /**
199
- * Union of all GraphQL call types.
200
- */
201
- type GqlCall<TCallNode> = GqlCallModel<TCallNode> | GqlCallSlice<TCallNode> | GqlCallOperation<TCallNode> | GqlCallInlineOperation<TCallNode>;
202
- //#endregion
203
- //#region packages/plugin-common/src/types/metadata.d.ts
204
- /**
205
- * Unified metadata types used across all plugins.
206
- */
207
- /**
208
- * Metadata for a GraphQL definition.
209
- */
210
- type GqlDefinitionMetadata = {
211
- readonly astPath: string;
212
- readonly isTopLevel: boolean;
213
- readonly isExported: boolean;
214
- readonly exportBinding?: string;
215
- };
216
- //#endregion
217
- //#region packages/plugin-common/src/utils/canonical-id.d.ts
218
- /**
219
- * Resolve a canonical ID from a filename and AST path.
220
- */
221
- declare const resolveCanonicalId: (filename: string, astPath: string) => CanonicalId;
222
- //#endregion
223
- export { GqlCall, GqlCallBase, GqlCallInlineOperation, GqlCallModel, GqlCallOperation, GqlCallSlice, GqlDefinitionMetadata, PluginAnalysisArtifactMissingError, PluginAnalysisMetadataMissingError, PluginAnalysisUnsupportedArtifactTypeError, PluginBuilderCircularDependencyError, PluginBuilderDocDuplicateError, PluginBuilderEntryNotFoundError, PluginBuilderModuleEvaluationFailedError, PluginBuilderUnexpectedError, PluginBuilderWriteFailedError, PluginError, PluginOptions, PluginOptionsInvalidBuilderConfigError, PluginSession, PluginTransformAstVisitorFailedError, PluginTransformMissingBuilderArgError, PluginTransformUnsupportedValueTypeError, assertUnreachable, createPluginSession, formatPluginError, isPluginError, resolveCanonicalId };
224
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/errors.ts","../src/plugin-session.ts","../src/types/gql-call.ts","../src/types/metadata.ts","../src/utils/canonical-id.ts"],"sourcesContent":[],"mappings":";;;;;AAOgC,KAA3B,2BAAA,GAC2B;EAC3B,SAAA,IAAA,EAAA,wBAAuB;EAEvB,SAAA,OAAA,EAAA,MAAoB;CAAA;KAHpB,2BAAA,GAG+B;WAAR,IAAA,EAAA,wBAAA;EAAO,SAAA,OAAA,EAAA,MAAA;AAAA,CAAA;KAF9B,uBAAA,GAGmB;WAAW,IAAA,EAAA,oBAAA;WAAR,OAAA,EAAA,MAAA;CAAO;AAAA,KAD7B,oBAAA,GAAuB,OAEE,CAFM,YAEN,EAAA;EAAA,IAAA,EAAA,iBAAA;;KADzB,mBAAA,GAAsB,OACM,CADE,YACF,EAAA;EAAO,IAAA,EAAA,eAAA;AAAA,CAAA,CAAA;KAAnC,yBAAA,GAA4B,OACC,CADO,YACP,EAAA;MAAW,EAAA,2BAAA;;KAAxC,6BAAA,GAAgC,OAAO,CAAC,YAAD,EAAA;EACvC,IAAA,EAAA,4BAAkB;CAAA,CAAA;KAAlB,kBAAA,GAAqB,OAAQ,CAAA,YAAA,EAAA;MAAR,EAAA,cAAA;CAAO,CAAA;AAAA,KAE5B,4BAAA,GAA4B;EAC5B,SAAA,QAAA,EAAA,MAAA;AAA6F,CAAA;AAG/D,KAH9B,4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AA,SAAA,CAAA,SEmBe,WFnBf,CEmB2B,SFnB3B,CAAA,CAAA;WAAW,IAAA,EAAA,OAAA;WAAR,QAAA,EEqBhB,oBFrBgB;;AAAO;;;;AACX,UE2BhB,gBF3BgB,CAAA,SAAA,CAAA,SE2BoB,WF3BpB,CE2BgC,SF3BhC,CAAA,CAAA;EAE5B,SAAA,IAAA,EAAA,WAAA;EACA,SAAA,QAAA,EE0BgB,wBF1BkE;AAAW;AAG/D;;;AAQjB,UEqBD,sBFrBC,CAAA,SAAA,CAAA,SEqByC,WFrBzC,CEqBqD,SFrBrD,CAAA,CAAA;EAAK,SAAA,IAAA,EAAA,iBAAA;EAGX,SAAA,QAAA,EEoBS,8BFpB6B;;;;;AAAG,KE0BzC,OF1ByC,CAAA,SAAA,CAAA,GE2BjD,YF3BiD,CE2BpC,SF3BoC,CAAA,GE4BjD,YF5BiD,CE4BpC,SF5BoC,CAAA,GE6BjD,gBF7BiD,CE6BhC,SF7BgC,CAAA,GE8BjD,sBF9BiD,CE8B1B,SF9B0B,CAAA;;;;;;;AA3Bc;AAEnC;AAE3B,KGFO,qBAAA,GHEgB;EAEvB,SAAA,OAAA,EAAA,MAAoB;EAAA,SAAA,UAAA,EAAA,OAAA;WAAW,UAAA,EAAA,OAAA;WAAR,aAAA,CAAA,EAAA,MAAA;CAAO;;;AANgC;AAEnC;AACA;AAG3B,cIDQ,kBJCY,EAAA,CAAA,QAAA,EAAA,MAAA,EAAA,OAAA,EAAA,MAAA,EAAA,GID8C,WJC9C"}
package/dist/index.js DELETED
@@ -1,75 +0,0 @@
1
- import { createBuilderService, createCanonicalId } from "@soda-gql/builder";
2
- import { cachedFn } from "@soda-gql/common";
3
- import { loadConfig } from "@soda-gql/config";
4
- import { resolve } from "node:path";
5
-
6
- //#region packages/plugin-common/src/errors.ts
7
- /**
8
- * Format a PluginError into a human-readable message.
9
- */
10
- const formatPluginError = (error) => {
11
- return `${`[${error.code}]`}${"stage" in error ? ` (${error.stage})` : ""} ${error.message}`;
12
- };
13
- /**
14
- * Type guard for PluginError.
15
- */
16
- const isPluginError = (value) => {
17
- return typeof value === "object" && value !== null && "type" in value && value.type === "PluginError" && "code" in value && "message" in value;
18
- };
19
- /**
20
- * Assertion helper for unreachable code paths.
21
- * This is the ONLY acceptable throw in plugin code.
22
- */
23
- const assertUnreachable = (value, context) => {
24
- throw new Error(`[INTERNAL] Unreachable code path${context ? ` in ${context}` : ""}: received ${JSON.stringify(value)}`);
25
- };
26
-
27
- //#endregion
28
- //#region packages/plugin-common/src/plugin-session.ts
29
- /**
30
- * Create plugin session by loading config and creating cached builder service.
31
- * Returns null if disabled or config load fails.
32
- */
33
- const createPluginSession = (options, pluginName) => {
34
- if (!(options.enabled ?? true)) return null;
35
- const configResult = loadConfig(options.configPath);
36
- if (configResult.isErr()) {
37
- console.error(`[${pluginName}] Failed to load config:`, {
38
- code: configResult.error.code,
39
- message: configResult.error.message,
40
- filePath: configResult.error.filePath,
41
- cause: configResult.error.cause
42
- });
43
- return null;
44
- }
45
- const config = configResult.value;
46
- const ensureBuilderService = cachedFn(() => createBuilderService({ config }));
47
- /**
48
- * Build artifact on every invocation (like tsc-plugin).
49
- * If artifact.useBuilder is false and artifact.path is provided, load from file instead.
50
- * This ensures the artifact is always up-to-date with the latest source files.
51
- */
52
- const getArtifact = () => {
53
- const buildResult = ensureBuilderService().build();
54
- if (buildResult.isErr()) {
55
- console.error(`[${pluginName}] Failed to build artifact: ${buildResult.error.message}`);
56
- return null;
57
- }
58
- return buildResult.value;
59
- };
60
- return {
61
- config,
62
- getArtifact
63
- };
64
- };
65
-
66
- //#endregion
67
- //#region packages/plugin-common/src/utils/canonical-id.ts
68
- /**
69
- * Resolve a canonical ID from a filename and AST path.
70
- */
71
- const resolveCanonicalId = (filename, astPath) => createCanonicalId(resolve(filename), astPath);
72
-
73
- //#endregion
74
- export { assertUnreachable, createPluginSession, formatPluginError, isPluginError, resolveCanonicalId };
75
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/errors.ts","../src/plugin-session.ts","../src/utils/canonical-id.ts"],"sourcesContent":["/**\n * Error types and formatters for plugin-babel.\n * Simplified from plugin-shared to include only types actually used by the Babel transformer.\n */\n\nimport type { BuilderError, CanonicalId } from \"@soda-gql/builder\";\n\ntype OptionsInvalidBuilderConfig = { readonly code: \"INVALID_BUILDER_CONFIG\"; readonly message: string };\ntype OptionsMissingBuilderConfig = { readonly code: \"MISSING_BUILDER_CONFIG\"; readonly message: string };\ntype OptionsConfigLoadFailed = { readonly code: \"CONFIG_LOAD_FAILED\"; readonly message: string };\n\ntype BuilderEntryNotFound = Extract<BuilderError, { code: \"ENTRY_NOT_FOUND\" }>;\ntype BuilderDocDuplicate = Extract<BuilderError, { code: \"DOC_DUPLICATE\" }>;\ntype BuilderCircularDependency = Extract<BuilderError, { code: \"GRAPH_CIRCULAR_DEPENDENCY\" }>;\ntype BuilderModuleEvaluationFailed = Extract<BuilderError, { code: \"RUNTIME_MODULE_LOAD_FAILED\" }>;\ntype BuilderWriteFailed = Extract<BuilderError, { code: \"WRITE_FAILED\" }>;\n\ntype AnalysisMetadataMissingCause = { readonly filename: string };\ntype AnalysisArtifactMissingCause = { readonly filename: string; readonly canonicalId: CanonicalId };\ntype AnalysisUnsupportedArtifactTypeCause = {\n readonly filename: string;\n readonly canonicalId: CanonicalId;\n readonly artifactType: string;\n};\n\ntype PluginErrorBase<Code extends string, Cause> = {\n readonly type: \"PluginError\";\n readonly code: Code;\n readonly message: string;\n readonly cause: Cause;\n};\n\nexport type PluginOptionsInvalidBuilderConfigError = PluginErrorBase<\n \"OPTIONS_INVALID_BUILDER_CONFIG\",\n OptionsInvalidBuilderConfig | OptionsMissingBuilderConfig | OptionsConfigLoadFailed\n> & { readonly stage: \"normalize-options\" };\n\nexport type PluginBuilderEntryNotFoundError = PluginErrorBase<\"SODA_GQL_BUILDER_ENTRY_NOT_FOUND\", BuilderEntryNotFound> & {\n readonly stage: \"builder\";\n readonly entry: string;\n};\n\nexport type PluginBuilderDocDuplicateError = PluginErrorBase<\"SODA_GQL_BUILDER_DOC_DUPLICATE\", BuilderDocDuplicate> & {\n readonly stage: \"builder\";\n readonly name: string;\n readonly sources: readonly string[];\n};\n\nexport type PluginBuilderCircularDependencyError = PluginErrorBase<\n \"SODA_GQL_BUILDER_CIRCULAR_DEPENDENCY\",\n BuilderCircularDependency\n> & { readonly stage: \"builder\"; readonly chain: readonly string[] };\n\nexport type PluginBuilderModuleEvaluationFailedError = PluginErrorBase<\n \"SODA_GQL_BUILDER_MODULE_EVALUATION_FAILED\",\n BuilderModuleEvaluationFailed\n> & { readonly stage: \"builder\"; readonly filePath: string; readonly astPath: string };\n\nexport type PluginBuilderWriteFailedError = PluginErrorBase<\"SODA_GQL_BUILDER_WRITE_FAILED\", BuilderWriteFailed> & {\n readonly stage: \"builder\";\n readonly outPath: string;\n};\n\nexport type PluginBuilderUnexpectedError = PluginErrorBase<\"SODA_GQL_BUILDER_UNEXPECTED\", unknown> & {\n readonly stage: \"builder\";\n};\n\nexport type PluginAnalysisMetadataMissingError = PluginErrorBase<\"SODA_GQL_METADATA_NOT_FOUND\", AnalysisMetadataMissingCause> & {\n readonly stage: \"analysis\";\n readonly filename: string;\n};\n\nexport type PluginAnalysisArtifactMissingError = PluginErrorBase<\n \"SODA_GQL_ANALYSIS_ARTIFACT_NOT_FOUND\",\n AnalysisArtifactMissingCause\n> & { readonly stage: \"analysis\"; readonly filename: string; readonly canonicalId: CanonicalId };\n\nexport type PluginAnalysisUnsupportedArtifactTypeError = PluginErrorBase<\n \"SODA_GQL_UNSUPPORTED_ARTIFACT_TYPE\",\n AnalysisUnsupportedArtifactTypeCause\n> & {\n readonly stage: \"analysis\";\n readonly filename: string;\n readonly canonicalId: CanonicalId;\n readonly artifactType: string;\n};\n\ntype TransformMissingBuilderArgCause = { readonly filename: string; readonly builderType: string; readonly argName: string };\ntype TransformUnsupportedValueTypeCause = { readonly valueType: string };\ntype TransformAstVisitorFailedCause = { readonly filename: string; readonly reason: string };\n\nexport type PluginTransformMissingBuilderArgError = PluginErrorBase<\n \"SODA_GQL_TRANSFORM_MISSING_BUILDER_ARG\",\n TransformMissingBuilderArgCause\n> & {\n readonly stage: \"transform\";\n readonly filename: string;\n readonly builderType: string;\n readonly argName: string;\n};\n\nexport type PluginTransformUnsupportedValueTypeError = PluginErrorBase<\n \"SODA_GQL_TRANSFORM_UNSUPPORTED_VALUE_TYPE\",\n TransformUnsupportedValueTypeCause\n> & { readonly stage: \"transform\"; readonly valueType: string };\n\nexport type PluginTransformAstVisitorFailedError = PluginErrorBase<\n \"SODA_GQL_TRANSFORM_AST_VISITOR_FAILED\",\n TransformAstVisitorFailedCause\n> & { readonly stage: \"transform\"; readonly filename: string; readonly reason: string };\n\n/**\n * Union of all plugin error types.\n */\nexport type PluginError =\n | PluginOptionsInvalidBuilderConfigError\n | PluginBuilderEntryNotFoundError\n | PluginBuilderDocDuplicateError\n | PluginBuilderCircularDependencyError\n | PluginBuilderModuleEvaluationFailedError\n | PluginBuilderWriteFailedError\n | PluginBuilderUnexpectedError\n | PluginAnalysisMetadataMissingError\n | PluginAnalysisArtifactMissingError\n | PluginAnalysisUnsupportedArtifactTypeError\n | PluginTransformMissingBuilderArgError\n | PluginTransformUnsupportedValueTypeError\n | PluginTransformAstVisitorFailedError;\n\n/**\n * Format a PluginError into a human-readable message.\n */\nexport const formatPluginError = (error: PluginError): string => {\n const codePrefix = `[${error.code}]`;\n const stageInfo = \"stage\" in error ? ` (${error.stage})` : \"\";\n return `${codePrefix}${stageInfo} ${error.message}`;\n};\n\n/**\n * Type guard for PluginError.\n */\nexport const isPluginError = (value: unknown): value is PluginError => {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"type\" in value &&\n value.type === \"PluginError\" &&\n \"code\" in value &&\n \"message\" in value\n );\n};\n\n/**\n * Assertion helper for unreachable code paths.\n * This is the ONLY acceptable throw in plugin code.\n */\nexport const assertUnreachable = (value: never, context?: string): never => {\n throw new Error(`[INTERNAL] Unreachable code path${context ? ` in ${context}` : \"\"}: received ${JSON.stringify(value)}`);\n};\n","/**\n * Plugin session management for all plugins.\n * Unified from plugin-babel and plugin-swc implementations.\n */\n\nimport type { BuilderArtifact } from \"@soda-gql/builder\";\nimport { createBuilderService } from \"@soda-gql/builder\";\nimport { cachedFn } from \"@soda-gql/common\";\nimport { loadConfig, type ResolvedSodaGqlConfig } from \"@soda-gql/config\";\n\n/**\n * Plugin options shared across all plugins.\n */\nexport type PluginOptions = {\n readonly configPath?: string;\n readonly enabled?: boolean;\n};\n\n/**\n * Plugin session containing builder service and configuration.\n */\nexport type PluginSession = {\n readonly config: ResolvedSodaGqlConfig;\n readonly getArtifact: () => BuilderArtifact | null;\n};\n\n/**\n * Create plugin session by loading config and creating cached builder service.\n * Returns null if disabled or config load fails.\n */\nexport const createPluginSession = (options: PluginOptions, pluginName: string): PluginSession | null => {\n const enabled = options.enabled ?? true;\n if (!enabled) {\n return null;\n }\n\n const configResult = loadConfig(options.configPath);\n if (configResult.isErr()) {\n console.error(`[${pluginName}] Failed to load config:`, {\n code: configResult.error.code,\n message: configResult.error.message,\n filePath: configResult.error.filePath,\n cause: configResult.error.cause,\n });\n return null;\n }\n\n const config = configResult.value;\n const ensureBuilderService = cachedFn(() => createBuilderService({ config }));\n\n /**\n * Build artifact on every invocation (like tsc-plugin).\n * If artifact.useBuilder is false and artifact.path is provided, load from file instead.\n * This ensures the artifact is always up-to-date with the latest source files.\n */\n const getArtifact = (): BuilderArtifact | null => {\n const builderService = ensureBuilderService();\n const buildResult = builderService.build();\n if (buildResult.isErr()) {\n console.error(`[${pluginName}] Failed to build artifact: ${buildResult.error.message}`);\n return null;\n }\n return buildResult.value;\n };\n\n return {\n config,\n getArtifact,\n };\n};\n","/**\n * Utility for working with canonical IDs.\n */\n\nimport { resolve } from \"node:path\";\nimport { type CanonicalId, createCanonicalId } from \"@soda-gql/builder\";\n\n/**\n * Resolve a canonical ID from a filename and AST path.\n */\nexport const resolveCanonicalId = (filename: string, astPath: string): CanonicalId =>\n createCanonicalId(resolve(filename), astPath);\n"],"mappings":";;;;;;;;;AAoIA,MAAa,qBAAqB,UAA+B;AAG/D,QAAO,GAFY,IAAI,MAAM,KAAK,KAChB,WAAW,QAAQ,KAAK,MAAM,MAAM,KAAK,GAC1B,GAAG,MAAM;;;;;AAM5C,MAAa,iBAAiB,UAAyC;AACrE,QACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,MAAM,SAAS,iBACf,UAAU,SACV,aAAa;;;;;;AAQjB,MAAa,qBAAqB,OAAc,YAA4B;AAC1E,OAAM,IAAI,MAAM,mCAAmC,UAAU,OAAO,YAAY,GAAG,aAAa,KAAK,UAAU,MAAM,GAAG;;;;;;;;;AC/H1H,MAAa,uBAAuB,SAAwB,eAA6C;AAEvG,KAAI,EADY,QAAQ,WAAW,MAEjC,QAAO;CAGT,MAAM,eAAe,WAAW,QAAQ,WAAW;AACnD,KAAI,aAAa,OAAO,EAAE;AACxB,UAAQ,MAAM,IAAI,WAAW,2BAA2B;GACtD,MAAM,aAAa,MAAM;GACzB,SAAS,aAAa,MAAM;GAC5B,UAAU,aAAa,MAAM;GAC7B,OAAO,aAAa,MAAM;GAC3B,CAAC;AACF,SAAO;;CAGT,MAAM,SAAS,aAAa;CAC5B,MAAM,uBAAuB,eAAe,qBAAqB,EAAE,QAAQ,CAAC,CAAC;;;;;;CAO7E,MAAM,oBAA4C;EAEhD,MAAM,cADiB,sBAAsB,CACV,OAAO;AAC1C,MAAI,YAAY,OAAO,EAAE;AACvB,WAAQ,MAAM,IAAI,WAAW,8BAA8B,YAAY,MAAM,UAAU;AACvF,UAAO;;AAET,SAAO,YAAY;;AAGrB,QAAO;EACL;EACA;EACD;;;;;;;;AC1DH,MAAa,sBAAsB,UAAkB,YACnD,kBAAkB,QAAQ,SAAS,EAAE,QAAQ"}