@ankhorage/projects 0.9.4 → 0.9.5
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/README.md +1 -1
- package/dist/features/projects/composition/createExpoProjectMaterializer.js +2 -2
- package/dist/features/projects/composition/createManifestSource.d.ts +3 -0
- package/dist/features/projects/composition/createManifestSource.js +8 -0
- package/dist/features/worker-materialization/composition/createWorkerMaterializationFile.js +13 -5
- package/package.json +4 -4
- package/dist/features/projects/composition/formatTypeScriptLiteral.d.ts +0 -2
- package/dist/features/projects/composition/formatTypeScriptLiteral.js +0 -46
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
# Ankhorage Projects
|
|
5
5
|
|
|
6
|
-
         
|
|
7
7
|
|
|
8
8
|
Provides standalone project identity, persistence, and repository-oriented project actions.
|
|
9
9
|
|
|
@@ -5,9 +5,9 @@ import { resolveExpoRuntimePlan } from '@ankhorage/expo-runtime/planning';
|
|
|
5
5
|
import { materializeTemplateRevision } from '@ankhorage/templates';
|
|
6
6
|
import { applyWorkerMaterialization } from '../../worker-materialization/composition/composeWorkerMaterialization.js';
|
|
7
7
|
import { composeGeneratedRuntimeMaterialization } from './composeGeneratedRuntimeMaterialization.js';
|
|
8
|
+
import { createManifestSource } from './createManifestSource.js';
|
|
8
9
|
import { createNavigatorMaterializationFiles, } from './createNavigatorMaterializationFiles.js';
|
|
9
10
|
import { createSocialManagerServerFiles } from './createSocialManagerServerFiles.js';
|
|
10
|
-
import { formatTypeScriptLiteral } from './formatTypeScriptLiteral.js';
|
|
11
11
|
/*** Create the public, caller-targeted Expo materializer for stored immutable project revisions. */
|
|
12
12
|
export function createExpoProjectMaterializer(input) {
|
|
13
13
|
return {
|
|
@@ -59,7 +59,7 @@ function createGeneratedFiles(manifest, projectId, navigatorInput, targetEnviron
|
|
|
59
59
|
})),
|
|
60
60
|
{
|
|
61
61
|
relativePath: 'src/ankh.manifest.ts',
|
|
62
|
-
source:
|
|
62
|
+
source: createManifestSource(manifest),
|
|
63
63
|
},
|
|
64
64
|
...app.files,
|
|
65
65
|
...createNavigatorMaterializationFiles(manifest, navigatorInput, packageSource.navigatorBindings),
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*** Serialize the immutable manifest as one JSON literal so generated source stays bounded and parser-safe. */
|
|
2
|
+
export function createManifestSource(manifest) {
|
|
3
|
+
const serializedManifest = JSON.stringify(manifest)
|
|
4
|
+
.replaceAll('\u2028', '\\u2028')
|
|
5
|
+
.replaceAll('\u2029', '\\u2029');
|
|
6
|
+
const sourceLiteral = `'${serializedManifest.replaceAll('\\', '\\\\').replaceAll("'", "\\'")}'`;
|
|
7
|
+
return `import type { AppManifest } from '@ankhorage/contracts';\n\nexport default JSON.parse(\n ${sourceLiteral},\n) as AppManifest;\n`;
|
|
8
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { quoteJavaScriptString } from '@ankhorage/utility/string';
|
|
1
2
|
import { WORKER_ENTRY_SOURCE_PATH, WORKER_WEB_DIRECTORY } from '../constants/worker.js';
|
|
2
3
|
/** Maximum requests per budget key admitted by the generated Worker. */
|
|
3
4
|
const WORKER_REQUEST_LIMIT = 10;
|
|
@@ -10,7 +11,6 @@ export function createWorkerMaterializationFile(input) {
|
|
|
10
11
|
}
|
|
11
12
|
/*** Render the Worker module that delegates trusted API operations to the published host boundary. */
|
|
12
13
|
function createWorkerEntrySource(input) {
|
|
13
|
-
const operations = Object.fromEntries(input.operations.map((operation) => [operation, operation]));
|
|
14
14
|
return `import { createNeonServerCallerAuthenticationPort } from '@ankhorage/auth-neon';
|
|
15
15
|
import { createNeonPostgresRequestBudget } from '@ankhorage/db-postgres';
|
|
16
16
|
import { createTrustedZefixWorkerEntry } from '@ankhorage/projects/worker';
|
|
@@ -19,10 +19,12 @@ import { createTrustedZefixWorkerEntry } from '@ankhorage/projects/worker';
|
|
|
19
19
|
// DATABASE_URL, ZEFIX_CREDENTIALS and ANKH_AUTH_ALLOWED_SUBJECTS are Worker secret bindings;
|
|
20
20
|
// NEON_AUTH_BASE_URL and NEON_AUTH_JWKS_URL are bound from the provisioned Neon Auth outputs.
|
|
21
21
|
export default createTrustedZefixWorkerEntry({
|
|
22
|
-
appId: ${
|
|
23
|
-
projectId: ${
|
|
24
|
-
environment: ${
|
|
25
|
-
operations:
|
|
22
|
+
appId: ${quoteJavaScriptString(input.appId)},
|
|
23
|
+
projectId: ${quoteJavaScriptString(input.projectId)},
|
|
24
|
+
environment: ${quoteJavaScriptString(input.environment)},
|
|
25
|
+
operations: {
|
|
26
|
+
${renderWorkerOperations(input.operations)}
|
|
27
|
+
},
|
|
26
28
|
createCallerAuthentication: (env) =>
|
|
27
29
|
createNeonServerCallerAuthenticationPort({
|
|
28
30
|
authUrl: env.NEON_AUTH_BASE_URL ?? '',
|
|
@@ -36,6 +38,12 @@ export default createTrustedZefixWorkerEntry({
|
|
|
36
38
|
});
|
|
37
39
|
`;
|
|
38
40
|
}
|
|
41
|
+
/*** Render the declared Worker operation map in the generated application's canonical source format. */
|
|
42
|
+
function renderWorkerOperations(operations) {
|
|
43
|
+
return operations
|
|
44
|
+
.map((operation) => ` ${quoteJavaScriptString(operation)}: ${quoteJavaScriptString(operation)},`)
|
|
45
|
+
.join('\n');
|
|
46
|
+
}
|
|
39
47
|
/*** Render the Worker module for an application without server APIs: every Worker-routed request is unknown. */
|
|
40
48
|
function createStaticWorkerEntrySource() {
|
|
41
49
|
return `// Server-only: bundled to dist/worker/index.js, never into the public ${WORKER_WEB_DIRECTORY} assets.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/projects",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.5",
|
|
4
4
|
"description": "Standalone project identity and repository actions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ankhorage",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"version-packages": "ankhorage-changeset version"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@ankhorage/devtools": "^2.
|
|
61
|
+
"@ankhorage/devtools": "^2.13.4",
|
|
62
62
|
"@ankhorage/paradox": "^0.6.2",
|
|
63
63
|
"@types/bun": "^1.4.5",
|
|
64
64
|
"@types/node": "^26.6.11",
|
|
@@ -70,14 +70,14 @@
|
|
|
70
70
|
"@ankhorage/connection": "^0.3.0",
|
|
71
71
|
"@ankhorage/contracts": "^28.0.0",
|
|
72
72
|
"@ankhorage/data-sources": "^2.4.0",
|
|
73
|
-
"@ankhorage/expo-runtime": "^7.10.
|
|
73
|
+
"@ankhorage/expo-runtime": "^7.10.4",
|
|
74
74
|
"@ankhorage/flow": "^0.12.0",
|
|
75
75
|
"@ankhorage/navigator": "^3.9.0",
|
|
76
76
|
"@ankhorage/permissions": "^0.2.64",
|
|
77
77
|
"@ankhorage/runtime": "^5.8.1",
|
|
78
78
|
"@ankhorage/secrets": "^0.3.2",
|
|
79
79
|
"@ankhorage/social": "^0.7.0",
|
|
80
|
-
"@ankhorage/templates": "^12.
|
|
80
|
+
"@ankhorage/templates": "^12.9.4",
|
|
81
81
|
"@ankhorage/utility": "^1.11.0"
|
|
82
82
|
},
|
|
83
83
|
"ankh": {
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/*** Render serializable data as deterministic, policy-compliant TypeScript source. */
|
|
2
|
-
export function formatTypeScriptLiteral(value, depth = 0) {
|
|
3
|
-
if (value === null)
|
|
4
|
-
return 'null';
|
|
5
|
-
if (typeof value === 'string')
|
|
6
|
-
return formatTypeScriptString(value);
|
|
7
|
-
if (typeof value === 'number' || typeof value === 'boolean')
|
|
8
|
-
return String(value);
|
|
9
|
-
if (Array.isArray(value))
|
|
10
|
-
return formatTypeScriptArray(value, depth);
|
|
11
|
-
if (isRecord(value))
|
|
12
|
-
return formatTypeScriptRecord(value, depth);
|
|
13
|
-
throw new Error('Generated manifest values must be JSON-serializable.');
|
|
14
|
-
}
|
|
15
|
-
/*** Render a serializable array with canonical indentation and trailing commas. */
|
|
16
|
-
function formatTypeScriptArray(values, depth) {
|
|
17
|
-
if (values.length === 0)
|
|
18
|
-
return '[]';
|
|
19
|
-
const indentation = ' '.repeat(depth + 1);
|
|
20
|
-
const closingIndentation = ' '.repeat(depth);
|
|
21
|
-
return `[\n${values.map((value) => `${indentation}${formatTypeScriptLiteral(value, depth + 1)},`).join('\n')}\n${closingIndentation}]`;
|
|
22
|
-
}
|
|
23
|
-
/*** Render an object with sorted keys so equal manifests produce equal source. */
|
|
24
|
-
function formatTypeScriptRecord(value, depth) {
|
|
25
|
-
const entries = Object.entries(value)
|
|
26
|
-
.filter(([, entryValue]) => entryValue !== undefined)
|
|
27
|
-
.sort(([left], [right]) => left.localeCompare(right));
|
|
28
|
-
if (entries.length === 0)
|
|
29
|
-
return '{}';
|
|
30
|
-
const indentation = ' '.repeat(depth + 1);
|
|
31
|
-
const closingIndentation = ' '.repeat(depth);
|
|
32
|
-
return `{\n${entries.map(([key, entryValue]) => `${indentation}${formatTypeScriptPropertyKey(key)}: ${formatTypeScriptLiteral(entryValue, depth + 1)},`).join('\n')}\n${closingIndentation}}`;
|
|
33
|
-
}
|
|
34
|
-
/*** Use an identifier key where TypeScript permits it and quote required property names. */
|
|
35
|
-
function formatTypeScriptPropertyKey(key) {
|
|
36
|
-
return /^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(key) ? key : formatTypeScriptString(key);
|
|
37
|
-
}
|
|
38
|
-
/*** Emit a single-quoted TypeScript string without a formatter runtime dependency. */
|
|
39
|
-
function formatTypeScriptString(value) {
|
|
40
|
-
const jsonContent = JSON.stringify(value).slice(1, -1);
|
|
41
|
-
return `'${jsonContent.replaceAll("'", "\\'").replaceAll('\u2028', '\\u2028').replaceAll('\u2029', '\\u2029')}'`;
|
|
42
|
-
}
|
|
43
|
-
/*** Narrow a JSON-compatible object for recursive rendering. */
|
|
44
|
-
function isRecord(value) {
|
|
45
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
46
|
-
}
|