@transcend-io/cli 2.2.3

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 (95) hide show
  1. package/.yarn/sdks/eslint/package.json +6 -0
  2. package/.yarn/sdks/prettier/package.json +6 -0
  3. package/.yarn/sdks/typescript/package.json +6 -0
  4. package/LICENSE +21 -0
  5. package/README.md +301 -0
  6. package/build/cli-pull.d.ts +3 -0
  7. package/build/cli-pull.d.ts.map +1 -0
  8. package/build/cli-pull.js +53 -0
  9. package/build/cli-pull.js.map +1 -0
  10. package/build/cli-push.d.ts +3 -0
  11. package/build/cli-push.d.ts.map +1 -0
  12. package/build/cli-push.js +82 -0
  13. package/build/cli-push.js.map +1 -0
  14. package/build/codecs.d.ts +541 -0
  15. package/build/codecs.d.ts.map +1 -0
  16. package/build/codecs.js +216 -0
  17. package/build/codecs.js.map +1 -0
  18. package/build/constants.d.ts +2 -0
  19. package/build/constants.d.ts.map +1 -0
  20. package/build/constants.js +5 -0
  21. package/build/constants.js.map +1 -0
  22. package/build/fetchApiKeys.d.ts +21 -0
  23. package/build/fetchApiKeys.d.ts.map +1 -0
  24. package/build/fetchApiKeys.js +56 -0
  25. package/build/fetchApiKeys.js.map +1 -0
  26. package/build/fetchDataSubjects.d.ts +40 -0
  27. package/build/fetchDataSubjects.d.ts.map +1 -0
  28. package/build/fetchDataSubjects.js +85 -0
  29. package/build/fetchDataSubjects.js.map +1 -0
  30. package/build/fetchIdentifiers.d.ts +27 -0
  31. package/build/fetchIdentifiers.d.ts.map +1 -0
  32. package/build/fetchIdentifiers.js +83 -0
  33. package/build/fetchIdentifiers.js.map +1 -0
  34. package/build/gqls.d.ts +16 -0
  35. package/build/gqls.d.ts.map +1 -0
  36. package/build/gqls.js +310 -0
  37. package/build/gqls.js.map +1 -0
  38. package/build/index.d.ts +4 -0
  39. package/build/index.d.ts.map +1 -0
  40. package/build/index.js +16 -0
  41. package/build/index.js.map +1 -0
  42. package/build/logger.d.ts +2 -0
  43. package/build/logger.d.ts.map +1 -0
  44. package/build/logger.js +5 -0
  45. package/build/logger.js.map +1 -0
  46. package/build/pullTranscendConfiguration.d.ts +11 -0
  47. package/build/pullTranscendConfiguration.d.ts.map +1 -0
  48. package/build/pullTranscendConfiguration.js +95 -0
  49. package/build/pullTranscendConfiguration.js.map +1 -0
  50. package/build/readTranscendYaml.d.ts +19 -0
  51. package/build/readTranscendYaml.d.ts.map +1 -0
  52. package/build/readTranscendYaml.js +47 -0
  53. package/build/readTranscendYaml.js.map +1 -0
  54. package/build/syncConfigurationToTranscend.d.ts +11 -0
  55. package/build/syncConfigurationToTranscend.d.ts.map +1 -0
  56. package/build/syncConfigurationToTranscend.js +96 -0
  57. package/build/syncConfigurationToTranscend.js.map +1 -0
  58. package/build/syncDataSilos.d.ts +144 -0
  59. package/build/syncDataSilos.d.ts.map +1 -0
  60. package/build/syncDataSilos.js +178 -0
  61. package/build/syncDataSilos.js.map +1 -0
  62. package/build/syncEnrichers.d.ts +45 -0
  63. package/build/syncEnrichers.d.ts.map +1 -0
  64. package/build/syncEnrichers.js +69 -0
  65. package/build/syncEnrichers.js.map +1 -0
  66. package/build/tests/fetchApiKeys.test.d.ts +1 -0
  67. package/build/tests/fetchApiKeys.test.d.ts.map +1 -0
  68. package/build/tests/fetchApiKeys.test.js +3 -0
  69. package/build/tests/fetchApiKeys.test.js.map +1 -0
  70. package/build/tests/fetchDataSubjects.test.d.ts +1 -0
  71. package/build/tests/fetchDataSubjects.test.d.ts.map +1 -0
  72. package/build/tests/fetchDataSubjects.test.js +3 -0
  73. package/build/tests/fetchDataSubjects.test.js.map +1 -0
  74. package/build/tests/fetchIdentifiers.test.d.ts +1 -0
  75. package/build/tests/fetchIdentifiers.test.d.ts.map +1 -0
  76. package/build/tests/fetchIdentifiers.test.js +3 -0
  77. package/build/tests/fetchIdentifiers.test.js.map +1 -0
  78. package/build/tests/main.test.d.ts +1 -0
  79. package/build/tests/main.test.d.ts.map +1 -0
  80. package/build/tests/main.test.js +6 -0
  81. package/build/tests/main.test.js.map +1 -0
  82. package/build/tests/readTranscendYaml.test.d.ts +2 -0
  83. package/build/tests/readTranscendYaml.test.d.ts.map +1 -0
  84. package/build/tests/readTranscendYaml.test.js +38 -0
  85. package/build/tests/readTranscendYaml.test.js.map +1 -0
  86. package/build/tests/syncDataSilos.test.d.ts +1 -0
  87. package/build/tests/syncDataSilos.test.d.ts.map +1 -0
  88. package/build/tests/syncDataSilos.test.js +3 -0
  89. package/build/tests/syncDataSilos.test.js.map +1 -0
  90. package/build/tests/syncEnrichers.test.d.ts +1 -0
  91. package/build/tests/syncEnrichers.test.d.ts.map +1 -0
  92. package/build/tests/syncEnrichers.test.js +3 -0
  93. package/build/tests/syncEnrichers.test.js.map +1 -0
  94. package/build/tsbuildinfo +1 -0
  95. package/package.json +70 -0
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "eslint",
3
+ "version": "8.10.0-sdk",
4
+ "main": "./lib/api.js",
5
+ "type": "commonjs"
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "prettier",
3
+ "version": "2.5.1-sdk",
4
+ "main": "./index.js",
5
+ "type": "commonjs"
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "typescript",
3
+ "version": "4.5.5-sdk",
4
+ "main": "./lib/typescript.js",
5
+ "type": "commonjs"
6
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Transcend
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,301 @@
1
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
2
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
3
+
4
+ ## Table of Contents
5
+
6
+ - [Overview](#overview)
7
+ - [Installation](#installation)
8
+ - [Authentication](#authentication)
9
+ - [transcend.yml](#transcendyml)
10
+ - [Usage](#usage)
11
+ - [tr-pull](#tr-pull)
12
+ - [tr-push](#tr-push)
13
+ - [CI Integration](#ci-integration)
14
+ - [Dynamic Variables](#dynamic-variables)
15
+
16
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
17
+
18
+ ## Overview
19
+
20
+ A command line interface that allows you to define your Data Map in code and sync that configuration back to https://app.transcend.io.
21
+
22
+ ## Installation
23
+
24
+ This package is distributed through npm and github package registries and assumes an installation of [npm and node](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).
25
+
26
+ If your codebase is typescript or javascript based, you can add this package as a dev dependency:
27
+
28
+ ```sh
29
+ # install locally with yarn
30
+ yarn add -D @transcend-io/cli
31
+
32
+ # cli commands available within package
33
+ yarn tr-pull --auth=xxx
34
+ yarn tr-push --auth=xxx
35
+ ```
36
+
37
+ or
38
+
39
+ ```sh
40
+ # install locally with npm
41
+ npm i -D @transcend-io/cli
42
+
43
+ # cli commands available within package
44
+ tr-pull --auth=xxx
45
+ tr-push --auth=xxx
46
+ ```
47
+
48
+ alternatively, you can install the cli globally on your machine:
49
+
50
+ ```sh
51
+ # install locally with npm
52
+ npm i -g @transcend-io/cli
53
+
54
+ # cli commands available everywhere on machine
55
+ tr-pull --auth=xxx
56
+ tr-push --auth=xxx
57
+ ```
58
+
59
+ ## Authentication
60
+
61
+ In order to use this cli, you will first need to generate an API key on the Transcend Admin Dashboard (https://app.transcend.io/infrastructure/api-keys).
62
+
63
+ The API key needs the following scopes:
64
+
65
+ - Manage Data Map
66
+ - Manage Request Identity Verification
67
+ - Connect Data Silos
68
+ - Manage Data Subject Request Settings
69
+ - View API Keys
70
+
71
+ ## transcend.yml
72
+
73
+ Within your git repositories, you can define a file `transcend.yml`. This file allows you define part of your Data Map in code. Using the cli, you can sync that configuration back to the Transcend Admin Dashboard (https://app.transcend.io/privacy-requests/connected-services).
74
+
75
+ You can find various examples for your `transcend.yml` file in the [examples/](./examples/) folder. If you are looking for a starting point to copy and paste, [simple.yml](./examples/simple.yml) is a good place to start. This file is annotated with links and documentations that new members of your team can use if they come across the file.
76
+
77
+ The API for this YAML file can be found in [./src/codecs.ts](./src/codecs.ts) under the variable named "TranscendInput". The shape of the yaml file will be type-checked every time a command is run.
78
+
79
+ The structure of the file looks something like the following:
80
+
81
+ ```yaml
82
+ # Manage at: https://app.transcend.io/infrastructure/api-keys
83
+ # See https://docs.transcend.io/docs/authentication
84
+ # Define API keys that may be shared across data silos
85
+ # in the data map. When creating new data silos through the yaml
86
+ # cli, it is possible to specify which API key should be associated
87
+ # with the newly created data silo.
88
+ api-keys:
89
+ - title: Webhook Key
90
+ - title: Analytics Key
91
+
92
+ # Manage at: https://app.transcend.io/privacy-requests/identifiers
93
+ # See https://docs.transcend.io/docs/identity-enrichment
94
+ # Define enricher or pre-flight check webhooks that will be executed
95
+ # prior to privacy request workflows. Some examples may include:
96
+ # - identity enrichment: look up additional identifiers for that user.
97
+ # i.e. map an email address to a user ID
98
+ # - fraud check: auto-cancel requests if the user is flagged for fraudulent behavior
99
+ # - customer check: auto-cancel request for some custom business criteria
100
+ enrichers:
101
+ - title: Basic Identity Enrichment
102
+ description: Enrich an email address to the userId and phone number
103
+ url: https://example.acme.com/transcend-enrichment-webhook
104
+ input-identifier: email
105
+ output-identifiers:
106
+ - userId
107
+ - phone
108
+ - myUniqueIdentifier
109
+ - title: Fraud Check
110
+ description: Ensure the email address is not marked as fraudulent
111
+ url: https://example.acme.com/transcend-fraud-check
112
+ input-identifier: email
113
+ output-identifiers:
114
+ - email
115
+ privacy-actions:
116
+ - ERASURE
117
+
118
+ # Manage at: https://app.transcend.io/privacy-requests/connected-services
119
+ # See https://docs.transcend.io/docs/the-data-map#data-silos
120
+ # Define the data silos in your data map. A data silo can be a database,
121
+ # or a web service that may use a collection of different data stores under the hood.
122
+ data-silos:
123
+ # Note: title is the only required top-level field for a data silo
124
+ - title: Redshift Data Warehouse
125
+ description: The mega-warehouse that contains a copy over all SQL backed databases
126
+ integrationName: server
127
+ url: https://example.acme.com/transcend-webhook
128
+ api-key-title: Webhook Key
129
+ data-subjects:
130
+ - customer
131
+ - employee
132
+ - newsletter-subscriber
133
+ - b2b-contact
134
+ identity-keys:
135
+ - email
136
+ - userId
137
+ deletion-dependencies:
138
+ - Identity Service
139
+ owners:
140
+ - alice@transcend.io
141
+ datapoints:
142
+ - title: Webhook Notification
143
+ key: _global
144
+ privacy-actions:
145
+ - ACCESS
146
+ - ERASURE
147
+ - SALE_OPT_OUT
148
+ - title: User Model
149
+ description: The centralized user model user
150
+ key: users
151
+ purpose: ESSENTIAL
152
+ category: USER_PROFILE
153
+ privacy-actions:
154
+ - ACCESS
155
+ fields:
156
+ - key: firstName
157
+ title: First Name
158
+ description: The first name of the user, inputted during onboarding
159
+ - key: email
160
+ title: Email
161
+ description: The email address of the user
162
+ ```
163
+
164
+ ## Usage
165
+
166
+ ### tr-pull
167
+
168
+ Generate's a transcend.yml by pulling the configuration from your connected services view (https://app.transcend.io/privacy-requests/connected-services).
169
+
170
+ This command can be helpful if you are looking to:
171
+
172
+ - Copy parts of your Data Map from one Transcend instance into another instance
173
+ - Generate a transcend.yml file as a starting point to maintain parts of your Data Map in code
174
+
175
+ ```sh
176
+ # Writes out file to ./transcend.yml
177
+ tr-pull --auth=<api-key>
178
+ ```
179
+
180
+ An alternative file destination can be specified:
181
+
182
+ ```sh
183
+ # Writes out file to ./custom/location.yml
184
+ tr-pull --auth=<api-key> --file=./custom/location.yml
185
+ ```
186
+
187
+ Or a specific data silo(s) can be pulled in:
188
+
189
+ ```sh
190
+ tr-pull --auth=<api-key> --dataSiloIds=710fec3c-7bcc-4c9e-baff-bf39f9bec43e
191
+ ```
192
+
193
+ Note: This command will overwrite the existing transcend.yml file that you have locally.
194
+
195
+ ### tr-push
196
+
197
+ Given a transcend.yml file, sync the contents up to your connected services view (https://app.transcend.io/privacy-requests/connected-services).
198
+
199
+ ```sh
200
+ # Looks for file at ./transcend.yml
201
+ tr-push --auth=<api-key>
202
+ ```
203
+
204
+ An alternative file destination can be specified:
205
+
206
+ ```sh
207
+ # Looks for file at custom location ./custom/location.yml
208
+ tr-push --auth=<api-key> --file=./custom/location.yml
209
+ ```
210
+
211
+ Some things to note about this sync process:
212
+
213
+ 1. Any field that is defined in your .yml file will be synced up to app.transcend.io. If any change was made on the admin dashboard, it will be overwritten.
214
+ 2. If you omit a field from the yaml file, this field will not be synced. This gives you the ability to define as much or as little configuration in your transcend.yml file as you would like, and let the remainder of fields be labeled through the Admin Dashboard
215
+ 3. If you define new data subjects, identifiers, data silos or datapoints that were not previously defined on the Admin Dashboard, the cli will create these new resources automatically.
216
+ 4. Currently, this cli does not handle deleting or renaming of resources. If you need to delete or rename a data silo, identifier, enricher or API key, you should make the change on the Admin Dashboard.
217
+ 5. The only resources that this cli will not auto generate are:
218
+
219
+ - a) Data silo owners: If you assign an email address to a data silo, you must first make sure that user is invited into your Transcend instance (https://app.transcend.io/admin/users).
220
+ - b) API keys: This cli will not create new API keys. You will need to first create the new API keys on the Admin Dashboard (https://app.transcend.io/infrastructure/api-keys). You can then list out the titles of the API keys that you generated in your transcend.yml file, after which the cli is capable of updating that API key to be able to respond to different data silos in your Data Map
221
+
222
+ #### CI Integration
223
+
224
+ Once you have a workflow for creating your transcend.yml file, you will want to integrate your `tr-push` command on your CI.
225
+
226
+ Below is an example of how to set this up using a Github action:
227
+
228
+ ```yaml
229
+ name: Transcend Data Map Syncing
230
+ # See https://app.transcend.io/privacy-requests/connected-services
231
+
232
+ on:
233
+ push:
234
+ branches:
235
+ - 'main'
236
+
237
+ jobs:
238
+ deploy:
239
+ runs-on: ubuntu-latest
240
+ steps:
241
+ - uses: actions/checkout@v2
242
+
243
+ - name: Setup Node.js
244
+ uses: actions/setup-node@v2
245
+ with:
246
+ node-version: '16'
247
+
248
+ - name: Install Transcend cli
249
+ run: npm i -D @transcend-io/cli
250
+
251
+ # If you have a script that generates your transcend.yml file from
252
+ # an ORM or infrastructure configuration, add that step here
253
+ # Leave this step commented out if you want to manage your transcend.yml manually
254
+ # - name: Generate transcend.yml
255
+ # run: ./scripts/generate_transcend_yml.py
256
+
257
+ - name: Push Transcend config
258
+ run: npx tr-push --auth=${{ secrets.TRANSCEND_API_KEY }}
259
+ ```
260
+
261
+ #### Dynamic Variables
262
+
263
+ If you are using this cli to sync your Data Map between multiple Transcend instances, you may find the need to make minor modifications to your configurations between environments. The most notable difference would be the domain where your webhook URLs are hosted on.
264
+
265
+ The `tr-push` command takes in a parameter `variables`. This is a CSV of `key:value` pairs.
266
+
267
+ ```sh
268
+ tr-push --auth=<api-key> --variables=domain:acme.com,stage:staging
269
+ ```
270
+
271
+ This command could fill out multiple parameters in a yaml file like [./examples/multi-instance.yml](./examples/multi-instance.yml), copied below:
272
+
273
+ ```yml
274
+ api-keys:
275
+ - title: Webhook Key
276
+ enrichers:
277
+ - title: Basic Identity Enrichment
278
+ description: Enrich an email address to the userId and phone number
279
+ # The data silo webhook URL is the same in each environment,
280
+ # except for the base domain in the webhook URL.
281
+ url: https://example.<<parameters.domain>>/transcend-enrichment-webhook
282
+ input-identifier: email
283
+ output-identifiers:
284
+ - userId
285
+ - phone
286
+ - myUniqueIdentifier
287
+ - title: Fraud Check
288
+ description: Ensure the email address is not marked as fraudulent
289
+ url: https://example.<<parameters.domain>>/transcend-fraud-check
290
+ input-identifier: email
291
+ output-identifiers:
292
+ - email
293
+ privacy-actions:
294
+ - ERASURE
295
+ data-silos:
296
+ - title: Redshift Data Warehouse
297
+ integrationName: server
298
+ description: The mega-warehouse that contains a copy over all SQL backed databases - <<parameters.stage>>
299
+ url: https://example.<<parameters.domain>>/transcend-webhook
300
+ api-key-title: Webhook Key
301
+ ```
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli-pull.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-pull.d.ts","sourceRoot":"","sources":["../src/cli-pull.ts"],"names":[],"mappings":""}
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const yargs_parser_1 = __importDefault(require("yargs-parser"));
8
+ const logger_1 = require("./logger");
9
+ const colors_1 = __importDefault(require("colors"));
10
+ const pullTranscendConfiguration_1 = require("./pullTranscendConfiguration");
11
+ const graphql_request_1 = require("graphql-request");
12
+ const readTranscendYaml_1 = require("./readTranscendYaml");
13
+ const constants_1 = require("./constants");
14
+ /**
15
+ * Sync data silo configuration from Transcend down locally to disk
16
+ *
17
+ * Dev Usage:
18
+ * yarn ts-node ./src/cli-pull.ts --file=./examples/invalid.yml --auth=asd123
19
+ *
20
+ * Standard usage
21
+ * yarn tr-push --file=./examples/invalid.yml --auth=asd123
22
+ */
23
+ async function main() {
24
+ // Parse command line arguments
25
+ const { file = './transcend.yml', transcendUrl = 'https://api.transcend.io', dataSiloIds = '', auth, } = (0, yargs_parser_1.default)(process.argv.slice(2));
26
+ // Ensure auth is passed
27
+ if (!auth) {
28
+ logger_1.logger.error(colors_1.default.red('A Transcend API key must be provided. You can specify using --auth=asd123'));
29
+ process.exit(1);
30
+ }
31
+ // Create a GraphQL client
32
+ // eslint-disable-next-line global-require
33
+ const { version } = require('../package.json');
34
+ const client = new graphql_request_1.GraphQLClient(`${transcendUrl}/graphql`, {
35
+ headers: {
36
+ Authorization: `Bearer ${auth}`,
37
+ version,
38
+ },
39
+ });
40
+ // Sync to Disk
41
+ try {
42
+ const configuration = await (0, pullTranscendConfiguration_1.pullTranscendConfiguration)(client, dataSiloIds.split(',').filter((x) => !!x));
43
+ (0, readTranscendYaml_1.writeTranscendYaml)(file, configuration);
44
+ }
45
+ catch (err) {
46
+ logger_1.logger.error(colors_1.default.red(`An error occurred syncing the schema: ${err.message}`));
47
+ process.exit(1);
48
+ }
49
+ // Indicate success
50
+ logger_1.logger.info(colors_1.default.green(`Successfully synced yaml file to disk at ${file}! View at ${constants_1.ADMIN_DASH}`));
51
+ }
52
+ main();
53
+ //# sourceMappingURL=cli-pull.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-pull.js","sourceRoot":"","sources":["../src/cli-pull.ts"],"names":[],"mappings":";;;;;;AAEA,gEAAiC;AACjC,qCAAkC;AAClC,oDAA4B;AAC5B,6EAA0E;AAC1E,qDAAgD;AAChD,2DAAyD;AACzD,2CAAyC;AAEzC;;;;;;;;GAQG;AACH,KAAK,UAAU,IAAI;IACjB,+BAA+B;IAC/B,MAAM,EACJ,IAAI,GAAG,iBAAiB,EACxB,YAAY,GAAG,0BAA0B,EACzC,WAAW,GAAG,EAAE,EAChB,IAAI,GACL,GAAG,IAAA,sBAAK,EAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAEjC,wBAAwB;IACxB,IAAI,CAAC,IAAI,EAAE;QACT,eAAM,CAAC,KAAK,CACV,gBAAM,CAAC,GAAG,CACR,2EAA2E,CAC5E,CACF,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;IAED,0BAA0B;IAC1B,0CAA0C;IAC1C,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC/C,MAAM,MAAM,GAAG,IAAI,+BAAa,CAAC,GAAG,YAAY,UAAU,EAAE;QAC1D,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,IAAI,EAAE;YAC/B,OAAO;SACR;KACF,CAAC,CAAC;IAEH,eAAe;IACf,IAAI;QACF,MAAM,aAAa,GAAG,MAAM,IAAA,uDAA0B,EACpD,MAAM,EACL,WAAsB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CACtD,CAAC;QACF,IAAA,sCAAkB,EAAC,IAAI,EAAE,aAAa,CAAC,CAAC;KACzC;IAAC,OAAO,GAAG,EAAE;QACZ,eAAM,CAAC,KAAK,CACV,gBAAM,CAAC,GAAG,CAAC,yCAAyC,GAAG,CAAC,OAAO,EAAE,CAAC,CACnE,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;IAED,mBAAmB;IACnB,eAAM,CAAC,IAAI,CACT,gBAAM,CAAC,KAAK,CACV,4CAA4C,IAAI,aAAa,sBAAU,EAAE,CAC1E,CACF,CAAC;AACJ,CAAC;AAED,IAAI,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli-push.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-push.d.ts","sourceRoot":"","sources":["../src/cli-push.ts"],"names":[],"mappings":""}
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const yargs_parser_1 = __importDefault(require("yargs-parser"));
8
+ const logger_1 = require("./logger");
9
+ const fs_1 = require("fs");
10
+ const readTranscendYaml_1 = require("./readTranscendYaml");
11
+ const colors_1 = __importDefault(require("colors"));
12
+ const syncConfigurationToTranscend_1 = require("./syncConfigurationToTranscend");
13
+ const graphql_request_1 = require("graphql-request");
14
+ const constants_1 = require("./constants");
15
+ /**
16
+ * Push the transcend.yml file remotely into a Transcend instance
17
+ *
18
+ * Dev Usage:
19
+ * yarn ts-node ./src/cli-push.ts --file=./examples/invalid.yml --auth=asd123 --variables=domain:acme.com,stage:staging
20
+ *
21
+ * Standard usage
22
+ * yarn tr-push --file=./examples/invalid.yml --auth=asd123 --variables=domain:acme.com,stage:staging
23
+ */
24
+ async function main() {
25
+ // Parse command line arguments
26
+ const { file = './transcend.yml', transcendUrl = 'https://api.transcend.io', auth, variables = '', } = (0, yargs_parser_1.default)(process.argv.slice(2));
27
+ // Ensure auth is passed
28
+ if (!auth) {
29
+ logger_1.logger.error(colors_1.default.red('A Transcend API key must be provided. You can specify using --auth=asd123'));
30
+ process.exit(1);
31
+ }
32
+ // Ensure yaml file exists on disk
33
+ if (!(0, fs_1.existsSync)(file)) {
34
+ logger_1.logger.error(colors_1.default.red(`The file path does not exist on disk: ${file}. You can specify the filepath using --file=./examples/transcend.yml`));
35
+ process.exit(1);
36
+ }
37
+ else {
38
+ logger_1.logger.info(colors_1.default.magenta(`Reading file "${file}"...`));
39
+ }
40
+ let contents;
41
+ try {
42
+ // Parse out the variables
43
+ const splitVars = variables.split(',').filter((x) => !!x);
44
+ const vars = {};
45
+ splitVars.forEach((variable) => {
46
+ const [k, v] = variable.split(':');
47
+ vars[k] = v;
48
+ });
49
+ // Read in the yaml file and validate it's shape
50
+ contents = (0, readTranscendYaml_1.readTranscendYaml)(file, vars);
51
+ logger_1.logger.info(colors_1.default.green(`Successfully read in "${file}"`));
52
+ }
53
+ catch (err) {
54
+ logger_1.logger.error(colors_1.default.red(`The shape of your yaml file is invalid with the following errors: ${err.message}`));
55
+ process.exit(1);
56
+ }
57
+ // Create a GraphQL client
58
+ // eslint-disable-next-line global-require
59
+ const { version } = require('../package.json');
60
+ const client = new graphql_request_1.GraphQLClient(`${transcendUrl}/graphql`, {
61
+ headers: {
62
+ Authorization: `Bearer ${auth}`,
63
+ version,
64
+ },
65
+ });
66
+ // Sync to Transcend
67
+ try {
68
+ const encounteredError = await (0, syncConfigurationToTranscend_1.syncConfigurationToTranscend)(contents, client);
69
+ if (encounteredError) {
70
+ logger_1.logger.info(colors_1.default.red(`Sync encountered errors. View output above for more information, or check out ${constants_1.ADMIN_DASH}`));
71
+ process.exit(1);
72
+ }
73
+ }
74
+ catch (err) {
75
+ logger_1.logger.error(colors_1.default.red(`An error occurred syncing the schema: ${err.message}`));
76
+ process.exit(1);
77
+ }
78
+ // Indicate success
79
+ logger_1.logger.info(colors_1.default.green(`Successfully synced yaml file to Transcend! View at ${constants_1.ADMIN_DASH}`));
80
+ }
81
+ main();
82
+ //# sourceMappingURL=cli-push.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-push.js","sourceRoot":"","sources":["../src/cli-push.ts"],"names":[],"mappings":";;;;;;AAEA,gEAAiC;AACjC,qCAAkC;AAClC,2BAAgC;AAChC,2DAAwD;AACxD,oDAA4B;AAE5B,iFAA8E;AAC9E,qDAAgD;AAEhD,2CAAyC;AAEzC;;;;;;;;GAQG;AACH,KAAK,UAAU,IAAI;IACjB,+BAA+B;IAC/B,MAAM,EACJ,IAAI,GAAG,iBAAiB,EACxB,YAAY,GAAG,0BAA0B,EACzC,IAAI,EACJ,SAAS,GAAG,EAAE,GACf,GAAG,IAAA,sBAAK,EAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAA8B,CAAC;IAE9D,wBAAwB;IACxB,IAAI,CAAC,IAAI,EAAE;QACT,eAAM,CAAC,KAAK,CACV,gBAAM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