sf_cli 0.0.7 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/{rdoc/README.rdoc → README.rdoc} +25 -39
  3. data/lib/sf_cli/console/commands.rb +52 -0
  4. data/lib/sf_cli/console.rb +5 -0
  5. data/lib/sf_cli/sf/apex/core.rb +5 -6
  6. data/lib/sf_cli/sf/apex/run.rb +32 -42
  7. data/lib/sf_cli/sf/core/base.rb +8 -0
  8. data/lib/sf_cli/sf/data/bulk_result_v2.rb +2 -3
  9. data/lib/sf_cli/sf/data/core.rb +5 -6
  10. data/lib/sf_cli/sf/data/create_record.rb +9 -9
  11. data/lib/sf_cli/sf/data/delete_bulk.rb +32 -16
  12. data/lib/sf_cli/sf/data/delete_record.rb +11 -10
  13. data/lib/sf_cli/sf/data/delete_resume.rb +14 -14
  14. data/lib/sf_cli/sf/data/get_record.rb +11 -13
  15. data/lib/sf_cli/sf/data/helper_methods.rb +1 -0
  16. data/lib/sf_cli/sf/data/query.rb +32 -35
  17. data/lib/sf_cli/sf/data/query_helper.rb +3 -0
  18. data/lib/sf_cli/sf/data/resume.rb +9 -7
  19. data/lib/sf_cli/sf/data/search.rb +12 -11
  20. data/lib/sf_cli/sf/data/update_record.rb +19 -20
  21. data/lib/sf_cli/sf/data/upsert_bulk.rb +33 -19
  22. data/lib/sf_cli/sf/data/upsert_resume.rb +12 -13
  23. data/lib/sf_cli/sf/main.rb +7 -3
  24. data/lib/sf_cli/sf/model/base_methods.rb +1 -0
  25. data/lib/sf_cli/sf/model/class_definition.rb +1 -0
  26. data/lib/sf_cli/sf/model/dml_methods.rb +1 -0
  27. data/lib/sf_cli/sf/model/generator.rb +2 -1
  28. data/lib/sf_cli/sf/model/query_condition.rb +1 -0
  29. data/lib/sf_cli/sf/model/query_methods.rb +6 -0
  30. data/lib/sf_cli/sf/model/sf_command_connection.rb +24 -5
  31. data/lib/sf_cli/sf/model.rb +6 -4
  32. data/lib/sf_cli/sf/org/core.rb +6 -6
  33. data/lib/sf_cli/sf/org/display.rb +10 -8
  34. data/lib/sf_cli/sf/org/list.rb +12 -13
  35. data/lib/sf_cli/sf/org/login.rb +22 -28
  36. data/lib/sf_cli/sf/project/core.rb +10 -72
  37. data/lib/sf_cli/sf/project/generate.rb +35 -0
  38. data/lib/sf_cli/sf/project/generate_manifest.rb +31 -0
  39. data/lib/sf_cli/sf/sobject/core.rb +10 -47
  40. data/lib/sf_cli/sf/sobject/describe.rb +31 -0
  41. data/lib/sf_cli/sf/sobject/list.rb +20 -0
  42. data/lib/sf_cli.rb +5 -12
  43. metadata +13 -12
  44. data/CHANGELOG.md +0 -57
  45. data/lib/sf_cli/sf/console.rb +0 -33
  46. data/rdoc/ObjectModel.rdoc +0 -83
@@ -29,23 +29,22 @@ module SfCli::Sf::Org
29
29
  end
30
30
  end
31
31
 
32
- # \List orgs you’ve created or authenticated to
32
+ # List orgs you’ve created or authenticated to
33
33
  #
34
- # ======
35
- # org_config_list = sf.org.list # returns a list of OrgConfig
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
- # \OrgConfig object has a org information including security sensitive things such as access token, username and so on.
37
+ # @example
38
+ # org_config_list = sf.org.list # returns a list of OrgConfig
38
39
  #
39
- # It also has some methods to identify its org type:
40
- # - devhub?
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
- # and you can check the org connected like this:
47
- # org_config_list = sf.org.list # returns a list of OrgConfig
48
- # org_config.first.conncected?
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
  #
@@ -1,18 +1,15 @@
1
1
  module SfCli::Sf::Org
2
2
  module Login
3
- # login to the org by the browser.
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
- # *target_org* --- an alias of paticular org, or username can be used<br>
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
- # 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_web_unified]
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
- # login to the org by access token.
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
- # *instance_url* --- URL of the instance that the org lives on.
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
- # *target_org* --- an alias of paticular org, or username can be used<br>
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
- # == how to set env variable outside of ruby
40
- # In Unix/mac:
41
- # $ SF_ACCESS_TOKEN='xxxxxxxxxx'
42
- # $ ruby app_using_sfcli.rb
43
- # or
44
- # $ SF_ACCESS_TOKEN='xxxxxxxxxx' ruby app_using_sfcli.rb
45
- #
46
- # In Windows:
47
- # $ set SF_ACCESS_TOKEN=xxxxxxxxxx
48
- # $ ruby app_using_sfcli.rb
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 = {
@@ -1,82 +1,20 @@
1
1
  require_relative '../core/base'
2
+ require_relative './generate'
3
+ require_relative './generate_manifest'
2
4
 
3
5
  module SfCli
4
6
  module Sf
7
+ #
8
+ # Project Commands
9
+ #
10
+ # @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_project_commands_unified.htm command reference
11
+ #
5
12
  module Project
6
- # ==== description
7
- # The class representing *sf* *project*
8
- #
9
- # command reference: https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_project_commands_unified.htm
10
- #
13
+ # @private :nodoc: just for developers
11
14
  class Core
12
15
  include ::SfCli::Sf::Core::Base
13
-
14
- GenerateResult = Struct.new(:output_dir, :files, :raw_output, :warnings)
15
-
16
- #
17
- # generate a Salesforce project
18
- #
19
- # *name* --- project name<br>
20
- #
21
- # *template* --- project template name<br>
22
- #
23
- # *output_dir* --- output directory<br>
24
- #
25
- # *manifest* --- switch to create manifest file in the project directory (manifest/package.xml). default: false
26
- #
27
- # For more command details, see the {reference document}[https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_project_commands_unified.htm#cli_reference_project_generate_unified]
28
- #
29
- def generate(name, manifest: false, template: nil, output_dir: nil)
30
- flags = {
31
- :name => name,
32
- :template => template,
33
- :"output-dir" => output_dir,
34
- }
35
- switches = {
36
- manifest: manifest,
37
- }
38
- json = exec(__method__, flags: flags, switches: switches, redirection: :null_stderr)
39
-
40
- GenerateResult.new(
41
- output_dir: json['result']['outputDir'],
42
- files: json['result']['created'],
43
- raw_output: json['result']['rawOutput'],
44
- warnings: json['warnings']
45
- )
46
- end
47
-
48
- # generate the manifest file of a Salesforce project
49
- #
50
- # *metadata* --- an array that consists of metadata type like CustomObject, Layout and so on. (default: [])<br>
51
- #
52
- # *api_verson* --- api version (default: nil)<br>
53
- #
54
- # *output_dir* --- manifest's output directory in the project directory. You can use relative path from the project root (default: nil)<br>
55
- #
56
- # *from_org* --- username or alias of the org that contains the metadata components from which to build a manifest (default: nil)<br>
57
- #
58
- # *source_dir* --- paths to the local source files to include in the manifest (default: nil)
59
- #
60
- # ======
61
- # sf.project.generate_manifest metadata: %w[CustomObject Layout] # creates a package.xml, which is initialized with CustomObject and Layout
62
- # sf.project.generate_manifest from_org: <org_name> # creates a package.xml, which is initialized with all metadata types in the org
63
- #
64
- # For more command details, see the {reference document}[https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_project_commands_unified.htm#cli_reference_project_generate_manifest_unified]
65
- #
66
- def generate_manifest(name: nil, output_dir: nil, api_version: nil, metadata: [], from_org: nil, source_dir: nil)
67
- flags = {
68
- :name => name,
69
- :"metadata" => (metadata.empty? ? nil : metadata.join(' ')),
70
- :"from-org" => from_org,
71
- :"source-dir" => source_dir,
72
- :"output-dir" => output_dir,
73
- :"api-version" => api_version,
74
- }
75
- action = __method__.to_s.tr('_', ' ')
76
- json = exec(action, flags: flags, redirection: :null_stderr)
77
-
78
- json['result']['path']
79
- end
16
+ include Generate
17
+ include GenerateManifest
80
18
  end
81
19
  end
82
20
  end
@@ -0,0 +1,35 @@
1
+ module SfCli::Sf::Project
2
+ module Generate
3
+ GenerateResult = Struct.new(:output_dir, :files, :raw_output, :warnings)
4
+
5
+ #
6
+ # Generate a Salesforce project
7
+ # @param name [Symbol,String] project name
8
+ # @param template [Symbol,String] project template name
9
+ # @param output_dir [String] output directory
10
+ # @param manifest [Boolian] switch to create manifest file in the project directory (manifest/package.xml)
11
+ #
12
+ # @return [GenerateResult] the retsult of project generation
13
+ #
14
+ # @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_project_commands_unified.htm#cli_reference_project_generate_unified command reference
15
+ #
16
+ def generate(name, manifest: false, template: nil, output_dir: nil)
17
+ flags = {
18
+ :name => name,
19
+ :template => template,
20
+ :"output-dir" => output_dir,
21
+ }
22
+ switches = {
23
+ manifest: manifest,
24
+ }
25
+ json = exec(__method__, flags: flags, switches: switches, redirection: :null_stderr)
26
+
27
+ GenerateResult.new(
28
+ output_dir: json['result']['outputDir'],
29
+ files: json['result']['created'],
30
+ raw_output: json['result']['rawOutput'],
31
+ warnings: json['warnings']
32
+ )
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,31 @@
1
+ module SfCli::Sf::Project
2
+ module GenerateManifest
3
+ # Generate the manifest file of a Salesforce DX project
4
+ # @param metadata [Array] an array that consists of metadata type like CustomObject, Layout and so on. (default: [])
5
+ # @param api_version [Integer] API version (default: nil)
6
+ # @param output_dir [String] manifest's output directory in the project directory. You can use relative path from the project root (default: nil)
7
+ # @param from_org [String] username or alias of the org that contains the metadata components from which to build a manifest (default: nil)
8
+ # @param source_dir [String] paths to the local source files to include in the manifest (default: nil)
9
+ #
10
+ # @example
11
+ # sf.project.generate_manifest metadata: %w[CustomObject Layout] # creates a package.xml, which is initialized with CustomObject and Layout
12
+ # sf.project.generate_manifest from_org: org_name # creates a package.xml, which is initialized with all metadata types in the org
13
+ #
14
+ # @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_project_commands_unified.htm#cli_reference_project_generate_manifest_unified command reference
15
+ #
16
+ def generate_manifest(name: nil, output_dir: nil, api_version: nil, metadata: [], from_org: nil, source_dir: nil)
17
+ flags = {
18
+ :name => name,
19
+ :"metadata" => (metadata.empty? ? nil : metadata.join(' ')),
20
+ :"from-org" => from_org,
21
+ :"source-dir" => source_dir,
22
+ :"output-dir" => output_dir,
23
+ :"api-version" => api_version,
24
+ }
25
+ action = __method__.to_s.tr('_', ' ')
26
+ json = exec(action, flags: flags, redirection: :null_stderr)
27
+
28
+ json['result']['path']
29
+ end
30
+ end
31
+ end
@@ -1,57 +1,20 @@
1
1
  require_relative '../core/base'
2
- require_relative './schema'
2
+ require_relative './describe'
3
+ require_relative './list'
3
4
 
4
5
  module SfCli
5
6
  module Sf
7
+ #
8
+ # SObject Commands
9
+ #
10
+ # @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_sobject_commands_unified.htm command reference
11
+ #
6
12
  module Sobject
7
- # ==== description
8
- # The class representing *sf* *sobject*
9
- #
10
- # command reference: https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_sobject_commands_unified.htm
11
- #
13
+ # @private :nodoc: just for developers
12
14
  class Core
13
15
  include ::SfCli::Sf::Core::Base
14
-
15
- # returns a schema object containing the Salesforce object schema
16
- #
17
- # *objectType* --- object type (ex: Account)<br>
18
- #
19
- # *target_org* --- an alias of paticular org, or username can be used<br>
20
- #
21
- # ======
22
- # schema = sf.sobject.describe :Account
23
- # schema.name # Account
24
- # schema.label # Account
25
- # schema.field_names # [:Id, :Name, ....]
26
- # schema.fields[:Name] # => {"aggregatable"=>true, "aiPredictionField"=>false, "autoNumber"=>false,...}
27
- #
28
- # 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_sobject_commands_unified.htm#cli_reference_sobject_describe_unified]
29
- #
30
- def describe(object_type, target_org: nil)
31
- flags = {
32
- :"sobject" => object_type,
33
- :"target-org" => target_org,
34
- }
35
- json = exec(__method__, flags: flags, redirection: :null_stderr)
36
- Schema.new(json['result'])
37
- end
38
-
39
- # returns a list of Salesforce object name
40
- #
41
- # *object_type* --- all or custom<br>
42
- #
43
- # *target_org* --- an alias of paticular org, or username can be used<br>
44
- #
45
- # 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_sobject_commands_unified.htm#cli_reference_sobject_list_unified]
46
- #
47
- def list(object_type, target_org: nil)
48
- flags = {
49
- :"sobject" => (object_type.to_sym == :custom ? :custom : :all),
50
- :"target-org" => target_org,
51
- }
52
- json = exec(__method__, flags: flags, redirection: :null_stderr)
53
- json['result']
54
- end
16
+ include Describe
17
+ include List
55
18
  end
56
19
  end
57
20
  end
@@ -0,0 +1,31 @@
1
+ require_relative './schema'
2
+
3
+ module SfCli::Sf::Sobject
4
+ module Describe
5
+ # Returns a schema object containing the Salesforce object schema
6
+ # @param object_type [Symbol,String] object type(ex: Account)
7
+ # @param target_org [Symbol,String] an alias of paticular org, or username can be used
8
+ # @param api_version [Numeric] override the api version used for api requests made by this command
9
+ #
10
+ # @return [Schema] a schema object that represents the object schema
11
+ #
12
+ # @example
13
+ # schema = sf.sobject.describe :Account
14
+ # schema.name # Account
15
+ # schema.label # Account
16
+ # schema.field_names # [:Id, :Name, ....]
17
+ # schema.fields[:Name] # => {"aggregatable"=>true, "aiPredictionField"=>false, "autoNumber"=>false,...}
18
+ #
19
+ # @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_sobject_commands_unified.htm#cli_reference_sobject_describe_unified command reference
20
+ #
21
+ def describe(object_type, target_org: nil, api_version: nil)
22
+ flags = {
23
+ :"sobject" => object_type,
24
+ :"target-org" => target_org,
25
+ :"api-version" => api_version,
26
+ }
27
+ json = exec(__method__, flags: flags, redirection: :null_stderr)
28
+ Schema.new(json['result'])
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,20 @@
1
+ module SfCli::Sf::Sobject
2
+ module List
3
+ # Returns a list of Salesforce object name
4
+ # @param object_type [Symbol,String] 'all' or 'custom'
5
+ # @param target_org [Symbol,String] an alias of paticular org, or username can be used
6
+ # @param api_version [Numeric] override the api version used for api requests made by this command
7
+ #
8
+ # @see https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_sobject_commands_unified.htm#cli_reference_sobject_list_unified command reference
9
+ #
10
+ def list(object_type, target_org: nil, api_version: nil)
11
+ flags = {
12
+ :"sobject" => (object_type.to_sym == :custom ? :custom : :all),
13
+ :"target-org" => target_org,
14
+ :"api-version" => api_version,
15
+ }
16
+ json = exec(__method__, flags: flags, redirection: :null_stderr)
17
+ json['result']
18
+ end
19
+ end
20
+ end
data/lib/sf_cli.rb CHANGED
@@ -1,18 +1,11 @@
1
1
  require 'sf_cli/sf/main'
2
- #
3
- # the global method that represents *sf* command.
2
+
3
+ # The global method that represents *sf* command.
4
4
  #
5
5
  # With method chaining, you can use similar syntax as original command.
6
- #
7
- # == examples
8
- #
9
- # ======
10
- # sf.org.display # => returns the org information object
11
- #
12
- # ======
13
- # sf.data.query "SELECT Name FROM Account" # => [{"Name"=>"Aethna Home Products"}]
14
- #
15
- # For details of sf command, see the {reference guide}[https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_unified.htm]
6
+ # @example
7
+ # sf.org.display # returns the org information object
8
+ # sf.data.query "SELECT Name FROM Account" # [{"Name"=>"Aethna Home Products"}]
16
9
  #
17
10
  def sf
18
11
  SfCli::Sf::Main.instance
metadata CHANGED
@@ -1,30 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sf_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takanobu Maekawa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-18 00:00:00.000000000 Z
11
+ date: 2024-09-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: This is a class library for introducing Salesforce CLI to Ruby scripting.
14
- Currenty only sf command is the target of development.
13
+ description: A class library for introducing Salesforce CLI to Ruby scripting. Currenty
14
+ only sf command is the target of development.
15
15
  email:
16
16
  executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files:
19
- - rdoc/ObjectModel.rdoc
20
- - rdoc/README.rdoc
21
- - CHANGELOG.md
19
+ - README.rdoc
22
20
  files:
23
- - CHANGELOG.md
21
+ - README.rdoc
24
22
  - lib/sf_cli.rb
23
+ - lib/sf_cli/console.rb
24
+ - lib/sf_cli/console/commands.rb
25
25
  - lib/sf_cli/sf/apex/core.rb
26
26
  - lib/sf_cli/sf/apex/run.rb
27
- - lib/sf_cli/sf/console.rb
28
27
  - lib/sf_cli/sf/core/base.rb
29
28
  - lib/sf_cli/sf/data/bulk_result_v2.rb
30
29
  - lib/sf_cli/sf/data/core.rb
@@ -55,10 +54,12 @@ files:
55
54
  - lib/sf_cli/sf/org/list.rb
56
55
  - lib/sf_cli/sf/org/login.rb
57
56
  - lib/sf_cli/sf/project/core.rb
57
+ - lib/sf_cli/sf/project/generate.rb
58
+ - lib/sf_cli/sf/project/generate_manifest.rb
58
59
  - lib/sf_cli/sf/sobject/core.rb
60
+ - lib/sf_cli/sf/sobject/describe.rb
61
+ - lib/sf_cli/sf/sobject/list.rb
59
62
  - lib/sf_cli/sf/sobject/schema.rb
60
- - rdoc/ObjectModel.rdoc
61
- - rdoc/README.rdoc
62
63
  homepage: https://github.com/tmkw/sf_cli
63
64
  licenses:
64
65
  - MIT
@@ -83,5 +84,5 @@ requirements:
83
84
  rubygems_version: 3.5.11
84
85
  signing_key:
85
86
  specification_version: 4
86
- summary: A library for using Salesforce CLI in Ruby
87
+ summary: A library for Salesforce CLI in Ruby
87
88
  test_files: []
data/CHANGELOG.md DELETED
@@ -1,57 +0,0 @@
1
- ## 0.0.7 - 2024-09-19
2
- - NEW: add `sf.apex.run`
3
- ## 0.0.6 - 2024-09-16
4
- - NEW: Object Model Support renewal;
5
- - `SfCli::Sf::Model.connection` represents the connection to Salesforce. It can be set by `set_connection` class method in the module. As of now there is only `SfCommandConnection`, which is based on sf command, as connection adapter. After the connection is set by `set_connection`, it is also automatically set to classes when `SfCli::Sf::Model.generate` method is called.
6
- - Each object model class has `create` class method for creating a new record.
7
- - Each object model has `#save` and `#delete` instance methods to create, update and delete the record it represents.
8
- - Each object class has query interface such as `where`, `select`, `limit` and `order` methods that can be chainable.
9
- - Each object class has query interface such as `find`, `all`, `take` and `pluck`.
10
- - CHANGE: `sf.sobject.describe` changed to return `schema` object.
11
- ## 0.0.5 - 2024-09-08
12
- - CHANGE: target CLI version is changed: from 2.54.6 to 2.56.7
13
- - NEW: new command features are added;
14
- - `--bulk` option to `sf.data.query`
15
- - `sf.data.query_resume`
16
- - `sf.data.upsert_bulk`
17
- - `sf.data.upsert_resume`
18
- - `sf.data.delete_bulk`
19
- - `sf.data.delete_resume`
20
- - `sf.data.resume`
21
- - `sf.data.search`
22
- - `sf.org.list`
23
- - `sf.login_access_token`
24
- - `--browser` option to `sf.login_web`
25
- ## 0.0.4 - 2024-09-02
26
- - breaking change:
27
- - Sf class doesn't exist anymore. You can not write like `sf = SfCli::Sf.new`. Instead of that, global `sf` method is introduced. You can directly type like `sf.org.display`, which is as almost same usability as the original command.
28
- - sf data query:
29
- - support child-parent relationship
30
- - support parent-children relationship
31
- - add `--result-format` option
32
- - auto generation of \Object Model (experimental)
33
- - generates SF \Object Classes automatically
34
- - relationship is supported
35
-
36
- ## 0.0.3 - 2024-08-25
37
- add command operations:
38
-
39
- - sf data get record
40
- - sf data create record
41
- - sf data update record
42
- - sf data delete record
43
-
44
- ## 0.0.2 - 2024-08-18
45
- this version up was made by mistake.
46
- nothing was changed.
47
-
48
- ## 0.0.1 - 2024-08-18
49
- support some command operations:
50
-
51
- - sf org login web
52
- - sf display
53
- - sf data query
54
- - sf sobject describe
55
- - sf sobject list
56
- - sf project generate
57
- - sf project generate manifest
@@ -1,33 +0,0 @@
1
- require 'sf_cli'
2
- require 'sf_cli/sf/model'
3
- require 'sf_cli/sf/model/sf_command_connection'
4
- require 'stringio'
5
-
6
- def sf_init(org_alias)
7
- org_info = sf.org.display target_org: org_alias
8
- conn = SfCli::Sf::Model::SfCommandConnection.new target_org: org_alias, instance_url: org_info.instance_url
9
- SfCli::Sf::Model.set_connection conn
10
- end
11
-
12
- def generate(*object_types)
13
- SfCli::Sf::Model.generate object_types
14
- end
15
-
16
- def connection
17
- SfCli::Sf::Model.connection
18
- end
19
-
20
- def target_org
21
- connection.target_org
22
- end
23
-
24
- def apex(apex_code)
25
- sf.apex.run target_org: target_org, file: StringIO.new(apex_code)
26
- end
27
-
28
- alias :sfinit :sf_init
29
- alias :gen :generate
30
- alias :conn :connection
31
- alias :org :target_org
32
-
33
- sfinit ARGV[0]
@@ -1,83 +0,0 @@
1
- == \Object Model support
2
- === generate Models
3
- require 'sf_cli/sf/model'
4
- require 'sf_cli/sf/model/sf_command_connection'
5
-
6
- # first, you must prepare the connection
7
- conn = SfCli::Sf::Model::SfCommandConnection.new target_org: your_org, instance_url: your_org_url
8
-
9
- # then set it to Model module
10
- SfCli::Sf::Model.set_connection conn
11
-
12
- # generates some model classes (for example, Account and Contact)
13
- SfCli::Sf::Model.generate %w[Account Contact]
14
- === apply to sf command
15
- rows = sf.data.query "SELECT Id, Name FROM Contact WHERE Name = 'Akin Kristen'", model_class: Contact
16
-
17
- # the array object contains Contact object instances
18
- rows.size # 1
19
- rows.first # <Contact: @Id="0035j00001RW3xbAAD", @Name="Akin Kristen">
20
- rows.first.Name # Akin Kristen
21
-
22
- === using models Independently
23
- ==== initialize and save a record
24
- c = Contact.new(:Name => "John Smith")
25
- c.Name # "John Smith"
26
- c.save
27
-
28
- ==== find and update a record
29
- # find by record ID and update
30
- c2 = Contact.find(c.id)
31
- c2.Name = "Johnny Smith"
32
- c2.save # update
33
-
34
- ==== delete a record
35
- c2 = Contact.find(c.id)
36
- c2.delete
37
-
38
- ==== query and get a record
39
- contact = Contact.select(:Id, :Name).where(Name: 'Akin Kristen').take
40
- contact # => #<Contact: @Id="0035j00001RW3xbAAD", @Name="Akin Kristen">
41
- contact.Name # Akin Kristen
42
-
43
- # these 2 example are the same meaning
44
- Contact.select(Name).where(Name: 'John Smith', LastModifiedDate: :Yesterday).take
45
- Contact.select(Name).where(Name: 'John Smith').where(LastModifiedDate: :Yesterday).take
46
-
47
- ==== query and get records
48
- contacts = Contact.select(:Id, :Name).where(LastModifiedDate: :Yesterday).all # get all records that is modified yesterday
49
-
50
- ==== child-parent relationship
51
- contact = Contact.select(:Id, :Name, "Account.Name").where(Name: 'Akin Kristen').take
52
- contact # <Contact: @Id="0035j00001RW3xbAAD", @Name="Akin Kristen", @Account= #<Account @Name="Aethna Home Products">>
53
- contact.Account.Name # Aethna Home Products
54
-
55
- ==== parent-children relationship
56
- account = Account.select(:Id, :Name, "(SELECT Name FROM Contacts)").take
57
- account # <Account @Contacts=[#<Contact @Name="Akin Kristen">], @Id="0015j00001dsDuhAAE", @Name="Aethna Home Products">
58
- account.Name # Aethna Home Products
59
- rows.Contacts # [#<Contact @Name="Akin Kristen">]
60
- rows.Contacts.first.Name # Akin Kristen
61
-
62
- ==== get all fields in a record
63
- # just by not using 'select' method
64
- contact = Contact.find(record_id) # <Contact @Id="...", @Name="...", other fields...>
65
-
66
- ==== time keywords such as 'yesterday' or 'LAST_N_DAYS:N' with symbol style
67
- Contact.select(:Name).where(LastModifiedDate: :Yesterday).take # "SELECT Id, Name FROM Contact WHERE LastModifiedDate = Yesterday"
68
- Contact.select(:Name).where(LastModifiedDate: :"LAST_N_DAYS:5").take # "SELECT Id, Name FROM Contact WHERE LastModifiedDate = LAST_N_DAYS:5"
69
-
70
- ==== array for 'IN' keyword
71
- Contact.select(:Name).where(Name: ['Jonny Good', 'John Smith']).all # same as "SELECT Name FROM Contact WHERE Name IN ('Jonny Good', 'John Smith')"
72
-
73
- ==== using partial soql directly
74
- Contact.select("Id, Name").where("LastModifiedDate = LAST_N_DAYS:5").all
75
-
76
- ==== ternary style
77
- Contact.select(:Id, :Name).where(:LastModifiedDate, :>=, :"LAST_N_DAYS:5").all # SELECT Id, Name FROM Contact WHERE LastModifiedDate >= LAST_N_DAYS:5
78
- Account.select(:Id, :Name).where(:Name, :LIKE, "%OIL%").all # SELECT Id, Name FROM Account WHERE Name LIKE '%OIL%'
79
-
80
- ==== get schema
81
- schema = Account.describe
82
- schema.name # Account
83
- schema.field_names # [Id, Name, ....]