@rytass/bpm-core-client 0.6.0 → 0.9.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 (31) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/README.md +6 -0
  3. package/package.json +2 -2
  4. package/src/lib/form/form-api.js +5 -1
  5. package/src/lib/form/form-api.js.map +1 -1
  6. package/src/lib/form/form-data-source-api.d.ts +50 -0
  7. package/src/lib/form/form-data-source-api.js +72 -0
  8. package/src/lib/form/form-data-source-api.js.map +1 -0
  9. package/src/lib/form/form-data-source-builder.d.ts +17 -0
  10. package/src/lib/form/form-data-source-builder.js +107 -0
  11. package/src/lib/form/form-data-source-builder.js.map +1 -0
  12. package/src/lib/form/form-data-source-errors.d.ts +30 -0
  13. package/src/lib/form/form-data-source-errors.js +152 -0
  14. package/src/lib/form/form-data-source-errors.js.map +1 -0
  15. package/src/lib/form/form-data-source-state.d.ts +12 -0
  16. package/src/lib/form/form-data-source-state.js +70 -0
  17. package/src/lib/form/form-data-source-state.js.map +1 -0
  18. package/src/lib/form/form-rendering.d.ts +2 -2
  19. package/src/lib/form/form-rendering.js +3 -4
  20. package/src/lib/form/form-rendering.js.map +1 -1
  21. package/src/lib/form/index.d.ts +4 -0
  22. package/src/lib/form/index.js +4 -0
  23. package/src/lib/form/index.js.map +1 -1
  24. package/src/lib/graphql-client.js +10 -5
  25. package/src/lib/graphql-client.js.map +1 -1
  26. package/src/lib/template/template-api.d.ts +6 -1
  27. package/src/lib/template/template-api.js +28 -1
  28. package/src/lib/template/template-api.js.map +1 -1
  29. package/src/lib/workflow/workflow-api.d.ts +14 -2
  30. package/src/lib/workflow/workflow-api.js +28 -5
  31. package/src/lib/workflow/workflow-api.js.map +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,52 @@
1
+ ## 0.9.0 (2026-08-17)
2
+
3
+ ### 🚀 Features
4
+
5
+ - **notification:** lift routing fields onto the created event ([e02270b](https://github.com/Rytass/BPMCore/commit/e02270b))
6
+ - **notification:** let a host observe notifications as they are created ([#21](https://github.com/Rytass/BPMCore/pull/21))
7
+ - **shared:** detect a quorum no approver set can ever satisfy ([5671497](https://github.com/Rytass/BPMCore/commit/5671497))
8
+ - **shared:** expose the decision policy to the workflow toolset ([f6152b0](https://github.com/Rytass/BPMCore/commit/f6152b0))
9
+
10
+ ### 🩹 Fixes
11
+
12
+ - ⚠️ **template:** reject deleting a referenced category ([#16](https://github.com/Rytass/BPMCore/pull/16))
13
+ - **template:** let a template actually change category ([#17](https://github.com/Rytass/BPMCore/pull/17))
14
+ - **shared:** keep an approver change from discarding a workable policy ([ea6afbe](https://github.com/Rytass/BPMCore/commit/ea6afbe))
15
+ - **e2e:** poll on the expected value in the quorum threshold sanitiser spec ([099529f](https://github.com/Rytass/BPMCore/commit/099529f))
16
+ - **bpm-core-react:** correct decision-policy panel review findings ([ebf0337](https://github.com/Rytass/BPMCore/commit/ebf0337))
17
+
18
+ ### ⚠️ Breaking Changes
19
+
20
+ - **template:** reject deleting a referenced category ([#16](https://github.com/Rytass/BPMCore/pull/16))
21
+ `deleteApprovalTemplateCategory` now throws
22
+ `BadRequestException` when templates still reference the category, instead
23
+ of deactivating it and reporting success.
24
+ The old behaviour substituted a different operation for the one requested
25
+ and returned the same entity type either way, so a caller could not tell
26
+ that the delete had not happened — nor that `isActive` had been flipped as
27
+ a side effect it never asked for. Downstream, the category vanished from
28
+ groupings because it was now inactive, with nothing to explain why.
29
+ Deactivation is not lost: `deactivateApprovalTemplateCategory(id)` has
30
+ always existed and is unchanged, so the fallback was never the only way to
31
+ reach that state.
32
+ The designer's category screen already wraps the call in try/catch and
33
+ surfaces the message, and it only closes the confirmation dialog on
34
+ success, so the new error reaches the author without a UI change.
35
+ Reported by a consumer on 0.7.0, who had to re-implement the reference
36
+ check ahead of the call to avoid telling users something had been deleted
37
+ when it had not.
38
+ Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
39
+
40
+ ### ❤️ Thank You
41
+
42
+ - Chia Yu Pai @fantasywind
43
+ - Claude Opus 5
44
+ - Kai-Chieh Yang
45
+
46
+ ## 0.7.0 (2026-08-10)
47
+
48
+ This was a version bump only for bpm-core-client to align it with other projects, there were no code changes.
49
+
1
50
  # Changelog
2
51
 
3
52
  All notable changes to `@rytass/bpm-core-client` are documented in this file.
@@ -5,6 +54,38 @@ All notable changes to `@rytass/bpm-core-client` are documented in this file.
5
54
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
6
55
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
56
 
57
+ ## Unreleased
58
+
59
+ ### Changed
60
+
61
+ - Form helpers now recognize `autocomplete` and distinguish static option
62
+ fields from DataSource-backed option fields without changing primitive form
63
+ values.
64
+ - Added typed catalog, designer preview, and authenticated runtime wrappers
65
+ for the host-registered form DataSource GraphQL boundary.
66
+ - Approval instance records now expose parsed and raw dynamic option snapshots
67
+ returned by the server.
68
+ - Added immutable DataSource option merge, selected hydration, unresolved-value,
69
+ dependency, and value-signature helpers plus the `FormDataSourceFieldStatus`
70
+ union used by the React renderer.
71
+ - Added immutable builder helpers for DataSource capability filtering, parameter
72
+ type matching, field/constant bindings, field-key rename propagation, and
73
+ dependent-field discovery.
74
+ - Added `FORM_DATA_SOURCE_ERROR_CODES`, `readFormDataSourceErrorCode()`,
75
+ `readFormDataSourceErrorMessage()`, and `readFormSchemaLintMessage()` so
76
+ consumers can turn the backend's stable DataSource codes into display copy
77
+ instead of showing the raw code. A code this client does not map yet still
78
+ yields readable copy rather than leaking the code to the screen. Detection is
79
+ token-bounded, and a publish failure that joins several lint lines has every
80
+ code mapped, not just the first. Lint lines that quote a host-chosen parameter
81
+ or descriptor name are left verbatim, so a parameter named like an error code
82
+ is not rewritten as that error's copy.
83
+
84
+ ### Fixed
85
+
86
+ - Explicit `NEXT_PUBLIC_API_URL` base URLs now resolve to `/graphql` before
87
+ browser requests, matching the documented API-base configuration contract.
88
+
8
89
  Releases are managed by [`nx release`](https://nx.dev/recipes/nx-release) with
9
90
  Conventional Commits — see `nx.json` for the release config.
10
91
 
package/README.md CHANGED
@@ -16,6 +16,12 @@ This package contains:
16
16
  It does **not** ship React components, hooks, or UI. Hosts can call the
17
17
  functions directly from any framework (Next.js / Vite / Remix / plain Node).
18
18
 
19
+ Form clients can import the shared option-field contracts from
20
+ `@rytass/bpm-core-shared/form`. `createFieldDefinition()` includes the
21
+ `autocomplete` variant, while the pure form-rendering helpers retain the
22
+ primitive value contract and distinguish static option fields from dynamic
23
+ DataSource references.
24
+
19
25
  ## Package Status
20
26
 
21
27
  Current version: `0.1.10`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rytass/bpm-core-client",
3
- "version": "0.6.0",
3
+ "version": "0.9.0",
4
4
  "description": "Framework-agnostic TypeScript client for the Rytass BPM approval workflow GraphQL surface: fetch-based GraphQL transport, REST auth client, pre-baked typed operations for organization, member, form, template, and workflow.",
5
5
  "keywords": [
6
6
  "bpm",
@@ -73,7 +73,7 @@
73
73
  }
74
74
  },
75
75
  "peerDependencies": {
76
- "@rytass/bpm-core-shared": "^0.6.0"
76
+ "@rytass/bpm-core-shared": "^0.9.0"
77
77
  },
78
78
  "dependencies": {
79
79
  "tslib": "^2.3.0"
@@ -195,7 +195,10 @@ function createFieldDefinition(type, index) {
195
195
  required: false,
196
196
  type,
197
197
  };
198
- if (type === 'select' || type === 'radio' || type === 'checkbox') {
198
+ if (type === 'select' ||
199
+ type === 'autocomplete' ||
200
+ type === 'radio' ||
201
+ type === 'checkbox') {
199
202
  return {
200
203
  ...base,
201
204
  options: [
@@ -224,6 +227,7 @@ function parseVersionJson(version) {
224
227
  function readDefaultFieldLabel(type, index) {
225
228
  const labels = {
226
229
  boolean: '開關',
230
+ autocomplete: '自動完成',
227
231
  checkbox: '複選',
228
232
  date: '日期',
229
233
  datetime: '日期時間',
@@ -1 +1 @@
1
- {"version":3,"file":"form-api.js","sourceRoot":"","sources":["../../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ldValue, FormUiSchema } from '@rytass/bpm-core-shared/form';
2
+ export type FormDataSourceControl = 'autocomplete' | 'checkbox' | 'radio' | 'select';
3
+ export type FormDataSourceParameterType = 'BOOLEAN' | 'NUMBER' | 'STRING' | 'STRING_ARRAY';
4
+ export type FormDataSourceRevalidationPolicy = 'ALWAYS' | 'WHEN_VALUE_OR_BINDINGS_CHANGE';
5
+ export interface FormDataSourceParameterRecord {
6
+ readonly key: string;
7
+ readonly label: string | null;
8
+ readonly required: boolean;
9
+ readonly type: FormDataSourceParameterType;
10
+ }
11
+ export interface FormDataSourceDescriptorRecord {
12
+ readonly description: string | null;
13
+ readonly key: string;
14
+ readonly label: string;
15
+ readonly maximumResultCount: number;
16
+ readonly minimumSearchLength: number;
17
+ readonly pageSize: number;
18
+ readonly paginationMode: 'CURSOR' | 'NONE';
19
+ readonly parameters: readonly FormDataSourceParameterRecord[];
20
+ readonly revalidationPolicy: FormDataSourceRevalidationPolicy;
21
+ readonly returnsCompleteList: boolean;
22
+ readonly supportedControls: readonly FormDataSourceControl[];
23
+ readonly supportsSearch: boolean;
24
+ readonly version: number;
25
+ }
26
+ export interface FormDataSourceOptionsResultRecord {
27
+ readonly dataSourceKey: string;
28
+ readonly dataSourceVersion: number;
29
+ readonly nextCursor: string | null;
30
+ readonly options: readonly FormFieldOption[];
31
+ }
32
+ export interface PreviewFormFieldOptionsInput {
33
+ readonly cursor?: string | null;
34
+ readonly fieldKey: string;
35
+ readonly formData?: Readonly<Record<string, FormFieldValue>>;
36
+ readonly schema: FormDefinitionSchema;
37
+ readonly searchText?: string | null;
38
+ readonly uiSchema: FormUiSchema;
39
+ }
40
+ export interface RuntimeFormFieldOptionsInput {
41
+ readonly cursor?: string | null;
42
+ readonly fieldKey: string;
43
+ readonly formData?: Readonly<Record<string, FormFieldValue>>;
44
+ readonly instanceId?: string | null;
45
+ readonly searchText?: string | null;
46
+ readonly templateId?: string | null;
47
+ }
48
+ export declare function listFormDataSources(): Promise<readonly FormDataSourceDescriptorRecord[]>;
49
+ export declare function previewFormFieldOptions(input: PreviewFormFieldOptionsInput): Promise<FormDataSourceOptionsResultRecord>;
50
+ export declare function readFormFieldOptions(input: RuntimeFormFieldOptionsInput): Promise<FormDataSourceOptionsResultRecord>;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listFormDataSources = listFormDataSources;
4
+ exports.previewFormFieldOptions = previewFormFieldOptions;
5
+ exports.readFormFieldOptions = readFormFieldOptions;
6
+ const graphql_client_1 = require("../graphql-client");
7
+ const DESCRIPTOR_FIELDS = `
8
+ description
9
+ key
10
+ label
11
+ maximumResultCount
12
+ minimumSearchLength
13
+ pageSize
14
+ paginationMode
15
+ parameters {
16
+ key
17
+ label
18
+ required
19
+ type
20
+ }
21
+ revalidationPolicy
22
+ returnsCompleteList
23
+ supportedControls
24
+ supportsSearch
25
+ version
26
+ `;
27
+ const OPTION_RESULT_FIELDS = `
28
+ dataSourceKey
29
+ dataSourceVersion
30
+ nextCursor
31
+ options {
32
+ label
33
+ value
34
+ }
35
+ `;
36
+ async function listFormDataSources() {
37
+ const data = await (0, graphql_client_1.requestGraphQl)(`query FormDataSources { formDataSources { ${DESCRIPTOR_FIELDS} } }`);
38
+ return data.formDataSources;
39
+ }
40
+ async function previewFormFieldOptions(input) {
41
+ const data = await (0, graphql_client_1.requestGraphQl)(`query PreviewFormFieldOptions($input: BPMPreviewFormFieldOptionsInput!) {
42
+ previewFormFieldOptions(input: $input) { ${OPTION_RESULT_FIELDS} }
43
+ }`, { input: serializePreviewInput(input) });
44
+ return data.previewFormFieldOptions;
45
+ }
46
+ async function readFormFieldOptions(input) {
47
+ const data = await (0, graphql_client_1.requestGraphQl)(`query FormFieldOptions($input: BPMRuntimeFormFieldOptionsInput!) {
48
+ formFieldOptions(input: $input) { ${OPTION_RESULT_FIELDS} }
49
+ }`, { input: serializeRuntimeInput(input) });
50
+ return data.formFieldOptions;
51
+ }
52
+ function serializePreviewInput(input) {
53
+ return {
54
+ cursor: input.cursor ?? null,
55
+ fieldKey: input.fieldKey,
56
+ formDataJson: input.formData ? JSON.stringify(input.formData) : null,
57
+ schemaJson: JSON.stringify(input.schema),
58
+ searchText: input.searchText ?? null,
59
+ uiSchemaJson: JSON.stringify(input.uiSchema),
60
+ };
61
+ }
62
+ function serializeRuntimeInput(input) {
63
+ return {
64
+ cursor: input.cursor ?? null,
65
+ fieldKey: input.fieldKey,
66
+ formDataJson: input.formData ? JSON.stringify(input.formData) : null,
67
+ instanceId: input.instanceId ?? null,
68
+ searchText: input.searchText ?? null,
69
+ templateId: input.templateId ?? null,
70
+ };
71
+ }
72
+ //# sourceMappingURL=form-data-source-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-data-source-api.js","sourceRoot":"","sources":["../../../../../../libs/bpm-core-client/src/lib/form/form-data-source-api.ts"],"names":[],"mappings":";;AAmHA,kDAQC;AAED,0DAWC;AAED,oDAWC;AA/ID,sDAAmD;AA8EnD,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;CAmBzB,CAAC;AAEF,MAAM,oBAAoB,GAAG;;;;;;;;CAQ5B,CAAC;AAEK,KAAK,UAAU,mBAAmB;IAGvC,MAAM,IAAI,GAAG,MAAM,IAAA,+BAAc,EAC/B,6CAA6C,iBAAiB,MAAM,CACrE,CAAC;IAEF,OAAO,IAAI,CAAC,eAAe,CAAC;AAC9B,CAAC;AAEM,KAAK,UAAU,uBAAuB,CAC3C,KAAmC;IAEnC,MAAM,IAAI,GAAG,MAAM,IAAA,+BAAc,EAC/B;iDAC6C,oBAAoB;MAC/D,EACF,EAAE,KAAK,EAAE,qBAAqB,CAAC,KAAK,CAAC,EAAE,CACxC,CAAC;IAEF,OAAO,IAAI,CAAC,uBAAuB,CAAC;AACtC,CAAC;AAEM,KAAK,UAAU,oBAAoB,CACxC,KAAmC;IAEnC,MAAM,IAAI,GAAG,MAAM,IAAA,+BAAc,EAC/B;0CACsC,oBAAoB;MACxD,EACF,EAAE,KAAK,EAAE,qBAAqB,CAAC,KAAK,CAAC,EAAE,CACxC,CAAC;IAEF,OAAO,IAAI,CAAC,gBAAgB,CAAC;AAC/B,CAAC;AAED,SAAS,qBAAqB,CAC5B,KAAmC;IAEnC,OAAO;QACL,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,IAAI;QAC5B,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI;QACpE,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC;QACxC,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,IAAI;QACpC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC;KAC7C,CAAC;AACJ,CAAC;AAED,SAAS,qBAAqB,CAC5B,KAAmC;IAEnC,OAAO;QACL,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,IAAI;QAC5B,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI;QACpE,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,IAAI;QACpC,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,IAAI;QACpC,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,IAAI;KACrC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { FormDataSourceBinding, FormDataSourceOptionFieldDefinition, FormDefinitionSchema, FormFieldDefinition, FormFieldValue } from '@rytass/bpm-core-shared/form';
2
+ import { FormDataSourceControl, FormDataSourceDescriptorRecord, FormDataSourceParameterType } from './form-data-source-api';
3
+ export interface FormDataSourceBindingFieldOption {
4
+ readonly id: string;
5
+ readonly name: string;
6
+ }
7
+ export declare function isFormDataSourceDescriptorCompatible(descriptor: FormDataSourceDescriptorRecord, control: FormDataSourceControl): boolean;
8
+ export declare function readCompatibleFormDataSourceDescriptors(control: FormDataSourceControl, descriptors: readonly FormDataSourceDescriptorRecord[]): readonly FormDataSourceDescriptorRecord[];
9
+ export declare function readFormDataSourceParameterType(field: FormFieldDefinition): FormDataSourceParameterType | null;
10
+ export declare function readCompatibleFormDataSourceBindingFields(parameterType: FormDataSourceParameterType, fields: readonly FormFieldDefinition[], targetFieldKey: string): readonly FormDataSourceBindingFieldOption[];
11
+ export declare function readFormDataSourceBinding(field: FormDataSourceOptionFieldDefinition, parameterKey: string): FormDataSourceBinding | null;
12
+ export declare function upsertFormDataSourceFieldBinding(field: FormDataSourceOptionFieldDefinition, parameterKey: string, binding: FormDataSourceBinding | null): FormDataSourceOptionFieldDefinition;
13
+ export declare function renameFormDataSourceFieldBindings(schema: FormDefinitionSchema, previousFieldKey: string, nextFieldKey: string): FormDefinitionSchema;
14
+ export declare function readFormDataSourceFieldDependencyKeys(field: FormDataSourceOptionFieldDefinition): readonly string[];
15
+ export declare function readFormDataSourceBindingValue(field: FormDataSourceOptionFieldDefinition, parameterKey: string): FormFieldValue | undefined;
16
+ export type FormDataSourceBindingValueKind = 'CONSTANT' | 'FIELD';
17
+ export declare function readFormDataSourceBindingValueKind(binding: FormDataSourceBinding | null): FormDataSourceBindingValueKind | null;
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isFormDataSourceDescriptorCompatible = isFormDataSourceDescriptorCompatible;
4
+ exports.readCompatibleFormDataSourceDescriptors = readCompatibleFormDataSourceDescriptors;
5
+ exports.readFormDataSourceParameterType = readFormDataSourceParameterType;
6
+ exports.readCompatibleFormDataSourceBindingFields = readCompatibleFormDataSourceBindingFields;
7
+ exports.readFormDataSourceBinding = readFormDataSourceBinding;
8
+ exports.upsertFormDataSourceFieldBinding = upsertFormDataSourceFieldBinding;
9
+ exports.renameFormDataSourceFieldBindings = renameFormDataSourceFieldBindings;
10
+ exports.readFormDataSourceFieldDependencyKeys = readFormDataSourceFieldDependencyKeys;
11
+ exports.readFormDataSourceBindingValue = readFormDataSourceBindingValue;
12
+ exports.readFormDataSourceBindingValueKind = readFormDataSourceBindingValueKind;
13
+ const form_1 = require("@rytass/bpm-core-shared/form");
14
+ function isFormDataSourceDescriptorCompatible(descriptor, control) {
15
+ if (!descriptor.supportedControls.includes(control)) {
16
+ return false;
17
+ }
18
+ return control === 'radio' || control === 'checkbox'
19
+ ? descriptor.returnsCompleteList && descriptor.maximumResultCount <= 50
20
+ : true;
21
+ }
22
+ function readCompatibleFormDataSourceDescriptors(control, descriptors) {
23
+ return descriptors.filter((descriptor) => isFormDataSourceDescriptorCompatible(descriptor, control));
24
+ }
25
+ function readFormDataSourceParameterType(field) {
26
+ switch (field.type) {
27
+ case 'boolean':
28
+ return 'BOOLEAN';
29
+ case 'checkbox':
30
+ case 'file_upload':
31
+ return 'STRING_ARRAY';
32
+ case 'money':
33
+ case 'number':
34
+ return 'NUMBER';
35
+ case 'autocomplete':
36
+ case 'radio':
37
+ case 'select': {
38
+ const mode = (0, form_1.readFormFieldSelectionMode)(field);
39
+ return mode === 'multiple' ? 'STRING_ARRAY' : 'STRING';
40
+ }
41
+ case 'date':
42
+ case 'datetime':
43
+ case 'text':
44
+ case 'textarea':
45
+ return 'STRING';
46
+ default:
47
+ return null;
48
+ }
49
+ }
50
+ function readCompatibleFormDataSourceBindingFields(parameterType, fields, targetFieldKey) {
51
+ return fields
52
+ .filter((field) => field.fieldKey !== targetFieldKey)
53
+ .filter((field) => readFormDataSourceParameterType(field) === parameterType)
54
+ .map((field) => ({ id: field.fieldKey, name: field.label }));
55
+ }
56
+ function readFormDataSourceBinding(field, parameterKey) {
57
+ return (field.dataSource.bindings.find((binding) => binding.parameter === parameterKey) ?? null);
58
+ }
59
+ function upsertFormDataSourceFieldBinding(field, parameterKey, binding) {
60
+ const nextBindings = field.dataSource.bindings
61
+ .filter((candidate) => candidate.parameter !== parameterKey)
62
+ .concat(binding ? [binding] : []);
63
+ return {
64
+ ...field,
65
+ dataSource: {
66
+ ...field.dataSource,
67
+ bindings: nextBindings,
68
+ },
69
+ };
70
+ }
71
+ function renameFormDataSourceFieldBindings(schema, previousFieldKey, nextFieldKey) {
72
+ return {
73
+ ...schema,
74
+ fields: schema.fields.map((field) => {
75
+ if (!(0, form_1.isFormDataSourceFieldDefinition)(field)) {
76
+ return field;
77
+ }
78
+ return {
79
+ ...field,
80
+ dataSource: {
81
+ ...field.dataSource,
82
+ bindings: field.dataSource.bindings.map((binding) => binding.from.kind === 'FIELD' &&
83
+ binding.from.fieldKey === previousFieldKey
84
+ ? {
85
+ ...binding,
86
+ from: {
87
+ ...binding.from,
88
+ fieldKey: nextFieldKey,
89
+ },
90
+ }
91
+ : binding),
92
+ },
93
+ };
94
+ }),
95
+ };
96
+ }
97
+ function readFormDataSourceFieldDependencyKeys(field) {
98
+ return field.dataSource.bindings.flatMap((binding) => binding.from.kind === 'FIELD' ? [binding.from.fieldKey] : []);
99
+ }
100
+ function readFormDataSourceBindingValue(field, parameterKey) {
101
+ const binding = readFormDataSourceBinding(field, parameterKey);
102
+ return binding?.from.kind === 'CONSTANT' ? binding.from.value : undefined;
103
+ }
104
+ function readFormDataSourceBindingValueKind(binding) {
105
+ return binding?.from.kind ?? null;
106
+ }
107
+ //# sourceMappingURL=form-data-source-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-data-source-builder.js","sourceRoot":"","sources":["../../../../../../libs/bpm-core-client/src/lib/form/form-data-source-builder.ts"],"names":[],"mappings":";;AAoBA,oFAWC;AAED,0FAOC;AAED,0EA2BC;AAED,8FAWC;AAED,8DASC;AAED,4EAgBC;AAED,8EAgCC;AAED,sFAMC;AAED,wEAOC;AAID,gFAIC;AA1KD,uDAQsC;AAYtC,SAAgB,oCAAoC,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L surface.
3
+ *
4
+ * The backend deliberately returns codes rather than prose so it never leaks an
5
+ * upstream URL, header, query or response body. Consumers are expected to map
6
+ * them to their own copy; `readFormDataSourceErrorMessage` is the default
7
+ * mapping used by the bundled React views.
8
+ */
9
+ export declare const FORM_DATA_SOURCE_ERROR_CODES: readonly ["FORM_DATA_SOURCE_FIELD_NOT_DYNAMIC", "FORM_DATA_SOURCE_INVALID_BINDING", "FORM_DATA_SOURCE_INVALID_DESCRIPTOR", "FORM_DATA_SOURCE_INVALID_PROVIDER_RESULT", "FORM_DATA_SOURCE_MISSING", "FORM_DATA_SOURCE_PARAMETER_LIMIT_EXCEEDED", "FORM_DATA_SOURCE_PROVIDER_FAILURE", "FORM_DATA_SOURCE_RESULT_LIMIT_EXCEEDED", "FORM_DATA_SOURCE_RUNTIME_CONTEXT_FORBIDDEN", "FORM_DATA_SOURCE_SEARCH_NOT_SUPPORTED", "FORM_DATA_SOURCE_SEARCH_TOO_SHORT", "FORM_DATA_SOURCE_TIMEOUT", "FORM_DATA_SOURCE_UNSUPPORTED_CONTROL", "FORM_DATA_SOURCE_VALUE_NOT_RESOLVED", "FORM_DATA_SOURCE_VERSION_MISSING", "FORM_DATA_SOURCE_WAITING_FOR_DEPENDENCIES"];
10
+ export type FormDataSourceErrorCode = (typeof FORM_DATA_SOURCE_ERROR_CODES)[number];
11
+ /**
12
+ * Extracts the DataSource error code carried by a rejected request, whether it
13
+ * arrives as the bare code, a GraphQL error message, or an `Error` wrapping
14
+ * either. Returns `null` for anything that is not a DataSource failure.
15
+ */
16
+ export declare function readFormDataSourceErrorCode(error: unknown): FormDataSourceErrorCode | null;
17
+ /**
18
+ * Maps a rejected request to display copy. Returns `null` only when the failure
19
+ * is not a DataSource error at all, so callers can fall back to their own
20
+ * message; an unrecognised `FORM_DATA_SOURCE_*` code still yields readable copy
21
+ * rather than leaking the code itself.
22
+ */
23
+ export declare function readFormDataSourceErrorMessage(error: unknown): string | null;
24
+ /**
25
+ * Rewrites a publish-lint line such as
26
+ * `schema.fields[1].dataSource FORM_DATA_SOURCE_MISSING` into readable copy
27
+ * while keeping the field path that tells the designer where to look. Lines
28
+ * without a DataSource code are returned unchanged.
29
+ */
30
+ export declare function readFormSchemaLintMessage(error: string): string;
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FORM_DATA_SOURCE_ERROR_CODES = void 0;
4
+ exports.readFormDataSourceErrorCode = readFormDataSourceErrorCode;
5
+ exports.readFormDataSourceErrorMessage = readFormDataSourceErrorMessage;
6
+ exports.readFormSchemaLintMessage = readFormSchemaLintMessage;
7
+ /**
8
+ * Stable error codes raised by the BPM form DataSource GraphQL surface.
9
+ *
10
+ * The backend deliberately returns codes rather than prose so it never leaks an
11
+ * upstream URL, header, query or response body. Consumers are expected to map
12
+ * them to their own copy; `readFormDataSourceErrorMessage` is the default
13
+ * mapping used by the bundled React views.
14
+ */
15
+ exports.FORM_DATA_SOURCE_ERROR_CODES = [
16
+ 'FORM_DATA_SOURCE_FIELD_NOT_DYNAMIC',
17
+ 'FORM_DATA_SOURCE_INVALID_BINDING',
18
+ 'FORM_DATA_SOURCE_INVALID_DESCRIPTOR',
19
+ 'FORM_DATA_SOURCE_INVALID_PROVIDER_RESULT',
20
+ 'FORM_DATA_SOURCE_MISSING',
21
+ 'FORM_DATA_SOURCE_PARAMETER_LIMIT_EXCEEDED',
22
+ 'FORM_DATA_SOURCE_PROVIDER_FAILURE',
23
+ 'FORM_DATA_SOURCE_RESULT_LIMIT_EXCEEDED',
24
+ 'FORM_DATA_SOURCE_RUNTIME_CONTEXT_FORBIDDEN',
25
+ 'FORM_DATA_SOURCE_SEARCH_NOT_SUPPORTED',
26
+ 'FORM_DATA_SOURCE_SEARCH_TOO_SHORT',
27
+ 'FORM_DATA_SOURCE_TIMEOUT',
28
+ 'FORM_DATA_SOURCE_UNSUPPORTED_CONTROL',
29
+ 'FORM_DATA_SOURCE_VALUE_NOT_RESOLVED',
30
+ 'FORM_DATA_SOURCE_VERSION_MISSING',
31
+ 'FORM_DATA_SOURCE_WAITING_FOR_DEPENDENCIES',
32
+ ];
33
+ const ERROR_MESSAGES = {
34
+ FORM_DATA_SOURCE_FIELD_NOT_DYNAMIC: '此欄位不是動態選項欄位。',
35
+ FORM_DATA_SOURCE_INVALID_BINDING: '選項查詢條件不正確,請重新確認表單內容。',
36
+ FORM_DATA_SOURCE_INVALID_DESCRIPTOR: '選項來源設定不正確,請聯絡系統管理員。',
37
+ FORM_DATA_SOURCE_INVALID_PROVIDER_RESULT: '選項來源回傳的資料不正確,請聯絡系統管理員。',
38
+ FORM_DATA_SOURCE_MISSING: '選項來源已不存在,請聯絡系統管理員。',
39
+ FORM_DATA_SOURCE_PARAMETER_LIMIT_EXCEEDED: '選項查詢條件過大,請縮減表單內容。',
40
+ FORM_DATA_SOURCE_PROVIDER_FAILURE: '選項來源目前無法回應,請稍後再試。',
41
+ FORM_DATA_SOURCE_RESULT_LIMIT_EXCEEDED: '選項數量超過上限,請縮小查詢範圍。',
42
+ FORM_DATA_SOURCE_RUNTIME_CONTEXT_FORBIDDEN: '沒有權限查詢此欄位的選項。',
43
+ FORM_DATA_SOURCE_SEARCH_NOT_SUPPORTED: '此選項來源不支援搜尋。',
44
+ FORM_DATA_SOURCE_SEARCH_TOO_SHORT: '請輸入更多搜尋文字。',
45
+ FORM_DATA_SOURCE_TIMEOUT: '選項來源回應逾時,請稍後再試。',
46
+ FORM_DATA_SOURCE_UNSUPPORTED_CONTROL: '此選項來源不支援目前的欄位型態。',
47
+ FORM_DATA_SOURCE_VALUE_NOT_RESOLVED: '已選取的選項已失效,請重新選擇。',
48
+ FORM_DATA_SOURCE_VERSION_MISSING: '選項來源版本已不存在,請聯絡系統管理員。',
49
+ FORM_DATA_SOURCE_WAITING_FOR_DEPENDENCIES: '請先填寫相依欄位。',
50
+ };
51
+ /**
52
+ * Token-bounded so `XFORM_DATA_SOURCE_TIMEOUT` is not mistaken for a code, and
53
+ * digit-tolerant so a future code is still recognised as one of ours.
54
+ */
55
+ const ERROR_CODE_PATTERN = /(?<![A-Za-z0-9_])FORM_DATA_SOURCE_[A-Z0-9_]+(?![A-Za-z0-9_])/u;
56
+ /**
57
+ * The only lint shape that carries an error code, anchored to the exact path the
58
+ * backend emits AND to the start of a `'; '`-joined lint segment:
59
+ * `schema.fields[<n>].dataSource <CODE>`.
60
+ *
61
+ * Segment anchoring is what closes the whole family of adversarial names: a
62
+ * host- or designer-chosen parameter or field key can only ever appear after a
63
+ * prose prefix
64
+ * within its segment, never at the segment start, so no name — however it is
65
+ * spelled — can be mistaken for an emitted code.
66
+ *
67
+ * Every other lint line is prose that may quote a host- or designer-chosen name — a
68
+ * DataSource parameter, a descriptor field, a form field key — and such a name
69
+ * may legitimately look like an error code. Replacing only this shape is why the
70
+ * formatter needs no allowlist of prose shapes to avoid rewriting those names.
71
+ */
72
+ const LINT_LINE_CODE_PATTERN = /(^|; )(schema\.fields\[\d+\]\.dataSource) (FORM_DATA_SOURCE_[A-Z0-9_]+)(?![A-Za-z0-9_])/gu;
73
+ /**
74
+ * Recognises publish-lint output by the paths it starts its lines with — both
75
+ * indexed forms (`schema.fields[0]...`) and the unindexed ones the structural
76
+ * lint emits (`schema.fields fieldKey is duplicated: <key>`). Inside
77
+ * such a message only the code-bearing shape above may be rewritten; a bare or
78
+ * wrapped code arrives as a plain error message instead and is mapped whole.
79
+ */
80
+ const LINT_MESSAGE_PATTERN = /(?:^|; )(?:schema\.|descriptor\.)/u;
81
+ /**
82
+ * Shown when the backend answers with a DataSource code this package does not
83
+ * know yet — a newer core against an older client. Without it the raw code
84
+ * would reach the screen.
85
+ */
86
+ const UNKNOWN_CODE_MESSAGE = '選項來源發生問題,請稍後再試或聯絡系統管理員。';
87
+ /**
88
+ * Extracts the DataSource error code carried by a rejected request, whether it
89
+ * arrives as the bare code, a GraphQL error message, or an `Error` wrapping
90
+ * either. Returns `null` for anything that is not a DataSource failure.
91
+ */
92
+ function readFormDataSourceErrorCode(error) {
93
+ const text = typeof error === 'string'
94
+ ? error
95
+ : error instanceof Error
96
+ ? error.message
97
+ : '';
98
+ const match = ERROR_CODE_PATTERN.exec(text);
99
+ return match &&
100
+ exports.FORM_DATA_SOURCE_ERROR_CODES.includes(match[0])
101
+ ? match[0]
102
+ : null;
103
+ }
104
+ /**
105
+ * Maps a rejected request to display copy. Returns `null` only when the failure
106
+ * is not a DataSource error at all, so callers can fall back to their own
107
+ * message; an unrecognised `FORM_DATA_SOURCE_*` code still yields readable copy
108
+ * rather than leaking the code itself.
109
+ */
110
+ function readFormDataSourceErrorMessage(error) {
111
+ const code = readFormDataSourceErrorCode(error);
112
+ if (code) {
113
+ return ERROR_MESSAGES[code];
114
+ }
115
+ return readsAsFormDataSourceCode(error) ? UNKNOWN_CODE_MESSAGE : null;
116
+ }
117
+ /**
118
+ * True when the failure carries a `FORM_DATA_SOURCE_*` token, including codes
119
+ * this package does not map yet.
120
+ */
121
+ function readsAsFormDataSourceCode(error) {
122
+ const text = typeof error === 'string'
123
+ ? error
124
+ : error instanceof Error
125
+ ? error.message
126
+ : '';
127
+ return ERROR_CODE_PATTERN.test(text);
128
+ }
129
+ /**
130
+ * Rewrites a publish-lint line such as
131
+ * `schema.fields[1].dataSource FORM_DATA_SOURCE_MISSING` into readable copy
132
+ * while keeping the field path that tells the designer where to look. Lines
133
+ * without a DataSource code are returned unchanged.
134
+ */
135
+ function readFormSchemaLintMessage(error) {
136
+ // A publish failure joins several lint lines, so map every code-bearing
137
+ // occurrence and leave all prose — including author-chosen names that look like
138
+ // codes — exactly as the backend wrote it.
139
+ const mapped = error.replace(LINT_LINE_CODE_PATTERN, (_match, separator, path, code) => `${separator}${path} ${readCodeMessage(code)}`);
140
+ if (LINT_MESSAGE_PATTERN.test(error)) {
141
+ return mapped;
142
+ }
143
+ // Not lint output: the message is a bare code or wraps one (for example
144
+ // `GraphQL error: FORM_DATA_SOURCE_TIMEOUT`), so map it as a whole.
145
+ return readFormDataSourceErrorMessage(error) ?? error;
146
+ }
147
+ function readCodeMessage(code) {
148
+ return exports.FORM_DATA_SOURCE_ERROR_CODES.includes(code)
149
+ ? ERROR_MESSAGES[code]
150
+ : UNKNOWN_CODE_MESSAGE;
151
+ }
152
+ //# sourceMappingURL=form-data-source-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-data-source-errors.js","sourceRoot":"","sources":["../../../../../../libs/bpm-core-client/src/lib/form/form-data-source-errors.ts"],"names":[],"mappings":";;;AAwGA,kEAeC;AAQD,wEAQC;AAuBD,8DAiBC;AA/KD;;;;;;;GAOG;AACU,QAAA,4BAA4B,GAAG;IAC1C,oCAAoC;IACpC,kCAAkC;IAClC,qCAAqC;IACrC,0CAA0C;IAC1C,0BAA0B;IAC1B,2CAA2C;IAC3C,mCAAmC;IACnC,wCAAwC;IACxC,4CAA4C;IAC5C,uCAAuC;IACvC,mCAAmC;IACnC,0BAA0B;IAC1B,sCAAsC;IACtC,qCAAqC;IACrC,kCAAkC;IAClC,2CAA2C;CACnC,CAAC;AAKX,MAAM,cAAc,GAAsD;IACxE,kCAAkC,EAAE,cAAc;IAClD,gCAAgC,EAC9B,sBAAsB;IACxB,mCAAmC,EACjC,qBAAqB;IACvB,wCAAwC,EACtC,wBAAwB;IAC1B,wBAAwB,EAAE,oBAAoB;IAC9C,yCAAyC,EACvC,mBAAmB;IACrB,iCAAiC,EAC/B,mBAAmB;IACrB,sCAAsC,EACpC,mBAAmB;IACrB,0CAA0C,EAAE,eAAe;IAC3D,qCAAqC,EAAE,aAAa;IACpD,iCAAiC,EAAE,YAAY;IAC/C,wBAAwB,EAAE,iBAAiB;IAC3C,oCAAoC,EAClC,kBAAkB;IACpB,mCAAmC,EAAE,kBAAkB;IACvD,gCAAgC,EAC9B,sBAAsB;IACxB,yCAAyC,EAAE,WAAW;CACvD,CAAC;AAEF;;;GAGG;AACH,MAAM,kBAAkB,GACtB,+DAA+D,CAAC;AAElE;;;;;;;;;;;;;;;GAeG;AACH,MAAM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IACrD,wEAAwE;IACxE,gFAAgF;IAChF,2CAA2C;IAC3C,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAC1B,sBAAsB,EACtB,CAAC,MAAM,EAAE,SAAiB,EAAE,IAAY,EAAE,IAAY,EAAU,EAAE,CAChE,GAAG,SAAS,GAAG,IAAI,IAAI,eAAe,CAAC,IAAI,CAAC,EAAE,CACjD,CAAC;IAEF,IAAI,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACrC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,wEAAwE;IACxE,oEAAoE;IACpE,OAAO,8BAA8B,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC;AACxD,CAAC;AAED,SAAS,eAAe,CAAC,IAAY;IACnC,OAAQ,oCAAkD,CAAC,QAAQ,CAAC,IAAI,CAAC;QACvE,CAAC,CAAC,cAAc,CAAC,IAA+B,CAAC;QACjD,CAAC,CAAC,oBAAoB,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { FormDataSourceOptionFieldDefinition, FormFieldOption, FormFieldValue } from '@rytass/bpm-core-shared/form';
2
+ import { FormRendererValues } from './form-rendering';
3
+ export type FormDataSourceFieldStatus = 'IDLE' | 'WAITING_FOR_DEPENDENCIES' | 'LOADING' | 'VALID' | 'STALE' | 'INVALID' | 'UNAVAILABLE';
4
+ /**
5
+ * Merges immutable option pages while preserving the first-seen order and
6
+ * letting newer results replace labels for an existing value.
7
+ */
8
+ export declare function mergeFormDataSourceOptions(...optionLists: readonly (readonly FormFieldOption[])[]): readonly FormFieldOption[];
9
+ export declare function readSelectedFormDataSourceOptions(value: FormFieldValue | undefined, options: readonly FormFieldOption[]): readonly FormFieldOption[];
10
+ export declare function readMissingFormDataSourceOptionValues(value: FormFieldValue | undefined, options: readonly FormFieldOption[]): readonly string[];
11
+ export declare function readMissingFormDataSourceDependencies(field: FormDataSourceOptionFieldDefinition, values: FormRendererValues): readonly string[];
12
+ export declare function readFormDataSourceValueSignature(value: FormFieldValue | undefined): string;