@geekmidas/manifest 9.0.2 → 10.0.0-alpha.1

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.
package/dist/index.mjs CHANGED
@@ -1,3 +1,1000 @@
1
+ //#region rolldown:runtime
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 __commonJS = (cb, mod) => function() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
13
+ key = keys[i];
14
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
+ get: ((k) => from[k]).bind(null, key),
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
22
+ value: mod,
23
+ enumerable: true
24
+ }) : target, mod));
25
+
26
+ //#endregion
27
+ //#region src/declaration.ts
28
+ /**
29
+ * The version used when a database names none.
30
+ *
31
+ * The point is not which number this is but that there is only one of them.
32
+ * Local ran 18 while Aurora provisioned its own default of 17.7, and nothing in
33
+ * any declaration recorded the difference — a stage could behave differently
34
+ * from a developer's machine for a reason neither could see. Both now read
35
+ * this.
36
+ */
37
+ const DEFAULT_POSTGRES_VERSION = 18;
38
+ /**
39
+ * How the process serving a declaration is built and run.
40
+ *
41
+ * The half of an application that a graph genuinely cannot derive. *What*
42
+ * exists — a surface, a site, the edges between them — is declared and read
43
+ * back from the manifest. *Where its source lives and which globs find its
44
+ * code* is not derivable from anything: it is a fact about a directory.
45
+ *
46
+ * It lives on the declaration rather than in a config `apps` block because the
47
+ * two were the same list written twice, and the copy in config was the one that
48
+ * could disagree. A site declared `path: 'apps/web'` and an app entry declared
49
+ * `path: 'apps/web'`, and nothing checked them against each other; a surface
50
+ * that config had no entry for simply never deployed.
51
+ *
52
+ * Only the declaration that *is* an app carries one. Two surfaces in one
53
+ * process means one of them has the spec and the other collapses onto it —
54
+ * which is the same rule that decides deploy units, now stated once.
55
+ */
56
+ /**
57
+ * Where an app's code lives when nobody says otherwise.
58
+ *
59
+ * One glob, every kind — the same rule the `constructs` glob follows. A handler
60
+ * in one of these directories is found; anywhere else needs a `code` glob, and
61
+ * saying so is the whole reason the field still exists.
62
+ */
63
+ const DEFAULT_APP_CODE = "./{endpoints,functions,crons,queues,topics,subscribers}/**/*.ts";
64
+ /**
65
+ * What each kind may derive from.
66
+ *
67
+ * Small enough to state exhaustively, and stating it makes cycles impossible
68
+ * without a graph walk: readers are terminal, so no chain can return to its
69
+ * start. There is no `writer` — the database *is* the writer, which is what
70
+ * keeps a replica from being reached by accident.
71
+ */
72
+ const DERIVES_FROM = {
73
+ "database-reader": ["database", "database-schema"],
74
+ "database-schema": ["database"],
75
+ "file-server": ["objects"],
76
+ cache: ["database", "database-schema"]
77
+ };
78
+ /**
79
+ * Which provided values may be shipped to a browser.
80
+ *
81
+ * Drives client-side prefixing (`VITE_`, `NEXT_PUBLIC_`) and nothing else — it
82
+ * is not a restriction on what may be depended on, since a server-side consumer
83
+ * can legitimately use any of them. A bucket's `url` presigns and stays private.
84
+ */
85
+ const PUBLIC = {
86
+ objects: [],
87
+ "file-server": ["url"],
88
+ email: [],
89
+ database: [],
90
+ "database-reader": [],
91
+ "database-schema": [],
92
+ cache: [],
93
+ secret: [],
94
+ credential: [],
95
+ "rest-api": ["url"],
96
+ queue: [],
97
+ topic: [],
98
+ oidc: ["issuer", "audience"],
99
+ function: [],
100
+ cron: [],
101
+ site: ["url"]
102
+ };
103
+
104
+ //#endregion
105
+ //#region src/errors.ts
106
+ /**
107
+ * Manifest errors.
108
+ *
109
+ * Messages state the rule, which is constant; the offending value is a field.
110
+ * An interpolated message cannot be matched on, reads differently every time it
111
+ * is thrown, and carries user input into every log line that touches it.
112
+ */
113
+ /** A construct id that cannot survive the names derived from it. */
114
+ var InvalidConstructId = class extends Error {
115
+ /** What was passed in. */
116
+ input;
117
+ /** What canonicalising it produced, which is what failed the rule. */
118
+ canonical;
119
+ constructor(input, canonical) {
120
+ super("A construct id must start with a letter and contain only letters and digits");
121
+ this.name = "InvalidConstructId";
122
+ this.input = input;
123
+ this.canonical = canonical;
124
+ }
125
+ };
126
+ /** A derived construct naming a parent the manifest does not contain. */
127
+ var UnknownParent = class extends Error {
128
+ /** The derived construct. */
129
+ id;
130
+ /** The parent it named. */
131
+ of;
132
+ /** Ids the manifest does contain, for the caller to match against. */
133
+ available;
134
+ constructor(id, of, available) {
135
+ super("A derived construct must name a parent present in the manifest");
136
+ this.name = "UnknownParent";
137
+ this.id = id;
138
+ this.of = of;
139
+ this.available = available;
140
+ }
141
+ };
142
+ /**
143
+ * A derived construct naming a parent that may not vend it — a reader of a
144
+ * reader, a schema of a schema.
145
+ */
146
+ var IllegalDerivation = class extends Error {
147
+ id;
148
+ kind;
149
+ /** The kind of the parent it named. */
150
+ parentKind;
151
+ /** The parent kinds that may vend this one. */
152
+ allowed;
153
+ constructor(id, kind, parentKind, allowed) {
154
+ super("A derived construct must name a parent whose kind may vend it");
155
+ this.name = "IllegalDerivation";
156
+ this.id = id;
157
+ this.kind = kind;
158
+ this.parentKind = parentKind;
159
+ this.allowed = allowed;
160
+ }
161
+ };
162
+
163
+ //#endregion
164
+ //#region ../../node_modules/.pnpm/lodash.snakecase@4.1.1/node_modules/lodash.snakecase/index.js
165
+ var require_lodash = __commonJS({ "../../node_modules/.pnpm/lodash.snakecase@4.1.1/node_modules/lodash.snakecase/index.js"(exports, module) {
166
+ /**
167
+ * lodash (Custom Build) <https://lodash.com/>
168
+ * Build: `lodash modularize exports="npm" -o ./`
169
+ * Copyright jQuery Foundation and other contributors <https://jquery.org/>
170
+ * Released under MIT license <https://lodash.com/license>
171
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
172
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
173
+ */
174
+ /** Used as references for various `Number` constants. */
175
+ var INFINITY = Infinity;
176
+ /** `Object#toString` result references. */
177
+ var symbolTag = "[object Symbol]";
178
+ /** Used to match words composed of alphanumeric characters. */
179
+ var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
180
+ /** Used to match Latin Unicode letters (excluding mathematical operators). */
181
+ var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
182
+ /** Used to compose unicode character classes. */
183
+ var rsAstralRange = "\\ud800-\\udfff", rsComboMarksRange = "\\u0300-\\u036f\\ufe20-\\ufe23", rsComboSymbolsRange = "\\u20d0-\\u20f0", rsDingbatRange = "\\u2700-\\u27bf", rsLowerRange = "a-z\\xdf-\\xf6\\xf8-\\xff", rsMathOpRange = "\\xac\\xb1\\xd7\\xf7", rsNonCharRange = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf", rsPunctuationRange = "\\u2000-\\u206f", rsSpaceRange = " \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000", rsUpperRange = "A-Z\\xc0-\\xd6\\xd8-\\xde", rsVarRange = "\\ufe0e\\ufe0f", rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
184
+ /** Used to compose unicode capture groups. */
185
+ var rsApos = "['’]", rsBreak = "[" + rsBreakRange + "]", rsCombo = "[" + rsComboMarksRange + rsComboSymbolsRange + "]", rsDigits = "\\d+", rsDingbat = "[" + rsDingbatRange + "]", rsLower = "[" + rsLowerRange + "]", rsMisc = "[^" + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + "]", rsFitz = "\\ud83c[\\udffb-\\udfff]", rsModifier = "(?:" + rsCombo + "|" + rsFitz + ")", rsNonAstral = "[^" + rsAstralRange + "]", rsRegional = "(?:\\ud83c[\\udde6-\\uddff]){2}", rsSurrPair = "[\\ud800-\\udbff][\\udc00-\\udfff]", rsUpper = "[" + rsUpperRange + "]", rsZWJ = "\\u200d";
186
+ /** Used to compose unicode regexes. */
187
+ var rsLowerMisc = "(?:" + rsLower + "|" + rsMisc + ")", rsUpperMisc = "(?:" + rsUpper + "|" + rsMisc + ")", rsOptLowerContr = "(?:" + rsApos + "(?:d|ll|m|re|s|t|ve))?", rsOptUpperContr = "(?:" + rsApos + "(?:D|LL|M|RE|S|T|VE))?", reOptMod = rsModifier + "?", rsOptVar = "[" + rsVarRange + "]?", rsOptJoin = "(?:" + rsZWJ + "(?:" + [
188
+ rsNonAstral,
189
+ rsRegional,
190
+ rsSurrPair
191
+ ].join("|") + ")" + rsOptVar + reOptMod + ")*", rsSeq = rsOptVar + reOptMod + rsOptJoin, rsEmoji = "(?:" + [
192
+ rsDingbat,
193
+ rsRegional,
194
+ rsSurrPair
195
+ ].join("|") + ")" + rsSeq;
196
+ /** Used to match apostrophes. */
197
+ var reApos = RegExp(rsApos, "g");
198
+ /**
199
+ * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
200
+ * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
201
+ */
202
+ var reComboMark = RegExp(rsCombo, "g");
203
+ /** Used to match complex or compound words. */
204
+ var reUnicodeWord = RegExp([
205
+ rsUpper + "?" + rsLower + "+" + rsOptLowerContr + "(?=" + [
206
+ rsBreak,
207
+ rsUpper,
208
+ "$"
209
+ ].join("|") + ")",
210
+ rsUpperMisc + "+" + rsOptUpperContr + "(?=" + [
211
+ rsBreak,
212
+ rsUpper + rsLowerMisc,
213
+ "$"
214
+ ].join("|") + ")",
215
+ rsUpper + "?" + rsLowerMisc + "+" + rsOptLowerContr,
216
+ rsUpper + "+" + rsOptUpperContr,
217
+ rsDigits,
218
+ rsEmoji
219
+ ].join("|"), "g");
220
+ /** Used to detect strings that need a more robust regexp to match words. */
221
+ var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
222
+ /** Used to map Latin Unicode letters to basic Latin letters. */
223
+ var deburredLetters = {
224
+ "À": "A",
225
+ "Á": "A",
226
+ "Â": "A",
227
+ "Ã": "A",
228
+ "Ä": "A",
229
+ "Å": "A",
230
+ "à": "a",
231
+ "á": "a",
232
+ "â": "a",
233
+ "ã": "a",
234
+ "ä": "a",
235
+ "å": "a",
236
+ "Ç": "C",
237
+ "ç": "c",
238
+ "Ð": "D",
239
+ "ð": "d",
240
+ "È": "E",
241
+ "É": "E",
242
+ "Ê": "E",
243
+ "Ë": "E",
244
+ "è": "e",
245
+ "é": "e",
246
+ "ê": "e",
247
+ "ë": "e",
248
+ "Ì": "I",
249
+ "Í": "I",
250
+ "Î": "I",
251
+ "Ï": "I",
252
+ "ì": "i",
253
+ "í": "i",
254
+ "î": "i",
255
+ "ï": "i",
256
+ "Ñ": "N",
257
+ "ñ": "n",
258
+ "Ò": "O",
259
+ "Ó": "O",
260
+ "Ô": "O",
261
+ "Õ": "O",
262
+ "Ö": "O",
263
+ "Ø": "O",
264
+ "ò": "o",
265
+ "ó": "o",
266
+ "ô": "o",
267
+ "õ": "o",
268
+ "ö": "o",
269
+ "ø": "o",
270
+ "Ù": "U",
271
+ "Ú": "U",
272
+ "Û": "U",
273
+ "Ü": "U",
274
+ "ù": "u",
275
+ "ú": "u",
276
+ "û": "u",
277
+ "ü": "u",
278
+ "Ý": "Y",
279
+ "ý": "y",
280
+ "ÿ": "y",
281
+ "Æ": "Ae",
282
+ "æ": "ae",
283
+ "Þ": "Th",
284
+ "þ": "th",
285
+ "ß": "ss",
286
+ "Ā": "A",
287
+ "Ă": "A",
288
+ "Ą": "A",
289
+ "ā": "a",
290
+ "ă": "a",
291
+ "ą": "a",
292
+ "Ć": "C",
293
+ "Ĉ": "C",
294
+ "Ċ": "C",
295
+ "Č": "C",
296
+ "ć": "c",
297
+ "ĉ": "c",
298
+ "ċ": "c",
299
+ "č": "c",
300
+ "Ď": "D",
301
+ "Đ": "D",
302
+ "ď": "d",
303
+ "đ": "d",
304
+ "Ē": "E",
305
+ "Ĕ": "E",
306
+ "Ė": "E",
307
+ "Ę": "E",
308
+ "Ě": "E",
309
+ "ē": "e",
310
+ "ĕ": "e",
311
+ "ė": "e",
312
+ "ę": "e",
313
+ "ě": "e",
314
+ "Ĝ": "G",
315
+ "Ğ": "G",
316
+ "Ġ": "G",
317
+ "Ģ": "G",
318
+ "ĝ": "g",
319
+ "ğ": "g",
320
+ "ġ": "g",
321
+ "ģ": "g",
322
+ "Ĥ": "H",
323
+ "Ħ": "H",
324
+ "ĥ": "h",
325
+ "ħ": "h",
326
+ "Ĩ": "I",
327
+ "Ī": "I",
328
+ "Ĭ": "I",
329
+ "Į": "I",
330
+ "İ": "I",
331
+ "ĩ": "i",
332
+ "ī": "i",
333
+ "ĭ": "i",
334
+ "į": "i",
335
+ "ı": "i",
336
+ "Ĵ": "J",
337
+ "ĵ": "j",
338
+ "Ķ": "K",
339
+ "ķ": "k",
340
+ "ĸ": "k",
341
+ "Ĺ": "L",
342
+ "Ļ": "L",
343
+ "Ľ": "L",
344
+ "Ŀ": "L",
345
+ "Ł": "L",
346
+ "ĺ": "l",
347
+ "ļ": "l",
348
+ "ľ": "l",
349
+ "ŀ": "l",
350
+ "ł": "l",
351
+ "Ń": "N",
352
+ "Ņ": "N",
353
+ "Ň": "N",
354
+ "Ŋ": "N",
355
+ "ń": "n",
356
+ "ņ": "n",
357
+ "ň": "n",
358
+ "ŋ": "n",
359
+ "Ō": "O",
360
+ "Ŏ": "O",
361
+ "Ő": "O",
362
+ "ō": "o",
363
+ "ŏ": "o",
364
+ "ő": "o",
365
+ "Ŕ": "R",
366
+ "Ŗ": "R",
367
+ "Ř": "R",
368
+ "ŕ": "r",
369
+ "ŗ": "r",
370
+ "ř": "r",
371
+ "Ś": "S",
372
+ "Ŝ": "S",
373
+ "Ş": "S",
374
+ "Š": "S",
375
+ "ś": "s",
376
+ "ŝ": "s",
377
+ "ş": "s",
378
+ "š": "s",
379
+ "Ţ": "T",
380
+ "Ť": "T",
381
+ "Ŧ": "T",
382
+ "ţ": "t",
383
+ "ť": "t",
384
+ "ŧ": "t",
385
+ "Ũ": "U",
386
+ "Ū": "U",
387
+ "Ŭ": "U",
388
+ "Ů": "U",
389
+ "Ű": "U",
390
+ "Ų": "U",
391
+ "ũ": "u",
392
+ "ū": "u",
393
+ "ŭ": "u",
394
+ "ů": "u",
395
+ "ű": "u",
396
+ "ų": "u",
397
+ "Ŵ": "W",
398
+ "ŵ": "w",
399
+ "Ŷ": "Y",
400
+ "ŷ": "y",
401
+ "Ÿ": "Y",
402
+ "Ź": "Z",
403
+ "Ż": "Z",
404
+ "Ž": "Z",
405
+ "ź": "z",
406
+ "ż": "z",
407
+ "ž": "z",
408
+ "IJ": "IJ",
409
+ "ij": "ij",
410
+ "Œ": "Oe",
411
+ "œ": "oe",
412
+ "ʼn": "'n",
413
+ "ſ": "ss"
414
+ };
415
+ /** Detect free variable `global` from Node.js. */
416
+ var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
417
+ /** Detect free variable `self`. */
418
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
419
+ /** Used as a reference to the global object. */
420
+ var root = freeGlobal || freeSelf || Function("return this")();
421
+ /**
422
+ * A specialized version of `_.reduce` for arrays without support for
423
+ * iteratee shorthands.
424
+ *
425
+ * @private
426
+ * @param {Array} [array] The array to iterate over.
427
+ * @param {Function} iteratee The function invoked per iteration.
428
+ * @param {*} [accumulator] The initial value.
429
+ * @param {boolean} [initAccum] Specify using the first element of `array` as
430
+ * the initial value.
431
+ * @returns {*} Returns the accumulated value.
432
+ */
433
+ function arrayReduce(array, iteratee, accumulator, initAccum) {
434
+ var index = -1, length = array ? array.length : 0;
435
+ if (initAccum && length) accumulator = array[++index];
436
+ while (++index < length) accumulator = iteratee(accumulator, array[index], index, array);
437
+ return accumulator;
438
+ }
439
+ /**
440
+ * Splits an ASCII `string` into an array of its words.
441
+ *
442
+ * @private
443
+ * @param {string} The string to inspect.
444
+ * @returns {Array} Returns the words of `string`.
445
+ */
446
+ function asciiWords(string) {
447
+ return string.match(reAsciiWord) || [];
448
+ }
449
+ /**
450
+ * The base implementation of `_.propertyOf` without support for deep paths.
451
+ *
452
+ * @private
453
+ * @param {Object} object The object to query.
454
+ * @returns {Function} Returns the new accessor function.
455
+ */
456
+ function basePropertyOf(object) {
457
+ return function(key) {
458
+ return object == null ? void 0 : object[key];
459
+ };
460
+ }
461
+ /**
462
+ * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
463
+ * letters to basic Latin letters.
464
+ *
465
+ * @private
466
+ * @param {string} letter The matched letter to deburr.
467
+ * @returns {string} Returns the deburred letter.
468
+ */
469
+ var deburrLetter = basePropertyOf(deburredLetters);
470
+ /**
471
+ * Checks if `string` contains a word composed of Unicode symbols.
472
+ *
473
+ * @private
474
+ * @param {string} string The string to inspect.
475
+ * @returns {boolean} Returns `true` if a word is found, else `false`.
476
+ */
477
+ function hasUnicodeWord(string) {
478
+ return reHasUnicodeWord.test(string);
479
+ }
480
+ /**
481
+ * Splits a Unicode `string` into an array of its words.
482
+ *
483
+ * @private
484
+ * @param {string} The string to inspect.
485
+ * @returns {Array} Returns the words of `string`.
486
+ */
487
+ function unicodeWords(string) {
488
+ return string.match(reUnicodeWord) || [];
489
+ }
490
+ /** Used for built-in method references. */
491
+ var objectProto = Object.prototype;
492
+ /**
493
+ * Used to resolve the
494
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
495
+ * of values.
496
+ */
497
+ var objectToString = objectProto.toString;
498
+ /** Built-in value references. */
499
+ var Symbol = root.Symbol;
500
+ /** Used to convert symbols to primitives and strings. */
501
+ var symbolProto = Symbol ? Symbol.prototype : void 0, symbolToString = symbolProto ? symbolProto.toString : void 0;
502
+ /**
503
+ * The base implementation of `_.toString` which doesn't convert nullish
504
+ * values to empty strings.
505
+ *
506
+ * @private
507
+ * @param {*} value The value to process.
508
+ * @returns {string} Returns the string.
509
+ */
510
+ function baseToString(value) {
511
+ if (typeof value == "string") return value;
512
+ if (isSymbol(value)) return symbolToString ? symbolToString.call(value) : "";
513
+ var result = value + "";
514
+ return result == "0" && 1 / value == -INFINITY ? "-0" : result;
515
+ }
516
+ /**
517
+ * Creates a function like `_.camelCase`.
518
+ *
519
+ * @private
520
+ * @param {Function} callback The function to combine each word.
521
+ * @returns {Function} Returns the new compounder function.
522
+ */
523
+ function createCompounder(callback) {
524
+ return function(string) {
525
+ return arrayReduce(words(deburr(string).replace(reApos, "")), callback, "");
526
+ };
527
+ }
528
+ /**
529
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
530
+ * and has a `typeof` result of "object".
531
+ *
532
+ * @static
533
+ * @memberOf _
534
+ * @since 4.0.0
535
+ * @category Lang
536
+ * @param {*} value The value to check.
537
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
538
+ * @example
539
+ *
540
+ * _.isObjectLike({});
541
+ * // => true
542
+ *
543
+ * _.isObjectLike([1, 2, 3]);
544
+ * // => true
545
+ *
546
+ * _.isObjectLike(_.noop);
547
+ * // => false
548
+ *
549
+ * _.isObjectLike(null);
550
+ * // => false
551
+ */
552
+ function isObjectLike(value) {
553
+ return !!value && typeof value == "object";
554
+ }
555
+ /**
556
+ * Checks if `value` is classified as a `Symbol` primitive or object.
557
+ *
558
+ * @static
559
+ * @memberOf _
560
+ * @since 4.0.0
561
+ * @category Lang
562
+ * @param {*} value The value to check.
563
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
564
+ * @example
565
+ *
566
+ * _.isSymbol(Symbol.iterator);
567
+ * // => true
568
+ *
569
+ * _.isSymbol('abc');
570
+ * // => false
571
+ */
572
+ function isSymbol(value) {
573
+ return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
574
+ }
575
+ /**
576
+ * Converts `value` to a string. An empty string is returned for `null`
577
+ * and `undefined` values. The sign of `-0` is preserved.
578
+ *
579
+ * @static
580
+ * @memberOf _
581
+ * @since 4.0.0
582
+ * @category Lang
583
+ * @param {*} value The value to process.
584
+ * @returns {string} Returns the string.
585
+ * @example
586
+ *
587
+ * _.toString(null);
588
+ * // => ''
589
+ *
590
+ * _.toString(-0);
591
+ * // => '-0'
592
+ *
593
+ * _.toString([1, 2, 3]);
594
+ * // => '1,2,3'
595
+ */
596
+ function toString(value) {
597
+ return value == null ? "" : baseToString(value);
598
+ }
599
+ /**
600
+ * Deburrs `string` by converting
601
+ * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
602
+ * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
603
+ * letters to basic Latin letters and removing
604
+ * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
605
+ *
606
+ * @static
607
+ * @memberOf _
608
+ * @since 3.0.0
609
+ * @category String
610
+ * @param {string} [string=''] The string to deburr.
611
+ * @returns {string} Returns the deburred string.
612
+ * @example
613
+ *
614
+ * _.deburr('déjà vu');
615
+ * // => 'deja vu'
616
+ */
617
+ function deburr(string) {
618
+ string = toString(string);
619
+ return string && string.replace(reLatin, deburrLetter).replace(reComboMark, "");
620
+ }
621
+ /**
622
+ * Converts `string` to
623
+ * [snake case](https://en.wikipedia.org/wiki/Snake_case).
624
+ *
625
+ * @static
626
+ * @memberOf _
627
+ * @since 3.0.0
628
+ * @category String
629
+ * @param {string} [string=''] The string to convert.
630
+ * @returns {string} Returns the snake cased string.
631
+ * @example
632
+ *
633
+ * _.snakeCase('Foo Bar');
634
+ * // => 'foo_bar'
635
+ *
636
+ * _.snakeCase('fooBar');
637
+ * // => 'foo_bar'
638
+ *
639
+ * _.snakeCase('--FOO-BAR--');
640
+ * // => 'foo_bar'
641
+ */
642
+ var snakeCase = createCompounder(function(result, word, index) {
643
+ return result + (index ? "_" : "") + word.toLowerCase();
644
+ });
645
+ /**
646
+ * Splits `string` into an array of its words.
647
+ *
648
+ * @static
649
+ * @memberOf _
650
+ * @since 3.0.0
651
+ * @category String
652
+ * @param {string} [string=''] The string to inspect.
653
+ * @param {RegExp|string} [pattern] The pattern to match words.
654
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
655
+ * @returns {Array} Returns the words of `string`.
656
+ * @example
657
+ *
658
+ * _.words('fred, barney, & pebbles');
659
+ * // => ['fred', 'barney', 'pebbles']
660
+ *
661
+ * _.words('fred, barney, & pebbles', /[^, ]+/g);
662
+ * // => ['fred', 'barney', '&', 'pebbles']
663
+ */
664
+ function words(string, pattern, guard) {
665
+ string = toString(string);
666
+ pattern = guard ? void 0 : pattern;
667
+ if (pattern === void 0) return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
668
+ return string.match(pattern) || [];
669
+ }
670
+ module.exports = snakeCase;
671
+ } });
672
+
673
+ //#endregion
674
+ //#region src/naming.ts
675
+ var import_lodash = __toESM(require_lodash(), 1);
676
+ /**
677
+ * `UPPER_SNAKE_CASE`, with numbers kept against the word they follow.
678
+ *
679
+ * Matches `environmentCase` in `@geekmidas/envkit`, which reads the values these
680
+ * names key. The two must agree exactly, so this is the implementation and that
681
+ * one should defer to it.
682
+ *
683
+ * @example environmentCase('sendEmail') // 'SEND_EMAIL'
684
+ * @example environmentCase('api2') // 'API2' (digit joins its word)
685
+ */
686
+ function environmentCase(name) {
687
+ return (0, import_lodash.default)(name).toUpperCase().replace(/_\d+/g, (r) => r.replace("_", ""));
688
+ }
689
+ /**
690
+ * The env key a construct provides for one of its roles.
691
+ *
692
+ * @example provideKey('Uploads', 'url') // 'UPLOADS_URL'
693
+ * @example provideKey('Uploads', 'cdnUrl') // 'UPLOADS_CDN_URL'
694
+ */
695
+ function provideKey(id, role) {
696
+ return environmentCase(`${id}_${role}`);
697
+ }
698
+ /**
699
+ * A construct's canonical id — PascalCase.
700
+ *
701
+ * `uploads`, `Uploads`, `user_uploads`, and `user-uploads` all canonicalise to
702
+ * the same id, so declaring two of them is a duplicate rather than a collision
703
+ * to detect.
704
+ *
705
+ * Runtime only. Writing the id in PascalCase is what keeps the *type* usable:
706
+ * the service key is `Uncapitalize<TName>`, a TypeScript intrinsic, so no
707
+ * type-level transform is needed and none has to be kept in step with this one.
708
+ *
709
+ * @example canonicalId('user-uploads') // 'UserUploads'
710
+ */
711
+ function canonicalId(input) {
712
+ const id = (0, import_lodash.default)(input).split("_").filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
713
+ if (!VALID_ID.test(id)) throw new InvalidConstructId(input, id);
714
+ return id;
715
+ }
716
+ /**
717
+ * A canonical id: PascalCase, letters and digits only.
718
+ *
719
+ * Narrower than a JavaScript identifier — `_id` and `$ref` are legal JavaScript
720
+ * and rejected here — because the id also has to survive `environmentCase` into
721
+ * an env key and `cloudName` into a DNS-safe resource name.
722
+ */
723
+ const VALID_ID = /^[A-Z][A-Za-z0-9]*$/;
724
+ /**
725
+ * The key a construct is reached under in the service record.
726
+ *
727
+ * The runtime twin of `Uncapitalize<TName>`, which types it — they must agree,
728
+ * so they live next to each other rather than being re-derived by each
729
+ * construct.
730
+ *
731
+ * @example serviceKey('UserUploads') // 'userUploads' → services.userUploads
732
+ */
733
+ function serviceKey(id) {
734
+ return id.charAt(0).toLowerCase() + id.slice(1);
735
+ }
736
+ /**
737
+ * The table a cache keeps its entries in, when nobody named one.
738
+ *
739
+ * Derived from the cache's own id rather than fixed at `cache`, because a
740
+ * database may hold more than one and two caches sharing a table share a
741
+ * keyspace — `orders.cache('Sessions')` and `orders.cache('Rates')` would
742
+ * silently read each other's entries and evict each other's keys.
743
+ *
744
+ * Prefixed rather than suffixed so every cache sorts together in `\dt`, and
745
+ * prefixed at all so a cache named for a thing the application also stores —
746
+ * `orders.cache('Users')` — cannot collide with the table holding that thing.
747
+ *
748
+ * Read by whoever composes the URL and by whoever creates the table, so both
749
+ * default the same way.
750
+ *
751
+ * @example cacheTable('Sessions') // 'cache_sessions'
752
+ */
753
+ function cacheTable(id) {
754
+ return `cache_${id.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase()}`;
755
+ }
756
+ /**
757
+ * Kebab-cases an identifier, acronym- and digit-aware.
758
+ *
759
+ * `userName` → `user-name`, `APIKey` → `api-key`, `S3Bucket` → `s3-bucket`.
760
+ *
761
+ * The last of those is why this is here rather than `snakecase(id)` with the
762
+ * underscores swapped: lodash splits a digit from the letter beside it, so
763
+ * `S3Bucket` became `s-3-bucket` on one provider and `s3-bucket` on the other.
764
+ * Two implementations of one rule, agreeing on every id anybody had tried.
765
+ *
766
+ * `environmentCase` already corrected for the same thing in the other
767
+ * direction — `api2` keeps its digit — so the two spellings of "kebab this id"
768
+ * in this file did not even agree with each other.
769
+ */
770
+ function kebabCase(value) {
771
+ return value.replace(/([A-Z]+)([A-Z][a-z])/g, "$1-$2").replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
772
+ }
773
+ /**
774
+ * The physical name a target provisions a construct under — lowercase kebab,
775
+ * scoped so two stages or apps sharing an account cannot collide.
776
+ *
777
+ * **One rule, every provider.** A construct is named the same thing on AWS and
778
+ * on Dokploy, which is what lets a name be read across them: `Database` in the
779
+ * `production` stage of `kitchen-sink` is `production-kitchen-sink-database`
780
+ * wherever it lands. The SST target's `prefixedName` is this function under
781
+ * another signature and defers to it.
782
+ *
783
+ * Idempotent in its prefix: an id that already carries the scope is not given a
784
+ * second one, so composing names cannot double up.
785
+ *
786
+ * @example cloudName({ stage: 'prod', app: 'myapp' }, 'UserUploads')
787
+ * // 'prod-myapp-user-uploads'
788
+ */
789
+ function cloudName(scope, id) {
790
+ return scopedName([scope.stage, scope.app], id);
791
+ }
792
+ /**
793
+ * {@link cloudName} for a caller that holds its scope as a list.
794
+ *
795
+ * The SST target's stacks add a segment of their own, so the prefix is not
796
+ * always two parts — which is the only reason this signature exists.
797
+ */
798
+ function scopedName(scope, id) {
799
+ const prefix = scope.join("-").toLowerCase();
800
+ const name = kebabCase(id);
801
+ return name.startsWith(prefix) ? name : `${prefix}-${name}`;
802
+ }
803
+ /**
804
+ * The domain a cookie must be scoped to so a surface and its callers share it.
805
+ *
806
+ * Derived from the addresses rather than configured, for the same reason the
807
+ * origins are: the set of things that talk to a surface is already in the graph,
808
+ * and the domain they have in common is a fact about that set. Returned with the
809
+ * leading dot a `Domain` attribute wants.
810
+ *
811
+ * Returns `undefined` when there is nothing to scope, which is the common case
812
+ * and not a failure:
813
+ *
814
+ * - **One host.** Locally everything is `localhost` on different ports, and
815
+ * cookies ignore the port — so a `Domain` would add nothing and `.localhost`
816
+ * is not a domain a browser will accept.
817
+ * - **Nothing in common.** Unrelated hosts cannot share a cookie at all, and
818
+ * emitting the longest common suffix anyway would be a value that silently
819
+ * fails to set.
820
+ *
821
+ * **The public-suffix limit, stated rather than discovered.** Two apps on
822
+ * `a.vercel.app` and `b.vercel.app` share `.vercel.app`, which every browser
823
+ * rejects because it is a registrable suffix rather than a registrable domain.
824
+ * Resolving that correctly needs the Public Suffix List, which is a downloaded,
825
+ * expiring dataset — so this requires at least two labels and otherwise trusts
826
+ * the addresses, and the value stays overridable for the case it gets wrong.
827
+ */
828
+ function cookieDomain(urls) {
829
+ const hosts = /* @__PURE__ */ new Set();
830
+ for (const url of urls) try {
831
+ const { hostname } = new URL(url);
832
+ if (/^\d+(\.\d+){3}$/.test(hostname) || hostname.includes(":")) return;
833
+ hosts.add(hostname.toLowerCase());
834
+ } catch {
835
+ return;
836
+ }
837
+ if (hosts.size === 0) return;
838
+ if (hosts.size === 1) return;
839
+ const [first = [], ...rest] = [...hosts].map((host) => host.split(".").reverse());
840
+ const shared = [];
841
+ for (const [index, label] of first.entries()) {
842
+ if (!rest.every((labels) => labels[index] === label)) break;
843
+ shared.push(label);
844
+ }
845
+ if (shared.length < 2) return;
846
+ return `.${shared.reverse().join(".")}`;
847
+ }
848
+ /**
849
+ * The env key a construct's provided role actually becomes.
850
+ *
851
+ * Almost always `provideKey(id, role)` — and `secret` is the exception, because
852
+ * a secret's *name* is its key: `Auth` signs with `AUTH_SECRET`, which is also
853
+ * what better-auth's own tooling looks for, and qualifying it by role would
854
+ * produce `AUTH_SECRET_VALUE`.
855
+ *
856
+ * It lives here rather than in each target because two targets deriving the
857
+ * same key separately is exactly the drift the app/infra contract check exists
858
+ * to catch — and a check deriving the key differently from the thing it checks
859
+ * cannot catch anything.
860
+ */
861
+ function providedKeyFor(id, kind, role) {
862
+ return kind === "secret" ? environmentCase(id) : provideKey(id, role);
863
+ }
864
+
865
+ //#endregion
866
+ //#region src/derive.ts
867
+ /** Whether a declaration names a parent. */
868
+ function isDerived(declaration) {
869
+ return declaration.kind in DERIVES_FROM && "of" in declaration && typeof declaration.of === "string";
870
+ }
871
+ /**
872
+ * Check every derived construct against its parent.
873
+ *
874
+ * Two rules: the parent exists, and its kind may vend this one. Together they
875
+ * make cycles unreachable — a reader is terminal, so no chain of `of` can
876
+ * return to where it started, and no walk is needed to prove it.
877
+ */
878
+ function assertDerivations(manifest) {
879
+ for (const [id, declaration] of Object.entries(manifest)) {
880
+ if (!isDerived(declaration)) continue;
881
+ const parent = manifest[declaration.of];
882
+ if (!parent) throw new UnknownParent(id, declaration.of, Object.keys(manifest));
883
+ const allowed = DERIVES_FROM[declaration.kind];
884
+ if (!allowed.includes(parent.kind)) throw new IllegalDerivation(id, declaration.kind, parent.kind, allowed);
885
+ }
886
+ }
887
+ /**
888
+ * The order constructs must be provisioned in: every parent before its children.
889
+ *
890
+ * Resources are leaves and so come first in any order; only derived nodes
891
+ * constrain the sequence, and they form a shallow forest rather than a general
892
+ * graph. This walks each node's ancestors on demand instead of running a full
893
+ * topological sort, which is the same result at this depth and reads as what it
894
+ * is.
895
+ *
896
+ * Assumes {@link assertDerivations} has passed — a missing parent would
897
+ * otherwise be a silent omission here rather than an error.
898
+ */
899
+ function provisionOrder(manifest) {
900
+ const ordered = [];
901
+ const placed = /* @__PURE__ */ new Set();
902
+ const place = (id) => {
903
+ if (placed.has(id)) return;
904
+ const declaration = manifest[id];
905
+ if (!declaration) return;
906
+ placed.add(id);
907
+ if (isDerived(declaration)) place(declaration.of);
908
+ ordered.push(id);
909
+ };
910
+ for (const id of Object.keys(manifest)) place(id);
911
+ return ordered;
912
+ }
913
+ /**
914
+ * Every edge a declaration carries, wherever the kind happens to keep them.
915
+ *
916
+ * Dependencies live in two places by design: on a node when the whole construct
917
+ * is the consumer (a site), and on each nested handler when the construct is a
918
+ * surface (a `rest-api`, whose routes each depend on their own things and
919
+ * nothing more). Flattening that difference here is what lets every consumer of
920
+ * the graph — reverse lookups, filtering, reference checks — ask one question.
921
+ */
922
+ function dependenciesOf(declaration) {
923
+ const own = "dependencies" in declaration ? declaration.dependencies ?? [] : [];
924
+ const calls = "calls" in declaration ? declaration.calls ?? [] : [];
925
+ const nested = declaration.kind === "rest-api" ? declaration.endpoints.flatMap((endpoint) => endpoint.dependencies) : [];
926
+ return [
927
+ ...own,
928
+ ...calls,
929
+ ...nested
930
+ ];
931
+ }
932
+ /**
933
+ * The ids that depend on one construct — the graph read backwards.
934
+ *
935
+ * This is the whole mechanism behind CORS origins and trusted origins. Both are
936
+ * lists of *callers*, and a caller is exactly an inbound edge, so neither is
937
+ * ever written down: a surface that listed its own callers would have to be
938
+ * edited every time something new called it, which is the hand-maintained list
939
+ * this replaces.
940
+ *
941
+ * Sorted, because it feeds a comma-separated env value that would otherwise
942
+ * change whenever the manifest's key order did — and a value that churns is a
943
+ * container that redeploys for no reason.
944
+ */
945
+ function dependentsOf(manifest, id) {
946
+ const callers = [];
947
+ for (const [callerId, declaration] of Object.entries(manifest)) {
948
+ if (callerId === id) continue;
949
+ if (dependenciesOf(declaration).some((edge) => edge.target === id)) callers.push(callerId);
950
+ }
951
+ return callers.sort();
952
+ }
953
+ /**
954
+ * How each site variant names a value it ships to the browser.
955
+ *
956
+ * The prefix *is* the framework's contract — `VITE_`, `NEXT_PUBLIC_` and
957
+ * `EXPO_PUBLIC_` all mean "inline this into the bundle" — so it is the one thing
958
+ * a variant changes, and it changes nothing else.
959
+ */
960
+ const PUBLIC_PREFIX = {
961
+ static: "VITE_",
962
+ tanstack: "VITE_",
963
+ next: "NEXT_PUBLIC_"
964
+ };
965
+ /**
966
+ * The keys a site's bundle needs, mapped to the key each value comes from —
967
+ * `{ VITE_API_URL: 'API_URL' }`.
968
+ *
969
+ * A rename, not a second derivation: `API_URL` is resolved once, by whatever
970
+ * resolved it for the server, and the site reads the same value under the name
971
+ * its bundler will inline. That is what keeps a site and its API from coming to
972
+ * disagree about where the API is.
973
+ *
974
+ * Filtered by `PUBLIC` rather than by what the site asked for. A site may
975
+ * legitimately depend on anything — its server half, where it has one, reads env
976
+ * exactly as a function does — so this is not a restriction on edges. It decides
977
+ * one thing: which values may be prefixed into a bundle, which is what keeps
978
+ * `ORDERS_URL` and its password out of a JavaScript file served to the public.
979
+ *
980
+ * Shared by every target for the same reason `providedKeyFor` is: a site built
981
+ * locally and the same site built by a deploy must inline the same names.
982
+ */
983
+ function publicEnvFor(declaration, manifest) {
984
+ const prefix = PUBLIC_PREFIX[declaration.variant];
985
+ const keys = {};
986
+ for (const edge of declaration.dependencies) {
987
+ const target = manifest[edge.target];
988
+ if (!target) continue;
989
+ for (const role of PUBLIC[target.kind] ?? []) {
990
+ const key = provideKey(edge.target, role);
991
+ keys[`${prefix}${key}`] = key;
992
+ }
993
+ }
994
+ return keys;
995
+ }
996
+
997
+ //#endregion
1
998
  //#region src/index.ts
2
999
  /** Flatten a manifest field (array or partitioned) into a plain array. */
3
1000
  function flattenManifestField(field) {
@@ -6,5 +1003,5 @@ function flattenManifestField(field) {
6
1003
  }
7
1004
 
8
1005
  //#endregion
9
- export { flattenManifestField };
1006
+ export { DEFAULT_APP_CODE, DEFAULT_POSTGRES_VERSION, DERIVES_FROM, IllegalDerivation, InvalidConstructId, PUBLIC, PUBLIC_PREFIX, UnknownParent, assertDerivations, cacheTable, canonicalId, cloudName, cookieDomain, dependenciesOf, dependentsOf, environmentCase, flattenManifestField, isDerived, kebabCase, provideKey, providedKeyFor, provisionOrder, publicEnvFor, scopedName, serviceKey };
10
1007
  //# sourceMappingURL=index.mjs.map