@eide/foir-cli 0.1.35 → 0.1.36

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 (227) hide show
  1. package/dist/cli.js +7467 -42
  2. package/dist/config/types.d.ts +7 -6
  3. package/dist/config/types.js +6 -14
  4. package/dist/generated-CPsQ9jfu.d.ts +195 -0
  5. package/dist/lib/extension-helpers.d.ts +10 -7
  6. package/dist/lib/extension-helpers.js +15 -85
  7. package/dist/lib/hook-helpers.d.ts +9 -6
  8. package/dist/lib/hook-helpers.js +12 -105
  9. package/dist/lib/seed-helpers.d.ts +10 -8
  10. package/dist/lib/seed-helpers.js +18 -124
  11. package/package.json +9 -8
  12. package/dist/auth/credentials.d.ts +0 -31
  13. package/dist/auth/credentials.d.ts.map +0 -1
  14. package/dist/auth/credentials.js +0 -139
  15. package/dist/cli.d.ts +0 -3
  16. package/dist/cli.d.ts.map +0 -1
  17. package/dist/codegen/fetch-customer-profile-schema.d.ts +0 -12
  18. package/dist/codegen/fetch-customer-profile-schema.d.ts.map +0 -1
  19. package/dist/codegen/fetch-customer-profile-schema.js +0 -21
  20. package/dist/codegen/fetch-models.d.ts +0 -58
  21. package/dist/codegen/fetch-models.d.ts.map +0 -1
  22. package/dist/codegen/fetch-models.js +0 -96
  23. package/dist/codegen/field-mapping.d.ts +0 -34
  24. package/dist/codegen/field-mapping.d.ts.map +0 -1
  25. package/dist/codegen/field-mapping.js +0 -250
  26. package/dist/codegen/generators/config.d.ts +0 -5
  27. package/dist/codegen/generators/config.d.ts.map +0 -1
  28. package/dist/codegen/generators/config.js +0 -82
  29. package/dist/codegen/generators/customer-profile-documents.d.ts +0 -5
  30. package/dist/codegen/generators/customer-profile-documents.d.ts.map +0 -1
  31. package/dist/codegen/generators/customer-profile-documents.js +0 -42
  32. package/dist/codegen/generators/customer-profile-hooks.d.ts +0 -5
  33. package/dist/codegen/generators/customer-profile-hooks.d.ts.map +0 -1
  34. package/dist/codegen/generators/customer-profile-hooks.js +0 -78
  35. package/dist/codegen/generators/customer-profile-loaders.d.ts +0 -5
  36. package/dist/codegen/generators/customer-profile-loaders.d.ts.map +0 -1
  37. package/dist/codegen/generators/customer-profile-loaders.js +0 -67
  38. package/dist/codegen/generators/customer-profile-operations.d.ts +0 -5
  39. package/dist/codegen/generators/customer-profile-operations.d.ts.map +0 -1
  40. package/dist/codegen/generators/customer-profile-operations.js +0 -126
  41. package/dist/codegen/generators/customer-profile-types.d.ts +0 -6
  42. package/dist/codegen/generators/customer-profile-types.d.ts.map +0 -1
  43. package/dist/codegen/generators/customer-profile-types.js +0 -45
  44. package/dist/codegen/generators/documents.d.ts +0 -12
  45. package/dist/codegen/generators/documents.d.ts.map +0 -1
  46. package/dist/codegen/generators/documents.js +0 -178
  47. package/dist/codegen/generators/field-types.d.ts +0 -5
  48. package/dist/codegen/generators/field-types.d.ts.map +0 -1
  49. package/dist/codegen/generators/field-types.js +0 -346
  50. package/dist/codegen/generators/model-index.d.ts +0 -6
  51. package/dist/codegen/generators/model-index.d.ts.map +0 -1
  52. package/dist/codegen/generators/model-index.js +0 -26
  53. package/dist/codegen/generators/model-types.d.ts +0 -12
  54. package/dist/codegen/generators/model-types.d.ts.map +0 -1
  55. package/dist/codegen/generators/model-types.js +0 -177
  56. package/dist/codegen/generators/public-schema-content.d.ts +0 -14
  57. package/dist/codegen/generators/public-schema-content.d.ts.map +0 -1
  58. package/dist/codegen/generators/public-schema-content.js +0 -22
  59. package/dist/codegen/generators/react-hooks-index.d.ts +0 -6
  60. package/dist/codegen/generators/react-hooks-index.d.ts.map +0 -1
  61. package/dist/codegen/generators/react-hooks-index.js +0 -20
  62. package/dist/codegen/generators/react-hooks.d.ts +0 -7
  63. package/dist/codegen/generators/react-hooks.d.ts.map +0 -1
  64. package/dist/codegen/generators/react-hooks.js +0 -139
  65. package/dist/codegen/generators/remix-loaders-index.d.ts +0 -6
  66. package/dist/codegen/generators/remix-loaders-index.d.ts.map +0 -1
  67. package/dist/codegen/generators/remix-loaders-index.js +0 -20
  68. package/dist/codegen/generators/remix-loaders.d.ts +0 -7
  69. package/dist/codegen/generators/remix-loaders.d.ts.map +0 -1
  70. package/dist/codegen/generators/remix-loaders.js +0 -107
  71. package/dist/codegen/generators/static-documents.d.ts +0 -14
  72. package/dist/codegen/generators/static-documents.d.ts.map +0 -1
  73. package/dist/codegen/generators/static-documents.js +0 -771
  74. package/dist/codegen/generators/swift-customer-profile.d.ts +0 -9
  75. package/dist/codegen/generators/swift-customer-profile.d.ts.map +0 -1
  76. package/dist/codegen/generators/swift-customer-profile.js +0 -152
  77. package/dist/codegen/generators/swift-field-types.d.ts +0 -5
  78. package/dist/codegen/generators/swift-field-types.d.ts.map +0 -1
  79. package/dist/codegen/generators/swift-field-types.js +0 -151
  80. package/dist/codegen/generators/swift-model-keys.d.ts +0 -6
  81. package/dist/codegen/generators/swift-model-keys.d.ts.map +0 -1
  82. package/dist/codegen/generators/swift-model-keys.js +0 -25
  83. package/dist/codegen/generators/swift-types.d.ts +0 -13
  84. package/dist/codegen/generators/swift-types.d.ts.map +0 -1
  85. package/dist/codegen/generators/swift-types.js +0 -188
  86. package/dist/codegen/generators/typed-operations-common.d.ts +0 -6
  87. package/dist/codegen/generators/typed-operations-common.d.ts.map +0 -1
  88. package/dist/codegen/generators/typed-operations-common.js +0 -84
  89. package/dist/codegen/generators/typed-operations-index.d.ts +0 -6
  90. package/dist/codegen/generators/typed-operations-index.d.ts.map +0 -1
  91. package/dist/codegen/generators/typed-operations-index.js +0 -22
  92. package/dist/codegen/generators/typed-operations.d.ts +0 -11
  93. package/dist/codegen/generators/typed-operations.d.ts.map +0 -1
  94. package/dist/codegen/generators/typed-operations.js +0 -263
  95. package/dist/codegen/swift-field-mapping.d.ts +0 -30
  96. package/dist/codegen/swift-field-mapping.d.ts.map +0 -1
  97. package/dist/codegen/swift-field-mapping.js +0 -150
  98. package/dist/codegen/write-files.d.ts +0 -15
  99. package/dist/codegen/write-files.d.ts.map +0 -1
  100. package/dist/codegen/write-files.js +0 -36
  101. package/dist/commands/api-keys.d.ts +0 -4
  102. package/dist/commands/api-keys.d.ts.map +0 -1
  103. package/dist/commands/api-keys.js +0 -129
  104. package/dist/commands/auth-config.d.ts +0 -4
  105. package/dist/commands/auth-config.d.ts.map +0 -1
  106. package/dist/commands/auth-config.js +0 -38
  107. package/dist/commands/auth-providers.d.ts +0 -4
  108. package/dist/commands/auth-providers.d.ts.map +0 -1
  109. package/dist/commands/auth-providers.js +0 -207
  110. package/dist/commands/context.d.ts +0 -4
  111. package/dist/commands/context.d.ts.map +0 -1
  112. package/dist/commands/context.js +0 -91
  113. package/dist/commands/create-extension.d.ts +0 -4
  114. package/dist/commands/create-extension.d.ts.map +0 -1
  115. package/dist/commands/create-extension.js +0 -60
  116. package/dist/commands/customer-profiles.d.ts +0 -4
  117. package/dist/commands/customer-profiles.d.ts.map +0 -1
  118. package/dist/commands/customer-profiles.js +0 -99
  119. package/dist/commands/customers.d.ts +0 -4
  120. package/dist/commands/customers.d.ts.map +0 -1
  121. package/dist/commands/customers.js +0 -126
  122. package/dist/commands/embeddings.d.ts +0 -4
  123. package/dist/commands/embeddings.d.ts.map +0 -1
  124. package/dist/commands/embeddings.js +0 -145
  125. package/dist/commands/experiments.d.ts +0 -4
  126. package/dist/commands/experiments.d.ts.map +0 -1
  127. package/dist/commands/experiments.js +0 -196
  128. package/dist/commands/extensions.d.ts +0 -4
  129. package/dist/commands/extensions.d.ts.map +0 -1
  130. package/dist/commands/extensions.js +0 -210
  131. package/dist/commands/files.d.ts +0 -4
  132. package/dist/commands/files.d.ts.map +0 -1
  133. package/dist/commands/files.js +0 -143
  134. package/dist/commands/hooks.d.ts +0 -4
  135. package/dist/commands/hooks.d.ts.map +0 -1
  136. package/dist/commands/hooks.js +0 -228
  137. package/dist/commands/locales.d.ts +0 -4
  138. package/dist/commands/locales.d.ts.map +0 -1
  139. package/dist/commands/locales.js +0 -140
  140. package/dist/commands/login.d.ts +0 -4
  141. package/dist/commands/login.d.ts.map +0 -1
  142. package/dist/commands/login.js +0 -124
  143. package/dist/commands/logout.d.ts +0 -4
  144. package/dist/commands/logout.d.ts.map +0 -1
  145. package/dist/commands/logout.js +0 -16
  146. package/dist/commands/media.d.ts +0 -4
  147. package/dist/commands/media.d.ts.map +0 -1
  148. package/dist/commands/media.js +0 -44
  149. package/dist/commands/models.d.ts +0 -4
  150. package/dist/commands/models.d.ts.map +0 -1
  151. package/dist/commands/models.js +0 -153
  152. package/dist/commands/notes.d.ts +0 -4
  153. package/dist/commands/notes.d.ts.map +0 -1
  154. package/dist/commands/notes.js +0 -132
  155. package/dist/commands/notifications.d.ts +0 -4
  156. package/dist/commands/notifications.d.ts.map +0 -1
  157. package/dist/commands/notifications.js +0 -73
  158. package/dist/commands/operations.d.ts +0 -4
  159. package/dist/commands/operations.d.ts.map +0 -1
  160. package/dist/commands/operations.js +0 -341
  161. package/dist/commands/playground.d.ts +0 -4
  162. package/dist/commands/playground.d.ts.map +0 -1
  163. package/dist/commands/playground.js +0 -270
  164. package/dist/commands/pull.d.ts +0 -4
  165. package/dist/commands/pull.d.ts.map +0 -1
  166. package/dist/commands/pull.js +0 -300
  167. package/dist/commands/records.d.ts +0 -4
  168. package/dist/commands/records.d.ts.map +0 -1
  169. package/dist/commands/records.js +0 -314
  170. package/dist/commands/register-commands.d.ts +0 -7
  171. package/dist/commands/register-commands.d.ts.map +0 -1
  172. package/dist/commands/register-commands.js +0 -259
  173. package/dist/commands/schedules.d.ts +0 -4
  174. package/dist/commands/schedules.d.ts.map +0 -1
  175. package/dist/commands/schedules.js +0 -155
  176. package/dist/commands/search.d.ts +0 -4
  177. package/dist/commands/search.d.ts.map +0 -1
  178. package/dist/commands/search.js +0 -60
  179. package/dist/commands/segments.d.ts +0 -4
  180. package/dist/commands/segments.d.ts.map +0 -1
  181. package/dist/commands/segments.js +0 -155
  182. package/dist/commands/select-project.d.ts +0 -4
  183. package/dist/commands/select-project.d.ts.map +0 -1
  184. package/dist/commands/select-project.js +0 -144
  185. package/dist/commands/settings.d.ts +0 -4
  186. package/dist/commands/settings.d.ts.map +0 -1
  187. package/dist/commands/settings.js +0 -115
  188. package/dist/commands/variant-catalog.d.ts +0 -4
  189. package/dist/commands/variant-catalog.d.ts.map +0 -1
  190. package/dist/commands/variant-catalog.js +0 -118
  191. package/dist/commands/whoami.d.ts +0 -4
  192. package/dist/commands/whoami.d.ts.map +0 -1
  193. package/dist/commands/whoami.js +0 -51
  194. package/dist/config/pull-config.d.ts +0 -33
  195. package/dist/config/pull-config.d.ts.map +0 -1
  196. package/dist/config/pull-config.js +0 -119
  197. package/dist/config/types.d.ts.map +0 -1
  198. package/dist/graphql/generated.d.ts +0 -6074
  199. package/dist/graphql/generated.d.ts.map +0 -1
  200. package/dist/graphql/generated.js +0 -355
  201. package/dist/lib/client.d.ts +0 -18
  202. package/dist/lib/client.d.ts.map +0 -1
  203. package/dist/lib/client.js +0 -64
  204. package/dist/lib/config-loader.d.ts +0 -28
  205. package/dist/lib/config-loader.d.ts.map +0 -1
  206. package/dist/lib/config-loader.js +0 -49
  207. package/dist/lib/config.d.ts +0 -12
  208. package/dist/lib/config.d.ts.map +0 -1
  209. package/dist/lib/config.js +0 -8
  210. package/dist/lib/errors.d.ts +0 -6
  211. package/dist/lib/errors.d.ts.map +0 -1
  212. package/dist/lib/errors.js +0 -76
  213. package/dist/lib/extension-helpers.d.ts.map +0 -1
  214. package/dist/lib/hook-helpers.d.ts.map +0 -1
  215. package/dist/lib/input.d.ts +0 -38
  216. package/dist/lib/input.d.ts.map +0 -1
  217. package/dist/lib/input.js +0 -108
  218. package/dist/lib/output.d.ts +0 -31
  219. package/dist/lib/output.d.ts.map +0 -1
  220. package/dist/lib/output.js +0 -107
  221. package/dist/lib/seed-helpers.d.ts.map +0 -1
  222. package/dist/scaffold/package-manager.d.ts +0 -12
  223. package/dist/scaffold/package-manager.d.ts.map +0 -1
  224. package/dist/scaffold/package-manager.js +0 -51
  225. package/dist/scaffold/scaffold.d.ts +0 -4
  226. package/dist/scaffold/scaffold.d.ts.map +0 -1
  227. package/dist/scaffold/scaffold.js +0 -462
@@ -1,73 +0,0 @@
1
- import { withErrorHandler } from '../lib/errors.js';
2
- import { createClient } from '../lib/client.js';
3
- import { formatOutput, formatList, timeAgo, success } from '../lib/output.js';
4
- import { ListNotificationsDocument, MarkNotificationReadDocument, MarkAllNotificationsReadDocument, } from '../graphql/generated.js';
5
- export function registerNotificationsCommands(program, globalOpts) {
6
- const notifications = program
7
- .command('notifications')
8
- .description('Manage notifications');
9
- // list
10
- notifications
11
- .command('list')
12
- .description('List notifications')
13
- .option('--unread', 'Only unread notifications')
14
- .option('--limit <n>', 'Max results', '20')
15
- .action(withErrorHandler(globalOpts, async (cmdOpts) => {
16
- const opts = globalOpts();
17
- const client = await createClient(opts);
18
- const data = await client.request(ListNotificationsDocument, {
19
- unreadOnly: !!cmdOpts.unread,
20
- limit: parseInt(String(cmdOpts.limit ?? '20'), 10),
21
- });
22
- if (!(opts.json || opts.jsonl || opts.quiet)) {
23
- console.log(`Unread: ${data.notifications.unreadCount}\n`);
24
- }
25
- formatList(data.notifications.items, opts, {
26
- columns: [
27
- { key: 'id', header: 'ID', width: 28 },
28
- { key: 'type', header: 'Type', width: 16 },
29
- { key: 'title', header: 'Title', width: 32 },
30
- {
31
- key: 'isRead',
32
- header: 'Read',
33
- width: 6,
34
- format: (v) => (v ? 'yes' : 'no'),
35
- },
36
- {
37
- key: 'createdAt',
38
- header: 'When',
39
- width: 12,
40
- format: (v) => timeAgo(v),
41
- },
42
- ],
43
- total: data.notifications.total,
44
- });
45
- }));
46
- // read
47
- notifications
48
- .command('read <id>')
49
- .description('Mark a notification as read')
50
- .action(withErrorHandler(globalOpts, async (id) => {
51
- const opts = globalOpts();
52
- const client = await createClient(opts);
53
- const data = await client.request(MarkNotificationReadDocument, { id });
54
- formatOutput(data.markNotificationRead, opts);
55
- if (!(opts.json || opts.jsonl || opts.quiet))
56
- success('Marked as read');
57
- }));
58
- // read-all
59
- notifications
60
- .command('read-all')
61
- .description('Mark all notifications as read')
62
- .action(withErrorHandler(globalOpts, async () => {
63
- const opts = globalOpts();
64
- const client = await createClient(opts);
65
- const data = await client.request(MarkAllNotificationsReadDocument);
66
- if (opts.json || opts.jsonl) {
67
- formatOutput({ marked: data.markAllNotificationsRead }, opts);
68
- }
69
- else {
70
- success(`Marked ${data.markAllNotificationsRead} notifications as read`);
71
- }
72
- }));
73
- }
@@ -1,4 +0,0 @@
1
- import type { Command } from 'commander';
2
- import type { GlobalOptions } from '../lib/config.js';
3
- export declare function registerOperationsCommands(program: Command, globalOpts: () => GlobalOptions): void;
4
- //# sourceMappingURL=operations.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../src/commands/operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAkBtD,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,aAAa,GAC9B,IAAI,CA8ZN"}
@@ -1,341 +0,0 @@
1
- import { withErrorHandler } from '../lib/errors.js';
2
- import { createClient } from '../lib/client.js';
3
- import { formatOutput, formatList, timeAgo, success } from '../lib/output.js';
4
- import { parseInputData, confirmAction } from '../lib/input.js';
5
- import { ListOperationsDocument, GetOperationDocument, ExecuteOperationDocument, OperationExecutionStatsDocument, DeadLetterOperationsDocument, RetryDeadLetterDocument, DismissDeadLetterDocument, CreateOperationDocument, UpdateOperationDocument, DeleteOperationDocument, } from '../graphql/generated.js';
6
- export function registerOperationsCommands(program, globalOpts) {
7
- const operations = program
8
- .command('operations')
9
- .description('Manage operations');
10
- // list
11
- operations
12
- .command('list')
13
- .description('List operations')
14
- .option('--category <cat>', 'Filter by category')
15
- .option('--active', 'Only active operations')
16
- .option('--search <term>', 'Search by name')
17
- .option('--limit <n>', 'Max results', '50')
18
- .action(withErrorHandler(globalOpts, async (cmdOpts) => {
19
- const opts = globalOpts();
20
- const client = await createClient(opts);
21
- const data = await client.request(ListOperationsDocument, {
22
- category: cmdOpts.category,
23
- isActive: cmdOpts.active ? true : undefined,
24
- search: cmdOpts.search,
25
- limit: parseInt(String(cmdOpts.limit ?? '50'), 10),
26
- });
27
- formatList(data.operations.items, opts, {
28
- columns: [
29
- { key: 'key', header: 'Key', width: 24 },
30
- { key: 'name', header: 'Name', width: 24 },
31
- { key: 'category', header: 'Category', width: 14 },
32
- {
33
- key: 'isActive',
34
- header: 'Active',
35
- width: 8,
36
- format: (v) => (v ? 'yes' : 'no'),
37
- },
38
- {
39
- key: 'updatedAt',
40
- header: 'Updated',
41
- width: 12,
42
- format: (v) => timeAgo(v),
43
- },
44
- ],
45
- total: data.operations.total,
46
- });
47
- }));
48
- // get
49
- operations
50
- .command('get <key>')
51
- .description('Get an operation by key')
52
- .action(withErrorHandler(globalOpts, async (key) => {
53
- const opts = globalOpts();
54
- const client = await createClient(opts);
55
- const data = await client.request(GetOperationDocument, { key });
56
- if (!data.operation)
57
- throw new Error(`Operation "${key}" not found.`);
58
- formatOutput(data.operation, opts);
59
- }));
60
- // execute
61
- operations
62
- .command('execute <key>')
63
- .description('Execute an operation')
64
- .option('-d, --data <json>', 'Input data as JSON')
65
- .option('-f, --file <path>', 'Read input from file')
66
- .option('--async', 'Execute asynchronously (shorthand for --mode async)')
67
- .option('--mode <mode>', 'Execution mode: sync, async, or stream')
68
- .action(withErrorHandler(globalOpts, async (key, cmdOpts) => {
69
- const opts = globalOpts();
70
- const client = await createClient(opts);
71
- let inputData = {};
72
- if (cmdOpts.data || cmdOpts.file) {
73
- inputData = await parseInputData(cmdOpts);
74
- }
75
- // Resolve execution mode: --mode takes precedence, --async is shorthand
76
- let mode;
77
- if (cmdOpts.mode) {
78
- mode = cmdOpts.mode.toUpperCase();
79
- }
80
- else if (cmdOpts.async) {
81
- mode = 'ASYNC';
82
- }
83
- const data = await client.request(ExecuteOperationDocument, {
84
- input: {
85
- operationKey: key,
86
- input: inputData,
87
- ...(mode ? { mode } : {}),
88
- },
89
- });
90
- // For stream mode, connect to SSE endpoint and print events
91
- if (mode === 'STREAM' && data.executeOperation.executionId) {
92
- const executionId = data.executeOperation.executionId;
93
- if (!(opts.json || opts.jsonl || opts.quiet)) {
94
- console.log(`Streaming execution ${executionId}…`);
95
- }
96
- const baseUrl = opts.apiUrl ??
97
- process.env.FOIR_API_URL ??
98
- 'http://localhost:4000';
99
- const sseUrl = `${baseUrl}/api/operations/${executionId}/stream`;
100
- const response = await fetch(sseUrl);
101
- if (!response.ok || !response.body) {
102
- throw new Error(`Failed to connect to stream: ${response.status}`);
103
- }
104
- const reader = response.body.getReader();
105
- const decoder = new TextDecoder();
106
- let buffer = '';
107
- while (true) {
108
- const { done, value } = await reader.read();
109
- if (done)
110
- break;
111
- buffer += decoder.decode(value, { stream: true });
112
- const lines = buffer.split('\n');
113
- buffer = lines.pop() ?? '';
114
- for (const line of lines) {
115
- if (line.startsWith('data: ')) {
116
- const eventData = JSON.parse(line.slice(6));
117
- if (opts.json || opts.jsonl) {
118
- console.log(JSON.stringify(eventData));
119
- }
120
- else if (!opts.quiet) {
121
- const ev = eventData;
122
- if (ev.event === 'chunk') {
123
- process.stdout.write(String(ev.data ?? ''));
124
- }
125
- else if (ev.event === 'progress') {
126
- console.log(`[progress] ${JSON.stringify(ev.data)}`);
127
- }
128
- else if (ev.event === 'error') {
129
- console.error(`[error] ${JSON.stringify(ev.data)}`);
130
- }
131
- else if (ev.event === 'result') {
132
- console.log(JSON.stringify(ev.data, null, 2));
133
- }
134
- }
135
- if (eventData.done)
136
- break;
137
- }
138
- }
139
- }
140
- if (!(opts.json || opts.jsonl || opts.quiet)) {
141
- success('Stream completed');
142
- }
143
- return;
144
- }
145
- formatOutput(data.executeOperation, opts);
146
- if (!(opts.json || opts.jsonl || opts.quiet)) {
147
- const result = data.executeOperation;
148
- if (result.success) {
149
- success(`Operation completed in ${result.durationMs}ms`);
150
- }
151
- else {
152
- const err = result.error;
153
- console.error(`Operation failed: ${err?.message ?? 'Unknown error'}`);
154
- }
155
- }
156
- }));
157
- // quota
158
- operations
159
- .command('quota <key>')
160
- .description('Show quota usage for an operation')
161
- .option('--json', 'JSON output')
162
- .action(withErrorHandler(globalOpts, async (key) => {
163
- const opts = globalOpts();
164
- const client = await createClient(opts);
165
- // First get the operation to see its quota rules
166
- const opData = await client.request(GetOperationDocument, { key });
167
- if (!opData.operation)
168
- throw new Error(`Operation "${key}" not found.`);
169
- const quotas = opData.operation.quotas;
170
- if (!quotas || quotas.length === 0) {
171
- if (opts.json || opts.jsonl)
172
- formatOutput({
173
- operationKey: key,
174
- quotas: [],
175
- message: 'No quotas configured',
176
- }, opts);
177
- else
178
- console.log('No quotas configured for this operation.');
179
- return;
180
- }
181
- if (opts.json || opts.jsonl) {
182
- formatOutput({ operationKey: key, quotas }, opts);
183
- }
184
- else {
185
- console.log(`\nQuota rules for "${key}":\n`);
186
- const header = [
187
- 'Segment'.padEnd(20),
188
- 'Scope'.padEnd(10),
189
- 'Limit'.padEnd(8),
190
- 'Window'.padEnd(10),
191
- ].join(' | ');
192
- console.log(header);
193
- console.log('-'.repeat(header.length));
194
- for (const q of quotas) {
195
- const segment = q.segmentKey ?? '(default)';
196
- const limit = q.points === 0 ? '\u221e' : String(q.points);
197
- const window = q.duration >= 86400
198
- ? `${q.duration / 86400}d`
199
- : q.duration >= 3600
200
- ? `${q.duration / 3600}h`
201
- : `${q.duration}s`;
202
- console.log([
203
- segment.padEnd(20),
204
- q.scope.padEnd(10),
205
- limit.padEnd(8),
206
- window.padEnd(10),
207
- ].join(' | '));
208
- }
209
- console.log('');
210
- }
211
- }));
212
- // stats
213
- operations
214
- .command('stats <key>')
215
- .description('Get execution statistics for an operation')
216
- .action(withErrorHandler(globalOpts, async (key) => {
217
- const opts = globalOpts();
218
- const client = await createClient(opts);
219
- const data = await client.request(OperationExecutionStatsDocument, {
220
- operationKey: key,
221
- });
222
- formatOutput(data.operationExecutionStats, opts);
223
- }));
224
- // dead-letters
225
- operations
226
- .command('dead-letters')
227
- .description('List failed operations in the dead letter queue')
228
- .option('--operation <key>', 'Filter by operation key')
229
- .option('--status <status>', 'Filter by status (PENDING, RETRIED, DISMISSED)')
230
- .option('--limit <n>', 'Max results', '20')
231
- .action(withErrorHandler(globalOpts, async (cmdOpts) => {
232
- const opts = globalOpts();
233
- const client = await createClient(opts);
234
- const data = await client.request(DeadLetterOperationsDocument, {
235
- operationKey: cmdOpts.operation,
236
- status: cmdOpts.status,
237
- limit: parseInt(cmdOpts.limit ?? '20', 10),
238
- });
239
- formatList(data.deadLetterOperations.items, opts, {
240
- columns: [
241
- { key: 'id', header: 'ID', width: 28 },
242
- { key: 'operationKey', header: 'Operation', width: 20 },
243
- { key: 'attempts', header: 'Tries', width: 6 },
244
- { key: 'lastError', header: 'Error', width: 36 },
245
- { key: 'status', header: 'Status', width: 10 },
246
- {
247
- key: 'failedAt',
248
- header: 'Failed',
249
- width: 12,
250
- format: (v) => timeAgo(v),
251
- },
252
- ],
253
- total: data.deadLetterOperations.total,
254
- });
255
- }));
256
- // retry-dead-letter
257
- operations
258
- .command('retry-dead-letter <id>')
259
- .description('Retry a failed dead letter operation')
260
- .action(withErrorHandler(globalOpts, async (id) => {
261
- const opts = globalOpts();
262
- const client = await createClient(opts);
263
- const data = await client.request(RetryDeadLetterDocument, { id });
264
- formatOutput(data.retryDeadLetterOperation, opts);
265
- if (!(opts.json || opts.jsonl || opts.quiet)) {
266
- const r = data.retryDeadLetterOperation;
267
- if (r.success)
268
- success('Retry succeeded');
269
- else
270
- console.error('Retry failed');
271
- }
272
- }));
273
- // dismiss-dead-letter
274
- operations
275
- .command('dismiss-dead-letter <id>')
276
- .description('Dismiss a dead letter operation without retrying')
277
- .action(withErrorHandler(globalOpts, async (id) => {
278
- const opts = globalOpts();
279
- const client = await createClient(opts);
280
- const data = await client.request(DismissDeadLetterDocument, { id });
281
- formatOutput(data.dismissDeadLetterOperation, opts);
282
- if (!(opts.json || opts.jsonl || opts.quiet))
283
- success(`Dismissed dead letter ${id}`);
284
- }));
285
- // create
286
- operations
287
- .command('create')
288
- .description('Create an operation')
289
- .option('-d, --data <json>', 'Operation data as JSON')
290
- .option('-f, --file <path>', 'Read input from file')
291
- .action(withErrorHandler(globalOpts, async (cmdOpts) => {
292
- const opts = globalOpts();
293
- const client = await createClient(opts);
294
- const input = await parseInputData(cmdOpts);
295
- const data = await client.request(CreateOperationDocument, {
296
- input,
297
- });
298
- formatOutput(data.createOperation, opts);
299
- if (!(opts.json || opts.jsonl || opts.quiet))
300
- success(`Created operation "${data.createOperation.key}"`);
301
- }));
302
- // update
303
- operations
304
- .command('update <key>')
305
- .description('Update an operation')
306
- .option('-d, --data <json>', 'Update data as JSON')
307
- .option('-f, --file <path>', 'Read input from file')
308
- .action(withErrorHandler(globalOpts, async (key, cmdOpts) => {
309
- const opts = globalOpts();
310
- const client = await createClient(opts);
311
- const input = await parseInputData(cmdOpts);
312
- const data = await client.request(UpdateOperationDocument, {
313
- key,
314
- input,
315
- });
316
- formatOutput(data.updateOperation, opts);
317
- if (!(opts.json || opts.jsonl || opts.quiet))
318
- success(`Updated operation "${key}"`);
319
- }));
320
- // delete
321
- operations
322
- .command('delete <key>')
323
- .description('Delete an operation')
324
- .option('--confirm', 'Skip confirmation prompt')
325
- .action(withErrorHandler(globalOpts, async (key, cmdOpts) => {
326
- const opts = globalOpts();
327
- const confirmed = await confirmAction(`Delete operation "${key}"?`, {
328
- confirm: !!cmdOpts.confirm,
329
- });
330
- if (!confirmed) {
331
- console.log('Aborted.');
332
- return;
333
- }
334
- const client = await createClient(opts);
335
- await client.request(DeleteOperationDocument, { key });
336
- if (opts.json || opts.jsonl)
337
- formatOutput({ deleted: true, key }, opts);
338
- else
339
- success(`Deleted operation "${key}"`);
340
- }));
341
- }
@@ -1,4 +0,0 @@
1
- import { type Command } from 'commander';
2
- import type { GlobalOptions } from '../lib/config.js';
3
- export declare function registerPlaygroundCommand(program: Command, getGlobalOpts: () => GlobalOptions): void;
4
- //# sourceMappingURL=playground.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../../src/commands/playground.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAgCtD,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,MAAM,aAAa,QA8QnC"}