@erxes/core-contract 0.1.0-v2.6 → 0.1.0-v2.7

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/client.d.ts CHANGED
@@ -21786,6 +21786,9 @@ export declare const orpc: {
21786
21786
  INVALID_CLIENT: {
21787
21787
  status: number;
21788
21788
  };
21789
+ INVALID_SCHEDULE: {
21790
+ status: number;
21791
+ };
21789
21792
  LIMIT_EXCEEDED: {
21790
21793
  status: number;
21791
21794
  };
@@ -21877,6 +21880,15 @@ export declare const orpc: {
21877
21880
  color?: string | undefined;
21878
21881
  }[] | undefined;
21879
21882
  subscriptions?: string[] | undefined;
21883
+ jobs?: {
21884
+ name: string;
21885
+ cron?: string | undefined;
21886
+ retry?: {
21887
+ attempts: number;
21888
+ delay: number;
21889
+ maxDelay: number;
21890
+ } | undefined;
21891
+ }[] | undefined;
21880
21892
  events?: {
21881
21893
  type: string;
21882
21894
  label: string;
@@ -21972,6 +21984,9 @@ export declare const orpc: {
21972
21984
  INVALID_CLIENT: {
21973
21985
  status: number;
21974
21986
  };
21987
+ INVALID_SCHEDULE: {
21988
+ status: number;
21989
+ };
21975
21990
  LIMIT_EXCEEDED: {
21976
21991
  status: number;
21977
21992
  };
@@ -22057,6 +22072,15 @@ export declare const orpc: {
22057
22072
  color?: string | undefined;
22058
22073
  }[] | undefined;
22059
22074
  subscriptions?: string[] | undefined;
22075
+ jobs?: {
22076
+ name: string;
22077
+ cron?: string | undefined;
22078
+ retry?: {
22079
+ attempts: number;
22080
+ delay: number;
22081
+ maxDelay: number;
22082
+ } | undefined;
22083
+ }[] | undefined;
22060
22084
  events?: {
22061
22085
  type: string;
22062
22086
  label: string;
@@ -22176,6 +22200,9 @@ export declare const orpc: {
22176
22200
  INVALID_CLIENT: {
22177
22201
  status: number;
22178
22202
  };
22203
+ INVALID_SCHEDULE: {
22204
+ status: number;
22205
+ };
22179
22206
  LIMIT_EXCEEDED: {
22180
22207
  status: number;
22181
22208
  };
@@ -22307,6 +22334,9 @@ export declare const orpc: {
22307
22334
  INVALID_CLIENT: {
22308
22335
  status: number;
22309
22336
  };
22337
+ INVALID_SCHEDULE: {
22338
+ status: number;
22339
+ };
22310
22340
  LIMIT_EXCEEDED: {
22311
22341
  status: number;
22312
22342
  };
@@ -22440,6 +22470,9 @@ export declare const orpc: {
22440
22470
  INVALID_CLIENT: {
22441
22471
  status: number;
22442
22472
  };
22473
+ INVALID_SCHEDULE: {
22474
+ status: number;
22475
+ };
22443
22476
  LIMIT_EXCEEDED: {
22444
22477
  status: number;
22445
22478
  };
@@ -22554,6 +22587,9 @@ export declare const orpc: {
22554
22587
  INVALID_CLIENT: {
22555
22588
  status: number;
22556
22589
  };
22590
+ INVALID_SCHEDULE: {
22591
+ status: number;
22592
+ };
22557
22593
  LIMIT_EXCEEDED: {
22558
22594
  status: number;
22559
22595
  };
@@ -22667,6 +22703,9 @@ export declare const orpc: {
22667
22703
  INVALID_CLIENT: {
22668
22704
  status: number;
22669
22705
  };
22706
+ INVALID_SCHEDULE: {
22707
+ status: number;
22708
+ };
22670
22709
  LIMIT_EXCEEDED: {
22671
22710
  status: number;
22672
22711
  };
package/dist/errors.d.ts CHANGED
@@ -378,6 +378,9 @@ export declare const ERRORS: {
378
378
  NAMESPACE_REQUIRED: {
379
379
  status: number;
380
380
  };
381
+ INVALID_SCHEDULE: {
382
+ status: number;
383
+ };
381
384
  PLUGIN_NOT_FOUND: {
382
385
  status: number;
383
386
  };
package/dist/errors.js CHANGED
@@ -168,6 +168,7 @@ const ERRORS = {
168
168
  INVALID_CLIENT: { status: 401 },
169
169
  NOT_INSTALLED: { status: 403 },
170
170
  NAMESPACE_REQUIRED: { status: 400 },
171
+ INVALID_SCHEDULE: { status: 400 },
171
172
  PLUGIN_NOT_FOUND: { status: 404 },
172
173
  INVALID_SUBDOMAIN: { status: 400 },
173
174
  UNKNOWN_PERMISSION: {
package/dist/index.d.ts CHANGED
@@ -22,6 +22,7 @@ import { CORE_NOTIFICATION_KINDS, CoreNotificationKind, Notification, Notificati
22
22
  import { ActorType, AppLink, DedupeKey, EntityType, EventType } from "./platform.js";
23
23
  import { Organization, OrganizationRegion, organizationsContract } from "./organizations.js";
24
24
  import { GatewayConfig, Invoice, InvoiceLine, InvoiceLineInput, InvoiceMetadata, PaymentGateway, PluginPaymentSettings, Refund, paymentsContract } from "./payments.js";
25
+ import { JobName, PluginJobDelivery, PluginJobs } from "./pluginJobs.js";
25
26
  import { LiveTopic, PLUGIN_SCOPES, Plugin, PluginInstallation, PluginManifest, PluginName, PluginScope, TokenResponse, pluginsContract } from "./plugins.js";
26
27
  import { Product, ProductCategory, ProductStatus, productCategoriesContract, productsContract } from "./products.js";
27
28
  import { CORE_PERMISSIONS, CorePermission, ManifestPermissionSet, OWNER_ONLY_PERMISSIONS, PermissionAction, PermissionInfo, PermissionSet, Role, rolesContract } from "./roles.js";
@@ -22399,6 +22400,9 @@ export declare const coreContract: {
22399
22400
  INVALID_CLIENT: {
22400
22401
  status: number;
22401
22402
  };
22403
+ INVALID_SCHEDULE: {
22404
+ status: number;
22405
+ };
22402
22406
  LIMIT_EXCEEDED: {
22403
22407
  status: number;
22404
22408
  };
@@ -22519,6 +22523,15 @@ export declare const coreContract: {
22519
22523
  color: import("zod").ZodOptional<import("zod").ZodString>;
22520
22524
  }, import("zod/v4/core").$strip>>>;
22521
22525
  subscriptions: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
22526
+ jobs: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
22527
+ name: import("zod").ZodString;
22528
+ cron: import("zod").ZodOptional<import("zod").ZodString>;
22529
+ retry: import("zod").ZodOptional<import("zod").ZodObject<{
22530
+ attempts: import("zod").ZodInt;
22531
+ delay: import("zod").ZodInt;
22532
+ maxDelay: import("zod").ZodInt;
22533
+ }, import("zod/v4/core").$strip>>;
22534
+ }, import("zod/v4/core").$strip>>>;
22522
22535
  events: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
22523
22536
  type: import("zod").ZodString;
22524
22537
  label: import("zod").ZodString;
@@ -22617,6 +22630,9 @@ export declare const coreContract: {
22617
22630
  INVALID_CLIENT: {
22618
22631
  status: number;
22619
22632
  };
22633
+ INVALID_SCHEDULE: {
22634
+ status: number;
22635
+ };
22620
22636
  LIMIT_EXCEEDED: {
22621
22637
  status: number;
22622
22638
  };
@@ -22757,6 +22773,9 @@ export declare const coreContract: {
22757
22773
  INVALID_CLIENT: {
22758
22774
  status: number;
22759
22775
  };
22776
+ INVALID_SCHEDULE: {
22777
+ status: number;
22778
+ };
22760
22779
  LIMIT_EXCEEDED: {
22761
22780
  status: number;
22762
22781
  };
@@ -22897,6 +22916,9 @@ export declare const coreContract: {
22897
22916
  INVALID_CLIENT: {
22898
22917
  status: number;
22899
22918
  };
22919
+ INVALID_SCHEDULE: {
22920
+ status: number;
22921
+ };
22900
22922
  LIMIT_EXCEEDED: {
22901
22923
  status: number;
22902
22924
  };
@@ -23037,6 +23059,9 @@ export declare const coreContract: {
23037
23059
  INVALID_CLIENT: {
23038
23060
  status: number;
23039
23061
  };
23062
+ INVALID_SCHEDULE: {
23063
+ status: number;
23064
+ };
23040
23065
  LIMIT_EXCEEDED: {
23041
23066
  status: number;
23042
23067
  };
@@ -23149,6 +23174,9 @@ export declare const coreContract: {
23149
23174
  INVALID_CLIENT: {
23150
23175
  status: number;
23151
23176
  };
23177
+ INVALID_SCHEDULE: {
23178
+ status: number;
23179
+ };
23152
23180
  LIMIT_EXCEEDED: {
23153
23181
  status: number;
23154
23182
  };
@@ -23260,6 +23288,9 @@ export declare const coreContract: {
23260
23288
  INVALID_CLIENT: {
23261
23289
  status: number;
23262
23290
  };
23291
+ INVALID_SCHEDULE: {
23292
+ status: number;
23293
+ };
23263
23294
  LIMIT_EXCEEDED: {
23264
23295
  status: number;
23265
23296
  };
@@ -31661,4 +31692,4 @@ export declare const coreContract: {
31661
31692
  }>, Record<never, never>>;
31662
31693
  };
31663
31694
  };
31664
- 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, 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_SCOPES, PageInfo, PaymentGateway, PaymentGatewayKind, PermissionAction, PermissionInfo, PermissionSet, PersonRef, PhoneNumber, Plugin, PluginAccess, PluginInstallation, PluginManifest, PluginName, PluginPaymentSettings, PluginPlan, PluginScope, PluginTier, 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, 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, pluginsContract, productCategoriesContract, productsContract, rolesContract, saasContract, tagsContract, transferContract, trashContract, usersContract, viewsContract, webhooksContract };
31695
+ 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_SCOPES, PageInfo, PaymentGateway, PaymentGatewayKind, PermissionAction, PermissionInfo, PermissionSet, PersonRef, PhoneNumber, Plugin, PluginAccess, PluginInstallation, PluginJobDelivery, PluginJobs, PluginManifest, PluginName, PluginPaymentSettings, PluginPlan, PluginScope, PluginTier, 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, 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, pluginsContract, productCategoriesContract, productsContract, rolesContract, saasContract, tagsContract, transferContract, trashContract, usersContract, viewsContract, webhooksContract };
package/dist/index.js CHANGED
@@ -30,6 +30,7 @@ import { ContentType, CursorQuery, CustomFields, CustomFieldsPatch, CustomValue,
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
+ import { JobName, PluginJobDelivery, PluginJobs } from "./pluginJobs.js";
33
34
  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";
34
35
  // src/index.ts
35
36
  /** The whole core API. Core implements it; plugins call it with a typed client. */
@@ -63,4 +64,4 @@ const coreContract = {
63
64
  views: viewsContract,
64
65
  webhooks: webhooksContract
65
66
  };
66
- 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, 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_SCOPES, PageInfo, PaymentGateway, PaymentGatewayKind, PermissionAction, PermissionInfo, PermissionSet, PersonRef, PhoneNumber, Plugin, PluginAccess, PluginInstallation, PluginManifest, PluginName, PluginPaymentSettings, PluginPlan, PluginScope, PluginTier, 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, 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, pluginsContract, productCategoriesContract, productsContract, rolesContract, saasContract, tagsContract, transferContract, trashContract, usersContract, viewsContract, webhooksContract };
67
+ 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_SCOPES, PageInfo, PaymentGateway, PaymentGatewayKind, PermissionAction, PermissionInfo, PermissionSet, PersonRef, PhoneNumber, Plugin, PluginAccess, PluginInstallation, PluginJobDelivery, PluginJobs, PluginManifest, PluginName, PluginPaymentSettings, PluginPlan, PluginScope, PluginTier, 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, 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, pluginsContract, productCategoriesContract, productsContract, rolesContract, saasContract, tagsContract, transferContract, trashContract, usersContract, viewsContract, webhooksContract };
@@ -0,0 +1,28 @@
1
+ import { z } from "zod";
2
+ /** A plugin job's name, the last part of its address: `mail.sync`, `token-refresh`. */
3
+ export declare const JobName: z.ZodString;
4
+ /**
5
+ * The manifest's `jobs`: background work at the plugin's API. The plugin
6
+ * queues a job with `core_enqueue_job()` in its own transaction; core POSTs
7
+ * each attempt to `<api.url>/jobs/<name>` with a core token and
8
+ * `Idempotency-Key: <job id>`, and retries until it answers 2xx. A job with
9
+ * `cron` also runs on that schedule, once for each organisation that has the plugin.
10
+ */
11
+ export declare const PluginJobs: z.ZodArray<z.ZodObject<{
12
+ name: z.ZodString;
13
+ cron: z.ZodOptional<z.ZodString>;
14
+ retry: z.ZodOptional<z.ZodObject<{
15
+ attempts: z.ZodInt;
16
+ delay: z.ZodInt;
17
+ maxDelay: z.ZodInt;
18
+ }, z.core.$strip>>;
19
+ }, z.core.$strip>>;
20
+ /** One attempt of a plugin job, as core POSTs it to `<api.url>/jobs/<name>`. */
21
+ export declare const PluginJobDelivery: z.ZodObject<{
22
+ jobId: z.ZodString;
23
+ orgId: z.ZodString;
24
+ name: z.ZodString;
25
+ attempt: z.ZodInt;
26
+ payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
27
+ }, z.core.$strip>;
28
+ export type PluginJobDelivery = z.infer<typeof PluginJobDelivery>;
@@ -0,0 +1,36 @@
1
+ import { z } from "zod";
2
+ // src/pluginJobs.ts
3
+ /** A plugin job's name, the last part of its address: `mail.sync`, `token-refresh`. */
4
+ const JobName = z.string().trim().regex(/^[a-z][a-z0-9_.-]{0,59}$/, "lower case letters, digits and . _ - (starting with a letter)");
5
+ const PluginJob = z.object({
6
+ name: JobName,
7
+ /** A cron schedule in UTC (`0 3 * * *`): one job per organisation each time it comes due. */
8
+ cron: z.string().trim().min(1).max(100).optional(),
9
+ /**
10
+ * Attempts in all; the first retry waits `delay` seconds, each next one
11
+ * about twice as long, up to `maxDelay`. Default: 8 attempts, 30 s, 6 hours.
12
+ */
13
+ retry: z.object({
14
+ attempts: z.int().min(1).max(25),
15
+ delay: z.int().min(1).max(86400),
16
+ maxDelay: z.int().min(1).max(604800)
17
+ }).refine((retry) => retry.maxDelay >= retry.delay, "maxDelay is at least delay").optional()
18
+ });
19
+ /**
20
+ * The manifest's `jobs`: background work at the plugin's API. The plugin
21
+ * queues a job with `core_enqueue_job()` in its own transaction; core POSTs
22
+ * each attempt to `<api.url>/jobs/<name>` with a core token and
23
+ * `Idempotency-Key: <job id>`, and retries until it answers 2xx. A job with
24
+ * `cron` also runs on that schedule, once for each organisation that has the plugin.
25
+ */
26
+ const PluginJobs = z.array(PluginJob).max(50).refine((jobs) => new Set(jobs.map((job) => job.name)).size === jobs.length, "each job name once");
27
+ /** One attempt of a plugin job, as core POSTs it to `<api.url>/jobs/<name>`. */
28
+ const PluginJobDelivery = z.object({
29
+ jobId: z.string(),
30
+ orgId: z.string(),
31
+ name: JobName,
32
+ /** 1 on the first try. */
33
+ attempt: z.int().min(1),
34
+ payload: z.record(z.string(), z.unknown())
35
+ });
36
+ export { JobName, PluginJobDelivery, PluginJobs };
package/dist/plugins.d.ts CHANGED
@@ -128,6 +128,15 @@ export declare const PluginManifest: z.ZodObject<{
128
128
  color: z.ZodOptional<z.ZodString>;
129
129
  }, z.core.$strip>>>;
130
130
  subscriptions: z.ZodOptional<z.ZodArray<z.ZodString>>;
131
+ jobs: z.ZodOptional<z.ZodArray<z.ZodObject<{
132
+ name: z.ZodString;
133
+ cron: z.ZodOptional<z.ZodString>;
134
+ retry: z.ZodOptional<z.ZodObject<{
135
+ attempts: z.ZodInt;
136
+ delay: z.ZodInt;
137
+ maxDelay: z.ZodInt;
138
+ }, z.core.$strip>>;
139
+ }, z.core.$strip>>>;
131
140
  events: z.ZodOptional<z.ZodArray<z.ZodObject<{
132
141
  type: z.ZodString;
133
142
  label: z.ZodString;
@@ -290,6 +299,9 @@ export declare const pluginsContract: {
290
299
  INVALID_CLIENT: {
291
300
  status: number;
292
301
  };
302
+ INVALID_SCHEDULE: {
303
+ status: number;
304
+ };
293
305
  LIMIT_EXCEEDED: {
294
306
  status: number;
295
307
  };
@@ -410,6 +422,15 @@ export declare const pluginsContract: {
410
422
  color: z.ZodOptional<z.ZodString>;
411
423
  }, z.core.$strip>>>;
412
424
  subscriptions: z.ZodOptional<z.ZodArray<z.ZodString>>;
425
+ jobs: z.ZodOptional<z.ZodArray<z.ZodObject<{
426
+ name: z.ZodString;
427
+ cron: z.ZodOptional<z.ZodString>;
428
+ retry: z.ZodOptional<z.ZodObject<{
429
+ attempts: z.ZodInt;
430
+ delay: z.ZodInt;
431
+ maxDelay: z.ZodInt;
432
+ }, z.core.$strip>>;
433
+ }, z.core.$strip>>>;
413
434
  events: z.ZodOptional<z.ZodArray<z.ZodObject<{
414
435
  type: z.ZodString;
415
436
  label: z.ZodString;
@@ -508,6 +529,9 @@ export declare const pluginsContract: {
508
529
  INVALID_CLIENT: {
509
530
  status: number;
510
531
  };
532
+ INVALID_SCHEDULE: {
533
+ status: number;
534
+ };
511
535
  LIMIT_EXCEEDED: {
512
536
  status: number;
513
537
  };
@@ -648,6 +672,9 @@ export declare const pluginsContract: {
648
672
  INVALID_CLIENT: {
649
673
  status: number;
650
674
  };
675
+ INVALID_SCHEDULE: {
676
+ status: number;
677
+ };
651
678
  LIMIT_EXCEEDED: {
652
679
  status: number;
653
680
  };
@@ -788,6 +815,9 @@ export declare const pluginsContract: {
788
815
  INVALID_CLIENT: {
789
816
  status: number;
790
817
  };
818
+ INVALID_SCHEDULE: {
819
+ status: number;
820
+ };
791
821
  LIMIT_EXCEEDED: {
792
822
  status: number;
793
823
  };
@@ -928,6 +958,9 @@ export declare const pluginsContract: {
928
958
  INVALID_CLIENT: {
929
959
  status: number;
930
960
  };
961
+ INVALID_SCHEDULE: {
962
+ status: number;
963
+ };
931
964
  LIMIT_EXCEEDED: {
932
965
  status: number;
933
966
  };
@@ -1040,6 +1073,9 @@ export declare const pluginsContract: {
1040
1073
  INVALID_CLIENT: {
1041
1074
  status: number;
1042
1075
  };
1076
+ INVALID_SCHEDULE: {
1077
+ status: number;
1078
+ };
1043
1079
  LIMIT_EXCEEDED: {
1044
1080
  status: number;
1045
1081
  };
@@ -1151,6 +1187,9 @@ export declare const pluginsContract: {
1151
1187
  INVALID_CLIENT: {
1152
1188
  status: number;
1153
1189
  };
1190
+ INVALID_SCHEDULE: {
1191
+ status: number;
1192
+ };
1154
1193
  LIMIT_EXCEEDED: {
1155
1194
  status: number;
1156
1195
  };
package/dist/plugins.js CHANGED
@@ -7,6 +7,7 @@ import { Id, isoDate, listOf } from "./common.js";
7
7
  import { ActionField } from "./automationRuns.js";
8
8
  import { Country } from "./money.js";
9
9
  import { EventType } from "./platform.js";
10
+ import { PluginJobs } from "./pluginJobs.js";
10
11
  import { ManifestPermissionSet } from "./roles.js";
11
12
  import { oc } from "@orpc/contract";
12
13
  import { z } from "zod";
@@ -135,6 +136,8 @@ const PluginManifest = z.object({
135
136
  * other plugins' events need `events:read`. Its own events are not sent back.
136
137
  */
137
138
  subscriptions: z.array(EventPattern).max(100).optional(),
139
+ /** Background work at its API (`PluginJobs`): core POSTs each job to `<api.url>/jobs/<name>`. */
140
+ jobs: PluginJobs.optional(),
138
141
  /**
139
142
  * Events it publishes: triggers for automations. `subject`: what its events
140
143
  * are about (published with `subject`), so automations started by it can
@@ -187,13 +190,14 @@ const TokenResponse = z.object({
187
190
  * plugin UIs (a member's short-lived session for one plugin's API), and live
188
191
  * signals to plugin UIs.
189
192
  */
190
- const { CROSS_SITE, DUPLICATE_PERMISSION_SET, INVALID_CLIENT, LIMIT_EXCEEDED, NAMESPACE_REQUIRED, NOT_INSTALLED, PLUGIN_NOT_FOUND, UNKNOWN_PERMISSION } = ERRORS;
193
+ const { CROSS_SITE, DUPLICATE_PERMISSION_SET, INVALID_CLIENT, INVALID_SCHEDULE, LIMIT_EXCEEDED, NAMESPACE_REQUIRED, NOT_INSTALLED, PLUGIN_NOT_FOUND, UNKNOWN_PERMISSION } = ERRORS;
191
194
  /** What these procedures answer with besides the common errors. */
192
195
  const base = oc.errors({
193
196
  ...COMMON_ERRORS,
194
197
  CROSS_SITE,
195
198
  DUPLICATE_PERMISSION_SET,
196
199
  INVALID_CLIENT,
200
+ INVALID_SCHEDULE,
197
201
  LIMIT_EXCEEDED,
198
202
  NAMESPACE_REQUIRED,
199
203
  NOT_INSTALLED,
@@ -214,7 +218,7 @@ const pluginsContract = {
214
218
  registerManifest: base.route({
215
219
  method: "PUT",
216
220
  path: "/plugins/manifest",
217
- summary: "The calling plugin declares its UI, API, scopes, permissions and events"
221
+ summary: "The calling plugin declares its UI, API, scopes, permissions, events and jobs. 400 INVALID_SCHEDULE when a job's cron doesn't parse"
218
222
  }).input(PluginManifest).output(z.object({ ok: z.literal(true) })),
219
223
  list: base.route({
220
224
  method: "GET",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erxes/core-contract",
3
- "version": "0.1.0-v2.6",
3
+ "version": "0.1.0-v2.7",
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",
@@ -37,6 +37,7 @@
37
37
  "./organizations": "./dist/organizations.js",
38
38
  "./payments": "./dist/payments.js",
39
39
  "./platform": "./dist/platform.js",
40
+ "./pluginJobs": "./dist/pluginJobs.js",
40
41
  "./plugins": "./dist/plugins.js",
41
42
  "./products": "./dist/products.js",
42
43
  "./roles": "./dist/roles.js",