contensis-cli 1.0.0-beta.5

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/.vscode/launch.json +15 -0
  2. package/README.md +631 -0
  3. package/cli.js +7 -0
  4. package/dist/commands/connect.js +44 -0
  5. package/dist/commands/connect.js.map +7 -0
  6. package/dist/commands/create.js +55 -0
  7. package/dist/commands/create.js.map +7 -0
  8. package/dist/commands/get.js +121 -0
  9. package/dist/commands/get.js.map +7 -0
  10. package/dist/commands/globalOptions.js +139 -0
  11. package/dist/commands/globalOptions.js.map +7 -0
  12. package/dist/commands/import.js +95 -0
  13. package/dist/commands/import.js.map +7 -0
  14. package/dist/commands/index.js +81 -0
  15. package/dist/commands/index.js.map +7 -0
  16. package/dist/commands/list.js +88 -0
  17. package/dist/commands/list.js.map +7 -0
  18. package/dist/commands/login.js +56 -0
  19. package/dist/commands/login.js.map +7 -0
  20. package/dist/commands/push.js +133 -0
  21. package/dist/commands/push.js.map +7 -0
  22. package/dist/commands/remove.js +77 -0
  23. package/dist/commands/remove.js.map +7 -0
  24. package/dist/commands/set.js +55 -0
  25. package/dist/commands/set.js.map +7 -0
  26. package/dist/index.js +32 -0
  27. package/dist/index.js.map +7 -0
  28. package/dist/localisation/en-GB.js +203 -0
  29. package/dist/localisation/en-GB.js.map +7 -0
  30. package/dist/models/AppError.d.js +2 -0
  31. package/dist/models/AppError.d.js.map +7 -0
  32. package/dist/models/Cache.d.js +2 -0
  33. package/dist/models/Cache.d.js.map +7 -0
  34. package/dist/models/JsModules.d.js +2 -0
  35. package/dist/models/JsModules.d.js.map +7 -0
  36. package/dist/providers/CredentialProvider.js +87 -0
  37. package/dist/providers/CredentialProvider.js.map +7 -0
  38. package/dist/providers/SessionCacheProvider.js +91 -0
  39. package/dist/providers/SessionCacheProvider.js.map +7 -0
  40. package/dist/providers/file-provider.js +113 -0
  41. package/dist/providers/file-provider.js.map +7 -0
  42. package/dist/services/ContensisAuthService.js +75 -0
  43. package/dist/services/ContensisAuthService.js.map +7 -0
  44. package/dist/services/ContensisCliService.js +1110 -0
  45. package/dist/services/ContensisCliService.js.map +7 -0
  46. package/dist/shell.js +261 -0
  47. package/dist/shell.js.map +7 -0
  48. package/dist/util/console.printer.js +194 -0
  49. package/dist/util/console.printer.js.map +7 -0
  50. package/dist/util/csv.formatter.js +50 -0
  51. package/dist/util/csv.formatter.js.map +7 -0
  52. package/dist/util/index.js +94 -0
  53. package/dist/util/index.js.map +7 -0
  54. package/dist/util/json.formatter.js +29 -0
  55. package/dist/util/json.formatter.js.map +7 -0
  56. package/dist/util/logger.js +184 -0
  57. package/dist/util/logger.js.map +7 -0
  58. package/dist/util/xml.formatter.js +51 -0
  59. package/dist/util/xml.formatter.js.map +7 -0
  60. package/dist/version.js +29 -0
  61. package/dist/version.js.map +7 -0
  62. package/esbuild.config.js +49 -0
  63. package/headless-setup.sh +7 -0
  64. package/package.json +59 -0
  65. package/patches/inquirer-command-prompt+0.1.0.patch +27 -0
  66. package/src/commands/connect.ts +23 -0
  67. package/src/commands/create.ts +41 -0
  68. package/src/commands/get.ts +139 -0
  69. package/src/commands/globalOptions.ts +126 -0
  70. package/src/commands/import.ts +89 -0
  71. package/src/commands/index.ts +72 -0
  72. package/src/commands/list.ts +90 -0
  73. package/src/commands/login.ts +33 -0
  74. package/src/commands/push.ts +120 -0
  75. package/src/commands/remove.ts +77 -0
  76. package/src/commands/set.ts +40 -0
  77. package/src/index.ts +19 -0
  78. package/src/localisation/en-GB.ts +211 -0
  79. package/src/models/AppError.d.ts +40 -0
  80. package/src/models/Cache.d.ts +25 -0
  81. package/src/models/JsModules.d.ts +1 -0
  82. package/src/providers/CredentialProvider.ts +88 -0
  83. package/src/providers/SessionCacheProvider.ts +74 -0
  84. package/src/providers/file-provider.ts +72 -0
  85. package/src/services/ContensisAuthService.ts +70 -0
  86. package/src/services/ContensisCliService.ts +1390 -0
  87. package/src/shell.ts +250 -0
  88. package/src/util/console.printer.ts +203 -0
  89. package/src/util/csv.formatter.ts +21 -0
  90. package/src/util/index.ts +67 -0
  91. package/src/util/json.formatter.ts +1 -0
  92. package/src/util/logger.ts +165 -0
  93. package/src/util/xml.formatter.ts +20 -0
  94. package/src/version.ts +1 -0
  95. package/tsconfig.json +22 -0
@@ -0,0 +1,203 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var en_GB_exports = {};
20
+ __export(en_GB_exports, {
21
+ LogMessages: () => LogMessages
22
+ });
23
+ module.exports = __toCommonJS(en_GB_exports);
24
+ var import_logger = require("../util/logger");
25
+ const LogMessages = {
26
+ app: {
27
+ contensis: () => "Contensis",
28
+ quit: () => `Goodbye \u{1F44B}
29
+ `,
30
+ startup: () => `\xA9 2001-${new Date().getFullYear()} Zengenti \u{1F1EC}\u{1F1E7}.
31
+ - Creators of Contensis and purveyors of other fine software
32
+
33
+ \u{1F44B} Welcome to the contensis-cli
34
+ `,
35
+ help: () => 'Press [CTRL]+[C] or type "quit" to return to your system shell\nPress [TAB] for suggestions\n',
36
+ suggestions: () => `
37
+ ${import_logger.Logger.errorText(">>")} Press [TAB] for suggestions
38
+ `,
39
+ autocomplete: () => `
40
+ ${import_logger.Logger.errorText(">>")} Available commands:`,
41
+ unknownError: () => `Something went wrong...`,
42
+ fileOutput: (format = "json", path) => `Output ${format} file: ${import_logger.Logger.infoText(path)}
43
+ `,
44
+ noFileOutput: () => `No output written
45
+ `
46
+ },
47
+ command: {
48
+ notKnown: (command) => `${command} is not known`
49
+ },
50
+ envs: {
51
+ found: (num) => `environments store found containing ${num} environment${num === 1 ? "" : "s"}`,
52
+ tip: () => `Connect to a Contensis cloud instance using "contensis connect {cms alias}"`
53
+ },
54
+ connect: {
55
+ command: {
56
+ name: () => "connect",
57
+ example: () => `Example call:
58
+ > connect example-dev`
59
+ },
60
+ args: {
61
+ alias: {
62
+ name: () => "<alias>",
63
+ description: () => "the Contensis Cloud alias to connect with"
64
+ }
65
+ },
66
+ noEnv: () => `Cannot connect - no environment alias specified`,
67
+ unreachable: (url, status) => `Cannot reach ${url}${status ? ` - status ${status}` : ""}`,
68
+ connected: (env) => `Current environment set to "${env}"`,
69
+ help: () => `Connect to a Contensis cloud instance using "contensis connect {cms alias}"`,
70
+ projects: () => `Available projects:`,
71
+ noProjects: () => `Cannot retrieve projects list`,
72
+ tip: () => `Introduce yourself with "login {username}" or "login {clientId} -s {secret}" or by passing credentials as options with your command`
73
+ },
74
+ login: {
75
+ command: {
76
+ name: () => "login",
77
+ usage: () => `<user/clientId> [password] [-s <sharedSecret>]`,
78
+ example: () => `Example call:
79
+ > login myuserid
80
+ -- or --
81
+ > login {clientId} -s {sharedSecret}`
82
+ },
83
+ args: {
84
+ user: {
85
+ name: () => "<user/clientId>",
86
+ description: () => "the username to login with"
87
+ },
88
+ password: {
89
+ name: () => "[password]",
90
+ description: () => "the password to use to login with (optional/insecure)"
91
+ },
92
+ secret: {
93
+ name: () => "-s --sharedSecret <sharedSecret>",
94
+ description: () => "the shared secret to use when logging in with a client id"
95
+ }
96
+ },
97
+ passwordPrompt: (env, userId) => `Enter password for ${userId}@${env}:`,
98
+ failed: (env, userId) => `Unable to login to ${env} as ${userId}`,
99
+ success: (env, userId) => `User ${userId} connected to ${env} successfully
100
+ `,
101
+ insecurePassword: () => `Could not connect to local keystore - your password could be stored unencrypted!`,
102
+ noEnv: () => `No environment set, use "contensis connect {alias}" first`,
103
+ noUserId: () => `No user id specified`
104
+ },
105
+ projects: {
106
+ list: () => `Available projects:`,
107
+ noList: () => `Cannot retrieve projects list`,
108
+ set: (projectId) => `Current project is set to "${projectId}"`,
109
+ failedSet: (projectId) => `Project "${projectId}" not found`
110
+ },
111
+ contenttypes: {
112
+ list: (projectId) => `Content types in "${projectId}":`,
113
+ noList: (projectId) => `[${projectId}] Cannot retrieve content types list`,
114
+ get: (projectId, contentTypeId) => `[${projectId}] Content type "${contentTypeId}"`,
115
+ failedGet: (projectId, contentTypeId) => `[${projectId}] Unable to get content type "${contentTypeId}"`,
116
+ created: (projectId, componentId, status) => `[${projectId}] Content type ${status}d "${componentId}"`,
117
+ removed: (env, id, commit) => `[${env}] ${commit ? `Deleted` : `Will delete`} content type "${id}"`,
118
+ failedRemove: (env, id) => `[${env}] Unable to delete content type "${id}"`
119
+ },
120
+ components: {
121
+ list: (projectId) => `Components in "${projectId}":`,
122
+ noList: (projectId) => `[${projectId}] Cannot retrieve components list`,
123
+ get: (projectId, componentId) => `[${projectId}] Component "${componentId}"`,
124
+ failedGet: (projectId, componentId) => `[${projectId}] Unable to get component "${componentId}"`,
125
+ created: (projectId, componentId, status) => `[${projectId}] Component ${status}d "${componentId}"`,
126
+ removed: (env, id, commit) => `[${env}] ${commit ? `Deleted` : `Will delete`} component "${id}"`,
127
+ failedRemove: (env, id) => `[${env}] Unable to delete component "${id}"`
128
+ },
129
+ version: {
130
+ set: (env, versionStatus) => `[${env}] Content version status set to "${versionStatus}"`,
131
+ invalid: (versionStatus) => `Content version status "${versionStatus}" is not valid, allowed values are "published" or "latest".`,
132
+ noEnv: () => `No Contensis environment set, connect to your Contensis cloud instance using "contensis connect {cms alias}"`
133
+ },
134
+ entries: {
135
+ migrateStatus: (status) => {
136
+ switch (status) {
137
+ case "no change":
138
+ return import_logger.Logger.successText;
139
+ case "create":
140
+ case "two-pass":
141
+ case "update":
142
+ case "delete":
143
+ return import_logger.Logger.warningText;
144
+ case "error":
145
+ case "not found":
146
+ return import_logger.Logger.errorText;
147
+ default:
148
+ return import_logger.Logger.infoText;
149
+ }
150
+ },
151
+ removed: (env, id, commit) => `[${env}] ${commit ? `Deleted` : `Will delete`} entry "${id}"`,
152
+ failedRemove: (env, id) => `[${env}] Unable to delete entry "${id}"`,
153
+ notFound: (id) => `Entry "${id}" not found`,
154
+ commitTip: () => ` Add --commit flag to commit the previewed changes`
155
+ },
156
+ keys: {
157
+ list: (env) => `[${env}] API keys:`,
158
+ noList: (env) => `[${env}] Cannot retrieve API`,
159
+ created: (env, name) => `[${env}] Created API key "${name}"`,
160
+ failedCreate: (env, name) => `[${env}] Unable to create API key "${name}"`,
161
+ removed: (env, id) => `[${env}] Deleted API key "${id}"`,
162
+ failedRemove: (env, id) => `[${env}] Unable to delete API key "${id}"`
163
+ },
164
+ blocks: {
165
+ runningStatus: (status) => {
166
+ switch (status) {
167
+ case "available":
168
+ return import_logger.Logger.successText(status);
169
+ case "pending":
170
+ case "starting":
171
+ case "stopped":
172
+ return import_logger.Logger.warningText(status);
173
+ case "degraded":
174
+ case "faulted":
175
+ case "broken":
176
+ return import_logger.Logger.errorText(status);
177
+ default:
178
+ return import_logger.Logger.infoText(status);
179
+ }
180
+ },
181
+ get: (env) => `[${env}] Block versions:`,
182
+ list: (env, projectId) => `[${env}] Blocks in project ${projectId}:`,
183
+ noList: (env, projectId) => `[${env}] Cannot retrieve blocks in project ${projectId}`,
184
+ tryPush: (id, branch, env, projectId) => `[${env}] Request to push block "${id}" in branch ${branch} in project ${projectId}`,
185
+ pushed: (id, branch, env, projectId) => `[${env}] Pushed block "${id}" in branch ${branch} in project ${projectId}`,
186
+ failedPush: (id, env, projectId) => `[${env}] Unable to push block "${id}" in project ${projectId}`,
187
+ deleted: (id, env, projectId) => `[${env}] Deleted block "${id}" in project ${projectId}`,
188
+ failedDelete: (id, env, projectId) => `[${env}] Unable to delete block "${id}" in project ${projectId}`
189
+ },
190
+ webhooks: {
191
+ list: (env) => `[${env}] Webhook subscriptions:`,
192
+ noList: (env) => `[${env}] Cannot retrieve webhook subscriptions`,
193
+ created: (env, name) => `[${env}] Created Webhook subscription "${name}"`,
194
+ failedCreate: (env, name) => `[${env}] Unable to create Webhook subscription "${name}"`,
195
+ deleted: (env, id) => `[${env}] Deleted Webhook subscription "${id}"`,
196
+ failedDelete: (env, id) => `[${env}] Unable to delete Webhook subscription "${id}"`
197
+ }
198
+ };
199
+ // Annotate the CommonJS export names for ESM import in node:
200
+ 0 && (module.exports = {
201
+ LogMessages
202
+ });
203
+ //# sourceMappingURL=en-GB.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/localisation/en-GB.ts"],
4
+ "sourcesContent": ["import { BlockRunningStatus, MigrateStatus } from 'migratortron';\nimport { Logger } from '~/util/logger';\n\nexport const LogMessages = {\n app: {\n contensis: () => 'Contensis',\n quit: () => `Goodbye \uD83D\uDC4B\\n`,\n startup: () =>\n `\u00A9 2001-${new Date().getFullYear()} Zengenti \uD83C\uDDEC\uD83C\uDDE7. \\n - Creators of Contensis and purveyors of other fine software\\n\\n\uD83D\uDC4B Welcome to the contensis-cli\\n`,\n help: () =>\n 'Press [CTRL]+[C] or type \"quit\" to return to your system shell\\nPress [TAB] for suggestions\\n',\n suggestions: () =>\n `\\n${Logger.errorText('>>')} Press [TAB] for suggestions\\n`,\n autocomplete: () => `\\n${Logger.errorText('>>')} Available commands:`,\n unknownError: () => `Something went wrong...`,\n fileOutput: (format = 'json', path?: string) =>\n `Output ${format} file: ${Logger.infoText(path)}\\n`,\n noFileOutput: () => `No output written\\n`,\n },\n command: {\n notKnown: (command: string) => `${command} is not known`,\n },\n envs: {\n found: (num: number) =>\n `environments store found containing ${num} environment${\n num === 1 ? '' : 's'\n }`,\n tip: () =>\n `Connect to a Contensis cloud instance using \"contensis connect {cms alias}\"`,\n },\n connect: {\n command: {\n name: () => 'connect',\n example: () => `Example call:\\n > connect example-dev`,\n },\n args: {\n alias: {\n name: () => '<alias>',\n description: () => 'the Contensis Cloud alias to connect with',\n },\n },\n noEnv: () => `Cannot connect - no environment alias specified`,\n unreachable: (url: string, status: number) =>\n `Cannot reach ${url}${status ? ` - status ${status}` : ''}`,\n connected: (env: string) => `Current environment set to \"${env}\"`,\n help: () =>\n `Connect to a Contensis cloud instance using \"contensis connect {cms alias}\"`,\n projects: () => `Available projects:`,\n noProjects: () => `Cannot retrieve projects list`,\n tip: () =>\n `Introduce yourself with \"login {username}\" or \"login {clientId} -s {secret}\" or by passing credentials as options with your command`,\n },\n login: {\n command: {\n name: () => 'login',\n usage: () => `<user/clientId> [password] [-s <sharedSecret>]`,\n example: () =>\n `Example call:\\n > login myuserid\\n -- or --\\n > login {clientId} -s {sharedSecret}`,\n },\n args: {\n user: {\n name: () => '<user/clientId>',\n description: () => 'the username to login with',\n },\n password: {\n name: () => '[password]',\n description: () =>\n 'the password to use to login with (optional/insecure)',\n },\n secret: {\n name: () => '-s --sharedSecret <sharedSecret>',\n description: () =>\n 'the shared secret to use when logging in with a client id',\n },\n },\n passwordPrompt: (env: string, userId: string) =>\n `Enter password for ${userId}@${env}:`,\n failed: (env: string, userId: string) =>\n `Unable to login to ${env} as ${userId}`,\n success: (env: string, userId: string) =>\n `User ${userId} connected to ${env} successfully\\n`,\n insecurePassword: () =>\n `Could not connect to local keystore - your password could be stored unencrypted!`,\n noEnv: () => `No environment set, use \"contensis connect {alias}\" first`,\n noUserId: () => `No user id specified`,\n },\n projects: {\n list: () => `Available projects:`,\n noList: () => `Cannot retrieve projects list`,\n set: (projectId: string) => `Current project is set to \"${projectId}\"`,\n failedSet: (projectId: string) => `Project \"${projectId}\" not found`,\n },\n contenttypes: {\n list: (projectId: string) => `Content types in \"${projectId}\":`,\n noList: (projectId: string) =>\n `[${projectId}] Cannot retrieve content types list`,\n get: (projectId: string, contentTypeId: string) =>\n `[${projectId}] Content type \"${contentTypeId}\"`,\n failedGet: (projectId: string, contentTypeId: string) =>\n `[${projectId}] Unable to get content type \"${contentTypeId}\"`,\n created: (projectId: string, componentId: string, status?: string) =>\n `[${projectId}] Content type ${status}d \"${componentId}\"`,\n removed: (env: string, id: string, commit: boolean) =>\n `[${env}] ${commit ? `Deleted` : `Will delete`} content type \"${id}\"`,\n failedRemove: (env: string, id: string) =>\n `[${env}] Unable to delete content type \"${id}\"`,\n },\n components: {\n list: (projectId: string) => `Components in \"${projectId}\":`,\n noList: (projectId: string) =>\n `[${projectId}] Cannot retrieve components list`,\n get: (projectId: string, componentId: string) =>\n `[${projectId}] Component \"${componentId}\"`,\n failedGet: (projectId: string, componentId: string) =>\n `[${projectId}] Unable to get component \"${componentId}\"`,\n created: (projectId: string, componentId: string, status?: string) =>\n `[${projectId}] Component ${status}d \"${componentId}\"`,\n removed: (env: string, id: string, commit: boolean) =>\n `[${env}] ${commit ? `Deleted` : `Will delete`} component \"${id}\"`,\n failedRemove: (env: string, id: string) =>\n `[${env}] Unable to delete component \"${id}\"`,\n },\n version: {\n set: (env: string, versionStatus: string) =>\n `[${env}] Content version status set to \"${versionStatus}\"`,\n invalid: (versionStatus: string) =>\n `Content version status \"${versionStatus}\" is not valid, allowed values are \"published\" or \"latest\".`,\n noEnv: () =>\n `No Contensis environment set, connect to your Contensis cloud instance using \"contensis connect {cms alias}\"`,\n },\n entries: {\n migrateStatus: (status: MigrateStatus) => {\n switch (status) {\n case 'no change':\n return Logger.successText;\n case 'create':\n case 'two-pass':\n case 'update':\n case 'delete':\n return Logger.warningText;\n case 'error':\n case 'not found':\n return Logger.errorText;\n default:\n return Logger.infoText;\n }\n },\n removed: (env: string, id: string, commit: boolean) =>\n `[${env}] ${commit ? `Deleted` : `Will delete`} entry \"${id}\"`,\n failedRemove: (env: string, id: string) =>\n `[${env}] Unable to delete entry \"${id}\"`,\n notFound: (id: string) => `Entry \"${id}\" not found`,\n commitTip: () => ` Add --commit flag to commit the previewed changes`,\n },\n keys: {\n list: (env: string) => `[${env}] API keys:`,\n noList: (env: string) => `[${env}] Cannot retrieve API`,\n created: (env: string, name: string) =>\n `[${env}] Created API key \"${name}\"`,\n failedCreate: (env: string, name: string) =>\n `[${env}] Unable to create API key \"${name}\"`,\n removed: (env: string, id: string) => `[${env}] Deleted API key \"${id}\"`,\n failedRemove: (env: string, id: string) =>\n `[${env}] Unable to delete API key \"${id}\"`,\n },\n blocks: {\n runningStatus: (status: BlockRunningStatus | 'broken') => {\n switch (status) {\n case 'available':\n return Logger.successText(status);\n case 'pending':\n case 'starting':\n case 'stopped':\n return Logger.warningText(status);\n case 'degraded':\n case 'faulted':\n case 'broken':\n return Logger.errorText(status);\n default:\n return Logger.infoText(status);\n }\n },\n get: (env: string) => `[${env}] Block versions:`,\n list: (env: string, projectId?: string) =>\n `[${env}] Blocks in project ${projectId}:`,\n noList: (env: string, projectId?: string) =>\n `[${env}] Cannot retrieve blocks in project ${projectId}`,\n tryPush: (id: string, branch: string, env: string, projectId?: string) =>\n `[${env}] Request to push block \"${id}\" in branch ${branch} in project ${projectId}`,\n pushed: (id: string, branch: string, env: string, projectId?: string) =>\n `[${env}] Pushed block \"${id}\" in branch ${branch} in project ${projectId}`,\n failedPush: (id: string, env: string, projectId?: string) =>\n `[${env}] Unable to push block \"${id}\" in project ${projectId}`,\n deleted: (id: string, env: string, projectId?: string) =>\n `[${env}] Deleted block \"${id}\" in project ${projectId}`,\n failedDelete: (id: string, env: string, projectId?: string) =>\n `[${env}] Unable to delete block \"${id}\" in project ${projectId}`,\n },\n webhooks: {\n list: (env: string) => `[${env}] Webhook subscriptions:`,\n noList: (env: string) => `[${env}] Cannot retrieve webhook subscriptions`,\n created: (env: string, name: string) =>\n `[${env}] Created Webhook subscription \"${name}\"`,\n failedCreate: (env: string, name: string) =>\n `[${env}] Unable to create Webhook subscription \"${name}\"`,\n deleted: (env: string, id: string) =>\n `[${env}] Deleted Webhook subscription \"${id}\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ppError.d.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=Cache.d.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=JsModules.d.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to2, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to2, key) && key !== except)
16
+ __defProp(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to2;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var CredentialProvider_exports = {};
26
+ __export(CredentialProvider_exports, {
27
+ default: () => CredentialProvider_default
28
+ });
29
+ module.exports = __toCommonJS(CredentialProvider_exports);
30
+ var import_keytar = __toESM(require("keytar"));
31
+ var import_await_to_js = __toESM(require("await-to-js"));
32
+ var import_logger = require("../util/logger");
33
+ const SERVICE_NAME = "contensis-cli";
34
+ class CredentialProvider {
35
+ serviceId;
36
+ userId = "";
37
+ passwordFallback;
38
+ current = null;
39
+ remarks = { secure: false };
40
+ constructor({ userId, alias }, passwordFallback) {
41
+ this.serviceId = typeof alias !== "undefined" ? `${SERVICE_NAME}_${alias}` : SERVICE_NAME;
42
+ this.userId = userId;
43
+ this.passwordFallback = passwordFallback;
44
+ }
45
+ Init = async () => {
46
+ const [err, stored] = await (0, import_await_to_js.default)(
47
+ import_keytar.default.findCredentials(this.serviceId)
48
+ );
49
+ if (err && this.passwordFallback) {
50
+ this.current = { account: this.userId, password: this.passwordFallback };
51
+ }
52
+ if (!err) {
53
+ this.remarks = { secure: true };
54
+ this.current = (stored == null ? void 0 : stored.find(
55
+ (u) => {
56
+ var _a;
57
+ return ((_a = u == null ? void 0 : u.account) == null ? void 0 : _a.toLowerCase()) === this.userId.toLowerCase();
58
+ }
59
+ )) || null;
60
+ }
61
+ return [err, this];
62
+ };
63
+ Save = async (password) => {
64
+ const [err] = await (0, import_await_to_js.default)(
65
+ import_keytar.default.setPassword(this.serviceId, this.userId, password)
66
+ );
67
+ if (!err)
68
+ import_logger.Logger.info(`${this.serviceId} - credentials saved`);
69
+ return err && !this.passwordFallback ? err : true;
70
+ };
71
+ Delete = async () => {
72
+ if (this.passwordFallback) {
73
+ this.passwordFallback = void 0;
74
+ return true;
75
+ } else {
76
+ const [err] = await (0, import_await_to_js.default)(
77
+ import_keytar.default.deletePassword(this.serviceId, this.userId)
78
+ );
79
+ import_logger.Logger.warning(`${this.serviceId} - invalid credentials removed`);
80
+ return err || true;
81
+ }
82
+ };
83
+ }
84
+ var CredentialProvider_default = CredentialProvider;
85
+ // Annotate the CommonJS export names for ESM import in node:
86
+ 0 && (module.exports = {});
87
+ //# sourceMappingURL=CredentialProvider.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/providers/CredentialProvider.ts"],
4
+ "sourcesContent": ["import keytar from 'keytar';\nimport to from 'await-to-js';\nimport { Logger } from '~/util/logger';\n\nconst SERVICE_NAME = 'contensis-cli';\n\ninterface Remarks {\n secure: boolean;\n}\n\nclass CredentialProvider {\n private serviceId: string;\n private userId: string = '';\n private passwordFallback?: string;\n\n current: {\n account: string;\n password: string;\n } | null = null;\n remarks: Remarks = { secure: false };\n\n constructor(\n { userId, alias }: { userId: string; alias?: string },\n passwordFallback?: string\n ) {\n this.serviceId =\n typeof alias !== 'undefined' ? `${SERVICE_NAME}_${alias}` : SERVICE_NAME;\n this.userId = userId;\n this.passwordFallback = passwordFallback;\n }\n\n Init = async (): Promise<[Error, CredentialProvider]> => {\n const [err, stored] = (await to(\n keytar.findCredentials(this.serviceId)\n )) as [\n Error,\n {\n account: string;\n password: string;\n }[]\n ];\n if (err && this.passwordFallback) {\n this.current = { account: this.userId, password: this.passwordFallback };\n // this.remarks = { secure: false };\n }\n if (!err) {\n this.remarks = { secure: true };\n this.current =\n stored?.find(\n u => u?.account?.toLowerCase() === this.userId.toLowerCase()\n ) || null;\n }\n return [err, this];\n };\n\n Save = async (password: string) => {\n const [err] = await to(\n keytar.setPassword(this.serviceId, this.userId, password)\n );\n\n if (!err) Logger.info(`${this.serviceId} - credentials saved`);\n return err && !this.passwordFallback ? err : true;\n };\n\n Delete = async () => {\n if (this.passwordFallback) {\n this.passwordFallback = undefined;\n return true;\n } else {\n const [err] = await to(\n keytar.deletePassword(this.serviceId, this.userId)\n );\n\n Logger.warning(`${this.serviceId} - invalid credentials removed`);\n return err || true;\n }\n };\n\n // GetPassword = async () => {\n // const [err, password] = await to(\n // keytar.getPassword(this.serviceId, this.userId)\n // );\n\n // return err || password;\n // };\n}\n\nexport default CredentialProvider;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;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C,GAAG,IAAI,UAAM,mBAAAD;AAAA,QAClB,cAAAC,QAAO,eAAe,KAAK,WAAW,KAAK,MAAM;AAAA,MACnD;AAEA,2BAAO,QAAQ,GAAG,KAAK,yCAAyC;AAChE,aAAO,OAAO;AAAA,IAChB;AAAA,EACF;AASF;AAEA,IAAO,6BAAQ;",
6
+ "names": ["to", "keytar"]
7
+ }
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var SessionCacheProvider_exports = {};
26
+ __export(SessionCacheProvider_exports, {
27
+ default: () => SessionCacheProvider_default
28
+ });
29
+ module.exports = __toCommonJS(SessionCacheProvider_exports);
30
+ var import_fs = __toESM(require("fs"));
31
+ var import_path = __toESM(require("path"));
32
+ var import_cloneDeep = __toESM(require("lodash/cloneDeep"));
33
+ var import_mergeWith = __toESM(require("lodash/mergeWith"));
34
+ var import_unionBy = __toESM(require("lodash/unionBy"));
35
+ var import_util = require("../util");
36
+ var import_logger = require("../util/logger");
37
+ class SessionCacheProvider {
38
+ localFilePath;
39
+ cache = {};
40
+ constructor() {
41
+ this.localFilePath = import_path.default.join(__dirname, "../../environments.json");
42
+ this.cache = {
43
+ currentTimestamp: new Date().toISOString(),
44
+ environments: {},
45
+ history: []
46
+ };
47
+ this.ReadCacheFromDisk();
48
+ }
49
+ ReadCacheFromDisk = () => {
50
+ try {
51
+ if (import_fs.default.existsSync(this.localFilePath)) {
52
+ const raw = import_fs.default.readFileSync(this.localFilePath, "utf-8");
53
+ if ((0, import_util.isJson)(raw))
54
+ this.cache = (0, import_util.tryParse)(raw);
55
+ } else {
56
+ this.WriteCacheToDisk();
57
+ }
58
+ } catch (ex) {
59
+ }
60
+ };
61
+ WriteCacheToDisk = () => {
62
+ try {
63
+ import_fs.default.writeFileSync(this.localFilePath, JSON.stringify(this.cache, null, 2));
64
+ } catch (ex) {
65
+ }
66
+ };
67
+ Get = () => (0, import_cloneDeep.default)(this.cache);
68
+ Update = (updateContent) => {
69
+ try {
70
+ this.cache = (0, import_mergeWith.default)(this.cache, updateContent, (val, src, key) => {
71
+ if (key === "history" && ((src == null ? void 0 : src[0]) && typeof src[0] === "object" && "createdDate" in src[0] || (val == null ? void 0 : val[0]) && typeof val[0] === "object" && "createdDate" in val[0])) {
72
+ return (0, import_unionBy.default)(val, src, "createdDate");
73
+ }
74
+ if (key === "projects")
75
+ return Array.isArray(val) ? [.../* @__PURE__ */ new Set([...val, ...src])] : src;
76
+ if (Array.isArray(val))
77
+ return val.concat(src);
78
+ });
79
+ this.cache.currentTimestamp = new Date().toISOString();
80
+ this.WriteCacheToDisk();
81
+ } catch (ex) {
82
+ import_logger.Logger.error(`Problem updating environments.json`);
83
+ import_logger.Logger.error(ex);
84
+ }
85
+ return this.Get();
86
+ };
87
+ }
88
+ var SessionCacheProvider_default = SessionCacheProvider;
89
+ // Annotate the CommonJS export names for ESM import in node:
90
+ 0 && (module.exports = {});
91
+ //# sourceMappingURL=SessionCacheProvider.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/providers/SessionCacheProvider.ts"],
4
+ "sourcesContent": ["import fs from 'fs';\nimport path from 'path';\nimport clone from 'lodash/cloneDeep';\nimport mergeWith from 'lodash/mergeWith';\nimport unionBy from 'lodash/unionBy';\nimport { isJson, tryParse, tryStringify } from '~/util';\nimport { Logger } from '~/util/logger';\n\nclass SessionCacheProvider {\n private localFilePath: string;\n private cache = {} as SessionCache;\n\n constructor() {\n this.localFilePath = path.join(__dirname, '../../environments.json');\n this.cache = {\n currentTimestamp: new Date().toISOString(),\n environments: {},\n history: [],\n };\n this.ReadCacheFromDisk();\n }\n\n private ReadCacheFromDisk = () => {\n try {\n if (fs.existsSync(this.localFilePath)) {\n const raw = fs.readFileSync(this.localFilePath, 'utf-8');\n if (isJson(raw)) this.cache = tryParse(raw);\n } else {\n this.WriteCacheToDisk();\n }\n } catch (ex) {\n // Problem reading or parsing cache file\n }\n };\n\n private WriteCacheToDisk = () => {\n try {\n fs.writeFileSync(this.localFilePath, JSON.stringify(this.cache, null, 2));\n } catch (ex) {\n // Problem writing session cache to file\n }\n };\n\n Get = () => clone(this.cache);\n\n Update = (updateContent: Partial<SessionCache>) => {\n try {\n this.cache = mergeWith(this.cache, updateContent, (val, src, key) => {\n if (\n key === 'history' &&\n ((src?.[0] &&\n typeof src[0] === 'object' &&\n 'createdDate' in src[0]) ||\n (val?.[0] && typeof val[0] === 'object' && 'createdDate' in val[0]))\n ) {\n return unionBy(val, src, 'createdDate');\n }\n if (key === 'projects')\n return Array.isArray(val) ? [...new Set([...val, ...src])] : src;\n\n if (Array.isArray(val)) return val.concat(src);\n });\n this.cache.currentTimestamp = new Date().toISOString();\n this.WriteCacheToDisk();\n } catch (ex: any) {\n // Problem merging cache data for update\n Logger.error(`Problem updating environments.json`);\n Logger.error(ex);\n }\n return this.Get();\n };\n}\n\nexport default SessionCacheProvider;\n"],
5
+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qBAAO,eAAAC,SAAQ,KAAK,KAAK,aAAa;AAAA,QACxC;AACA,YAAI,QAAQ;AACV,iBAAO,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,oBAAI,IAAI,CAAC,GAAG,KAAK,GAAG,GAAG,CAAC,CAAC,IAAI;AAE/D,YAAI,MAAM,QAAQ,GAAG;AAAG,iBAAO,IAAI,OAAO,GAAG;AAAA,MAC/C,CAAC;AACD,WAAK,MAAM,mBAAmB,IAAI,KAAK,EAAE,YAAY;AACrD,WAAK,iBAAiB;AAAA,IACxB,SAAS,IAAP;AAEA,2BAAO,MAAM,oCAAoC;AACjD,2BAAO,MAAM,EAAE;AAAA,IACjB;AACA,WAAO,KAAK,IAAI;AAAA,EAClB;AACF;AAEA,IAAO,+BAAQ;",
6
+ "names": ["path", "fs", "clone", "mergeWith", "unionBy"]
7
+ }
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var file_provider_exports = {};
26
+ __export(file_provider_exports, {
27
+ checkDir: () => checkDir,
28
+ localPath: () => localPath,
29
+ moveFile: () => moveFile,
30
+ readFile: () => readFile,
31
+ readFiles: () => readFiles,
32
+ readJsonFile: () => readJsonFile,
33
+ removeFile: () => removeFile,
34
+ writeFile: () => writeFile
35
+ });
36
+ module.exports = __toCommonJS(file_provider_exports);
37
+ var import_fs = __toESM(require("fs"));
38
+ var import_path = __toESM(require("path"));
39
+ var import_app_root_path = require("app-root-path");
40
+ var import_util = require("../util");
41
+ const readJsonFile = (filePath) => {
42
+ const file = readFile(filePath);
43
+ if (file)
44
+ return (0, import_util.tryParse)(file);
45
+ return void 0;
46
+ };
47
+ const readFile = (filePath) => {
48
+ const directoryPath = localPath(filePath);
49
+ if (import_fs.default.existsSync(directoryPath)) {
50
+ const file = import_fs.default.readFileSync(directoryPath, "utf8");
51
+ return file;
52
+ } else {
53
+ return void 0;
54
+ }
55
+ };
56
+ const readFiles = (directory) => {
57
+ const directoryPath = localPath(directory);
58
+ if (import_fs.default.existsSync(directoryPath)) {
59
+ const files = import_fs.default.readdirSync(directoryPath);
60
+ return files;
61
+ } else {
62
+ import_fs.default.mkdirSync(directoryPath, { recursive: true });
63
+ return [];
64
+ }
65
+ };
66
+ const writeFile = (filePath, content) => {
67
+ const directoryPath = localPath(filePath);
68
+ import_fs.default.writeFileSync(directoryPath, content, { encoding: "utf-8" });
69
+ };
70
+ const removeFile = (filePath) => {
71
+ const directoryPath = localPath(filePath);
72
+ if (import_fs.default.existsSync(directoryPath)) {
73
+ import_fs.default.rmSync(directoryPath);
74
+ }
75
+ };
76
+ const moveFile = (file, fromPath, toPath) => {
77
+ const from = import_path.default.join(import_app_root_path.path, `${fromPath}${file}`);
78
+ const to = import_path.default.join(import_app_root_path.path, `${toPath}${file}`);
79
+ if (import_fs.default.existsSync(from)) {
80
+ checkDir(toPath);
81
+ import_fs.default.rename(from, to, (err) => {
82
+ if (err)
83
+ console.error(
84
+ `Could not rename file "${file}" from: ${fromPath} to: ${toPath}`,
85
+ err
86
+ );
87
+ console.info(`Renamed file "${file}" from: ${fromPath} to: ${toPath}`);
88
+ });
89
+ } else {
90
+ console.error(
91
+ `Could not rename file "${file}" from: ${fromPath} to: ${toPath}
92
+ File does not exist!`
93
+ );
94
+ }
95
+ };
96
+ const checkDir = (filePath) => {
97
+ const directoryPath = import_path.default.dirname(localPath(filePath));
98
+ if (!import_fs.default.existsSync(directoryPath))
99
+ import_fs.default.mkdirSync(directoryPath, { recursive: true });
100
+ };
101
+ const localPath = (filePath) => import_path.default.join(import_app_root_path.path, filePath);
102
+ // Annotate the CommonJS export names for ESM import in node:
103
+ 0 && (module.exports = {
104
+ checkDir,
105
+ localPath,
106
+ moveFile,
107
+ readFile,
108
+ readFiles,
109
+ readJsonFile,
110
+ removeFile,
111
+ writeFile
112
+ });
113
+ //# sourceMappingURL=file-provider.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/providers/file-provider.ts"],
4
+ "sourcesContent": ["import fs from 'fs';\nimport path from 'path';\nimport { path as appRoot } from 'app-root-path';\nimport { tryParse } from '~/util';\n\nexport const readJsonFile = <T>(filePath: string) => {\n const file = readFile(filePath);\n if (file) return tryParse(file) as T | string;\n return undefined;\n};\nexport const readFile = (filePath: string) => {\n const directoryPath = localPath(filePath);\n if (fs.existsSync(directoryPath)) {\n const file = fs.readFileSync(directoryPath, 'utf8');\n return file;\n } else {\n return undefined;\n }\n};\n\nexport const readFiles = (directory: string) => {\n const directoryPath = localPath(directory);\n if (fs.existsSync(directoryPath)) {\n const files = fs.readdirSync(directoryPath);\n return files;\n } else {\n fs.mkdirSync(directoryPath, { recursive: true });\n return [];\n }\n};\n\nexport const writeFile = (filePath: string, content: string) => {\n const directoryPath = localPath(filePath);\n fs.writeFileSync(directoryPath, content, { encoding: 'utf-8' });\n};\n\nexport const removeFile = (filePath: string) => {\n const directoryPath = localPath(filePath);\n if (fs.existsSync(directoryPath)) {\n fs.rmSync(directoryPath);\n }\n};\n\nexport const moveFile = (file: string, fromPath: string, toPath: string) => {\n const from = path.join(appRoot, `${fromPath}${file}`);\n const to = path.join(appRoot, `${toPath}${file}`);\n if (fs.existsSync(from)) {\n checkDir(toPath);\n // if (!fs.existsSync(toPath)) fs.mkdirSync(toPath, { recursive: true });\n\n fs.rename(from, to, err => {\n if (err)\n console.error(\n `Could not rename file \"${file}\" from: ${fromPath} to: ${toPath}`,\n err\n );\n console.info(`Renamed file \"${file}\" from: ${fromPath} to: ${toPath}`);\n });\n } else {\n console.error(\n `Could not rename file \"${file}\" from: ${fromPath} to: ${toPath}\\nFile does not exist!`\n );\n }\n};\n\nexport const checkDir = (filePath: string) => {\n const directoryPath = path.dirname(localPath(filePath));\n if (!fs.existsSync(directoryPath))\n fs.mkdirSync(directoryPath, { recursive: true });\n};\n\nexport const localPath = (filePath: string) => path.join(appRoot, filePath);\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AACf,kBAAiB;AACjB,2BAAgC;AAChC,kBAAyB;AAElB,MAAM,eAAe,CAAI,aAAqB;AACnD,QAAM,OAAO,SAAS,QAAQ;AAC9B,MAAI;AAAM,eAAO,sBAAS,IAAI;AAC9B,SAAO;AACT;AACO,MAAM,WAAW,CAAC,aAAqB;AAC5C,QAAM,gBAAgB,UAAU,QAAQ;AACxC,MAAI,UAAAA,QAAG,WAAW,aAAa,GAAG;AAChC,UAAM,OAAO,UAAAA,QAAG,aAAa,eAAe,MAAM;AAClD,WAAO;AAAA,EACT,OAAO;AACL,WAAO;AAAA,EACT;AACF;AAEO,MAAM,YAAY,CAAC,cAAsB;AAC9C,QAAM,gBAAgB,UAAU,SAAS;AACzC,MAAI,UAAAA,QAAG,WAAW,aAAa,GAAG;AAChC,UAAM,QAAQ,UAAAA,QA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