@lwc-bolts/sf2ts 0.0.5 → 1.0.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.md +7 -0
- package/README.md +285 -0
- package/dist/apex/apexdoc.d.ts +19 -0
- package/dist/apex/apexdoc.js +79 -0
- package/dist/apex/file.d.ts +37 -0
- package/dist/apex/file.js +623 -0
- package/dist/apex/library.config.d.ts +23 -0
- package/dist/apex/library.config.js +17 -0
- package/dist/apex/library.d.ts +54 -0
- package/dist/apex/library.generated.d.ts +2 -0
- package/dist/apex/library.generated.js +215 -0
- package/dist/apex/library.js +47 -0
- package/dist/apex/namespace.d.ts +32 -0
- package/dist/apex/namespace.js +41 -0
- package/dist/apex/resolution.d.ts +77 -0
- package/dist/apex/resolution.js +306 -0
- package/dist/apex/sobjects.d.ts +45 -0
- package/dist/apex/sobjects.js +141 -0
- package/dist/context.d.ts +16 -0
- package/dist/context.js +28 -0
- package/dist/converters/apex-class.d.ts +7 -0
- package/dist/converters/apex-class.js +23 -0
- package/dist/converters/content-asset.d.ts +3 -0
- package/dist/converters/content-asset.js +20 -0
- package/dist/converters/custom-field.d.ts +3 -0
- package/dist/converters/custom-field.js +107 -0
- package/dist/converters/custom-label.d.ts +10 -0
- package/dist/converters/custom-label.js +36 -0
- package/dist/converters/custom-labels.d.ts +3 -0
- package/dist/converters/custom-labels.js +10 -0
- package/dist/converters/custom-object.d.ts +3 -0
- package/dist/converters/custom-object.js +37 -0
- package/dist/converters/custom-permission.d.ts +3 -0
- package/dist/converters/custom-permission.js +21 -0
- package/dist/converters/lightning-component-bundle.d.ts +7 -0
- package/dist/converters/lightning-component-bundle.js +31 -0
- package/dist/converters/lightning-message-channel.d.ts +10 -0
- package/dist/converters/lightning-message-channel.js +39 -0
- package/dist/converters/registry.d.ts +22 -0
- package/dist/converters/registry.js +18 -0
- package/dist/converters/static-resource.d.ts +3 -0
- package/dist/converters/static-resource.js +20 -0
- package/dist/diagnostics.d.ts +5 -0
- package/dist/diagnostics.js +18 -0
- package/dist/identifiers.d.ts +12 -0
- package/dist/identifiers.js +19 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +47 -0
- package/dist/jsdoc.d.ts +14 -0
- package/dist/jsdoc.js +28 -0
- package/dist/lightning-component-bundle/component-source.d.ts +6 -0
- package/dist/lightning-component-bundle/component-source.js +21 -0
- package/dist/lightning-component-bundle/metadata.d.ts +36 -0
- package/dist/lightning-component-bundle/metadata.js +93 -0
- package/dist/lightning-component-bundle/templates/ast.d.ts +47 -0
- package/dist/lightning-component-bundle/templates/ast.js +46 -0
- package/dist/lightning-component-bundle/templates/base-components.d.ts +6 -0
- package/dist/lightning-component-bundle/templates/base-components.js +17 -0
- package/dist/lightning-component-bundle/templates/declarations.d.ts +30 -0
- package/dist/lightning-component-bundle/templates/declarations.js +82 -0
- package/dist/lightning-component-bundle/templates/expressions.d.ts +16 -0
- package/dist/lightning-component-bundle/templates/expressions.js +33 -0
- package/dist/lightning-component-bundle/templates/helpers.d.ts +10 -0
- package/dist/lightning-component-bundle/templates/helpers.js +47 -0
- package/dist/lightning-component-bundle/templates/slots.d.ts +24 -0
- package/dist/lightning-component-bundle/templates/slots.js +78 -0
- package/dist/lightning-component-bundle/templates/source.d.ts +36 -0
- package/dist/lightning-component-bundle/templates/source.js +81 -0
- package/dist/lightning-component-bundle/templates/tags.d.ts +41 -0
- package/dist/lightning-component-bundle/templates/tags.js +36 -0
- package/dist/lightning-component-bundle/templates/template.d.ts +53 -0
- package/dist/lightning-component-bundle/templates/template.js +518 -0
- package/dist/lightning-component-bundle/templates/writer.d.ts +9 -0
- package/dist/lightning-component-bundle/templates/writer.js +32 -0
- package/dist/module-declaration.d.ts +27 -0
- package/dist/module-declaration.js +28 -0
- package/dist/names.d.ts +39 -0
- package/dist/names.js +67 -0
- package/dist/text-builder.d.ts +34 -0
- package/dist/text-builder.js +46 -0
- package/dist/types.d.ts +128 -0
- package/dist/types.js +3 -0
- package/dist/xml.d.ts +32 -0
- package/dist/xml.js +80 -0
- package/package.json +37 -26
- package/README.MD +0 -5
- package/lib/converts/_index.mjs +0 -8
- package/lib/converts/apex-class.mjs +0 -469
- package/lib/converts/content-asset.mjs +0 -48
- package/lib/converts/custom-field.mjs +0 -63
- package/lib/converts/custom-label.mjs +0 -61
- package/lib/converts/custom-labels.mjs +0 -34
- package/lib/converts/custom-object.mjs +0 -51
- package/lib/converts/custom-permission.mjs +0 -51
- package/lib/converts/static-resource.mjs +0 -56
- package/lib/index.mjs +0 -51
- package/lib/util.mjs +0 -68
- package/lib-cjs/bundle.cjs +0 -962
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/** @import { Component, ConvertedComponent } from "../index.mjs" */
|
|
2
|
-
import { parseString } from "xml2js";
|
|
3
|
-
import { PositionAwareTextBuilder } from "../util.mjs";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
* @param {Component} component
|
|
8
|
-
* @returns {ConvertedComponent}
|
|
9
|
-
*/
|
|
10
|
-
export function CustomObject(component) {
|
|
11
|
-
// generate d.ts
|
|
12
|
-
/** @type {any} */
|
|
13
|
-
let obj;
|
|
14
|
-
parseString(component.content, (error, result) => {
|
|
15
|
-
if (error) {
|
|
16
|
-
throw error;
|
|
17
|
-
}
|
|
18
|
-
obj = result;
|
|
19
|
-
});
|
|
20
|
-
const objectName = component.path.split("/").pop()?.split(".")[0];
|
|
21
|
-
if (!objectName) {
|
|
22
|
-
throw new Error("Unable to find Object Name");
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const namePos = component.content.indexOf("<label>") + "<label>".length;
|
|
26
|
-
const namePosEnd = component.content.indexOf("</label>");
|
|
27
|
-
|
|
28
|
-
const builder = new PositionAwareTextBuilder();
|
|
29
|
-
builder.addText(`declare module `);
|
|
30
|
-
builder.addText(`"@salesforce/schema/${objectName}"`, namePos, namePosEnd);
|
|
31
|
-
builder.addText(
|
|
32
|
-
` {
|
|
33
|
-
/**
|
|
34
|
-
* @description ${obj.CustomObject.description}
|
|
35
|
-
*/
|
|
36
|
-
const `
|
|
37
|
-
);
|
|
38
|
-
builder.addText(`${objectName}`, namePos, namePosEnd);
|
|
39
|
-
builder.addText(
|
|
40
|
-
`: {
|
|
41
|
-
objectApiName: '${objectName}';
|
|
42
|
-
}
|
|
43
|
-
export default ${objectName};
|
|
44
|
-
}`
|
|
45
|
-
);
|
|
46
|
-
return {
|
|
47
|
-
declarationContent: builder.build(),
|
|
48
|
-
mapData: builder.getMappings(),
|
|
49
|
-
...component,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/** @import { Component, ConvertedComponent } from "../index.mjs" */
|
|
2
|
-
import { parseString } from "xml2js";
|
|
3
|
-
import { PositionAwareTextBuilder } from "../util.mjs";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
* @param {Component} component
|
|
8
|
-
* @returns {ConvertedComponent}
|
|
9
|
-
*/
|
|
10
|
-
export function CustomPermission(component) {
|
|
11
|
-
/** @type {any} */
|
|
12
|
-
let perm;
|
|
13
|
-
parseString(component.content, (error, result) => {
|
|
14
|
-
if (error) {
|
|
15
|
-
throw error;
|
|
16
|
-
}
|
|
17
|
-
perm = result;
|
|
18
|
-
});
|
|
19
|
-
const permName = component.path.split("/").pop()?.split(".")[0];
|
|
20
|
-
const namePosStart = component.content.indexOf("<label>") + "<label>".length;
|
|
21
|
-
const namePosEnd = component.content.indexOf("</label>");
|
|
22
|
-
|
|
23
|
-
const builder = new PositionAwareTextBuilder();
|
|
24
|
-
builder.addText("declare module ");
|
|
25
|
-
builder.addText(
|
|
26
|
-
`"@salesforce/customPermission/${permName}"`,
|
|
27
|
-
namePosStart,
|
|
28
|
-
namePosEnd
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
builder.addText(
|
|
32
|
-
` {
|
|
33
|
-
/**
|
|
34
|
-
* ${perm.CustomPermission.label}
|
|
35
|
-
*
|
|
36
|
-
* @description ${perm.CustomPermission.description}
|
|
37
|
-
*/
|
|
38
|
-
const `
|
|
39
|
-
);
|
|
40
|
-
builder.addText(`has${permName}`, namePosStart, namePosEnd);
|
|
41
|
-
builder.addText(
|
|
42
|
-
`:boolean;
|
|
43
|
-
export default has${permName};
|
|
44
|
-
}`
|
|
45
|
-
);
|
|
46
|
-
return {
|
|
47
|
-
declarationContent: builder.build(),
|
|
48
|
-
mapData: builder.getMappings(),
|
|
49
|
-
...component,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/** @import { Component, ConvertedComponent } from "../index.mjs" */
|
|
2
|
-
import { parseString } from "xml2js";
|
|
3
|
-
import { PositionAwareTextBuilder } from "../util.mjs";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
* @param {Component} component
|
|
8
|
-
* @returns {ConvertedComponent}
|
|
9
|
-
*/
|
|
10
|
-
export function StaticResource(component) {
|
|
11
|
-
// generate d.ts
|
|
12
|
-
/** @type {any} */
|
|
13
|
-
let resource;
|
|
14
|
-
parseString(component.content, (error, result) => {
|
|
15
|
-
if (error) {
|
|
16
|
-
throw error;
|
|
17
|
-
}
|
|
18
|
-
resource = result;
|
|
19
|
-
});
|
|
20
|
-
const resourceName = component.path.split("/").pop()?.split(".")[0];
|
|
21
|
-
const namePosStart =
|
|
22
|
-
component.content.indexOf("<description>") + "<description>".length;
|
|
23
|
-
const namePosEnd = component.content.indexOf("</description>");
|
|
24
|
-
|
|
25
|
-
const builder = new PositionAwareTextBuilder();
|
|
26
|
-
|
|
27
|
-
builder.addText("declare module ");
|
|
28
|
-
|
|
29
|
-
builder.addText(
|
|
30
|
-
`"@salesforce/resourceUrl/${resourceName}"`,
|
|
31
|
-
namePosStart,
|
|
32
|
-
namePosEnd
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
builder.addText(
|
|
36
|
-
` {
|
|
37
|
-
/**
|
|
38
|
-
* @description ${resource.StaticResource.description}
|
|
39
|
-
* @access ${resource.StaticResource.cacheControl}
|
|
40
|
-
*/
|
|
41
|
-
const `
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
builder.addText(`${resourceName}`, namePosStart, namePosEnd);
|
|
45
|
-
|
|
46
|
-
builder.addText(
|
|
47
|
-
`:string;
|
|
48
|
-
export default ${resourceName};
|
|
49
|
-
}`
|
|
50
|
-
);
|
|
51
|
-
return {
|
|
52
|
-
declarationContent: builder.build(),
|
|
53
|
-
mapData: builder.getMappings(),
|
|
54
|
-
...component,
|
|
55
|
-
};
|
|
56
|
-
}
|
package/lib/index.mjs
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import * as converters from "./converts/_index.mjs";
|
|
2
|
-
|
|
3
|
-
// maybe there is a smarter way to do this
|
|
4
|
-
/** @type {Readonly<{[p in keyof converters]: p}>} */
|
|
5
|
-
export const MetadataType = Object.freeze(
|
|
6
|
-
Object.keys(converters).reduce((/** @type {any} */ t, v) => {
|
|
7
|
-
t[v] = v;
|
|
8
|
-
return t;
|
|
9
|
-
}, {})
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @typedef MapPair
|
|
14
|
-
* @property {number} sourcePos
|
|
15
|
-
* @property {number} destPos
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @typedef Component
|
|
20
|
-
* @property {string} path
|
|
21
|
-
* @property {keyof converters} type
|
|
22
|
-
* @property {string} content
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @typedef { Component & {
|
|
27
|
-
* declarationContent: string;
|
|
28
|
-
* mapData: MapPair[]}} ConvertedComponent
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
*
|
|
33
|
-
* @param {Component[]} components
|
|
34
|
-
* @returns {ConvertedComponent[]}
|
|
35
|
-
*/
|
|
36
|
-
export function convert(components) {
|
|
37
|
-
/** @type {ConvertedComponent[]} */
|
|
38
|
-
const convertedComponents = [];
|
|
39
|
-
for (const c of components) {
|
|
40
|
-
if (!converters[c.type]) {
|
|
41
|
-
throw new Error(
|
|
42
|
-
"Unsupported Metadata Type:" +
|
|
43
|
-
c.type +
|
|
44
|
-
", must be one of " +
|
|
45
|
-
Object.keys(converters)
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
convertedComponents.push(converters[c.type](c));
|
|
49
|
-
}
|
|
50
|
-
return convertedComponents;
|
|
51
|
-
}
|
package/lib/util.mjs
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/** @import { MapPair } from "./index.mjs" */
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @typedef MapDelta
|
|
5
|
-
* @property {number | null} sourcePos
|
|
6
|
-
* @property {number} destDeltaPos
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
* @param {MapDelta[]} mappings
|
|
12
|
-
*/
|
|
13
|
-
export function getMappings(mappings) {
|
|
14
|
-
// increase destination position as an aggregate
|
|
15
|
-
/** @type {MapPair[]} */
|
|
16
|
-
let filteredMappings = [];
|
|
17
|
-
let lastDestPos = 0;
|
|
18
|
-
mappings.forEach((m) => {
|
|
19
|
-
m.destDeltaPos += lastDestPos;
|
|
20
|
-
lastDestPos = m.destDeltaPos;
|
|
21
|
-
if (m.sourcePos !== null) {
|
|
22
|
-
filteredMappings.push({
|
|
23
|
-
sourcePos: m.sourcePos,
|
|
24
|
-
destPos: m.destDeltaPos,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
return filteredMappings;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export class PositionAwareTextBuilder {
|
|
32
|
-
/** @type {MapDelta[]} */
|
|
33
|
-
mappings = [];
|
|
34
|
-
/** @type {string[]} */
|
|
35
|
-
textParts = [];
|
|
36
|
-
|
|
37
|
-
lastTextLen = 0;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
41
|
-
* @param {string} text
|
|
42
|
-
* @param {number?} sourceStartPos
|
|
43
|
-
* @param {number?} sourceEndPos
|
|
44
|
-
*/
|
|
45
|
-
addText(text, sourceStartPos = null, sourceEndPos = null) {
|
|
46
|
-
this.mappings.push({
|
|
47
|
-
sourcePos: sourceStartPos,
|
|
48
|
-
destDeltaPos: this.lastTextLen,
|
|
49
|
-
});
|
|
50
|
-
this.lastTextLen = text.length;
|
|
51
|
-
if (sourceEndPos != null) {
|
|
52
|
-
this.mappings.push({
|
|
53
|
-
sourcePos: sourceEndPos,
|
|
54
|
-
destDeltaPos: this.lastTextLen,
|
|
55
|
-
});
|
|
56
|
-
this.lastTextLen = 0;
|
|
57
|
-
}
|
|
58
|
-
this.textParts.push(text);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
build() {
|
|
62
|
-
return this.textParts.join("");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
getMappings() {
|
|
66
|
-
return getMappings(this.mappings);
|
|
67
|
-
}
|
|
68
|
-
}
|