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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +39 -115
  3. data/lib/sf_cli/console/commands.rb +36 -0
  4. data/lib/sf_cli/console.rb +5 -0
  5. data/lib/sf_cli/sf/apex/core.rb +18 -0
  6. data/lib/sf_cli/sf/apex/run.rb +113 -0
  7. data/lib/sf_cli/sf/core/base.rb +1 -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 +6 -8
  11. data/lib/sf_cli/sf/data/delete_bulk.rb +9 -10
  12. data/lib/sf_cli/sf/data/delete_record.rb +8 -9
  13. data/lib/sf_cli/sf/data/delete_resume.rb +7 -9
  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 +20 -27
  17. data/lib/sf_cli/sf/data/query_helper.rb +3 -0
  18. data/lib/sf_cli/sf/data/resume.rb +6 -6
  19. data/lib/sf_cli/sf/data/search.rb +9 -10
  20. data/lib/sf_cli/sf/data/update_record.rb +11 -14
  21. data/lib/sf_cli/sf/data/upsert_bulk.rb +9 -12
  22. data/lib/sf_cli/sf/data/upsert_resume.rb +7 -10
  23. data/lib/sf_cli/sf/main.rb +8 -4
  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 +2 -1
  29. data/lib/sf_cli/sf/model/query_methods.rb +1 -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 +7 -6
  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 +29 -0
  41. data/lib/sf_cli/sf/sobject/list.rb +18 -0
  42. data/lib/sf_cli.rb +5 -12
  43. metadata +11 -8
  44. data/CHANGELOG.md +0 -55
  45. data/bin/sfc +0 -7
  46. data/lib/sf_cli/sf/console.rb +0 -26
@@ -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,29 @@
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
+ #
9
+ # @return [Schema] a schema object that represents the object schema
10
+ #
11
+ # @example
12
+ # schema = sf.sobject.describe :Account
13
+ # schema.name # Account
14
+ # schema.label # Account
15
+ # schema.field_names # [:Id, :Name, ....]
16
+ # schema.fields[:Name] # => {"aggregatable"=>true, "aiPredictionField"=>false, "autoNumber"=>false,...}
17
+ #
18
+ # @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
19
+ #
20
+ def describe(object_type, target_org: nil)
21
+ flags = {
22
+ :"sobject" => object_type,
23
+ :"target-org" => target_org,
24
+ }
25
+ json = exec(__method__, flags: flags, redirection: :null_stderr)
26
+ Schema.new(json['result'])
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,18 @@
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
+ #
7
+ # @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
8
+ #
9
+ def list(object_type, target_org: nil)
10
+ flags = {
11
+ :"sobject" => (object_type.to_sym == :custom ? :custom : :all),
12
+ :"target-org" => target_org,
13
+ }
14
+ json = exec(__method__, flags: flags, redirection: :null_stderr)
15
+ json['result']
16
+ end
17
+ end
18
+ 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.beta2
4
+ version: 0.0.8
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-16 00:00:00.000000000 Z
11
+ date: 2024-09-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This is a class library for introducing Salesforce CLI to Ruby scripting.
14
14
  Currenty only sf command is the target of development.
15
15
  email:
16
- executables:
17
- - sfc
16
+ executables: []
18
17
  extensions: []
19
18
  extra_rdoc_files:
20
19
  - README.rdoc
21
- - CHANGELOG.md
22
20
  files:
23
- - CHANGELOG.md
24
21
  - README.rdoc
25
- - bin/sfc
26
22
  - lib/sf_cli.rb
27
- - lib/sf_cli/sf/console.rb
23
+ - lib/sf_cli/console.rb
24
+ - lib/sf_cli/console/commands.rb
25
+ - lib/sf_cli/sf/apex/core.rb
26
+ - lib/sf_cli/sf/apex/run.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,7 +54,11 @@ 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
63
  homepage: https://github.com/tmkw/sf_cli
61
64
  licenses:
data/CHANGELOG.md DELETED
@@ -1,55 +0,0 @@
1
- ## 0.0.6 - 2024-09-16
2
- - NEW: Object Model Support renewal;
3
- - `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.
4
- - Each object model class has `create` class method for creating a new record.
5
- - Each object model has `#save` and `#delete` instance methods to create, update and delete the record it represents.
6
- - Each object class has query interface such as `where`, `select`, `limit` and `order` methods that can be chainable.
7
- - Each object class has query interface such as `find`, `all`, `take` and `pluck`.
8
- - CHANGE: `sf.sobject.describe` changed to return `schema` object.
9
- ## 0.0.5 - 2024-09-08
10
- - CHANGE: target CLI version is changed: from 2.54.6 to 2.56.7
11
- - NEW: new command features are added;
12
- - `--bulk` option to `sf.data.query`
13
- - `sf.data.query_resume`
14
- - `sf.data.upsert_bulk`
15
- - `sf.data.upsert_resume`
16
- - `sf.data.delete_bulk`
17
- - `sf.data.delete_resume`
18
- - `sf.data.resume`
19
- - `sf.data.search`
20
- - `sf.org.list`
21
- - `sf.login_access_token`
22
- - `--browser` option to `sf.login_web`
23
- ## 0.0.4 - 2024-09-02
24
- - breaking change:
25
- - 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.
26
- - sf data query:
27
- - support child-parent relationship
28
- - support parent-children relationship
29
- - add `--result-format` option
30
- - auto generation of \Object Model (experimental)
31
- - generates SF \Object Classes automatically
32
- - relationship is supported
33
-
34
- ## 0.0.3 - 2024-08-25
35
- add command operations:
36
-
37
- - sf data get record
38
- - sf data create record
39
- - sf data update record
40
- - sf data delete record
41
-
42
- ## 0.0.2 - 2024-08-18
43
- this version up was made by mistake.
44
- nothing was changed.
45
-
46
- ## 0.0.1 - 2024-08-18
47
- support some command operations:
48
-
49
- - sf org login web
50
- - sf display
51
- - sf data query
52
- - sf sobject describe
53
- - sf sobject list
54
- - sf project generate
55
- - sf project generate manifest
data/bin/sfc DELETED
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'rake'
4
-
5
- Rake.application.init
6
- Rake.application.define_task(Rake::Task, :default) { system('irb -r sf_cli/sf/console') }
7
- Rake.application.top_level
@@ -1,26 +0,0 @@
1
- require 'sf_cli'
2
- require 'sf_cli/sf/model'
3
- require 'sf_cli/sf/model/sf_command_connection'
4
-
5
- def sf_init(org_alias)
6
- org_info = sf.org.display target_org: org_alias
7
- conn = SfCli::Sf::Model::SfCommandConnection.new target_org: org_alias, instance_url: org_info.instance_url
8
- SfCli::Sf::Model.set_connection conn
9
- end
10
-
11
- def generate(*object_types)
12
- SfCli::Sf::Model.generate object_types
13
- end
14
-
15
- def connection
16
- SfCli::Sf::Model.connection
17
- end
18
-
19
- def target_org
20
- connection.target_org
21
- end
22
-
23
- alias :sfinit :sf_init
24
- alias :gen :generate
25
- alias :conn :connection
26
- alias :org :target_org