@fanfare-io/fanfare-sdk-contracts 0.1.0
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/LICENSE +202 -0
- package/README.md +22 -0
- package/dist/auction.d.ts +25 -0
- package/dist/auction.js +20 -0
- package/dist/beacon-names.d.ts +25 -0
- package/dist/beacon-names.js +46 -0
- package/dist/beacon.d.ts +2468 -0
- package/dist/beacon.js +269 -0
- package/dist/challenges.d.ts +36 -0
- package/dist/challenges.js +37 -0
- package/dist/consumer-me.d.ts +28988 -0
- package/dist/consumer-me.js +320 -0
- package/dist/errors.d.ts +147 -0
- package/dist/errors.js +133 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +62 -0
- package/dist/routing.d.ts +1202 -0
- package/dist/routing.js +141 -0
- package/dist/theme.d.ts +25 -0
- package/dist/theme.js +43 -0
- package/package.json +107 -0
package/dist/routing.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import * as e from "valibot";
|
|
2
|
+
import { BotMitigationStateSchema as u, RoutingChallengeSchema as g, ChallengeProvider as d, ChallengePurpose as h, ChallengeType as m } from "./challenges.js";
|
|
3
|
+
import { ChallengeProviderSchema as M, ChallengeProviders as H, ChallengePurposeSchema as N, ChallengePurposes as x, ChallengeTypeSchema as Q, ChallengeTypes as W } from "./challenges.js";
|
|
4
|
+
const O = d, j = h, U = m, n = {
|
|
5
|
+
LOW: "LOW",
|
|
6
|
+
MEDIUM: "MEDIUM",
|
|
7
|
+
HIGH: "HIGH"
|
|
8
|
+
}, R = [n.LOW, n.MEDIUM, n.HIGH], C = e.picklist(R), a = e.object({
|
|
9
|
+
riskLevel: C,
|
|
10
|
+
requiresChallenge: e.boolean(),
|
|
11
|
+
blocked: e.boolean()
|
|
12
|
+
}), p = [
|
|
13
|
+
"NO_SEQUENCES",
|
|
14
|
+
"NO_ACCESS",
|
|
15
|
+
"AUTH_REQUIRED",
|
|
16
|
+
"ACCESS_CODE_REQUIRED",
|
|
17
|
+
"ACCESS_CODE_INVALID",
|
|
18
|
+
"AUDIENCE_NOT_MEMBER",
|
|
19
|
+
"BOT_REQUIRED",
|
|
20
|
+
"BOT_BLOCKED"
|
|
21
|
+
], c = e.picklist(p), G = c, t = e.object({
|
|
22
|
+
code: c,
|
|
23
|
+
detail: e.optional(e.string())
|
|
24
|
+
}), T = t, o = e.object({
|
|
25
|
+
id: e.string(),
|
|
26
|
+
name: e.string(),
|
|
27
|
+
experienceId: e.string(),
|
|
28
|
+
priority: e.number(),
|
|
29
|
+
color: e.nullable(e.string())
|
|
30
|
+
}), f = o, S = e.object({
|
|
31
|
+
type: e.literal("authentication"),
|
|
32
|
+
status: e.literal("required"),
|
|
33
|
+
reason: e.object({ code: e.literal("AUTH_REQUIRED"), detail: e.optional(e.string()) })
|
|
34
|
+
}), E = e.object({
|
|
35
|
+
type: e.literal("access_code"),
|
|
36
|
+
status: e.picklist(["missing", "invalid"]),
|
|
37
|
+
reason: e.object({
|
|
38
|
+
code: e.picklist(["ACCESS_CODE_REQUIRED", "ACCESS_CODE_INVALID"]),
|
|
39
|
+
detail: e.optional(e.string())
|
|
40
|
+
})
|
|
41
|
+
}), b = e.object({
|
|
42
|
+
type: e.literal("bot_check"),
|
|
43
|
+
status: e.picklist(["required", "blocked"]),
|
|
44
|
+
reason: e.object({
|
|
45
|
+
code: e.picklist(["BOT_REQUIRED", "BOT_BLOCKED"]),
|
|
46
|
+
detail: e.optional(e.string())
|
|
47
|
+
}),
|
|
48
|
+
challenge: e.optional(g),
|
|
49
|
+
mitigation: e.optional(u)
|
|
50
|
+
}), l = e.union([
|
|
51
|
+
S,
|
|
52
|
+
E,
|
|
53
|
+
b
|
|
54
|
+
]), v = l, s = {
|
|
55
|
+
gates: e.array(l),
|
|
56
|
+
reasons: e.array(t),
|
|
57
|
+
sequenceCapabilityGrant: e.optional(e.string()),
|
|
58
|
+
sequenceCapabilityGrantExpiresAt: e.optional(e.string())
|
|
59
|
+
}, r = e.object({
|
|
60
|
+
sequence: o,
|
|
61
|
+
status: e.literal("admissible"),
|
|
62
|
+
...s
|
|
63
|
+
}), i = e.object({
|
|
64
|
+
sequence: o,
|
|
65
|
+
status: e.literal("gated"),
|
|
66
|
+
...s
|
|
67
|
+
}), D = e.object({
|
|
68
|
+
sequence: o,
|
|
69
|
+
status: e.literal("denied"),
|
|
70
|
+
...s
|
|
71
|
+
}), V = e.union([
|
|
72
|
+
r,
|
|
73
|
+
i,
|
|
74
|
+
D
|
|
75
|
+
]), L = V, I = e.object({
|
|
76
|
+
schemaVersion: e.literal(1),
|
|
77
|
+
experienceId: e.string(),
|
|
78
|
+
outcome: e.literal("routed"),
|
|
79
|
+
selected: r,
|
|
80
|
+
offers: e.array(i),
|
|
81
|
+
outcomeReasons: e.array(t),
|
|
82
|
+
riskAssessment: e.optional(a)
|
|
83
|
+
}), _ = e.object({
|
|
84
|
+
schemaVersion: e.literal(1),
|
|
85
|
+
experienceId: e.string(),
|
|
86
|
+
outcome: e.literal("gated"),
|
|
87
|
+
selected: i,
|
|
88
|
+
offers: e.tuple([]),
|
|
89
|
+
outcomeReasons: e.array(t),
|
|
90
|
+
riskAssessment: e.optional(a)
|
|
91
|
+
}), A = e.object({
|
|
92
|
+
schemaVersion: e.literal(1),
|
|
93
|
+
experienceId: e.string(),
|
|
94
|
+
outcome: e.literal("no_access"),
|
|
95
|
+
offers: e.tuple([]),
|
|
96
|
+
outcomeReasons: e.array(t),
|
|
97
|
+
riskAssessment: e.optional(a)
|
|
98
|
+
}), k = e.union([
|
|
99
|
+
I,
|
|
100
|
+
_,
|
|
101
|
+
A
|
|
102
|
+
]), q = k;
|
|
103
|
+
export {
|
|
104
|
+
E as AccessCodeRoutingGateV1Schema,
|
|
105
|
+
r as AdmissibleRoutingCandidateV1Schema,
|
|
106
|
+
S as AuthenticationRoutingGateV1Schema,
|
|
107
|
+
b as BotCheckRoutingGateV1Schema,
|
|
108
|
+
u as BotMitigationStateSchema,
|
|
109
|
+
O as ChallengeProvider,
|
|
110
|
+
M as ChallengeProviderSchema,
|
|
111
|
+
H as ChallengeProviders,
|
|
112
|
+
j as ChallengePurpose,
|
|
113
|
+
N as ChallengePurposeSchema,
|
|
114
|
+
x as ChallengePurposes,
|
|
115
|
+
U as ChallengeType,
|
|
116
|
+
Q as ChallengeTypeSchema,
|
|
117
|
+
W as ChallengeTypes,
|
|
118
|
+
D as DeniedRoutingCandidateV1Schema,
|
|
119
|
+
_ as GatedDecisionV1Schema,
|
|
120
|
+
i as GatedRoutingCandidateV1Schema,
|
|
121
|
+
A as NoAccessDecisionV1Schema,
|
|
122
|
+
a as RiskAssessmentSchema,
|
|
123
|
+
n as RiskLevel,
|
|
124
|
+
C as RiskLevelSchema,
|
|
125
|
+
R as RiskLevels,
|
|
126
|
+
I as RoutedDecisionV1Schema,
|
|
127
|
+
L as RoutingCandidateSchema,
|
|
128
|
+
V as RoutingCandidateV1Schema,
|
|
129
|
+
g as RoutingChallengeSchema,
|
|
130
|
+
q as RoutingDecisionSchema,
|
|
131
|
+
k as RoutingDecisionV1Schema,
|
|
132
|
+
v as RoutingGateSchema,
|
|
133
|
+
l as RoutingGateV1Schema,
|
|
134
|
+
G as RoutingReasonCodeSchema,
|
|
135
|
+
c as RoutingReasonCodeV1Schema,
|
|
136
|
+
p as RoutingReasonCodesV1,
|
|
137
|
+
T as RoutingReasonSchema,
|
|
138
|
+
t as RoutingReasonV1Schema,
|
|
139
|
+
f as RoutingSequenceRefSchema,
|
|
140
|
+
o as RoutingSequenceRefV1Schema
|
|
141
|
+
};
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { InferOutput } from 'valibot';
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
export declare const WidgetVariants: readonly ["default", "retro", "rounded", "clean"];
|
|
4
|
+
export type WidgetVariant = (typeof WidgetVariants)[number];
|
|
5
|
+
export declare const WidgetVariantSchema: v.PicklistSchema<readonly ["default", "retro", "rounded", "clean"], undefined>;
|
|
6
|
+
export declare const BrandThemeSchema: v.ObjectSchema<{
|
|
7
|
+
readonly primary: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
8
|
+
readonly secondary: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
9
|
+
readonly background: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
10
|
+
readonly surface: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
11
|
+
readonly text: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
12
|
+
readonly muted: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
13
|
+
readonly success: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
14
|
+
readonly warning: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
15
|
+
readonly danger: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
16
|
+
readonly fontFamily: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
17
|
+
readonly fontHeading: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
18
|
+
readonly logoUrl: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.UrlAction<string, "validation.url">]>, undefined>;
|
|
19
|
+
readonly headerImageUrl: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.UrlAction<string, "validation.url">]>, undefined>;
|
|
20
|
+
readonly variant: v.OptionalSchema<v.PicklistSchema<readonly ["default", "retro", "rounded", "clean"], undefined>, undefined>;
|
|
21
|
+
}, undefined>;
|
|
22
|
+
export type BrandTheme = InferOutput<typeof BrandThemeSchema>;
|
|
23
|
+
export type ResolvedBrandTheme = Required<Omit<BrandTheme, "logoUrl" | "headerImageUrl">> & Pick<BrandTheme, "logoUrl" | "headerImageUrl">;
|
|
24
|
+
export declare const DefaultBrandTheme: Required<Omit<BrandTheme, "logoUrl" | "headerImageUrl">>;
|
|
25
|
+
export declare function mergeBrandTheme(theme: BrandTheme | null | undefined): ResolvedBrandTheme;
|
package/dist/theme.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as n from "valibot";
|
|
2
|
+
const a = ["default", "retro", "rounded", "clean"], r = n.picklist(a), o = n.object({
|
|
3
|
+
primary: n.optional(n.string()),
|
|
4
|
+
secondary: n.optional(n.string()),
|
|
5
|
+
background: n.optional(n.string()),
|
|
6
|
+
surface: n.optional(n.string()),
|
|
7
|
+
text: n.optional(n.string()),
|
|
8
|
+
muted: n.optional(n.string()),
|
|
9
|
+
success: n.optional(n.string()),
|
|
10
|
+
warning: n.optional(n.string()),
|
|
11
|
+
danger: n.optional(n.string()),
|
|
12
|
+
fontFamily: n.optional(n.string()),
|
|
13
|
+
fontHeading: n.optional(n.string()),
|
|
14
|
+
logoUrl: n.optional(n.pipe(n.string(), n.url("validation.url"))),
|
|
15
|
+
headerImageUrl: n.optional(n.pipe(n.string(), n.url("validation.url"))),
|
|
16
|
+
variant: n.optional(r)
|
|
17
|
+
}), i = {
|
|
18
|
+
primary: "#8C14FF",
|
|
19
|
+
secondary: "#F5F3FF",
|
|
20
|
+
background: "#FFFFFF",
|
|
21
|
+
surface: "transparent",
|
|
22
|
+
text: "#1D1F27",
|
|
23
|
+
muted: "#4B4E56CC",
|
|
24
|
+
success: "#22C55E",
|
|
25
|
+
warning: "#F59E0B",
|
|
26
|
+
danger: "#EF4444",
|
|
27
|
+
fontFamily: "Inter",
|
|
28
|
+
fontHeading: "Inter",
|
|
29
|
+
variant: "default"
|
|
30
|
+
};
|
|
31
|
+
function e(t) {
|
|
32
|
+
return {
|
|
33
|
+
...i,
|
|
34
|
+
...t ?? {}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
o as BrandThemeSchema,
|
|
39
|
+
i as DefaultBrandTheme,
|
|
40
|
+
r as WidgetVariantSchema,
|
|
41
|
+
a as WidgetVariants,
|
|
42
|
+
e as mergeBrandTheme
|
|
43
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fanfare-io/fanfare-sdk-contracts",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Public Fanfare schemas, types, and contract helpers shared by SDKs and internal services",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"registry": "https://registry.npmjs.org",
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/fanfare-io/fanfare-sdk.git"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://docs.fanfare.io/sdk/reference/types",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/fanfare-io/fanfare-sdk/issues"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"fanfare",
|
|
20
|
+
"schemas",
|
|
21
|
+
"types",
|
|
22
|
+
"validation",
|
|
23
|
+
"sdk",
|
|
24
|
+
"contracts"
|
|
25
|
+
],
|
|
26
|
+
"type": "module",
|
|
27
|
+
"sideEffects": false,
|
|
28
|
+
"files": [
|
|
29
|
+
"dist/"
|
|
30
|
+
],
|
|
31
|
+
"module": "./dist/index.js",
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"types": "./dist/index.d.ts",
|
|
36
|
+
"import": "./dist/index.js",
|
|
37
|
+
"default": "./dist/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./theme": {
|
|
40
|
+
"types": "./dist/theme.d.ts",
|
|
41
|
+
"import": "./dist/theme.js",
|
|
42
|
+
"default": "./dist/theme.js"
|
|
43
|
+
},
|
|
44
|
+
"./challenges": {
|
|
45
|
+
"types": "./dist/challenges.d.ts",
|
|
46
|
+
"import": "./dist/challenges.js",
|
|
47
|
+
"default": "./dist/challenges.js"
|
|
48
|
+
},
|
|
49
|
+
"./consumer-me": {
|
|
50
|
+
"types": "./dist/consumer-me.d.ts",
|
|
51
|
+
"import": "./dist/consumer-me.js",
|
|
52
|
+
"default": "./dist/consumer-me.js"
|
|
53
|
+
},
|
|
54
|
+
"./auction": {
|
|
55
|
+
"types": "./dist/auction.d.ts",
|
|
56
|
+
"import": "./dist/auction.js",
|
|
57
|
+
"default": "./dist/auction.js"
|
|
58
|
+
},
|
|
59
|
+
"./beacon": {
|
|
60
|
+
"types": "./dist/beacon.d.ts",
|
|
61
|
+
"import": "./dist/beacon.js",
|
|
62
|
+
"default": "./dist/beacon.js"
|
|
63
|
+
},
|
|
64
|
+
"./beacon/names": {
|
|
65
|
+
"types": "./dist/beacon-names.d.ts",
|
|
66
|
+
"import": "./dist/beacon-names.js",
|
|
67
|
+
"default": "./dist/beacon-names.js"
|
|
68
|
+
},
|
|
69
|
+
"./routing": {
|
|
70
|
+
"types": "./dist/routing.d.ts",
|
|
71
|
+
"import": "./dist/routing.js",
|
|
72
|
+
"default": "./dist/routing.js"
|
|
73
|
+
},
|
|
74
|
+
"./errors": {
|
|
75
|
+
"types": "./dist/errors.d.ts",
|
|
76
|
+
"import": "./dist/errors.js",
|
|
77
|
+
"default": "./dist/errors.js"
|
|
78
|
+
},
|
|
79
|
+
"./package.json": "./package.json"
|
|
80
|
+
},
|
|
81
|
+
"peerDependencies": {
|
|
82
|
+
"valibot": "^1.1.0"
|
|
83
|
+
},
|
|
84
|
+
"devDependencies": {
|
|
85
|
+
"prettier": "^3.5.3",
|
|
86
|
+
"prettier-plugin-organize-imports": "^4.1.0",
|
|
87
|
+
"rimraf": "^6.0.1",
|
|
88
|
+
"typescript": "^5.9.2",
|
|
89
|
+
"vite": "^7.3.1",
|
|
90
|
+
"vite-plugin-dts": "^4.5.4",
|
|
91
|
+
"vite-tsconfig-paths": "^5.1.4",
|
|
92
|
+
"vitest": "^3.2.4"
|
|
93
|
+
},
|
|
94
|
+
"scripts": {
|
|
95
|
+
"build": "vite build",
|
|
96
|
+
"build:strict": "pnpm typecheck && pnpm build",
|
|
97
|
+
"build:incremental": "vite build",
|
|
98
|
+
"typecheck": "tsc --noEmit",
|
|
99
|
+
"test": "vitest run",
|
|
100
|
+
"test:watch": "vitest",
|
|
101
|
+
"test:unit": "vitest run .unit.test.ts --passWithNoTests",
|
|
102
|
+
"fmt": "prettier src --write",
|
|
103
|
+
"lint": "oxlint src",
|
|
104
|
+
"lint:fix": "oxlint --fix src",
|
|
105
|
+
"prebuild": "rimraf dist"
|
|
106
|
+
}
|
|
107
|
+
}
|