sf_cli 0.0.7.beta2 → 0.0.8
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.
- checksums.yaml +4 -4
- data/README.rdoc +39 -115
- data/lib/sf_cli/console/commands.rb +36 -0
- data/lib/sf_cli/console.rb +5 -0
- data/lib/sf_cli/sf/apex/core.rb +18 -0
- data/lib/sf_cli/sf/apex/run.rb +113 -0
- data/lib/sf_cli/sf/core/base.rb +1 -0
- data/lib/sf_cli/sf/data/bulk_result_v2.rb +2 -3
- data/lib/sf_cli/sf/data/core.rb +5 -6
- data/lib/sf_cli/sf/data/create_record.rb +6 -8
- data/lib/sf_cli/sf/data/delete_bulk.rb +9 -10
- data/lib/sf_cli/sf/data/delete_record.rb +8 -9
- data/lib/sf_cli/sf/data/delete_resume.rb +7 -9
- data/lib/sf_cli/sf/data/get_record.rb +11 -13
- data/lib/sf_cli/sf/data/helper_methods.rb +1 -0
- data/lib/sf_cli/sf/data/query.rb +20 -27
- data/lib/sf_cli/sf/data/query_helper.rb +3 -0
- data/lib/sf_cli/sf/data/resume.rb +6 -6
- data/lib/sf_cli/sf/data/search.rb +9 -10
- data/lib/sf_cli/sf/data/update_record.rb +11 -14
- data/lib/sf_cli/sf/data/upsert_bulk.rb +9 -12
- data/lib/sf_cli/sf/data/upsert_resume.rb +7 -10
- data/lib/sf_cli/sf/main.rb +8 -4
- data/lib/sf_cli/sf/model/base_methods.rb +1 -0
- data/lib/sf_cli/sf/model/class_definition.rb +1 -0
- data/lib/sf_cli/sf/model/dml_methods.rb +1 -0
- data/lib/sf_cli/sf/model/generator.rb +2 -1
- data/lib/sf_cli/sf/model/query_condition.rb +2 -1
- data/lib/sf_cli/sf/model/query_methods.rb +1 -0
- data/lib/sf_cli/sf/model/sf_command_connection.rb +24 -5
- data/lib/sf_cli/sf/model.rb +6 -4
- data/lib/sf_cli/sf/org/core.rb +6 -6
- data/lib/sf_cli/sf/org/display.rb +7 -6
- data/lib/sf_cli/sf/org/list.rb +12 -13
- data/lib/sf_cli/sf/org/login.rb +22 -28
- data/lib/sf_cli/sf/project/core.rb +10 -72
- data/lib/sf_cli/sf/project/generate.rb +35 -0
- data/lib/sf_cli/sf/project/generate_manifest.rb +31 -0
- data/lib/sf_cli/sf/sobject/core.rb +10 -47
- data/lib/sf_cli/sf/sobject/describe.rb +29 -0
- data/lib/sf_cli/sf/sobject/list.rb +18 -0
- data/lib/sf_cli.rb +5 -12
- metadata +11 -8
- data/CHANGELOG.md +0 -55
- data/bin/sfc +0 -7
- data/lib/sf_cli/sf/console.rb +0 -26
data/lib/sf_cli/sf/data/query.rb
CHANGED
@@ -3,21 +3,17 @@ require_relative './query_helper'
|
|
3
3
|
|
4
4
|
module SfCli::Sf::Data
|
5
5
|
module Query
|
6
|
-
#
|
6
|
+
# Get object records using SOQL.
|
7
|
+
# @param soql [String] SOQL
|
8
|
+
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
9
|
+
# @param format [Symbol,String] get the command's raw output. human, csv, json can be available
|
10
|
+
# @param model_class [Class] the object model class
|
11
|
+
# @param bulk [Boolean] use Bulk API
|
12
|
+
# @param timeout [Integer] max minutes to wait for the job complete in Bulk API mode
|
7
13
|
#
|
8
|
-
#
|
14
|
+
# @return [Array,[String,Array]] records or a tuple containing a flag and records
|
9
15
|
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
# *format* --- get the command's raw output. human, csv, json can be available<br>
|
13
|
-
#
|
14
|
-
# *model_class* --- the object model class<br>
|
15
|
-
#
|
16
|
-
# *bulk* --- use Bulk API<br>
|
17
|
-
#
|
18
|
-
# *timeout* --- max minutes to wait for the job complete in Bulk API mode<br>
|
19
|
-
#
|
20
|
-
# ======
|
16
|
+
# @example
|
21
17
|
# sf.data.query 'SELECT Id, Name FROM Account LIMIT 1' # => [{Id: "abc", Name: "account name"}]
|
22
18
|
#
|
23
19
|
# Account = Struct.new(:Id, :Name)
|
@@ -32,7 +28,7 @@ module SfCli::Sf::Data
|
|
32
28
|
# When using Bulk API, you get the records when the query job completes within time limit.
|
33
29
|
# The method returns a tapple(an array), which changes its contents according to the job result.
|
34
30
|
#
|
35
|
-
#
|
31
|
+
# @example
|
36
32
|
# done, result = sf.data.query 'SELECT Id, Name FROM Account', bulk: true # max wait 1 min to get result (default)
|
37
33
|
# done, result = sf.data.query 'SELECT Id, Name FROM Account', bulk: true, timeout: 5 # max wait 5 min to get result
|
38
34
|
# done, result = sf.data.query 'SELECT Id, Name FROM Account', bulk: true, timeout: 0 # returns immediately
|
@@ -40,9 +36,7 @@ module SfCli::Sf::Data
|
|
40
36
|
# rows = result if done # if job is completed, the result is an array of record
|
41
37
|
# job_id = result unless done # if job hasn't completed or it has aborted, the result is the job ID
|
42
38
|
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
# About querying with auto generated object model, see the section {"Object Model support"}[link://files/README_rdoc.html#label-Object+Model+support+-28experimental-2C+since+0.0.4-29] in README.
|
39
|
+
# @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_data_commands_unified.htm#cli_reference_data_query_unified command reference
|
46
40
|
#
|
47
41
|
def query(soql, target_org: nil, format: nil, bulk: false, timeout: nil, model_class: nil)
|
48
42
|
flags = {
|
@@ -62,17 +56,15 @@ module SfCli::Sf::Data
|
|
62
56
|
return_result(result, raw_output, bulk, model_class)
|
63
57
|
end
|
64
58
|
|
65
|
-
#
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#
|
69
|
-
#
|
59
|
+
# Resume a bulk query job, which you previously started, and get records
|
60
|
+
# @param job_id [String] job ID you want to resume
|
61
|
+
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
62
|
+
# @param format [Symbol,String] get the command's raw output. human, csv, json can be available
|
63
|
+
# @param model_class [Class] the object model class
|
70
64
|
#
|
71
|
-
#
|
65
|
+
# @return [Array,[String,Array]] records or a tuple containing a flag and records
|
72
66
|
#
|
73
|
-
#
|
74
|
-
#
|
75
|
-
# ======
|
67
|
+
# @example
|
76
68
|
# # start a query job
|
77
69
|
# result1 = sf.data.query 'SELECT Id, Name FROM Account', bulk: true, timeout: 0 # returns immediately
|
78
70
|
#
|
@@ -86,7 +78,8 @@ module SfCli::Sf::Data
|
|
86
78
|
#
|
87
79
|
# result2 # => if done is true, this is an array of record. Otherwise it should be the Job ID.
|
88
80
|
#
|
89
|
-
#
|
81
|
+
# @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_data_commands_unified.htm#cli_reference_data_query_resume_unified command reference
|
82
|
+
#
|
90
83
|
def query_resume(job_id:, target_org: nil, format: nil, model_class: nil)
|
91
84
|
flags = {
|
92
85
|
:"bulk-query-id" => job_id,
|
@@ -2,6 +2,7 @@ require_relative './helper_methods'
|
|
2
2
|
|
3
3
|
module SfCli::Sf::Data
|
4
4
|
module Query
|
5
|
+
# @private
|
5
6
|
class RegularResultAdjuster # :nodoc: all
|
6
7
|
include ::SfCli::Sf::Data::HelperMethods
|
7
8
|
|
@@ -20,6 +21,7 @@ module SfCli::Sf::Data
|
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
24
|
+
# @private
|
23
25
|
class BulkResultAdjuster # :nodoc: all
|
24
26
|
include ::SfCli::Sf::Data::HelperMethods
|
25
27
|
|
@@ -42,6 +44,7 @@ module SfCli::Sf::Data
|
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
47
|
+
# @private
|
45
48
|
class RawOutputResultAdjuster # :nodoc: all
|
46
49
|
attr_reader :result
|
47
50
|
|
@@ -49,12 +49,12 @@ module SfCli::Sf::Data
|
|
49
49
|
end
|
50
50
|
|
51
51
|
# View the status of a bulk job.
|
52
|
+
# @param job_id [String] job ID you want to resume
|
53
|
+
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
52
54
|
#
|
53
|
-
#
|
55
|
+
# @return [JobInfo] job information
|
54
56
|
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
# ======
|
57
|
+
# @example
|
58
58
|
# # start a delete job
|
59
59
|
# jobinfo = sf.data.delete_bulk sobject: :TestCustomObject__c, file: 'delete.csv' # this returns immediately
|
60
60
|
# jobinfo.id # => "750J4000003g1OaIAI" it's job ID
|
@@ -69,9 +69,9 @@ module SfCli::Sf::Data
|
|
69
69
|
# - in_progress?
|
70
70
|
# - completed?
|
71
71
|
#
|
72
|
-
# To know job status more, take a look at {
|
72
|
+
# To know job status more, take a look at {https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/bulk_api_2_job_states.htm the bulk API developer guide}
|
73
73
|
#
|
74
|
-
#
|
74
|
+
# @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_data_commands_unified.htm#cli_reference_data_resume_unified command reference
|
75
75
|
#
|
76
76
|
def resume(job_id:, target_org: nil)
|
77
77
|
flags = {
|
@@ -1,16 +1,15 @@
|
|
1
1
|
module SfCli::Sf::Data
|
2
2
|
module Search
|
3
|
-
#
|
3
|
+
# Search objects using SOSL.
|
4
|
+
# @param sosl [String] SOSL
|
5
|
+
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
6
|
+
# @param format [Symbol,String] get the command's raw output. human, csv, json can be available.
|
4
7
|
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# *target_org* --- an alias of paticular org, or username can be used<br>
|
8
|
-
#
|
9
|
-
# *format* --- get the command's raw output. human, csv, json can be available. *NOTE*: if you choose csv, csv files are downloaded in current directory<br>
|
10
|
-
#
|
11
|
-
# ======
|
12
|
-
# # example (in irb):
|
8
|
+
# @return [Hash] the search result
|
9
|
+
# @note if you choose csv as format, csv files are downloaded in current directory
|
13
10
|
#
|
11
|
+
# @example
|
12
|
+
# (in irb):
|
14
13
|
# > sf.data.search "FIND {TIM OR YOUNG OR OIL} IN Name Fields"
|
15
14
|
# =>
|
16
15
|
# {"Lead"=>["00Q5j00000WgEuDEAV"],
|
@@ -24,7 +23,7 @@ module SfCli::Sf::Data
|
|
24
23
|
# "0065j00001XHJLJAA5"],
|
25
24
|
# "User"=>["0055j00000CcL2bAAF", "0055j00000CcL1YAAV"]}
|
26
25
|
#
|
27
|
-
#
|
26
|
+
# @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_data_commands_unified.htm#cli_reference_data_search_unified command reference
|
28
27
|
#
|
29
28
|
def search(sosl, target_org: nil, format: nil)
|
30
29
|
flags = {
|
@@ -1,23 +1,20 @@
|
|
1
1
|
module SfCli::Sf::Data
|
2
2
|
module UpdateRecord
|
3
3
|
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
# *target_org* --- an alias of paticular org, or username can be used<br>
|
15
|
-
#
|
16
|
-
# ==== examples
|
4
|
+
# Update a object record.
|
5
|
+
# @param object_type [Symbol,String] object type(ex. Account)
|
6
|
+
# @param record_id [String] ID of the object
|
7
|
+
# @param where [Hash] field values to identify a record
|
8
|
+
# @param values [Hash] field values for update
|
9
|
+
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
10
|
+
#
|
11
|
+
# @return [String] ID of the record updated
|
12
|
+
#
|
13
|
+
# @example
|
17
14
|
# sf.data.update_record :Account, record_id: 'xxxxxxx', values: {Name: 'New Account Name'}
|
18
15
|
# sf.data.update_record :Hoge__c, where: {Name: 'Jonny B.Good', Country: 'USA'}, values: {Phone: 'xxxxx', bar: 2000}
|
19
16
|
#
|
20
|
-
#
|
17
|
+
# @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_data_commands_unified.htm#cli_reference_data_update_record_unified command reference
|
21
18
|
#
|
22
19
|
def update_record(object_type, record_id: nil, where: nil, values: nil, target_org: nil)
|
23
20
|
where_conditions = field_value_pairs(where)
|
@@ -2,19 +2,16 @@ require_relative './bulk_result_v2'
|
|
2
2
|
|
3
3
|
module SfCli::Sf::Data
|
4
4
|
module UpsertBulk
|
5
|
-
#
|
5
|
+
# Update records using Bulk API 2.0
|
6
|
+
# @param file [String] path of a CSV file to update records
|
7
|
+
# @param sobject [Symbol,String] object type(ex. Account)
|
8
|
+
# @param external_id [String] name of the external ID field.Otherwise it must be Id
|
9
|
+
# @param timeout [Integer] max minutes to wait for the job complete the task
|
10
|
+
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
6
11
|
#
|
7
|
-
#
|
12
|
+
# @return [JobInfo, BulkResultV2] the job result, whose type is changed by situation
|
8
13
|
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
# *external_id* --- Name of the external ID field, or the Id field<br>
|
12
|
-
#
|
13
|
-
# *timeout* --- max minutes to wait for the job complete the task.<br>
|
14
|
-
#
|
15
|
-
# *target_org* --- an alias of paticular org, or username can be used<br>
|
16
|
-
#
|
17
|
-
# ======
|
14
|
+
# @example
|
18
15
|
# # start a upsert job
|
19
16
|
# jobinfo = sf.data.upsert_bulk sobject: :TestCustomObject__c, file: 'upsert.csv' # this returns immediately
|
20
17
|
# jobinfo.id # => "750J4000003g1OaIAI" it's job ID
|
@@ -25,7 +22,7 @@ module SfCli::Sf::Data
|
|
25
22
|
# # Or, you can wait for the job completion with one try.
|
26
23
|
# result = sf.data.upsert_bulk sobject: :TestCustomObject__c, file: 'upsert.csv', timeout: 5 # wait within 5 minutes
|
27
24
|
#
|
28
|
-
#
|
25
|
+
# @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_data_commands_unified.htm#cli_reference_data_upsert_bulk_unified command reference
|
29
26
|
#
|
30
27
|
def upsert_bulk(file:, sobject:, external_id:, timeout: nil, target_org: nil)
|
31
28
|
flags = {
|
@@ -2,15 +2,14 @@ require_relative './bulk_result_v2'
|
|
2
2
|
|
3
3
|
module SfCli::Sf::Data
|
4
4
|
module UpsertResume
|
5
|
-
#
|
5
|
+
# Resume a bulk upsert job you previously started with Bulk API 2.0 and return a bulk result object.
|
6
|
+
# @param job_id [String] job ID you want to resume
|
7
|
+
# @param timeout [Integer] max minutes to wait for the job complete the task
|
8
|
+
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
6
9
|
#
|
7
|
-
#
|
10
|
+
# @return [JobInfo, BulkResultV2] the job result, whose type is changed by situation
|
8
11
|
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
# *target_org* --- an alias of paticular org, or username can be used<br>
|
12
|
-
#
|
13
|
-
# ======
|
12
|
+
# @example
|
14
13
|
# # start a upsert job
|
15
14
|
# jobinfo = sf.data.upsert_bulk sobject: :TestCustomObject__c, file: 'upsert.csv' # this returns immediately
|
16
15
|
# jobinfo.id # => "750J4000003g1OaIAI" it's job ID
|
@@ -22,9 +21,7 @@ module SfCli::Sf::Data
|
|
22
21
|
#
|
23
22
|
# puts 'yey!' if result.job_info.completed? # the job has completed
|
24
23
|
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
# For more command details, see {the command reference}[https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_data_commands_unified.htm#cli_reference_data_upsert_resume_unified]
|
24
|
+
# @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_data_commands_unified.htm#cli_reference_data_upsert_resume_unified command reference
|
28
25
|
#
|
29
26
|
def upsert_resume(job_id:, timeout: nil, target_org: nil)
|
30
27
|
flags = {
|
data/lib/sf_cli/sf/main.rb
CHANGED
@@ -3,24 +3,28 @@ require 'json'
|
|
3
3
|
|
4
4
|
module SfCli
|
5
5
|
module Sf
|
6
|
-
|
7
|
-
# The entry class of sf command. It is returned by sf method.
|
6
|
+
|
7
|
+
# The entry class of sf command. It is returned by the sf method.
|
8
8
|
# With including Singleton module, the instance of this class is guaranteed as singleton.
|
9
9
|
#
|
10
|
-
#
|
10
|
+
# @example
|
11
11
|
# sf # returns a instance of SfCli::Sf
|
12
12
|
# sf.org.display # you can follow the similar syntax to the original command by using method chain.
|
13
13
|
#
|
14
|
+
# @private :nodoc: just for developers
|
14
15
|
class Main
|
15
16
|
include Singleton
|
16
17
|
|
17
|
-
OPERATION_CATEGORIES = %w[Org Sobject Data Project]
|
18
|
+
OPERATION_CATEGORIES = %w[Org Sobject Data Project Apex]
|
18
19
|
|
19
20
|
OPERATION_CATEGORIES.each do |category|
|
20
21
|
require_relative %(#{category.downcase}/core)
|
21
22
|
attr_reader category.downcase.to_sym
|
22
23
|
end
|
23
24
|
|
25
|
+
# Generate each sub command object such as org, data and sobject
|
26
|
+
# so that it can chain like `sf.org.display`.
|
27
|
+
#
|
24
28
|
def initialize
|
25
29
|
OPERATION_CATEGORIES.each do |category|
|
26
30
|
instance_variable_set(:"@#{category.downcase}", Object.const_get(%|::SfCli::Sf::#{category}::Core|).new)
|
@@ -3,8 +3,9 @@ require_relative './class_definition'
|
|
3
3
|
module SfCli
|
4
4
|
module Sf
|
5
5
|
module Model
|
6
|
+
# @private :nodoc: just for developers
|
6
7
|
class Generator
|
7
|
-
attr_reader :
|
8
|
+
attr_reader :connection
|
8
9
|
|
9
10
|
def initialize(connection)
|
10
11
|
@connection = connection
|
@@ -4,6 +4,7 @@ module SfCli
|
|
4
4
|
module Sf
|
5
5
|
module Model
|
6
6
|
module QueryMethods
|
7
|
+
# @private :nodoc: just for developers
|
7
8
|
class QueryCondition
|
8
9
|
attr_reader :connection, :object_name, :all_field_names, :fields, :conditions, :limit_num, :row_order
|
9
10
|
|
@@ -123,7 +124,7 @@ module SfCli
|
|
123
124
|
end
|
124
125
|
|
125
126
|
def take
|
126
|
-
all.first
|
127
|
+
limit(1).all.first
|
127
128
|
end
|
128
129
|
|
129
130
|
def select_fields
|
@@ -5,9 +5,18 @@ require_relative '../org/core'
|
|
5
5
|
module SfCli
|
6
6
|
module Sf
|
7
7
|
module Model
|
8
|
+
#
|
9
|
+
# Connection object to access Salesforce based on Sf command
|
10
|
+
#
|
8
11
|
class SfCommandConnection
|
9
|
-
attr_reader :
|
12
|
+
attr_reader :target_org, :instance_url
|
10
13
|
|
14
|
+
# @private :nodoc: just for developers
|
15
|
+
attr_reader :sf_data, :sf_org, :sf_sobject
|
16
|
+
|
17
|
+
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
18
|
+
# @param instance_url [String] URL of the instance that the org lives on.
|
19
|
+
#
|
11
20
|
def initialize(target_org: nil, instance_url: nil)
|
12
21
|
@sf_org = ::SfCli::Sf::Org::Core.new
|
13
22
|
@sf_data = ::SfCli::Sf::Data::Core.new
|
@@ -24,10 +33,20 @@ module SfCli
|
|
24
33
|
end
|
25
34
|
end
|
26
35
|
|
36
|
+
# Sf command style query interface for Model module
|
37
|
+
#
|
38
|
+
# For query details, see {SfCli::Sf::Data::Query sf data query}
|
39
|
+
#
|
40
|
+
def exec_query(soql, format: nil, bulk: false, timeout: nil, model_class: nil)
|
41
|
+
sf_data.query(soql, target_org: target_org, format: format, bulk: bulk, timeout: timeout, model_class: model_class)
|
42
|
+
end
|
43
|
+
|
44
|
+
# @private :nodoc: just for developers
|
27
45
|
def find(object_type, id, klass)
|
28
46
|
sf_data.get_record object_type, record_id: id, target_org: target_org, model_class: klass
|
29
47
|
end
|
30
48
|
|
49
|
+
# @private :nodoc: just for developers
|
31
50
|
def create(object_type, values, klass = nil)
|
32
51
|
id = sf_data.create_record object_type, values: values, target_org: target_org
|
33
52
|
return id if klass.nil?
|
@@ -35,22 +54,22 @@ module SfCli
|
|
35
54
|
find(object_type, id, klass)
|
36
55
|
end
|
37
56
|
|
57
|
+
# @private :nodoc: just for developers
|
38
58
|
def update(object_type, id, values)
|
39
59
|
sf_data.update_record object_type, record_id: id, where: nil, values: values, target_org: target_org
|
40
60
|
end
|
41
61
|
|
62
|
+
# @private :nodoc: just for developers
|
42
63
|
def delete(object_type, id)
|
43
64
|
sf_data.delete_record object_type, record_id: id, where: nil, target_org: target_org
|
44
65
|
end
|
45
66
|
|
67
|
+
# @private :nodoc: just for developers
|
46
68
|
def query(soql, klass)
|
47
69
|
sf_data.query soql, target_org: target_org, model_class: klass
|
48
70
|
end
|
49
71
|
|
50
|
-
|
51
|
-
sf_data.query(soql, target_org: target_org, format: format, bulk: bulk, timeout: timeout, model_class: model_class)
|
52
|
-
end
|
53
|
-
|
72
|
+
# @private :nodoc: just for developers
|
54
73
|
def describe(object_type)
|
55
74
|
sf_sobject.describe(object_type, target_org: target_org)
|
56
75
|
end
|
data/lib/sf_cli/sf/model.rb
CHANGED
@@ -3,20 +3,22 @@ require_relative 'model/generator'
|
|
3
3
|
module SfCli
|
4
4
|
module Sf
|
5
5
|
#
|
6
|
-
#
|
7
|
-
# The module for \Object \Model definition and generation
|
8
|
-
#
|
9
|
-
# see the section {"Object Model support"}[link://files/README_rdoc.html#label-Object+Model+support+-28experimental-2C+since+0.0.4-29] in README.
|
6
|
+
# The module for object model definition and generation
|
10
7
|
#
|
11
8
|
module Model
|
9
|
+
# The connection object to access Salesforce
|
12
10
|
def self.connection
|
13
11
|
@@connection
|
14
12
|
end
|
15
13
|
|
14
|
+
# set the connection
|
16
15
|
def self.set_connection(conn)
|
17
16
|
@@connection = conn
|
18
17
|
end
|
19
18
|
|
19
|
+
# generate object models
|
20
|
+
# @param object_names [Array] a list of object name
|
21
|
+
#
|
20
22
|
def self.generate(object_names)
|
21
23
|
generator = Generator.new(connection)
|
22
24
|
|
data/lib/sf_cli/sf/org/core.rb
CHANGED
@@ -5,13 +5,13 @@ require_relative './list'
|
|
5
5
|
|
6
6
|
module SfCli
|
7
7
|
module Sf
|
8
|
+
#
|
9
|
+
# Org Commands
|
10
|
+
#
|
11
|
+
# @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_org_commands_unified.htm command reference
|
12
|
+
#
|
8
13
|
module Org
|
9
|
-
#
|
10
|
-
# ==== description
|
11
|
-
# The class representing *sf* *org*.
|
12
|
-
#
|
13
|
-
# https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_org_commands_unified.htm
|
14
|
-
#
|
14
|
+
# @private :nodoc: just for developers
|
15
15
|
class Core
|
16
16
|
include ::SfCli::Sf::Core::Base
|
17
17
|
include Login
|
@@ -3,13 +3,14 @@ module SfCli::Sf::Org
|
|
3
3
|
ConnectionInfo = Struct.new(:id, :access_token, :alias, :instance_url, :user_name, :api_version, :status)
|
4
4
|
|
5
5
|
#
|
6
|
-
#
|
6
|
+
# Returns the org's connection information
|
7
|
+
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
7
8
|
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
# ======
|
11
|
-
# # example (in irb):
|
9
|
+
# @note this function returns the org information including security sensitive things such as access token, username and so on.
|
10
|
+
# @return [ConnectionInfo] the org's connection information
|
12
11
|
#
|
12
|
+
# @example
|
13
|
+
# (in irb):
|
13
14
|
# > sf.org.display
|
14
15
|
# =>
|
15
16
|
# #<struct SfCli::Sf::Org::Display::ConnectionInfo
|
@@ -21,7 +22,7 @@ module SfCli::Sf::Org
|
|
21
22
|
# api_version="61.0",
|
22
23
|
# status="Connected">
|
23
24
|
#
|
24
|
-
#
|
25
|
+
# @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_org_commands_unified.htm#cli_reference_org_display_unified command reference
|
25
26
|
#
|
26
27
|
def display(target_org: nil)
|
27
28
|
flags = {:"target-org" => target_org}
|
data/lib/sf_cli/sf/org/list.rb
CHANGED
@@ -29,23 +29,22 @@ module SfCli::Sf::Org
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
#
|
32
|
+
# List orgs you’ve created or authenticated to
|
33
33
|
#
|
34
|
-
#
|
35
|
-
#
|
34
|
+
# @note this function returns org information including security sensitive things such as access token, username and so on.
|
35
|
+
# @return [OrgConfig] the org configulation
|
36
36
|
#
|
37
|
-
#
|
37
|
+
# @example
|
38
|
+
# org_config_list = sf.org.list # returns a list of OrgConfig
|
38
39
|
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
# - sandbox?
|
42
|
-
# - scratch?
|
43
|
-
# - default?
|
44
|
-
# - default_devhub?
|
40
|
+
# org_config.first.accesstoken # returns the access token
|
41
|
+
# org_config.first.instance_url # returns the org's url
|
45
42
|
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
# org_config.first.
|
43
|
+
# org_config.first.conncected? # check the connection status
|
44
|
+
# org_config.first.devhub? # check if the org is devhub or not
|
45
|
+
# org_config.first.scratch? # check if the org is scratch or not
|
46
|
+
# org_config.first.default? # check if the org is default or not
|
47
|
+
# org_config.first.default_devhub? # check if the org is devhub default or not
|
49
48
|
#
|
50
49
|
# For more command details, see {the command reference}[https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_org_commands_unified.htm#cli_reference_org_list_unified]
|
51
50
|
#
|
data/lib/sf_cli/sf/org/login.rb
CHANGED
@@ -1,18 +1,15 @@
|
|
1
1
|
module SfCli::Sf::Org
|
2
2
|
module Login
|
3
|
-
#
|
3
|
+
# Login to the org by the browser.
|
4
|
+
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
5
|
+
# @param instance_url [String] URL of the instance that the org lives on.
|
6
|
+
# @param browser [Symbol,String] browser in which to open the org.
|
4
7
|
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# *instance_url* --- URL of the instance that the org lives on.
|
8
|
-
#
|
9
|
-
# *browser* --- browser in which to open the org.
|
10
|
-
#
|
11
|
-
# == examples:
|
8
|
+
# @example
|
12
9
|
# sf.org.login_web
|
13
10
|
# sf.org.login_web target_org: :dev
|
14
11
|
#
|
15
|
-
#
|
12
|
+
# @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_org_commands_unified.htm#cli_reference_org_login_web_unified command reference
|
16
13
|
#
|
17
14
|
def login_web(target_org: nil, instance_url: nil, browser: nil)
|
18
15
|
flags = {
|
@@ -24,30 +21,27 @@ module SfCli::Sf::Org
|
|
24
21
|
exec(action, flags: flags)
|
25
22
|
end
|
26
23
|
|
27
|
-
#
|
28
|
-
#
|
29
|
-
# NOTE: this method doesn't support user interactive mode, so *SF_ACCESS_TOKEN* environment variable must be set before call this method.
|
24
|
+
# Login to the org by access token.
|
25
|
+
# @note This method doesn't support user interactive mode, so *SF_ACCESS_TOKEN* environment variable must be set before call this method.
|
30
26
|
#
|
31
|
-
#
|
27
|
+
# @param target_org [Symbol,String] an alias of paticular org, or username can be used
|
28
|
+
# @param instance_url [String] URL of the instance that the org lives on.
|
32
29
|
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
# ======
|
30
|
+
# @example
|
36
31
|
# ENV['SF_ACCESS_TOKEN'] = 'xxxxxxxxxx'
|
37
32
|
# sf.org.login_access_token instance_url: https://hoge.bar.baz.salesforce.com
|
38
33
|
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
# For more command details, see {the command reference}[https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_org_commands_unified.htm#cli_reference_org_login_access-token_unified]
|
34
|
+
# How to set env variable outside of Ruby::
|
35
|
+
# In Unix/mac::
|
36
|
+
# $ SF_ACCESS_TOKEN='xxxxxxxxxx'
|
37
|
+
# $ ruby app_using_sfcli.rb
|
38
|
+
# OR
|
39
|
+
# $ SF_ACCESS_TOKEN='xxxxxxxxxx' ruby app_using_sfcli.rb
|
40
|
+
# In Windows::
|
41
|
+
# $ set SF_ACCESS_TOKEN=xxxxxxxxxx
|
42
|
+
# $ ruby app_using_sfcli.rb
|
43
|
+
#
|
44
|
+
# @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_org_commands_unified.htm#cli_reference_org_login_access-token_unified command reference
|
51
45
|
#
|
52
46
|
def login_access_token(instance_url:, target_org: nil)
|
53
47
|
flags = {
|