@erxes/core-contract 0.1.0-v2.8 → 0.1.0-v2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import "./db/src/schema/index.js";
2
2
  import { ActionInput, Audience, AutomationDefinition, AutomationStep, AutomationTrigger, ConditionGroup, ConditionOperator, ConditionRule, ContextPath, Reentry, RelativeAmount } from "./db/src/automationDefinition.js";
3
- import { Activity, ActivityInput, ActivityTarget, CORE_ACTIVITY_TYPES, Note, NoteInput, NoteVersion, TimelineKind, TimelineTarget, activitiesContract } from "./activities.js";
4
- import { ActionField, ActionInfo, AutomationRun, RunStatus, RunStep } from "./automationRuns.js";
3
+ import { Activity, ActivityInput, CORE_ACTIVITY_TYPES, Note, NoteInput, NoteVersion, TimelineKind, activitiesContract } from "./activities.js";
4
+ import { ActionField, ActionFields, ActionInfo, AutomationRun, RunStatus, RunStep } from "./automationRuns.js";
5
5
  import { CONDITION_OPERATORS, PLUGIN_SCOPES } from "./db/src/enums.js";
6
6
  import { ConditionGroup as ConditionGroup$1 } from "./db/src/schema/common.js";
7
7
  import { Automation, AutomationFieldPath, DryRunStep, automationsContract } from "./automations.js";
@@ -29,6 +29,7 @@ import { Product, ProductCategory, ProductStatus, productCategoriesContract, pro
29
29
  import { CORE_PERMISSIONS, CorePermission, ManifestPermissionSet, OWNER_ONLY_PERMISSIONS, PermissionAction, PermissionInfo, PermissionSet, Role, rolesContract } from "./roles.js";
30
30
  import { EntitlementStatus, OrganizationStatus, PluginAccess, PluginPlan, PluginTier, SaasWorkspace, SubscriptionInfo, saasContract } from "./saas.js";
31
31
  import { Tag, tagsContract } from "./tags.js";
32
+ import { ActivityTarget, PluginTimeline, RecordAccessAnswer, RecordAccessCheck, TimelineTarget } from "./timelines.js";
32
33
  import { TrashItem, trashContract } from "./trash.js";
33
34
  import { Export, ExportQuery, Import, ImportOptions, ImportRow, ImportStatus, TransferColumn, TransferRecordType, transferContract } from "./transfer.js";
34
35
  import { DateOnly, User, UserLinks, UserStatus, usersContract } from "./users.js";
@@ -374,6 +375,160 @@ export declare const coreContract: {
374
375
  status: number;
375
376
  };
376
377
  }>, Record<never, never>>;
378
+ importNote: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<import("zod").ZodObject<{
379
+ targetType: import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
380
+ company: "company";
381
+ customer: "customer";
382
+ }>, import("zod").ZodString]>;
383
+ targetId: import("zod").ZodString;
384
+ body: import("zod").ZodString;
385
+ authorId: import("zod").ZodString;
386
+ createdAt: import("zod").ZodISODateTime;
387
+ dedupeKey: import("zod").ZodString;
388
+ }, import("zod/v4/core").$strip>, import("zod").ZodObject<{
389
+ activity: import("zod").ZodObject<{
390
+ id: import("zod").ZodString;
391
+ targetType: import("zod").ZodString;
392
+ targetId: import("zod").ZodString;
393
+ source: import("zod").ZodString;
394
+ type: import("zod").ZodString;
395
+ summary: import("zod").ZodNullable<import("zod").ZodString>;
396
+ data: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>;
397
+ entityType: import("zod").ZodNullable<import("zod").ZodString>;
398
+ entityId: import("zod").ZodNullable<import("zod").ZodString>;
399
+ link: import("zod").ZodNullable<import("zod").ZodString>;
400
+ actorType: import("zod").ZodEnum<{
401
+ customer: "customer";
402
+ plugin: "plugin";
403
+ system: "system";
404
+ user: "user";
405
+ }>;
406
+ actorId: import("zod").ZodNullable<import("zod").ZodString>;
407
+ occurredAt: import("zod").ZodCodec<import("zod").ZodDate, import("zod").ZodISODateTime>;
408
+ actorName: import("zod").ZodNullable<import("zod").ZodString>;
409
+ actorAvatarUrl: import("zod").ZodNullable<import("zod").ZodString>;
410
+ note: import("zod").ZodNullable<import("zod").ZodObject<{
411
+ body: import("zod").ZodString;
412
+ mentions: import("zod").ZodArray<import("zod").ZodString>;
413
+ fileIds: import("zod").ZodArray<import("zod").ZodString>;
414
+ pinnedAt: import("zod").ZodNullable<import("zod").ZodCodec<import("zod").ZodDate, import("zod").ZodISODateTime>>;
415
+ editedAt: import("zod").ZodNullable<import("zod").ZodCodec<import("zod").ZodDate, import("zod").ZodISODateTime>>;
416
+ }, {
417
+ out: {};
418
+ in: {};
419
+ }>>;
420
+ reactions: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>>;
421
+ }, {
422
+ out: {};
423
+ in: {};
424
+ }>;
425
+ created: import("zod").ZodBoolean;
426
+ }, import("zod/v4/core").$strip>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
427
+ UNAUTHORIZED: {
428
+ status: number;
429
+ };
430
+ NOT_ALLOWED: {
431
+ status: number;
432
+ data: import("zod").ZodOptional<import("zod").ZodObject<{
433
+ permission: import("zod").ZodString;
434
+ }, import("zod/v4/core").$strip>>;
435
+ };
436
+ PLUGIN_ONLY: {
437
+ status: number;
438
+ };
439
+ MEMBERS_ONLY: {
440
+ status: number;
441
+ };
442
+ ORG_REQUIRED: {
443
+ status: number;
444
+ };
445
+ SCOPE_REQUIRED: {
446
+ status: number;
447
+ };
448
+ SERVICE_TOKEN_REQUIRED: {
449
+ status: number;
450
+ };
451
+ ORGANIZATION_DISABLED: {
452
+ status: number;
453
+ data: import("zod").ZodObject<{
454
+ manageUrl: import("zod").ZodNullable<import("zod").ZodString>;
455
+ }, import("zod/v4/core").$strip>;
456
+ };
457
+ NOT_IN_PLAN: {
458
+ status: number;
459
+ data: import("zod").ZodOptional<import("zod").ZodObject<{
460
+ manageUrl: import("zod").ZodNullable<import("zod").ZodString>;
461
+ }, import("zod/v4/core").$strip>>;
462
+ };
463
+ READ_ONLY: {
464
+ status: number;
465
+ };
466
+ TOO_MANY_REQUESTS: {
467
+ status: number;
468
+ };
469
+ INVALID_INPUT: {
470
+ status: number;
471
+ data: import("zod").ZodObject<{
472
+ issues: import("zod").ZodArray<import("zod").ZodObject<{
473
+ path: import("zod").ZodArray<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodInt]>>;
474
+ message: import("zod").ZodString;
475
+ }, import("zod/v4/core").$strip>>;
476
+ }, import("zod/v4/core").$strip>;
477
+ };
478
+ NOT_FOUND: {
479
+ status: number;
480
+ };
481
+ TAKEN: {
482
+ status: number;
483
+ data: import("zod").ZodObject<{
484
+ field: import("zod").ZodString;
485
+ id: import("zod").ZodOptional<import("zod").ZodString>;
486
+ values: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
487
+ }, import("zod/v4/core").$strip>;
488
+ };
489
+ INVALID_CURSOR: {
490
+ status: number;
491
+ };
492
+ INVALID_REFERENCE: {
493
+ status: number;
494
+ data: import("zod").ZodObject<{
495
+ field: import("zod").ZodString;
496
+ }, import("zod/v4/core").$strip>;
497
+ };
498
+ INVALID_FILTER: {
499
+ status: number;
500
+ };
501
+ FILTER_TOO_SLOW: {
502
+ status: number;
503
+ };
504
+ INVALID_ACTOR: {
505
+ status: number;
506
+ };
507
+ INVALID_FILE: {
508
+ status: number;
509
+ };
510
+ INVALID_OWNER: {
511
+ status: number;
512
+ };
513
+ INVALID_RECIPIENT: {
514
+ status: number;
515
+ };
516
+ INVALID_TYPE: {
517
+ status: number;
518
+ };
519
+ MASS_DELETE_STOPPED: {
520
+ status: number;
521
+ };
522
+ NOT_AUTHOR: {
523
+ status: number;
524
+ };
525
+ NO_TIMELINE: {
526
+ status: number;
527
+ };
528
+ TOO_MANY_REACTIONS: {
529
+ status: number;
530
+ };
531
+ }>, Record<never, never>>;
377
532
  react: import("@orpc/contract").ContractProcedureBuilderWithInputOutput<import("zod").ZodObject<{
378
533
  id: import("zod").ZodString;
379
534
  emoji: import("zod").ZodString;
@@ -1608,6 +1763,7 @@ export declare const coreContract: {
1608
1763
  longtext: "longtext";
1609
1764
  members: "members";
1610
1765
  number: "number";
1766
+ plugin_record: "plugin_record";
1611
1767
  recipients: "recipients";
1612
1768
  select: "select";
1613
1769
  tags: "tags";
@@ -1621,6 +1777,8 @@ export declare const coreContract: {
1621
1777
  description: import("zod").ZodOptional<import("zod").ZodString>;
1622
1778
  placeholder: import("zod").ZodOptional<import("zod").ZodString>;
1623
1779
  sameTypeAs: import("zod").ZodOptional<import("zod").ZodString>;
1780
+ recordType: import("zod").ZodOptional<import("zod").ZodString>;
1781
+ dependsOn: import("zod").ZodOptional<import("zod").ZodString>;
1624
1782
  }, import("zod/v4/core").$strip>>;
1625
1783
  }, import("zod/v4/core").$strip>>;
1626
1784
  }, import("zod/v4/core").$strip>, import("@orpc/contract").MergedErrorMap<Record<never, never>, {
@@ -22870,6 +23028,7 @@ export declare const coreContract: {
22870
23028
  longtext: "longtext";
22871
23029
  members: "members";
22872
23030
  number: "number";
23031
+ plugin_record: "plugin_record";
22873
23032
  recipients: "recipients";
22874
23033
  select: "select";
22875
23034
  tags: "tags";
@@ -22883,12 +23042,15 @@ export declare const coreContract: {
22883
23042
  description: import("zod").ZodOptional<import("zod").ZodString>;
22884
23043
  placeholder: import("zod").ZodOptional<import("zod").ZodString>;
22885
23044
  sameTypeAs: import("zod").ZodOptional<import("zod").ZodString>;
23045
+ recordType: import("zod").ZodOptional<import("zod").ZodString>;
23046
+ dependsOn: import("zod").ZodOptional<import("zod").ZodString>;
22886
23047
  }, import("zod/v4/core").$strip>>>;
22887
23048
  }, import("zod/v4/core").$strip>>>;
22888
23049
  timelines: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
22889
23050
  type: import("zod").ZodString;
22890
23051
  label: import("zod").ZodString;
22891
23052
  permission: import("zod").ZodOptional<import("zod").ZodString>;
23053
+ recordAccess: import("zod").ZodOptional<import("zod").ZodBoolean>;
22892
23054
  }, import("zod/v4/core").$strip>>>;
22893
23055
  activityTypes: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
22894
23056
  type: import("zod").ZodString;
@@ -22900,6 +23062,7 @@ export declare const coreContract: {
22900
23062
  jobs: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
22901
23063
  name: import("zod").ZodString;
22902
23064
  cron: import("zod").ZodOptional<import("zod").ZodString>;
23065
+ onInstall: import("zod").ZodOptional<import("zod").ZodBoolean>;
22903
23066
  retry: import("zod").ZodOptional<import("zod").ZodObject<{
22904
23067
  attempts: import("zod").ZodInt;
22905
23068
  delay: import("zod").ZodInt;
@@ -32205,4 +32368,4 @@ export declare const coreContract: {
32205
32368
  }>, Record<never, never>>;
32206
32369
  };
32207
32370
  };
32208
- export { ActionField, ActionInfo, ActionInput, Activity, ActivityInput, ActivityTarget, ActorType, AppLink, Audience, AuditEntry, AuditStream, AuditStreamFormat, Automation, AutomationDefinition, AutomationFieldPath, AutomationRun, AutomationStatus, AutomationStep, AutomationTrigger, COMMON_ERRORS, CONDITION_OPERATORS, CORE_ACTIVITY_TYPES, CORE_API_PREFIX, CORE_API_VERSION, CORE_EVENT_TYPES, CORE_NOTIFICATION_GROUPS, CORE_NOTIFICATION_KINDS, CORE_PERMISSIONS, COUNTRIES, Company, CompanyFields, CompanyInput, CompanyRef, ConditionGroup, ConditionOperator, ConditionRule, ContactLink, ContactLinkInput, ContactState, ContentType, ContextPath, CoreEvent, CoreNotificationKind, CorePermission, Country, Currency, CursorQuery, CustomFields, CustomFieldsPatch, CustomValue, Customer, CustomerFields, CustomerInput, CustomerLogin, CustomerProfile, CustomerSession, CustomerSex, CustomerState, CustomerTokens, DESCRIPTION_MAX, DateOnly, DedupeKey, DryRunStep, ERRORS, EmailAddress, EmailMessage, EntitlementStatus, EntityType, ErrorCode, EventFailure, EventFailureStatus, EventInput, EventNotify, EventPattern, EventType, EventTypeInfo, Export, ExportQuery, FIELD_TYPE_FAMILIES, Field, FieldContentType, FieldGroup, FieldType, FieldUsage, FieldValidation, FileInfo, FileSettings, FilterField, GatewayConfig, Id, IdList, ImageAddress, Import, ImportOptions, ImportRow, ImportStatus, InvalidInput, InviteRole, Invoice, InvoiceLine, InvoiceLineInput, InvoiceMetadata, InvoiceStatus, JobName, LEAD_SOURCES, LIFECYCLE_COLUMNS, LIFECYCLE_INPUT_COLUMNS, LIST_MAX, LeadEvent, LeadRecordType, LeadReport, LeadSource, LeadStage, LeadStageKind, LiveMode, LiveTopic, ManifestPermissionSet, NewPassword, Note, NoteInput, NoteVersion, Notification, NotificationDelivery, NotificationGroupSetting, NotificationInput, NotificationSettings, OPTION_FIELD_TYPES, OWNER_ONLY_PERMISSIONS, Organization, OrganizationRegion, OrganizationStatus, PAYMENT_GATEWAYS, PLUGIN_FIELDS_MAX, PLUGIN_SCOPES, PLUGIN_VALUES_MAX, PageInfo, PaymentGateway, PaymentGatewayKind, PermissionAction, PermissionInfo, PermissionSet, PersonRef, PhoneNumber, Plugin, PluginAccess, PluginField, PluginFields, PluginInstallation, PluginJobDelivery, PluginJobs, PluginManifest, PluginName, PluginPaymentSettings, PluginPlan, PluginScope, PluginTier, PluginViewType, Product, ProductCategory, ProductKind, ProductStatus, QueryBoolean, QueryFlag, RecordFilter, Reentry, Refund, RelativeAmount, Role, RoleKey, RunStatus, RunStep, SaasWorkspace, Session, SourceDetails, SubscriptionInfo, Tag, TimelineKind, TimelineTarget, TokenResponse, TransferColumn, TransferRecordType, TrashItem, UNMUTABLE_NOTIFICATION_KINDS, USER_LINK_NAMES, UploadTarget, User, UserLinkName, UserLinks, UserStatus, VIEW_MATCHES_MAX, View, ViewListType, ViewRecordType, ViewSort, Webhook, WebhookDelivery, activitiesContract, auditContract, authContract, automationsContract, companiesContract, currencyDigits, currencyOfCountry, cursorPageOf, customerAccountContract, customerAuthContract, customersContract, emailsContract, eventsContract, fieldGroupsContract, fieldsContract, filesContract, gatewayTakes, isoDate, leadsContract, lifecycleInput, lifecycleRow, listOf, notificationGroupOf, notificationsContract, organizationsContract, paymentsContract, pluginFieldsContract, pluginsContract, productCategoriesContract, productsContract, rolesContract, saasContract, tagsContract, transferContract, trashContract, usersContract, viewsContract, webhooksContract };
32371
+ export { ActionField, ActionFields, ActionInfo, ActionInput, Activity, ActivityInput, ActivityTarget, ActorType, AppLink, Audience, AuditEntry, AuditStream, AuditStreamFormat, Automation, AutomationDefinition, AutomationFieldPath, AutomationRun, AutomationStatus, AutomationStep, AutomationTrigger, COMMON_ERRORS, CONDITION_OPERATORS, CORE_ACTIVITY_TYPES, CORE_API_PREFIX, CORE_API_VERSION, CORE_EVENT_TYPES, CORE_NOTIFICATION_GROUPS, CORE_NOTIFICATION_KINDS, CORE_PERMISSIONS, COUNTRIES, Company, CompanyFields, CompanyInput, CompanyRef, ConditionGroup, ConditionOperator, ConditionRule, ContactLink, ContactLinkInput, ContactState, ContentType, ContextPath, CoreEvent, CoreNotificationKind, CorePermission, Country, Currency, CursorQuery, CustomFields, CustomFieldsPatch, CustomValue, Customer, CustomerFields, CustomerInput, CustomerLogin, CustomerProfile, CustomerSession, CustomerSex, CustomerState, CustomerTokens, DESCRIPTION_MAX, DateOnly, DedupeKey, DryRunStep, ERRORS, EmailAddress, EmailMessage, EntitlementStatus, EntityType, ErrorCode, EventFailure, EventFailureStatus, EventInput, EventNotify, EventPattern, EventType, EventTypeInfo, Export, ExportQuery, FIELD_TYPE_FAMILIES, Field, FieldContentType, FieldGroup, FieldType, FieldUsage, FieldValidation, FileInfo, FileSettings, FilterField, GatewayConfig, Id, IdList, ImageAddress, Import, ImportOptions, ImportRow, ImportStatus, InvalidInput, InviteRole, Invoice, InvoiceLine, InvoiceLineInput, InvoiceMetadata, InvoiceStatus, JobName, LEAD_SOURCES, LIFECYCLE_COLUMNS, LIFECYCLE_INPUT_COLUMNS, LIST_MAX, LeadEvent, LeadRecordType, LeadReport, LeadSource, LeadStage, LeadStageKind, LiveMode, LiveTopic, ManifestPermissionSet, NewPassword, Note, NoteInput, NoteVersion, Notification, NotificationDelivery, NotificationGroupSetting, NotificationInput, NotificationSettings, OPTION_FIELD_TYPES, OWNER_ONLY_PERMISSIONS, Organization, OrganizationRegion, OrganizationStatus, PAYMENT_GATEWAYS, PLUGIN_FIELDS_MAX, PLUGIN_SCOPES, PLUGIN_VALUES_MAX, PageInfo, PaymentGateway, PaymentGatewayKind, PermissionAction, PermissionInfo, PermissionSet, PersonRef, PhoneNumber, Plugin, PluginAccess, PluginField, PluginFields, PluginInstallation, PluginJobDelivery, PluginJobs, PluginManifest, PluginName, PluginPaymentSettings, PluginPlan, PluginScope, PluginTier, PluginTimeline, PluginViewType, Product, ProductCategory, ProductKind, ProductStatus, QueryBoolean, QueryFlag, RecordAccessAnswer, RecordAccessCheck, RecordFilter, Reentry, Refund, RelativeAmount, Role, RoleKey, RunStatus, RunStep, SaasWorkspace, Session, SourceDetails, SubscriptionInfo, Tag, TimelineKind, TimelineTarget, TokenResponse, TransferColumn, TransferRecordType, TrashItem, UNMUTABLE_NOTIFICATION_KINDS, USER_LINK_NAMES, UploadTarget, User, UserLinkName, UserLinks, UserStatus, VIEW_MATCHES_MAX, View, ViewListType, ViewRecordType, ViewSort, Webhook, WebhookDelivery, activitiesContract, auditContract, authContract, automationsContract, companiesContract, currencyDigits, currencyOfCountry, cursorPageOf, customerAccountContract, customerAuthContract, customersContract, emailsContract, eventsContract, fieldGroupsContract, fieldsContract, filesContract, gatewayTakes, isoDate, leadsContract, lifecycleInput, lifecycleRow, listOf, notificationGroupOf, notificationsContract, organizationsContract, paymentsContract, pluginFieldsContract, pluginsContract, productCategoriesContract, productsContract, rolesContract, saasContract, tagsContract, transferContract, trashContract, usersContract, viewsContract, webhooksContract };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { CONDITION_OPERATORS, PLUGIN_SCOPES } from "./db/src/enums.js";
2
- import { Activity, ActivityInput, ActivityTarget, CORE_ACTIVITY_TYPES, Note, NoteInput, NoteVersion, TimelineKind, TimelineTarget, activitiesContract } from "./activities.js";
2
+ import { Activity, ActivityInput, CORE_ACTIVITY_TYPES, Note, NoteInput, NoteVersion, TimelineKind, activitiesContract } from "./activities.js";
3
3
  import { Automation, AutomationFieldPath, DryRunStep, automationsContract } from "./automations.js";
4
4
  import { AuditEntry, AuditStream, auditContract } from "./audit.js";
5
5
  import { Session, authContract } from "./auth.js";
@@ -25,13 +25,14 @@ import { FilterField, PluginViewType, RecordFilter, VIEW_MATCHES_MAX, View, View
25
25
  import { Export, ExportQuery, Import, ImportOptions, ImportRow, ImportStatus, TransferColumn, TransferRecordType, transferContract } from "./transfer.js";
26
26
  import { LEAD_SOURCES, LIFECYCLE_COLUMNS, LIFECYCLE_INPUT_COLUMNS, LeadEvent, LeadRecordType, LeadReport, LeadSource, LeadStage, LeadStageKind, SourceDetails, leadsContract, lifecycleInput, lifecycleRow } from "./leads.js";
27
27
  import { ActionInput, Audience, AutomationDefinition, AutomationStep, AutomationTrigger, ConditionGroup, ConditionOperator, ConditionRule, ContextPath, Reentry, RelativeAmount } from "./db/src/automationDefinition.js";
28
- import { ActionField, ActionInfo, AutomationRun, RunStatus, RunStep } from "./automationRuns.js";
28
+ import { ActionField, ActionFields, ActionInfo, AutomationRun, RunStatus, RunStep } from "./automationRuns.js";
29
29
  import { ContentType, CursorQuery, CustomFields, CustomFieldsPatch, CustomValue, DESCRIPTION_MAX, EmailAddress, FieldContentType, Id, IdList, ImageAddress, InvalidInput, LIST_MAX, PageInfo, PhoneNumber, QueryBoolean, QueryFlag, cursorPageOf, isoDate, listOf } from "./common.js";
30
30
  import { COMMON_ERRORS, ERRORS } from "./errors.js";
31
31
  import { COUNTRIES, Country, Currency, currencyDigits, currencyOfCountry } from "./money.js";
32
32
  import { ActorType, AppLink, DedupeKey, EntityType, EventType } from "./platform.js";
33
33
  import { JobName, PluginJobDelivery, PluginJobs } from "./pluginJobs.js";
34
34
  import { PLUGIN_FIELDS_MAX, PLUGIN_VALUES_MAX, PluginField, PluginFields, pluginFieldsContract } from "./pluginFields.js";
35
+ import { ActivityTarget, PluginTimeline, RecordAccessAnswer, RecordAccessCheck, TimelineTarget } from "./timelines.js";
35
36
  import { AuditStreamFormat, AutomationStatus, CORE_API_PREFIX, CORE_API_VERSION, CORE_NOTIFICATION_GROUPS, ContactState, CustomerSex, FIELD_TYPE_FAMILIES, FieldType, FieldValidation, InviteRole, InvoiceStatus, LiveMode, NewPassword, NotificationDelivery, OPTION_FIELD_TYPES, PAYMENT_GATEWAYS, PaymentGatewayKind, ProductKind, RoleKey, UNMUTABLE_NOTIFICATION_KINDS, USER_LINK_NAMES, UserLinkName, gatewayTakes, notificationGroupOf } from "./values.js";
36
37
  // src/index.ts
37
38
  /** The whole core API. Core implements it; plugins call it with a typed client. */
@@ -65,4 +66,4 @@ const coreContract = {
65
66
  views: viewsContract,
66
67
  webhooks: webhooksContract
67
68
  };
68
- export { ActionField, ActionInfo, ActionInput, Activity, ActivityInput, ActivityTarget, ActorType, AppLink, Audience, AuditEntry, AuditStream, AuditStreamFormat, Automation, AutomationDefinition, AutomationFieldPath, AutomationRun, AutomationStatus, AutomationStep, AutomationTrigger, COMMON_ERRORS, CONDITION_OPERATORS, CORE_ACTIVITY_TYPES, CORE_API_PREFIX, CORE_API_VERSION, CORE_EVENT_TYPES, CORE_NOTIFICATION_GROUPS, CORE_NOTIFICATION_KINDS, CORE_PERMISSIONS, COUNTRIES, Company, CompanyFields, CompanyRef, ConditionGroup, ConditionOperator, ConditionRule, ContactLink, ContactLinkInput, ContactState, ContentType, ContextPath, CoreEvent, Country, Currency, CursorQuery, CustomFields, CustomFieldsPatch, CustomValue, Customer, CustomerFields, CustomerLogin, CustomerProfile, CustomerSession, CustomerSex, CustomerState, CustomerTokens, DESCRIPTION_MAX, DateOnly, DedupeKey, DryRunStep, ERRORS, EmailAddress, EmailMessage, EntitlementStatus, EntityType, EventFailure, EventFailureStatus, EventInput, EventNotify, EventPattern, EventType, EventTypeInfo, Export, ExportQuery, FIELD_TYPE_FAMILIES, Field, FieldContentType, FieldGroup, FieldType, FieldUsage, FieldValidation, FileInfo, FileSettings, FilterField, GatewayConfig, Id, IdList, ImageAddress, Import, ImportOptions, ImportRow, ImportStatus, InvalidInput, InviteRole, Invoice, InvoiceLine, InvoiceLineInput, InvoiceMetadata, InvoiceStatus, JobName, LEAD_SOURCES, LIFECYCLE_COLUMNS, LIFECYCLE_INPUT_COLUMNS, LIST_MAX, LeadEvent, LeadRecordType, LeadReport, LeadSource, LeadStage, LeadStageKind, LiveMode, LiveTopic, ManifestPermissionSet, NewPassword, Note, NoteInput, NoteVersion, Notification, NotificationDelivery, NotificationGroupSetting, NotificationInput, NotificationSettings, OPTION_FIELD_TYPES, OWNER_ONLY_PERMISSIONS, Organization, OrganizationRegion, OrganizationStatus, PAYMENT_GATEWAYS, PLUGIN_FIELDS_MAX, PLUGIN_SCOPES, PLUGIN_VALUES_MAX, PageInfo, PaymentGateway, PaymentGatewayKind, PermissionAction, PermissionInfo, PermissionSet, PersonRef, PhoneNumber, Plugin, PluginAccess, PluginField, PluginFields, PluginInstallation, PluginJobDelivery, PluginJobs, PluginManifest, PluginName, PluginPaymentSettings, PluginPlan, PluginScope, PluginTier, PluginViewType, Product, ProductCategory, ProductKind, ProductStatus, QueryBoolean, QueryFlag, RecordFilter, Reentry, Refund, RelativeAmount, Role, RoleKey, RunStatus, RunStep, SaasWorkspace, Session, SourceDetails, SubscriptionInfo, Tag, TimelineKind, TimelineTarget, TokenResponse, TransferColumn, TransferRecordType, TrashItem, UNMUTABLE_NOTIFICATION_KINDS, USER_LINK_NAMES, UploadTarget, User, UserLinkName, UserLinks, UserStatus, VIEW_MATCHES_MAX, View, ViewListType, ViewRecordType, ViewSort, Webhook, WebhookDelivery, activitiesContract, auditContract, authContract, automationsContract, companiesContract, coreContract, currencyDigits, currencyOfCountry, cursorPageOf, customerAccountContract, customerAuthContract, customersContract, emailsContract, eventsContract, fieldGroupsContract, fieldsContract, filesContract, gatewayTakes, isoDate, leadsContract, lifecycleInput, lifecycleRow, listOf, notificationGroupOf, notificationsContract, organizationsContract, paymentsContract, pluginFieldsContract, pluginsContract, productCategoriesContract, productsContract, rolesContract, saasContract, tagsContract, transferContract, trashContract, usersContract, viewsContract, webhooksContract };
69
+ export { ActionField, ActionFields, ActionInfo, ActionInput, Activity, ActivityInput, ActivityTarget, ActorType, AppLink, Audience, AuditEntry, AuditStream, AuditStreamFormat, Automation, AutomationDefinition, AutomationFieldPath, AutomationRun, AutomationStatus, AutomationStep, AutomationTrigger, COMMON_ERRORS, CONDITION_OPERATORS, CORE_ACTIVITY_TYPES, CORE_API_PREFIX, CORE_API_VERSION, CORE_EVENT_TYPES, CORE_NOTIFICATION_GROUPS, CORE_NOTIFICATION_KINDS, CORE_PERMISSIONS, COUNTRIES, Company, CompanyFields, CompanyRef, ConditionGroup, ConditionOperator, ConditionRule, ContactLink, ContactLinkInput, ContactState, ContentType, ContextPath, CoreEvent, Country, Currency, CursorQuery, CustomFields, CustomFieldsPatch, CustomValue, Customer, CustomerFields, CustomerLogin, CustomerProfile, CustomerSession, CustomerSex, CustomerState, CustomerTokens, DESCRIPTION_MAX, DateOnly, DedupeKey, DryRunStep, ERRORS, EmailAddress, EmailMessage, EntitlementStatus, EntityType, EventFailure, EventFailureStatus, EventInput, EventNotify, EventPattern, EventType, EventTypeInfo, Export, ExportQuery, FIELD_TYPE_FAMILIES, Field, FieldContentType, FieldGroup, FieldType, FieldUsage, FieldValidation, FileInfo, FileSettings, FilterField, GatewayConfig, Id, IdList, ImageAddress, Import, ImportOptions, ImportRow, ImportStatus, InvalidInput, InviteRole, Invoice, InvoiceLine, InvoiceLineInput, InvoiceMetadata, InvoiceStatus, JobName, LEAD_SOURCES, LIFECYCLE_COLUMNS, LIFECYCLE_INPUT_COLUMNS, LIST_MAX, LeadEvent, LeadRecordType, LeadReport, LeadSource, LeadStage, LeadStageKind, LiveMode, LiveTopic, ManifestPermissionSet, NewPassword, Note, NoteInput, NoteVersion, Notification, NotificationDelivery, NotificationGroupSetting, NotificationInput, NotificationSettings, OPTION_FIELD_TYPES, OWNER_ONLY_PERMISSIONS, Organization, OrganizationRegion, OrganizationStatus, PAYMENT_GATEWAYS, PLUGIN_FIELDS_MAX, PLUGIN_SCOPES, PLUGIN_VALUES_MAX, PageInfo, PaymentGateway, PaymentGatewayKind, PermissionAction, PermissionInfo, PermissionSet, PersonRef, PhoneNumber, Plugin, PluginAccess, PluginField, PluginFields, PluginInstallation, PluginJobDelivery, PluginJobs, PluginManifest, PluginName, PluginPaymentSettings, PluginPlan, PluginScope, PluginTier, PluginTimeline, PluginViewType, Product, ProductCategory, ProductKind, ProductStatus, QueryBoolean, QueryFlag, RecordAccessAnswer, RecordAccessCheck, RecordFilter, Reentry, Refund, RelativeAmount, Role, RoleKey, RunStatus, RunStep, SaasWorkspace, Session, SourceDetails, SubscriptionInfo, Tag, TimelineKind, TimelineTarget, TokenResponse, TransferColumn, TransferRecordType, TrashItem, UNMUTABLE_NOTIFICATION_KINDS, USER_LINK_NAMES, UploadTarget, User, UserLinkName, UserLinks, UserStatus, VIEW_MATCHES_MAX, View, ViewListType, ViewRecordType, ViewSort, Webhook, WebhookDelivery, activitiesContract, auditContract, authContract, automationsContract, companiesContract, coreContract, currencyDigits, currencyOfCountry, cursorPageOf, customerAccountContract, customerAuthContract, customersContract, emailsContract, eventsContract, fieldGroupsContract, fieldsContract, filesContract, gatewayTakes, isoDate, leadsContract, lifecycleInput, lifecycleRow, listOf, notificationGroupOf, notificationsContract, organizationsContract, paymentsContract, pluginFieldsContract, pluginsContract, productCategoriesContract, productsContract, rolesContract, saasContract, tagsContract, transferContract, trashContract, usersContract, viewsContract, webhooksContract };
@@ -11,6 +11,7 @@ export declare const JobName: z.ZodString;
11
11
  export declare const PluginJobs: z.ZodArray<z.ZodObject<{
12
12
  name: z.ZodString;
13
13
  cron: z.ZodOptional<z.ZodString>;
14
+ onInstall: z.ZodOptional<z.ZodBoolean>;
14
15
  retry: z.ZodOptional<z.ZodObject<{
15
16
  attempts: z.ZodInt;
16
17
  delay: z.ZodInt;
@@ -7,6 +7,11 @@ const PluginJob = z.object({
7
7
  /** A cron schedule in UTC (`0 3 * * *`): one job per organisation each time it comes due. */
8
8
  cron: z.string().trim().min(1).max(100).optional(),
9
9
  /**
10
+ * Also runs once for an organisation when it installs the plugin or approves the scopes a newer
11
+ * version asks for: a backfill of what the plugin could not do before.
12
+ */
13
+ onInstall: z.boolean().optional(),
14
+ /**
10
15
  * Attempts in all; the first retry waits `delay` seconds, each next one
11
16
  * about twice as long, up to `maxDelay`. Default: 8 attempts, 30 s, 6 hours.
12
17
  */
package/dist/plugins.d.ts CHANGED
@@ -101,6 +101,7 @@ export declare const PluginManifest: z.ZodObject<{
101
101
  longtext: "longtext";
102
102
  members: "members";
103
103
  number: "number";
104
+ plugin_record: "plugin_record";
104
105
  recipients: "recipients";
105
106
  select: "select";
106
107
  tags: "tags";
@@ -114,12 +115,15 @@ export declare const PluginManifest: z.ZodObject<{
114
115
  description: z.ZodOptional<z.ZodString>;
115
116
  placeholder: z.ZodOptional<z.ZodString>;
116
117
  sameTypeAs: z.ZodOptional<z.ZodString>;
118
+ recordType: z.ZodOptional<z.ZodString>;
119
+ dependsOn: z.ZodOptional<z.ZodString>;
117
120
  }, z.core.$strip>>>;
118
121
  }, z.core.$strip>>>;
119
122
  timelines: z.ZodOptional<z.ZodArray<z.ZodObject<{
120
123
  type: z.ZodString;
121
124
  label: z.ZodString;
122
125
  permission: z.ZodOptional<z.ZodString>;
126
+ recordAccess: z.ZodOptional<z.ZodBoolean>;
123
127
  }, z.core.$strip>>>;
124
128
  activityTypes: z.ZodOptional<z.ZodArray<z.ZodObject<{
125
129
  type: z.ZodString;
@@ -131,6 +135,7 @@ export declare const PluginManifest: z.ZodObject<{
131
135
  jobs: z.ZodOptional<z.ZodArray<z.ZodObject<{
132
136
  name: z.ZodString;
133
137
  cron: z.ZodOptional<z.ZodString>;
138
+ onInstall: z.ZodOptional<z.ZodBoolean>;
134
139
  retry: z.ZodOptional<z.ZodObject<{
135
140
  attempts: z.ZodInt;
136
141
  delay: z.ZodInt;
@@ -414,6 +419,7 @@ export declare const pluginsContract: {
414
419
  longtext: "longtext";
415
420
  members: "members";
416
421
  number: "number";
422
+ plugin_record: "plugin_record";
417
423
  recipients: "recipients";
418
424
  select: "select";
419
425
  tags: "tags";
@@ -427,12 +433,15 @@ export declare const pluginsContract: {
427
433
  description: z.ZodOptional<z.ZodString>;
428
434
  placeholder: z.ZodOptional<z.ZodString>;
429
435
  sameTypeAs: z.ZodOptional<z.ZodString>;
436
+ recordType: z.ZodOptional<z.ZodString>;
437
+ dependsOn: z.ZodOptional<z.ZodString>;
430
438
  }, z.core.$strip>>>;
431
439
  }, z.core.$strip>>>;
432
440
  timelines: z.ZodOptional<z.ZodArray<z.ZodObject<{
433
441
  type: z.ZodString;
434
442
  label: z.ZodString;
435
443
  permission: z.ZodOptional<z.ZodString>;
444
+ recordAccess: z.ZodOptional<z.ZodBoolean>;
436
445
  }, z.core.$strip>>>;
437
446
  activityTypes: z.ZodOptional<z.ZodArray<z.ZodObject<{
438
447
  type: z.ZodString;
@@ -444,6 +453,7 @@ export declare const pluginsContract: {
444
453
  jobs: z.ZodOptional<z.ZodArray<z.ZodObject<{
445
454
  name: z.ZodString;
446
455
  cron: z.ZodOptional<z.ZodString>;
456
+ onInstall: z.ZodOptional<z.ZodBoolean>;
447
457
  retry: z.ZodOptional<z.ZodObject<{
448
458
  attempts: z.ZodInt;
449
459
  delay: z.ZodInt;
package/dist/plugins.js CHANGED
@@ -4,12 +4,13 @@ import "./db/src/schema/index.js";
4
4
  import { COMMON_ERRORS, ERRORS } from "./errors.js";
5
5
  import { EventPattern } from "./webhooks.js";
6
6
  import { Id, isoDate, listOf } from "./common.js";
7
- import { ActionField } from "./automationRuns.js";
7
+ import { ActionFields } from "./automationRuns.js";
8
8
  import { Country } from "./money.js";
9
9
  import { EventType } from "./platform.js";
10
10
  import { PluginFields } from "./pluginFields.js";
11
11
  import { PluginJobs } from "./pluginJobs.js";
12
12
  import { ManifestPermissionSet } from "./roles.js";
13
+ import { PluginTimeline } from "./timelines.js";
13
14
  import { oc } from "@orpc/contract";
14
15
  import { z } from "zod";
15
16
  import { createSelectSchema } from "drizzle-zod";
@@ -79,21 +80,19 @@ const PluginManifest = z.object({
79
80
  * Actions automations can run (`hr.leave.create`): core POSTs
80
81
  * `{ input, context }` to `<api.url>/automations/actions/<type>` with a
81
82
  * core token and an `Idempotency-Key`; the JSON answer is the step's output.
83
+ * A `plugin_record` field's choices come from
84
+ * `GET <api.url>/automations/records/<recordType>?parent=<its dependsOn value>`,
85
+ * called with the member's session token, answering `[{ value, label }]`.
82
86
  */
83
87
  actions: z.array(z.object({
84
88
  type: EventType,
85
89
  label: z.string().trim().min(1).max(100),
86
90
  description: z.string().trim().max(300).optional(),
87
91
  subject: z.enum(AUTOMATION_SUBJECTS).optional(),
88
- fields: z.array(ActionField).max(50).default([])
92
+ fields: ActionFields.default([])
89
93
  })).max(200).optional(),
90
94
  /** Its own record types that get a timeline in erxes (notes, mentions, entries), and who may see it. */
91
- timelines: z.array(z.object({
92
- type: z.string().regex(/^[a-z][a-z0-9_]*\.[a-z][a-z0-9_]*$/),
93
- label: z.string().trim().min(1).max(100),
94
- /** A permission action of the plugin (`hr.employee.view`); none: every member. */
95
- permission: z.string().optional()
96
- })).max(50).optional(),
95
+ timelines: z.array(PluginTimeline).max(50).optional(),
97
96
  /**
98
97
  * How its timeline entries look: a label, a colour and an icon per type —
99
98
  * one of IconBeach, IconBriefcase, IconCalendarEvent, IconCash,
@@ -0,0 +1,36 @@
1
+ import { z } from "zod";
2
+ export declare const ActivityTarget: z.ZodEnum<{
3
+ company: "company";
4
+ customer: "customer";
5
+ }>;
6
+ export type ActivityTarget = z.infer<typeof ActivityTarget>;
7
+ /**
8
+ * What a timeline is about: a customer or company, or a plugin's own record
9
+ * type declared in its manifest (`hr.employee`, `ecom.order`).
10
+ */
11
+ export declare const TimelineTarget: z.ZodUnion<readonly [z.ZodEnum<{
12
+ company: "company";
13
+ customer: "customer";
14
+ }>, z.ZodString]>;
15
+ export type TimelineTarget = z.infer<typeof TimelineTarget>;
16
+ /** One of a manifest's `timelines`: a record type of the plugin's, and who may see its timeline. */
17
+ export declare const PluginTimeline: z.ZodObject<{
18
+ type: z.ZodString;
19
+ label: z.ZodString;
20
+ permission: z.ZodOptional<z.ZodString>;
21
+ recordAccess: z.ZodOptional<z.ZodBoolean>;
22
+ }, z.core.$strip>;
23
+ /**
24
+ * What core POSTs to `<api.url>/timelines/access` for a timeline with `recordAccess`: may this
25
+ * member read this record? The plugin answers `RecordAccessAnswer`.
26
+ */
27
+ export declare const RecordAccessCheck: z.ZodObject<{
28
+ orgId: z.ZodString;
29
+ userId: z.ZodString;
30
+ type: z.ZodString;
31
+ id: z.ZodString;
32
+ }, z.core.$strip>;
33
+ export type RecordAccessCheck = z.infer<typeof RecordAccessCheck>;
34
+ export declare const RecordAccessAnswer: z.ZodObject<{
35
+ allowed: z.ZodBoolean;
36
+ }, z.core.$strip>;
@@ -0,0 +1,38 @@
1
+ import { ACTIVITY_TARGETS } from "./db/src/enums.js";
2
+ import { z } from "zod";
3
+ // src/timelines.ts
4
+ const ActivityTarget = z.enum(ACTIVITY_TARGETS);
5
+ /** A plugin's own record type with a timeline: `<plugin>.<type>`. */
6
+ const PLUGIN_TIMELINE_TYPE = /^[a-z][a-z0-9_]*\.[a-z][a-z0-9_]*$/;
7
+ /**
8
+ * What a timeline is about: a customer or company, or a plugin's own record
9
+ * type declared in its manifest (`hr.employee`, `ecom.order`).
10
+ */
11
+ const TimelineTarget = z.union([ActivityTarget, z.string().regex(PLUGIN_TIMELINE_TYPE, "customer, company or <plugin>.<type>")]);
12
+ /** One of a manifest's `timelines`: a record type of the plugin's, and who may see its timeline. */
13
+ const PluginTimeline = z.object({
14
+ type: z.string().regex(PLUGIN_TIMELINE_TYPE),
15
+ label: z.string().trim().min(1).max(100),
16
+ /** A permission action of the plugin (`hr.employee.view`); none: every member. */
17
+ permission: z.string().optional(),
18
+ /**
19
+ * Some members may not read some records (a ticket only its channel's members read):
20
+ * before a member reads or notes on one's timeline, core POSTs a `RecordAccessCheck` to
21
+ * `<api.url>/timelines/access` and refuses unless the plugin answers `{ "allowed": true }`
22
+ * within 5 seconds.
23
+ */
24
+ recordAccess: z.boolean().optional()
25
+ });
26
+ /**
27
+ * What core POSTs to `<api.url>/timelines/access` for a timeline with `recordAccess`: may this
28
+ * member read this record? The plugin answers `RecordAccessAnswer`.
29
+ */
30
+ const RecordAccessCheck = z.object({
31
+ orgId: z.string(),
32
+ userId: z.string(),
33
+ /** The timeline type, `frontline.ticket`. */
34
+ type: z.string(),
35
+ id: z.string()
36
+ });
37
+ const RecordAccessAnswer = z.object({ allowed: z.boolean() });
38
+ export { ActivityTarget, PluginTimeline, RecordAccessAnswer, RecordAccessCheck, TimelineTarget };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erxes/core-contract",
3
- "version": "0.1.0-v2.8",
3
+ "version": "0.1.0-v2.9",
4
4
  "private": false,
5
5
  "description": "erxes core API contract (/core/v1) and event schemas, shared by core and plugins",
6
6
  "license": "AGPL-3.0-only",
@@ -45,6 +45,7 @@
45
45
  "./routes": "./dist/routes.js",
46
46
  "./saas": "./dist/saas.js",
47
47
  "./tags": "./dist/tags.js",
48
+ "./timelines": "./dist/timelines.js",
48
49
  "./transfer": "./dist/transfer.js",
49
50
  "./trash": "./dist/trash.js",
50
51
  "./users": "./dist/users.js",