@wayai/cli 0.3.348 → 0.3.349

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
@@ -6339,6 +6339,25 @@ var init_chunk_63UWXV4T = __esm({
6339
6339
  }
6340
6340
  });
6341
6341
 
6342
+ // ../../packages/core/dist/chunk-TVUDMGWV.js
6343
+ var bootstrapQuery;
6344
+ var init_chunk_TVUDMGWV = __esm({
6345
+ "../../packages/core/dist/chunk-TVUDMGWV.js"() {
6346
+ "use strict";
6347
+ init_zod();
6348
+ bootstrapQuery = external_exports.object({
6349
+ active_hub_id: external_exports.string().uuid().optional(),
6350
+ active_conversation_id: external_exports.string().uuid().optional(),
6351
+ active_nav: external_exports.enum(["chat", "task", "support"]).optional(),
6352
+ /**
6353
+ * The people thread the URL names (`/chat/threads/:threadId`, gh #4661): the snapshot
6354
+ * preloads it as `people.active_thread` when the viewer is a member.
6355
+ */
6356
+ active_thread_id: external_exports.string().uuid().optional()
6357
+ });
6358
+ }
6359
+ });
6360
+
6342
6361
  // ../../packages/core/dist/chunk-S4HVRNEQ.js
6343
6362
  var PERMISSIONS;
6344
6363
  var init_chunk_S4HVRNEQ = __esm({
@@ -6491,6 +6510,231 @@ var init_chunk_ZC6YGHNX = __esm({
6491
6510
  }
6492
6511
  });
6493
6512
 
6513
+ // ../../packages/core/dist/chunk-2YEGUQR7.js
6514
+ var PERSON_ID_PATTERN, CONTACT_PERSON_ID_PATTERN, PERSON_ID_FORM_MESSAGE, userPersonIdSchema, personIdSchema;
6515
+ var init_chunk_2YEGUQR7 = __esm({
6516
+ "../../packages/core/dist/chunk-2YEGUQR7.js"() {
6517
+ "use strict";
6518
+ init_zod();
6519
+ PERSON_ID_PATTERN = /^prs_[a-z2-7]{52}$/;
6520
+ CONTACT_PERSON_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
6521
+ PERSON_ID_FORM_MESSAGE = "Must be a person id (prs_\u2026) or a contact id (a lowercase UUID)";
6522
+ userPersonIdSchema = external_exports.string().regex(PERSON_ID_PATTERN, { message: "Must be a person id (prs_\u2026)" });
6523
+ personIdSchema = external_exports.string().refine(
6524
+ (value) => PERSON_ID_PATTERN.test(value) || CONTACT_PERSON_ID_PATTERN.test(value),
6525
+ { message: PERSON_ID_FORM_MESSAGE }
6526
+ );
6527
+ }
6528
+ });
6529
+
6530
+ // ../../packages/core/dist/chunk-UAOHHCW5.js
6531
+ function normalizeContactPhone(raw) {
6532
+ const compact = raw.trim().replace(/[\s\-.()]/g, "");
6533
+ const withPlus = compact.startsWith("00") ? `+${compact.slice(2)}` : compact;
6534
+ return /^\+[1-9]\d{7,14}$/.test(withPlus) ? withPlus : null;
6535
+ }
6536
+ function normalizeContactLabel(raw) {
6537
+ return raw.trim().replace(/\s+/g, " ").toLowerCase();
6538
+ }
6539
+ function importRowLabels(row, batchLabels) {
6540
+ return [.../* @__PURE__ */ new Set([...row.labels ?? [], ...batchLabels ?? []])];
6541
+ }
6542
+ var CONTACT_ENVIRONMENTS, CONTACT_NAME_MAX, CONTACT_EMAIL_MAX, CONTACT_PHONE_INPUT_MAX, CONTACT_INSTAGRAM_SID_MAX, CONTACT_METADATA_MAX_BYTES, CONTACT_LABEL_MAX, CONTACT_LABELS_MAX, CONTACT_SCOPE_TAGS_MAX, CONTACT_PAGE_MAX, CONTACT_IMPORT_BATCH_MAX, CONTACT_SEARCH_MAX, CONTACT_LIST_NAME_MAX, CONTACT_LIST_NAME_REGEX, CONTACT_LIST_DESCRIPTION_MAX, CONTACT_LIST_FILTER_MAX, CONTACT_LIST_PINS_PER_REQUEST_MAX, SUPPRESSION_SCOPES, SUPPRESSION_ID_REGEX, contactName, contactPhone, contactEmail, contactInstagramSid, contactLabel, contactLabels, contactMetadata, scopeTagIds, contactVisibilitySchema, hasIdentity, IDENTITY_REQUIRED, contactBookOrgQuery, contactBookContactParam, contactBookListParam, contactBookHubParam, contactBookPageQuery, listContactBookContactsQuery, listHubContactBookContactsQuery, contactBookLinkCandidatesQuery, listContactBookListMembersQuery, contactRowFields, createContactBookContactBody, updateContactBookContactBody, contactImportRowSchema, importContactBookContactsBody, linkContactBookContactBody, listName, contactListFilterSchema, createContactBookListBody, updateContactBookListBody, updateContactBookListPinsBody, suppressionIdentitySchema, createContactBookSuppressionBody, contactBookSuppressionParam, listContactBookSuppressionsQuery, contactBookEmailUnsubscribeTokenSchema, contactBookEmailUnsubscribeQuery, orgListReferenceSchema;
6543
+ var init_chunk_UAOHHCW5 = __esm({
6544
+ "../../packages/core/dist/chunk-UAOHHCW5.js"() {
6545
+ "use strict";
6546
+ init_zod();
6547
+ CONTACT_ENVIRONMENTS = ["production", "preview", "all"];
6548
+ CONTACT_NAME_MAX = 200;
6549
+ CONTACT_EMAIL_MAX = 320;
6550
+ CONTACT_PHONE_INPUT_MAX = 40;
6551
+ CONTACT_INSTAGRAM_SID_MAX = 64;
6552
+ CONTACT_METADATA_MAX_BYTES = 4096;
6553
+ CONTACT_LABEL_MAX = 64;
6554
+ CONTACT_LABELS_MAX = 20;
6555
+ CONTACT_SCOPE_TAGS_MAX = 20;
6556
+ CONTACT_PAGE_MAX = 100;
6557
+ CONTACT_IMPORT_BATCH_MAX = 500;
6558
+ CONTACT_SEARCH_MAX = 100;
6559
+ CONTACT_LIST_NAME_MAX = 64;
6560
+ CONTACT_LIST_NAME_REGEX = /^[a-z0-9]+(-[a-z0-9]+)*$/;
6561
+ CONTACT_LIST_DESCRIPTION_MAX = 1e3;
6562
+ CONTACT_LIST_FILTER_MAX = 20;
6563
+ CONTACT_LIST_PINS_PER_REQUEST_MAX = 100;
6564
+ SUPPRESSION_SCOPES = ["all", "marketing"];
6565
+ SUPPRESSION_ID_REGEX = /^[0-9a-f]{64}$/;
6566
+ contactName = external_exports.string().trim().min(1).max(CONTACT_NAME_MAX);
6567
+ contactPhone = external_exports.string().max(CONTACT_PHONE_INPUT_MAX).transform((raw, ctx) => {
6568
+ const phone = normalizeContactPhone(raw);
6569
+ if (phone === null) {
6570
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "Phone must be an international number, e.g. +5511999999999" });
6571
+ return external_exports.NEVER;
6572
+ }
6573
+ return phone;
6574
+ });
6575
+ contactEmail = external_exports.string().trim().toLowerCase().max(CONTACT_EMAIL_MAX).email();
6576
+ contactInstagramSid = external_exports.string().trim().min(1).max(CONTACT_INSTAGRAM_SID_MAX);
6577
+ contactLabel = external_exports.string().max(CONTACT_LABEL_MAX).transform(normalizeContactLabel).refine((label3) => label3.length > 0, "A label cannot be empty").refine((label3) => !label3.includes(","), "A label cannot contain a comma");
6578
+ contactLabels = external_exports.array(contactLabel).max(CONTACT_LABELS_MAX).transform((labels) => [...new Set(labels)]);
6579
+ contactMetadata = external_exports.record(external_exports.unknown()).refine((metadata) => {
6580
+ try {
6581
+ return new TextEncoder().encode(JSON.stringify(metadata)).length <= CONTACT_METADATA_MAX_BYTES;
6582
+ } catch {
6583
+ return false;
6584
+ }
6585
+ }, `Metadata must serialize to at most ${CONTACT_METADATA_MAX_BYTES} bytes`);
6586
+ scopeTagIds = external_exports.array(external_exports.string().uuid()).min(1).max(CONTACT_SCOPE_TAGS_MAX).transform((ids) => [...new Set(ids)]);
6587
+ contactVisibilitySchema = external_exports.discriminatedUnion("scope", [
6588
+ external_exports.object({ scope: external_exports.literal("all_hubs") }).strict(),
6589
+ external_exports.object({ scope: external_exports.literal("tags"), tag_ids: scopeTagIds }).strict()
6590
+ ]);
6591
+ hasIdentity = (row) => Boolean(row.phone || row.email || row.instagram_sid);
6592
+ IDENTITY_REQUIRED = "A contact needs a phone, an email or an Instagram id";
6593
+ contactBookOrgQuery = external_exports.object({
6594
+ organization_id: external_exports.string().uuid()
6595
+ });
6596
+ contactBookContactParam = external_exports.object({
6597
+ contactId: external_exports.string().uuid()
6598
+ });
6599
+ contactBookListParam = external_exports.object({
6600
+ listId: external_exports.string().uuid()
6601
+ });
6602
+ contactBookHubParam = external_exports.object({
6603
+ hubId: external_exports.string().uuid()
6604
+ });
6605
+ contactBookPageQuery = external_exports.object({
6606
+ cursor: external_exports.string().max(2048).optional(),
6607
+ limit: external_exports.coerce.number().int().min(1).max(CONTACT_PAGE_MAX).default(50)
6608
+ });
6609
+ listContactBookContactsQuery = contactBookOrgQuery.merge(contactBookPageQuery).extend({
6610
+ q: external_exports.string().trim().max(CONTACT_SEARCH_MAX).optional(),
6611
+ label: external_exports.string().max(CONTACT_LABEL_MAX).transform(normalizeContactLabel).optional(),
6612
+ scope_tag_id: external_exports.string().uuid().optional()
6613
+ });
6614
+ listHubContactBookContactsQuery = contactBookPageQuery.extend({
6615
+ q: external_exports.string().trim().max(CONTACT_SEARCH_MAX).optional()
6616
+ });
6617
+ contactBookLinkCandidatesQuery = contactBookOrgQuery.extend({
6618
+ email: contactEmail
6619
+ });
6620
+ listContactBookListMembersQuery = contactBookOrgQuery.merge(contactBookPageQuery);
6621
+ contactRowFields = {
6622
+ name: contactName,
6623
+ phone: contactPhone.nullish(),
6624
+ email: contactEmail.nullish(),
6625
+ instagram_sid: contactInstagramSid.nullish(),
6626
+ labels: contactLabels.optional(),
6627
+ metadata: contactMetadata.optional()
6628
+ };
6629
+ createContactBookContactBody = external_exports.object({
6630
+ organization_id: external_exports.string().uuid(),
6631
+ ...contactRowFields,
6632
+ visibility: contactVisibilitySchema,
6633
+ environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional()
6634
+ }).strict().refine(hasIdentity, IDENTITY_REQUIRED);
6635
+ updateContactBookContactBody = external_exports.object({
6636
+ name: contactName.optional(),
6637
+ phone: contactPhone.nullable().optional(),
6638
+ email: contactEmail.nullable().optional(),
6639
+ instagram_sid: contactInstagramSid.nullable().optional(),
6640
+ labels: contactLabels.optional(),
6641
+ metadata: contactMetadata.optional(),
6642
+ visibility: contactVisibilitySchema.optional(),
6643
+ environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional()
6644
+ }).strict();
6645
+ contactImportRowSchema = external_exports.object(contactRowFields).strict().refine(hasIdentity, IDENTITY_REQUIRED);
6646
+ importContactBookContactsBody = external_exports.object({
6647
+ organization_id: external_exports.string().uuid(),
6648
+ visibility: contactVisibilitySchema,
6649
+ environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional(),
6650
+ labels: contactLabels.optional(),
6651
+ rows: external_exports.array(contactImportRowSchema).min(1).max(CONTACT_IMPORT_BATCH_MAX)
6652
+ }).strict().superRefine((batch, ctx) => {
6653
+ batch.rows.forEach((row, index) => {
6654
+ if (importRowLabels(row, batch.labels).length > CONTACT_LABELS_MAX) {
6655
+ ctx.addIssue({
6656
+ code: external_exports.ZodIssueCode.custom,
6657
+ path: ["rows", index, "labels"],
6658
+ message: `A contact holds at most ${CONTACT_LABELS_MAX} labels, the batch's included`
6659
+ });
6660
+ }
6661
+ });
6662
+ });
6663
+ linkContactBookContactBody = external_exports.object({
6664
+ user_id: external_exports.string().min(1).max(128)
6665
+ }).strict();
6666
+ listName = external_exports.string().trim().min(1).max(CONTACT_LIST_NAME_MAX).regex(CONTACT_LIST_NAME_REGEX, {
6667
+ message: 'Must be lowercase alphanumeric with hyphens (e.g. "vip-customers")'
6668
+ });
6669
+ contactListFilterSchema = external_exports.object({
6670
+ labels: external_exports.array(contactLabel).max(CONTACT_LIST_FILTER_MAX).transform((l) => [...new Set(l)]).default([]),
6671
+ scope_tag_ids: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_FILTER_MAX).transform((t) => [...new Set(t)]).default([])
6672
+ }).strict();
6673
+ createContactBookListBody = external_exports.object({
6674
+ organization_id: external_exports.string().uuid(),
6675
+ name: listName,
6676
+ description: external_exports.string().max(CONTACT_LIST_DESCRIPTION_MAX).nullish(),
6677
+ filter: contactListFilterSchema.optional()
6678
+ }).strict();
6679
+ updateContactBookListBody = external_exports.object({
6680
+ name: listName.optional(),
6681
+ description: external_exports.string().max(CONTACT_LIST_DESCRIPTION_MAX).nullable().optional(),
6682
+ filter: contactListFilterSchema.optional()
6683
+ }).strict();
6684
+ updateContactBookListPinsBody = external_exports.object({
6685
+ add: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_PINS_PER_REQUEST_MAX).default([]),
6686
+ remove: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_PINS_PER_REQUEST_MAX).default([])
6687
+ }).strict().refine((b) => b.add.length + b.remove.length > 0, "Add or remove at least one contact");
6688
+ suppressionIdentitySchema = external_exports.discriminatedUnion("kind", [
6689
+ external_exports.object({ kind: external_exports.literal("phone"), value: contactPhone }).strict(),
6690
+ external_exports.object({ kind: external_exports.literal("email"), value: contactEmail }).strict(),
6691
+ external_exports.object({ kind: external_exports.literal("instagram"), value: contactInstagramSid }).strict()
6692
+ ]);
6693
+ createContactBookSuppressionBody = external_exports.object({
6694
+ organization_id: external_exports.string().uuid(),
6695
+ identity: suppressionIdentitySchema,
6696
+ scope: external_exports.enum(SUPPRESSION_SCOPES)
6697
+ }).strict();
6698
+ contactBookSuppressionParam = external_exports.object({
6699
+ suppressionId: external_exports.string().regex(SUPPRESSION_ID_REGEX)
6700
+ });
6701
+ listContactBookSuppressionsQuery = contactBookOrgQuery.merge(contactBookPageQuery);
6702
+ contactBookEmailUnsubscribeTokenSchema = external_exports.string().max(200).regex(/^[0-9a-f-]{36}\.[0-9a-f]{64}\.[0-9a-f]{64}$/i);
6703
+ contactBookEmailUnsubscribeQuery = external_exports.object({ token: contactBookEmailUnsubscribeTokenSchema });
6704
+ orgListReferenceSchema = listName;
6705
+ }
6706
+ });
6707
+
6708
+ // ../../packages/core/dist/chunk-MGBAXT5Y.js
6709
+ var PERSON_LINKS_MAX, PERSON_DENY_PAGE_MAX, personParam, personLinkParam, deniedPersonParam, listDeniedPersonsQuery, conversationCustomerPersonParam;
6710
+ var init_chunk_MGBAXT5Y = __esm({
6711
+ "../../packages/core/dist/chunk-MGBAXT5Y.js"() {
6712
+ "use strict";
6713
+ init_chunk_2YEGUQR7();
6714
+ init_chunk_UAOHHCW5();
6715
+ init_zod();
6716
+ PERSON_LINKS_MAX = 15;
6717
+ PERSON_DENY_PAGE_MAX = 100;
6718
+ personParam = external_exports.object({
6719
+ personId: userPersonIdSchema
6720
+ });
6721
+ personLinkParam = personParam.extend({
6722
+ targetId: personIdSchema
6723
+ });
6724
+ deniedPersonParam = external_exports.object({
6725
+ personId: personIdSchema
6726
+ });
6727
+ listDeniedPersonsQuery = contactBookOrgQuery.extend({
6728
+ cursor: personIdSchema.optional(),
6729
+ limit: external_exports.coerce.number().int().min(1).max(PERSON_DENY_PAGE_MAX).default(50)
6730
+ });
6731
+ conversationCustomerPersonParam = external_exports.object({
6732
+ hubId: external_exports.string().uuid(),
6733
+ conversationId: external_exports.string().uuid()
6734
+ });
6735
+ }
6736
+ });
6737
+
6494
6738
  // ../../packages/core/dist/chunk-5DGHIY7L.js
6495
6739
  var rekorBaseChangeMessageSchema;
6496
6740
  var init_chunk_5DGHIY7L = __esm({
@@ -7449,22 +7693,41 @@ var init_chunk_PFGVH2CX = __esm({
7449
7693
  }
7450
7694
  });
7451
7695
 
7452
- // ../../packages/core/dist/chunk-TVUDMGWV.js
7453
- var bootstrapQuery;
7454
- var init_chunk_TVUDMGWV = __esm({
7455
- "../../packages/core/dist/chunk-TVUDMGWV.js"() {
7696
+ // ../../packages/core/dist/chunk-FPSDNS2E.js
7697
+ var noticeSeveritySchema, noticeStatusSchema, NOTICE_SCOPE_REGEX, noticeScopeSchema, noticeLinkSchema, createNoticeBody, updateNoticeBody, listNoticesQuery, noticeIdParamSchema;
7698
+ var init_chunk_FPSDNS2E = __esm({
7699
+ "../../packages/core/dist/chunk-FPSDNS2E.js"() {
7456
7700
  "use strict";
7457
7701
  init_zod();
7458
- bootstrapQuery = external_exports.object({
7459
- active_hub_id: external_exports.string().uuid().optional(),
7460
- active_conversation_id: external_exports.string().uuid().optional(),
7461
- active_nav: external_exports.enum(["chat", "task", "support"]).optional(),
7462
- /**
7463
- * The people thread the URL names (`/chat/threads/:threadId`, gh #4661): the snapshot
7464
- * preloads it as `people.active_thread` when the viewer is a member.
7465
- */
7466
- active_thread_id: external_exports.string().uuid().optional()
7702
+ noticeSeveritySchema = external_exports.enum(["critical", "warn", "info"]);
7703
+ noticeStatusSchema = external_exports.enum(["active", "resolved"]);
7704
+ NOTICE_SCOPE_REGEX = /^(global|provider:[a-z0-9_-]{1,40}|service:[a-z0-9_-]{1,40})$/;
7705
+ noticeScopeSchema = external_exports.string().regex(NOTICE_SCOPE_REGEX, "scope must be 'global', 'provider:<x>', or 'service:<x>'");
7706
+ noticeLinkSchema = external_exports.string().url().refine((u) => /^https?:\/\//i.test(u), { message: "link must be an http(s) URL" });
7707
+ createNoticeBody = external_exports.object({
7708
+ severity: noticeSeveritySchema.default("info"),
7709
+ scope: noticeScopeSchema.default("global"),
7710
+ title: external_exports.string().trim().min(1).max(200),
7711
+ body: external_exports.string().max(2e3).optional(),
7712
+ link: noticeLinkSchema.optional(),
7713
+ starts_at: external_exports.string().datetime().optional(),
7714
+ ends_at: external_exports.string().datetime().optional()
7715
+ });
7716
+ updateNoticeBody = external_exports.object({
7717
+ severity: noticeSeveritySchema.optional(),
7718
+ scope: noticeScopeSchema.optional(),
7719
+ title: external_exports.string().trim().min(1).max(200).optional(),
7720
+ body: external_exports.string().max(2e3).nullable().optional(),
7721
+ link: noticeLinkSchema.nullable().optional(),
7722
+ starts_at: external_exports.string().datetime().optional(),
7723
+ ends_at: external_exports.string().datetime().nullable().optional()
7724
+ }).refine((b) => Object.keys(b).length > 0, { message: "at least one field must be provided" });
7725
+ listNoticesQuery = external_exports.object({
7726
+ status: noticeStatusSchema.optional(),
7727
+ limit: external_exports.coerce.number().int().min(1).max(200).optional(),
7728
+ offset: external_exports.coerce.number().int().min(0).optional()
7467
7729
  });
7730
+ noticeIdParamSchema = external_exports.object({ id: external_exports.string().min(1) });
7468
7731
  }
7469
7732
  });
7470
7733
 
@@ -7974,231 +8237,6 @@ var init_chunk_Y7CFCYX4 = __esm({
7974
8237
  }
7975
8238
  });
7976
8239
 
7977
- // ../../packages/core/dist/chunk-2YEGUQR7.js
7978
- var PERSON_ID_PATTERN, CONTACT_PERSON_ID_PATTERN, PERSON_ID_FORM_MESSAGE, userPersonIdSchema, personIdSchema;
7979
- var init_chunk_2YEGUQR7 = __esm({
7980
- "../../packages/core/dist/chunk-2YEGUQR7.js"() {
7981
- "use strict";
7982
- init_zod();
7983
- PERSON_ID_PATTERN = /^prs_[a-z2-7]{52}$/;
7984
- CONTACT_PERSON_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
7985
- PERSON_ID_FORM_MESSAGE = "Must be a person id (prs_\u2026) or a contact id (a lowercase UUID)";
7986
- userPersonIdSchema = external_exports.string().regex(PERSON_ID_PATTERN, { message: "Must be a person id (prs_\u2026)" });
7987
- personIdSchema = external_exports.string().refine(
7988
- (value) => PERSON_ID_PATTERN.test(value) || CONTACT_PERSON_ID_PATTERN.test(value),
7989
- { message: PERSON_ID_FORM_MESSAGE }
7990
- );
7991
- }
7992
- });
7993
-
7994
- // ../../packages/core/dist/chunk-UAOHHCW5.js
7995
- function normalizeContactPhone(raw) {
7996
- const compact = raw.trim().replace(/[\s\-.()]/g, "");
7997
- const withPlus = compact.startsWith("00") ? `+${compact.slice(2)}` : compact;
7998
- return /^\+[1-9]\d{7,14}$/.test(withPlus) ? withPlus : null;
7999
- }
8000
- function normalizeContactLabel(raw) {
8001
- return raw.trim().replace(/\s+/g, " ").toLowerCase();
8002
- }
8003
- function importRowLabels(row, batchLabels) {
8004
- return [.../* @__PURE__ */ new Set([...row.labels ?? [], ...batchLabels ?? []])];
8005
- }
8006
- var CONTACT_ENVIRONMENTS, CONTACT_NAME_MAX, CONTACT_EMAIL_MAX, CONTACT_PHONE_INPUT_MAX, CONTACT_INSTAGRAM_SID_MAX, CONTACT_METADATA_MAX_BYTES, CONTACT_LABEL_MAX, CONTACT_LABELS_MAX, CONTACT_SCOPE_TAGS_MAX, CONTACT_PAGE_MAX, CONTACT_IMPORT_BATCH_MAX, CONTACT_SEARCH_MAX, CONTACT_LIST_NAME_MAX, CONTACT_LIST_NAME_REGEX, CONTACT_LIST_DESCRIPTION_MAX, CONTACT_LIST_FILTER_MAX, CONTACT_LIST_PINS_PER_REQUEST_MAX, SUPPRESSION_SCOPES, SUPPRESSION_ID_REGEX, contactName, contactPhone, contactEmail, contactInstagramSid, contactLabel, contactLabels, contactMetadata, scopeTagIds, contactVisibilitySchema, hasIdentity, IDENTITY_REQUIRED, contactBookOrgQuery, contactBookContactParam, contactBookListParam, contactBookHubParam, contactBookPageQuery, listContactBookContactsQuery, listHubContactBookContactsQuery, contactBookLinkCandidatesQuery, listContactBookListMembersQuery, contactRowFields, createContactBookContactBody, updateContactBookContactBody, contactImportRowSchema, importContactBookContactsBody, linkContactBookContactBody, listName, contactListFilterSchema, createContactBookListBody, updateContactBookListBody, updateContactBookListPinsBody, suppressionIdentitySchema, createContactBookSuppressionBody, contactBookSuppressionParam, listContactBookSuppressionsQuery, contactBookEmailUnsubscribeTokenSchema, contactBookEmailUnsubscribeQuery, orgListReferenceSchema;
8007
- var init_chunk_UAOHHCW5 = __esm({
8008
- "../../packages/core/dist/chunk-UAOHHCW5.js"() {
8009
- "use strict";
8010
- init_zod();
8011
- CONTACT_ENVIRONMENTS = ["production", "preview", "all"];
8012
- CONTACT_NAME_MAX = 200;
8013
- CONTACT_EMAIL_MAX = 320;
8014
- CONTACT_PHONE_INPUT_MAX = 40;
8015
- CONTACT_INSTAGRAM_SID_MAX = 64;
8016
- CONTACT_METADATA_MAX_BYTES = 4096;
8017
- CONTACT_LABEL_MAX = 64;
8018
- CONTACT_LABELS_MAX = 20;
8019
- CONTACT_SCOPE_TAGS_MAX = 20;
8020
- CONTACT_PAGE_MAX = 100;
8021
- CONTACT_IMPORT_BATCH_MAX = 500;
8022
- CONTACT_SEARCH_MAX = 100;
8023
- CONTACT_LIST_NAME_MAX = 64;
8024
- CONTACT_LIST_NAME_REGEX = /^[a-z0-9]+(-[a-z0-9]+)*$/;
8025
- CONTACT_LIST_DESCRIPTION_MAX = 1e3;
8026
- CONTACT_LIST_FILTER_MAX = 20;
8027
- CONTACT_LIST_PINS_PER_REQUEST_MAX = 100;
8028
- SUPPRESSION_SCOPES = ["all", "marketing"];
8029
- SUPPRESSION_ID_REGEX = /^[0-9a-f]{64}$/;
8030
- contactName = external_exports.string().trim().min(1).max(CONTACT_NAME_MAX);
8031
- contactPhone = external_exports.string().max(CONTACT_PHONE_INPUT_MAX).transform((raw, ctx) => {
8032
- const phone = normalizeContactPhone(raw);
8033
- if (phone === null) {
8034
- ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "Phone must be an international number, e.g. +5511999999999" });
8035
- return external_exports.NEVER;
8036
- }
8037
- return phone;
8038
- });
8039
- contactEmail = external_exports.string().trim().toLowerCase().max(CONTACT_EMAIL_MAX).email();
8040
- contactInstagramSid = external_exports.string().trim().min(1).max(CONTACT_INSTAGRAM_SID_MAX);
8041
- contactLabel = external_exports.string().max(CONTACT_LABEL_MAX).transform(normalizeContactLabel).refine((label3) => label3.length > 0, "A label cannot be empty").refine((label3) => !label3.includes(","), "A label cannot contain a comma");
8042
- contactLabels = external_exports.array(contactLabel).max(CONTACT_LABELS_MAX).transform((labels) => [...new Set(labels)]);
8043
- contactMetadata = external_exports.record(external_exports.unknown()).refine((metadata) => {
8044
- try {
8045
- return new TextEncoder().encode(JSON.stringify(metadata)).length <= CONTACT_METADATA_MAX_BYTES;
8046
- } catch {
8047
- return false;
8048
- }
8049
- }, `Metadata must serialize to at most ${CONTACT_METADATA_MAX_BYTES} bytes`);
8050
- scopeTagIds = external_exports.array(external_exports.string().uuid()).min(1).max(CONTACT_SCOPE_TAGS_MAX).transform((ids) => [...new Set(ids)]);
8051
- contactVisibilitySchema = external_exports.discriminatedUnion("scope", [
8052
- external_exports.object({ scope: external_exports.literal("all_hubs") }).strict(),
8053
- external_exports.object({ scope: external_exports.literal("tags"), tag_ids: scopeTagIds }).strict()
8054
- ]);
8055
- hasIdentity = (row) => Boolean(row.phone || row.email || row.instagram_sid);
8056
- IDENTITY_REQUIRED = "A contact needs a phone, an email or an Instagram id";
8057
- contactBookOrgQuery = external_exports.object({
8058
- organization_id: external_exports.string().uuid()
8059
- });
8060
- contactBookContactParam = external_exports.object({
8061
- contactId: external_exports.string().uuid()
8062
- });
8063
- contactBookListParam = external_exports.object({
8064
- listId: external_exports.string().uuid()
8065
- });
8066
- contactBookHubParam = external_exports.object({
8067
- hubId: external_exports.string().uuid()
8068
- });
8069
- contactBookPageQuery = external_exports.object({
8070
- cursor: external_exports.string().max(2048).optional(),
8071
- limit: external_exports.coerce.number().int().min(1).max(CONTACT_PAGE_MAX).default(50)
8072
- });
8073
- listContactBookContactsQuery = contactBookOrgQuery.merge(contactBookPageQuery).extend({
8074
- q: external_exports.string().trim().max(CONTACT_SEARCH_MAX).optional(),
8075
- label: external_exports.string().max(CONTACT_LABEL_MAX).transform(normalizeContactLabel).optional(),
8076
- scope_tag_id: external_exports.string().uuid().optional()
8077
- });
8078
- listHubContactBookContactsQuery = contactBookPageQuery.extend({
8079
- q: external_exports.string().trim().max(CONTACT_SEARCH_MAX).optional()
8080
- });
8081
- contactBookLinkCandidatesQuery = contactBookOrgQuery.extend({
8082
- email: contactEmail
8083
- });
8084
- listContactBookListMembersQuery = contactBookOrgQuery.merge(contactBookPageQuery);
8085
- contactRowFields = {
8086
- name: contactName,
8087
- phone: contactPhone.nullish(),
8088
- email: contactEmail.nullish(),
8089
- instagram_sid: contactInstagramSid.nullish(),
8090
- labels: contactLabels.optional(),
8091
- metadata: contactMetadata.optional()
8092
- };
8093
- createContactBookContactBody = external_exports.object({
8094
- organization_id: external_exports.string().uuid(),
8095
- ...contactRowFields,
8096
- visibility: contactVisibilitySchema,
8097
- environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional()
8098
- }).strict().refine(hasIdentity, IDENTITY_REQUIRED);
8099
- updateContactBookContactBody = external_exports.object({
8100
- name: contactName.optional(),
8101
- phone: contactPhone.nullable().optional(),
8102
- email: contactEmail.nullable().optional(),
8103
- instagram_sid: contactInstagramSid.nullable().optional(),
8104
- labels: contactLabels.optional(),
8105
- metadata: contactMetadata.optional(),
8106
- visibility: contactVisibilitySchema.optional(),
8107
- environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional()
8108
- }).strict();
8109
- contactImportRowSchema = external_exports.object(contactRowFields).strict().refine(hasIdentity, IDENTITY_REQUIRED);
8110
- importContactBookContactsBody = external_exports.object({
8111
- organization_id: external_exports.string().uuid(),
8112
- visibility: contactVisibilitySchema,
8113
- environment: external_exports.enum(CONTACT_ENVIRONMENTS).optional(),
8114
- labels: contactLabels.optional(),
8115
- rows: external_exports.array(contactImportRowSchema).min(1).max(CONTACT_IMPORT_BATCH_MAX)
8116
- }).strict().superRefine((batch, ctx) => {
8117
- batch.rows.forEach((row, index) => {
8118
- if (importRowLabels(row, batch.labels).length > CONTACT_LABELS_MAX) {
8119
- ctx.addIssue({
8120
- code: external_exports.ZodIssueCode.custom,
8121
- path: ["rows", index, "labels"],
8122
- message: `A contact holds at most ${CONTACT_LABELS_MAX} labels, the batch's included`
8123
- });
8124
- }
8125
- });
8126
- });
8127
- linkContactBookContactBody = external_exports.object({
8128
- user_id: external_exports.string().min(1).max(128)
8129
- }).strict();
8130
- listName = external_exports.string().trim().min(1).max(CONTACT_LIST_NAME_MAX).regex(CONTACT_LIST_NAME_REGEX, {
8131
- message: 'Must be lowercase alphanumeric with hyphens (e.g. "vip-customers")'
8132
- });
8133
- contactListFilterSchema = external_exports.object({
8134
- labels: external_exports.array(contactLabel).max(CONTACT_LIST_FILTER_MAX).transform((l) => [...new Set(l)]).default([]),
8135
- scope_tag_ids: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_FILTER_MAX).transform((t) => [...new Set(t)]).default([])
8136
- }).strict();
8137
- createContactBookListBody = external_exports.object({
8138
- organization_id: external_exports.string().uuid(),
8139
- name: listName,
8140
- description: external_exports.string().max(CONTACT_LIST_DESCRIPTION_MAX).nullish(),
8141
- filter: contactListFilterSchema.optional()
8142
- }).strict();
8143
- updateContactBookListBody = external_exports.object({
8144
- name: listName.optional(),
8145
- description: external_exports.string().max(CONTACT_LIST_DESCRIPTION_MAX).nullable().optional(),
8146
- filter: contactListFilterSchema.optional()
8147
- }).strict();
8148
- updateContactBookListPinsBody = external_exports.object({
8149
- add: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_PINS_PER_REQUEST_MAX).default([]),
8150
- remove: external_exports.array(external_exports.string().uuid()).max(CONTACT_LIST_PINS_PER_REQUEST_MAX).default([])
8151
- }).strict().refine((b) => b.add.length + b.remove.length > 0, "Add or remove at least one contact");
8152
- suppressionIdentitySchema = external_exports.discriminatedUnion("kind", [
8153
- external_exports.object({ kind: external_exports.literal("phone"), value: contactPhone }).strict(),
8154
- external_exports.object({ kind: external_exports.literal("email"), value: contactEmail }).strict(),
8155
- external_exports.object({ kind: external_exports.literal("instagram"), value: contactInstagramSid }).strict()
8156
- ]);
8157
- createContactBookSuppressionBody = external_exports.object({
8158
- organization_id: external_exports.string().uuid(),
8159
- identity: suppressionIdentitySchema,
8160
- scope: external_exports.enum(SUPPRESSION_SCOPES)
8161
- }).strict();
8162
- contactBookSuppressionParam = external_exports.object({
8163
- suppressionId: external_exports.string().regex(SUPPRESSION_ID_REGEX)
8164
- });
8165
- listContactBookSuppressionsQuery = contactBookOrgQuery.merge(contactBookPageQuery);
8166
- contactBookEmailUnsubscribeTokenSchema = external_exports.string().max(200).regex(/^[0-9a-f-]{36}\.[0-9a-f]{64}\.[0-9a-f]{64}$/i);
8167
- contactBookEmailUnsubscribeQuery = external_exports.object({ token: contactBookEmailUnsubscribeTokenSchema });
8168
- orgListReferenceSchema = listName;
8169
- }
8170
- });
8171
-
8172
- // ../../packages/core/dist/chunk-MGBAXT5Y.js
8173
- var PERSON_LINKS_MAX, PERSON_DENY_PAGE_MAX, personParam, personLinkParam, deniedPersonParam, listDeniedPersonsQuery, conversationCustomerPersonParam;
8174
- var init_chunk_MGBAXT5Y = __esm({
8175
- "../../packages/core/dist/chunk-MGBAXT5Y.js"() {
8176
- "use strict";
8177
- init_chunk_2YEGUQR7();
8178
- init_chunk_UAOHHCW5();
8179
- init_zod();
8180
- PERSON_LINKS_MAX = 15;
8181
- PERSON_DENY_PAGE_MAX = 100;
8182
- personParam = external_exports.object({
8183
- personId: userPersonIdSchema
8184
- });
8185
- personLinkParam = personParam.extend({
8186
- targetId: personIdSchema
8187
- });
8188
- deniedPersonParam = external_exports.object({
8189
- personId: personIdSchema
8190
- });
8191
- listDeniedPersonsQuery = contactBookOrgQuery.extend({
8192
- cursor: personIdSchema.optional(),
8193
- limit: external_exports.coerce.number().int().min(1).max(PERSON_DENY_PAGE_MAX).default(50)
8194
- });
8195
- conversationCustomerPersonParam = external_exports.object({
8196
- hubId: external_exports.string().uuid(),
8197
- conversationId: external_exports.string().uuid()
8198
- });
8199
- }
8200
- });
8201
-
8202
8240
  // ../../packages/core/dist/chunk-YUZFHVB2.js
8203
8241
  var invitePreviewQuery, inviteRolePreviewResponse, inviteContactPreviewResponse, invitePreviewResponse, inviteUnsubscribeBody;
8204
8242
  var init_chunk_YUZFHVB2 = __esm({
@@ -8645,41 +8683,18 @@ var init_chunk_34LE6P7E = __esm({
8645
8683
  }
8646
8684
  });
8647
8685
 
8648
- // ../../packages/core/dist/chunk-FPSDNS2E.js
8649
- var noticeSeveritySchema, noticeStatusSchema, NOTICE_SCOPE_REGEX, noticeScopeSchema, noticeLinkSchema, createNoticeBody, updateNoticeBody, listNoticesQuery, noticeIdParamSchema;
8650
- var init_chunk_FPSDNS2E = __esm({
8651
- "../../packages/core/dist/chunk-FPSDNS2E.js"() {
8686
+ // ../../packages/core/dist/chunk-IR2NOSI3.js
8687
+ var adminSetGuideHubBody, GUIDE_HUB_INELIGIBLE_REASON;
8688
+ var init_chunk_IR2NOSI3 = __esm({
8689
+ "../../packages/core/dist/chunk-IR2NOSI3.js"() {
8652
8690
  "use strict";
8691
+ init_chunk_HZ6CADSY();
8653
8692
  init_zod();
8654
- noticeSeveritySchema = external_exports.enum(["critical", "warn", "info"]);
8655
- noticeStatusSchema = external_exports.enum(["active", "resolved"]);
8656
- NOTICE_SCOPE_REGEX = /^(global|provider:[a-z0-9_-]{1,40}|service:[a-z0-9_-]{1,40})$/;
8657
- noticeScopeSchema = external_exports.string().regex(NOTICE_SCOPE_REGEX, "scope must be 'global', 'provider:<x>', or 'service:<x>'");
8658
- noticeLinkSchema = external_exports.string().url().refine((u) => /^https?:\/\//i.test(u), { message: "link must be an http(s) URL" });
8659
- createNoticeBody = external_exports.object({
8660
- severity: noticeSeveritySchema.default("info"),
8661
- scope: noticeScopeSchema.default("global"),
8662
- title: external_exports.string().trim().min(1).max(200),
8663
- body: external_exports.string().max(2e3).optional(),
8664
- link: noticeLinkSchema.optional(),
8665
- starts_at: external_exports.string().datetime().optional(),
8666
- ends_at: external_exports.string().datetime().optional()
8667
- });
8668
- updateNoticeBody = external_exports.object({
8669
- severity: noticeSeveritySchema.optional(),
8670
- scope: noticeScopeSchema.optional(),
8671
- title: external_exports.string().trim().min(1).max(200).optional(),
8672
- body: external_exports.string().max(2e3).nullable().optional(),
8673
- link: noticeLinkSchema.nullable().optional(),
8674
- starts_at: external_exports.string().datetime().optional(),
8675
- ends_at: external_exports.string().datetime().nullable().optional()
8676
- }).refine((b) => Object.keys(b).length > 0, { message: "at least one field must be provided" });
8677
- listNoticesQuery = external_exports.object({
8678
- status: noticeStatusSchema.optional(),
8679
- limit: external_exports.coerce.number().int().min(1).max(200).optional(),
8680
- offset: external_exports.coerce.number().int().min(0).optional()
8681
- });
8682
- noticeIdParamSchema = external_exports.object({ id: external_exports.string().min(1) });
8693
+ adminSetGuideHubBody = external_exports.object({
8694
+ hub_id: uuidSchema,
8695
+ dry_run: external_exports.boolean().optional()
8696
+ }).strict();
8697
+ GUIDE_HUB_INELIGIBLE_REASON = "guide_hub_ineligible";
8683
8698
  }
8684
8699
  });
8685
8700
 
@@ -9146,6 +9161,29 @@ var init_chunk_2ZZZHXZR = __esm({
9146
9161
  }
9147
9162
  });
9148
9163
 
9164
+ // ../../packages/core/dist/chunk-MH4O3YEX.js
9165
+ var stateOperationBody;
9166
+ var init_chunk_MH4O3YEX = __esm({
9167
+ "../../packages/core/dist/chunk-MH4O3YEX.js"() {
9168
+ "use strict";
9169
+ init_chunk_6TSQ5HXC();
9170
+ init_zod();
9171
+ stateOperationBody = external_exports.object({
9172
+ hub_id: external_exports.string().uuid(),
9173
+ operation: external_exports.enum(["get", "update", "set_path", "reset"]),
9174
+ state_slug: slugSchema,
9175
+ /**
9176
+ * Deprecated and ignored. Scope is derived from the hub's state definition.
9177
+ * Kept on the schema so legacy bodies still validate.
9178
+ */
9179
+ state_scope: external_exports.enum(["conversation", "user"]).optional(),
9180
+ updates: external_exports.record(external_exports.unknown()).optional(),
9181
+ path: external_exports.array(external_exports.string()).optional(),
9182
+ value: external_exports.unknown().optional()
9183
+ });
9184
+ }
9185
+ });
9186
+
9149
9187
  // ../../packages/core/dist/chunk-IBL7FANV.js
9150
9188
  var SUMMARIZATION_THRESHOLD_MIN, SUMMARIZATION_THRESHOLD_MAX;
9151
9189
  var init_chunk_IBL7FANV = __esm({
@@ -12731,21 +12769,6 @@ var init_chunk_C4HEZ7ZI = __esm({
12731
12769
  }
12732
12770
  });
12733
12771
 
12734
- // ../../packages/core/dist/chunk-IR2NOSI3.js
12735
- var adminSetGuideHubBody, GUIDE_HUB_INELIGIBLE_REASON;
12736
- var init_chunk_IR2NOSI3 = __esm({
12737
- "../../packages/core/dist/chunk-IR2NOSI3.js"() {
12738
- "use strict";
12739
- init_chunk_HZ6CADSY();
12740
- init_zod();
12741
- adminSetGuideHubBody = external_exports.object({
12742
- hub_id: uuidSchema,
12743
- dry_run: external_exports.boolean().optional()
12744
- }).strict();
12745
- GUIDE_HUB_INELIGIBLE_REASON = "guide_hub_ineligible";
12746
- }
12747
- });
12748
-
12749
12772
  // ../../packages/core/dist/chunk-YULHXJ5M.js
12750
12773
  var COMMUNITY_LESSON_TREE_MAX_BYTES, COMMUNITY_LESSON_LINK_PROTOCOLS, COMMUNITY_LESSON_TREE_TOO_LARGE_REASON, COMMUNITY_LESSON_TREE_TOO_DEEP_REASON, COMMUNITY_LESSON_LINE_PREFIX_TOO_WIDE_REASON, LINK_SCHEME;
12751
12774
  var init_chunk_YULHXJ5M = __esm({
@@ -12849,29 +12872,6 @@ var init_chunk_ACGAI25T = __esm({
12849
12872
  }
12850
12873
  });
12851
12874
 
12852
- // ../../packages/core/dist/chunk-MH4O3YEX.js
12853
- var stateOperationBody;
12854
- var init_chunk_MH4O3YEX = __esm({
12855
- "../../packages/core/dist/chunk-MH4O3YEX.js"() {
12856
- "use strict";
12857
- init_chunk_6TSQ5HXC();
12858
- init_zod();
12859
- stateOperationBody = external_exports.object({
12860
- hub_id: external_exports.string().uuid(),
12861
- operation: external_exports.enum(["get", "update", "set_path", "reset"]),
12862
- state_slug: slugSchema,
12863
- /**
12864
- * Deprecated and ignored. Scope is derived from the hub's state definition.
12865
- * Kept on the schema so legacy bodies still validate.
12866
- */
12867
- state_scope: external_exports.enum(["conversation", "user"]).optional(),
12868
- updates: external_exports.record(external_exports.unknown()).optional(),
12869
- path: external_exports.array(external_exports.string()).optional(),
12870
- value: external_exports.unknown().optional()
12871
- });
12872
- }
12873
- });
12874
-
12875
12875
  // ../../packages/core/dist/chunk-5Y2NNQHX.js
12876
12876
  var CASE_SUBMISSION_ISSUED_KINDS, CASE_SUBMISSION_RENDER_STUCK_MS, CASE_SUBMISSION_MARK_ID_PATTERN, CASE_CORRECTION_REASON_MAX_LENGTH, submitCaseBody, correctCaseSubmissionBody, caseDeliveryQuery;
12877
12877
  var init_chunk_5Y2NNQHX = __esm({
@@ -16608,6 +16608,25 @@ var init_chunk_M2IF4G6X = __esm({
16608
16608
  }
16609
16609
  });
16610
16610
 
16611
+ // ../../packages/core/dist/chunk-UOPCLXCU.js
16612
+ var CASE_CHANGE_TOPICS, caseChangedFrameSchema;
16613
+ var init_chunk_UOPCLXCU = __esm({
16614
+ "../../packages/core/dist/chunk-UOPCLXCU.js"() {
16615
+ "use strict";
16616
+ init_chunk_733K4J4G();
16617
+ init_chunk_HZ6CADSY();
16618
+ init_zod();
16619
+ CASE_CHANGE_TOPICS = ["submission", "agenda", "access"];
16620
+ caseChangedFrameSchema = external_exports.object({
16621
+ org_id: uuidSchema,
16622
+ space_id: uuidSchema,
16623
+ /** The case, by its code; null for an `access` change, which names none. */
16624
+ code: caseRecordParam.shape.code.nullable(),
16625
+ topic: external_exports.enum(CASE_CHANGE_TOPICS)
16626
+ }).strict();
16627
+ }
16628
+ });
16629
+
16611
16630
  // ../../packages/core/dist/chunk-7CZSLDOE.js
16612
16631
  var CASE_MEMBER_CASES_PAGE_MAX, caseMemberReachQuery;
16613
16632
  var init_chunk_7CZSLDOE = __esm({
@@ -16976,237 +16995,6 @@ var init_chunk_WYCUCSD5 = __esm({
16976
16995
  }
16977
16996
  });
16978
16997
 
16979
- // ../../packages/core/dist/chunk-H6V7NEWR.js
16980
- function isCaseDueDate(value) {
16981
- const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
16982
- if (!match) return false;
16983
- const [year, month, day] = [Number(match[1]), Number(match[2]), Number(match[3])];
16984
- if (year < CASE_DUE_DATE_MIN_YEAR || year > CASE_DUE_DATE_MAX_YEAR) return false;
16985
- const date = new Date(Date.UTC(year, month - 1, day));
16986
- return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
16987
- }
16988
- function setCaseDeadlinesProblem(body) {
16989
- const seen = /* @__PURE__ */ new Set();
16990
- for (const [index, phase] of body.phases.entries()) {
16991
- if (seen.has(phase.phase_id)) return { reason: "phase_repeated", at: `phases.${index}.phase_id` };
16992
- seen.add(phase.phase_id);
16993
- }
16994
- return null;
16995
- }
16996
- var CASE_DUE_DATE_MIN_YEAR, CASE_DUE_DATE_MAX_YEAR, CASE_DEADLINES_PHASES_MAX, CASE_OVERDUE_CASES_MAX, caseDueDateSchema, setCaseDeadlinesShape, setCaseDeadlinesBody, setCaseTaskPlanBody, setCaseOwnerBody, caseOverdueQuery;
16997
- var init_chunk_H6V7NEWR = __esm({
16998
- "../../packages/core/dist/chunk-H6V7NEWR.js"() {
16999
- "use strict";
17000
- init_chunk_3T3D7LTE();
17001
- init_chunk_HZ6CADSY();
17002
- init_zod();
17003
- CASE_DUE_DATE_MIN_YEAR = 2e3;
17004
- CASE_DUE_DATE_MAX_YEAR = 2100;
17005
- CASE_DEADLINES_PHASES_MAX = 50;
17006
- CASE_OVERDUE_CASES_MAX = 50;
17007
- caseDueDateSchema = external_exports.string().refine(isCaseDueDate, "Not a calendar date (YYYY-MM-DD)");
17008
- setCaseDeadlinesShape = external_exports.object({
17009
- phases: external_exports.array(external_exports.object({ phase_id: uuidSchema, due_on: caseDueDateSchema.nullable() }).strict()).min(1).max(CASE_DEADLINES_PHASES_MAX)
17010
- }).strict();
17011
- setCaseDeadlinesBody = setCaseDeadlinesShape.superRefine((body, ctx) => {
17012
- const found = setCaseDeadlinesProblem(body);
17013
- if (found) {
17014
- ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: found.reason, path: found.at.split("."), params: { case_deadlines_reason: found.reason } });
17015
- }
17016
- });
17017
- setCaseTaskPlanBody = external_exports.object({
17018
- owner_person_id: uuidSchema.nullable(),
17019
- due_on: caseDueDateSchema.nullable()
17020
- }).strict();
17021
- setCaseOwnerBody = external_exports.object({ owner_person_id: uuidSchema.nullable() }).strict();
17022
- caseOverdueQuery = casePageQuery.extend({
17023
- limit: external_exports.coerce.number().int().min(1).max(CASE_OVERDUE_CASES_MAX).optional()
17024
- });
17025
- }
17026
- });
17027
-
17028
- // ../../packages/core/dist/chunk-ZVIMTUGZ.js
17029
- var CASE_GUEST_EMAIL_MAX, CASE_GUEST_INVITATIONS_PAGE_MAX, CASE_GUEST_INVITE_TOKEN_LENGTH, caseGuestEmailSchema, caseGuestInviteTokenSchema, inviteCaseGuestBody, caseGuestInvitationParam, caseGuestInvitationsQuery, joinCaseSpaceBody, caseJoinSearchParams;
17030
- var init_chunk_ZVIMTUGZ = __esm({
17031
- "../../packages/core/dist/chunk-ZVIMTUGZ.js"() {
17032
- "use strict";
17033
- init_chunk_3T3D7LTE();
17034
- init_chunk_HZ6CADSY();
17035
- init_zod();
17036
- CASE_GUEST_EMAIL_MAX = 320;
17037
- CASE_GUEST_INVITATIONS_PAGE_MAX = 100;
17038
- CASE_GUEST_INVITE_TOKEN_LENGTH = 43;
17039
- caseGuestEmailSchema = external_exports.string().trim().toLowerCase().max(CASE_GUEST_EMAIL_MAX).email();
17040
- caseGuestInviteTokenSchema = external_exports.string().regex(new RegExp(`^[A-Za-z0-9_-]{${CASE_GUEST_INVITE_TOKEN_LENGTH}}$`));
17041
- inviteCaseGuestBody = external_exports.object({ email: caseGuestEmailSchema }).strict();
17042
- caseGuestInvitationParam = caseSpaceParam.extend({ invitation_id: uuidSchema });
17043
- caseGuestInvitationsQuery = casePageQuery.extend({
17044
- limit: external_exports.coerce.number().int().min(1).max(CASE_GUEST_INVITATIONS_PAGE_MAX).optional()
17045
- });
17046
- joinCaseSpaceBody = external_exports.object({ invite: caseGuestInviteTokenSchema }).strict();
17047
- caseJoinSearchParams = external_exports.object({ org: uuidSchema, space: uuidSchema, invite: caseGuestInviteTokenSchema });
17048
- }
17049
- });
17050
-
17051
- // ../../packages/core/dist/chunk-BVQCYBU6.js
17052
- var CASE_RELATION_TYPE_CODE_PATTERN, CASE_RELATION_TYPE_CODE_MAX_LENGTH, CASE_RELATION_TYPE_NAME_MAX_LENGTH, CASE_RELATION_TYPES_PER_SPACE_MAX, CASE_RELATION_DESCRIPTION_MAX_LENGTH, CASE_RELATION_SIDES, CASE_EXTERNAL_SYSTEM_PATTERN, CASE_EXTERNAL_NUMBER_MAX_LENGTH, CASE_EXTERNAL_URL_MAX_LENGTH, trimmedName2, relationTypeFields, createCaseRelationTypeBody, updateCaseRelationTypeBody, relateCasesBody, addCaseExternalReferenceBody, caseRelationTypeParam, caseRelationParam, caseExternalReferenceParam, caseRelationTypesQuery;
17053
- var init_chunk_BVQCYBU6 = __esm({
17054
- "../../packages/core/dist/chunk-BVQCYBU6.js"() {
17055
- "use strict";
17056
- init_chunk_733K4J4G();
17057
- init_chunk_3T3D7LTE();
17058
- init_chunk_HZ6CADSY();
17059
- init_zod();
17060
- CASE_RELATION_TYPE_CODE_PATTERN = /^[a-z0-9]+(_[a-z0-9]+)*$/;
17061
- CASE_RELATION_TYPE_CODE_MAX_LENGTH = 64;
17062
- CASE_RELATION_TYPE_NAME_MAX_LENGTH = 200;
17063
- CASE_RELATION_TYPES_PER_SPACE_MAX = 100;
17064
- CASE_RELATION_DESCRIPTION_MAX_LENGTH = 500;
17065
- CASE_RELATION_SIDES = ["origin", "destination"];
17066
- CASE_EXTERNAL_SYSTEM_PATTERN = /^[A-Za-z0-9][A-Za-z0-9 ._-]{0,30}$/;
17067
- CASE_EXTERNAL_NUMBER_MAX_LENGTH = 120;
17068
- CASE_EXTERNAL_URL_MAX_LENGTH = 2048;
17069
- trimmedName2 = external_exports.string().trim().min(1).max(CASE_RELATION_TYPE_NAME_MAX_LENGTH);
17070
- relationTypeFields = { name: trimmedName2, inverse_name: trimmedName2, active: external_exports.boolean().default(true) };
17071
- createCaseRelationTypeBody = external_exports.object({
17072
- code: external_exports.string().trim().max(CASE_RELATION_TYPE_CODE_MAX_LENGTH).regex(CASE_RELATION_TYPE_CODE_PATTERN),
17073
- ...relationTypeFields
17074
- }).strict();
17075
- updateCaseRelationTypeBody = external_exports.object({ ...relationTypeFields, expected_updated_at: timestampSchema.optional() }).strict();
17076
- relateCasesBody = external_exports.object({
17077
- relation_type_id: uuidSchema,
17078
- other_code: external_exports.string().max(CASE_RECORD_CODE_MAX_LENGTH).regex(CASE_RECORD_CODE_PATTERN),
17079
- /** This case's side: `origin` reads the type's name ("continues"), `destination` its inverse. */
17080
- side: external_exports.enum(CASE_RELATION_SIDES).default("origin"),
17081
- description: external_exports.string().trim().min(1).max(CASE_RELATION_DESCRIPTION_MAX_LENGTH).nullable().default(null)
17082
- }).strict();
17083
- addCaseExternalReferenceBody = external_exports.object({
17084
- system: external_exports.string().trim().regex(CASE_EXTERNAL_SYSTEM_PATTERN),
17085
- number: external_exports.string().trim().min(1).max(CASE_EXTERNAL_NUMBER_MAX_LENGTH),
17086
- url: external_exports.string().trim().max(CASE_EXTERNAL_URL_MAX_LENGTH).url().refine((url) => url.startsWith("https://"), "An https link").nullable().default(null)
17087
- }).strict();
17088
- caseRelationTypeParam = caseSpaceParam.extend({ relation_type_id: uuidSchema });
17089
- caseRelationParam = caseRecordParam.extend({ relation_id: uuidSchema });
17090
- caseExternalReferenceParam = caseRecordParam.extend({ reference_id: uuidSchema });
17091
- caseRelationTypesQuery = casePageQuery.extend({
17092
- limit: external_exports.coerce.number().int().min(1).max(CASE_RELATION_TYPES_PER_SPACE_MAX).optional()
17093
- });
17094
- }
17095
- });
17096
-
17097
- // ../../packages/core/dist/chunk-UOPCLXCU.js
17098
- var CASE_CHANGE_TOPICS, caseChangedFrameSchema;
17099
- var init_chunk_UOPCLXCU = __esm({
17100
- "../../packages/core/dist/chunk-UOPCLXCU.js"() {
17101
- "use strict";
17102
- init_chunk_733K4J4G();
17103
- init_chunk_HZ6CADSY();
17104
- init_zod();
17105
- CASE_CHANGE_TOPICS = ["submission", "agenda", "access"];
17106
- caseChangedFrameSchema = external_exports.object({
17107
- org_id: uuidSchema,
17108
- space_id: uuidSchema,
17109
- /** The case, by its code; null for an `access` change, which names none. */
17110
- code: caseRecordParam.shape.code.nullable(),
17111
- topic: external_exports.enum(CASE_CHANGE_TOPICS)
17112
- }).strict();
17113
- }
17114
- });
17115
-
17116
- // ../../packages/core/dist/chunk-Z3SV3XTC.js
17117
- var caseAccessQuery;
17118
- var init_chunk_Z3SV3XTC = __esm({
17119
- "../../packages/core/dist/chunk-Z3SV3XTC.js"() {
17120
- "use strict";
17121
- init_chunk_HZ6CADSY();
17122
- init_zod();
17123
- caseAccessQuery = external_exports.object({ with_team_id: uuidSchema.optional() }).strict();
17124
- }
17125
- });
17126
-
17127
- // ../../packages/core/dist/chunk-NHC27NIE.js
17128
- var CASE_ADJUSTMENT_REASON_MAX_LENGTH, CASE_ADJUSTMENT_DISPENSATION_KINDS, reason, activateCasePhaseBody, dispenseCaseBody, addCaseTaskBody, addCaseInputBody, caseOwnItemSchema, addCaseItemBody;
17129
- var init_chunk_NHC27NIE = __esm({
17130
- "../../packages/core/dist/chunk-NHC27NIE.js"() {
17131
- "use strict";
17132
- init_chunk_PFPADFUC();
17133
- init_chunk_HZ6CADSY();
17134
- init_zod();
17135
- CASE_ADJUSTMENT_REASON_MAX_LENGTH = 2e3;
17136
- CASE_ADJUSTMENT_DISPENSATION_KINDS = ["phase", "item", "output", "input"];
17137
- reason = external_exports.string().trim().min(1).max(CASE_ADJUSTMENT_REASON_MAX_LENGTH);
17138
- activateCasePhaseBody = external_exports.object({ phase_id: uuidSchema, reason }).strict();
17139
- dispenseCaseBody = external_exports.object({ kind: external_exports.enum(CASE_ADJUSTMENT_DISPENSATION_KINDS), target_id: uuidSchema, reason }).strict();
17140
- addCaseTaskBody = external_exports.object({
17141
- phase_id: uuidSchema,
17142
- name: external_exports.string().trim().min(1).max(CASE_TASK_NAME_MAX_LENGTH),
17143
- required: external_exports.boolean().default(false),
17144
- /** Tasks of the same phase it waits for. */
17145
- depends_on: external_exports.array(uuidSchema).max(CASE_TASK_DEPENDENCIES_MAX).default([])
17146
- }).strict();
17147
- addCaseInputBody = external_exports.object({
17148
- phase_id: uuidSchema,
17149
- input: casePhaseInputSchema.extend({ agenda_group: caseAgendaGroupCodeSchema.nullable().default(null) }),
17150
- reason
17151
- }).strict();
17152
- caseOwnItemSchema = caseOutputItemSchema.omit({ waivable: true, template_mode: true, fixed_text: true }).extend({ agenda_group: caseAgendaGroupCodeSchema.nullable().default(null) });
17153
- addCaseItemBody = external_exports.object({
17154
- phase_id: uuidSchema,
17155
- /** The phase's output it goes in. */
17156
- output_id: uuidSchema,
17157
- item: caseOwnItemSchema,
17158
- reason
17159
- }).strict();
17160
- }
17161
- });
17162
-
17163
- // ../../packages/core/dist/chunk-UMAPAGFH.js
17164
- var CASE_AGENDA_VALUE_MAX_LENGTH, CASE_AGENDA_JUSTIFICATION_MAX_LENGTH, CASE_AGENDA_EVIDENCE_MAX_LENGTH, CASE_AGENDA_COMMENT_MAX_LENGTH, CASE_AGENDA_VERDICTS, comment, caseAgendaGroupParam, caseAgendaDecisionParam, caseAgendaQuery, caseApprovedDecisionsQuery, proposeCaseAgendaValueBody, decideCaseAgendaBody, dispenseCaseAgendaBody, addCaseDecisionBody;
17165
- var init_chunk_UMAPAGFH = __esm({
17166
- "../../packages/core/dist/chunk-UMAPAGFH.js"() {
17167
- "use strict";
17168
- init_chunk_733K4J4G();
17169
- init_chunk_PFPADFUC();
17170
- init_chunk_3T3D7LTE();
17171
- init_chunk_M2T55BV6();
17172
- init_chunk_HZ6CADSY();
17173
- init_zod();
17174
- CASE_AGENDA_VALUE_MAX_LENGTH = 2e3;
17175
- CASE_AGENDA_JUSTIFICATION_MAX_LENGTH = 2e3;
17176
- CASE_AGENDA_EVIDENCE_MAX_LENGTH = 500;
17177
- CASE_AGENDA_COMMENT_MAX_LENGTH = 2e3;
17178
- CASE_AGENDA_VERDICTS = ["approve", "return"];
17179
- comment = external_exports.string().trim().min(1).max(CASE_AGENDA_COMMENT_MAX_LENGTH);
17180
- caseAgendaGroupParam = caseRecordParam.extend({ group_id: uuidSchema });
17181
- caseAgendaDecisionParam = caseRecordParam.extend({ decision_code: caseDecisionCodeSchema });
17182
- caseAgendaQuery = external_exports.object({
17183
- phase_id: uuidSchema,
17184
- cursor: external_exports.string().min(1).max(CASE_PAGE_CURSOR_MAX_LENGTH).optional()
17185
- });
17186
- caseApprovedDecisionsQuery = external_exports.object({
17187
- confidential: external_exports.enum(["true", "false"]).optional().transform((value) => value === "true")
17188
- });
17189
- proposeCaseAgendaValueBody = external_exports.object({
17190
- /** As written: a numeric type also takes a string of digits with a `.` or `,` decimal mark (Rito's). */
17191
- value: external_exports.union([external_exports.number(), external_exports.boolean(), external_exports.string().max(CASE_AGENDA_VALUE_MAX_LENGTH)]),
17192
- justification: external_exports.string().trim().min(1).max(CASE_AGENDA_JUSTIFICATION_MAX_LENGTH),
17193
- evidence: external_exports.string().trim().max(CASE_AGENDA_EVIDENCE_MAX_LENGTH).nullable().default(null).transform((text5) => text5 || null),
17194
- /** Required on an approved group: why it is revised. */
17195
- reason: comment.nullable().default(null)
17196
- }).strict();
17197
- decideCaseAgendaBody = external_exports.object({
17198
- decision: external_exports.enum(CASE_AGENDA_VERDICTS),
17199
- /** The sending its decider read (`CaseAgendaGroupView.sending_id`). */
17200
- sending_id: uuidSchema,
17201
- comment: comment.nullable().default(null)
17202
- }).strict().superRefine((body, ctx) => {
17203
- if (body.decision === "return" && body.comment === null) ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "A return needs its comment", path: ["comment"] });
17204
- });
17205
- dispenseCaseAgendaBody = external_exports.object({ reason: comment }).strict();
17206
- addCaseDecisionBody = external_exports.object({ decision: caseAgendaDecisionSchema, reason: comment }).strict();
17207
- }
17208
- });
17209
-
17210
16998
  // ../../packages/core/dist/chunk-7TQYAKCB.js
17211
16999
  function addCaseNoteProblem(note) {
17212
17000
  return note.origin !== null && note.kind !== "contribution" ? { reason: "origin_not_contribution", at: "origin" } : null;
@@ -17292,7 +17080,7 @@ var init_chunk_S7UAXLHJ = __esm({
17292
17080
  });
17293
17081
 
17294
17082
  // ../../packages/core/dist/chunk-S4NDHW3Q.js
17295
- var CASE_VERSION_DECISION_REASON_MAX_LENGTH, CASE_VERSION_DECISIONS, caseVersionDecisionReason, reason2, lineNumber2, recordCaseReferenceBody, CASE_PASSAGE_REVERSED_REASON, citeCasePassageBody, decideCaseVersionBody;
17083
+ var CASE_VERSION_DECISION_REASON_MAX_LENGTH, CASE_VERSION_DECISIONS, caseVersionDecisionReason, reason, lineNumber2, recordCaseReferenceBody, CASE_PASSAGE_REVERSED_REASON, citeCasePassageBody, decideCaseVersionBody;
17296
17084
  var init_chunk_S4NDHW3Q = __esm({
17297
17085
  "../../packages/core/dist/chunk-S4NDHW3Q.js"() {
17298
17086
  "use strict";
@@ -17302,7 +17090,7 @@ var init_chunk_S4NDHW3Q = __esm({
17302
17090
  CASE_VERSION_DECISION_REASON_MAX_LENGTH = 2e3;
17303
17091
  CASE_VERSION_DECISIONS = ["adopt", "keep"];
17304
17092
  caseVersionDecisionReason = external_exports.string().trim().min(1).max(CASE_VERSION_DECISION_REASON_MAX_LENGTH);
17305
- reason2 = caseVersionDecisionReason;
17093
+ reason = caseVersionDecisionReason;
17306
17094
  lineNumber2 = casePassageLineSchema;
17307
17095
  recordCaseReferenceBody = external_exports.object({
17308
17096
  document_id: uuidSchema,
@@ -17322,7 +17110,7 @@ var init_chunk_S4NDHW3Q = __esm({
17322
17110
  decision: external_exports.enum(CASE_VERSION_DECISIONS),
17323
17111
  /** The newer version its decider read as current. */
17324
17112
  expect_version_id: uuidSchema,
17325
- reason: reason2.nullable().default(null)
17113
+ reason: reason.nullable().default(null)
17326
17114
  }).strict().superRefine((body, ctx) => {
17327
17115
  if (body.decision === "keep" && body.reason === null) ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "A version kept needs its reason", path: ["reason"] });
17328
17116
  });
@@ -17360,6 +17148,329 @@ var init_chunk_UZ72OHQN = __esm({
17360
17148
  }
17361
17149
  });
17362
17150
 
17151
+ // ../../packages/core/dist/chunk-H6V7NEWR.js
17152
+ function isCaseDueDate(value) {
17153
+ const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
17154
+ if (!match) return false;
17155
+ const [year, month, day] = [Number(match[1]), Number(match[2]), Number(match[3])];
17156
+ if (year < CASE_DUE_DATE_MIN_YEAR || year > CASE_DUE_DATE_MAX_YEAR) return false;
17157
+ const date = new Date(Date.UTC(year, month - 1, day));
17158
+ return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
17159
+ }
17160
+ function setCaseDeadlinesProblem(body) {
17161
+ const seen = /* @__PURE__ */ new Set();
17162
+ for (const [index, phase] of body.phases.entries()) {
17163
+ if (seen.has(phase.phase_id)) return { reason: "phase_repeated", at: `phases.${index}.phase_id` };
17164
+ seen.add(phase.phase_id);
17165
+ }
17166
+ return null;
17167
+ }
17168
+ var CASE_DUE_DATE_MIN_YEAR, CASE_DUE_DATE_MAX_YEAR, CASE_DEADLINES_PHASES_MAX, CASE_OVERDUE_CASES_MAX, caseDueDateSchema, setCaseDeadlinesShape, setCaseDeadlinesBody, setCaseTaskPlanBody, setCaseOwnerBody, caseOverdueQuery;
17169
+ var init_chunk_H6V7NEWR = __esm({
17170
+ "../../packages/core/dist/chunk-H6V7NEWR.js"() {
17171
+ "use strict";
17172
+ init_chunk_3T3D7LTE();
17173
+ init_chunk_HZ6CADSY();
17174
+ init_zod();
17175
+ CASE_DUE_DATE_MIN_YEAR = 2e3;
17176
+ CASE_DUE_DATE_MAX_YEAR = 2100;
17177
+ CASE_DEADLINES_PHASES_MAX = 50;
17178
+ CASE_OVERDUE_CASES_MAX = 50;
17179
+ caseDueDateSchema = external_exports.string().refine(isCaseDueDate, "Not a calendar date (YYYY-MM-DD)");
17180
+ setCaseDeadlinesShape = external_exports.object({
17181
+ phases: external_exports.array(external_exports.object({ phase_id: uuidSchema, due_on: caseDueDateSchema.nullable() }).strict()).min(1).max(CASE_DEADLINES_PHASES_MAX)
17182
+ }).strict();
17183
+ setCaseDeadlinesBody = setCaseDeadlinesShape.superRefine((body, ctx) => {
17184
+ const found = setCaseDeadlinesProblem(body);
17185
+ if (found) {
17186
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: found.reason, path: found.at.split("."), params: { case_deadlines_reason: found.reason } });
17187
+ }
17188
+ });
17189
+ setCaseTaskPlanBody = external_exports.object({
17190
+ owner_person_id: uuidSchema.nullable(),
17191
+ due_on: caseDueDateSchema.nullable()
17192
+ }).strict();
17193
+ setCaseOwnerBody = external_exports.object({ owner_person_id: uuidSchema.nullable() }).strict();
17194
+ caseOverdueQuery = casePageQuery.extend({
17195
+ limit: external_exports.coerce.number().int().min(1).max(CASE_OVERDUE_CASES_MAX).optional()
17196
+ });
17197
+ }
17198
+ });
17199
+
17200
+ // ../../packages/core/dist/chunk-ZVIMTUGZ.js
17201
+ var CASE_GUEST_EMAIL_MAX, CASE_GUEST_INVITATIONS_PAGE_MAX, CASE_GUEST_INVITE_TOKEN_LENGTH, caseGuestEmailSchema, caseGuestInviteTokenSchema, inviteCaseGuestBody, caseGuestInvitationParam, caseGuestInvitationsQuery, joinCaseSpaceBody, caseJoinSearchParams;
17202
+ var init_chunk_ZVIMTUGZ = __esm({
17203
+ "../../packages/core/dist/chunk-ZVIMTUGZ.js"() {
17204
+ "use strict";
17205
+ init_chunk_3T3D7LTE();
17206
+ init_chunk_HZ6CADSY();
17207
+ init_zod();
17208
+ CASE_GUEST_EMAIL_MAX = 320;
17209
+ CASE_GUEST_INVITATIONS_PAGE_MAX = 100;
17210
+ CASE_GUEST_INVITE_TOKEN_LENGTH = 43;
17211
+ caseGuestEmailSchema = external_exports.string().trim().toLowerCase().max(CASE_GUEST_EMAIL_MAX).email();
17212
+ caseGuestInviteTokenSchema = external_exports.string().regex(new RegExp(`^[A-Za-z0-9_-]{${CASE_GUEST_INVITE_TOKEN_LENGTH}}$`));
17213
+ inviteCaseGuestBody = external_exports.object({ email: caseGuestEmailSchema }).strict();
17214
+ caseGuestInvitationParam = caseSpaceParam.extend({ invitation_id: uuidSchema });
17215
+ caseGuestInvitationsQuery = casePageQuery.extend({
17216
+ limit: external_exports.coerce.number().int().min(1).max(CASE_GUEST_INVITATIONS_PAGE_MAX).optional()
17217
+ });
17218
+ joinCaseSpaceBody = external_exports.object({ invite: caseGuestInviteTokenSchema }).strict();
17219
+ caseJoinSearchParams = external_exports.object({ org: uuidSchema, space: uuidSchema, invite: caseGuestInviteTokenSchema });
17220
+ }
17221
+ });
17222
+
17223
+ // ../../packages/core/dist/chunk-BVQCYBU6.js
17224
+ var CASE_RELATION_TYPE_CODE_PATTERN, CASE_RELATION_TYPE_CODE_MAX_LENGTH, CASE_RELATION_TYPE_NAME_MAX_LENGTH, CASE_RELATION_TYPES_PER_SPACE_MAX, CASE_RELATION_DESCRIPTION_MAX_LENGTH, CASE_RELATION_SIDES, CASE_EXTERNAL_SYSTEM_PATTERN, CASE_EXTERNAL_NUMBER_MAX_LENGTH, CASE_EXTERNAL_URL_MAX_LENGTH, trimmedName2, relationTypeFields, createCaseRelationTypeBody, updateCaseRelationTypeBody, relateCasesBody, addCaseExternalReferenceBody, caseRelationTypeParam, caseRelationParam, caseExternalReferenceParam, caseRelationTypesQuery;
17225
+ var init_chunk_BVQCYBU6 = __esm({
17226
+ "../../packages/core/dist/chunk-BVQCYBU6.js"() {
17227
+ "use strict";
17228
+ init_chunk_733K4J4G();
17229
+ init_chunk_3T3D7LTE();
17230
+ init_chunk_HZ6CADSY();
17231
+ init_zod();
17232
+ CASE_RELATION_TYPE_CODE_PATTERN = /^[a-z0-9]+(_[a-z0-9]+)*$/;
17233
+ CASE_RELATION_TYPE_CODE_MAX_LENGTH = 64;
17234
+ CASE_RELATION_TYPE_NAME_MAX_LENGTH = 200;
17235
+ CASE_RELATION_TYPES_PER_SPACE_MAX = 100;
17236
+ CASE_RELATION_DESCRIPTION_MAX_LENGTH = 500;
17237
+ CASE_RELATION_SIDES = ["origin", "destination"];
17238
+ CASE_EXTERNAL_SYSTEM_PATTERN = /^[A-Za-z0-9][A-Za-z0-9 ._-]{0,30}$/;
17239
+ CASE_EXTERNAL_NUMBER_MAX_LENGTH = 120;
17240
+ CASE_EXTERNAL_URL_MAX_LENGTH = 2048;
17241
+ trimmedName2 = external_exports.string().trim().min(1).max(CASE_RELATION_TYPE_NAME_MAX_LENGTH);
17242
+ relationTypeFields = { name: trimmedName2, inverse_name: trimmedName2, active: external_exports.boolean().default(true) };
17243
+ createCaseRelationTypeBody = external_exports.object({
17244
+ code: external_exports.string().trim().max(CASE_RELATION_TYPE_CODE_MAX_LENGTH).regex(CASE_RELATION_TYPE_CODE_PATTERN),
17245
+ ...relationTypeFields
17246
+ }).strict();
17247
+ updateCaseRelationTypeBody = external_exports.object({ ...relationTypeFields, expected_updated_at: timestampSchema.optional() }).strict();
17248
+ relateCasesBody = external_exports.object({
17249
+ relation_type_id: uuidSchema,
17250
+ other_code: external_exports.string().max(CASE_RECORD_CODE_MAX_LENGTH).regex(CASE_RECORD_CODE_PATTERN),
17251
+ /** This case's side: `origin` reads the type's name ("continues"), `destination` its inverse. */
17252
+ side: external_exports.enum(CASE_RELATION_SIDES).default("origin"),
17253
+ description: external_exports.string().trim().min(1).max(CASE_RELATION_DESCRIPTION_MAX_LENGTH).nullable().default(null)
17254
+ }).strict();
17255
+ addCaseExternalReferenceBody = external_exports.object({
17256
+ system: external_exports.string().trim().regex(CASE_EXTERNAL_SYSTEM_PATTERN),
17257
+ number: external_exports.string().trim().min(1).max(CASE_EXTERNAL_NUMBER_MAX_LENGTH),
17258
+ url: external_exports.string().trim().max(CASE_EXTERNAL_URL_MAX_LENGTH).url().refine((url) => url.startsWith("https://"), "An https link").nullable().default(null)
17259
+ }).strict();
17260
+ caseRelationTypeParam = caseSpaceParam.extend({ relation_type_id: uuidSchema });
17261
+ caseRelationParam = caseRecordParam.extend({ relation_id: uuidSchema });
17262
+ caseExternalReferenceParam = caseRecordParam.extend({ reference_id: uuidSchema });
17263
+ caseRelationTypesQuery = casePageQuery.extend({
17264
+ limit: external_exports.coerce.number().int().min(1).max(CASE_RELATION_TYPES_PER_SPACE_MAX).optional()
17265
+ });
17266
+ }
17267
+ });
17268
+
17269
+ // ../../packages/core/dist/chunk-Z3SV3XTC.js
17270
+ var caseAccessQuery;
17271
+ var init_chunk_Z3SV3XTC = __esm({
17272
+ "../../packages/core/dist/chunk-Z3SV3XTC.js"() {
17273
+ "use strict";
17274
+ init_chunk_HZ6CADSY();
17275
+ init_zod();
17276
+ caseAccessQuery = external_exports.object({ with_team_id: uuidSchema.optional() }).strict();
17277
+ }
17278
+ });
17279
+
17280
+ // ../../packages/core/dist/chunk-NHC27NIE.js
17281
+ var CASE_ADJUSTMENT_REASON_MAX_LENGTH, CASE_ADJUSTMENT_DISPENSATION_KINDS, reason2, activateCasePhaseBody, dispenseCaseBody, addCaseTaskBody, addCaseInputBody, caseOwnItemSchema, addCaseItemBody;
17282
+ var init_chunk_NHC27NIE = __esm({
17283
+ "../../packages/core/dist/chunk-NHC27NIE.js"() {
17284
+ "use strict";
17285
+ init_chunk_PFPADFUC();
17286
+ init_chunk_HZ6CADSY();
17287
+ init_zod();
17288
+ CASE_ADJUSTMENT_REASON_MAX_LENGTH = 2e3;
17289
+ CASE_ADJUSTMENT_DISPENSATION_KINDS = ["phase", "item", "output", "input"];
17290
+ reason2 = external_exports.string().trim().min(1).max(CASE_ADJUSTMENT_REASON_MAX_LENGTH);
17291
+ activateCasePhaseBody = external_exports.object({ phase_id: uuidSchema, reason: reason2 }).strict();
17292
+ dispenseCaseBody = external_exports.object({ kind: external_exports.enum(CASE_ADJUSTMENT_DISPENSATION_KINDS), target_id: uuidSchema, reason: reason2 }).strict();
17293
+ addCaseTaskBody = external_exports.object({
17294
+ phase_id: uuidSchema,
17295
+ name: external_exports.string().trim().min(1).max(CASE_TASK_NAME_MAX_LENGTH),
17296
+ required: external_exports.boolean().default(false),
17297
+ /** Tasks of the same phase it waits for. */
17298
+ depends_on: external_exports.array(uuidSchema).max(CASE_TASK_DEPENDENCIES_MAX).default([])
17299
+ }).strict();
17300
+ addCaseInputBody = external_exports.object({
17301
+ phase_id: uuidSchema,
17302
+ input: casePhaseInputSchema.extend({ agenda_group: caseAgendaGroupCodeSchema.nullable().default(null) }),
17303
+ reason: reason2
17304
+ }).strict();
17305
+ caseOwnItemSchema = caseOutputItemSchema.omit({ waivable: true, template_mode: true, fixed_text: true }).extend({ agenda_group: caseAgendaGroupCodeSchema.nullable().default(null) });
17306
+ addCaseItemBody = external_exports.object({
17307
+ phase_id: uuidSchema,
17308
+ /** The phase's output it goes in. */
17309
+ output_id: uuidSchema,
17310
+ item: caseOwnItemSchema,
17311
+ reason: reason2
17312
+ }).strict();
17313
+ }
17314
+ });
17315
+
17316
+ // ../../packages/core/dist/chunk-UMAPAGFH.js
17317
+ var CASE_AGENDA_VALUE_MAX_LENGTH, CASE_AGENDA_JUSTIFICATION_MAX_LENGTH, CASE_AGENDA_EVIDENCE_MAX_LENGTH, CASE_AGENDA_COMMENT_MAX_LENGTH, CASE_AGENDA_VERDICTS, comment, caseAgendaGroupParam, caseAgendaDecisionParam, caseAgendaQuery, caseApprovedDecisionsQuery, proposeCaseAgendaValueBody, decideCaseAgendaBody, dispenseCaseAgendaBody, addCaseDecisionBody;
17318
+ var init_chunk_UMAPAGFH = __esm({
17319
+ "../../packages/core/dist/chunk-UMAPAGFH.js"() {
17320
+ "use strict";
17321
+ init_chunk_733K4J4G();
17322
+ init_chunk_PFPADFUC();
17323
+ init_chunk_3T3D7LTE();
17324
+ init_chunk_M2T55BV6();
17325
+ init_chunk_HZ6CADSY();
17326
+ init_zod();
17327
+ CASE_AGENDA_VALUE_MAX_LENGTH = 2e3;
17328
+ CASE_AGENDA_JUSTIFICATION_MAX_LENGTH = 2e3;
17329
+ CASE_AGENDA_EVIDENCE_MAX_LENGTH = 500;
17330
+ CASE_AGENDA_COMMENT_MAX_LENGTH = 2e3;
17331
+ CASE_AGENDA_VERDICTS = ["approve", "return"];
17332
+ comment = external_exports.string().trim().min(1).max(CASE_AGENDA_COMMENT_MAX_LENGTH);
17333
+ caseAgendaGroupParam = caseRecordParam.extend({ group_id: uuidSchema });
17334
+ caseAgendaDecisionParam = caseRecordParam.extend({ decision_code: caseDecisionCodeSchema });
17335
+ caseAgendaQuery = external_exports.object({
17336
+ phase_id: uuidSchema,
17337
+ cursor: external_exports.string().min(1).max(CASE_PAGE_CURSOR_MAX_LENGTH).optional()
17338
+ });
17339
+ caseApprovedDecisionsQuery = external_exports.object({
17340
+ confidential: external_exports.enum(["true", "false"]).optional().transform((value) => value === "true")
17341
+ });
17342
+ proposeCaseAgendaValueBody = external_exports.object({
17343
+ /** As written: a numeric type also takes a string of digits with a `.` or `,` decimal mark (Rito's). */
17344
+ value: external_exports.union([external_exports.number(), external_exports.boolean(), external_exports.string().max(CASE_AGENDA_VALUE_MAX_LENGTH)]),
17345
+ justification: external_exports.string().trim().min(1).max(CASE_AGENDA_JUSTIFICATION_MAX_LENGTH),
17346
+ evidence: external_exports.string().trim().max(CASE_AGENDA_EVIDENCE_MAX_LENGTH).nullable().default(null).transform((text5) => text5 || null),
17347
+ /** Required on an approved group: why it is revised. */
17348
+ reason: comment.nullable().default(null)
17349
+ }).strict();
17350
+ decideCaseAgendaBody = external_exports.object({
17351
+ decision: external_exports.enum(CASE_AGENDA_VERDICTS),
17352
+ /** The sending its decider read (`CaseAgendaGroupView.sending_id`). */
17353
+ sending_id: uuidSchema,
17354
+ comment: comment.nullable().default(null)
17355
+ }).strict().superRefine((body, ctx) => {
17356
+ if (body.decision === "return" && body.comment === null) ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "A return needs its comment", path: ["comment"] });
17357
+ });
17358
+ dispenseCaseAgendaBody = external_exports.object({ reason: comment }).strict();
17359
+ addCaseDecisionBody = external_exports.object({ decision: caseAgendaDecisionSchema, reason: comment }).strict();
17360
+ }
17361
+ });
17362
+
17363
+ // ../../packages/core/dist/chunk-2PZIF56U.js
17364
+ var analyticsHubIdParam, analyticsVariableIdParam, updateVariablePinBody, updateAnalyticsViewBody, NUMERIC_FILTER_OPS, TEXT_FILTER_OPS, CATEGORICAL_FILTER_OPS, VARIABLE_FILTER_OPS, STRUCTURED_QUERY_OPS, STRUCTURED_QUERY_AGGREGATIONS, filterValueSchema, conversationsBody, analyticsConversationIdParam, messagesQuery, conversationDetailDataQuery, analyticsDataBody, structuredQueryBody, analyticsSqlBody, analyticsSqlTable, analyticsSqlSchemaQuery;
17365
+ var init_chunk_2PZIF56U = __esm({
17366
+ "../../packages/core/dist/chunk-2PZIF56U.js"() {
17367
+ "use strict";
17368
+ init_zod();
17369
+ analyticsHubIdParam = external_exports.object({
17370
+ hubId: external_exports.string().uuid()
17371
+ });
17372
+ analyticsVariableIdParam = external_exports.object({
17373
+ variableId: external_exports.string().uuid()
17374
+ });
17375
+ updateVariablePinBody = external_exports.object({
17376
+ pin: external_exports.union([external_exports.boolean(), external_exports.string()])
17377
+ });
17378
+ updateAnalyticsViewBody = external_exports.object({
17379
+ // 64 covers UUIDs (36) and the `sys:{name}` synthetic IDs for system variables.
17380
+ selected_variable_ids: external_exports.array(external_exports.string().min(1).max(64)).max(200)
17381
+ });
17382
+ NUMERIC_FILTER_OPS = ["eq", "neq", "gt", "gte", "lt", "lte"];
17383
+ TEXT_FILTER_OPS = ["equals", "not_equals", "contains", "not_contains", "starts_with", "ends_with"];
17384
+ CATEGORICAL_FILTER_OPS = ["is", "is_not", "in", "not_in"];
17385
+ VARIABLE_FILTER_OPS = [
17386
+ ...NUMERIC_FILTER_OPS,
17387
+ ...TEXT_FILTER_OPS,
17388
+ ...CATEGORICAL_FILTER_OPS
17389
+ ];
17390
+ STRUCTURED_QUERY_OPS = ["eq", "neq", "gt", "gte", "lt", "lte", "in", "not_in", "like"];
17391
+ STRUCTURED_QUERY_AGGREGATIONS = ["avg", "sum", "min", "max", "count", "quantile", "stddevPop", "corr", "uniq"];
17392
+ filterValueSchema = external_exports.object({
17393
+ variable_id: external_exports.string(),
17394
+ filter_type: external_exports.enum(VARIABLE_FILTER_OPS),
17395
+ filter_value: external_exports.union([external_exports.string(), external_exports.number()])
17396
+ });
17397
+ conversationsBody = external_exports.object({
17398
+ hub_id: external_exports.string().uuid(),
17399
+ time_interval: external_exports.object({
17400
+ start: external_exports.string().optional(),
17401
+ end: external_exports.string().optional()
17402
+ }).optional(),
17403
+ filters: external_exports.array(filterValueSchema).optional(),
17404
+ limit: external_exports.number().int().positive().max(500).default(50),
17405
+ offset: external_exports.number().int().min(0).default(0)
17406
+ });
17407
+ analyticsConversationIdParam = external_exports.object({
17408
+ conversationId: external_exports.string().uuid()
17409
+ });
17410
+ messagesQuery = external_exports.object({
17411
+ hub_id: external_exports.string().uuid(),
17412
+ limit: external_exports.string().regex(/^\d+$/).optional(),
17413
+ offset: external_exports.string().regex(/^\d+$/).optional()
17414
+ });
17415
+ conversationDetailDataQuery = external_exports.object({
17416
+ hub_id: external_exports.string().uuid()
17417
+ });
17418
+ analyticsDataBody = external_exports.object({
17419
+ hub_id: external_exports.string().uuid(),
17420
+ periodicity: external_exports.enum(["daily", "weekly", "monthly", "yearly"]),
17421
+ time_interval: external_exports.object({
17422
+ start: external_exports.string(),
17423
+ end: external_exports.string()
17424
+ }),
17425
+ trend_analysis: external_exports.boolean(),
17426
+ filters: external_exports.array(filterValueSchema).optional(),
17427
+ selected_variables: external_exports.array(external_exports.string()),
17428
+ include_summary: external_exports.boolean().optional(),
17429
+ include_variables: external_exports.boolean().optional(),
17430
+ variable_origin: external_exports.enum(["agent", "system", "annotation"]).optional(),
17431
+ variable_category: external_exports.string().optional(),
17432
+ variables_only: external_exports.boolean().optional()
17433
+ });
17434
+ structuredQueryBody = external_exports.object({
17435
+ hub_id: external_exports.string().uuid(),
17436
+ metrics: external_exports.array(external_exports.object({
17437
+ column: external_exports.string(),
17438
+ aggregation: external_exports.enum(STRUCTURED_QUERY_AGGREGATIONS),
17439
+ alias: external_exports.string().optional(),
17440
+ corr_with: external_exports.string().optional(),
17441
+ quantile_level: external_exports.number().min(0).max(1).optional()
17442
+ })).min(1),
17443
+ group_by: external_exports.array(external_exports.string()).optional(),
17444
+ order_by: external_exports.array(external_exports.object({
17445
+ column: external_exports.string(),
17446
+ direction: external_exports.enum(["asc", "desc"]).optional()
17447
+ })).optional(),
17448
+ filters: external_exports.array(external_exports.object({
17449
+ column: external_exports.string(),
17450
+ operator: external_exports.enum(STRUCTURED_QUERY_OPS),
17451
+ value: external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean()])
17452
+ })).optional(),
17453
+ time_range: external_exports.object({
17454
+ start: external_exports.string(),
17455
+ end: external_exports.string()
17456
+ }).optional(),
17457
+ limit: external_exports.number().int().positive().max(1e4).optional()
17458
+ });
17459
+ analyticsSqlBody = external_exports.object({
17460
+ hub_id: external_exports.string().uuid(),
17461
+ // Hard size cap before the validator runs — keeps lex/parse work bounded.
17462
+ sql: external_exports.string().min(1).max(8e3),
17463
+ limit: external_exports.number().int().positive().max(1e4).optional()
17464
+ });
17465
+ analyticsSqlTable = external_exports.enum(["conversation", "message"]);
17466
+ analyticsSqlSchemaQuery = external_exports.object({
17467
+ hub_id: external_exports.string().uuid(),
17468
+ // Defaulted so a client that predates the message table keeps its old response.
17469
+ table: analyticsSqlTable.default("conversation")
17470
+ });
17471
+ }
17472
+ });
17473
+
17363
17474
  // ../../packages/core/dist/chunk-UEJOG2Q7.js
17364
17475
  var archiveHubIdParam, archiveConversationParams, archiveListQuery, archiveMessageObservabilityParams;
17365
17476
  var init_chunk_UEJOG2Q7 = __esm({
@@ -18265,117 +18376,6 @@ var init_chunk_Q5SZRRLP = __esm({
18265
18376
  }
18266
18377
  });
18267
18378
 
18268
- // ../../packages/core/dist/chunk-2PZIF56U.js
18269
- var analyticsHubIdParam, analyticsVariableIdParam, updateVariablePinBody, updateAnalyticsViewBody, NUMERIC_FILTER_OPS, TEXT_FILTER_OPS, CATEGORICAL_FILTER_OPS, VARIABLE_FILTER_OPS, STRUCTURED_QUERY_OPS, STRUCTURED_QUERY_AGGREGATIONS, filterValueSchema, conversationsBody, analyticsConversationIdParam, messagesQuery, conversationDetailDataQuery, analyticsDataBody, structuredQueryBody, analyticsSqlBody, analyticsSqlTable, analyticsSqlSchemaQuery;
18270
- var init_chunk_2PZIF56U = __esm({
18271
- "../../packages/core/dist/chunk-2PZIF56U.js"() {
18272
- "use strict";
18273
- init_zod();
18274
- analyticsHubIdParam = external_exports.object({
18275
- hubId: external_exports.string().uuid()
18276
- });
18277
- analyticsVariableIdParam = external_exports.object({
18278
- variableId: external_exports.string().uuid()
18279
- });
18280
- updateVariablePinBody = external_exports.object({
18281
- pin: external_exports.union([external_exports.boolean(), external_exports.string()])
18282
- });
18283
- updateAnalyticsViewBody = external_exports.object({
18284
- // 64 covers UUIDs (36) and the `sys:{name}` synthetic IDs for system variables.
18285
- selected_variable_ids: external_exports.array(external_exports.string().min(1).max(64)).max(200)
18286
- });
18287
- NUMERIC_FILTER_OPS = ["eq", "neq", "gt", "gte", "lt", "lte"];
18288
- TEXT_FILTER_OPS = ["equals", "not_equals", "contains", "not_contains", "starts_with", "ends_with"];
18289
- CATEGORICAL_FILTER_OPS = ["is", "is_not", "in", "not_in"];
18290
- VARIABLE_FILTER_OPS = [
18291
- ...NUMERIC_FILTER_OPS,
18292
- ...TEXT_FILTER_OPS,
18293
- ...CATEGORICAL_FILTER_OPS
18294
- ];
18295
- STRUCTURED_QUERY_OPS = ["eq", "neq", "gt", "gte", "lt", "lte", "in", "not_in", "like"];
18296
- STRUCTURED_QUERY_AGGREGATIONS = ["avg", "sum", "min", "max", "count", "quantile", "stddevPop", "corr", "uniq"];
18297
- filterValueSchema = external_exports.object({
18298
- variable_id: external_exports.string(),
18299
- filter_type: external_exports.enum(VARIABLE_FILTER_OPS),
18300
- filter_value: external_exports.union([external_exports.string(), external_exports.number()])
18301
- });
18302
- conversationsBody = external_exports.object({
18303
- hub_id: external_exports.string().uuid(),
18304
- time_interval: external_exports.object({
18305
- start: external_exports.string().optional(),
18306
- end: external_exports.string().optional()
18307
- }).optional(),
18308
- filters: external_exports.array(filterValueSchema).optional(),
18309
- limit: external_exports.number().int().positive().max(500).default(50),
18310
- offset: external_exports.number().int().min(0).default(0)
18311
- });
18312
- analyticsConversationIdParam = external_exports.object({
18313
- conversationId: external_exports.string().uuid()
18314
- });
18315
- messagesQuery = external_exports.object({
18316
- hub_id: external_exports.string().uuid(),
18317
- limit: external_exports.string().regex(/^\d+$/).optional(),
18318
- offset: external_exports.string().regex(/^\d+$/).optional()
18319
- });
18320
- conversationDetailDataQuery = external_exports.object({
18321
- hub_id: external_exports.string().uuid()
18322
- });
18323
- analyticsDataBody = external_exports.object({
18324
- hub_id: external_exports.string().uuid(),
18325
- periodicity: external_exports.enum(["daily", "weekly", "monthly", "yearly"]),
18326
- time_interval: external_exports.object({
18327
- start: external_exports.string(),
18328
- end: external_exports.string()
18329
- }),
18330
- trend_analysis: external_exports.boolean(),
18331
- filters: external_exports.array(filterValueSchema).optional(),
18332
- selected_variables: external_exports.array(external_exports.string()),
18333
- include_summary: external_exports.boolean().optional(),
18334
- include_variables: external_exports.boolean().optional(),
18335
- variable_origin: external_exports.enum(["agent", "system", "annotation"]).optional(),
18336
- variable_category: external_exports.string().optional(),
18337
- variables_only: external_exports.boolean().optional()
18338
- });
18339
- structuredQueryBody = external_exports.object({
18340
- hub_id: external_exports.string().uuid(),
18341
- metrics: external_exports.array(external_exports.object({
18342
- column: external_exports.string(),
18343
- aggregation: external_exports.enum(STRUCTURED_QUERY_AGGREGATIONS),
18344
- alias: external_exports.string().optional(),
18345
- corr_with: external_exports.string().optional(),
18346
- quantile_level: external_exports.number().min(0).max(1).optional()
18347
- })).min(1),
18348
- group_by: external_exports.array(external_exports.string()).optional(),
18349
- order_by: external_exports.array(external_exports.object({
18350
- column: external_exports.string(),
18351
- direction: external_exports.enum(["asc", "desc"]).optional()
18352
- })).optional(),
18353
- filters: external_exports.array(external_exports.object({
18354
- column: external_exports.string(),
18355
- operator: external_exports.enum(STRUCTURED_QUERY_OPS),
18356
- value: external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean()])
18357
- })).optional(),
18358
- time_range: external_exports.object({
18359
- start: external_exports.string(),
18360
- end: external_exports.string()
18361
- }).optional(),
18362
- limit: external_exports.number().int().positive().max(1e4).optional()
18363
- });
18364
- analyticsSqlBody = external_exports.object({
18365
- hub_id: external_exports.string().uuid(),
18366
- // Hard size cap before the validator runs — keeps lex/parse work bounded.
18367
- sql: external_exports.string().min(1).max(8e3),
18368
- limit: external_exports.number().int().positive().max(1e4).optional()
18369
- });
18370
- analyticsSqlTable = external_exports.enum(["conversation", "message"]);
18371
- analyticsSqlSchemaQuery = external_exports.object({
18372
- hub_id: external_exports.string().uuid(),
18373
- // Defaulted so a client that predates the message table keeps its old response.
18374
- table: analyticsSqlTable.default("conversation")
18375
- });
18376
- }
18377
- });
18378
-
18379
18379
  // ../../packages/core/dist/chunk-ZRXP6OOJ.js
18380
18380
  function capped(max, field) {
18381
18381
  return (value, ctx) => {
@@ -18437,40 +18437,40 @@ var init_contracts = __esm({
18437
18437
  init_chunk_C7UAGRXF();
18438
18438
  init_chunk_IPXBFWUU();
18439
18439
  init_chunk_63UWXV4T();
18440
+ init_chunk_TVUDMGWV();
18440
18441
  init_chunk_WTIGECE5();
18441
18442
  init_chunk_WDAXZDJO();
18442
18443
  init_chunk_ZC6YGHNX();
18444
+ init_chunk_MGBAXT5Y();
18443
18445
  init_chunk_5DGHIY7L();
18444
18446
  init_chunk_TID3PAFF();
18445
18447
  init_chunk_IPDOHAZ5();
18446
18448
  init_chunk_PFGVH2CX();
18447
- init_chunk_TVUDMGWV();
18449
+ init_chunk_FPSDNS2E();
18448
18450
  init_chunk_TZH6DKKJ();
18449
18451
  init_chunk_SSPK6ISL();
18450
18452
  init_chunk_ZXK6N2HN();
18451
18453
  init_chunk_Y7CFCYX4();
18452
- init_chunk_MGBAXT5Y();
18453
18454
  init_chunk_YUZFHVB2();
18454
18455
  init_chunk_I3O2RACG();
18455
18456
  init_chunk_CMRECH67();
18456
18457
  init_chunk_34LE6P7E();
18457
- init_chunk_FPSDNS2E();
18458
+ init_chunk_IR2NOSI3();
18458
18459
  init_chunk_OPETF4GS();
18459
18460
  init_chunk_SY6PLCPK();
18460
18461
  init_chunk_2ZZZHXZR();
18462
+ init_chunk_MH4O3YEX();
18461
18463
  init_chunk_QEEQN2NE();
18462
18464
  init_chunk_KSTYTQ7I();
18463
18465
  init_chunk_LKBSHANA();
18464
18466
  init_chunk_LX3D5LCB();
18465
18467
  init_chunk_C4HEZ7ZI();
18466
- init_chunk_IR2NOSI3();
18467
18468
  init_chunk_UCYWGWQT();
18468
18469
  init_chunk_6AYIXGDT();
18469
18470
  init_chunk_YULHXJ5M();
18470
18471
  init_chunk_V4FRPRH5();
18471
18472
  init_chunk_LWMLR2WI();
18472
18473
  init_chunk_ACGAI25T();
18473
- init_chunk_MH4O3YEX();
18474
18474
  init_chunk_NNC2ZECG();
18475
18475
  init_chunk_7CYHPF35();
18476
18476
  init_chunk_NETRUHZF();
@@ -18485,22 +18485,24 @@ var init_contracts = __esm({
18485
18485
  init_chunk_K3PD6AOF();
18486
18486
  init_chunk_KVMROYDC();
18487
18487
  init_chunk_M2IF4G6X();
18488
+ init_chunk_UOPCLXCU();
18488
18489
  init_chunk_7CZSLDOE();
18489
18490
  init_chunk_2YVCHUBL();
18490
18491
  init_chunk_RRU36I2I();
18491
18492
  init_chunk_WYCUCSD5();
18493
+ init_chunk_UZ72OHQN();
18494
+ init_chunk_6CHDJVQ6();
18495
+ init_chunk_U3X3BIQH();
18496
+ init_chunk_EYOBPUDN();
18492
18497
  init_chunk_H6V7NEWR();
18493
18498
  init_chunk_ZVIMTUGZ();
18494
18499
  init_chunk_BVQCYBU6();
18495
- init_chunk_UOPCLXCU();
18500
+ init_chunk_5PKKFSSF();
18496
18501
  init_chunk_Z3SV3XTC();
18497
18502
  init_chunk_NHC27NIE();
18498
18503
  init_chunk_UMAPAGFH();
18499
- init_chunk_UZ72OHQN();
18500
- init_chunk_6CHDJVQ6();
18501
- init_chunk_U3X3BIQH();
18502
- init_chunk_EYOBPUDN();
18503
18504
  init_chunk_S4NDHW3Q();
18505
+ init_chunk_2PZIF56U();
18504
18506
  init_chunk_UEJOG2Q7();
18505
18507
  init_chunk_KEN2DASI();
18506
18508
  init_chunk_L5GC53VI();
@@ -18512,7 +18514,6 @@ var init_contracts = __esm({
18512
18514
  init_chunk_PZPOUXJR();
18513
18515
  init_chunk_LBDH7LCG();
18514
18516
  init_chunk_4LXDRTO4();
18515
- init_chunk_5PKKFSSF();
18516
18517
  init_chunk_NVKU5PPQ();
18517
18518
  init_chunk_Q5SZRRLP();
18518
18519
  init_chunk_FECLIZTY();
@@ -18523,7 +18524,6 @@ var init_contracts = __esm({
18523
18524
  init_chunk_D3EP4TDU();
18524
18525
  init_chunk_PIZTARVG();
18525
18526
  init_chunk_OMPT4ZHR();
18526
- init_chunk_2PZIF56U();
18527
18527
  init_chunk_6J742GLA();
18528
18528
  init_chunk_ZRXP6OOJ();
18529
18529
  init_chunk_BGNWWR6B();
@@ -26335,7 +26335,7 @@ var init_helpers = __esm({
26335
26335
  init_base_id();
26336
26336
  init_expected();
26337
26337
  init_utils();
26338
- BASE_SECRET_STORAGE_WHY = "a base's secrets are to be kept in the credentials vault, which does not hold them yet";
26338
+ BASE_SECRET_STORAGE_WHY = "the credentials vault does not hold this kind of secret yet";
26339
26339
  DURATION_RE = /^(\d+)([smhd])$/;
26340
26340
  DURATION_UNIT_MS = {
26341
26341
  s: 1e3,
@@ -26975,6 +26975,250 @@ var init_triggers = __esm({
26975
26975
  }
26976
26976
  });
26977
26977
 
26978
+ // src/data/commands/credentials.ts
26979
+ import { Command as Command2 } from "commander";
26980
+ import { readFileSync as readFileSync15 } from "fs";
26981
+ function withValueSourceOptions(cmd, what) {
26982
+ return cmd.option(
26983
+ "--file <path>",
26984
+ `Read ${what} from a file and base64-encode it (certificates, keystores, service-account JSON)`
26985
+ ).option("--value-stdin", `Read ${what} from stdin (recommended for CI)`).option("--value-prompt", `Prompt for ${what}, masked`);
26986
+ }
26987
+ async function resolveValue(opts, label3) {
26988
+ if (opts.file !== void 0) {
26989
+ if (opts.valueStdin || opts.valuePrompt) {
26990
+ throw expected("--file cannot be combined with --value-stdin or --value-prompt \u2014 pass one.");
26991
+ }
26992
+ try {
26993
+ return readFileSync15(opts.file).toString("base64");
26994
+ } catch (e) {
26995
+ throw expected(`--file ${opts.file}: ${e instanceof Error ? e.message : "could not be read"}`);
26996
+ }
26997
+ }
26998
+ return readSecret(
26999
+ {
27000
+ stdin: opts.valueStdin,
27001
+ prompt: opts.valuePrompt,
27002
+ stdinFlag: "--value-stdin",
27003
+ promptHint: "--value-prompt"
27004
+ },
27005
+ label3
27006
+ );
27007
+ }
27008
+ function credentialPath(base, id) {
27009
+ const root = `/v1/${pathSegment(base, "base id")}/credentials`;
27010
+ return id === void 0 ? root : `${root}/${pathSegment(id, "credential id")}`;
27011
+ }
27012
+ function refusalReason(err) {
27013
+ const reason3 = dataErrorDetails(err)?.reason;
27014
+ return typeof reason3 === "string" ? reason3 : null;
27015
+ }
27016
+ async function assertStorageOn(client, path55, body) {
27017
+ try {
27018
+ await client.request("POST", path55, body);
27019
+ } catch (err) {
27020
+ if (refusalReason(err) === VALUE_MISSING) return;
27021
+ if (refusalReason(err) === STORAGE_OFF) {
27022
+ throw expected(`${refusalMessage(err)} Nothing was read or stored.`);
27023
+ }
27024
+ throw err;
27025
+ }
27026
+ throw new Error("The credential service accepted a request that carried no value.");
27027
+ }
27028
+ function refusalMessage(err) {
27029
+ return dataErrorMessage(err) ?? (err instanceof Error ? err.message : String(err));
27030
+ }
27031
+ function parseRule(raw) {
27032
+ return raw === void 0 ? void 0 : parseData(raw, "--rule");
27033
+ }
27034
+ function parseProposedSources(raw) {
27035
+ if (raw === void 0) return void 0;
27036
+ const parsed = parseData(raw, "--proposed-sources");
27037
+ if (!Array.isArray(parsed)) throw expected("--proposed-sources must be a JSON list of sources, as a record type carries them.");
27038
+ return parsed;
27039
+ }
27040
+ function statedFromStored(policy) {
27041
+ const scopes = policy?.scopes;
27042
+ if (!Array.isArray(scopes) || scopes.length === 0) return null;
27043
+ return {
27044
+ scopes: scopes.map((scope) => ({
27045
+ origin: scope.origin,
27046
+ path: scope.path,
27047
+ match: scope.match,
27048
+ methods: scope.methods
27049
+ }))
27050
+ };
27051
+ }
27052
+ function overStoredLimit(err) {
27053
+ if (refusalReason(err) !== RULE_REFUSED) return false;
27054
+ const refusals = dataErrorDetails(err)?.refusals;
27055
+ return Array.isArray(refusals) && refusals.some((r) => r?.code === "too_many_scopes" || r?.code === "policy_too_large");
27056
+ }
27057
+ function sourceNamesCredential(source, name) {
27058
+ const ref = `${CREDENTIAL_REF}${name}`;
27059
+ const s = source;
27060
+ if (s?.auth?.secret_ref === ref) return true;
27061
+ return (s?.injections ?? []).some((i) => i?.target === "header" && i.secret_ref === ref);
27062
+ }
27063
+ function isUncoveredCredentialRefusal(err) {
27064
+ return refusalReason(err) === RULE_NOT_COVERING;
27065
+ }
27066
+ function rotatableInRefusal(message) {
27067
+ const found = /* @__PURE__ */ new Map();
27068
+ for (const m of message.matchAll(/credential '([^']+)' \(POST …\/credentials\/([^/\s)]+)\/rotate\)/g)) {
27069
+ found.set(m[2], { id: m[2], name: m[1] });
27070
+ }
27071
+ return [...found.values()];
27072
+ }
27073
+ async function reenterRefusedCredentials(client, base, message, pushedSources) {
27074
+ const named = rotatableInRefusal(message);
27075
+ if (named.length === 0) return false;
27076
+ const held = await client.request("GET", credentialPath(base));
27077
+ const refused = named.filter((c) => (Array.isArray(held) ? held : []).some((row) => row.id === c.id && row.name === c.name && row.policy) && pushedSources.some((source) => sourceNamesCredential(source, c.name)));
27078
+ if (refused.length === 0) return false;
27079
+ if (!isInteractive()) {
27080
+ for (const c of refused) {
27081
+ console.error(
27082
+ `To send credential '${sanitizeTerminalText(c.name)}' there, enter its value again: run \`wayai push\` in a terminal, or \`wayai bases credentials rotate ${sanitizeTerminalText(c.id)} --base ${sanitizeTerminalText(base)} --value-stdin --proposed-sources @<file>\` with a JSON list of the sources in your files that place it, then push again.`
27083
+ );
27084
+ }
27085
+ return false;
27086
+ }
27087
+ for (const c of refused) {
27088
+ const name = sanitizeTerminalText(c.name);
27089
+ if (!await confirm(`Enter the value of credential '${name}' again, so it may go where this change sends it?`)) return false;
27090
+ const path55 = `${credentialPath(base, c.id)}/rotate`;
27091
+ await assertStorageOn(client, path55, {});
27092
+ const value = await readSecret(
27093
+ { stdin: false, prompt: true, stdinFlag: "--value-stdin", promptHint: "--value-prompt" },
27094
+ `Value of credential '${name}'`
27095
+ );
27096
+ await client.request("POST", path55, {
27097
+ value,
27098
+ proposed_sources: pushedSources.filter((source) => sourceNamesCredential(source, c.name))
27099
+ });
27100
+ console.log(`Rotated credential '${name}': its rule now covers this change.`);
27101
+ }
27102
+ return true;
27103
+ }
27104
+ function buildBasesCredentialsCommand() {
27105
+ const credentials = withBaseOption(
27106
+ new Command2("credentials").description("Manage a base's integration credentials")
27107
+ );
27108
+ withValueSourceOptions(
27109
+ credentials.command("create").description(
27110
+ "Store a credential a source of this base names (value read from stdin, a masked prompt, or --file), with the rule derived from those sources"
27111
+ ).requiredOption("--name <name>", "Credential name \u2014 what a credential:<name> reference resolves").option("--content-type <mime>", "MIME type of the value (e.g. application/x-pkcs12)").option(
27112
+ "--expires-at <date>",
27113
+ "Expiry as ISO-8601 (e.g. 2027-01-01T00:00:00Z) \u2014 informational; nothing is auto-disabled"
27114
+ ).option(
27115
+ "--rule <json>",
27116
+ 'A wider rule than the derived one, inline or @file: {"scopes":[{"origin","path","match":"prefix"|"exact","methods"}]}'
27117
+ ),
27118
+ "the credential value"
27119
+ ).action(async function(opts) {
27120
+ const base = requireBase(this);
27121
+ const rule = parseRule(opts.rule);
27122
+ const client = await createDataClient();
27123
+ await assertStorageOn(client, credentialPath(base), { name: opts.name });
27124
+ const body = {
27125
+ name: opts.name,
27126
+ value: await resolveValue(opts, "Credential value")
27127
+ };
27128
+ if (opts.contentType) body.content_type = opts.contentType;
27129
+ if (opts.expiresAt) body.expires_at = opts.expiresAt;
27130
+ if (rule) body.rule = rule;
27131
+ printOutput(await client.request("POST", credentialPath(base), body), outputFormat(this));
27132
+ });
27133
+ credentials.command("list").description("List this base's credentials and the rule each was stored with (values are never returned)").action(async function() {
27134
+ const base = requireBase(this);
27135
+ const client = await createDataClient();
27136
+ printOutput(
27137
+ await client.request("GET", credentialPath(base)),
27138
+ outputFormat(this)
27139
+ );
27140
+ });
27141
+ credentials.command("get <id>").description("Get credential metadata and its stored rule (the value is never returned)").action(async function(id) {
27142
+ const base = requireBase(this);
27143
+ const client = await createDataClient();
27144
+ printOutput(
27145
+ await client.request("GET", credentialPath(base, id)),
27146
+ outputFormat(this)
27147
+ );
27148
+ });
27149
+ withValueSourceOptions(
27150
+ credentials.command("rotate <id>").description("Enter a new value, under the rule derived again from the sources (never auto-generates)").option("--expires-at <date>", "Set the rotated credential's new expiry (ISO-8601)").option("--rule <json>", "A wider rule than the derived one, inline or @file (as create takes it)").option("--keep-rule", "State the rule the credential is stored with again, as the wider rule").option(
27151
+ "--proposed-sources <json>",
27152
+ "Sources a refused save proposed, as a JSON list, inline or @file: the rule then covers them too (no source is saved)"
27153
+ ),
27154
+ "the new credential value"
27155
+ ).action(async function(id, opts) {
27156
+ const base = requireBase(this);
27157
+ if (opts.rule !== void 0 && opts.keepRule) throw expected("--rule cannot be combined with --keep-rule \u2014 pass one.");
27158
+ let rule = parseRule(opts.rule);
27159
+ const proposed = parseProposedSources(opts.proposedSources);
27160
+ const client = await createDataClient();
27161
+ const path55 = `${credentialPath(base, id)}/rotate`;
27162
+ await assertStorageOn(client, path55, {});
27163
+ const storedRule = async () => statedFromStored((await client.request("GET", credentialPath(base, id)))?.policy);
27164
+ if (opts.keepRule) {
27165
+ rule = await storedRule() ?? void 0;
27166
+ if (!rule) throw expected("This credential holds no stored rule to keep. Nothing was read or stored.");
27167
+ }
27168
+ const body = { value: await resolveValue(opts, "New credential value") };
27169
+ if (opts.expiresAt) body.expires_at = opts.expiresAt;
27170
+ if (rule) body.rule = rule;
27171
+ if (proposed) body.proposed_sources = proposed;
27172
+ try {
27173
+ printOutput(await client.request("POST", path55, body), outputFormat(this));
27174
+ } catch (err) {
27175
+ if (!rule && overStoredLimit(err) && await storedRule()) {
27176
+ throw expected(
27177
+ `${refusalMessage(err)} It is stored under a wider rule: if that rule still covers every use the sources make, run the rotation again with --keep-rule to state it again; otherwise pass --rule with one that does.`
27178
+ );
27179
+ }
27180
+ throw err;
27181
+ }
27182
+ });
27183
+ credentials.command("set-sync <id>").description("Set the promote-time publish flag \u2014 has no effect: promotion carries no credential").option("--no-sync-to-production", "Do not publish this credential on promote (has no effect)").action(() => {
27184
+ throw expected("Promotion carries no base credential, so the publish flag has no effect. Nothing was changed.");
27185
+ });
27186
+ credentials.command("delete <id>").description("Delete a direct credential").option("-y, --yes", "Skip confirmation prompt").action(async function(id, opts) {
27187
+ const base = requireBase(this);
27188
+ if (!opts.yes) {
27189
+ if (!isInteractive()) {
27190
+ throw expected("Refusing to delete without confirmation \u2014 pass --yes to delete non-interactively.");
27191
+ }
27192
+ if (!await confirm(`Delete credential ${id} on base ${base}? This cannot be undone.`)) {
27193
+ console.log("Aborted");
27194
+ return;
27195
+ }
27196
+ }
27197
+ const client = await createDataClient();
27198
+ await client.request("DELETE", credentialPath(base, id));
27199
+ printOutput({ id, deleted: true }, outputFormat(this));
27200
+ });
27201
+ return credentials;
27202
+ }
27203
+ var STORAGE_OFF, VALUE_MISSING, RULE_NOT_COVERING, RULE_REFUSED, CREDENTIAL_REF;
27204
+ var init_credentials = __esm({
27205
+ "src/data/commands/credentials.ts"() {
27206
+ "use strict";
27207
+ init_api_client();
27208
+ init_client();
27209
+ init_output();
27210
+ init_helpers();
27211
+ init_utils();
27212
+ init_expected();
27213
+ init_terminal_output();
27214
+ STORAGE_OFF = "secret_storage_unavailable";
27215
+ VALUE_MISSING = "credential_value_not_storable";
27216
+ RULE_NOT_COVERING = "credential_rule_not_covering";
27217
+ RULE_REFUSED = "credential_rule_refused";
27218
+ CREDENTIAL_REF = "credential:";
27219
+ }
27220
+ });
27221
+
26978
27222
  // src/data/config-as-code/sync.ts
26979
27223
  var sync_exports = {};
26980
27224
  __export(sync_exports, {
@@ -27016,6 +27260,19 @@ async function mirrorLinkedProduction(client, basesDir, originId) {
27016
27260
  );
27017
27261
  }
27018
27262
  }
27263
+ async function applyRefusedCredentialsAgain(client, baseId, config) {
27264
+ try {
27265
+ return await applyConfig(client, baseId, config);
27266
+ } catch (err) {
27267
+ if (!isUncoveredCredentialRefusal(err)) throw err;
27268
+ const message = refusalMessage(err);
27269
+ console.error(`
27270
+ ${RED}${sanitizeTerminalText(message)}${RESET}`);
27271
+ const sources = config.record_types.flatMap((rt) => rt.sources ?? []);
27272
+ if (!await reenterRefusedCredentials(client, baseId, message, sources)) throw err;
27273
+ return applyConfig(client, baseId, config);
27274
+ }
27275
+ }
27019
27276
  async function pullBase(gitRootOrNull, selector, args2) {
27020
27277
  const { autoConfirm } = parseArgs5(args2);
27021
27278
  const gitRoot = requireGitRoot(gitRootOrNull);
@@ -27158,7 +27415,7 @@ Apply these changes to preview "${sanitizeTerminalText(baseId)}"?`);
27158
27415
  return;
27159
27416
  }
27160
27417
  }
27161
- const result = await applyConfig(client, baseId, config);
27418
+ const result = await applyRefusedCredentialsAgain(client, baseId, config);
27162
27419
  warnUnsignedTriggers(result.unsigned_triggers);
27163
27420
  const removals = collectRemovals(diff);
27164
27421
  if (removals.length > 0) {
@@ -27202,6 +27459,7 @@ var init_sync = __esm({
27202
27459
  init_base_workspace();
27203
27460
  init_types2();
27204
27461
  init_triggers();
27462
+ init_credentials();
27205
27463
  }
27206
27464
  });
27207
27465
 
@@ -36787,7 +37045,7 @@ var init_eval_results = __esm({
36787
37045
 
36788
37046
  // src/lib/call-eval/caller-audio.ts
36789
37047
  import { createHash as createHash4 } from "crypto";
36790
- import { mkdirSync as mkdirSync16, readFileSync as readFileSync18, renameSync as renameSync8, writeFileSync as writeFileSync9 } from "fs";
37048
+ import { mkdirSync as mkdirSync16, readFileSync as readFileSync19, renameSync as renameSync8, writeFileSync as writeFileSync9 } from "fs";
36791
37049
  import { homedir as homedir6 } from "os";
36792
37050
  import { dirname as dirname18, isAbsolute as isAbsolute2, join as join40, resolve as resolve16 } from "path";
36793
37051
  function parseWav(buf, name = "clip") {
@@ -36881,7 +37139,7 @@ var init_caller_audio = __esm({
36881
37139
  if (!path55) throw new Error(`Line ${line.n} has no clip: give --clips <dir>, or a "clip" for it in the plan.`);
36882
37140
  let buf;
36883
37141
  try {
36884
- buf = readFileSync18(path55);
37142
+ buf = readFileSync19(path55);
36885
37143
  } catch {
36886
37144
  throw new Error(`Line ${line.n}'s clip ${path55} cannot be read.`);
36887
37145
  }
@@ -36925,7 +37183,7 @@ ${text5}`).digest("hex");
36925
37183
  }
36926
37184
  async readOrSynthesize(line, path55) {
36927
37185
  try {
36928
- return pcmClip(readFileSync18(path55));
37186
+ return pcmClip(readFileSync19(path55));
36929
37187
  } catch {
36930
37188
  }
36931
37189
  const res = await this.doFetch("https://api.openai.com/v1/audio/speech", {
@@ -38431,7 +38689,7 @@ __export(eval_call_exports, {
38431
38689
  printEvalCallHelp: () => printEvalCallHelp,
38432
38690
  suiteExitCode: () => suiteExitCode
38433
38691
  });
38434
- import { accessSync, constants as fsConstants, existsSync as existsSync17, readFileSync as readFileSync19, statSync as statSync10, writeFileSync as writeFileSync10 } from "fs";
38692
+ import { accessSync, constants as fsConstants, existsSync as existsSync17, readFileSync as readFileSync20, statSync as statSync10, writeFileSync as writeFileSync10 } from "fs";
38435
38693
  import { dirname as dirname19, resolve as resolve17 } from "path";
38436
38694
  function fail(message) {
38437
38695
  throw new Error(message);
@@ -38589,7 +38847,7 @@ async function evalCallCommand(argv) {
38589
38847
  let plan;
38590
38848
  try {
38591
38849
  options = parseEvalCallArgs(args2);
38592
- plan = options.planPath ? parseCallPlan(JSON.parse(readFileSync19(options.planPath, "utf8"))) : { lines: {} };
38850
+ plan = options.planPath ? parseCallPlan(JSON.parse(readFileSync20(options.planPath, "utf8"))) : { lines: {} };
38593
38851
  } catch (err) {
38594
38852
  console.error(extractApiMessage(err));
38595
38853
  process.exit(1);
@@ -45256,7 +45514,7 @@ var init_file_map = __esm({
45256
45514
  });
45257
45515
 
45258
45516
  // ../../packages/core/dist/contracts/vault.js
45259
- var vaultIdSchema, vaultFailureOutcomeSchema, vaultRefreshCategorySchema, vaultFailureBodySchema, VAULT_BASE_SOURCE_MAX_REFS, VAULT_VALUE_MAX_BYTES, vaultSendEnvelopeSchema, vaultVerifyEnvelopeSchema, vaultAutomationHmacEnvelopeSchema, vaultAutomationStaticEnvelopeSchema, AUTOMATION_WEBHOOK_VAULT_GATE_ID, GITHUB_APP_VAULT_GATE_ID, vaultVerifyResponseSchema, vaultVersionSchema, vaultPutResponseSchema, vaultDeleteResponseSchema, vaultInstantSchema, vaultMetaResponseSchema, vaultRefreshResponseSchema, vaultMintResponseSchema, vaultSignEnvelopeSchema, VAULT_SIGN_MAX_BODY_BYTES, vaultSignResponseSchema;
45517
+ var vaultIdSchema, vaultFailureOutcomeSchema, vaultRefreshCategorySchema, vaultFailureBodySchema, VAULT_BASE_SOURCE_MAX_REFS, VAULT_VALUE_MAX_BYTES, vaultSendEnvelopeSchema, vaultVerifyEnvelopeSchema, vaultAutomationHmacEnvelopeSchema, vaultAutomationStaticEnvelopeSchema, AUTOMATION_WEBHOOK_VAULT_GATE_ID, GITHUB_APP_VAULT_GATE_ID, BASE_SOURCE_VAULT_GATE_ID, vaultVerifyResponseSchema, vaultVersionSchema, vaultPutResponseSchema, vaultDeleteResponseSchema, vaultInstantSchema, vaultMetaResponseSchema, vaultRefreshResponseSchema, vaultMintResponseSchema, vaultSignEnvelopeSchema, VAULT_SIGN_MAX_BODY_BYTES, vaultSignResponseSchema;
45260
45518
  var init_vault = __esm({
45261
45519
  "../../packages/core/dist/contracts/vault.js"() {
45262
45520
  "use strict";
@@ -45327,6 +45585,7 @@ var init_vault = __esm({
45327
45585
  vaultAutomationStaticEnvelopeSchema = external_exports.object({}).strict();
45328
45586
  AUTOMATION_WEBHOOK_VAULT_GATE_ID = "c2d6f1a4-7e3b-4f1a-9b8d-6a1f4e7c3b20";
45329
45587
  GITHUB_APP_VAULT_GATE_ID = "fff3a999-e46a-483d-a50b-ab9d01bcb707";
45588
+ BASE_SOURCE_VAULT_GATE_ID = "bdf54b42-0f2c-4627-8474-a442f725d0ce";
45330
45589
  vaultVerifyResponseSchema = external_exports.object({});
45331
45590
  vaultVersionSchema = external_exports.number().int().positive();
45332
45591
  vaultPutResponseSchema = external_exports.object({ version: vaultVersionSchema });
@@ -47688,7 +47947,7 @@ Usage:
47688
47947
 
47689
47948
  wayai admin vault-gate status [--json] Print the vault_connector_ids list (on production it decides only Instagram's and base credentials' gates: the backend's vault-gate.ts)
47690
47949
  wayai admin vault-gate add <connector> [--yes] [--json]
47691
- List a connector: a vault connector's name (e.g. telegram, whatsapp, instagram, or openai for its LLM, STT and TTS ids, never GPT-Live's) or one catalog id (GPT-Live's only so); prints before and after, confirms unless --yes
47950
+ List a connector: a vault connector's name (e.g. telegram, whatsapp, instagram, base_source for new base credentials, or openai for its LLM, STT and TTS ids, never GPT-Live's) or one catalog id (GPT-Live's only so); prints before and after, confirms unless --yes
47692
47951
  wayai admin vault-gate remove <connector> [--yes] [--json]
47693
47952
  Stop listing it: its new credentials no longer go to the vault (on production only Instagram's and base credentials' gates read the list)
47694
47953
 
@@ -47938,7 +48197,8 @@ var init_admin = __esm({
47938
48197
  ["resend", ["a1b2c3d4-e5f6-4a89-b012-3e5e0d000001"]],
47939
48198
  ["claude_managed_agents", ["4b8eeecf-a835-444a-abed-516d0a29cee2"]],
47940
48199
  ["github_app", [GITHUB_APP_VAULT_GATE_ID]],
47941
- ["api_channel", ["a1b2c3d4-e5f6-4a89-b012-3e5e0d000003"]]
48200
+ ["api_channel", ["a1b2c3d4-e5f6-4a89-b012-3e5e0d000003"]],
48201
+ ["base_source", [BASE_SOURCE_VAULT_GATE_ID]]
47942
48202
  ]);
47943
48203
  VAULT_GATE_BY_ID_ONLY = /* @__PURE__ */ new Map([
47944
48204
  ["01e7b19c-bc94-43f4-a780-ad5a22fb7127", "openai"]
@@ -48410,9 +48670,9 @@ var init_update = __esm({
48410
48670
  });
48411
48671
 
48412
48672
  // src/data/commands/actions.ts
48413
- import { Command as Command2 } from "commander";
48673
+ import { Command as Command3 } from "commander";
48414
48674
  function buildActionsCommand() {
48415
- const actions = new Command2("actions").description(
48675
+ const actions = new Command3("actions").description(
48416
48676
  "Manage Actions \u2014 reusable, named definitions: one record_type + one operation, or a composite of atomic write steps (--config with `steps`)"
48417
48677
  );
48418
48678
  actions.command("upsert <id>").description(
@@ -48481,8 +48741,8 @@ var init_actions = __esm({
48481
48741
  });
48482
48742
 
48483
48743
  // src/data/commands/attachments.ts
48484
- import { Command as Command3 } from "commander";
48485
- import { readFileSync as readFileSync22 } from "fs";
48744
+ import { Command as Command4 } from "commander";
48745
+ import { readFileSync as readFileSync23 } from "fs";
48486
48746
  function findAttachmentByFilename(attachments, filename) {
48487
48747
  return attachments.find((a) => a.key.endsWith(`/${filename}`)) ?? null;
48488
48748
  }
@@ -48508,7 +48768,7 @@ function uploadPathFrom(uploadUrl) {
48508
48768
  return uploadUrl;
48509
48769
  }
48510
48770
  function buildAttachmentsCommand() {
48511
- const attachments = new Command3("attachments").description("Manage record attachments");
48771
+ const attachments = new Command4("attachments").description("Manage record attachments");
48512
48772
  attachments.command("upload <record_type> <id>").description(
48513
48773
  "Get a presigned upload URL for a record attachment. With --file, uploads the file content in one step."
48514
48774
  ).requiredOption("--filename <name>", "File name or path (e.g. docs/guide.md)").option("--content-type <type>", "MIME type", "application/octet-stream").option("--file <path>", "Local file to upload (skips presigned URL output, uploads directly)").action(async function(recordType2, id, opts) {
@@ -48523,7 +48783,7 @@ function buildAttachmentsCommand() {
48523
48783
  printOutput(data, outputFormat(this));
48524
48784
  return;
48525
48785
  }
48526
- const body = readFileSync22(opts.file);
48786
+ const body = readFileSync23(opts.file);
48527
48787
  await client.upload(uploadPathFrom(data?.upload_url), body, opts.contentType);
48528
48788
  printOutput({ ...data, uploaded: true }, outputFormat(this));
48529
48789
  });
@@ -48588,9 +48848,9 @@ var init_attachments = __esm({
48588
48848
  });
48589
48849
 
48590
48850
  // src/data/commands/batch.ts
48591
- import { Command as Command4 } from "commander";
48851
+ import { Command as Command5 } from "commander";
48592
48852
  function buildBasesBatchCommand() {
48593
- return withBaseOption(new Command4("batch")).description("Execute atomic batch operations (up to 1,000 operations)").requiredOption("--operations <json>", "Operations array (inline JSON or @filename)").action(async function(opts) {
48853
+ return withBaseOption(new Command5("batch")).description("Execute atomic batch operations (up to 1,000 operations)").requiredOption("--operations <json>", "Operations array (inline JSON or @filename)").action(async function(opts) {
48594
48854
  const base = pathSegment(requireBase(this), "--base");
48595
48855
  const operations = parseData(opts.operations, "--operations");
48596
48856
  const client = await createDataClient();
@@ -48619,7 +48879,7 @@ import { createReadStream } from "fs";
48619
48879
  import { access, constants as constants2, stat } from "fs/promises";
48620
48880
  import { createInterface as createInterface3 } from "readline";
48621
48881
  import { randomUUID as randomUUID2 } from "crypto";
48622
- import { Command as Command5 } from "commander";
48882
+ import { Command as Command6 } from "commander";
48623
48883
  function isRetryable(err) {
48624
48884
  if (isNetworkError(err)) return true;
48625
48885
  if (!(err instanceof ApiError)) return false;
@@ -48695,7 +48955,7 @@ async function beginSession(state, client, base, recordType2, requestKey) {
48695
48955
  return res.session;
48696
48956
  }
48697
48957
  function buildBasesImportCommand() {
48698
- const importCmd = withBaseOption(new Command5("import")).description(
48958
+ const importCmd = withBaseOption(new Command6("import")).description(
48699
48959
  "Bulk historical import: load an NDJSON backfill, list sessions, or undo one"
48700
48960
  );
48701
48961
  importCmd.command("run <record_type>").description(
@@ -48939,7 +49199,7 @@ var init_import = __esm({
48939
49199
  });
48940
49200
 
48941
49201
  // src/data/commands/providers.ts
48942
- import { Command as Command6 } from "commander";
49202
+ import { Command as Command7 } from "commander";
48943
49203
  import { writeFileSync as writeFileSync13 } from "fs";
48944
49204
  function providerSegment(provider) {
48945
49205
  if (!VALID_PROVIDERS.includes(provider)) {
@@ -48948,7 +49208,7 @@ function providerSegment(provider) {
48948
49208
  return pathSegment(provider, "provider");
48949
49209
  }
48950
49210
  function buildBasesProvidersCommand() {
48951
- const providers = withBaseOption(new Command6("providers")).description(
49211
+ const providers = withBaseOption(new Command7("providers")).description(
48952
49212
  "Import/export tool definitions between LLM providers and record types"
48953
49213
  );
48954
49214
  providers.command("import <provider>").description(`Import tool definitions as record types. Providers: ${VALID_PROVIDERS_HELP}`).requiredOption("--tools <json>", "Tool definitions (inline JSON or @filename)").action(async function(provider, opts) {
@@ -49018,83 +49278,9 @@ var init_providers = __esm({
49018
49278
  }
49019
49279
  });
49020
49280
 
49021
- // src/data/commands/credentials.ts
49022
- import { Command as Command7 } from "commander";
49023
- function withValueSourceOptions(cmd, what) {
49024
- return cmd.option("--file <path>", `Read ${what} from a file (unavailable for now)`).option("--value-stdin", `Read ${what} from stdin (unavailable for now)`).option("--value-prompt", `Prompt for ${what}, masked (unavailable for now)`);
49025
- }
49026
- function credentialPath(base, id) {
49027
- const root = `/v1/${pathSegment(base, "base id")}/credentials`;
49028
- return id === void 0 ? root : `${root}/${pathSegment(id, "credential id")}`;
49029
- }
49030
- function buildBasesCredentialsCommand() {
49031
- const credentials = withBaseOption(
49032
- new Command7("credentials").description("Manage a base's integration credentials")
49033
- );
49034
- withValueSourceOptions(
49035
- credentials.command("create").description("Store a credential on this base \u2014 unavailable for now").option("--name <name>", "Credential name").option("--content-type <mime>", "MIME type of the value").option("--expires-at <date>", "Expiry as ISO-8601").option("--no-sync-to-production", "Do not publish this credential on promote (unavailable for now)"),
49036
- "the credential value"
49037
- ).action(() => {
49038
- throw expected(STORAGE_UNAVAILABLE);
49039
- });
49040
- credentials.command("list").description("List this base's credentials (values are never returned)").action(async function() {
49041
- const base = requireBase(this);
49042
- const client = await createDataClient();
49043
- printOutput(
49044
- await client.request("GET", credentialPath(base)),
49045
- outputFormat(this)
49046
- );
49047
- });
49048
- credentials.command("get <id>").description("Get credential metadata (the value is never returned)").action(async function(id) {
49049
- const base = requireBase(this);
49050
- const client = await createDataClient();
49051
- printOutput(
49052
- await client.request("GET", credentialPath(base, id)),
49053
- outputFormat(this)
49054
- );
49055
- });
49056
- withValueSourceOptions(
49057
- credentials.command("rotate <id>").description("Install a new value \u2014 unavailable for now").option("--expires-at <date>", "Set the rotated credential's new expiry (ISO-8601)"),
49058
- "the new credential value"
49059
- ).action(() => {
49060
- throw expected(STORAGE_UNAVAILABLE);
49061
- });
49062
- credentials.command("set-sync <id>").description("Set the promote-time publish flag \u2014 unavailable for now: promotion carries no credential").option("--no-sync-to-production", "Do not publish this credential on promote (unavailable for now)").action(() => {
49063
- throw expected("Promotion carries no base credential for now, so the publish flag has no effect. Nothing was changed.");
49064
- });
49065
- credentials.command("delete <id>").description("Delete a direct credential").option("-y, --yes", "Skip confirmation prompt").action(async function(id, opts) {
49066
- const base = requireBase(this);
49067
- if (!opts.yes) {
49068
- if (!isInteractive()) {
49069
- throw expected("Refusing to delete without confirmation \u2014 pass --yes to delete non-interactively.");
49070
- }
49071
- if (!await confirm(`Delete credential ${id} on base ${base}? This cannot be undone.`)) {
49072
- console.log("Aborted");
49073
- return;
49074
- }
49075
- }
49076
- const client = await createDataClient();
49077
- await client.request("DELETE", credentialPath(base, id));
49078
- printOutput({ id, deleted: true }, outputFormat(this));
49079
- });
49080
- return credentials;
49081
- }
49082
- var STORAGE_UNAVAILABLE;
49083
- var init_credentials = __esm({
49084
- "src/data/commands/credentials.ts"() {
49085
- "use strict";
49086
- init_client();
49087
- init_output();
49088
- init_helpers();
49089
- init_utils();
49090
- init_expected();
49091
- STORAGE_UNAVAILABLE = `Storing a base credential is unavailable for now: ${BASE_SECRET_STORAGE_WHY}. Nothing was read or stored.`;
49092
- }
49093
- });
49094
-
49095
49281
  // src/data/commands/sql.ts
49096
49282
  import { Command as Command8 } from "commander";
49097
- import { readFileSync as readFileSync23 } from "fs";
49283
+ import { readFileSync as readFileSync24 } from "fs";
49098
49284
  function buildBasesSqlCommand() {
49099
49285
  return withBaseOption(new Command8("sql")).description("Execute a read-only SQL query against base data").argument("[query]", "SQL query (SELECT only)").option("--file <path>", "Read SQL from a file instead of the argument").option(
49100
49286
  "--param <kv...>",
@@ -49104,7 +49290,7 @@ function buildBasesSqlCommand() {
49104
49290
  let query;
49105
49291
  if (opts.file) {
49106
49292
  try {
49107
- query = readFileSync23(opts.file, "utf-8").trim();
49293
+ query = readFileSync24(opts.file, "utf-8").trim();
49108
49294
  } catch (e) {
49109
49295
  throw expected(`--file ${opts.file}: ${e instanceof Error ? e.message : "could not be read"}`);
49110
49296
  }
@@ -49783,7 +49969,7 @@ var init_file_types = __esm({
49783
49969
 
49784
49970
  // src/data/commands/files.ts
49785
49971
  import { Command as Command12 } from "commander";
49786
- import { readFileSync as readFileSync24, writeFileSync as writeFileSync14 } from "fs";
49972
+ import { readFileSync as readFileSync25, writeFileSync as writeFileSync14 } from "fs";
49787
49973
  import { basename as basename31 } from "path";
49788
49974
  function renderFileDiff(fileType, filePath3, from, to, d) {
49789
49975
  console.log(sanitizeTerminalText(`${fileType}/${filePath3}: v${from} \u2192 v${to}`));
@@ -49840,7 +50026,7 @@ function buildFilesCommand() {
49840
50026
  label: opts.label,
49841
50027
  metadata: opts.metadata === void 0 ? void 0 : parseData(opts.metadata, "--metadata")
49842
50028
  });
49843
- const body = readFileSync24(opts.file);
50029
+ const body = readFileSync25(opts.file);
49844
50030
  const client = await createDataClient();
49845
50031
  printOutput(
49846
50032
  await client.upload(
@@ -50803,7 +50989,7 @@ init_errors3();
50803
50989
  init_mask_secrets();
50804
50990
  init_utils();
50805
50991
  init_registry();
50806
- import { readFileSync as readFileSync25 } from "fs";
50992
+ import { readFileSync as readFileSync26 } from "fs";
50807
50993
  import { fileURLToPath as fileURLToPath2 } from "url";
50808
50994
  import { dirname as dirname22, join as join49 } from "path";
50809
50995
 
@@ -50961,7 +51147,7 @@ Run \`wayai admin skill install\` to update.`);
50961
51147
 
50962
51148
  // src/index.ts
50963
51149
  var __dirname = dirname22(fileURLToPath2(import.meta.url));
50964
- var pkg = JSON.parse(readFileSync25(join49(__dirname, "..", "package.json"), "utf-8"));
51150
+ var pkg = JSON.parse(readFileSync26(join49(__dirname, "..", "package.json"), "utf-8"));
50965
51151
  var [, , command, ...args] = process.argv;
50966
51152
  var isBackgroundRefresh = command === REFRESH_COMMAND;
50967
51153
  if (!isBackgroundRefresh) initSentry(command, pkg.version);