@joai/core 5.0.0 → 5.0.3
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/index.d.mts +341 -149
- package/dist/index.mjs +186 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -374,7 +374,7 @@ type ShippingCarrierOption = {
|
|
|
374
374
|
};
|
|
375
375
|
type Fulfillment = {
|
|
376
376
|
id: string;
|
|
377
|
-
orderId:
|
|
377
|
+
orderId: string;
|
|
378
378
|
method: FulfillmentMethod;
|
|
379
379
|
status: FulfillmentStatus;
|
|
380
380
|
carrierCode: string | null;
|
|
@@ -390,7 +390,8 @@ type Fulfillment = {
|
|
|
390
390
|
};
|
|
391
391
|
type Return = {
|
|
392
392
|
id: string;
|
|
393
|
-
orderId:
|
|
393
|
+
orderId: string;
|
|
394
|
+
fulfillmentId?: string | null;
|
|
394
395
|
status: ReturnStatus;
|
|
395
396
|
reason: string;
|
|
396
397
|
merchantNote: string | null;
|
|
@@ -398,8 +399,12 @@ type Return = {
|
|
|
398
399
|
orderItemId: number;
|
|
399
400
|
quantity: number;
|
|
400
401
|
condition: string | null;
|
|
402
|
+
name?: string | null;
|
|
401
403
|
}[];
|
|
402
404
|
refundAmount: number | null;
|
|
405
|
+
suggestedRefundAmount?: number | null;
|
|
406
|
+
createdAt?: string;
|
|
407
|
+
order?: Order | null;
|
|
403
408
|
};
|
|
404
409
|
type SubscriptionDelivery = {
|
|
405
410
|
fulfillmentMethod: FulfillmentMethod | null;
|
|
@@ -778,151 +783,6 @@ type Room = {
|
|
|
778
783
|
integration: Integration | null;
|
|
779
784
|
};
|
|
780
785
|
//#endregion
|
|
781
|
-
//#region src/meeting/types.d.ts
|
|
782
|
-
type MeetingSessionState = 'idle' | 'listening' | 'ended';
|
|
783
|
-
type TranscriptEntry = {
|
|
784
|
-
id: string;
|
|
785
|
-
text: string;
|
|
786
|
-
isFinal: boolean;
|
|
787
|
-
timestamp: number;
|
|
788
|
-
speakerId?: number;
|
|
789
|
-
speakerName?: string;
|
|
790
|
-
};
|
|
791
|
-
type BookmarkEntry = {
|
|
792
|
-
id: string;
|
|
793
|
-
timestamp: number;
|
|
794
|
-
transcriptEntryId: string;
|
|
795
|
-
};
|
|
796
|
-
type MeetingParticipant = {
|
|
797
|
-
name: string | null;
|
|
798
|
-
profileImageUrl: string | null;
|
|
799
|
-
};
|
|
800
|
-
type MeetingSpeakerAssignment = {
|
|
801
|
-
speakerId: number;
|
|
802
|
-
name: string;
|
|
803
|
-
contactId: string | null;
|
|
804
|
-
};
|
|
805
|
-
type Meeting = {
|
|
806
|
-
id: string;
|
|
807
|
-
code: string;
|
|
808
|
-
name: string | null;
|
|
809
|
-
room: Room | null;
|
|
810
|
-
inviteUrl: string;
|
|
811
|
-
status: MeetingStatus;
|
|
812
|
-
conferenceProvider: MeetingConferenceProvider | null;
|
|
813
|
-
conferenceUrl: string | null;
|
|
814
|
-
conferenceExternalId: string | null;
|
|
815
|
-
configuration?: Configuration;
|
|
816
|
-
captureMode: 'desktop_local' | null;
|
|
817
|
-
transcriptUrl: string | null;
|
|
818
|
-
summaryUrl: string | null;
|
|
819
|
-
participants?: MeetingParticipant[]; /** CRM contacts linked to an appointment booking, when available. */
|
|
820
|
-
contacts?: Contact[];
|
|
821
|
-
speakerAssignments?: MeetingSpeakerAssignment[] | null;
|
|
822
|
-
scheduledAt: string | null;
|
|
823
|
-
scheduledEndAt?: string | null;
|
|
824
|
-
timezone?: string | null;
|
|
825
|
-
calendarEventId: number | null;
|
|
826
|
-
startedAt: string | null;
|
|
827
|
-
endedAt: string | null;
|
|
828
|
-
createdAt: string;
|
|
829
|
-
};
|
|
830
|
-
type MeetingStatus = 'active' | 'completed' | 'analyzed' | 'scheduled' | 'cancelled';
|
|
831
|
-
type MeetingConferenceProvider = 'google_meet' | 'teams' | 'zoom';
|
|
832
|
-
type MeetingFeature = 'transcription' | 'summary' | 'insights' | 'actions';
|
|
833
|
-
type MeetingJoinTeam = {
|
|
834
|
-
slug: string;
|
|
835
|
-
name: string;
|
|
836
|
-
logo: string | null;
|
|
837
|
-
};
|
|
838
|
-
type MeetingJoinInfo = {
|
|
839
|
-
id: string;
|
|
840
|
-
code: string;
|
|
841
|
-
name: string | null;
|
|
842
|
-
inviteUrl: string;
|
|
843
|
-
agentName: string;
|
|
844
|
-
team: MeetingJoinTeam;
|
|
845
|
-
status: MeetingStatus;
|
|
846
|
-
isPhysical: boolean;
|
|
847
|
-
scheduledAt: string | null;
|
|
848
|
-
scheduledEndAt: string | null;
|
|
849
|
-
timezone: string;
|
|
850
|
-
conferenceUrl: string | null;
|
|
851
|
-
conferenceProvider: MeetingConferenceProvider | null;
|
|
852
|
-
endedAt: string | null;
|
|
853
|
-
canCancel: boolean;
|
|
854
|
-
features: Record<MeetingFeature, boolean>;
|
|
855
|
-
};
|
|
856
|
-
type MeetingTranscriptEntry = {
|
|
857
|
-
speaker: 'user' | 'agent';
|
|
858
|
-
text: string;
|
|
859
|
-
timestamp: string;
|
|
860
|
-
};
|
|
861
|
-
type MeetingUsage = {
|
|
862
|
-
current: number;
|
|
863
|
-
limit: number;
|
|
864
|
-
reached: boolean;
|
|
865
|
-
remainingWords: number | null;
|
|
866
|
-
};
|
|
867
|
-
type MeetingSummary = {
|
|
868
|
-
content: string;
|
|
869
|
-
};
|
|
870
|
-
//#endregion
|
|
871
|
-
//#region src/site/types.d.ts
|
|
872
|
-
type SiteType = 'undefined' | 'shop';
|
|
873
|
-
type SiteTeam = {
|
|
874
|
-
name: string;
|
|
875
|
-
slug: string;
|
|
876
|
-
logoUrl: string | null;
|
|
877
|
-
};
|
|
878
|
-
type SiteAgent = {
|
|
879
|
-
uuid: string | null;
|
|
880
|
-
};
|
|
881
|
-
type Site = {
|
|
882
|
-
id: number;
|
|
883
|
-
slug: string;
|
|
884
|
-
name: string | null;
|
|
885
|
-
url: string | null;
|
|
886
|
-
type: SiteType;
|
|
887
|
-
brandSlug: string | null;
|
|
888
|
-
customDomain: string | null;
|
|
889
|
-
enabled: boolean;
|
|
890
|
-
contactId?: string | null;
|
|
891
|
-
metricsSource?: string | null;
|
|
892
|
-
metricsResource?: string | null;
|
|
893
|
-
monthlyReport?: boolean;
|
|
894
|
-
team: SiteTeam | null;
|
|
895
|
-
agent: SiteAgent | null;
|
|
896
|
-
settings: Record<string, JsonValue>;
|
|
897
|
-
};
|
|
898
|
-
type SiteRoute = {
|
|
899
|
-
path: string;
|
|
900
|
-
warp: string;
|
|
901
|
-
label: WarpI18nText;
|
|
902
|
-
nav?: boolean;
|
|
903
|
-
hiddenFields?: string[];
|
|
904
|
-
};
|
|
905
|
-
type BrandSiteConfig = {
|
|
906
|
-
enabled: boolean;
|
|
907
|
-
auth?: boolean;
|
|
908
|
-
indexPath: string;
|
|
909
|
-
routes: SiteRoute[];
|
|
910
|
-
name?: string;
|
|
911
|
-
logoUrl?: string | null;
|
|
912
|
-
};
|
|
913
|
-
type SiteBrand = {
|
|
914
|
-
slug: string;
|
|
915
|
-
configureRoute: Pick<SiteRoute, 'path' | 'label'> | null;
|
|
916
|
-
};
|
|
917
|
-
type AggregatedRoute = {
|
|
918
|
-
path: string;
|
|
919
|
-
warp: string;
|
|
920
|
-
label: WarpI18nText;
|
|
921
|
-
nav?: boolean;
|
|
922
|
-
hiddenFields?: string[];
|
|
923
|
-
moduleSlug?: string;
|
|
924
|
-
};
|
|
925
|
-
//#endregion
|
|
926
786
|
//#region src/flow/types.d.ts
|
|
927
787
|
type FlowCategory = 'none' | 'defi' | 'nft' | 'social' | 'devtools' | 'productivity' | 'trading' | 'portfolio';
|
|
928
788
|
type FlowStatus = 'draft' | 'published';
|
|
@@ -968,6 +828,7 @@ declare const UserPermissions: {
|
|
|
968
828
|
readonly ContentPublish: "content-publish";
|
|
969
829
|
readonly TeamMemberInvite: "team-member-invite";
|
|
970
830
|
readonly TeamMemberRemove: "team-member-remove";
|
|
831
|
+
readonly TeamMemberRole: "team-member-role";
|
|
971
832
|
readonly TeamSecretView: "team-secret-view";
|
|
972
833
|
readonly TeamSecretManage: "team-secret-manage";
|
|
973
834
|
readonly AgentExecute: "agent-execute";
|
|
@@ -1001,6 +862,9 @@ declare const isUserRole: (value: string) => value is UserRole;
|
|
|
1001
862
|
declare const InviteableTeamRoles: readonly ["member", "developer", "admin"];
|
|
1002
863
|
declare const DefaultInviteTeamRole: "member";
|
|
1003
864
|
declare const inviteableTeamRoles: () => UserRole[];
|
|
865
|
+
/** Roles assignable to an existing member — unlike invites, ownership can be transferred. */
|
|
866
|
+
declare const AssignableTeamRoles: readonly ["owner", "admin", "developer", "member"];
|
|
867
|
+
declare const assignableTeamRoles: () => UserRole[];
|
|
1004
868
|
declare const defaultInviteTeamRole: () => UserRole;
|
|
1005
869
|
//#endregion
|
|
1006
870
|
//#region src/user/types.d.ts
|
|
@@ -1195,6 +1059,7 @@ type TeamMeta = {
|
|
|
1195
1059
|
'shop.legal.withdrawal_url'?: string | null;
|
|
1196
1060
|
'shop.legal.imprint_url'?: string | null;
|
|
1197
1061
|
'orders.notify_emails'?: string[];
|
|
1062
|
+
'orders.payment_reminders'?: boolean;
|
|
1198
1063
|
contactPropertyMaskWarp?: string;
|
|
1199
1064
|
branding?: TeamBrand | null;
|
|
1200
1065
|
settings: Record<string, unknown> & {
|
|
@@ -1322,6 +1187,7 @@ type TeamSettings = {
|
|
|
1322
1187
|
'shop.legal.withdrawal_url'?: string | null;
|
|
1323
1188
|
'shop.legal.imprint_url'?: string | null;
|
|
1324
1189
|
'orders.notify_emails'?: string[];
|
|
1190
|
+
'orders.payment_reminders'?: boolean;
|
|
1325
1191
|
branding?: TeamBrand | null;
|
|
1326
1192
|
};
|
|
1327
1193
|
type TeamUsage = Partial<Record<PlanFeature, TeamFeatureUsage>> & {
|
|
@@ -1379,6 +1245,152 @@ type AiCostsResponse = {
|
|
|
1379
1245
|
};
|
|
1380
1246
|
};
|
|
1381
1247
|
//#endregion
|
|
1248
|
+
//#region src/meeting/types.d.ts
|
|
1249
|
+
type MeetingSessionState = 'idle' | 'listening' | 'ended';
|
|
1250
|
+
type TranscriptEntry = {
|
|
1251
|
+
id: string;
|
|
1252
|
+
text: string;
|
|
1253
|
+
isFinal: boolean;
|
|
1254
|
+
timestamp: number;
|
|
1255
|
+
speakerId?: number;
|
|
1256
|
+
speakerName?: string;
|
|
1257
|
+
};
|
|
1258
|
+
type BookmarkEntry = {
|
|
1259
|
+
id: string;
|
|
1260
|
+
timestamp: number;
|
|
1261
|
+
transcriptEntryId: string;
|
|
1262
|
+
};
|
|
1263
|
+
type MeetingParticipant = {
|
|
1264
|
+
name: string | null;
|
|
1265
|
+
profileImageUrl: string | null;
|
|
1266
|
+
};
|
|
1267
|
+
type MeetingSpeakerAssignment = {
|
|
1268
|
+
speakerId: number;
|
|
1269
|
+
name: string;
|
|
1270
|
+
contactId: string | null;
|
|
1271
|
+
};
|
|
1272
|
+
type Meeting = {
|
|
1273
|
+
id: string;
|
|
1274
|
+
code: string;
|
|
1275
|
+
name: string | null;
|
|
1276
|
+
room: Room | null;
|
|
1277
|
+
inviteUrl: string;
|
|
1278
|
+
status: MeetingStatus;
|
|
1279
|
+
conferenceProvider: MeetingConferenceProvider | null;
|
|
1280
|
+
conferenceUrl: string | null;
|
|
1281
|
+
conferenceExternalId: string | null;
|
|
1282
|
+
configuration?: Configuration;
|
|
1283
|
+
captureMode: 'desktop_local' | null;
|
|
1284
|
+
transcriptUrl: string | null;
|
|
1285
|
+
summaryUrl: string | null;
|
|
1286
|
+
participants?: MeetingParticipant[]; /** CRM contacts linked to an appointment booking, when available. */
|
|
1287
|
+
contacts?: Contact[];
|
|
1288
|
+
speakerAssignments?: MeetingSpeakerAssignment[] | null;
|
|
1289
|
+
scheduledAt: string | null;
|
|
1290
|
+
scheduledEndAt?: string | null;
|
|
1291
|
+
timezone?: string | null;
|
|
1292
|
+
calendarEventId: number | null;
|
|
1293
|
+
startedAt: string | null;
|
|
1294
|
+
endedAt: string | null;
|
|
1295
|
+
createdAt: string;
|
|
1296
|
+
};
|
|
1297
|
+
type MeetingStatus = 'active' | 'completed' | 'analyzed' | 'scheduled' | 'cancelled';
|
|
1298
|
+
type MeetingConferenceProvider = 'google_meet' | 'teams' | 'zoom';
|
|
1299
|
+
type MeetingFeature = 'transcription' | 'summary' | 'insights' | 'actions';
|
|
1300
|
+
type MeetingJoinTeam = {
|
|
1301
|
+
slug: string;
|
|
1302
|
+
name: string;
|
|
1303
|
+
logo: string | null;
|
|
1304
|
+
place?: TeamPlace | null;
|
|
1305
|
+
};
|
|
1306
|
+
type MeetingJoinInfo = {
|
|
1307
|
+
id: string;
|
|
1308
|
+
code: string;
|
|
1309
|
+
name: string | null;
|
|
1310
|
+
inviteUrl: string;
|
|
1311
|
+
agentName: string;
|
|
1312
|
+
team: MeetingJoinTeam;
|
|
1313
|
+
status: MeetingStatus;
|
|
1314
|
+
isPhysical: boolean;
|
|
1315
|
+
scheduledAt: string | null;
|
|
1316
|
+
scheduledEndAt: string | null;
|
|
1317
|
+
timezone: string;
|
|
1318
|
+
conferenceUrl: string | null;
|
|
1319
|
+
conferenceProvider: MeetingConferenceProvider | null;
|
|
1320
|
+
endedAt: string | null;
|
|
1321
|
+
canCancel: boolean;
|
|
1322
|
+
features: Record<MeetingFeature, boolean>;
|
|
1323
|
+
};
|
|
1324
|
+
type MeetingTranscriptEntry = {
|
|
1325
|
+
speaker: 'user' | 'agent';
|
|
1326
|
+
text: string;
|
|
1327
|
+
timestamp: string;
|
|
1328
|
+
};
|
|
1329
|
+
type MeetingUsage = {
|
|
1330
|
+
current: number;
|
|
1331
|
+
limit: number;
|
|
1332
|
+
reached: boolean;
|
|
1333
|
+
remainingWords: number | null;
|
|
1334
|
+
};
|
|
1335
|
+
type MeetingSummary = {
|
|
1336
|
+
content: string;
|
|
1337
|
+
};
|
|
1338
|
+
//#endregion
|
|
1339
|
+
//#region src/site/types.d.ts
|
|
1340
|
+
type SiteType = 'undefined' | 'shop';
|
|
1341
|
+
type SiteTeam = {
|
|
1342
|
+
name: string;
|
|
1343
|
+
slug: string;
|
|
1344
|
+
logoUrl: string | null;
|
|
1345
|
+
};
|
|
1346
|
+
type SiteAgent = {
|
|
1347
|
+
uuid: string | null;
|
|
1348
|
+
};
|
|
1349
|
+
type Site = {
|
|
1350
|
+
id: number;
|
|
1351
|
+
slug: string;
|
|
1352
|
+
name: string | null;
|
|
1353
|
+
url: string | null;
|
|
1354
|
+
type: SiteType;
|
|
1355
|
+
brandSlug: string | null;
|
|
1356
|
+
customDomain: string | null;
|
|
1357
|
+
enabled: boolean;
|
|
1358
|
+
contactId?: string | null;
|
|
1359
|
+
metricsSource?: string | null;
|
|
1360
|
+
metricsResource?: string | null;
|
|
1361
|
+
monthlyReport?: boolean;
|
|
1362
|
+
team: SiteTeam | null;
|
|
1363
|
+
agent: SiteAgent | null;
|
|
1364
|
+
settings: Record<string, JsonValue>;
|
|
1365
|
+
};
|
|
1366
|
+
type SiteRoute = {
|
|
1367
|
+
path: string;
|
|
1368
|
+
warp: string;
|
|
1369
|
+
label: WarpI18nText;
|
|
1370
|
+
nav?: boolean;
|
|
1371
|
+
hiddenFields?: string[];
|
|
1372
|
+
};
|
|
1373
|
+
type BrandSiteConfig = {
|
|
1374
|
+
enabled: boolean;
|
|
1375
|
+
auth?: boolean;
|
|
1376
|
+
indexPath: string;
|
|
1377
|
+
routes: SiteRoute[];
|
|
1378
|
+
name?: string;
|
|
1379
|
+
logoUrl?: string | null;
|
|
1380
|
+
};
|
|
1381
|
+
type SiteBrand = {
|
|
1382
|
+
slug: string;
|
|
1383
|
+
configureRoute: Pick<SiteRoute, 'path' | 'label'> | null;
|
|
1384
|
+
};
|
|
1385
|
+
type AggregatedRoute = {
|
|
1386
|
+
path: string;
|
|
1387
|
+
warp: string;
|
|
1388
|
+
label: WarpI18nText;
|
|
1389
|
+
nav?: boolean;
|
|
1390
|
+
hiddenFields?: string[];
|
|
1391
|
+
moduleSlug?: string;
|
|
1392
|
+
};
|
|
1393
|
+
//#endregion
|
|
1382
1394
|
//#region src/billing/types.d.ts
|
|
1383
1395
|
type TranslatableValue = Partial<Record<WarpLocale, string>>;
|
|
1384
1396
|
type OrderStatus = 'pending' | 'confirmed' | 'processing' | 'shipped' | 'completed' | 'delivered' | 'canceled' | 'returned';
|
|
@@ -2312,6 +2324,11 @@ type ArtifactDeliverPayload = {
|
|
|
2312
2324
|
contactIds?: string[];
|
|
2313
2325
|
agentId?: string;
|
|
2314
2326
|
};
|
|
2327
|
+
type ArtifactDeliveryPreview = {
|
|
2328
|
+
subject: string | null;
|
|
2329
|
+
integration: ArtifactDeliverIntegration;
|
|
2330
|
+
message: string;
|
|
2331
|
+
};
|
|
2315
2332
|
type ArtifactDelivery = {
|
|
2316
2333
|
id: string;
|
|
2317
2334
|
contactId: string;
|
|
@@ -2336,6 +2353,7 @@ type Service = {
|
|
|
2336
2353
|
digital: boolean;
|
|
2337
2354
|
public: boolean;
|
|
2338
2355
|
bookable: boolean;
|
|
2356
|
+
order?: number | null;
|
|
2339
2357
|
taxClassId?: string | null;
|
|
2340
2358
|
settings?: Record<string, unknown> | null;
|
|
2341
2359
|
createdAt: string;
|
|
@@ -2758,6 +2776,39 @@ declare const cartLineTotal: <T extends CartLine>(items: T[]) => number;
|
|
|
2758
2776
|
declare const cartPayableTotal: <T extends CartLine>(items: T[], discountCents?: number) => number;
|
|
2759
2777
|
declare const isCompleteAddressInput: (address: Pick<AddressInput, "name" | "addressOne" | "city" | "zipCode" | "country">) => boolean;
|
|
2760
2778
|
//#endregion
|
|
2779
|
+
//#region src/commerce/returns.d.ts
|
|
2780
|
+
/** Pickup "collected" is `delivered`; goods must have left the shop before a return makes sense. */
|
|
2781
|
+
declare const RETURNABLE_FULFILLMENT_STATUSES: readonly FulfillmentStatus[];
|
|
2782
|
+
type ReturnableItem = {
|
|
2783
|
+
item: OrderItem;
|
|
2784
|
+
orderItemId: number;
|
|
2785
|
+
quantity: number; /** Prefer this fulfillment when creating the return; null when quantity spans multiple. */
|
|
2786
|
+
fulfillmentId: string | null;
|
|
2787
|
+
};
|
|
2788
|
+
type ReturnCreatePayload = {
|
|
2789
|
+
fulfillmentId?: string;
|
|
2790
|
+
items: {
|
|
2791
|
+
orderItemId: number;
|
|
2792
|
+
quantity: number;
|
|
2793
|
+
condition?: string;
|
|
2794
|
+
}[];
|
|
2795
|
+
};
|
|
2796
|
+
/** Physical quantities of a paid order that were shipped/delivered and are not yet in a non-rejected return. */
|
|
2797
|
+
declare const getReturnableItems: (order: Pick<Order, "items" | "status" | "fulfillments" | "returns">, returns?: Pick<Return, "status" | "items" | "fulfillmentId">[]) => ReturnableItem[];
|
|
2798
|
+
/**
|
|
2799
|
+
* Split selected return quantities into create payloads, one per fulfillment when possible.
|
|
2800
|
+
* Quantities without a single fulfillment go in an unscoped payload.
|
|
2801
|
+
*/
|
|
2802
|
+
declare const buildReturnCreatePayloads: (order: Pick<Order, "items" | "status" | "fulfillments" | "returns">, selected: {
|
|
2803
|
+
orderItemId: number;
|
|
2804
|
+
quantity: number;
|
|
2805
|
+
condition?: string;
|
|
2806
|
+
}[], returns?: Pick<Return, "status" | "items" | "fulfillmentId">[]) => ReturnCreatePayload[];
|
|
2807
|
+
/** Customer-paid amount for returned units (includes proportional tax when prices are net). */
|
|
2808
|
+
declare const getReturnRefundAmount: (order: Pick<Order, "items" | "total"> & {
|
|
2809
|
+
priceMode?: OrderPriceMode | null;
|
|
2810
|
+
}, request: Pick<Return, "items" | "suggestedRefundAmount" | "refundAmount">, alreadyRefunded?: number) => number;
|
|
2811
|
+
//#endregion
|
|
2761
2812
|
//#region src/budget/types.d.ts
|
|
2762
2813
|
type Budget = {
|
|
2763
2814
|
id: number;
|
|
@@ -4267,6 +4318,96 @@ type LoyaltyProgram = {
|
|
|
4267
4318
|
rewardCount: number;
|
|
4268
4319
|
tierCount: number;
|
|
4269
4320
|
memberCount: number;
|
|
4321
|
+
rewards?: LoyaltyReward[];
|
|
4322
|
+
tiers?: LoyaltyTier[]; /** Public view: collectable points only. Team view: all of them (edit through `updateProgram` settings.collect_points). */
|
|
4323
|
+
collectPoints?: LoyaltyCollectPoint[];
|
|
4324
|
+
};
|
|
4325
|
+
type LoyaltyCollectLimit = 'once' | 'daily' | 'per_window';
|
|
4326
|
+
/** `daily`: the code changes every calendar day (team timezone, hard cut at midnight), so shared links stop working. */
|
|
4327
|
+
type LoyaltyCollectCodeRotation = 'none' | 'daily';
|
|
4328
|
+
type LoyaltyCollectPoint = {
|
|
4329
|
+
id: number;
|
|
4330
|
+
key: string;
|
|
4331
|
+
name: string;
|
|
4332
|
+
source: string;
|
|
4333
|
+
points: number;
|
|
4334
|
+
limit: LoyaltyCollectLimit;
|
|
4335
|
+
windowMinutes: number | null;
|
|
4336
|
+
startsAt: string | null;
|
|
4337
|
+
endsAt: string | null;
|
|
4338
|
+
active: boolean;
|
|
4339
|
+
requiresCode: boolean; /** Present on every program view. `daily` means the code changes each team calendar day. */
|
|
4340
|
+
codeRotation: LoyaltyCollectCodeRotation;
|
|
4341
|
+
meta: Record<string, JsonValue> | null;
|
|
4342
|
+
/**
|
|
4343
|
+
* Staff / team program view only (`loyalty.getProgram()` without `team`), and only when
|
|
4344
|
+
* `codeRotation` is `daily`: the code valid right now. Signed-in team members only: never on the public or customer
|
|
4345
|
+
* view, and never for agent auth keys — do not rely on it there.
|
|
4346
|
+
*/
|
|
4347
|
+
codeToday?: string; /** Same visibility as `codeToday` (signed-in team members only): when it stops working (next midnight in the team timezone). */
|
|
4348
|
+
codeValidUntil?: string; /** Only for a signed-in customer with an account: a collect now would answer `already` (respects the limit window). */
|
|
4349
|
+
collected?: boolean; /** Only for a signed-in customer: their latest collect at this point, also from earlier windows. */
|
|
4350
|
+
collectedAt?: string | null; /** Only for a signed-in customer: when the next window opens while `collected` (daily / per_window). */
|
|
4351
|
+
nextAvailableAt?: string | null;
|
|
4352
|
+
};
|
|
4353
|
+
/**
|
|
4354
|
+
* One entry of `settings.collect_points` in `updateProgram`. The list replaces all collect points; entries match by key.
|
|
4355
|
+
* Omit `code` to keep the existing one, `null` removes it. `codeRotation: 'daily'` replaces a fixed code with a daily
|
|
4356
|
+
* code (do not send `code` then); omit `codeRotation` to keep the current mode.
|
|
4357
|
+
*/
|
|
4358
|
+
type LoyaltyCollectPointInput = {
|
|
4359
|
+
key: string;
|
|
4360
|
+
name: string;
|
|
4361
|
+
source: string;
|
|
4362
|
+
points: number;
|
|
4363
|
+
limit?: LoyaltyCollectLimit;
|
|
4364
|
+
windowMinutes?: number | null;
|
|
4365
|
+
startsAt?: string | null;
|
|
4366
|
+
endsAt?: string | null;
|
|
4367
|
+
active?: boolean;
|
|
4368
|
+
code?: string | null;
|
|
4369
|
+
codeRotation?: LoyaltyCollectCodeRotation;
|
|
4370
|
+
meta?: Record<string, JsonValue> | null;
|
|
4371
|
+
};
|
|
4372
|
+
type LoyaltyWalletAccount = {
|
|
4373
|
+
contactId: string;
|
|
4374
|
+
team: {
|
|
4375
|
+
slug: string;
|
|
4376
|
+
name: string;
|
|
4377
|
+
logoUrl: string | null;
|
|
4378
|
+
};
|
|
4379
|
+
program: {
|
|
4380
|
+
name: string;
|
|
4381
|
+
settings: ProgramSettings;
|
|
4382
|
+
};
|
|
4383
|
+
points: number;
|
|
4384
|
+
lifetimePoints: number;
|
|
4385
|
+
tier: {
|
|
4386
|
+
name: string;
|
|
4387
|
+
multiplier: number;
|
|
4388
|
+
} | null;
|
|
4389
|
+
rewards: LoyaltyReward[];
|
|
4390
|
+
updatedAt: string;
|
|
4391
|
+
};
|
|
4392
|
+
type LoyaltyJoinResponse = {
|
|
4393
|
+
joined: boolean;
|
|
4394
|
+
account: LoyaltyWalletAccount;
|
|
4395
|
+
};
|
|
4396
|
+
type LoyaltyCollectResponse = {
|
|
4397
|
+
collected: boolean;
|
|
4398
|
+
already: boolean;
|
|
4399
|
+
joined: boolean;
|
|
4400
|
+
points: number;
|
|
4401
|
+
balance: number;
|
|
4402
|
+
lifetimePoints: number;
|
|
4403
|
+
tier: string | null;
|
|
4404
|
+
nextAvailableAt: string | null;
|
|
4405
|
+
collectPoint: {
|
|
4406
|
+
id: number;
|
|
4407
|
+
key: string;
|
|
4408
|
+
name: string;
|
|
4409
|
+
source: string;
|
|
4410
|
+
};
|
|
4270
4411
|
};
|
|
4271
4412
|
type LoyaltyReward = {
|
|
4272
4413
|
id: string;
|
|
@@ -4335,6 +4476,8 @@ type LoyaltyTransaction = {
|
|
|
4335
4476
|
points: number;
|
|
4336
4477
|
balanceAfter: number;
|
|
4337
4478
|
description: string | null;
|
|
4479
|
+
collectPointId?: number | null;
|
|
4480
|
+
expiresAt?: string | null;
|
|
4338
4481
|
createdAt: string;
|
|
4339
4482
|
};
|
|
4340
4483
|
type EarnResponse = {
|
|
@@ -4384,6 +4527,45 @@ type LoyaltyMember = {
|
|
|
4384
4527
|
updatedAt: string;
|
|
4385
4528
|
};
|
|
4386
4529
|
//#endregion
|
|
4530
|
+
//#region src/install/types.d.ts
|
|
4531
|
+
type InstallPlatform = 'ios' | 'android' | 'web';
|
|
4532
|
+
type InstallPushStatus = 'subscribed' | 'opted_out' | 'unavailable';
|
|
4533
|
+
type PushProvider = 'onesignal';
|
|
4534
|
+
type Install = {
|
|
4535
|
+
id: string;
|
|
4536
|
+
platform: InstallPlatform;
|
|
4537
|
+
pushProvider: PushProvider;
|
|
4538
|
+
pushProviderRef: string;
|
|
4539
|
+
pushStatus: InstallPushStatus;
|
|
4540
|
+
appBundleId: string | null;
|
|
4541
|
+
userId: string | null;
|
|
4542
|
+
contactId: string | null;
|
|
4543
|
+
lastSeenAt: string | null;
|
|
4544
|
+
createdAt: string | null;
|
|
4545
|
+
updatedAt: string | null;
|
|
4546
|
+
};
|
|
4547
|
+
type InstallRegisterPayload = {
|
|
4548
|
+
pushProvider: PushProvider;
|
|
4549
|
+
pushProviderRef: string;
|
|
4550
|
+
platform: InstallPlatform;
|
|
4551
|
+
pushStatus?: InstallPushStatus;
|
|
4552
|
+
appBundleId?: string | null;
|
|
4553
|
+
locale?: string | null;
|
|
4554
|
+
version?: string | null;
|
|
4555
|
+
model?: string | null;
|
|
4556
|
+
os?: string | null;
|
|
4557
|
+
};
|
|
4558
|
+
type InstallClaimPayload = {
|
|
4559
|
+
pushProvider: PushProvider;
|
|
4560
|
+
pushProviderRef: string;
|
|
4561
|
+
};
|
|
4562
|
+
type InstallOptOutPayload = {
|
|
4563
|
+
pushProvider: PushProvider;
|
|
4564
|
+
pushProviderRef: string;
|
|
4565
|
+
pushStatus?: Extract<InstallPushStatus, 'opted_out' | 'unavailable'>;
|
|
4566
|
+
platform?: InstallPlatform;
|
|
4567
|
+
};
|
|
4568
|
+
//#endregion
|
|
4387
4569
|
//#region src/segment/types.d.ts
|
|
4388
4570
|
type SegmentConditionType = 'tag' | 'has_email' | 'has_phone' | 'has_user' | 'last_purchase_after' | 'last_purchase_before' | 'total_order_amount' | 'order_count_at_least' | 'never_purchased' | 'avg_order_value_at_least' | 'last_contact_after' | 'last_contact_before' | 'waiting_on' | 'created_after' | 'created_before' | 'email_contains' | 'prop' | 'marketing_opt_out';
|
|
4389
4571
|
type SegmentCondition = {
|
|
@@ -4571,9 +4753,14 @@ type UpdateStats = {
|
|
|
4571
4753
|
//#region src/social-post/types.d.ts
|
|
4572
4754
|
type SocialPostPlatform = 'instagram' | 'x' | 'facebook' | 'linkedin';
|
|
4573
4755
|
type SocialPostStatus = 'draft' | 'scheduled' | 'publishing' | 'published' | 'failed' | 'cancelled';
|
|
4756
|
+
type SocialPostAccount = {
|
|
4757
|
+
id: string;
|
|
4758
|
+
displayName: string;
|
|
4759
|
+
};
|
|
4574
4760
|
type SocialPost = {
|
|
4575
4761
|
id: string;
|
|
4576
4762
|
platform: SocialPostPlatform;
|
|
4763
|
+
accountId: string | null;
|
|
4577
4764
|
status: SocialPostStatus;
|
|
4578
4765
|
body: string | null;
|
|
4579
4766
|
media: Media[];
|
|
@@ -4601,6 +4788,7 @@ type SharedSocialPost = {
|
|
|
4601
4788
|
};
|
|
4602
4789
|
type SocialPostCreatePayload = {
|
|
4603
4790
|
platform: SocialPostPlatform;
|
|
4791
|
+
accountId?: string | null;
|
|
4604
4792
|
body?: string | null;
|
|
4605
4793
|
media?: string[];
|
|
4606
4794
|
exportId?: string | null;
|
|
@@ -4627,6 +4815,7 @@ type SocialPostConnection = {
|
|
|
4627
4815
|
platform: SocialPostPlatform;
|
|
4628
4816
|
connected: boolean;
|
|
4629
4817
|
displayName: string | null;
|
|
4818
|
+
accounts: SocialPostAccount[];
|
|
4630
4819
|
minImages: number;
|
|
4631
4820
|
maxImages: number;
|
|
4632
4821
|
maxBodyLength: number;
|
|
@@ -4717,6 +4906,7 @@ declare const PermissionPresetNames: {
|
|
|
4717
4906
|
readonly SecretManage: "secretManage";
|
|
4718
4907
|
readonly TeamMemberInvite: "teamMemberInvite";
|
|
4719
4908
|
readonly TeamMemberRemove: "teamMemberRemove";
|
|
4909
|
+
readonly TeamMemberRole: "teamMemberRole";
|
|
4720
4910
|
readonly AgentWalletManage: "agentWalletManage";
|
|
4721
4911
|
readonly SwarmCreate: "swarmCreate";
|
|
4722
4912
|
};
|
|
@@ -4744,7 +4934,7 @@ type RampProviderInfo = {
|
|
|
4744
4934
|
active: boolean;
|
|
4745
4935
|
};
|
|
4746
4936
|
//#endregion
|
|
4747
|
-
//#region src/
|
|
4937
|
+
//#region src/hooks/types.d.ts
|
|
4748
4938
|
type HookTriggerCondition = {
|
|
4749
4939
|
path: string;
|
|
4750
4940
|
operator: 'exists' | 'equals' | 'contains' | 'not_contains';
|
|
@@ -4763,6 +4953,8 @@ type HookTrigger = {
|
|
|
4763
4953
|
when?: HookTriggerCondition[];
|
|
4764
4954
|
inputs?: Record<string, HookTriggerInput>;
|
|
4765
4955
|
};
|
|
4956
|
+
type InternalHookTriggerEvent = 'contact.created' | 'contact.updated' | 'update.created';
|
|
4957
|
+
declare const INTERNAL_HOOK_TRIGGER_EVENTS: readonly ["contact.created", "contact.updated", "update.created"];
|
|
4766
4958
|
type WebHookTriggerEvent = 'agent.action' | 'agent.message' | 'agent.activity' | 'user.message' | 'external.message';
|
|
4767
4959
|
type Hook = {
|
|
4768
4960
|
id: string;
|
|
@@ -4905,4 +5097,4 @@ type CliSessionStatus = {
|
|
|
4905
5097
|
meta: CliSessionMeta | null;
|
|
4906
5098
|
};
|
|
4907
5099
|
//#endregion
|
|
4908
|
-
export { AUTOMATION_SEND_CHANNELS, Achievement, Address, AddressCreatePayload, AddressInput, AddressSnapshot, type AddressType, AddressTypes, AddressUpdatePayload, Affiliate, AffiliateStatus, AffiliateTier, AffiliateTierName, Agent, AgentActionHistoryEntry, AgentCharacter, AgentDelegatable, AgentEngine, AgentExecuteHandler, AgentExecuteOptions, AgentGender, AgentMessageMeta, AgentMessageOptions, AgentPrivate, AgentSettings, AgentSetupTarget, AgentSimple, AgentToolingAccess, AgentTrustedActionRule, AgentWalletMode, AggregatedRoute, AiCostEntry, AiCostsResponse, AiCostsSummary, Alert, ApiToken, AppAccessRule, AppEnv, AppFile, AppFileType, AppIngestion, AppSetupTarget, AppendKvEntryResult, AppointmentAvailability, AppointmentAvailabilityService, AppointmentAvailabilitySlot, AppointmentBooking, AppointmentBookingContext, AppointmentPolicy, AppointmentPolicySync, AppointmentPolicyUpsert, AppointmentRequest, AppointmentSlot, Artifact, ArtifactBlock, ArtifactBlockType, ArtifactContactSummary, ArtifactCreatePayload, ArtifactDeliverIntegration, ArtifactDeliverPayload, ArtifactDelivery, ArtifactLink, ArtifactStatus, ArtifactType, ArtifactUpdatePayload, AuthUser, Automation, AutomationAction, AutomationActionConfig, AutomationActionInput, AutomationActionType, AutomationAudiencePreview, AutomationCreatePayload, AutomationEnrollment, AutomationEnrollmentChange, AutomationEnrollmentStatus, AutomationEnrollmentUpdatedPayload, AutomationSendChannel, AutomationSendChannelId, AutomationSkipReason, AutomationStats, AutomationTriggerConfig, AutomationTriggerType, AutomationUpdatePayload, BillingManageAccess, Blueprint, BlueprintOnboardingStep, BlueprintRedirect, BlueprintSettings, BlueprintShortcut, BlueprintTask, BlueprintTeam, BoardSummaryViewable, BookmarkEntry, BrandBackend, BrandIntegration, BrandIntegrationAction, BrandIntegrationProvider, BrandSearchHit, BrandSiteConfig, BrandSourceConfig, Budget, ByokProviderConfig, ByokProviderName, ByokProviders, CAMPAIGN_CHANNELS, CONTACT_MESSAGE_SEND_WARP, CalendarProvider, CalendarStatus, Campaign, CampaignApproval, CampaignAudiencePreview, CampaignAudiencePreviewPayload, CampaignCategory, CampaignChannel, CampaignChannelId, CampaignCreatePayload, CampaignRecipient, CampaignRecipientStatus, CampaignSkipReason, CampaignSkipReasons, CampaignStats, CampaignStatus, CampaignUpdatePayload, Card, Cart, CartItem, CartLine, Challenge, Challenges, ChangelogEntry, Character, ChatClientAction, ChatClientThought, ChatStreamData, ChatStreamEventType, CheckoutSnapshot, CheckoutSnapshotRequest, CliSessionMeta, CliSessionStatus, CommissionAgreement, Configuration, Contact, ContactActivity, ContactActivityAuthor, ContactActivityType, ContactConsent, ContactConsentStatus, ContactCreatePayload, ContactFormData, ContactHealth, ContactRelation, ContactRelationCategory, ContactRelationContact, ContactRelationDirection, ContactRelationPayload, ContactRelationType, ContactRelationUpdatePayload, ContactViewable, Content, ContentDefinition, ContentEntry, ContentField, ContentFieldType, ContentPatch, ContentStatus, ContentValue, ContentVersion, Contract, ContractCategoryDisplayNames, ContractCategoryName, ContractCodeMetadata, ContractEntity, ContractOnNetwork, ContractVersion, ContractsAddressConfig, CortexExecuteOptions, Coupon, CouponCondition, CouponRestrictedItem, CouponRestrictedItemType, CreateContentInput, CreateHookPayload, CreateInboundHookPayload, CreateInternalHookPayload, CreateKvFieldPayload, CreateWarpLinkedHookPayload, CreateWebHookPayload, DefaultAppLocale, DefaultCodeMetadata, DefaultInviteTeamRole, DemoFlow, DemoMessage, Desk, DeskItem, DeskItemRole, Document, EarnResponse, Earning, Element, ElementSpec, ElementType, ElementVariation, EmailProvider, EmbedStatus, EncryptionStatus, Entity, EntityDirectExecuteRequest, EntityProposable, EntitySignable, EntityTemplate, Experience, FeatureSetupTarget, FileInfo, FileMetadata, Flow, FlowCategory, FlowInputMapping, FlowStatus, FlowStep, Fulfillment, FulfillmentFlowAction, FulfillmentFlowStep, FulfillmentLocation, type FulfillmentMethod, FulfillmentMethods, type FulfillmentStatus, FulfillmentStatuses, GamificationData, GamificationEventType, Goal, GoalCreatePayload, GoalPriority, GoalProgressViewable, GoalStatus, GuestBuyer, HintOptions, HintPosition, Hook, HookSample, HookTrigger, HookTriggerCondition, HookTriggerInput, HttpService, IAppResponse, IHttpService, IRequestOptions, ImageCompressionOptions, ImageCropOptions, ImageCropRectangle, ImageCropState, ImageDimensionRules, ImageDimensions, IngestionSourceType, IngestionStatus, Inquiry, InquiryStatus, InquiryType, Integration, IntegrationConnectionDetails, IntegrationDetails, IntegrationMeta, IntegrationType, Intent, InviteableTeamRoles, Item, ItemCreatePayload, ItemExecutionStatus, ItemPriority, ItemStatus, ItemUpdatePayload, ItemViewable, JoaiUrls, JsonValue, KvEntry, KvEntryPayload, KvField, KvFieldWithEntries, KvValue, Kyc, KycStatus, Link, LinkCreatePayload, LinkScanHistory, LinkStats, LinkUpdatePayload, LinkVariation, LinkVariationBatchCreatePayload, LinkVariationCreatePayload, LocalAgentWallet, LoyaltyAccount, LoyaltyMember, LoyaltyNextTier, LoyaltyProgram, LoyaltyPromotion, LoyaltyReward, LoyaltyStatus, LoyaltyTier, LoyaltyTierInfo, LoyaltyTransaction, McpToolCall, McpToolCallBroadcast, McpToolCallStatus, Media, MediaAspectRatio, MediaAttributes, MediaItems, MediaLibraryAttributes, MediaMime, Meeting, MeetingConferenceProvider, MeetingFeature, MeetingJoinInfo, MeetingJoinTeam, MeetingParticipant, MeetingSessionState, MeetingSpeakerAssignment, MeetingStatus, MeetingSummary, MeetingTranscriptEntry, MeetingUsage, Memory, Message, MessageId, MessageRole, Metric, MetricSource, MetricsResult, Milestone, MilestoneType, Mission, MissionBudget, MissionCreatePayload, MissionPlan, MissionPriority, MissionSchedule, MissionStatus, MissionViewable, MollieTerminalPaymentResult, MultimodalContent, MultimodalFile, NATIVE_AUTH_TOKEN_PARAM, NativeApp, NativeApps, Notification, NotificationAction, NotificationAgent, NotificationChannel, NotificationSetting, OG_IMAGE_CONFIG, OG_IMAGE_HEIGHT, OG_IMAGE_WIDTH, ORDER_FULFILLMENT_STATUSES, ORDER_POST_CHECKOUT_STATUSES, OUTBOUND_CHANNELS, OfficeAgent, OfficeEntity, OfficeEntityKind, OfficeLiveOverrides, OfficeMember, OfficeSnapshot, OfficeStatus, OfficeStatusFilter, OfficeTypeFilter, OgImageColors, Order, OrderConfigurationItem, OrderContext, OrderItem, OrderPriceMode, OrderSource, OrderStatus, OrderStatusDisplay, OrderType, OutboundChannel, OutboundChannelId, PLATFORM_CURRENCY, PaginatedResponse, Pass, PatchContentInput, PaymentAccount, PaymentAccountOnboarding, PaymentProvider, PayoutEntry, PeriodTypeLabels, PeriodTypeOptions, PermissionConfigType, PermissionPresetName, PermissionPresetNames, PersonaQuestionable, PickupNextAction, Plan, PlanBenefit, PlanExtra, PlanFeature, PlanInterval, PolicyMethod, PolicySetting, PricingModel, Product, ProductDetailKind, ProductDetailRow, ProductDetailSection, ProductDetailText, ProductDiscount, ProductMeta, ProductPieces, ProductRating, ProductRelation, ProductRelationType, ProductVariation, ProductVariationMeta, ProductVariationType, ProgramSettings, Project, ProjectAspectRatio, ProjectAssembly, ProjectCaptionStyle, ProjectClipCandidate, ProjectClips, ProjectExport, ProjectExportAsset, ProjectExportResponse, ProjectImages, ProjectInputAssistIntent, ProjectInputAssistResponse, ProjectMutation, ProjectOutputPreset, ProjectOutputType, ProjectPlan, ProjectRender, ProjectRenderMode, ProjectSelectedClip, ProjectShot, ProjectSoundtrack, ProjectSourceMedia, ProjectStatus, ProjectStudioHistoryEntry, ProjectStudioQuestion, ProjectStudioResponse, ProjectStudioStage, ProjectStudioState, ProjectStudioSummary, ProjectStyleDirection, ProjectTranscript, ProjectTranscriptSegment, Proposal, ProposalAction, ProposalActionPayment, ProposalActionPaymentSerializable, ProposalActionSerializable, ProposalPollOption, ProposalStatus, PublicFormResults, PurchaseOptions, PurchaseResult, RampProvider, RampProviderInfo, Reactions, RecentExperience, RedeemResponse, Reminder, Return, type ReturnStatus, ReturnStatuses, ReturnUpdateStatus, ReturnUpdateStatuses, Room, RoomId, RoomKind, ScInfo, SchedulePreset, SecretAuthorizable, SecretSettable, Segment, SegmentCondition, SegmentConditionType, SegmentCountPayload, SegmentCountResult, SegmentCreatePayload, SegmentGroup, SendableActivityUpdate, SendableAgentAction, SendableAgentMessage, SendableAgentThought, SendableMedia, SendableUserMessage, Service, SetKvEntryResult, SharedSocialPost, ShippingCarrierOption, ShippingRate, ShippingZone, Shortcut, Site, SiteAgent, SiteBrand, SiteRoute, SiteTeam, SiteType, Skill, SkillMediaBindingRole, SkillMediaBindingRoleValue, SkillScope, SkillScopeValue, SkillType, SkillTypeValue, SocialAuthProvider, SocialBot, SocialPlatform, SocialPost, SocialPostConnection, SocialPostCreatePayload, SocialPostGenerateCaptionPayload, SocialPostGeneratedCaption, SocialPostPlatform, SocialPostStatus, SocialPostUpdatePayload, StampResponse, StoreAgent, StoreCheckoutItem, StoreData, StoreEntityType, StoreInfo, StoreItem, StoreListing, StorePriceTier, StorePricing, StorePurchasable, StorePurchaseResult, Streak, Subscription, SubscriptionDelivery, SubscriptionInterval, SubscriptionPlan, SubscriptionStatus, SupportedAppLocale, SupportedAppLocales, Swarm, Tag, TagType, Task, TaxBreakdownRow, TaxClass, Team, TeamAccessCatalog, TeamAccessConfig, TeamBrand, TeamCategory, TeamCurrencySource, TeamEarning, TeamEarningsBalance, TeamFeature, TeamFeatureAccess, TeamFeatureArea, TeamFeatureUsage, TeamManageAccess, TeamMember, TeamMeta, TeamOrderStats, TeamPayout, TeamPayoutAddress, TeamPlace, TeamPrivate, TeamSettings, TeamUsage, TeamViewAccess, TerminalConnectionToken, TerminalPaymentIntent, Tier, TierFeature, TierName, ToggleKvFieldResult, TranscriptEntry, TranscriptionCorrection, TranscriptionResponse, TranslatableValue, UNIFIED_MCP_SERVER_NAME, Update, UpdateCreatePayload, UpdateRelation, UpdateStats, UpdateStatus, UpdateType, UpdateUpdatePayload, Upgrade, UpgradeSourceType, UpgradeStatus, User, UserInterest, UserMode, type UserPermission, UserPermissions, UserPrivate, type UserRole, UserRoles, UserSettings, UserSocialAccount, UserStats, VolumePrice, Wallet, WalletList, WarpApprovable, WarpBackend, WarpBackendStatus, WarpBatchItem, WarpBatchable, WarpCloudExecutable, WarpCreateable, WarpExecutable, WarpExecutionBackend, WarpExtras, WarpExtrasFaq, WarpInputable, WarpScreenshotVariant, WarpSearchHit, WarpSelectable, WarpSelectableDetails, WarpSuggestion, WarpTestable, WarpViewable, WebHookTriggerEvent, WorkspaceCloudFile, WorkspaceContext, WorkspaceInfo, WorkspaceSettings, XIntegrationStatus, abbreviateNumber, addressTypeValues, automationSendChannel, buildAgentMcpServerName, buildAgentSetupClipboardText, buildAppSetupClipboardText, buildFeatureSetupClipboardText, buildMcpServerName, canOpenFulfillmentFlow, canTransitionOrderStatus, cartLineTotal, cartPayableTotal, containedImageDimensions, createCursorMcpInstallLink, cropOutputDimensions, defaultInviteTeamRole, documentShareUrl, firstValidationMessage, formatAddressSnapshotLines, fulfillmentMethodValues, fulfillmentStatusValues, getAgentSetupPromptUrl, getAgentsBaseUrl, getApiBaseUrl, getAppBaseUrl, getAssetAppLogoUrl, getAssetChainLogoUrl, getAssetPartnerLogoUrl, getAssetTokenLogoUrl, getAssetWalletLogoUrl, getCortexBaseUrl, getDigestBaseUrl, getDocumentsBaseUrl, getEditableOrderStatuses, getFormsBaseUrl, getFulfillmentFlowAction, getFulfillmentFlowStepperIndex, getGenBaseUrl, getInvoiceEditableStatuses, getLoginUrl, getMcpServerAgentUrl, getMcpServerUrl, getPickupEditableStatuses, getPickupNextAction, getShippingEditableStatuses, getSiteUrl, getSitesBaseUrl, getSitesRootDomain, getStoreBaseUrl, getWarpScreenshotUrl, hasAllPermissions, hasAllTeamPermissions, hasAnyPermissions, hasPermission, hasTeamPermission, imageCropRectangle, integrationSlugForChannel, inviteableTeamRoles, isAutomationSendChannelId, isCampaignChannelId, isCompleteAddressInput, isContactMessageAction, isContactMessageWarpId, isFileFormatAudio, isFileFormatImage, isFileFormatVideo, isNativeApp, isNativeAppAccessible, isNativeAppGated, isNativeAppLocked, isOrderCanceled, isOrderInFulfillment, isOrderPending, isOrderPostCheckout, isPickupOrderReady, isPickupReady, isSupportedAppLocale, isTeamFeatureAccessible, isTeamFeatureGated, isTeamFeatureLocked, isUnifiedMcpUrl, isUserRole, localize, nativeAppSlugs, normalizeAutomationActionType, ogImageUrl, outboundChannel, permissionPresetRules, resolveAccessCatalog, resolveAgentMcpUrl, resolveConnectMcpUrl, resolveFulfillmentFlowStep, resolveOrderStatusDisplay, resolveTeamCurrency, resolveWarpText, returnStatusValues, returnUpdateStatusValues, sanitizeAlphanumeric, sanitizeNumeric, slugifyMcpSegment, teamCategories, toCurrencyDisplay, toHexEncodedNonce, toNameInitials, toNftId, toPreviewText, userPermissionValues, userRoleValues, validateImageDimensions, validationMessageFor, withRetry };
|
|
5100
|
+
export { AUTOMATION_SEND_CHANNELS, Achievement, Address, AddressCreatePayload, AddressInput, AddressSnapshot, type AddressType, AddressTypes, AddressUpdatePayload, Affiliate, AffiliateStatus, AffiliateTier, AffiliateTierName, Agent, AgentActionHistoryEntry, AgentCharacter, AgentDelegatable, AgentEngine, AgentExecuteHandler, AgentExecuteOptions, AgentGender, AgentMessageMeta, AgentMessageOptions, AgentPrivate, AgentSettings, AgentSetupTarget, AgentSimple, AgentToolingAccess, AgentTrustedActionRule, AgentWalletMode, AggregatedRoute, AiCostEntry, AiCostsResponse, AiCostsSummary, Alert, ApiToken, AppAccessRule, AppEnv, AppFile, AppFileType, AppIngestion, AppSetupTarget, AppendKvEntryResult, AppointmentAvailability, AppointmentAvailabilityService, AppointmentAvailabilitySlot, AppointmentBooking, AppointmentBookingContext, AppointmentPolicy, AppointmentPolicySync, AppointmentPolicyUpsert, AppointmentRequest, AppointmentSlot, Artifact, ArtifactBlock, ArtifactBlockType, ArtifactContactSummary, ArtifactCreatePayload, ArtifactDeliverIntegration, ArtifactDeliverPayload, ArtifactDelivery, ArtifactDeliveryPreview, ArtifactLink, ArtifactStatus, ArtifactType, ArtifactUpdatePayload, AssignableTeamRoles, AuthUser, Automation, AutomationAction, AutomationActionConfig, AutomationActionInput, AutomationActionType, AutomationAudiencePreview, AutomationCreatePayload, AutomationEnrollment, AutomationEnrollmentChange, AutomationEnrollmentStatus, AutomationEnrollmentUpdatedPayload, AutomationSendChannel, AutomationSendChannelId, AutomationSkipReason, AutomationStats, AutomationTriggerConfig, AutomationTriggerType, AutomationUpdatePayload, BillingManageAccess, Blueprint, BlueprintOnboardingStep, BlueprintRedirect, BlueprintSettings, BlueprintShortcut, BlueprintTask, BlueprintTeam, BoardSummaryViewable, BookmarkEntry, BrandBackend, BrandIntegration, BrandIntegrationAction, BrandIntegrationProvider, BrandSearchHit, BrandSiteConfig, BrandSourceConfig, Budget, ByokProviderConfig, ByokProviderName, ByokProviders, CAMPAIGN_CHANNELS, CONTACT_MESSAGE_SEND_WARP, CalendarProvider, CalendarStatus, Campaign, CampaignApproval, CampaignAudiencePreview, CampaignAudiencePreviewPayload, CampaignCategory, CampaignChannel, CampaignChannelId, CampaignCreatePayload, CampaignRecipient, CampaignRecipientStatus, CampaignSkipReason, CampaignSkipReasons, CampaignStats, CampaignStatus, CampaignUpdatePayload, Card, Cart, CartItem, CartLine, Challenge, Challenges, ChangelogEntry, Character, ChatClientAction, ChatClientThought, ChatStreamData, ChatStreamEventType, CheckoutSnapshot, CheckoutSnapshotRequest, CliSessionMeta, CliSessionStatus, CommissionAgreement, Configuration, Contact, ContactActivity, ContactActivityAuthor, ContactActivityType, ContactConsent, ContactConsentStatus, ContactCreatePayload, ContactFormData, ContactHealth, ContactRelation, ContactRelationCategory, ContactRelationContact, ContactRelationDirection, ContactRelationPayload, ContactRelationType, ContactRelationUpdatePayload, ContactViewable, Content, ContentDefinition, ContentEntry, ContentField, ContentFieldType, ContentPatch, ContentStatus, ContentValue, ContentVersion, Contract, ContractCategoryDisplayNames, ContractCategoryName, ContractCodeMetadata, ContractEntity, ContractOnNetwork, ContractVersion, ContractsAddressConfig, CortexExecuteOptions, Coupon, CouponCondition, CouponRestrictedItem, CouponRestrictedItemType, CreateContentInput, CreateHookPayload, CreateInboundHookPayload, CreateInternalHookPayload, CreateKvFieldPayload, CreateWarpLinkedHookPayload, CreateWebHookPayload, DefaultAppLocale, DefaultCodeMetadata, DefaultInviteTeamRole, DemoFlow, DemoMessage, Desk, DeskItem, DeskItemRole, Document, EarnResponse, Earning, Element, ElementSpec, ElementType, ElementVariation, EmailProvider, EmbedStatus, EncryptionStatus, Entity, EntityDirectExecuteRequest, EntityProposable, EntitySignable, EntityTemplate, Experience, FeatureSetupTarget, FileInfo, FileMetadata, Flow, FlowCategory, FlowInputMapping, FlowStatus, FlowStep, Fulfillment, FulfillmentFlowAction, FulfillmentFlowStep, FulfillmentLocation, type FulfillmentMethod, FulfillmentMethods, type FulfillmentStatus, FulfillmentStatuses, GamificationData, GamificationEventType, Goal, GoalCreatePayload, GoalPriority, GoalProgressViewable, GoalStatus, GuestBuyer, HintOptions, HintPosition, Hook, HookSample, HookTrigger, HookTriggerCondition, HookTriggerInput, HttpService, IAppResponse, IHttpService, INTERNAL_HOOK_TRIGGER_EVENTS, IRequestOptions, ImageCompressionOptions, ImageCropOptions, ImageCropRectangle, ImageCropState, ImageDimensionRules, ImageDimensions, IngestionSourceType, IngestionStatus, Inquiry, InquiryStatus, InquiryType, Install, InstallClaimPayload, InstallOptOutPayload, InstallPlatform, InstallPushStatus, InstallRegisterPayload, Integration, IntegrationConnectionDetails, IntegrationDetails, IntegrationMeta, IntegrationType, Intent, InternalHookTriggerEvent, InviteableTeamRoles, Item, ItemCreatePayload, ItemExecutionStatus, ItemPriority, ItemStatus, ItemUpdatePayload, ItemViewable, JoaiUrls, JsonValue, KvEntry, KvEntryPayload, KvField, KvFieldWithEntries, KvValue, Kyc, KycStatus, Link, LinkCreatePayload, LinkScanHistory, LinkStats, LinkUpdatePayload, LinkVariation, LinkVariationBatchCreatePayload, LinkVariationCreatePayload, LocalAgentWallet, LoyaltyAccount, LoyaltyCollectCodeRotation, LoyaltyCollectLimit, LoyaltyCollectPoint, LoyaltyCollectPointInput, LoyaltyCollectResponse, LoyaltyJoinResponse, LoyaltyMember, LoyaltyNextTier, LoyaltyProgram, LoyaltyPromotion, LoyaltyReward, LoyaltyStatus, LoyaltyTier, LoyaltyTierInfo, LoyaltyTransaction, LoyaltyWalletAccount, McpToolCall, McpToolCallBroadcast, McpToolCallStatus, Media, MediaAspectRatio, MediaAttributes, MediaItems, MediaLibraryAttributes, MediaMime, Meeting, MeetingConferenceProvider, MeetingFeature, MeetingJoinInfo, MeetingJoinTeam, MeetingParticipant, MeetingSessionState, MeetingSpeakerAssignment, MeetingStatus, MeetingSummary, MeetingTranscriptEntry, MeetingUsage, Memory, Message, MessageId, MessageRole, Metric, MetricSource, MetricsResult, Milestone, MilestoneType, Mission, MissionBudget, MissionCreatePayload, MissionPlan, MissionPriority, MissionSchedule, MissionStatus, MissionViewable, MollieTerminalPaymentResult, MultimodalContent, MultimodalFile, NATIVE_AUTH_TOKEN_PARAM, NativeApp, NativeApps, Notification, NotificationAction, NotificationAgent, NotificationChannel, NotificationSetting, OG_IMAGE_CONFIG, OG_IMAGE_HEIGHT, OG_IMAGE_WIDTH, ORDER_FULFILLMENT_STATUSES, ORDER_POST_CHECKOUT_STATUSES, OUTBOUND_CHANNELS, OfficeAgent, OfficeEntity, OfficeEntityKind, OfficeLiveOverrides, OfficeMember, OfficeSnapshot, OfficeStatus, OfficeStatusFilter, OfficeTypeFilter, OgImageColors, Order, OrderConfigurationItem, OrderContext, OrderItem, OrderPriceMode, OrderSource, OrderStatus, OrderStatusDisplay, OrderType, OutboundChannel, OutboundChannelId, PLATFORM_CURRENCY, PaginatedResponse, Pass, PatchContentInput, PaymentAccount, PaymentAccountOnboarding, PaymentProvider, PayoutEntry, PeriodTypeLabels, PeriodTypeOptions, PermissionConfigType, PermissionPresetName, PermissionPresetNames, PersonaQuestionable, PickupNextAction, Plan, PlanBenefit, PlanExtra, PlanFeature, PlanInterval, PolicyMethod, PolicySetting, PricingModel, Product, ProductDetailKind, ProductDetailRow, ProductDetailSection, ProductDetailText, ProductDiscount, ProductMeta, ProductPieces, ProductRating, ProductRelation, ProductRelationType, ProductVariation, ProductVariationMeta, ProductVariationType, ProgramSettings, Project, ProjectAspectRatio, ProjectAssembly, ProjectCaptionStyle, ProjectClipCandidate, ProjectClips, ProjectExport, ProjectExportAsset, ProjectExportResponse, ProjectImages, ProjectInputAssistIntent, ProjectInputAssistResponse, ProjectMutation, ProjectOutputPreset, ProjectOutputType, ProjectPlan, ProjectRender, ProjectRenderMode, ProjectSelectedClip, ProjectShot, ProjectSoundtrack, ProjectSourceMedia, ProjectStatus, ProjectStudioHistoryEntry, ProjectStudioQuestion, ProjectStudioResponse, ProjectStudioStage, ProjectStudioState, ProjectStudioSummary, ProjectStyleDirection, ProjectTranscript, ProjectTranscriptSegment, Proposal, ProposalAction, ProposalActionPayment, ProposalActionPaymentSerializable, ProposalActionSerializable, ProposalPollOption, ProposalStatus, PublicFormResults, PurchaseOptions, PurchaseResult, PushProvider, RETURNABLE_FULFILLMENT_STATUSES, RampProvider, RampProviderInfo, Reactions, RecentExperience, RedeemResponse, Reminder, Return, ReturnCreatePayload, type ReturnStatus, ReturnStatuses, ReturnUpdateStatus, ReturnUpdateStatuses, ReturnableItem, Room, RoomId, RoomKind, ScInfo, SchedulePreset, SecretAuthorizable, SecretSettable, Segment, SegmentCondition, SegmentConditionType, SegmentCountPayload, SegmentCountResult, SegmentCreatePayload, SegmentGroup, SendableActivityUpdate, SendableAgentAction, SendableAgentMessage, SendableAgentThought, SendableMedia, SendableUserMessage, Service, SetKvEntryResult, SharedSocialPost, ShippingCarrierOption, ShippingRate, ShippingZone, Shortcut, Site, SiteAgent, SiteBrand, SiteRoute, SiteTeam, SiteType, Skill, SkillMediaBindingRole, SkillMediaBindingRoleValue, SkillScope, SkillScopeValue, SkillType, SkillTypeValue, SocialAuthProvider, SocialBot, SocialPlatform, SocialPost, SocialPostAccount, SocialPostConnection, SocialPostCreatePayload, SocialPostGenerateCaptionPayload, SocialPostGeneratedCaption, SocialPostPlatform, SocialPostStatus, SocialPostUpdatePayload, StampResponse, StoreAgent, StoreCheckoutItem, StoreData, StoreEntityType, StoreInfo, StoreItem, StoreListing, StorePriceTier, StorePricing, StorePurchasable, StorePurchaseResult, Streak, Subscription, SubscriptionDelivery, SubscriptionInterval, SubscriptionPlan, SubscriptionStatus, SupportedAppLocale, SupportedAppLocales, Swarm, Tag, TagType, Task, TaxBreakdownRow, TaxClass, Team, TeamAccessCatalog, TeamAccessConfig, TeamBrand, TeamCategory, TeamCurrencySource, TeamEarning, TeamEarningsBalance, TeamFeature, TeamFeatureAccess, TeamFeatureArea, TeamFeatureUsage, TeamManageAccess, TeamMember, TeamMeta, TeamOrderStats, TeamPayout, TeamPayoutAddress, TeamPlace, TeamPrivate, TeamSettings, TeamUsage, TeamViewAccess, TerminalConnectionToken, TerminalPaymentIntent, Tier, TierFeature, TierName, ToggleKvFieldResult, TranscriptEntry, TranscriptionCorrection, TranscriptionResponse, TranslatableValue, UNIFIED_MCP_SERVER_NAME, Update, UpdateCreatePayload, UpdateRelation, UpdateStats, UpdateStatus, UpdateType, UpdateUpdatePayload, Upgrade, UpgradeSourceType, UpgradeStatus, User, UserInterest, UserMode, type UserPermission, UserPermissions, UserPrivate, type UserRole, UserRoles, UserSettings, UserSocialAccount, UserStats, VolumePrice, Wallet, WalletList, WarpApprovable, WarpBackend, WarpBackendStatus, WarpBatchItem, WarpBatchable, WarpCloudExecutable, WarpCreateable, WarpExecutable, WarpExecutionBackend, WarpExtras, WarpExtrasFaq, WarpInputable, WarpScreenshotVariant, WarpSearchHit, WarpSelectable, WarpSelectableDetails, WarpSuggestion, WarpTestable, WarpViewable, WebHookTriggerEvent, WorkspaceCloudFile, WorkspaceContext, WorkspaceInfo, WorkspaceSettings, XIntegrationStatus, abbreviateNumber, addressTypeValues, assignableTeamRoles, automationSendChannel, buildAgentMcpServerName, buildAgentSetupClipboardText, buildAppSetupClipboardText, buildFeatureSetupClipboardText, buildMcpServerName, buildReturnCreatePayloads, canOpenFulfillmentFlow, canTransitionOrderStatus, cartLineTotal, cartPayableTotal, containedImageDimensions, createCursorMcpInstallLink, cropOutputDimensions, defaultInviteTeamRole, documentShareUrl, firstValidationMessage, formatAddressSnapshotLines, fulfillmentMethodValues, fulfillmentStatusValues, getAgentSetupPromptUrl, getAgentsBaseUrl, getApiBaseUrl, getAppBaseUrl, getAssetAppLogoUrl, getAssetChainLogoUrl, getAssetPartnerLogoUrl, getAssetTokenLogoUrl, getAssetWalletLogoUrl, getCortexBaseUrl, getDigestBaseUrl, getDocumentsBaseUrl, getEditableOrderStatuses, getFormsBaseUrl, getFulfillmentFlowAction, getFulfillmentFlowStepperIndex, getGenBaseUrl, getInvoiceEditableStatuses, getLoginUrl, getMcpServerAgentUrl, getMcpServerUrl, getPickupEditableStatuses, getPickupNextAction, getReturnRefundAmount, getReturnableItems, getShippingEditableStatuses, getSiteUrl, getSitesBaseUrl, getSitesRootDomain, getStoreBaseUrl, getWarpScreenshotUrl, hasAllPermissions, hasAllTeamPermissions, hasAnyPermissions, hasPermission, hasTeamPermission, imageCropRectangle, integrationSlugForChannel, inviteableTeamRoles, isAutomationSendChannelId, isCampaignChannelId, isCompleteAddressInput, isContactMessageAction, isContactMessageWarpId, isFileFormatAudio, isFileFormatImage, isFileFormatVideo, isNativeApp, isNativeAppAccessible, isNativeAppGated, isNativeAppLocked, isOrderCanceled, isOrderInFulfillment, isOrderPending, isOrderPostCheckout, isPickupOrderReady, isPickupReady, isSupportedAppLocale, isTeamFeatureAccessible, isTeamFeatureGated, isTeamFeatureLocked, isUnifiedMcpUrl, isUserRole, localize, nativeAppSlugs, normalizeAutomationActionType, ogImageUrl, outboundChannel, permissionPresetRules, resolveAccessCatalog, resolveAgentMcpUrl, resolveConnectMcpUrl, resolveFulfillmentFlowStep, resolveOrderStatusDisplay, resolveTeamCurrency, resolveWarpText, returnStatusValues, returnUpdateStatusValues, sanitizeAlphanumeric, sanitizeNumeric, slugifyMcpSegment, teamCategories, toCurrencyDisplay, toHexEncodedNonce, toNameInitials, toNftId, toPreviewText, userPermissionValues, userRoleValues, validateImageDimensions, validationMessageFor, withRetry };
|
package/dist/index.mjs
CHANGED
|
@@ -686,6 +686,173 @@ const cartLineTotal = (items) => items.reduce((total, item) => total + item.pric
|
|
|
686
686
|
const cartPayableTotal = (items, discountCents = 0) => Math.max(0, cartLineTotal(items) - Math.max(0, discountCents));
|
|
687
687
|
const isCompleteAddressInput = (address) => Boolean(address.name.trim() && address.addressOne.trim() && address.city.trim() && address.zipCode.trim() && address.country.trim());
|
|
688
688
|
//#endregion
|
|
689
|
+
//#region src/commerce/returns.ts
|
|
690
|
+
/** Pickup "collected" is `delivered`; goods must have left the shop before a return makes sense. */
|
|
691
|
+
const RETURNABLE_FULFILLMENT_STATUSES = ["shipped", "delivered"];
|
|
692
|
+
const resolveOrderItemId = (item) => typeof item.orderItemId === "number" && Number.isFinite(item.orderItemId) ? item.orderItemId : Number(item.id);
|
|
693
|
+
const resolveFulfillmentId = (value) => {
|
|
694
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
695
|
+
return String(value);
|
|
696
|
+
};
|
|
697
|
+
/** Physical quantities of a paid order that were shipped/delivered and are not yet in a non-rejected return. */
|
|
698
|
+
const getReturnableItems = (order, returns = order.returns ?? []) => {
|
|
699
|
+
if (!isOrderInFulfillment(order.status)) return [];
|
|
700
|
+
const shippedByItem = /* @__PURE__ */ new Map();
|
|
701
|
+
(order.fulfillments ?? []).filter((fulfillment) => RETURNABLE_FULFILLMENT_STATUSES.includes(fulfillment.status)).forEach((fulfillment) => {
|
|
702
|
+
const fulfillmentId = resolveFulfillmentId(fulfillment.id);
|
|
703
|
+
if (fulfillmentId === null) return;
|
|
704
|
+
fulfillment.items.forEach((item) => {
|
|
705
|
+
const byFulfillment = shippedByItem.get(item.orderItemId) ?? /* @__PURE__ */ new Map();
|
|
706
|
+
byFulfillment.set(fulfillmentId, (byFulfillment.get(fulfillmentId) ?? 0) + item.quantity);
|
|
707
|
+
shippedByItem.set(item.orderItemId, byFulfillment);
|
|
708
|
+
});
|
|
709
|
+
});
|
|
710
|
+
returns.filter((request) => request.status !== "rejected").forEach((request) => {
|
|
711
|
+
const preferredFulfillmentId = resolveFulfillmentId(request.fulfillmentId);
|
|
712
|
+
request.items.forEach((item) => {
|
|
713
|
+
const byFulfillment = shippedByItem.get(item.orderItemId);
|
|
714
|
+
if (!byFulfillment) return;
|
|
715
|
+
let remaining = item.quantity;
|
|
716
|
+
if (preferredFulfillmentId !== null && byFulfillment.has(preferredFulfillmentId)) {
|
|
717
|
+
const available = byFulfillment.get(preferredFulfillmentId) ?? 0;
|
|
718
|
+
const used = Math.min(available, remaining);
|
|
719
|
+
byFulfillment.set(preferredFulfillmentId, available - used);
|
|
720
|
+
remaining -= used;
|
|
721
|
+
}
|
|
722
|
+
for (const [fulfillmentId, available] of byFulfillment) {
|
|
723
|
+
if (remaining <= 0) break;
|
|
724
|
+
if (preferredFulfillmentId !== null && fulfillmentId === preferredFulfillmentId) continue;
|
|
725
|
+
const used = Math.min(available, remaining);
|
|
726
|
+
byFulfillment.set(fulfillmentId, available - used);
|
|
727
|
+
remaining -= used;
|
|
728
|
+
}
|
|
729
|
+
});
|
|
730
|
+
});
|
|
731
|
+
return order.items.filter((item) => !item.digital && item.type !== "coupon").map((item) => {
|
|
732
|
+
const orderItemId = resolveOrderItemId(item);
|
|
733
|
+
const byFulfillment = shippedByItem.get(orderItemId) ?? /* @__PURE__ */ new Map();
|
|
734
|
+
const quantity = Math.min(item.quantity, [...byFulfillment.values()].reduce((sum, value) => sum + value, 0));
|
|
735
|
+
const fulfillmentIds = [...byFulfillment.entries()].filter(([, available]) => available > 0).map(([id]) => id);
|
|
736
|
+
return {
|
|
737
|
+
item,
|
|
738
|
+
orderItemId,
|
|
739
|
+
quantity,
|
|
740
|
+
fulfillmentId: fulfillmentIds.length === 1 ? fulfillmentIds[0] : null
|
|
741
|
+
};
|
|
742
|
+
}).filter(({ orderItemId, quantity }) => Number.isFinite(orderItemId) && quantity > 0);
|
|
743
|
+
};
|
|
744
|
+
/**
|
|
745
|
+
* Split selected return quantities into create payloads, one per fulfillment when possible.
|
|
746
|
+
* Quantities without a single fulfillment go in an unscoped payload.
|
|
747
|
+
*/
|
|
748
|
+
const buildReturnCreatePayloads = (order, selected, returns = order.returns ?? []) => {
|
|
749
|
+
const returnable = getReturnableItems(order, returns);
|
|
750
|
+
const remainingByItem = new Map(returnable.map((item) => [item.orderItemId, item.quantity]));
|
|
751
|
+
const fulfillmentPools = /* @__PURE__ */ new Map();
|
|
752
|
+
(order.fulfillments ?? []).filter((fulfillment) => RETURNABLE_FULFILLMENT_STATUSES.includes(fulfillment.status)).forEach((fulfillment) => {
|
|
753
|
+
const fulfillmentId = resolveFulfillmentId(fulfillment.id);
|
|
754
|
+
if (fulfillmentId === null) return;
|
|
755
|
+
const pool = /* @__PURE__ */ new Map();
|
|
756
|
+
fulfillment.items.forEach((item) => pool.set(item.orderItemId, (pool.get(item.orderItemId) ?? 0) + item.quantity));
|
|
757
|
+
fulfillmentPools.set(fulfillmentId, pool);
|
|
758
|
+
});
|
|
759
|
+
returns.filter((request) => request.status !== "rejected").forEach((request) => {
|
|
760
|
+
const preferredFulfillmentId = resolveFulfillmentId(request.fulfillmentId);
|
|
761
|
+
request.items.forEach((item) => {
|
|
762
|
+
let remaining = item.quantity;
|
|
763
|
+
if (preferredFulfillmentId !== null) {
|
|
764
|
+
const pool = fulfillmentPools.get(preferredFulfillmentId);
|
|
765
|
+
if (pool) {
|
|
766
|
+
const available = pool.get(item.orderItemId) ?? 0;
|
|
767
|
+
const used = Math.min(available, remaining);
|
|
768
|
+
pool.set(item.orderItemId, available - used);
|
|
769
|
+
remaining -= used;
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
for (const pool of fulfillmentPools.values()) {
|
|
773
|
+
if (remaining <= 0) break;
|
|
774
|
+
const available = pool.get(item.orderItemId) ?? 0;
|
|
775
|
+
const used = Math.min(available, remaining);
|
|
776
|
+
pool.set(item.orderItemId, available - used);
|
|
777
|
+
remaining -= used;
|
|
778
|
+
}
|
|
779
|
+
});
|
|
780
|
+
});
|
|
781
|
+
const payloads = /* @__PURE__ */ new Map();
|
|
782
|
+
selected.filter((item) => item.quantity > 0).forEach((item) => {
|
|
783
|
+
let remaining = Math.min(item.quantity, remainingByItem.get(item.orderItemId) ?? 0);
|
|
784
|
+
remainingByItem.set(item.orderItemId, (remainingByItem.get(item.orderItemId) ?? 0) - remaining);
|
|
785
|
+
const preferred = returnable.find((candidate) => candidate.orderItemId === item.orderItemId)?.fulfillmentId;
|
|
786
|
+
if (preferred !== null && preferred !== void 0) {
|
|
787
|
+
const pool = fulfillmentPools.get(preferred);
|
|
788
|
+
const available = pool?.get(item.orderItemId) ?? 0;
|
|
789
|
+
const used = Math.min(available, remaining);
|
|
790
|
+
if (used > 0) {
|
|
791
|
+
pool?.set(item.orderItemId, available - used);
|
|
792
|
+
const key = preferred;
|
|
793
|
+
const payload = payloads.get(key) ?? {
|
|
794
|
+
fulfillmentId: preferred,
|
|
795
|
+
items: []
|
|
796
|
+
};
|
|
797
|
+
payload.items.push({
|
|
798
|
+
orderItemId: item.orderItemId,
|
|
799
|
+
quantity: used,
|
|
800
|
+
condition: item.condition
|
|
801
|
+
});
|
|
802
|
+
payloads.set(key, payload);
|
|
803
|
+
remaining -= used;
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
for (const [fulfillmentId, pool] of fulfillmentPools) {
|
|
807
|
+
if (remaining <= 0) break;
|
|
808
|
+
if (preferred !== null && preferred !== void 0 && fulfillmentId === preferred) continue;
|
|
809
|
+
const available = pool.get(item.orderItemId) ?? 0;
|
|
810
|
+
const used = Math.min(available, remaining);
|
|
811
|
+
if (used <= 0) continue;
|
|
812
|
+
pool.set(item.orderItemId, available - used);
|
|
813
|
+
const payload = payloads.get(fulfillmentId) ?? {
|
|
814
|
+
fulfillmentId,
|
|
815
|
+
items: []
|
|
816
|
+
};
|
|
817
|
+
payload.items.push({
|
|
818
|
+
orderItemId: item.orderItemId,
|
|
819
|
+
quantity: used,
|
|
820
|
+
condition: item.condition
|
|
821
|
+
});
|
|
822
|
+
payloads.set(fulfillmentId, payload);
|
|
823
|
+
remaining -= used;
|
|
824
|
+
}
|
|
825
|
+
if (remaining > 0) {
|
|
826
|
+
const payload = payloads.get("unscoped") ?? { items: [] };
|
|
827
|
+
payload.items.push({
|
|
828
|
+
orderItemId: item.orderItemId,
|
|
829
|
+
quantity: remaining,
|
|
830
|
+
condition: item.condition
|
|
831
|
+
});
|
|
832
|
+
payloads.set("unscoped", payload);
|
|
833
|
+
}
|
|
834
|
+
});
|
|
835
|
+
return [...payloads.values()].filter((payload) => payload.items.length > 0);
|
|
836
|
+
};
|
|
837
|
+
/** Customer-paid amount for returned units (includes proportional tax when prices are net). */
|
|
838
|
+
const getReturnRefundAmount = (order, request, alreadyRefunded = 0) => {
|
|
839
|
+
if (typeof request.suggestedRefundAmount === "number" && Number.isFinite(request.suggestedRefundAmount)) return Math.max(0, request.suggestedRefundAmount);
|
|
840
|
+
if (typeof request.refundAmount === "number" && request.refundAmount > 0) return request.refundAmount;
|
|
841
|
+
const amount = request.items.reduce((sum, returnItem) => {
|
|
842
|
+
const orderItem = order.items.find((item) => resolveOrderItemId(item) === returnItem.orderItemId);
|
|
843
|
+
if (!orderItem || orderItem.quantity < 1) return sum;
|
|
844
|
+
const quantity = Math.min(returnItem.quantity, orderItem.quantity);
|
|
845
|
+
const line = orderItem.unitPrice * quantity;
|
|
846
|
+
if ((order.priceMode ?? "gross") === "net") {
|
|
847
|
+
const tax = Math.round((orderItem.taxAmount ?? 0) * quantity / orderItem.quantity);
|
|
848
|
+
return sum + line + tax;
|
|
849
|
+
}
|
|
850
|
+
return sum + line;
|
|
851
|
+
}, 0);
|
|
852
|
+
const remaining = typeof order.total === "number" ? Math.max(0, order.total - alreadyRefunded) : amount;
|
|
853
|
+
return Math.max(0, Math.min(amount, remaining));
|
|
854
|
+
};
|
|
855
|
+
//#endregion
|
|
689
856
|
//#region src/budget/types.ts
|
|
690
857
|
const PeriodTypeLabels = {
|
|
691
858
|
0: "One-time",
|
|
@@ -951,6 +1118,7 @@ const UserPermissions = {
|
|
|
951
1118
|
ContentPublish: "content-publish",
|
|
952
1119
|
TeamMemberInvite: "team-member-invite",
|
|
953
1120
|
TeamMemberRemove: "team-member-remove",
|
|
1121
|
+
TeamMemberRole: "team-member-role",
|
|
954
1122
|
TeamSecretView: "team-secret-view",
|
|
955
1123
|
TeamSecretManage: "team-secret-manage",
|
|
956
1124
|
AgentExecute: "agent-execute",
|
|
@@ -975,6 +1143,7 @@ const PermissionPresetNames = {
|
|
|
975
1143
|
SecretManage: "secretManage",
|
|
976
1144
|
TeamMemberInvite: "teamMemberInvite",
|
|
977
1145
|
TeamMemberRemove: "teamMemberRemove",
|
|
1146
|
+
TeamMemberRole: "teamMemberRole",
|
|
978
1147
|
AgentWalletManage: "agentWalletManage",
|
|
979
1148
|
SwarmCreate: "swarmCreate"
|
|
980
1149
|
};
|
|
@@ -988,6 +1157,7 @@ const permissionPresetRules = {
|
|
|
988
1157
|
secretManage: teamManageOr(UserPermissions.TeamSecretManage),
|
|
989
1158
|
teamMemberInvite: teamManageOr(UserPermissions.TeamMemberInvite),
|
|
990
1159
|
teamMemberRemove: teamManageOr(UserPermissions.TeamMemberRemove),
|
|
1160
|
+
teamMemberRole: teamManageOr(UserPermissions.TeamMemberRole),
|
|
991
1161
|
agentWalletManage: teamManageOr(UserPermissions.AgentWalletManage),
|
|
992
1162
|
swarmCreate: teamManageOr(UserPermissions.SwarmCreate)
|
|
993
1163
|
};
|
|
@@ -1032,6 +1202,21 @@ const InviteableTeamRoles = [
|
|
|
1032
1202
|
];
|
|
1033
1203
|
const DefaultInviteTeamRole = UserRoles.Member;
|
|
1034
1204
|
const inviteableTeamRoles = () => [...InviteableTeamRoles];
|
|
1205
|
+
/** Roles assignable to an existing member — unlike invites, ownership can be transferred. */
|
|
1206
|
+
const AssignableTeamRoles = [
|
|
1207
|
+
UserRoles.Owner,
|
|
1208
|
+
UserRoles.Admin,
|
|
1209
|
+
UserRoles.Developer,
|
|
1210
|
+
UserRoles.Member
|
|
1211
|
+
];
|
|
1212
|
+
const assignableTeamRoles = () => [...AssignableTeamRoles];
|
|
1035
1213
|
const defaultInviteTeamRole = () => DefaultInviteTeamRole;
|
|
1036
1214
|
//#endregion
|
|
1037
|
-
|
|
1215
|
+
//#region src/hooks/types.ts
|
|
1216
|
+
const INTERNAL_HOOK_TRIGGER_EVENTS = [
|
|
1217
|
+
"contact.created",
|
|
1218
|
+
"contact.updated",
|
|
1219
|
+
"update.created"
|
|
1220
|
+
];
|
|
1221
|
+
//#endregion
|
|
1222
|
+
export { AUTOMATION_SEND_CHANNELS, AddressTypes, AgentToolingAccess, AssignableTeamRoles, BillingManageAccess, CAMPAIGN_CHANNELS, CONTACT_MESSAGE_SEND_WARP, ContractCategoryDisplayNames, DefaultAppLocale, DefaultCodeMetadata, DefaultInviteTeamRole, FulfillmentMethods, FulfillmentStatuses, HttpService, INTERNAL_HOOK_TRIGGER_EVENTS, InviteableTeamRoles, JoaiUrls, NATIVE_AUTH_TOKEN_PARAM, NativeApps, OG_IMAGE_CONFIG, OG_IMAGE_HEIGHT, OG_IMAGE_WIDTH, ORDER_FULFILLMENT_STATUSES, ORDER_POST_CHECKOUT_STATUSES, OUTBOUND_CHANNELS, OgImageColors, PLATFORM_CURRENCY, PeriodTypeLabels, PeriodTypeOptions, PermissionPresetNames, RETURNABLE_FULFILLMENT_STATUSES, ReturnStatuses, ReturnUpdateStatuses, SkillMediaBindingRole, SkillScope, SkillType, SupportedAppLocales, TeamManageAccess, TeamViewAccess, UNIFIED_MCP_SERVER_NAME, UserPermissions, UserRoles, abbreviateNumber, addressTypeValues, assignableTeamRoles, automationSendChannel, buildAgentMcpServerName, buildAgentSetupClipboardText, buildAppSetupClipboardText, buildFeatureSetupClipboardText, buildMcpServerName, buildReturnCreatePayloads, canOpenFulfillmentFlow, canTransitionOrderStatus, cartLineTotal, cartPayableTotal, containedImageDimensions, createCursorMcpInstallLink, cropOutputDimensions, defaultInviteTeamRole, documentShareUrl, firstValidationMessage, formatAddressSnapshotLines, fulfillmentMethodValues, fulfillmentStatusValues, getAgentSetupPromptUrl, getAgentsBaseUrl, getApiBaseUrl, getAppBaseUrl, getAssetAppLogoUrl, getAssetChainLogoUrl, getAssetPartnerLogoUrl, getAssetTokenLogoUrl, getAssetWalletLogoUrl, getCortexBaseUrl, getDigestBaseUrl, getDocumentsBaseUrl, getEditableOrderStatuses, getFormsBaseUrl, getFulfillmentFlowAction, getFulfillmentFlowStepperIndex, getGenBaseUrl, getInvoiceEditableStatuses, getLoginUrl, getMcpServerAgentUrl, getMcpServerUrl, getPickupEditableStatuses, getPickupNextAction, getReturnRefundAmount, getReturnableItems, getShippingEditableStatuses, getSiteUrl, getSitesBaseUrl, getSitesRootDomain, getStoreBaseUrl, getWarpScreenshotUrl, hasAllPermissions, hasAllTeamPermissions, hasAnyPermissions, hasPermission, hasTeamPermission, imageCropRectangle, integrationSlugForChannel, inviteableTeamRoles, isAutomationSendChannelId, isCampaignChannelId, isCompleteAddressInput, isContactMessageAction, isContactMessageWarpId, isFileFormatAudio, isFileFormatImage, isFileFormatVideo, isNativeApp, isNativeAppAccessible, isNativeAppGated, isNativeAppLocked, isOrderCanceled, isOrderInFulfillment, isOrderPending, isOrderPostCheckout, isPickupOrderReady, isPickupReady, isSupportedAppLocale, isTeamFeatureAccessible, isTeamFeatureGated, isTeamFeatureLocked, isUnifiedMcpUrl, isUserRole, localize, nativeAppSlugs, normalizeAutomationActionType, ogImageUrl, outboundChannel, permissionPresetRules, resolveAccessCatalog, resolveAgentMcpUrl, resolveConnectMcpUrl, resolveFulfillmentFlowStep, resolveOrderStatusDisplay, resolveTeamCurrency, resolveWarpText, returnStatusValues, returnUpdateStatusValues, sanitizeAlphanumeric, sanitizeNumeric, slugifyMcpSegment, teamCategories, toCurrencyDisplay, toHexEncodedNonce, toNameInitials, toNftId, toPreviewText, userPermissionValues, userRoleValues, validateImageDimensions, validationMessageFor, withRetry };
|