@sharinpix/sharinpix-sf-cli 1.1.0 → 1.3.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/README.md +40 -50
- package/lib/commands/sharinpix/form/pull.d.ts +2 -0
- package/lib/commands/sharinpix/form/pull.js +17 -35
- package/lib/commands/sharinpix/form/pull.js.map +1 -1
- package/lib/commands/{hello/world.d.ts → sharinpix/form/push.d.ts} +6 -3
- package/lib/commands/sharinpix/form/push.js +129 -0
- package/lib/commands/sharinpix/form/push.js.map +1 -0
- package/lib/helpers/json-utils.d.ts +1 -0
- package/lib/helpers/json-utils.js +4 -0
- package/lib/helpers/json-utils.js.map +1 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/messages/sharinpix.form.pull.md +29 -0
- package/messages/sharinpix.form.push.md +41 -0
- package/oclif.manifest.json +33 -28
- package/package.json +3 -7
- package/lib/commands/hello/world.js +0 -55
- package/lib/commands/hello/world.js.map +0 -1
- package/messages/hello.world.md +0 -29
package/README.md
CHANGED
|
@@ -1,24 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# SharinPix Salesforce CLI Plugin
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/@sharinpix/sharinpix-sf-cli) [](https://npmjs.org/package/@sharinpix/sharinpix-sf-cli) [](https://raw.githubusercontent.com/sharinpix/sharinpix-sf-cli/main/LICENSE.txt)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
This repository provides a template for creating a plugin for the Salesforce CLI. To convert this template to a working plugin:
|
|
8
|
-
|
|
9
|
-
1. Please get in touch with the Platform CLI team. We want to help you develop your plugin.
|
|
10
|
-
2. Generate your plugin:
|
|
11
|
-
|
|
12
|
-
```
|
|
13
|
-
sf plugins install dev
|
|
14
|
-
sf dev generate plugin
|
|
15
|
-
|
|
16
|
-
git init -b main
|
|
17
|
-
git add . && git commit -m "chore: initial commit"
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
3. Create your plugin's repo in the salesforcecli github org
|
|
21
|
-
4. When you're ready, replace the contents of this README with the information you want.
|
|
5
|
+
The SharinPix Salesforce CLI plugin provides tools to interact with SharinPix form templates in your Salesforce orgs. This plugin allows you to pull form templates from your Salesforce org and save them as local JSON files for version control and deployment management.
|
|
22
6
|
|
|
23
7
|
## Learn about `sf` plugins
|
|
24
8
|
|
|
@@ -50,15 +34,17 @@ This plugin is bundled with the [Salesforce CLI](https://developer.salesforce.co
|
|
|
50
34
|
|
|
51
35
|
We always recommend using the latest version of these commands bundled with the CLI, however, you can install a specific version or tag if needed.
|
|
52
36
|
|
|
53
|
-
##
|
|
37
|
+
## Usage
|
|
54
38
|
|
|
55
39
|
```bash
|
|
56
|
-
sf
|
|
40
|
+
sf org login web
|
|
41
|
+
sf plugins install @sharinpix/sharinpix-sf-cli
|
|
42
|
+
sf sharinpix form pull -o yourusername@salesforce.com
|
|
57
43
|
```
|
|
58
44
|
|
|
59
45
|
## Issues
|
|
60
46
|
|
|
61
|
-
Please report any issues at https://github.com/
|
|
47
|
+
Please report any issues at https://github.com/sharinpix/sharinpix-sf-cli/issues
|
|
62
48
|
|
|
63
49
|
## Contributing
|
|
64
50
|
|
|
@@ -85,17 +71,17 @@ To build the plugin locally, make sure to have npm installed and run the followi
|
|
|
85
71
|
|
|
86
72
|
```bash
|
|
87
73
|
# Clone the repository
|
|
88
|
-
git clone git@github.com:
|
|
74
|
+
git clone git@github.com:sharinpix/sharinpix-sf-cli
|
|
89
75
|
|
|
90
76
|
# Install the dependencies and compile
|
|
91
|
-
npm && npm run build
|
|
77
|
+
npm install && npm run build
|
|
92
78
|
```
|
|
93
79
|
|
|
94
80
|
To use your plugin, run using the local `./bin/dev` or `./bin/dev.cmd` file.
|
|
95
81
|
|
|
96
82
|
```bash
|
|
97
83
|
# Run using local run file.
|
|
98
|
-
./bin/dev
|
|
84
|
+
./bin/dev sharinpix form pull --target-org myorg@example.com
|
|
99
85
|
```
|
|
100
86
|
|
|
101
87
|
There should be no differences when running via the Salesforce CLI or using the local run file. However, it can be useful to link the plugin to do some additional testing or run your commands from anywhere on your machine.
|
|
@@ -110,76 +96,80 @@ sf plugins
|
|
|
110
96
|
## Commands
|
|
111
97
|
|
|
112
98
|
<!-- commands -->
|
|
113
|
-
* [`sf hello world`](#sf-hello-world)
|
|
114
99
|
* [`sf sharinpix form pull`](#sf-sharinpix-form-pull)
|
|
100
|
+
* [`sf sharinpix form push`](#sf-sharinpix-form-push)
|
|
115
101
|
|
|
116
|
-
## `sf
|
|
102
|
+
## `sf sharinpix form pull`
|
|
117
103
|
|
|
118
|
-
|
|
104
|
+
Pull SharinPix form templates from Salesforce org.
|
|
119
105
|
|
|
120
106
|
```
|
|
121
107
|
USAGE
|
|
122
|
-
$ sf
|
|
108
|
+
$ sf sharinpix form pull -o <value> [--json] [--flags-dir <value>]
|
|
123
109
|
|
|
124
110
|
FLAGS
|
|
125
|
-
-o, --org=<value> (required) The
|
|
111
|
+
-o, --org=<value> (required) The Salesforce org to pull form templates from.
|
|
126
112
|
|
|
127
113
|
GLOBAL FLAGS
|
|
128
114
|
--flags-dir=<value> Import flag values from a directory.
|
|
129
115
|
--json Format output as json.
|
|
130
116
|
|
|
131
117
|
DESCRIPTION
|
|
132
|
-
|
|
118
|
+
Pull SharinPix form templates from Salesforce org.
|
|
133
119
|
|
|
134
|
-
|
|
120
|
+
Retrieves all SharinPix form templates from the connected Salesforce org and saves them as JSON files in the local
|
|
121
|
+
sharinpix/forms directory. This command fetches the form template metadata and downloads the actual form definition
|
|
122
|
+
files.
|
|
135
123
|
|
|
136
124
|
EXAMPLES
|
|
137
|
-
|
|
125
|
+
Pull all form templates from the default org:
|
|
138
126
|
|
|
139
|
-
$ sf
|
|
127
|
+
$ sf sharinpix form pull
|
|
140
128
|
|
|
141
|
-
|
|
129
|
+
Pull form templates from a specific org:
|
|
142
130
|
|
|
143
|
-
$ sf
|
|
131
|
+
$ sf sharinpix form pull --target-org myorg@example.com
|
|
144
132
|
|
|
145
133
|
FLAG DESCRIPTIONS
|
|
146
|
-
-o, --org=<value> The
|
|
134
|
+
-o, --org=<value> The Salesforce org to pull form templates from.
|
|
147
135
|
|
|
148
|
-
|
|
136
|
+
The target Salesforce org containing the SharinPix form templates to be pulled.
|
|
149
137
|
```
|
|
150
138
|
|
|
151
|
-
## `sf sharinpix form
|
|
139
|
+
## `sf sharinpix form push`
|
|
152
140
|
|
|
153
|
-
|
|
141
|
+
Push SharinPix form templates to Salesforce org.
|
|
154
142
|
|
|
155
143
|
```
|
|
156
144
|
USAGE
|
|
157
|
-
$ sf sharinpix form
|
|
145
|
+
$ sf sharinpix form push -o <value> [--json] [--flags-dir <value>]
|
|
158
146
|
|
|
159
147
|
FLAGS
|
|
160
|
-
-o, --org=<value> (required) The
|
|
148
|
+
-o, --org=<value> (required) The Salesforce org to push form templates to.
|
|
161
149
|
|
|
162
150
|
GLOBAL FLAGS
|
|
163
151
|
--flags-dir=<value> Import flag values from a directory.
|
|
164
152
|
--json Format output as json.
|
|
165
153
|
|
|
166
154
|
DESCRIPTION
|
|
167
|
-
|
|
155
|
+
Push SharinPix form templates to Salesforce org.
|
|
168
156
|
|
|
169
|
-
|
|
157
|
+
Uploads SharinPix form templates from local JSON files to the connected Salesforce org. This command reads form
|
|
158
|
+
templates from the local directory and creates or updates corresponding records in Salesforce. Existing forms will be
|
|
159
|
+
updated unless the force flag is used to skip them.
|
|
170
160
|
|
|
171
161
|
EXAMPLES
|
|
172
|
-
|
|
162
|
+
Push all form templates to the default org:
|
|
173
163
|
|
|
174
|
-
$ sf sharinpix form
|
|
164
|
+
$ sf sharinpix form push
|
|
175
165
|
|
|
176
|
-
|
|
166
|
+
Push form templates to a specific org:
|
|
177
167
|
|
|
178
|
-
$ sf sharinpix form
|
|
168
|
+
$ sf sharinpix form push --target-org myorg@example.com
|
|
179
169
|
|
|
180
170
|
FLAG DESCRIPTIONS
|
|
181
|
-
-o, --org=<value> The
|
|
171
|
+
-o, --org=<value> The Salesforce org to push form templates to.
|
|
182
172
|
|
|
183
|
-
|
|
173
|
+
The target Salesforce org where the SharinPix form templates will be uploaded and stored.
|
|
184
174
|
```
|
|
185
175
|
<!-- commandsstop -->
|
|
@@ -4,7 +4,7 @@ import fs from 'node:fs';
|
|
|
4
4
|
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
5
5
|
import { Messages } from '@salesforce/core';
|
|
6
6
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
7
|
-
const messages = Messages.loadMessages('@sharinpix/sharinpix-sf-cli', '
|
|
7
|
+
const messages = Messages.loadMessages('@sharinpix/sharinpix-sf-cli', 'sharinpix.form.pull');
|
|
8
8
|
export default class Pull extends SfCommand {
|
|
9
9
|
static summary = messages.getMessage('summary');
|
|
10
10
|
static description = messages.getMessage('description');
|
|
@@ -20,53 +20,35 @@ export default class Pull extends SfCommand {
|
|
|
20
20
|
const { flags } = await this.parse(Pull);
|
|
21
21
|
const connection = flags.org.getConnection('63.0');
|
|
22
22
|
fs.mkdirSync('sharinpix/forms', { recursive: true });
|
|
23
|
-
const records = (await connection.query('SELECT Id, sharinpix__FormUrl__c, Name, sharinpix__Description__c FROM sharinpix__FormTemplate__c order by LastModifiedDate desc')).records
|
|
23
|
+
const records = (await connection.query('SELECT Id, sharinpix__FormUrl__c, Name, sharinpix__Description__c FROM sharinpix__FormTemplate__c order by LastModifiedDate desc')).records;
|
|
24
|
+
let formsDownloaded = 0;
|
|
25
|
+
let formsFailed = 0;
|
|
24
26
|
for (const record of records) {
|
|
25
27
|
try {
|
|
26
|
-
const
|
|
28
|
+
const response = await fetch(record.sharinpix__FormUrl__c + '.json', {
|
|
27
29
|
headers: {
|
|
28
30
|
'Accept': 'application/json',
|
|
29
31
|
}
|
|
30
|
-
})
|
|
32
|
+
});
|
|
33
|
+
if (!response.ok) {
|
|
34
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
35
|
+
}
|
|
36
|
+
const form = await response.json();
|
|
31
37
|
fs.writeFileSync(`sharinpix/forms/${record.Name}.json`, JSON.stringify(form, null, 2));
|
|
32
38
|
this.log(messages.getMessage('info.hello', [record.Name, record.sharinpix__FormUrl__c]));
|
|
39
|
+
formsDownloaded++;
|
|
33
40
|
}
|
|
34
41
|
catch (error) {
|
|
35
|
-
//
|
|
36
|
-
|
|
42
|
+
// Skip forms that can't be fetched (e.g., network errors, invalid URLs)
|
|
43
|
+
this.warn(`Failed to fetch form template ${record.Name}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
44
|
+
formsFailed++;
|
|
37
45
|
}
|
|
38
|
-
// return [record.Id, record.sharinpix__FormUrl__c, record.Name, record.sharinpix__Description__c].join(',')
|
|
39
46
|
}
|
|
40
|
-
|
|
41
|
-
/* const result2 = (await connection.query('SELECT Id, Name FROM sharinpix__FormTemplate__c LIMIT 50')).records
|
|
42
|
-
.map((record) => [record.Id, record.Name].join(','))
|
|
43
|
-
.join('\n');
|
|
44
|
-
this.log(messages.getMessage('info.hello', [result2, flags.org.getOrgId()]));*/
|
|
45
|
-
/* await connection.apex.post('/sharinpix/FormTemplateImport', {
|
|
46
|
-
recordId: 'a0WJ6000001Ya27MAC',
|
|
47
|
-
name: 'Super CLI IMPORT',
|
|
48
|
-
description: 'From the cli',
|
|
49
|
-
url: 'https://google.com',
|
|
50
|
-
formTemplateJson: JSON.stringify({
|
|
51
|
-
submit: {
|
|
52
|
-
label: 'Submit',
|
|
53
|
-
},
|
|
54
|
-
elements: [
|
|
55
|
-
{
|
|
56
|
-
elemType: 'question',
|
|
57
|
-
inputType: 'string',
|
|
58
|
-
label: 'Name tega',
|
|
59
|
-
id: '0198844b-db9d-710d-8919-63d84a6663cc',
|
|
60
|
-
apiName: 'name_tega',
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
}),
|
|
64
|
-
});*/
|
|
65
|
-
// this.log(messages.getMessage('info.hello', [exec.logs.join(','), time]));
|
|
66
|
-
// this.log(messages.getMessage('info.hello', [exec.exceptionMessage, time]));
|
|
67
|
-
// this.log(messages.getMessage('info.hello', [await connection.tooling.executeAnonymous('System.debug(\'Hello Pull\');'), time]));
|
|
47
|
+
this.log(`Successfully downloaded ${formsDownloaded} form template(s). ${formsFailed} failed.`);
|
|
68
48
|
return {
|
|
69
49
|
name: 'OK',
|
|
50
|
+
formsDownloaded,
|
|
51
|
+
formsFailed,
|
|
70
52
|
};
|
|
71
53
|
}
|
|
72
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull.js","sourceRoot":"","sources":["../../../../src/commands/sharinpix/form/pull.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,qCAAqC;AACrC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,6BAA6B,EAAE,
|
|
1
|
+
{"version":3,"file":"pull.js","sourceRoot":"","sources":["../../../../src/commands/sharinpix/form/pull.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,qCAAqC;AACrC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,6BAA6B,EAAE,qBAAqB,CAAC,CAAC;AAe7F,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,SAAqB;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KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;gBACrE,CAAC;gBAED,MAAM,IAAI,GAAY,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;gBAC5C,EAAE,CAAC,aAAa,CAAC,mBAAmB,MAAM,CAAC,IAAI,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;gBACvF,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;gBACzF,eAAe,EAAE,CAAC;YACpB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,wEAAwE;gBACxE,IAAI,CAAC,IAAI,CAAC,iCAAiC,MAAM,CAAC,IAAI,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC;gBACvH,WAAW,EAAE,CAAC;YAChB,CAAC;QACH,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,2BAA2B,eAAe,sBAAsB,WAAW,UAAU,CAAC,CAAC;QAEhG,OAAO;YACL,IAAI,EAAE,IAAI;YACV,eAAe;YACf,WAAW;SACZ,CAAC;IACJ,CAAC"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
-
export type
|
|
2
|
+
export type PushResult = {
|
|
3
3
|
name: string;
|
|
4
|
+
uploaded?: number;
|
|
5
|
+
failed?: number;
|
|
6
|
+
skipped?: number;
|
|
4
7
|
};
|
|
5
|
-
export default class
|
|
8
|
+
export default class Push extends SfCommand<PushResult> {
|
|
6
9
|
static readonly summary: string;
|
|
7
10
|
static readonly description: string;
|
|
8
11
|
static readonly examples: string[];
|
|
9
12
|
static readonly flags: {
|
|
10
13
|
org: import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
14
|
};
|
|
12
|
-
run(): Promise<
|
|
15
|
+
run(): Promise<PushResult>;
|
|
13
16
|
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
/* eslint-disable no-await-in-loop */
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
6
|
+
import { Messages } from '@salesforce/core';
|
|
7
|
+
import { isJsonEqual } from '../../../helpers/json-utils.js';
|
|
8
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
9
|
+
const messages = Messages.loadMessages('@sharinpix/sharinpix-sf-cli', 'sharinpix.form.push');
|
|
10
|
+
export default class Push extends SfCommand {
|
|
11
|
+
static summary = messages.getMessage('summary');
|
|
12
|
+
static description = messages.getMessage('description');
|
|
13
|
+
static examples = messages.getMessages('examples');
|
|
14
|
+
static flags = {
|
|
15
|
+
org: Flags.requiredOrg({
|
|
16
|
+
char: 'o',
|
|
17
|
+
summary: messages.getMessage('flags.org.summary'),
|
|
18
|
+
description: messages.getMessage('flags.org.description'),
|
|
19
|
+
}),
|
|
20
|
+
};
|
|
21
|
+
async run() {
|
|
22
|
+
const { flags } = await this.parse(Push);
|
|
23
|
+
const connection = flags.org.getConnection('63.0');
|
|
24
|
+
const files = fs
|
|
25
|
+
.readdirSync('sharinpix/forms')
|
|
26
|
+
.filter((file) => file.endsWith('.json'))
|
|
27
|
+
.map((file) => path.join('sharinpix/forms', file));
|
|
28
|
+
if (files.length === 0) {
|
|
29
|
+
this.log('No form template files found in the specified directory.');
|
|
30
|
+
return {
|
|
31
|
+
name: 'OK',
|
|
32
|
+
uploaded: 0,
|
|
33
|
+
failed: 0,
|
|
34
|
+
skipped: 0,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const responseToken = await connection.apex.post('/sharinpix/Token', {
|
|
38
|
+
// eslint-disable-next-line camelcase
|
|
39
|
+
form_template_create: true,
|
|
40
|
+
});
|
|
41
|
+
const existingRecords = (await connection.query('SELECT Id, Name, sharinpix__FormUrl__c, sharinpix__Description__c FROM sharinpix__FormTemplate__c')).records;
|
|
42
|
+
const existingMap = new Map(existingRecords.map((record) => [record.Name, record]));
|
|
43
|
+
let uploaded = 0;
|
|
44
|
+
let failed = 0;
|
|
45
|
+
let skipped = 0;
|
|
46
|
+
for (const file of files) {
|
|
47
|
+
try {
|
|
48
|
+
const fileName = path.basename(file, '.json');
|
|
49
|
+
const fileContent = fs.readFileSync(file, 'utf8');
|
|
50
|
+
const json = JSON.parse(fileContent);
|
|
51
|
+
const existingRecord = existingMap.get(fileName);
|
|
52
|
+
const existingId = existingRecord?.Id ?? null;
|
|
53
|
+
if (existingRecord) {
|
|
54
|
+
// Check if form has changed by comparing with stored JSON
|
|
55
|
+
const response = await fetch(existingRecord?.sharinpix__FormUrl__c + '.json', {
|
|
56
|
+
headers: {
|
|
57
|
+
Accept: 'application/json',
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
if (!response.ok) {
|
|
61
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
62
|
+
}
|
|
63
|
+
const existingJson = await response.json();
|
|
64
|
+
if (existingJson) {
|
|
65
|
+
try {
|
|
66
|
+
if (isJsonEqual(json, existingJson)) {
|
|
67
|
+
this.log(messages.getMessage('info.skipped', [fileName]));
|
|
68
|
+
skipped++;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch (parseError) {
|
|
73
|
+
this.warn(`Failed to parse stored JSON for ${fileName}, proceeding with update`);
|
|
74
|
+
failed++;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
80
|
+
const responseData = await (await fetch(`${responseToken.host}/api/v1/form/templates`, {
|
|
81
|
+
method: 'POST',
|
|
82
|
+
body: JSON.stringify({
|
|
83
|
+
sfid: existingId ?? undefined,
|
|
84
|
+
config: {
|
|
85
|
+
name: fileName,
|
|
86
|
+
...json,
|
|
87
|
+
},
|
|
88
|
+
}),
|
|
89
|
+
headers: {
|
|
90
|
+
'Content-Type': 'application/json',
|
|
91
|
+
Accept: 'application/json',
|
|
92
|
+
Authorization: `Bearer ${responseToken.token}`,
|
|
93
|
+
},
|
|
94
|
+
})).json();
|
|
95
|
+
const formTemplateJson = JSON.stringify({
|
|
96
|
+
...json,
|
|
97
|
+
url: responseData.url,
|
|
98
|
+
});
|
|
99
|
+
await connection.apex.post('/sharinpix/FormTemplateImport', {
|
|
100
|
+
recordId: existingId ?? undefined,
|
|
101
|
+
name: fileName,
|
|
102
|
+
url: responseData.url,
|
|
103
|
+
formTemplateJson,
|
|
104
|
+
});
|
|
105
|
+
if (existingId) {
|
|
106
|
+
this.log(messages.getMessage('info.updated', [fileName]));
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
this.log(messages.getMessage('info.created', [fileName]));
|
|
110
|
+
}
|
|
111
|
+
uploaded++;
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
const fileName = path.basename(file, '.json');
|
|
115
|
+
this.warn(`Failed to push form template ${fileName}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
116
|
+
failed++;
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
this.log(messages.getMessage('info.summary', [uploaded, failed, skipped]));
|
|
121
|
+
return {
|
|
122
|
+
name: 'OK',
|
|
123
|
+
uploaded,
|
|
124
|
+
failed,
|
|
125
|
+
skipped,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=push.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push.js","sourceRoot":"","sources":["../../../../src/comm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AAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;QAE3E,OAAO;YACL,IAAI,EAAE,IAAI;YACV,QAAQ;YACR,MAAM;YACN,OAAO;SACR,CAAC;IACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isJsonEqual(obj1: unknown, obj2: unknown): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-utils.js","sourceRoot":"","sources":["../../src/helpers/json-utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW,CAAC,IAAa,EAAE,IAAa;IACtD,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AACvD,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export default
|
|
1
|
+
export { default as pull } from './commands/sharinpix/form/pull.js';
|
|
2
|
+
export { default as push } from './commands/sharinpix/form/push.js';
|
package/lib/index.js
CHANGED
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,mCAAmC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# summary
|
|
2
|
+
|
|
3
|
+
Pull SharinPix form templates from Salesforce org.
|
|
4
|
+
|
|
5
|
+
# description
|
|
6
|
+
|
|
7
|
+
Retrieves all SharinPix form templates from the connected Salesforce org and saves them as JSON files in the local sharinpix/forms directory. This command fetches the form template metadata and downloads the actual form definition files.
|
|
8
|
+
|
|
9
|
+
# flags.org.summary
|
|
10
|
+
|
|
11
|
+
The Salesforce org to pull form templates from.
|
|
12
|
+
|
|
13
|
+
# flags.org.description
|
|
14
|
+
|
|
15
|
+
The target Salesforce org containing the SharinPix form templates to be pulled.
|
|
16
|
+
|
|
17
|
+
# examples
|
|
18
|
+
|
|
19
|
+
- Pull all form templates from the default org:
|
|
20
|
+
|
|
21
|
+
<%= config.bin %> <%= command.id %>
|
|
22
|
+
|
|
23
|
+
- Pull form templates from a specific org:
|
|
24
|
+
|
|
25
|
+
<%= config.bin %> <%= command.id %> --target-org myorg@example.com
|
|
26
|
+
|
|
27
|
+
# info.hello
|
|
28
|
+
|
|
29
|
+
Pulled form template %s from %s
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# summary
|
|
2
|
+
|
|
3
|
+
Push SharinPix form templates to Salesforce org.
|
|
4
|
+
|
|
5
|
+
# description
|
|
6
|
+
|
|
7
|
+
Uploads SharinPix form templates from local JSON files to the connected Salesforce org. This command reads form templates from the local directory and creates or updates corresponding records in Salesforce. Existing forms will be updated unless the force flag is used to skip them.
|
|
8
|
+
|
|
9
|
+
# flags.org.summary
|
|
10
|
+
|
|
11
|
+
The Salesforce org to push form templates to.
|
|
12
|
+
|
|
13
|
+
# flags.org.description
|
|
14
|
+
|
|
15
|
+
The target Salesforce org where the SharinPix form templates will be uploaded and stored.
|
|
16
|
+
|
|
17
|
+
# examples
|
|
18
|
+
|
|
19
|
+
- Push all form templates to the default org:
|
|
20
|
+
|
|
21
|
+
<%= config.bin %> <%= command.id %>
|
|
22
|
+
|
|
23
|
+
- Push form templates to a specific org:
|
|
24
|
+
|
|
25
|
+
<%= config.bin %> <%= command.id %> --target-org myorg@example.com
|
|
26
|
+
|
|
27
|
+
# info.created
|
|
28
|
+
|
|
29
|
+
Created form template %s
|
|
30
|
+
|
|
31
|
+
# info.updated
|
|
32
|
+
|
|
33
|
+
Updated form template %s
|
|
34
|
+
|
|
35
|
+
# info.skipped
|
|
36
|
+
|
|
37
|
+
Skipped form template %s (no changes detected)
|
|
38
|
+
|
|
39
|
+
# info.summary
|
|
40
|
+
|
|
41
|
+
Push completed: %d forms uploaded, %d forms failed, %d forms skipped
|
package/oclif.manifest.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"commands": {
|
|
3
|
-
"
|
|
3
|
+
"sharinpix:form:pull": {
|
|
4
4
|
"aliases": [],
|
|
5
5
|
"args": {},
|
|
6
|
-
"description": "
|
|
6
|
+
"description": "Retrieves all SharinPix form templates from the connected Salesforce org and saves them as JSON files in the local sharinpix/forms directory. This command fetches the form template metadata and downloads the actual form definition files.",
|
|
7
7
|
"examples": [
|
|
8
|
-
"
|
|
9
|
-
"
|
|
8
|
+
"Pull all form templates from the default org:\n<%= config.bin %> <%= command.id %>",
|
|
9
|
+
"Pull form templates from a specific org:\n<%= config.bin %> <%= command.id %> --target-org myorg@example.com"
|
|
10
10
|
],
|
|
11
11
|
"flags": {
|
|
12
12
|
"json": {
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
},
|
|
27
27
|
"org": {
|
|
28
28
|
"char": "o",
|
|
29
|
-
"description": "
|
|
29
|
+
"description": "The target Salesforce org containing the SharinPix form templates to be pulled.",
|
|
30
30
|
"name": "org",
|
|
31
31
|
"noCacheDefault": true,
|
|
32
32
|
"required": true,
|
|
33
|
-
"summary": "The
|
|
33
|
+
"summary": "The Salesforce org to pull form templates from.",
|
|
34
34
|
"hasDynamicHelp": true,
|
|
35
35
|
"multiple": false,
|
|
36
36
|
"type": "option"
|
|
@@ -38,33 +38,38 @@
|
|
|
38
38
|
},
|
|
39
39
|
"hasDynamicHelp": true,
|
|
40
40
|
"hiddenAliases": [],
|
|
41
|
-
"id": "
|
|
41
|
+
"id": "sharinpix:form:pull",
|
|
42
42
|
"pluginAlias": "@sharinpix/sharinpix-sf-cli",
|
|
43
43
|
"pluginName": "@sharinpix/sharinpix-sf-cli",
|
|
44
44
|
"pluginType": "core",
|
|
45
45
|
"strict": true,
|
|
46
|
-
"summary": "
|
|
46
|
+
"summary": "Pull SharinPix form templates from Salesforce org.",
|
|
47
47
|
"enableJsonFlag": true,
|
|
48
48
|
"isESM": true,
|
|
49
49
|
"relativePath": [
|
|
50
50
|
"lib",
|
|
51
51
|
"commands",
|
|
52
|
-
"
|
|
53
|
-
"
|
|
52
|
+
"sharinpix",
|
|
53
|
+
"form",
|
|
54
|
+
"pull.js"
|
|
54
55
|
],
|
|
55
56
|
"aliasPermutations": [],
|
|
56
57
|
"permutations": [
|
|
57
|
-
"
|
|
58
|
-
"
|
|
58
|
+
"sharinpix:form:pull",
|
|
59
|
+
"form:sharinpix:pull",
|
|
60
|
+
"form:pull:sharinpix",
|
|
61
|
+
"sharinpix:pull:form",
|
|
62
|
+
"pull:sharinpix:form",
|
|
63
|
+
"pull:form:sharinpix"
|
|
59
64
|
]
|
|
60
65
|
},
|
|
61
|
-
"sharinpix:form:
|
|
66
|
+
"sharinpix:form:push": {
|
|
62
67
|
"aliases": [],
|
|
63
68
|
"args": {},
|
|
64
|
-
"description": "
|
|
69
|
+
"description": "Uploads SharinPix form templates from local JSON files to the connected Salesforce org. This command reads form templates from the local directory and creates or updates corresponding records in Salesforce. Existing forms will be updated unless the force flag is used to skip them.",
|
|
65
70
|
"examples": [
|
|
66
|
-
"
|
|
67
|
-
"
|
|
71
|
+
"Push all form templates to the default org:\n<%= config.bin %> <%= command.id %>",
|
|
72
|
+
"Push form templates to a specific org:\n<%= config.bin %> <%= command.id %> --target-org myorg@example.com"
|
|
68
73
|
],
|
|
69
74
|
"flags": {
|
|
70
75
|
"json": {
|
|
@@ -84,11 +89,11 @@
|
|
|
84
89
|
},
|
|
85
90
|
"org": {
|
|
86
91
|
"char": "o",
|
|
87
|
-
"description": "
|
|
92
|
+
"description": "The target Salesforce org where the SharinPix form templates will be uploaded and stored.",
|
|
88
93
|
"name": "org",
|
|
89
94
|
"noCacheDefault": true,
|
|
90
95
|
"required": true,
|
|
91
|
-
"summary": "The
|
|
96
|
+
"summary": "The Salesforce org to push form templates to.",
|
|
92
97
|
"hasDynamicHelp": true,
|
|
93
98
|
"multiple": false,
|
|
94
99
|
"type": "option"
|
|
@@ -96,12 +101,12 @@
|
|
|
96
101
|
},
|
|
97
102
|
"hasDynamicHelp": true,
|
|
98
103
|
"hiddenAliases": [],
|
|
99
|
-
"id": "sharinpix:form:
|
|
104
|
+
"id": "sharinpix:form:push",
|
|
100
105
|
"pluginAlias": "@sharinpix/sharinpix-sf-cli",
|
|
101
106
|
"pluginName": "@sharinpix/sharinpix-sf-cli",
|
|
102
107
|
"pluginType": "core",
|
|
103
108
|
"strict": true,
|
|
104
|
-
"summary": "
|
|
109
|
+
"summary": "Push SharinPix form templates to Salesforce org.",
|
|
105
110
|
"enableJsonFlag": true,
|
|
106
111
|
"isESM": true,
|
|
107
112
|
"relativePath": [
|
|
@@ -109,18 +114,18 @@
|
|
|
109
114
|
"commands",
|
|
110
115
|
"sharinpix",
|
|
111
116
|
"form",
|
|
112
|
-
"
|
|
117
|
+
"push.js"
|
|
113
118
|
],
|
|
114
119
|
"aliasPermutations": [],
|
|
115
120
|
"permutations": [
|
|
116
|
-
"sharinpix:form:
|
|
117
|
-
"form:sharinpix:
|
|
118
|
-
"form:
|
|
119
|
-
"sharinpix:
|
|
120
|
-
"
|
|
121
|
-
"
|
|
121
|
+
"sharinpix:form:push",
|
|
122
|
+
"form:sharinpix:push",
|
|
123
|
+
"form:push:sharinpix",
|
|
124
|
+
"sharinpix:push:form",
|
|
125
|
+
"push:sharinpix:form",
|
|
126
|
+
"push:form:sharinpix"
|
|
122
127
|
]
|
|
123
128
|
}
|
|
124
129
|
},
|
|
125
|
-
"version": "1.
|
|
130
|
+
"version": "1.3.0"
|
|
126
131
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sharinpix/sharinpix-sf-cli",
|
|
3
3
|
"description": "SharinPix salesforce cli plugin",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@oclif/core": "^4",
|
|
7
7
|
"@salesforce/core": "^8",
|
|
@@ -45,11 +45,7 @@
|
|
|
45
45
|
"devPlugins": [
|
|
46
46
|
"@oclif/plugin-help"
|
|
47
47
|
],
|
|
48
|
-
"topics": {
|
|
49
|
-
"hello": {
|
|
50
|
-
"description": "Commands to say hello."
|
|
51
|
-
}
|
|
52
|
-
},
|
|
48
|
+
"topics": {},
|
|
53
49
|
"flexibleTaxonomy": true
|
|
54
50
|
},
|
|
55
51
|
"scripts": {
|
|
@@ -64,7 +60,7 @@
|
|
|
64
60
|
"postpack": "sf-clean --ignore-signing-artifacts",
|
|
65
61
|
"prepack": "sf-prepack",
|
|
66
62
|
"test": "wireit",
|
|
67
|
-
"test:nuts": "nyc mocha \"**/*.nut.ts\" --slow 4500 --timeout 600000 --parallel",
|
|
63
|
+
"test:nuts": "TS_NODE_PROJECT=./test/tsconfig.json nyc mocha \"**/*.nut.ts\" --slow 4500 --timeout 600000 --parallel",
|
|
68
64
|
"test:only": "wireit",
|
|
69
65
|
"version": "oclif readme",
|
|
70
66
|
"prepare": "husky",
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
2
|
-
import { Messages } from '@salesforce/core';
|
|
3
|
-
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
4
|
-
const messages = Messages.loadMessages('@sharinpix/sharinpix-sf-cli', 'hello.world');
|
|
5
|
-
export default class World extends SfCommand {
|
|
6
|
-
static summary = messages.getMessage('summary');
|
|
7
|
-
static description = messages.getMessage('description');
|
|
8
|
-
static examples = messages.getMessages('examples');
|
|
9
|
-
static flags = {
|
|
10
|
-
org: Flags.requiredOrg({
|
|
11
|
-
char: 'o',
|
|
12
|
-
summary: messages.getMessage('flags.org.summary'),
|
|
13
|
-
description: messages.getMessage('flags.org.description'),
|
|
14
|
-
}),
|
|
15
|
-
};
|
|
16
|
-
async run() {
|
|
17
|
-
const { flags } = await this.parse(World);
|
|
18
|
-
const connection = flags.org.getConnection('63.0');
|
|
19
|
-
const result = (await connection.query('SELECT Id, sharinpix__FormUrl__c, Name, sharinpix__Description__c FROM sharinpix__FormTemplate__c LIMIT 50')).records
|
|
20
|
-
.map((record) => [record.Id, record.sharinpix__FormUrl__c, record.Name, record.sharinpix__Description__c].join(','))
|
|
21
|
-
.join('\n');
|
|
22
|
-
this.log(messages.getMessage('info.hello', [result, flags.org.getOrgId()]));
|
|
23
|
-
const result2 = (await connection.query('SELECT Id, Name FROM sharinpix__FormTemplate__c LIMIT 50')).records
|
|
24
|
-
.map((record) => [record.Id, record.Name].join(','))
|
|
25
|
-
.join('\n');
|
|
26
|
-
this.log(messages.getMessage('info.hello', [result2, flags.org.getOrgId()]));
|
|
27
|
-
await connection.apex.post('/sharinpix/FormTemplateImport', {
|
|
28
|
-
recordId: 'a0WJ6000001Ya27MAC',
|
|
29
|
-
name: 'Super CLI IMPORT',
|
|
30
|
-
description: 'From the cli',
|
|
31
|
-
url: 'https://google.com',
|
|
32
|
-
formTemplateJson: JSON.stringify({
|
|
33
|
-
submit: {
|
|
34
|
-
label: 'Submit',
|
|
35
|
-
},
|
|
36
|
-
elements: [
|
|
37
|
-
{
|
|
38
|
-
elemType: 'question',
|
|
39
|
-
inputType: 'string',
|
|
40
|
-
label: 'Name tega',
|
|
41
|
-
id: '0198844b-db9d-710d-8919-63d84a6663cc',
|
|
42
|
-
apiName: 'name_tega',
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
}),
|
|
46
|
-
});
|
|
47
|
-
// this.log(messages.getMessage('info.hello', [exec.logs.join(','), time]));
|
|
48
|
-
// this.log(messages.getMessage('info.hello', [exec.exceptionMessage, time]));
|
|
49
|
-
// this.log(messages.getMessage('info.hello', [await connection.tooling.executeAnonymous('System.debug(\'Hello World\');'), time]));
|
|
50
|
-
return {
|
|
51
|
-
name: 'OK',
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=world.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"world.js","sourceRoot":"","sources":["../../../src/commands/hello/world.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,6BAA6B,EAAE,aAAa,CAAC,CAAC;AAMrF,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,SAA2B;IACrD,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACzD,MAAM,CAAU,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACjE,MAAM,CAAU,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAE5D,MAAM,CAAU,KAAK,GAAG;QAC7B,GAAG,EAAE,KAAK,CAAC,WAAW,CAAC;YACrB,IAAI,EAAE,GAAG;YACT,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,mBAAmB,CAAC;YACjD,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,uBAAuB,CAAC;SAC1D,CAAC;KACH,CAAC;IAEK,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1C,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QACnD,MA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WAAW;wBAClB,EAAE,EAAE,sCAAsC;wBAC1C,OAAO,EAAE,WAAW;qBACrB;iBACF;aACF,CAAC;SACH,CAAC,CAAC;QACH,4EAA4E;QAC5E,8EAA8E;QAC9E,oIAAoI;QACpI,OAAO;YACL,IAAI,EAAE,IAAI;SACX,CAAC;IACJ,CAAC"}
|
package/messages/hello.world.md
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# summary
|
|
2
|
-
|
|
3
|
-
Say hello.
|
|
4
|
-
|
|
5
|
-
# description
|
|
6
|
-
|
|
7
|
-
Say hello either to the world or someone you know.
|
|
8
|
-
|
|
9
|
-
# flags.org.summary
|
|
10
|
-
|
|
11
|
-
The name of the person you'd like to say hello to.
|
|
12
|
-
|
|
13
|
-
# flags.org.description
|
|
14
|
-
|
|
15
|
-
This person can be anyone in the world!
|
|
16
|
-
|
|
17
|
-
# examples
|
|
18
|
-
|
|
19
|
-
- Say hello to the world:
|
|
20
|
-
|
|
21
|
-
<%= config.bin %> <%= command.id %>
|
|
22
|
-
|
|
23
|
-
- Say hello to someone you know:
|
|
24
|
-
|
|
25
|
-
<%= config.bin %> <%= command.id %> --name Astro
|
|
26
|
-
|
|
27
|
-
# info.hello
|
|
28
|
-
|
|
29
|
-
Hello %s at %s
|