@joai/sdk 4.2.0 → 4.2.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/dist/index.d.mts CHANGED
@@ -154,8 +154,33 @@ type WalletList = Partial<Record<WarpChainName, {
154
154
  provider: WarpWalletProvider;
155
155
  address?: string;
156
156
  }>>; //#endregion
157
+ //#region src/user/permissions.d.ts
158
+ /** Permission string values — must match joai--api `UserPermission::value`. */
159
+ declare const UserPermissions: {
160
+ readonly BillingManage: "billing-manage";
161
+ readonly TeamManage: "team-manage";
162
+ readonly TeamView: "team-view";
163
+ readonly TeamMemberInvite: "team-member-invite";
164
+ readonly TeamMemberRemove: "team-member-remove";
165
+ readonly TeamSecretView: "team-secret-view";
166
+ readonly TeamSecretManage: "team-secret-manage";
167
+ readonly AgentExecute: "agent-execute";
168
+ readonly AgentWalletManage: "agent-wallet-manage";
169
+ readonly SwarmCreate: "swarm-create";
170
+ };
171
+ type UserPermission = (typeof UserPermissions)[keyof typeof UserPermissions];
172
+ //#endregion
173
+ //#region src/user/roles.d.ts
174
+ /** Team member roles — values must match joai--api `UserRole::toName()`. */
175
+ declare const UserRoles: {
176
+ readonly Owner: "owner";
177
+ readonly Admin: "admin";
178
+ readonly Member: "member";
179
+ readonly Developer: "developer";
180
+ };
181
+ type UserRole = (typeof UserRoles)[keyof typeof UserRoles];
182
+ //#endregion
157
183
  //#region src/user/types.d.ts
158
- type UserRole = 'owner' | 'member';
159
184
  type UserMode = 'simple' | 'advanced';
160
185
  type UserInterest = 'payments' | 'health' | 'content' | 'business' | 'finance' | 'research' | 'shopping' | 'web3' | 'developer' | 'fitness' | 'ecommerce';
161
186
  type UserSettings = {
@@ -191,7 +216,6 @@ type UserPrivate = {
191
216
  socials: UserSocialAccount[];
192
217
  justCreated: boolean;
193
218
  affiliate: Affiliate | null;
194
- betaRestricted: boolean;
195
219
  kyc?: Kyc | null;
196
220
  settings: UserSettings;
197
221
  };
@@ -242,8 +266,6 @@ type AffiliateTier = {
242
266
  threshold: number;
243
267
  };
244
268
  type AffiliateStatus = 'pending' | 'approved' | 'rejected' | 'suspended' | 'demoted'; //#endregion
245
- //#region src/team/constants.d.ts
246
- declare const teamCategories: readonly ["general", "food-drink", "retail", "beauty-wellness", "health", "sports-fitness", "trades-services", "professional-services", "education-culture", "clubs-organizations", "leisure-tourism"]; //#endregion
247
269
  //#region src/team/apps.d.ts
248
270
  declare const NativeApps: {
249
271
  readonly Board: "board";
@@ -264,6 +286,25 @@ declare const NativeApps: {
264
286
  };
265
287
  type NativeApp = (typeof NativeApps)[keyof typeof NativeApps];
266
288
  //#endregion
289
+ //#region src/access/team-access.d.ts
290
+ type TeamFeatureArea = 'nativeApps' | 'agentSettings' | 'teamSettings' | 'developerHub' | 'areas' | 'commerce';
291
+ /** Keys per area that the API evaluates in `team.access`. */
292
+ type TeamAccessCatalog = Partial<Record<TeamFeatureArea, string[]>>;
293
+ type TeamAccessConfig = {
294
+ accessCatalog: TeamAccessCatalog;
295
+ };
296
+ /** Resolved feature access from API `TeamPrivate.access` — do not evaluate rules on the client. */
297
+ type TeamFeatureAccess = {
298
+ nativeApps?: Partial<Record<NativeApp, boolean>>;
299
+ agentSettings?: Partial<Record<string, boolean>>;
300
+ teamSettings?: Partial<Record<string, boolean>>;
301
+ developerHub?: Partial<Record<string, boolean>>;
302
+ areas?: Partial<Record<string, boolean>>;
303
+ commerce?: Partial<Record<string, boolean>>;
304
+ };
305
+ //#endregion
306
+ //#region src/team/constants.d.ts
307
+ declare const teamCategories: readonly ["general", "food-drink", "retail", "beauty-wellness", "health", "sports-fitness", "trades-services", "professional-services", "education-culture", "clubs-organizations", "leisure-tourism"]; //#endregion
267
308
  //#region src/team/types.d.ts
268
309
  type TeamCategory = (typeof teamCategories)[number];
269
310
  type TeamFeature = 'shop' | 'appointments';
@@ -375,6 +416,10 @@ type TeamPrivate = {
375
416
  category: TeamCategory;
376
417
  createdAt: string;
377
418
  justCreated: boolean;
419
+ role?: UserRole | null;
420
+ permissions?: UserPermission[];
421
+ access?: TeamFeatureAccess;
422
+ accessCatalog?: TeamAccessCatalog;
378
423
  };
379
424
  type ByokProviderConfig = {
380
425
  apiKey?: string;
@@ -442,8 +487,14 @@ type AiCostsResponse = {
442
487
  };
443
488
  };
444
489
  }; //#endregion
490
+ //#region src/address/enums.d.ts
491
+ declare const AddressTypes: {
492
+ readonly Billing: "billing";
493
+ readonly Shipping: "shipping";
494
+ };
495
+ type AddressType = (typeof AddressTypes)[keyof typeof AddressTypes];
496
+ //#endregion
445
497
  //#region src/address/types.d.ts
446
- type AddressType = 'shipping' | 'billing';
447
498
  type Address = {
448
499
  id: string;
449
500
  type: AddressType;
@@ -495,8 +546,30 @@ type AddressCreatePayload = {
495
546
  team?: string;
496
547
  };
497
548
  type AddressUpdatePayload = Partial<Omit<AddressCreatePayload, 'contact' | 'team'>>; //#endregion
549
+ //#region src/commerce/enums.d.ts
550
+ declare const FulfillmentStatuses: {
551
+ readonly Pending: "pending";
552
+ readonly ReadyForPickup: "ready_for_pickup";
553
+ readonly Shipped: "shipped";
554
+ readonly Delivered: "delivered";
555
+ readonly Cancelled: "cancelled";
556
+ };
557
+ type FulfillmentStatus = (typeof FulfillmentStatuses)[keyof typeof FulfillmentStatuses];
558
+ declare const FulfillmentMethods: {
559
+ readonly Shipping: "shipping";
560
+ readonly Pickup: "pickup";
561
+ };
562
+ type FulfillmentMethod = (typeof FulfillmentMethods)[keyof typeof FulfillmentMethods];
563
+ declare const ReturnStatuses: {
564
+ readonly Requested: "requested";
565
+ readonly Approved: "approved";
566
+ readonly Rejected: "rejected";
567
+ readonly Received: "received";
568
+ readonly Closed: "closed";
569
+ };
570
+ type ReturnStatus = (typeof ReturnStatuses)[keyof typeof ReturnStatuses];
571
+ //#endregion
498
572
  //#region src/commerce/types.d.ts
499
- type FulfillmentMethod = 'shipping' | 'pickup';
500
573
  type ShippingRate = {
501
574
  id: number;
502
575
  name: string;
@@ -523,6 +596,10 @@ type CheckoutSnapshot = {
523
596
  expiresAt: string;
524
597
  accessToken?: string | null;
525
598
  };
599
+ type GuestBuyer = {
600
+ name: string;
601
+ email: string;
602
+ };
526
603
  type CheckoutSnapshotRequest = {
527
604
  fulfillmentMethod: FulfillmentMethod;
528
605
  items: {
@@ -554,7 +631,6 @@ type FulfillmentLocation = {
554
631
  instructions: string | null;
555
632
  active: boolean;
556
633
  };
557
- type FulfillmentStatus = 'pending' | 'ready_for_pickup' | 'shipped' | 'delivered' | 'cancelled';
558
634
  type Fulfillment = {
559
635
  id: string;
560
636
  orderId: number;
@@ -571,7 +647,6 @@ type Fulfillment = {
571
647
  readyForPickupAt: string | null;
572
648
  deliveredAt: string | null;
573
649
  };
574
- type ReturnStatus = 'requested' | 'approved' | 'rejected' | 'received' | 'closed';
575
650
  type Return = {
576
651
  id: string;
577
652
  orderId: number;
@@ -924,7 +999,7 @@ type Order = {
924
999
  linkVariationId: string | null;
925
1000
  notes: string | null;
926
1001
  fulfillmentMethod?: FulfillmentMethod | null;
927
- address?: AddressSnapshot | null;
1002
+ billingAddress?: AddressSnapshot | null;
928
1003
  shippingAddress?: AddressSnapshot | null;
929
1004
  shippingRate?: Pick<ShippingRate, 'name' | 'price' | 'estimatedMinDays' | 'estimatedMaxDays'> | null;
930
1005
  fulfillmentLocation?: {
@@ -3066,10 +3141,7 @@ declare class AddressesResource {
3066
3141
  //#endregion
3067
3142
  //#region src/commerce/checkout.d.ts
3068
3143
  type PlaceCheckoutOrderRequest = CheckoutSnapshotRequest & {
3069
- guest?: {
3070
- name: string;
3071
- email: string;
3072
- };
3144
+ guest?: GuestBuyer;
3073
3145
  notes?: string;
3074
3146
  idempotencyKey?: string;
3075
3147
  saveAddresses?: boolean;
@@ -4486,7 +4558,7 @@ type TeamMutationPayload = {
4486
4558
  settings?: Record<string, JsonValue>;
4487
4559
  emails?: {
4488
4560
  email: string;
4489
- role: 'owner' | 'admin' | 'member';
4561
+ role: UserRole;
4490
4562
  }[];
4491
4563
  website?: string | null;
4492
4564
  phone?: string | null;
@@ -4512,7 +4584,7 @@ declare class TeamsResource {
4512
4584
  updateTagline(teamSlug: string, tagline: TranslatableValue | null): Promise<IAppResponse<TeamPrivate>>;
4513
4585
  invite(teamSlug: string, payload: {
4514
4586
  email: string;
4515
- role: 'owner' | 'admin' | 'member';
4587
+ role: UserRole;
4516
4588
  }): Promise<IAppResponse<void>>;
4517
4589
  inviteMember(teamSlug: string, email: string, role: UserRole): Promise<IAppResponse<void>>;
4518
4590
  removeMember(teamSlug: string, memberId: string): Promise<IAppResponse<void>>;
@@ -4527,6 +4599,7 @@ declare class TeamsResource {
4527
4599
  }): Promise<IAppResponse<TeamPlace[]>>;
4528
4600
  selectPlace(teamSlug: string, sourceId: string | null): Promise<IAppResponse<TeamPrivate>>;
4529
4601
  listPrivate(): Promise<IAppResponse<TeamPrivate[]>>;
4602
+ accessConfig(): Promise<IAppResponse<TeamAccessConfig>>;
4530
4603
  getInviteByToken(token: string): Promise<IAppResponse<TeamInviteInfo>>;
4531
4604
  acceptInvite(slug: string): Promise<IAppResponse<void>>;
4532
4605
  usage(teamSlug: string): Promise<IAppResponse<TeamUsage>>;
@@ -4947,4 +5020,4 @@ declare class DistributionResource {
4947
5020
  private fetchDistribution;
4948
5021
  }
4949
5022
  //#endregion
4950
- export { AddressesResource, AgentsResource, AlertsResource, ApiTokensResource, AppointmentsResource, type AttachedMedia, type AuthConfirmCodeRequest, type AuthConfirmCodeResponse, type AuthNativeSessionResponse, type AuthPortalSessionResponse, AuthResource, type AuthSendCodeRequest, type BackendWarp, type BackendWarpBrand, BillingResource, BlueprintsResource, type CacheConfig, CachedHttpService, CampaignsResource, CardsResource, CartsResource, ChangelogResource, CharactersResource, CheckoutResource, CommerceResource, ContactsResource, ContractsResource, type CreateHookPayload, type CreateInboundHookPayload, type CreateInternalHookPayload, type CreateWarpLinkedHookPayload, type CreateWebHookPayload, DeskResource, DistributionResource, DocumentsResource, ElementsResource, EntitiesResource, FlowsResource, FulfillmentsResource, GoalsResource, type GuestCheckoutDraft, type GuestCommerceStorageOptions, type GuestOrderAccess, type Hook, type HookSample, type HookTrigger, type HookTriggerCondition, type HookTriggerInput, HooksResource, IngestionsResource, InquiriesResource, IntegrationsResource, IntentsResource, ItemsResource, JoAiClient, type JoAiClientConfig, KvResource, LinksResource, LoyaltyResource, McpResource, type MediaUploadType, MeetingsResource, MemoriesResource, MessagesResource, MissionsResource, NotificationsResource, OfficeResource, type OpenPortalSessionOptions, type OpeningHoursEntry, type OpeningHoursFormatOptions, OrdersResource, PersonaResource, type Product, type ProductVariation, ProductsResource, ProjectsResource, RemindersResource, ReturnsResource, SegmentsResource, ServicesResource, ShippingResource, ShortcutsResource, SitesResource, SkillsResource, StatsResource, StoreResource, SubscriptionsResource, SwarmsResource, TagsResource, TasksResource, type TeamInviteInfo, TeamsResource, UpdatesResource, UpgradesResource, UsersResource, VoiceResource, WalletsResource, WarpsResource, type WebHookTriggerEvent, WorkspaceResource, completePortalSession, createClient, createGuestCommerceStorage, formatOpeningHours, getAuthFragmentToken, isAllowedRedirectUrl, isPortalCallbackUrl, openPortalSession, sanitizePortalCallbackUrl };
5023
+ export { AddressesResource, AgentsResource, AlertsResource, ApiTokensResource, AppointmentsResource, type AttachedMedia, type AuthConfirmCodeRequest, type AuthConfirmCodeResponse, type AuthNativeSessionResponse, type AuthPortalSessionResponse, AuthResource, type AuthSendCodeRequest, type BackendWarp, type BackendWarpBrand, BillingResource, BlueprintsResource, type CacheConfig, CachedHttpService, CampaignsResource, CardsResource, CartsResource, ChangelogResource, CharactersResource, CheckoutResource, CommerceResource, ContactsResource, ContractsResource, type CreateHookPayload, type CreateInboundHookPayload, type CreateInternalHookPayload, type CreateWarpLinkedHookPayload, type CreateWebHookPayload, DeskResource, DistributionResource, DocumentsResource, ElementsResource, EntitiesResource, FlowsResource, FulfillmentsResource, GoalsResource, type GuestBuyer, type GuestCheckoutDraft, type GuestCommerceStorageOptions, type GuestOrderAccess, type Hook, type HookSample, type HookTrigger, type HookTriggerCondition, type HookTriggerInput, HooksResource, IngestionsResource, InquiriesResource, IntegrationsResource, IntentsResource, ItemsResource, JoAiClient, type JoAiClientConfig, KvResource, LinksResource, LoyaltyResource, McpResource, type MediaUploadType, MeetingsResource, MemoriesResource, MessagesResource, MissionsResource, NotificationsResource, OfficeResource, type OpenPortalSessionOptions, type OpeningHoursEntry, type OpeningHoursFormatOptions, OrdersResource, PersonaResource, type PlaceCheckoutOrderRequest, type Product, type ProductVariation, ProductsResource, ProjectsResource, RemindersResource, ReturnsResource, SegmentsResource, ServicesResource, ShippingResource, ShortcutsResource, SitesResource, SkillsResource, StatsResource, StoreResource, SubscriptionsResource, SwarmsResource, TagsResource, TasksResource, type TeamInviteInfo, TeamsResource, UpdatesResource, UpgradesResource, UsersResource, VoiceResource, WalletsResource, WarpsResource, type WebHookTriggerEvent, WorkspaceResource, completePortalSession, createClient, createGuestCommerceStorage, formatOpeningHours, getAuthFragmentToken, isAllowedRedirectUrl, isPortalCallbackUrl, openPortalSession, sanitizePortalCallbackUrl };
package/dist/index.mjs CHANGED
@@ -110,6 +110,34 @@ var HttpService = class {
110
110
  };
111
111
  }
112
112
  };
113
+ Object.values({
114
+ Billing: "billing",
115
+ Shipping: "shipping"
116
+ });
117
+ Object.values({
118
+ Pending: "pending",
119
+ ReadyForPickup: "ready_for_pickup",
120
+ Shipped: "shipped",
121
+ Delivered: "delivered",
122
+ Cancelled: "cancelled"
123
+ });
124
+ Object.values({
125
+ Shipping: "shipping",
126
+ Pickup: "pickup"
127
+ });
128
+ Object.values({
129
+ Requested: "requested",
130
+ Approved: "approved",
131
+ Rejected: "rejected",
132
+ Received: "received",
133
+ Closed: "closed"
134
+ });
135
+ Object.values({
136
+ Approved: "approved",
137
+ Rejected: "rejected",
138
+ Received: "received",
139
+ Closed: "closed"
140
+ });
113
141
  Object.values({
114
142
  Board: "board",
115
143
  Shop: "shop",
@@ -127,6 +155,47 @@ Object.values({
127
155
  Sites: "sites",
128
156
  Contracts: "contracts"
129
157
  });
158
+ /** Permission string values — must match joai--api `UserPermission::value`. */
159
+ const UserPermissions = {
160
+ BillingManage: "billing-manage",
161
+ TeamManage: "team-manage",
162
+ TeamView: "team-view",
163
+ TeamMemberInvite: "team-member-invite",
164
+ TeamMemberRemove: "team-member-remove",
165
+ TeamSecretView: "team-secret-view",
166
+ TeamSecretManage: "team-secret-manage",
167
+ AgentExecute: "agent-execute",
168
+ AgentWalletManage: "agent-wallet-manage",
169
+ SwarmCreate: "swarm-create"
170
+ };
171
+ Object.values(UserPermissions);
172
+ const teamManageOr = (...permissions) => ({ permissionsAny: [UserPermissions.TeamManage, ...permissions] });
173
+ const permissionPresetRules = {
174
+ teamManage: { permissions: [UserPermissions.TeamManage] },
175
+ teamView: teamManageOr(UserPermissions.TeamView),
176
+ billingManage: teamManageOr(UserPermissions.BillingManage),
177
+ agentTooling: teamManageOr(UserPermissions.AgentExecute),
178
+ secretView: teamManageOr(UserPermissions.TeamSecretView),
179
+ secretManage: teamManageOr(UserPermissions.TeamSecretManage),
180
+ teamMemberInvite: teamManageOr(UserPermissions.TeamMemberInvite),
181
+ teamMemberRemove: teamManageOr(UserPermissions.TeamMemberRemove),
182
+ agentWalletManage: teamManageOr(UserPermissions.AgentWalletManage),
183
+ swarmCreate: teamManageOr(UserPermissions.SwarmCreate)
184
+ };
185
+ permissionPresetRules.teamManage;
186
+ permissionPresetRules.teamView;
187
+ permissionPresetRules.agentTooling;
188
+ permissionPresetRules.billingManage;
189
+ /** Team member roles — values must match joai--api `UserRole::toName()`. */
190
+ const UserRoles = {
191
+ Owner: "owner",
192
+ Admin: "admin",
193
+ Member: "member",
194
+ Developer: "developer"
195
+ };
196
+ Object.values(UserRoles);
197
+ UserRoles.Member, UserRoles.Developer, UserRoles.Admin;
198
+ UserRoles.Member;
130
199
  //#endregion
131
200
  //#region src/resources/agents.ts
132
201
  var AgentsResource = class {
@@ -353,6 +422,12 @@ const safeSet = (key, value) => {
353
422
  localStorage.setItem(key, value);
354
423
  } catch {}
355
424
  };
425
+ const safeRemove = (key) => {
426
+ if (typeof localStorage === "undefined") return;
427
+ try {
428
+ localStorage.removeItem(key);
429
+ } catch {}
430
+ };
356
431
  const parseGuestOrderAccess = (entry) => {
357
432
  if (!entry || typeof entry !== "object") return null;
358
433
  const record = entry;
@@ -392,19 +467,25 @@ function createGuestCommerceStorage(options) {
392
467
  },
393
468
  saveOrderAccess({ orderId, accessToken }) {
394
469
  const key = orderAccessKey(options.namespace, orderId);
395
- if (accessToken) safeSet(key, accessToken);
470
+ const resolvedToken = accessToken || safeGet(key);
471
+ if (resolvedToken) safeSet(key, resolvedToken);
396
472
  const orders = readOrderList(options.namespace).filter((entry) => entry.orderId !== orderId);
397
473
  orders.unshift({
398
474
  orderId,
399
- accessToken
475
+ accessToken: resolvedToken
400
476
  });
401
- safeSet(ordersKey(options.namespace), JSON.stringify(orders.slice(0, maxOrders)));
477
+ const kept = orders.slice(0, maxOrders);
478
+ for (const dropped of orders.slice(maxOrders)) safeRemove(orderAccessKey(options.namespace, dropped.orderId));
479
+ safeSet(ordersKey(options.namespace), JSON.stringify(kept));
402
480
  },
403
481
  readOrderAccess(orderId) {
404
482
  return safeGet(orderAccessKey(options.namespace, orderId));
405
483
  },
406
484
  listOrderAccess() {
407
- return readOrderList(options.namespace);
485
+ return readOrderList(options.namespace).map((entry) => ({
486
+ orderId: entry.orderId,
487
+ accessToken: entry.accessToken || safeGet(orderAccessKey(options.namespace, entry.orderId))
488
+ }));
408
489
  }
409
490
  };
410
491
  }
@@ -2298,6 +2379,9 @@ var TeamsResource = class {
2298
2379
  listPrivate() {
2299
2380
  return this.http.get("teams?me=true");
2300
2381
  }
2382
+ accessConfig() {
2383
+ return this.http.get("teams/access-config");
2384
+ }
2301
2385
  getInviteByToken(token) {
2302
2386
  return this.http.get(`teams/invite/${token}`);
2303
2387
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joai/sdk",
3
- "version": "4.2.0",
3
+ "version": "4.2.2",
4
4
  "description": "JoAi public API SDK — build with your AI agents",
5
5
  "license": "MIT",
6
6
  "type": "module",