@marlinjai/mail-contract 0.13.0 → 0.14.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/index.js CHANGED
@@ -107,10 +107,13 @@ __export(index_exports, {
107
107
  BILLING_NOT_CONFIGURED_REASON: () => BILLING_NOT_CONFIGURED_REASON,
108
108
  BoundedAutomationFilter: () => BoundedAutomationFilter,
109
109
  BoundedSegmentFilter: () => BoundedSegmentFilter,
110
+ COMPANY_GRANT_ROLES: () => COMPANY_GRANT_ROLES,
111
+ COMPANY_ROLE_MAX_AGE_HOURS: () => COMPANY_ROLE_MAX_AGE_HOURS,
110
112
  CONTACT_PROPERTY_TYPES: () => CONTACT_PROPERTY_TYPES,
111
113
  CatalogPlan: () => CatalogPlan,
112
114
  CheckoutRequest: () => CheckoutRequest,
113
115
  CheckoutSession: () => CheckoutSession,
116
+ CompanyGrantRole: () => CompanyGrantRole,
114
117
  CompanyId: () => CompanyId,
115
118
  CompileMessage: () => CompileMessage,
116
119
  CompileRequest: () => CompileRequest,
@@ -249,6 +252,7 @@ __export(index_exports, {
249
252
  MAX_STEPS: () => MAX_STEPS,
250
253
  MAX_STEP_VISITS: () => MAX_STEP_VISITS,
251
254
  MAX_SUBJECT_LENGTH: () => MAX_SUBJECT_LENGTH,
255
+ MAX_SYNC_COMPANIES: () => MAX_SYNC_COMPANIES,
252
256
  MAX_TEMPLATE_INPUTS: () => MAX_TEMPLATE_INPUTS,
253
257
  MAX_TEMPLATE_INPUTS_APP_LENGTH: () => MAX_TEMPLATE_INPUTS_APP_LENGTH,
254
258
  MAX_TEMPLATE_INPUTS_SEEN: () => MAX_TEMPLATE_INPUTS_SEEN,
@@ -259,6 +263,7 @@ __export(index_exports, {
259
263
  MAX_TEMPLATE_TRANSLATIONS: () => MAX_TEMPLATE_TRANSLATIONS,
260
264
  MAX_TRIGGERS: () => MAX_TRIGGERS,
261
265
  MEMBER_ROLES: () => MEMBER_ROLES,
266
+ MEMBER_SOURCES: () => MEMBER_SOURCES,
262
267
  MERGE_FIELD_PATTERN: () => MERGE_FIELD_PATTERN,
263
268
  MESSAGE_OUTCOMES: () => MESSAGE_OUTCOMES,
264
269
  MIN_SPLIT_BRANCHES: () => MIN_SPLIT_BRANCHES,
@@ -294,8 +299,11 @@ __export(index_exports, {
294
299
  MailingTestResult: () => MailingTestResult,
295
300
  MailingUpdate: () => MailingUpdate,
296
301
  Member: () => Member,
302
+ MemberCompanySync: () => MemberCompanySync,
303
+ MemberCompanySyncResult: () => MemberCompanySyncResult,
297
304
  MemberCreate: () => MemberCreate,
298
305
  MemberRole: () => MemberRole,
306
+ MemberSource: () => MemberSource,
299
307
  MemberUpdate: () => MemberUpdate,
300
308
  MergeDefaultValue: () => MergeDefaultValue,
301
309
  MergeDefaults: () => MergeDefaults,
@@ -3474,12 +3482,13 @@ var WorkspaceCreate = import_zod11.z.object({
3474
3482
  name: import_zod11.z.string().max(200).nullable().optional()
3475
3483
  }),
3476
3484
  /**
3477
- * The signed-in person's active auth-brain company. The dashboard always
3478
- * sends it, which is what links the workspace to auth-brain's company
3479
- * erasure; omitted, the workspace belongs to no company and no company
3480
- * erasure reaches it.
3485
+ * The auth-brain company the workspace is created in. Required since 0.14.0:
3486
+ * every new workspace belongs to a company, which is what links it to that
3487
+ * company's erasure and lets the company's owners and admins in without an
3488
+ * invitation (`members.syncCompanyRole`). A workspace created before, without
3489
+ * one, keeps working and simply has no such inheritance.
3481
3490
  */
3482
- company_id: CompanyId.optional()
3491
+ company_id: CompanyId
3483
3492
  });
3484
3493
  var WorkspaceUpdate = import_zod11.z.object({
3485
3494
  name: import_zod11.z.string().min(1).max(120),
@@ -3489,14 +3498,58 @@ var WorkspaceMove = import_zod11.z.object({ company_id: CompanyId });
3489
3498
  var MEMBER_ROLES = ["owner", "admin", "editor", "viewer"];
3490
3499
  var MemberRole = import_zod11.z.enum(MEMBER_ROLES);
3491
3500
  var WorkspaceMembership = Workspace.extend({ role: MemberRole });
3501
+ var MEMBER_SOURCES = ["invited", "company"];
3502
+ var MemberSource = import_zod11.z.enum(MEMBER_SOURCES);
3503
+ var COMPANY_GRANT_ROLES = ["owner", "admin"];
3504
+ var CompanyGrantRole = import_zod11.z.enum(COMPANY_GRANT_ROLES);
3505
+ var COMPANY_ROLE_MAX_AGE_HOURS = 24;
3492
3506
  var Member = import_zod11.z.object({
3493
3507
  id: Id,
3494
3508
  /** The person's auth-brain subject. */
3495
3509
  subject: import_zod11.z.string().min(1).max(255),
3496
3510
  email: Email,
3497
3511
  name: import_zod11.z.string().max(200).nullable(),
3512
+ /**
3513
+ * The role in force: the higher of the person's own role in the workspace
3514
+ * and the one a confirmed company role carries. For a `company` row that is
3515
+ * no longer confirmed, the role it would carry once confirmed again.
3516
+ */
3498
3517
  role: MemberRole,
3499
- created_at: Timestamp
3518
+ created_at: Timestamp,
3519
+ /*
3520
+ * The five fields below exist since 0.14.0 and are optional only so that a
3521
+ * client built against this contract can still read a service that predates
3522
+ * them: absent means an ordinary, invited member.
3523
+ */
3524
+ source: MemberSource.optional(),
3525
+ /** The company role last reported for the person (`members.syncCompanyRole`), or null. */
3526
+ company_role: CompanyGrantRole.nullable().optional(),
3527
+ /** When the dashboard last confirmed `company_role`; null without one. */
3528
+ company_checked_at: Timestamp.nullable().optional(),
3529
+ /** The person's own role in the workspace; null for a `company` row. */
3530
+ direct_role: MemberRole.nullable().optional(),
3531
+ /**
3532
+ * True while `role` is held only through a confirmed company role. Such a
3533
+ * member cannot be changed or removed here (`inherited_from_company`): the
3534
+ * role is managed in the shared login. A `company` row with `inherited`
3535
+ * false is one whose company role has not been confirmed within
3536
+ * `COMPANY_ROLE_MAX_AGE_HOURS`; it grants nothing and an admin may remove it.
3537
+ */
3538
+ inherited: import_zod11.z.boolean().optional()
3539
+ });
3540
+ var MAX_SYNC_COMPANIES = 100;
3541
+ var MemberCompanySync = import_zod11.z.object({
3542
+ email: Email,
3543
+ name: import_zod11.z.string().max(200).nullable().optional(),
3544
+ companies: import_zod11.z.array(import_zod11.z.object({ company_id: CompanyId, role: CompanyGrantRole })).max(MAX_SYNC_COMPANIES).refine((list2) => new Set(list2.map((c) => c.company_id)).size === list2.length, "each company at most once")
3545
+ });
3546
+ var MemberCompanySyncResult = import_zod11.z.object({
3547
+ /** Workspaces in which the person now holds a company role they did not hold, or held differently, before this call. */
3548
+ granted: import_zod11.z.array(Id),
3549
+ /** Workspaces in which a company role was taken away by this call. */
3550
+ revoked: import_zod11.z.array(Id),
3551
+ /** Workspaces in which the person's company role was already as stated. */
3552
+ unchanged: import_zod11.z.array(Id)
3500
3553
  });
3501
3554
  var MemberCreate = import_zod11.z.object({
3502
3555
  subject: import_zod11.z.string().min(1).max(255),
@@ -5104,6 +5157,24 @@ var foundationRoutes = {
5104
5157
  access: "admin",
5105
5158
  phase: "S0"
5106
5159
  },
5160
+ /**
5161
+ * The dashboard states the signed-in person's owner and admin roles in
5162
+ * companies, and the service brings the member lists in line (see
5163
+ * `MemberCompanySync`). `dashboard` access: the dashboard's service token
5164
+ * and the person's subject, no workspace. An API key is refused, and so is
5165
+ * every trusted application: it is not in any `TRUSTED_APP_OPERATIONS` list
5166
+ * and the handler refuses an application once more by itself.
5167
+ */
5168
+ "members.syncCompanyRole": {
5169
+ method: "POST",
5170
+ path: "/v1/members/company-sync",
5171
+ body: MemberCompanySync,
5172
+ response: MemberCompanySyncResult,
5173
+ status: 200,
5174
+ access: "dashboard",
5175
+ phase: "S0",
5176
+ statement: true
5177
+ },
5107
5178
  "apiKeys.list": {
5108
5179
  method: "GET",
5109
5180
  path: "/v1/api-keys",
@@ -6407,7 +6478,7 @@ function trustedAppMayCall(app, id) {
6407
6478
  return TRUSTED_APP_OPERATIONS[app].includes(id);
6408
6479
  }
6409
6480
  function acceptsIdempotencyKey(route) {
6410
- return route.method !== "GET";
6481
+ return route.method !== "GET" && route.statement !== true;
6411
6482
  }
6412
6483
  function buildPath(path, params = {}) {
6413
6484
  return path.replace(/:([a-z_]+)/g, (_, name) => {
@@ -6528,10 +6599,13 @@ function matchRoute(method, pathname) {
6528
6599
  BILLING_NOT_CONFIGURED_REASON,
6529
6600
  BoundedAutomationFilter,
6530
6601
  BoundedSegmentFilter,
6602
+ COMPANY_GRANT_ROLES,
6603
+ COMPANY_ROLE_MAX_AGE_HOURS,
6531
6604
  CONTACT_PROPERTY_TYPES,
6532
6605
  CatalogPlan,
6533
6606
  CheckoutRequest,
6534
6607
  CheckoutSession,
6608
+ CompanyGrantRole,
6535
6609
  CompanyId,
6536
6610
  CompileMessage,
6537
6611
  CompileRequest,
@@ -6670,6 +6744,7 @@ function matchRoute(method, pathname) {
6670
6744
  MAX_STEPS,
6671
6745
  MAX_STEP_VISITS,
6672
6746
  MAX_SUBJECT_LENGTH,
6747
+ MAX_SYNC_COMPANIES,
6673
6748
  MAX_TEMPLATE_INPUTS,
6674
6749
  MAX_TEMPLATE_INPUTS_APP_LENGTH,
6675
6750
  MAX_TEMPLATE_INPUTS_SEEN,
@@ -6680,6 +6755,7 @@ function matchRoute(method, pathname) {
6680
6755
  MAX_TEMPLATE_TRANSLATIONS,
6681
6756
  MAX_TRIGGERS,
6682
6757
  MEMBER_ROLES,
6758
+ MEMBER_SOURCES,
6683
6759
  MERGE_FIELD_PATTERN,
6684
6760
  MESSAGE_OUTCOMES,
6685
6761
  MIN_SPLIT_BRANCHES,
@@ -6715,8 +6791,11 @@ function matchRoute(method, pathname) {
6715
6791
  MailingTestResult,
6716
6792
  MailingUpdate,
6717
6793
  Member,
6794
+ MemberCompanySync,
6795
+ MemberCompanySyncResult,
6718
6796
  MemberCreate,
6719
6797
  MemberRole,
6798
+ MemberSource,
6720
6799
  MemberUpdate,
6721
6800
  MergeDefaultValue,
6722
6801
  MergeDefaults,
package/dist/index.mjs CHANGED
@@ -2843,12 +2843,13 @@ var WorkspaceCreate = z11.object({
2843
2843
  name: z11.string().max(200).nullable().optional()
2844
2844
  }),
2845
2845
  /**
2846
- * The signed-in person's active auth-brain company. The dashboard always
2847
- * sends it, which is what links the workspace to auth-brain's company
2848
- * erasure; omitted, the workspace belongs to no company and no company
2849
- * erasure reaches it.
2846
+ * The auth-brain company the workspace is created in. Required since 0.14.0:
2847
+ * every new workspace belongs to a company, which is what links it to that
2848
+ * company's erasure and lets the company's owners and admins in without an
2849
+ * invitation (`members.syncCompanyRole`). A workspace created before, without
2850
+ * one, keeps working and simply has no such inheritance.
2850
2851
  */
2851
- company_id: CompanyId.optional()
2852
+ company_id: CompanyId
2852
2853
  });
2853
2854
  var WorkspaceUpdate = z11.object({
2854
2855
  name: z11.string().min(1).max(120),
@@ -2858,14 +2859,58 @@ var WorkspaceMove = z11.object({ company_id: CompanyId });
2858
2859
  var MEMBER_ROLES = ["owner", "admin", "editor", "viewer"];
2859
2860
  var MemberRole = z11.enum(MEMBER_ROLES);
2860
2861
  var WorkspaceMembership = Workspace.extend({ role: MemberRole });
2862
+ var MEMBER_SOURCES = ["invited", "company"];
2863
+ var MemberSource = z11.enum(MEMBER_SOURCES);
2864
+ var COMPANY_GRANT_ROLES = ["owner", "admin"];
2865
+ var CompanyGrantRole = z11.enum(COMPANY_GRANT_ROLES);
2866
+ var COMPANY_ROLE_MAX_AGE_HOURS = 24;
2861
2867
  var Member = z11.object({
2862
2868
  id: Id,
2863
2869
  /** The person's auth-brain subject. */
2864
2870
  subject: z11.string().min(1).max(255),
2865
2871
  email: Email,
2866
2872
  name: z11.string().max(200).nullable(),
2873
+ /**
2874
+ * The role in force: the higher of the person's own role in the workspace
2875
+ * and the one a confirmed company role carries. For a `company` row that is
2876
+ * no longer confirmed, the role it would carry once confirmed again.
2877
+ */
2867
2878
  role: MemberRole,
2868
- created_at: Timestamp
2879
+ created_at: Timestamp,
2880
+ /*
2881
+ * The five fields below exist since 0.14.0 and are optional only so that a
2882
+ * client built against this contract can still read a service that predates
2883
+ * them: absent means an ordinary, invited member.
2884
+ */
2885
+ source: MemberSource.optional(),
2886
+ /** The company role last reported for the person (`members.syncCompanyRole`), or null. */
2887
+ company_role: CompanyGrantRole.nullable().optional(),
2888
+ /** When the dashboard last confirmed `company_role`; null without one. */
2889
+ company_checked_at: Timestamp.nullable().optional(),
2890
+ /** The person's own role in the workspace; null for a `company` row. */
2891
+ direct_role: MemberRole.nullable().optional(),
2892
+ /**
2893
+ * True while `role` is held only through a confirmed company role. Such a
2894
+ * member cannot be changed or removed here (`inherited_from_company`): the
2895
+ * role is managed in the shared login. A `company` row with `inherited`
2896
+ * false is one whose company role has not been confirmed within
2897
+ * `COMPANY_ROLE_MAX_AGE_HOURS`; it grants nothing and an admin may remove it.
2898
+ */
2899
+ inherited: z11.boolean().optional()
2900
+ });
2901
+ var MAX_SYNC_COMPANIES = 100;
2902
+ var MemberCompanySync = z11.object({
2903
+ email: Email,
2904
+ name: z11.string().max(200).nullable().optional(),
2905
+ companies: z11.array(z11.object({ company_id: CompanyId, role: CompanyGrantRole })).max(MAX_SYNC_COMPANIES).refine((list2) => new Set(list2.map((c) => c.company_id)).size === list2.length, "each company at most once")
2906
+ });
2907
+ var MemberCompanySyncResult = z11.object({
2908
+ /** Workspaces in which the person now holds a company role they did not hold, or held differently, before this call. */
2909
+ granted: z11.array(Id),
2910
+ /** Workspaces in which a company role was taken away by this call. */
2911
+ revoked: z11.array(Id),
2912
+ /** Workspaces in which the person's company role was already as stated. */
2913
+ unchanged: z11.array(Id)
2869
2914
  });
2870
2915
  var MemberCreate = z11.object({
2871
2916
  subject: z11.string().min(1).max(255),
@@ -4473,6 +4518,24 @@ var foundationRoutes = {
4473
4518
  access: "admin",
4474
4519
  phase: "S0"
4475
4520
  },
4521
+ /**
4522
+ * The dashboard states the signed-in person's owner and admin roles in
4523
+ * companies, and the service brings the member lists in line (see
4524
+ * `MemberCompanySync`). `dashboard` access: the dashboard's service token
4525
+ * and the person's subject, no workspace. An API key is refused, and so is
4526
+ * every trusted application: it is not in any `TRUSTED_APP_OPERATIONS` list
4527
+ * and the handler refuses an application once more by itself.
4528
+ */
4529
+ "members.syncCompanyRole": {
4530
+ method: "POST",
4531
+ path: "/v1/members/company-sync",
4532
+ body: MemberCompanySync,
4533
+ response: MemberCompanySyncResult,
4534
+ status: 200,
4535
+ access: "dashboard",
4536
+ phase: "S0",
4537
+ statement: true
4538
+ },
4476
4539
  "apiKeys.list": {
4477
4540
  method: "GET",
4478
4541
  path: "/v1/api-keys",
@@ -5776,7 +5839,7 @@ function trustedAppMayCall(app, id) {
5776
5839
  return TRUSTED_APP_OPERATIONS[app].includes(id);
5777
5840
  }
5778
5841
  function acceptsIdempotencyKey(route) {
5779
- return route.method !== "GET";
5842
+ return route.method !== "GET" && route.statement !== true;
5780
5843
  }
5781
5844
  function buildPath(path, params = {}) {
5782
5845
  return path.replace(/:([a-z_]+)/g, (_, name) => {
@@ -5896,10 +5959,13 @@ export {
5896
5959
  BILLING_NOT_CONFIGURED_REASON,
5897
5960
  BoundedAutomationFilter,
5898
5961
  BoundedSegmentFilter,
5962
+ COMPANY_GRANT_ROLES,
5963
+ COMPANY_ROLE_MAX_AGE_HOURS,
5899
5964
  CONTACT_PROPERTY_TYPES,
5900
5965
  CatalogPlan,
5901
5966
  CheckoutRequest,
5902
5967
  CheckoutSession,
5968
+ CompanyGrantRole,
5903
5969
  CompanyId,
5904
5970
  CompileMessage,
5905
5971
  CompileRequest,
@@ -6038,6 +6104,7 @@ export {
6038
6104
  MAX_STEPS,
6039
6105
  MAX_STEP_VISITS,
6040
6106
  MAX_SUBJECT_LENGTH,
6107
+ MAX_SYNC_COMPANIES,
6041
6108
  MAX_TEMPLATE_INPUTS,
6042
6109
  MAX_TEMPLATE_INPUTS_APP_LENGTH,
6043
6110
  MAX_TEMPLATE_INPUTS_SEEN,
@@ -6048,6 +6115,7 @@ export {
6048
6115
  MAX_TEMPLATE_TRANSLATIONS,
6049
6116
  MAX_TRIGGERS,
6050
6117
  MEMBER_ROLES,
6118
+ MEMBER_SOURCES,
6051
6119
  MERGE_FIELD_PATTERN,
6052
6120
  MESSAGE_OUTCOMES,
6053
6121
  MIN_SPLIT_BRANCHES,
@@ -6083,8 +6151,11 @@ export {
6083
6151
  MailingTestResult,
6084
6152
  MailingUpdate,
6085
6153
  Member,
6154
+ MemberCompanySync,
6155
+ MemberCompanySyncResult,
6086
6156
  MemberCreate,
6087
6157
  MemberRole,
6158
+ MemberSource,
6088
6159
  MemberUpdate,
6089
6160
  MergeDefaultValue,
6090
6161
  MergeDefaults,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.13.0",
6
+ "version": "0.14.0",
7
7
  "description": "The v1 API contract of the mail service: zod schemas and types for every request, response, error and webhook, the route table, and webhook signing helpers",
8
8
  "license": "MIT",
9
9
  "repository": {