@odla-ai/chapter 0.8.0 → 0.9.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.
@@ -95,13 +95,15 @@ function createWorkerContext(options) {
95
95
  import { createCrmRoutes } from "@odla-ai/crm";
96
96
 
97
97
  // src/clerk.ts
98
+ var heal = (status) => status === 422 ? { ok: true, status, existed: true } : { ok: false, status };
98
99
  function clerkInviteRequest(input) {
99
100
  return {
100
101
  path: "/v1/invitations",
101
102
  body: {
102
103
  email_address: input.email,
103
104
  notify: true,
104
- ...input.redirectUrl ? { redirect_url: input.redirectUrl } : {}
105
+ ...input.redirectUrl ? { redirect_url: input.redirectUrl } : {},
106
+ ...input.publicMetadata ? { public_metadata: input.publicMetadata } : {}
105
107
  }
106
108
  };
107
109
  }
@@ -112,7 +114,7 @@ async function createClerkInvitation(secretKey, input, fetchImpl = fetch) {
112
114
  headers: { authorization: `Bearer ${secretKey}`, "content-type": "application/json" },
113
115
  body: JSON.stringify(body)
114
116
  });
115
- return { ok: res.ok, status: res.status };
117
+ return res.ok ? { ok: true, status: res.status } : heal(res.status);
116
118
  }
117
119
  function clerkUserRequest(input) {
118
120
  return {
@@ -121,7 +123,8 @@ function clerkUserRequest(input) {
121
123
  email_address: [input.email],
122
124
  skip_password_requirement: true,
123
125
  ...input.firstName ? { first_name: input.firstName } : {},
124
- ...input.lastName ? { last_name: input.lastName } : {}
126
+ ...input.lastName ? { last_name: input.lastName } : {},
127
+ ...input.publicMetadata ? { public_metadata: input.publicMetadata } : {}
125
128
  }
126
129
  };
127
130
  }
@@ -132,7 +135,7 @@ async function createClerkUser(secretKey, input, fetchImpl = fetch) {
132
135
  headers: { authorization: `Bearer ${secretKey}`, "content-type": "application/json" },
133
136
  body: JSON.stringify(body)
134
137
  });
135
- return { ok: res.ok, status: res.status };
138
+ return res.ok ? { ok: true, status: res.status } : heal(res.status);
136
139
  }
137
140
 
138
141
  // src/member.ts