Skip to content

Commit 043df54

Browse files
committed
Rename the manifest's extendServerConfig to setupFn, following the prismaSetupFn convention
1 parent 7c6c91a commit 043df54

5 files changed

Lines changed: 16 additions & 16 deletions

File tree

waspc/data/packages/spec/__tests__/spec/mapApp.unit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ describe("mapAuth", () => {
500500
userSignupFields: mapRefObjectForMockProjectDir(
501501
provider.userSignupFields,
502502
),
503-
extendServerConfig: undefined,
503+
setupFn: undefined,
504504
optionsJson: JSON.stringify(provider.options),
505505
},
506506
} satisfies AppSpec.Auth);

waspc/data/packages/spec/src/appSpec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export type ExternalAuthProviderSpec = {
184184
capabilities: string[];
185185
envVars: ExternalProviderEnvVars;
186186
userSignupFields: Optional<ExtImport>;
187-
extendServerConfig: Optional<ExtImport>;
187+
setupFn: Optional<ExtImport>;
188188
optionsJson: Optional<string>;
189189
};
190190

waspc/data/packages/spec/src/spec/mapper/app.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,7 @@ function mapExternalAuthProvider(
155155
userSignupFields:
156156
manifest.userSignupFields &&
157157
ctx.parseRefObject(manifest.userSignupFields),
158-
extendServerConfig:
159-
manifest.extendServerConfig &&
160-
ctx.parseRefObject(manifest.extendServerConfig),
158+
setupFn: manifest.setupFn && ctx.parseRefObject(manifest.setupFn),
161159
optionsJson: mapProviderOptions(manifest),
162160
};
163161
}
@@ -178,15 +176,15 @@ function mapProviderOptions(
178176
// Options travel to the generated code as JSON, so anything that doesn't
179177
// survive the round-trip (functions, class instances, undefined-holed
180178
// arrays) would arrive silently mangled. Rejecting here turns that into an
181-
// error at compile time, with `extendServerConfig` as the documented escape
179+
// error at compile time, with `setupFn` as the documented escape
182180
// hatch for non-serializable configuration.
183181
const optionsJson = JSON.stringify(manifest.options);
184182
if (
185183
optionsJson === undefined ||
186184
!isEqual(JSON.parse(optionsJson), manifest.options)
187185
) {
188186
throw new WaspSpecUserError(
189-
`Auth provider '${manifest.id}' has options that do not survive JSON serialization. Provider options must be plain serializable data; use extendServerConfig for functions and other live values.`,
187+
`Auth provider '${manifest.id}' has options that do not survive JSON serialization. Provider options must be plain serializable data; use setupFn for functions and other live values.`,
190188
);
191189
}
192190

waspc/data/packages/spec/src/spec/publicApi/waspSpec.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,13 @@ export interface ExternalAuthProviderManifest {
330330
*/
331331
userSignupFields?: Reference<AnyObject>;
332332
/**
333-
* Escape hatch for non-serializable adapter configuration (functions, class
334-
* instances -- e.g. Better Auth's email-sending callbacks). References a
335-
* user-code module; the adapter's server factory applies it after its own
336-
* defaults.
333+
* Setup function for the provider's underlying library, following the same
334+
* convention as `db.prismaSetupFn`: a reference to a user-code function the
335+
* adapter calls with its integration config, whose return value becomes the
336+
* configuration to use. This is how an app reaches everything serializable
337+
* options cannot carry -- hooks, plugins, email-sending callbacks.
337338
*/
338-
extendServerConfig?: Reference<AnyFunction>;
339+
setupFn?: Reference<AnyFunction>;
339340
/**
340341
* Serializable adapter options, passed verbatim to the adapter's server and
341342
* client factories. Must survive a JSON round-trip; the compiler checks.

waspc/src/Wasp/AppSpec/App/Auth.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,11 @@ data ExternalAuthProviderSpec = ExternalAuthProviderSpec
149149
-- | Populates the user entity when Wasp provisions a local user for a
150150
-- subject it has not seen before.
151151
userSignupFields :: Maybe ExtImport,
152-
-- | Escape hatch for non-serializable adapter configuration (functions,
153-
-- class instances). Applied by the adapter's server factory after its own
154-
-- defaults.
155-
extendServerConfig :: Maybe ExtImport,
152+
-- | Setup function for the provider's underlying library (the
153+
-- @prismaSetupFn@ convention): the adapter calls it with its integration
154+
-- config and uses the returned configuration. The escape hatch for
155+
-- everything serializable options cannot carry.
156+
setupFn :: Maybe ExtImport,
156157
-- | The adapter's serializable options, JSON-encoded. Kept as a string so
157158
-- the generator can splice it into generated code verbatim.
158159
optionsJson :: Maybe String

0 commit comments

Comments
 (0)