@coast/core-types 0.0.58 → 0.0.60

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.
Files changed (30) hide show
  1. package/dist/automations/TCreateAutomation.d.ts +17 -0
  2. package/dist/automations/TCreateAutomation.js +3 -0
  3. package/dist/automations/TCreateAutomation.js.map +1 -0
  4. package/dist/automations/TUpdateAutomation.d.ts +18 -0
  5. package/dist/automations/TUpdateAutomation.js +3 -0
  6. package/dist/automations/TUpdateAutomation.js.map +1 -0
  7. package/dist/automations/ValidatableAutomation.d.ts +4 -0
  8. package/dist/automations/ValidatableAutomation.js +3 -0
  9. package/dist/automations/ValidatableAutomation.js.map +1 -0
  10. package/dist/automations/action/TCreateAnyAutomationAction.d.ts +3 -0
  11. package/dist/automations/action/TCreateAnyAutomationAction.js +3 -0
  12. package/dist/automations/action/TCreateAnyAutomationAction.js.map +1 -0
  13. package/dist/automations/action/TSaveAnyAutomationAction.d.ts +3 -0
  14. package/dist/automations/action/TSaveAnyAutomationAction.js +3 -0
  15. package/dist/automations/action/TSaveAnyAutomationAction.js.map +1 -0
  16. package/dist/automations/error/AutomationErrorCode.d.ts +1 -0
  17. package/dist/automations/error/AutomationErrorCode.js +1 -0
  18. package/dist/automations/error/AutomationErrorCode.js.map +1 -1
  19. package/dist/utils/DistributiveOmit.d.ts +1 -0
  20. package/dist/utils/DistributiveOmit.js +3 -0
  21. package/dist/utils/DistributiveOmit.js.map +1 -0
  22. package/package.json +1 -1
  23. package/src/automations/TCreateAutomation.ts +19 -0
  24. package/src/automations/TUpdateAutomation.ts +19 -0
  25. package/src/automations/ValidatableAutomation.ts +5 -0
  26. package/src/automations/action/TCreateAnyAutomationAction.ts +9 -0
  27. package/src/automations/action/TSaveAnyAutomationAction.ts +4 -0
  28. package/src/automations/error/AutomationErrorCode.ts +1 -0
  29. package/src/utils/DistributiveOmit.ts +9 -0
  30. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,17 @@
1
+ import { BusinessId } from '../business/BusinessId';
2
+ import { WorkflowTemplateId } from '../workflow-template/WorkflowTemplateId';
3
+ import { TSaveAnyAutomationAction } from './action/TSaveAnyAutomationAction';
4
+ import { AutomationId } from './AutomationId';
5
+ import { AutomationTriggerType } from './AutomationTriggerType';
6
+ import { TCondition } from './condition/TCondition';
7
+ export interface TCreateAutomation {
8
+ workflowTemplateId: WorkflowTemplateId;
9
+ businessId: BusinessId;
10
+ name: string;
11
+ enabled: boolean;
12
+ suppressAutomationChain: boolean;
13
+ trigger: AutomationTriggerType;
14
+ actions: TSaveAnyAutomationAction[];
15
+ conditions?: TCondition[];
16
+ parentId?: AutomationId;
17
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=TCreateAutomation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TCreateAutomation.js","sourceRoot":"","sources":["../../src/automations/TCreateAutomation.ts"],"names":[],"mappings":""}
@@ -0,0 +1,18 @@
1
+ import { BusinessId } from '../business/BusinessId';
2
+ import { WorkflowTemplateId } from '../workflow-template/WorkflowTemplateId';
3
+ import { TSaveAnyAutomationAction } from './action/TSaveAnyAutomationAction';
4
+ import { AutomationId } from './AutomationId';
5
+ import { AutomationTriggerType } from './AutomationTriggerType';
6
+ import { TCondition } from './condition/TCondition';
7
+ export interface TUpdateAutomation {
8
+ id: AutomationId;
9
+ businessId: BusinessId;
10
+ workflowTemplateId: WorkflowTemplateId;
11
+ name: string;
12
+ enabled: boolean;
13
+ suppressAutomationChain: boolean;
14
+ trigger: AutomationTriggerType;
15
+ actions: TSaveAnyAutomationAction[];
16
+ conditions?: TCondition[];
17
+ parentId?: AutomationId;
18
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=TUpdateAutomation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TUpdateAutomation.js","sourceRoot":"","sources":["../../src/automations/TUpdateAutomation.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import { TAutomation } from './TAutomation';
2
+ import { TCreateAutomation } from './TCreateAutomation';
3
+ import { TUpdateAutomation } from './TUpdateAutomation';
4
+ export type ValidatableAutomation = TAutomation | TCreateAutomation | TUpdateAutomation;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ValidatableAutomation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ValidatableAutomation.js","sourceRoot":"","sources":["../../src/automations/ValidatableAutomation.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import { DistributiveOmit } from '../../utils/DistributiveOmit';
2
+ import { TAnyAutomationAction } from './TAnyAutomationAction';
3
+ export type TCreateAnyAutomationAction = DistributiveOmit<TAnyAutomationAction, 'id'>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=TCreateAnyAutomationAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TCreateAnyAutomationAction.js","sourceRoot":"","sources":["../../../src/automations/action/TCreateAnyAutomationAction.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import { TAnyAutomationAction } from './TAnyAutomationAction';
2
+ import { TCreateAnyAutomationAction } from './TCreateAnyAutomationAction';
3
+ export type TSaveAnyAutomationAction = TAnyAutomationAction | TCreateAnyAutomationAction;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=TSaveAnyAutomationAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TSaveAnyAutomationAction.js","sourceRoot":"","sources":["../../../src/automations/action/TSaveAnyAutomationAction.ts"],"names":[],"mappings":""}
@@ -4,6 +4,7 @@ export declare enum AutomationErrorCode {
4
4
  AUTOMATION_ACTION_NULL_WORKFLOW_TEMPLATE_REFERENCE = "AUTOMATION_ACTION_NULL_WORKFLOW_TEMPLATE_REFERENCE",
5
5
  AUTOMATION_ACTIONS_TO_TRIGGER_AUTOMATIONS_NOT_SUPPORTED = "AUTOMATION_ACTIONS_TO_TRIGGER_AUTOMATIONS_NOT_SUPPORTED",
6
6
  AUTOMATION_CLEAR_VALUE_NOT_SUPPORTED_IN_CREATE_ACTION = "AUTOMATION_CLEAR_VALUE_NOT_SUPPORTED_IN_CREATE_ACTION",
7
+ AUTOMATION_COMPONENT_OPERAND_UNSUPPORTED_SCALAR_KEY = "AUTOMATION_COMPONENT_OPERAND_UNSUPPORTED_SCALAR_KEY",
7
8
  AUTOMATION_COMPONENT_TYPE_MISMATCH = "AUTOMATION_COMPONENT_TYPE_MISMATCH",
8
9
  AUTOMATION_COMPONENT_TYPE_NOT_REPLICABLE = "AUTOMATION_COMPONENT_TYPE_NOT_REPLICABLE",
9
10
  AUTOMATION_CONDITION_NULL_WORKFLOW_TEMPLATE_REFERENCE = "AUTOMATION_CONDITION_NULL_WORKFLOW_TEMPLATE_REFERENCE",
@@ -8,6 +8,7 @@ var AutomationErrorCode;
8
8
  AutomationErrorCode["AUTOMATION_ACTION_NULL_WORKFLOW_TEMPLATE_REFERENCE"] = "AUTOMATION_ACTION_NULL_WORKFLOW_TEMPLATE_REFERENCE";
9
9
  AutomationErrorCode["AUTOMATION_ACTIONS_TO_TRIGGER_AUTOMATIONS_NOT_SUPPORTED"] = "AUTOMATION_ACTIONS_TO_TRIGGER_AUTOMATIONS_NOT_SUPPORTED";
10
10
  AutomationErrorCode["AUTOMATION_CLEAR_VALUE_NOT_SUPPORTED_IN_CREATE_ACTION"] = "AUTOMATION_CLEAR_VALUE_NOT_SUPPORTED_IN_CREATE_ACTION";
11
+ AutomationErrorCode["AUTOMATION_COMPONENT_OPERAND_UNSUPPORTED_SCALAR_KEY"] = "AUTOMATION_COMPONENT_OPERAND_UNSUPPORTED_SCALAR_KEY";
11
12
  AutomationErrorCode["AUTOMATION_COMPONENT_TYPE_MISMATCH"] = "AUTOMATION_COMPONENT_TYPE_MISMATCH";
12
13
  AutomationErrorCode["AUTOMATION_COMPONENT_TYPE_NOT_REPLICABLE"] = "AUTOMATION_COMPONENT_TYPE_NOT_REPLICABLE";
13
14
  AutomationErrorCode["AUTOMATION_CONDITION_NULL_WORKFLOW_TEMPLATE_REFERENCE"] = "AUTOMATION_CONDITION_NULL_WORKFLOW_TEMPLATE_REFERENCE";
@@ -1 +1 @@
1
- {"version":3,"file":"AutomationErrorCode.js","sourceRoot":"","sources":["../../../src/automations/error/AutomationErrorCode.ts"],"names":[],"mappings":";;;AAAA,IAAY,mBAcX;AAdD,WAAY,mBAAmB;IAC3B,kHAA2F,CAAA;IAC3F,gHAAyF,CAAA;IACzF,gIAAyG,CAAA;IACzG,0IAAmH,CAAA;IACnH,sIAA+G,CAAA;IAC/G,gGAAyE,CAAA;IACzE,4GAAqF,CAAA;IACrF,sIAA+G,CAAA;IAC/G,8IAAuH,CAAA;IACvH,oJAA6H,CAAA;IAC7H,0IAAmH,CAAA;IACnH,oJAA6H,CAAA;IAC7H,4IAAqH,CAAA;AACzH,CAAC,EAdW,mBAAmB,aAAnB,mBAAmB,GAAnB,mBAAmB,QAc9B"}
1
+ {"version":3,"file":"AutomationErrorCode.js","sourceRoot":"","sources":["../../../src/automations/error/AutomationErrorCode.ts"],"names":[],"mappings":";;;AAAA,IAAY,mBAeX;AAfD,WAAY,mBAAmB;IAC3B,kHAA2F,CAAA;IAC3F,gHAAyF,CAAA;IACzF,gIAAyG,CAAA;IACzG,0IAAmH,CAAA;IACnH,sIAA+G,CAAA;IAC/G,kIAA2G,CAAA;IAC3G,gGAAyE,CAAA;IACzE,4GAAqF,CAAA;IACrF,sIAA+G,CAAA;IAC/G,8IAAuH,CAAA;IACvH,oJAA6H,CAAA;IAC7H,0IAAmH,CAAA;IACnH,oJAA6H,CAAA;IAC7H,4IAAqH,CAAA;AACzH,CAAC,EAfW,mBAAmB,aAAnB,mBAAmB,GAAnB,mBAAmB,QAe9B"}
@@ -0,0 +1 @@
1
+ export type DistributiveOmit<T, K extends keyof never> = T extends unknown ? Omit<T, K> : never;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=DistributiveOmit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DistributiveOmit.js","sourceRoot":"","sources":["../../src/utils/DistributiveOmit.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coast/core-types",
3
- "version": "0.0.58",
3
+ "version": "0.0.60",
4
4
  "author": "Coast Engineering",
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -0,0 +1,19 @@
1
+ import { BusinessId } from '../business/BusinessId';
2
+ import { WorkflowTemplateId } from '../workflow-template/WorkflowTemplateId';
3
+ import { TSaveAnyAutomationAction } from './action/TSaveAnyAutomationAction';
4
+ import { AutomationId } from './AutomationId';
5
+ import { AutomationTriggerType } from './AutomationTriggerType';
6
+ import { TCondition } from './condition/TCondition';
7
+
8
+ export interface TCreateAutomation {
9
+ workflowTemplateId: WorkflowTemplateId;
10
+ businessId: BusinessId;
11
+ name: string;
12
+ enabled: boolean;
13
+ suppressAutomationChain: boolean;
14
+ trigger: AutomationTriggerType;
15
+ // Support actions with pre-generated ids so that clients can create Automations with references between actions
16
+ actions: TSaveAnyAutomationAction[];
17
+ conditions?: TCondition[];
18
+ parentId?: AutomationId;
19
+ }
@@ -0,0 +1,19 @@
1
+ import { BusinessId } from '../business/BusinessId';
2
+ import { WorkflowTemplateId } from '../workflow-template/WorkflowTemplateId';
3
+ import { TSaveAnyAutomationAction } from './action/TSaveAnyAutomationAction';
4
+ import { AutomationId } from './AutomationId';
5
+ import { AutomationTriggerType } from './AutomationTriggerType';
6
+ import { TCondition } from './condition/TCondition';
7
+
8
+ export interface TUpdateAutomation {
9
+ id: AutomationId;
10
+ businessId: BusinessId;
11
+ workflowTemplateId: WorkflowTemplateId;
12
+ name: string;
13
+ enabled: boolean;
14
+ suppressAutomationChain: boolean;
15
+ trigger: AutomationTriggerType;
16
+ actions: TSaveAnyAutomationAction[];
17
+ conditions?: TCondition[];
18
+ parentId?: AutomationId;
19
+ }
@@ -0,0 +1,5 @@
1
+ import { TAutomation } from './TAutomation';
2
+ import { TCreateAutomation } from './TCreateAutomation';
3
+ import { TUpdateAutomation } from './TUpdateAutomation';
4
+
5
+ export type ValidatableAutomation = TAutomation | TCreateAutomation | TUpdateAutomation;
@@ -0,0 +1,9 @@
1
+ import { DistributiveOmit } from '../../utils/DistributiveOmit';
2
+ import { TAnyAutomationAction } from './TAnyAutomationAction';
3
+
4
+ /**
5
+ * An action as submitted on *create*: identical to a read action, but with no `id` yet
6
+ * (action ids are DB-generated). `DistributiveOmit` (not `Omit`) keeps this a discriminated
7
+ * union so `switch (action.type)` still narrows.
8
+ */
9
+ export type TCreateAnyAutomationAction = DistributiveOmit<TAnyAutomationAction, 'id'>;
@@ -0,0 +1,4 @@
1
+ import { TAnyAutomationAction } from './TAnyAutomationAction';
2
+ import { TCreateAnyAutomationAction } from './TCreateAnyAutomationAction';
3
+
4
+ export type TSaveAnyAutomationAction = TAnyAutomationAction | TCreateAnyAutomationAction;
@@ -4,6 +4,7 @@ export enum AutomationErrorCode {
4
4
  AUTOMATION_ACTION_NULL_WORKFLOW_TEMPLATE_REFERENCE = 'AUTOMATION_ACTION_NULL_WORKFLOW_TEMPLATE_REFERENCE',
5
5
  AUTOMATION_ACTIONS_TO_TRIGGER_AUTOMATIONS_NOT_SUPPORTED = 'AUTOMATION_ACTIONS_TO_TRIGGER_AUTOMATIONS_NOT_SUPPORTED',
6
6
  AUTOMATION_CLEAR_VALUE_NOT_SUPPORTED_IN_CREATE_ACTION = 'AUTOMATION_CLEAR_VALUE_NOT_SUPPORTED_IN_CREATE_ACTION',
7
+ AUTOMATION_COMPONENT_OPERAND_UNSUPPORTED_SCALAR_KEY = 'AUTOMATION_COMPONENT_OPERAND_UNSUPPORTED_SCALAR_KEY',
7
8
  AUTOMATION_COMPONENT_TYPE_MISMATCH = 'AUTOMATION_COMPONENT_TYPE_MISMATCH',
8
9
  AUTOMATION_COMPONENT_TYPE_NOT_REPLICABLE = 'AUTOMATION_COMPONENT_TYPE_NOT_REPLICABLE',
9
10
  AUTOMATION_CONDITION_NULL_WORKFLOW_TEMPLATE_REFERENCE = 'AUTOMATION_CONDITION_NULL_WORKFLOW_TEMPLATE_REFERENCE',
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Like the built-in `Omit`, but distributes over the members of a union.
3
+ *
4
+ * `Omit<A | B, K>` collapses the union into a *single* merged object (losing the discriminant),
5
+ * which breaks `switch (x.type)` narrowing. `DistributiveOmit` applies `Omit` to each member
6
+ * individually, so `DistributiveOmit<A | B, K>` is `Omit<A, K> | Omit<B, K>` and the union
7
+ * (and its discriminant) survives.
8
+ */
9
+ export type DistributiveOmit<T, K extends keyof never> = T extends unknown ? Omit<T, K> : never;