@rytass/bpm-core-client 0.3.0 → 0.5.0

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 (64) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/eslint.config.mjs +19 -0
  3. package/jest.config.cts +10 -0
  4. package/package.json +3 -4
  5. package/project.json +66 -0
  6. package/src/lib/api-auth-client.ts +182 -0
  7. package/src/lib/client-config.ts +99 -0
  8. package/src/lib/form/form-api.spec.ts +81 -0
  9. package/src/lib/form/form-api.ts +402 -0
  10. package/src/lib/form/form-rendering.ts +580 -0
  11. package/src/lib/graphql-client.spec.ts +65 -0
  12. package/src/lib/graphql-client.ts +128 -0
  13. package/src/lib/member-api.ts +129 -0
  14. package/src/lib/organization/organization-api.spec.ts +90 -0
  15. package/src/lib/organization/organization-api.ts +711 -0
  16. package/src/lib/template/template-api.spec.ts +88 -0
  17. package/src/lib/template/template-api.ts +894 -0
  18. package/src/lib/workflow/workflow-api.spec.ts +132 -0
  19. package/src/lib/workflow/workflow-api.ts +2124 -0
  20. package/tsconfig.json +27 -0
  21. package/tsconfig.lib.json +16 -0
  22. package/tsconfig.spec.json +16 -0
  23. package/src/index.js +0 -8
  24. package/src/index.js.map +0 -1
  25. package/src/lib/api-auth-client.d.ts +0 -73
  26. package/src/lib/api-auth-client.js +0 -129
  27. package/src/lib/api-auth-client.js.map +0 -1
  28. package/src/lib/client-config.d.ts +0 -81
  29. package/src/lib/client-config.js +0 -63
  30. package/src/lib/client-config.js.map +0 -1
  31. package/src/lib/form/form-api.d.ts +0 -54
  32. package/src/lib/form/form-api.js +0 -240
  33. package/src/lib/form/form-api.js.map +0 -1
  34. package/src/lib/form/form-rendering.d.ts +0 -52
  35. package/src/lib/form/form-rendering.js +0 -341
  36. package/src/lib/form/form-rendering.js.map +0 -1
  37. package/src/lib/form/index.js +0 -6
  38. package/src/lib/form/index.js.map +0 -1
  39. package/src/lib/graphql-client.d.ts +0 -45
  40. package/src/lib/graphql-client.js +0 -101
  41. package/src/lib/graphql-client.js.map +0 -1
  42. package/src/lib/member-api.d.ts +0 -49
  43. package/src/lib/member-api.js +0 -72
  44. package/src/lib/member-api.js.map +0 -1
  45. package/src/lib/organization/index.js +0 -5
  46. package/src/lib/organization/index.js.map +0 -1
  47. package/src/lib/organization/organization-api.d.ts +0 -173
  48. package/src/lib/organization/organization-api.js +0 -394
  49. package/src/lib/organization/organization-api.js.map +0 -1
  50. package/src/lib/template/index.js +0 -5
  51. package/src/lib/template/index.js.map +0 -1
  52. package/src/lib/template/template-api.d.ts +0 -174
  53. package/src/lib/template/template-api.js +0 -469
  54. package/src/lib/template/template-api.js.map +0 -1
  55. package/src/lib/workflow/index.js +0 -5
  56. package/src/lib/workflow/index.js.map +0 -1
  57. package/src/lib/workflow/workflow-api.d.ts +0 -517
  58. package/src/lib/workflow/workflow-api.js +0 -1068
  59. package/src/lib/workflow/workflow-api.js.map +0 -1
  60. /package/src/{index.d.ts → index.ts} +0 -0
  61. /package/src/lib/form/{index.d.ts → index.ts} +0 -0
  62. /package/src/lib/organization/{index.d.ts → index.ts} +0 -0
  63. /package/src/lib/template/{index.d.ts → index.ts} +0 -0
  64. /package/src/lib/workflow/{index.d.ts → index.ts} +0 -0
@@ -0,0 +1,88 @@
1
+ import {
2
+ createApprovalTemplate,
3
+ listApprovalTemplates,
4
+ } from './template-api';
5
+
6
+ interface CapturedRequest {
7
+ readonly query: string;
8
+ readonly variables?: Readonly<Record<string, unknown>>;
9
+ }
10
+
11
+ function installFetchMock<TData>(payload: TData): {
12
+ readonly capture: () => CapturedRequest;
13
+ readonly restore: () => void;
14
+ } {
15
+ const originalFetch = global.fetch;
16
+ const fetchMock = jest.fn<
17
+ Promise<Response>,
18
+ [RequestInfo | URL, RequestInit?]
19
+ >();
20
+ fetchMock.mockImplementation(
21
+ async () =>
22
+ new Response(JSON.stringify({ data: payload }), {
23
+ headers: { 'Content-Type': 'application/json' },
24
+ status: 200,
25
+ }),
26
+ );
27
+ (global as { fetch: typeof fetch }).fetch =
28
+ fetchMock as unknown as typeof fetch;
29
+
30
+ return {
31
+ capture: (): CapturedRequest => {
32
+ expect(fetchMock).toHaveBeenCalledTimes(1);
33
+ const init = fetchMock.mock.calls[0]?.[1];
34
+ return JSON.parse(String(init?.body ?? '{}')) as CapturedRequest;
35
+ },
36
+ restore: (): void => {
37
+ (global as { fetch: typeof fetch }).fetch = originalFetch;
38
+ },
39
+ };
40
+ }
41
+
42
+ describe('@rytass/bpm-core-client/template', () => {
43
+ describe('listApprovalTemplates', () => {
44
+ it('issues the ApprovalTemplates query and returns the records', async (): Promise<void> => {
45
+ const harness = installFetchMock({ approvalTemplates: [] });
46
+ try {
47
+ const records = await listApprovalTemplates();
48
+ const request = harness.capture();
49
+
50
+ expect(request.query).toContain('query ApprovalTemplates');
51
+ expect(request.variables).toBeUndefined();
52
+ expect(records).toEqual([]);
53
+ } finally {
54
+ harness.restore();
55
+ }
56
+ });
57
+ });
58
+
59
+ describe('createApprovalTemplate', () => {
60
+ it('wraps the name and category into CreateApprovalTemplateInput', async (): Promise<void> => {
61
+ const harness = installFetchMock({
62
+ createApprovalTemplate: { id: 'template-1' },
63
+ });
64
+ try {
65
+ const id = await createApprovalTemplate({
66
+ categoryId: 'cat-1',
67
+ name: 'Expense reimbursement',
68
+ });
69
+ const request = harness.capture();
70
+
71
+ expect(request.query).toContain('mutation CreateApprovalTemplate');
72
+ expect(request.variables).toEqual({
73
+ input: {
74
+ category: null,
75
+ categoryId: 'cat-1',
76
+ createdByMemberId: null,
77
+ description: null,
78
+ formDefinitionVersionId: null,
79
+ name: 'Expense reimbursement',
80
+ },
81
+ });
82
+ expect(id).toBe('template-1');
83
+ } finally {
84
+ harness.restore();
85
+ }
86
+ });
87
+ });
88
+ });