@suitegeezus/suitecloud-stacker 25.2.127

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 (113) hide show
  1. package/.idea/compiler.xml +6 -0
  2. package/.idea/git_toolbox_blame.xml +6 -0
  3. package/.idea/git_toolbox_prj.xml +15 -0
  4. package/.idea/misc.xml +6 -0
  5. package/.idea/modules.xml +8 -0
  6. package/.idea/suitecloud-stacker.iml +9 -0
  7. package/.idea/vcs.xml +6 -0
  8. package/CONTRIBUTING.md +72 -0
  9. package/README.md +242 -0
  10. package/bin/updateModule.d.ts +6 -0
  11. package/bin/updateModule.js +12 -0
  12. package/commands/CONTRIBUTING.md +7 -0
  13. package/commands/accountManageauth.d.ts +93 -0
  14. package/commands/accountManageauth.js +228 -0
  15. package/commands/accountSetup.d.ts +56 -0
  16. package/commands/accountSetup.js +218 -0
  17. package/commands/customhook/compiless.d.ts +10 -0
  18. package/commands/customhook/compiless.js +46 -0
  19. package/commands/customhook/watchss.d.ts +14 -0
  20. package/commands/customhook/watchss.js +77 -0
  21. package/commands/fileImport.d.ts +31 -0
  22. package/commands/fileImport.js +503 -0
  23. package/commands/fileList.d.ts +19 -0
  24. package/commands/fileList.js +40 -0
  25. package/commands/fileUpload.d.ts +52 -0
  26. package/commands/fileUpload.js +355 -0
  27. package/commands/generic.d.ts +5 -0
  28. package/commands/generic.js +13 -0
  29. package/commands/objectImport.d.ts +32 -0
  30. package/commands/objectImport.js +287 -0
  31. package/commands/objectList.d.ts +13 -0
  32. package/commands/objectList.js +78 -0
  33. package/commands/projectCreate.d.ts +31 -0
  34. package/commands/projectCreate.js +506 -0
  35. package/commands/projectDeploy.d.ts +25 -0
  36. package/commands/projectDeploy.js +371 -0
  37. package/commands/projectPackage.d.ts +10 -0
  38. package/commands/projectPackage.js +32 -0
  39. package/commands/projectValidate.d.ts +21 -0
  40. package/commands/projectValidate.js +112 -0
  41. package/commands/sdfAcs_authmap.d.ts +15 -0
  42. package/commands/sdfAcs_authmap.js +26 -0
  43. package/commands/sdfAcs_clean.d.ts +20 -0
  44. package/commands/sdfAcs_clean.js +22 -0
  45. package/deleteManifest.cjs +11 -0
  46. package/demo.md +26 -0
  47. package/index.d.ts +284 -0
  48. package/lib/MakeJestTestsFromDeploy.d.ts +13 -0
  49. package/lib/MakeJestTestsFromDeploy.js +60 -0
  50. package/lib/addGitKeep.d.ts +5 -0
  51. package/lib/addGitKeep.js +40 -0
  52. package/lib/addSdfObjectDirs.d.ts +5 -0
  53. package/lib/addSdfObjectDirs.js +16 -0
  54. package/lib/callCli.d.ts +7 -0
  55. package/lib/callCli.js +26 -0
  56. package/lib/compileHelper.d.ts +44 -0
  57. package/lib/compileHelper.js +196 -0
  58. package/lib/deleteProjectJson.d.ts +6 -0
  59. package/lib/deleteProjectJson.js +16 -0
  60. package/lib/deployFileHelper.d.ts +77 -0
  61. package/lib/deployFileHelper.js +249 -0
  62. package/lib/handleRootProjectJson.d.ts +10 -0
  63. package/lib/handleRootProjectJson.js +30 -0
  64. package/lib/isProd.d.ts +9 -0
  65. package/lib/isProd.js +13 -0
  66. package/lib/logHelper.d.ts +5 -0
  67. package/lib/logHelper.js +13 -0
  68. package/lib/logger.d.ts +6 -0
  69. package/lib/logger.js +10 -0
  70. package/lib/makeDeployXml.d.ts +6 -0
  71. package/lib/makeDeployXml.js +30 -0
  72. package/lib/makeJest.d.ts +12 -0
  73. package/lib/makeJest.js +58 -0
  74. package/lib/makeManifestXml.d.ts +6 -0
  75. package/lib/makeManifestXml.js +21 -0
  76. package/lib/makeProjectJson.d.ts +6 -0
  77. package/lib/makeProjectJson.js +16 -0
  78. package/lib/onErrorHelper.d.ts +31 -0
  79. package/lib/onErrorHelper.js +93 -0
  80. package/lib/pathHelpers.d.ts +133 -0
  81. package/lib/pathHelpers.js +428 -0
  82. package/lib/pause.d.ts +6 -0
  83. package/lib/pause.js +10 -0
  84. package/lib/projectJsonHelpers.d.ts +29 -0
  85. package/lib/projectJsonHelpers.js +92 -0
  86. package/lib/promptHelpers.d.ts +77 -0
  87. package/lib/promptHelpers.js +195 -0
  88. package/lib/removeFiles.d.ts +20 -0
  89. package/lib/removeFiles.js +46 -0
  90. package/lib/sdf.d.ts +11 -0
  91. package/lib/sdf.js +158 -0
  92. package/lib/spawnSuitecloudChild.d.ts +30 -0
  93. package/lib/spawnSuitecloudChild.js +88 -0
  94. package/lib/switchAuth.d.ts +17 -0
  95. package/lib/switchAuth.js +23 -0
  96. package/lib/tempFileHelper.d.ts +29 -0
  97. package/lib/tempFileHelper.js +70 -0
  98. package/lib/updateModule.d.ts +10 -0
  99. package/lib/updateModule.js +79 -0
  100. package/lib/validators.d.ts +12 -0
  101. package/lib/validators.js +25 -0
  102. package/package.json +38 -0
  103. package/safeCommands.d.ts +95 -0
  104. package/safeCommands.js +959 -0
  105. package/sdf.config.js +15 -0
  106. package/sdf.exe.js +16 -0
  107. package/templates/customizations.projectroot.d.ts +74 -0
  108. package/templates/makeModuleTypeDef.d.ts +5 -0
  109. package/templates/makeModuleTypeDef.js +29 -0
  110. package/templates/sdfGitIgnore.txt +42 -0
  111. package/templates/suitecloud.config.js +17 -0
  112. package/templates/tsconfig.ss21.projectroot.json +64 -0
  113. package/types/colors.d.ts +43 -0
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="TypeScriptCompiler">
4
+ <option name="nodeInterpreterTextField" value="$USER_HOME$/.nvm/versions/node/v20.20.0/bin/node" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="GitToolBoxBlameSettings">
4
+ <option name="version" value="2" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="GitToolBoxProjectSettings">
4
+ <option name="commitMessageIssueKeyValidationOverride">
5
+ <BoolValueOverride>
6
+ <option name="enabled" value="true" />
7
+ </BoolValueOverride>
8
+ </option>
9
+ <option name="commitMessageValidationEnabledOverride">
10
+ <BoolValueOverride>
11
+ <option name="enabled" value="true" />
12
+ </BoolValueOverride>
13
+ </option>
14
+ </component>
15
+ </project>
package/.idea/misc.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
4
+ <output url="file://$PROJECT_DIR$/out" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/suitecloud-stacker.iml" filepath="$PROJECT_DIR$/.idea/suitecloud-stacker.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="JAVA_MODULE" version="4">
3
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
4
+ <exclude-output />
5
+ <content url="file://$MODULE_DIR$" />
6
+ <orderEntry type="inheritedJdk" />
7
+ <orderEntry type="sourceFolder" forTests="false" />
8
+ </component>
9
+ </module>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,72 @@
1
+ ## the project type is 'commonjs'
2
+ suitecloud-cli will only look for a config with a `.js` and never a `.cjs` extension!! 😓
3
+ this conflicts with how suitescript unit tests are written which is with es6 modules.
4
+ It is possible to use modules with flags on node so that is what we will need to do.
5
+ This means certain files such as suitecloud.config.js may show some resolve errors. There are some other ways to get around this b
6
+
7
+ ## Your authentication is setup correctly and you are definitely pushing or pulling from the implied environment
8
+ Unfortunately, we are human and make mistakes. But SDF doesn't care
9
+ When authentication is set it will just assume this is what you want and has no safety net.
10
+
11
+ this project solves this problem by:
12
+ - Using the `@suitegeezus/suitecloud-cli` which has an authid argument available
13
+ - requiring the authid to be passed onto the command line
14
+ - detecting it is set in the hooks
15
+ - optional: erasing the project.json file before and after every execution.
16
+ - prompting you to enter the same authid a second time during the action
17
+
18
+ # Testing
19
+
20
+ This project lacks unit tests. It was initially difficult to figure out how to test a cli such as suitecloud more effectively in a unit test than in on the command line itself especially because it did not publish its hook behaviour. So it was often better to test by running the commands locally.
21
+
22
+ However, there should be unit tests and the stackable system makes it easy to do so.
23
+
24
+ Running the compiler with `map` files and in watch mode helps a lot.
25
+
26
+ # Writing Code
27
+ All code needs to be in Typescript
28
+
29
+ Anything that is a stackable handler should be for a specific command and be in the `commands/` directory.
30
+
31
+ e.g. something for `file:import` goes in `commands/fileImport.ts`
32
+
33
+ Each handler should be function that return `SdfCommand` type. Which has this shape:
34
+ ```ts
35
+ interface SdfCommand{
36
+ beforeExecuting?: <O>(options:O)=>Promise<O>;
37
+ onCompleted?: <O>(options:O)=>Promise<O>;
38
+ onError?: <S>(err:S)=>Promise<S>;
39
+ projectFolder?: string;
40
+ /** @description - non native but added for detection */
41
+ stacked: true;
42
+ isStackable: true;
43
+ _origin: string;
44
+ }
45
+ ```
46
+
47
+ ## Throwing Errors
48
+ - SDF only passes strings to `onError`
49
+ - SDF always prints the message
50
+
51
+ - so ....
52
+ You should call `makeError` when throwing errors. This will throw a serialized string but log the stack first.
53
+ ```ts
54
+ throw onErrorHelper.makeError(origin, new Error('whatever'));
55
+ ```
56
+
57
+ Your `onError` method should be the returnType of `detectOriginAndReturn`
58
+
59
+ ```ts
60
+ onError : async (error:string)=> onErrorHelper.detectOriginAndReturn(
61
+ origin, // : string,
62
+ error, // string-- the non-serialized message
63
+ (e: string /* this will only be the message portion */)=>{
64
+ // you can do things in here like
65
+ // - print a friendlier message when it's not a catastropich error
66
+ // - print a usage
67
+ }
68
+ );
69
+ ```
70
+ If you need the results of an SDF command that is supported and you'll see examples
71
+
72
+ Anything that is re-usable should be somewhere in `sdf/lib`.
package/README.md ADDED
@@ -0,0 +1,242 @@
1
+ Contains helpers for SDF (Node CLI edition)
2
+
3
+ # Features
4
+ - Collection of pre-configured hooks (commands) to manage ACS problems withing customer account
5
+ - Collection of pre-configured hooks to manage the outer project
6
+ - Pre-defined handlers that you can pick and choose from for a given "command"
7
+ - Types for SDF commands
8
+ - command line enhancements
9
+
10
+ Missing: Collection of hooks to manage an entire instance -- Cuz we (ACS) don't do this but if you have your own instance / demo account then feel free to create your own suitecloud.config file and use the stackable structure. Note that most customers don't really do this either -- they often have outside devs who contribute at least sometimes
11
+
12
+ # Demos
13
+
14
+ ## `account:setup:ci` : Token Auth Memory
15
+ Setup token auth for an account from existing token auths that you have with detection for conflicts and valid naming
16
+ ![example](./img/accountsetupci.example1.gif)
17
+
18
+ ## `project:create`: New Account
19
+ Create project to work on a case
20
+ ![example](./img/projectcreate.example1.gif)
21
+
22
+ ## `project:create`: New Case on Account
23
+ ![example](./img/projectcreate.example2.gif)
24
+
25
+ ## `file:upload`: Globbing that filters out irrelevant files
26
+ ![example](./img/fileupload.example1.gif)
27
+
28
+ ## `file:upload`: Upload all files from a deploy.xml file
29
+ ![example](./img/fileupload.example3.gif)
30
+
31
+ ## `file:upload`: Compile and / or run tests on files you are uploading
32
+ ![example](./img/fileupload.example4.gif)
33
+
34
+ ## `file:import`: Compare your current file with what is in the account
35
+ ![example](./img/fileimport.example3.gif)
36
+
37
+ ## `file:import`: Import files that match a glob pattern
38
+ ![example](./img/fileimport.example2.gif)
39
+
40
+ ## `file:import`: Import all files from a deploy.xml file
41
+ ```shell
42
+ cd /SuiteScripts/ACS/casefolder
43
+ suitecloud file:import --paths ./deploy/deploy.xml
44
+ ```
45
+
46
+ ## `object:import`: import objects that match a glob pattern
47
+ ![example](./img/objectimport.example1.gif)
48
+
49
+ ## `object:import`: import all objects that are listed in a chosen deploy.xml file
50
+ ![example](./img/objectimport.example2.gif)
51
+
52
+ ## `project:deploy`: Choose which project definition to deploy
53
+
54
+ ## `object:import`: Import Objects will organize them into folders by type automatically
55
+ ![example](./img/objectOrganization.png)
56
+
57
+ ## Compile and test typescript as you write
58
+ ![example](./img/nodemon.example1.gif);
59
+
60
+ # How SDF works in this project
61
+
62
+ SDF by default has a certain structure that makes the following (annoying?) assumptions:
63
+
64
+ ## `defaultProjectFolder` is flexible
65
+ The IDE plugins force you to use `src`. You can if you want but this is more flexible. It defaults to 'src'
66
+ The reason you would NOT want to use `src` is if you wanted to use the plugin to match what is in the account but what is in your repo is either or both of:
67
+ - has extra stuff you don't want to put into the account by accident
68
+ - want to keep it separate
69
+
70
+ One emample in this project is that to do diffs it will automatically create a root `temp` for you.
71
+
72
+ ## Attempts to facilitate any activity in an account-based project to be only for that account
73
+ For example, if you try to `file:upload` or `project:deploy` code it will prompt you for the account with only choices relevant to that project.
74
+
75
+ # Installation
76
+
77
+ ## Pre-requisites
78
+ ### Desktop pre-reqs
79
+
80
+ Should work same on Windows but i haven't tested it and i might have messed something up for windows so let me know if you have issues and you can help me fix them
81
+
82
+ 1. Install SuiteCloud globally using the latest release version
83
+ 2. Optional: Install nodemon globally
84
+ ```shell
85
+ npm install -g nodemon
86
+ ```
87
+ 3. Install a nice terminal that you like to use.
88
+ - Highly recommend enhancing the mac shell with iTerm AND [Oh my Zsh!](https://ohmyz.sh/)
89
+ 4. Optional: Be able to sync repositories with ALM via OCNA
90
+ - These are entitlements that will help you stay on the latest version of this repo and use customer repos
91
+ - If you can't then you can still use this for your testdrive accounts -- just ask me how
92
+ 5. Optional: define `oraclegit` in your ssh **config** (highly recommended)
93
+ ```txt
94
+ HOST oraclegit
95
+ User gerald.gillespie@fullscript.com
96
+ HostName alm.oraclecorp.com
97
+ TCPKeepAlive yes
98
+ AddKeysToAgent yes
99
+ UseKeyChain yes
100
+ IdentityFile ~/.ssh/ed25519ggoracle2
101
+ ```
102
+ 6. Optional: Create an environment variable for DIFF_TOOL
103
+ ```shell
104
+ #➜ nsaccounts git:(main) ✗ set | grep 'DIFF'
105
+ export DIFF_TOOL='/Applications/./IntelliJ\ IDEA.app/Contents/MacOS/idea'
106
+ ```
107
+
108
+ ### NetSuite pre-requisites
109
+ You will need to have:
110
+ - SuiteCloud installed in the account
111
+ - Oauth 2.0 turned on
112
+ - SuiteScript, etc enabled
113
+
114
+ ## Install on Mac / Linux / Windows
115
+ 1. clone the repo (not the weird extra slash `:/` ALM needs)
116
+ ```shell
117
+ git clone oraclegit:/nscs_suitecloud-stacker_114170/suitecloud-stacker-root.git
118
+ ```
119
+ 2. Run npm install
120
+ ```shell
121
+ npm install
122
+ ```
123
+
124
+ # Usage: Hello World Example
125
+
126
+ - install as above
127
+ - open a terminal to the root folder
128
+
129
+
130
+
131
+ ## Pre-Defined Stacks for the Common scenario
132
+ - Collection of hooks meant for ACP subprojects (e.g. a specific case/ project)
133
+ ```js
134
+ const safeCommands = require('suitecloud-stacker/safeCommands.js');
135
+ module.exports = {
136
+ ...projectJson,
137
+ commands: {...safeCommands.caseCommands},
138
+ },
139
+ {debug: false, block: false},
140
+ module
141
+
142
+ ```
143
+
144
+ ### Spin up a new SDF project for a case
145
+ You can use this command to create your own case
146
+ ```bash
147
+ cd ~/code/projectRoot
148
+ suitecloud project:create
149
+ # follow-the prompts
150
+ ```
151
+
152
+ ## Stackable / chaining structure for SDF command hooks
153
+ This means your suitecloud.config.js can specify or replace commands something like this:
154
+
155
+ ```js
156
+ const commands = {
157
+ 'file:import': stack('file:upload')
158
+ .stack(
159
+ accountManageAuth.promptForAccountChoice()
160
+ ).stack(
161
+ fileUpload.fixFileUploadPaths()
162
+ ).stack(
163
+ fileUpload.compileFilesPrompt()
164
+ ).stack(
165
+ fileUpload.testFilesPrompt()
166
+ )
167
+ .done(),
168
+ };
169
+ ```
170
+
171
+ ## Stacking
172
+ At the heart of this is a "Stackable" structure for SDF. It is expected and encouraged that you have at least one suitecloud.config.js for a customer account rather than relying on the outer one.
173
+
174
+ Also, don't bother with the IDE plugins. not only do they have their own limitations but they are a black box so you can't do anything about it.
175
+
176
+ This has the following usage
177
+
178
+ ### `--authid`
179
+ supports a format like this `2452352:wut` where the value before the `:` is the authid and the value after the colon is the folder name.
180
+
181
+ if you only specify the first part without any colon then the same value is used for both. i.e. `2452352` is equivalent to `2452352:2452352`
182
+
183
+ you can create this anywhere. Wherever you create it you should invoke it from there.
184
+ e.g.
185
+ ```bash
186
+ cd FileCabinet/SuiteScripts/folder
187
+ suitecloud
188
+ ```
189
+
190
+ ## working directory
191
+ native `suitecloud` must be called from a directory that has a `suitecloud.config.js` file.
192
+
193
+ As such if you setup a project using native command and run it then it will work because that process will create a `suitecloud.config.js`.
194
+
195
+ It is recommended that you set your `suitecloud.config.js` file to be the following:
196
+
197
+ ```js
198
+ const sdfAcs = require('./sdf/safeCommands');
199
+
200
+ // create the commands that you want
201
+ const commands = {};
202
+
203
+ // pass them through the sdfAcs layer
204
+ module.exports = sdfAcs.makeSuiteCloudConfig({commands});
205
+ ```
206
+
207
+ # Errors
208
+ > No account has been set up for this project. Run "suitecloud account:setup" to link your project with your account.
209
+
210
+ This is a native SDF error that means you do not have a project.json
211
+ Do not remedy this by creating a project.json as this will be created for you.
212
+ --> Remedy this by having an `--authid` flag on your command line like this:
213
+ `sdf file:import --paths "/SuiteScripts/myfile.js" --authid td12345:dist`
214
+
215
+ if that authid exists and the folder `dist` exists then the file will be imported there. A project.json file will be quickly created and destroyed in the process
216
+
217
+ # Relationships between project directories and accounts
218
+ In Netsuite we write code.
219
+ We don't (usually) write code specifically for a sandbox, nor for production.
220
+ We write code for the customer for a solution and it goes through a dev process that involves sandboxes and production. e.g. SB2 / Dev -> SB1/ UA2 -> Prod
221
+
222
+ This should also be true of objects.
223
+
224
+ We can use SDF for both code (suitescripts) and objects.
225
+
226
+ Regardless of how many sandboxen the customer has...
227
+ Regardless of what weird branching strategies they might have... or don't have.
228
+ Regardless of whether we are writing code for the customer's use or writing code the helps us create the solution for the customer...
229
+ Regardless of how many cases are concurrently being worked on for a customer...
230
+ When we write code or create objects it is hella convenient and powerful to have both under source control and to use merging strategies that support the work we are doing for the customer.
231
+
232
+ In all of the above you can have a real "customer" or it could simply be a concept "customer"
233
+
234
+ So we have one folder for a customer.
235
+
236
+ If a customer has multiple sandboxes then we probably have multiple branches but it doesn't matter. Our "master" branch is not the customer's master branch. It is our statement that this code is production worthy and ready to be vetted.
237
+
238
+ ## But I don't want my customer to be a sub-folder in this project!
239
+ You don't have to.
240
+ There is nothing stopping you in git from (in fact it supports) having a subfolder be for a different repository. That repository can have different users. ESS member Bob can have a different set of accounts from Raffi and they can share any overlapping number of them. But when they want to collaborate on something in source control related to an account they can `pull` from a common view and still work independantly on separate branches and yet have full visibility into the other work.
241
+
242
+ Further, the ability to `pull` from source control does not mean that you will be able to `file:deploy` to the customer account. You still need to have an authenticated token to do that. And that probably means you'll need to have login privileges to the customer's account (production, sandbox or whatever).
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @file /Users/geraldgillespie/code/nsaccounts/sdf/bin/updateModule
3
+ * - keeps module up to date with what is in the current directory
4
+ * @author Gerald Gillespie <gerald.gillespie@fullscript.com>
5
+ */
6
+ export {};
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ /**
3
+ * @file /Users/geraldgillespie/code/nsaccounts/sdf/bin/updateModule
4
+ * - keeps module up to date with what is in the current directory
5
+ * @author Gerald Gillespie <gerald.gillespie@fullscript.com>
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ const updateModule_1 = require("../lib/updateModule");
9
+ (async () => {
10
+ await (0, updateModule_1.updateModuleTypeDef)();
11
+ })();
12
+ //# sourceMappingURL=updateModule.js.map
@@ -0,0 +1,7 @@
1
+ In this folder each library should export handlers related to an SDF command.
2
+
3
+ e.g. fileImport.ts serves `file:import` related commands.
4
+
5
+ These handler should return sdf-expected methods and each method should be stackable / chainable. See [sdf/safeCommands/stack](../safeCommands.ts);
6
+
7
+ Tests would be great. Use proxies to glean the arguments that SDF passed in and use those as your mock options.
@@ -0,0 +1,93 @@
1
+ /**
2
+ * @file /Users/geraldgillespie/code/nsaccounts/sdf/commands/accountManageauth
3
+ * @author Gerald Gillespie <gerald.gillespie@fullscript.com>
4
+ */
5
+ import { SdfCommand, StackableHook } from "index";
6
+ type AccountManageAuthOnCompletedOptions<A = 'list' | 'remove' | 'rename' | 'info'> = {
7
+ _status: 'SUCCESS' | string;
8
+ _commandParameters: A extends 'list' ? {} : A extends 'info' ? {
9
+ info: string;
10
+ } : never;
11
+ _actionExecuted: A;
12
+ _data: {
13
+ authid: A extends 'info' ? string : undefined;
14
+ authId?: string;
15
+ accountInfo: {
16
+ companyId: string;
17
+ companyName: string;
18
+ roleId: string;
19
+ roleName: string;
20
+ entityId: string;
21
+ };
22
+ token?: A extends 'list' ? {
23
+ accessToken: string;
24
+ expirationDate: string;
25
+ } : never;
26
+ domain?: A extends 'info' ? string : never;
27
+ hostInfo?: A extends 'list' ? {
28
+ hostName: string;
29
+ clientId: string;
30
+ } : never;
31
+ certificateInfo?: A extends 'list' ? {
32
+ privateKeyPath: string;
33
+ certificateId: string;
34
+ } : never;
35
+ };
36
+ };
37
+ /**
38
+ * @description - save the list of account details as json
39
+ */
40
+ export declare const saveList: () => SdfCommand;
41
+ type BetterAccountList = {
42
+ authid: string;
43
+ authId?: string;
44
+ domain: string | null;
45
+ accountInfo: {
46
+ companyId: string;
47
+ companyName: string;
48
+ roleName: string;
49
+ entityId: string;
50
+ };
51
+ auth: {
52
+ certificateId: string;
53
+ privatekeyPath: string;
54
+ expiration: string;
55
+ };
56
+ };
57
+ /**
58
+ * @description - Filters an account list for those relevant to the given account
59
+ * @example ```js
60
+ * authid: "ACMEINC-DEV",
61
+ * domain: "654321-sb1.app.netsuite.com",
62
+ * accountInfo: {
63
+ * companyId:"654321_SB1",
64
+ * companyName:"Acme, Inc (SB2)",
65
+ * roleName: "Administrator",
66
+ * entityId: "1324546",
67
+ * };
68
+ * auth: {
69
+ * certificateId: "aEB5fUYumwJbnvP09kR",
70
+ * privatekeyPath: "/Users/geraldgillespie/.keys/sdfgg.pem",
71
+ * expiration: "2025-03-05T14:29.3961Z",
72
+ * }
73
+ * ```
74
+ * @returns {Promise<ReturnType<makeList>>}
75
+ */
76
+ export declare const fetchAccountList: () => Promise<BetterAccountList[]>;
77
+ export declare const betterList: () => SdfCommand;
78
+ /**
79
+ * @description - Prompts for account choice. This provides both verification and literal choice. If the choice does not match the current
80
+ * context then an error is forced -- this is because SDF does not recognize a change in the account after launching.
81
+ * @returns {*}
82
+ */
83
+ export declare const promptForAccountChoice: StackableHook<any, any, never, any>;
84
+ /**
85
+ * @description -
86
+ * @param options
87
+ */
88
+ export declare const validateList: (options: any) => {
89
+ _origin: string;
90
+ onCompleted: (options: AccountManageAuthOnCompletedOptions) => void;
91
+ isStackable: boolean;
92
+ };
93
+ export {};