@rytass/bpm-core-client 0.4.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 +9 -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
package/tsconfig.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "module": "commonjs",
5
+ "target": "es2021",
6
+ "moduleResolution": "node",
7
+ "forceConsistentCasingInFileNames": true,
8
+ "strict": true,
9
+ "strictNullChecks": true,
10
+ "noImplicitAny": true,
11
+ "noImplicitOverride": true,
12
+ "noImplicitReturns": true,
13
+ "noFallthroughCasesInSwitch": true,
14
+ "importHelpers": true,
15
+ "lib": ["es2021", "dom"]
16
+ },
17
+ "files": [],
18
+ "include": [],
19
+ "references": [
20
+ {
21
+ "path": "./tsconfig.lib.json"
22
+ },
23
+ {
24
+ "path": "./tsconfig.spec.json"
25
+ }
26
+ ]
27
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "module": "commonjs",
5
+ "outDir": "../../dist/out-tsc",
6
+ "declaration": true,
7
+ "types": ["node"]
8
+ },
9
+ "include": ["src/**/*.ts"],
10
+ "exclude": [
11
+ "jest.config.ts",
12
+ "jest.config.cts",
13
+ "src/**/*.spec.ts",
14
+ "src/**/*.test.ts"
15
+ ]
16
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../dist/out-tsc",
5
+ "module": "commonjs",
6
+ "moduleResolution": "node10",
7
+ "types": ["jest", "node"]
8
+ },
9
+ "include": [
10
+ "jest.config.ts",
11
+ "jest.config.cts",
12
+ "src/**/*.test.ts",
13
+ "src/**/*.spec.ts",
14
+ "src/**/*.d.ts"
15
+ ]
16
+ }
package/src/index.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./lib/api-auth-client"), exports);
5
- tslib_1.__exportStar(require("./lib/client-config"), exports);
6
- tslib_1.__exportStar(require("./lib/graphql-client"), exports);
7
- tslib_1.__exportStar(require("./lib/member-api"), exports);
8
- //# sourceMappingURL=index.js.map
package/src/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/bpm-core-client/src/index.ts"],"names":[],"mappings":";;;AAAA,gEAAsC;AACtC,8DAAoC;AACpC,+DAAqC;AACrC,2DAAiC"}
@@ -1,73 +0,0 @@
1
- /**
2
- * Authenticated BPM member returned by {@link loginApi} and
3
- * {@link readApiCurrentMember}.
4
- *
5
- * Mirrors the shape that BPM-compatible wrapper hosts emit from their
6
- * `POST /auth/login` and `GET /auth/me` endpoints. Roles and permissions
7
- * are used by BPM's `BPMAdminGuard` / `BPMDesignerGuard`.
8
- */
9
- export interface ApiMember {
10
- readonly email: string;
11
- readonly expiresAt: string;
12
- readonly memberId: string;
13
- readonly name: string;
14
- readonly permissions: readonly string[];
15
- readonly roles: readonly string[];
16
- }
17
- /**
18
- * Reduced member shape returned by {@link listApiTestMembers}. Excludes
19
- * `permissions` and `expiresAt` because the test-members endpoint is meant
20
- * for picker UIs in dev / demo, not for session establishment.
21
- */
22
- export interface ApiPublicMember {
23
- readonly email: string;
24
- readonly memberId: string;
25
- readonly name: string;
26
- readonly roles: readonly string[];
27
- }
28
- /**
29
- * Lists seeded test members exposed by the host's `/auth/test-members`
30
- * endpoint. Hosts targeting production typically disable this endpoint or
31
- * gate it behind a feature flag.
32
- */
33
- export declare function listApiTestMembers(): Promise<readonly ApiPublicMember[]>;
34
- /**
35
- * Performs a login against the host's `POST /auth/login` endpoint. On
36
- * success the host issues an HTTP-only session cookie that subsequent
37
- * {@link requestGraphQl} calls automatically carry, because
38
- * {@link requestApi} uses `credentials: 'include'`.
39
- *
40
- * Throws on HTTP errors with a message extracted from the response body
41
- * when available.
42
- *
43
- * @param input.identifier - Member id, email, or any other identifier the
44
- * host understands.
45
- * @param input.password - Cleartext credential — TLS is the consumer's
46
- * responsibility.
47
- */
48
- export declare function loginApi(input: {
49
- readonly identifier: string;
50
- readonly password: string;
51
- }): Promise<ApiMember>;
52
- /**
53
- * Calls `POST /auth/logout` on the host. The host clears the session
54
- * cookie. Safe to call when not logged in (host should return 200).
55
- */
56
- export declare function logoutApi(): Promise<void>;
57
- /**
58
- * Reads the currently authenticated member from `GET /auth/me`.
59
- *
60
- * Returns `null` when the host replies `401`, which is the conventional
61
- * way to signal "no active session". Any other HTTP failure throws.
62
- */
63
- export declare function readApiCurrentMember(): Promise<ApiMember | null>;
64
- /**
65
- * Resolves the base URL used by the REST `/auth/*` calls.
66
- *
67
- * Resolution order:
68
- * 1. `process.env.NEXT_PUBLIC_API_AUTH_URL` if non-empty.
69
- * 2. Derived from {@link readGraphQlEndpoint}'s origin — the host is
70
- * assumed to expose both `/graphql` and `/auth/*` at the same origin.
71
- */
72
- export declare function readApiBaseUrl(): string;
73
- export declare function resolveApiBaseUrlFromGraphQlEndpoint(graphQlEndpoint: string): string;
@@ -1,129 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listApiTestMembers = listApiTestMembers;
4
- exports.loginApi = loginApi;
5
- exports.logoutApi = logoutApi;
6
- exports.readApiCurrentMember = readApiCurrentMember;
7
- exports.readApiBaseUrl = readApiBaseUrl;
8
- exports.resolveApiBaseUrlFromGraphQlEndpoint = resolveApiBaseUrlFromGraphQlEndpoint;
9
- const graphql_client_1 = require("./graphql-client");
10
- const client_config_1 = require("./client-config");
11
- /**
12
- * Lists seeded test members exposed by the host's `/auth/test-members`
13
- * endpoint. Hosts targeting production typically disable this endpoint or
14
- * gate it behind a feature flag.
15
- */
16
- async function listApiTestMembers() {
17
- return requestApi('/auth/test-members');
18
- }
19
- /**
20
- * Performs a login against the host's `POST /auth/login` endpoint. On
21
- * success the host issues an HTTP-only session cookie that subsequent
22
- * {@link requestGraphQl} calls automatically carry, because
23
- * {@link requestApi} uses `credentials: 'include'`.
24
- *
25
- * Throws on HTTP errors with a message extracted from the response body
26
- * when available.
27
- *
28
- * @param input.identifier - Member id, email, or any other identifier the
29
- * host understands.
30
- * @param input.password - Cleartext credential — TLS is the consumer's
31
- * responsibility.
32
- */
33
- async function loginApi(input) {
34
- return requestApi('/auth/login', {
35
- body: JSON.stringify(input),
36
- headers: { 'Content-Type': 'application/json' },
37
- method: 'POST',
38
- });
39
- }
40
- /**
41
- * Calls `POST /auth/logout` on the host. The host clears the session
42
- * cookie. Safe to call when not logged in (host should return 200).
43
- */
44
- async function logoutApi() {
45
- await requestApi('/auth/logout', {
46
- method: 'POST',
47
- });
48
- }
49
- /**
50
- * Reads the currently authenticated member from `GET /auth/me`.
51
- *
52
- * Returns `null` when the host replies `401`, which is the conventional
53
- * way to signal "no active session". Any other HTTP failure throws.
54
- */
55
- async function readApiCurrentMember() {
56
- try {
57
- return await requestApi('/auth/me');
58
- }
59
- catch (error) {
60
- if (error instanceof ApiRequestError && error.status === 401) {
61
- return null;
62
- }
63
- throw error;
64
- }
65
- }
66
- /**
67
- * Resolves the base URL used by the REST `/auth/*` calls.
68
- *
69
- * Resolution order:
70
- * 1. `process.env.NEXT_PUBLIC_API_AUTH_URL` if non-empty.
71
- * 2. Derived from {@link readGraphQlEndpoint}'s origin — the host is
72
- * assumed to expose both `/graphql` and `/auth/*` at the same origin.
73
- */
74
- function readApiBaseUrl() {
75
- const config = (0, client_config_1.readBPMClientConfig)();
76
- if (config.authBaseUrl?.trim()) {
77
- return config.authBaseUrl.trim().replace(/\/$/, '');
78
- }
79
- const explicitApiBaseUrl = process.env.NEXT_PUBLIC_API_AUTH_URL?.trim();
80
- if (explicitApiBaseUrl) {
81
- return explicitApiBaseUrl.replace(/\/$/, '');
82
- }
83
- const graphQlEndpoint = (0, graphql_client_1.readGraphQlEndpoint)();
84
- return resolveApiBaseUrlFromGraphQlEndpoint(graphQlEndpoint);
85
- }
86
- function resolveApiBaseUrlFromGraphQlEndpoint(graphQlEndpoint) {
87
- if (!isAbsoluteUrl(graphQlEndpoint)) {
88
- return '';
89
- }
90
- const endpoint = new URL(graphQlEndpoint);
91
- endpoint.pathname = '/';
92
- endpoint.search = '';
93
- endpoint.hash = '';
94
- return endpoint.toString().replace(/\/$/, '');
95
- }
96
- async function requestApi(path, init) {
97
- const fetchImpl = (0, client_config_1.resolveBPMFetch)();
98
- const configuredHeaders = (0, client_config_1.readBPMConfiguredHeaders)();
99
- const response = await fetchImpl(`${readApiBaseUrl()}${path}`, {
100
- credentials: 'include',
101
- ...init,
102
- headers: { ...configuredHeaders, ...(init?.headers ?? {}) },
103
- });
104
- if (!response.ok) {
105
- throw new ApiRequestError(response.status, await readError(response));
106
- }
107
- return (await response.json());
108
- }
109
- async function readError(response) {
110
- try {
111
- const payload = (await response.json());
112
- return typeof payload.message === 'string'
113
- ? payload.message
114
- : `BPM API request failed with HTTP ${response.status}`;
115
- }
116
- catch {
117
- return `BPM API request failed with HTTP ${response.status}`;
118
- }
119
- }
120
- class ApiRequestError extends Error {
121
- constructor(status, message) {
122
- super(message);
123
- this.status = status;
124
- }
125
- }
126
- function isAbsoluteUrl(value) {
127
- return value.startsWith('http://') || value.startsWith('https://');
128
- }
129
- //# sourceMappingURL=api-auth-client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api-auth-client.js","sourceRoot":"","sources":["../../../../../libs/bpm-core-client/src/lib/api-auth-client.ts"],"names":[],"mappings":";;AAyCA,gDAIC;AAgBD,4BASC;AAMD,8BAIC;AAQD,oDAUC;AAUD,wCAeC;AAED,oFAYC;AAzID,qDAAuD;AACvD,mDAIyB;AA+BzB;;;;GAIG;AACI,KAAK,UAAU,kBAAkB;IAGtC,OAAO,UAAU,CAA6B,oBAAoB,CAAC,CAAC;AACtE,CAAC;AAED;;;;;;;;;;;;;GAaG;AACI,KAAK,UAAU,QAAQ,CAAC,KAG9B;IACC,OAAO,UAAU,CAAY,aAAa,EAAE;QAC1C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;QAC3B,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,MAAM,EAAE,MAAM;KACf,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,SAAS;IAC7B,MAAM,UAAU,CAAwB,cAAc,EAAE;QACtD,MAAM,EAAE,MAAM;KACf,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,oBAAoB;IACxC,IAAI,CAAC;QACH,OAAO,MAAM,UAAU,CAAY,UAAU,CAAC,CAAC;IACjD,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,IAAI,KAAK,YAAY,eAAe,IAAI,KAAK,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC7D,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,cAAc;IAC5B,MAAM,MAAM,GAAG,IAAA,mCAAmB,GAAE,CAAC;IACrC,IAAI,MAAM,CAAC,WAAW,EAAE,IAAI,EAAE,EAAE,CAAC;QAC/B,OAAO,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,MAAM,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,IAAI,EAAE,CAAC;IAExE,IAAI,kBAAkB,EAAE,CAAC;QACvB,OAAO,kBAAkB,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,eAAe,GAAG,IAAA,oCAAmB,GAAE,CAAC;IAE9C,OAAO,oCAAoC,CAAC,eAAe,CAAC,CAAC;AAC/D,CAAC;AAED,SAAgB,oCAAoC,CAClD,eAAuB;IAEvB,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,EAAE,CAAC;QACpC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,CAAC;IAC1C,QAAQ,CAAC,QAAQ,GAAG,GAAG,CAAC;IACxB,QAAQ,CAAC,MAAM,GAAG,EAAE,CAAC;IACrB,QAAQ,CAAC,IAAI,GAAG,EAAE,CAAC;IACnB,OAAO,QAAQ,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAChD,CAAC;AAED,KAAK,UAAU,UAAU,CACvB,IAAY,EACZ,IAAkB;IAElB,MAAM,SAAS,GAAG,IAAA,+BAAe,GAAE,CAAC;IACpC,MAAM,iBAAiB,GAAG,IAAA,wCAAwB,GAAE,CAAC;IACrD,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,cAAc,EAAE,GAAG,IAAI,EAAE,EAAE;QAC7D,WAAW,EAAE,SAAS;QACtB,GAAG,IAAI;QACP,OAAO,EAAE,EAAE,GAAG,iBAAiB,EAAE,GAAG,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,CAAC,EAAE;KAC5D,CAAC,CAAC;IAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,eAAe,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAU,CAAC;AAC1C,CAAC;AAED,KAAK,UAAU,SAAS,CAAC,QAAkB;IACzC,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAmC,CAAC;QAE1E,OAAO,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ;YACxC,CAAC,CAAC,OAAO,CAAC,OAAO;YACjB,CAAC,CAAC,oCAAoC,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC5D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,oCAAoC,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC/D,CAAC;AACH,CAAC;AAED,MAAM,eAAgB,SAAQ,KAAK;IACjC,YACW,MAAc,EACvB,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QAHN,WAAM,GAAN,MAAM,CAAQ;IAIzB,CAAC;CACF;AAED,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;AACrE,CAAC"}
@@ -1,81 +0,0 @@
1
- /**
2
- * Programmatic configuration override for the BPM client transport.
3
- *
4
- * The default endpoint resolution (`NEXT_PUBLIC_API_URL` → localhost →
5
- * same-origin) covers Next.js consumers. Node-side scripts (cron
6
- * workers, one-off org seeds, integration tests) usually cannot rely on
7
- * environment variables and need a programmatic hook. Call
8
- * {@link configureBPMClient} once at startup; subsequent
9
- * `requestGraphQl` and REST auth calls honor the override.
10
- */
11
- export interface BPMClientConfig {
12
- /**
13
- * Override the GraphQL endpoint URL. When provided, takes precedence
14
- * over `NEXT_PUBLIC_API_URL` and the default localhost / same-origin
15
- * resolution. Pass an absolute URL ending without `/graphql` to also
16
- * derive the REST `/auth/*` base URL automatically, or pass the full
17
- * `https://host/graphql` form to set the GraphQL endpoint directly.
18
- *
19
- * If you need different bases for GraphQL vs `/auth/*` (rare — most
20
- * hosts colocate them), set both `baseUrl` and `authBaseUrl`.
21
- */
22
- readonly baseUrl?: string;
23
- /**
24
- * Override the REST `/auth/*` base URL independently of `baseUrl`.
25
- * Most hosts colocate GraphQL and auth on the same origin; this knob
26
- * exists for the rare split-origin deployment.
27
- */
28
- readonly authBaseUrl?: string;
29
- /**
30
- * Replace the global `fetch` implementation. Useful when running on a
31
- * runtime without a global `fetch` (older Node versions, edge runtimes
32
- * with custom polyfills) or when you want to inject a tracing wrapper.
33
- */
34
- readonly fetch?: typeof fetch;
35
- /**
36
- * Additional headers merged into every outbound request. Use this to
37
- * pass service tokens, tracing headers, or a server-side session
38
- * cookie that the browser would normally send automatically.
39
- *
40
- * Note: `Content-Type` is set internally for GraphQL POSTs and
41
- * cannot be overridden through this option.
42
- */
43
- readonly headers?: Readonly<Record<string, string>>;
44
- }
45
- /**
46
- * Sets the active {@link BPMClientConfig}. Subsequent calls **replace**
47
- * the previous configuration; pass `{}` to reset to environment-based
48
- * defaults.
49
- *
50
- * Idiomatic call site is the very top of a Node worker's bootstrap:
51
- *
52
- * ```ts
53
- * import { configureBPMClient } from '@rytass/bpm-core-client';
54
- *
55
- * configureBPMClient({
56
- * baseUrl: 'https://api.shuttle.example.com',
57
- * headers: { 'X-Service-Token': process.env.BPM_SYNC_TOKEN ?? '' },
58
- * });
59
- * ```
60
- *
61
- * Browser consumers under Next.js typically do **not** need to call
62
- * this — `NEXT_PUBLIC_API_URL` plus same-origin defaults cover the
63
- * common case.
64
- */
65
- export declare function configureBPMClient(config: BPMClientConfig): void;
66
- /**
67
- * Reads the active {@link BPMClientConfig}. Exposed primarily for tests
68
- * and for inspecting the current override at runtime — consumers should
69
- * use {@link configureBPMClient} to mutate, never reach in directly.
70
- */
71
- export declare function readBPMClientConfig(): BPMClientConfig;
72
- /**
73
- * Resolves the effective `fetch` implementation honoring the active
74
- * override, falling back to the global `fetch`.
75
- */
76
- export declare function resolveBPMFetch(): typeof fetch;
77
- /**
78
- * Returns the headers configured via {@link configureBPMClient}.
79
- * Internal transports merge these into every outbound request.
80
- */
81
- export declare function readBPMConfiguredHeaders(): Readonly<Record<string, string>>;
@@ -1,63 +0,0 @@
1
- "use strict";
2
- /**
3
- * Programmatic configuration override for the BPM client transport.
4
- *
5
- * The default endpoint resolution (`NEXT_PUBLIC_API_URL` → localhost →
6
- * same-origin) covers Next.js consumers. Node-side scripts (cron
7
- * workers, one-off org seeds, integration tests) usually cannot rely on
8
- * environment variables and need a programmatic hook. Call
9
- * {@link configureBPMClient} once at startup; subsequent
10
- * `requestGraphQl` and REST auth calls honor the override.
11
- */
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.configureBPMClient = configureBPMClient;
14
- exports.readBPMClientConfig = readBPMClientConfig;
15
- exports.resolveBPMFetch = resolveBPMFetch;
16
- exports.readBPMConfiguredHeaders = readBPMConfiguredHeaders;
17
- let currentConfig = {};
18
- /**
19
- * Sets the active {@link BPMClientConfig}. Subsequent calls **replace**
20
- * the previous configuration; pass `{}` to reset to environment-based
21
- * defaults.
22
- *
23
- * Idiomatic call site is the very top of a Node worker's bootstrap:
24
- *
25
- * ```ts
26
- * import { configureBPMClient } from '@rytass/bpm-core-client';
27
- *
28
- * configureBPMClient({
29
- * baseUrl: 'https://api.shuttle.example.com',
30
- * headers: { 'X-Service-Token': process.env.BPM_SYNC_TOKEN ?? '' },
31
- * });
32
- * ```
33
- *
34
- * Browser consumers under Next.js typically do **not** need to call
35
- * this — `NEXT_PUBLIC_API_URL` plus same-origin defaults cover the
36
- * common case.
37
- */
38
- function configureBPMClient(config) {
39
- currentConfig = { ...config };
40
- }
41
- /**
42
- * Reads the active {@link BPMClientConfig}. Exposed primarily for tests
43
- * and for inspecting the current override at runtime — consumers should
44
- * use {@link configureBPMClient} to mutate, never reach in directly.
45
- */
46
- function readBPMClientConfig() {
47
- return currentConfig;
48
- }
49
- /**
50
- * Resolves the effective `fetch` implementation honoring the active
51
- * override, falling back to the global `fetch`.
52
- */
53
- function resolveBPMFetch() {
54
- return currentConfig.fetch ?? globalThis.fetch;
55
- }
56
- /**
57
- * Returns the headers configured via {@link configureBPMClient}.
58
- * Internal transports merge these into every outbound request.
59
- */
60
- function readBPMConfiguredHeaders() {
61
- return currentConfig.headers ?? {};
62
- }
63
- //# sourceMappingURL=client-config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client-config.js","sourceRoot":"","sources":["../../../../../libs/bpm-core-client/src/lib/client-config.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AA8DH,gDAEC;AAOD,kDAEC;AAMD,0CAEC;AAMD,4DAEC;AAjDD,IAAI,aAAa,GAAoB,EAAE,CAAC;AAExC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,kBAAkB,CAAC,MAAuB;IACxD,aAAa,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;AAChC,CAAC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB;IACjC,OAAO,aAAa,CAAC;AACvB,CAAC;AAED;;;GAGG;AACH,SAAgB,eAAe;IAC7B,OAAO,aAAa,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC;AACjD,CAAC;AAED;;;GAGG;AACH,SAAgB,wBAAwB;IACtC,OAAO,aAAa,CAAC,OAAO,IAAI,EAAE,CAAC;AACrC,CAAC"}
@@ -1,54 +0,0 @@
1
- import { FormDefinitionSchema, FormFieldDefinition, FormUiSchema } from '@rytass/bpm-core-shared/form';
2
- export interface FormDefinitionRecord {
3
- readonly currentVersionId: string | null;
4
- readonly currentVersionCreatedAt: string | null;
5
- readonly currentVersionNumber: number | null;
6
- readonly currentVersionPublishedAt: string | null;
7
- readonly description: string | null;
8
- readonly id: string;
9
- readonly name: string;
10
- readonly updatedAt: string;
11
- }
12
- export type FormDefinitionListStatus = 'DRAFT' | 'PUBLISHED';
13
- export interface FormDefinitionVersionRecord {
14
- readonly id: string;
15
- readonly publishedAt: string | null;
16
- readonly schema: FormDefinitionSchema;
17
- readonly schemaJson: string;
18
- readonly status: 'ARCHIVED' | 'DRAFT' | 'PUBLISHED';
19
- readonly uiSchema: FormUiSchema;
20
- readonly uiSchemaJson: string;
21
- readonly updatedAt: string;
22
- readonly version: number;
23
- }
24
- export interface FormBuilderRecord {
25
- readonly definition: FormDefinitionRecord;
26
- readonly versions: readonly FormDefinitionVersionRecord[];
27
- }
28
- export interface FormSchemaLintResult {
29
- readonly errors: readonly string[];
30
- readonly valid: boolean;
31
- }
32
- export declare function listFormDefinitions(): Promise<readonly FormDefinitionRecord[]>;
33
- export declare function listFormDefinitionsPage({ page, pageSize, status, }: {
34
- readonly page: number;
35
- readonly pageSize: number;
36
- readonly status?: FormDefinitionListStatus | null;
37
- }): Promise<{
38
- readonly forms: readonly FormDefinitionRecord[];
39
- readonly totalCount: number;
40
- }>;
41
- export declare function createFormDefinition(name: string): Promise<string>;
42
- export declare function updateFormDefinition(id: string, name: string): Promise<FormDefinitionRecord>;
43
- export declare function readFormBuilder(formDefinitionId: string): Promise<FormBuilderRecord>;
44
- export declare function updateFormDefinitionDraft(versionId: string, schema: FormDefinitionSchema, uiSchema: FormUiSchema): Promise<FormDefinitionVersionRecord>;
45
- export declare function publishFormDefinitionVersion(versionId: string): Promise<FormDefinitionVersionRecord>;
46
- /**
47
- * Publishes the given content as the form's current version atomically.
48
- * Before the first publish the single draft is updated and published;
49
- * afterwards a brand-new published version is created directly. Content
50
- * identical to the current published version is a no-op.
51
- */
52
- export declare function publishFormDefinitionContent(formDefinitionId: string, schema: FormDefinitionSchema, uiSchema: FormUiSchema): Promise<FormDefinitionVersionRecord>;
53
- export declare function lintFormSchema(schema: FormDefinitionSchema, uiSchema: FormUiSchema): Promise<FormSchemaLintResult>;
54
- export declare function createFieldDefinition(type: FormFieldDefinition['type'], index: number): FormFieldDefinition;