@lucern/sdk 0.3.0-alpha.17 → 0.3.0-alpha.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/CHANGELOG.md +0 -12
- package/README.md +4 -110
- package/dist/adminClient.d.ts +8 -10
- package/dist/adminClient.js +39 -260
- package/dist/adminClient.js.map +1 -1
- package/dist/answersClient.d.ts +0 -2
- package/dist/answersClient.js +11 -239
- package/dist/answersClient.js.map +1 -1
- package/dist/audience/index.d.ts +1 -2
- package/dist/audience/index.js +3 -1
- package/dist/audience/index.js.map +1 -1
- package/dist/audiencesClient.d.ts +16 -18
- package/dist/audiencesClient.js +90 -315
- package/dist/audiencesClient.js.map +1 -1
- package/dist/auditClient.d.ts +0 -2
- package/dist/auditClient.js +15 -245
- package/dist/auditClient.js.map +1 -1
- package/dist/beliefs/index.d.ts +5 -27
- package/dist/beliefs/index.js +1177 -3842
- package/dist/beliefs/index.js.map +1 -1
- package/dist/beliefsClient.d.ts +2 -4
- package/dist/beliefsClient.js +26 -248
- package/dist/beliefsClient.js.map +1 -1
- package/dist/client-B6aWUUwp.d.ts +2552 -0
- package/dist/client.d.ts +27 -3041
- package/dist/client.js +1177 -3842
- package/dist/client.js.map +1 -1
- package/dist/contextClient.d.ts +3 -6
- package/dist/contextClient.js +30 -270
- package/dist/contextClient.js.map +1 -1
- package/dist/contextFacade.js +16 -25
- package/dist/contextFacade.js.map +1 -1
- package/dist/contextPackCompiler.js +30 -19
- package/dist/contextPackCompiler.js.map +1 -1
- package/dist/contextPackPolicy.js +17 -7
- package/dist/contextPackPolicy.js.map +1 -1
- package/dist/contextTypes.d.ts +0 -2
- package/dist/contracts/api-enums.contract.d.ts +2 -2
- package/dist/contracts/api-enums.contract.js +1 -6
- package/dist/contracts/api-enums.contract.js.map +1 -1
- package/dist/contracts/auth-session.contract.d.ts +1 -1
- package/dist/contracts/auth-session.contract.js +2 -14
- package/dist/contracts/auth-session.contract.js.map +1 -1
- package/dist/contracts/index.d.ts +0 -1
- package/dist/contracts/index.js +7 -134
- package/dist/contracts/index.js.map +1 -1
- package/dist/contracts/lens-filter.contract.js +3 -4
- package/dist/contracts/lens-filter.contract.js.map +1 -1
- package/dist/contracts/lens-workflow.contract.js +3 -4
- package/dist/contracts/lens-workflow.contract.js.map +1 -1
- package/dist/contracts/lensFilter.js +3 -4
- package/dist/contracts/lensFilter.js.map +1 -1
- package/dist/contracts/lensWorkflow.js +3 -4
- package/dist/contracts/lensWorkflow.js.map +1 -1
- package/dist/contracts/mcpTools.d.ts +1 -46
- package/dist/contracts/mcpTools.js +0 -108
- package/dist/contracts/mcpTools.js.map +1 -1
- package/dist/contradictions/index.d.ts +4 -26
- package/dist/contradictions/index.js +1177 -3842
- package/dist/contradictions/index.js.map +1 -1
- package/dist/coreClient.d.ts +2 -28
- package/dist/coreClient.js +14 -240
- package/dist/coreClient.js.map +1 -1
- package/dist/decisions/index.d.ts +14 -36
- package/dist/decisions/index.js +1177 -3842
- package/dist/decisions/index.js.map +1 -1
- package/dist/decisionsClient.d.ts +12 -6
- package/dist/decisionsClient.js +37 -253
- package/dist/decisionsClient.js.map +1 -1
- package/dist/edges/index.d.ts +87 -49
- package/dist/edges/index.js +1177 -3842
- package/dist/edges/index.js.map +1 -1
- package/dist/events.js +3 -6
- package/dist/events.js.map +1 -1
- package/dist/eventsCore.d.ts +1 -3
- package/dist/eventsCore.js +14 -240
- package/dist/eventsCore.js.map +1 -1
- package/dist/evidence/index.d.ts +4 -26
- package/dist/evidence/index.js +1177 -3842
- package/dist/evidence/index.js.map +1 -1
- package/dist/evidenceClient.d.ts +0 -2
- package/dist/evidenceClient.js +14 -240
- package/dist/evidenceClient.js.map +1 -1
- package/dist/facade/context.d.ts +1 -2
- package/dist/facade/context.js +16 -25
- package/dist/facade/context.js.map +1 -1
- package/dist/gatewayFacades.d.ts +46 -90
- package/dist/gatewayFacades.js +128 -609
- package/dist/gatewayFacades.js.map +1 -1
- package/dist/graphClient.d.ts +13 -8
- package/dist/graphClient.js +45 -262
- package/dist/graphClient.js.map +1 -1
- package/dist/harnessClient.d.ts +24 -15
- package/dist/harnessClient.js +42 -253
- package/dist/harnessClient.js.map +1 -1
- package/dist/identityClient.d.ts +11 -115
- package/dist/identityClient.js +33 -555
- package/dist/identityClient.js.map +1 -1
- package/dist/index.d.ts +6 -32
- package/dist/index.js +2581 -5826
- package/dist/index.js.map +1 -1
- package/dist/learningClient.d.ts +6 -8
- package/dist/learningClient.js +44 -270
- package/dist/learningClient.js.map +1 -1
- package/dist/lenses/index.d.ts +38 -78
- package/dist/lenses/index.js +1177 -3842
- package/dist/lenses/index.js.map +1 -1
- package/dist/nodes/index.d.ts +21 -65
- package/dist/nodes/index.js +1177 -3842
- package/dist/nodes/index.js.map +1 -1
- package/dist/ontologies/index.d.ts +32 -55
- package/dist/ontologies/index.js +1177 -3842
- package/dist/ontologies/index.js.map +1 -1
- package/dist/ontologyClient.d.ts +25 -19
- package/dist/ontologyClient.js +40 -276
- package/dist/ontologyClient.js.map +1 -1
- package/dist/packsClient.d.ts +23 -11
- package/dist/packsClient.js +46 -252
- package/dist/packsClient.js.map +1 -1
- package/dist/policyClient.d.ts +10 -13
- package/dist/policyClient.js +25 -261
- package/dist/policyClient.js.map +1 -1
- package/dist/questions/index.d.ts +4 -26
- package/dist/questions/index.js +1177 -3842
- package/dist/questions/index.js.map +1 -1
- package/dist/realtime/index.d.ts +1 -1
- package/dist/reportsClient.d.ts +7 -9
- package/dist/reportsClient.js +53 -299
- package/dist/reportsClient.js.map +1 -1
- package/dist/schemaClient.d.ts +3 -5
- package/dist/schemaClient.js +29 -253
- package/dist/schemaClient.js.map +1 -1
- package/dist/sdkSurface.d.ts +3 -8
- package/dist/sdkSurface.js +6 -10
- package/dist/sdkSurface.js.map +1 -1
- package/dist/sourcesClient.d.ts +0 -2
- package/dist/sourcesClient.js +14 -240
- package/dist/sourcesClient.js.map +1 -1
- package/dist/topics/index.d.ts +9 -37
- package/dist/topics/index.js +1177 -3844
- package/dist/topics/index.js.map +1 -1
- package/dist/topicsClient.d.ts +0 -4
- package/dist/topicsClient.js +24 -255
- package/dist/topicsClient.js.map +1 -1
- package/dist/types.d.ts +0 -17
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/dist/workflowClient.d.ts +40 -60
- package/dist/workflowClient.js +58 -261
- package/dist/workflowClient.js.map +1 -1
- package/dist/worktrees/index.d.ts +33 -71
- package/dist/worktrees/index.js +1177 -3842
- package/dist/worktrees/index.js.map +1 -1
- package/package.json +3 -17
- package/dist/accessControl.d.ts +0 -79
- package/dist/accessControl.js +0 -1270
- package/dist/accessControl.js.map +0 -1
- package/dist/authContext.d.ts +0 -56
- package/dist/authContext.js +0 -170
- package/dist/authContext.js.map +0 -1
- package/dist/authDeviceClient.d.ts +0 -49
- package/dist/authDeviceClient.js +0 -121
- package/dist/authDeviceClient.js.map +0 -1
- package/dist/boundaryClientSurface.d.ts +0 -20
- package/dist/boundaryClientSurface.js +0 -73
- package/dist/boundaryClientSurface.js.map +0 -1
- package/dist/clientHelpers.d.ts +0 -48
- package/dist/clientHelpers.js +0 -137
- package/dist/clientHelpers.js.map +0 -1
- package/dist/control-plane.d.ts +0 -69
- package/dist/control-plane.js +0 -674
- package/dist/control-plane.js.map +0 -1
- package/dist/embeddingsClient.d.ts +0 -106
- package/dist/embeddingsClient.js +0 -749
- package/dist/embeddingsClient.js.map +0 -1
- package/dist/eventingClient.d.ts +0 -96
- package/dist/eventingClient.js +0 -746
- package/dist/eventingClient.js.map +0 -1
- package/dist/functionSurface.d.ts +0 -144
- package/dist/functionSurface.js +0 -1227
- package/dist/functionSurface.js.map +0 -1
- package/dist/functionSurfaceClient.d.ts +0 -8
- package/dist/functionSurfaceClient.js +0 -1227
- package/dist/functionSurfaceClient.js.map +0 -1
- package/dist/graphAnalysisClient.d.ts +0 -192
- package/dist/graphAnalysisClient.js +0 -817
- package/dist/graphAnalysisClient.js.map +0 -1
- package/dist/graphIntel.d.ts +0 -4
- package/dist/graphIntel.js +0 -3
- package/dist/graphIntel.js.map +0 -1
- package/dist/graphIntelligence.d.ts +0 -2
- package/dist/graphIntelligence.js +0 -47
- package/dist/graphIntelligence.js.map +0 -1
- package/dist/graphRecommendationsClient.d.ts +0 -56
- package/dist/graphRecommendationsClient.js +0 -682
- package/dist/graphRecommendationsClient.js.map +0 -1
- package/dist/graphStateClassifierClient.d.ts +0 -73
- package/dist/graphStateClassifierClient.js +0 -734
- package/dist/graphStateClassifierClient.js.map +0 -1
- package/dist/infisicalRuntime.d.ts +0 -43
- package/dist/infisicalRuntime.js +0 -346
- package/dist/infisicalRuntime.js.map +0 -1
- package/dist/jobsClient.d.ts +0 -98
- package/dist/jobsClient.js +0 -744
- package/dist/jobsClient.js.map +0 -1
- package/dist/mcpClient.d.ts +0 -28
- package/dist/mcpClient.js +0 -687
- package/dist/mcpClient.js.map +0 -1
- package/dist/modelRuntimeClient.d.ts +0 -72
- package/dist/modelRuntimeClient.js +0 -722
- package/dist/modelRuntimeClient.js.map +0 -1
- package/dist/ontologyLinksClient.d.ts +0 -71
- package/dist/ontologyLinksClient.js +0 -715
- package/dist/ontologyLinksClient.js.map +0 -1
- package/dist/orgGraphSearchClient.d.ts +0 -85
- package/dist/orgGraphSearchClient.js +0 -690
- package/dist/orgGraphSearchClient.js.map +0 -1
- package/dist/secrets.d.ts +0 -1
- package/dist/secrets.js +0 -3
- package/dist/secrets.js.map +0 -1
- package/dist/telemetryClient.d.ts +0 -94
- package/dist/telemetryClient.js +0 -759
- package/dist/telemetryClient.js.map +0 -1
- package/dist/toolRegistryClient.d.ts +0 -115
- package/dist/toolRegistryClient.js +0 -785
- package/dist/toolRegistryClient.js.map +0 -1
package/dist/eventingClient.js
DELETED
|
@@ -1,746 +0,0 @@
|
|
|
1
|
-
// src/authContext.ts
|
|
2
|
-
var LucernSdkAuthContextError = class extends Error {
|
|
3
|
-
reason;
|
|
4
|
-
constructor(reason, message) {
|
|
5
|
-
super(message);
|
|
6
|
-
this.name = "LucernSdkAuthContextError";
|
|
7
|
-
this.reason = reason;
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
function cleanString(value) {
|
|
11
|
-
const normalized = value?.trim();
|
|
12
|
-
return normalized ? normalized : void 0;
|
|
13
|
-
}
|
|
14
|
-
function cleanStringList(values) {
|
|
15
|
-
if (!values) {
|
|
16
|
-
return [];
|
|
17
|
-
}
|
|
18
|
-
return values.map((value) => value.trim()).filter(
|
|
19
|
-
(value, index, list) => value.length > 0 && list.indexOf(value) === index
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
function requireString(value, reason, label) {
|
|
23
|
-
const normalized = cleanString(value);
|
|
24
|
-
if (!normalized) {
|
|
25
|
-
throw new LucernSdkAuthContextError(
|
|
26
|
-
reason,
|
|
27
|
-
`Canonical Lucern SDK auth context is missing ${label}.`
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
return normalized;
|
|
31
|
-
}
|
|
32
|
-
function requirePrincipalType(principalType) {
|
|
33
|
-
if (!principalType) {
|
|
34
|
-
throw new LucernSdkAuthContextError(
|
|
35
|
-
"principal_missing",
|
|
36
|
-
"Canonical Lucern SDK auth context is missing principalType."
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
return principalType;
|
|
40
|
-
}
|
|
41
|
-
function requireAuthMode(authMode) {
|
|
42
|
-
if (!authMode) {
|
|
43
|
-
throw new LucernSdkAuthContextError(
|
|
44
|
-
"principal_missing",
|
|
45
|
-
"Canonical Lucern SDK auth context is missing authMode."
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
return authMode;
|
|
49
|
-
}
|
|
50
|
-
function ensurePermitMatch(args) {
|
|
51
|
-
const actual = cleanString(args.actual);
|
|
52
|
-
if (actual && actual !== args.expected) {
|
|
53
|
-
throw new LucernSdkAuthContextError(
|
|
54
|
-
"policy_denied",
|
|
55
|
-
`Canonical Lucern SDK auth context has conflicting Permit ${args.field}.`
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
function normalizeCanonicalLucernAuthContext(input) {
|
|
60
|
-
if (!input) {
|
|
61
|
-
throw new LucernSdkAuthContextError(
|
|
62
|
-
"principal_missing",
|
|
63
|
-
"Canonical Lucern SDK auth context is required."
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
if (input.policyDecision === "deny") {
|
|
67
|
-
throw new LucernSdkAuthContextError(
|
|
68
|
-
"policy_denied",
|
|
69
|
-
"Canonical Lucern SDK auth context carries a denied policy decision."
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
const principalId = requireString(
|
|
73
|
-
input.principalId,
|
|
74
|
-
"principal_missing",
|
|
75
|
-
"principalId"
|
|
76
|
-
);
|
|
77
|
-
const tenantId = requireString(input.tenantId, "tenant_missing", "tenantId");
|
|
78
|
-
const workspaceId = requireString(
|
|
79
|
-
input.workspaceId,
|
|
80
|
-
"workspace_missing",
|
|
81
|
-
"workspaceId"
|
|
82
|
-
);
|
|
83
|
-
const roles = cleanStringList(input.roles);
|
|
84
|
-
const scopes = cleanStringList(input.scopes);
|
|
85
|
-
const principalType = requirePrincipalType(input.principalType);
|
|
86
|
-
const authMode = requireAuthMode(input.authMode);
|
|
87
|
-
const roleBasedInteractiveAuth = authMode === "interactive_user" && roles.length > 0;
|
|
88
|
-
if (roles.length === 0 || scopes.length === 0 && !roleBasedInteractiveAuth) {
|
|
89
|
-
throw new LucernSdkAuthContextError(
|
|
90
|
-
"membership_missing",
|
|
91
|
-
"Canonical Lucern SDK auth context requires non-empty roles and scopes."
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
const subject = cleanString(input.permit?.subject) ?? principalId;
|
|
95
|
-
const tenant = cleanString(input.permit?.tenant) ?? tenantId;
|
|
96
|
-
const workspace = cleanString(input.permit?.workspace) ?? workspaceId;
|
|
97
|
-
ensurePermitMatch({
|
|
98
|
-
field: "subject",
|
|
99
|
-
expected: principalId,
|
|
100
|
-
actual: subject
|
|
101
|
-
});
|
|
102
|
-
ensurePermitMatch({ field: "tenant", expected: tenantId, actual: tenant });
|
|
103
|
-
ensurePermitMatch({
|
|
104
|
-
field: "workspace",
|
|
105
|
-
expected: workspaceId,
|
|
106
|
-
actual: workspace
|
|
107
|
-
});
|
|
108
|
-
const context = input.permit?.context ? { ...input.permit.context } : void 0;
|
|
109
|
-
return {
|
|
110
|
-
clerkId: cleanString(input.clerkId),
|
|
111
|
-
principalId,
|
|
112
|
-
tenantId,
|
|
113
|
-
workspaceId,
|
|
114
|
-
principalType,
|
|
115
|
-
authMode,
|
|
116
|
-
roles,
|
|
117
|
-
scopes,
|
|
118
|
-
delegationChain: input.delegationChain ? [...input.delegationChain] : [],
|
|
119
|
-
policyTraceId: cleanString(input.policyTraceId),
|
|
120
|
-
correlationId: cleanString(input.correlationId),
|
|
121
|
-
membershipId: cleanString(input.membershipId),
|
|
122
|
-
permit: {
|
|
123
|
-
subject,
|
|
124
|
-
tenant,
|
|
125
|
-
workspace,
|
|
126
|
-
resource: cleanString(input.permit?.resource),
|
|
127
|
-
action: cleanString(input.permit?.action),
|
|
128
|
-
relation: cleanString(input.permit?.relation),
|
|
129
|
-
context
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
function createCanonicalAuthHeaders(authContext) {
|
|
134
|
-
const headers = {
|
|
135
|
-
"x-lucern-principal-id": authContext.principalId,
|
|
136
|
-
"x-lucern-principal-type": authContext.principalType,
|
|
137
|
-
"x-lucern-tenant": authContext.tenantId,
|
|
138
|
-
"x-lucern-tenant-id": authContext.tenantId,
|
|
139
|
-
"x-lucern-workspace": authContext.workspaceId,
|
|
140
|
-
"x-lucern-workspace-id": authContext.workspaceId,
|
|
141
|
-
"x-lucern-auth-mode": authContext.authMode,
|
|
142
|
-
"x-lucern-roles": authContext.roles.join(","),
|
|
143
|
-
"x-lucern-scopes": authContext.scopes.join(","),
|
|
144
|
-
"x-lucern-permit-context": JSON.stringify(authContext.permit)
|
|
145
|
-
};
|
|
146
|
-
if (authContext.clerkId) {
|
|
147
|
-
headers["x-lucern-clerk-id"] = authContext.clerkId;
|
|
148
|
-
headers["x-lucern-user-id"] = authContext.clerkId;
|
|
149
|
-
}
|
|
150
|
-
if (authContext.delegationChain.length > 0) {
|
|
151
|
-
headers["x-lucern-delegation-chain"] = JSON.stringify(
|
|
152
|
-
authContext.delegationChain
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
if (authContext.policyTraceId) {
|
|
156
|
-
headers["x-lucern-policy-trace-id"] = authContext.policyTraceId;
|
|
157
|
-
}
|
|
158
|
-
if (authContext.correlationId) {
|
|
159
|
-
headers["x-correlation-id"] = authContext.correlationId;
|
|
160
|
-
headers["x-lucern-correlation-id"] = authContext.correlationId;
|
|
161
|
-
}
|
|
162
|
-
if (authContext.membershipId) {
|
|
163
|
-
headers["x-lucern-membership-id"] = authContext.membershipId;
|
|
164
|
-
}
|
|
165
|
-
return headers;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// src/coreClient.ts
|
|
169
|
-
var LucernApiError = class extends Error {
|
|
170
|
-
code;
|
|
171
|
-
status;
|
|
172
|
-
invariant;
|
|
173
|
-
suggestion;
|
|
174
|
-
details;
|
|
175
|
-
requestId;
|
|
176
|
-
correlationId;
|
|
177
|
-
policyTraceId;
|
|
178
|
-
constructor(args) {
|
|
179
|
-
super(args.message);
|
|
180
|
-
this.name = "LucernApiError";
|
|
181
|
-
this.code = args.code;
|
|
182
|
-
this.status = args.status;
|
|
183
|
-
this.invariant = args.invariant;
|
|
184
|
-
this.suggestion = args.suggestion;
|
|
185
|
-
this.details = args.details;
|
|
186
|
-
this.requestId = args.requestId;
|
|
187
|
-
this.correlationId = args.correlationId;
|
|
188
|
-
this.policyTraceId = args.policyTraceId;
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
function toQueryString(scope) {
|
|
192
|
-
const params = new URLSearchParams();
|
|
193
|
-
if (scope.tenantId) {
|
|
194
|
-
params.set("tenantId", scope.tenantId);
|
|
195
|
-
}
|
|
196
|
-
if (scope.workspaceId) {
|
|
197
|
-
params.set("workspaceId", scope.workspaceId);
|
|
198
|
-
}
|
|
199
|
-
for (const [key, value] of Object.entries(scope)) {
|
|
200
|
-
if (key === "tenantId" || key === "workspaceId") {
|
|
201
|
-
continue;
|
|
202
|
-
}
|
|
203
|
-
if (value === void 0) {
|
|
204
|
-
continue;
|
|
205
|
-
}
|
|
206
|
-
params.set(key, String(value));
|
|
207
|
-
}
|
|
208
|
-
const serialized = params.toString();
|
|
209
|
-
return serialized.length > 0 ? `?${serialized}` : "";
|
|
210
|
-
}
|
|
211
|
-
function fillRandomBytes(length) {
|
|
212
|
-
const bytes = new Uint8Array(length);
|
|
213
|
-
if (typeof globalThis.crypto?.getRandomValues === "function") {
|
|
214
|
-
globalThis.crypto.getRandomValues(bytes);
|
|
215
|
-
return bytes;
|
|
216
|
-
}
|
|
217
|
-
for (let index = 0; index < length; index += 1) {
|
|
218
|
-
bytes[index] = Math.floor(Math.random() * 256);
|
|
219
|
-
}
|
|
220
|
-
return bytes;
|
|
221
|
-
}
|
|
222
|
-
function generatePortableRequestId() {
|
|
223
|
-
if (typeof globalThis.crypto?.randomUUID === "function") {
|
|
224
|
-
return globalThis.crypto.randomUUID();
|
|
225
|
-
}
|
|
226
|
-
const bytes = fillRandomBytes(16);
|
|
227
|
-
bytes[6] = bytes[6] & 15 | 64;
|
|
228
|
-
bytes[8] = bytes[8] & 63 | 128;
|
|
229
|
-
const hex = Array.from(bytes, (value) => value.toString(16).padStart(2, "0"));
|
|
230
|
-
return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(
|
|
231
|
-
6,
|
|
232
|
-
8
|
|
233
|
-
).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
|
|
234
|
-
}
|
|
235
|
-
var randomIdempotencyKey = generatePortableRequestId;
|
|
236
|
-
function isRetryableStatus(status) {
|
|
237
|
-
return status >= 500 || status === 408 || status === 429;
|
|
238
|
-
}
|
|
239
|
-
function fallbackErrorCode(status) {
|
|
240
|
-
if (status === 401) {
|
|
241
|
-
return "AUTHENTICATION_REQUIRED";
|
|
242
|
-
}
|
|
243
|
-
if (status === 403) {
|
|
244
|
-
return "FORBIDDEN";
|
|
245
|
-
}
|
|
246
|
-
if (status === 404) {
|
|
247
|
-
return "NOT_FOUND";
|
|
248
|
-
}
|
|
249
|
-
if (status === 408) {
|
|
250
|
-
return "UPSTREAM_ERROR";
|
|
251
|
-
}
|
|
252
|
-
if (status === 409) {
|
|
253
|
-
return "CONFLICT";
|
|
254
|
-
}
|
|
255
|
-
if (status === 429) {
|
|
256
|
-
return "RATE_LIMIT_EXCEEDED";
|
|
257
|
-
}
|
|
258
|
-
if (status >= 500) {
|
|
259
|
-
return "UPSTREAM_ERROR";
|
|
260
|
-
}
|
|
261
|
-
return "INTERNAL_ERROR";
|
|
262
|
-
}
|
|
263
|
-
function delay(ms) {
|
|
264
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
265
|
-
}
|
|
266
|
-
function parseRetryAfterMs(value) {
|
|
267
|
-
if (!value) {
|
|
268
|
-
return null;
|
|
269
|
-
}
|
|
270
|
-
const trimmed = value.trim();
|
|
271
|
-
if (!trimmed) {
|
|
272
|
-
return null;
|
|
273
|
-
}
|
|
274
|
-
const numeric = Number(trimmed);
|
|
275
|
-
if (Number.isFinite(numeric)) {
|
|
276
|
-
return Math.max(0, Math.round(numeric * 1e3));
|
|
277
|
-
}
|
|
278
|
-
const parsedDate = Date.parse(trimmed);
|
|
279
|
-
if (Number.isFinite(parsedDate)) {
|
|
280
|
-
return Math.max(0, parsedDate - Date.now());
|
|
281
|
-
}
|
|
282
|
-
return null;
|
|
283
|
-
}
|
|
284
|
-
function computeRetryDelayMs(args) {
|
|
285
|
-
const baseDelay = args.status === 429 ? Math.max(
|
|
286
|
-
args.retryAfterMs ?? 0,
|
|
287
|
-
Math.min(1e3 * 2 ** args.attempt, 1e4)
|
|
288
|
-
) : Math.min(1e3 * 2 ** args.attempt, 4e3);
|
|
289
|
-
if (args.status !== 429) {
|
|
290
|
-
return baseDelay;
|
|
291
|
-
}
|
|
292
|
-
const jitterWindow = Math.max(250, Math.round(baseDelay * 0.25));
|
|
293
|
-
return baseDelay + Math.round(Math.random() * jitterWindow);
|
|
294
|
-
}
|
|
295
|
-
function timeoutError(timeoutMs) {
|
|
296
|
-
const error = new Error(`Request timed out after ${timeoutMs}ms`);
|
|
297
|
-
error.name = "AbortError";
|
|
298
|
-
return error;
|
|
299
|
-
}
|
|
300
|
-
function isRecord(value) {
|
|
301
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
302
|
-
}
|
|
303
|
-
function readPolicySummaryFromDetails(details) {
|
|
304
|
-
if (!isRecord(details)) {
|
|
305
|
-
return null;
|
|
306
|
-
}
|
|
307
|
-
const directSummary = details.summary;
|
|
308
|
-
if (typeof directSummary === "string" && directSummary.trim().length > 0) {
|
|
309
|
-
return directSummary.trim();
|
|
310
|
-
}
|
|
311
|
-
const policy = details.policy;
|
|
312
|
-
if (!isRecord(policy)) {
|
|
313
|
-
return null;
|
|
314
|
-
}
|
|
315
|
-
const explanation = policy.explanation;
|
|
316
|
-
if (!isRecord(explanation)) {
|
|
317
|
-
return null;
|
|
318
|
-
}
|
|
319
|
-
const nestedSummary = explanation.summary;
|
|
320
|
-
if (typeof nestedSummary === "string" && nestedSummary.trim().length > 0) {
|
|
321
|
-
return nestedSummary.trim();
|
|
322
|
-
}
|
|
323
|
-
return null;
|
|
324
|
-
}
|
|
325
|
-
async function resolveConfiguredAuthContext(authContext) {
|
|
326
|
-
if (typeof authContext === "function") {
|
|
327
|
-
return await authContext();
|
|
328
|
-
}
|
|
329
|
-
return authContext;
|
|
330
|
-
}
|
|
331
|
-
function mergeHeaderRecord(base, addition) {
|
|
332
|
-
const headers = new Headers(base);
|
|
333
|
-
for (const [key, value] of Object.entries(addition)) {
|
|
334
|
-
const existing = headers.get(key);
|
|
335
|
-
if (existing !== null && existing !== value) {
|
|
336
|
-
throw new LucernSdkAuthContextError(
|
|
337
|
-
"policy_denied",
|
|
338
|
-
`Canonical Lucern SDK auth context conflicts with existing ${key} header.`
|
|
339
|
-
);
|
|
340
|
-
}
|
|
341
|
-
headers.set(key, value);
|
|
342
|
-
}
|
|
343
|
-
return Object.fromEntries(headers.entries());
|
|
344
|
-
}
|
|
345
|
-
function cleanHeaderValue(value) {
|
|
346
|
-
const normalized = value?.trim();
|
|
347
|
-
return normalized ? normalized : void 0;
|
|
348
|
-
}
|
|
349
|
-
function createGatewayRequestClient(config = {}) {
|
|
350
|
-
const fetchImpl = config.fetchImpl ?? fetch;
|
|
351
|
-
const baseUrl = config.baseUrl?.replace(/\/+$/, "") ?? "";
|
|
352
|
-
const maxRetries = config.maxRetries ?? 2;
|
|
353
|
-
const requestIdFactory = config.requestIdFactory ?? (() => generatePortableRequestId());
|
|
354
|
-
async function resolveAuthHeaders() {
|
|
355
|
-
const provided = config.getAuthHeaders ? await config.getAuthHeaders() : {};
|
|
356
|
-
const headers = new Headers(provided);
|
|
357
|
-
const setIfAbsent = (name, value) => {
|
|
358
|
-
const normalized = cleanHeaderValue(value);
|
|
359
|
-
if (normalized && !headers.has(name)) {
|
|
360
|
-
headers.set(name, normalized);
|
|
361
|
-
}
|
|
362
|
-
};
|
|
363
|
-
setIfAbsent("x-lucern-key", config.apiKey);
|
|
364
|
-
setIfAbsent("x-lucern-session-token", config.userToken);
|
|
365
|
-
setIfAbsent("x-lucern-environment", config.environment);
|
|
366
|
-
setIfAbsent("x-lucern-clerk-id", config.clerkId);
|
|
367
|
-
setIfAbsent("x-lucern-user-id", config.userId ?? config.clerkId);
|
|
368
|
-
setIfAbsent("x-lucern-deployment-host", config.deploymentHost);
|
|
369
|
-
const base = Object.fromEntries(headers.entries());
|
|
370
|
-
const authContextInput = await resolveConfiguredAuthContext(
|
|
371
|
-
config.authContext
|
|
372
|
-
);
|
|
373
|
-
if (!authContextInput && !config.requireCanonicalAuthContext) {
|
|
374
|
-
return base;
|
|
375
|
-
}
|
|
376
|
-
const authContext = normalizeCanonicalLucernAuthContext(authContextInput);
|
|
377
|
-
return mergeHeaderRecord(base, createCanonicalAuthHeaders(authContext));
|
|
378
|
-
}
|
|
379
|
-
async function fetchWithTimeout(url, init, timeoutMs) {
|
|
380
|
-
const controller = new AbortController();
|
|
381
|
-
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
382
|
-
try {
|
|
383
|
-
return await fetchImpl(url, { ...init, signal: controller.signal });
|
|
384
|
-
} catch (error) {
|
|
385
|
-
if (controller.signal.aborted) {
|
|
386
|
-
throw timeoutError(timeoutMs);
|
|
387
|
-
}
|
|
388
|
-
throw error;
|
|
389
|
-
} finally {
|
|
390
|
-
clearTimeout(timer);
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
async function parsePayload(response) {
|
|
394
|
-
const text = await response.text();
|
|
395
|
-
if (!text) {
|
|
396
|
-
return null;
|
|
397
|
-
}
|
|
398
|
-
const parsed = tryParseGatewayEnvelopeJson(text);
|
|
399
|
-
if (!parsed.ok) {
|
|
400
|
-
return null;
|
|
401
|
-
}
|
|
402
|
-
return isRecord(parsed.value) ? parsed.value : null;
|
|
403
|
-
}
|
|
404
|
-
function resolveTimeoutMs(method, requestTimeoutMs) {
|
|
405
|
-
if (typeof requestTimeoutMs === "number") {
|
|
406
|
-
return requestTimeoutMs;
|
|
407
|
-
}
|
|
408
|
-
const methodTimeoutMs = config.timeoutMsByMethod?.[method];
|
|
409
|
-
if (typeof methodTimeoutMs === "number") {
|
|
410
|
-
return methodTimeoutMs;
|
|
411
|
-
}
|
|
412
|
-
return config.timeoutMs ?? 15e3;
|
|
413
|
-
}
|
|
414
|
-
function tryParseGatewayEnvelopeJson(text) {
|
|
415
|
-
const trimmed = text.trim();
|
|
416
|
-
if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) {
|
|
417
|
-
return { ok: false, reason: "non-json" };
|
|
418
|
-
}
|
|
419
|
-
try {
|
|
420
|
-
return { ok: true, value: JSON.parse(trimmed) };
|
|
421
|
-
} catch (error) {
|
|
422
|
-
if (error instanceof SyntaxError) {
|
|
423
|
-
return { ok: false, reason: "invalid-json", error };
|
|
424
|
-
}
|
|
425
|
-
throw error;
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
function buildApiError(args) {
|
|
429
|
-
const failure = args.failure;
|
|
430
|
-
const legacyError = failure && isRecord(failure.error) ? failure.error : failure?.legacyError;
|
|
431
|
-
const correlationId = failure?.correlationId ?? args.response.headers.get("x-lucern-correlation-id")?.trim() ?? args.requestId;
|
|
432
|
-
const policyTraceId = failure?.policyTraceId ?? args.response.headers.get("x-lucern-policy-trace-id")?.trim() ?? null;
|
|
433
|
-
const details = failure?.details ?? legacyError?.details;
|
|
434
|
-
const policySummary = readPolicySummaryFromDetails(details);
|
|
435
|
-
const failureMessage = typeof failure?.error === "string" ? failure.error : legacyError?.message;
|
|
436
|
-
return new LucernApiError({
|
|
437
|
-
code: failure?.code ?? legacyError?.code ?? fallbackErrorCode(args.response.status),
|
|
438
|
-
message: policySummary ?? failureMessage ?? (args.response.ok ? "Platform API returned an invalid success payload." : "Platform API request failed."),
|
|
439
|
-
status: args.response.status,
|
|
440
|
-
invariant: failure?.invariant,
|
|
441
|
-
suggestion: failure?.suggestion,
|
|
442
|
-
details,
|
|
443
|
-
requestId: args.requestId,
|
|
444
|
-
correlationId,
|
|
445
|
-
policyTraceId
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
async function request(args) {
|
|
449
|
-
const authHeaders = await resolveAuthHeaders();
|
|
450
|
-
const method = args.method ?? "GET";
|
|
451
|
-
const timeoutMs = resolveTimeoutMs(method, args.timeoutMs);
|
|
452
|
-
const headers = new Headers({
|
|
453
|
-
"content-type": "application/json",
|
|
454
|
-
...authHeaders
|
|
455
|
-
});
|
|
456
|
-
if (args.idempotencyKey) {
|
|
457
|
-
headers.set("idempotency-key", args.idempotencyKey);
|
|
458
|
-
}
|
|
459
|
-
const requestId = headers.get("x-correlation-id")?.trim() || headers.get("x-request-id")?.trim() || args.requestId || requestIdFactory();
|
|
460
|
-
if (!headers.has("x-correlation-id") && !headers.has("x-request-id")) {
|
|
461
|
-
headers.set("x-correlation-id", requestId);
|
|
462
|
-
}
|
|
463
|
-
const url = `${baseUrl}${args.path}`;
|
|
464
|
-
const serializedBody = args.body ? JSON.stringify(args.body) : void 0;
|
|
465
|
-
const init = {
|
|
466
|
-
method,
|
|
467
|
-
headers,
|
|
468
|
-
body: serializedBody
|
|
469
|
-
};
|
|
470
|
-
let lastError;
|
|
471
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
472
|
-
const hookRequestContext = {
|
|
473
|
-
requestId,
|
|
474
|
-
attempt,
|
|
475
|
-
maxRetries,
|
|
476
|
-
method,
|
|
477
|
-
path: args.path,
|
|
478
|
-
url,
|
|
479
|
-
headers: new Headers(headers),
|
|
480
|
-
body: serializedBody,
|
|
481
|
-
timeoutMs
|
|
482
|
-
};
|
|
483
|
-
await config.onRequest?.(hookRequestContext);
|
|
484
|
-
const startedAt = Date.now();
|
|
485
|
-
try {
|
|
486
|
-
const response = await fetchWithTimeout(url, init, timeoutMs);
|
|
487
|
-
const responseClone = response.clone();
|
|
488
|
-
const payload = await parsePayload(response);
|
|
489
|
-
const retryAfterMs = parseRetryAfterMs(
|
|
490
|
-
response.headers.get("Retry-After")
|
|
491
|
-
);
|
|
492
|
-
if (!response.ok || !payload?.success) {
|
|
493
|
-
const failure = payload && !payload.success ? payload : null;
|
|
494
|
-
const apiError = buildApiError({
|
|
495
|
-
requestId,
|
|
496
|
-
response,
|
|
497
|
-
failure
|
|
498
|
-
});
|
|
499
|
-
const willRetry = attempt < maxRetries && isRetryableStatus(response.status);
|
|
500
|
-
await config.onResponse?.({
|
|
501
|
-
...hookRequestContext,
|
|
502
|
-
durationMs: Date.now() - startedAt,
|
|
503
|
-
status: response.status,
|
|
504
|
-
response: responseClone,
|
|
505
|
-
error: apiError,
|
|
506
|
-
correlationId: apiError.correlationId ?? requestId,
|
|
507
|
-
policyTraceId: apiError.policyTraceId ?? null,
|
|
508
|
-
retryAfterMs,
|
|
509
|
-
willRetry
|
|
510
|
-
});
|
|
511
|
-
if (willRetry) {
|
|
512
|
-
lastError = apiError;
|
|
513
|
-
await delay(
|
|
514
|
-
computeRetryDelayMs({
|
|
515
|
-
attempt,
|
|
516
|
-
status: response.status,
|
|
517
|
-
retryAfterMs
|
|
518
|
-
})
|
|
519
|
-
);
|
|
520
|
-
continue;
|
|
521
|
-
}
|
|
522
|
-
throw apiError;
|
|
523
|
-
}
|
|
524
|
-
const successPayload = payload;
|
|
525
|
-
await config.onResponse?.({
|
|
526
|
-
...hookRequestContext,
|
|
527
|
-
durationMs: Date.now() - startedAt,
|
|
528
|
-
status: response.status,
|
|
529
|
-
response: responseClone,
|
|
530
|
-
correlationId: successPayload.correlationId ?? response.headers.get("x-lucern-correlation-id")?.trim() ?? requestId,
|
|
531
|
-
policyTraceId: successPayload.policyTraceId ?? response.headers.get("x-lucern-policy-trace-id")?.trim() ?? null,
|
|
532
|
-
idempotentReplay: successPayload.idempotentReplay,
|
|
533
|
-
retryAfterMs,
|
|
534
|
-
willRetry: false
|
|
535
|
-
});
|
|
536
|
-
return successPayload;
|
|
537
|
-
} catch (fetchError) {
|
|
538
|
-
if (fetchError instanceof LucernApiError) {
|
|
539
|
-
throw fetchError;
|
|
540
|
-
}
|
|
541
|
-
const willRetry = attempt < maxRetries;
|
|
542
|
-
await config.onResponse?.({
|
|
543
|
-
...hookRequestContext,
|
|
544
|
-
durationMs: Date.now() - startedAt,
|
|
545
|
-
error: fetchError,
|
|
546
|
-
correlationId: requestId,
|
|
547
|
-
policyTraceId: null,
|
|
548
|
-
willRetry
|
|
549
|
-
});
|
|
550
|
-
lastError = fetchError;
|
|
551
|
-
if (willRetry) {
|
|
552
|
-
await delay(computeRetryDelayMs({ attempt }));
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
throw lastError instanceof Error ? lastError : new Error("Platform API request failed after retries.");
|
|
557
|
-
}
|
|
558
|
-
return {
|
|
559
|
-
request
|
|
560
|
-
};
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
// src/sdkSurface.ts
|
|
564
|
-
function createListResult(items, legacyKey) {
|
|
565
|
-
const result = {
|
|
566
|
-
items,
|
|
567
|
-
total: items.length
|
|
568
|
-
};
|
|
569
|
-
if (legacyKey) {
|
|
570
|
-
return {
|
|
571
|
-
...result,
|
|
572
|
-
[legacyKey]: items
|
|
573
|
-
};
|
|
574
|
-
}
|
|
575
|
-
return result;
|
|
576
|
-
}
|
|
577
|
-
function mapGatewayData(response, mapper) {
|
|
578
|
-
return {
|
|
579
|
-
...response,
|
|
580
|
-
data: mapper(response.data)
|
|
581
|
-
};
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
// src/boundaryClientSurface.ts
|
|
585
|
-
function cleanOptionalString(value) {
|
|
586
|
-
const normalized = value?.trim();
|
|
587
|
-
return normalized ? normalized : void 0;
|
|
588
|
-
}
|
|
589
|
-
function isRecord2(value) {
|
|
590
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
591
|
-
}
|
|
592
|
-
function cleanRequiredString(value, label) {
|
|
593
|
-
const normalized = cleanOptionalString(value);
|
|
594
|
-
if (!normalized) {
|
|
595
|
-
throw new Error(`${label} is required`);
|
|
596
|
-
}
|
|
597
|
-
return normalized;
|
|
598
|
-
}
|
|
599
|
-
function assertKnownKeys(input, allowed, operation) {
|
|
600
|
-
const allowedSet = new Set(allowed);
|
|
601
|
-
const unknownKeys = Object.keys(input).filter((key) => !allowedSet.has(key));
|
|
602
|
-
if (unknownKeys.length > 0) {
|
|
603
|
-
throw new Error(
|
|
604
|
-
`${operation} received unsupported field(s): ${unknownKeys.join(", ")}`
|
|
605
|
-
);
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
function knownPayload(input, allowed, operation) {
|
|
609
|
-
assertKnownKeys(input, allowed, operation);
|
|
610
|
-
return { ...input };
|
|
611
|
-
}
|
|
612
|
-
function listResultFromEnvelope(data, legacyKey) {
|
|
613
|
-
const record = isRecord2(data) ? data : {};
|
|
614
|
-
const legacyItems = record[legacyKey];
|
|
615
|
-
return createListResult(
|
|
616
|
-
Array.isArray(legacyItems) ? legacyItems : Array.isArray(data) ? data : [],
|
|
617
|
-
legacyKey
|
|
618
|
-
);
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
// src/eventingClient.ts
|
|
622
|
-
var EVENTING_FIELDS = [
|
|
623
|
-
"tenantId",
|
|
624
|
-
"workspaceId",
|
|
625
|
-
"principalId",
|
|
626
|
-
"topicId",
|
|
627
|
-
"eventId",
|
|
628
|
-
"eventType",
|
|
629
|
-
"eventPayload",
|
|
630
|
-
"webhookId",
|
|
631
|
-
"deliveryId",
|
|
632
|
-
"status",
|
|
633
|
-
"attempt",
|
|
634
|
-
"statusCode",
|
|
635
|
-
"error",
|
|
636
|
-
"responseBody",
|
|
637
|
-
"durationMs",
|
|
638
|
-
"metadata",
|
|
639
|
-
"limit",
|
|
640
|
-
"cursor"
|
|
641
|
-
];
|
|
642
|
-
function query(input) {
|
|
643
|
-
return {
|
|
644
|
-
tenantId: cleanRequiredString(input.tenantId, "tenantId"),
|
|
645
|
-
workspaceId: input.workspaceId,
|
|
646
|
-
principalId: input.principalId,
|
|
647
|
-
topicId: input.topicId,
|
|
648
|
-
eventType: input.eventType,
|
|
649
|
-
webhookId: input.webhookId,
|
|
650
|
-
status: input.status,
|
|
651
|
-
limit: input.limit,
|
|
652
|
-
cursor: input.cursor
|
|
653
|
-
};
|
|
654
|
-
}
|
|
655
|
-
function body(input, operation) {
|
|
656
|
-
return knownPayload(input, EVENTING_FIELDS, operation);
|
|
657
|
-
}
|
|
658
|
-
function createEventingClient(config = {}) {
|
|
659
|
-
const gateway = createGatewayRequestClient(config);
|
|
660
|
-
return {
|
|
661
|
-
recordEvent(input, idempotencyKey) {
|
|
662
|
-
cleanRequiredString(input.tenantId, "tenantId");
|
|
663
|
-
cleanRequiredString(input.eventType, "eventType");
|
|
664
|
-
return gateway.request({
|
|
665
|
-
path: "/api/platform/v1/events",
|
|
666
|
-
method: "POST",
|
|
667
|
-
body: body(
|
|
668
|
-
input,
|
|
669
|
-
"events.recordEvent"
|
|
670
|
-
),
|
|
671
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
672
|
-
});
|
|
673
|
-
},
|
|
674
|
-
listEvents(input) {
|
|
675
|
-
return gateway.request({
|
|
676
|
-
path: `/api/platform/v1/events${toQueryString(query(input))}`
|
|
677
|
-
}).then(
|
|
678
|
-
(response) => mapGatewayData(
|
|
679
|
-
response,
|
|
680
|
-
(data) => listResultFromEnvelope(data, "events")
|
|
681
|
-
)
|
|
682
|
-
);
|
|
683
|
-
},
|
|
684
|
-
listWebhooks(input) {
|
|
685
|
-
return gateway.request({
|
|
686
|
-
path: `/api/platform/v1/webhooks${toQueryString(query(input))}`
|
|
687
|
-
}).then(
|
|
688
|
-
(response) => mapGatewayData(
|
|
689
|
-
response,
|
|
690
|
-
(data) => listResultFromEnvelope(
|
|
691
|
-
data,
|
|
692
|
-
"webhooks"
|
|
693
|
-
)
|
|
694
|
-
)
|
|
695
|
-
);
|
|
696
|
-
},
|
|
697
|
-
enqueueDelivery(input, idempotencyKey) {
|
|
698
|
-
cleanRequiredString(input.tenantId, "tenantId");
|
|
699
|
-
cleanRequiredString(input.eventId, "eventId");
|
|
700
|
-
cleanRequiredString(input.webhookId, "webhookId");
|
|
701
|
-
return gateway.request({
|
|
702
|
-
path: "/api/platform/v1/events/deliveries",
|
|
703
|
-
method: "POST",
|
|
704
|
-
body: body(
|
|
705
|
-
input,
|
|
706
|
-
"events.enqueueDelivery"
|
|
707
|
-
),
|
|
708
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
709
|
-
});
|
|
710
|
-
},
|
|
711
|
-
recordDeliveryAttempt(input, idempotencyKey) {
|
|
712
|
-
cleanRequiredString(input.tenantId, "tenantId");
|
|
713
|
-
cleanRequiredString(input.deliveryId, "deliveryId");
|
|
714
|
-
return gateway.request({
|
|
715
|
-
path: `/api/platform/v1/events/deliveries/${encodeURIComponent(
|
|
716
|
-
input.deliveryId
|
|
717
|
-
)}/attempts`,
|
|
718
|
-
method: "POST",
|
|
719
|
-
body: body(
|
|
720
|
-
input,
|
|
721
|
-
"events.recordDeliveryAttempt"
|
|
722
|
-
),
|
|
723
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
724
|
-
});
|
|
725
|
-
},
|
|
726
|
-
updateDeliveryStatus(input, idempotencyKey) {
|
|
727
|
-
cleanRequiredString(input.tenantId, "tenantId");
|
|
728
|
-
cleanRequiredString(input.deliveryId, "deliveryId");
|
|
729
|
-
return gateway.request({
|
|
730
|
-
path: `/api/platform/v1/events/deliveries/${encodeURIComponent(
|
|
731
|
-
input.deliveryId
|
|
732
|
-
)}/status`,
|
|
733
|
-
method: "PATCH",
|
|
734
|
-
body: body(
|
|
735
|
-
input,
|
|
736
|
-
"events.updateDeliveryStatus"
|
|
737
|
-
),
|
|
738
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
739
|
-
});
|
|
740
|
-
}
|
|
741
|
-
};
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
export { EVENTING_FIELDS, createEventingClient };
|
|
745
|
-
//# sourceMappingURL=eventingClient.js.map
|
|
746
|
-
//# sourceMappingURL=eventingClient.js.map
|