@geekmidas/manifest 10.0.0-alpha.4 → 10.0.0-alpha.40
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.cjs +206 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +239 -112
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +239 -112
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +194 -67
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var
|
|
9
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
-
};
|
|
9
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
11
10
|
var __copyProps = (to, from, except, desc) => {
|
|
12
11
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
13
12
|
key = keys[i];
|
|
@@ -18,13 +17,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
17
|
}
|
|
19
18
|
return to;
|
|
20
19
|
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
22
21
|
value: mod,
|
|
23
22
|
enumerable: true
|
|
24
23
|
}) : target, mod));
|
|
25
|
-
|
|
26
24
|
//#endregion
|
|
27
|
-
|
|
28
25
|
//#region src/declaration.ts
|
|
29
26
|
/**
|
|
30
27
|
* The version used when a database names none.
|
|
@@ -37,32 +34,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
37
34
|
*/
|
|
38
35
|
const DEFAULT_POSTGRES_VERSION = 18;
|
|
39
36
|
/**
|
|
40
|
-
* How the process serving a declaration is built and run.
|
|
41
|
-
*
|
|
42
|
-
* The half of an application that a graph genuinely cannot derive. *What*
|
|
43
|
-
* exists — a surface, a site, the edges between them — is declared and read
|
|
44
|
-
* back from the manifest. *Where its source lives and which globs find its
|
|
45
|
-
* code* is not derivable from anything: it is a fact about a directory.
|
|
46
|
-
*
|
|
47
|
-
* It lives on the declaration rather than in a config `apps` block because the
|
|
48
|
-
* two were the same list written twice, and the copy in config was the one that
|
|
49
|
-
* could disagree. A site declared `path: 'apps/web'` and an app entry declared
|
|
50
|
-
* `path: 'apps/web'`, and nothing checked them against each other; a surface
|
|
51
|
-
* that config had no entry for simply never deployed.
|
|
52
|
-
*
|
|
53
|
-
* Only the declaration that *is* an app carries one. Two surfaces in one
|
|
54
|
-
* process means one of them has the spec and the other collapses onto it —
|
|
55
|
-
* which is the same rule that decides deploy units, now stated once.
|
|
56
|
-
*/
|
|
57
|
-
/**
|
|
58
|
-
* Where an app's code lives when nobody says otherwise.
|
|
59
|
-
*
|
|
60
|
-
* One glob, every kind — the same rule the `constructs` glob follows. A handler
|
|
61
|
-
* in one of these directories is found; anywhere else needs a `code` glob, and
|
|
62
|
-
* saying so is the whole reason the field still exists.
|
|
63
|
-
*/
|
|
64
|
-
const DEFAULT_APP_CODE = "./{endpoints,functions,crons,queues,topics,subscribers}/**/*.ts";
|
|
65
|
-
/**
|
|
66
37
|
* What each kind may derive from.
|
|
67
38
|
*
|
|
68
39
|
* Small enough to state exhaustively, and stating it makes cycles impossible
|
|
@@ -97,12 +68,13 @@ const PUBLIC = {
|
|
|
97
68
|
queue: [],
|
|
98
69
|
topic: [],
|
|
99
70
|
oidc: ["issuer", "audience"],
|
|
71
|
+
"external-api": [],
|
|
100
72
|
function: [],
|
|
101
73
|
cron: [],
|
|
74
|
+
"mobile-app": [],
|
|
102
75
|
site: ["url"],
|
|
103
76
|
worker: []
|
|
104
77
|
};
|
|
105
|
-
|
|
106
78
|
//#endregion
|
|
107
79
|
//#region src/errors.ts
|
|
108
80
|
/**
|
|
@@ -161,20 +133,9 @@ var IllegalDerivation = class extends Error {
|
|
|
161
133
|
this.allowed = allowed;
|
|
162
134
|
}
|
|
163
135
|
};
|
|
164
|
-
|
|
165
136
|
//#endregion
|
|
166
|
-
//#region
|
|
167
|
-
var
|
|
168
|
-
/**
|
|
169
|
-
* lodash (Custom Build) <https://lodash.com/>
|
|
170
|
-
* Build: `lodash modularize exports="npm" -o ./`
|
|
171
|
-
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
|
172
|
-
* Released under MIT license <https://lodash.com/license>
|
|
173
|
-
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
174
|
-
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
175
|
-
*/
|
|
176
|
-
/** Used as references for various `Number` constants. */
|
|
177
|
-
var INFINITY = Infinity;
|
|
137
|
+
//#region src/naming.ts
|
|
138
|
+
var import_lodash_snakecase = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
178
139
|
/** `Object#toString` result references. */
|
|
179
140
|
var symbolTag = "[object Symbol]";
|
|
180
141
|
/** Used to match words composed of alphanumeric characters. */
|
|
@@ -182,15 +143,46 @@ var require_lodash = __commonJS({ "../../node_modules/.pnpm/lodash.snakecase@4.1
|
|
|
182
143
|
/** Used to match Latin Unicode letters (excluding mathematical operators). */
|
|
183
144
|
var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
|
|
184
145
|
/** Used to compose unicode character classes. */
|
|
185
|
-
var rsAstralRange = "\\ud800-\\udfff"
|
|
146
|
+
var rsAstralRange = "\\ud800-\\udfff";
|
|
147
|
+
var rsComboMarksRange = "\\u0300-\\u036f\\ufe20-\\ufe23";
|
|
148
|
+
var rsComboSymbolsRange = "\\u20d0-\\u20f0";
|
|
149
|
+
var rsDingbatRange = "\\u2700-\\u27bf";
|
|
150
|
+
var rsLowerRange = "a-z\\xdf-\\xf6\\xf8-\\xff";
|
|
151
|
+
var rsMathOpRange = "\\xac\\xb1\\xd7\\xf7";
|
|
152
|
+
var rsNonCharRange = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf";
|
|
153
|
+
var rsPunctuationRange = "\\u2000-\\u206f";
|
|
154
|
+
var 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";
|
|
155
|
+
var rsUpperRange = "A-Z\\xc0-\\xd6\\xd8-\\xde";
|
|
156
|
+
var rsVarRange = "\\ufe0e\\ufe0f";
|
|
157
|
+
var rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
|
|
186
158
|
/** Used to compose unicode capture groups. */
|
|
187
|
-
var rsApos = "['’]"
|
|
159
|
+
var rsApos = "['’]";
|
|
160
|
+
var rsBreak = "[" + rsBreakRange + "]";
|
|
161
|
+
var rsCombo = "[" + rsComboMarksRange + rsComboSymbolsRange + "]";
|
|
162
|
+
var rsDigits = "\\d+";
|
|
163
|
+
var rsDingbat = "[" + rsDingbatRange + "]";
|
|
164
|
+
var rsLower = "[" + rsLowerRange + "]";
|
|
165
|
+
var rsMisc = "[^" + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + "]";
|
|
166
|
+
var rsModifier = "(?:" + rsCombo + "|\\ud83c[\\udffb-\\udfff])";
|
|
167
|
+
var rsNonAstral = "[^" + rsAstralRange + "]";
|
|
168
|
+
var rsRegional = "(?:\\ud83c[\\udde6-\\uddff]){2}";
|
|
169
|
+
var rsSurrPair = "[\\ud800-\\udbff][\\udc00-\\udfff]";
|
|
170
|
+
var rsUpper = "[" + rsUpperRange + "]";
|
|
171
|
+
var rsZWJ = "\\u200d";
|
|
188
172
|
/** Used to compose unicode regexes. */
|
|
189
|
-
var rsLowerMisc = "(?:" + rsLower + "|" + rsMisc + ")"
|
|
173
|
+
var rsLowerMisc = "(?:" + rsLower + "|" + rsMisc + ")";
|
|
174
|
+
var rsUpperMisc = "(?:" + rsUpper + "|" + rsMisc + ")";
|
|
175
|
+
var rsOptLowerContr = "(?:" + rsApos + "(?:d|ll|m|re|s|t|ve))?";
|
|
176
|
+
var rsOptUpperContr = "(?:" + rsApos + "(?:D|LL|M|RE|S|T|VE))?";
|
|
177
|
+
var reOptMod = rsModifier + "?";
|
|
178
|
+
var rsOptVar = "[" + rsVarRange + "]?";
|
|
179
|
+
var rsOptJoin = "(?:" + rsZWJ + "(?:" + [
|
|
190
180
|
rsNonAstral,
|
|
191
181
|
rsRegional,
|
|
192
182
|
rsSurrPair
|
|
193
|
-
].join("|") + ")" + rsOptVar + reOptMod + ")*"
|
|
183
|
+
].join("|") + ")" + rsOptVar + reOptMod + ")*";
|
|
184
|
+
var rsSeq = rsOptVar + reOptMod + rsOptJoin;
|
|
185
|
+
var rsEmoji = "(?:" + [
|
|
194
186
|
rsDingbat,
|
|
195
187
|
rsRegional,
|
|
196
188
|
rsSurrPair
|
|
@@ -489,18 +481,17 @@ var require_lodash = __commonJS({ "../../node_modules/.pnpm/lodash.snakecase@4.1
|
|
|
489
481
|
function unicodeWords(string) {
|
|
490
482
|
return string.match(reUnicodeWord) || [];
|
|
491
483
|
}
|
|
492
|
-
/** Used for built-in method references. */
|
|
493
|
-
var objectProto = Object.prototype;
|
|
494
484
|
/**
|
|
495
485
|
* Used to resolve the
|
|
496
486
|
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
497
487
|
* of values.
|
|
498
488
|
*/
|
|
499
|
-
var objectToString =
|
|
489
|
+
var objectToString = Object.prototype.toString;
|
|
500
490
|
/** Built-in value references. */
|
|
501
491
|
var Symbol = root.Symbol;
|
|
502
492
|
/** Used to convert symbols to primitives and strings. */
|
|
503
|
-
var symbolProto = Symbol ? Symbol.prototype : void 0
|
|
493
|
+
var symbolProto = Symbol ? Symbol.prototype : void 0;
|
|
494
|
+
var symbolToString = symbolProto ? symbolProto.toString : void 0;
|
|
504
495
|
/**
|
|
505
496
|
* The base implementation of `_.toString` which doesn't convert nullish
|
|
506
497
|
* values to empty strings.
|
|
@@ -513,7 +504,7 @@ var require_lodash = __commonJS({ "../../node_modules/.pnpm/lodash.snakecase@4.1
|
|
|
513
504
|
if (typeof value == "string") return value;
|
|
514
505
|
if (isSymbol(value)) return symbolToString ? symbolToString.call(value) : "";
|
|
515
506
|
var result = value + "";
|
|
516
|
-
return result == "0" && 1 / value == -
|
|
507
|
+
return result == "0" && 1 / value == -Infinity ? "-0" : result;
|
|
517
508
|
}
|
|
518
509
|
/**
|
|
519
510
|
* Creates a function like `_.camelCase`.
|
|
@@ -670,11 +661,7 @@ var require_lodash = __commonJS({ "../../node_modules/.pnpm/lodash.snakecase@4.1
|
|
|
670
661
|
return string.match(pattern) || [];
|
|
671
662
|
}
|
|
672
663
|
module.exports = snakeCase;
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
//#endregion
|
|
676
|
-
//#region src/naming.ts
|
|
677
|
-
var import_lodash = __toESM(require_lodash(), 1);
|
|
664
|
+
})))(), 1);
|
|
678
665
|
/**
|
|
679
666
|
* `UPPER_SNAKE_CASE`, with numbers kept against the word they follow.
|
|
680
667
|
*
|
|
@@ -686,7 +673,7 @@ var import_lodash = __toESM(require_lodash(), 1);
|
|
|
686
673
|
* @example environmentCase('api2') // 'API2' (digit joins its word)
|
|
687
674
|
*/
|
|
688
675
|
function environmentCase(name) {
|
|
689
|
-
return (0,
|
|
676
|
+
return (0, import_lodash_snakecase.default)(name).toUpperCase().replace(/_\d+/g, (r) => r.replace("_", ""));
|
|
690
677
|
}
|
|
691
678
|
/**
|
|
692
679
|
* The env key a construct provides for one of its roles.
|
|
@@ -711,7 +698,7 @@ function provideKey(id, role) {
|
|
|
711
698
|
* @example canonicalId('user-uploads') // 'UserUploads'
|
|
712
699
|
*/
|
|
713
700
|
function canonicalId(input) {
|
|
714
|
-
const id = (0,
|
|
701
|
+
const id = (0, import_lodash_snakecase.default)(input).split("_").filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
715
702
|
if (!VALID_ID.test(id)) throw new InvalidConstructId(input, id);
|
|
716
703
|
return id;
|
|
717
704
|
}
|
|
@@ -863,7 +850,6 @@ function cookieDomain(urls) {
|
|
|
863
850
|
function providedKeyFor(id, kind, role) {
|
|
864
851
|
return kind === "secret" ? environmentCase(id) : provideKey(id, role);
|
|
865
852
|
}
|
|
866
|
-
|
|
867
853
|
//#endregion
|
|
868
854
|
//#region src/derive.ts
|
|
869
855
|
/** Whether a declaration names a parent. */
|
|
@@ -962,7 +948,8 @@ function dependentsOf(manifest, id) {
|
|
|
962
948
|
const PUBLIC_PREFIX = {
|
|
963
949
|
static: "VITE_",
|
|
964
950
|
tanstack: "VITE_",
|
|
965
|
-
next: "NEXT_PUBLIC_"
|
|
951
|
+
next: "NEXT_PUBLIC_",
|
|
952
|
+
expo: "EXPO_PUBLIC_"
|
|
966
953
|
};
|
|
967
954
|
/**
|
|
968
955
|
* The keys a site's bundle needs, mapped to the key each value comes from —
|
|
@@ -995,7 +982,147 @@ function publicEnvFor(declaration, manifest) {
|
|
|
995
982
|
}
|
|
996
983
|
return keys;
|
|
997
984
|
}
|
|
998
|
-
|
|
985
|
+
//#endregion
|
|
986
|
+
//#region src/external.ts
|
|
987
|
+
/** The key in a by-stage `url` that answers for every stage not listed. */
|
|
988
|
+
const DEFAULT_STAGE_URL = "default";
|
|
989
|
+
/**
|
|
990
|
+
* Where an external API answers on a deployed stage.
|
|
991
|
+
*
|
|
992
|
+
* One URL answers every stage; a record answers by stage name, falling back
|
|
993
|
+
* to `default`. Read at build and deploy, so a stage nobody gave a URL fails
|
|
994
|
+
* there — with the stage named — rather than at the first request.
|
|
995
|
+
*
|
|
996
|
+
* @throws {NoUrlForStage} when a record names neither the stage nor a default.
|
|
997
|
+
*/
|
|
998
|
+
function externalApiUrl(declaration, stage) {
|
|
999
|
+
const { url } = declaration;
|
|
1000
|
+
if (typeof url === "string") return url;
|
|
1001
|
+
const resolved = url[stage] ?? url["default"];
|
|
1002
|
+
if (!resolved) throw new NoUrlForStage(declaration.id, stage, Object.keys(url));
|
|
1003
|
+
return resolved;
|
|
1004
|
+
}
|
|
1005
|
+
/** An external API's `url` record has nothing for the stage being deployed. */
|
|
1006
|
+
var NoUrlForStage = class extends Error {
|
|
1007
|
+
id;
|
|
1008
|
+
stage;
|
|
1009
|
+
stages;
|
|
1010
|
+
constructor(id, stage, stages) {
|
|
1011
|
+
super(`'${id}' has no URL for the stage '${stage}': its url names ${stages.length ? stages.map((s) => `'${s}'`).join(", ") : "no stages"}. Add '${stage}', or a '${DEFAULT_STAGE_URL}' for every stage not listed.`);
|
|
1012
|
+
this.id = id;
|
|
1013
|
+
this.stage = stage;
|
|
1014
|
+
this.stages = stages;
|
|
1015
|
+
this.name = "NoUrlForStage";
|
|
1016
|
+
}
|
|
1017
|
+
};
|
|
1018
|
+
//#endregion
|
|
1019
|
+
//#region src/migrations.ts
|
|
1020
|
+
/** Where every construct's folder lives, from the project root. */
|
|
1021
|
+
const MIGRATIONS_ROOT = "db";
|
|
1022
|
+
/** The two folders a construct's folder holds, and nothing else. */
|
|
1023
|
+
const DATABASE_FOLDERS = ["migrations", "seeds"];
|
|
1024
|
+
/**
|
|
1025
|
+
* The constructs that take migrations, parents before the tenants inside them.
|
|
1026
|
+
*
|
|
1027
|
+
* A database and each schema tenant: every one has an owner role and a schema
|
|
1028
|
+
* of its own, and so a history of its own. A reader has neither — it reads its
|
|
1029
|
+
* parent's schema — and a cache's table is created by provisioning, not by a
|
|
1030
|
+
* migration anyone writes.
|
|
1031
|
+
*/
|
|
1032
|
+
function migrationTargets(manifest) {
|
|
1033
|
+
return provisionOrder(manifest).flatMap((id) => {
|
|
1034
|
+
const declaration = manifest[id];
|
|
1035
|
+
if (!declaration) return [];
|
|
1036
|
+
if (declaration.kind === "database") return [target(id)];
|
|
1037
|
+
if (declaration.kind === "database-schema") return [{
|
|
1038
|
+
...target(id),
|
|
1039
|
+
of: declaration.of
|
|
1040
|
+
}];
|
|
1041
|
+
return [];
|
|
1042
|
+
});
|
|
1043
|
+
}
|
|
1044
|
+
/**
|
|
1045
|
+
* A construct's folder, relative to the project root.
|
|
1046
|
+
*
|
|
1047
|
+
* Named by the construct — `AuthDatabase` is `db/auth-database` — in the case
|
|
1048
|
+
* every other name outside TypeScript takes. Lowercase, because a folder that
|
|
1049
|
+
* differs from another only in case is two folders on Linux and one on a Mac;
|
|
1050
|
+
* and `canonicalId` reads it back to the construct exactly, which is how a
|
|
1051
|
+
* folder naming nothing is caught rather than skipped.
|
|
1052
|
+
*/
|
|
1053
|
+
function databaseFolder(id) {
|
|
1054
|
+
return `db/${kebabCase(id)}`;
|
|
1055
|
+
}
|
|
1056
|
+
/** Where a construct's migrations live: `db/auth-database/migrations`. */
|
|
1057
|
+
function migrationFolder(id) {
|
|
1058
|
+
return `${databaseFolder(id)}/migrations`;
|
|
1059
|
+
}
|
|
1060
|
+
/**
|
|
1061
|
+
* Where a construct's seeds live: `db/auth-database/seeds`.
|
|
1062
|
+
*
|
|
1063
|
+
* Reference data the app needs to run — a permission catalogue, roles, lookup
|
|
1064
|
+
* tables. Seeds are upserts run on every pass, after the migrations, so a
|
|
1065
|
+
* changed seed is applied by running it again. Sample data is factories'.
|
|
1066
|
+
*/
|
|
1067
|
+
function seedFolder(id) {
|
|
1068
|
+
return `${databaseFolder(id)}/seeds`;
|
|
1069
|
+
}
|
|
1070
|
+
function target(id) {
|
|
1071
|
+
return {
|
|
1072
|
+
id,
|
|
1073
|
+
folder: databaseFolder(id),
|
|
1074
|
+
migrations: migrationFolder(id),
|
|
1075
|
+
seeds: seedFolder(id)
|
|
1076
|
+
};
|
|
1077
|
+
}
|
|
1078
|
+
//#endregion
|
|
1079
|
+
//#region src/mobile.ts
|
|
1080
|
+
/**
|
|
1081
|
+
* How a mobile app is reached: its URL scheme, and the origins a surface trusts
|
|
1082
|
+
* for it.
|
|
1083
|
+
*
|
|
1084
|
+
* Stated once, here, because three targets ask — the local one (`gkm dev`,
|
|
1085
|
+
* `gkm test`), Dokploy and AWS — and a scheme one of them derived differently
|
|
1086
|
+
* would be an app whose sign-in callback the auth server refuses on exactly one
|
|
1087
|
+
* of them.
|
|
1088
|
+
*/
|
|
1089
|
+
/**
|
|
1090
|
+
* An app's scheme: the one given, or the project's name made a valid scheme.
|
|
1091
|
+
*
|
|
1092
|
+
* One for every stage. A development build and the store build register the
|
|
1093
|
+
* same scheme, so the auth server of whichever stage a build talks to trusts
|
|
1094
|
+
* it, and nothing about the app differs between stages but its URLs.
|
|
1095
|
+
*
|
|
1096
|
+
* A scheme is a letter followed by letters, digits, `+`, `-` or `.` — so
|
|
1097
|
+
* `Corner Shop` becomes `corner-shop`, and a name that starts with a digit gets a
|
|
1098
|
+
* leading `app`.
|
|
1099
|
+
*/
|
|
1100
|
+
function schemeBase(project, given) {
|
|
1101
|
+
const raw = (given ?? project).toLowerCase().replace(/[^a-z0-9+.-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
1102
|
+
if (!raw) return "app";
|
|
1103
|
+
return /^[a-z]/.test(raw) ? raw : `app${raw}`;
|
|
1104
|
+
}
|
|
1105
|
+
/**
|
|
1106
|
+
* The origins a surface trusts for a mobile caller.
|
|
1107
|
+
*
|
|
1108
|
+
* Better Auth's Expo plugin sends the app's scheme as its origin
|
|
1109
|
+
* (`shop://`), and a link can carry a path after it (`shop://*`).
|
|
1110
|
+
* In development, Expo Go sends `exp://<host>:<port>` instead — so a local
|
|
1111
|
+
* stage adds the hosts a device actually reaches Metro on, and Metro's port
|
|
1112
|
+
* when the target placed it: a whole subnet is not trusted because one phone
|
|
1113
|
+
* is on it.
|
|
1114
|
+
*/
|
|
1115
|
+
function mobileOrigins(scheme, metro) {
|
|
1116
|
+
return [
|
|
1117
|
+
`${scheme}://`,
|
|
1118
|
+
`${scheme}://*`,
|
|
1119
|
+
...(metro?.hosts ?? []).flatMap((host) => [`exp://${host}:${metro?.port ?? "*"}`, `exp://${host}:${metro?.port ?? "*"}/**`])
|
|
1120
|
+
];
|
|
1121
|
+
}
|
|
1122
|
+
/** Whether an origin is a web one — what a cookie domain is derived from. */
|
|
1123
|
+
function isWebOrigin(origin) {
|
|
1124
|
+
return origin.startsWith("http://") || origin.startsWith("https://");
|
|
1125
|
+
}
|
|
999
1126
|
//#endregion
|
|
1000
1127
|
//#region src/index.ts
|
|
1001
1128
|
/** Flatten a manifest field (array or partitioned) into a plain array. */
|
|
@@ -1003,13 +1130,15 @@ function flattenManifestField(field) {
|
|
|
1003
1130
|
if (!field) return [];
|
|
1004
1131
|
return Array.isArray(field) ? [...field] : Object.values(field).flat();
|
|
1005
1132
|
}
|
|
1006
|
-
|
|
1007
1133
|
//#endregion
|
|
1008
|
-
exports.
|
|
1134
|
+
exports.DATABASE_FOLDERS = DATABASE_FOLDERS;
|
|
1009
1135
|
exports.DEFAULT_POSTGRES_VERSION = DEFAULT_POSTGRES_VERSION;
|
|
1136
|
+
exports.DEFAULT_STAGE_URL = DEFAULT_STAGE_URL;
|
|
1010
1137
|
exports.DERIVES_FROM = DERIVES_FROM;
|
|
1011
1138
|
exports.IllegalDerivation = IllegalDerivation;
|
|
1012
1139
|
exports.InvalidConstructId = InvalidConstructId;
|
|
1140
|
+
exports.MIGRATIONS_ROOT = MIGRATIONS_ROOT;
|
|
1141
|
+
exports.NoUrlForStage = NoUrlForStage;
|
|
1013
1142
|
exports.PUBLIC = PUBLIC;
|
|
1014
1143
|
exports.PUBLIC_PREFIX = PUBLIC_PREFIX;
|
|
1015
1144
|
exports.UnknownParent = UnknownParent;
|
|
@@ -1018,16 +1147,25 @@ exports.cacheTable = cacheTable;
|
|
|
1018
1147
|
exports.canonicalId = canonicalId;
|
|
1019
1148
|
exports.cloudName = cloudName;
|
|
1020
1149
|
exports.cookieDomain = cookieDomain;
|
|
1150
|
+
exports.databaseFolder = databaseFolder;
|
|
1021
1151
|
exports.dependenciesOf = dependenciesOf;
|
|
1022
1152
|
exports.dependentsOf = dependentsOf;
|
|
1023
1153
|
exports.environmentCase = environmentCase;
|
|
1154
|
+
exports.externalApiUrl = externalApiUrl;
|
|
1024
1155
|
exports.flattenManifestField = flattenManifestField;
|
|
1025
1156
|
exports.isDerived = isDerived;
|
|
1157
|
+
exports.isWebOrigin = isWebOrigin;
|
|
1026
1158
|
exports.kebabCase = kebabCase;
|
|
1159
|
+
exports.migrationFolder = migrationFolder;
|
|
1160
|
+
exports.migrationTargets = migrationTargets;
|
|
1161
|
+
exports.mobileOrigins = mobileOrigins;
|
|
1027
1162
|
exports.provideKey = provideKey;
|
|
1028
1163
|
exports.providedKeyFor = providedKeyFor;
|
|
1029
1164
|
exports.provisionOrder = provisionOrder;
|
|
1030
1165
|
exports.publicEnvFor = publicEnvFor;
|
|
1166
|
+
exports.schemeBase = schemeBase;
|
|
1031
1167
|
exports.scopedName = scopedName;
|
|
1168
|
+
exports.seedFolder = seedFolder;
|
|
1032
1169
|
exports.serviceKey = serviceKey;
|
|
1170
|
+
|
|
1033
1171
|
//# sourceMappingURL=index.cjs.map
|