gdc-common-utils-ts 2.0.18 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -1
- package/dist/claims/claims-helpers-allergy-intolerance.d.ts +8 -0
- package/dist/claims/claims-helpers-allergy-intolerance.js +30 -12
- package/dist/claims/claims-helpers-condition.d.ts +8 -0
- package/dist/claims/claims-helpers-condition.js +30 -12
- package/dist/claims/claims-helpers-consent.d.ts +4 -0
- package/dist/claims/claims-helpers-consent.js +15 -1
- package/dist/claims/claims-helpers-diagnostic-report.d.ts +4 -0
- package/dist/claims/claims-helpers-diagnostic-report.js +17 -2
- package/dist/claims/claims-helpers-medication-statement.d.ts +10 -2
- package/dist/claims/claims-helpers-medication-statement.js +32 -14
- package/dist/constants/didcomm.d.ts +22 -0
- package/dist/constants/didcomm.js +22 -0
- package/dist/constants/fhir-resource-types.d.ts +2 -0
- package/dist/constants/fhir-resource-types.js +1 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +1 -0
- package/dist/constants/lifecycle.d.ts +2 -0
- package/dist/constants/lifecycle.js +2 -0
- package/dist/constants/verifiable-credentials.d.ts +9 -0
- package/dist/constants/verifiable-credentials.js +9 -0
- package/dist/examples/bundle-didcomm-payload.d.ts +11 -0
- package/dist/examples/bundle-didcomm-payload.js +15 -0
- package/dist/examples/communication-attached-bundle-session.js +28 -27
- package/dist/examples/communication-didcomm-payload.d.ts +39 -0
- package/dist/examples/communication-didcomm-payload.js +44 -0
- package/dist/examples/consent-access.js +2 -1
- package/dist/examples/employee.d.ts +21 -0
- package/dist/examples/employee.js +21 -0
- package/dist/examples/index.d.ts +4 -0
- package/dist/examples/index.js +4 -0
- package/dist/examples/individual-controller.d.ts +27 -0
- package/dist/examples/individual-controller.js +28 -1
- package/dist/examples/inter-tenant-access-contract.js +3 -2
- package/dist/examples/ips-bundle.js +17 -16
- package/dist/examples/lifecycle.js +13 -11
- package/dist/examples/profile-manager-mem.d.ts +45 -0
- package/dist/examples/profile-manager-mem.js +30 -0
- package/dist/examples/related-person.d.ts +14 -0
- package/dist/examples/related-person.js +18 -4
- package/dist/examples/shared.d.ts +13 -3
- package/dist/examples/shared.js +14 -4
- package/dist/examples/vital-signs.js +1 -1
- package/dist/examples/wallet-mem.d.ts +38 -0
- package/dist/examples/wallet-mem.js +42 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/interfaces/IProfileOutboxRepository.d.ts +36 -0
- package/dist/interfaces/IProfileOutboxRepository.js +2 -0
- package/dist/interfaces/IWallet.d.ts +74 -0
- package/dist/interfaces/IWallet.js +2 -0
- package/dist/interfaces/IWalletQueue.d.ts +30 -0
- package/dist/interfaces/IWalletQueue.js +2 -0
- package/dist/interfaces/index.d.ts +8 -0
- package/dist/interfaces/index.js +8 -0
- package/dist/models/authority-resolution.d.ts +56 -0
- package/dist/models/authority-resolution.js +2 -0
- package/dist/models/bundle-editor-types.d.ts +89 -0
- package/dist/models/bundle-editor-types.js +45 -0
- package/dist/models/bundle.d.ts +5 -0
- package/dist/models/communication-attached-bundle-session.d.ts +195 -0
- package/dist/models/communication-attached-bundle-session.js +36 -0
- package/dist/models/confidential-storage.d.ts +2 -1
- package/dist/models/consent-rule.d.ts +11 -1
- package/dist/models/consent-rule.js +9 -1
- package/dist/models/index.d.ts +5 -0
- package/dist/models/index.js +5 -0
- package/dist/models/individual-onboarding.d.ts +18 -0
- package/dist/models/interoperable-claims/allergy-intolerance-claims.d.ts +12 -1
- package/dist/models/interoperable-claims/allergy-intolerance-claims.js +12 -1
- package/dist/models/interoperable-claims/condition-claims.d.ts +12 -1
- package/dist/models/interoperable-claims/condition-claims.js +12 -1
- package/dist/models/interoperable-claims/diagnostic-report-claims.d.ts +14 -4
- package/dist/models/interoperable-claims/diagnostic-report-claims.js +13 -3
- package/dist/models/interoperable-claims/document-reference-claims.d.ts +1 -0
- package/dist/models/interoperable-claims/document-reference-claims.js +3 -0
- package/dist/models/interoperable-claims/medication-statement-claims.d.ts +17 -0
- package/dist/models/interoperable-claims/medication-statement-claims.js +17 -0
- package/dist/models/profile-manager.d.ts +85 -0
- package/dist/models/profile-manager.js +2 -0
- package/dist/models/wallet.d.ts +59 -0
- package/dist/models/wallet.js +22 -0
- package/dist/utils/allergy-intolerance-entry-editor.d.ts +51 -0
- package/dist/utils/allergy-intolerance-entry-editor.js +55 -0
- package/dist/utils/authority-resolution.d.ts +37 -0
- package/dist/utils/authority-resolution.js +112 -0
- package/dist/utils/backend-message-manager-mem.d.ts +78 -0
- package/dist/utils/backend-message-manager-mem.js +238 -0
- package/dist/utils/bundle-didcomm-payload.d.ts +29 -0
- package/dist/utils/bundle-didcomm-payload.js +49 -0
- package/dist/utils/bundle-document-builder.d.ts +1 -0
- package/dist/utils/bundle-document-builder.js +134 -14
- package/dist/utils/bundle-editor-core.d.ts +181 -0
- package/dist/utils/bundle-editor-core.js +467 -0
- package/dist/utils/bundle-editor-helpers.d.ts +53 -0
- package/dist/utils/bundle-editor-helpers.js +146 -0
- package/dist/utils/bundle-editor-registry.d.ts +6 -0
- package/dist/utils/bundle-editor-registry.js +14 -0
- package/dist/utils/bundle-editor.d.ts +21 -722
- package/dist/utils/bundle-editor.js +21 -1601
- package/dist/utils/bundle-entry-editor.d.ts +96 -0
- package/dist/utils/bundle-entry-editor.js +305 -0
- package/dist/utils/bundle-query.d.ts +1 -0
- package/dist/utils/bundle-query.js +12 -3
- package/dist/utils/bundle-reader.d.ts +48 -0
- package/dist/utils/bundle-reader.js +175 -1
- package/dist/utils/care-plan-entry-editor.d.ts +43 -0
- package/dist/utils/care-plan-entry-editor.js +47 -0
- package/dist/utils/client-assertion.d.ts +38 -0
- package/dist/utils/client-assertion.js +113 -0
- package/dist/utils/clinical-impression-entry-editor.d.ts +43 -0
- package/dist/utils/clinical-impression-entry-editor.js +47 -0
- package/dist/utils/clinical-resource-entry-editor.d.ts +123 -0
- package/dist/utils/clinical-resource-entry-editor.js +296 -0
- package/dist/utils/communication-attached-bundle-session-helpers.d.ts +54 -0
- package/dist/utils/communication-attached-bundle-session-helpers.js +519 -0
- package/dist/utils/communication-attached-bundle-session.d.ts +87 -304
- package/dist/utils/communication-attached-bundle-session.js +175 -841
- package/dist/utils/communication-consent-access-editor.d.ts +85 -0
- package/dist/utils/communication-consent-access-editor.js +244 -0
- package/dist/utils/communication-didcomm-payload.d.ts +38 -0
- package/dist/utils/communication-didcomm-payload.js +85 -0
- package/dist/utils/communication-document-reference.d.ts +23 -0
- package/dist/utils/communication-document-reference.js +89 -0
- package/dist/utils/communication-editor.d.ts +53 -0
- package/dist/utils/communication-editor.js +97 -0
- package/dist/utils/condition-entry-editor.d.ts +30 -0
- package/dist/utils/condition-entry-editor.js +34 -0
- package/dist/utils/consent-claim-helpers.d.ts +4 -0
- package/dist/utils/consent-claim-helpers.js +15 -1
- package/dist/utils/coverage-entry-editor.d.ts +51 -0
- package/dist/utils/coverage-entry-editor.js +55 -0
- package/dist/utils/device-entry-editor.d.ts +59 -0
- package/dist/utils/device-entry-editor.js +63 -0
- package/dist/utils/device-use-statement-entry-editor.d.ts +43 -0
- package/dist/utils/device-use-statement-entry-editor.js +47 -0
- package/dist/utils/diagnostic-report-entry-editor.d.ts +74 -0
- package/dist/utils/diagnostic-report-entry-editor.js +136 -0
- package/dist/utils/did.d.ts +8 -0
- package/dist/utils/did.js +22 -0
- package/dist/utils/document-reference-entry-editor.d.ts +62 -0
- package/dist/utils/document-reference-entry-editor.js +66 -0
- package/dist/utils/employee-entry-editor.d.ts +36 -0
- package/dist/utils/employee-entry-editor.js +88 -0
- package/dist/utils/employee.d.ts +1 -0
- package/dist/utils/employee.js +2 -1
- package/dist/utils/encounter-entry-editor.d.ts +51 -0
- package/dist/utils/encounter-entry-editor.js +55 -0
- package/dist/utils/flag-entry-editor.d.ts +47 -0
- package/dist/utils/flag-entry-editor.js +51 -0
- package/dist/utils/immunization-entry-editor.d.ts +87 -0
- package/dist/utils/immunization-entry-editor.js +169 -0
- package/dist/utils/index.d.ts +15 -0
- package/dist/utils/index.js +15 -0
- package/dist/utils/individual-onboarding-acceptance-credential.d.ts +35 -0
- package/dist/utils/individual-onboarding-acceptance-credential.js +55 -0
- package/dist/utils/individual-smart.d.ts +59 -0
- package/dist/utils/individual-smart.js +135 -0
- package/dist/utils/medication-statement-entry-editor.d.ts +90 -0
- package/dist/utils/medication-statement-entry-editor.js +94 -0
- package/dist/utils/observation-component-entry-editor.d.ts +57 -0
- package/dist/utils/observation-component-entry-editor.js +105 -0
- package/dist/utils/observation-entry-editor.d.ts +29 -0
- package/dist/utils/observation-entry-editor.js +68 -0
- package/dist/utils/procedure-entry-editor.d.ts +71 -0
- package/dist/utils/procedure-entry-editor.js +75 -0
- package/dist/utils/professional-smart.d.ts +87 -0
- package/dist/utils/professional-smart.js +118 -4
- package/dist/utils/profile-manager-mem.d.ts +69 -0
- package/dist/utils/profile-manager-mem.js +79 -0
- package/dist/utils/profile-outbox-memory-repository.d.ts +34 -0
- package/dist/utils/profile-outbox-memory-repository.js +57 -0
- package/dist/utils/same-as.d.ts +40 -0
- package/dist/utils/same-as.js +72 -0
- package/dist/utils/unified-health-id.d.ts +51 -0
- package/dist/utils/unified-health-id.js +92 -0
- package/dist/utils/vital-sign-day-batch.d.ts +25 -0
- package/dist/utils/vital-sign-day-batch.js +115 -0
- package/dist/utils/vital-sign-entry-editor.d.ts +61 -0
- package/dist/utils/vital-sign-entry-editor.js +152 -0
- package/dist/utils/wallet-mem.d.ts +93 -0
- package/dist/utils/wallet-mem.js +277 -0
- package/dist/utils/wallet-memory-queue.d.ts +32 -0
- package/dist/utils/wallet-memory-queue.js +82 -0
- package/package.json +2 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type BundleRequest } from '../models/bundle';
|
|
2
|
+
import { type BundleOperation } from '../models/bundle-editor-types';
|
|
3
|
+
export declare function cloneEntry<T>(value: T): T;
|
|
4
|
+
/** Clones one claim value while preserving simple arrays used by flat claims. */
|
|
5
|
+
export declare function cloneClaimValue<T>(value: T): T;
|
|
6
|
+
/**
|
|
7
|
+
* Trims one candidate identifier-like value and returns `undefined` when it is
|
|
8
|
+
* empty or absent.
|
|
9
|
+
*
|
|
10
|
+
* Use this before writing ids, references, `fullUrl`, or flat-claim scalars so
|
|
11
|
+
* every editor follows the same blank-value rule.
|
|
12
|
+
*/
|
|
13
|
+
export declare function normalizeOptionalIdentifier(value: unknown): string | undefined;
|
|
14
|
+
/** Returns one canonical `urn:uuid:*` identifier for new entry/resource drafts. */
|
|
15
|
+
export declare function createCanonicalIdentifierUrn(): string;
|
|
16
|
+
/**
|
|
17
|
+
* Maps the editor's high-level business operation to the low-level request
|
|
18
|
+
* method stored in staged bundle entries.
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveRequestMethodForOperation(operation: BundleOperation): BundleRequest['method'];
|
|
21
|
+
/**
|
|
22
|
+
* Resolves the legacy entry `type` string used by employee-oriented batch flows.
|
|
23
|
+
*
|
|
24
|
+
* This is not the same concept as `resource.resourceType`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveEntryTypeForOperation(operation: BundleOperation): string;
|
|
27
|
+
/**
|
|
28
|
+
* Builds the generic entry `type` string for non-employee resource drafts.
|
|
29
|
+
*
|
|
30
|
+
* This is one bundle-internal classification token, not a FHIR field.
|
|
31
|
+
*/
|
|
32
|
+
export declare function inferGenericEntryType(resourceType: string, operation: BundleOperation): string;
|
|
33
|
+
/**
|
|
34
|
+
* Resolves which flat-claims key stores the CSV of linked/contained resource
|
|
35
|
+
* references for one parent resource type.
|
|
36
|
+
*/
|
|
37
|
+
export declare function resolveContainedReferenceListClaimKey(resourceType: string): string;
|
|
38
|
+
/** Returns the internal visibility-control claim that marks one resource as contained. */
|
|
39
|
+
export declare function resolveContainedFlagClaimKey(resourceType: string): string;
|
|
40
|
+
/** Returns the internal parent-reference claim for one contained child resource. */
|
|
41
|
+
export declare function resolveContainedParentReferenceClaimKey(resourceType: string): string;
|
|
42
|
+
/**
|
|
43
|
+
* Normalizes one linked-resource reference into both:
|
|
44
|
+
* - `identifier`: the entry-local id part
|
|
45
|
+
* - `reference`: the canonical `ResourceType/<id>` string
|
|
46
|
+
*
|
|
47
|
+
* This lets the editors accept either a bare id or a full FHIR-style reference
|
|
48
|
+
* while keeping one normalized shape internally.
|
|
49
|
+
*/
|
|
50
|
+
export declare function normalizeContainedReference(resourceType: string, referenceOrIdentifier: string): {
|
|
51
|
+
identifier: string;
|
|
52
|
+
reference: string;
|
|
53
|
+
};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File discipline note:
|
|
3
|
+
* - Read `ARCHITECTURE.md` and `CONTRIBUTING.md` before changing this module.
|
|
4
|
+
* - Keep only reusable pure helper logic here.
|
|
5
|
+
* - Do not move entry-specific orchestration back into this file; that belongs
|
|
6
|
+
* in the editor classes.
|
|
7
|
+
*/
|
|
8
|
+
import { ResourceTypesFhirR4 } from '../constants/fhir-resource-types.js';
|
|
9
|
+
import { AllergyIntoleranceClaim, } from '../models/interoperable-claims/allergy-intolerance-claims.js';
|
|
10
|
+
import { ConditionClaim } from '../models/interoperable-claims/condition-claims.js';
|
|
11
|
+
import { DiagnosticReportClaim } from '../models/interoperable-claims/diagnostic-report-claims.js';
|
|
12
|
+
import { MedicationStatementClaim } from '../models/interoperable-claims/medication-statement-claims.js';
|
|
13
|
+
import { ClaimConsent } from '../models/consent-rule.js';
|
|
14
|
+
import { BundleEditableResourceTypes, } from '../models/bundle-editor-types.js';
|
|
15
|
+
import { EmployeeBatchEntryTypes, EmployeeBundleMethods, EmployeeBundleOperations, } from './employee.js';
|
|
16
|
+
export function cloneEntry(value) {
|
|
17
|
+
return JSON.parse(JSON.stringify(value));
|
|
18
|
+
}
|
|
19
|
+
/** Clones one claim value while preserving simple arrays used by flat claims. */
|
|
20
|
+
export function cloneClaimValue(value) {
|
|
21
|
+
if (Array.isArray(value)) {
|
|
22
|
+
return [...value];
|
|
23
|
+
}
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Trims one candidate identifier-like value and returns `undefined` when it is
|
|
28
|
+
* empty or absent.
|
|
29
|
+
*
|
|
30
|
+
* Use this before writing ids, references, `fullUrl`, or flat-claim scalars so
|
|
31
|
+
* every editor follows the same blank-value rule.
|
|
32
|
+
*/
|
|
33
|
+
export function normalizeOptionalIdentifier(value) {
|
|
34
|
+
if (value === undefined || value === null) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
const normalized = String(value).trim();
|
|
38
|
+
return normalized ? normalized : undefined;
|
|
39
|
+
}
|
|
40
|
+
/** Returns one canonical `urn:uuid:*` identifier for new entry/resource drafts. */
|
|
41
|
+
export function createCanonicalIdentifierUrn() {
|
|
42
|
+
const cryptoLike = globalThis;
|
|
43
|
+
const uuid = typeof cryptoLike.crypto?.randomUUID === 'function'
|
|
44
|
+
? cryptoLike.crypto.randomUUID()
|
|
45
|
+
: `resource-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
46
|
+
return `urn:uuid:${uuid}`;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Maps the editor's high-level business operation to the low-level request
|
|
50
|
+
* method stored in staged bundle entries.
|
|
51
|
+
*/
|
|
52
|
+
export function resolveRequestMethodForOperation(operation) {
|
|
53
|
+
switch (operation) {
|
|
54
|
+
case EmployeeBundleOperations.disable:
|
|
55
|
+
return EmployeeBundleMethods.disable;
|
|
56
|
+
case EmployeeBundleOperations.search:
|
|
57
|
+
case EmployeeBundleOperations.create:
|
|
58
|
+
case EmployeeBundleOperations.purge:
|
|
59
|
+
default:
|
|
60
|
+
return EmployeeBundleMethods.create;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Resolves the legacy entry `type` string used by employee-oriented batch flows.
|
|
65
|
+
*
|
|
66
|
+
* This is not the same concept as `resource.resourceType`.
|
|
67
|
+
*/
|
|
68
|
+
export function resolveEntryTypeForOperation(operation) {
|
|
69
|
+
switch (operation) {
|
|
70
|
+
case EmployeeBundleOperations.search:
|
|
71
|
+
return EmployeeBatchEntryTypes.search;
|
|
72
|
+
case EmployeeBundleOperations.disable:
|
|
73
|
+
return EmployeeBatchEntryTypes.disable;
|
|
74
|
+
case EmployeeBundleOperations.purge:
|
|
75
|
+
return EmployeeBatchEntryTypes.purge;
|
|
76
|
+
case EmployeeBundleOperations.create:
|
|
77
|
+
default:
|
|
78
|
+
return EmployeeBatchEntryTypes.create;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Builds the generic entry `type` string for non-employee resource drafts.
|
|
83
|
+
*
|
|
84
|
+
* This is one bundle-internal classification token, not a FHIR field.
|
|
85
|
+
*/
|
|
86
|
+
export function inferGenericEntryType(resourceType, operation) {
|
|
87
|
+
const normalizedResourceType = String(resourceType || '').trim();
|
|
88
|
+
if (normalizedResourceType === BundleEditableResourceTypes.employee) {
|
|
89
|
+
return resolveEntryTypeForOperation(operation);
|
|
90
|
+
}
|
|
91
|
+
return `${normalizedResourceType}-${operation}-request-v1.0`;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Resolves which flat-claims key stores the CSV of linked/contained resource
|
|
95
|
+
* references for one parent resource type.
|
|
96
|
+
*/
|
|
97
|
+
export function resolveContainedReferenceListClaimKey(resourceType) {
|
|
98
|
+
switch (resourceType) {
|
|
99
|
+
case ResourceTypesFhirR4.AllergyIntolerance:
|
|
100
|
+
return AllergyIntoleranceClaim.ContainedReferenceList;
|
|
101
|
+
case ResourceTypesFhirR4.Condition:
|
|
102
|
+
return ConditionClaim.ContainedReferenceList;
|
|
103
|
+
case ResourceTypesFhirR4.MedicationStatement:
|
|
104
|
+
return MedicationStatementClaim.ContainedReferenceList;
|
|
105
|
+
case ResourceTypesFhirR4.DiagnosticReport:
|
|
106
|
+
return DiagnosticReportClaim.ContainedReferenceList;
|
|
107
|
+
case ResourceTypesFhirR4.Consent:
|
|
108
|
+
return ClaimConsent.containedReferenceList;
|
|
109
|
+
default:
|
|
110
|
+
return '';
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/** Returns the internal visibility-control claim that marks one resource as contained. */
|
|
114
|
+
export function resolveContainedFlagClaimKey(resourceType) {
|
|
115
|
+
return `${resourceType}.is-contained`;
|
|
116
|
+
}
|
|
117
|
+
/** Returns the internal parent-reference claim for one contained child resource. */
|
|
118
|
+
export function resolveContainedParentReferenceClaimKey(resourceType) {
|
|
119
|
+
return `${resourceType}.contained-parent-reference`;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Normalizes one linked-resource reference into both:
|
|
123
|
+
* - `identifier`: the entry-local id part
|
|
124
|
+
* - `reference`: the canonical `ResourceType/<id>` string
|
|
125
|
+
*
|
|
126
|
+
* This lets the editors accept either a bare id or a full FHIR-style reference
|
|
127
|
+
* while keeping one normalized shape internally.
|
|
128
|
+
*/
|
|
129
|
+
export function normalizeContainedReference(resourceType, referenceOrIdentifier) {
|
|
130
|
+
const normalizedValue = normalizeOptionalIdentifier(referenceOrIdentifier);
|
|
131
|
+
if (!normalizedValue) {
|
|
132
|
+
return { identifier: '', reference: '' };
|
|
133
|
+
}
|
|
134
|
+
const slashIndex = normalizedValue.indexOf('/');
|
|
135
|
+
if (slashIndex > 0) {
|
|
136
|
+
const identifier = normalizedValue.slice(slashIndex + 1).trim();
|
|
137
|
+
return {
|
|
138
|
+
identifier,
|
|
139
|
+
reference: `${String(resourceType || '').trim() || normalizedValue.slice(0, slashIndex).trim()}/${identifier}`,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
identifier: normalizedValue,
|
|
144
|
+
reference: `${String(resourceType || '').trim()}/${normalizedValue}`,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BundleEditor } from './bundle-editor-core';
|
|
2
|
+
import type { BundleEntryEditor } from './bundle-entry-editor';
|
|
3
|
+
export type BundleEntryEditorConstructor<T extends BundleEntryEditor = BundleEntryEditor> = new (bundleEditor: BundleEditor, entryIndex: number) => T;
|
|
4
|
+
export declare function registerBundleEntryEditor(resourceType: string, ctor: BundleEntryEditorConstructor): void;
|
|
5
|
+
export declare function getBundleEntryEditorConstructor(resourceType: string): BundleEntryEditorConstructor | undefined;
|
|
6
|
+
export declare function createRegisteredBundleEntryEditor<T extends BundleEntryEditor>(resourceType: string, bundleEditor: BundleEditor, entryIndex: number): T;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const bundleEntryEditorConstructors = new Map();
|
|
2
|
+
export function registerBundleEntryEditor(resourceType, ctor) {
|
|
3
|
+
bundleEntryEditorConstructors.set(String(resourceType || '').trim(), ctor);
|
|
4
|
+
}
|
|
5
|
+
export function getBundleEntryEditorConstructor(resourceType) {
|
|
6
|
+
return bundleEntryEditorConstructors.get(String(resourceType || '').trim());
|
|
7
|
+
}
|
|
8
|
+
export function createRegisteredBundleEntryEditor(resourceType, bundleEditor, entryIndex) {
|
|
9
|
+
const ctor = getBundleEntryEditorConstructor(resourceType);
|
|
10
|
+
if (!ctor) {
|
|
11
|
+
throw new Error('BundleEntryEditor has not registered a constructor for resource type: ' + String(resourceType || '').trim());
|
|
12
|
+
}
|
|
13
|
+
return new ctor(bundleEditor, entryIndex);
|
|
14
|
+
}
|