Skip to content

Commit 55508d7

Browse files
refactor(core): move legacy success callback schemas to credential.ts for better modularity
1 parent 936d1f5 commit 55508d7

2 files changed

Lines changed: 19 additions & 18 deletions

File tree

packages/core/src/credential.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,24 @@ export const Info = Schema.Union([OAuth, Key])
3434
.annotate({ identifier: "Credential.Info" })
3535
export type Info = Schema.Schema.Type<typeof Info>
3636

37+
export const LegacySuccessOAuth = Schema.Struct({
38+
type: Schema.Literal("success"),
39+
access: Schema.String,
40+
refresh: Schema.optional(Schema.String),
41+
expires: Schema.optional(Schema.Number),
42+
accountId: Schema.optional(Schema.String),
43+
enterpriseUrl: Schema.optional(Schema.String),
44+
metadata: Schema.optional(Schema.Record(Schema.String, Schema.String)),
45+
})
46+
47+
export const LegacySuccessKey = Schema.Struct({
48+
type: Schema.Literal("success"),
49+
key: Schema.String,
50+
metadata: Schema.optional(Schema.Record(Schema.String, Schema.String)),
51+
})
52+
53+
export const LegacySuccessValue = Schema.Union([LegacySuccessOAuth, LegacySuccessKey])
54+
3755
export class Stored extends Schema.Class<Stored>("Credential.Stored")({
3856
id: ID,
3957
integrationID: IntegrationSchema.ID,

packages/core/src/integration.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -362,24 +362,7 @@ export const locationLayer = Layer.effect(
362362
return error instanceof Error ? error.message : String(error)
363363
}
364364

365-
const LegacySuccessOAuth = Schema.Struct({
366-
type: Schema.Literal("success"),
367-
access: Schema.String,
368-
refresh: Schema.optional(Schema.String),
369-
expires: Schema.optional(Schema.Number),
370-
accountId: Schema.optional(Schema.String),
371-
enterpriseUrl: Schema.optional(Schema.String),
372-
metadata: Schema.optional(Schema.Record(Schema.String, Schema.String)),
373-
})
374-
375-
const LegacySuccessKey = Schema.Struct({
376-
type: Schema.Literal("success"),
377-
key: Schema.String,
378-
metadata: Schema.optional(Schema.Record(Schema.String, Schema.String)),
379-
})
380-
381-
const LegacySuccessValue = Schema.Union([LegacySuccessOAuth, LegacySuccessKey])
382-
const decodeLegacySuccess = Schema.decodeUnknownOption(LegacySuccessValue)
365+
const decodeLegacySuccess = Schema.decodeUnknownOption(Credential.LegacySuccessValue)
383366

384367
const settle = Effect.fnUntraced(function* (attemptID: AttemptID, exit: Exit.Exit<Credential.Info, unknown>) {
385368
const now = yield* Clock.currentTimeMillis

0 commit comments

Comments
 (0)