@sylphx/sdk 0.21.1 → 0.22.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/dist/health/index.d.ts +4 -1
- package/dist/health/index.mjs +1 -0
- package/dist/health/index.mjs.map +1 -1
- package/dist/index.d.ts +86 -96
- package/dist/index.mjs +323 -205
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.ts +40 -66
- package/dist/react/index.mjs +60 -31
- package/dist/react/index.mjs.map +1 -1
- package/dist/server/index.d.ts +5 -6
- package/package.json +2 -2
package/dist/react/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SdkBillingPlan, SdkBillingSubscription, SdkConsentType, UserConsent as UserConsent$1, ReferralRewardDefaults as ReferralRewardDefaults$1,
|
|
1
|
+
import { SdkBillingPlan, SdkBillingSubscription, SdkConsentType, UserConsent as UserConsent$1, ConsentHistoryResponse, GetStatsResponse, ReferralRewardDefaults as ReferralRewardDefaults$1, RedeemResponse, RuntimeWebhookDelivery, OrgSdkRole, OrgInvitation, OrgMember, CreateOrgInput as CreateOrgInput$1, Organization, File as File$1, FileId } from '@sylphx/contract';
|
|
2
2
|
export { Organization, File as StorageFile, FileId as StorageFileId } from '@sylphx/contract';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import * as react from 'react';
|
|
@@ -1018,12 +1018,11 @@ type Subscription = SdkBillingSubscription;
|
|
|
1018
1018
|
* - Platform auto-discovers/creates consent types when first referenced
|
|
1019
1019
|
* - Console can override names, descriptions, requirements without deployment
|
|
1020
1020
|
*
|
|
1021
|
-
* Wire-shape types are re-exported from
|
|
1022
|
-
* contract is the single source of truth
|
|
1023
|
-
* `GET /consent`, `POST /consent`, and friends.
|
|
1024
|
-
*
|
|
1025
|
-
*
|
|
1026
|
-
* shapes themselves.
|
|
1021
|
+
* Wire-shape types and endpoint paths are re-exported from
|
|
1022
|
+
* `@sylphx/contract` (ADR-084). The contract is the single source of truth
|
|
1023
|
+
* for `GET /consent/types`, `GET /consent`, `POST /consent`, and friends.
|
|
1024
|
+
* This module keeps ergonomic helper inputs only where the public SDK API
|
|
1025
|
+
* intentionally differs from the wire shape.
|
|
1027
1026
|
*
|
|
1028
1027
|
* @example
|
|
1029
1028
|
* ```typescript
|
|
@@ -1067,36 +1066,7 @@ interface GetConsentHistoryInput {
|
|
|
1067
1066
|
*/
|
|
1068
1067
|
cursor?: string;
|
|
1069
1068
|
}
|
|
1070
|
-
|
|
1071
|
-
interface ConsentHistoryEntry {
|
|
1072
|
-
/** Unique entry ID */
|
|
1073
|
-
id: string;
|
|
1074
|
-
/** Consent type slug (e.g., 'analytics') */
|
|
1075
|
-
consentType: string;
|
|
1076
|
-
/** Display name of the consent type */
|
|
1077
|
-
consentTypeName: string;
|
|
1078
|
-
/** Previous consent state (null = initial consent) */
|
|
1079
|
-
previousGranted: boolean | null;
|
|
1080
|
-
/** New consent state */
|
|
1081
|
-
newGranted: boolean;
|
|
1082
|
-
/** Source of the change (banner, settings, api) */
|
|
1083
|
-
source: string;
|
|
1084
|
-
/** Reason for change (user_action, policy_update, etc.) */
|
|
1085
|
-
reason: string | null;
|
|
1086
|
-
/** ISO timestamp when change occurred */
|
|
1087
|
-
createdAt: string;
|
|
1088
|
-
}
|
|
1089
|
-
interface ConsentHistoryResult {
|
|
1090
|
-
/** List of consent change entries */
|
|
1091
|
-
entries: ConsentHistoryEntry[];
|
|
1092
|
-
/**
|
|
1093
|
-
* Opaque cursor for the next page. Pass as `cursor` to the next call.
|
|
1094
|
-
* Null when this is the last page.
|
|
1095
|
-
*/
|
|
1096
|
-
nextCursor: string | null;
|
|
1097
|
-
/** Whether there are more entries */
|
|
1098
|
-
hasMore: boolean;
|
|
1099
|
-
}
|
|
1069
|
+
type ConsentHistoryResult = ConsentHistoryResponse;
|
|
1100
1070
|
/**
|
|
1101
1071
|
* Inline defaults for consent purpose auto-discovery
|
|
1102
1072
|
*
|
|
@@ -1197,42 +1167,20 @@ interface ToolCall {
|
|
|
1197
1167
|
*/
|
|
1198
1168
|
|
|
1199
1169
|
type ReferralRewardDefaults = ReferralRewardDefaults$1;
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
code: string;
|
|
1203
|
-
/** Total referrals made */
|
|
1204
|
-
totalReferrals: number;
|
|
1205
|
-
/** Successful (redeemed) referrals */
|
|
1206
|
-
successfulReferrals: number;
|
|
1207
|
-
/** Pending referrals */
|
|
1208
|
-
pendingReferrals: number;
|
|
1209
|
-
/** Total rewards earned */
|
|
1210
|
-
totalRewards: number;
|
|
1211
|
-
}
|
|
1212
|
-
interface RedeemResult {
|
|
1213
|
-
success: boolean;
|
|
1214
|
-
/** Reward type - platform types or app-specific types */
|
|
1215
|
-
rewardType: 'points' | 'premium_trial' | 'discount' | 'credit' | (string & {});
|
|
1216
|
-
referredReward?: Record<string, unknown>;
|
|
1217
|
-
referrerReward?: Record<string, unknown>;
|
|
1218
|
-
}
|
|
1170
|
+
type ReferralStats = GetStatsResponse;
|
|
1171
|
+
type RedeemResult = RedeemResponse;
|
|
1219
1172
|
|
|
1220
1173
|
/**
|
|
1221
1174
|
* Webhooks Functions
|
|
1222
1175
|
*
|
|
1223
1176
|
* Pure functions for webhook configuration and delivery management.
|
|
1224
1177
|
*
|
|
1225
|
-
*
|
|
1226
|
-
*
|
|
1227
|
-
*
|
|
1228
|
-
*
|
|
1229
|
-
* `WebhookStats`, `WebhookConfigUpdate`, `ListDeliveriesOptions`,
|
|
1230
|
-
* `WebhookDeliveriesResult`) that are looser or richer than the strict
|
|
1231
|
-
* contract shapes — they predate the contract and stay put to avoid
|
|
1232
|
-
* breaking downstream consumers (SDK tests, apps/web hooks layer).
|
|
1178
|
+
* Runtime endpoint paths and methods come from `webhooksRuntimeEndpoints`
|
|
1179
|
+
* (ADR-084). Management-plane webhook administration stays in
|
|
1180
|
+
* `webhooksEndpoints`; this module targets the BaaS runtime API mounted at
|
|
1181
|
+
* `/webhooks` for customer SDK calls.
|
|
1233
1182
|
*/
|
|
1234
1183
|
|
|
1235
|
-
type WebhookDelivery$1 = WebhookDelivery$2;
|
|
1236
1184
|
interface WebhookEnvironment {
|
|
1237
1185
|
id: string;
|
|
1238
1186
|
name: string;
|
|
@@ -1254,7 +1202,33 @@ interface WebhookConfig {
|
|
|
1254
1202
|
interface WebhookDeliveriesResult {
|
|
1255
1203
|
deliveries: WebhookDelivery$1[];
|
|
1256
1204
|
total: number;
|
|
1257
|
-
hasMore
|
|
1205
|
+
hasMore?: boolean;
|
|
1206
|
+
limit?: number;
|
|
1207
|
+
offset?: number;
|
|
1208
|
+
}
|
|
1209
|
+
type WebhookDeliveryStatus$1 = RuntimeWebhookDelivery['status'] | 'success';
|
|
1210
|
+
interface WebhookDelivery$1 {
|
|
1211
|
+
id: string;
|
|
1212
|
+
event: string;
|
|
1213
|
+
eventType?: string;
|
|
1214
|
+
url: string;
|
|
1215
|
+
status: WebhookDeliveryStatus$1;
|
|
1216
|
+
retryCount: number;
|
|
1217
|
+
responseStatus?: number | null;
|
|
1218
|
+
statusCode?: number;
|
|
1219
|
+
error?: string | null;
|
|
1220
|
+
payload?: Record<string, unknown>;
|
|
1221
|
+
messageId?: string | null;
|
|
1222
|
+
attempts?: number;
|
|
1223
|
+
response?: string | null;
|
|
1224
|
+
createdAt: string;
|
|
1225
|
+
queuedAt?: string | null;
|
|
1226
|
+
deliveredAt?: string | null;
|
|
1227
|
+
failedAt?: string | null;
|
|
1228
|
+
lastAttemptAt?: string | null;
|
|
1229
|
+
timestamp?: string;
|
|
1230
|
+
webhookId?: string;
|
|
1231
|
+
duration?: number;
|
|
1258
1232
|
}
|
|
1259
1233
|
interface WebhookStats {
|
|
1260
1234
|
total: number;
|
package/dist/react/index.mjs
CHANGED
|
@@ -11540,9 +11540,11 @@ import { QueryClient, QueryClientProvider, useQuery as useQuery5 } from "@tansta
|
|
|
11540
11540
|
import { useCallback as useCallback27, useEffect as useEffect23, useMemo as useMemo9, useRef as useRef10, useState as useState30 } from "react";
|
|
11541
11541
|
|
|
11542
11542
|
// src/consent.ts
|
|
11543
|
+
import { consentEndpoints } from "@sylphx/contract";
|
|
11543
11544
|
async function linkAnonymousConsents(config2, input) {
|
|
11544
|
-
|
|
11545
|
-
|
|
11545
|
+
const endpoint = consentEndpoints.linkAnonymous;
|
|
11546
|
+
await callApi(config2, endpoint.path, {
|
|
11547
|
+
method: endpoint.method,
|
|
11546
11548
|
body: input
|
|
11547
11549
|
});
|
|
11548
11550
|
}
|
|
@@ -14715,6 +14717,18 @@ function useHasPermission(permissions, required) {
|
|
|
14715
14717
|
import { useMutation as useMutation2, useQuery as useQuery7, useQueryClient as useQueryClient6 } from "@tanstack/react-query";
|
|
14716
14718
|
import { useCallback as useCallback29, useContext as useContext17, useMemo as useMemo11, useState as useState31 } from "react";
|
|
14717
14719
|
|
|
14720
|
+
// src/storage.ts
|
|
14721
|
+
import { storageEndpoints } from "@sylphx/contract";
|
|
14722
|
+
|
|
14723
|
+
// src/contract-http.ts
|
|
14724
|
+
function interpolatePath(template, params) {
|
|
14725
|
+
let path = template;
|
|
14726
|
+
for (const [key, value] of Object.entries(params)) {
|
|
14727
|
+
path = path.replace(`:${key}`, encodeURIComponent(value));
|
|
14728
|
+
}
|
|
14729
|
+
return path;
|
|
14730
|
+
}
|
|
14731
|
+
|
|
14718
14732
|
// src/lib/retry.ts
|
|
14719
14733
|
init_constants();
|
|
14720
14734
|
var DEFAULT_RETRY_CONFIG = {
|
|
@@ -14825,18 +14839,24 @@ function randomBytes(n2) {
|
|
|
14825
14839
|
|
|
14826
14840
|
// src/storage.ts
|
|
14827
14841
|
var PATHS = {
|
|
14828
|
-
uploads:
|
|
14829
|
-
upload: (id) =>
|
|
14830
|
-
uploadComplete: (id) =>
|
|
14831
|
-
uploadPart: (id, n2) =>
|
|
14832
|
-
|
|
14833
|
-
|
|
14834
|
-
|
|
14835
|
-
|
|
14836
|
-
|
|
14837
|
-
|
|
14838
|
-
|
|
14839
|
-
|
|
14842
|
+
uploads: storageEndpoints.createUpload.path,
|
|
14843
|
+
upload: (id) => interpolatePath(storageEndpoints.abortUpload.path, { uploadId: String(id) }),
|
|
14844
|
+
uploadComplete: (id) => interpolatePath(storageEndpoints.completeUpload.path, { uploadId: String(id) }),
|
|
14845
|
+
uploadPart: (id, n2) => interpolatePath(storageEndpoints.presignUploadPart.path, {
|
|
14846
|
+
uploadId: String(id),
|
|
14847
|
+
partNumber: String(n2)
|
|
14848
|
+
}),
|
|
14849
|
+
files: storageEndpoints.listFiles.path,
|
|
14850
|
+
file: (id) => interpolatePath(storageEndpoints.getFile.path, { fileId: String(id) }),
|
|
14851
|
+
fileTakedown: (id) => interpolatePath(storageEndpoints.takedownFile.path, { fileId: String(id) }),
|
|
14852
|
+
fileRestore: (id) => interpolatePath(storageEndpoints.restoreFile.path, { fileId: String(id) }),
|
|
14853
|
+
fileSignedUrl: (id) => interpolatePath(storageEndpoints.signFileUrl.path, { fileId: String(id) }),
|
|
14854
|
+
fileCopy: (id) => interpolatePath(storageEndpoints.copyFile.path, { fileId: String(id) }),
|
|
14855
|
+
versions: (id) => interpolatePath(storageEndpoints.listFileVersions.path, { fileId: String(id) }),
|
|
14856
|
+
versionRestore: (id, vid) => interpolatePath(storageEndpoints.restoreFileVersion.path, {
|
|
14857
|
+
fileId: String(id),
|
|
14858
|
+
versionId: String(vid)
|
|
14859
|
+
})
|
|
14840
14860
|
};
|
|
14841
14861
|
var hasXhr = () => typeof globalThis.XMLHttpRequest !== "undefined";
|
|
14842
14862
|
var hasLocalStorage = () => {
|
|
@@ -15034,7 +15054,7 @@ async function uploadsCreate(config2, blob, options) {
|
|
|
15034
15054
|
ifNoneMatch: options.ifNoneMatch
|
|
15035
15055
|
};
|
|
15036
15056
|
const session = await callApi(config2, PATHS.uploads, {
|
|
15037
|
-
method:
|
|
15057
|
+
method: storageEndpoints.createUpload.method,
|
|
15038
15058
|
body: createBody,
|
|
15039
15059
|
idempotencyKey,
|
|
15040
15060
|
signal
|
|
@@ -15042,7 +15062,7 @@ async function uploadsCreate(config2, blob, options) {
|
|
|
15042
15062
|
const uploadId = session.uploadId;
|
|
15043
15063
|
const onAborted = async () => {
|
|
15044
15064
|
try {
|
|
15045
|
-
await callApi(config2, PATHS.upload(uploadId), { method:
|
|
15065
|
+
await callApi(config2, PATHS.upload(uploadId), { method: storageEndpoints.abortUpload.method });
|
|
15046
15066
|
} catch {
|
|
15047
15067
|
}
|
|
15048
15068
|
clearResume(String(uploadId));
|
|
@@ -15074,7 +15094,7 @@ async function runSinglePart(config2, blob, session, options, idempotencyKey) {
|
|
|
15074
15094
|
config2,
|
|
15075
15095
|
PATHS.uploadComplete(session.uploadId),
|
|
15076
15096
|
{
|
|
15077
|
-
method:
|
|
15097
|
+
method: storageEndpoints.completeUpload.method,
|
|
15078
15098
|
body: { parts: [{ partNumber: 1, etag: put.etag }] },
|
|
15079
15099
|
idempotencyKey: `${idempotencyKey}:complete`,
|
|
15080
15100
|
signal
|
|
@@ -15119,7 +15139,7 @@ async function runMultipart(config2, blob, session, options, idempotencyKey) {
|
|
|
15119
15139
|
config2,
|
|
15120
15140
|
PATHS.uploadComplete(session.uploadId),
|
|
15121
15141
|
{
|
|
15122
|
-
method:
|
|
15142
|
+
method: storageEndpoints.completeUpload.method,
|
|
15123
15143
|
body: { parts: completedParts },
|
|
15124
15144
|
idempotencyKey: `${idempotencyKey}:complete`,
|
|
15125
15145
|
signal
|
|
@@ -15129,9 +15149,12 @@ async function runMultipart(config2, blob, session, options, idempotencyKey) {
|
|
|
15129
15149
|
return fileFromCompletion(completion, options, blob);
|
|
15130
15150
|
}
|
|
15131
15151
|
async function uploadsAbort(config2, uploadId) {
|
|
15132
|
-
await withRetry(
|
|
15133
|
-
|
|
15134
|
-
|
|
15152
|
+
await withRetry(
|
|
15153
|
+
() => callApi(config2, PATHS.upload(uploadId), { method: storageEndpoints.abortUpload.method }),
|
|
15154
|
+
{
|
|
15155
|
+
maxRetries: 3
|
|
15156
|
+
}
|
|
15157
|
+
);
|
|
15135
15158
|
clearResume(String(uploadId));
|
|
15136
15159
|
}
|
|
15137
15160
|
function filesListPage(config2, options, cursor) {
|
|
@@ -15142,7 +15165,7 @@ function filesListPage(config2, options, cursor) {
|
|
|
15142
15165
|
includeDeleted: options.includeDeleted
|
|
15143
15166
|
};
|
|
15144
15167
|
return callApi(config2, PATHS.files, {
|
|
15145
|
-
method:
|
|
15168
|
+
method: storageEndpoints.listFiles.method,
|
|
15146
15169
|
query: {
|
|
15147
15170
|
folder: query.folder,
|
|
15148
15171
|
cursor: query.cursor,
|
|
@@ -15166,19 +15189,23 @@ function filesList(config2, options = {}) {
|
|
|
15166
15189
|
return Object.assign(iter, { fetchPage });
|
|
15167
15190
|
}
|
|
15168
15191
|
async function filesGet(config2, fileId) {
|
|
15169
|
-
return callApi(config2, PATHS.file(fileId), {
|
|
15192
|
+
return callApi(config2, PATHS.file(fileId), {
|
|
15193
|
+
method: storageEndpoints.getFile.method
|
|
15194
|
+
});
|
|
15170
15195
|
}
|
|
15171
15196
|
async function filesDelete(config2, fileId) {
|
|
15172
|
-
return callApi(config2, PATHS.file(fileId), { method:
|
|
15197
|
+
return callApi(config2, PATHS.file(fileId), { method: storageEndpoints.deleteFile.method });
|
|
15173
15198
|
}
|
|
15174
15199
|
async function filesTakedown(config2, fileId, options) {
|
|
15175
15200
|
return callApi(config2, PATHS.fileTakedown(fileId), {
|
|
15176
|
-
method:
|
|
15201
|
+
method: storageEndpoints.takedownFile.method,
|
|
15177
15202
|
body: options
|
|
15178
15203
|
});
|
|
15179
15204
|
}
|
|
15180
15205
|
async function filesRestore(config2, fileId) {
|
|
15181
|
-
return callApi(config2, PATHS.fileRestore(fileId), {
|
|
15206
|
+
return callApi(config2, PATHS.fileRestore(fileId), {
|
|
15207
|
+
method: storageEndpoints.restoreFile.method
|
|
15208
|
+
});
|
|
15182
15209
|
}
|
|
15183
15210
|
async function filesSignedUrl(config2, fileId, options = {}) {
|
|
15184
15211
|
const body = {
|
|
@@ -15187,7 +15214,7 @@ async function filesSignedUrl(config2, fileId, options = {}) {
|
|
|
15187
15214
|
userId: options.userId
|
|
15188
15215
|
};
|
|
15189
15216
|
return callApi(config2, PATHS.fileSignedUrl(fileId), {
|
|
15190
|
-
method:
|
|
15217
|
+
method: storageEndpoints.signFileUrl.method,
|
|
15191
15218
|
body
|
|
15192
15219
|
});
|
|
15193
15220
|
}
|
|
@@ -15199,18 +15226,20 @@ async function filesCopy(config2, fileId, options) {
|
|
|
15199
15226
|
metadata: options.metadata
|
|
15200
15227
|
};
|
|
15201
15228
|
return callApi(config2, PATHS.fileCopy(fileId), {
|
|
15202
|
-
method:
|
|
15229
|
+
method: storageEndpoints.copyFile.method,
|
|
15203
15230
|
body
|
|
15204
15231
|
});
|
|
15205
15232
|
}
|
|
15206
15233
|
async function filesVersionsList(config2, fileId) {
|
|
15207
15234
|
const data = await callApi(config2, PATHS.versions(fileId), {
|
|
15208
|
-
method:
|
|
15235
|
+
method: storageEndpoints.listFileVersions.method
|
|
15209
15236
|
});
|
|
15210
15237
|
return data.versions;
|
|
15211
15238
|
}
|
|
15212
15239
|
async function filesVersionsRestore(config2, fileId, versionId) {
|
|
15213
|
-
return callApi(config2, PATHS.versionRestore(fileId, versionId), {
|
|
15240
|
+
return callApi(config2, PATHS.versionRestore(fileId, versionId), {
|
|
15241
|
+
method: storageEndpoints.restoreFileVersion.method
|
|
15242
|
+
});
|
|
15214
15243
|
}
|
|
15215
15244
|
var storage = {
|
|
15216
15245
|
uploads: {
|
|
@@ -25231,7 +25260,7 @@ function ReferralCardInner({
|
|
|
25231
25260
|
fontWeight: 700,
|
|
25232
25261
|
color: theme.colorSuccess
|
|
25233
25262
|
},
|
|
25234
|
-
children: stats.
|
|
25263
|
+
children: stats.completedReferrals || 0
|
|
25235
25264
|
}
|
|
25236
25265
|
),
|
|
25237
25266
|
/* @__PURE__ */ jsx42("div", { style: mergeStyles(styles2.textXs, styles2.textMuted), children: "Successful" })
|