@geekmidas/manifest 10.0.0-alpha.5 → 10.0.0-alpha.51
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 +232 -75
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +298 -133
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +298 -133
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +218 -73
- 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
|
|
@@ -86,23 +57,25 @@ const DERIVES_FROM = {
|
|
|
86
57
|
const PUBLIC = {
|
|
87
58
|
objects: [],
|
|
88
59
|
"file-server": ["url"],
|
|
89
|
-
email: [],
|
|
60
|
+
email: ["inboxUrl"],
|
|
90
61
|
database: [],
|
|
91
62
|
"database-reader": [],
|
|
92
63
|
"database-schema": [],
|
|
93
64
|
cache: [],
|
|
94
65
|
secret: [],
|
|
95
66
|
credential: [],
|
|
67
|
+
encryption: [],
|
|
96
68
|
"rest-api": ["url"],
|
|
97
69
|
queue: [],
|
|
98
70
|
topic: [],
|
|
99
71
|
oidc: ["issuer", "audience"],
|
|
72
|
+
"external-api": [],
|
|
100
73
|
function: [],
|
|
101
74
|
cron: [],
|
|
75
|
+
"mobile-app": [],
|
|
102
76
|
site: ["url"],
|
|
103
77
|
worker: []
|
|
104
78
|
};
|
|
105
|
-
|
|
106
79
|
//#endregion
|
|
107
80
|
//#region src/errors.ts
|
|
108
81
|
/**
|
|
@@ -161,20 +134,9 @@ var IllegalDerivation = class extends Error {
|
|
|
161
134
|
this.allowed = allowed;
|
|
162
135
|
}
|
|
163
136
|
};
|
|
164
|
-
|
|
165
137
|
//#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;
|
|
138
|
+
//#region src/naming.ts
|
|
139
|
+
var import_lodash_snakecase = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
178
140
|
/** `Object#toString` result references. */
|
|
179
141
|
var symbolTag = "[object Symbol]";
|
|
180
142
|
/** Used to match words composed of alphanumeric characters. */
|
|
@@ -182,15 +144,46 @@ var require_lodash = __commonJS({ "../../node_modules/.pnpm/lodash.snakecase@4.1
|
|
|
182
144
|
/** Used to match Latin Unicode letters (excluding mathematical operators). */
|
|
183
145
|
var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
|
|
184
146
|
/** Used to compose unicode character classes. */
|
|
185
|
-
var rsAstralRange = "\\ud800-\\udfff"
|
|
147
|
+
var rsAstralRange = "\\ud800-\\udfff";
|
|
148
|
+
var rsComboMarksRange = "\\u0300-\\u036f\\ufe20-\\ufe23";
|
|
149
|
+
var rsComboSymbolsRange = "\\u20d0-\\u20f0";
|
|
150
|
+
var rsDingbatRange = "\\u2700-\\u27bf";
|
|
151
|
+
var rsLowerRange = "a-z\\xdf-\\xf6\\xf8-\\xff";
|
|
152
|
+
var rsMathOpRange = "\\xac\\xb1\\xd7\\xf7";
|
|
153
|
+
var rsNonCharRange = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf";
|
|
154
|
+
var rsPunctuationRange = "\\u2000-\\u206f";
|
|
155
|
+
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";
|
|
156
|
+
var rsUpperRange = "A-Z\\xc0-\\xd6\\xd8-\\xde";
|
|
157
|
+
var rsVarRange = "\\ufe0e\\ufe0f";
|
|
158
|
+
var rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
|
|
186
159
|
/** Used to compose unicode capture groups. */
|
|
187
|
-
var rsApos = "['’]"
|
|
160
|
+
var rsApos = "['’]";
|
|
161
|
+
var rsBreak = "[" + rsBreakRange + "]";
|
|
162
|
+
var rsCombo = "[" + rsComboMarksRange + rsComboSymbolsRange + "]";
|
|
163
|
+
var rsDigits = "\\d+";
|
|
164
|
+
var rsDingbat = "[" + rsDingbatRange + "]";
|
|
165
|
+
var rsLower = "[" + rsLowerRange + "]";
|
|
166
|
+
var rsMisc = "[^" + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + "]";
|
|
167
|
+
var rsModifier = "(?:" + rsCombo + "|\\ud83c[\\udffb-\\udfff])";
|
|
168
|
+
var rsNonAstral = "[^" + rsAstralRange + "]";
|
|
169
|
+
var rsRegional = "(?:\\ud83c[\\udde6-\\uddff]){2}";
|
|
170
|
+
var rsSurrPair = "[\\ud800-\\udbff][\\udc00-\\udfff]";
|
|
171
|
+
var rsUpper = "[" + rsUpperRange + "]";
|
|
172
|
+
var rsZWJ = "\\u200d";
|
|
188
173
|
/** Used to compose unicode regexes. */
|
|
189
|
-
var rsLowerMisc = "(?:" + rsLower + "|" + rsMisc + ")"
|
|
174
|
+
var rsLowerMisc = "(?:" + rsLower + "|" + rsMisc + ")";
|
|
175
|
+
var rsUpperMisc = "(?:" + rsUpper + "|" + rsMisc + ")";
|
|
176
|
+
var rsOptLowerContr = "(?:" + rsApos + "(?:d|ll|m|re|s|t|ve))?";
|
|
177
|
+
var rsOptUpperContr = "(?:" + rsApos + "(?:D|LL|M|RE|S|T|VE))?";
|
|
178
|
+
var reOptMod = rsModifier + "?";
|
|
179
|
+
var rsOptVar = "[" + rsVarRange + "]?";
|
|
180
|
+
var rsOptJoin = "(?:" + rsZWJ + "(?:" + [
|
|
190
181
|
rsNonAstral,
|
|
191
182
|
rsRegional,
|
|
192
183
|
rsSurrPair
|
|
193
|
-
].join("|") + ")" + rsOptVar + reOptMod + ")*"
|
|
184
|
+
].join("|") + ")" + rsOptVar + reOptMod + ")*";
|
|
185
|
+
var rsSeq = rsOptVar + reOptMod + rsOptJoin;
|
|
186
|
+
var rsEmoji = "(?:" + [
|
|
194
187
|
rsDingbat,
|
|
195
188
|
rsRegional,
|
|
196
189
|
rsSurrPair
|
|
@@ -489,18 +482,17 @@ var require_lodash = __commonJS({ "../../node_modules/.pnpm/lodash.snakecase@4.1
|
|
|
489
482
|
function unicodeWords(string) {
|
|
490
483
|
return string.match(reUnicodeWord) || [];
|
|
491
484
|
}
|
|
492
|
-
/** Used for built-in method references. */
|
|
493
|
-
var objectProto = Object.prototype;
|
|
494
485
|
/**
|
|
495
486
|
* Used to resolve the
|
|
496
487
|
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
497
488
|
* of values.
|
|
498
489
|
*/
|
|
499
|
-
var objectToString =
|
|
490
|
+
var objectToString = Object.prototype.toString;
|
|
500
491
|
/** Built-in value references. */
|
|
501
492
|
var Symbol = root.Symbol;
|
|
502
493
|
/** Used to convert symbols to primitives and strings. */
|
|
503
|
-
var symbolProto = Symbol ? Symbol.prototype : void 0
|
|
494
|
+
var symbolProto = Symbol ? Symbol.prototype : void 0;
|
|
495
|
+
var symbolToString = symbolProto ? symbolProto.toString : void 0;
|
|
504
496
|
/**
|
|
505
497
|
* The base implementation of `_.toString` which doesn't convert nullish
|
|
506
498
|
* values to empty strings.
|
|
@@ -513,7 +505,7 @@ var require_lodash = __commonJS({ "../../node_modules/.pnpm/lodash.snakecase@4.1
|
|
|
513
505
|
if (typeof value == "string") return value;
|
|
514
506
|
if (isSymbol(value)) return symbolToString ? symbolToString.call(value) : "";
|
|
515
507
|
var result = value + "";
|
|
516
|
-
return result == "0" && 1 / value == -
|
|
508
|
+
return result == "0" && 1 / value == -Infinity ? "-0" : result;
|
|
517
509
|
}
|
|
518
510
|
/**
|
|
519
511
|
* Creates a function like `_.camelCase`.
|
|
@@ -670,11 +662,7 @@ var require_lodash = __commonJS({ "../../node_modules/.pnpm/lodash.snakecase@4.1
|
|
|
670
662
|
return string.match(pattern) || [];
|
|
671
663
|
}
|
|
672
664
|
module.exports = snakeCase;
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
//#endregion
|
|
676
|
-
//#region src/naming.ts
|
|
677
|
-
var import_lodash = __toESM(require_lodash(), 1);
|
|
665
|
+
})))(), 1);
|
|
678
666
|
/**
|
|
679
667
|
* `UPPER_SNAKE_CASE`, with numbers kept against the word they follow.
|
|
680
668
|
*
|
|
@@ -686,7 +674,7 @@ var import_lodash = __toESM(require_lodash(), 1);
|
|
|
686
674
|
* @example environmentCase('api2') // 'API2' (digit joins its word)
|
|
687
675
|
*/
|
|
688
676
|
function environmentCase(name) {
|
|
689
|
-
return (0,
|
|
677
|
+
return (0, import_lodash_snakecase.default)(name).toUpperCase().replace(/_\d+/g, (r) => r.replace("_", ""));
|
|
690
678
|
}
|
|
691
679
|
/**
|
|
692
680
|
* The env key a construct provides for one of its roles.
|
|
@@ -711,7 +699,7 @@ function provideKey(id, role) {
|
|
|
711
699
|
* @example canonicalId('user-uploads') // 'UserUploads'
|
|
712
700
|
*/
|
|
713
701
|
function canonicalId(input) {
|
|
714
|
-
const id = (0,
|
|
702
|
+
const id = (0, import_lodash_snakecase.default)(input).split("_").filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
715
703
|
if (!VALID_ID.test(id)) throw new InvalidConstructId(input, id);
|
|
716
704
|
return id;
|
|
717
705
|
}
|
|
@@ -863,7 +851,6 @@ function cookieDomain(urls) {
|
|
|
863
851
|
function providedKeyFor(id, kind, role) {
|
|
864
852
|
return kind === "secret" ? environmentCase(id) : provideKey(id, role);
|
|
865
853
|
}
|
|
866
|
-
|
|
867
854
|
//#endregion
|
|
868
855
|
//#region src/derive.ts
|
|
869
856
|
/** Whether a declaration names a parent. */
|
|
@@ -962,7 +949,8 @@ function dependentsOf(manifest, id) {
|
|
|
962
949
|
const PUBLIC_PREFIX = {
|
|
963
950
|
static: "VITE_",
|
|
964
951
|
tanstack: "VITE_",
|
|
965
|
-
next: "NEXT_PUBLIC_"
|
|
952
|
+
next: "NEXT_PUBLIC_",
|
|
953
|
+
expo: "EXPO_PUBLIC_"
|
|
966
954
|
};
|
|
967
955
|
/**
|
|
968
956
|
* The keys a site's bundle needs, mapped to the key each value comes from —
|
|
@@ -995,21 +983,181 @@ function publicEnvFor(declaration, manifest) {
|
|
|
995
983
|
}
|
|
996
984
|
return keys;
|
|
997
985
|
}
|
|
998
|
-
|
|
999
986
|
//#endregion
|
|
1000
|
-
//#region src/
|
|
1001
|
-
/**
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
987
|
+
//#region src/encryption.ts
|
|
988
|
+
/**
|
|
989
|
+
* The `kms://` URL an `Encryption` construct reads on AWS.
|
|
990
|
+
*
|
|
991
|
+
* Here because two packages meet on it: `@geekmidas/cloud` composes it from
|
|
992
|
+
* the keys it provisioned, and `@geekmidas/constructs` parses it to reach
|
|
993
|
+
* them. One function, so the two cannot disagree about a parameter's name.
|
|
994
|
+
*/
|
|
995
|
+
const KMS_SCHEME = "kms:";
|
|
996
|
+
/**
|
|
997
|
+
* `kms://<region>?key=<key arn>&index=<hmac key arn>[&endpoint=<url>]`
|
|
998
|
+
*
|
|
999
|
+
* `endpoint` reaches an emulator instead of AWS — floci, locally and in tests —
|
|
1000
|
+
* the same parameter an `sns://` connection string carries for the same reason.
|
|
1001
|
+
*/
|
|
1002
|
+
function kmsUrl(input) {
|
|
1003
|
+
const query = new URLSearchParams({
|
|
1004
|
+
key: input.key,
|
|
1005
|
+
index: input.index,
|
|
1006
|
+
...input.endpoint ? { endpoint: input.endpoint } : {}
|
|
1007
|
+
});
|
|
1008
|
+
return `${KMS_SCHEME}//${input.region}?${query}`;
|
|
1009
|
+
}
|
|
1010
|
+
//#endregion
|
|
1011
|
+
//#region src/external.ts
|
|
1012
|
+
/** The key in a by-stage `url` that answers for every stage not listed. */
|
|
1013
|
+
const DEFAULT_STAGE_URL = "default";
|
|
1014
|
+
/**
|
|
1015
|
+
* Where an external API answers on a deployed stage.
|
|
1016
|
+
*
|
|
1017
|
+
* One URL answers every stage; a record answers by stage name, falling back
|
|
1018
|
+
* to `default`. Read at build and deploy, so a stage nobody gave a URL fails
|
|
1019
|
+
* there — with the stage named — rather than at the first request.
|
|
1020
|
+
*
|
|
1021
|
+
* @throws {NoUrlForStage} when a record names neither the stage nor a default.
|
|
1022
|
+
*/
|
|
1023
|
+
function externalApiUrl(declaration, stage) {
|
|
1024
|
+
const { url } = declaration;
|
|
1025
|
+
if (typeof url === "string") return url;
|
|
1026
|
+
const resolved = url[stage] ?? url["default"];
|
|
1027
|
+
if (!resolved) throw new NoUrlForStage(declaration.id, stage, Object.keys(url));
|
|
1028
|
+
return resolved;
|
|
1005
1029
|
}
|
|
1006
|
-
|
|
1030
|
+
/** An external API's `url` record has nothing for the stage being deployed. */
|
|
1031
|
+
var NoUrlForStage = class extends Error {
|
|
1032
|
+
id;
|
|
1033
|
+
stage;
|
|
1034
|
+
stages;
|
|
1035
|
+
constructor(id, stage, stages) {
|
|
1036
|
+
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.`);
|
|
1037
|
+
this.id = id;
|
|
1038
|
+
this.stage = stage;
|
|
1039
|
+
this.stages = stages;
|
|
1040
|
+
this.name = "NoUrlForStage";
|
|
1041
|
+
}
|
|
1042
|
+
};
|
|
1007
1043
|
//#endregion
|
|
1008
|
-
|
|
1044
|
+
//#region src/migrations.ts
|
|
1045
|
+
/** Where every construct's folder lives, from the project root. */
|
|
1046
|
+
const MIGRATIONS_ROOT = "db";
|
|
1047
|
+
/** The two folders a construct's folder holds, and nothing else. */
|
|
1048
|
+
const DATABASE_FOLDERS = ["migrations", "seeds"];
|
|
1049
|
+
/**
|
|
1050
|
+
* The constructs that take migrations, parents before the tenants inside them.
|
|
1051
|
+
*
|
|
1052
|
+
* A database and each schema tenant: every one has an owner role and a schema
|
|
1053
|
+
* of its own, and so a history of its own. A reader has neither — it reads its
|
|
1054
|
+
* parent's schema — and a cache's table is created by provisioning, not by a
|
|
1055
|
+
* migration anyone writes.
|
|
1056
|
+
*/
|
|
1057
|
+
function migrationTargets(manifest) {
|
|
1058
|
+
return provisionOrder(manifest).flatMap((id) => {
|
|
1059
|
+
const declaration = manifest[id];
|
|
1060
|
+
if (!declaration) return [];
|
|
1061
|
+
if (declaration.kind === "database") return [target(id)];
|
|
1062
|
+
if (declaration.kind === "database-schema") return [{
|
|
1063
|
+
...target(id),
|
|
1064
|
+
of: declaration.of
|
|
1065
|
+
}];
|
|
1066
|
+
return [];
|
|
1067
|
+
});
|
|
1068
|
+
}
|
|
1069
|
+
/**
|
|
1070
|
+
* A construct's folder, relative to the project root.
|
|
1071
|
+
*
|
|
1072
|
+
* Named by the construct — `AuthDatabase` is `db/auth-database` — in the case
|
|
1073
|
+
* every other name outside TypeScript takes. Lowercase, because a folder that
|
|
1074
|
+
* differs from another only in case is two folders on Linux and one on a Mac;
|
|
1075
|
+
* and `canonicalId` reads it back to the construct exactly, which is how a
|
|
1076
|
+
* folder naming nothing is caught rather than skipped.
|
|
1077
|
+
*/
|
|
1078
|
+
function databaseFolder(id) {
|
|
1079
|
+
return `db/${kebabCase(id)}`;
|
|
1080
|
+
}
|
|
1081
|
+
/** Where a construct's migrations live: `db/auth-database/migrations`. */
|
|
1082
|
+
function migrationFolder(id) {
|
|
1083
|
+
return `${databaseFolder(id)}/migrations`;
|
|
1084
|
+
}
|
|
1085
|
+
/**
|
|
1086
|
+
* Where a construct's seeds live: `db/auth-database/seeds`.
|
|
1087
|
+
*
|
|
1088
|
+
* Reference data the app needs to run — a permission catalogue, roles, lookup
|
|
1089
|
+
* tables. Seeds are upserts run on every pass, after the migrations, so a
|
|
1090
|
+
* changed seed is applied by running it again. Sample data is factories'.
|
|
1091
|
+
*/
|
|
1092
|
+
function seedFolder(id) {
|
|
1093
|
+
return `${databaseFolder(id)}/seeds`;
|
|
1094
|
+
}
|
|
1095
|
+
function target(id) {
|
|
1096
|
+
return {
|
|
1097
|
+
id,
|
|
1098
|
+
folder: databaseFolder(id),
|
|
1099
|
+
migrations: migrationFolder(id),
|
|
1100
|
+
seeds: seedFolder(id)
|
|
1101
|
+
};
|
|
1102
|
+
}
|
|
1103
|
+
//#endregion
|
|
1104
|
+
//#region src/mobile.ts
|
|
1105
|
+
/**
|
|
1106
|
+
* How a mobile app is reached: its URL scheme, and the origins a surface trusts
|
|
1107
|
+
* for it.
|
|
1108
|
+
*
|
|
1109
|
+
* Stated once, here, because three targets ask — the local one (`gkm dev`,
|
|
1110
|
+
* `gkm test`), Dokploy and AWS — and a scheme one of them derived differently
|
|
1111
|
+
* would be an app whose sign-in callback the auth server refuses on exactly one
|
|
1112
|
+
* of them.
|
|
1113
|
+
*/
|
|
1114
|
+
/**
|
|
1115
|
+
* An app's scheme: the one given, or the project's name made a valid scheme.
|
|
1116
|
+
*
|
|
1117
|
+
* One for every stage. A development build and the store build register the
|
|
1118
|
+
* same scheme, so the auth server of whichever stage a build talks to trusts
|
|
1119
|
+
* it, and nothing about the app differs between stages but its URLs.
|
|
1120
|
+
*
|
|
1121
|
+
* A scheme is a letter followed by letters, digits, `+`, `-` or `.` — so
|
|
1122
|
+
* `Corner Shop` becomes `corner-shop`, and a name that starts with a digit gets a
|
|
1123
|
+
* leading `app`.
|
|
1124
|
+
*/
|
|
1125
|
+
function schemeBase(project, given) {
|
|
1126
|
+
const raw = (given ?? project).toLowerCase().replace(/[^a-z0-9+.-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
1127
|
+
if (!raw) return "app";
|
|
1128
|
+
return /^[a-z]/.test(raw) ? raw : `app${raw}`;
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* The origins a surface trusts for a mobile caller.
|
|
1132
|
+
*
|
|
1133
|
+
* Better Auth's Expo plugin sends the app's scheme as its origin
|
|
1134
|
+
* (`shop://`), and a link can carry a path after it (`shop://*`).
|
|
1135
|
+
* In development, Expo Go sends `exp://<host>:<port>` instead — so a local
|
|
1136
|
+
* stage adds the hosts a device actually reaches Metro on, and Metro's port
|
|
1137
|
+
* when the target placed it: a whole subnet is not trusted because one phone
|
|
1138
|
+
* is on it.
|
|
1139
|
+
*/
|
|
1140
|
+
function mobileOrigins(scheme, metro) {
|
|
1141
|
+
return [
|
|
1142
|
+
`${scheme}://`,
|
|
1143
|
+
`${scheme}://*`,
|
|
1144
|
+
...(metro?.hosts ?? []).flatMap((host) => [`exp://${host}:${metro?.port ?? "*"}`, `exp://${host}:${metro?.port ?? "*"}/**`])
|
|
1145
|
+
];
|
|
1146
|
+
}
|
|
1147
|
+
/** Whether an origin is a web one — what a cookie domain is derived from. */
|
|
1148
|
+
function isWebOrigin(origin) {
|
|
1149
|
+
return origin.startsWith("http://") || origin.startsWith("https://");
|
|
1150
|
+
}
|
|
1151
|
+
//#endregion
|
|
1152
|
+
exports.DATABASE_FOLDERS = DATABASE_FOLDERS;
|
|
1009
1153
|
exports.DEFAULT_POSTGRES_VERSION = DEFAULT_POSTGRES_VERSION;
|
|
1154
|
+
exports.DEFAULT_STAGE_URL = DEFAULT_STAGE_URL;
|
|
1010
1155
|
exports.DERIVES_FROM = DERIVES_FROM;
|
|
1011
1156
|
exports.IllegalDerivation = IllegalDerivation;
|
|
1012
1157
|
exports.InvalidConstructId = InvalidConstructId;
|
|
1158
|
+
exports.KMS_SCHEME = KMS_SCHEME;
|
|
1159
|
+
exports.MIGRATIONS_ROOT = MIGRATIONS_ROOT;
|
|
1160
|
+
exports.NoUrlForStage = NoUrlForStage;
|
|
1013
1161
|
exports.PUBLIC = PUBLIC;
|
|
1014
1162
|
exports.PUBLIC_PREFIX = PUBLIC_PREFIX;
|
|
1015
1163
|
exports.UnknownParent = UnknownParent;
|
|
@@ -1018,16 +1166,25 @@ exports.cacheTable = cacheTable;
|
|
|
1018
1166
|
exports.canonicalId = canonicalId;
|
|
1019
1167
|
exports.cloudName = cloudName;
|
|
1020
1168
|
exports.cookieDomain = cookieDomain;
|
|
1169
|
+
exports.databaseFolder = databaseFolder;
|
|
1021
1170
|
exports.dependenciesOf = dependenciesOf;
|
|
1022
1171
|
exports.dependentsOf = dependentsOf;
|
|
1023
1172
|
exports.environmentCase = environmentCase;
|
|
1024
|
-
exports.
|
|
1173
|
+
exports.externalApiUrl = externalApiUrl;
|
|
1025
1174
|
exports.isDerived = isDerived;
|
|
1175
|
+
exports.isWebOrigin = isWebOrigin;
|
|
1026
1176
|
exports.kebabCase = kebabCase;
|
|
1177
|
+
exports.kmsUrl = kmsUrl;
|
|
1178
|
+
exports.migrationFolder = migrationFolder;
|
|
1179
|
+
exports.migrationTargets = migrationTargets;
|
|
1180
|
+
exports.mobileOrigins = mobileOrigins;
|
|
1027
1181
|
exports.provideKey = provideKey;
|
|
1028
1182
|
exports.providedKeyFor = providedKeyFor;
|
|
1029
1183
|
exports.provisionOrder = provisionOrder;
|
|
1030
1184
|
exports.publicEnvFor = publicEnvFor;
|
|
1185
|
+
exports.schemeBase = schemeBase;
|
|
1031
1186
|
exports.scopedName = scopedName;
|
|
1187
|
+
exports.seedFolder = seedFolder;
|
|
1032
1188
|
exports.serviceKey = serviceKey;
|
|
1189
|
+
|
|
1033
1190
|
//# sourceMappingURL=index.cjs.map
|