@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
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook configuration helpers.
|
|
3
|
+
*
|
|
4
|
+
* These helpers provide type-safe configuration for creating and managing
|
|
5
|
+
* hooks using types generated from the platform's GraphQL schema.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { defineHook } from '@eide/foir-cli/hooks';
|
|
10
|
+
*
|
|
11
|
+
* export default defineHook({
|
|
12
|
+
* key: 'notify-on-publish',
|
|
13
|
+
* name: 'Notify on Publish',
|
|
14
|
+
* event: 'RECORD_PUBLISHED',
|
|
15
|
+
* targetType: 'operation',
|
|
16
|
+
* operationKey: 'send-notification',
|
|
17
|
+
* filter: {
|
|
18
|
+
* modelKey: 'blog_post',
|
|
19
|
+
* condition: {
|
|
20
|
+
* type: 'condition',
|
|
21
|
+
* left: { type: 'context', path: 'customer.profile.plan' },
|
|
22
|
+
* operator: 'in',
|
|
23
|
+
* right: { type: 'literal', value: ['pro', 'enterprise'] },
|
|
24
|
+
* },
|
|
25
|
+
* },
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
import type { CreateHookInput, HookFilterInput } from '../graphql/generated.js';
|
|
30
|
+
/**
|
|
31
|
+
* Define a hook with full type safety.
|
|
32
|
+
*
|
|
33
|
+
* Provides IntelliSense for all hook fields including:
|
|
34
|
+
* - `key`, `name`, `event` (required)
|
|
35
|
+
* - `targetType`: 'operation' (default) or 'notification'
|
|
36
|
+
* - `operationKey`: key of the operation to execute (when targetType='operation')
|
|
37
|
+
* - `notificationConfig`: notification settings (when targetType='notification')
|
|
38
|
+
* - `filter.modelKey`: only fire for records of this model
|
|
39
|
+
* - `filter.customerSegmentKey`: only fire for customers in this segment
|
|
40
|
+
* - `filter.condition`: rule expression (JSON) for conditional execution
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* // Operation hook
|
|
45
|
+
* const hook = defineHook({
|
|
46
|
+
* key: 'sync-on-create',
|
|
47
|
+
* name: 'Sync on Create',
|
|
48
|
+
* event: 'RECORD_CREATED',
|
|
49
|
+
* operationKey: 'sync-to-external',
|
|
50
|
+
* filter: { modelKey: 'product' },
|
|
51
|
+
* });
|
|
52
|
+
*
|
|
53
|
+
* // Notification hook with condition
|
|
54
|
+
* const notifyHook = defineHook({
|
|
55
|
+
* key: 'alert-vip-update',
|
|
56
|
+
* name: 'Alert on VIP Update',
|
|
57
|
+
* event: 'RECORD_UPDATED',
|
|
58
|
+
* targetType: 'notification',
|
|
59
|
+
* notificationConfig: {
|
|
60
|
+
* title: 'VIP record updated',
|
|
61
|
+
* audience: { type: 'segment', segmentId: 'vip-customers' },
|
|
62
|
+
* },
|
|
63
|
+
* filter: {
|
|
64
|
+
* condition: {
|
|
65
|
+
* type: 'condition',
|
|
66
|
+
* left: { type: 'context', path: 'customer.profile.tier' },
|
|
67
|
+
* operator: 'equals',
|
|
68
|
+
* right: { type: 'literal', value: 'vip', valueType: 'string' },
|
|
69
|
+
* },
|
|
70
|
+
* },
|
|
71
|
+
* });
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare function defineHook(hook: CreateHookInput): CreateHookInput;
|
|
75
|
+
/**
|
|
76
|
+
* Define multiple hooks with type safety.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* export const hooks = defineHooks([
|
|
81
|
+
* { key: 'on-create', name: 'On Create', event: 'RECORD_CREATED', operationKey: 'sync' },
|
|
82
|
+
* { key: 'on-delete', name: 'On Delete', event: 'RECORD_DELETED', operationKey: 'cleanup' },
|
|
83
|
+
* ]);
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare function defineHooks(hooks: CreateHookInput[]): CreateHookInput[];
|
|
87
|
+
/**
|
|
88
|
+
* Define a hook filter with type safety.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* const filter = defineHookFilter({
|
|
93
|
+
* modelKey: 'blog_post',
|
|
94
|
+
* condition: {
|
|
95
|
+
* type: 'condition',
|
|
96
|
+
* left: { type: 'field', path: 'status' },
|
|
97
|
+
* operator: 'equals',
|
|
98
|
+
* right: { type: 'literal', value: 'published', valueType: 'string' },
|
|
99
|
+
* },
|
|
100
|
+
* });
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare function defineHookFilter(filter: HookFilterInput): HookFilterInput;
|
|
104
|
+
export type { CreateHookInput, UpdateHookInput, HookFilterInput, HookEvent, } from '../graphql/generated.js';
|
|
105
|
+
//# sourceMappingURL=hook-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook-helpers.d.ts","sourceRoot":"","sources":["../../src/lib/hook-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,eAAe,GAAG,eAAe,CAEjE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,eAAe,EAAE,CAEvE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,CAEzE;AAGD,YAAY,EACV,eAAe,EACf,eAAe,EACf,eAAe,EACf,SAAS,GACV,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook configuration helpers.
|
|
3
|
+
*
|
|
4
|
+
* These helpers provide type-safe configuration for creating and managing
|
|
5
|
+
* hooks using types generated from the platform's GraphQL schema.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { defineHook } from '@eide/foir-cli/hooks';
|
|
10
|
+
*
|
|
11
|
+
* export default defineHook({
|
|
12
|
+
* key: 'notify-on-publish',
|
|
13
|
+
* name: 'Notify on Publish',
|
|
14
|
+
* event: 'RECORD_PUBLISHED',
|
|
15
|
+
* targetType: 'operation',
|
|
16
|
+
* operationKey: 'send-notification',
|
|
17
|
+
* filter: {
|
|
18
|
+
* modelKey: 'blog_post',
|
|
19
|
+
* condition: {
|
|
20
|
+
* type: 'condition',
|
|
21
|
+
* left: { type: 'context', path: 'customer.profile.plan' },
|
|
22
|
+
* operator: 'in',
|
|
23
|
+
* right: { type: 'literal', value: ['pro', 'enterprise'] },
|
|
24
|
+
* },
|
|
25
|
+
* },
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Define a hook with full type safety.
|
|
31
|
+
*
|
|
32
|
+
* Provides IntelliSense for all hook fields including:
|
|
33
|
+
* - `key`, `name`, `event` (required)
|
|
34
|
+
* - `targetType`: 'operation' (default) or 'notification'
|
|
35
|
+
* - `operationKey`: key of the operation to execute (when targetType='operation')
|
|
36
|
+
* - `notificationConfig`: notification settings (when targetType='notification')
|
|
37
|
+
* - `filter.modelKey`: only fire for records of this model
|
|
38
|
+
* - `filter.customerSegmentKey`: only fire for customers in this segment
|
|
39
|
+
* - `filter.condition`: rule expression (JSON) for conditional execution
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* // Operation hook
|
|
44
|
+
* const hook = defineHook({
|
|
45
|
+
* key: 'sync-on-create',
|
|
46
|
+
* name: 'Sync on Create',
|
|
47
|
+
* event: 'RECORD_CREATED',
|
|
48
|
+
* operationKey: 'sync-to-external',
|
|
49
|
+
* filter: { modelKey: 'product' },
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* // Notification hook with condition
|
|
53
|
+
* const notifyHook = defineHook({
|
|
54
|
+
* key: 'alert-vip-update',
|
|
55
|
+
* name: 'Alert on VIP Update',
|
|
56
|
+
* event: 'RECORD_UPDATED',
|
|
57
|
+
* targetType: 'notification',
|
|
58
|
+
* notificationConfig: {
|
|
59
|
+
* title: 'VIP record updated',
|
|
60
|
+
* audience: { type: 'segment', segmentId: 'vip-customers' },
|
|
61
|
+
* },
|
|
62
|
+
* filter: {
|
|
63
|
+
* condition: {
|
|
64
|
+
* type: 'condition',
|
|
65
|
+
* left: { type: 'context', path: 'customer.profile.tier' },
|
|
66
|
+
* operator: 'equals',
|
|
67
|
+
* right: { type: 'literal', value: 'vip', valueType: 'string' },
|
|
68
|
+
* },
|
|
69
|
+
* },
|
|
70
|
+
* });
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export function defineHook(hook) {
|
|
74
|
+
return hook;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Define multiple hooks with type safety.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* export const hooks = defineHooks([
|
|
82
|
+
* { key: 'on-create', name: 'On Create', event: 'RECORD_CREATED', operationKey: 'sync' },
|
|
83
|
+
* { key: 'on-delete', name: 'On Delete', event: 'RECORD_DELETED', operationKey: 'cleanup' },
|
|
84
|
+
* ]);
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export function defineHooks(hooks) {
|
|
88
|
+
return hooks;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Define a hook filter with type safety.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* const filter = defineHookFilter({
|
|
96
|
+
* modelKey: 'blog_post',
|
|
97
|
+
* condition: {
|
|
98
|
+
* type: 'condition',
|
|
99
|
+
* left: { type: 'field', path: 'status' },
|
|
100
|
+
* operator: 'equals',
|
|
101
|
+
* right: { type: 'literal', value: 'published', valueType: 'string' },
|
|
102
|
+
* },
|
|
103
|
+
* });
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export function defineHookFilter(filter) {
|
|
107
|
+
return filter;
|
|
108
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eide/foir-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.32",
|
|
4
4
|
"description": "Universal platform CLI for EIDE — scriptable, composable resource management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
"types": "./dist/lib/extension-helpers.js",
|
|
23
23
|
"import": "./dist/lib/extension-helpers.js"
|
|
24
24
|
},
|
|
25
|
+
"./hooks": {
|
|
26
|
+
"types": "./dist/lib/hook-helpers.js",
|
|
27
|
+
"import": "./dist/lib/hook-helpers.js"
|
|
28
|
+
},
|
|
25
29
|
"./seed": {
|
|
26
30
|
"types": "./dist/lib/seed-helpers.js",
|
|
27
31
|
"import": "./dist/lib/seed-helpers.js"
|
|
@@ -31,6 +35,21 @@
|
|
|
31
35
|
"dist",
|
|
32
36
|
"README.md"
|
|
33
37
|
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsc -p tsconfig.build.json",
|
|
40
|
+
"dev:cli": "tsx src/cli.ts",
|
|
41
|
+
"check-types": "tsc --noEmit",
|
|
42
|
+
"lint": "eslint src/",
|
|
43
|
+
"lint:fix": "eslint src/ --fix",
|
|
44
|
+
"test": "vitest run",
|
|
45
|
+
"test:watch": "vitest watch",
|
|
46
|
+
"codegen": "graphql-codegen --config codegen.ts",
|
|
47
|
+
"codegen:watch": "graphql-codegen --config codegen.ts --watch",
|
|
48
|
+
"prepublishOnly": "pnpm run build",
|
|
49
|
+
"release:patch": "pnpm version patch",
|
|
50
|
+
"release:minor": "pnpm version minor",
|
|
51
|
+
"release:major": "pnpm version major"
|
|
52
|
+
},
|
|
34
53
|
"keywords": [
|
|
35
54
|
"foir",
|
|
36
55
|
"eide",
|
|
@@ -54,6 +73,7 @@
|
|
|
54
73
|
"prettier": "^3.4.2"
|
|
55
74
|
},
|
|
56
75
|
"devDependencies": {
|
|
76
|
+
"@foir/platform": "workspace:*",
|
|
57
77
|
"@graphql-codegen/cli": "^5.0.3",
|
|
58
78
|
"@graphql-codegen/typed-document-node": "^5.0.12",
|
|
59
79
|
"@graphql-codegen/typescript": "^4.1.2",
|
|
@@ -63,8 +83,7 @@
|
|
|
63
83
|
"@types/node": "^22.5.0",
|
|
64
84
|
"tsx": "^4.20.0",
|
|
65
85
|
"typescript": "5.9.2",
|
|
66
|
-
"vitest": "^3.2.4"
|
|
67
|
-
"@foir/platform": "1.0.0"
|
|
86
|
+
"vitest": "^3.2.4"
|
|
68
87
|
},
|
|
69
88
|
"engines": {
|
|
70
89
|
"node": ">=18.0.0"
|
|
@@ -73,19 +92,5 @@
|
|
|
73
92
|
"type": "git",
|
|
74
93
|
"url": "https://github.com/eidebuild/eide.git",
|
|
75
94
|
"directory": "packages/cli"
|
|
76
|
-
},
|
|
77
|
-
"scripts": {
|
|
78
|
-
"build": "tsc -p tsconfig.build.json",
|
|
79
|
-
"dev:cli": "tsx src/cli.ts",
|
|
80
|
-
"check-types": "tsc --noEmit",
|
|
81
|
-
"lint": "eslint src/",
|
|
82
|
-
"lint:fix": "eslint src/ --fix",
|
|
83
|
-
"test": "vitest run",
|
|
84
|
-
"test:watch": "vitest watch",
|
|
85
|
-
"codegen": "graphql-codegen --config codegen.ts",
|
|
86
|
-
"codegen:watch": "graphql-codegen --config codegen.ts --watch",
|
|
87
|
-
"release:patch": "pnpm version patch",
|
|
88
|
-
"release:minor": "pnpm version minor",
|
|
89
|
-
"release:major": "pnpm version major"
|
|
90
95
|
}
|
|
91
|
-
}
|
|
96
|
+
}
|