@adminide-stack/form-builder-core 5.1.4-alpha.81 → 5.1.6-alpha.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.
- package/LICENSE +30 -21
- package/lib/config/__tests__/connectorFieldTokenResolver.test.d.ts +2 -0
- package/lib/config/__tests__/connectorFieldTokenResolver.test.d.ts.map +1 -0
- package/lib/config/cdnConfig.d.ts +17 -0
- package/lib/config/cdnConfig.d.ts.map +1 -0
- package/lib/config/cdnConfig.js +29 -0
- package/lib/config/cdnConfig.js.map +1 -0
- package/lib/config/configTypes.d.ts +220 -0
- package/lib/config/configTypes.d.ts.map +1 -0
- package/lib/config/configTypes.js +6 -0
- package/lib/config/configTypes.js.map +1 -0
- package/lib/config/connectorFieldTokenResolver.d.ts +11 -0
- package/lib/config/connectorFieldTokenResolver.d.ts.map +1 -0
- package/lib/config/connectorFieldTokenResolver.js +95 -0
- package/lib/config/connectorFieldTokenResolver.js.map +1 -0
- package/lib/config/connectorsConfig.d.ts +3 -0
- package/lib/config/connectorsConfig.d.ts.map +1 -0
- package/lib/config/connectorsConfig.js +44533 -0
- package/lib/config/connectorsConfig.js.map +1 -0
- package/lib/config/connectorsConfig2.d.ts +11 -0
- package/lib/config/connectorsConfig2.d.ts.map +1 -0
- package/lib/config/llmProviderConfig.d.ts +3 -0
- package/lib/config/llmProviderConfig.d.ts.map +1 -0
- package/lib/config/llmProviderConfig.js +457 -0
- package/lib/config/llmProviderConfig.js.map +1 -0
- package/lib/config/mcpConnectorConfig.d.ts +3 -0
- package/lib/config/mcpConnectorConfig.d.ts.map +1 -0
- package/lib/config/mcpConnectorConfig.js +961 -0
- package/lib/config/mcpConnectorConfig.js.map +1 -0
- package/lib/index.d.ts +11 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/inngest/generateFunctionCode.d.ts +1 -0
- package/lib/inngest/generateFunctionCode.d.ts.map +1 -1
- package/lib/inngest/generateFunctionCode.js +73 -4
- package/lib/inngest/generateFunctionCode.js.map +1 -1
- package/lib/utils/__tests__/deepMergeFormSteps.test.d.ts +2 -0
- package/lib/utils/__tests__/deepMergeFormSteps.test.d.ts.map +1 -0
- package/lib/utils/authMetaDataSchema.d.ts +199 -0
- package/lib/utils/authMetaDataSchema.d.ts.map +1 -0
- package/lib/utils/authMetaDataSchema.js +1601 -0
- package/lib/utils/authMetaDataSchema.js.map +1 -0
- package/lib/utils/deepMergeFormSteps.d.ts +15 -0
- package/lib/utils/deepMergeFormSteps.d.ts.map +1 -0
- package/lib/utils/deepMergeFormSteps.js +64 -0
- package/lib/utils/deepMergeFormSteps.js.map +1 -0
- package/lib/utils/schemaHelpers.d.ts +85 -0
- package/lib/utils/schemaHelpers.d.ts.map +1 -0
- package/lib/utils/schemaHelpers.js +473 -0
- package/lib/utils/schemaHelpers.js.map +1 -0
- package/package.json +3 -2
- package/CHANGELOG.md +0 -56
- package/rollup.config.mjs +0 -33
- package/src/index.ts +0 -5
- package/src/inngest/MONACO_INTEGRATION_EXAMPLE.md +0 -406
- package/src/inngest/README_AUTOCOMPLETE.md +0 -380
- package/src/inngest/generateFunctionCode.ts +0 -151
- package/src/inngest/interfaces/index.ts +0 -1
- package/src/inngest/interfaces/types.ts +0 -63
- package/src/inngest/monacoAutocompleteIntegration.ts +0 -432
- package/src/inngest/stepGenerator.ts +0 -538
- package/src/utils/json.ts +0 -50
- package/tsconfig.json +0 -14
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authMetaDataSchema.js","sources":["../../src/utils/authMetaDataSchema.ts"],"sourcesContent":[null],"names":[],"mappings":"qOAeA,MAAA,WAAU,GAAA,GAAA,IAAA,GAAoB,CAAA,KAAA,CAAA,GAAA,CAAA,CAAA,GAAA,CAAA,CAAA,IAAA,CAAA,CAAA,IAAA,EAAA,CAAA,CAAA,MAAA,CAAA,OAAA,CAAA;MAC1B,eAAY,GAAA,GAAA,IAAA;MACZ,KAAA,CAAA,WAAmB,C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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep merge preGeneratedFormSteps arrays by matching step/element ids recursively.
|
|
3
|
+
* When two steps share the same id (e.g. "credential"), their elements/children are
|
|
4
|
+
* recursively merged so that all unique template namespaces appear as siblings in the tree.
|
|
5
|
+
*
|
|
6
|
+
* This utility lives in core so it can be reused by both browser and server code.
|
|
7
|
+
*/
|
|
8
|
+
export declare function deepMergeFormSteps(existingSteps: any[], newSteps: any[]): any[];
|
|
9
|
+
/**
|
|
10
|
+
* Recursively merge element/children arrays by matching on element id.
|
|
11
|
+
* Groups with matching ids have their children merged recursively;
|
|
12
|
+
* elements with unique ids are appended.
|
|
13
|
+
*/
|
|
14
|
+
export declare function deepMergeElements(existingElements: any[], newElements: any[]): any[];
|
|
15
|
+
//# sourceMappingURL=deepMergeFormSteps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deepMergeFormSteps.d.ts","sourceRoot":"","sources":["../../src/utils/deepMergeFormSteps.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,GAAG,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,CAmB/E;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,GAAG,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,CAyBpF"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep merge preGeneratedFormSteps arrays by matching step/element ids recursively.
|
|
3
|
+
* When two steps share the same id (e.g. "credential"), their elements/children are
|
|
4
|
+
* recursively merged so that all unique template namespaces appear as siblings in the tree.
|
|
5
|
+
*
|
|
6
|
+
* This utility lives in core so it can be reused by both browser and server code.
|
|
7
|
+
*/
|
|
8
|
+
function deepMergeFormSteps(existingSteps, newSteps) {
|
|
9
|
+
const result = existingSteps.map(step => ({
|
|
10
|
+
...step
|
|
11
|
+
}));
|
|
12
|
+
for (const newStep of newSteps) {
|
|
13
|
+
const existingIndex = result.findIndex(s => s.id === newStep.id);
|
|
14
|
+
if (existingIndex >= 0) {
|
|
15
|
+
// Same step id — deep merge elements
|
|
16
|
+
const existing = result[existingIndex];
|
|
17
|
+
result[existingIndex] = {
|
|
18
|
+
...existing,
|
|
19
|
+
...newStep,
|
|
20
|
+
elements: deepMergeElements(existing.elements || [], newStep.elements || [])
|
|
21
|
+
};
|
|
22
|
+
} else {
|
|
23
|
+
result.push({
|
|
24
|
+
...newStep
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Recursively merge element/children arrays by matching on element id.
|
|
32
|
+
* Groups with matching ids have their children merged recursively;
|
|
33
|
+
* elements with unique ids are appended.
|
|
34
|
+
*/
|
|
35
|
+
function deepMergeElements(existingElements, newElements) {
|
|
36
|
+
const result = existingElements.map(el => ({
|
|
37
|
+
...el
|
|
38
|
+
}));
|
|
39
|
+
for (const newEl of newElements) {
|
|
40
|
+
const existingIndex = result.findIndex(e => e.id === newEl.id);
|
|
41
|
+
if (existingIndex >= 0) {
|
|
42
|
+
const existing = result[existingIndex];
|
|
43
|
+
if (existing.children && newEl.children) {
|
|
44
|
+
// Both have children — recursively merge
|
|
45
|
+
result[existingIndex] = {
|
|
46
|
+
...existing,
|
|
47
|
+
...newEl,
|
|
48
|
+
children: deepMergeElements(existing.children, newEl.children)
|
|
49
|
+
};
|
|
50
|
+
} else if (newEl.children) {
|
|
51
|
+
// Only new has children — use new
|
|
52
|
+
result[existingIndex] = {
|
|
53
|
+
...newEl
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
// If only existing has children or neither has, keep existing
|
|
57
|
+
} else {
|
|
58
|
+
result.push({
|
|
59
|
+
...newEl
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}export{deepMergeElements,deepMergeFormSteps};//# sourceMappingURL=deepMergeFormSteps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deepMergeFormSteps.js","sources":["../../src/utils/deepMergeFormSteps.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;AAMG;AACH,SAAA,kBAAgB,CAAA,aAAmB,EAAA,QAAe;AAqBlD,EAAA,MAAA,MAAA,GAAA,aAAA,CAAA,GAAA,CAAA,IAAA,KAAA;;;;AAIG,IAAA,MAAA,aAAA,GAAA,MAAA,CAAA,SAAA,CAAA,CAAA,IAAA,CAAA,CAAA,EAAA,KAAA,OAAA,CAAA,EAAA,CAAA;AACH,IAAA,IAAA,aAAA,IAAgB,CAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
export interface FormField {
|
|
2
|
+
type?: string;
|
|
3
|
+
title?: string;
|
|
4
|
+
required?: boolean;
|
|
5
|
+
enum?: string[];
|
|
6
|
+
enumNames?: string[];
|
|
7
|
+
enumLabels?: Array<{
|
|
8
|
+
key: string;
|
|
9
|
+
value: string;
|
|
10
|
+
}>;
|
|
11
|
+
oneOf?: Array<{
|
|
12
|
+
const: string;
|
|
13
|
+
title: string;
|
|
14
|
+
}>;
|
|
15
|
+
uniqueItems?: boolean;
|
|
16
|
+
properties?: Record<string, FormField>;
|
|
17
|
+
items?: FormField;
|
|
18
|
+
format?: string;
|
|
19
|
+
minimum?: number;
|
|
20
|
+
maximum?: number;
|
|
21
|
+
$ref?: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
discriminator?: {
|
|
24
|
+
propertyName: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export interface Definition {
|
|
28
|
+
type?: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
properties?: Record<string, any>;
|
|
31
|
+
}
|
|
32
|
+
export interface CombinedSchema {
|
|
33
|
+
formSchema?: {
|
|
34
|
+
type?: string;
|
|
35
|
+
title?: string;
|
|
36
|
+
properties?: Record<string, FormField>;
|
|
37
|
+
required?: string[];
|
|
38
|
+
$defs?: Record<string, Definition>;
|
|
39
|
+
definitions?: Record<string, Definition>;
|
|
40
|
+
};
|
|
41
|
+
uiSchema?: Record<string, any>;
|
|
42
|
+
connectionsSchema?: Record<string, any>;
|
|
43
|
+
}
|
|
44
|
+
export type ParsedSampleResult = {
|
|
45
|
+
mainNodes: any[];
|
|
46
|
+
mainMetadataNode: any | null;
|
|
47
|
+
additionalSchemas: Array<{
|
|
48
|
+
schemaId: string;
|
|
49
|
+
type: string;
|
|
50
|
+
formId: string;
|
|
51
|
+
configurationNodes: any[];
|
|
52
|
+
}>;
|
|
53
|
+
};
|
|
54
|
+
export declare const FORM_METADATA_NODE_TYPE = "form-metadata";
|
|
55
|
+
export declare enum FormType {
|
|
56
|
+
CONTRIBUTION = "Contribution",
|
|
57
|
+
DATABASE_BUILDER = "DatabaseBuilder",
|
|
58
|
+
MULTI_FORM = "Multi Form"
|
|
59
|
+
}
|
|
60
|
+
export declare enum DatabaseType {
|
|
61
|
+
POSTGRESQL = "postgresql",
|
|
62
|
+
MYSQL = "mysql",
|
|
63
|
+
MONGODB = "mongodb"
|
|
64
|
+
}
|
|
65
|
+
export declare const SCHEMA_ID_OPTIONS: {
|
|
66
|
+
Contribution: {
|
|
67
|
+
value: string;
|
|
68
|
+
label: string;
|
|
69
|
+
}[];
|
|
70
|
+
DatabaseBuilder: {
|
|
71
|
+
label: string;
|
|
72
|
+
value: string;
|
|
73
|
+
databaseType: DatabaseType;
|
|
74
|
+
}[];
|
|
75
|
+
"Multi Form": {
|
|
76
|
+
label: string;
|
|
77
|
+
value: string;
|
|
78
|
+
}[];
|
|
79
|
+
};
|
|
80
|
+
export declare const isContributionSchemaId: (schemaId: string) => boolean;
|
|
81
|
+
export declare const flattenSchemaWithUiContext: (schema: any, uiSchema?: any, prefix?: string, parentMeta?: any) => Record<string, any>;
|
|
82
|
+
export declare const flattenUiSchema: (uiSchema: any, prefix?: string) => Record<string, any>;
|
|
83
|
+
export declare const flattenSchemas: (schemas: CombinedSchema) => CombinedSchema;
|
|
84
|
+
export declare const parseSampleNodes: (sampleNodes: any[], fallbackSchemaId: string, fallbackType: string) => ParsedSampleResult;
|
|
85
|
+
//# sourceMappingURL=schemaHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemaHelpers.d.ts","sourceRoot":"","sources":["../../src/utils/schemaHelpers.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,SAAS;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,UAAU,CAAC,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnD,KAAK,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACvC,KAAK,CAAC,EAAE,SAAS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;CACN,CAAC;AAEF,eAAO,MAAM,uBAAuB,kBAAkB,CAAC;AAEvD,oBAAY,QAAQ;IAChB,YAAY,iBAAiB;IAC7B,gBAAgB,oBAAoB;IACpC,UAAU,eAAe;CAE5B;AAED,oBAAY,YAAY;IACpB,UAAU,eAAe;IACzB,KAAK,UAAU;IACf,OAAO,YAAY;CACtB;AAED,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;CAsB7B,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,UAAU,MAAM,KAAG,OAGzD,CAAC;AAgBF,eAAO,MAAM,0BAA0B,GACnC,QAAQ,GAAG,EACX,WAAW,GAAG,EACd,eAAW,EACX,aAAY,GAAQ,KACrB,MAAM,CAAC,MAAM,EAAE,GAAG,CA2UpB,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,UAAU,GAAG,EAAE,eAAW,KAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAyC9E,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,SAAS,cAAc,KAAG,cAyBxD,CAAC;AAEF,eAAO,MAAM,gBAAgB,GACzB,aAAa,GAAG,EAAE,EAClB,kBAAkB,MAAM,EACxB,cAAc,MAAM,KACrB,kBAwDF,CAAC"}
|
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
import {ContributionSchemaId}from'common';const FORM_METADATA_NODE_TYPE = 'form-metadata';
|
|
2
|
+
var FormType;
|
|
3
|
+
(function (FormType) {
|
|
4
|
+
FormType["CONTRIBUTION"] = "Contribution";
|
|
5
|
+
FormType["DATABASE_BUILDER"] = "DatabaseBuilder";
|
|
6
|
+
FormType["MULTI_FORM"] = "Multi Form";
|
|
7
|
+
// CREDENTIALS = 'Credentials',
|
|
8
|
+
})(FormType || (FormType = {}));
|
|
9
|
+
var DatabaseType;
|
|
10
|
+
(function (DatabaseType) {
|
|
11
|
+
DatabaseType["POSTGRESQL"] = "postgresql";
|
|
12
|
+
DatabaseType["MYSQL"] = "mysql";
|
|
13
|
+
DatabaseType["MONGODB"] = "mongodb";
|
|
14
|
+
})(DatabaseType || (DatabaseType = {}));
|
|
15
|
+
const SCHEMA_ID_OPTIONS = {
|
|
16
|
+
[FormType.CONTRIBUTION]: [{
|
|
17
|
+
value: ContributionSchemaId.UserRole,
|
|
18
|
+
label: 'User Role'
|
|
19
|
+
}, {
|
|
20
|
+
value: ContributionSchemaId.Permission,
|
|
21
|
+
label: 'Permission'
|
|
22
|
+
}, {
|
|
23
|
+
value: ContributionSchemaId.Configuration,
|
|
24
|
+
label: 'Configuration'
|
|
25
|
+
}, {
|
|
26
|
+
value: ContributionSchemaId.Policy,
|
|
27
|
+
label: 'Policy'
|
|
28
|
+
}, {
|
|
29
|
+
value: ContributionSchemaId.UiLayout,
|
|
30
|
+
label: 'UI Layout'
|
|
31
|
+
},
|
|
32
|
+
// Note: Secrets schema removed - use Environment Variable toggle on any element instead
|
|
33
|
+
{
|
|
34
|
+
value: 'commands',
|
|
35
|
+
label: 'Commands'
|
|
36
|
+
}, {
|
|
37
|
+
value: 'menus',
|
|
38
|
+
label: 'Menus'
|
|
39
|
+
}, {
|
|
40
|
+
value: ContributionSchemaId.SubscriptionPlan,
|
|
41
|
+
label: 'Subscription Plan'
|
|
42
|
+
}],
|
|
43
|
+
[FormType.DATABASE_BUILDER]: [{
|
|
44
|
+
label: 'PostgreSQL Database',
|
|
45
|
+
value: 'postgresql-builder',
|
|
46
|
+
databaseType: DatabaseType.POSTGRESQL
|
|
47
|
+
}, {
|
|
48
|
+
label: 'MySQL Database',
|
|
49
|
+
value: 'mysql-builder',
|
|
50
|
+
databaseType: DatabaseType.MYSQL
|
|
51
|
+
}, {
|
|
52
|
+
label: 'General Database',
|
|
53
|
+
value: 'mongodb-builder',
|
|
54
|
+
databaseType: DatabaseType.MONGODB
|
|
55
|
+
}],
|
|
56
|
+
[FormType.MULTI_FORM]: [{
|
|
57
|
+
label: 'Stepper Form',
|
|
58
|
+
value: 'stepper-form'
|
|
59
|
+
}, {
|
|
60
|
+
label: 'Form Page builder',
|
|
61
|
+
value: 'form-page-builder'
|
|
62
|
+
}]
|
|
63
|
+
// [FormType.CREDENTIALS]: [{ label: 'Credentials', value: 'credentials' }],
|
|
64
|
+
};
|
|
65
|
+
const isContributionSchemaId = schemaId => {
|
|
66
|
+
const contributionSchemaIds = SCHEMA_ID_OPTIONS[FormType.CONTRIBUTION] || [];
|
|
67
|
+
return contributionSchemaIds.some(option => option.value === schemaId);
|
|
68
|
+
};
|
|
69
|
+
const isCompositeNumberSelect = (uiSchema, path) => {
|
|
70
|
+
if (!uiSchema) return false;
|
|
71
|
+
const pathParts = path.split('.');
|
|
72
|
+
let current = uiSchema;
|
|
73
|
+
for (const part of pathParts) {
|
|
74
|
+
if (!current || !current[part]) return false;
|
|
75
|
+
current = current[part];
|
|
76
|
+
}
|
|
77
|
+
return current && current['ui:field'] === 'CompositeNumberSelectField';
|
|
78
|
+
};
|
|
79
|
+
const flattenSchemaWithUiContext = (schema, uiSchema, prefix = '', parentMeta = {}) => {
|
|
80
|
+
const result = {};
|
|
81
|
+
// Debug: Log function entry
|
|
82
|
+
console.log(`[FlattenSchemaWithUiContext] Entry:`, {
|
|
83
|
+
prefix,
|
|
84
|
+
schemaType: typeof schema,
|
|
85
|
+
isArray: Array.isArray(schema),
|
|
86
|
+
schemaKeys: schema && typeof schema === 'object' ? Object.keys(schema) : 'not an object',
|
|
87
|
+
hasProperties: !!schema?.properties,
|
|
88
|
+
schemaTypeValue: schema?.type,
|
|
89
|
+
depth: prefix ? prefix.split('.').length : 0
|
|
90
|
+
});
|
|
91
|
+
// Handle different schema types
|
|
92
|
+
if (!schema || typeof schema !== 'object') {
|
|
93
|
+
console.log(`[FlattenSchemaWithUiContext] Early return - not an object:`, {
|
|
94
|
+
schema,
|
|
95
|
+
prefix
|
|
96
|
+
});
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
// Special handling for top-level form schema
|
|
100
|
+
// Handle schemas with type: 'object' and properties, regardless of title
|
|
101
|
+
// This ensures properties are processed directly without adding 'properties.' prefix
|
|
102
|
+
const isTopLevelSchema = (schema.type === 'object' && schema.title === 'Dynamic Form' || schema.type === 'object' && schema.properties || Object.keys(schema).length === 1 && schema.properties) && schema.properties && !prefix;
|
|
103
|
+
console.log(`[FlattenSchemaWithUiContext] Checking top-level condition:`, {
|
|
104
|
+
prefix,
|
|
105
|
+
isTopLevelSchema,
|
|
106
|
+
hasType: !!schema.type,
|
|
107
|
+
hasProperties: !!schema.properties,
|
|
108
|
+
title: schema.title,
|
|
109
|
+
schemaKeys: Object.keys(schema)
|
|
110
|
+
});
|
|
111
|
+
if (isTopLevelSchema) {
|
|
112
|
+
// Extract only the required field
|
|
113
|
+
if (schema.required) {
|
|
114
|
+
result.required = schema.required;
|
|
115
|
+
}
|
|
116
|
+
// Process properties directly
|
|
117
|
+
const flattenedProperties = {};
|
|
118
|
+
Object.keys(schema.properties).forEach((stepKey, idx) => {
|
|
119
|
+
const stepValue = schema.properties[stepKey];
|
|
120
|
+
if (stepValue && typeof stepValue === 'object' && stepValue.type === 'object' && stepValue.properties) {
|
|
121
|
+
// Add .meta key for this group/step
|
|
122
|
+
const meta = {
|
|
123
|
+
title: stepValue.title || '',
|
|
124
|
+
description: stepValue.description || '',
|
|
125
|
+
type: stepValue.type || 'object',
|
|
126
|
+
position: idx
|
|
127
|
+
};
|
|
128
|
+
// Preserve custom metadata properties for configuration and secret elements
|
|
129
|
+
if ('fieldMeta' in stepValue) meta['fieldMeta'] = stepValue['fieldMeta'];
|
|
130
|
+
if ('isSecretElement' in stepValue) meta.isSecretElement = stepValue.isSecretElement;
|
|
131
|
+
if ('writeOnly' in stepValue) meta.writeOnly = stepValue.writeOnly;
|
|
132
|
+
if ('databaseField' in stepValue) meta.databaseField = stepValue.databaseField;
|
|
133
|
+
if ('columnsPerRow' in stepValue) meta.columnsPerRow = stepValue.columnsPerRow;
|
|
134
|
+
// Preserve schema element flags for elements from configuration/policy schemas
|
|
135
|
+
if ('isSchemaElement' in stepValue) meta.isSchemaElement = stepValue.isSchemaElement;
|
|
136
|
+
if ('sourceSchemaId' in stepValue) meta.sourceSchemaId = stepValue.sourceSchemaId;
|
|
137
|
+
// CRITICAL: Preserve secret/environment variable properties
|
|
138
|
+
if ('isEnvironmentVariable' in stepValue) meta.isEnvironmentVariable = stepValue.isEnvironmentVariable;
|
|
139
|
+
if ('secretType' in stepValue) meta.secretType = stepValue.secretType;
|
|
140
|
+
if ('vaultKeyName' in stepValue) meta.vaultKeyName = stepValue.vaultKeyName;
|
|
141
|
+
if ('x-env' in stepValue) meta['x-env'] = stepValue['x-env'];
|
|
142
|
+
// Log secret properties being flattened
|
|
143
|
+
if (stepValue.isEnvironmentVariable || stepValue['x-env']) {
|
|
144
|
+
console.log('[flattenSchemaWithUiContext] Step has secret props:', {
|
|
145
|
+
stepKey,
|
|
146
|
+
isEnvironmentVariable: stepValue.isEnvironmentVariable,
|
|
147
|
+
secretType: stepValue.secretType,
|
|
148
|
+
vaultKeyName: stepValue.vaultKeyName,
|
|
149
|
+
xEnv: stepValue['x-env'],
|
|
150
|
+
metaSecretProps: {
|
|
151
|
+
isEnvironmentVariable: meta.isEnvironmentVariable,
|
|
152
|
+
secretType: meta.secretType,
|
|
153
|
+
vaultKeyName: meta.vaultKeyName,
|
|
154
|
+
xEnv: meta['x-env']
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
flattenedProperties[`${stepKey}.meta`] = meta;
|
|
159
|
+
if (stepValue.required) {
|
|
160
|
+
flattenedProperties[`${stepKey}.required`] = stepValue.required;
|
|
161
|
+
}
|
|
162
|
+
// Recursively process nested properties with correct uiSchema context
|
|
163
|
+
const nestedUiSchema = uiSchema?.[stepKey];
|
|
164
|
+
console.log(`[FlattenSchema] About to recursively process ${stepKey}:`, {
|
|
165
|
+
inputProperties: stepValue.properties,
|
|
166
|
+
inputKeys: Object.keys(stepValue.properties || {}),
|
|
167
|
+
nestedUiSchemaKeys: nestedUiSchema ? Object.keys(nestedUiSchema) : 'no uiSchema',
|
|
168
|
+
prefix: stepKey
|
|
169
|
+
});
|
|
170
|
+
const nestedFlattened = flattenSchemaWithUiContext(stepValue.properties, nestedUiSchema, stepKey);
|
|
171
|
+
console.log(`[FlattenSchema] Recursive call result for ${stepKey}:`, {
|
|
172
|
+
inputKeys: Object.keys(stepValue.properties || {}),
|
|
173
|
+
outputKeys: Object.keys(nestedFlattened),
|
|
174
|
+
outputKeyCount: Object.keys(nestedFlattened).length,
|
|
175
|
+
allOutputKeys: Object.keys(nestedFlattened),
|
|
176
|
+
prefix: stepKey
|
|
177
|
+
});
|
|
178
|
+
Object.assign(flattenedProperties, nestedFlattened);
|
|
179
|
+
} else {
|
|
180
|
+
flattenedProperties[stepKey] = stepValue;
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
// Process $defs if present
|
|
184
|
+
if (schema.$defs) {
|
|
185
|
+
const flattenedDefs = {};
|
|
186
|
+
Object.keys(schema.$defs).forEach(defKey => {
|
|
187
|
+
const defValue = schema.$defs[defKey];
|
|
188
|
+
if (defValue && typeof defValue === 'object' && defValue.properties) {
|
|
189
|
+
Object.keys(defValue.properties).forEach(propKey => {
|
|
190
|
+
const propValue = defValue.properties[propKey];
|
|
191
|
+
flattenedDefs[`$defs.${defKey}.${propKey}`] = propValue;
|
|
192
|
+
});
|
|
193
|
+
} else {
|
|
194
|
+
flattenedDefs[`$defs.${defKey}`] = defValue;
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
return {
|
|
198
|
+
...result,
|
|
199
|
+
...flattenedProperties,
|
|
200
|
+
...flattenedDefs
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
...result,
|
|
205
|
+
...flattenedProperties
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
// Process each property with composite element detection
|
|
209
|
+
// This handles nested properties objects (like contributionPoint.properties.categoryName.properties...)
|
|
210
|
+
// Check if schema is a plain object where all values are objects (not arrays, not null, not primitives)
|
|
211
|
+
const isPropertiesObject = Object.keys(schema).length > 0 && Object.keys(schema).every(k => typeof schema[k] === 'object' && schema[k] !== null && !Array.isArray(schema[k]) && (schema[k].type !== undefined || schema[k].properties !== undefined || Object.keys(schema[k]).length > 0));
|
|
212
|
+
if (isPropertiesObject) {
|
|
213
|
+
console.log(`[FlattenSchema] Entering properties object processing (prefix: ${prefix}):`, {
|
|
214
|
+
schemaKeys: Object.keys(schema),
|
|
215
|
+
prefix,
|
|
216
|
+
depth: prefix ? prefix.split('.').length : 0
|
|
217
|
+
});
|
|
218
|
+
const keys = Object.keys(schema);
|
|
219
|
+
keys.forEach((key, idx) => {
|
|
220
|
+
// Skip any UI-only keys that may have leaked into the form JSON schema
|
|
221
|
+
if (key.startsWith('ui:')) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const value = schema[key];
|
|
225
|
+
const newKey = prefix ? `${prefix}.${key}` : key;
|
|
226
|
+
if (value && typeof value === 'object' && value.type === 'object' && value.properties) {
|
|
227
|
+
// Check if this is a compositeNumberSelect element
|
|
228
|
+
const isComposite = isCompositeNumberSelect(uiSchema, newKey);
|
|
229
|
+
// Debug logging for nested structure processing
|
|
230
|
+
console.log(`[FlattenSchema] Processing nested object at path: ${newKey}`, {
|
|
231
|
+
hasProperties: !!value.properties,
|
|
232
|
+
propertyKeys: Object.keys(value.properties || {}),
|
|
233
|
+
prefix,
|
|
234
|
+
depth: newKey.split('.').length
|
|
235
|
+
});
|
|
236
|
+
const meta = {
|
|
237
|
+
title: value.title || '',
|
|
238
|
+
description: value.description || '',
|
|
239
|
+
type: value.type || 'object',
|
|
240
|
+
position: idx
|
|
241
|
+
};
|
|
242
|
+
// Add composite element marker
|
|
243
|
+
if (isComposite) {
|
|
244
|
+
meta['x-composite-type'] = 'compositeNumberSelect';
|
|
245
|
+
console.log(`[FlattenSchema] ✅ Marked as composite: ${newKey}`);
|
|
246
|
+
}
|
|
247
|
+
// Preserve custom metadata properties for configuration and secret elements
|
|
248
|
+
if ('fieldMeta' in value) meta['fieldMeta'] = value['fieldMeta'];
|
|
249
|
+
if ('isSecretElement' in value) meta.isSecretElement = value.isSecretElement;
|
|
250
|
+
if ('writeOnly' in value) meta.writeOnly = value.writeOnly;
|
|
251
|
+
if ('databaseField' in value) meta.databaseField = value.databaseField;
|
|
252
|
+
if ('columnsPerRow' in value) meta.columnsPerRow = value.columnsPerRow;
|
|
253
|
+
// Preserve schema element flags for elements from configuration/policy schemas
|
|
254
|
+
if ('isSchemaElement' in value) meta.isSchemaElement = value.isSchemaElement;
|
|
255
|
+
if ('sourceSchemaId' in value) meta.sourceSchemaId = value.sourceSchemaId;
|
|
256
|
+
// CRITICAL: Preserve secret/environment variable properties
|
|
257
|
+
if ('isEnvironmentVariable' in value) meta.isEnvironmentVariable = value.isEnvironmentVariable;
|
|
258
|
+
if ('secretType' in value) meta.secretType = value.secretType;
|
|
259
|
+
if ('vaultKeyName' in value) meta.vaultKeyName = value.vaultKeyName;
|
|
260
|
+
if ('x-env' in value) meta['x-env'] = value['x-env'];
|
|
261
|
+
result[`${newKey}.meta`] = meta;
|
|
262
|
+
if (value.required) {
|
|
263
|
+
result[`${newKey}.required`] = value.required;
|
|
264
|
+
}
|
|
265
|
+
// Recursively process nested properties with correct uiSchema context
|
|
266
|
+
const nestedUiSchema = uiSchema?.[key];
|
|
267
|
+
const nestedFlattened = flattenSchemaWithUiContext(value.properties, nestedUiSchema, newKey);
|
|
268
|
+
console.log(`[FlattenSchema] Recursive result for ${newKey}:`, {
|
|
269
|
+
inputKeys: Object.keys(value.properties || {}),
|
|
270
|
+
outputKeys: Object.keys(nestedFlattened),
|
|
271
|
+
sampleOutputKeys: Object.keys(nestedFlattened).slice(0, 5)
|
|
272
|
+
});
|
|
273
|
+
Object.assign(result, nestedFlattened);
|
|
274
|
+
} else {
|
|
275
|
+
result[newKey] = value;
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
return result;
|
|
279
|
+
}
|
|
280
|
+
// Fallback processing - handles cases where schema doesn't match previous conditions
|
|
281
|
+
console.log(`[FlattenSchemaWithUiContext] Entering fallback processing (prefix: ${prefix}):`, {
|
|
282
|
+
schemaKeys: Object.keys(schema),
|
|
283
|
+
prefix,
|
|
284
|
+
depth: prefix ? prefix.split('.').length : 0,
|
|
285
|
+
schemaSample: Object.keys(schema).slice(0, 3).reduce((acc, k) => {
|
|
286
|
+
acc[k] = {
|
|
287
|
+
type: schema[k]?.type,
|
|
288
|
+
hasProperties: !!schema[k]?.properties
|
|
289
|
+
};
|
|
290
|
+
return acc;
|
|
291
|
+
}, {})
|
|
292
|
+
});
|
|
293
|
+
Object.keys(schema).forEach(key => {
|
|
294
|
+
// Skip any UI-only keys that may have leaked into the form JSON schema
|
|
295
|
+
if (key.startsWith('ui:')) {
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
const value = schema[key];
|
|
299
|
+
const newKey = prefix ? `${prefix}.${key}` : key;
|
|
300
|
+
if (value && typeof value === 'object' && value.type === 'object' && value.properties) {
|
|
301
|
+
const isComposite = isCompositeNumberSelect(uiSchema, newKey);
|
|
302
|
+
// Debug composite detection for troubleshooting (fallback section)
|
|
303
|
+
console.log(`[FlattenSchema:Fallback] Checking composite for path: ${newKey}`, {
|
|
304
|
+
isComposite,
|
|
305
|
+
hasValueProp: !!value.properties?.value,
|
|
306
|
+
hasTypeProp: !!value.properties?.type,
|
|
307
|
+
valueType: value.properties?.value?.type,
|
|
308
|
+
typeEnum: value.properties?.type?.enum,
|
|
309
|
+
uiSchemaKeys: uiSchema ? Object.keys(uiSchema) : 'no uiSchema'
|
|
310
|
+
});
|
|
311
|
+
const meta = {
|
|
312
|
+
title: value.title || '',
|
|
313
|
+
description: value.description || '',
|
|
314
|
+
type: value.type || 'object',
|
|
315
|
+
position: 0
|
|
316
|
+
};
|
|
317
|
+
if (isComposite) {
|
|
318
|
+
meta['x-composite-type'] = 'compositeNumberSelect';
|
|
319
|
+
}
|
|
320
|
+
// Preserve custom metadata properties for configuration and secret elements
|
|
321
|
+
if ('fieldMeta' in value) meta['fieldMeta'] = value['fieldMeta'];
|
|
322
|
+
if ('isSecretElement' in value) meta.isSecretElement = value.isSecretElement;
|
|
323
|
+
if ('writeOnly' in value) meta.writeOnly = value.writeOnly;
|
|
324
|
+
if ('databaseField' in value) meta.databaseField = value.databaseField;
|
|
325
|
+
if ('columnsPerRow' in value) meta.columnsPerRow = value.columnsPerRow;
|
|
326
|
+
// Preserve schema element flags for elements from configuration/policy schemas
|
|
327
|
+
if ('isSchemaElement' in value) meta.isSchemaElement = value.isSchemaElement;
|
|
328
|
+
if ('sourceSchemaId' in value) meta.sourceSchemaId = value.sourceSchemaId;
|
|
329
|
+
// CRITICAL: Preserve secret/environment variable properties
|
|
330
|
+
if ('isEnvironmentVariable' in value) meta.isEnvironmentVariable = value.isEnvironmentVariable;
|
|
331
|
+
if ('secretType' in value) meta.secretType = value.secretType;
|
|
332
|
+
if ('vaultKeyName' in value) meta.vaultKeyName = value.vaultKeyName;
|
|
333
|
+
if ('x-env' in value) meta['x-env'] = value['x-env'];
|
|
334
|
+
result[`${newKey}.meta`] = meta;
|
|
335
|
+
if (value.required) {
|
|
336
|
+
result[`${newKey}.required`] = value.required;
|
|
337
|
+
}
|
|
338
|
+
// Recursively process nested properties with correct uiSchema context
|
|
339
|
+
const nestedUiSchema = uiSchema?.[key];
|
|
340
|
+
const nestedFlattened = flattenSchemaWithUiContext(value.properties, nestedUiSchema, newKey);
|
|
341
|
+
console.log(`[FlattenSchema:Fallback] Recursive result for ${newKey}:`, {
|
|
342
|
+
inputKeys: Object.keys(value.properties || {}),
|
|
343
|
+
outputKeys: Object.keys(nestedFlattened),
|
|
344
|
+
sampleOutputKeys: Object.keys(nestedFlattened).slice(0, 5)
|
|
345
|
+
});
|
|
346
|
+
Object.assign(result, nestedFlattened);
|
|
347
|
+
} else if (value && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).length > 0) {
|
|
348
|
+
if (value.type || value.title || value.$ref) {
|
|
349
|
+
result[newKey] = value;
|
|
350
|
+
} else {
|
|
351
|
+
// Recursively process object without explicit type
|
|
352
|
+
const nestedUiSchema = uiSchema?.[key];
|
|
353
|
+
Object.assign(result, flattenSchemaWithUiContext(value, nestedUiSchema, newKey));
|
|
354
|
+
}
|
|
355
|
+
} else {
|
|
356
|
+
result[newKey] = value;
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
return result;
|
|
360
|
+
};
|
|
361
|
+
const flattenUiSchema = (uiSchema, prefix = '') => {
|
|
362
|
+
const result = {};
|
|
363
|
+
if (!uiSchema || typeof uiSchema !== 'object' || Array.isArray(uiSchema)) {
|
|
364
|
+
return result;
|
|
365
|
+
}
|
|
366
|
+
Object.keys(uiSchema).forEach(key => {
|
|
367
|
+
const value = uiSchema[key];
|
|
368
|
+
const newKey = prefix ? `${prefix}.${key}` : key;
|
|
369
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
370
|
+
// Separate UI properties from nested fields
|
|
371
|
+
const uiProperties = {};
|
|
372
|
+
const nestedFields = {};
|
|
373
|
+
Object.keys(value).forEach(subKey => {
|
|
374
|
+
if (subKey.startsWith('ui:')) {
|
|
375
|
+
uiProperties[subKey] = value[subKey];
|
|
376
|
+
} else {
|
|
377
|
+
nestedFields[subKey] = value[subKey];
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
// If this object has UI properties, store them
|
|
381
|
+
if (Object.keys(uiProperties).length > 0) {
|
|
382
|
+
result[newKey] = uiProperties;
|
|
383
|
+
}
|
|
384
|
+
// If this object has nested fields, recurse into them
|
|
385
|
+
if (Object.keys(nestedFields).length > 0) {
|
|
386
|
+
const nestedResults = flattenUiSchema(nestedFields, newKey);
|
|
387
|
+
Object.assign(result, nestedResults);
|
|
388
|
+
}
|
|
389
|
+
} else {
|
|
390
|
+
// Handle primitive values (though rare in UI schema)
|
|
391
|
+
result[newKey] = value;
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
return result;
|
|
395
|
+
};
|
|
396
|
+
const flattenSchemas = schemas => {
|
|
397
|
+
const result = {};
|
|
398
|
+
// Flatten form schema if provided, passing UI schema for composite element detection
|
|
399
|
+
if (schemas.formSchema) {
|
|
400
|
+
const flattened = flattenSchemaWithUiContext(schemas.formSchema, schemas.uiSchema);
|
|
401
|
+
// Safeguard: Remove any top-level schema keys that should not be in flattened output
|
|
402
|
+
// The flattened result should only contain dot-notation keys and 'required' array
|
|
403
|
+
if ('type' in flattened && flattened.type === 'object') {
|
|
404
|
+
delete flattened.type;
|
|
405
|
+
}
|
|
406
|
+
if ('title' in flattened && typeof flattened.title === 'string') {
|
|
407
|
+
delete flattened.title;
|
|
408
|
+
}
|
|
409
|
+
result.formSchema = flattened;
|
|
410
|
+
}
|
|
411
|
+
// Flatten UI schema if provided
|
|
412
|
+
if (schemas.uiSchema) {
|
|
413
|
+
result.uiSchema = flattenUiSchema(schemas.uiSchema);
|
|
414
|
+
}
|
|
415
|
+
return result;
|
|
416
|
+
};
|
|
417
|
+
const parseSampleNodes = (sampleNodes, fallbackSchemaId, fallbackType) => {
|
|
418
|
+
const groups = [];
|
|
419
|
+
let pendingNodes = [];
|
|
420
|
+
let currentGroup = null;
|
|
421
|
+
for (const node of sampleNodes) {
|
|
422
|
+
if (node?.type === FORM_METADATA_NODE_TYPE) {
|
|
423
|
+
if (currentGroup) {
|
|
424
|
+
groups.push(currentGroup);
|
|
425
|
+
}
|
|
426
|
+
const nodes = [node];
|
|
427
|
+
if (pendingNodes.length > 0) {
|
|
428
|
+
nodes.push(...pendingNodes);
|
|
429
|
+
pendingNodes = [];
|
|
430
|
+
}
|
|
431
|
+
currentGroup = {
|
|
432
|
+
metadataNode: node,
|
|
433
|
+
nodes
|
|
434
|
+
};
|
|
435
|
+
} else if (currentGroup) {
|
|
436
|
+
currentGroup.nodes.push(node);
|
|
437
|
+
} else {
|
|
438
|
+
pendingNodes.push(node);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
if (currentGroup) {
|
|
442
|
+
groups.push(currentGroup);
|
|
443
|
+
} else if (pendingNodes.length > 0) {
|
|
444
|
+
groups.push({
|
|
445
|
+
nodes: pendingNodes
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
const explicitMainIdx = groups.findIndex(g => g.metadataNode?.type === FORM_METADATA_NODE_TYPE && !g.metadataNode?.properties?.schemaId);
|
|
449
|
+
const mainIdx = explicitMainIdx >= 0 ? explicitMainIdx : 0;
|
|
450
|
+
const mainGroup = groups[mainIdx];
|
|
451
|
+
const mainMetadataNode = mainGroup?.metadataNode || null;
|
|
452
|
+
const mainNodes = (mainGroup?.nodes || sampleNodes).filter(n => n.type !== FORM_METADATA_NODE_TYPE);
|
|
453
|
+
const additionalSchemas = [];
|
|
454
|
+
groups.forEach((group, idx) => {
|
|
455
|
+
if (idx === mainIdx) return;
|
|
456
|
+
if (!group?.nodes || group.nodes.length === 0) return;
|
|
457
|
+
const meta = group.metadataNode?.properties || {};
|
|
458
|
+
const groupSchemaId = meta.schemaId || fallbackSchemaId;
|
|
459
|
+
const groupType = meta.type || (isContributionSchemaId(groupSchemaId) ? FormType.CONTRIBUTION : fallbackType);
|
|
460
|
+
const groupFormId = isContributionSchemaId(groupSchemaId) ? '' : meta.id || '';
|
|
461
|
+
additionalSchemas.push({
|
|
462
|
+
schemaId: groupSchemaId,
|
|
463
|
+
type: groupType,
|
|
464
|
+
formId: groupFormId,
|
|
465
|
+
configurationNodes: group.nodes
|
|
466
|
+
});
|
|
467
|
+
});
|
|
468
|
+
return {
|
|
469
|
+
mainNodes,
|
|
470
|
+
mainMetadataNode,
|
|
471
|
+
additionalSchemas
|
|
472
|
+
};
|
|
473
|
+
};export{DatabaseType,FORM_METADATA_NODE_TYPE,FormType,SCHEMA_ID_OPTIONS,flattenSchemaWithUiContext,flattenSchemas,flattenUiSchema,isContributionSchemaId,parseSampleNodes};//# sourceMappingURL=schemaHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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