@eide/foir-cli 0.1.31 → 0.1.32
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/cli.js +0 -0
- package/dist/commands/hooks.d.ts.map +1 -1
- package/dist/commands/hooks.js +41 -3
- package/dist/graphql/generated.d.ts +29 -8
- package/dist/graphql/generated.d.ts.map +1 -1
- package/dist/graphql/generated.js +10167 -135
- package/dist/lib/hook-helpers.d.ts +105 -0
- package/dist/lib/hook-helpers.d.ts.map +1 -0
- package/dist/lib/hook-helpers.js +108 -0
- package/package.json +23 -18
package/dist/cli.js
CHANGED
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/commands/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAgBtD,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,aAAa,GAC9B,IAAI,
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/commands/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAgBtD,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,aAAa,GAC9B,IAAI,CAoRN"}
|
package/dist/commands/hooks.js
CHANGED
|
@@ -4,7 +4,9 @@ import { formatOutput, formatList, timeAgo, success } from '../lib/output.js';
|
|
|
4
4
|
import { parseInputData, confirmAction } from '../lib/input.js';
|
|
5
5
|
import { ListHooksDocument, GetHookByKeyDocument, CreateHookDocument, UpdateHookDocument, DeleteHookDocument, HookDeliveriesDocument, RetryHookDeliveryDocument, TestHookDocument, } from '../graphql/generated.js';
|
|
6
6
|
export function registerHooksCommands(program, globalOpts) {
|
|
7
|
-
const hooks = program
|
|
7
|
+
const hooks = program
|
|
8
|
+
.command('hooks')
|
|
9
|
+
.description('Manage event hooks — triggers that run operations or send notifications when platform events occur');
|
|
8
10
|
// list
|
|
9
11
|
hooks
|
|
10
12
|
.command('list')
|
|
@@ -25,6 +27,12 @@ export function registerHooksCommands(program, globalOpts) {
|
|
|
25
27
|
{ key: 'key', header: 'Key', width: 24 },
|
|
26
28
|
{ key: 'name', header: 'Name', width: 20 },
|
|
27
29
|
{ key: 'event', header: 'Event', width: 24 },
|
|
30
|
+
{
|
|
31
|
+
key: 'targetType',
|
|
32
|
+
header: 'Target',
|
|
33
|
+
width: 14,
|
|
34
|
+
format: (v) => v === 'notification' ? 'notification' : 'operation',
|
|
35
|
+
},
|
|
28
36
|
{ key: 'operationKey', header: 'Operation', width: 20 },
|
|
29
37
|
{
|
|
30
38
|
key: 'isActive',
|
|
@@ -57,7 +65,34 @@ export function registerHooksCommands(program, globalOpts) {
|
|
|
57
65
|
// create
|
|
58
66
|
hooks
|
|
59
67
|
.command('create')
|
|
60
|
-
.description(
|
|
68
|
+
.description(`Create a hook
|
|
69
|
+
|
|
70
|
+
Required fields: key, name, event
|
|
71
|
+
Optional fields: targetType (operation|notification), operationKey, notificationConfig,
|
|
72
|
+
filter { modelKey, customerSegmentKey, condition }, isActive
|
|
73
|
+
|
|
74
|
+
Events: RECORD_CREATED, RECORD_UPDATED, RECORD_DELETED, RECORD_PUBLISHED,
|
|
75
|
+
RECORD_UNPUBLISHED, CUSTOMER_REGISTERED, CUSTOMER_DELETED,
|
|
76
|
+
CUSTOMER_PROFILE_UPDATED, EXTENSION_INITIALIZED, and more.
|
|
77
|
+
|
|
78
|
+
Conditions use rule expressions (JSON) to filter when the hook fires.
|
|
79
|
+
Example with condition:
|
|
80
|
+
foir hooks create -d '{
|
|
81
|
+
"key": "notify-pro-publish",
|
|
82
|
+
"name": "Notify on Pro Publish",
|
|
83
|
+
"event": "RECORD_PUBLISHED",
|
|
84
|
+
"targetType": "operation",
|
|
85
|
+
"operationKey": "my-webhook",
|
|
86
|
+
"filter": {
|
|
87
|
+
"modelKey": "blog_post",
|
|
88
|
+
"condition": {
|
|
89
|
+
"type": "condition",
|
|
90
|
+
"left": { "type": "context", "path": "customer.profile.plan" },
|
|
91
|
+
"operator": "in",
|
|
92
|
+
"right": { "type": "literal", "value": ["pro", "enterprise"] }
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}'`)
|
|
61
96
|
.option('-d, --data <json>', 'Hook data as JSON')
|
|
62
97
|
.option('-f, --file <path>', 'Read input from file')
|
|
63
98
|
.action(withErrorHandler(globalOpts, async (cmdOpts) => {
|
|
@@ -73,7 +108,10 @@ export function registerHooksCommands(program, globalOpts) {
|
|
|
73
108
|
// update
|
|
74
109
|
hooks
|
|
75
110
|
.command('update <id>')
|
|
76
|
-
.description(
|
|
111
|
+
.description(`Update a hook
|
|
112
|
+
|
|
113
|
+
All fields are optional. Supports: name, event, targetType, operationKey,
|
|
114
|
+
notificationConfig, filter (with condition), isActive.`)
|
|
77
115
|
.option('-d, --data <json>', 'Update data as JSON')
|
|
78
116
|
.option('-f, --file <path>', 'Read input from file')
|
|
79
117
|
.action(withErrorHandler(globalOpts, async (id, cmdOpts) => {
|
|
@@ -692,7 +692,9 @@ export type CreateHookInput = {
|
|
|
692
692
|
isActive?: InputMaybe<Scalars['Boolean']['input']>;
|
|
693
693
|
key: Scalars['String']['input'];
|
|
694
694
|
name: Scalars['String']['input'];
|
|
695
|
-
|
|
695
|
+
notificationConfig?: InputMaybe<Scalars['JSON']['input']>;
|
|
696
|
+
operationKey?: InputMaybe<Scalars['String']['input']>;
|
|
697
|
+
targetType?: InputMaybe<Scalars['String']['input']>;
|
|
696
698
|
};
|
|
697
699
|
/** Input for creating an invitation */
|
|
698
700
|
export type CreateInvitationInput = {
|
|
@@ -1772,17 +1774,20 @@ export type GrantAccessInput = {
|
|
|
1772
1774
|
role: AdminAccessRole;
|
|
1773
1775
|
tenantId: Scalars['ID']['input'];
|
|
1774
1776
|
};
|
|
1775
|
-
/** Event-driven hook that triggers an operation */
|
|
1777
|
+
/** Event-driven hook that triggers an operation or notification */
|
|
1776
1778
|
export type Hook = {
|
|
1777
1779
|
createdAt: Scalars['DateTime']['output'];
|
|
1778
1780
|
description?: Maybe<Scalars['String']['output']>;
|
|
1779
1781
|
event: HookEvent;
|
|
1782
|
+
extensionId?: Maybe<Scalars['ID']['output']>;
|
|
1780
1783
|
filter?: Maybe<HookFilter>;
|
|
1781
1784
|
id: Scalars['ID']['output'];
|
|
1782
1785
|
isActive: Scalars['Boolean']['output'];
|
|
1783
1786
|
key: Scalars['String']['output'];
|
|
1784
1787
|
name: Scalars['String']['output'];
|
|
1785
|
-
|
|
1788
|
+
notificationConfig?: Maybe<Scalars['JSON']['output']>;
|
|
1789
|
+
operationKey?: Maybe<Scalars['String']['output']>;
|
|
1790
|
+
targetType: Scalars['String']['output'];
|
|
1786
1791
|
updatedAt: Scalars['DateTime']['output'];
|
|
1787
1792
|
};
|
|
1788
1793
|
/** Paginated list of hooks */
|
|
@@ -1812,14 +1817,16 @@ export type HookDeliveryConnection = {
|
|
|
1812
1817
|
/** Hook delivery status */
|
|
1813
1818
|
export type HookDeliveryStatus = 'FAILED' | 'RETRYING' | 'SUCCESS';
|
|
1814
1819
|
/** Platform events that can trigger hooks. */
|
|
1815
|
-
export type HookEvent = 'CUSTOMER_AUTH_PROVIDER_LINKED' | 'CUSTOMER_AUTH_PROVIDER_UNLINKED' | 'CUSTOMER_DELETED' | 'CUSTOMER_EMAIL_UPDATED' | 'CUSTOMER_EMAIL_VERIFIED' | 'CUSTOMER_PASSWORD_CHANGED' | 'CUSTOMER_PASSWORD_RESET_COMPLETED' | 'CUSTOMER_PASSWORD_RESET_REQUESTED' | 'CUSTOMER_PROFILE_UPDATED' | 'CUSTOMER_REGISTERED' | 'CUSTOMER_SESSION_CREATED' | 'CUSTOMER_SESSION_REVOKED' | 'RECORD_CREATED' | 'RECORD_DELETED' | 'RECORD_PUBLISHED' | 'RECORD_SHARED' | 'RECORD_SHARE_ACCEPTED' | 'RECORD_SHARE_REVOKED' | 'RECORD_UNPUBLISHED' | 'RECORD_UPDATED';
|
|
1820
|
+
export type HookEvent = 'CUSTOMER_AUTH_PROVIDER_LINKED' | 'CUSTOMER_AUTH_PROVIDER_UNLINKED' | 'CUSTOMER_DELETED' | 'CUSTOMER_EMAIL_UPDATED' | 'CUSTOMER_EMAIL_VERIFIED' | 'CUSTOMER_PASSWORD_CHANGED' | 'CUSTOMER_PASSWORD_RESET_COMPLETED' | 'CUSTOMER_PASSWORD_RESET_REQUESTED' | 'CUSTOMER_PROFILE_UPDATED' | 'CUSTOMER_REGISTERED' | 'CUSTOMER_SESSION_CREATED' | 'CUSTOMER_SESSION_REVOKED' | 'EXTENSION_CLEANUP_STARTED' | 'EXTENSION_INITIALIZED' | 'RECORD_CREATED' | 'RECORD_DELETED' | 'RECORD_PUBLISHED' | 'RECORD_SHARED' | 'RECORD_SHARE_ACCEPTED' | 'RECORD_SHARE_REVOKED' | 'RECORD_UNPUBLISHED' | 'RECORD_UPDATED';
|
|
1816
1821
|
/** Optional filter to narrow when a hook fires */
|
|
1817
1822
|
export type HookFilter = {
|
|
1823
|
+
condition?: Maybe<Scalars['JSON']['output']>;
|
|
1818
1824
|
customerSegmentKey?: Maybe<Scalars['String']['output']>;
|
|
1819
1825
|
metadata?: Maybe<Scalars['JSON']['output']>;
|
|
1820
1826
|
modelKey?: Maybe<Scalars['String']['output']>;
|
|
1821
1827
|
};
|
|
1822
1828
|
export type HookFilterInput = {
|
|
1829
|
+
condition?: InputMaybe<Scalars['JSON']['input']>;
|
|
1823
1830
|
customerSegmentKey?: InputMaybe<Scalars['String']['input']>;
|
|
1824
1831
|
metadata?: InputMaybe<Scalars['JSON']['input']>;
|
|
1825
1832
|
modelKey?: InputMaybe<Scalars['String']['input']>;
|
|
@@ -5648,7 +5655,9 @@ export type UpdateHookInput = {
|
|
|
5648
5655
|
filter?: InputMaybe<HookFilterInput>;
|
|
5649
5656
|
isActive?: InputMaybe<Scalars['Boolean']['input']>;
|
|
5650
5657
|
name?: InputMaybe<Scalars['String']['input']>;
|
|
5658
|
+
notificationConfig?: InputMaybe<Scalars['JSON']['input']>;
|
|
5651
5659
|
operationKey?: InputMaybe<Scalars['String']['input']>;
|
|
5660
|
+
targetType?: InputMaybe<Scalars['String']['input']>;
|
|
5652
5661
|
};
|
|
5653
5662
|
export type UpdateLocaleInput = {
|
|
5654
5663
|
displayName?: InputMaybe<Scalars['String']['input']>;
|
|
@@ -6791,12 +6800,16 @@ export type ListHooksQuery = {
|
|
|
6791
6800
|
key: string;
|
|
6792
6801
|
name: string;
|
|
6793
6802
|
event: HookEvent;
|
|
6794
|
-
|
|
6803
|
+
targetType: string;
|
|
6804
|
+
operationKey?: string | null;
|
|
6805
|
+
notificationConfig?: unknown | null;
|
|
6795
6806
|
isActive: boolean;
|
|
6807
|
+
extensionId?: string | null;
|
|
6796
6808
|
updatedAt: string;
|
|
6797
6809
|
filter?: {
|
|
6798
6810
|
modelKey?: string | null;
|
|
6799
6811
|
customerSegmentKey?: string | null;
|
|
6812
|
+
condition?: unknown | null;
|
|
6800
6813
|
} | null;
|
|
6801
6814
|
}>;
|
|
6802
6815
|
};
|
|
@@ -6811,14 +6824,18 @@ export type GetHookByKeyQuery = {
|
|
|
6811
6824
|
name: string;
|
|
6812
6825
|
description?: string | null;
|
|
6813
6826
|
event: HookEvent;
|
|
6814
|
-
|
|
6827
|
+
targetType: string;
|
|
6828
|
+
operationKey?: string | null;
|
|
6829
|
+
notificationConfig?: unknown | null;
|
|
6815
6830
|
isActive: boolean;
|
|
6831
|
+
extensionId?: string | null;
|
|
6816
6832
|
createdAt: string;
|
|
6817
6833
|
updatedAt: string;
|
|
6818
6834
|
filter?: {
|
|
6819
6835
|
modelKey?: string | null;
|
|
6820
6836
|
customerSegmentKey?: string | null;
|
|
6821
6837
|
metadata?: unknown | null;
|
|
6838
|
+
condition?: unknown | null;
|
|
6822
6839
|
} | null;
|
|
6823
6840
|
} | null;
|
|
6824
6841
|
};
|
|
@@ -6831,7 +6848,9 @@ export type CreateHookMutation = {
|
|
|
6831
6848
|
key: string;
|
|
6832
6849
|
name: string;
|
|
6833
6850
|
event: HookEvent;
|
|
6834
|
-
|
|
6851
|
+
targetType: string;
|
|
6852
|
+
operationKey?: string | null;
|
|
6853
|
+
notificationConfig?: unknown | null;
|
|
6835
6854
|
isActive: boolean;
|
|
6836
6855
|
createdAt: string;
|
|
6837
6856
|
};
|
|
@@ -6846,7 +6865,9 @@ export type UpdateHookMutation = {
|
|
|
6846
6865
|
key: string;
|
|
6847
6866
|
name: string;
|
|
6848
6867
|
event: HookEvent;
|
|
6849
|
-
|
|
6868
|
+
targetType: string;
|
|
6869
|
+
operationKey?: string | null;
|
|
6870
|
+
notificationConfig?: unknown | null;
|
|
6850
6871
|
isActive: boolean;
|
|
6851
6872
|
updatedAt: string;
|
|
6852
6873
|
};
|