@scarn/sdk 0.8.19 → 0.8.21

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 (76) hide show
  1. package/dist/auth/api-token-cache.d.ts +24 -0
  2. package/dist/auth/api-token-source.d.ts +39 -0
  3. package/dist/auth/authenticated-fetch.d.ts +10 -0
  4. package/dist/auth/index.d.ts +3 -0
  5. package/dist/auth/index.js +20 -0
  6. package/dist/automations/index.js +6 -6
  7. package/dist/{chunk-pqtd0hr7.js → chunk-08gcnrzh.js} +2 -2
  8. package/dist/{chunk-2tmrw253.js → chunk-0he2dx5n.js} +5 -5
  9. package/dist/{chunk-aknfw08j.js → chunk-59arcerk.js} +16 -13
  10. package/dist/{chunk-61jf8b6s.js → chunk-5dny5jg1.js} +11 -1
  11. package/dist/{chunk-46wmsgv7.js → chunk-5say64w8.js} +1 -1
  12. package/dist/{chunk-9we3vqsv.js → chunk-6p340dd4.js} +2 -2
  13. package/dist/{chunk-19brnwkp.js → chunk-8hsk6f6b.js} +1 -1
  14. package/dist/{chunk-098740f7.js → chunk-8kzaxz52.js} +1 -1
  15. package/dist/{chunk-mmy80pec.js → chunk-8tmsvkmj.js} +5 -5
  16. package/dist/{chunk-e0pt5x0e.js → chunk-aph2js2v.js} +5 -5
  17. package/dist/chunk-azss2d1n.js +1036 -0
  18. package/dist/{chunk-t1dq2c2s.js → chunk-gasw078g.js} +5 -5
  19. package/dist/{chunk-0c60x3v8.js → chunk-h1v6w1fh.js} +5 -5
  20. package/dist/{chunk-tvjcfh6s.js → chunk-k57h6qke.js} +8 -5
  21. package/dist/{chunk-x0hjhqrf.js → chunk-mp2rqtcj.js} +1 -1
  22. package/dist/{chunk-aemxz9r7.js → chunk-mrzn5tq4.js} +1 -1
  23. package/dist/{chunk-qgkx89eg.js → chunk-nkm31g10.js} +3 -3
  24. package/dist/{chunk-833ef6dg.js → chunk-p74r4y6j.js} +14 -14
  25. package/dist/{chunk-p1fs73bd.js → chunk-pwyj6qf3.js} +2 -2
  26. package/dist/{chunk-evb3hw48.js → chunk-qt81x1pm.js} +7 -4
  27. package/dist/{chunk-mzj1j0p5.js → chunk-r3sbp2wn.js} +3 -3
  28. package/dist/{chunk-rphfy0fj.js → chunk-vsp708vw.js} +1 -1
  29. package/dist/{chunk-yf15kdte.js → chunk-xhpp6qz8.js} +96 -96
  30. package/dist/{chunk-jj9pezwb.js → chunk-xqfj56m9.js} +43 -3
  31. package/dist/{chunk-y34zsgsw.js → chunk-y7ac1t9c.js} +1 -1
  32. package/dist/{chunk-3zp2qtf8.js → chunk-y81cr6tp.js} +38 -14
  33. package/dist/{chunk-ymywp5ht.js → chunk-zxzvketc.js} +5 -5
  34. package/dist/client.d.ts +5 -1
  35. package/dist/client.js +2 -2
  36. package/dist/connectors/index.js +4 -4
  37. package/dist/contracts/artifacts.js +2 -2
  38. package/dist/contracts/automation-document/index.js +3 -3
  39. package/dist/contracts/pipeline-document/index.js +5 -3
  40. package/dist/contracts/pipeline-document/routes.d.ts +9 -0
  41. package/dist/contracts/pipeline-document/schema.d.ts +40 -1
  42. package/dist/contracts/step-artifact-submissions.js +2 -2
  43. package/dist/contracts/work-item-changes.js +1 -1
  44. package/dist/create-api-client.d.ts +11 -0
  45. package/dist/defaults/index.js +32 -871
  46. package/dist/defaults/load-push-defaults.d.ts +11 -4
  47. package/dist/defaults/project-ref.d.ts +2 -4
  48. package/dist/definitions/automations/automations-client.d.ts +2 -1
  49. package/dist/definitions/automations/index.js +3 -3
  50. package/dist/definitions/environments/environments-client.d.ts +2 -1
  51. package/dist/definitions/environments/index.js +10 -10
  52. package/dist/definitions/pipelines/index.js +3 -3
  53. package/dist/definitions/pipelines/pipeline-definitions-client.d.ts +2 -1
  54. package/dist/definitions/steps/index.js +14 -14
  55. package/dist/definitions/steps/step-definitions-client.d.ts +2 -1
  56. package/dist/definitions/validation/index.js +10 -10
  57. package/dist/devcontainer-config-path.js +2 -2
  58. package/dist/env-vars.js +2 -2
  59. package/dist/environment.js +7 -7
  60. package/dist/generated/index.d.ts +1 -1
  61. package/dist/generated/sdk.gen.d.ts +5 -1
  62. package/dist/generated/types.gen.d.ts +298 -0
  63. package/dist/health-checks.js +2 -2
  64. package/dist/index.js +23 -23
  65. package/dist/managed-runtimes.js +2 -2
  66. package/dist/opencode-mcp.js +3 -3
  67. package/dist/pipelines/index.d.ts +1 -1
  68. package/dist/pipelines/index.js +6 -6
  69. package/dist/pipelines/model.d.ts +10 -4
  70. package/dist/pipelines/types.d.ts +13 -1
  71. package/dist/push/index.js +43 -42
  72. package/dist/push/push-from-directory.d.ts +6 -1
  73. package/dist/repo-config.js +2 -2
  74. package/dist/resolve-environment.js +8 -8
  75. package/dist/task-plane-client.d.ts +6 -0
  76. package/package.json +6 -2
@@ -1,863 +1,27 @@
1
1
  // @bun
2
+ import {
3
+ createApiTokenSource,
4
+ createAuthenticatedFetch,
5
+ parse,
6
+ resolveHomeDir,
7
+ setHomeDirForTests,
8
+ writeJsonFileAtomically
9
+ } from "../chunk-azss2d1n.js";
2
10
  import {
3
11
  parseJsonc
4
12
  } from "../chunk-rt9tq4j6.js";
5
13
  import {
6
14
  createScarnClient
7
- } from "../chunk-tvjcfh6s.js";
8
- import"../chunk-3zp2qtf8.js";
15
+ } from "../chunk-k57h6qke.js";
16
+ import"../chunk-y81cr6tp.js";
9
17
  import"../chunk-y64skrwp.js";
10
18
 
11
19
  // src/defaults/auth-file.ts
12
- import { existsSync as existsSync3, lstatSync as lstatSync2, readFileSync as readFileSync2, rmSync as rmSync2 } from "fs";
20
+ import { existsSync as existsSync2, lstatSync as lstatSync2, readFileSync as readFileSync2, rmSync as rmSync2 } from "fs";
13
21
  import { join as join2 } from "path";
14
22
 
15
- // ../../../node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/scanner.js
16
- function createScanner(text, ignoreTrivia = false) {
17
- const len = text.length;
18
- let pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
19
- function scanHexDigits(count, exact) {
20
- let digits = 0;
21
- let value2 = 0;
22
- while (digits < count || !exact) {
23
- let ch = text.charCodeAt(pos);
24
- if (ch >= 48 && ch <= 57) {
25
- value2 = value2 * 16 + ch - 48;
26
- } else if (ch >= 65 && ch <= 70) {
27
- value2 = value2 * 16 + ch - 65 + 10;
28
- } else if (ch >= 97 && ch <= 102) {
29
- value2 = value2 * 16 + ch - 97 + 10;
30
- } else {
31
- break;
32
- }
33
- pos++;
34
- digits++;
35
- }
36
- if (digits < count) {
37
- value2 = -1;
38
- }
39
- return value2;
40
- }
41
- function setPosition(newPosition) {
42
- pos = newPosition;
43
- value = "";
44
- tokenOffset = 0;
45
- token = 16;
46
- scanError = 0;
47
- }
48
- function scanNumber() {
49
- let start = pos;
50
- if (text.charCodeAt(pos) === 48) {
51
- pos++;
52
- } else {
53
- pos++;
54
- while (pos < text.length && isDigit(text.charCodeAt(pos))) {
55
- pos++;
56
- }
57
- }
58
- if (pos < text.length && text.charCodeAt(pos) === 46) {
59
- pos++;
60
- if (pos < text.length && isDigit(text.charCodeAt(pos))) {
61
- pos++;
62
- while (pos < text.length && isDigit(text.charCodeAt(pos))) {
63
- pos++;
64
- }
65
- } else {
66
- scanError = 3;
67
- return text.substring(start, pos);
68
- }
69
- }
70
- let end = pos;
71
- if (pos < text.length && (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101)) {
72
- pos++;
73
- if (pos < text.length && text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) {
74
- pos++;
75
- }
76
- if (pos < text.length && isDigit(text.charCodeAt(pos))) {
77
- pos++;
78
- while (pos < text.length && isDigit(text.charCodeAt(pos))) {
79
- pos++;
80
- }
81
- end = pos;
82
- } else {
83
- scanError = 3;
84
- }
85
- }
86
- return text.substring(start, end);
87
- }
88
- function scanString() {
89
- let result = "", start = pos;
90
- while (true) {
91
- if (pos >= len) {
92
- result += text.substring(start, pos);
93
- scanError = 2;
94
- break;
95
- }
96
- const ch = text.charCodeAt(pos);
97
- if (ch === 34) {
98
- result += text.substring(start, pos);
99
- pos++;
100
- break;
101
- }
102
- if (ch === 92) {
103
- result += text.substring(start, pos);
104
- pos++;
105
- if (pos >= len) {
106
- scanError = 2;
107
- break;
108
- }
109
- const ch2 = text.charCodeAt(pos++);
110
- switch (ch2) {
111
- case 34:
112
- result += '"';
113
- break;
114
- case 92:
115
- result += "\\";
116
- break;
117
- case 47:
118
- result += "/";
119
- break;
120
- case 98:
121
- result += "\b";
122
- break;
123
- case 102:
124
- result += "\f";
125
- break;
126
- case 110:
127
- result += `
128
- `;
129
- break;
130
- case 114:
131
- result += "\r";
132
- break;
133
- case 116:
134
- result += "\t";
135
- break;
136
- case 117:
137
- const ch3 = scanHexDigits(4, true);
138
- if (ch3 >= 0) {
139
- result += String.fromCharCode(ch3);
140
- } else {
141
- scanError = 4;
142
- }
143
- break;
144
- default:
145
- scanError = 5;
146
- }
147
- start = pos;
148
- continue;
149
- }
150
- if (ch >= 0 && ch <= 31) {
151
- if (isLineBreak(ch)) {
152
- result += text.substring(start, pos);
153
- scanError = 2;
154
- break;
155
- } else {
156
- scanError = 6;
157
- }
158
- }
159
- pos++;
160
- }
161
- return result;
162
- }
163
- function scanNext() {
164
- value = "";
165
- scanError = 0;
166
- tokenOffset = pos;
167
- lineStartOffset = lineNumber;
168
- prevTokenLineStartOffset = tokenLineStartOffset;
169
- if (pos >= len) {
170
- tokenOffset = len;
171
- return token = 17;
172
- }
173
- let code = text.charCodeAt(pos);
174
- if (isWhiteSpace(code)) {
175
- do {
176
- pos++;
177
- value += String.fromCharCode(code);
178
- code = text.charCodeAt(pos);
179
- } while (isWhiteSpace(code));
180
- return token = 15;
181
- }
182
- if (isLineBreak(code)) {
183
- pos++;
184
- value += String.fromCharCode(code);
185
- if (code === 13 && text.charCodeAt(pos) === 10) {
186
- pos++;
187
- value += `
188
- `;
189
- }
190
- lineNumber++;
191
- tokenLineStartOffset = pos;
192
- return token = 14;
193
- }
194
- switch (code) {
195
- case 123:
196
- pos++;
197
- return token = 1;
198
- case 125:
199
- pos++;
200
- return token = 2;
201
- case 91:
202
- pos++;
203
- return token = 3;
204
- case 93:
205
- pos++;
206
- return token = 4;
207
- case 58:
208
- pos++;
209
- return token = 6;
210
- case 44:
211
- pos++;
212
- return token = 5;
213
- case 34:
214
- pos++;
215
- value = scanString();
216
- return token = 10;
217
- case 47:
218
- const start = pos - 1;
219
- if (text.charCodeAt(pos + 1) === 47) {
220
- pos += 2;
221
- while (pos < len) {
222
- if (isLineBreak(text.charCodeAt(pos))) {
223
- break;
224
- }
225
- pos++;
226
- }
227
- value = text.substring(start, pos);
228
- return token = 12;
229
- }
230
- if (text.charCodeAt(pos + 1) === 42) {
231
- pos += 2;
232
- const safeLength = len - 1;
233
- let commentClosed = false;
234
- while (pos < safeLength) {
235
- const ch = text.charCodeAt(pos);
236
- if (ch === 42 && text.charCodeAt(pos + 1) === 47) {
237
- pos += 2;
238
- commentClosed = true;
239
- break;
240
- }
241
- pos++;
242
- if (isLineBreak(ch)) {
243
- if (ch === 13 && text.charCodeAt(pos) === 10) {
244
- pos++;
245
- }
246
- lineNumber++;
247
- tokenLineStartOffset = pos;
248
- }
249
- }
250
- if (!commentClosed) {
251
- pos++;
252
- scanError = 1;
253
- }
254
- value = text.substring(start, pos);
255
- return token = 13;
256
- }
257
- value += String.fromCharCode(code);
258
- pos++;
259
- return token = 16;
260
- case 45:
261
- value += String.fromCharCode(code);
262
- pos++;
263
- if (pos === len || !isDigit(text.charCodeAt(pos))) {
264
- return token = 16;
265
- }
266
- case 48:
267
- case 49:
268
- case 50:
269
- case 51:
270
- case 52:
271
- case 53:
272
- case 54:
273
- case 55:
274
- case 56:
275
- case 57:
276
- value += scanNumber();
277
- return token = 11;
278
- default:
279
- while (pos < len && isUnknownContentCharacter(code)) {
280
- pos++;
281
- code = text.charCodeAt(pos);
282
- }
283
- if (tokenOffset !== pos) {
284
- value = text.substring(tokenOffset, pos);
285
- switch (value) {
286
- case "true":
287
- return token = 8;
288
- case "false":
289
- return token = 9;
290
- case "null":
291
- return token = 7;
292
- }
293
- return token = 16;
294
- }
295
- value += String.fromCharCode(code);
296
- pos++;
297
- return token = 16;
298
- }
299
- }
300
- function isUnknownContentCharacter(code) {
301
- if (isWhiteSpace(code) || isLineBreak(code)) {
302
- return false;
303
- }
304
- switch (code) {
305
- case 125:
306
- case 93:
307
- case 123:
308
- case 91:
309
- case 34:
310
- case 58:
311
- case 44:
312
- case 47:
313
- return false;
314
- }
315
- return true;
316
- }
317
- function scanNextNonTrivia() {
318
- let result;
319
- do {
320
- result = scanNext();
321
- } while (result >= 12 && result <= 15);
322
- return result;
323
- }
324
- return {
325
- setPosition,
326
- getPosition: () => pos,
327
- scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
328
- getToken: () => token,
329
- getTokenValue: () => value,
330
- getTokenOffset: () => tokenOffset,
331
- getTokenLength: () => pos - tokenOffset,
332
- getTokenStartLine: () => lineStartOffset,
333
- getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset,
334
- getTokenError: () => scanError
335
- };
336
- }
337
- function isWhiteSpace(ch) {
338
- return ch === 32 || ch === 9;
339
- }
340
- function isLineBreak(ch) {
341
- return ch === 10 || ch === 13;
342
- }
343
- function isDigit(ch) {
344
- return ch >= 48 && ch <= 57;
345
- }
346
- var CharacterCodes;
347
- (function(CharacterCodes2) {
348
- CharacterCodes2[CharacterCodes2["lineFeed"] = 10] = "lineFeed";
349
- CharacterCodes2[CharacterCodes2["carriageReturn"] = 13] = "carriageReturn";
350
- CharacterCodes2[CharacterCodes2["space"] = 32] = "space";
351
- CharacterCodes2[CharacterCodes2["_0"] = 48] = "_0";
352
- CharacterCodes2[CharacterCodes2["_1"] = 49] = "_1";
353
- CharacterCodes2[CharacterCodes2["_2"] = 50] = "_2";
354
- CharacterCodes2[CharacterCodes2["_3"] = 51] = "_3";
355
- CharacterCodes2[CharacterCodes2["_4"] = 52] = "_4";
356
- CharacterCodes2[CharacterCodes2["_5"] = 53] = "_5";
357
- CharacterCodes2[CharacterCodes2["_6"] = 54] = "_6";
358
- CharacterCodes2[CharacterCodes2["_7"] = 55] = "_7";
359
- CharacterCodes2[CharacterCodes2["_8"] = 56] = "_8";
360
- CharacterCodes2[CharacterCodes2["_9"] = 57] = "_9";
361
- CharacterCodes2[CharacterCodes2["a"] = 97] = "a";
362
- CharacterCodes2[CharacterCodes2["b"] = 98] = "b";
363
- CharacterCodes2[CharacterCodes2["c"] = 99] = "c";
364
- CharacterCodes2[CharacterCodes2["d"] = 100] = "d";
365
- CharacterCodes2[CharacterCodes2["e"] = 101] = "e";
366
- CharacterCodes2[CharacterCodes2["f"] = 102] = "f";
367
- CharacterCodes2[CharacterCodes2["g"] = 103] = "g";
368
- CharacterCodes2[CharacterCodes2["h"] = 104] = "h";
369
- CharacterCodes2[CharacterCodes2["i"] = 105] = "i";
370
- CharacterCodes2[CharacterCodes2["j"] = 106] = "j";
371
- CharacterCodes2[CharacterCodes2["k"] = 107] = "k";
372
- CharacterCodes2[CharacterCodes2["l"] = 108] = "l";
373
- CharacterCodes2[CharacterCodes2["m"] = 109] = "m";
374
- CharacterCodes2[CharacterCodes2["n"] = 110] = "n";
375
- CharacterCodes2[CharacterCodes2["o"] = 111] = "o";
376
- CharacterCodes2[CharacterCodes2["p"] = 112] = "p";
377
- CharacterCodes2[CharacterCodes2["q"] = 113] = "q";
378
- CharacterCodes2[CharacterCodes2["r"] = 114] = "r";
379
- CharacterCodes2[CharacterCodes2["s"] = 115] = "s";
380
- CharacterCodes2[CharacterCodes2["t"] = 116] = "t";
381
- CharacterCodes2[CharacterCodes2["u"] = 117] = "u";
382
- CharacterCodes2[CharacterCodes2["v"] = 118] = "v";
383
- CharacterCodes2[CharacterCodes2["w"] = 119] = "w";
384
- CharacterCodes2[CharacterCodes2["x"] = 120] = "x";
385
- CharacterCodes2[CharacterCodes2["y"] = 121] = "y";
386
- CharacterCodes2[CharacterCodes2["z"] = 122] = "z";
387
- CharacterCodes2[CharacterCodes2["A"] = 65] = "A";
388
- CharacterCodes2[CharacterCodes2["B"] = 66] = "B";
389
- CharacterCodes2[CharacterCodes2["C"] = 67] = "C";
390
- CharacterCodes2[CharacterCodes2["D"] = 68] = "D";
391
- CharacterCodes2[CharacterCodes2["E"] = 69] = "E";
392
- CharacterCodes2[CharacterCodes2["F"] = 70] = "F";
393
- CharacterCodes2[CharacterCodes2["G"] = 71] = "G";
394
- CharacterCodes2[CharacterCodes2["H"] = 72] = "H";
395
- CharacterCodes2[CharacterCodes2["I"] = 73] = "I";
396
- CharacterCodes2[CharacterCodes2["J"] = 74] = "J";
397
- CharacterCodes2[CharacterCodes2["K"] = 75] = "K";
398
- CharacterCodes2[CharacterCodes2["L"] = 76] = "L";
399
- CharacterCodes2[CharacterCodes2["M"] = 77] = "M";
400
- CharacterCodes2[CharacterCodes2["N"] = 78] = "N";
401
- CharacterCodes2[CharacterCodes2["O"] = 79] = "O";
402
- CharacterCodes2[CharacterCodes2["P"] = 80] = "P";
403
- CharacterCodes2[CharacterCodes2["Q"] = 81] = "Q";
404
- CharacterCodes2[CharacterCodes2["R"] = 82] = "R";
405
- CharacterCodes2[CharacterCodes2["S"] = 83] = "S";
406
- CharacterCodes2[CharacterCodes2["T"] = 84] = "T";
407
- CharacterCodes2[CharacterCodes2["U"] = 85] = "U";
408
- CharacterCodes2[CharacterCodes2["V"] = 86] = "V";
409
- CharacterCodes2[CharacterCodes2["W"] = 87] = "W";
410
- CharacterCodes2[CharacterCodes2["X"] = 88] = "X";
411
- CharacterCodes2[CharacterCodes2["Y"] = 89] = "Y";
412
- CharacterCodes2[CharacterCodes2["Z"] = 90] = "Z";
413
- CharacterCodes2[CharacterCodes2["asterisk"] = 42] = "asterisk";
414
- CharacterCodes2[CharacterCodes2["backslash"] = 92] = "backslash";
415
- CharacterCodes2[CharacterCodes2["closeBrace"] = 125] = "closeBrace";
416
- CharacterCodes2[CharacterCodes2["closeBracket"] = 93] = "closeBracket";
417
- CharacterCodes2[CharacterCodes2["colon"] = 58] = "colon";
418
- CharacterCodes2[CharacterCodes2["comma"] = 44] = "comma";
419
- CharacterCodes2[CharacterCodes2["dot"] = 46] = "dot";
420
- CharacterCodes2[CharacterCodes2["doubleQuote"] = 34] = "doubleQuote";
421
- CharacterCodes2[CharacterCodes2["minus"] = 45] = "minus";
422
- CharacterCodes2[CharacterCodes2["openBrace"] = 123] = "openBrace";
423
- CharacterCodes2[CharacterCodes2["openBracket"] = 91] = "openBracket";
424
- CharacterCodes2[CharacterCodes2["plus"] = 43] = "plus";
425
- CharacterCodes2[CharacterCodes2["slash"] = 47] = "slash";
426
- CharacterCodes2[CharacterCodes2["formFeed"] = 12] = "formFeed";
427
- CharacterCodes2[CharacterCodes2["tab"] = 9] = "tab";
428
- })(CharacterCodes || (CharacterCodes = {}));
429
-
430
- // ../../../node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/string-intern.js
431
- var cachedSpaces = new Array(20).fill(0).map((_, index) => {
432
- return " ".repeat(index);
433
- });
434
- var maxCachedValues = 200;
435
- var cachedBreakLinesWithSpaces = {
436
- " ": {
437
- "\n": new Array(maxCachedValues).fill(0).map((_, index) => {
438
- return `
439
- ` + " ".repeat(index);
440
- }),
441
- "\r": new Array(maxCachedValues).fill(0).map((_, index) => {
442
- return "\r" + " ".repeat(index);
443
- }),
444
- "\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
445
- return `\r
446
- ` + " ".repeat(index);
447
- })
448
- },
449
- "\t": {
450
- "\n": new Array(maxCachedValues).fill(0).map((_, index) => {
451
- return `
452
- ` + "\t".repeat(index);
453
- }),
454
- "\r": new Array(maxCachedValues).fill(0).map((_, index) => {
455
- return "\r" + "\t".repeat(index);
456
- }),
457
- "\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
458
- return `\r
459
- ` + "\t".repeat(index);
460
- })
461
- }
462
- };
463
-
464
- // ../../../node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/parser.js
465
- var ParseOptions;
466
- (function(ParseOptions2) {
467
- ParseOptions2.DEFAULT = {
468
- allowTrailingComma: false
469
- };
470
- })(ParseOptions || (ParseOptions = {}));
471
- function parse(text, errors = [], options = ParseOptions.DEFAULT) {
472
- let currentProperty = null;
473
- let currentParent = [];
474
- const previousParents = [];
475
- function onValue(value) {
476
- if (Array.isArray(currentParent)) {
477
- currentParent.push(value);
478
- } else if (currentProperty !== null) {
479
- currentParent[currentProperty] = value;
480
- }
481
- }
482
- const visitor = {
483
- onObjectBegin: () => {
484
- const object = {};
485
- onValue(object);
486
- previousParents.push(currentParent);
487
- currentParent = object;
488
- currentProperty = null;
489
- },
490
- onObjectProperty: (name) => {
491
- currentProperty = name;
492
- },
493
- onObjectEnd: () => {
494
- currentParent = previousParents.pop();
495
- },
496
- onArrayBegin: () => {
497
- const array = [];
498
- onValue(array);
499
- previousParents.push(currentParent);
500
- currentParent = array;
501
- currentProperty = null;
502
- },
503
- onArrayEnd: () => {
504
- currentParent = previousParents.pop();
505
- },
506
- onLiteralValue: onValue,
507
- onError: (error, offset, length) => {
508
- errors.push({ error, offset, length });
509
- }
510
- };
511
- visit(text, visitor, options);
512
- return currentParent[0];
513
- }
514
- function visit(text, visitor, options = ParseOptions.DEFAULT) {
515
- const _scanner = createScanner(text, false);
516
- const _jsonPath = [];
517
- let suppressedCallbacks = 0;
518
- function toNoArgVisit(visitFunction) {
519
- return visitFunction ? () => suppressedCallbacks === 0 && visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
520
- }
521
- function toOneArgVisit(visitFunction) {
522
- return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
523
- }
524
- function toOneArgVisitWithPath(visitFunction) {
525
- return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
526
- }
527
- function toBeginVisit(visitFunction) {
528
- return visitFunction ? () => {
529
- if (suppressedCallbacks > 0) {
530
- suppressedCallbacks++;
531
- } else {
532
- let cbReturn = visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice());
533
- if (cbReturn === false) {
534
- suppressedCallbacks = 1;
535
- }
536
- }
537
- } : () => true;
538
- }
539
- function toEndVisit(visitFunction) {
540
- return visitFunction ? () => {
541
- if (suppressedCallbacks > 0) {
542
- suppressedCallbacks--;
543
- }
544
- if (suppressedCallbacks === 0) {
545
- visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter());
546
- }
547
- } : () => true;
548
- }
549
- const onObjectBegin = toBeginVisit(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toEndVisit(visitor.onObjectEnd), onArrayBegin = toBeginVisit(visitor.onArrayBegin), onArrayEnd = toEndVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
550
- const disallowComments = options && options.disallowComments;
551
- const allowTrailingComma = options && options.allowTrailingComma;
552
- function scanNext() {
553
- while (true) {
554
- const token = _scanner.scan();
555
- switch (_scanner.getTokenError()) {
556
- case 4:
557
- handleError(14);
558
- break;
559
- case 5:
560
- handleError(15);
561
- break;
562
- case 3:
563
- handleError(13);
564
- break;
565
- case 1:
566
- if (!disallowComments) {
567
- handleError(11);
568
- }
569
- break;
570
- case 2:
571
- handleError(12);
572
- break;
573
- case 6:
574
- handleError(16);
575
- break;
576
- }
577
- switch (token) {
578
- case 12:
579
- case 13:
580
- if (disallowComments) {
581
- handleError(10);
582
- } else {
583
- onComment();
584
- }
585
- break;
586
- case 16:
587
- handleError(1);
588
- break;
589
- case 15:
590
- case 14:
591
- break;
592
- default:
593
- return token;
594
- }
595
- }
596
- }
597
- function handleError(error, skipUntilAfter = [], skipUntil = []) {
598
- onError(error);
599
- if (skipUntilAfter.length + skipUntil.length > 0) {
600
- let token = _scanner.getToken();
601
- while (token !== 17) {
602
- if (skipUntilAfter.indexOf(token) !== -1) {
603
- scanNext();
604
- break;
605
- } else if (skipUntil.indexOf(token) !== -1) {
606
- break;
607
- }
608
- token = scanNext();
609
- }
610
- }
611
- }
612
- function parseString(isValue) {
613
- const value = _scanner.getTokenValue();
614
- if (isValue) {
615
- onLiteralValue(value);
616
- } else {
617
- onObjectProperty(value);
618
- _jsonPath.push(value);
619
- }
620
- scanNext();
621
- return true;
622
- }
623
- function parseLiteral() {
624
- switch (_scanner.getToken()) {
625
- case 11:
626
- const tokenValue = _scanner.getTokenValue();
627
- let value = Number(tokenValue);
628
- if (isNaN(value)) {
629
- handleError(2);
630
- value = 0;
631
- }
632
- onLiteralValue(value);
633
- break;
634
- case 7:
635
- onLiteralValue(null);
636
- break;
637
- case 8:
638
- onLiteralValue(true);
639
- break;
640
- case 9:
641
- onLiteralValue(false);
642
- break;
643
- default:
644
- return false;
645
- }
646
- scanNext();
647
- return true;
648
- }
649
- function parseProperty() {
650
- if (_scanner.getToken() !== 10) {
651
- handleError(3, [], [2, 5]);
652
- return false;
653
- }
654
- parseString(false);
655
- if (_scanner.getToken() === 6) {
656
- onSeparator(":");
657
- scanNext();
658
- if (!parseValue()) {
659
- handleError(4, [], [2, 5]);
660
- }
661
- } else {
662
- handleError(5, [], [2, 5]);
663
- }
664
- _jsonPath.pop();
665
- return true;
666
- }
667
- function parseObject() {
668
- onObjectBegin();
669
- scanNext();
670
- let needsComma = false;
671
- while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17) {
672
- if (_scanner.getToken() === 5) {
673
- if (!needsComma) {
674
- handleError(4, [], []);
675
- }
676
- onSeparator(",");
677
- scanNext();
678
- if (_scanner.getToken() === 2 && allowTrailingComma) {
679
- break;
680
- }
681
- } else if (needsComma) {
682
- handleError(6, [], []);
683
- }
684
- if (!parseProperty()) {
685
- handleError(4, [], [2, 5]);
686
- }
687
- needsComma = true;
688
- }
689
- onObjectEnd();
690
- if (_scanner.getToken() !== 2) {
691
- handleError(7, [2], []);
692
- } else {
693
- scanNext();
694
- }
695
- return true;
696
- }
697
- function parseArray() {
698
- onArrayBegin();
699
- scanNext();
700
- let isFirstElement = true;
701
- let needsComma = false;
702
- while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17) {
703
- if (_scanner.getToken() === 5) {
704
- if (!needsComma) {
705
- handleError(4, [], []);
706
- }
707
- onSeparator(",");
708
- scanNext();
709
- if (_scanner.getToken() === 4 && allowTrailingComma) {
710
- break;
711
- }
712
- } else if (needsComma) {
713
- handleError(6, [], []);
714
- }
715
- if (isFirstElement) {
716
- _jsonPath.push(0);
717
- isFirstElement = false;
718
- } else {
719
- _jsonPath[_jsonPath.length - 1]++;
720
- }
721
- if (!parseValue()) {
722
- handleError(4, [], [4, 5]);
723
- }
724
- needsComma = true;
725
- }
726
- onArrayEnd();
727
- if (!isFirstElement) {
728
- _jsonPath.pop();
729
- }
730
- if (_scanner.getToken() !== 4) {
731
- handleError(8, [4], []);
732
- } else {
733
- scanNext();
734
- }
735
- return true;
736
- }
737
- function parseValue() {
738
- switch (_scanner.getToken()) {
739
- case 3:
740
- return parseArray();
741
- case 1:
742
- return parseObject();
743
- case 10:
744
- return parseString(true);
745
- default:
746
- return parseLiteral();
747
- }
748
- }
749
- scanNext();
750
- if (_scanner.getToken() === 17) {
751
- if (options.allowEmptyContent) {
752
- return true;
753
- }
754
- handleError(4, [], []);
755
- return false;
756
- }
757
- if (!parseValue()) {
758
- handleError(4, [], []);
759
- return false;
760
- }
761
- if (_scanner.getToken() !== 17) {
762
- handleError(9, [], []);
763
- }
764
- return true;
765
- }
766
-
767
- // ../../../node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/main.js
768
- var ScanError;
769
- (function(ScanError2) {
770
- ScanError2[ScanError2["None"] = 0] = "None";
771
- ScanError2[ScanError2["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
772
- ScanError2[ScanError2["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
773
- ScanError2[ScanError2["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
774
- ScanError2[ScanError2["InvalidUnicode"] = 4] = "InvalidUnicode";
775
- ScanError2[ScanError2["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
776
- ScanError2[ScanError2["InvalidCharacter"] = 6] = "InvalidCharacter";
777
- })(ScanError || (ScanError = {}));
778
- var SyntaxKind;
779
- (function(SyntaxKind2) {
780
- SyntaxKind2[SyntaxKind2["OpenBraceToken"] = 1] = "OpenBraceToken";
781
- SyntaxKind2[SyntaxKind2["CloseBraceToken"] = 2] = "CloseBraceToken";
782
- SyntaxKind2[SyntaxKind2["OpenBracketToken"] = 3] = "OpenBracketToken";
783
- SyntaxKind2[SyntaxKind2["CloseBracketToken"] = 4] = "CloseBracketToken";
784
- SyntaxKind2[SyntaxKind2["CommaToken"] = 5] = "CommaToken";
785
- SyntaxKind2[SyntaxKind2["ColonToken"] = 6] = "ColonToken";
786
- SyntaxKind2[SyntaxKind2["NullKeyword"] = 7] = "NullKeyword";
787
- SyntaxKind2[SyntaxKind2["TrueKeyword"] = 8] = "TrueKeyword";
788
- SyntaxKind2[SyntaxKind2["FalseKeyword"] = 9] = "FalseKeyword";
789
- SyntaxKind2[SyntaxKind2["StringLiteral"] = 10] = "StringLiteral";
790
- SyntaxKind2[SyntaxKind2["NumericLiteral"] = 11] = "NumericLiteral";
791
- SyntaxKind2[SyntaxKind2["LineCommentTrivia"] = 12] = "LineCommentTrivia";
792
- SyntaxKind2[SyntaxKind2["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
793
- SyntaxKind2[SyntaxKind2["LineBreakTrivia"] = 14] = "LineBreakTrivia";
794
- SyntaxKind2[SyntaxKind2["Trivia"] = 15] = "Trivia";
795
- SyntaxKind2[SyntaxKind2["Unknown"] = 16] = "Unknown";
796
- SyntaxKind2[SyntaxKind2["EOF"] = 17] = "EOF";
797
- })(SyntaxKind || (SyntaxKind = {}));
798
- var parse2 = parse;
799
- var ParseErrorCode;
800
- (function(ParseErrorCode2) {
801
- ParseErrorCode2[ParseErrorCode2["InvalidSymbol"] = 1] = "InvalidSymbol";
802
- ParseErrorCode2[ParseErrorCode2["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
803
- ParseErrorCode2[ParseErrorCode2["PropertyNameExpected"] = 3] = "PropertyNameExpected";
804
- ParseErrorCode2[ParseErrorCode2["ValueExpected"] = 4] = "ValueExpected";
805
- ParseErrorCode2[ParseErrorCode2["ColonExpected"] = 5] = "ColonExpected";
806
- ParseErrorCode2[ParseErrorCode2["CommaExpected"] = 6] = "CommaExpected";
807
- ParseErrorCode2[ParseErrorCode2["CloseBraceExpected"] = 7] = "CloseBraceExpected";
808
- ParseErrorCode2[ParseErrorCode2["CloseBracketExpected"] = 8] = "CloseBracketExpected";
809
- ParseErrorCode2[ParseErrorCode2["EndOfFileExpected"] = 9] = "EndOfFileExpected";
810
- ParseErrorCode2[ParseErrorCode2["InvalidCommentToken"] = 10] = "InvalidCommentToken";
811
- ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
812
- ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
813
- ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
814
- ParseErrorCode2[ParseErrorCode2["InvalidUnicode"] = 14] = "InvalidUnicode";
815
- ParseErrorCode2[ParseErrorCode2["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
816
- ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter";
817
- })(ParseErrorCode || (ParseErrorCode = {}));
818
-
819
- // src/defaults/atomic-json-file.ts
820
- import {
821
- chmodSync,
822
- existsSync,
823
- mkdirSync,
824
- renameSync,
825
- writeFileSync
826
- } from "fs";
827
- import { dirname } from "path";
828
- var ensureFilePermissions = (filePath) => {
829
- try {
830
- chmodSync(filePath, 384);
831
- } catch {}
832
- };
833
- function writeJsonFileAtomically(filePath, data) {
834
- const parentDirectory = dirname(filePath);
835
- if (!existsSync(parentDirectory)) {
836
- mkdirSync(parentDirectory, { recursive: true });
837
- }
838
- const temporaryPath = `${filePath}.${String(process.pid)}.${String(Date.now())}.tmp`;
839
- writeFileSync(temporaryPath, `${JSON.stringify(data, null, 2)}
840
- `, {
841
- encoding: "utf8",
842
- mode: 384
843
- });
844
- ensureFilePermissions(temporaryPath);
845
- renameSync(temporaryPath, filePath);
846
- ensureFilePermissions(filePath);
847
- }
848
-
849
- // src/defaults/home-dir.ts
850
- import { homedir } from "os";
851
- var homeDirOverrideForTests;
852
- function setHomeDirForTests(dir) {
853
- homeDirOverrideForTests = dir;
854
- }
855
- function resolveHomeDir() {
856
- return homeDirOverrideForTests ?? homedir();
857
- }
858
-
859
23
  // src/defaults/legacy-config-migration.ts
860
- import { existsSync as existsSync2, lstatSync, readFileSync, rmSync } from "fs";
24
+ import { existsSync, lstatSync, readFileSync, rmSync } from "fs";
861
25
  import { join } from "path";
862
26
  var legacyBareAuthFilePath = () => join(resolveHomeDir(), ".scarn");
863
27
  var legacyJsonAuthFilePath = () => join(resolveHomeDir(), ".scarn.json");
@@ -865,8 +29,8 @@ var isPlainObject = (value) => typeof value === "object" && value !== null && !A
865
29
  function migrateLegacyConfigIfNeeded(input) {
866
30
  if (input.authFileExists() && input.configFileExists())
867
31
  return;
868
- const legacyPath = existsSync2(legacyJsonAuthFilePath()) ? legacyJsonAuthFilePath() : legacyBareAuthFilePath();
869
- if (!existsSync2(legacyPath) || !lstatSync(legacyPath).isFile())
32
+ const legacyPath = existsSync(legacyJsonAuthFilePath()) ? legacyJsonAuthFilePath() : legacyBareAuthFilePath();
33
+ if (!existsSync(legacyPath) || !lstatSync(legacyPath).isFile())
870
34
  return;
871
35
  let parsed;
872
36
  try {
@@ -878,7 +42,7 @@ function migrateLegacyConfigIfNeeded(input) {
878
42
  return;
879
43
  rmSync(legacyPath, { force: true });
880
44
  const otherLegacyPath = legacyPath === legacyJsonAuthFilePath() ? legacyBareAuthFilePath() : legacyJsonAuthFilePath();
881
- if (existsSync2(otherLegacyPath) && lstatSync(otherLegacyPath).isFile()) {
45
+ if (existsSync(otherLegacyPath) && lstatSync(otherLegacyPath).isFile()) {
882
46
  rmSync(otherLegacyPath, { force: true });
883
47
  }
884
48
  if (!input.authFileExists()) {
@@ -931,7 +95,7 @@ function isAuthFile(value) {
931
95
  }
932
96
  var getAuthFilePath = () => authFilePath();
933
97
  var loadAuthFileFromPath = (filePath) => {
934
- if (!existsSync3(filePath))
98
+ if (!existsSync2(filePath))
935
99
  return emptyAuthFile();
936
100
  if (!lstatSync2(filePath).isFile())
937
101
  return emptyAuthFile();
@@ -939,7 +103,7 @@ var loadAuthFileFromPath = (filePath) => {
939
103
  if (content.trim().length === 0)
940
104
  return emptyAuthFile();
941
105
  const errors = [];
942
- const parsed = parse2(content, errors, {
106
+ const parsed = parse(content, errors, {
943
107
  allowTrailingComma: true
944
108
  });
945
109
  if (errors.length > 0)
@@ -950,8 +114,8 @@ var loadAuthFileFromPath = (filePath) => {
950
114
  };
951
115
  var loadAuthFile = () => {
952
116
  migrateLegacyConfigIfNeeded({
953
- authFileExists: () => existsSync3(authFilePath()),
954
- configFileExists: () => existsSync3(configFilePath()),
117
+ authFileExists: () => existsSync2(authFilePath()),
118
+ configFileExists: () => existsSync2(configFilePath()),
955
119
  writeAuthFile: (profiles) => {
956
120
  writeJsonFileAtomically(authFilePath(), { profiles });
957
121
  },
@@ -988,7 +152,7 @@ var deleteAuthProfile = (baseUrl) => {
988
152
  writeAuthFile({ profiles: remainingProfiles });
989
153
  };
990
154
  // src/defaults/config-file.ts
991
- import { existsSync as existsSync4, lstatSync as lstatSync3, readFileSync as readFileSync3 } from "fs";
155
+ import { existsSync as existsSync3, lstatSync as lstatSync3, readFileSync as readFileSync3 } from "fs";
992
156
  import { randomUUID } from "crypto";
993
157
  import { join as join3 } from "path";
994
158
  var DEFAULT_ARTIFACT_LOCAL_MAX_BYTES = 2 * 1024 ** 3;
@@ -1021,7 +185,7 @@ function isConfigFile(value) {
1021
185
  return isArtifactRetentionSettings(obj["artifacts"]);
1022
186
  }
1023
187
  var loadConfigFileFromPath = (filePath) => {
1024
- if (!existsSync4(filePath))
188
+ if (!existsSync3(filePath))
1025
189
  return defaultConfigFile();
1026
190
  if (!lstatSync3(filePath).isFile())
1027
191
  return defaultConfigFile();
@@ -1029,7 +193,7 @@ var loadConfigFileFromPath = (filePath) => {
1029
193
  if (content.trim().length === 0)
1030
194
  return defaultConfigFile();
1031
195
  const errors = [];
1032
- const parsed = parse2(content, errors, {
196
+ const parsed = parse(content, errors, {
1033
197
  allowTrailingComma: true
1034
198
  });
1035
199
  if (errors.length > 0)
@@ -1040,8 +204,8 @@ var loadConfigFileFromPath = (filePath) => {
1040
204
  };
1041
205
  var loadConfigFile = () => {
1042
206
  migrateLegacyConfigIfNeeded({
1043
- authFileExists: () => existsSync4(authFilePath2()),
1044
- configFileExists: () => existsSync4(configFilePath2()),
207
+ authFileExists: () => existsSync3(authFilePath2()),
208
+ configFileExists: () => existsSync3(configFilePath2()),
1045
209
  writeAuthFile: (profiles) => {
1046
210
  writeJsonFileAtomically(authFilePath2(), { profiles });
1047
211
  },
@@ -1157,14 +321,13 @@ class ProjectRefError extends Error {
1157
321
  }
1158
322
  }
1159
323
  var PROJECT_REF_FORMAT_HINT = 'Expected "<owner>/<project-slug>", e.g. "acme/web-app".';
1160
- async function resolveProjectRef(client, ref, { headers, action = "view" }) {
324
+ async function resolveProjectRef(client, ref, { action = "view" } = {}) {
1161
325
  const parsed = parseProjectRef(ref);
1162
326
  if (!parsed) {
1163
327
  throw new ProjectRefError("invalid", ref, `"${ref}" is not a valid project. ${PROJECT_REF_FORMAT_HINT}`);
1164
328
  }
1165
329
  const { data, error, response } = await client.projects.resolveProjectBySlug({
1166
- query: { username: parsed.owner, slug: parsed.slug },
1167
- headers
330
+ query: { username: parsed.owner, slug: parsed.slug }
1168
331
  });
1169
332
  if (data) {
1170
333
  return { id: data.id, owner: parsed.owner, slug: parsed.slug };
@@ -1200,19 +363,17 @@ async function loadPushDefaults(opts) {
1200
363
  const baseUrl = resolveScarnBaseUrl();
1201
364
  const envAccessToken = process.env["SCARN_ACCESS_TOKEN"]?.trim();
1202
365
  const accessToken = envAccessToken ? envAccessToken : loadAuthProfile(baseUrl)?.accessToken;
366
+ const fetch = accessToken ? createAuthenticatedFetch(createApiTokenSource({ baseUrl, getSessionToken: () => accessToken })) : undefined;
1203
367
  const envProjectId = process.env["SCARN_PROJECT_ID"]?.trim();
1204
368
  if (envProjectId) {
1205
- return { baseUrl, projectId: envProjectId, accessToken };
369
+ return { baseUrl, projectId: envProjectId, fetch };
1206
370
  }
1207
371
  const config = await findProjectConfigUpwards(opts.dir);
1208
- if (!config || !accessToken) {
1209
- return { baseUrl, projectId: undefined, accessToken };
372
+ if (!config || !fetch) {
373
+ return { baseUrl, projectId: undefined, fetch };
1210
374
  }
1211
- const resolved = await resolveProjectRef(createScarnClient(baseUrl), config.project, {
1212
- headers: { Authorization: `Bearer ${accessToken}` },
1213
- action: "push pipelines to"
1214
- });
1215
- return { baseUrl, projectId: resolved.id, accessToken };
375
+ const resolved = await resolveProjectRef(createScarnClient(baseUrl, { fetch }), config.project, { action: "push pipelines to" });
376
+ return { baseUrl, projectId: resolved.id, fetch };
1216
377
  }
1217
378
  export {
1218
379
  PROJECT_CONFIG_RELATIVE_PATH,